@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,11 @@
|
|
|
1
|
+
import { P as PipelineStep, a as UploadFile, d as PipelineContext } from '../contracts-pipeline-cf177270.cjs';
|
|
2
|
+
|
|
3
|
+
declare class PipelineEngine {
|
|
4
|
+
private steps;
|
|
5
|
+
constructor(steps: PipelineStep[]);
|
|
6
|
+
get stepCount(): number;
|
|
7
|
+
process(file: UploadFile, context: PipelineContext): Promise<UploadFile>;
|
|
8
|
+
processAll(files: UploadFile[], context: PipelineContext): Promise<UploadFile[]>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { PipelineEngine };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { P as PipelineStep, a as UploadFile, d as PipelineContext } from '../contracts-pipeline-cf177270.js';
|
|
2
|
+
|
|
3
|
+
declare class PipelineEngine {
|
|
4
|
+
private steps;
|
|
5
|
+
constructor(steps: PipelineStep[]);
|
|
6
|
+
get stepCount(): number;
|
|
7
|
+
process(file: UploadFile, context: PipelineContext): Promise<UploadFile>;
|
|
8
|
+
processAll(files: UploadFile[], context: PipelineContext): Promise<UploadFile[]>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { PipelineEngine };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PipelineEngine } from '../chunk-FYQQRULL.js';
|
|
@@ -0,0 +1,199 @@
|
|
|
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/worker/handle-task.ts
|
|
8
|
+
async function sha256Hex(buffer) {
|
|
9
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
10
|
+
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
11
|
+
}
|
|
12
|
+
function asUploadFile(data, mime, name) {
|
|
13
|
+
const file = new File([data], name, { type: mime });
|
|
14
|
+
return Object.assign(file, {
|
|
15
|
+
id: "worker",
|
|
16
|
+
metadata: {}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function jpegName(name) {
|
|
20
|
+
if (/\.(heic|heif)$/i.test(name))
|
|
21
|
+
return name.replace(/\.(heic|heif)$/i, ".jpg");
|
|
22
|
+
return `${name}.jpg`;
|
|
23
|
+
}
|
|
24
|
+
async function toImageResult(processed) {
|
|
25
|
+
if (!processed) return null;
|
|
26
|
+
const bytes = await processed.arrayBuffer();
|
|
27
|
+
return {
|
|
28
|
+
kind: "image",
|
|
29
|
+
bytes,
|
|
30
|
+
type: processed.type,
|
|
31
|
+
name: processed.name,
|
|
32
|
+
metadata: processed.metadata
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
async function handleTask(req) {
|
|
36
|
+
try {
|
|
37
|
+
const params = req.params ?? {};
|
|
38
|
+
const mime = params.mime || "application/octet-stream";
|
|
39
|
+
const name = params.name || "file";
|
|
40
|
+
switch (req.type) {
|
|
41
|
+
case "hash": {
|
|
42
|
+
const checksum = await sha256Hex(req.data);
|
|
43
|
+
return {
|
|
44
|
+
id: req.id,
|
|
45
|
+
ok: true,
|
|
46
|
+
result: { kind: "hash", checksum }
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
case "heic": {
|
|
50
|
+
const blob = await chunkE3ZCNOXG_cjs.heicToJpegBlob(
|
|
51
|
+
new Blob([req.data], { type: mime }),
|
|
52
|
+
{ quality: 0.92 }
|
|
53
|
+
);
|
|
54
|
+
if (!blob)
|
|
55
|
+
return {
|
|
56
|
+
id: req.id,
|
|
57
|
+
ok: false,
|
|
58
|
+
error: "heic: no decode backend"
|
|
59
|
+
};
|
|
60
|
+
const bytes = await blob.arrayBuffer();
|
|
61
|
+
return {
|
|
62
|
+
id: req.id,
|
|
63
|
+
ok: true,
|
|
64
|
+
result: {
|
|
65
|
+
kind: "image",
|
|
66
|
+
bytes,
|
|
67
|
+
type: "image/jpeg",
|
|
68
|
+
name: jpegName(name),
|
|
69
|
+
metadata: {
|
|
70
|
+
heicConverted: true,
|
|
71
|
+
originalSize: req.data.byteLength,
|
|
72
|
+
processedSize: bytes.byteLength
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
case "exif": {
|
|
78
|
+
const processed = await chunkBSGQGINR_cjs.encodeImageFile(
|
|
79
|
+
asUploadFile(req.data, mime, name),
|
|
80
|
+
{
|
|
81
|
+
type: mime || "image/jpeg",
|
|
82
|
+
quality: 0.92,
|
|
83
|
+
metadata: { exifStripped: true }
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
const result = await toImageResult(processed);
|
|
87
|
+
if (!result)
|
|
88
|
+
return {
|
|
89
|
+
id: req.id,
|
|
90
|
+
ok: false,
|
|
91
|
+
error: "exif: encode failed"
|
|
92
|
+
};
|
|
93
|
+
if (result.metadata)
|
|
94
|
+
result.metadata.processedSize = result.bytes.byteLength;
|
|
95
|
+
return { id: req.id, ok: true, result };
|
|
96
|
+
}
|
|
97
|
+
case "compress": {
|
|
98
|
+
const file = asUploadFile(req.data, mime, name);
|
|
99
|
+
const maxWidthOrHeight = params.maxWidthOrHeight ?? 1920;
|
|
100
|
+
const maxBytes = typeof params.maxSizeMB === "number" ? params.maxSizeMB * 1024 * 1024 : void 0;
|
|
101
|
+
let quality = params.quality ?? 0.82;
|
|
102
|
+
let processed = await chunkBSGQGINR_cjs.encodeImageFile(file, {
|
|
103
|
+
maxWidthOrHeight,
|
|
104
|
+
quality,
|
|
105
|
+
metadata: {
|
|
106
|
+
originalSize: req.data.byteLength,
|
|
107
|
+
compressed: true
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
while (processed && maxBytes && processed.size > maxBytes && quality > 0.35) {
|
|
111
|
+
quality = Math.max(0.35, quality - 0.12);
|
|
112
|
+
processed = await chunkBSGQGINR_cjs.encodeImageFile(file, {
|
|
113
|
+
maxWidthOrHeight,
|
|
114
|
+
quality,
|
|
115
|
+
metadata: {
|
|
116
|
+
originalSize: req.data.byteLength,
|
|
117
|
+
compressed: true
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
if (!processed)
|
|
122
|
+
return {
|
|
123
|
+
id: req.id,
|
|
124
|
+
ok: false,
|
|
125
|
+
error: "compress: encode failed"
|
|
126
|
+
};
|
|
127
|
+
if (processed.size >= req.data.byteLength && !maxBytes && !params.maxWidthOrHeight) {
|
|
128
|
+
return {
|
|
129
|
+
id: req.id,
|
|
130
|
+
ok: true,
|
|
131
|
+
result: {
|
|
132
|
+
kind: "image",
|
|
133
|
+
bytes: req.data,
|
|
134
|
+
type: mime,
|
|
135
|
+
name,
|
|
136
|
+
metadata: {}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const result = await toImageResult(processed);
|
|
141
|
+
if (!result)
|
|
142
|
+
return {
|
|
143
|
+
id: req.id,
|
|
144
|
+
ok: false,
|
|
145
|
+
error: "compress: encode failed"
|
|
146
|
+
};
|
|
147
|
+
if (result.metadata)
|
|
148
|
+
result.metadata.processedSize = result.bytes.byteLength;
|
|
149
|
+
return { id: req.id, ok: true, result };
|
|
150
|
+
}
|
|
151
|
+
case "thumbnail": {
|
|
152
|
+
const thumb = await chunkBSGQGINR_cjs.createThumbnail(
|
|
153
|
+
asUploadFile(req.data, mime, name),
|
|
154
|
+
{
|
|
155
|
+
...params.maxWidthOrHeight !== void 0 ? { width: params.maxWidthOrHeight } : {},
|
|
156
|
+
...params.quality !== void 0 ? { quality: params.quality } : {}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
if (!thumb)
|
|
160
|
+
return { id: req.id, ok: false, error: "thumbnail: failed" };
|
|
161
|
+
const bytes = await thumb.file.arrayBuffer();
|
|
162
|
+
return {
|
|
163
|
+
id: req.id,
|
|
164
|
+
ok: true,
|
|
165
|
+
result: {
|
|
166
|
+
kind: "thumbnail",
|
|
167
|
+
thumbnailUrl: thumb.dataUrl,
|
|
168
|
+
bytes,
|
|
169
|
+
type: thumb.file.type,
|
|
170
|
+
name: thumb.file.name
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
return {
|
|
176
|
+
id: req.id,
|
|
177
|
+
ok: false,
|
|
178
|
+
error: `unknown task type: ${req.type}`
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
} catch (e) {
|
|
182
|
+
return {
|
|
183
|
+
id: req.id,
|
|
184
|
+
ok: false,
|
|
185
|
+
error: e instanceof Error ? e.message : String(e)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// src/worker/pipeline-worker.ts
|
|
191
|
+
var ctx = self;
|
|
192
|
+
ctx.onmessage = async (event) => {
|
|
193
|
+
const response = await handleTask(event.data);
|
|
194
|
+
const transfer = [];
|
|
195
|
+
if (response.ok && "bytes" in response.result) {
|
|
196
|
+
transfer.push(response.result.bytes);
|
|
197
|
+
}
|
|
198
|
+
ctx.postMessage(response, transfer);
|
|
199
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { heicToJpegBlob } from './chunk-I7ULPCA2.js';
|
|
2
|
+
import { createThumbnail, encodeImageFile } from './chunk-6S5DQDQH.js';
|
|
3
|
+
import './chunk-GE4LIVXP.js';
|
|
4
|
+
|
|
5
|
+
// src/worker/handle-task.ts
|
|
6
|
+
async function sha256Hex(buffer) {
|
|
7
|
+
const digest = await crypto.subtle.digest("SHA-256", buffer);
|
|
8
|
+
return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
9
|
+
}
|
|
10
|
+
function asUploadFile(data, mime, name) {
|
|
11
|
+
const file = new File([data], name, { type: mime });
|
|
12
|
+
return Object.assign(file, {
|
|
13
|
+
id: "worker",
|
|
14
|
+
metadata: {}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function jpegName(name) {
|
|
18
|
+
if (/\.(heic|heif)$/i.test(name))
|
|
19
|
+
return name.replace(/\.(heic|heif)$/i, ".jpg");
|
|
20
|
+
return `${name}.jpg`;
|
|
21
|
+
}
|
|
22
|
+
async function toImageResult(processed) {
|
|
23
|
+
if (!processed) return null;
|
|
24
|
+
const bytes = await processed.arrayBuffer();
|
|
25
|
+
return {
|
|
26
|
+
kind: "image",
|
|
27
|
+
bytes,
|
|
28
|
+
type: processed.type,
|
|
29
|
+
name: processed.name,
|
|
30
|
+
metadata: processed.metadata
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function handleTask(req) {
|
|
34
|
+
try {
|
|
35
|
+
const params = req.params ?? {};
|
|
36
|
+
const mime = params.mime || "application/octet-stream";
|
|
37
|
+
const name = params.name || "file";
|
|
38
|
+
switch (req.type) {
|
|
39
|
+
case "hash": {
|
|
40
|
+
const checksum = await sha256Hex(req.data);
|
|
41
|
+
return {
|
|
42
|
+
id: req.id,
|
|
43
|
+
ok: true,
|
|
44
|
+
result: { kind: "hash", checksum }
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
case "heic": {
|
|
48
|
+
const blob = await heicToJpegBlob(
|
|
49
|
+
new Blob([req.data], { type: mime }),
|
|
50
|
+
{ quality: 0.92 }
|
|
51
|
+
);
|
|
52
|
+
if (!blob)
|
|
53
|
+
return {
|
|
54
|
+
id: req.id,
|
|
55
|
+
ok: false,
|
|
56
|
+
error: "heic: no decode backend"
|
|
57
|
+
};
|
|
58
|
+
const bytes = await blob.arrayBuffer();
|
|
59
|
+
return {
|
|
60
|
+
id: req.id,
|
|
61
|
+
ok: true,
|
|
62
|
+
result: {
|
|
63
|
+
kind: "image",
|
|
64
|
+
bytes,
|
|
65
|
+
type: "image/jpeg",
|
|
66
|
+
name: jpegName(name),
|
|
67
|
+
metadata: {
|
|
68
|
+
heicConverted: true,
|
|
69
|
+
originalSize: req.data.byteLength,
|
|
70
|
+
processedSize: bytes.byteLength
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
case "exif": {
|
|
76
|
+
const processed = await encodeImageFile(
|
|
77
|
+
asUploadFile(req.data, mime, name),
|
|
78
|
+
{
|
|
79
|
+
type: mime || "image/jpeg",
|
|
80
|
+
quality: 0.92,
|
|
81
|
+
metadata: { exifStripped: true }
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
const result = await toImageResult(processed);
|
|
85
|
+
if (!result)
|
|
86
|
+
return {
|
|
87
|
+
id: req.id,
|
|
88
|
+
ok: false,
|
|
89
|
+
error: "exif: encode failed"
|
|
90
|
+
};
|
|
91
|
+
if (result.metadata)
|
|
92
|
+
result.metadata.processedSize = result.bytes.byteLength;
|
|
93
|
+
return { id: req.id, ok: true, result };
|
|
94
|
+
}
|
|
95
|
+
case "compress": {
|
|
96
|
+
const file = asUploadFile(req.data, mime, name);
|
|
97
|
+
const maxWidthOrHeight = params.maxWidthOrHeight ?? 1920;
|
|
98
|
+
const maxBytes = typeof params.maxSizeMB === "number" ? params.maxSizeMB * 1024 * 1024 : void 0;
|
|
99
|
+
let quality = params.quality ?? 0.82;
|
|
100
|
+
let processed = await encodeImageFile(file, {
|
|
101
|
+
maxWidthOrHeight,
|
|
102
|
+
quality,
|
|
103
|
+
metadata: {
|
|
104
|
+
originalSize: req.data.byteLength,
|
|
105
|
+
compressed: true
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
while (processed && maxBytes && processed.size > maxBytes && quality > 0.35) {
|
|
109
|
+
quality = Math.max(0.35, quality - 0.12);
|
|
110
|
+
processed = await encodeImageFile(file, {
|
|
111
|
+
maxWidthOrHeight,
|
|
112
|
+
quality,
|
|
113
|
+
metadata: {
|
|
114
|
+
originalSize: req.data.byteLength,
|
|
115
|
+
compressed: true
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (!processed)
|
|
120
|
+
return {
|
|
121
|
+
id: req.id,
|
|
122
|
+
ok: false,
|
|
123
|
+
error: "compress: encode failed"
|
|
124
|
+
};
|
|
125
|
+
if (processed.size >= req.data.byteLength && !maxBytes && !params.maxWidthOrHeight) {
|
|
126
|
+
return {
|
|
127
|
+
id: req.id,
|
|
128
|
+
ok: true,
|
|
129
|
+
result: {
|
|
130
|
+
kind: "image",
|
|
131
|
+
bytes: req.data,
|
|
132
|
+
type: mime,
|
|
133
|
+
name,
|
|
134
|
+
metadata: {}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
const result = await toImageResult(processed);
|
|
139
|
+
if (!result)
|
|
140
|
+
return {
|
|
141
|
+
id: req.id,
|
|
142
|
+
ok: false,
|
|
143
|
+
error: "compress: encode failed"
|
|
144
|
+
};
|
|
145
|
+
if (result.metadata)
|
|
146
|
+
result.metadata.processedSize = result.bytes.byteLength;
|
|
147
|
+
return { id: req.id, ok: true, result };
|
|
148
|
+
}
|
|
149
|
+
case "thumbnail": {
|
|
150
|
+
const thumb = await createThumbnail(
|
|
151
|
+
asUploadFile(req.data, mime, name),
|
|
152
|
+
{
|
|
153
|
+
...params.maxWidthOrHeight !== void 0 ? { width: params.maxWidthOrHeight } : {},
|
|
154
|
+
...params.quality !== void 0 ? { quality: params.quality } : {}
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
if (!thumb)
|
|
158
|
+
return { id: req.id, ok: false, error: "thumbnail: failed" };
|
|
159
|
+
const bytes = await thumb.file.arrayBuffer();
|
|
160
|
+
return {
|
|
161
|
+
id: req.id,
|
|
162
|
+
ok: true,
|
|
163
|
+
result: {
|
|
164
|
+
kind: "thumbnail",
|
|
165
|
+
thumbnailUrl: thumb.dataUrl,
|
|
166
|
+
bytes,
|
|
167
|
+
type: thumb.file.type,
|
|
168
|
+
name: thumb.file.name
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
default:
|
|
173
|
+
return {
|
|
174
|
+
id: req.id,
|
|
175
|
+
ok: false,
|
|
176
|
+
error: `unknown task type: ${req.type}`
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
return {
|
|
181
|
+
id: req.id,
|
|
182
|
+
ok: false,
|
|
183
|
+
error: e instanceof Error ? e.message : String(e)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/worker/pipeline-worker.ts
|
|
189
|
+
var ctx = self;
|
|
190
|
+
ctx.onmessage = async (event) => {
|
|
191
|
+
const response = await handleTask(event.data);
|
|
192
|
+
const transfer = [];
|
|
193
|
+
if (response.ok && "bytes" in response.result) {
|
|
194
|
+
transfer.push(response.result.bytes);
|
|
195
|
+
}
|
|
196
|
+
ctx.postMessage(response, transfer);
|
|
197
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { L as LocaleBundle, a as UpupLocaleCode, M as MessageNamespace } from './ui-translations-c5d00392.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a locale candidate to its LocaleBundle:
|
|
5
|
+
* - already a LocaleBundle object → returned as-is.
|
|
6
|
+
* - a registered BCP 47 string code (e.g. "fr-FR", or "fr_FR" via
|
|
7
|
+
* normalizeBcp47) → resolved from the registry.
|
|
8
|
+
* - anything else (undefined, an unregistered code) → undefined.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveLocaleBundle(candidate: LocaleBundle | UpupLocaleCode | undefined): LocaleBundle | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Build a fallback chain: fr-CA -> fr -> en-US
|
|
13
|
+
*/
|
|
14
|
+
declare function buildFallbackChain(code: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a single message from a set of bundles using a fallback chain.
|
|
17
|
+
*/
|
|
18
|
+
declare function resolveMessage(bundles: Map<string, LocaleBundle>, chain: string[], ns: MessageNamespace, key: string): string | undefined;
|
|
19
|
+
|
|
20
|
+
export { resolveLocaleBundle as a, buildFallbackChain as b, resolveMessage as r };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { L as LocaleBundle, a as UpupLocaleCode, M as MessageNamespace } from './ui-translations-c5d00392.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Resolve a locale candidate to its LocaleBundle:
|
|
5
|
+
* - already a LocaleBundle object → returned as-is.
|
|
6
|
+
* - a registered BCP 47 string code (e.g. "fr-FR", or "fr_FR" via
|
|
7
|
+
* normalizeBcp47) → resolved from the registry.
|
|
8
|
+
* - anything else (undefined, an unregistered code) → undefined.
|
|
9
|
+
*/
|
|
10
|
+
declare function resolveLocaleBundle(candidate: LocaleBundle | UpupLocaleCode | undefined): LocaleBundle | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Build a fallback chain: fr-CA -> fr -> en-US
|
|
13
|
+
*/
|
|
14
|
+
declare function buildFallbackChain(code: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a single message from a set of bundles using a fallback chain.
|
|
17
|
+
*/
|
|
18
|
+
declare function resolveMessage(bundles: Map<string, LocaleBundle>, chain: string[], ns: MessageNamespace, key: string): string | undefined;
|
|
19
|
+
|
|
20
|
+
export { resolveLocaleBundle as a, buildFallbackChain as b, resolveMessage as r };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { d as UpupThemeTokens, f as UpupThemeConfig, D as DeepPartial, j as UpupThemeSlots, g as UpupResolvedTheme } from './vars-d3421f6c.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Light preset — sky-family defaults matching the gradient default theme
|
|
5
|
+
* (the landing "MockUploader" look brought into the product).
|
|
6
|
+
*
|
|
7
|
+
* Sky accent mappings (light):
|
|
8
|
+
* primary = #0284c7 (sky-600 — text/links on light)
|
|
9
|
+
* primaryHover = #0369a1 (sky-700)
|
|
10
|
+
* borderActive = #0ea5e9 (sky-500 — drag/active border)
|
|
11
|
+
* dragBg = #e0f2fe (sky-100 — drag-over background)
|
|
12
|
+
* text = #0B0B0B
|
|
13
|
+
* textMuted = #6D6D6D
|
|
14
|
+
* surface = #FFFFFF
|
|
15
|
+
* surfaceAlt = #F7F7F8
|
|
16
|
+
*
|
|
17
|
+
* NOTE: the token layer is currently unconsumed by the components (they paint
|
|
18
|
+
* via hardcoded `upup-*` classes), so these values are cosmetic-of-record — they
|
|
19
|
+
* keep the token layer honest about the default without repainting the DOM today.
|
|
20
|
+
*/
|
|
21
|
+
declare const lightPreset: UpupThemeTokens;
|
|
22
|
+
/**
|
|
23
|
+
* Dark preset — sky-family defaults matching the gradient default theme
|
|
24
|
+
* (close to the landing "MockUploader" mock, which is dark by design).
|
|
25
|
+
*
|
|
26
|
+
* Sky accent mappings (dark):
|
|
27
|
+
* primary = #38bdf8 (sky-400 — text/links, matches the mock accent)
|
|
28
|
+
* primaryHover = #7dd3fc (sky-300)
|
|
29
|
+
* borderActive = #38bdf8 (sky-400 — drag/active border)
|
|
30
|
+
* dragBg = #0b2a3a (deep sky — drag-over background)
|
|
31
|
+
* text = #FFFFFF
|
|
32
|
+
* textMuted = #D1D5DB
|
|
33
|
+
* surfaceAlt = rgba(255,255,255,0.05) mapped to #252540
|
|
34
|
+
*
|
|
35
|
+
* NOTE: the token layer is currently unconsumed by the components (they paint
|
|
36
|
+
* via hardcoded `upup-*` classes), so these values are cosmetic-of-record — they
|
|
37
|
+
* keep the token layer honest about the default without repainting the DOM today.
|
|
38
|
+
*/
|
|
39
|
+
declare const darkPreset: UpupThemeTokens;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resolve theme pipeline:
|
|
43
|
+
* 1. Pick base preset from mode (light/dark/system)
|
|
44
|
+
* 2. Deep-merge provider-level token overrides
|
|
45
|
+
* 3. Deep-merge instance-level token overrides
|
|
46
|
+
*
|
|
47
|
+
* @param config - Instance-level theme config (from `theme` prop)
|
|
48
|
+
* @param providerTokens - Provider-level token overrides (from UpupThemeProvider)
|
|
49
|
+
* @param providerSlots - Provider-level slot overrides (from UpupThemeProvider)
|
|
50
|
+
*/
|
|
51
|
+
declare function resolveTheme(config?: UpupThemeConfig, providerTokens?: DeepPartial<UpupThemeTokens>, providerSlots?: DeepPartial<UpupThemeSlots>): UpupResolvedTheme;
|
|
52
|
+
|
|
53
|
+
export { darkPreset as d, lightPreset as l, resolveTheme as r };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { d as UpupThemeTokens, f as UpupThemeConfig, D as DeepPartial, j as UpupThemeSlots, g as UpupResolvedTheme } from './vars-d3421f6c.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Light preset — sky-family defaults matching the gradient default theme
|
|
5
|
+
* (the landing "MockUploader" look brought into the product).
|
|
6
|
+
*
|
|
7
|
+
* Sky accent mappings (light):
|
|
8
|
+
* primary = #0284c7 (sky-600 — text/links on light)
|
|
9
|
+
* primaryHover = #0369a1 (sky-700)
|
|
10
|
+
* borderActive = #0ea5e9 (sky-500 — drag/active border)
|
|
11
|
+
* dragBg = #e0f2fe (sky-100 — drag-over background)
|
|
12
|
+
* text = #0B0B0B
|
|
13
|
+
* textMuted = #6D6D6D
|
|
14
|
+
* surface = #FFFFFF
|
|
15
|
+
* surfaceAlt = #F7F7F8
|
|
16
|
+
*
|
|
17
|
+
* NOTE: the token layer is currently unconsumed by the components (they paint
|
|
18
|
+
* via hardcoded `upup-*` classes), so these values are cosmetic-of-record — they
|
|
19
|
+
* keep the token layer honest about the default without repainting the DOM today.
|
|
20
|
+
*/
|
|
21
|
+
declare const lightPreset: UpupThemeTokens;
|
|
22
|
+
/**
|
|
23
|
+
* Dark preset — sky-family defaults matching the gradient default theme
|
|
24
|
+
* (close to the landing "MockUploader" mock, which is dark by design).
|
|
25
|
+
*
|
|
26
|
+
* Sky accent mappings (dark):
|
|
27
|
+
* primary = #38bdf8 (sky-400 — text/links, matches the mock accent)
|
|
28
|
+
* primaryHover = #7dd3fc (sky-300)
|
|
29
|
+
* borderActive = #38bdf8 (sky-400 — drag/active border)
|
|
30
|
+
* dragBg = #0b2a3a (deep sky — drag-over background)
|
|
31
|
+
* text = #FFFFFF
|
|
32
|
+
* textMuted = #D1D5DB
|
|
33
|
+
* surfaceAlt = rgba(255,255,255,0.05) mapped to #252540
|
|
34
|
+
*
|
|
35
|
+
* NOTE: the token layer is currently unconsumed by the components (they paint
|
|
36
|
+
* via hardcoded `upup-*` classes), so these values are cosmetic-of-record — they
|
|
37
|
+
* keep the token layer honest about the default without repainting the DOM today.
|
|
38
|
+
*/
|
|
39
|
+
declare const darkPreset: UpupThemeTokens;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Resolve theme pipeline:
|
|
43
|
+
* 1. Pick base preset from mode (light/dark/system)
|
|
44
|
+
* 2. Deep-merge provider-level token overrides
|
|
45
|
+
* 3. Deep-merge instance-level token overrides
|
|
46
|
+
*
|
|
47
|
+
* @param config - Instance-level theme config (from `theme` prop)
|
|
48
|
+
* @param providerTokens - Provider-level token overrides (from UpupThemeProvider)
|
|
49
|
+
* @param providerSlots - Provider-level slot overrides (from UpupThemeProvider)
|
|
50
|
+
*/
|
|
51
|
+
declare function resolveTheme(config?: UpupThemeConfig, providerTokens?: DeepPartial<UpupThemeTokens>, providerSlots?: DeepPartial<UpupThemeSlots>): UpupResolvedTheme;
|
|
52
|
+
|
|
53
|
+
export { darkPreset as d, lightPreset as l, resolveTheme as r };
|