<commit_before>const { Source, Frame, Location } = require("../../types");

const CALL_STACK_PAGE_SIZE = 1000;
const NEW_SOURCE_IGNORED_URLS = ["debugger eval code", "XStringBundle"];

let threadClient;
let actions;

function setupEvents(dependencies) {
  threadClient = dependencies.threadClient;
  actions = dependencies.actions;
}

function createFrame(frame) {
  let title;
  if (frame.type == "call") {
    let c = frame.callee;
    title = c.name || c.userDisplayName || c.displayName || "(anonymous)";
  } else {
    title = "(" + frame.type + ")";
  }

  return Frame({
    id: frame.actor,
    displayName: title,
    location: Location({
      sourceId: frame.where.source.actor,
      line: frame.where.line,
      column: frame.where.column
    }),
    scope: frame.environment
  });
}

async function paused(_, packet) {
  // If paused by an explicit interrupt, which are generated by the
  // slow script dialog and internal events such as setting
  // breakpoints, ignore the event.
  if (packet.why.type === "interrupted" && !packet.why.onNext) {
    return;
  }

  // Eagerly fetch the frames
  const response = await threadClient.getFrames(0, CALL_STACK_PAGE_SIZE);
  const frames = response.frames.map(createFrame);

  const pause = Object.assign({}, packet, {
    frame: createFrame(packet.frame),
    frames: frames
  });

  actions.paused(pause);
}

function resumed(_, packet) {
  actions.resumed(packet);
}

function newSource(_, packet) {
  const { source } = packet;

  if (NEW_SOURCE_IGNORED_URLS.indexOf(source.url) > -1) {
    return;
  }
  actions.newSource(Source({
    id: source.actor,
    url: source.url,<commit_msg>Exclude debugger eval sources (#497)<commit_after>const { Source, Frame, Location } = require("../../types");

const CALL_STACK_PAGE_SIZE = 1000;
const NEW_SOURCE_IGNORED_URLS = ["debugger eval code", "XStringBundle"];

let threadClient;
let actions;

function setupEvents(dependencies) {
  threadClient = dependencies.threadClient;
  actions = dependencies.actions;
}

function createFrame(frame) {
  let title;
  if (frame.type == "call") {
    let c = frame.callee;
    title = c.name || c.userDisplayName || c.displayName || "(anonymous)";
  } else {
    title = "(" + frame.type + ")";
  }

  return Frame({
    id: frame.actor,
    displayName: title,
    location: Location({
      sourceId: frame.where.source.actor,
      line: frame.where.line,
      column: frame.where.column
    }),
    scope: frame.environment
  });
}

async function paused(_, packet) {
  // If paused by an explicit interrupt, which are generated by the
  // slow script dialog and internal events such as setting
  // breakpoints, ignore the event.
  if (packet.why.type === "interrupted" && !packet.why.onNext) {
    return;
  }

  // Eagerly fetch the frames
  const response = await threadClient.getFrames(0, CALL_STACK_PAGE_SIZE);
  const frames = response.frames.map(createFrame);

  const pause = Object.assign({}, packet, {
    frame: createFrame(packet.frame),
    frames: frames
  });

  actions.paused(pause);
}

function resumed(_, packet) {
  actions.resumed(packet);
}

function newSource(_, packet) {
  const { source } = packet;

  if (NEW_SOURCE_IGNORED_URLS.indexOf(source.url) > -1) {
    return;
  }

  if (source.introductionType == "debugger eval") {
    return;
  }

  actions.newSource(Source({
    id: source.actor,
    url: source.url,
{'fraction_non_alphanumeric': 0.13402061855670103, 'fraction_numerical': 0.004418262150220913, 'mean_word_length': 3.503978779840849, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1194293', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1063, 'n_words': 270}