@scalemule/nextjs 0.1.32 → 0.1.33
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/client.js +263 -5
- package/dist/client.mjs +263 -5
- package/dist/index.js +30 -32
- package/dist/index.mjs +30 -32
- package/package.json +2 -2
package/dist/client.js
CHANGED
|
@@ -1,16 +1,273 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
3
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
6
|
var __esm = (fn, res) => function __init() {
|
|
5
7
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
8
|
};
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var upload_resume_exports = {};
|
|
14
|
+
__export(upload_resume_exports, {
|
|
15
|
+
UploadResumeStore: () => UploadResumeStore
|
|
16
|
+
});
|
|
17
|
+
var DB_NAME;
|
|
18
|
+
var STORE_NAME;
|
|
19
|
+
var DB_VERSION;
|
|
20
|
+
var MAX_AGE_MS;
|
|
21
|
+
var UploadResumeStore;
|
|
22
|
+
var init_upload_resume = __esm({
|
|
23
|
+
"src/services/upload-resume.ts"() {
|
|
24
|
+
DB_NAME = "sm_upload_sessions_v1";
|
|
25
|
+
STORE_NAME = "sessions";
|
|
26
|
+
DB_VERSION = 1;
|
|
27
|
+
MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
28
|
+
UploadResumeStore = class {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.db = null;
|
|
31
|
+
}
|
|
32
|
+
/** Generate a deterministic resume key from upload identity */
|
|
33
|
+
static async generateResumeKey(appId, userId, filename, size, lastModified) {
|
|
34
|
+
const raw = `${appId}:${userId}:${filename}:${size}:${lastModified ?? 0}`;
|
|
35
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
36
|
+
const buffer = new TextEncoder().encode(raw);
|
|
37
|
+
const hash2 = await crypto.subtle.digest("SHA-256", buffer);
|
|
38
|
+
return Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
39
|
+
}
|
|
40
|
+
let hash = 0;
|
|
41
|
+
for (let i = 0; i < raw.length; i++) {
|
|
42
|
+
const chr = raw.charCodeAt(i);
|
|
43
|
+
hash = (hash << 5) - hash + chr;
|
|
44
|
+
hash |= 0;
|
|
45
|
+
}
|
|
46
|
+
return `fallback_${Math.abs(hash).toString(36)}`;
|
|
47
|
+
}
|
|
48
|
+
/** Open the IndexedDB store. No-ops if IndexedDB is unavailable. */
|
|
49
|
+
async open() {
|
|
50
|
+
if (typeof indexedDB === "undefined") return;
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
53
|
+
request.onupgradeneeded = () => {
|
|
54
|
+
const db = request.result;
|
|
55
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
56
|
+
const store = db.createObjectStore(STORE_NAME, { keyPath: "key" });
|
|
57
|
+
store.createIndex("updated_at", "updated_at");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
request.onsuccess = () => {
|
|
61
|
+
this.db = request.result;
|
|
62
|
+
resolve();
|
|
63
|
+
};
|
|
64
|
+
request.onerror = () => {
|
|
65
|
+
reject(request.error);
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/** Get a resume session by key. Returns null if not found or stale. */
|
|
70
|
+
async get(key) {
|
|
71
|
+
if (!this.db) return null;
|
|
72
|
+
return new Promise((resolve) => {
|
|
73
|
+
const tx = this.db.transaction(STORE_NAME, "readonly");
|
|
74
|
+
const store = tx.objectStore(STORE_NAME);
|
|
75
|
+
const request = store.get(key);
|
|
76
|
+
request.onsuccess = () => {
|
|
77
|
+
const entry = request.result;
|
|
78
|
+
if (!entry) {
|
|
79
|
+
resolve(null);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (Date.now() - entry.updated_at > MAX_AGE_MS) {
|
|
83
|
+
this.remove(key).catch(() => {
|
|
84
|
+
});
|
|
85
|
+
resolve(null);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
resolve(entry.session);
|
|
89
|
+
};
|
|
90
|
+
request.onerror = () => resolve(null);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** Save a new resume session. */
|
|
94
|
+
async save(key, session) {
|
|
95
|
+
if (!this.db) return;
|
|
96
|
+
return new Promise((resolve, reject) => {
|
|
97
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
98
|
+
const store = tx.objectStore(STORE_NAME);
|
|
99
|
+
const entry = {
|
|
100
|
+
key,
|
|
101
|
+
session: { ...session, created_at: Date.now() },
|
|
102
|
+
updated_at: Date.now()
|
|
103
|
+
};
|
|
104
|
+
const request = store.put(entry);
|
|
105
|
+
request.onsuccess = () => resolve();
|
|
106
|
+
request.onerror = () => reject(request.error);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/** Update a single completed part in an existing session. */
|
|
110
|
+
async updatePart(key, partNumber, etag) {
|
|
111
|
+
if (!this.db) return;
|
|
112
|
+
return new Promise((resolve) => {
|
|
113
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
114
|
+
const store = tx.objectStore(STORE_NAME);
|
|
115
|
+
const getRequest = store.get(key);
|
|
116
|
+
getRequest.onsuccess = () => {
|
|
117
|
+
const entry = getRequest.result;
|
|
118
|
+
if (!entry) {
|
|
119
|
+
resolve();
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const existing = entry.session.completed_parts.find((p) => p.part_number === partNumber);
|
|
123
|
+
if (!existing) {
|
|
124
|
+
entry.session.completed_parts.push({ part_number: partNumber, etag });
|
|
125
|
+
}
|
|
126
|
+
entry.updated_at = Date.now();
|
|
127
|
+
const putRequest = store.put(entry);
|
|
128
|
+
putRequest.onsuccess = () => resolve();
|
|
129
|
+
putRequest.onerror = () => resolve();
|
|
130
|
+
};
|
|
131
|
+
getRequest.onerror = () => resolve();
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** Remove a resume session (e.g., after successful completion). */
|
|
135
|
+
async remove(key) {
|
|
136
|
+
if (!this.db) return;
|
|
137
|
+
return new Promise((resolve) => {
|
|
138
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
139
|
+
const store = tx.objectStore(STORE_NAME);
|
|
140
|
+
const request = store.delete(key);
|
|
141
|
+
request.onsuccess = () => resolve();
|
|
142
|
+
request.onerror = () => resolve();
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** Purge all stale entries (older than MAX_AGE_MS). */
|
|
146
|
+
async purgeStale() {
|
|
147
|
+
if (!this.db) return 0;
|
|
148
|
+
return new Promise((resolve) => {
|
|
149
|
+
const cutoff = Date.now() - MAX_AGE_MS;
|
|
150
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
151
|
+
const store = tx.objectStore(STORE_NAME);
|
|
152
|
+
const index = store.index("updated_at");
|
|
153
|
+
const range = IDBKeyRange.upperBound(cutoff);
|
|
154
|
+
const request = index.openCursor(range);
|
|
155
|
+
let count = 0;
|
|
156
|
+
request.onsuccess = () => {
|
|
157
|
+
const cursor = request.result;
|
|
158
|
+
if (cursor) {
|
|
159
|
+
cursor.delete();
|
|
160
|
+
count++;
|
|
161
|
+
cursor.continue();
|
|
162
|
+
} else {
|
|
163
|
+
resolve(count);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
request.onerror = () => resolve(0);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** Close the database connection. */
|
|
170
|
+
close() {
|
|
171
|
+
if (this.db) {
|
|
172
|
+
this.db.close();
|
|
173
|
+
this.db = null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
9
177
|
}
|
|
10
178
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
179
|
+
var upload_compression_exports = {};
|
|
180
|
+
__export(upload_compression_exports, {
|
|
181
|
+
maybeCompressImage: () => maybeCompressImage
|
|
182
|
+
});
|
|
183
|
+
async function maybeCompressImage(file, userConfig, sessionId, telemetry) {
|
|
184
|
+
const type = file.type?.toLowerCase() || "";
|
|
185
|
+
if (!type.startsWith("image/")) return null;
|
|
186
|
+
if (SKIP_TYPES.has(type)) {
|
|
187
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "format", type });
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
if (!COMPRESSIBLE_TYPES.has(type)) {
|
|
191
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "unsupported_type", type });
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
if (file.size < MIN_COMPRESS_SIZE) {
|
|
195
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "too_small", size: file.size });
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const networkType = getNetworkEffectiveType();
|
|
199
|
+
const defaultProfile = { maxWidth: 3840, maxHeight: 3840, quality: 0.85, maxSizeMB: 5 };
|
|
200
|
+
const networkProfile = NETWORK_PROFILES[networkType] ?? defaultProfile;
|
|
201
|
+
const config = {
|
|
202
|
+
maxWidth: userConfig?.maxWidth ?? networkProfile.maxWidth,
|
|
203
|
+
maxHeight: userConfig?.maxHeight ?? networkProfile.maxHeight,
|
|
204
|
+
quality: userConfig?.quality ?? networkProfile.quality,
|
|
205
|
+
maxSizeMB: userConfig?.maxSizeMB ?? networkProfile.maxSizeMB
|
|
206
|
+
};
|
|
207
|
+
telemetry?.emit(sessionId, "upload.compression.started", {
|
|
208
|
+
original_size: file.size,
|
|
209
|
+
network: networkType,
|
|
210
|
+
target_quality: config.quality
|
|
211
|
+
});
|
|
212
|
+
try {
|
|
213
|
+
const imageCompression = await loadImageCompression();
|
|
214
|
+
if (!imageCompression) {
|
|
215
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "library_unavailable" });
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const compressed = await imageCompression(file, {
|
|
219
|
+
maxSizeMB: config.maxSizeMB,
|
|
220
|
+
maxWidthOrHeight: Math.max(config.maxWidth, config.maxHeight),
|
|
221
|
+
initialQuality: config.quality,
|
|
222
|
+
useWebWorker: true,
|
|
223
|
+
fileType: type === "image/png" ? "image/webp" : void 0
|
|
224
|
+
});
|
|
225
|
+
if (compressed.size >= file.size * 0.95) {
|
|
226
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
227
|
+
reason: "no_size_reduction",
|
|
228
|
+
original_size: file.size,
|
|
229
|
+
compressed_size: compressed.size
|
|
230
|
+
});
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
telemetry?.emit(sessionId, "upload.compression.completed", {
|
|
234
|
+
original_size: file.size,
|
|
235
|
+
compressed_size: compressed.size,
|
|
236
|
+
ratio: (compressed.size / file.size).toFixed(2)
|
|
237
|
+
});
|
|
238
|
+
return compressed;
|
|
239
|
+
} catch (err) {
|
|
240
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
241
|
+
reason: "error",
|
|
242
|
+
error: err instanceof Error ? err.message : "Unknown compression error"
|
|
243
|
+
});
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function loadImageCompression() {
|
|
248
|
+
if (cachedImport === false) return null;
|
|
249
|
+
if (cachedImport) return cachedImport;
|
|
250
|
+
try {
|
|
251
|
+
const mod = await Function('return import("browser-image-compression")')();
|
|
252
|
+
cachedImport = mod.default || mod;
|
|
253
|
+
return cachedImport;
|
|
254
|
+
} catch {
|
|
255
|
+
cachedImport = false;
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function getNetworkEffectiveType() {
|
|
260
|
+
if (typeof navigator !== "undefined" && "connection" in navigator) {
|
|
261
|
+
const conn = navigator.connection;
|
|
262
|
+
return conn?.effectiveType || "4g";
|
|
263
|
+
}
|
|
264
|
+
return "4g";
|
|
265
|
+
}
|
|
266
|
+
var MIN_COMPRESS_SIZE;
|
|
267
|
+
var COMPRESSIBLE_TYPES;
|
|
268
|
+
var SKIP_TYPES;
|
|
269
|
+
var NETWORK_PROFILES;
|
|
270
|
+
var cachedImport;
|
|
14
271
|
var STORAGE_KEYS = {
|
|
15
272
|
SESSION: "scalemule_session",
|
|
16
273
|
USER_ID: "scalemule_user_id",
|
|
@@ -137,6 +394,7 @@ var PHONE_COUNTRIES = [
|
|
|
137
394
|
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
138
395
|
];
|
|
139
396
|
[...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
397
|
+
init_upload_resume();
|
|
140
398
|
|
|
141
399
|
// src/types/index.ts
|
|
142
400
|
var ScaleMuleApiError = class extends Error {
|
package/dist/client.mjs
CHANGED
|
@@ -1,14 +1,271 @@
|
|
|
1
|
+
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
1
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
4
|
var __esm = (fn, res) => function __init() {
|
|
3
5
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
6
|
};
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var upload_resume_exports = {};
|
|
12
|
+
__export(upload_resume_exports, {
|
|
13
|
+
UploadResumeStore: () => UploadResumeStore
|
|
14
|
+
});
|
|
15
|
+
var DB_NAME;
|
|
16
|
+
var STORE_NAME;
|
|
17
|
+
var DB_VERSION;
|
|
18
|
+
var MAX_AGE_MS;
|
|
19
|
+
var UploadResumeStore;
|
|
20
|
+
var init_upload_resume = __esm({
|
|
21
|
+
"src/services/upload-resume.ts"() {
|
|
22
|
+
DB_NAME = "sm_upload_sessions_v1";
|
|
23
|
+
STORE_NAME = "sessions";
|
|
24
|
+
DB_VERSION = 1;
|
|
25
|
+
MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
26
|
+
UploadResumeStore = class {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.db = null;
|
|
29
|
+
}
|
|
30
|
+
/** Generate a deterministic resume key from upload identity */
|
|
31
|
+
static async generateResumeKey(appId, userId, filename, size, lastModified) {
|
|
32
|
+
const raw = `${appId}:${userId}:${filename}:${size}:${lastModified ?? 0}`;
|
|
33
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
34
|
+
const buffer = new TextEncoder().encode(raw);
|
|
35
|
+
const hash2 = await crypto.subtle.digest("SHA-256", buffer);
|
|
36
|
+
return Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
37
|
+
}
|
|
38
|
+
let hash = 0;
|
|
39
|
+
for (let i = 0; i < raw.length; i++) {
|
|
40
|
+
const chr = raw.charCodeAt(i);
|
|
41
|
+
hash = (hash << 5) - hash + chr;
|
|
42
|
+
hash |= 0;
|
|
43
|
+
}
|
|
44
|
+
return `fallback_${Math.abs(hash).toString(36)}`;
|
|
45
|
+
}
|
|
46
|
+
/** Open the IndexedDB store. No-ops if IndexedDB is unavailable. */
|
|
47
|
+
async open() {
|
|
48
|
+
if (typeof indexedDB === "undefined") return;
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
51
|
+
request.onupgradeneeded = () => {
|
|
52
|
+
const db = request.result;
|
|
53
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
54
|
+
const store = db.createObjectStore(STORE_NAME, { keyPath: "key" });
|
|
55
|
+
store.createIndex("updated_at", "updated_at");
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
request.onsuccess = () => {
|
|
59
|
+
this.db = request.result;
|
|
60
|
+
resolve();
|
|
61
|
+
};
|
|
62
|
+
request.onerror = () => {
|
|
63
|
+
reject(request.error);
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/** Get a resume session by key. Returns null if not found or stale. */
|
|
68
|
+
async get(key) {
|
|
69
|
+
if (!this.db) return null;
|
|
70
|
+
return new Promise((resolve) => {
|
|
71
|
+
const tx = this.db.transaction(STORE_NAME, "readonly");
|
|
72
|
+
const store = tx.objectStore(STORE_NAME);
|
|
73
|
+
const request = store.get(key);
|
|
74
|
+
request.onsuccess = () => {
|
|
75
|
+
const entry = request.result;
|
|
76
|
+
if (!entry) {
|
|
77
|
+
resolve(null);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (Date.now() - entry.updated_at > MAX_AGE_MS) {
|
|
81
|
+
this.remove(key).catch(() => {
|
|
82
|
+
});
|
|
83
|
+
resolve(null);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
resolve(entry.session);
|
|
87
|
+
};
|
|
88
|
+
request.onerror = () => resolve(null);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/** Save a new resume session. */
|
|
92
|
+
async save(key, session) {
|
|
93
|
+
if (!this.db) return;
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
96
|
+
const store = tx.objectStore(STORE_NAME);
|
|
97
|
+
const entry = {
|
|
98
|
+
key,
|
|
99
|
+
session: { ...session, created_at: Date.now() },
|
|
100
|
+
updated_at: Date.now()
|
|
101
|
+
};
|
|
102
|
+
const request = store.put(entry);
|
|
103
|
+
request.onsuccess = () => resolve();
|
|
104
|
+
request.onerror = () => reject(request.error);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Update a single completed part in an existing session. */
|
|
108
|
+
async updatePart(key, partNumber, etag) {
|
|
109
|
+
if (!this.db) return;
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
112
|
+
const store = tx.objectStore(STORE_NAME);
|
|
113
|
+
const getRequest = store.get(key);
|
|
114
|
+
getRequest.onsuccess = () => {
|
|
115
|
+
const entry = getRequest.result;
|
|
116
|
+
if (!entry) {
|
|
117
|
+
resolve();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const existing = entry.session.completed_parts.find((p) => p.part_number === partNumber);
|
|
121
|
+
if (!existing) {
|
|
122
|
+
entry.session.completed_parts.push({ part_number: partNumber, etag });
|
|
123
|
+
}
|
|
124
|
+
entry.updated_at = Date.now();
|
|
125
|
+
const putRequest = store.put(entry);
|
|
126
|
+
putRequest.onsuccess = () => resolve();
|
|
127
|
+
putRequest.onerror = () => resolve();
|
|
128
|
+
};
|
|
129
|
+
getRequest.onerror = () => resolve();
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/** Remove a resume session (e.g., after successful completion). */
|
|
133
|
+
async remove(key) {
|
|
134
|
+
if (!this.db) return;
|
|
135
|
+
return new Promise((resolve) => {
|
|
136
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
137
|
+
const store = tx.objectStore(STORE_NAME);
|
|
138
|
+
const request = store.delete(key);
|
|
139
|
+
request.onsuccess = () => resolve();
|
|
140
|
+
request.onerror = () => resolve();
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Purge all stale entries (older than MAX_AGE_MS). */
|
|
144
|
+
async purgeStale() {
|
|
145
|
+
if (!this.db) return 0;
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
const cutoff = Date.now() - MAX_AGE_MS;
|
|
148
|
+
const tx = this.db.transaction(STORE_NAME, "readwrite");
|
|
149
|
+
const store = tx.objectStore(STORE_NAME);
|
|
150
|
+
const index = store.index("updated_at");
|
|
151
|
+
const range = IDBKeyRange.upperBound(cutoff);
|
|
152
|
+
const request = index.openCursor(range);
|
|
153
|
+
let count = 0;
|
|
154
|
+
request.onsuccess = () => {
|
|
155
|
+
const cursor = request.result;
|
|
156
|
+
if (cursor) {
|
|
157
|
+
cursor.delete();
|
|
158
|
+
count++;
|
|
159
|
+
cursor.continue();
|
|
160
|
+
} else {
|
|
161
|
+
resolve(count);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
request.onerror = () => resolve(0);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/** Close the database connection. */
|
|
168
|
+
close() {
|
|
169
|
+
if (this.db) {
|
|
170
|
+
this.db.close();
|
|
171
|
+
this.db = null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
7
175
|
}
|
|
8
176
|
});
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
177
|
+
var upload_compression_exports = {};
|
|
178
|
+
__export(upload_compression_exports, {
|
|
179
|
+
maybeCompressImage: () => maybeCompressImage
|
|
180
|
+
});
|
|
181
|
+
async function maybeCompressImage(file, userConfig, sessionId, telemetry) {
|
|
182
|
+
const type = file.type?.toLowerCase() || "";
|
|
183
|
+
if (!type.startsWith("image/")) return null;
|
|
184
|
+
if (SKIP_TYPES.has(type)) {
|
|
185
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "format", type });
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
if (!COMPRESSIBLE_TYPES.has(type)) {
|
|
189
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "unsupported_type", type });
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
if (file.size < MIN_COMPRESS_SIZE) {
|
|
193
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "too_small", size: file.size });
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
const networkType = getNetworkEffectiveType();
|
|
197
|
+
const defaultProfile = { maxWidth: 3840, maxHeight: 3840, quality: 0.85, maxSizeMB: 5 };
|
|
198
|
+
const networkProfile = NETWORK_PROFILES[networkType] ?? defaultProfile;
|
|
199
|
+
const config = {
|
|
200
|
+
maxWidth: userConfig?.maxWidth ?? networkProfile.maxWidth,
|
|
201
|
+
maxHeight: userConfig?.maxHeight ?? networkProfile.maxHeight,
|
|
202
|
+
quality: userConfig?.quality ?? networkProfile.quality,
|
|
203
|
+
maxSizeMB: userConfig?.maxSizeMB ?? networkProfile.maxSizeMB
|
|
204
|
+
};
|
|
205
|
+
telemetry?.emit(sessionId, "upload.compression.started", {
|
|
206
|
+
original_size: file.size,
|
|
207
|
+
network: networkType,
|
|
208
|
+
target_quality: config.quality
|
|
209
|
+
});
|
|
210
|
+
try {
|
|
211
|
+
const imageCompression = await loadImageCompression();
|
|
212
|
+
if (!imageCompression) {
|
|
213
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", { reason: "library_unavailable" });
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const compressed = await imageCompression(file, {
|
|
217
|
+
maxSizeMB: config.maxSizeMB,
|
|
218
|
+
maxWidthOrHeight: Math.max(config.maxWidth, config.maxHeight),
|
|
219
|
+
initialQuality: config.quality,
|
|
220
|
+
useWebWorker: true,
|
|
221
|
+
fileType: type === "image/png" ? "image/webp" : void 0
|
|
222
|
+
});
|
|
223
|
+
if (compressed.size >= file.size * 0.95) {
|
|
224
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
225
|
+
reason: "no_size_reduction",
|
|
226
|
+
original_size: file.size,
|
|
227
|
+
compressed_size: compressed.size
|
|
228
|
+
});
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
231
|
+
telemetry?.emit(sessionId, "upload.compression.completed", {
|
|
232
|
+
original_size: file.size,
|
|
233
|
+
compressed_size: compressed.size,
|
|
234
|
+
ratio: (compressed.size / file.size).toFixed(2)
|
|
235
|
+
});
|
|
236
|
+
return compressed;
|
|
237
|
+
} catch (err) {
|
|
238
|
+
telemetry?.emit(sessionId, "upload.compression.skipped", {
|
|
239
|
+
reason: "error",
|
|
240
|
+
error: err instanceof Error ? err.message : "Unknown compression error"
|
|
241
|
+
});
|
|
242
|
+
return null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
async function loadImageCompression() {
|
|
246
|
+
if (cachedImport === false) return null;
|
|
247
|
+
if (cachedImport) return cachedImport;
|
|
248
|
+
try {
|
|
249
|
+
const mod = await Function('return import("browser-image-compression")')();
|
|
250
|
+
cachedImport = mod.default || mod;
|
|
251
|
+
return cachedImport;
|
|
252
|
+
} catch {
|
|
253
|
+
cachedImport = false;
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function getNetworkEffectiveType() {
|
|
258
|
+
if (typeof navigator !== "undefined" && "connection" in navigator) {
|
|
259
|
+
const conn = navigator.connection;
|
|
260
|
+
return conn?.effectiveType || "4g";
|
|
261
|
+
}
|
|
262
|
+
return "4g";
|
|
263
|
+
}
|
|
264
|
+
var MIN_COMPRESS_SIZE;
|
|
265
|
+
var COMPRESSIBLE_TYPES;
|
|
266
|
+
var SKIP_TYPES;
|
|
267
|
+
var NETWORK_PROFILES;
|
|
268
|
+
var cachedImport;
|
|
12
269
|
var STORAGE_KEYS = {
|
|
13
270
|
SESSION: "scalemule_session",
|
|
14
271
|
USER_ID: "scalemule_user_id",
|
|
@@ -135,6 +392,7 @@ var PHONE_COUNTRIES = [
|
|
|
135
392
|
{ code: "NZ", name: "New Zealand", dialCode: "+64" }
|
|
136
393
|
];
|
|
137
394
|
[...PHONE_COUNTRIES].sort((a, b) => b.dialCode.length - a.dialCode.length);
|
|
395
|
+
init_upload_resume();
|
|
138
396
|
|
|
139
397
|
// src/types/index.ts
|
|
140
398
|
var ScaleMuleApiError = class extends Error {
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,9 @@ function _interopNamespace(e) {
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
26
|
|
|
27
|
+
// src/provider.tsx
|
|
28
|
+
|
|
29
|
+
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
27
30
|
var __defProp = Object.defineProperty;
|
|
28
31
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
29
32
|
var __esm = (fn, res) => function __init() {
|
|
@@ -33,11 +36,17 @@ var __export = (target, all) => {
|
|
|
33
36
|
for (var name in all)
|
|
34
37
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
38
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
var upload_resume_exports = {};
|
|
40
|
+
__export(upload_resume_exports, {
|
|
41
|
+
UploadResumeStore: () => UploadResumeStore
|
|
42
|
+
});
|
|
43
|
+
var DB_NAME;
|
|
44
|
+
var STORE_NAME;
|
|
45
|
+
var DB_VERSION;
|
|
46
|
+
var MAX_AGE_MS;
|
|
47
|
+
var UploadResumeStore;
|
|
48
|
+
var init_upload_resume = __esm({
|
|
49
|
+
"src/services/upload-resume.ts"() {
|
|
41
50
|
DB_NAME = "sm_upload_sessions_v1";
|
|
42
51
|
STORE_NAME = "sessions";
|
|
43
52
|
DB_VERSION = 1;
|
|
@@ -193,21 +202,8 @@ var init_chunk_3FTGBRLU = __esm({
|
|
|
193
202
|
};
|
|
194
203
|
}
|
|
195
204
|
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
var upload_resume_RXLHBH5E_exports = {};
|
|
199
|
-
__export(upload_resume_RXLHBH5E_exports, {
|
|
200
|
-
UploadResumeStore: () => UploadResumeStore
|
|
201
|
-
});
|
|
202
|
-
var init_upload_resume_RXLHBH5E = __esm({
|
|
203
|
-
"node_modules/@scalemule/sdk/dist/upload-resume-RXLHBH5E.mjs"() {
|
|
204
|
-
init_chunk_3FTGBRLU();
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// node_modules/@scalemule/sdk/dist/upload-compression-VOUJRAIM.mjs
|
|
209
|
-
var upload_compression_VOUJRAIM_exports = {};
|
|
210
|
-
__export(upload_compression_VOUJRAIM_exports, {
|
|
205
|
+
var upload_compression_exports = {};
|
|
206
|
+
__export(upload_compression_exports, {
|
|
211
207
|
maybeCompressImage: () => maybeCompressImage
|
|
212
208
|
});
|
|
213
209
|
async function maybeCompressImage(file, userConfig, sessionId, telemetry) {
|
|
@@ -293,9 +289,13 @@ function getNetworkEffectiveType() {
|
|
|
293
289
|
}
|
|
294
290
|
return "4g";
|
|
295
291
|
}
|
|
296
|
-
var MIN_COMPRESS_SIZE
|
|
297
|
-
var
|
|
298
|
-
|
|
292
|
+
var MIN_COMPRESS_SIZE;
|
|
293
|
+
var COMPRESSIBLE_TYPES;
|
|
294
|
+
var SKIP_TYPES;
|
|
295
|
+
var NETWORK_PROFILES;
|
|
296
|
+
var cachedImport;
|
|
297
|
+
var init_upload_compression = __esm({
|
|
298
|
+
"src/services/upload-compression.ts"() {
|
|
299
299
|
MIN_COMPRESS_SIZE = 100 * 1024;
|
|
300
300
|
COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/jpg", "image/png", "image/bmp", "image/tiff"]);
|
|
301
301
|
SKIP_TYPES = /* @__PURE__ */ new Set(["image/gif", "image/svg+xml", "image/webp", "image/avif"]);
|
|
@@ -308,9 +308,6 @@ var init_upload_compression_VOUJRAIM = __esm({
|
|
|
308
308
|
cachedImport = null;
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
|
-
|
|
312
|
-
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
313
|
-
init_chunk_3FTGBRLU();
|
|
314
311
|
function buildClientContextHeaders(context) {
|
|
315
312
|
if (!context) return {};
|
|
316
313
|
const headers = {};
|
|
@@ -2481,7 +2478,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2481
2478
|
let resumeData = null;
|
|
2482
2479
|
if (options?.resume !== "off" && typeof window !== "undefined") {
|
|
2483
2480
|
try {
|
|
2484
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2481
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2485
2482
|
resumeStore = new UploadResumeStore2();
|
|
2486
2483
|
await resumeStore.open();
|
|
2487
2484
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
@@ -2529,7 +2526,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2529
2526
|
} else {
|
|
2530
2527
|
let clientUploadKey;
|
|
2531
2528
|
try {
|
|
2532
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2529
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2533
2530
|
clientUploadKey = await UploadResumeStore2.generateResumeKey(
|
|
2534
2531
|
this.client.getApiKey?.() || "",
|
|
2535
2532
|
this.client.getUserId?.() || "",
|
|
@@ -2562,7 +2559,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2562
2559
|
const { upload_session_id, file_id, part_size_bytes, total_parts } = startData;
|
|
2563
2560
|
if (resumeStore && !resumeData) {
|
|
2564
2561
|
try {
|
|
2565
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2562
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2566
2563
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2567
2564
|
this.client.getApiKey?.() || "",
|
|
2568
2565
|
this.client.getUserId?.() || "",
|
|
@@ -2713,7 +2710,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2713
2710
|
telemetry?.emit(sessionId, "upload.multipart.part_completed", { part_number: result.partNum });
|
|
2714
2711
|
if (resumeStore) {
|
|
2715
2712
|
try {
|
|
2716
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2713
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2717
2714
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2718
2715
|
this.client.getApiKey?.() || "",
|
|
2719
2716
|
this.client.getUserId?.() || "",
|
|
@@ -2765,7 +2762,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2765
2762
|
);
|
|
2766
2763
|
if (resumeStore) {
|
|
2767
2764
|
try {
|
|
2768
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2765
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2769
2766
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2770
2767
|
this.client.getApiKey?.() || "",
|
|
2771
2768
|
this.client.getUserId?.() || "",
|
|
@@ -3417,7 +3414,7 @@ var StorageService = class extends ServiceModule {
|
|
|
3417
3414
|
}
|
|
3418
3415
|
async maybeCompress(file, config, sessionId, telemetry) {
|
|
3419
3416
|
try {
|
|
3420
|
-
const { maybeCompressImage: maybeCompressImage2 } = await Promise.resolve().then(() => (
|
|
3417
|
+
const { maybeCompressImage: maybeCompressImage2 } = await Promise.resolve().then(() => (init_upload_compression(), upload_compression_exports));
|
|
3421
3418
|
return await maybeCompressImage2(file, config, sessionId, telemetry);
|
|
3422
3419
|
} catch {
|
|
3423
3420
|
return null;
|
|
@@ -3505,6 +3502,7 @@ function extractS3ErrorCode(body) {
|
|
|
3505
3502
|
const m = body.match(/<Code>([^<]+)<\/Code>/);
|
|
3506
3503
|
return m ? m[1] : void 0;
|
|
3507
3504
|
}
|
|
3505
|
+
init_upload_resume();
|
|
3508
3506
|
var DEFAULT_RECONNECT_BASE_MS = 1e3;
|
|
3509
3507
|
var MAX_RECONNECT_MS = 3e4;
|
|
3510
3508
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,9 @@ import { createMoneyClient } from '@scalemule/money';
|
|
|
4
4
|
export { MoneyClient, createMoneyClient } from '@scalemule/money';
|
|
5
5
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
6
6
|
|
|
7
|
+
// src/provider.tsx
|
|
8
|
+
|
|
9
|
+
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
7
10
|
var __defProp = Object.defineProperty;
|
|
8
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
9
12
|
var __esm = (fn, res) => function __init() {
|
|
@@ -13,11 +16,17 @@ var __export = (target, all) => {
|
|
|
13
16
|
for (var name in all)
|
|
14
17
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
18
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
var upload_resume_exports = {};
|
|
20
|
+
__export(upload_resume_exports, {
|
|
21
|
+
UploadResumeStore: () => UploadResumeStore
|
|
22
|
+
});
|
|
23
|
+
var DB_NAME;
|
|
24
|
+
var STORE_NAME;
|
|
25
|
+
var DB_VERSION;
|
|
26
|
+
var MAX_AGE_MS;
|
|
27
|
+
var UploadResumeStore;
|
|
28
|
+
var init_upload_resume = __esm({
|
|
29
|
+
"src/services/upload-resume.ts"() {
|
|
21
30
|
DB_NAME = "sm_upload_sessions_v1";
|
|
22
31
|
STORE_NAME = "sessions";
|
|
23
32
|
DB_VERSION = 1;
|
|
@@ -173,21 +182,8 @@ var init_chunk_3FTGBRLU = __esm({
|
|
|
173
182
|
};
|
|
174
183
|
}
|
|
175
184
|
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var upload_resume_RXLHBH5E_exports = {};
|
|
179
|
-
__export(upload_resume_RXLHBH5E_exports, {
|
|
180
|
-
UploadResumeStore: () => UploadResumeStore
|
|
181
|
-
});
|
|
182
|
-
var init_upload_resume_RXLHBH5E = __esm({
|
|
183
|
-
"node_modules/@scalemule/sdk/dist/upload-resume-RXLHBH5E.mjs"() {
|
|
184
|
-
init_chunk_3FTGBRLU();
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
// node_modules/@scalemule/sdk/dist/upload-compression-VOUJRAIM.mjs
|
|
189
|
-
var upload_compression_VOUJRAIM_exports = {};
|
|
190
|
-
__export(upload_compression_VOUJRAIM_exports, {
|
|
185
|
+
var upload_compression_exports = {};
|
|
186
|
+
__export(upload_compression_exports, {
|
|
191
187
|
maybeCompressImage: () => maybeCompressImage
|
|
192
188
|
});
|
|
193
189
|
async function maybeCompressImage(file, userConfig, sessionId, telemetry) {
|
|
@@ -273,9 +269,13 @@ function getNetworkEffectiveType() {
|
|
|
273
269
|
}
|
|
274
270
|
return "4g";
|
|
275
271
|
}
|
|
276
|
-
var MIN_COMPRESS_SIZE
|
|
277
|
-
var
|
|
278
|
-
|
|
272
|
+
var MIN_COMPRESS_SIZE;
|
|
273
|
+
var COMPRESSIBLE_TYPES;
|
|
274
|
+
var SKIP_TYPES;
|
|
275
|
+
var NETWORK_PROFILES;
|
|
276
|
+
var cachedImport;
|
|
277
|
+
var init_upload_compression = __esm({
|
|
278
|
+
"src/services/upload-compression.ts"() {
|
|
279
279
|
MIN_COMPRESS_SIZE = 100 * 1024;
|
|
280
280
|
COMPRESSIBLE_TYPES = /* @__PURE__ */ new Set(["image/jpeg", "image/jpg", "image/png", "image/bmp", "image/tiff"]);
|
|
281
281
|
SKIP_TYPES = /* @__PURE__ */ new Set(["image/gif", "image/svg+xml", "image/webp", "image/avif"]);
|
|
@@ -288,9 +288,6 @@ var init_upload_compression_VOUJRAIM = __esm({
|
|
|
288
288
|
cachedImport = null;
|
|
289
289
|
}
|
|
290
290
|
});
|
|
291
|
-
|
|
292
|
-
// node_modules/@scalemule/sdk/dist/index.mjs
|
|
293
|
-
init_chunk_3FTGBRLU();
|
|
294
291
|
function buildClientContextHeaders(context) {
|
|
295
292
|
if (!context) return {};
|
|
296
293
|
const headers = {};
|
|
@@ -2461,7 +2458,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2461
2458
|
let resumeData = null;
|
|
2462
2459
|
if (options?.resume !== "off" && typeof window !== "undefined") {
|
|
2463
2460
|
try {
|
|
2464
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2461
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2465
2462
|
resumeStore = new UploadResumeStore2();
|
|
2466
2463
|
await resumeStore.open();
|
|
2467
2464
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
@@ -2509,7 +2506,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2509
2506
|
} else {
|
|
2510
2507
|
let clientUploadKey;
|
|
2511
2508
|
try {
|
|
2512
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2509
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2513
2510
|
clientUploadKey = await UploadResumeStore2.generateResumeKey(
|
|
2514
2511
|
this.client.getApiKey?.() || "",
|
|
2515
2512
|
this.client.getUserId?.() || "",
|
|
@@ -2542,7 +2539,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2542
2539
|
const { upload_session_id, file_id, part_size_bytes, total_parts } = startData;
|
|
2543
2540
|
if (resumeStore && !resumeData) {
|
|
2544
2541
|
try {
|
|
2545
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2542
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2546
2543
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2547
2544
|
this.client.getApiKey?.() || "",
|
|
2548
2545
|
this.client.getUserId?.() || "",
|
|
@@ -2693,7 +2690,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2693
2690
|
telemetry?.emit(sessionId, "upload.multipart.part_completed", { part_number: result.partNum });
|
|
2694
2691
|
if (resumeStore) {
|
|
2695
2692
|
try {
|
|
2696
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2693
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2697
2694
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2698
2695
|
this.client.getApiKey?.() || "",
|
|
2699
2696
|
this.client.getUserId?.() || "",
|
|
@@ -2745,7 +2742,7 @@ var StorageService = class extends ServiceModule {
|
|
|
2745
2742
|
);
|
|
2746
2743
|
if (resumeStore) {
|
|
2747
2744
|
try {
|
|
2748
|
-
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (
|
|
2745
|
+
const { UploadResumeStore: UploadResumeStore2 } = await Promise.resolve().then(() => (init_upload_resume(), upload_resume_exports));
|
|
2749
2746
|
const resumeKey = await UploadResumeStore2.generateResumeKey(
|
|
2750
2747
|
this.client.getApiKey?.() || "",
|
|
2751
2748
|
this.client.getUserId?.() || "",
|
|
@@ -3397,7 +3394,7 @@ var StorageService = class extends ServiceModule {
|
|
|
3397
3394
|
}
|
|
3398
3395
|
async maybeCompress(file, config, sessionId, telemetry) {
|
|
3399
3396
|
try {
|
|
3400
|
-
const { maybeCompressImage: maybeCompressImage2 } = await Promise.resolve().then(() => (
|
|
3397
|
+
const { maybeCompressImage: maybeCompressImage2 } = await Promise.resolve().then(() => (init_upload_compression(), upload_compression_exports));
|
|
3401
3398
|
return await maybeCompressImage2(file, config, sessionId, telemetry);
|
|
3402
3399
|
} catch {
|
|
3403
3400
|
return null;
|
|
@@ -3485,6 +3482,7 @@ function extractS3ErrorCode(body) {
|
|
|
3485
3482
|
const m = body.match(/<Code>([^<]+)<\/Code>/);
|
|
3486
3483
|
return m ? m[1] : void 0;
|
|
3487
3484
|
}
|
|
3485
|
+
init_upload_resume();
|
|
3488
3486
|
var DEFAULT_RECONNECT_BASE_MS = 1e3;
|
|
3489
3487
|
var MAX_RECONNECT_MS = 3e4;
|
|
3490
3488
|
var HEARTBEAT_INTERVAL_MS = 3e4;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalemule/nextjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "ScaleMule SDK for Next.js applications - authentication, storage, and user management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@scalemule/ledvery": "^0.0.1",
|
|
62
62
|
"@scalemule/money": "^0.0.1",
|
|
63
|
-
"@scalemule/sdk": "^0.0.
|
|
63
|
+
"@scalemule/sdk": "^0.0.60"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"next": ">=14.0.0",
|