@flareapp/vite 2.12.0 → 2.12.1

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 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);
@@ -16,6 +39,7 @@ const RETRIABLE_STATUS_CODES = new Set([
16
39
  503,
17
40
  504
18
41
  ]);
42
+ const MAX_CONCURRENT_UPLOADS = 10;
19
43
  function describeNetworkError(error) {
20
44
  if (!(error instanceof Error)) return String(error);
21
45
  const cause = error.cause;
@@ -39,6 +63,9 @@ var FlareApi = class {
39
63
  sourcemap: base64GzipSourcemap
40
64
  });
41
65
  }
66
+ uploadSourcemaps(sourcemaps) {
67
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
68
+ }
42
69
  async postWithRetry(data, maxRetries = 3) {
43
70
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
44
71
  try {
@@ -126,7 +153,7 @@ function flareSourcemaps({ apiKey, base, apiEndpoint = "https://flareapp.io/api/
126
153
  }
127
154
  if (!sourcemaps.length) return;
128
155
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
129
- const results = await Promise.allSettled(sourcemaps.map((sourcemap) => flare.uploadSourcemap(sourcemap)));
156
+ const results = await flare.uploadSourcemaps(sourcemaps);
130
157
  const failed = results.filter((r) => r.status === "rejected");
131
158
  if (failed.length > 0) {
132
159
  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);
@@ -16,6 +39,7 @@ const RETRIABLE_STATUS_CODES = new Set([
16
39
  503,
17
40
  504
18
41
  ]);
42
+ const MAX_CONCURRENT_UPLOADS = 10;
19
43
  function describeNetworkError(error) {
20
44
  if (!(error instanceof Error)) return String(error);
21
45
  const cause = error.cause;
@@ -39,6 +63,9 @@ var FlareApi = class {
39
63
  sourcemap: base64GzipSourcemap
40
64
  });
41
65
  }
66
+ uploadSourcemaps(sourcemaps) {
67
+ return settleWithConcurrency(sourcemaps, MAX_CONCURRENT_UPLOADS, (sourcemap) => this.uploadSourcemap(sourcemap));
68
+ }
42
69
  async postWithRetry(data, maxRetries = 3) {
43
70
  for (let attempt = 1; attempt <= maxRetries; attempt++) {
44
71
  try {
@@ -126,7 +153,7 @@ function flareSourcemaps({ apiKey, base, apiEndpoint = "https://flareapp.io/api/
126
153
  }
127
154
  if (!sourcemaps.length) return;
128
155
  log(`Uploading ${sourcemaps.length} sourcemap(s) to Flare.`);
129
- const results = await Promise.allSettled(sourcemaps.map((sourcemap) => flare.uploadSourcemap(sourcemap)));
156
+ const results = await flare.uploadSourcemaps(sourcemaps);
130
157
  const failed = results.filter((r) => r.status === "rejected");
131
158
  if (failed.length > 0) {
132
159
  for (const result of failed) log(`Upload failed: ${result.reason}`, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flareapp/vite",
3
- "version": "2.12.0",
3
+ "version": "2.12.1",
4
4
  "description": "Vite plugin for flareapp.io",
5
5
  "homepage": "https://flareapp.io",
6
6
  "bugs": "https://github.com/spatie/flare-client-js/issues",