@flareapp/vite 2.12.0 → 2.12.2
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/index.cjs +30 -2
- package/dist/index.mjs +30 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4,6 +4,29 @@ let node_path = require("node:path");
|
|
|
4
4
|
let node_zlib = require("node:zlib");
|
|
5
5
|
|
|
6
6
|
//#region ../flare-api/dist/index.mjs
|
|
7
|
+
async function settleWithConcurrency(items, concurrency, task) {
|
|
8
|
+
const results = Array.from({ length: items.length });
|
|
9
|
+
let nextIndex = 0;
|
|
10
|
+
async function worker() {
|
|
11
|
+
while (nextIndex < items.length) {
|
|
12
|
+
const index = nextIndex++;
|
|
13
|
+
try {
|
|
14
|
+
results[index] = {
|
|
15
|
+
status: "fulfilled",
|
|
16
|
+
value: await task(items[index])
|
|
17
|
+
};
|
|
18
|
+
} catch (reason) {
|
|
19
|
+
results[index] = {
|
|
20
|
+
status: "rejected",
|
|
21
|
+
reason
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const workerCount = Math.min(concurrency, items.length);
|
|
27
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
28
|
+
return results;
|
|
29
|
+
}
|
|
7
30
|
var FlareApiError = class extends Error {
|
|
8
31
|
constructor(message) {
|
|
9
32
|
super(message);
|
|
@@ -14,8 +37,10 @@ const RETRIABLE_STATUS_CODES = new Set([
|
|
|
14
37
|
429,
|
|
15
38
|
502,
|
|
16
39
|
503,
|
|
17
|
-
504
|
|
40
|
+
504,
|
|
41
|
+
525
|
|
18
42
|
]);
|
|
43
|
+
const MAX_CONCURRENT_UPLOADS = 10;
|
|
19
44
|
function describeNetworkError(error) {
|
|
20
45
|
if (!(error instanceof Error)) return String(error);
|
|
21
46
|
const cause = error.cause;
|
|
@@ -39,6 +64,9 @@ var FlareApi = class {
|
|
|
39
64
|
sourcemap: base64GzipSourcemap
|
|
40
65
|
});
|
|
41
66
|
}
|
|
67
|
+
uploadSourcemaps(sourcemaps) {
|
|
68
|
+
return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
|
|
69
|
+
}
|
|
42
70
|
async postWithRetry(data, maxRetries = 3) {
|
|
43
71
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
44
72
|
try {
|
|
@@ -126,7 +154,7 @@ function flareSourcemaps({ apiKey, base, apiEndpoint = "https://flareapp.io/api/
|
|
|
126
154
|
}
|
|
127
155
|
if (!sourcemaps.length) return;
|
|
128
156
|
log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
|
|
129
|
-
const results = await
|
|
157
|
+
const results = await flare.uploadSourcemaps(sourcemaps);
|
|
130
158
|
const failed = results.filter((r) => r.status === "rejected");
|
|
131
159
|
if (failed.length > 0) {
|
|
132
160
|
for (const result of failed) log(`Upload failed: ${result.reason}`, true);
|
package/dist/index.mjs
CHANGED
|
@@ -4,6 +4,29 @@ import { resolve } from "node:path";
|
|
|
4
4
|
import { deflateRawSync } from "node:zlib";
|
|
5
5
|
|
|
6
6
|
//#region ../flare-api/dist/index.mjs
|
|
7
|
+
async function settleWithConcurrency(items, concurrency, task) {
|
|
8
|
+
const results = Array.from({ length: items.length });
|
|
9
|
+
let nextIndex = 0;
|
|
10
|
+
async function worker() {
|
|
11
|
+
while (nextIndex < items.length) {
|
|
12
|
+
const index = nextIndex++;
|
|
13
|
+
try {
|
|
14
|
+
results[index] = {
|
|
15
|
+
status: "fulfilled",
|
|
16
|
+
value: await task(items[index])
|
|
17
|
+
};
|
|
18
|
+
} catch (reason) {
|
|
19
|
+
results[index] = {
|
|
20
|
+
status: "rejected",
|
|
21
|
+
reason
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const workerCount = Math.min(concurrency, items.length);
|
|
27
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
28
|
+
return results;
|
|
29
|
+
}
|
|
7
30
|
var FlareApiError = class extends Error {
|
|
8
31
|
constructor(message) {
|
|
9
32
|
super(message);
|
|
@@ -14,8 +37,10 @@ const RETRIABLE_STATUS_CODES = new Set([
|
|
|
14
37
|
429,
|
|
15
38
|
502,
|
|
16
39
|
503,
|
|
17
|
-
504
|
|
40
|
+
504,
|
|
41
|
+
525
|
|
18
42
|
]);
|
|
43
|
+
const MAX_CONCURRENT_UPLOADS = 10;
|
|
19
44
|
function describeNetworkError(error) {
|
|
20
45
|
if (!(error instanceof Error)) return String(error);
|
|
21
46
|
const cause = error.cause;
|
|
@@ -39,6 +64,9 @@ var FlareApi = class {
|
|
|
39
64
|
sourcemap: base64GzipSourcemap
|
|
40
65
|
});
|
|
41
66
|
}
|
|
67
|
+
uploadSourcemaps(sourcemaps) {
|
|
68
|
+
return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
|
|
69
|
+
}
|
|
42
70
|
async postWithRetry(data, maxRetries = 3) {
|
|
43
71
|
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
44
72
|
try {
|
|
@@ -126,7 +154,7 @@ function flareSourcemaps({ apiKey, base, apiEndpoint = "https://flareapp.io/api/
|
|
|
126
154
|
}
|
|
127
155
|
if (!sourcemaps.length) return;
|
|
128
156
|
log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
|
|
129
|
-
const results = await
|
|
157
|
+
const results = await flare.uploadSourcemaps(sourcemaps);
|
|
130
158
|
const failed = results.filter((r) => r.status === "rejected");
|
|
131
159
|
if (failed.length > 0) {
|
|
132
160
|
for (const result of failed) log(`Upload failed: ${result.reason}`, true);
|