11import { Base64 } from 'js-base64'
2- // @ts -ignore
2+ // TODO: Package url-parse is CommonJS. Can we replace this with a ESM package that
3+ // provides WHATWG URL? Then we can get rid of @rollup/plugin-commonjs.
34import URL from 'url-parse'
45import { DetailedError } from './DetailedError.js'
56import { StallDetector } from './StallDetector.js'
@@ -11,15 +12,13 @@ import {
1112 PROTOCOL_IETF_DRAFT_03 ,
1213 PROTOCOL_IETF_DRAFT_05 ,
1314 PROTOCOL_TUS_V1 ,
14- type Part ,
1515 type PreviousUpload ,
1616 type SliceType ,
1717 type UploadInput ,
1818 type UploadOptions ,
1919} from './options.js'
2020import { uuid } from './uuid.js'
2121
22- // Add this type definition after the imports
2322interface ExtendedHttpRequest extends HttpRequest {
2423 _upload ?: BaseUpload
2524}
@@ -33,17 +32,17 @@ export const defaultOptions = {
3332 fingerprint : undefined ,
3433 uploadSize : undefined ,
3534
36- onProgress : null ,
37- onChunkComplete : null ,
38- onSuccess : null ,
39- onError : null ,
40- onUploadUrlAvailable : null ,
35+ onProgress : undefined ,
36+ onChunkComplete : undefined ,
37+ onSuccess : undefined ,
38+ onError : undefined ,
39+ onUploadUrlAvailable : undefined ,
4140
4241 overridePatchMethod : false ,
4342 headers : { } ,
4443 addRequestId : false ,
45- onBeforeRequest : null ,
46- onAfterResponse : null ,
44+ onBeforeRequest : undefined ,
45+ onAfterResponse : undefined ,
4746 onShouldRetry : defaultOnShouldRetry ,
4847
4948 chunkSize : Number . POSITIVE_INFINITY ,
@@ -1245,6 +1244,8 @@ function resolveUrl(origin: string, link: string): string {
12451244 return new URL ( link , origin ) . toString ( )
12461245}
12471246
1247+ type Part = { start : number ; end : number }
1248+
12481249/**
12491250 * Calculate the start and end positions for the parts if an upload
12501251 * is split into multiple parallel requests.
0 commit comments