@saptools/cf-inspector 0.3.18 → 0.3.19

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/cli.js CHANGED
@@ -557,6 +557,9 @@ function asString(value, fallback = "") {
557
557
  function asNumber(value, fallback = 0) {
558
558
  return typeof value === "number" && Number.isFinite(value) ? value : fallback;
559
559
  }
560
+ function nonEmptyString(value) {
561
+ return typeof value === "string" && value.length > 0 ? value : void 0;
562
+ }
560
563
  function toResolvedLocations(value) {
561
564
  if (!Array.isArray(value)) {
562
565
  return [];
@@ -595,7 +598,18 @@ function toScopeChain(value) {
595
598
  return [objectId === void 0 ? base : { ...base, objectId }];
596
599
  });
597
600
  }
598
- function toCallFrames(value) {
601
+ function resolveCallFrameUrl(frame, scripts) {
602
+ const direct = nonEmptyString(frame.url);
603
+ if (direct !== void 0) {
604
+ return direct;
605
+ }
606
+ const scriptId = nonEmptyString(frame.location?.scriptId);
607
+ if (scriptId === void 0) {
608
+ return void 0;
609
+ }
610
+ return nonEmptyString(scripts?.get(scriptId)?.url);
611
+ }
612
+ function toCallFrames(value, scripts) {
599
613
  if (!Array.isArray(value)) {
600
614
  return [];
601
615
  }
@@ -608,7 +622,7 @@ function toCallFrames(value) {
608
622
  if (callFrameId.length === 0) {
609
623
  return [];
610
624
  }
611
- const url = typeof candidate.url === "string" ? candidate.url : void 0;
625
+ const url = resolveCallFrameUrl(candidate, scripts);
612
626
  const base = {
613
627
  callFrameId,
614
628
  functionName: asString(candidate.functionName),
@@ -619,11 +633,11 @@ function toCallFrames(value) {
619
633
  return [url === void 0 ? base : { ...base, url }];
620
634
  });
621
635
  }
622
- function toPauseEvent(params, receivedAtMs) {
636
+ function toPauseEvent(params, receivedAtMs, scripts) {
623
637
  return {
624
638
  reason: asString(params.reason),
625
639
  hitBreakpoints: Array.isArray(params.hitBreakpoints) ? params.hitBreakpoints.filter((id) => typeof id === "string") : [],
626
- callFrames: toCallFrames(params.callFrames),
640
+ callFrames: toCallFrames(params.callFrames, scripts),
627
641
  receivedAtMs
628
642
  };
629
643
  }
@@ -677,7 +691,7 @@ async function connectInspector(options) {
677
691
  return;
678
692
  }
679
693
  const params = raw;
680
- const event = toPauseEvent(params, performance.now());
694
+ const event = toPauseEvent(params, performance.now(), scripts);
681
695
  if (pauseBuffer.length >= PAUSE_BUFFER_LIMIT) {
682
696
  pauseBuffer.shift();
683
697
  }
@@ -1446,7 +1460,7 @@ async function waitForLivePause(session, options, deadlineMs) {
1446
1460
  } finally {
1447
1461
  session.pauseWaitGate.active = false;
1448
1462
  }
1449
- return toPauseEvent(params, receivedAtMs ?? performance2.now());
1463
+ return toPauseEvent(params, receivedAtMs ?? performance2.now(), session.scripts);
1450
1464
  }
1451
1465
 
1452
1466
  // src/snapshot/values.ts