@youtyan/code-viewer 0.8.5 → 0.8.7
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/README.md +10 -8
- package/dist/code-viewer.js +210 -783
- package/package.json +1 -1
- package/web/app.js +139 -33
package/package.json
CHANGED
package/web/app.js
CHANGED
|
@@ -227,6 +227,8 @@ ${lines.join(`
|
|
|
227
227
|
function shouldAutoLoadForRoute(route, options = {}) {
|
|
228
228
|
if (route.screen === "history")
|
|
229
229
|
return options.historyWorktreeSelected === true;
|
|
230
|
+
if (route.screen === "diff")
|
|
231
|
+
return !route.range.from || route.range.from === "worktree" || !route.range.to || route.range.to === "worktree";
|
|
230
232
|
if (route.screen === "database" || route.screen === "journal" || route.screen === "help" || route.screen === "unknown")
|
|
231
233
|
return false;
|
|
232
234
|
return true;
|
|
@@ -9672,6 +9674,10 @@ ${frontmatter.yaml}
|
|
|
9672
9674
|
}
|
|
9673
9675
|
|
|
9674
9676
|
// web-src/views/file-shell.ts
|
|
9677
|
+
function isMediaPreviewOnlySource(path) {
|
|
9678
|
+
const kind = sourceDisplayKind(path);
|
|
9679
|
+
return kind === "image" || kind === "video" || kind === "audio" || kind === "pdf";
|
|
9680
|
+
}
|
|
9675
9681
|
function isBlobOrBlameFileRoute(route) {
|
|
9676
9682
|
return route.screen === "file" && (route.view === "blob" || route.view === "blame");
|
|
9677
9683
|
}
|
|
@@ -9724,14 +9730,18 @@ ${frontmatter.yaml}
|
|
|
9724
9730
|
}
|
|
9725
9731
|
function appendFileViewTabs(tabs, deps, target, activeTab, options = {}) {
|
|
9726
9732
|
const includeFileTabs = options.includeFileTabs !== false;
|
|
9727
|
-
const
|
|
9733
|
+
const mediaOnly = options.previewable === undefined && isMediaPreviewOnlySource(target.path);
|
|
9734
|
+
const showPreview = mediaOnly || (options.previewable ?? (isPreviewableSource(target.path) || activeTab === "preview"));
|
|
9728
9735
|
let previewButton = null;
|
|
9729
9736
|
if (showPreview) {
|
|
9730
|
-
previewButton = createBlobSourceTabButton(deps, target, "preview", activeTab === "preview", options);
|
|
9737
|
+
previewButton = createBlobSourceTabButton(deps, target, "preview", activeTab === "preview" || mediaOnly && activeTab === "code", options);
|
|
9731
9738
|
tabs.appendChild(previewButton);
|
|
9732
9739
|
}
|
|
9733
|
-
|
|
9734
|
-
|
|
9740
|
+
let codeButton = null;
|
|
9741
|
+
if (!mediaOnly) {
|
|
9742
|
+
codeButton = createBlobSourceTabButton(deps, target, "code", activeTab === "code", options);
|
|
9743
|
+
tabs.appendChild(codeButton);
|
|
9744
|
+
}
|
|
9735
9745
|
if (includeFileTabs) {
|
|
9736
9746
|
tabs.appendChild(createFileViewTabButton(deps, target, "blame", "Blame", activeTab === "blame"));
|
|
9737
9747
|
tabs.appendChild(createFileViewTabButton(deps, target, "history", "History", activeTab === "history"));
|
|
@@ -9783,14 +9793,18 @@ ${frontmatter.yaml}
|
|
|
9783
9793
|
sticky.appendChild(tabsHost);
|
|
9784
9794
|
return { sticky, header, tabsHost };
|
|
9785
9795
|
}
|
|
9786
|
-
function mountFileShellCard(deps, target, card, repoTarget = deps.repoFileTargetFromRoute()) {
|
|
9796
|
+
function mountFileShellCard(deps, target, card, repoTarget = deps.repoFileTargetFromRoute(), options = {}) {
|
|
9787
9797
|
const root = deps.$("#diff");
|
|
9788
9798
|
if (repoTarget) {
|
|
9789
9799
|
const layout = document.createElement("div");
|
|
9790
9800
|
layout.className = "gdp-repo-blob-layout";
|
|
9791
9801
|
layout.appendChild(card);
|
|
9792
9802
|
root.prepend(layout);
|
|
9793
|
-
|
|
9803
|
+
if (options.loadSidebar !== false) {
|
|
9804
|
+
Promise.resolve(deps.renderRepoBlobSidebar(target.path, repoTarget)).catch((error2) => {
|
|
9805
|
+
console.error("[code-viewer] failed to load repository sidebar", error2);
|
|
9806
|
+
}).finally(() => deps.placeSidebarToggle());
|
|
9807
|
+
}
|
|
9794
9808
|
} else {
|
|
9795
9809
|
root.prepend(card);
|
|
9796
9810
|
}
|
|
@@ -23765,7 +23779,7 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
23765
23779
|
if (fresh && card.isConnected)
|
|
23766
23780
|
enqueueLoad(fresh, card, 0);
|
|
23767
23781
|
};
|
|
23768
|
-
|
|
23782
|
+
const request = trackLoad(fetch(url).then(async (r2) => {
|
|
23769
23783
|
if (!r2.ok)
|
|
23770
23784
|
throw new Error(await r2.text());
|
|
23771
23785
|
return r2.json();
|
|
@@ -23785,9 +23799,10 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
23785
23799
|
if (String(myReq) !== card.dataset.reqId)
|
|
23786
23800
|
return;
|
|
23787
23801
|
renderFile(file, data, card);
|
|
23788
|
-
}).catch(() => {
|
|
23802
|
+
}).catch((error2) => {
|
|
23789
23803
|
if (String(myReq) !== card.dataset.reqId)
|
|
23790
23804
|
return;
|
|
23805
|
+
console.error("[code-viewer] failed to load diff", error2);
|
|
23791
23806
|
card.classList.remove("loading");
|
|
23792
23807
|
card.classList.add("error");
|
|
23793
23808
|
card.style.minHeight = "";
|
|
@@ -23804,13 +23819,24 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
23804
23819
|
enqueueLoad(file, card, 1);
|
|
23805
23820
|
});
|
|
23806
23821
|
});
|
|
23822
|
+
const completed = request.finally(() => {
|
|
23823
|
+
if (card._loadPromise === completed)
|
|
23824
|
+
delete card._loadPromise;
|
|
23825
|
+
});
|
|
23826
|
+
card._loadPromise = completed;
|
|
23827
|
+
return completed;
|
|
23807
23828
|
}
|
|
23808
23829
|
async function loadDiffFile(path) {
|
|
23809
|
-
const
|
|
23830
|
+
const root = getDiffRoot?.() || document;
|
|
23831
|
+
const card = root.querySelector(diffCardSelector(path));
|
|
23810
23832
|
if (!card || card.classList.contains("gdp-standalone-source"))
|
|
23811
23833
|
return false;
|
|
23812
23834
|
if (card.classList.contains("loaded"))
|
|
23813
23835
|
return true;
|
|
23836
|
+
if (card.classList.contains("loading") && card._loadPromise) {
|
|
23837
|
+
await card._loadPromise;
|
|
23838
|
+
return card.classList.contains("loaded");
|
|
23839
|
+
}
|
|
23814
23840
|
const file = card._file || STATE.files.find((x) => x.path === path);
|
|
23815
23841
|
if (!file)
|
|
23816
23842
|
return false;
|
|
@@ -25601,7 +25627,7 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
25601
25627
|
(el.closest(".gdp-repo-blob-layout") || el).remove();
|
|
25602
25628
|
});
|
|
25603
25629
|
}
|
|
25604
|
-
function renderFileHistoryShell(deps, route) {
|
|
25630
|
+
function renderFileHistoryShell(deps, route, options = {}) {
|
|
25605
25631
|
removeFileHistoryShell();
|
|
25606
25632
|
const target = { path: route.path, ref: route.ref };
|
|
25607
25633
|
const card = document.createElement("article");
|
|
@@ -25637,7 +25663,7 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
25637
25663
|
body.appendChild(embed);
|
|
25638
25664
|
wrapper.appendChild(body);
|
|
25639
25665
|
card.appendChild(wrapper);
|
|
25640
|
-
mountFileShellCard(deps, target, card, target.ref);
|
|
25666
|
+
mountFileShellCard(deps, target, card, target.ref, options);
|
|
25641
25667
|
return {
|
|
25642
25668
|
...panelDom,
|
|
25643
25669
|
commitInfo,
|
|
@@ -26044,7 +26070,7 @@ ${entry.message}` : entry.detail ?? entry.message ?? "";
|
|
|
26044
26070
|
},
|
|
26045
26071
|
{
|
|
26046
26072
|
kind: "paragraph",
|
|
26047
|
-
text: "A file detail page exposes four tabs — Preview, Code, Blame, History. Code is the default and ?preview=1 opts in to the Markdown / media
|
|
26073
|
+
text: "A file detail page exposes up to four tabs — Preview, Code, Blame, History. For text files Code is the default and ?preview=1 opts in to the Markdown / HTML preview; media files (images, video, audio, PDF) show a Preview tab only, with no Code tab. Blame and History have their own canonical URLs (view=blame, view=history) so deep links and the browser back/forward stay in sync, and they keep the Repository sidebar visible."
|
|
26048
26074
|
},
|
|
26049
26075
|
{
|
|
26050
26076
|
kind: "paragraph",
|
|
@@ -26715,7 +26741,7 @@ code-viewer query agent-help`
|
|
|
26715
26741
|
},
|
|
26716
26742
|
{
|
|
26717
26743
|
kind: "paragraph",
|
|
26718
|
-
text: "
|
|
26744
|
+
text: "ファイル詳細ページには最大 4 つのタブ (Preview / Code / Blame / History) があります。テキストファイルは Code がデフォルトで、?preview=1 を付けると Markdown / HTML プレビューに切り替わります。画像・動画・音声・PDF などのメディアファイルは Preview タブのみ表示され、Code タブは表示されません。Blame と History はそれぞれ専用 URL (view=blame, view=history) を持つため、ディープリンクとブラウザの戻る / 進むが同期し、いずれも Repository サイドバーは表示されたままです。"
|
|
26719
26745
|
},
|
|
26720
26746
|
{
|
|
26721
26747
|
kind: "paragraph",
|
|
@@ -30153,14 +30179,34 @@ code-viewer query agent-help`
|
|
|
30153
30179
|
if (!popBody || !popSearch)
|
|
30154
30180
|
return;
|
|
30155
30181
|
let popTarget = null;
|
|
30182
|
+
let refsLoaded = false;
|
|
30183
|
+
let refsLoading = false;
|
|
30184
|
+
let refsError = false;
|
|
30185
|
+
let refsInFlight = null;
|
|
30156
30186
|
function fetchRefs() {
|
|
30157
|
-
|
|
30187
|
+
if (refsLoaded)
|
|
30188
|
+
return Promise.resolve();
|
|
30189
|
+
if (refsInFlight)
|
|
30190
|
+
return refsInFlight;
|
|
30191
|
+
refsLoading = true;
|
|
30192
|
+
refsError = false;
|
|
30193
|
+
const request = fetch("/_refs").then((r2) => r2.json()).then((refs) => {
|
|
30158
30194
|
Object.assign(REFS, refs);
|
|
30159
|
-
|
|
30160
|
-
|
|
30195
|
+
refsLoaded = true;
|
|
30196
|
+
if (!popover.hidden && popTab !== "commits")
|
|
30197
|
+
buildPopBody(popSearch.value);
|
|
30198
|
+
}).catch((error2) => {
|
|
30199
|
+
refsError = true;
|
|
30200
|
+
console.error("[code-viewer] failed to load refs", error2);
|
|
30201
|
+
}).finally(() => {
|
|
30202
|
+
refsLoading = false;
|
|
30203
|
+
refsInFlight = null;
|
|
30204
|
+
if (!popover.hidden && popTab !== "commits")
|
|
30205
|
+
buildPopBody(popSearch.value);
|
|
30161
30206
|
});
|
|
30207
|
+
refsInFlight = request;
|
|
30208
|
+
return request;
|
|
30162
30209
|
}
|
|
30163
|
-
fetchRefs();
|
|
30164
30210
|
let popTab = "commits";
|
|
30165
30211
|
const COMMIT_PAGE_SIZE = 50;
|
|
30166
30212
|
let commitSearchTimer = null;
|
|
@@ -30301,6 +30347,10 @@ code-viewer query agent-help`
|
|
|
30301
30347
|
} else if (commitHasMore) {
|
|
30302
30348
|
html.push('<div class="rp-empty">scroll for more commits...</div>');
|
|
30303
30349
|
}
|
|
30350
|
+
} else if (refsLoading) {
|
|
30351
|
+
html.push('<div class="rp-empty">loading refs...</div>');
|
|
30352
|
+
} else if (refsError) {
|
|
30353
|
+
html.push('<div class="rp-empty">failed to load refs</div>');
|
|
30304
30354
|
} else if (popTab === "branches") {
|
|
30305
30355
|
const branches = (REFS.branches || []).filter((b2) => m(b2.name));
|
|
30306
30356
|
if (!branches.length) {
|
|
@@ -30435,6 +30485,14 @@ code-viewer query agent-help`
|
|
|
30435
30485
|
});
|
|
30436
30486
|
if (popTab === "commits")
|
|
30437
30487
|
scheduleCommitSearch(popSearch.value);
|
|
30488
|
+
else {
|
|
30489
|
+
if (commitSearchTimer) {
|
|
30490
|
+
clearTimeout(commitSearchTimer);
|
|
30491
|
+
commitSearchTimer = null;
|
|
30492
|
+
}
|
|
30493
|
+
commitSearchLoading = false;
|
|
30494
|
+
fetchRefs();
|
|
30495
|
+
}
|
|
30438
30496
|
buildPopBody(popSearch.value);
|
|
30439
30497
|
});
|
|
30440
30498
|
});
|
|
@@ -34083,6 +34141,8 @@ code-viewer query agent-help`
|
|
|
34083
34141
|
});
|
|
34084
34142
|
}
|
|
34085
34143
|
function applyRenderedSourceTab(tab, codeButton, previewButton, codePane, previewPane, updateRoute = true) {
|
|
34144
|
+
if (!codeButton)
|
|
34145
|
+
return false;
|
|
34086
34146
|
if (tab === "preview" && (!previewButton || !previewPane))
|
|
34087
34147
|
return false;
|
|
34088
34148
|
codeButton.classList.toggle("active", tab === "code");
|
|
@@ -34332,6 +34392,7 @@ code-viewer query agent-help`
|
|
|
34332
34392
|
body.replaceWith(view);
|
|
34333
34393
|
else
|
|
34334
34394
|
card.appendChild(view);
|
|
34395
|
+
setSourceCardState(card, "error");
|
|
34335
34396
|
}
|
|
34336
34397
|
function renderSourceCancelled(card, target) {
|
|
34337
34398
|
const body = card.querySelector(".gdp-file-detail-body, .d2h-files-diff, .d2h-file-diff, .gdp-media, .gdp-source-viewer");
|
|
@@ -34356,6 +34417,7 @@ code-viewer query agent-help`
|
|
|
34356
34417
|
body.replaceWith(view);
|
|
34357
34418
|
else
|
|
34358
34419
|
card.appendChild(view);
|
|
34420
|
+
setSourceCardState(card, "cancelled");
|
|
34359
34421
|
}
|
|
34360
34422
|
function renderSourceUnsupported(card, target) {
|
|
34361
34423
|
const body = card.querySelector(".gdp-file-detail-body, .d2h-files-diff, .d2h-file-diff, .gdp-media, .gdp-source-viewer");
|
|
@@ -34374,6 +34436,7 @@ code-viewer query agent-help`
|
|
|
34374
34436
|
body.replaceWith(view);
|
|
34375
34437
|
else
|
|
34376
34438
|
card.appendChild(view);
|
|
34439
|
+
setSourceCardState(card, "done");
|
|
34377
34440
|
}
|
|
34378
34441
|
function renderSourceInternalPath(card, target, kind) {
|
|
34379
34442
|
const body = card.querySelector(".gdp-file-detail-body, .d2h-files-diff, .d2h-file-diff, .gdp-media, .gdp-source-viewer");
|
|
@@ -34398,6 +34461,7 @@ code-viewer query agent-help`
|
|
|
34398
34461
|
body.replaceWith(view);
|
|
34399
34462
|
else
|
|
34400
34463
|
card.appendChild(view);
|
|
34464
|
+
setSourceCardState(card, "done");
|
|
34401
34465
|
}
|
|
34402
34466
|
function renderHtmlPreview(target, html) {
|
|
34403
34467
|
return renderHtmlPreviewFrame(`${target.path} preview`, html);
|
|
@@ -34511,7 +34575,7 @@ code-viewer query agent-help`
|
|
|
34511
34575
|
previewButton2?.addEventListener("click", () => {
|
|
34512
34576
|
applyRenderedSourceTab("preview", codeButton2, previewButton2, virtualCode, preview);
|
|
34513
34577
|
});
|
|
34514
|
-
codeButton2
|
|
34578
|
+
codeButton2?.addEventListener("click", () => {
|
|
34515
34579
|
applyRenderedSourceTab("code", codeButton2, previewButton2, virtualCode, preview);
|
|
34516
34580
|
});
|
|
34517
34581
|
if (header)
|
|
@@ -34606,7 +34670,7 @@ code-viewer query agent-help`
|
|
|
34606
34670
|
previewButton?.addEventListener("click", () => {
|
|
34607
34671
|
applyRenderedSourceTab("preview", codeButton, previewButton, table2, preview);
|
|
34608
34672
|
});
|
|
34609
|
-
codeButton
|
|
34673
|
+
codeButton?.addEventListener("click", () => {
|
|
34610
34674
|
applyRenderedSourceTab("code", codeButton, previewButton, table2, preview);
|
|
34611
34675
|
});
|
|
34612
34676
|
if (header)
|
|
@@ -34926,7 +34990,7 @@ code-viewer query agent-help`
|
|
|
34926
34990
|
e2.preventDefault();
|
|
34927
34991
|
const url = new URL(full.href, window.location.origin);
|
|
34928
34992
|
setRoute(parseRoute(url.pathname, url.search, currentRange()), true);
|
|
34929
|
-
renderStandaloneSource(target);
|
|
34993
|
+
renderStandaloneSource(target, { refresh: true });
|
|
34930
34994
|
});
|
|
34931
34995
|
actions.append(copy, full);
|
|
34932
34996
|
info.append(badge, summary, actions);
|
|
@@ -35042,7 +35106,7 @@ code-viewer query agent-help`
|
|
|
35042
35106
|
e2.preventDefault();
|
|
35043
35107
|
const url = new URL(full.href, window.location.origin);
|
|
35044
35108
|
setRoute(parseRoute(url.pathname, url.search, currentRange()), true);
|
|
35045
|
-
renderStandaloneSource(target);
|
|
35109
|
+
renderStandaloneSource(target, { refresh: true });
|
|
35046
35110
|
});
|
|
35047
35111
|
actions.append(raw, full);
|
|
35048
35112
|
info.append(badge, summary, actions);
|
|
@@ -35308,6 +35372,7 @@ code-viewer query agent-help`
|
|
|
35308
35372
|
body.replaceWith(view);
|
|
35309
35373
|
else
|
|
35310
35374
|
card.appendChild(view);
|
|
35375
|
+
setSourceCardState(card, "done");
|
|
35311
35376
|
}
|
|
35312
35377
|
function _renderSourceBinary(card, target) {
|
|
35313
35378
|
const body = card.querySelector(".gdp-file-detail-body, .d2h-files-diff, .d2h-file-diff, .gdp-media, .gdp-source-viewer");
|
|
@@ -35331,7 +35396,30 @@ code-viewer query agent-help`
|
|
|
35331
35396
|
else
|
|
35332
35397
|
card.appendChild(view);
|
|
35333
35398
|
}
|
|
35334
|
-
|
|
35399
|
+
function mountedStandaloneSourceCard(target) {
|
|
35400
|
+
const card = document.querySelector(".gdp-standalone-source");
|
|
35401
|
+
if (!card)
|
|
35402
|
+
return null;
|
|
35403
|
+
if (card.dataset.path !== target.path)
|
|
35404
|
+
return null;
|
|
35405
|
+
if (card.dataset.sourceRef !== (target.ref || "worktree"))
|
|
35406
|
+
return null;
|
|
35407
|
+
return card;
|
|
35408
|
+
}
|
|
35409
|
+
function setSourceCardState(card, state) {
|
|
35410
|
+
card.dataset.sourceState = state;
|
|
35411
|
+
}
|
|
35412
|
+
async function renderStandaloneSource(target, options = {}) {
|
|
35413
|
+
if (!options.refresh) {
|
|
35414
|
+
const mounted = mountedStandaloneSourceCard(target);
|
|
35415
|
+
const state = mounted?.dataset.sourceState;
|
|
35416
|
+
if (mounted && state === "done") {
|
|
35417
|
+
scrollStandaloneSourceLine(mounted, lineTargetStart(STATE.route.screen === "file" ? STATE.route.line : undefined));
|
|
35418
|
+
return;
|
|
35419
|
+
}
|
|
35420
|
+
if (mounted && state === "loading")
|
|
35421
|
+
return;
|
|
35422
|
+
}
|
|
35335
35423
|
cancelActiveSourceLoad("navigation");
|
|
35336
35424
|
const req = ++SOURCE_REQ_SEQ;
|
|
35337
35425
|
const repoTarget = repoFileTargetFromRoute();
|
|
@@ -35343,10 +35431,13 @@ code-viewer query agent-help`
|
|
|
35343
35431
|
const card = document.createElement("article");
|
|
35344
35432
|
card.className = "gdp-file-shell loaded gdp-standalone-source gdp-source-mode";
|
|
35345
35433
|
card.dataset.path = target.path;
|
|
35434
|
+
card.dataset.sourceRef = target.ref || "worktree";
|
|
35435
|
+
setSourceCardState(card, "loading");
|
|
35346
35436
|
const internalKind = sourceInternalPathKind(target.path);
|
|
35347
35437
|
const wrapper = document.createElement("div");
|
|
35348
35438
|
wrapper.className = "gdp-file-detail-wrapper";
|
|
35349
|
-
const
|
|
35439
|
+
const mediaOnly = !internalKind && isMediaPreviewOnlySource(target.path);
|
|
35440
|
+
const activeTab = mediaOnly || !internalKind && STATE.route.screen === "file" && STATE.route.preview ? "preview" : "code";
|
|
35350
35441
|
const { sticky, header } = createFileShellSticky({
|
|
35351
35442
|
currentRange,
|
|
35352
35443
|
setRoute,
|
|
@@ -35427,9 +35518,13 @@ code-viewer query agent-help`
|
|
|
35427
35518
|
const rendered2 = await renderPagedSourceText(card, target, meta.size, controller.signal);
|
|
35428
35519
|
if (req !== SOURCE_REQ_SEQ || !sourceTargetsEqual(sourceTargetFromRoute(), target))
|
|
35429
35520
|
return;
|
|
35430
|
-
if (!rendered2)
|
|
35521
|
+
if (!rendered2) {
|
|
35522
|
+
finishSourceLoad(req);
|
|
35523
|
+
renderSourceError(card, target, `Cannot load ${target.path} at ${target.ref}`);
|
|
35431
35524
|
return;
|
|
35525
|
+
}
|
|
35432
35526
|
scrollStandaloneSourceLine(card, lineTargetStart(STATE.route.screen === "file" ? STATE.route.line : undefined));
|
|
35527
|
+
setSourceCardState(card, "done");
|
|
35433
35528
|
finishSourceLoad(req);
|
|
35434
35529
|
return;
|
|
35435
35530
|
}
|
|
@@ -35450,6 +35545,7 @@ code-viewer query agent-help`
|
|
|
35450
35545
|
if (!rendered)
|
|
35451
35546
|
return;
|
|
35452
35547
|
scrollStandaloneSourceLine(card, lineTargetStart(STATE.route.screen === "file" ? STATE.route.line : undefined));
|
|
35548
|
+
setSourceCardState(card, "done");
|
|
35453
35549
|
finishSourceLoad(req);
|
|
35454
35550
|
}
|
|
35455
35551
|
} catch (err) {
|
|
@@ -35477,7 +35573,7 @@ code-viewer query agent-help`
|
|
|
35477
35573
|
if (row)
|
|
35478
35574
|
row.scrollIntoView({ block: "center" });
|
|
35479
35575
|
}
|
|
35480
|
-
function applySourceRouteToShell() {
|
|
35576
|
+
function applySourceRouteToShell(options = {}) {
|
|
35481
35577
|
const target = sourceTargetFromRoute();
|
|
35482
35578
|
setPageMode();
|
|
35483
35579
|
if (!target) {
|
|
@@ -35487,7 +35583,7 @@ code-viewer query agent-help`
|
|
|
35487
35583
|
});
|
|
35488
35584
|
return;
|
|
35489
35585
|
}
|
|
35490
|
-
renderStandaloneSource(target);
|
|
35586
|
+
renderStandaloneSource(target, options);
|
|
35491
35587
|
}
|
|
35492
35588
|
function inferLang(path) {
|
|
35493
35589
|
const name = sourceFileName(path);
|
|
@@ -37604,7 +37700,7 @@ code-viewer query agent-help`
|
|
|
37604
37700
|
setPreferredSourceTab: (tab) => SOURCE_VIEW.setPreferredSourceTab(tab),
|
|
37605
37701
|
createFileBreadcrumb: (path, ref) => DIFF_VIEW.createFileBreadcrumb(path, ref),
|
|
37606
37702
|
emptyText: () => uiText().diff
|
|
37607
|
-
}, historyRoute);
|
|
37703
|
+
}, historyRoute, { loadSidebar: false });
|
|
37608
37704
|
activeFileHistoryDiffHost = mount.diffHost;
|
|
37609
37705
|
activeFileHistoryEmptyHost = mount.emptyHost;
|
|
37610
37706
|
return mount;
|
|
@@ -37636,12 +37732,12 @@ code-viewer query agent-help`
|
|
|
37636
37732
|
history.replaceState(historyStateForRoute(STATE.route), "", url + window.location.hash);
|
|
37637
37733
|
}
|
|
37638
37734
|
}
|
|
37639
|
-
function dispatchFileRoute(route) {
|
|
37735
|
+
function dispatchFileRoute(route, options = {}) {
|
|
37640
37736
|
if (route.view === "blob") {
|
|
37641
37737
|
setStatus("live");
|
|
37642
37738
|
removeFileHistoryShell2();
|
|
37643
37739
|
BLAME_VIEW.removeBlamePage();
|
|
37644
|
-
applySourceRouteToShell();
|
|
37740
|
+
applySourceRouteToShell(options);
|
|
37645
37741
|
return true;
|
|
37646
37742
|
}
|
|
37647
37743
|
if (route.view === "blame") {
|
|
@@ -37659,7 +37755,17 @@ code-viewer query agent-help`
|
|
|
37659
37755
|
parkRangeForHistory();
|
|
37660
37756
|
setPageMode();
|
|
37661
37757
|
const mount = renderFileHistoryShell2(route);
|
|
37662
|
-
HISTORY_VIEW.enterHistory({ mount })
|
|
37758
|
+
HISTORY_VIEW.enterHistory({ mount }).then(async () => {
|
|
37759
|
+
const currentRoute = STATE.route;
|
|
37760
|
+
if (currentRoute.screen !== "file" || currentRoute.view !== "history" || currentRoute.path !== route.path || currentRoute.ref !== route.ref)
|
|
37761
|
+
return;
|
|
37762
|
+
await loadDiffFile(route.path);
|
|
37763
|
+
const routeAfterDiff = STATE.route;
|
|
37764
|
+
if (routeAfterDiff.screen !== "file" || routeAfterDiff.view !== "history" || routeAfterDiff.path !== route.path || routeAfterDiff.ref !== route.ref)
|
|
37765
|
+
return;
|
|
37766
|
+
await REPO_VIEW.renderRepoBlobSidebar(route.path, route.ref);
|
|
37767
|
+
placeSidebarToggle();
|
|
37768
|
+
});
|
|
37663
37769
|
return true;
|
|
37664
37770
|
}
|
|
37665
37771
|
return false;
|
|
@@ -38649,7 +38755,7 @@ code-viewer query agent-help`
|
|
|
38649
38755
|
setStatus("live");
|
|
38650
38756
|
return Promise.resolve(null);
|
|
38651
38757
|
}
|
|
38652
|
-
if (STATE.route.screen === "file" && !(isFileHistoryRoute(STATE.route) && activeHistoryPathFilter) && dispatchFileRoute(STATE.route)) {
|
|
38758
|
+
if (STATE.route.screen === "file" && !(isFileHistoryRoute(STATE.route) && activeHistoryPathFilter) && dispatchFileRoute(STATE.route, { refresh: true })) {
|
|
38653
38759
|
return Promise.resolve({
|
|
38654
38760
|
structureChanged: false,
|
|
38655
38761
|
invalidatedCards: 0,
|
|
@@ -39342,7 +39448,7 @@ code-viewer query agent-help`
|
|
|
39342
39448
|
if (!shouldAutoLoadCurrentRoute(route))
|
|
39343
39449
|
return;
|
|
39344
39450
|
if (isBlobOrBlameFileRoute(route)) {
|
|
39345
|
-
dispatchFileRoute(route);
|
|
39451
|
+
dispatchFileRoute(route, { refresh: true });
|
|
39346
39452
|
return;
|
|
39347
39453
|
}
|
|
39348
39454
|
doSseLoad(paths);
|
|
@@ -39382,7 +39488,7 @@ code-viewer query agent-help`
|
|
|
39382
39488
|
const viewingPath = route.path;
|
|
39383
39489
|
if (paths && viewingPath && !paths.has(viewingPath))
|
|
39384
39490
|
return;
|
|
39385
|
-
dispatchFileRoute(route);
|
|
39491
|
+
dispatchFileRoute(route, { refresh: true });
|
|
39386
39492
|
return;
|
|
39387
39493
|
}
|
|
39388
39494
|
if (route.screen === "repo") {
|