@remote-logger/sdk 0.1.7 → 0.1.8
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/vite.js +28 -2
- package/dist/vite.mjs +29 -3
- package/package.json +1 -1
package/dist/vite.js
CHANGED
|
@@ -26,7 +26,10 @@ module.exports = __toCommonJS(vite_exports);
|
|
|
26
26
|
var import_crypto = require("crypto");
|
|
27
27
|
var import_fs = require("fs");
|
|
28
28
|
var import_path = require("path");
|
|
29
|
+
var import_os = require("os");
|
|
29
30
|
var DEFAULT_ENDPOINT = "https://log.terodato.com";
|
|
31
|
+
var RELEASE_FILE = (0, import_path.join)((0, import_os.tmpdir)(), ".remote-logger-release");
|
|
32
|
+
var RELEASE_FILE_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
30
33
|
function collectMapFiles(dir) {
|
|
31
34
|
const results = [];
|
|
32
35
|
try {
|
|
@@ -45,9 +48,32 @@ function collectMapFiles(dir) {
|
|
|
45
48
|
}
|
|
46
49
|
var sharedReleaseId = null;
|
|
47
50
|
var uploadedOutDirs = /* @__PURE__ */ new Set();
|
|
51
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
52
|
+
function getOrCreateReleaseId() {
|
|
53
|
+
if (sharedReleaseId) return sharedReleaseId;
|
|
54
|
+
try {
|
|
55
|
+
if ((0, import_fs.existsSync)(RELEASE_FILE)) {
|
|
56
|
+
const stat = (0, import_fs.statSync)(RELEASE_FILE);
|
|
57
|
+
if (Date.now() - stat.mtimeMs < RELEASE_FILE_MAX_AGE_MS) {
|
|
58
|
+
const id2 = (0, import_fs.readFileSync)(RELEASE_FILE, "utf-8").trim();
|
|
59
|
+
if (UUID_REGEX.test(id2)) {
|
|
60
|
+
sharedReleaseId = id2;
|
|
61
|
+
return id2;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
const id = (0, import_crypto.randomUUID)();
|
|
68
|
+
sharedReleaseId = id;
|
|
69
|
+
try {
|
|
70
|
+
(0, import_fs.writeFileSync)(RELEASE_FILE, id, "utf-8");
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
73
|
+
return id;
|
|
74
|
+
}
|
|
48
75
|
function remoteLoggerPlugin(options) {
|
|
49
|
-
|
|
50
|
-
const releaseId = sharedReleaseId;
|
|
76
|
+
const releaseId = getOrCreateReleaseId();
|
|
51
77
|
let resolvedConfig;
|
|
52
78
|
let skip = false;
|
|
53
79
|
return {
|
package/dist/vite.mjs
CHANGED
|
@@ -2,9 +2,12 @@ import "./chunk-JKIIIVNW.mjs";
|
|
|
2
2
|
|
|
3
3
|
// src/vite.ts
|
|
4
4
|
import { randomUUID } from "crypto";
|
|
5
|
-
import { readdirSync, readFileSync } from "fs";
|
|
5
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "fs";
|
|
6
6
|
import { join, relative } from "path";
|
|
7
|
+
import { tmpdir } from "os";
|
|
7
8
|
var DEFAULT_ENDPOINT = "https://log.terodato.com";
|
|
9
|
+
var RELEASE_FILE = join(tmpdir(), ".remote-logger-release");
|
|
10
|
+
var RELEASE_FILE_MAX_AGE_MS = 5 * 60 * 1e3;
|
|
8
11
|
function collectMapFiles(dir) {
|
|
9
12
|
const results = [];
|
|
10
13
|
try {
|
|
@@ -23,9 +26,32 @@ function collectMapFiles(dir) {
|
|
|
23
26
|
}
|
|
24
27
|
var sharedReleaseId = null;
|
|
25
28
|
var uploadedOutDirs = /* @__PURE__ */ new Set();
|
|
29
|
+
var UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
30
|
+
function getOrCreateReleaseId() {
|
|
31
|
+
if (sharedReleaseId) return sharedReleaseId;
|
|
32
|
+
try {
|
|
33
|
+
if (existsSync(RELEASE_FILE)) {
|
|
34
|
+
const stat = statSync(RELEASE_FILE);
|
|
35
|
+
if (Date.now() - stat.mtimeMs < RELEASE_FILE_MAX_AGE_MS) {
|
|
36
|
+
const id2 = readFileSync(RELEASE_FILE, "utf-8").trim();
|
|
37
|
+
if (UUID_REGEX.test(id2)) {
|
|
38
|
+
sharedReleaseId = id2;
|
|
39
|
+
return id2;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch {
|
|
44
|
+
}
|
|
45
|
+
const id = randomUUID();
|
|
46
|
+
sharedReleaseId = id;
|
|
47
|
+
try {
|
|
48
|
+
writeFileSync(RELEASE_FILE, id, "utf-8");
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
return id;
|
|
52
|
+
}
|
|
26
53
|
function remoteLoggerPlugin(options) {
|
|
27
|
-
|
|
28
|
-
const releaseId = sharedReleaseId;
|
|
54
|
+
const releaseId = getOrCreateReleaseId();
|
|
29
55
|
let resolvedConfig;
|
|
30
56
|
let skip = false;
|
|
31
57
|
return {
|