@glasstrace/sdk 0.11.0 → 0.12.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/dist/adapters/drizzle.js +1 -1
- package/dist/{chunk-2JUH3VGJ.js → chunk-6GRNJ722.js} +38 -17
- package/dist/chunk-6GRNJ722.js.map +1 -0
- package/dist/chunk-IPGOKORJ.js +580 -0
- package/dist/chunk-IPGOKORJ.js.map +1 -0
- package/dist/{chunk-M7RDFOFR.js → chunk-LW7DPKBA.js} +2 -2
- package/dist/{chunk-SLSWEQCC.js → chunk-MSMOH6IH.js} +108 -38
- package/dist/chunk-MSMOH6IH.js.map +1 -0
- package/dist/chunk-NSBPE2FW.js +17 -0
- package/dist/{chunk-D3JC3LAK.js → chunk-OKIP4SRG.js} +2 -2
- package/dist/cli/init.cjs +454 -329
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +25 -1
- package/dist/cli/init.d.ts +25 -1
- package/dist/cli/init.js +114 -4
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +60 -46
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +3 -3
- package/dist/cli/uninit.js +15 -564
- package/dist/cli/uninit.js.map +1 -1
- package/dist/{esm-POMEQPKL.js → esm-KBPHCVB4.js} +2 -2
- package/dist/{getMachineId-bsd-TC3JSTY5.js → getMachineId-bsd-345PYXFX.js} +2 -2
- package/dist/{getMachineId-darwin-2SUKQCE6.js → getMachineId-darwin-5L2D25AD.js} +2 -2
- package/dist/{getMachineId-linux-PNAFHLXH.js → getMachineId-linux-KJR4P5HN.js} +2 -2
- package/dist/{getMachineId-unsupported-L2MNYW3W.js → getMachineId-unsupported-NDNXDYDY.js} +2 -2
- package/dist/{getMachineId-win-D6D42WOQ.js → getMachineId-win-T7PJNJXG.js} +2 -2
- package/dist/index.cjs +297 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +51 -10
- package/dist/index.d.ts +51 -10
- package/dist/index.js +133 -78
- package/dist/index.js.map +1 -1
- package/dist/{source-map-uploader-OFEM54UE.js → source-map-uploader-ZFCYOURS.js} +6 -4
- package/package.json +1 -1
- package/dist/chunk-2JUH3VGJ.js.map +0 -1
- package/dist/chunk-PZ5AY32C.js +0 -10
- package/dist/chunk-SLSWEQCC.js.map +0 -1
- /package/dist/{chunk-M7RDFOFR.js.map → chunk-LW7DPKBA.js.map} +0 -0
- /package/dist/{chunk-PZ5AY32C.js.map → chunk-NSBPE2FW.js.map} +0 -0
- /package/dist/{chunk-D3JC3LAK.js.map → chunk-OKIP4SRG.js.map} +0 -0
- /package/dist/{esm-POMEQPKL.js.map → esm-KBPHCVB4.js.map} +0 -0
- /package/dist/{getMachineId-bsd-TC3JSTY5.js.map → getMachineId-bsd-345PYXFX.js.map} +0 -0
- /package/dist/{getMachineId-darwin-2SUKQCE6.js.map → getMachineId-darwin-5L2D25AD.js.map} +0 -0
- /package/dist/{getMachineId-linux-PNAFHLXH.js.map → getMachineId-linux-KJR4P5HN.js.map} +0 -0
- /package/dist/{getMachineId-unsupported-L2MNYW3W.js.map → getMachineId-unsupported-NDNXDYDY.js.map} +0 -0
- /package/dist/{getMachineId-win-D6D42WOQ.js.map → getMachineId-win-T7PJNJXG.js.map} +0 -0
- /package/dist/{source-map-uploader-OFEM54UE.js.map → source-map-uploader-ZFCYOURS.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -16252,6 +16252,16 @@ var init_esm = __esm({
|
|
|
16252
16252
|
function sanitize(input) {
|
|
16253
16253
|
return input.replace(/[\x00-\x1f\x7f]/g, "");
|
|
16254
16254
|
}
|
|
16255
|
+
function markerFileExists() {
|
|
16256
|
+
try {
|
|
16257
|
+
const fs4 = require("fs");
|
|
16258
|
+
const path4 = require("path");
|
|
16259
|
+
const markerPath = path4.join(process.cwd(), ".glasstrace", "mcp-connected");
|
|
16260
|
+
return fs4.existsSync(markerPath);
|
|
16261
|
+
} catch {
|
|
16262
|
+
return false;
|
|
16263
|
+
}
|
|
16264
|
+
}
|
|
16255
16265
|
function maybeShowMcpNudge(errorSummary) {
|
|
16256
16266
|
if (hasFired) {
|
|
16257
16267
|
return;
|
|
@@ -16261,14 +16271,7 @@ function maybeShowMcpNudge(errorSummary) {
|
|
|
16261
16271
|
hasFired = true;
|
|
16262
16272
|
return;
|
|
16263
16273
|
}
|
|
16264
|
-
|
|
16265
|
-
try {
|
|
16266
|
-
const markerPath = (0, import_node_path3.join)(process.cwd(), ".glasstrace", "mcp-connected");
|
|
16267
|
-
markerExists = (0, import_node_fs2.existsSync)(markerPath);
|
|
16268
|
-
} catch {
|
|
16269
|
-
markerExists = false;
|
|
16270
|
-
}
|
|
16271
|
-
if (markerExists) {
|
|
16274
|
+
if (markerFileExists()) {
|
|
16272
16275
|
hasFired = true;
|
|
16273
16276
|
return;
|
|
16274
16277
|
}
|
|
@@ -16281,12 +16284,10 @@ function maybeShowMcpNudge(errorSummary) {
|
|
|
16281
16284
|
`
|
|
16282
16285
|
);
|
|
16283
16286
|
}
|
|
16284
|
-
var
|
|
16287
|
+
var hasFired;
|
|
16285
16288
|
var init_error_nudge = __esm({
|
|
16286
16289
|
"src/nudge/error-nudge.ts"() {
|
|
16287
16290
|
"use strict";
|
|
16288
|
-
import_node_fs2 = require("fs");
|
|
16289
|
-
import_node_path3 = require("path");
|
|
16290
16291
|
init_env_detection();
|
|
16291
16292
|
hasFired = false;
|
|
16292
16293
|
}
|
|
@@ -16374,6 +16375,7 @@ __export(source_map_uploader_exports, {
|
|
|
16374
16375
|
PRESIGNED_THRESHOLD_BYTES: () => PRESIGNED_THRESHOLD_BYTES,
|
|
16375
16376
|
collectSourceMaps: () => collectSourceMaps,
|
|
16376
16377
|
computeBuildHash: () => computeBuildHash,
|
|
16378
|
+
discoverSourceMapFiles: () => discoverSourceMapFiles,
|
|
16377
16379
|
requestPresignedTokens: () => requestPresignedTokens,
|
|
16378
16380
|
submitManifest: () => submitManifest,
|
|
16379
16381
|
uploadSourceMaps: () => uploadSourceMaps,
|
|
@@ -16381,16 +16383,26 @@ __export(source_map_uploader_exports, {
|
|
|
16381
16383
|
uploadSourceMapsPresigned: () => uploadSourceMapsPresigned,
|
|
16382
16384
|
uploadToBlob: () => uploadToBlob
|
|
16383
16385
|
});
|
|
16384
|
-
async function
|
|
16386
|
+
async function discoverSourceMapFiles(buildDir) {
|
|
16387
|
+
const resolvedDir = path2.resolve(buildDir);
|
|
16385
16388
|
const results = [];
|
|
16386
16389
|
try {
|
|
16387
|
-
await
|
|
16390
|
+
await walkDirMetadata(resolvedDir, resolvedDir, results);
|
|
16388
16391
|
} catch {
|
|
16389
16392
|
return [];
|
|
16390
16393
|
}
|
|
16394
|
+
for (const file2 of results) {
|
|
16395
|
+
if (file2.sizeBytes >= LARGE_FILE_WARNING_BYTES) {
|
|
16396
|
+
const sizeMB = (file2.sizeBytes / (1024 * 1024)).toFixed(1);
|
|
16397
|
+
sdkLog(
|
|
16398
|
+
"warn",
|
|
16399
|
+
`[glasstrace] Large source map detected: ${file2.filePath} (${sizeMB}MB). Consider enabling source map compression.`
|
|
16400
|
+
);
|
|
16401
|
+
}
|
|
16402
|
+
}
|
|
16391
16403
|
return results;
|
|
16392
16404
|
}
|
|
16393
|
-
async function
|
|
16405
|
+
async function walkDirMetadata(baseDir, currentDir, results) {
|
|
16394
16406
|
let entries;
|
|
16395
16407
|
try {
|
|
16396
16408
|
entries = await fs2.readdir(currentDir, { withFileTypes: true });
|
|
@@ -16400,18 +16412,37 @@ async function walkDir(baseDir, currentDir, results) {
|
|
|
16400
16412
|
for (const entry of entries) {
|
|
16401
16413
|
const fullPath = path2.join(currentDir, entry.name);
|
|
16402
16414
|
if (entry.isDirectory()) {
|
|
16403
|
-
await
|
|
16415
|
+
await walkDirMetadata(baseDir, fullPath, results);
|
|
16404
16416
|
} else if (entry.isFile() && entry.name.endsWith(".map")) {
|
|
16405
16417
|
try {
|
|
16406
|
-
const
|
|
16418
|
+
const stat2 = await fs2.stat(fullPath);
|
|
16407
16419
|
const relativePath = path2.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
16408
16420
|
const compiledPath = relativePath.replace(/\.map$/, "");
|
|
16409
|
-
results.push({
|
|
16421
|
+
results.push({
|
|
16422
|
+
filePath: compiledPath,
|
|
16423
|
+
absolutePath: fullPath,
|
|
16424
|
+
sizeBytes: stat2.size
|
|
16425
|
+
});
|
|
16410
16426
|
} catch {
|
|
16411
16427
|
}
|
|
16412
16428
|
}
|
|
16413
16429
|
}
|
|
16414
16430
|
}
|
|
16431
|
+
async function readSourceMapContent(absolutePath) {
|
|
16432
|
+
return fs2.readFile(absolutePath, "utf-8");
|
|
16433
|
+
}
|
|
16434
|
+
async function collectSourceMaps(buildDir) {
|
|
16435
|
+
const fileInfos = await discoverSourceMapFiles(buildDir);
|
|
16436
|
+
const results = [];
|
|
16437
|
+
for (const info of fileInfos) {
|
|
16438
|
+
try {
|
|
16439
|
+
const content = await readSourceMapContent(info.absolutePath);
|
|
16440
|
+
results.push({ filePath: info.filePath, content });
|
|
16441
|
+
} catch {
|
|
16442
|
+
}
|
|
16443
|
+
}
|
|
16444
|
+
return results;
|
|
16445
|
+
}
|
|
16415
16446
|
async function computeBuildHash(maps) {
|
|
16416
16447
|
try {
|
|
16417
16448
|
const sha = (0, import_node_child_process.execFileSync)("git", ["rev-parse", "HEAD"], { encoding: "utf-8" }).trim();
|
|
@@ -16423,20 +16454,38 @@ async function computeBuildHash(maps) {
|
|
|
16423
16454
|
const sortedMaps = [...maps ?? []].sort(
|
|
16424
16455
|
(a, b) => a.filePath.localeCompare(b.filePath)
|
|
16425
16456
|
);
|
|
16426
|
-
const
|
|
16427
|
-
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16457
|
+
const hash2 = crypto2.createHash("sha256");
|
|
16458
|
+
for (const m of sortedMaps) {
|
|
16459
|
+
let content;
|
|
16460
|
+
if ("content" in m) {
|
|
16461
|
+
content = m.content;
|
|
16462
|
+
} else {
|
|
16463
|
+
try {
|
|
16464
|
+
content = await readSourceMapContent(m.absolutePath);
|
|
16465
|
+
} catch {
|
|
16466
|
+
continue;
|
|
16467
|
+
}
|
|
16468
|
+
}
|
|
16469
|
+
hash2.update(`${m.filePath}
|
|
16470
|
+
${content.length}
|
|
16471
|
+
${content}`);
|
|
16472
|
+
}
|
|
16473
|
+
return hash2.digest("hex");
|
|
16431
16474
|
}
|
|
16432
16475
|
async function uploadSourceMaps(apiKey, endpoint, buildHash, maps) {
|
|
16476
|
+
const files = [];
|
|
16477
|
+
for (const m of maps) {
|
|
16478
|
+
try {
|
|
16479
|
+
const content = "content" in m ? m.content : await readSourceMapContent(m.absolutePath);
|
|
16480
|
+
files.push({ filePath: m.filePath, sourceMap: content });
|
|
16481
|
+
} catch {
|
|
16482
|
+
sdkLog("warn", `[glasstrace] Skipping unreadable source map: ${m.filePath}`);
|
|
16483
|
+
}
|
|
16484
|
+
}
|
|
16433
16485
|
const body = {
|
|
16434
16486
|
apiKey,
|
|
16435
16487
|
buildHash,
|
|
16436
|
-
files
|
|
16437
|
-
filePath: m.filePath,
|
|
16438
|
-
sourceMap: m.content
|
|
16439
|
-
}))
|
|
16488
|
+
files
|
|
16440
16489
|
};
|
|
16441
16490
|
const baseUrl = stripTrailingSlashes(endpoint);
|
|
16442
16491
|
const response = await fetch(`${baseUrl}/v1/source-maps`, {
|
|
@@ -16533,14 +16582,15 @@ async function uploadSourceMapsPresigned(apiKey, endpoint, buildHash, maps, blob
|
|
|
16533
16582
|
if (maps.length === 0) {
|
|
16534
16583
|
throw new Error("No source maps to upload");
|
|
16535
16584
|
}
|
|
16585
|
+
const fileMetadata = maps.map((m) => ({
|
|
16586
|
+
filePath: m.filePath,
|
|
16587
|
+
sizeBytes: "content" in m ? Buffer.byteLength(m.content, "utf-8") : m.sizeBytes
|
|
16588
|
+
}));
|
|
16536
16589
|
const presigned = await requestPresignedTokens(
|
|
16537
16590
|
apiKey,
|
|
16538
16591
|
endpoint,
|
|
16539
16592
|
buildHash,
|
|
16540
|
-
|
|
16541
|
-
filePath: m.filePath,
|
|
16542
|
-
sizeBytes: Buffer.byteLength(m.content, "utf-8")
|
|
16543
|
-
}))
|
|
16593
|
+
fileMetadata
|
|
16544
16594
|
);
|
|
16545
16595
|
const mapsByPath = new Map(maps.map((m) => [m.filePath, m]));
|
|
16546
16596
|
if (mapsByPath.size !== maps.length) {
|
|
@@ -16560,7 +16610,18 @@ async function uploadSourceMapsPresigned(apiKey, endpoint, buildHash, maps, blob
|
|
|
16560
16610
|
const chunkResults = await Promise.all(
|
|
16561
16611
|
chunk.map(async (token) => {
|
|
16562
16612
|
const entry = mapsByPath.get(token.filePath);
|
|
16563
|
-
|
|
16613
|
+
let content;
|
|
16614
|
+
if ("content" in entry) {
|
|
16615
|
+
content = entry.content;
|
|
16616
|
+
} else {
|
|
16617
|
+
try {
|
|
16618
|
+
content = await readSourceMapContent(entry.absolutePath);
|
|
16619
|
+
} catch {
|
|
16620
|
+
sdkLog("warn", `[glasstrace] Skipping unreadable source map: ${token.filePath}`);
|
|
16621
|
+
return null;
|
|
16622
|
+
}
|
|
16623
|
+
}
|
|
16624
|
+
const result = await blobUploader(token.clientToken, token.pathname, content);
|
|
16564
16625
|
return {
|
|
16565
16626
|
filePath: token.filePath,
|
|
16566
16627
|
sizeBytes: result.size,
|
|
@@ -16568,7 +16629,11 @@ async function uploadSourceMapsPresigned(apiKey, endpoint, buildHash, maps, blob
|
|
|
16568
16629
|
};
|
|
16569
16630
|
})
|
|
16570
16631
|
);
|
|
16571
|
-
|
|
16632
|
+
for (const r of chunkResults) {
|
|
16633
|
+
if (r !== null) {
|
|
16634
|
+
uploadResults.push(r);
|
|
16635
|
+
}
|
|
16636
|
+
}
|
|
16572
16637
|
}
|
|
16573
16638
|
return submitManifest(apiKey, endpoint, presigned.uploadId, buildHash, uploadResults);
|
|
16574
16639
|
}
|
|
@@ -16577,7 +16642,10 @@ async function uploadSourceMapsAuto(apiKey, endpoint, buildHash, maps, options)
|
|
|
16577
16642
|
throw new Error("No source maps to upload");
|
|
16578
16643
|
}
|
|
16579
16644
|
const totalBytes = maps.reduce(
|
|
16580
|
-
(sum, m) =>
|
|
16645
|
+
(sum, m) => {
|
|
16646
|
+
const bytes = "content" in m ? Buffer.byteLength(m.content, "utf-8") : m.sizeBytes;
|
|
16647
|
+
return sum + bytes;
|
|
16648
|
+
},
|
|
16581
16649
|
0
|
|
16582
16650
|
);
|
|
16583
16651
|
if (totalBytes < PRESIGNED_THRESHOLD_BYTES) {
|
|
@@ -16603,11 +16671,11 @@ async function uploadSourceMapsAuto(apiKey, endpoint, buildHash, maps, options)
|
|
|
16603
16671
|
}
|
|
16604
16672
|
sdkLog(
|
|
16605
16673
|
"warn",
|
|
16606
|
-
`[glasstrace] Build exceeds 4.5MB (${totalBytes} bytes). Install @vercel/blob for presigned uploads to avoid serverless body size limits. Falling back to legacy upload.`
|
|
16674
|
+
`[glasstrace] Build exceeds 4.5MB (${String(totalBytes)} bytes). Install @vercel/blob for presigned uploads to avoid serverless body size limits. Falling back to legacy upload.`
|
|
16607
16675
|
);
|
|
16608
16676
|
return uploadSourceMaps(apiKey, endpoint, buildHash, maps);
|
|
16609
16677
|
}
|
|
16610
|
-
var fs2, path2, crypto2, import_node_child_process, PRESIGNED_THRESHOLD_BYTES;
|
|
16678
|
+
var fs2, path2, crypto2, import_node_child_process, LARGE_FILE_WARNING_BYTES, PRESIGNED_THRESHOLD_BYTES;
|
|
16611
16679
|
var init_source_map_uploader = __esm({
|
|
16612
16680
|
"src/source-map-uploader.ts"() {
|
|
16613
16681
|
"use strict";
|
|
@@ -16617,6 +16685,7 @@ var init_source_map_uploader = __esm({
|
|
|
16617
16685
|
import_node_child_process = require("child_process");
|
|
16618
16686
|
init_console_capture();
|
|
16619
16687
|
init_dist();
|
|
16688
|
+
LARGE_FILE_WARNING_BYTES = 50 * 1024 * 1024;
|
|
16620
16689
|
PRESIGNED_THRESHOLD_BYTES = 45e5;
|
|
16621
16690
|
}
|
|
16622
16691
|
});
|
|
@@ -16636,6 +16705,7 @@ __export(src_exports, {
|
|
|
16636
16705
|
computeBuildHash: () => computeBuildHash,
|
|
16637
16706
|
createDiscoveryHandler: () => createDiscoveryHandler,
|
|
16638
16707
|
deriveSessionId: () => deriveSessionId,
|
|
16708
|
+
discoverSourceMapFiles: () => discoverSourceMapFiles,
|
|
16639
16709
|
discoverTestFiles: () => discoverTestFiles,
|
|
16640
16710
|
extractImports: () => extractImports,
|
|
16641
16711
|
getActiveConfig: () => getActiveConfig,
|
|
@@ -16675,14 +16745,37 @@ var SdkError = class extends Error {
|
|
|
16675
16745
|
init_env_detection();
|
|
16676
16746
|
|
|
16677
16747
|
// src/session.ts
|
|
16678
|
-
var import_node_crypto = require("crypto");
|
|
16679
16748
|
init_dist();
|
|
16680
16749
|
var FOUR_HOURS_MS = 4 * 60 * 60 * 1e3;
|
|
16750
|
+
var hashFn = null;
|
|
16751
|
+
function fnv1aHash(input) {
|
|
16752
|
+
let hash2 = 2166136261;
|
|
16753
|
+
for (let i = 0; i < input.length; i++) {
|
|
16754
|
+
hash2 ^= input.charCodeAt(i);
|
|
16755
|
+
hash2 = Math.imul(hash2, 16777619);
|
|
16756
|
+
hash2 >>>= 0;
|
|
16757
|
+
}
|
|
16758
|
+
return hash2.toString(16).padStart(8, "0");
|
|
16759
|
+
}
|
|
16760
|
+
function getHashFn() {
|
|
16761
|
+
if (hashFn) return hashFn;
|
|
16762
|
+
try {
|
|
16763
|
+
const { createHash: createHash3 } = require("crypto");
|
|
16764
|
+
hashFn = (input) => createHash3("sha256").update(input).digest("hex").slice(0, 16);
|
|
16765
|
+
} catch {
|
|
16766
|
+
hashFn = (input) => {
|
|
16767
|
+
const h1 = fnv1aHash(input);
|
|
16768
|
+
const h2 = fnv1aHash(input + "\0");
|
|
16769
|
+
return (h1 + h2).slice(0, 16);
|
|
16770
|
+
};
|
|
16771
|
+
}
|
|
16772
|
+
return hashFn;
|
|
16773
|
+
}
|
|
16681
16774
|
var cachedGlasstraceEnv = process.env.GLASSTRACE_ENV;
|
|
16682
16775
|
var cachedPort = process.env.PORT ?? "3000";
|
|
16683
16776
|
function deriveSessionId(apiKey, origin, date5, windowIndex) {
|
|
16684
16777
|
const input = JSON.stringify([apiKey, origin, date5, windowIndex]);
|
|
16685
|
-
const hash2 = (
|
|
16778
|
+
const hash2 = getHashFn()(input);
|
|
16686
16779
|
return SessionIdSchema.parse(hash2);
|
|
16687
16780
|
}
|
|
16688
16781
|
function getOrigin() {
|
|
@@ -16768,22 +16861,38 @@ function classifyFetchTarget(url2) {
|
|
|
16768
16861
|
}
|
|
16769
16862
|
|
|
16770
16863
|
// src/anon-key.ts
|
|
16771
|
-
var import_promises = require("fs/promises");
|
|
16772
|
-
var import_node_path = require("path");
|
|
16773
16864
|
init_dist();
|
|
16774
16865
|
var GLASSTRACE_DIR = ".glasstrace";
|
|
16775
16866
|
var ANON_KEY_FILE = "anon_key";
|
|
16867
|
+
var fsPathCache;
|
|
16868
|
+
async function loadFsPath() {
|
|
16869
|
+
if (fsPathCache !== void 0) return fsPathCache;
|
|
16870
|
+
try {
|
|
16871
|
+
const [fs4, path4] = await Promise.all([
|
|
16872
|
+
import("fs/promises"),
|
|
16873
|
+
import("path")
|
|
16874
|
+
]);
|
|
16875
|
+
fsPathCache = { fs: fs4, path: path4 };
|
|
16876
|
+
return fsPathCache;
|
|
16877
|
+
} catch {
|
|
16878
|
+
fsPathCache = null;
|
|
16879
|
+
return null;
|
|
16880
|
+
}
|
|
16881
|
+
}
|
|
16776
16882
|
var ephemeralKeyCache = /* @__PURE__ */ new Map();
|
|
16777
16883
|
async function readAnonKey(projectRoot) {
|
|
16778
16884
|
const root = projectRoot ?? process.cwd();
|
|
16779
|
-
const
|
|
16780
|
-
|
|
16781
|
-
const
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16885
|
+
const modules = await loadFsPath();
|
|
16886
|
+
if (modules) {
|
|
16887
|
+
const keyPath = modules.path.join(root, GLASSTRACE_DIR, ANON_KEY_FILE);
|
|
16888
|
+
try {
|
|
16889
|
+
const content = await modules.fs.readFile(keyPath, "utf-8");
|
|
16890
|
+
const result = AnonApiKeySchema.safeParse(content);
|
|
16891
|
+
if (result.success) {
|
|
16892
|
+
return result.data;
|
|
16893
|
+
}
|
|
16894
|
+
} catch {
|
|
16785
16895
|
}
|
|
16786
|
-
} catch {
|
|
16787
16896
|
}
|
|
16788
16897
|
const cached2 = ephemeralKeyCache.get(root);
|
|
16789
16898
|
if (cached2 !== void 0) {
|
|
@@ -16793,8 +16902,6 @@ async function readAnonKey(projectRoot) {
|
|
|
16793
16902
|
}
|
|
16794
16903
|
async function getOrCreateAnonKey(projectRoot) {
|
|
16795
16904
|
const root = projectRoot ?? process.cwd();
|
|
16796
|
-
const dirPath = (0, import_node_path.join)(root, GLASSTRACE_DIR);
|
|
16797
|
-
const keyPath = (0, import_node_path.join)(dirPath, ANON_KEY_FILE);
|
|
16798
16905
|
const existingKey = await readAnonKey(root);
|
|
16799
16906
|
if (existingKey !== null) {
|
|
16800
16907
|
return existingKey;
|
|
@@ -16804,9 +16911,16 @@ async function getOrCreateAnonKey(projectRoot) {
|
|
|
16804
16911
|
return cached2;
|
|
16805
16912
|
}
|
|
16806
16913
|
const newKey = createAnonApiKey();
|
|
16914
|
+
const modules = await loadFsPath();
|
|
16915
|
+
if (!modules) {
|
|
16916
|
+
ephemeralKeyCache.set(root, newKey);
|
|
16917
|
+
return newKey;
|
|
16918
|
+
}
|
|
16919
|
+
const dirPath = modules.path.join(root, GLASSTRACE_DIR);
|
|
16920
|
+
const keyPath = modules.path.join(dirPath, ANON_KEY_FILE);
|
|
16807
16921
|
try {
|
|
16808
|
-
await
|
|
16809
|
-
await
|
|
16922
|
+
await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
|
|
16923
|
+
await modules.fs.writeFile(keyPath, newKey, { flag: "wx", mode: 384 });
|
|
16810
16924
|
return newKey;
|
|
16811
16925
|
} catch (err) {
|
|
16812
16926
|
const code = err.code;
|
|
@@ -16817,12 +16931,12 @@ async function getOrCreateAnonKey(projectRoot) {
|
|
|
16817
16931
|
return winnerKey;
|
|
16818
16932
|
}
|
|
16819
16933
|
if (attempt < 2) {
|
|
16820
|
-
await new Promise((
|
|
16934
|
+
await new Promise((resolve3) => setTimeout(resolve3, 50));
|
|
16821
16935
|
}
|
|
16822
16936
|
}
|
|
16823
16937
|
try {
|
|
16824
|
-
await
|
|
16825
|
-
await
|
|
16938
|
+
await modules.fs.writeFile(keyPath, newKey, { mode: 384 });
|
|
16939
|
+
await modules.fs.chmod(keyPath, 384);
|
|
16826
16940
|
return newKey;
|
|
16827
16941
|
} catch {
|
|
16828
16942
|
}
|
|
@@ -16836,22 +16950,45 @@ async function getOrCreateAnonKey(projectRoot) {
|
|
|
16836
16950
|
}
|
|
16837
16951
|
|
|
16838
16952
|
// src/init-client.ts
|
|
16839
|
-
var import_node_fs = require("fs");
|
|
16840
|
-
var import_promises2 = require("fs/promises");
|
|
16841
|
-
var import_node_path2 = require("path");
|
|
16842
16953
|
init_dist();
|
|
16843
16954
|
var GLASSTRACE_DIR2 = ".glasstrace";
|
|
16844
16955
|
var CONFIG_FILE = "config";
|
|
16845
16956
|
var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
|
|
16846
16957
|
var INIT_TIMEOUT_MS = 1e4;
|
|
16958
|
+
var fsPathAsyncCache;
|
|
16959
|
+
async function loadFsPathAsync() {
|
|
16960
|
+
if (fsPathAsyncCache !== void 0) return fsPathAsyncCache;
|
|
16961
|
+
try {
|
|
16962
|
+
const [fs4, path4] = await Promise.all([
|
|
16963
|
+
import("fs/promises"),
|
|
16964
|
+
import("path")
|
|
16965
|
+
]);
|
|
16966
|
+
fsPathAsyncCache = { fs: fs4, path: path4 };
|
|
16967
|
+
return fsPathAsyncCache;
|
|
16968
|
+
} catch {
|
|
16969
|
+
fsPathAsyncCache = null;
|
|
16970
|
+
return null;
|
|
16971
|
+
}
|
|
16972
|
+
}
|
|
16973
|
+
function loadFsSyncOrNull() {
|
|
16974
|
+
try {
|
|
16975
|
+
const fs4 = require("fs");
|
|
16976
|
+
const path4 = require("path");
|
|
16977
|
+
return { readFileSync: fs4.readFileSync, join: path4.join };
|
|
16978
|
+
} catch {
|
|
16979
|
+
return null;
|
|
16980
|
+
}
|
|
16981
|
+
}
|
|
16847
16982
|
var currentConfig = null;
|
|
16848
16983
|
var configCacheChecked = false;
|
|
16849
16984
|
var rateLimitBackoff = false;
|
|
16850
16985
|
function loadCachedConfig(projectRoot) {
|
|
16986
|
+
const modules = loadFsSyncOrNull();
|
|
16987
|
+
if (!modules) return null;
|
|
16851
16988
|
const root = projectRoot ?? process.cwd();
|
|
16852
|
-
const configPath =
|
|
16989
|
+
const configPath = modules.join(root, GLASSTRACE_DIR2, CONFIG_FILE);
|
|
16853
16990
|
try {
|
|
16854
|
-
const content =
|
|
16991
|
+
const content = modules.readFileSync(configPath, "utf-8");
|
|
16855
16992
|
const parsed = JSON.parse(content);
|
|
16856
16993
|
const cached2 = SdkCachedConfigSchema.parse(parsed);
|
|
16857
16994
|
const age = Date.now() - cached2.cachedAt;
|
|
@@ -16871,18 +17008,20 @@ function loadCachedConfig(projectRoot) {
|
|
|
16871
17008
|
}
|
|
16872
17009
|
}
|
|
16873
17010
|
async function saveCachedConfig(response, projectRoot) {
|
|
17011
|
+
const modules = await loadFsPathAsync();
|
|
17012
|
+
if (!modules) return;
|
|
16874
17013
|
const root = projectRoot ?? process.cwd();
|
|
16875
|
-
const dirPath =
|
|
16876
|
-
const configPath =
|
|
17014
|
+
const dirPath = modules.path.join(root, GLASSTRACE_DIR2);
|
|
17015
|
+
const configPath = modules.path.join(dirPath, CONFIG_FILE);
|
|
16877
17016
|
try {
|
|
16878
|
-
await
|
|
16879
|
-
await
|
|
17017
|
+
await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
|
|
17018
|
+
await modules.fs.chmod(dirPath, 448);
|
|
16880
17019
|
const cached2 = {
|
|
16881
17020
|
response,
|
|
16882
17021
|
cachedAt: Date.now()
|
|
16883
17022
|
};
|
|
16884
|
-
await
|
|
16885
|
-
await
|
|
17023
|
+
await modules.fs.writeFile(configPath, JSON.stringify(cached2), { encoding: "utf-8", mode: 384 });
|
|
17024
|
+
await modules.fs.chmod(configPath, 384);
|
|
16886
17025
|
} catch (err) {
|
|
16887
17026
|
console.warn(
|
|
16888
17027
|
`[glasstrace] Failed to cache config to ${configPath}: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -16936,69 +17075,72 @@ async function sendInitRequest(config2, anonKey, sdkVersion, importGraph, health
|
|
|
16936
17075
|
return SdkInitResponseSchema.parse(body);
|
|
16937
17076
|
}
|
|
16938
17077
|
async function writeClaimedKey(newApiKey, projectRoot) {
|
|
16939
|
-
const
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
let
|
|
17078
|
+
const modules = await loadFsPathAsync();
|
|
17079
|
+
if (modules) {
|
|
17080
|
+
const root = projectRoot ?? process.cwd();
|
|
17081
|
+
const envLocalPath = modules.path.join(root, ".env.local");
|
|
17082
|
+
let envLocalWritten = false;
|
|
16944
17083
|
try {
|
|
16945
|
-
content
|
|
16946
|
-
|
|
16947
|
-
content =
|
|
16948
|
-
|
|
16949
|
-
|
|
16950
|
-
|
|
16951
|
-
|
|
16952
|
-
|
|
16953
|
-
|
|
17084
|
+
let content;
|
|
17085
|
+
try {
|
|
17086
|
+
content = await modules.fs.readFile(envLocalPath, "utf-8");
|
|
17087
|
+
if (/^GLASSTRACE_API_KEY=.*/m.test(content)) {
|
|
17088
|
+
content = content.replace(
|
|
17089
|
+
/^GLASSTRACE_API_KEY=.*$/gm,
|
|
17090
|
+
`GLASSTRACE_API_KEY=${newApiKey}`
|
|
17091
|
+
);
|
|
17092
|
+
} else {
|
|
17093
|
+
if (content.length > 0 && !content.endsWith("\n")) {
|
|
17094
|
+
content += "\n";
|
|
17095
|
+
}
|
|
17096
|
+
content += `GLASSTRACE_API_KEY=${newApiKey}
|
|
17097
|
+
`;
|
|
17098
|
+
}
|
|
17099
|
+
} catch (readErr) {
|
|
17100
|
+
const code = readErr instanceof Error ? readErr.code : void 0;
|
|
17101
|
+
if (code !== "ENOENT") {
|
|
17102
|
+
throw readErr;
|
|
16954
17103
|
}
|
|
16955
|
-
content
|
|
17104
|
+
content = `GLASSTRACE_API_KEY=${newApiKey}
|
|
16956
17105
|
`;
|
|
16957
17106
|
}
|
|
16958
|
-
|
|
16959
|
-
|
|
16960
|
-
|
|
16961
|
-
|
|
17107
|
+
await modules.fs.writeFile(envLocalPath, content, { encoding: "utf-8", mode: 384 });
|
|
17108
|
+
await modules.fs.chmod(envLocalPath, 384);
|
|
17109
|
+
envLocalWritten = true;
|
|
17110
|
+
} catch {
|
|
17111
|
+
}
|
|
17112
|
+
if (envLocalWritten) {
|
|
17113
|
+
try {
|
|
17114
|
+
process.stderr.write(
|
|
17115
|
+
"[glasstrace] Account claimed! API key written to .env.local. Restart your dev server to use it.\n"
|
|
17116
|
+
);
|
|
17117
|
+
} catch {
|
|
16962
17118
|
}
|
|
16963
|
-
|
|
16964
|
-
`;
|
|
17119
|
+
return;
|
|
16965
17120
|
}
|
|
16966
|
-
|
|
16967
|
-
await (0, import_promises2.chmod)(envLocalPath, 384);
|
|
16968
|
-
envLocalWritten = true;
|
|
16969
|
-
} catch {
|
|
16970
|
-
}
|
|
16971
|
-
if (envLocalWritten) {
|
|
17121
|
+
let claimedKeyWritten = false;
|
|
16972
17122
|
try {
|
|
16973
|
-
|
|
16974
|
-
|
|
16975
|
-
);
|
|
17123
|
+
const dirPath = modules.path.join(root, GLASSTRACE_DIR2);
|
|
17124
|
+
await modules.fs.mkdir(dirPath, { recursive: true, mode: 448 });
|
|
17125
|
+
await modules.fs.chmod(dirPath, 448);
|
|
17126
|
+
const claimedKeyPath = modules.path.join(dirPath, "claimed-key");
|
|
17127
|
+
await modules.fs.writeFile(claimedKeyPath, newApiKey, {
|
|
17128
|
+
encoding: "utf-8",
|
|
17129
|
+
mode: 384
|
|
17130
|
+
});
|
|
17131
|
+
await modules.fs.chmod(claimedKeyPath, 384);
|
|
17132
|
+
claimedKeyWritten = true;
|
|
16976
17133
|
} catch {
|
|
16977
17134
|
}
|
|
16978
|
-
|
|
16979
|
-
|
|
16980
|
-
|
|
16981
|
-
|
|
16982
|
-
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
|
|
16986
|
-
await (0, import_promises2.writeFile)(claimedKeyPath, newApiKey, {
|
|
16987
|
-
encoding: "utf-8",
|
|
16988
|
-
mode: 384
|
|
16989
|
-
});
|
|
16990
|
-
await (0, import_promises2.chmod)(claimedKeyPath, 384);
|
|
16991
|
-
claimedKeyWritten = true;
|
|
16992
|
-
} catch {
|
|
16993
|
-
}
|
|
16994
|
-
if (claimedKeyWritten) {
|
|
16995
|
-
try {
|
|
16996
|
-
process.stderr.write(
|
|
16997
|
-
"[glasstrace] Account claimed! API key written to .glasstrace/claimed-key. Copy it to your .env.local file.\n"
|
|
16998
|
-
);
|
|
16999
|
-
} catch {
|
|
17135
|
+
if (claimedKeyWritten) {
|
|
17136
|
+
try {
|
|
17137
|
+
process.stderr.write(
|
|
17138
|
+
"[glasstrace] Account claimed! API key written to .glasstrace/claimed-key. Copy it to your .env.local file.\n"
|
|
17139
|
+
);
|
|
17140
|
+
} catch {
|
|
17141
|
+
}
|
|
17142
|
+
return;
|
|
17000
17143
|
}
|
|
17001
|
-
return;
|
|
17002
17144
|
}
|
|
17003
17145
|
try {
|
|
17004
17146
|
process.stderr.write(
|
|
@@ -18017,8 +18159,8 @@ var Deferred = class {
|
|
|
18017
18159
|
_resolve;
|
|
18018
18160
|
_reject;
|
|
18019
18161
|
constructor() {
|
|
18020
|
-
this._promise = new Promise((
|
|
18021
|
-
this._resolve =
|
|
18162
|
+
this._promise = new Promise((resolve3, reject) => {
|
|
18163
|
+
this._resolve = resolve3;
|
|
18022
18164
|
this._reject = reject;
|
|
18023
18165
|
});
|
|
18024
18166
|
}
|
|
@@ -18636,7 +18778,7 @@ var VERSION3 = "0.214.0";
|
|
|
18636
18778
|
// ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/transport/http-transport-utils.js
|
|
18637
18779
|
var DEFAULT_USER_AGENT = `OTel-OTLP-Exporter-JavaScript/${VERSION3}`;
|
|
18638
18780
|
function sendWithHttp(request, url2, headers, compression, userAgent, agent, data, timeoutMillis) {
|
|
18639
|
-
return new Promise((
|
|
18781
|
+
return new Promise((resolve3) => {
|
|
18640
18782
|
const parsedUrl = new URL(url2);
|
|
18641
18783
|
if (userAgent) {
|
|
18642
18784
|
headers["User-Agent"] = `${userAgent} ${DEFAULT_USER_AGENT}`;
|
|
@@ -18656,18 +18798,18 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
|
|
|
18656
18798
|
res.on("data", (chunk) => responseData.push(chunk));
|
|
18657
18799
|
res.on("end", () => {
|
|
18658
18800
|
if (res.statusCode && res.statusCode <= 299) {
|
|
18659
|
-
|
|
18801
|
+
resolve3({
|
|
18660
18802
|
status: "success",
|
|
18661
18803
|
data: Buffer.concat(responseData)
|
|
18662
18804
|
});
|
|
18663
18805
|
} else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
|
|
18664
|
-
|
|
18806
|
+
resolve3({
|
|
18665
18807
|
status: "retryable",
|
|
18666
18808
|
retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
|
|
18667
18809
|
});
|
|
18668
18810
|
} else {
|
|
18669
18811
|
const error48 = new OTLPExporterError(res.statusMessage, res.statusCode, Buffer.concat(responseData).toString());
|
|
18670
|
-
|
|
18812
|
+
resolve3({
|
|
18671
18813
|
status: "failure",
|
|
18672
18814
|
error: error48
|
|
18673
18815
|
});
|
|
@@ -18675,17 +18817,17 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
|
|
|
18675
18817
|
});
|
|
18676
18818
|
res.on("error", (error48) => {
|
|
18677
18819
|
if (res.statusCode && res.statusCode <= 299) {
|
|
18678
|
-
|
|
18820
|
+
resolve3({
|
|
18679
18821
|
status: "success"
|
|
18680
18822
|
});
|
|
18681
18823
|
} else if (res.statusCode && isExportHTTPErrorRetryable(res.statusCode)) {
|
|
18682
|
-
|
|
18824
|
+
resolve3({
|
|
18683
18825
|
status: "retryable",
|
|
18684
18826
|
error: error48,
|
|
18685
18827
|
retryInMillis: parseRetryAfterToMills(res.headers["retry-after"])
|
|
18686
18828
|
});
|
|
18687
18829
|
} else {
|
|
18688
|
-
|
|
18830
|
+
resolve3({
|
|
18689
18831
|
status: "failure",
|
|
18690
18832
|
error: error48
|
|
18691
18833
|
});
|
|
@@ -18694,26 +18836,26 @@ function sendWithHttp(request, url2, headers, compression, userAgent, agent, dat
|
|
|
18694
18836
|
});
|
|
18695
18837
|
req.setTimeout(timeoutMillis, () => {
|
|
18696
18838
|
req.destroy();
|
|
18697
|
-
|
|
18839
|
+
resolve3({
|
|
18698
18840
|
status: "retryable",
|
|
18699
18841
|
error: new Error("Request timed out")
|
|
18700
18842
|
});
|
|
18701
18843
|
});
|
|
18702
18844
|
req.on("error", (error48) => {
|
|
18703
18845
|
if (isHttpTransportNetworkErrorRetryable(error48)) {
|
|
18704
|
-
|
|
18846
|
+
resolve3({
|
|
18705
18847
|
status: "retryable",
|
|
18706
18848
|
error: error48
|
|
18707
18849
|
});
|
|
18708
18850
|
} else {
|
|
18709
|
-
|
|
18851
|
+
resolve3({
|
|
18710
18852
|
status: "failure",
|
|
18711
18853
|
error: error48
|
|
18712
18854
|
});
|
|
18713
18855
|
}
|
|
18714
18856
|
});
|
|
18715
18857
|
compressAndSend(req, compression, data, (error48) => {
|
|
18716
|
-
|
|
18858
|
+
resolve3({
|
|
18717
18859
|
status: "failure",
|
|
18718
18860
|
error: error48
|
|
18719
18861
|
});
|
|
@@ -18803,9 +18945,9 @@ var RetryingTransport = class {
|
|
|
18803
18945
|
this._transport = transport;
|
|
18804
18946
|
}
|
|
18805
18947
|
retry(data, timeoutMillis, inMillis) {
|
|
18806
|
-
return new Promise((
|
|
18948
|
+
return new Promise((resolve3, reject) => {
|
|
18807
18949
|
setTimeout(() => {
|
|
18808
|
-
this._transport.send(data, timeoutMillis).then(
|
|
18950
|
+
this._transport.send(data, timeoutMillis).then(resolve3, reject);
|
|
18809
18951
|
}, inMillis);
|
|
18810
18952
|
});
|
|
18811
18953
|
}
|
|
@@ -19669,14 +19811,14 @@ var BatchSpanProcessorBase = class {
|
|
|
19669
19811
|
* for all other cases _flush should be used
|
|
19670
19812
|
* */
|
|
19671
19813
|
_flushAll() {
|
|
19672
|
-
return new Promise((
|
|
19814
|
+
return new Promise((resolve3, reject) => {
|
|
19673
19815
|
const promises = [];
|
|
19674
19816
|
const count = Math.ceil(this._finishedSpans.length / this._maxExportBatchSize);
|
|
19675
19817
|
for (let i = 0, j = count; i < j; i++) {
|
|
19676
19818
|
promises.push(this._flushOneBatch());
|
|
19677
19819
|
}
|
|
19678
19820
|
Promise.all(promises).then(() => {
|
|
19679
|
-
|
|
19821
|
+
resolve3();
|
|
19680
19822
|
}).catch(reject);
|
|
19681
19823
|
});
|
|
19682
19824
|
}
|
|
@@ -19685,7 +19827,7 @@ var BatchSpanProcessorBase = class {
|
|
|
19685
19827
|
if (this._finishedSpans.length === 0) {
|
|
19686
19828
|
return Promise.resolve();
|
|
19687
19829
|
}
|
|
19688
|
-
return new Promise((
|
|
19830
|
+
return new Promise((resolve3, reject) => {
|
|
19689
19831
|
const timer = setTimeout(() => {
|
|
19690
19832
|
reject(new Error("Timeout"));
|
|
19691
19833
|
}, this._exportTimeoutMillis);
|
|
@@ -19700,7 +19842,7 @@ var BatchSpanProcessorBase = class {
|
|
|
19700
19842
|
const doExport = () => this._exporter.export(spans, (result) => {
|
|
19701
19843
|
clearTimeout(timer);
|
|
19702
19844
|
if (result.code === ExportResultCode.SUCCESS) {
|
|
19703
|
-
|
|
19845
|
+
resolve3();
|
|
19704
19846
|
} else {
|
|
19705
19847
|
reject(result.error ?? new Error("BatchSpanProcessor: span export failed"));
|
|
19706
19848
|
}
|
|
@@ -19987,12 +20129,12 @@ var MultiSpanProcessor = class {
|
|
|
19987
20129
|
for (const spanProcessor of this._spanProcessors) {
|
|
19988
20130
|
promises.push(spanProcessor.forceFlush());
|
|
19989
20131
|
}
|
|
19990
|
-
return new Promise((
|
|
20132
|
+
return new Promise((resolve3) => {
|
|
19991
20133
|
Promise.all(promises).then(() => {
|
|
19992
|
-
|
|
20134
|
+
resolve3();
|
|
19993
20135
|
}).catch((error48) => {
|
|
19994
20136
|
globalErrorHandler(error48 || new Error("MultiSpanProcessor: forceFlush failed"));
|
|
19995
|
-
|
|
20137
|
+
resolve3();
|
|
19996
20138
|
});
|
|
19997
20139
|
});
|
|
19998
20140
|
}
|
|
@@ -20018,9 +20160,9 @@ var MultiSpanProcessor = class {
|
|
|
20018
20160
|
for (const spanProcessor of this._spanProcessors) {
|
|
20019
20161
|
promises.push(spanProcessor.shutdown());
|
|
20020
20162
|
}
|
|
20021
|
-
return new Promise((
|
|
20163
|
+
return new Promise((resolve3, reject) => {
|
|
20022
20164
|
Promise.all(promises).then(() => {
|
|
20023
|
-
|
|
20165
|
+
resolve3();
|
|
20024
20166
|
}, reject);
|
|
20025
20167
|
});
|
|
20026
20168
|
}
|
|
@@ -20061,32 +20203,32 @@ var BasicTracerProvider = class {
|
|
|
20061
20203
|
forceFlush() {
|
|
20062
20204
|
const timeout = this._config.forceFlushTimeoutMillis;
|
|
20063
20205
|
const promises = this._activeSpanProcessor["_spanProcessors"].map((spanProcessor) => {
|
|
20064
|
-
return new Promise((
|
|
20206
|
+
return new Promise((resolve3) => {
|
|
20065
20207
|
let state;
|
|
20066
20208
|
const timeoutInterval = setTimeout(() => {
|
|
20067
|
-
|
|
20209
|
+
resolve3(new Error(`Span processor did not completed within timeout period of ${timeout} ms`));
|
|
20068
20210
|
state = ForceFlushState.timeout;
|
|
20069
20211
|
}, timeout);
|
|
20070
20212
|
spanProcessor.forceFlush().then(() => {
|
|
20071
20213
|
clearTimeout(timeoutInterval);
|
|
20072
20214
|
if (state !== ForceFlushState.timeout) {
|
|
20073
20215
|
state = ForceFlushState.resolved;
|
|
20074
|
-
|
|
20216
|
+
resolve3(state);
|
|
20075
20217
|
}
|
|
20076
20218
|
}).catch((error48) => {
|
|
20077
20219
|
clearTimeout(timeoutInterval);
|
|
20078
20220
|
state = ForceFlushState.error;
|
|
20079
|
-
|
|
20221
|
+
resolve3(error48);
|
|
20080
20222
|
});
|
|
20081
20223
|
});
|
|
20082
20224
|
});
|
|
20083
|
-
return new Promise((
|
|
20225
|
+
return new Promise((resolve3, reject) => {
|
|
20084
20226
|
Promise.all(promises).then((results) => {
|
|
20085
20227
|
const errors = results.filter((result) => result !== ForceFlushState.resolved);
|
|
20086
20228
|
if (errors.length > 0) {
|
|
20087
20229
|
reject(errors);
|
|
20088
20230
|
} else {
|
|
20089
|
-
|
|
20231
|
+
resolve3();
|
|
20090
20232
|
}
|
|
20091
20233
|
}).catch((error48) => reject([error48]));
|
|
20092
20234
|
});
|
|
@@ -20343,7 +20485,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
20343
20485
|
if (config2.verbose) {
|
|
20344
20486
|
console.info("[glasstrace] Background init firing.");
|
|
20345
20487
|
}
|
|
20346
|
-
const initResult = await performInit(config2, anonKeyForInit, "0.
|
|
20488
|
+
const initResult = await performInit(config2, anonKeyForInit, "0.12.0");
|
|
20347
20489
|
if (generation !== registrationGeneration) return;
|
|
20348
20490
|
if (initResult?.claimResult) {
|
|
20349
20491
|
setResolvedApiKey(initResult.claimResult.newApiKey);
|
|
@@ -20417,16 +20559,16 @@ async function handleSourceMapUpload(distDir) {
|
|
|
20417
20559
|
);
|
|
20418
20560
|
return;
|
|
20419
20561
|
}
|
|
20420
|
-
const {
|
|
20421
|
-
const
|
|
20422
|
-
if (
|
|
20562
|
+
const { discoverSourceMapFiles: discoverSourceMapFiles2, computeBuildHash: computeBuildHash2, uploadSourceMaps: uploadSourceMaps2 } = await Promise.resolve().then(() => (init_source_map_uploader(), source_map_uploader_exports));
|
|
20563
|
+
const files = await discoverSourceMapFiles2(distDir);
|
|
20564
|
+
if (files.length === 0) {
|
|
20423
20565
|
console.info("[glasstrace] No source map files found. Skipping upload.");
|
|
20424
20566
|
return;
|
|
20425
20567
|
}
|
|
20426
|
-
const buildHash = await computeBuildHash2(
|
|
20427
|
-
await uploadSourceMaps2(apiKey, endpoint, buildHash,
|
|
20568
|
+
const buildHash = await computeBuildHash2(files);
|
|
20569
|
+
await uploadSourceMaps2(apiKey, endpoint, buildHash, files);
|
|
20428
20570
|
console.info(
|
|
20429
|
-
`[glasstrace] Uploaded ${String(
|
|
20571
|
+
`[glasstrace] Uploaded ${String(files.length)} source map(s) for build ${buildHash}.`
|
|
20430
20572
|
);
|
|
20431
20573
|
} catch (error48) {
|
|
20432
20574
|
const message = error48 instanceof Error ? error48.message : "Unknown error";
|
|
@@ -20643,6 +20785,7 @@ async function buildImportGraph(projectRoot) {
|
|
|
20643
20785
|
computeBuildHash,
|
|
20644
20786
|
createDiscoveryHandler,
|
|
20645
20787
|
deriveSessionId,
|
|
20788
|
+
discoverSourceMapFiles,
|
|
20646
20789
|
discoverTestFiles,
|
|
20647
20790
|
extractImports,
|
|
20648
20791
|
getActiveConfig,
|