@ac-kit/format-dash 0.0.0-stage → 0.1.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 (92) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/LICENSE +28 -0
  3. package/README.md +180 -2
  4. package/dist/_template.d.ts +34 -0
  5. package/dist/_template.d.ts.map +1 -0
  6. package/dist/_template.js +90 -0
  7. package/dist/_template.js.map +1 -0
  8. package/dist/_xlink.d.ts +9 -0
  9. package/dist/_xlink.d.ts.map +1 -0
  10. package/dist/_xlink.js +14 -0
  11. package/dist/_xlink.js.map +1 -0
  12. package/dist/dash-namespaces.d.ts +27 -0
  13. package/dist/dash-namespaces.d.ts.map +1 -0
  14. package/dist/dash-namespaces.js +30 -0
  15. package/dist/dash-namespaces.js.map +1 -0
  16. package/dist/errors.d.ts +127 -0
  17. package/dist/errors.d.ts.map +1 -0
  18. package/dist/errors.js +52 -0
  19. package/dist/errors.js.map +1 -0
  20. package/dist/index.d.ts +12 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +12 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/limits.d.ts +51 -0
  25. package/dist/limits.d.ts.map +1 -0
  26. package/dist/limits.js +39 -0
  27. package/dist/limits.js.map +1 -0
  28. package/dist/model/dash-common.d.ts +124 -0
  29. package/dist/model/dash-common.d.ts.map +1 -0
  30. package/dist/model/dash-common.js +2 -0
  31. package/dist/model/dash-common.js.map +1 -0
  32. package/dist/model/dash-mpd.d.ts +111 -0
  33. package/dist/model/dash-mpd.d.ts.map +1 -0
  34. package/dist/model/dash-mpd.js +2 -0
  35. package/dist/model/dash-mpd.js.map +1 -0
  36. package/dist/model/dash-segment-information.d.ts +90 -0
  37. package/dist/model/dash-segment-information.d.ts.map +1 -0
  38. package/dist/model/dash-segment-information.js +2 -0
  39. package/dist/model/dash-segment-information.js.map +1 -0
  40. package/dist/parse/_attribute-reader.d.ts +94 -0
  41. package/dist/parse/_attribute-reader.d.ts.map +1 -0
  42. package/dist/parse/_attribute-reader.js +382 -0
  43. package/dist/parse/_attribute-reader.js.map +1 -0
  44. package/dist/parse/_context.d.ts +35 -0
  45. package/dist/parse/_context.d.ts.map +1 -0
  46. package/dist/parse/_context.js +39 -0
  47. package/dist/parse/_context.js.map +1 -0
  48. package/dist/parse/_xs-temporal.d.ts +22 -0
  49. package/dist/parse/_xs-temporal.d.ts.map +1 -0
  50. package/dist/parse/_xs-temporal.js +98 -0
  51. package/dist/parse/_xs-temporal.js.map +1 -0
  52. package/dist/parse/parse-dash-mpd.d.ts +67 -0
  53. package/dist/parse/parse-dash-mpd.d.ts.map +1 -0
  54. package/dist/parse/parse-dash-mpd.js +928 -0
  55. package/dist/parse/parse-dash-mpd.js.map +1 -0
  56. package/dist/resolve/_base-url.d.ts +41 -0
  57. package/dist/resolve/_base-url.d.ts.map +1 -0
  58. package/dist/resolve/_base-url.js +69 -0
  59. package/dist/resolve/_base-url.js.map +1 -0
  60. package/dist/resolve/_essential-properties.d.ts +38 -0
  61. package/dist/resolve/_essential-properties.d.ts.map +1 -0
  62. package/dist/resolve/_essential-properties.js +106 -0
  63. package/dist/resolve/_essential-properties.js.map +1 -0
  64. package/dist/resolve/_inherit.d.ts +43 -0
  65. package/dist/resolve/_inherit.d.ts.map +1 -0
  66. package/dist/resolve/_inherit.js +105 -0
  67. package/dist/resolve/_inherit.js.map +1 -0
  68. package/dist/resolve/_segment-runs.d.ts +81 -0
  69. package/dist/resolve/_segment-runs.d.ts.map +1 -0
  70. package/dist/resolve/_segment-runs.js +126 -0
  71. package/dist/resolve/_segment-runs.js.map +1 -0
  72. package/dist/resolve/dash-resolve-diagnostic.d.ts +34 -0
  73. package/dist/resolve/dash-resolve-diagnostic.d.ts.map +1 -0
  74. package/dist/resolve/dash-resolve-diagnostic.js +2 -0
  75. package/dist/resolve/dash-resolve-diagnostic.js.map +1 -0
  76. package/dist/resolve/resolve-dash-representations.d.ts +130 -0
  77. package/dist/resolve/resolve-dash-representations.d.ts.map +1 -0
  78. package/dist/resolve/resolve-dash-representations.js +203 -0
  79. package/dist/resolve/resolve-dash-representations.js.map +1 -0
  80. package/dist/resolve/resolve-dash-segments.d.ts +169 -0
  81. package/dist/resolve/resolve-dash-segments.d.ts.map +1 -0
  82. package/dist/resolve/resolve-dash-segments.js +665 -0
  83. package/dist/resolve/resolve-dash-segments.js.map +1 -0
  84. package/dist/timing/_exact-period-timings.d.ts +28 -0
  85. package/dist/timing/_exact-period-timings.d.ts.map +1 -0
  86. package/dist/timing/_exact-period-timings.js +142 -0
  87. package/dist/timing/_exact-period-timings.js.map +1 -0
  88. package/dist/timing/dash-period-timings.d.ts +29 -0
  89. package/dist/timing/dash-period-timings.d.ts.map +1 -0
  90. package/dist/timing/dash-period-timings.js +23 -0
  91. package/dist/timing/dash-period-timings.js.map +1 -0
  92. package/package.json +63 -3
@@ -0,0 +1,94 @@
1
+ import { type XmlAttribute, type XmlElement } from "@ac-kit/format-xml";
2
+ import { type TemplateIdentifier } from "../_template.js";
3
+ import type { DashDiagnosticCode } from "../errors.js";
4
+ import type { DashByteRange, DashRatio, DashXlink } from "../model/dash-common.js";
5
+ import type { ParseContext } from "./_context.js";
6
+ /**
7
+ * Reads the typed attributes of one element, remembering which it read so the
8
+ * rest become `otherAttributes`, and which it refused so they become
9
+ * `invalidAttributes`. A value that does not read as its type is a violation;
10
+ * lenient mode answers `null` for it.
11
+ */
12
+ export declare class AttributeReader {
13
+ private readonly context_;
14
+ private readonly element_;
15
+ /** Offset of the element, or of its nearest ancestor with a span. */
16
+ readonly position: number | undefined;
17
+ private readonly read_;
18
+ private readonly invalid_;
19
+ constructor(context_: ParseContext, element_: XmlElement,
20
+ /** Offset of the element, or of its nearest ancestor with a span. */
21
+ position: number | undefined);
22
+ /** The raw value of an unprefixed attribute, `null` when absent. */
23
+ string(name: string): string | null;
24
+ /**
25
+ * The raw value of the attribute `name` in `namespace`. No namespace matches
26
+ * an unprefixed name only, as `@ac-kit/format-xml`'s `xmlAttributeValueNs`
27
+ * does, so a lenient parse never reads an unbound `p:id` as `id`.
28
+ */
29
+ namespaced(name: string, namespace: string | null): string | null;
30
+ /** {@link string}, a violation when absent. */
31
+ required(name: string): string | null;
32
+ /**
33
+ * Refuses the attribute `name` after a check of the caller's: a violation,
34
+ * and in lenient mode the attribute moves to `invalidAttributes`.
35
+ */
36
+ refuse(name: string, code: DashDiagnosticCode, message: string): void;
37
+ /** An `xs:unsignedInt`: at most 4 294 967 295. */
38
+ unsigned(name: string): number | null;
39
+ /** {@link unsigned}, a violation when absent. */
40
+ requiredUnsigned(name: string): number | null;
41
+ /** An `xs:unsignedLong` held as a `number`: past 2^53−1 is `unsafe-integer`. */
42
+ unsignedLongNumber(name: string): number | null;
43
+ /**
44
+ * An `xs:unsignedLong`, exactly. Only its significant digits — at most 20 —
45
+ * reach `BigInt`.
46
+ */
47
+ unsignedLong(name: string): bigint | null;
48
+ /**
49
+ * An `xs:integer`, exactly, within ±(2^64−1): past that no MPD value means
50
+ * anything, and refusing it bounds the `BigInt` parse.
51
+ */
52
+ integer(name: string): bigint | null;
53
+ /**
54
+ * An `xs:double`; `Infinity` for `INF`. `NaN`, `-INF` and a finite form past
55
+ * the range of a double are refused.
56
+ */
57
+ double(name: string): number | null;
58
+ /** An `xs:boolean`. */
59
+ boolean(name: string): boolean | null;
60
+ /** A ConditionalUintType: `xs:unsignedInt` or `xs:boolean`. */
61
+ conditionalUnsigned(name: string): boolean | number | null;
62
+ /** One of `values`. */
63
+ enumeration<T extends string>(name: string, values: readonly T[]): T | null;
64
+ /** An `xs:duration` with a fixed length. */
65
+ duration(name: string): Temporal.Duration | null;
66
+ /** An `xs:dateTime`, UTC when written with no zone. */
67
+ dateTime(name: string): Temporal.Instant | null;
68
+ /** A RatioType, `16:9`. */
69
+ ratio(name: string): DashRatio | null;
70
+ /** A FrameRateType, `25` or `30000/1001`; `29.97` is read as 2997/100. */
71
+ frameRate(name: string): DashRatio | null;
72
+ /** A byte range, `first-last` or `first-`. */
73
+ byteRange(name: string): DashByteRange | null;
74
+ /** A whitespace-separated list (StringVectorType). */
75
+ list(name: string): string[] | null;
76
+ /** A whitespace-separated list of unsigned integers (UIntVectorType). */
77
+ unsignedList(name: string): number[] | null;
78
+ /** A comma-separated list (ListOfProfilesType), items trimmed. */
79
+ commaList(name: string): string[] | null;
80
+ /**
81
+ * A segment template, checked; `forbidden` lists identifiers the attribute
82
+ * may not use (`@initialization` takes neither `$Number$` nor `$Time$`).
83
+ */
84
+ template(name: string, forbidden?: readonly TemplateIdentifier[]): string | null;
85
+ /** `xlink:href` and `xlink:actuate`, or `null` for a local element. */
86
+ xlink(namespace: string): DashXlink | null;
87
+ /** The attributes not read, in source order. */
88
+ rest(): XmlAttribute[];
89
+ /** The attributes refused, in the order they were read. */
90
+ invalid(): XmlAttribute[];
91
+ private find_;
92
+ private typed_;
93
+ }
94
+ //# sourceMappingURL=_attribute-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_attribute-reader.d.ts","sourceRoot":"","sources":["../../src/parse/_attribute-reader.ts"],"names":[],"mappings":"AACA,OAAO,EAGN,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EACX,aAAa,EACb,SAAS,EACT,SAAS,EACT,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA2BlD;;;;;GAKG;AACH,qBAAa,eAAe;IAK1B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS;IAPtC,OAAO,CAAC,QAAQ,CAAC,KAAK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, saturatingDecimalToNumber } from "@ac-kit/core";
2
+ import { isXmlAttributeInNamespace, trimXsdWhitespace, } from "@ac-kit/format-xml";
3
+ import { parseTemplate } from "../_template.js";
4
+ import { readXsDateTime, readXsDuration } from "./_xs-temporal.js";
5
+ const UNSIGNED_ = /^\+?\d+$/u;
6
+ const INTEGER_ = /^[+-]?\d+$/u;
7
+ const DOUBLE_ = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$|^\+?INF$/u;
8
+ const RATIO_ = /^(\d+):(\d+)$/u;
9
+ const FRAME_RATE_ = /^(\d+)(?:\/(\d+))?$/u;
10
+ const DECIMAL_FRAME_RATE_ = /^(\d+)\.(\d{1,9})$/u;
11
+ const BYTE_RANGE_ = /^(\d+)-(\d+)?$/u;
12
+ const LIST_SEPARATOR_ = /[ \t\r\n]+/u;
13
+ const NON_ZERO_DIGIT_ = /[1-9]/u;
14
+ const UNSIGNED_INT_MAX_ = "4294967295";
15
+ const UNSIGNED_LONG_MAX_ = "18446744073709551615";
16
+ const MAX_SAFE_ = String(Number.MAX_SAFE_INTEGER);
17
+ const REFUSED_ = Symbol("refused");
18
+ const INVALID_ = { [REFUSED_]: "invalid-attribute-value" };
19
+ const UNSAFE_ = { [REFUSED_]: "unsafe-integer" };
20
+ /**
21
+ * Reads the typed attributes of one element, remembering which it read so the
22
+ * rest become `otherAttributes`, and which it refused so they become
23
+ * `invalidAttributes`. A value that does not read as its type is a violation;
24
+ * lenient mode answers `null` for it.
25
+ */
26
+ export class AttributeReader {
27
+ context_;
28
+ element_;
29
+ position;
30
+ read_ = new Set();
31
+ invalid_ = [];
32
+ constructor(context_, element_,
33
+ /** Offset of the element, or of its nearest ancestor with a span. */
34
+ position) {
35
+ this.context_ = context_;
36
+ this.element_ = element_;
37
+ this.position = position;
38
+ }
39
+ /** The raw value of an unprefixed attribute, `null` when absent. */
40
+ string(name) {
41
+ return this.find_(name, null)?.value ?? null;
42
+ }
43
+ /**
44
+ * The raw value of the attribute `name` in `namespace`. No namespace matches
45
+ * an unprefixed name only, as `@ac-kit/format-xml`'s `xmlAttributeValueNs`
46
+ * does, so a lenient parse never reads an unbound `p:id` as `id`.
47
+ */
48
+ namespaced(name, namespace) {
49
+ return this.find_(name, namespace)?.value ?? null;
50
+ }
51
+ /** {@link string}, a violation when absent. */
52
+ required(name) {
53
+ const value = this.string(name);
54
+ if (value === null) {
55
+ this.context_.sink.violation("missing-attribute", `${this.element_.name.local} has no @${name}`, this.position);
56
+ }
57
+ return value;
58
+ }
59
+ /**
60
+ * Refuses the attribute `name` after a check of the caller's: a violation,
61
+ * and in lenient mode the attribute moves to `invalidAttributes`.
62
+ */
63
+ refuse(name, code, message) {
64
+ const attribute = this.find_(name, null);
65
+ this.context_.sink.violation(code, message, attribute?.span?.start ?? this.position);
66
+ if (attribute !== undefined) {
67
+ this.invalid_.push(attribute);
68
+ }
69
+ }
70
+ /** An `xs:unsignedInt`: at most 4 294 967 295. */
71
+ unsigned(name) {
72
+ return this.typed_(name, (text) => {
73
+ if (!UNSIGNED_.test(text)) {
74
+ return INVALID_;
75
+ }
76
+ const digits = unsignedDigits_(text);
77
+ return compareDecimalDigits(digits, UNSIGNED_INT_MAX_) > 0
78
+ ? INVALID_
79
+ : saturatingDecimalToNumber(digits);
80
+ });
81
+ }
82
+ /** {@link unsigned}, a violation when absent. */
83
+ requiredUnsigned(name) {
84
+ if (this.string(name) === null) {
85
+ this.required(name);
86
+ return null;
87
+ }
88
+ return this.unsigned(name);
89
+ }
90
+ /** An `xs:unsignedLong` held as a `number`: past 2^53−1 is `unsafe-integer`. */
91
+ unsignedLongNumber(name) {
92
+ return this.typed_(name, (text) => {
93
+ if (!UNSIGNED_.test(text)) {
94
+ return INVALID_;
95
+ }
96
+ const digits = unsignedDigits_(text);
97
+ if (compareDecimalDigits(digits, UNSIGNED_LONG_MAX_) > 0) {
98
+ return INVALID_;
99
+ }
100
+ return compareDecimalDigits(digits, MAX_SAFE_) > 0
101
+ ? UNSAFE_
102
+ : saturatingDecimalToNumber(digits);
103
+ });
104
+ }
105
+ /**
106
+ * An `xs:unsignedLong`, exactly. Only its significant digits — at most 20 —
107
+ * reach `BigInt`.
108
+ */
109
+ unsignedLong(name) {
110
+ return this.typed_(name, (text) => {
111
+ if (!UNSIGNED_.test(text)) {
112
+ return INVALID_;
113
+ }
114
+ const digits = unsignedDigits_(text);
115
+ return compareDecimalDigits(digits, UNSIGNED_LONG_MAX_) > 0
116
+ ? INVALID_
117
+ : BigInt(significant_(digits));
118
+ });
119
+ }
120
+ /**
121
+ * An `xs:integer`, exactly, within ±(2^64−1): past that no MPD value means
122
+ * anything, and refusing it bounds the `BigInt` parse.
123
+ */
124
+ integer(name) {
125
+ return this.typed_(name, (text) => {
126
+ if (!INTEGER_.test(text)) {
127
+ return INVALID_;
128
+ }
129
+ const negative = text.startsWith("-");
130
+ const digits = unsignedDigits_(text);
131
+ if (compareDecimalDigits(digits, UNSIGNED_LONG_MAX_) > 0) {
132
+ return INVALID_;
133
+ }
134
+ const value = BigInt(significant_(digits));
135
+ return negative ? -value : value;
136
+ });
137
+ }
138
+ /**
139
+ * An `xs:double`; `Infinity` for `INF`. `NaN`, `-INF` and a finite form past
140
+ * the range of a double are refused.
141
+ */
142
+ double(name) {
143
+ return this.typed_(name, (text) => {
144
+ if (!DOUBLE_.test(text)) {
145
+ return INVALID_;
146
+ }
147
+ if (text.endsWith("INF")) {
148
+ return Infinity;
149
+ }
150
+ const value = Number(text);
151
+ return Number.isFinite(value) ? value : INVALID_;
152
+ });
153
+ }
154
+ /** An `xs:boolean`. */
155
+ boolean(name) {
156
+ return this.typed_(name, (text) => {
157
+ switch (text) {
158
+ case "true":
159
+ case "1":
160
+ return true;
161
+ case "false":
162
+ case "0":
163
+ return false;
164
+ default:
165
+ return INVALID_;
166
+ }
167
+ });
168
+ }
169
+ /** A ConditionalUintType: `xs:unsignedInt` or `xs:boolean`. */
170
+ conditionalUnsigned(name) {
171
+ return this.typed_(name, (text) => {
172
+ if (text === "true" || text === "false") {
173
+ return text === "true";
174
+ }
175
+ if (!UNSIGNED_.test(text)) {
176
+ return INVALID_;
177
+ }
178
+ const digits = unsignedDigits_(text);
179
+ return compareDecimalDigits(digits, UNSIGNED_INT_MAX_) > 0
180
+ ? INVALID_
181
+ : saturatingDecimalToNumber(digits);
182
+ });
183
+ }
184
+ /** One of `values`. */
185
+ enumeration(name, values) {
186
+ const raw = this.string(name);
187
+ if (raw === null) {
188
+ return null;
189
+ }
190
+ const text = trimXsdWhitespace(raw);
191
+ if (values.includes(text)) {
192
+ return text;
193
+ }
194
+ this.refuse(name, "invalid-attribute-value", `@${name} "${raw}" is not one of ${values.join(", ")}`);
195
+ return null;
196
+ }
197
+ /** An `xs:duration` with a fixed length. */
198
+ duration(name) {
199
+ return this.typed_(name, (text) => {
200
+ const value = readXsDuration(text);
201
+ return typeof value === "string"
202
+ ? { [REFUSED_]: "invalid-duration", reason: value }
203
+ : value;
204
+ });
205
+ }
206
+ /** An `xs:dateTime`, UTC when written with no zone. */
207
+ dateTime(name) {
208
+ return this.typed_(name, (text) => {
209
+ const value = readXsDateTime(text);
210
+ return typeof value === "string"
211
+ ? { [REFUSED_]: "invalid-date-time", reason: value }
212
+ : value;
213
+ });
214
+ }
215
+ /** A RatioType, `16:9`. */
216
+ ratio(name) {
217
+ return this.typed_(name, (text) => {
218
+ const match = RATIO_.exec(text);
219
+ return match === null ? INVALID_ : ratio_(match[1], match[2]);
220
+ });
221
+ }
222
+ /** A FrameRateType, `25` or `30000/1001`; `29.97` is read as 2997/100. */
223
+ frameRate(name) {
224
+ return this.typed_(name, (text) => {
225
+ const match = FRAME_RATE_.exec(text);
226
+ if (match !== null) {
227
+ return ratio_(match[1], match[2] ?? "1");
228
+ }
229
+ const decimal = DECIMAL_FRAME_RATE_.exec(text);
230
+ if (decimal === null) {
231
+ return INVALID_;
232
+ }
233
+ return ratio_(decimal[1] + decimal[2], `1${"0".repeat(decimal[2].length)}`);
234
+ });
235
+ }
236
+ /** A byte range, `first-last` or `first-`. */
237
+ byteRange(name) {
238
+ return this.typed_(name, (text) => {
239
+ const match = BYTE_RANGE_.exec(text);
240
+ if (match === null) {
241
+ return INVALID_;
242
+ }
243
+ const first = Number(match[1]);
244
+ const last = match[2] === undefined ? null : Number(match[2]);
245
+ if (!Number.isSafeInteger(first) ||
246
+ (last !== null && !Number.isSafeInteger(last))) {
247
+ return UNSAFE_;
248
+ }
249
+ return last !== null && last < first ? INVALID_ : { first, last };
250
+ });
251
+ }
252
+ /** A whitespace-separated list (StringVectorType). */
253
+ list(name) {
254
+ const text = this.string(name);
255
+ if (text === null) {
256
+ return null;
257
+ }
258
+ const collapsed = trimXsdWhitespace(text);
259
+ return collapsed === "" ? [] : collapsed.split(LIST_SEPARATOR_);
260
+ }
261
+ /** A whitespace-separated list of unsigned integers (UIntVectorType). */
262
+ unsignedList(name) {
263
+ return this.typed_(name, (text) => {
264
+ const values = [];
265
+ for (const item of text.split(LIST_SEPARATOR_)) {
266
+ if (!UNSIGNED_.test(item) ||
267
+ compareDecimalDigits(unsignedDigits_(item), UNSIGNED_INT_MAX_) > 0) {
268
+ return INVALID_;
269
+ }
270
+ values.push(saturatingDecimalToNumber(unsignedDigits_(item)));
271
+ }
272
+ return values;
273
+ });
274
+ }
275
+ /** A comma-separated list (ListOfProfilesType), items trimmed. */
276
+ commaList(name) {
277
+ const text = this.string(name);
278
+ if (text === null) {
279
+ return null;
280
+ }
281
+ return text
282
+ .split(",")
283
+ .map(trimXsdWhitespace)
284
+ .filter((item) => item !== "");
285
+ }
286
+ /**
287
+ * A segment template, checked; `forbidden` lists identifiers the attribute
288
+ * may not use (`@initialization` takes neither `$Number$` nor `$Time$`).
289
+ */
290
+ template(name, forbidden = []) {
291
+ const text = this.string(name);
292
+ if (text === null) {
293
+ return null;
294
+ }
295
+ const parts = parseTemplate(text);
296
+ let problem = typeof parts === "string" ? parts : null;
297
+ if (typeof parts !== "string") {
298
+ const used = parts.find((part) => typeof part !== "string" && forbidden.includes(part.identifier));
299
+ if (used !== undefined && typeof used !== "string") {
300
+ problem = `@${name} must not use $${used.identifier}$`;
301
+ }
302
+ }
303
+ if (problem === null) {
304
+ return text;
305
+ }
306
+ this.refuse(name, "invalid-template", problem);
307
+ return null;
308
+ }
309
+ /** `xlink:href` and `xlink:actuate`, or `null` for a local element. */
310
+ xlink(namespace) {
311
+ const href = this.namespaced("href", namespace);
312
+ const actuate = this.namespaced("actuate", namespace);
313
+ if (href === null) {
314
+ return null;
315
+ }
316
+ if (actuate !== null && actuate !== "onLoad" && actuate !== "onRequest") {
317
+ const attribute = this.find_("actuate", namespace);
318
+ this.context_.sink.violation("invalid-attribute-value", `xlink:actuate "${actuate}" is neither onLoad nor onRequest`, attribute.span?.start ?? this.position);
319
+ this.invalid_.push(attribute);
320
+ }
321
+ return { href, actuate: actuate === "onLoad" ? "onLoad" : "onRequest" };
322
+ }
323
+ /** The attributes not read, in source order. */
324
+ rest() {
325
+ return this.element_.attributes.filter((attribute) => !this.read_.has(attribute));
326
+ }
327
+ /** The attributes refused, in the order they were read. */
328
+ invalid() {
329
+ return this.invalid_;
330
+ }
331
+ find_(name, namespace) {
332
+ for (const attribute of this.element_.attributes) {
333
+ if (attribute.name.local === name &&
334
+ isXmlAttributeInNamespace(this.context_.namespaces, attribute, namespace)) {
335
+ this.read_.add(attribute);
336
+ return attribute;
337
+ }
338
+ }
339
+ return undefined;
340
+ }
341
+ typed_(name, read) {
342
+ const raw = this.string(name);
343
+ if (raw === null) {
344
+ return null;
345
+ }
346
+ const value = read(trimXsdWhitespace(raw));
347
+ if (!isRefusal_(value)) {
348
+ return value;
349
+ }
350
+ const code = value[REFUSED_];
351
+ let message = `@${name} "${raw}" is not a valid value`;
352
+ if (value.reason !== undefined) {
353
+ message = `@${name}: ${value.reason}`;
354
+ }
355
+ else if (code === "unsafe-integer") {
356
+ message = `@${name} "${raw}" is past 2^53-1`;
357
+ }
358
+ this.refuse(name, code, message);
359
+ return null;
360
+ }
361
+ }
362
+ function ratio_(numerator, denominator) {
363
+ const top = Number(numerator);
364
+ const bottom = Number(denominator);
365
+ if (!Number.isSafeInteger(top) || !Number.isSafeInteger(bottom)) {
366
+ return UNSAFE_;
367
+ }
368
+ return bottom === 0 ? INVALID_ : { numerator: top, denominator: bottom };
369
+ }
370
+ function isRefusal_(value) {
371
+ return typeof value === "object" && value !== null && REFUSED_ in value;
372
+ }
373
+ /** The digits of an integer lexical form, without its sign. */
374
+ function unsignedDigits_(text) {
375
+ return text.startsWith("+") || text.startsWith("-") ? text.slice(1) : text;
376
+ }
377
+ /** `digits` without leading zeros, `"0"` for zero. */
378
+ function significant_(digits) {
379
+ const first = digits.search(NON_ZERO_DIGIT_);
380
+ return first === -1 ? "0" : digits.slice(first);
381
+ }
382
+ //# sourceMappingURL=_attribute-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_attribute-reader.js","sourceRoot":"","sources":["../../src/parse/_attribute-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EACN,yBAAyB,EACzB,iBAAiB,GAGjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAA2B,MAAM,iBAAiB,CAAC;AAQzE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnE,MAAM,SAAS,GAAG,WAAW,CAAC;AAC9B,MAAM,QAAQ,GAAG,aAAa,CAAC;AAC/B,MAAM,OAAO,GAAG,2DAA2D,CAAC;AAC5E,MAAM,MAAM,GAAG,gBAAgB,CAAC;AAChC,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAC3C,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AAClD,MAAM,WAAW,GAAG,iBAAiB,CAAC;AACtC,MAAM,eAAe,GAAG,aAAa,CAAC;AACtC,MAAM,eAAe,GAAG,QAAQ,CAAC;AACjC,MAAM,iBAAiB,GAAG,YAA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,EAAE,MAAM,EAAE,CAAC;AAC1E,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,QAAQ,IAAI,KAAK,CAAC;AACzE,CAAC;AAED,+DAA+D;AAC/D,SAAS,eAAe,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC;AAED,sDAAsD;AACtD,SAAS,YAAY,CAAC,MAAc;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAC7C,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1,35 @@
1
+ import type { WorkBudget } from "@ac-kit/core";
2
+ import type { XmlNamespaces } from "@ac-kit/format-xml";
3
+ import { type DashDiagnostic, type DashDiagnosticCode } from "../errors.js";
4
+ import type { ResolvedDashLimits } from "../limits.js";
5
+ /**
6
+ * Collects diagnostics for one parse: a violation throws in strict mode and is
7
+ * recorded in lenient mode, an advisory is recorded in both, and a fatal
8
+ * problem throws in both. Recording stops at `maxWarnings`; later diagnostics
9
+ * only set `truncated`.
10
+ */
11
+ export declare class DiagnosticSink {
12
+ readonly lenient: boolean;
13
+ private readonly maxWarnings_;
14
+ readonly warnings: DashDiagnostic[];
15
+ truncated: boolean;
16
+ constructor(lenient: boolean, maxWarnings_: number);
17
+ /** @throws {DashSyntaxError} In strict mode. */
18
+ violation(code: DashDiagnosticCode, message: string, position: number | undefined): void;
19
+ advisory(code: DashDiagnosticCode, message: string, position: number | undefined): void;
20
+ /** @throws {DashSyntaxError} Always. */
21
+ fatal(code: DashDiagnosticCode, message: string, position: number | undefined): never;
22
+ private record_;
23
+ }
24
+ /** What every reader of one parse shares. */
25
+ export type ParseContext = {
26
+ readonly sink: DiagnosticSink;
27
+ readonly namespaces: XmlNamespaces;
28
+ /** The namespace MPD elements are matched in: the root's. */
29
+ readonly mpdNamespace: string | null;
30
+ readonly limits: ResolvedDashLimits;
31
+ readonly budget: WorkBudget;
32
+ /** `<S>` elements read so far, against `maxTimelineEntries`. */
33
+ timelineEntries: number;
34
+ };
35
+ //# sourceMappingURL=_context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_context.d.ts","sourceRoot":"","sources":["../../src/parse/_context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,kBAAkB,EAEvB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD;;;;;GAKG;AACH,qBAAa,cAAc;IAKzB,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAL9B,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAM;IACzC,SAAS,UAAS;IAElB,YACU,OAAO,EAAE,OAAO,EACR,YAAY,EAAE,MAAM,EAClC;IAEJ,gDAAgD;IAChD,SAAS,CACR,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAKN;IAED,QAAQ,CACP,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAEN;IAED,wCAAwC;IACxC,KAAK,CACJ,IAAI,EAAE,kBAAkB,EACxB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC1B,KAAK,CAEP;IAED,OAAO,CAAC,OAAO;CAOf;AAED,6CAA6C;AAC7C,MAAM,MAAM,YAAY,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B,gEAAgE;IAChE,eAAe,EAAE,MAAM,CAAC;CACxB,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { DashSyntaxError, } from "../errors.js";
2
+ /**
3
+ * Collects diagnostics for one parse: a violation throws in strict mode and is
4
+ * recorded in lenient mode, an advisory is recorded in both, and a fatal
5
+ * problem throws in both. Recording stops at `maxWarnings`; later diagnostics
6
+ * only set `truncated`.
7
+ */
8
+ export class DiagnosticSink {
9
+ lenient;
10
+ maxWarnings_;
11
+ warnings = [];
12
+ truncated = false;
13
+ constructor(lenient, maxWarnings_) {
14
+ this.lenient = lenient;
15
+ this.maxWarnings_ = maxWarnings_;
16
+ }
17
+ /** @throws {DashSyntaxError} In strict mode. */
18
+ violation(code, message, position) {
19
+ if (!this.lenient) {
20
+ throw new DashSyntaxError(code, message, position);
21
+ }
22
+ this.record_({ code, severity: "violation", message, position });
23
+ }
24
+ advisory(code, message, position) {
25
+ this.record_({ code, severity: "advisory", message, position });
26
+ }
27
+ /** @throws {DashSyntaxError} Always. */
28
+ fatal(code, message, position) {
29
+ throw new DashSyntaxError(code, message, position);
30
+ }
31
+ record_(diagnostic) {
32
+ if (this.warnings.length >= this.maxWarnings_) {
33
+ this.truncated = true;
34
+ return;
35
+ }
36
+ this.warnings.push(diagnostic);
37
+ }
38
+ }
39
+ //# sourceMappingURL=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 -0,0 +1,22 @@
1
+ /**
2
+ * Reads an `xs:duration` as a `Temporal.Duration` of days, hours, minutes,
3
+ * seconds and sub-second units, digits past the ninth fractional one truncated.
4
+ * A day is 24 hours, as in XSD. Temporal alone is more lenient — it also takes
5
+ * weeks, a fraction on hours or minutes, a comma and lower-case designators —
6
+ * so the lexical form is checked first. An MPD duration needs a fixed length.
7
+ *
8
+ * @returns The duration, or a message saying why `text` is not one an MPD can
9
+ * use: not an `xs:duration`, negative, with years, months or a component past
10
+ * 2^53−1, or past Temporal's range.
11
+ */
12
+ export declare function readXsDuration(text: string): Temporal.Duration | string;
13
+ /**
14
+ * Reads an `xs:dateTime` as an instant; one written with no zone is UTC, the
15
+ * tolerance players apply. Digits past the ninth fractional one are truncated.
16
+ *
17
+ * @returns The instant, or a message saying why `text` is not one: not an
18
+ * `xs:dateTime` (a day or time that does not exist, a zone past ±14:00),
19
+ * `24:00:00`, a negative year or one past Temporal's range.
20
+ */
21
+ export declare function readXsDateTime(text: string): Temporal.Instant | string;
22
+ //# sourceMappingURL=_xs-temporal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_xs-temporal.d.ts","sourceRoot":"","sources":["../../src/parse/_xs-temporal.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,QAAQ,GAAG,MAAM,CA6CvE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,GAAG,MAAM,CAuCtE"}