@flareapp/vite 1.0.3 → 1.2.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/.release-it.json +16 -0
- package/dist/index.js +10 -33
- package/dist/index.mjs +10 -33
- package/package.json +5 -4
- package/src/flareApi.ts +16 -47
package/.release-it.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"git": {
|
|
3
|
+
"commitMessage": "Release @flareapp/vite v${version}",
|
|
4
|
+
"tagName": "@flareapp/vite@${version}",
|
|
5
|
+
"tagAnnotation": "Release @flareapp/vite v${version}"
|
|
6
|
+
},
|
|
7
|
+
"github": {
|
|
8
|
+
"release": false
|
|
9
|
+
},
|
|
10
|
+
"npm": {
|
|
11
|
+
"publish": true
|
|
12
|
+
},
|
|
13
|
+
"hooks": {
|
|
14
|
+
"after:bump": "npm run build"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -39,49 +39,26 @@ var import_path = require("path");
|
|
|
39
39
|
|
|
40
40
|
// src/flareApi.ts
|
|
41
41
|
var import_axios = __toESM(require("axios"));
|
|
42
|
-
var import_https = __toESM(require("https"));
|
|
43
42
|
var import_zlib = require("zlib");
|
|
44
43
|
var FlareApi = class {
|
|
45
44
|
constructor(endpoint, key, version) {
|
|
46
45
|
this.endpoint = endpoint;
|
|
47
46
|
this.key = key;
|
|
48
47
|
this.version = version;
|
|
49
|
-
this.client = import_axios.default.create({
|
|
50
|
-
httpsAgent: new import_https.default.Agent({ keepAlive: false })
|
|
51
|
-
});
|
|
52
48
|
}
|
|
53
49
|
uploadSourcemap(sourcemap) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
return new Promise((resolve2, reject) => {
|
|
51
|
+
const base64GzipSourcemap = (0, import_zlib.deflateRawSync)(sourcemap.content).toString("base64");
|
|
52
|
+
import_axios.default.post(this.endpoint, {
|
|
53
|
+
key: this.key,
|
|
54
|
+
version_id: this.version,
|
|
55
|
+
relative_filename: sourcemap.original_file,
|
|
56
|
+
sourcemap: base64GzipSourcemap
|
|
57
|
+
}).then(resolve2).catch((error) => {
|
|
58
|
+
return reject(`${error.response.status}: ${JSON.stringify(error.response.data)}`);
|
|
59
|
+
});
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
async postWithRetry(data, retries = 3) {
|
|
63
|
-
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
64
|
-
try {
|
|
65
|
-
return await this.client.post(this.endpoint, data);
|
|
66
|
-
} catch (error) {
|
|
67
|
-
if (import_axios.default.isAxiosError(error)) {
|
|
68
|
-
if (error.response) {
|
|
69
|
-
throw `${error.response.status}: ${JSON.stringify(error.response.data)}`;
|
|
70
|
-
}
|
|
71
|
-
if (attempt < retries) {
|
|
72
|
-
await this.delay(attempt * 1e3);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
throw `Network error: ${error.message}`;
|
|
76
|
-
}
|
|
77
|
-
throw `Request setup error: ${error instanceof Error ? error.message : String(error)}`;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
throw "Unexpected: retry loop exited without returning or throwing";
|
|
81
|
-
}
|
|
82
|
-
delay(ms) {
|
|
83
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
84
|
-
}
|
|
85
62
|
};
|
|
86
63
|
|
|
87
64
|
// src/util.ts
|
package/dist/index.mjs
CHANGED
|
@@ -5,49 +5,26 @@ import { resolve } from "path";
|
|
|
5
5
|
|
|
6
6
|
// src/flareApi.ts
|
|
7
7
|
import axios from "axios";
|
|
8
|
-
import https from "https";
|
|
9
8
|
import { deflateRawSync } from "zlib";
|
|
10
9
|
var FlareApi = class {
|
|
11
10
|
constructor(endpoint, key, version) {
|
|
12
11
|
this.endpoint = endpoint;
|
|
13
12
|
this.key = key;
|
|
14
13
|
this.version = version;
|
|
15
|
-
this.client = axios.create({
|
|
16
|
-
httpsAgent: new https.Agent({ keepAlive: false })
|
|
17
|
-
});
|
|
18
14
|
}
|
|
19
15
|
uploadSourcemap(sourcemap) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
return new Promise((resolve2, reject) => {
|
|
17
|
+
const base64GzipSourcemap = deflateRawSync(sourcemap.content).toString("base64");
|
|
18
|
+
axios.post(this.endpoint, {
|
|
19
|
+
key: this.key,
|
|
20
|
+
version_id: this.version,
|
|
21
|
+
relative_filename: sourcemap.original_file,
|
|
22
|
+
sourcemap: base64GzipSourcemap
|
|
23
|
+
}).then(resolve2).catch((error) => {
|
|
24
|
+
return reject(`${error.response.status}: ${JSON.stringify(error.response.data)}`);
|
|
25
|
+
});
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
async postWithRetry(data, retries = 3) {
|
|
29
|
-
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
30
|
-
try {
|
|
31
|
-
return await this.client.post(this.endpoint, data);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (axios.isAxiosError(error)) {
|
|
34
|
-
if (error.response) {
|
|
35
|
-
throw `${error.response.status}: ${JSON.stringify(error.response.data)}`;
|
|
36
|
-
}
|
|
37
|
-
if (attempt < retries) {
|
|
38
|
-
await this.delay(attempt * 1e3);
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
throw `Network error: ${error.message}`;
|
|
42
|
-
}
|
|
43
|
-
throw `Request setup error: ${error instanceof Error ? error.message : String(error)}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
throw "Unexpected: retry loop exited without returning or throwing";
|
|
47
|
-
}
|
|
48
|
-
delay(ms) {
|
|
49
|
-
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
50
|
-
}
|
|
51
28
|
};
|
|
52
29
|
|
|
53
30
|
// src/util.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flareapp/vite",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
24
24
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
25
|
-
"typescript": "tsc"
|
|
25
|
+
"typescript": "tsc",
|
|
26
|
+
"release": "npx release-it"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"axios": "^1.2.1",
|
|
@@ -31,10 +32,10 @@
|
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/node": "^18.11.17",
|
|
33
34
|
"typescript": "^5.3.3",
|
|
34
|
-
"vite": "^4.0.0||^5.0.0||^6.0.0
|
|
35
|
+
"vite": "^4.0.0||^5.0.0||^6.0.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
|
-
"vite": "^4.0.0||^5.0.0||^6.0.0
|
|
38
|
+
"vite": "^4.0.0||^5.0.0||^6.0.0"
|
|
38
39
|
},
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|
package/src/flareApi.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import axios
|
|
2
|
-
import https from 'https';
|
|
1
|
+
import axios from 'axios';
|
|
3
2
|
import { deflateRawSync } from 'zlib';
|
|
4
3
|
|
|
5
4
|
import { Sourcemap } from './index';
|
|
@@ -8,58 +7,28 @@ export default class FlareApi {
|
|
|
8
7
|
endpoint: string;
|
|
9
8
|
key: string;
|
|
10
9
|
version: string;
|
|
11
|
-
private client: AxiosInstance;
|
|
12
10
|
|
|
13
11
|
constructor(endpoint: string, key: string, version: string) {
|
|
14
12
|
this.endpoint = endpoint;
|
|
15
13
|
this.key = key;
|
|
16
14
|
this.version = version;
|
|
17
|
-
this.client = axios.create({
|
|
18
|
-
httpsAgent: new https.Agent({ keepAlive: false }),
|
|
19
|
-
});
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
uploadSourcemap(sourcemap: Sourcemap)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
uploadSourcemap(sourcemap: Sourcemap) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const base64GzipSourcemap = deflateRawSync(sourcemap.content).toString('base64');
|
|
20
|
+
|
|
21
|
+
axios
|
|
22
|
+
.post(this.endpoint, {
|
|
23
|
+
key: this.key,
|
|
24
|
+
version_id: this.version,
|
|
25
|
+
relative_filename: sourcemap.original_file,
|
|
26
|
+
sourcemap: base64GzipSourcemap,
|
|
27
|
+
})
|
|
28
|
+
.then(resolve)
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
return reject(`${error.response.status}: ${JSON.stringify(error.response.data)}`);
|
|
31
|
+
});
|
|
30
32
|
});
|
|
31
33
|
}
|
|
32
|
-
|
|
33
|
-
private async postWithRetry(data: Record<string, string>, retries = 3): Promise<unknown> {
|
|
34
|
-
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
35
|
-
try {
|
|
36
|
-
return await this.client.post(this.endpoint, data);
|
|
37
|
-
} catch (error: unknown) {
|
|
38
|
-
if (axios.isAxiosError(error)) {
|
|
39
|
-
if (error.response) {
|
|
40
|
-
// HTTP error (4xx/5xx) - do not retry
|
|
41
|
-
throw `${error.response.status}: ${JSON.stringify(error.response.data)}`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Network error (no response) - retry if attempts remain
|
|
45
|
-
if (attempt < retries) {
|
|
46
|
-
await this.delay(attempt * 1000);
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// Exhausted retries for network error
|
|
51
|
-
throw `Network error: ${error.message}`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Non-axios error - do not retry
|
|
55
|
-
throw `Request setup error: ${error instanceof Error ? error.message : String(error)}`;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
throw 'Unexpected: retry loop exited without returning or throwing';
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private delay(ms: number): Promise<void> {
|
|
63
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
64
|
-
}
|
|
65
34
|
}
|