@glasstrace/sdk 0.20.1 → 1.0.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.
Files changed (46) hide show
  1. package/README.md +76 -5
  2. package/dist/chunk-3TU62WD6.js +142 -0
  3. package/dist/chunk-3TU62WD6.js.map +1 -0
  4. package/dist/chunk-67RIOAXV.js +105 -0
  5. package/dist/chunk-67RIOAXV.js.map +1 -0
  6. package/dist/{chunk-IQN6TRMQ.js → chunk-KE7MCPO5.js} +3 -140
  7. package/dist/chunk-KE7MCPO5.js.map +1 -0
  8. package/dist/{chunk-R4DAIPXD.js → chunk-MV3F7HVX.js} +96 -10
  9. package/dist/chunk-MV3F7HVX.js.map +1 -0
  10. package/dist/{chunk-BT2OCXCG.js → chunk-UGJ3X4CT.js} +1 -1
  11. package/dist/chunk-UGJ3X4CT.js.map +1 -0
  12. package/dist/cli/init.cjs +1 -1
  13. package/dist/cli/init.cjs.map +1 -1
  14. package/dist/cli/init.js +2 -2
  15. package/dist/cli/init.js.map +1 -1
  16. package/dist/{edge-entry-Ds2fNOeh.d.ts → edge-entry-CFq085RZ.d.ts} +2 -29
  17. package/dist/{edge-entry-FJFKkeFF.d.cts → edge-entry-DYl05SJ-.d.cts} +2 -29
  18. package/dist/edge-entry.cjs +2 -102
  19. package/dist/edge-entry.cjs.map +1 -1
  20. package/dist/edge-entry.d.cts +2 -2
  21. package/dist/edge-entry.d.ts +2 -2
  22. package/dist/edge-entry.js +3 -5
  23. package/dist/index.cjs +38 -244
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/{index.d-DgeH-pNJ.d.cts → index.d-CYYe3PxB.d.cts} +1 -1
  26. package/dist/{index.d-DgeH-pNJ.d.ts → index.d-CYYe3PxB.d.ts} +1 -1
  27. package/dist/index.d.cts +4 -5
  28. package/dist/index.d.ts +4 -5
  29. package/dist/index.js +4 -29
  30. package/dist/node-entry.cjs +93 -104
  31. package/dist/node-entry.cjs.map +1 -1
  32. package/dist/node-entry.d.cts +2 -2
  33. package/dist/node-entry.d.ts +2 -2
  34. package/dist/node-entry.js +6 -7
  35. package/dist/node-subpath.cjs.map +1 -1
  36. package/dist/node-subpath.d.cts +110 -3
  37. package/dist/node-subpath.d.ts +110 -3
  38. package/dist/node-subpath.js +3 -2
  39. package/dist/{source-map-uploader-YXWO6JLN.js → source-map-uploader-BJIXRLJ6.js} +3 -2
  40. package/package.json +11 -2
  41. package/dist/chunk-BT2OCXCG.js.map +0 -1
  42. package/dist/chunk-IQN6TRMQ.js.map +0 -1
  43. package/dist/chunk-R4DAIPXD.js.map +0 -1
  44. package/dist/chunk-Z2EGETTT.js +0 -204
  45. package/dist/chunk-Z2EGETTT.js.map +0 -1
  46. /package/dist/{source-map-uploader-YXWO6JLN.js.map → source-map-uploader-BJIXRLJ6.js.map} +0 -0
@@ -1,5 +1,5 @@
1
- export { C as ClaimState, a as CorrelationIdRequest, G as GlasstraceSpanProcessor, b as SdkError, c as captureCorrelationId, d as createDiscoveryHandler } from './edge-entry-FJFKkeFF.cjs';
2
- import './index.d-DgeH-pNJ.cjs';
1
+ export { C as CorrelationIdRequest, G as GlasstraceSpanProcessor, S as SdkError, c as captureCorrelationId } from './edge-entry-DYl05SJ-.cjs';
2
+ import './index.d-CYYe3PxB.cjs';
3
3
  import './v4/classic/external.cjs';
4
4
  import './export/ReadableSpan';
5
5
  import './Span';
@@ -1,5 +1,5 @@
1
- export { C as ClaimState, a as CorrelationIdRequest, G as GlasstraceSpanProcessor, b as SdkError, c as captureCorrelationId, d as createDiscoveryHandler } from './edge-entry-Ds2fNOeh.js';
2
- import './index.d-DgeH-pNJ.js';
1
+ export { C as CorrelationIdRequest, G as GlasstraceSpanProcessor, S as SdkError, c as captureCorrelationId } from './edge-entry-CFq085RZ.js';
2
+ import './index.d-CYYe3PxB.js';
3
3
  import './v4/classic/external.cjs';
4
4
  import './export/ReadableSpan';
5
5
  import './Span';
@@ -1,16 +1,14 @@
1
1
  import {
2
2
  GlasstraceSpanProcessor,
3
3
  SdkError,
4
- captureCorrelationId,
5
- createDiscoveryHandler
6
- } from "./chunk-Z2EGETTT.js";
4
+ captureCorrelationId
5
+ } from "./chunk-67RIOAXV.js";
7
6
  import "./chunk-DQ25VOKK.js";
8
7
  import "./chunk-TQ54WLCZ.js";
9
8
  import "./chunk-NSBPE2FW.js";
10
9
  export {
11
10
  GlasstraceSpanProcessor,
12
11
  SdkError,
13
- captureCorrelationId,
14
- createDiscoveryHandler
12
+ captureCorrelationId
15
13
  };
16
14
  //# sourceMappingURL=edge-entry.js.map
package/dist/index.cjs CHANGED
@@ -339,10 +339,10 @@ function mergeDefs(...defs) {
339
339
  function cloneDef(schema) {
340
340
  return mergeDefs(schema._zod.def);
341
341
  }
342
- function getElementAtPath(obj, path4) {
343
- if (!path4)
342
+ function getElementAtPath(obj, path3) {
343
+ if (!path3)
344
344
  return obj;
345
- return path4.reduce((acc, key) => acc?.[key], obj);
345
+ return path3.reduce((acc, key) => acc?.[key], obj);
346
346
  }
347
347
  function promiseAllObject(promisesObj) {
348
348
  const keys = Object.keys(promisesObj);
@@ -654,11 +654,11 @@ function aborted(x, startIndex = 0) {
654
654
  }
655
655
  return false;
656
656
  }
657
- function prefixIssues(path4, issues) {
657
+ function prefixIssues(path3, issues) {
658
658
  return issues.map((iss) => {
659
659
  var _a2;
660
660
  (_a2 = iss).path ?? (_a2.path = []);
661
- iss.path.unshift(path4);
661
+ iss.path.unshift(path3);
662
662
  return iss;
663
663
  });
664
664
  }
@@ -901,7 +901,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
901
901
  }
902
902
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
903
903
  const result = { errors: [] };
904
- const processError = (error49, path4 = []) => {
904
+ const processError = (error49, path3 = []) => {
905
905
  var _a2, _b;
906
906
  for (const issue2 of error49.issues) {
907
907
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -911,7 +911,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
911
911
  } else if (issue2.code === "invalid_element") {
912
912
  processError({ issues: issue2.issues }, issue2.path);
913
913
  } else {
914
- const fullpath = [...path4, ...issue2.path];
914
+ const fullpath = [...path3, ...issue2.path];
915
915
  if (fullpath.length === 0) {
916
916
  result.errors.push(mapper(issue2));
917
917
  continue;
@@ -943,8 +943,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
943
943
  }
944
944
  function toDotPath(_path) {
945
945
  const segs = [];
946
- const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
947
- for (const seg of path4) {
946
+ const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
947
+ for (const seg of path3) {
948
948
  if (typeof seg === "number")
949
949
  segs.push(`[${seg}]`);
950
950
  else if (typeof seg === "symbol")
@@ -13708,13 +13708,13 @@ function resolveRef(ref, ctx) {
13708
13708
  if (!ref.startsWith("#")) {
13709
13709
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
13710
13710
  }
13711
- const path4 = ref.slice(1).split("/").filter(Boolean);
13712
- if (path4.length === 0) {
13711
+ const path3 = ref.slice(1).split("/").filter(Boolean);
13712
+ if (path3.length === 0) {
13713
13713
  return ctx.rootSchema;
13714
13714
  }
13715
13715
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
13716
- if (path4[0] === defsKey) {
13717
- const key = path4[1];
13716
+ if (path3[0] === defsKey) {
13717
+ const key = path3[1];
13718
13718
  if (!key || !ctx.defs[key]) {
13719
13719
  throw new Error(`Reference not found: ${ref}`);
13720
13720
  }
@@ -14486,9 +14486,6 @@ function randomHex(byteCount) {
14486
14486
  function createAnonApiKey() {
14487
14487
  return AnonApiKeySchema.parse(`gt_anon_${randomHex(24)}`);
14488
14488
  }
14489
- function createBuildHash(hash2) {
14490
- return BuildHashSchema.parse(hash2);
14491
- }
14492
14489
  function rotr(x, n) {
14493
14490
  return (x >>> n | x << 32 - n) >>> 0;
14494
14491
  }
@@ -16402,10 +16399,10 @@ function sanitize(input) {
16402
16399
  }
16403
16400
  function markerFileExists() {
16404
16401
  try {
16405
- const fs4 = require("node:fs");
16406
- const path4 = require("node:path");
16407
- const markerPath = path4.join(process.cwd(), ".glasstrace", "mcp-connected");
16408
- return fs4.existsSync(markerPath);
16402
+ const fs3 = require("node:fs");
16403
+ const path3 = require("node:path");
16404
+ const markerPath = path3.join(process.cwd(), ".glasstrace", "mcp-connected");
16405
+ return fs3.existsSync(markerPath);
16409
16406
  } catch {
16410
16407
  return false;
16411
16408
  }
@@ -16875,21 +16872,13 @@ var src_exports = {};
16875
16872
  __export(src_exports, {
16876
16873
  GlasstraceExporter: () => GlasstraceExporter,
16877
16874
  GlasstraceSpanProcessor: () => GlasstraceSpanProcessor,
16878
- PRESIGNED_THRESHOLD_BYTES: () => PRESIGNED_THRESHOLD_BYTES,
16879
16875
  SdkError: () => SdkError,
16880
16876
  SessionManager: () => SessionManager,
16881
- buildImportGraph: () => buildImportGraph,
16882
16877
  captureCorrelationId: () => captureCorrelationId,
16883
16878
  captureError: () => captureError,
16884
16879
  classifyFetchTarget: () => classifyFetchTarget,
16885
- collectSourceMaps: () => collectSourceMaps,
16886
- computeBuildHash: () => computeBuildHash,
16887
- createDiscoveryHandler: () => createDiscoveryHandler,
16888
16880
  createGlasstraceSpanProcessor: () => createGlasstraceSpanProcessor,
16889
16881
  deriveSessionId: () => deriveSessionId,
16890
- discoverSourceMapFiles: () => discoverSourceMapFiles,
16891
- discoverTestFiles: () => discoverTestFiles,
16892
- extractImports: () => extractImports,
16893
16882
  getActiveConfig: () => getActiveConfig,
16894
16883
  getDateString: () => getDateString,
16895
16884
  getDiscoveryHandler: () => getDiscoveryHandler,
@@ -16908,9 +16897,6 @@ __export(src_exports, {
16908
16897
  resolveConfig: () => resolveConfig,
16909
16898
  saveCachedConfig: () => saveCachedConfig,
16910
16899
  sendInitRequest: () => sendInitRequest,
16911
- uploadSourceMaps: () => uploadSourceMaps,
16912
- uploadSourceMapsAuto: () => uploadSourceMapsAuto,
16913
- uploadSourceMapsPresigned: () => uploadSourceMapsPresigned,
16914
16900
  waitForReady: () => waitForReady,
16915
16901
  withGlasstraceConfig: () => withGlasstraceConfig
16916
16902
  });
@@ -17024,11 +17010,11 @@ var fsPathCache;
17024
17010
  async function loadFsPath() {
17025
17011
  if (fsPathCache !== void 0) return fsPathCache;
17026
17012
  try {
17027
- const [fs4, path4] = await Promise.all([
17013
+ const [fs3, path3] = await Promise.all([
17028
17014
  import("node:fs/promises"),
17029
17015
  import("node:path")
17030
17016
  ]);
17031
- fsPathCache = { fs: fs4, path: path4 };
17017
+ fsPathCache = { fs: fs3, path: path3 };
17032
17018
  return fsPathCache;
17033
17019
  } catch {
17034
17020
  fsPathCache = null;
@@ -17401,11 +17387,11 @@ var fsPathAsyncCache;
17401
17387
  async function loadFsPathAsync() {
17402
17388
  if (fsPathAsyncCache !== void 0) return fsPathAsyncCache;
17403
17389
  try {
17404
- const [fs4, path4] = await Promise.all([
17390
+ const [fs3, path3] = await Promise.all([
17405
17391
  import("node:fs/promises"),
17406
17392
  import("node:path")
17407
17393
  ]);
17408
- fsPathAsyncCache = { fs: fs4, path: path4 };
17394
+ fsPathAsyncCache = { fs: fs3, path: path3 };
17409
17395
  return fsPathAsyncCache;
17410
17396
  } catch {
17411
17397
  fsPathAsyncCache = null;
@@ -17414,9 +17400,9 @@ async function loadFsPathAsync() {
17414
17400
  }
17415
17401
  function loadFsSyncOrNull() {
17416
17402
  try {
17417
- const fs4 = require("node:fs");
17418
- const path4 = require("node:path");
17419
- return { readFileSync: fs4.readFileSync, join: path4.join };
17403
+ const fs3 = require("node:fs");
17404
+ const path3 = require("node:path");
17405
+ return { readFileSync: fs3.readFileSync, join: path3.join };
17420
17406
  } catch {
17421
17407
  return null;
17422
17408
  }
@@ -18169,15 +18155,10 @@ function deriveErrorCategory(errorType) {
18169
18155
  return "internal";
18170
18156
  }
18171
18157
 
18158
+ // src/register.ts
18159
+ init_env_detection();
18160
+
18172
18161
  // src/discovery-endpoint.ts
18173
- var runtimeHandlerDeprecationWarned = false;
18174
- function warnRuntimeHandlerDeprecatedOnce() {
18175
- if (runtimeHandlerDeprecationWarned) return;
18176
- runtimeHandlerDeprecationWarned = true;
18177
- console.warn(
18178
- "[glasstrace] createDiscoveryHandler is deprecated. Run `npx glasstrace init` to generate a static file at public/.well-known/glasstrace.json (or static/.well-known/glasstrace.json on SvelteKit). The runtime handler will be removed in v1.0.0."
18179
- );
18180
- }
18181
18162
  function isAllowedOrigin(origin) {
18182
18163
  if (origin === null) return true;
18183
18164
  if (origin.startsWith("chrome-extension://")) return true;
@@ -18206,7 +18187,6 @@ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
18206
18187
  if (url2.pathname !== "/__glasstrace/config") {
18207
18188
  return null;
18208
18189
  }
18209
- warnRuntimeHandlerDeprecatedOnce();
18210
18190
  const origin = request.headers.get("Origin");
18211
18191
  const corsHeaders = buildCorsHeaders(origin);
18212
18192
  if (request.method === "OPTIONS") {
@@ -18267,9 +18247,6 @@ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
18267
18247
  };
18268
18248
  }
18269
18249
 
18270
- // src/register.ts
18271
- init_env_detection();
18272
-
18273
18250
  // ../../node_modules/@opentelemetry/otlp-exporter-base/build/esm/OTLPExporterBase.js
18274
18251
  var OTLPExporterBase = class {
18275
18252
  _delegate;
@@ -19698,7 +19675,7 @@ function appendRootPathToUrlIfNeeded(url2) {
19698
19675
  return void 0;
19699
19676
  }
19700
19677
  }
19701
- function appendResourcePathToUrl(url2, path4) {
19678
+ function appendResourcePathToUrl(url2, path3) {
19702
19679
  try {
19703
19680
  new URL(url2);
19704
19681
  } catch {
@@ -19708,11 +19685,11 @@ function appendResourcePathToUrl(url2, path4) {
19708
19685
  if (!url2.endsWith("/")) {
19709
19686
  url2 = url2 + "/";
19710
19687
  }
19711
- url2 += path4;
19688
+ url2 += path3;
19712
19689
  try {
19713
19690
  new URL(url2);
19714
19691
  } catch {
19715
- diag2.warn(`Configuration: Provided URL appended with '${path4}' is not a valid URL, using 'undefined' instead of '${url2}'`);
19692
+ diag2.warn(`Configuration: Provided URL appended with '${path3}' is not a valid URL, using 'undefined' instead of '${url2}'`);
19716
19693
  return void 0;
19717
19694
  }
19718
19695
  return url2;
@@ -21655,19 +21632,19 @@ function stopHeartbeat() {
21655
21632
  }
21656
21633
  }
21657
21634
  function checkShutdownMarker(projectRoot) {
21658
- let fsSync2 = null;
21635
+ let fsSync = null;
21659
21636
  let pathSync = null;
21660
21637
  try {
21661
- fsSync2 = require("node:fs");
21638
+ fsSync = require("node:fs");
21662
21639
  pathSync = require("node:path");
21663
21640
  } catch {
21664
21641
  return { triggered: false };
21665
21642
  }
21666
21643
  const root = projectRoot ?? (typeof process !== "undefined" ? process.cwd() : ".");
21667
21644
  const markerPath = pathSync.join(root, SHUTDOWN_MARKER_RELPATH);
21668
- if (!fsSync2.existsSync(markerPath)) return { triggered: false };
21645
+ if (!fsSync.existsSync(markerPath)) return { triggered: false };
21669
21646
  try {
21670
- fsSync2.unlinkSync(markerPath);
21647
+ fsSync.unlinkSync(markerPath);
21671
21648
  } catch {
21672
21649
  }
21673
21650
  const shutdown = executeShutdown().catch(() => {
@@ -21844,7 +21821,7 @@ function registerGlasstrace(options) {
21844
21821
  setCoreState(CoreState.REGISTERING);
21845
21822
  startRuntimeStateWriter({
21846
21823
  projectRoot: process.cwd(),
21847
- sdkVersion: "0.20.1"
21824
+ sdkVersion: "1.0.1"
21848
21825
  });
21849
21826
  const config2 = resolveConfig(options);
21850
21827
  if (config2.verbose) {
@@ -22010,8 +21987,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22010
21987
  if (config2.verbose) {
22011
21988
  console.info("[glasstrace] Background init firing.");
22012
21989
  }
22013
- const healthReport = collectHealthReport("0.20.1");
22014
- const initResult = await performInit(config2, anonKeyForInit, "0.20.1", healthReport);
21990
+ const healthReport = collectHealthReport("1.0.1");
21991
+ const initResult = await performInit(config2, anonKeyForInit, "1.0.1", healthReport);
22015
21992
  if (generation !== registrationGeneration) return;
22016
21993
  const currentState = getCoreState();
22017
21994
  if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
@@ -22034,7 +22011,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
22034
22011
  }
22035
22012
  maybeInstallConsoleCapture();
22036
22013
  if (didLastInitSucceed()) {
22037
- startHeartbeat(config2, anonKeyForInit, "0.20.1", generation, (newApiKey, accountId) => {
22014
+ startHeartbeat(config2, anonKeyForInit, "1.0.1", generation, (newApiKey, accountId) => {
22038
22015
  setAuthState(AuthState.CLAIMING);
22039
22016
  emitLifecycleEvent("auth:claim_started", { accountId });
22040
22017
  setResolvedApiKey(newApiKey);
@@ -22190,9 +22167,6 @@ async function handleSourceMapUpload(distDir) {
22190
22167
  }
22191
22168
  }
22192
22169
 
22193
- // src/index.ts
22194
- init_source_map_uploader();
22195
-
22196
22170
  // src/capture-error.ts
22197
22171
  init_esm();
22198
22172
  init_error_nudge();
@@ -22277,194 +22251,17 @@ function firstToken(value) {
22277
22251
  }
22278
22252
  return void 0;
22279
22253
  }
22280
-
22281
- // src/import-graph.ts
22282
- var fs3 = __toESM(require("node:fs/promises"), 1);
22283
- var fsSync = __toESM(require("node:fs"), 1);
22284
- var path3 = __toESM(require("node:path"), 1);
22285
- var crypto3 = __toESM(require("node:crypto"), 1);
22286
- init_dist();
22287
- var MAX_TEST_FILES = 5e3;
22288
- var EXCLUDED_DIRS = /* @__PURE__ */ new Set(["node_modules", ".next", ".git", "dist", ".turbo"]);
22289
- var DEFAULT_TEST_PATTERNS = [
22290
- /\.test\.tsx?$/,
22291
- /\.spec\.tsx?$/
22292
- ];
22293
- function globToRegExp(glob) {
22294
- const DOUBLE_STAR_PLACEHOLDER = "\0DSTAR\0";
22295
- const regexStr = glob.replace(/\*\*\//g, DOUBLE_STAR_PLACEHOLDER).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]+").replace(new RegExp(DOUBLE_STAR_PLACEHOLDER.replace(/\0/g, "\\0"), "g"), "(?:.+/)?");
22296
- return new RegExp("^" + regexStr + "$");
22297
- }
22298
- function loadCustomTestPatterns(projectRoot) {
22299
- const configNames = [
22300
- "vitest.config.ts",
22301
- "vitest.config.js",
22302
- "vitest.config.mts",
22303
- "vitest.config.mjs",
22304
- "vite.config.ts",
22305
- "vite.config.js",
22306
- "vite.config.mts",
22307
- "vite.config.mjs",
22308
- "jest.config.ts",
22309
- "jest.config.js",
22310
- "jest.config.mts",
22311
- "jest.config.mjs"
22312
- ];
22313
- for (const name of configNames) {
22314
- const configPath = path3.join(projectRoot, name);
22315
- let content;
22316
- try {
22317
- content = fsSync.readFileSync(configPath, "utf-8");
22318
- } catch {
22319
- continue;
22320
- }
22321
- try {
22322
- const isJest = name.startsWith("jest.");
22323
- let includeMatch = null;
22324
- if (isJest) {
22325
- includeMatch = /testMatch\s*:\s*\[([^\]]*)\]/s.exec(content);
22326
- } else {
22327
- const testBlockMatch = /\btest\s*[:{]\s*/s.exec(content);
22328
- if (testBlockMatch) {
22329
- const afterTest = content.slice(testBlockMatch.index, testBlockMatch.index + 500);
22330
- includeMatch = /include\s*:\s*\[([^\]]*)\]/s.exec(afterTest);
22331
- }
22332
- }
22333
- if (!includeMatch) {
22334
- continue;
22335
- }
22336
- const arrayContent = includeMatch[1];
22337
- const stringRegex = /['"]([^'"]+)['"]/g;
22338
- const patterns = [];
22339
- let match;
22340
- match = stringRegex.exec(arrayContent);
22341
- while (match !== null) {
22342
- patterns.push(globToRegExp(match[1]));
22343
- match = stringRegex.exec(arrayContent);
22344
- }
22345
- if (patterns.length > 0) {
22346
- return patterns;
22347
- }
22348
- } catch {
22349
- continue;
22350
- }
22351
- }
22352
- return [];
22353
- }
22354
- async function discoverTestFiles(projectRoot) {
22355
- const customPatterns = loadCustomTestPatterns(projectRoot);
22356
- const testPatterns = [...DEFAULT_TEST_PATTERNS, ...customPatterns];
22357
- const results = [];
22358
- try {
22359
- await walkForTests(projectRoot, projectRoot, results, testPatterns);
22360
- } catch {
22361
- return [];
22362
- }
22363
- return results.slice(0, MAX_TEST_FILES);
22364
- }
22365
- async function walkForTests(baseDir, currentDir, results, testPatterns) {
22366
- if (results.length >= MAX_TEST_FILES) {
22367
- return;
22368
- }
22369
- let entries;
22370
- try {
22371
- entries = await fs3.readdir(currentDir, { withFileTypes: true });
22372
- } catch {
22373
- return;
22374
- }
22375
- for (const entry of entries) {
22376
- if (results.length >= MAX_TEST_FILES) {
22377
- return;
22378
- }
22379
- const fullPath = path3.join(currentDir, entry.name);
22380
- if (entry.isDirectory()) {
22381
- if (EXCLUDED_DIRS.has(entry.name)) {
22382
- continue;
22383
- }
22384
- await walkForTests(baseDir, fullPath, results, testPatterns);
22385
- } else if (entry.isFile()) {
22386
- const relativePath = path3.relative(baseDir, fullPath).replace(/\\/g, "/");
22387
- const isTestFile = testPatterns.some((p) => p.test(entry.name) || p.test(relativePath)) || relativePath.includes("__tests__");
22388
- if (isTestFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) {
22389
- results.push(relativePath);
22390
- }
22391
- }
22392
- }
22393
- }
22394
- function extractImports(fileContent) {
22395
- const seen = /* @__PURE__ */ new Set();
22396
- const imports = [];
22397
- const addUnique = (importPath) => {
22398
- if (!seen.has(importPath)) {
22399
- seen.add(importPath);
22400
- imports.push(importPath);
22401
- }
22402
- };
22403
- const esFromImportRegex = /\bimport\b[^'"]+\bfrom\s+['"]([^'"]+)['"]/g;
22404
- const esSideEffectRegex = /\bimport\s+['"]([^'"]+)['"]/g;
22405
- let match;
22406
- match = esFromImportRegex.exec(fileContent);
22407
- while (match !== null) {
22408
- addUnique(match[1]);
22409
- match = esFromImportRegex.exec(fileContent);
22410
- }
22411
- match = esSideEffectRegex.exec(fileContent);
22412
- while (match !== null) {
22413
- addUnique(match[1]);
22414
- match = esSideEffectRegex.exec(fileContent);
22415
- }
22416
- const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
22417
- match = requireRegex.exec(fileContent);
22418
- while (match !== null) {
22419
- addUnique(match[1]);
22420
- match = requireRegex.exec(fileContent);
22421
- }
22422
- const dynamicImportRegex = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
22423
- match = dynamicImportRegex.exec(fileContent);
22424
- while (match !== null) {
22425
- addUnique(match[1]);
22426
- match = dynamicImportRegex.exec(fileContent);
22427
- }
22428
- return imports;
22429
- }
22430
- async function buildImportGraph(projectRoot) {
22431
- const testFiles = await discoverTestFiles(projectRoot);
22432
- const graph = {};
22433
- for (const testFile of testFiles) {
22434
- const fullPath = path3.join(projectRoot, testFile);
22435
- try {
22436
- const content = await fs3.readFile(fullPath, "utf-8");
22437
- const imports = extractImports(content);
22438
- graph[testFile] = imports;
22439
- } catch {
22440
- continue;
22441
- }
22442
- }
22443
- const sortedKeys = Object.keys(graph).sort();
22444
- const serialized = sortedKeys.map((key) => `${key}:${JSON.stringify(graph[key])}`).join("\n");
22445
- const hashHex = crypto3.createHash("sha256").update(serialized).digest("hex");
22446
- const buildHash = createBuildHash(hashHex);
22447
- return { buildHash, graph };
22448
- }
22449
22254
  // Annotate the CommonJS export names for ESM import in node:
22450
22255
  0 && (module.exports = {
22451
22256
  GlasstraceExporter,
22452
22257
  GlasstraceSpanProcessor,
22453
- PRESIGNED_THRESHOLD_BYTES,
22454
22258
  SdkError,
22455
22259
  SessionManager,
22456
- buildImportGraph,
22457
22260
  captureCorrelationId,
22458
22261
  captureError,
22459
22262
  classifyFetchTarget,
22460
- collectSourceMaps,
22461
- computeBuildHash,
22462
- createDiscoveryHandler,
22463
22263
  createGlasstraceSpanProcessor,
22464
22264
  deriveSessionId,
22465
- discoverSourceMapFiles,
22466
- discoverTestFiles,
22467
- extractImports,
22468
22265
  getActiveConfig,
22469
22266
  getDateString,
22470
22267
  getDiscoveryHandler,
@@ -22483,9 +22280,6 @@ async function buildImportGraph(projectRoot) {
22483
22280
  resolveConfig,
22484
22281
  saveCachedConfig,
22485
22282
  sendInitRequest,
22486
- uploadSourceMaps,
22487
- uploadSourceMapsAuto,
22488
- uploadSourceMapsPresigned,
22489
22283
  waitForReady,
22490
22284
  withGlasstraceConfig
22491
22285
  });