@ac-kit/format-dash 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -0
- package/LICENSE +28 -0
- package/README.md +180 -2
- package/dist/_template.d.ts +34 -0
- package/dist/_template.d.ts.map +1 -0
- package/dist/_template.js +90 -0
- package/dist/_template.js.map +1 -0
- package/dist/_xlink.d.ts +9 -0
- package/dist/_xlink.d.ts.map +1 -0
- package/dist/_xlink.js +14 -0
- package/dist/_xlink.js.map +1 -0
- package/dist/dash-namespaces.d.ts +27 -0
- package/dist/dash-namespaces.d.ts.map +1 -0
- package/dist/dash-namespaces.js +30 -0
- package/dist/dash-namespaces.js.map +1 -0
- package/dist/errors.d.ts +127 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +52 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +51 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +39 -0
- package/dist/limits.js.map +1 -0
- package/dist/model/dash-common.d.ts +124 -0
- package/dist/model/dash-common.d.ts.map +1 -0
- package/dist/model/dash-common.js +2 -0
- package/dist/model/dash-common.js.map +1 -0
- package/dist/model/dash-mpd.d.ts +111 -0
- package/dist/model/dash-mpd.d.ts.map +1 -0
- package/dist/model/dash-mpd.js +2 -0
- package/dist/model/dash-mpd.js.map +1 -0
- package/dist/model/dash-segment-information.d.ts +90 -0
- package/dist/model/dash-segment-information.d.ts.map +1 -0
- package/dist/model/dash-segment-information.js +2 -0
- package/dist/model/dash-segment-information.js.map +1 -0
- package/dist/parse/_attribute-reader.d.ts +94 -0
- package/dist/parse/_attribute-reader.d.ts.map +1 -0
- package/dist/parse/_attribute-reader.js +382 -0
- package/dist/parse/_attribute-reader.js.map +1 -0
- package/dist/parse/_context.d.ts +35 -0
- package/dist/parse/_context.d.ts.map +1 -0
- package/dist/parse/_context.js +39 -0
- package/dist/parse/_context.js.map +1 -0
- package/dist/parse/_xs-temporal.d.ts +22 -0
- package/dist/parse/_xs-temporal.d.ts.map +1 -0
- package/dist/parse/_xs-temporal.js +98 -0
- package/dist/parse/_xs-temporal.js.map +1 -0
- package/dist/parse/parse-dash-mpd.d.ts +67 -0
- package/dist/parse/parse-dash-mpd.d.ts.map +1 -0
- package/dist/parse/parse-dash-mpd.js +928 -0
- package/dist/parse/parse-dash-mpd.js.map +1 -0
- package/dist/resolve/_base-url.d.ts +41 -0
- package/dist/resolve/_base-url.d.ts.map +1 -0
- package/dist/resolve/_base-url.js +69 -0
- package/dist/resolve/_base-url.js.map +1 -0
- package/dist/resolve/_essential-properties.d.ts +38 -0
- package/dist/resolve/_essential-properties.d.ts.map +1 -0
- package/dist/resolve/_essential-properties.js +106 -0
- package/dist/resolve/_essential-properties.js.map +1 -0
- package/dist/resolve/_inherit.d.ts +43 -0
- package/dist/resolve/_inherit.d.ts.map +1 -0
- package/dist/resolve/_inherit.js +105 -0
- package/dist/resolve/_inherit.js.map +1 -0
- package/dist/resolve/_segment-runs.d.ts +81 -0
- package/dist/resolve/_segment-runs.d.ts.map +1 -0
- package/dist/resolve/_segment-runs.js +126 -0
- package/dist/resolve/_segment-runs.js.map +1 -0
- package/dist/resolve/dash-resolve-diagnostic.d.ts +34 -0
- package/dist/resolve/dash-resolve-diagnostic.d.ts.map +1 -0
- package/dist/resolve/dash-resolve-diagnostic.js +2 -0
- package/dist/resolve/dash-resolve-diagnostic.js.map +1 -0
- package/dist/resolve/resolve-dash-representations.d.ts +130 -0
- package/dist/resolve/resolve-dash-representations.d.ts.map +1 -0
- package/dist/resolve/resolve-dash-representations.js +203 -0
- package/dist/resolve/resolve-dash-representations.js.map +1 -0
- package/dist/resolve/resolve-dash-segments.d.ts +169 -0
- package/dist/resolve/resolve-dash-segments.d.ts.map +1 -0
- package/dist/resolve/resolve-dash-segments.js +665 -0
- package/dist/resolve/resolve-dash-segments.js.map +1 -0
- package/dist/timing/_exact-period-timings.d.ts +28 -0
- package/dist/timing/_exact-period-timings.d.ts.map +1 -0
- package/dist/timing/_exact-period-timings.js +142 -0
- package/dist/timing/_exact-period-timings.js.map +1 -0
- package/dist/timing/dash-period-timings.d.ts +29 -0
- package/dist/timing/dash-period-timings.d.ts.map +1 -0
- package/dist/timing/dash-period-timings.js +23 -0
- package/dist/timing/dash-period-timings.js.map +1 -0
- package/package.json +63 -3
|
@@ -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=_context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_context.js","sourceRoot":"","sources":["../../src/parse/_context.ts"],"names":[],"mappings":"AAGA,OAAO,EAGN,eAAe,GACf,MAAM,cAAc,CAAC;AAGtB;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAKhB,OAAO;IACC,YAAY;IALrB,QAAQ,GAAqB,EAAE,CAAC;IACzC,SAAS,GAAG,KAAK,CAAC;IAElB,YACU,OAAgB,EACR,YAAoB;uBAD5B,OAAO;4BACC,YAAY;IAC3B,CAAC;IAEJ,gDAAgD;IAChD,SAAS,CACR,IAAwB,EACxB,OAAe,EACf,QAA4B;QAE5B,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,QAAQ,CACP,IAAwB,EACxB,OAAe,EACf,QAA4B;QAE5B,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,wCAAwC;IACxC,KAAK,CACJ,IAAwB,EACxB,OAAe,EACf,QAA4B;QAE5B,MAAM,IAAI,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAEO,OAAO,CAAC,UAA0B;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC/C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;YACtB,OAAO;QACR,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;CACD"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { parseXsDateTime, parseXsDuration } from "@ac-kit/format-xml";
|
|
2
|
+
const MAX_INSTANT_YEAR_DIGITS_ = 6;
|
|
3
|
+
/**
|
|
4
|
+
* Reads an `xs:duration` as a `Temporal.Duration` of days, hours, minutes,
|
|
5
|
+
* seconds and sub-second units, digits past the ninth fractional one truncated.
|
|
6
|
+
* A day is 24 hours, as in XSD. Temporal alone is more lenient — it also takes
|
|
7
|
+
* weeks, a fraction on hours or minutes, a comma and lower-case designators —
|
|
8
|
+
* so the lexical form is checked first. An MPD duration needs a fixed length.
|
|
9
|
+
*
|
|
10
|
+
* @returns The duration, or a message saying why `text` is not one an MPD can
|
|
11
|
+
* use: not an `xs:duration`, negative, with years, months or a component past
|
|
12
|
+
* 2^53−1, or past Temporal's range.
|
|
13
|
+
*/
|
|
14
|
+
export function readXsDuration(text) {
|
|
15
|
+
const lexical = parseXsDuration(text);
|
|
16
|
+
if (lexical === null) {
|
|
17
|
+
return `"${text}" is not an xs:duration`;
|
|
18
|
+
}
|
|
19
|
+
if (lexical.negative) {
|
|
20
|
+
return `"${text}" is negative`;
|
|
21
|
+
}
|
|
22
|
+
if (Number(lexical.years ?? 0) !== 0 || Number(lexical.months ?? 0) !== 0) {
|
|
23
|
+
return `"${text}" has years or months, which have no fixed length`;
|
|
24
|
+
}
|
|
25
|
+
const [wholeSeconds = "", fraction = ""] = (lexical.seconds ?? "0").split(".");
|
|
26
|
+
const components = [
|
|
27
|
+
lexical.days,
|
|
28
|
+
lexical.hours,
|
|
29
|
+
lexical.minutes,
|
|
30
|
+
wholeSeconds,
|
|
31
|
+
];
|
|
32
|
+
if (components.some((component) => component !== null && !Number.isSafeInteger(Number(component)))) {
|
|
33
|
+
return `"${text}" has a component past 2^53-1`;
|
|
34
|
+
}
|
|
35
|
+
const nanoseconds = fraction.slice(0, 9).padEnd(9, "0");
|
|
36
|
+
try {
|
|
37
|
+
return Temporal.Duration.from({
|
|
38
|
+
days: Number(lexical.days ?? 0),
|
|
39
|
+
hours: Number(lexical.hours ?? 0),
|
|
40
|
+
minutes: Number(lexical.minutes ?? 0),
|
|
41
|
+
seconds: Number(wholeSeconds === "" ? 0 : wholeSeconds),
|
|
42
|
+
milliseconds: Number(nanoseconds.slice(0, 3)),
|
|
43
|
+
microseconds: Number(nanoseconds.slice(3, 6)),
|
|
44
|
+
nanoseconds: Number(nanoseconds.slice(6, 9)),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof RangeError) {
|
|
49
|
+
return `"${text}" is past the range of a duration`;
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reads an `xs:dateTime` as an instant; one written with no zone is UTC, the
|
|
56
|
+
* tolerance players apply. Digits past the ninth fractional one are truncated.
|
|
57
|
+
*
|
|
58
|
+
* @returns The instant, or a message saying why `text` is not one: not an
|
|
59
|
+
* `xs:dateTime` (a day or time that does not exist, a zone past ±14:00),
|
|
60
|
+
* `24:00:00`, a negative year or one past Temporal's range.
|
|
61
|
+
*/
|
|
62
|
+
export function readXsDateTime(text) {
|
|
63
|
+
const lexical = parseXsDateTime(text);
|
|
64
|
+
if (lexical === null) {
|
|
65
|
+
return `"${text}" is not an xs:dateTime`;
|
|
66
|
+
}
|
|
67
|
+
if (lexical.negativeYear) {
|
|
68
|
+
return `"${text}" has a negative year`;
|
|
69
|
+
}
|
|
70
|
+
if (lexical.year.length > MAX_INSTANT_YEAR_DIGITS_) {
|
|
71
|
+
return `"${text}" is past the range of an instant`;
|
|
72
|
+
}
|
|
73
|
+
if (lexical.hour === 24) {
|
|
74
|
+
return `"${text}" names a time that does not exist`;
|
|
75
|
+
}
|
|
76
|
+
const pad = (value) => String(value).padStart(2, "0");
|
|
77
|
+
const year = lexical.year.length > 4
|
|
78
|
+
? `+${lexical.year.padStart(6, "0")}`
|
|
79
|
+
: lexical.year;
|
|
80
|
+
const fraction = lexical.fraction === "" ? "" : `.${lexical.fraction.slice(0, 9)}`;
|
|
81
|
+
const local = `${year}-${pad(lexical.month)}-${pad(lexical.day)}T${pad(lexical.hour)}:${pad(lexical.minute)}:${pad(lexical.second)}${fraction}`;
|
|
82
|
+
try {
|
|
83
|
+
const dateTime = Temporal.PlainDateTime.from(local, { overflow: "reject" });
|
|
84
|
+
if (lexical.timezoneMinutes === null || lexical.timezoneMinutes === 0) {
|
|
85
|
+
return dateTime.toZonedDateTime("UTC").toInstant();
|
|
86
|
+
}
|
|
87
|
+
const offset = Math.abs(lexical.timezoneMinutes);
|
|
88
|
+
const sign = lexical.timezoneMinutes < 0 ? "-" : "+";
|
|
89
|
+
return Temporal.Instant.from(`${local}${sign}${pad(Math.floor(offset / 60))}:${pad(offset % 60)}`);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (error instanceof RangeError) {
|
|
93
|
+
return `"${text}" is past the range of an instant`;
|
|
94
|
+
}
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=_xs-temporal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_xs-temporal.js","sourceRoot":"","sources":["../../src/parse/_xs-temporal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEtE,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY;IAC1C,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,yBAAyB,CAAC;IAC1C,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AAC,EAAE,CACpE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;YACjC,OAAO,IAAI,IAAI,mCAAmC,CAAC;QACpD,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type WorkBudget } from "@ac-kit/core";
|
|
2
|
+
import { type XmlDocument, type XmlParseOptions } from "@ac-kit/format-xml";
|
|
3
|
+
import { type DashDiagnostic } from "../errors.js";
|
|
4
|
+
import { type DashLimits } from "../limits.js";
|
|
5
|
+
import type { DashMpd } from "../model/dash-mpd.js";
|
|
6
|
+
/** Options of {@link parseDashMpd}. */
|
|
7
|
+
export type DashParseOptions = DashLimits & Omit<XmlParseOptions, "budget"> & {
|
|
8
|
+
/**
|
|
9
|
+
* `"strict"` by default: every violation of ISO/IEC 23009-1 the parser
|
|
10
|
+
* checks, and every Namespaces in XML violation, throws. `"lenient"`
|
|
11
|
+
* recovers from each and records it in `warnings`: a typed attribute that
|
|
12
|
+
* does not read becomes `null`.
|
|
13
|
+
*/
|
|
14
|
+
readonly mode?: "strict" | "lenient";
|
|
15
|
+
/**
|
|
16
|
+
* A single allowance for XML parsing, namespace resolution and the MPD
|
|
17
|
+
* pass. A caller's `WorkBudget` can be shared across calls; its error
|
|
18
|
+
* propagates unchanged. A numeric limit creates a private budget
|
|
19
|
+
* ({@link DEFAULT_DASH_WORK_BUDGET} by default) whose exhaustion raises a
|
|
20
|
+
* {@link DashLimitError} with limit `budget`.
|
|
21
|
+
*/
|
|
22
|
+
readonly budget?: WorkBudget | number;
|
|
23
|
+
};
|
|
24
|
+
/** What {@link parseDashMpd} answers. */
|
|
25
|
+
export type DashParseResult = {
|
|
26
|
+
readonly mpd: DashMpd;
|
|
27
|
+
/** Advisories, and in lenient mode the violations recovered from, in order. */
|
|
28
|
+
readonly warnings: readonly DashDiagnostic[];
|
|
29
|
+
/** Whether more than `maxWarnings` diagnostics were found. */
|
|
30
|
+
readonly warningsTruncated: boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Reads an MPD (ISO/IEC 23009-1, 5th edition schema) into its as-written model.
|
|
34
|
+
* Fetches nothing: remote (xlink) elements are recorded, never resolved.
|
|
35
|
+
*
|
|
36
|
+
* Elements match by namespace: the root's, which must be
|
|
37
|
+
* {@link DASH_MPD_NAMESPACE}, {@link DASH_MPD_LEGACY_NAMESPACE} or none (the
|
|
38
|
+
* last two with an advisory). Every typed attribute is checked against its
|
|
39
|
+
* lexical form; inheritance is not applied; what the model does not type is
|
|
40
|
+
* kept in `otherAttributes` and `otherElements`. ContentProtection is plain
|
|
41
|
+
* data. Durations and date-times are `Temporal` values: requires a `Temporal`
|
|
42
|
+
* global.
|
|
43
|
+
*
|
|
44
|
+
* Time O(n) in the document, charged to `budget`; the recursion follows the MPD
|
|
45
|
+
* schema's fixed depth, never the input's nesting, and wide sibling lists are
|
|
46
|
+
* appended one by one.
|
|
47
|
+
*
|
|
48
|
+
* @throws {XmlSyntaxError} When the source is not well-formed XML or exceeds an
|
|
49
|
+
* XML limit, in both modes.
|
|
50
|
+
* @throws {XmlNamespaceError} When it is not namespace-well-formed, in strict
|
|
51
|
+
* mode.
|
|
52
|
+
* @throws {DashSyntaxError} On the first violation in strict mode; in both
|
|
53
|
+
* modes when the root is not an MPD.
|
|
54
|
+
* @throws {DashLimitError} Past `maxLength`, `maxTimelineEntries` or a private
|
|
55
|
+
* `budget`, in both modes.
|
|
56
|
+
* @throws Whatever a caller's `budget` throws once spent.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parseDashMpd(source: string | Uint8Array | XmlDocument, options?: DashParseOptions): DashParseResult;
|
|
59
|
+
/**
|
|
60
|
+
* {@link parseDashMpd}, answering `null` instead of throwing `XmlSyntaxError`,
|
|
61
|
+
* `XmlNamespaceError` or {@link DashSyntaxError} — an XML limit is an
|
|
62
|
+
* `XmlSyntaxError`, so it answers `null` too. {@link DashLimitError} and
|
|
63
|
+
* anything thrown by a caller's budget propagate unchanged, even if the budget
|
|
64
|
+
* throws a syntax error.
|
|
65
|
+
*/
|
|
66
|
+
export declare function tryParseDashMpd(source: string | Uint8Array | XmlDocument, options?: DashParseOptions): DashParseResult | null;
|
|
67
|
+
//# sourceMappingURL=parse-dash-mpd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-dash-mpd.d.ts","sourceRoot":"","sources":["../../src/parse/parse-dash-mpd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,UAAU,EAAkB,MAAM,cAAc,CAAC;AAE1E,OAAO,EAKN,KAAK,WAAW,EAIhB,KAAK,eAAe,EAIpB,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EACN,KAAK,cAAc,EAGnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEN,KAAK,UAAU,EAEf,MAAM,cAAc,CAAC;AAStB,OAAO,KAAK,EAEX,OAAO,EAIP,MAAM,sBAAsB,CAAC;AAa9B,uCAAuC;AACvC,MAAM,MAAM,gBAAgB,GAAG,UAAU,GACxC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GAAG;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACrC;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CACtC,CAAC;AAEH,yCAAyC;AACzC,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,8DAA8D;IAC9D,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC3B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