@amazon/vinyl-util 3.0.1 → 3.2.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/dist/browserTestUtil/index.js.map +2 -2
- package/dist/browserTestUtil/types/current/mock/dom/lib.dom.d.ts.map +1 -1
- package/dist/browserTestUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/index.cjs +165 -178
- package/dist/index.cjs.map +4 -4
- package/dist/index.js +165 -178
- package/dist/index.js.map +4 -4
- package/dist/polyfill/index.js +35 -32
- package/dist/polyfill/index.js.map +3 -3
- package/dist/polyfill/tsconfig.tsbuildinfo +1 -1
- package/dist/test/benchmark.js.map +2 -2
- package/dist/testUtil/index.js +0 -36
- package/dist/testUtil/index.js.map +3 -3
- package/dist/testUtil/types/current/index.d.ts +0 -1
- package/dist/testUtil/types/current/index.d.ts.map +1 -1
- package/dist/testUtil/types/current/index.js +0 -1
- package/dist/testUtil/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/testUtil/types/ts3.7/index.d.ts +0 -1
- package/dist/testUtil/types/ts4.1/index.d.ts +0 -1
- package/dist/testUtil/types/ts4.7/index.d.ts +0 -1
- package/dist/types/current/index.d.ts +1 -1
- package/dist/types/current/index.d.ts.map +1 -1
- package/dist/types/current/index.js +1 -1
- package/dist/types/current/network/responseUtil.d.ts +21 -0
- package/dist/types/current/network/responseUtil.d.ts.map +1 -1
- package/dist/types/current/network/responseUtil.js +30 -0
- package/dist/types/current/tsconfig.tsbuildinfo +1 -1
- package/dist/types/current/util/async/never.d.ts.map +1 -1
- package/dist/types/current/util/type.d.ts.map +1 -1
- package/dist/types/current/util/webm/parseWebm.d.ts +43 -0
- package/dist/types/current/util/webm/parseWebm.d.ts.map +1 -0
- package/dist/types/current/util/webm/parseWebm.js +166 -0
- package/dist/types/ts3.7/index.d.ts +1 -1
- package/dist/types/ts3.7/network/responseUtil.d.ts +21 -0
- package/dist/types/ts3.7/util/webm/parseWebm.d.ts +43 -0
- package/dist/types/ts4.1/index.d.ts +1 -1
- package/dist/types/ts4.1/network/responseUtil.d.ts +21 -0
- package/dist/types/ts4.1/util/webm/parseWebm.d.ts +43 -0
- package/dist/types/ts4.7/index.d.ts +1 -1
- package/dist/types/ts4.7/network/responseUtil.d.ts +21 -0
- package/dist/types/ts4.7/util/webm/parseWebm.d.ts +43 -0
- package/dist/unit/types/current/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/testUtil/types/current/patch/addPatchTests.d.ts +0 -35
- package/dist/testUtil/types/current/patch/addPatchTests.d.ts.map +0 -1
- package/dist/testUtil/types/current/patch/addPatchTests.js +0 -54
- package/dist/testUtil/types/ts3.7/patch/addPatchTests.d.ts +0 -35
- package/dist/testUtil/types/ts4.1/patch/addPatchTests.d.ts +0 -35
- package/dist/testUtil/types/ts4.7/patch/addPatchTests.d.ts +0 -35
- package/dist/types/current/patch/patchTarget.d.ts +0 -114
- package/dist/types/current/patch/patchTarget.d.ts.map +0 -1
- package/dist/types/current/patch/patchTarget.js +0 -219
- package/dist/types/ts3.7/patch/patchTarget.d.ts +0 -114
- package/dist/types/ts4.1/patch/patchTarget.d.ts +0 -114
- package/dist/types/ts4.7/patch/patchTarget.d.ts +0 -114
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { ValidationError } from '../../error/ValidationError';
|
|
6
|
+
import { ErrorOrigin } from '../../error/ErrorOrigin';
|
|
7
|
+
/**
|
|
8
|
+
* A minimal EBML/Matroska (WebM) parser: just enough to index a DASH
|
|
9
|
+
* `SegmentBase` WebM stream — the `Segment` data offset and `TimecodeScale`
|
|
10
|
+
* from the initialization segment, and the `CuePoint`s from the `Cues` element
|
|
11
|
+
* (the WebM equivalent of an ISO-BMFF `sidx`).
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** EBML element IDs (with their length-descriptor marker bits intact). */
|
|
16
|
+
const EBML_ID = {
|
|
17
|
+
Segment: 0x18538067,
|
|
18
|
+
Info: 0x1549a966,
|
|
19
|
+
TimecodeScale: 0x2ad7b1,
|
|
20
|
+
Cues: 0x1c53bb6b,
|
|
21
|
+
CuePoint: 0xbb,
|
|
22
|
+
CueTime: 0xb3,
|
|
23
|
+
CueTrackPositions: 0xb7,
|
|
24
|
+
CueClusterPosition: 0xf1,
|
|
25
|
+
};
|
|
26
|
+
/** The default `TimecodeScale` (1ms in nanoseconds) when none is present. */
|
|
27
|
+
export const DEFAULT_WEBM_TIMECODE_SCALE = 1_000_000;
|
|
28
|
+
/**
|
|
29
|
+
* Reads an EBML variable-length integer at `pos`.
|
|
30
|
+
*
|
|
31
|
+
* @param keepMarker When true (element ids), the leading length-descriptor
|
|
32
|
+
* marker bit is retained; when false (sizes/uints), it is stripped to yield the
|
|
33
|
+
* numeric value, and an all-ones value ("unknown size") yields `null`.
|
|
34
|
+
*/
|
|
35
|
+
function readVint(view, pos, keepMarker) {
|
|
36
|
+
const first = view.getUint8(pos);
|
|
37
|
+
let mask = 0x80;
|
|
38
|
+
let length = 1;
|
|
39
|
+
while (length <= 8 && (first & mask) === 0) {
|
|
40
|
+
mask >>= 1;
|
|
41
|
+
length++;
|
|
42
|
+
}
|
|
43
|
+
if (length > 8)
|
|
44
|
+
throw new ValidationError('invalid EBML variable-length integer', ErrorOrigin.MEDIA);
|
|
45
|
+
let value = keepMarker ? first : first & (mask - 1);
|
|
46
|
+
let allOnes = (first & (mask - 1)) === mask - 1;
|
|
47
|
+
for (let i = 1; i < length; i++) {
|
|
48
|
+
const byte = view.getUint8(pos + i);
|
|
49
|
+
allOnes = allOnes && byte === 0xff;
|
|
50
|
+
// Multiply (not shift) to stay correct beyond 32 bits.
|
|
51
|
+
value = value * 256 + byte;
|
|
52
|
+
}
|
|
53
|
+
return { value: !keepMarker && allOnes ? null : value, length };
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Reads the EBML element header at `pos`.
|
|
57
|
+
*/
|
|
58
|
+
function readElementHeader(view, pos) {
|
|
59
|
+
const { value: id, length: idLength } = readVint(view, pos, true);
|
|
60
|
+
const { value: size, length: sizeLength } = readVint(view, pos + idLength, false);
|
|
61
|
+
const contentStart = pos + idLength + sizeLength;
|
|
62
|
+
return {
|
|
63
|
+
id: id,
|
|
64
|
+
contentStart,
|
|
65
|
+
size,
|
|
66
|
+
end: size == null ? null : contentStart + size,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Reads the child element headers in `[start, end)`. An unknown-size element
|
|
71
|
+
* (no bounded end) terminates the list.
|
|
72
|
+
*/
|
|
73
|
+
function childHeaders(view, start, end) {
|
|
74
|
+
const out = [];
|
|
75
|
+
let pos = start;
|
|
76
|
+
while (pos < end) {
|
|
77
|
+
const el = readElementHeader(view, pos);
|
|
78
|
+
out.push(el);
|
|
79
|
+
if (el.end == null)
|
|
80
|
+
break;
|
|
81
|
+
pos = el.end;
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Reads a big-endian unsigned integer of `length` bytes at `pos`.
|
|
87
|
+
*/
|
|
88
|
+
function readUint(view, pos, length) {
|
|
89
|
+
let value = 0;
|
|
90
|
+
for (let i = 0; i < length; i++)
|
|
91
|
+
value = value * 256 + view.getUint8(pos + i);
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Parses a WebM initialization segment for the `Segment` data offset and
|
|
96
|
+
* `TimecodeScale`. The init segment is everything before the first `Cluster`
|
|
97
|
+
* (EBML header, `Segment` header, `SeekHead`, `Info`, `Tracks`).
|
|
98
|
+
*/
|
|
99
|
+
export function parseWebmInit(buffer) {
|
|
100
|
+
const view = new DataView(buffer);
|
|
101
|
+
const segment = childHeaders(view, 0, view.byteLength).find((el) => el.id === EBML_ID.Segment);
|
|
102
|
+
if (!segment)
|
|
103
|
+
throw new ValidationError('WebM init segment missing Segment element', ErrorOrigin.MEDIA);
|
|
104
|
+
const segmentEnd = Math.min(segment.end ?? view.byteLength, view.byteLength);
|
|
105
|
+
const info = childHeaders(view, segment.contentStart, segmentEnd).find((el) => el.id === EBML_ID.Info && el.size != null);
|
|
106
|
+
return {
|
|
107
|
+
segmentDataStart: segment.contentStart,
|
|
108
|
+
segmentSize: segment.size,
|
|
109
|
+
timecodeScale: info
|
|
110
|
+
? readTimecodeScale(view, info.contentStart, info.end)
|
|
111
|
+
: DEFAULT_WEBM_TIMECODE_SCALE,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reads `Info > TimecodeScale`, defaulting when absent.
|
|
116
|
+
*/
|
|
117
|
+
function readTimecodeScale(view, start, end) {
|
|
118
|
+
const el = childHeaders(view, start, end).find((child) => child.id === EBML_ID.TimecodeScale && child.size);
|
|
119
|
+
return el
|
|
120
|
+
? readUint(view, el.contentStart, el.size)
|
|
121
|
+
: DEFAULT_WEBM_TIMECODE_SCALE;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Parses a WebM `Cues` element (as located by a DASH `SegmentBase@indexRange`)
|
|
125
|
+
* into its cue points, in order.
|
|
126
|
+
*/
|
|
127
|
+
export function parseWebmCues(buffer) {
|
|
128
|
+
const view = new DataView(buffer);
|
|
129
|
+
const cues = readElementHeader(view, 0);
|
|
130
|
+
if (cues.id !== EBML_ID.Cues)
|
|
131
|
+
throw new ValidationError(`expected WebM 'Cues' element but had id: 0x${cues.id.toString(16)}`, ErrorOrigin.MEDIA);
|
|
132
|
+
const cuesEnd = Math.min(cues.end ?? view.byteLength, view.byteLength);
|
|
133
|
+
const cuePoints = [];
|
|
134
|
+
for (const el of childHeaders(view, cues.contentStart, cuesEnd)) {
|
|
135
|
+
if (el.id !== EBML_ID.CuePoint || el.size == null)
|
|
136
|
+
continue;
|
|
137
|
+
const cuePoint = parseCuePoint(view, el.contentStart, el.end);
|
|
138
|
+
if (cuePoint)
|
|
139
|
+
cuePoints.push(cuePoint);
|
|
140
|
+
}
|
|
141
|
+
return cuePoints;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Parses a single `CuePoint` (its `CueTime` and first
|
|
145
|
+
* `CueTrackPositions > CueClusterPosition`).
|
|
146
|
+
*/
|
|
147
|
+
function parseCuePoint(view, start, end) {
|
|
148
|
+
let time = null;
|
|
149
|
+
let clusterPosition = null;
|
|
150
|
+
for (const el of childHeaders(view, start, end)) {
|
|
151
|
+
if (el.id === EBML_ID.CueTime && el.size)
|
|
152
|
+
time = readUint(view, el.contentStart, el.size);
|
|
153
|
+
else if (el.id === EBML_ID.CueTrackPositions && el.size != null)
|
|
154
|
+
clusterPosition = readCueClusterPosition(view, el.contentStart, el.end);
|
|
155
|
+
}
|
|
156
|
+
return time != null && clusterPosition != null
|
|
157
|
+
? { time, clusterPosition }
|
|
158
|
+
: null;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Reads `CueTrackPositions > CueClusterPosition`.
|
|
162
|
+
*/
|
|
163
|
+
function readCueClusterPosition(view, start, end) {
|
|
164
|
+
const el = childHeaders(view, start, end).find((child) => child.id === EBML_ID.CueClusterPosition && child.size);
|
|
165
|
+
return el ? readUint(view, el.contentStart, el.size) : null;
|
|
166
|
+
}
|
|
@@ -54,7 +54,6 @@ export * from './network/requesterUtil';
|
|
|
54
54
|
export * from './network/RequestInterceptor';
|
|
55
55
|
export * from './network/responseUtil';
|
|
56
56
|
export * from './patch/network/fetch';
|
|
57
|
-
export * from './patch/patchTarget';
|
|
58
57
|
export * from './persistence/KeyValuePersistence';
|
|
59
58
|
export * from './persistence/persistenceRef';
|
|
60
59
|
export * from './persistence/PersistentItem';
|
|
@@ -116,4 +115,5 @@ export * from './util/string/StringReader';
|
|
|
116
115
|
export * from './util/string/uid';
|
|
117
116
|
export * from './util/type';
|
|
118
117
|
export * from './util/url/resolveUrl';
|
|
118
|
+
export * from './util/webm/parseWebm';
|
|
119
119
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,25 @@ import { RequestError } from './RequestError';
|
|
|
7
7
|
export declare function isResponseError(error: any): error is RequestError & {
|
|
8
8
|
readonly info: RequestResponseErrorEvent;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* The body representations {@link readResponseBody} can produce.
|
|
12
|
+
*/
|
|
13
|
+
export type ResponseBodyType = 'arrayBuffer' | 'text' | 'json';
|
|
14
|
+
/**
|
|
15
|
+
* Reads a response body, classifying a read failure with a service error origin.
|
|
16
|
+
*
|
|
17
|
+
* The requester (`requestWithRetry`/`request`) classifies only the `fetch` and
|
|
18
|
+
* the response status; it returns the {@link Response} before the body is
|
|
19
|
+
* consumed. Reading the body stream can fail *after* a successful response —
|
|
20
|
+
* e.g. the connection drops mid-body — rejecting with a bare `TypeError`
|
|
21
|
+
* ("Failed to fetch") that carries no origin and would otherwise be reported
|
|
22
|
+
* with {@link ReportableError}'s `internal` default. This reads the body on the
|
|
23
|
+
* caller's behalf and rethrows such failures as a {@link ReportableError} with a
|
|
24
|
+
* service origin (mirroring {@link RequestError} origin classification: a 5xx
|
|
25
|
+
* status is `serviceExternal`, anything else `serviceInternal`). An aborted read
|
|
26
|
+
* is preserved as a silent error so an intentional cancellation is not reported.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readResponseBody(response: Response, as: 'arrayBuffer'): Promise<ArrayBuffer>;
|
|
29
|
+
export declare function readResponseBody(response: Response, as: 'text'): Promise<string>;
|
|
30
|
+
export declare function readResponseBody(response: Response, as: 'json'): Promise<any>;
|
|
10
31
|
//# sourceMappingURL=responseUtil.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The default `TimecodeScale` (1ms in nanoseconds) when none is present. */
|
|
2
|
+
export declare const DEFAULT_WEBM_TIMECODE_SCALE = 1000000;
|
|
3
|
+
export interface WebmInitInfo {
|
|
4
|
+
/**
|
|
5
|
+
* The absolute byte offset (in the file) where the `Segment` element's
|
|
6
|
+
* content begins. `CueClusterPosition` values are relative to this.
|
|
7
|
+
*/
|
|
8
|
+
readonly segmentDataStart: number;
|
|
9
|
+
/**
|
|
10
|
+
* The `Segment` content size in bytes, or `null` if encoded as unknown.
|
|
11
|
+
*/
|
|
12
|
+
readonly segmentSize: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* The `TimecodeScale` in nanoseconds per tick (cue times are in these ticks).
|
|
15
|
+
*/
|
|
16
|
+
readonly timecodeScale: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parses a WebM initialization segment for the `Segment` data offset and
|
|
20
|
+
* `TimecodeScale`. The init segment is everything before the first `Cluster`
|
|
21
|
+
* (EBML header, `Segment` header, `SeekHead`, `Info`, `Tracks`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseWebmInit(buffer: ArrayBuffer): WebmInitInfo;
|
|
24
|
+
/**
|
|
25
|
+
* A single WebM cue point: a cluster's start time and its byte offset relative
|
|
26
|
+
* to the `Segment` data start.
|
|
27
|
+
*/
|
|
28
|
+
export interface WebmCuePoint {
|
|
29
|
+
/**
|
|
30
|
+
* The cluster's start time, in `TimecodeScale` ticks.
|
|
31
|
+
*/
|
|
32
|
+
readonly time: number;
|
|
33
|
+
/**
|
|
34
|
+
* The cluster's byte offset relative to the `Segment` data start.
|
|
35
|
+
*/
|
|
36
|
+
readonly clusterPosition: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses a WebM `Cues` element (as located by a DASH `SegmentBase@indexRange`)
|
|
40
|
+
* into its cue points, in order.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseWebmCues(buffer: ArrayBuffer): readonly WebmCuePoint[];
|
|
43
|
+
//# sourceMappingURL=parseWebm.d.ts.map
|
|
@@ -54,7 +54,6 @@ export * from './network/requesterUtil';
|
|
|
54
54
|
export * from './network/RequestInterceptor';
|
|
55
55
|
export * from './network/responseUtil';
|
|
56
56
|
export * from './patch/network/fetch';
|
|
57
|
-
export * from './patch/patchTarget';
|
|
58
57
|
export * from './persistence/KeyValuePersistence';
|
|
59
58
|
export * from './persistence/persistenceRef';
|
|
60
59
|
export * from './persistence/PersistentItem';
|
|
@@ -116,4 +115,5 @@ export * from './util/string/StringReader';
|
|
|
116
115
|
export * from './util/string/uid';
|
|
117
116
|
export * from './util/type';
|
|
118
117
|
export * from './util/url/resolveUrl';
|
|
118
|
+
export * from './util/webm/parseWebm';
|
|
119
119
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,25 @@ import { RequestError } from './RequestError';
|
|
|
7
7
|
export declare function isResponseError(error: any): error is RequestError & {
|
|
8
8
|
readonly info: RequestResponseErrorEvent;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* The body representations {@link readResponseBody} can produce.
|
|
12
|
+
*/
|
|
13
|
+
export type ResponseBodyType = 'arrayBuffer' | 'text' | 'json';
|
|
14
|
+
/**
|
|
15
|
+
* Reads a response body, classifying a read failure with a service error origin.
|
|
16
|
+
*
|
|
17
|
+
* The requester (`requestWithRetry`/`request`) classifies only the `fetch` and
|
|
18
|
+
* the response status; it returns the {@link Response} before the body is
|
|
19
|
+
* consumed. Reading the body stream can fail *after* a successful response —
|
|
20
|
+
* e.g. the connection drops mid-body — rejecting with a bare `TypeError`
|
|
21
|
+
* ("Failed to fetch") that carries no origin and would otherwise be reported
|
|
22
|
+
* with {@link ReportableError}'s `internal` default. This reads the body on the
|
|
23
|
+
* caller's behalf and rethrows such failures as a {@link ReportableError} with a
|
|
24
|
+
* service origin (mirroring {@link RequestError} origin classification: a 5xx
|
|
25
|
+
* status is `serviceExternal`, anything else `serviceInternal`). An aborted read
|
|
26
|
+
* is preserved as a silent error so an intentional cancellation is not reported.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readResponseBody(response: Response, as: 'arrayBuffer'): Promise<ArrayBuffer>;
|
|
29
|
+
export declare function readResponseBody(response: Response, as: 'text'): Promise<string>;
|
|
30
|
+
export declare function readResponseBody(response: Response, as: 'json'): Promise<any>;
|
|
10
31
|
//# sourceMappingURL=responseUtil.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The default `TimecodeScale` (1ms in nanoseconds) when none is present. */
|
|
2
|
+
export declare const DEFAULT_WEBM_TIMECODE_SCALE = 1000000;
|
|
3
|
+
export interface WebmInitInfo {
|
|
4
|
+
/**
|
|
5
|
+
* The absolute byte offset (in the file) where the `Segment` element's
|
|
6
|
+
* content begins. `CueClusterPosition` values are relative to this.
|
|
7
|
+
*/
|
|
8
|
+
readonly segmentDataStart: number;
|
|
9
|
+
/**
|
|
10
|
+
* The `Segment` content size in bytes, or `null` if encoded as unknown.
|
|
11
|
+
*/
|
|
12
|
+
readonly segmentSize: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* The `TimecodeScale` in nanoseconds per tick (cue times are in these ticks).
|
|
15
|
+
*/
|
|
16
|
+
readonly timecodeScale: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parses a WebM initialization segment for the `Segment` data offset and
|
|
20
|
+
* `TimecodeScale`. The init segment is everything before the first `Cluster`
|
|
21
|
+
* (EBML header, `Segment` header, `SeekHead`, `Info`, `Tracks`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseWebmInit(buffer: ArrayBuffer): WebmInitInfo;
|
|
24
|
+
/**
|
|
25
|
+
* A single WebM cue point: a cluster's start time and its byte offset relative
|
|
26
|
+
* to the `Segment` data start.
|
|
27
|
+
*/
|
|
28
|
+
export interface WebmCuePoint {
|
|
29
|
+
/**
|
|
30
|
+
* The cluster's start time, in `TimecodeScale` ticks.
|
|
31
|
+
*/
|
|
32
|
+
readonly time: number;
|
|
33
|
+
/**
|
|
34
|
+
* The cluster's byte offset relative to the `Segment` data start.
|
|
35
|
+
*/
|
|
36
|
+
readonly clusterPosition: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses a WebM `Cues` element (as located by a DASH `SegmentBase@indexRange`)
|
|
40
|
+
* into its cue points, in order.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseWebmCues(buffer: ArrayBuffer): readonly WebmCuePoint[];
|
|
43
|
+
//# sourceMappingURL=parseWebm.d.ts.map
|
|
@@ -54,7 +54,6 @@ export * from './network/requesterUtil';
|
|
|
54
54
|
export * from './network/RequestInterceptor';
|
|
55
55
|
export * from './network/responseUtil';
|
|
56
56
|
export * from './patch/network/fetch';
|
|
57
|
-
export * from './patch/patchTarget';
|
|
58
57
|
export * from './persistence/KeyValuePersistence';
|
|
59
58
|
export * from './persistence/persistenceRef';
|
|
60
59
|
export * from './persistence/PersistentItem';
|
|
@@ -116,4 +115,5 @@ export * from './util/string/StringReader';
|
|
|
116
115
|
export * from './util/string/uid';
|
|
117
116
|
export * from './util/type';
|
|
118
117
|
export * from './util/url/resolveUrl';
|
|
118
|
+
export * from './util/webm/parseWebm';
|
|
119
119
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -7,4 +7,25 @@ import { RequestError } from './RequestError';
|
|
|
7
7
|
export declare function isResponseError(error: any): error is RequestError & {
|
|
8
8
|
readonly info: RequestResponseErrorEvent;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* The body representations {@link readResponseBody} can produce.
|
|
12
|
+
*/
|
|
13
|
+
export type ResponseBodyType = 'arrayBuffer' | 'text' | 'json';
|
|
14
|
+
/**
|
|
15
|
+
* Reads a response body, classifying a read failure with a service error origin.
|
|
16
|
+
*
|
|
17
|
+
* The requester (`requestWithRetry`/`request`) classifies only the `fetch` and
|
|
18
|
+
* the response status; it returns the {@link Response} before the body is
|
|
19
|
+
* consumed. Reading the body stream can fail *after* a successful response —
|
|
20
|
+
* e.g. the connection drops mid-body — rejecting with a bare `TypeError`
|
|
21
|
+
* ("Failed to fetch") that carries no origin and would otherwise be reported
|
|
22
|
+
* with {@link ReportableError}'s `internal` default. This reads the body on the
|
|
23
|
+
* caller's behalf and rethrows such failures as a {@link ReportableError} with a
|
|
24
|
+
* service origin (mirroring {@link RequestError} origin classification: a 5xx
|
|
25
|
+
* status is `serviceExternal`, anything else `serviceInternal`). An aborted read
|
|
26
|
+
* is preserved as a silent error so an intentional cancellation is not reported.
|
|
27
|
+
*/
|
|
28
|
+
export declare function readResponseBody(response: Response, as: 'arrayBuffer'): Promise<ArrayBuffer>;
|
|
29
|
+
export declare function readResponseBody(response: Response, as: 'text'): Promise<string>;
|
|
30
|
+
export declare function readResponseBody(response: Response, as: 'json'): Promise<any>;
|
|
10
31
|
//# sourceMappingURL=responseUtil.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The default `TimecodeScale` (1ms in nanoseconds) when none is present. */
|
|
2
|
+
export declare const DEFAULT_WEBM_TIMECODE_SCALE = 1000000;
|
|
3
|
+
export interface WebmInitInfo {
|
|
4
|
+
/**
|
|
5
|
+
* The absolute byte offset (in the file) where the `Segment` element's
|
|
6
|
+
* content begins. `CueClusterPosition` values are relative to this.
|
|
7
|
+
*/
|
|
8
|
+
readonly segmentDataStart: number;
|
|
9
|
+
/**
|
|
10
|
+
* The `Segment` content size in bytes, or `null` if encoded as unknown.
|
|
11
|
+
*/
|
|
12
|
+
readonly segmentSize: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* The `TimecodeScale` in nanoseconds per tick (cue times are in these ticks).
|
|
15
|
+
*/
|
|
16
|
+
readonly timecodeScale: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parses a WebM initialization segment for the `Segment` data offset and
|
|
20
|
+
* `TimecodeScale`. The init segment is everything before the first `Cluster`
|
|
21
|
+
* (EBML header, `Segment` header, `SeekHead`, `Info`, `Tracks`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseWebmInit(buffer: ArrayBuffer): WebmInitInfo;
|
|
24
|
+
/**
|
|
25
|
+
* A single WebM cue point: a cluster's start time and its byte offset relative
|
|
26
|
+
* to the `Segment` data start.
|
|
27
|
+
*/
|
|
28
|
+
export interface WebmCuePoint {
|
|
29
|
+
/**
|
|
30
|
+
* The cluster's start time, in `TimecodeScale` ticks.
|
|
31
|
+
*/
|
|
32
|
+
readonly time: number;
|
|
33
|
+
/**
|
|
34
|
+
* The cluster's byte offset relative to the `Segment` data start.
|
|
35
|
+
*/
|
|
36
|
+
readonly clusterPosition: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Parses a WebM `Cues` element (as located by a DASH `SegmentBase@indexRange`)
|
|
40
|
+
* into its cue points, in order.
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseWebmCues(buffer: ArrayBuffer): readonly WebmCuePoint[];
|
|
43
|
+
//# sourceMappingURL=parseWebm.d.ts.map
|