@davmash/bygone 0.7.1 → 0.8.3

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/out/changeTour.js CHANGED
@@ -1515,7 +1515,11 @@ function applySource(source, defaultScenes, repoRoot) {
1515
1515
  continue;
1516
1516
  }
1517
1517
  if (authoredScene.kind === "stacked-diff") {
1518
- const stackedScene = buildStackedScene(repoRoot, authoredScene);
1518
+ const stackedScene = buildStackedScene(
1519
+ repoRoot,
1520
+ authoredScene,
1521
+ [...available.keys()]
1522
+ );
1519
1523
  scenes.push(stackedScene);
1520
1524
  sceneIds.push(stackedScene.id);
1521
1525
  continue;
@@ -1623,8 +1627,7 @@ function buildDeconstructedManifestScene(repoRoot, source, baseRef, targetRef) {
1623
1627
  }))
1624
1628
  };
1625
1629
  }
1626
- function buildStackedScene(repoRoot, source) {
1627
- var _a;
1630
+ function buildStackedScene(repoRoot, source, availableFilePaths) {
1628
1631
  const stack = source.stack.map((entry) => ({
1629
1632
  id: entry.id,
1630
1633
  ref: entry.ref,
@@ -1644,15 +1647,18 @@ function buildStackedScene(repoRoot, source) {
1644
1647
  maxBuffer: 16 * 1024 * 1024,
1645
1648
  stdio: ["ignore", "pipe", "pipe"]
1646
1649
  })));
1647
- const renamedPreviousPaths = new Set(adjacentChanges.flatMap((changes) => changes.map((change) => change.previousPath).filter((candidate) => Boolean(candidate))));
1648
- const changedFiles = [...new Set(adjacentChanges.flatMap((changes) => changes.map((change) => change.path)))].filter((filePath) => !renamedPreviousPaths.has(filePath)).sort();
1649
- const filePaths = ((_a = source.files) == null ? void 0 : _a.length) ? [...new Set(source.files)] : changedFiles;
1650
- for (const step of source.steps) {
1651
- if (!filePaths.includes(step.file)) throw new Error(`Stacked step ${step.id} references undeclared file ${step.file}.`);
1652
- }
1650
+ const filePaths = [.../* @__PURE__ */ new Set([
1651
+ ...availableFilePaths,
1652
+ ...source.files || [],
1653
+ ...source.steps.map((step) => step.file)
1654
+ ])].sort();
1653
1655
  if (filePaths.length === 0) throw new Error(`Stacked scene ${source.id} has no changed files.`);
1656
+ const requiredFilePaths = /* @__PURE__ */ new Set([
1657
+ ...source.files || [],
1658
+ ...source.steps.map((step) => step.file)
1659
+ ]);
1654
1660
  let totalContentBytes = 0;
1655
- const files = filePaths.map((filePath) => {
1661
+ const files = filePaths.flatMap((filePath) => {
1656
1662
  const aliases = /* @__PURE__ */ new Set([filePath]);
1657
1663
  for (const changes of adjacentChanges) {
1658
1664
  for (const change of changes) {
@@ -1662,26 +1668,35 @@ function buildStackedScene(repoRoot, source) {
1662
1668
  }
1663
1669
  }
1664
1670
  }
1665
- const panels = stack.map((entry) => {
1671
+ let fileContentBytes = 0;
1672
+ const panels = [];
1673
+ for (const entry of stack) {
1666
1674
  const resolvedPath = [...aliases].find((candidate) => gitBlobExists(repoRoot, entry.oid, candidate));
1667
1675
  if (!resolvedPath) {
1668
- return { id: entry.id, label: `${entry.label} / ${filePath} (missing)`, content: "", exists: false };
1676
+ panels.push({ id: entry.id, label: `${entry.label} / ${filePath} (missing)`, content: "", exists: false });
1677
+ continue;
1669
1678
  }
1670
1679
  const content = readGitText2(repoRoot, entry.oid, resolvedPath, DEFAULT_MAX_TOUR_FILE_BYTES, DEFAULT_MAX_TOUR_LINE_BYTES);
1671
- if (content.kind !== "text") throw new Error(`Stacked tour file is binary or too large: ${resolvedPath}`);
1672
- totalContentBytes += Buffer.byteLength(content.content);
1673
- if (totalContentBytes > DEFAULT_MAX_STACK_CONTENT_BYTES) {
1674
- throw new Error(`Stacked tour content exceeds ${DEFAULT_MAX_STACK_CONTENT_BYTES} bytes.`);
1680
+ if (content.kind !== "text") {
1681
+ if (requiredFilePaths.has(filePath)) {
1682
+ throw new Error(`Stacked tour file is binary or too large: ${resolvedPath}`);
1683
+ }
1684
+ return [];
1675
1685
  }
1676
- return {
1686
+ fileContentBytes += Buffer.byteLength(content.content);
1687
+ panels.push({
1677
1688
  id: entry.id,
1678
1689
  label: `${entry.label} / ${resolvedPath}`,
1679
1690
  path: resolvedPath,
1680
1691
  content: content.content,
1681
1692
  exists: true
1682
- };
1683
- });
1684
- return { path: filePath, panels };
1693
+ });
1694
+ }
1695
+ totalContentBytes += fileContentBytes;
1696
+ if (totalContentBytes > DEFAULT_MAX_STACK_CONTENT_BYTES) {
1697
+ throw new Error(`Stacked tour content exceeds ${DEFAULT_MAX_STACK_CONTENT_BYTES} bytes.`);
1698
+ }
1699
+ return [{ path: filePath, panels }];
1685
1700
  });
1686
1701
  const stackIds = stack.map((entry) => entry.id);
1687
1702
  return {
@@ -1695,7 +1710,7 @@ function buildStackedScene(repoRoot, source) {
1695
1710
  stack,
1696
1711
  files,
1697
1712
  steps: source.steps.map((step) => {
1698
- var _a2, _b;
1713
+ var _a, _b;
1699
1714
  return {
1700
1715
  id: step.id,
1701
1716
  title: step.title,
@@ -1703,7 +1718,7 @@ function buildStackedScene(repoRoot, source) {
1703
1718
  file: step.file,
1704
1719
  pairIndex: stackIds.indexOf(step.pair[0]),
1705
1720
  side: step.side || "right",
1706
- startLine: (_a2 = step.lines) == null ? void 0 : _a2[0],
1721
+ startLine: (_a = step.lines) == null ? void 0 : _a[0],
1707
1722
  endLine: (_b = step.lines) == null ? void 0 : _b[1]
1708
1723
  };
1709
1724
  })