{"version":3,"file":"webFiles-gkmgR3MY.cjs","names":[],"sources":["../src/services/doomIgnore/index.ts","../src/types/webFiles.ts"],"sourcesContent":["import ignore from 'ignore';\n\nimport type { FilesItemView } from '../../types/webFiles';\n\nfunction matchablePath(relPath: string): string | undefined {\n  const normalized = relPath.replace(/\\\\/gu, '/');\n  if (\n    normalized.length === 0 ||\n    normalized.includes('\\0') ||\n    normalized === '..' ||\n    normalized.startsWith('../') ||\n    normalized.startsWith('/') ||\n    /^[A-Za-z]:\\//u.test(normalized)\n  ) {\n    return undefined;\n  }\n  return normalized;\n}\n\n/**\n * Builds the project's ignore test, or nothing when there are no rules.\n *\n * Shared because the same rules are needed twice: once when deciding what to\n * record, and once when deciding what to list. A caller that built its own\n * matcher would let the two drift apart.\n *\n * The test answers false for anything it cannot safely match, so a path that\n * escapes the project stays visible rather than being hidden by accident.\n */\nexport function createDoomIgnoreMatcher(content: string): ((relPath: string) => boolean) | undefined {\n  try {\n    if (content.trim().length === 0) return undefined;\n    const matcher = ignore().add(content);\n    return (relPath: string): boolean => {\n      const candidate = matchablePath(relPath);\n      return candidate !== undefined && matcher.ignores(candidate);\n    };\n  } catch {\n    return undefined;\n  }\n}\n\n/** Applies project-local gitignore rules while keeping unsafe candidates visible. */\nexport function filterDoomIgnoredFiles(items: FilesItemView[], content: string): FilesItemView[] {\n  const ignored = createDoomIgnoreMatcher(content);\n  if (ignored === undefined) return items;\n  return items.filter((item) => !ignored(item.relPath));\n}\n","import type { FileEditTool } from './domain';\n\n/**\n * View types shared by this package's hub channel and its web plugin. Wire\n * JSON only, no node types, so the cockpit bundle can carry them; the\n * cockpit receives them as 'file_edits' channel payloads.\n *\n * The channel carries the list alone. One file's diffs and content are large\n * and only wanted once a reader opens the file, so those come from the session\n * API instead (see fileEditsApi.ts).\n */\n\n/** One file this session changed, as the activity dock lists it. */\nexport interface FilesItemView {\n  /** Absolute path, and the identity every API route takes back. */\n  path: string;\n  /** Path relative to the session's working directory, which is what a row shows. */\n  relPath: string;\n  /** The tool behind the most recent change. */\n  tool: FileEditTool;\n  /** When that change happened, epoch milliseconds. */\n  at: number;\n  /** How many changes this session recorded for the file. */\n  count: number;\n  /**\n   * Whether any change captured a baseline, so a diff can be shown at all. A\n   * file found by comparing the tree around a bash call has no \"before\", so it\n   * is listed and readable but never diffed.\n   */\n  diffable: boolean;\n}\n\n/** The frame type the hub publishes and the web plugin claims; declared in the doompiWeb block too. */\nexport const filesChannelType = 'file_edits';\n\n/** Footer status key whose presence shows the activity group; the extension publishes it. */\nexport const filesStatusKey = 'doom-file-edit-files';\n"],"mappings":";;;;AAIA,SAAS,cAAc,SAAqC;CAC1D,MAAM,aAAa,QAAQ,QAAQ,QAAQ,GAAG;CAC9C,IACE,WAAW,WAAW,KACtB,WAAW,SAAS,IAAI,KACxB,eAAe,QACf,WAAW,WAAW,KAAK,KAC3B,WAAW,WAAW,GAAG,KACzB,gBAAgB,KAAK,UAAU,GAE/B;CAEF,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,wBAAwB,SAA6D;CACnG,IAAI;EACF,IAAI,QAAQ,KAAK,CAAC,CAAC,WAAW,GAAG,OAAO,KAAA;EACxC,MAAM,WAAA,GAAU,OAAA,QAAA,CAAO,CAAC,CAAC,IAAI,OAAO;EACpC,QAAQ,YAA6B;GACnC,MAAM,YAAY,cAAc,OAAO;GACvC,OAAO,cAAc,KAAA,KAAa,QAAQ,QAAQ,SAAS;EAC7D;CACF,QAAQ;EACN;CACF;AACF;;AAGA,SAAgB,uBAAuB,OAAwB,SAAkC;CAC/F,MAAM,UAAU,wBAAwB,OAAO;CAC/C,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,OAAO,MAAM,QAAQ,SAAS,CAAC,QAAQ,KAAK,OAAO,CAAC;AACtD;;;;ACdA,MAAa,mBAAmB;;AAGhC,MAAa,iBAAiB"}