@useupup/core 3.3.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/LICENSE +21 -0
- package/NOTICE +8 -0
- package/README.md +75 -0
- package/dist/browser-SXR426OQ.cjs +10 -0
- package/dist/browser-WD6T5ABJ.js +1 -0
- package/dist/chunk-2H5ICKFT.cjs +122 -0
- package/dist/chunk-6HF3I2JS.cjs +39 -0
- package/dist/chunk-6S5DQDQH.js +212 -0
- package/dist/chunk-BMQC27OE.cjs +92 -0
- package/dist/chunk-BSGQGINR.cjs +219 -0
- package/dist/chunk-CPKZ2CXD.cjs +179 -0
- package/dist/chunk-DTKDIMKT.cjs +573 -0
- package/dist/chunk-DYE5XJ6Z.cjs +2134 -0
- package/dist/chunk-E3ZCNOXG.cjs +74 -0
- package/dist/chunk-FEQY2WYY.cjs +2377 -0
- package/dist/chunk-FMURBCZ7.js +120 -0
- package/dist/chunk-FYQQRULL.js +37 -0
- package/dist/chunk-GE4LIVXP.js +133 -0
- package/dist/chunk-HFR5HZJZ.js +56 -0
- package/dist/chunk-I7ULPCA2.js +72 -0
- package/dist/chunk-MHYXDLZR.js +569 -0
- package/dist/chunk-N2SLHVAW.cjs +61 -0
- package/dist/chunk-OOPDEOTM.js +169 -0
- package/dist/chunk-PMBR3OUW.js +2359 -0
- package/dist/chunk-QK7HZIVY.cjs +144 -0
- package/dist/chunk-T2AQHY7V.cjs +59 -0
- package/dist/chunk-TRCP5FUR.js +90 -0
- package/dist/chunk-U7KL5M2H.cjs +374 -0
- package/dist/chunk-UXNPM54W.js +2108 -0
- package/dist/chunk-VV6QCQLL.js +365 -0
- package/dist/chunk-ZMS2HXLB.js +56 -0
- package/dist/context-shapes-123dd3b6.d.cts +207 -0
- package/dist/context-shapes-27b24c8f.d.ts +207 -0
- package/dist/contracts-pipeline-cf177270.d.cts +78 -0
- package/dist/contracts-pipeline-cf177270.d.ts +78 -0
- package/dist/contracts-strategies-378a16b7.d.cts +168 -0
- package/dist/contracts-strategies-378a16b7.d.ts +168 -0
- package/dist/contracts.cjs +181 -0
- package/dist/contracts.d.cts +11 -0
- package/dist/contracts.d.ts +11 -0
- package/dist/contracts.js +4 -0
- package/dist/core-141335ac.d.ts +651 -0
- package/dist/core-bea2ceca.d.cts +651 -0
- package/dist/create-worker-provider-AA5SRII6.js +58 -0
- package/dist/create-worker-provider-KJNUSSTW.cjs +60 -0
- package/dist/eligibility-ONLNJ6FB.cjs +10 -0
- package/dist/eligibility-ULFC3E4G.js +8 -0
- package/dist/error-code-map-9c44a425.d.ts +62 -0
- package/dist/error-code-map-dd5becfa.d.cts +62 -0
- package/dist/i18n/index.cjs +90 -0
- package/dist/i18n/index.d.cts +3 -0
- package/dist/i18n/index.d.ts +3 -0
- package/dist/i18n/index.js +1 -0
- package/dist/index.cjs +1770 -0
- package/dist/index.d.cts +280 -0
- package/dist/index.d.ts +280 -0
- package/dist/index.js +1589 -0
- package/dist/internal.cjs +2407 -0
- package/dist/internal.d.cts +595 -0
- package/dist/internal.d.ts +595 -0
- package/dist/internal.js +2275 -0
- package/dist/pipeline/index.cjs +10 -0
- package/dist/pipeline/index.d.cts +11 -0
- package/dist/pipeline/index.d.ts +11 -0
- package/dist/pipeline/index.js +1 -0
- package/dist/pipeline-worker.cjs +199 -0
- package/dist/pipeline-worker.d.cts +2 -0
- package/dist/pipeline-worker.d.ts +2 -0
- package/dist/pipeline-worker.js +197 -0
- package/dist/resolve-locale-81feef21.d.ts +20 -0
- package/dist/resolve-locale-9cb63600.d.cts +20 -0
- package/dist/resolve-theme-01758105.d.ts +53 -0
- package/dist/resolve-theme-66cf8d98.d.cts +53 -0
- package/dist/server-mode-drive-controller-b5f8ee12.d.cts +180 -0
- package/dist/server-mode-drive-controller-b5f8ee12.d.ts +180 -0
- package/dist/steps/compress.cjs +66 -0
- package/dist/steps/compress.d.cts +10 -0
- package/dist/steps/compress.d.ts +10 -0
- package/dist/steps/compress.js +64 -0
- package/dist/steps/exif.cjs +44 -0
- package/dist/steps/exif.d.cts +5 -0
- package/dist/steps/exif.d.ts +5 -0
- package/dist/steps/exif.js +42 -0
- package/dist/steps/hash.cjs +44 -0
- package/dist/steps/hash.d.cts +5 -0
- package/dist/steps/hash.d.ts +5 -0
- package/dist/steps/hash.js +42 -0
- package/dist/steps/heic.cjs +59 -0
- package/dist/steps/heic.d.cts +5 -0
- package/dist/steps/heic.d.ts +5 -0
- package/dist/steps/heic.js +57 -0
- package/dist/steps/thumbnail.cjs +54 -0
- package/dist/steps/thumbnail.d.cts +10 -0
- package/dist/steps/thumbnail.d.ts +10 -0
- package/dist/steps/thumbnail.js +52 -0
- package/dist/strategies/index.cjs +82 -0
- package/dist/strategies/index.d.cts +187 -0
- package/dist/strategies/index.d.ts +187 -0
- package/dist/strategies/index.js +60 -0
- package/dist/strategies/tus-upload.cjs +14 -0
- package/dist/strategies/tus-upload.d.cts +15 -0
- package/dist/strategies/tus-upload.d.ts +15 -0
- package/dist/strategies/tus-upload.js +5 -0
- package/dist/theme/index.cjs +38 -0
- package/dist/theme/index.d.cts +3 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +1 -0
- package/dist/theme-store-2e56a674.d.cts +39 -0
- package/dist/theme-store-f13e0315.d.ts +39 -0
- package/dist/token-endpoint-5fdb4a35.d.ts +20 -0
- package/dist/token-endpoint-a7d15ab6.d.cts +20 -0
- package/dist/ui-translations-c5d00392.d.cts +455 -0
- package/dist/ui-translations-c5d00392.d.ts +455 -0
- package/dist/uploader-props-72242002.d.ts +340 -0
- package/dist/uploader-props-7f956e60.d.cts +340 -0
- package/dist/vars-d3421f6c.d.cts +240 -0
- package/dist/vars-d3421f6c.d.ts +240 -0
- package/package.json +182 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/steps/hash.ts
|
|
2
|
+
async function computeSHA256(buffer) {
|
|
3
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", buffer);
|
|
4
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
5
|
+
return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6
|
+
}
|
|
7
|
+
function hashStep() {
|
|
8
|
+
return {
|
|
9
|
+
name: "hash",
|
|
10
|
+
async process(file, context) {
|
|
11
|
+
if (context.worker) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await context.worker.execute({
|
|
14
|
+
type: "hash",
|
|
15
|
+
data: await file.arrayBuffer()
|
|
16
|
+
});
|
|
17
|
+
if (result.kind === "hash") {
|
|
18
|
+
file.metadata = {
|
|
19
|
+
...file.metadata,
|
|
20
|
+
checksum: result.checksum,
|
|
21
|
+
originalContentHash: result.checksum
|
|
22
|
+
};
|
|
23
|
+
return Object.assign(file, {
|
|
24
|
+
checksumSHA256: result.checksum
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const buffer = await file.arrayBuffer();
|
|
31
|
+
const hash = await computeSHA256(buffer);
|
|
32
|
+
file.metadata = {
|
|
33
|
+
...file.metadata,
|
|
34
|
+
checksum: hash,
|
|
35
|
+
originalContentHash: hash
|
|
36
|
+
};
|
|
37
|
+
return Object.assign(file, { checksumSHA256: hash });
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { hashStep };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkE3ZCNOXG_cjs = require('../chunk-E3ZCNOXG.cjs');
|
|
4
|
+
var chunkBSGQGINR_cjs = require('../chunk-BSGQGINR.cjs');
|
|
5
|
+
require('../chunk-QK7HZIVY.cjs');
|
|
6
|
+
|
|
7
|
+
// src/steps/heic.ts
|
|
8
|
+
function jpegName(name) {
|
|
9
|
+
if (/\.(heic|heif)$/i.test(name))
|
|
10
|
+
return name.replace(/\.(heic|heif)$/i, ".jpg");
|
|
11
|
+
return `${name}.jpg`;
|
|
12
|
+
}
|
|
13
|
+
function heicStep() {
|
|
14
|
+
return {
|
|
15
|
+
name: "heic",
|
|
16
|
+
shouldProcess: (file) => file.type === "image/heic" || file.type === "image/heif" || /\.(heic|heif)$/i.test(file.name),
|
|
17
|
+
async process(file, context) {
|
|
18
|
+
if (context.worker) {
|
|
19
|
+
try {
|
|
20
|
+
const result = await context.worker.execute({
|
|
21
|
+
type: "heic",
|
|
22
|
+
data: await file.arrayBuffer(),
|
|
23
|
+
params: { mime: file.type, name: file.name }
|
|
24
|
+
});
|
|
25
|
+
if (result.kind === "image")
|
|
26
|
+
return chunkBSGQGINR_cjs.uploadFileFromImageResult(file, result);
|
|
27
|
+
} catch {
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const blob = await chunkE3ZCNOXG_cjs.heicToJpegBlob(file, { quality: 0.92 });
|
|
32
|
+
if (!blob) return file;
|
|
33
|
+
const converted = new File([blob], jpegName(file.name), {
|
|
34
|
+
type: "image/jpeg",
|
|
35
|
+
lastModified: file.lastModified
|
|
36
|
+
});
|
|
37
|
+
return chunkBSGQGINR_cjs.cloneUploadFile(file, converted, {
|
|
38
|
+
originalSize: file.size,
|
|
39
|
+
processedSize: converted.size,
|
|
40
|
+
heicConverted: true
|
|
41
|
+
});
|
|
42
|
+
} catch (err) {
|
|
43
|
+
context.emit("pipeline-error", {
|
|
44
|
+
scope: "heic",
|
|
45
|
+
name: file.name,
|
|
46
|
+
message: err instanceof Error ? err.message : String(err)
|
|
47
|
+
});
|
|
48
|
+
console.error(
|
|
49
|
+
"[upup] HEIC conversion failed for",
|
|
50
|
+
file.name,
|
|
51
|
+
err
|
|
52
|
+
);
|
|
53
|
+
return file;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.heicStep = heicStep;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { heicToJpegBlob } from '../chunk-I7ULPCA2.js';
|
|
2
|
+
import { uploadFileFromImageResult, cloneUploadFile } from '../chunk-6S5DQDQH.js';
|
|
3
|
+
import '../chunk-GE4LIVXP.js';
|
|
4
|
+
|
|
5
|
+
// src/steps/heic.ts
|
|
6
|
+
function jpegName(name) {
|
|
7
|
+
if (/\.(heic|heif)$/i.test(name))
|
|
8
|
+
return name.replace(/\.(heic|heif)$/i, ".jpg");
|
|
9
|
+
return `${name}.jpg`;
|
|
10
|
+
}
|
|
11
|
+
function heicStep() {
|
|
12
|
+
return {
|
|
13
|
+
name: "heic",
|
|
14
|
+
shouldProcess: (file) => file.type === "image/heic" || file.type === "image/heif" || /\.(heic|heif)$/i.test(file.name),
|
|
15
|
+
async process(file, context) {
|
|
16
|
+
if (context.worker) {
|
|
17
|
+
try {
|
|
18
|
+
const result = await context.worker.execute({
|
|
19
|
+
type: "heic",
|
|
20
|
+
data: await file.arrayBuffer(),
|
|
21
|
+
params: { mime: file.type, name: file.name }
|
|
22
|
+
});
|
|
23
|
+
if (result.kind === "image")
|
|
24
|
+
return uploadFileFromImageResult(file, result);
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const blob = await heicToJpegBlob(file, { quality: 0.92 });
|
|
30
|
+
if (!blob) return file;
|
|
31
|
+
const converted = new File([blob], jpegName(file.name), {
|
|
32
|
+
type: "image/jpeg",
|
|
33
|
+
lastModified: file.lastModified
|
|
34
|
+
});
|
|
35
|
+
return cloneUploadFile(file, converted, {
|
|
36
|
+
originalSize: file.size,
|
|
37
|
+
processedSize: converted.size,
|
|
38
|
+
heicConverted: true
|
|
39
|
+
});
|
|
40
|
+
} catch (err) {
|
|
41
|
+
context.emit("pipeline-error", {
|
|
42
|
+
scope: "heic",
|
|
43
|
+
name: file.name,
|
|
44
|
+
message: err instanceof Error ? err.message : String(err)
|
|
45
|
+
});
|
|
46
|
+
console.error(
|
|
47
|
+
"[upup] HEIC conversion failed for",
|
|
48
|
+
file.name,
|
|
49
|
+
err
|
|
50
|
+
);
|
|
51
|
+
return file;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { heicStep };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkBSGQGINR_cjs = require('../chunk-BSGQGINR.cjs');
|
|
4
|
+
require('../chunk-QK7HZIVY.cjs');
|
|
5
|
+
|
|
6
|
+
// src/steps/thumbnail.ts
|
|
7
|
+
function thumbnailStep(_options) {
|
|
8
|
+
return {
|
|
9
|
+
name: "thumbnail",
|
|
10
|
+
shouldProcess: (file) => file.type.startsWith("image/"),
|
|
11
|
+
async process(file, context) {
|
|
12
|
+
if (!file.type.startsWith("image/")) return file;
|
|
13
|
+
if (context.worker) {
|
|
14
|
+
try {
|
|
15
|
+
const result = await context.worker.execute({
|
|
16
|
+
type: "thumbnail",
|
|
17
|
+
data: await file.arrayBuffer(),
|
|
18
|
+
params: {
|
|
19
|
+
mime: file.type,
|
|
20
|
+
name: file.name,
|
|
21
|
+
maxWidthOrHeight: _options?.width,
|
|
22
|
+
quality: _options?.quality
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
if (result.kind === "thumbnail") {
|
|
26
|
+
file.metadata = {
|
|
27
|
+
...file.metadata,
|
|
28
|
+
thumbnailUrl: result.thumbnailUrl
|
|
29
|
+
};
|
|
30
|
+
file.thumbnail = {
|
|
31
|
+
file: new File([result.bytes], result.name, {
|
|
32
|
+
type: result.type,
|
|
33
|
+
lastModified: file.lastModified
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
return file;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const thumbnail = await chunkBSGQGINR_cjs.createThumbnail(file, _options);
|
|
42
|
+
if (!thumbnail) return file;
|
|
43
|
+
file.metadata = {
|
|
44
|
+
...file.metadata,
|
|
45
|
+
thumbnailUrl: thumbnail.dataUrl
|
|
46
|
+
};
|
|
47
|
+
const fileRecord = file;
|
|
48
|
+
fileRecord.thumbnail = { file: thumbnail.file };
|
|
49
|
+
return file;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.thumbnailStep = thumbnailStep;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { P as PipelineStep } from '../contracts-pipeline-cf177270.cjs';
|
|
2
|
+
|
|
3
|
+
interface ThumbnailGeneratorOptions {
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
quality?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function thumbnailStep(_options?: ThumbnailGeneratorOptions): PipelineStep;
|
|
9
|
+
|
|
10
|
+
export { type ThumbnailGeneratorOptions, thumbnailStep };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { P as PipelineStep } from '../contracts-pipeline-cf177270.js';
|
|
2
|
+
|
|
3
|
+
interface ThumbnailGeneratorOptions {
|
|
4
|
+
width?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
quality?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function thumbnailStep(_options?: ThumbnailGeneratorOptions): PipelineStep;
|
|
9
|
+
|
|
10
|
+
export { type ThumbnailGeneratorOptions, thumbnailStep };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createThumbnail } from '../chunk-6S5DQDQH.js';
|
|
2
|
+
import '../chunk-GE4LIVXP.js';
|
|
3
|
+
|
|
4
|
+
// src/steps/thumbnail.ts
|
|
5
|
+
function thumbnailStep(_options) {
|
|
6
|
+
return {
|
|
7
|
+
name: "thumbnail",
|
|
8
|
+
shouldProcess: (file) => file.type.startsWith("image/"),
|
|
9
|
+
async process(file, context) {
|
|
10
|
+
if (!file.type.startsWith("image/")) return file;
|
|
11
|
+
if (context.worker) {
|
|
12
|
+
try {
|
|
13
|
+
const result = await context.worker.execute({
|
|
14
|
+
type: "thumbnail",
|
|
15
|
+
data: await file.arrayBuffer(),
|
|
16
|
+
params: {
|
|
17
|
+
mime: file.type,
|
|
18
|
+
name: file.name,
|
|
19
|
+
maxWidthOrHeight: _options?.width,
|
|
20
|
+
quality: _options?.quality
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
if (result.kind === "thumbnail") {
|
|
24
|
+
file.metadata = {
|
|
25
|
+
...file.metadata,
|
|
26
|
+
thumbnailUrl: result.thumbnailUrl
|
|
27
|
+
};
|
|
28
|
+
file.thumbnail = {
|
|
29
|
+
file: new File([result.bytes], result.name, {
|
|
30
|
+
type: result.type,
|
|
31
|
+
lastModified: file.lastModified
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
return file;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const thumbnail = await createThumbnail(file, _options);
|
|
40
|
+
if (!thumbnail) return file;
|
|
41
|
+
file.metadata = {
|
|
42
|
+
...file.metadata,
|
|
43
|
+
thumbnailUrl: thumbnail.dataUrl
|
|
44
|
+
};
|
|
45
|
+
const fileRecord = file;
|
|
46
|
+
fileRecord.thumbnail = { file: thumbnail.file };
|
|
47
|
+
return file;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { thumbnailStep };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDTKDIMKT_cjs = require('../chunk-DTKDIMKT.cjs');
|
|
4
|
+
var chunkCPKZ2CXD_cjs = require('../chunk-CPKZ2CXD.cjs');
|
|
5
|
+
var chunkBMQC27OE_cjs = require('../chunk-BMQC27OE.cjs');
|
|
6
|
+
require('../chunk-N2SLHVAW.cjs');
|
|
7
|
+
var chunkQK7HZIVY_cjs = require('../chunk-QK7HZIVY.cjs');
|
|
8
|
+
require('../chunk-DYE5XJ6Z.cjs');
|
|
9
|
+
require('../chunk-U7KL5M2H.cjs');
|
|
10
|
+
|
|
11
|
+
// src/strategies/server-transfer.ts
|
|
12
|
+
var ServerTransfer = class {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.serverUrl = options.serverUrl.replace(/\/$/, "");
|
|
15
|
+
this.headers = {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
...options.headers
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
providerSlug(provider) {
|
|
21
|
+
switch (provider) {
|
|
22
|
+
case "googleDrive":
|
|
23
|
+
return "google-drive";
|
|
24
|
+
case "oneDrive":
|
|
25
|
+
return "one-drive";
|
|
26
|
+
case "dropbox":
|
|
27
|
+
return "dropbox";
|
|
28
|
+
case "box":
|
|
29
|
+
return "box";
|
|
30
|
+
default:
|
|
31
|
+
return provider;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async transfer(provider, fileId, options) {
|
|
35
|
+
const slug = this.providerSlug(provider);
|
|
36
|
+
const response = await fetch(
|
|
37
|
+
`${this.serverUrl}/files/${slug}/transfer`,
|
|
38
|
+
{
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: this.headers,
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
fileId,
|
|
43
|
+
fileName: options?.fileName,
|
|
44
|
+
token: options?.token
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
const body = await response.text().catch(() => "");
|
|
50
|
+
const err = chunkQK7HZIVY_cjs.uploadErrorFromResponse({
|
|
51
|
+
status: response.status,
|
|
52
|
+
statusText: response.statusText,
|
|
53
|
+
body,
|
|
54
|
+
kind: "network"
|
|
55
|
+
});
|
|
56
|
+
throw err;
|
|
57
|
+
}
|
|
58
|
+
return response.json();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
Object.defineProperty(exports, 'MultipartUpload', {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () { return chunkDTKDIMKT_cjs.MultipartUpload; }
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, 'ServerCredentials', {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function () { return chunkDTKDIMKT_cjs.ServerCredentials; }
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(exports, 'DirectUpload', {
|
|
71
|
+
enumerable: true,
|
|
72
|
+
get: function () { return chunkCPKZ2CXD_cjs.DirectUpload; }
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(exports, 'TokenEndpointCredentials', {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () { return chunkCPKZ2CXD_cjs.TokenEndpointCredentials; }
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, 'TusUpload', {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function () { return chunkBMQC27OE_cjs.TusUpload; }
|
|
81
|
+
});
|
|
82
|
+
exports.ServerTransfer = ServerTransfer;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { k as CredentialStrategy, F as FileMetadata, P as PresignedUrlResponse, a as MultipartInitResponse, b as MultipartSignPartResponse, f as MultipartCompleteResponse, e as MultipartResumeResponse, l as UploadStrategy, U as UploadCredentials, h as UploadResult, j as CloudProvider } from '../contracts-strategies-378a16b7.cjs';
|
|
2
|
+
export { i as ProgressInfo, m as RuntimeAdapter } from '../contracts-strategies-378a16b7.cjs';
|
|
3
|
+
export { D as DirectUpload, T as TokenEndpointCredentials } from '../token-endpoint-a7d15ab6.cjs';
|
|
4
|
+
export { TusUpload } from './tus-upload.cjs';
|
|
5
|
+
|
|
6
|
+
interface ServerCredentialsOptions {
|
|
7
|
+
serverUrl: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
declare class ServerCredentials implements CredentialStrategy {
|
|
11
|
+
private serverUrl;
|
|
12
|
+
private headers;
|
|
13
|
+
constructor(options: ServerCredentialsOptions);
|
|
14
|
+
private post;
|
|
15
|
+
getPresignedUrl(file: FileMetadata): Promise<PresignedUrlResponse>;
|
|
16
|
+
initMultipartUpload(file: FileMetadata): Promise<MultipartInitResponse>;
|
|
17
|
+
signPart(params: {
|
|
18
|
+
token: string;
|
|
19
|
+
partNumber: number;
|
|
20
|
+
}): Promise<MultipartSignPartResponse>;
|
|
21
|
+
completeMultipartUpload(params: {
|
|
22
|
+
token: string;
|
|
23
|
+
parts: {
|
|
24
|
+
partNumber: number;
|
|
25
|
+
eTag: string;
|
|
26
|
+
}[];
|
|
27
|
+
}): Promise<MultipartCompleteResponse>;
|
|
28
|
+
abortMultipartUpload(params: {
|
|
29
|
+
token: string;
|
|
30
|
+
}): Promise<void>;
|
|
31
|
+
/** Re-attach to an upload the client left in flight (page reload, pause,
|
|
32
|
+
* retry) or whose token aged past its 1h TTL. The presented token is the
|
|
33
|
+
* ONLY input — key/uploadId are never sent by the client — and the
|
|
34
|
+
* response carries a freshly-signed replacement plus the parts storage
|
|
35
|
+
* already holds, each with its byte size. */
|
|
36
|
+
resumeMultipartUpload(params: {
|
|
37
|
+
token: string;
|
|
38
|
+
}): Promise<MultipartResumeResponse>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface MultipartUploadOptions {
|
|
42
|
+
credentials: CredentialStrategy;
|
|
43
|
+
chunkSizeBytes?: number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Parts of this one file in flight at once. Throughput on a fast link
|
|
46
|
+
* against memory and socket pressure — every in-flight part holds its own
|
|
47
|
+
* chunk. Clamped to a whole number ≥ 1 — the cap is a count of live
|
|
48
|
+
* requests, and a run with none in flight can never finish.
|
|
49
|
+
*/
|
|
50
|
+
maxConcurrentParts?: number | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Persist a resumable session (localStorage) for `File` inputs, so a page
|
|
53
|
+
* reload, a pause, or a retry re-attaches to the server-side upload rather
|
|
54
|
+
* than restarting it from part 1.
|
|
55
|
+
*
|
|
56
|
+
* Defaults to FALSE here on purpose: `resolveUploadConfig` is the single
|
|
57
|
+
* place that opts the product default in (`resumable.persist ?? true`), so
|
|
58
|
+
* a hand-constructed strategy keeps the historical abort-on-failure
|
|
59
|
+
* semantics until it explicitly asks for persistence.
|
|
60
|
+
*/
|
|
61
|
+
persist?: boolean | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* The serverUrl sessions belong to. A session saved against server A must
|
|
64
|
+
* never be resumed against server B — its token means nothing there.
|
|
65
|
+
*/
|
|
66
|
+
sessionScope?: string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Delays (ms) before each successive retry of a part whose attempt failed
|
|
69
|
+
* transiently — a network-level fetch rejection, a 429, a 5xx, or a stall
|
|
70
|
+
* caught by `partTimeoutMs`. Same vocabulary as the tus strategy's
|
|
71
|
+
* `retryDelays`: the array length is the retry budget, `[]` disables part
|
|
72
|
+
* retries. Definitive 4xx rejections are never retried.
|
|
73
|
+
*/
|
|
74
|
+
retryDelays?: number[] | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Watchdog budget applied to each PHASE of a part attempt separately: the
|
|
77
|
+
* sign call, the source read (parts small enough to be materialized —
|
|
78
|
+
* see MATERIALIZE_PART_MAX_BYTES), and the PUT, where it is an INACTIVITY
|
|
79
|
+
* window reset by upload progress. A phase that neither succeeds nor
|
|
80
|
+
* fails within its window is aborted and counted as a transient failure,
|
|
81
|
+
* so a hung connection or a hung blob read costs one `retryDelays` slot
|
|
82
|
+
* instead of hanging the whole upload forever (worst case per attempt is
|
|
83
|
+
* therefore up to 3 × this value, not 1 ×). A slow-but-progressing PUT is
|
|
84
|
+
* never aborted — only one with no forward motion at all.
|
|
85
|
+
*/
|
|
86
|
+
partTimeoutMs?: number | undefined;
|
|
87
|
+
}
|
|
88
|
+
declare class MultipartUpload implements UploadStrategy {
|
|
89
|
+
private credentials;
|
|
90
|
+
private initMultipartUpload;
|
|
91
|
+
private signPart;
|
|
92
|
+
private completeMultipartUpload;
|
|
93
|
+
private resumeMultipartUpload;
|
|
94
|
+
private chunkSizeBytes;
|
|
95
|
+
private maxConcurrentParts;
|
|
96
|
+
private persist;
|
|
97
|
+
private sessionScope;
|
|
98
|
+
private retryDelays;
|
|
99
|
+
private partTimeoutMs;
|
|
100
|
+
constructor(options: MultipartUploadOptions);
|
|
101
|
+
/**
|
|
102
|
+
* Each stored part must be byte-for-byte where this file's own chunking
|
|
103
|
+
* would put it: exactly `partSize`, except the file's TRUE final part
|
|
104
|
+
* (`partNumber === totalParts`), which must be exactly the remaining tail.
|
|
105
|
+
*
|
|
106
|
+
* The "highest part number we happen to hold" is NOT the exemption — the
|
|
107
|
+
* server may hold a sparse prefix (say parts 1, 2, 5 of 10), and letting
|
|
108
|
+
* part 5 be short would splice a short block into the MIDDLE of the object.
|
|
109
|
+
* S3 only enforces the ≥5 MiB floor on non-final parts, so it would accept
|
|
110
|
+
* the complete call and hand back a silently corrupt object. A part with no
|
|
111
|
+
* reported `size` is unverifiable and therefore equally unusable.
|
|
112
|
+
*/
|
|
113
|
+
private partsMatchSession;
|
|
114
|
+
/**
|
|
115
|
+
* Try to re-attach to the upload a previous session left in flight.
|
|
116
|
+
* Returns `null` for every "just start fresh" outcome — a resume failure
|
|
117
|
+
* must never fail an upload that a fresh init could still serve.
|
|
118
|
+
*/
|
|
119
|
+
private tryResume;
|
|
120
|
+
/**
|
|
121
|
+
* Failure teardown. THE behavior change of cross-reload resume: with
|
|
122
|
+
* `persist` on, an error or abort deliberately leaves the server-side
|
|
123
|
+
* upload alive so the next attempt can resume into it — pause(), a dropped
|
|
124
|
+
* connection, and UploadManager's own retries all re-enter `upload()` and
|
|
125
|
+
* pick the session back up. Without persist this is exactly the historical
|
|
126
|
+
* best-effort abort. Either way, a 4xx from init/complete kills the
|
|
127
|
+
* session: the server has already torn the upload down.
|
|
128
|
+
*/
|
|
129
|
+
private handleUploadFailure;
|
|
130
|
+
/**
|
|
131
|
+
* PUT one signed part over XMLHttpRequest, under an INACTIVITY watchdog.
|
|
132
|
+
*
|
|
133
|
+
* The watchdog resets on every `upload` progress event and fires only after
|
|
134
|
+
* `partTimeoutMs` with no forward motion at all. That distinction is the
|
|
135
|
+
* point: `fetch()` for a PUT resolves only once the whole body is sent, so a
|
|
136
|
+
* flat ceiling on total time aborts a large part on a slow-but-healthy link
|
|
137
|
+
* (a 5 MiB part under ~233 kbit/s crosses the 180s default) even though it
|
|
138
|
+
* is uploading fine. An inactivity timer kills the connection the watchdog
|
|
139
|
+
* was built for — one that has genuinely stopped moving bytes — without
|
|
140
|
+
* penalizing the slow one. Mirrors the XHR PUT in direct-upload.ts.
|
|
141
|
+
*
|
|
142
|
+
* Resolves with the part's ETag. Rejects with: the retryable stall on
|
|
143
|
+
* inactivity (`partStallError`) — covering both the slice READ and the PUT;
|
|
144
|
+
* a retryable `UPLOAD_FAILED` when the slice read itself rejects;
|
|
145
|
+
* `UpupNetworkError('Upload aborted')` when
|
|
146
|
+
* the caller's signal aborts; a retryable `TypeError` on a network-level
|
|
147
|
+
* failure (the shape `fetch` produced, which `isRetryablePartFailure`
|
|
148
|
+
* already classifies); or an `uploadErrorFromResponse` on a non-2xx — its
|
|
149
|
+
* body read synchronously from `xhr.responseText`, so the whole request
|
|
150
|
+
* including the error body stays inside the one abort/inactivity window (the
|
|
151
|
+
* old `await response.text()` ran AFTER the watchdog was cleared and could
|
|
152
|
+
* hang a half-dead connection forever on the body read).
|
|
153
|
+
*/
|
|
154
|
+
private putPart;
|
|
155
|
+
upload(file: File | Blob, _credentials: UploadCredentials, options: {
|
|
156
|
+
onProgress: (loaded: number, total: number) => void;
|
|
157
|
+
signal: AbortSignal;
|
|
158
|
+
}): Promise<UploadResult>;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface ServerTransferOptions {
|
|
162
|
+
serverUrl: string;
|
|
163
|
+
headers?: Record<string, string>;
|
|
164
|
+
}
|
|
165
|
+
interface TransferResult {
|
|
166
|
+
provider: string;
|
|
167
|
+
fileId: string;
|
|
168
|
+
status: string;
|
|
169
|
+
key?: string;
|
|
170
|
+
url?: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Strategy that POSTs to the server's /files/:provider/transfer endpoint
|
|
174
|
+
* to transfer a file from a cloud drive directly to S3 on the server side.
|
|
175
|
+
*/
|
|
176
|
+
declare class ServerTransfer {
|
|
177
|
+
private serverUrl;
|
|
178
|
+
private headers;
|
|
179
|
+
constructor(options: ServerTransferOptions);
|
|
180
|
+
private providerSlug;
|
|
181
|
+
transfer(provider: CloudProvider, fileId: string, options?: {
|
|
182
|
+
token?: string;
|
|
183
|
+
fileName?: string;
|
|
184
|
+
}): Promise<TransferResult>;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export { CloudProvider, CredentialStrategy, FileMetadata, MultipartUpload, ServerCredentials, ServerTransfer, UploadCredentials, UploadResult, UploadStrategy };
|