git-tm 2.1.0 → 2.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-tm",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Explore any Git repository in your browser: commit graph, syntax-highlighted diffs, blame, reflog recovery, insights, time travel, and opt-in safe history editing. Zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -178,6 +178,7 @@ export function renderDetail(pane, app, hash, initial = {}) {
178
178
  <span class="muted small">${blob.binary ? "binary" : plural(lines.length, "line")} · ${bytes(entry.size)}</span>
179
179
  <span class="spacer"></span>
180
180
  ${blob.binary ? "" : html`<button class="btn btn-sm ${blame ? "btn-primary" : ""}" data-act="blame" aria-pressed="${Boolean(blame)}">Blame</button>`}
181
+ ${globalThis.gitTmBridge?.openFile ? html`<button class="btn btn-sm" data-act="open-editor" title="Open current file in VS Code">${raw(icons.external)} Open in Editor</button>` : ""}
181
182
  <button class="btn btn-sm" data-act="file-history">${raw(icons.history)} History</button>
182
183
  ${blob.binary ? "" : html`<button class="btn btn-sm" data-act="copy-file">${raw(icons.copy)} Copy</button>`}
183
184
  </div>
@@ -231,6 +232,8 @@ export function renderDetail(pane, app, hash, initial = {}) {
231
232
  case "blame":
232
233
  opts.blame = !opts.blame;
233
234
  return drawBody();
235
+ case "open-editor":
236
+ return globalThis.gitTmBridge?.openFile(opts.path);
234
237
  case "file-history":
235
238
  return app.setFilter({ path: opts.path, follow: true });
236
239
  case "copy-file":
@@ -369,6 +369,7 @@ export async function mountChanges(el, opts) {
369
369
  const res = sec._res;
370
370
  const tools = html`<div class="file-tools">
371
371
  ${to !== WORKTREE && f.status !== "D" && opts.onOpenFile ? html`<button class="btn btn-sm btn-ghost" data-act="open-file">View file</button>` : ""}
372
+ ${f.status !== "D" && globalThis.gitTmBridge?.openFile ? html`<button class="btn btn-sm btn-ghost" data-act="open-editor" title="Open current file in VS Code">${raw(icons.external)} Open in Editor</button>` : ""}
372
373
  ${opts.onFileHistory ? html`<button class="btn btn-sm btn-ghost" data-act="file-history">${raw(icons.history)} History</button>` : ""}
373
374
  ${f.binary ? "" : html`<button class="btn btn-sm btn-ghost" data-act="full" aria-pressed="${sec._full}">${sec._full ? "Show changes only" : "Show full file"}</button>`}
374
375
  </div>`;
@@ -409,6 +410,8 @@ export async function mountChanges(el, opts) {
409
410
  return paint(sec);
410
411
  case "open-file":
411
412
  return opts.onOpenFile(f.path, to);
413
+ case "open-editor":
414
+ return globalThis.gitTmBridge?.openFile(f.path);
412
415
  case "file-history":
413
416
  return opts.onFileHistory(f.path);
414
417
  }
@@ -492,14 +492,19 @@ async function boot() {
492
492
  poll();
493
493
  document.addEventListener("visibilitychange", poll);
494
494
 
495
- // VS Code extension: open filtered (File History), retarget an open panel, or pick up changed settings.
495
+ // VS Code extension: open filtered (File History), jump to a view/commit, retarget an open panel, or pick up changed settings.
496
496
  const applyQuery = (q) => {
497
497
  if (typeof q !== "string") return;
498
498
  $("#search").value = q;
499
499
  app.setFilter(q.trim() ? parseQuery(q) : null);
500
500
  };
501
+ const applyHash = (h) => {
502
+ if (typeof h === "string" && h.startsWith("#/")) app.navigate(h);
503
+ };
501
504
  if (globalThis.gitTmBridge?.initialQuery) applyQuery(globalThis.gitTmBridge.initialQuery);
505
+ if (globalThis.gitTmBridge?.initialHash) applyHash(globalThis.gitTmBridge.initialHash);
502
506
  window.addEventListener("gtm-query", (e) => applyQuery(e.detail));
507
+ window.addEventListener("gtm-navigate", (e) => applyHash(e.detail));
503
508
  window.addEventListener("gtm-refresh", async () => {
504
509
  try {
505
510
  clearAvatars(); // refilled by the next responses if avatars are still on