@youtyan/code-viewer 0.1.39 → 0.1.41

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 (2) hide show
  1. package/package.json +1 -1
  2. package/web/app.js +15 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youtyan/code-viewer",
3
- "version": "0.1.39",
3
+ "version": "0.1.41",
4
4
  "description": "Local browser-based code and git diff viewer",
5
5
  "type": "module",
6
6
  "bin": {
package/web/app.js CHANGED
@@ -7544,16 +7544,25 @@ ${frontmatter.yaml}
7544
7544
  deps.setRange(from, to);
7545
7545
  deps.syncRefInputs();
7546
7546
  deps.cancelActiveSourceLoad("navigation");
7547
- deps.setRoute({ screen: "diff", range, path: entry.path, line });
7548
- deps.setPageMode();
7549
- const hasDiffCards = !!document.querySelector(".gdp-file-shell:not(.gdp-standalone-source)");
7550
- if (rangeChanged || !deps.getFiles().length || !hasDiffCards) {
7547
+ const needDiffLoad = rangeChanged || !deps.getFiles().length;
7548
+ if (needDiffLoad) {
7549
+ deps.setRoute({ screen: "diff", range, path: entry.path, line });
7550
+ deps.setPageMode();
7551
7551
  deps.removeStandaloneSource();
7552
7552
  await deps.load();
7553
7553
  if (stale())
7554
7554
  return;
7555
7555
  }
7556
7556
  if (deps.getFiles().some((f2) => f2.path === entry.path)) {
7557
+ deps.setRoute({ screen: "diff", range, path: entry.path, line }, needDiffLoad);
7558
+ deps.setPageMode();
7559
+ const hasDiffCards = !!document.querySelector(".gdp-file-shell:not(.gdp-standalone-source)");
7560
+ if (!hasDiffCards) {
7561
+ deps.removeStandaloneSource();
7562
+ await deps.load();
7563
+ if (stale())
7564
+ return;
7565
+ }
7557
7566
  deps.removeStandaloneSource();
7558
7567
  deps.scrollToFile(entry.path, line);
7559
7568
  await expandAnnotationContext(entry);
@@ -7563,7 +7572,7 @@ ${frontmatter.yaml}
7563
7572
  const ref = annotationRefForEntry(entry);
7564
7573
  const card = document.querySelector(".gdp-standalone-source");
7565
7574
  const reusable = prevRoute.screen === "file" && prevRoute.path === entry.path && prevRoute.ref === ref && card?.dataset.path === entry.path && !!card.querySelector(".gdp-source-table");
7566
- deps.setRoute({ screen: "file", path: entry.path, ref, view: "blob", line, range }, true);
7575
+ deps.setRoute({ screen: "file", path: entry.path, ref, view: "blob", line, range }, needDiffLoad);
7567
7576
  deps.setPageMode();
7568
7577
  if (reusable && card) {
7569
7578
  focusStandaloneSourceLines(card, entry);
@@ -15649,6 +15658,7 @@ ${frontmatter.yaml}
15649
15658
  }
15650
15659
  if (action === "annotation-next" || action === "annotation-previous") {
15651
15660
  ANNOTATIONS_UI?.stepAnnotation(action === "annotation-next" ? 1 : -1);
15661
+ scheduleMainSurfaceFocus();
15652
15662
  return true;
15653
15663
  }
15654
15664
  if (action === "start-g-sequence") {