@kubohiroya/turbowarp-plus-editor-git 0.15.0 → 0.16.1

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 (38) hide show
  1. package/README.ja.md +5 -3
  2. package/README.md +5 -3
  3. package/dist/close-button.d.ts +6 -0
  4. package/dist/file-diff-view.d.ts +3 -1
  5. package/dist/filesystem.d.ts +2 -2
  6. package/dist/history-graph-view.d.ts +40 -0
  7. package/dist/history-graph.d.ts +44 -0
  8. package/dist/index.d.ts +18 -1
  9. package/dist/index.js +697 -31
  10. package/dist/local-operations.d.ts +14 -0
  11. package/dist/messages.d.ts +52 -0
  12. package/dist/{project-comparison-LAyP_beL.js → project-comparison-1rggIJse.js} +240 -20
  13. package/dist/project-comparison.d.ts +1 -0
  14. package/dist/project-source-diff.d.ts +2 -0
  15. package/dist/project-source-diff.js +2 -2
  16. package/dist/project-source-review.d.ts +43 -0
  17. package/dist/project-source-tabs.d.ts +35 -0
  18. package/dist/pull-request-panel.d.ts +6 -1
  19. package/dist/{repository-Cx-mxT9l.js → repository-BYno-5f8.js} +491 -4
  20. package/dist/repository.d.ts +44 -0
  21. package/dist/repository.js +1 -1
  22. package/dist/style.css +31 -4
  23. package/package.json +1 -1
  24. package/src/close-button.tsx +10 -0
  25. package/src/file-diff-view.tsx +7 -3
  26. package/src/filesystem.ts +2 -1
  27. package/src/history-graph-view.tsx +233 -0
  28. package/src/history-graph.ts +90 -0
  29. package/src/index.tsx +137 -17
  30. package/src/local-operations.ts +59 -4
  31. package/src/messages.ts +26 -2
  32. package/src/project-comparison.tsx +4 -2
  33. package/src/project-source-diff.tsx +2 -0
  34. package/src/project-source-review.tsx +127 -15
  35. package/src/project-source-tabs.tsx +118 -0
  36. package/src/pull-request-panel.tsx +26 -5
  37. package/src/repository.ts +155 -1
  38. package/src/style.css +31 -4
package/README.ja.md CHANGED
@@ -4,15 +4,17 @@
4
4
 
5
5
  TurboWarp Plus Editor のファイルメニューに「ローカル Git」を追加します。リポジトリルートを一度選び、配下の sb3-toolchain v1 作品フォルダをパネルから開きます。作品の編集と保存には Editor の project-folder 接続を使います。
6
6
 
7
- ステージ済み・未ステージ・未追跡の変更、現在のブランチ、HEAD、ローカルブランチと直近50件の履歴を表示します。ファイルを選ぶとテキスト差分またはバイナリのサイズを確認できます。作品データ(`project.source.json`)は、ホストがブロックの描画関数を渡していればステージ・スプライト別、コード別のブロックで比べ、「テキスト」に切り替えると行単位の差分を表示します。ステージ・スプライトの見出しには、その版の現在のコスチューム(ステージは背景)のサムネイルを添えます。素材は比較する版から読みます(ステージ済みは HEAD とインデックス、未ステージはインデックスと作業ツリー、未追跡は作業ツリー、コミットは第一親とそのコミット)。素材のフォルダはその版の `sb3-source.json` の `assetsDirectory`(既定は `assets`)です。読めない版では名前だけを示します。コミットを選ぶと第一親との差分を表示します。作品を選んでいるときは、変更一覧と差分をそのフォルダに絞ります。
7
+ ステージ済み・未ステージ・未追跡の変更、現在のブランチ、HEAD、ローカルブランチと履歴を表示します。ファイルを選ぶとテキスト差分またはバイナリのサイズを確認できます。作品データ(`project.source.json`)は、ホストがブロックの描画関数を渡していればステージ・スプライト別、コード別のブロックで比べ、「テキスト」に切り替えると行単位の差分を表示します。ステージ・スプライトの見出しには、その版の現在のコスチューム(ステージは背景)のサムネイルを添えます。素材は比較する版から読みます(ステージ済みは HEAD とインデックス、未ステージはインデックスと作業ツリー、未追跡は作業ツリー、コミットは第一親とそのコミット)。素材のフォルダはその版の `sb3-source.json` の `assetsDirectory`(既定は `assets`)です。読めない版では名前だけを示します。コミットを選ぶと第一親との差分を表示します。作品を選んでいるときは、変更一覧と差分をそのフォルダに絞ります。
8
8
 
9
9
  パネルを開いている間は、2 秒ごと、ウィンドウにフォーカスが戻ったとき、対応環境では `FileSystemObserver` の通知でリポジトリを確認します。HEAD、インデックス、`packed-refs`、`config`、現在のブランチの参照、選択中の作品フォルダのファイル(作品を選んでいない場合は作業ツリー全体、5,000 件まで)のサイズと更新時刻を比べます。変更があり、差分やコミットを開いていなければ読み直します。差分・コミット・プルリクエストのレビューを開いている間は表示を保ち、**再取得** を案内します。Git がメタデータをロックしている間は確認を待ちます。**作品を再読込** では、Editor の未保存編集を確認してから同じ作品を開き直します。Git の閲覧には読み取り専用のアダプターを使い、インデックスの更新を無効にします。読み取り中にファイルや Git の状態が変わった場合は、外部操作の完了後に再取得します。
10
10
 
11
- ホストが `localWrite` を渡すと、現在のブランチで、ファイルを次の記録に入れる(ステージ)、次の記録から外す(アンステージ)、入れた変更を記録する(コミット)操作も使えます。pull と同じく、Git の書き込みを先にまとめ、置き換えるファイルを確かめ直してから適用し、途中で失敗したら適用した分を戻します。書き込むのは `.git/index`、オブジェクト、現在のブランチの参照だけで、作業ツリーと `.git/config` は書きません。コミットの作者はリポジトリの `user.name` と `user.email` を使い、足りない分だけ `localWrite.author()` で補います。補った値を設定には書きません。Editor に保存していない編集があるときは、ステージを待ちます。ブラウザーからは実行権限とシンボリックリンクが見えないため、Git が `100644` 以外のモードで記録しているファイルはステージできません。ほかのツールが `index.lock` を持っているときや、マージ・cherry-pick・revert・rebase の途中では操作しません。`localWrite` がなければ、パネルは読むだけです。
11
+ ホストが `localWrite` を渡すと、現在のブランチで、ファイルを次の記録に入れる(ステージ)、次の記録から外す(アンステージ)、入れた変更を記録する(コミット)操作も使えます。pull と同じく、Git の書き込みを先にまとめ、置き換えるファイルを確かめ直してから適用し、途中で失敗したら適用した分を戻します。書き込むのは `.git/index`、オブジェクト、現在のブランチの参照だけで、作業ツリーと `.git/config` は書きません。コミットの作者はリポジトリの `user.name` と `user.email` を使い、足りない分だけ `localWrite.author()` で補います。補った値を設定には書きません。Editor に保存していない編集があるときは、ステージを待ちます。ブラウザーからは実行権限とシンボリックリンクが見えないため、Git が `100644` 以外のモードで記録しているファイルはステージできません。ほかのツールが `index.lock` を持っているときや、マージ・cherry-pick・revert・rebase の途中では操作しません。`localWrite` があると、左側の一覧にローカルブランチと **切り替える**、HEAD から新しいブランチを作る欄(作ったら切り替えることもできます)、`origin` から取得済みでローカルにまだないブランチの **作って切り替える** が出ます。切り替えは HEAD・インデックス・作業ツリーを同じ確かめ方で書き換えるので、作品を止め、未保存の編集と作業ツリーの変更をなくしておく必要があります。切り替え先のファイルが通常の `100644` でなければ切り替えません。`origin/<名前>` から作ったブランチには追跡の設定を書きません(`.git/config` は書かないため)。fetch・pull・push は同じ名前のリモートブランチを使います。開いている作品フォルダが切り替え先にないときは、先に確かめます。切り替えた後は **作品を再読込** で、そのブランチのファイルを開けます。`localWrite` がなければ、パネルは読むだけです。
12
+
13
+ 履歴は、ローカルブランチ、`origin/*`、ブランチ未選択の HEAD からたどれるコミット(タグだけからたどれるものは除く)のグラフです。コミット時刻の新しい順に、子を必ず親より上に並べ、50 件ずつ表示して **さらに表示** で続きを読みます。レーンは [DoltHub のコミットグラフ](https://www.dolthub.com/blog/2024-08-07-drawing-a-commit-graph/) の考え方でパネル内で割り当て、SVG で描きます。各コミットはボタンで、ブランチ(`main`、`origin/main`、現在のブランチの印)、作者、日時を示します。Tab で一覧に入り、上下矢印(Home・End)でコミットを移り、Enter か Space で選ぶと第一親との差分を表示します。各コミットの **⋯** ボタン(またはコンテキストメニューキー、Shift+F10)で操作を開きます。**コミットの ID をコピー** は常に、`localWrite` があれば **ここからブランチを作る…**(名前を入れ、作ったら切り替えることもできます)、そのコミットにあるローカルブランチへの **切り替える**、ローカルにまだない `origin/<名前>` の **作って切り替える** が出ます。ブランチ一覧と同じ確かめ方・確認を通ります。ほかの場所に履歴を出すホストは、`Repository.history({limit, after})` でページを読み、`HistoryGraph` で描けます。`layoutHistory` はレーンの割り当てだけを行います。
12
14
 
13
15
  File System Access に対応する Chromium 系ブラウザーが必要です。初版は通常の `.git` ディレクトリとファイル内容の変更を扱います。linked worktree、サブモジュール、シンボリックリンクは対象外です。作業ツリーの実行権限の変更はブラウザーから検出できません。Git に記録済みのファイルモードは表示します。バイナリアセットはサイズを示し、テキスト差分の生成には上限があります。
14
16
 
15
- Node.js 26 で `npm ci` と `npm test` を実行します。Vite でライブラリとスタイルシート、TypeScript で型宣言を生成します。`npm pack` で Editor 用の配布物を作成します。`npm run test:browser` は、最小 editor runtime(`@kubohiroya/turbowarp-plus-editor-test-runtime`)の上で、比較ダイアログのブロックの描画を Chromium で試します。Editor が固定する VM と Scratch Blocks を使い、Editor のビルドは要りません。Editor では既定で有効です。起動 URL に `twPlusLocalGit=0` を指定するとパネルの接続を解除できます。
17
+ Node.js 26 で `npm ci` と `npm test` を実行します。Vite でライブラリとスタイルシート、TypeScript で型宣言を生成します。`npm pack` で Editor 用の配布物を作成します。`npm run test:browser` は、最小 editor runtime(`@kubohiroya/turbowarp-plus-editor-test-runtime`)の上で、履歴グラフのキーボード操作と操作メニュー、比較ダイアログのブロックの描画を Chromium で試します。Editor が固定する VM と Scratch Blocks を使い、Editor のビルドは要りません。Editor では既定で有効です。起動 URL に `twPlusLocalGit=0` を指定するとパネルの接続を解除できます。
16
18
 
17
19
  パネルの構成とローカル Git の扱いは [duff](https://github.com/chigichan24/duff) を参考にしました。実装には [isomorphic-git](https://github.com/isomorphic-git/isomorphic-git) と [react-diff-view](https://github.com/otakustay/react-diff-view) を使用し、同梱依存のライセンスはビルド時の第三者ライセンス一覧に収録します。
18
20
 
package/README.md CHANGED
@@ -4,15 +4,17 @@
4
4
 
5
5
  Local Git adds a panel to the TurboWarp Plus Editor File menu. Select the repository root once, then browse to an sb3-toolchain v1 project folder inside it. Project editing and saving are supplied by the Editor's project-folder integration.
6
6
 
7
- The panel separates staged, unstaged, and untracked changes. It shows the current branch, HEAD, local branches, and the latest 50 commits. Select a file to inspect its text diff or binary size. When the host supplies a block renderer, project data (`project.source.json`) is compared as blocks by stage, sprite and code, and **Text** switches to the line diff. Each stage and sprite heading shows a thumbnail of its current costume (the backdrop for the stage) in each version. Assets are read from the compared versions: HEAD and the index for staged changes, the index and the working tree for unstaged changes, the working tree for untracked files, and the first parent and the commit for history. The assets folder is the `assetsDirectory` of that version's `sb3-source.json` (`assets` by default). When an asset cannot be read, only the name is shown. Pull request reviews read the same thumbnails from raw.githubusercontent.com at the merge base and head, without using the GitHub API rate limit. A review's **Reviewed** marks are kept in browser storage per repository and pull request, together with each script's content: they survive closing the panel and reloading the Editor, and only the marks of scripts whose content changed are cleared when the pull request head moves. They are never written to project files or Git. Select a commit to compare its files with its first parent. The selected project limits the file list and diffs to that folder.
7
+ The panel separates staged, unstaged, and untracked changes. It shows the current branch, HEAD, local branches, and the history. Select a file to inspect its text diff or binary size. When the host supplies a block renderer, project data (`project.source.json`) is compared as blocks by stage, sprite and code, and **Text** switches to the line diff. Each stage and sprite heading shows a thumbnail of its current costume (the backdrop for the stage) in each version. Assets are read from the compared versions: HEAD and the index for staged changes, the index and the working tree for unstaged changes, the working tree for untracked files, and the first parent and the commit for history. The assets folder is the `assetsDirectory` of that version's `sb3-source.json` (`assets` by default). When an asset cannot be read, only the name is shown. Pull request reviews read the same thumbnails from raw.githubusercontent.com at the merge base and head, without using the GitHub API rate limit. A review's **Reviewed** marks are kept in browser storage per repository and pull request, together with each script's content: they survive closing the panel and reloading the Editor, and only the marks of scripts whose content changed are cleared when the pull request head moves. They are never written to project files or Git. Select a commit to compare its files with its first parent. The selected project limits the file list and diffs to that folder.
8
8
 
9
9
  While the panel is open, it checks the repository every two seconds, when the window regains focus, and on `FileSystemObserver` notifications where available. It compares the sizes and modification times of HEAD, the index, `packed-refs`, `config`, the current branch ref, and the files in the selected project folder (the whole work tree when no project is selected, up to 5,000 files). When something changed and no diff or commit is open, the panel reads the repository again. While a diff, a commit or a pull request review is open, it keeps the view and asks you to **Refresh** instead. Checks wait while Git holds a lock on its metadata. **Reload Project** opens the selected project again using the Editor's unsaved-edit confirmation. Git inspection uses a read-only adapter and isomorphic-git with index refresh disabled. If the repository changes during a read, refresh after the other operation completes.
10
10
 
11
- When the host passes `localWrite`, the panel can also add files to the next record (stage), remove them from it (unstage) and record the staged changes (commit) on the current branch. Like pull, these operations collect Git's writes first and apply them only after the files they replace are checked again; a failure part way puts back what was applied. They write only `.git/index`, objects and the current branch ref; the work tree and `.git/config` are never written. Commits use the repository's `user.name` and `user.email`; `localWrite.author()` fills in only what the config lacks, and is never written to it. Staging waits until the Editor's edits are saved. The browser cannot see executable bits or symbolic links, so files that Git records with another mode than `100644` cannot be staged here. Operations stop while another tool holds `index.lock` or is in the middle of a merge, cherry-pick, revert or rebase. Without `localWrite`, the panel only reads.
11
+ When the host passes `localWrite`, the panel can also add files to the next record (stage), remove them from it (unstage) and record the staged changes (commit) on the current branch. Like pull, these operations collect Git's writes first and apply them only after the files they replace are checked again; a failure part way puts back what was applied. They write only `.git/index`, objects and the current branch ref; the work tree and `.git/config` are never written. Commits use the repository's `user.name` and `user.email`; `localWrite.author()` fills in only what the config lacks, and is never written to it. Staging waits until the Editor's edits are saved. The browser cannot see executable bits or symbolic links, so files that Git records with another mode than `100644` cannot be staged here. Operations stop while another tool holds `index.lock` or is in the middle of a merge, cherry-pick, revert or rebase. With `localWrite`, the side list also shows the local branches with **Switch**, a form to create a branch at HEAD (optionally switching to it), and **Create and Switch** for branches fetched from `origin` that have no local branch yet. Switching rewrites HEAD, the index and the work tree through the same checked path, so it needs a stopped project, no unsaved edits and no changes in the work tree, and refuses branches whose files are not regular `100644` files. A branch made from `origin/<name>` gets no tracking settings, since `.git/config` is never written; fetch, pull and push then use the remote branch of the same name. When the open project folder is not on the target branch, the panel asks first. After switching, **Reload Project** opens the branch's files. Without `localWrite`, the panel only reads.
12
+
13
+ The history is a graph of the commits reachable from the local branches, `origin/*` and a detached HEAD (not from tags), newest committer time first with every child above its parents, 50 at a time with **Show more**. Lanes are laid out in the panel after [DoltHub's commit graph](https://www.dolthub.com/blog/2024-08-07-drawing-a-commit-graph/) and drawn in SVG; each commit is a button showing its branches (`main`, `origin/main`, the current one marked), author and date. Tab enters the list, ArrowUp and ArrowDown (Home, End) move between commits, Enter or Space selects one to compare it with its first parent. Each commit's **⋯** button (or the context menu key, or Shift+F10) opens its actions: **Copy commit ID**, and with `localWrite` **Create branch here…** (a name, optionally switching to it), **Switch to** a local branch at that commit, and **Create and switch to** an `origin/<name>` there without a local branch. They take the same checked path, guards and confirmations as the branch list. `Repository.history({limit, after})` reads the pages and `HistoryGraph` draws them, for hosts that show the history elsewhere; `layoutHistory` is the layout alone.
12
14
 
13
15
  A Chromium-based browser with File System Access support is required. The first version supports ordinary `.git` directories and content changes. Linked worktrees, submodules, and symbolic links are outside this scope. The browser cannot detect working-tree executable-bit changes. Recorded index and tree modes remain visible. Binary assets show sizes, and text diff generation is bounded.
14
16
 
15
- Use Node.js 26, run `npm ci`, then `npm test`. Vite builds the library and stylesheet, and TypeScript emits declarations. `npm pack` prepares the artifact used by the Editor build. `npm run test:browser` runs the comparison dialog's block drawing in Chromium on the minimal editor runtime (`@kubohiroya/turbowarp-plus-editor-test-runtime`), with the Editor's pinned VM and Scratch Blocks and without building the Editor. The Editor enables the panel by default. Start it with `twPlusLocalGit=0` in its URL to disable the integration.
17
+ Use Node.js 26, run `npm ci`, then `npm test`. Vite builds the library and stylesheet, and TypeScript emits declarations. `npm pack` prepares the artifact used by the Editor build. `npm run test:browser` runs the history graph's keyboard and actions, and the comparison dialog's block drawing, in Chromium on the minimal editor runtime (`@kubohiroya/turbowarp-plus-editor-test-runtime`), with the Editor's pinned VM and Scratch Blocks and without building the Editor. The Editor enables the panel by default. Start it with `twPlusLocalGit=0` in its URL to disable the integration.
16
18
 
17
19
  The panel structure and local Git approach were informed by [duff](https://github.com/chigichan24/duff). The implementation uses [isomorphic-git](https://github.com/isomorphic-git/isomorphic-git) and [react-diff-view](https://github.com/otakustay/react-diff-view). Bundled licenses are listed in the build's third-party notices.
18
20
 
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ /** A button drawn as an X, named by `label` for screen readers and in its tooltip. */
3
+ export declare function CloseButton({ label, onClick }: {
4
+ label: string;
5
+ onClick(): void;
6
+ }): React.JSX.Element;
@@ -9,7 +9,7 @@ export declare const isProjectSource: (path: string) => boolean;
9
9
  /**
10
10
  * Shows one changed file. Project sources are compared as blocks by default, with their text diff one switch away.
11
11
  */
12
- export declare function FileDiffView({ change, diff, labels, locale, renderBlock, loadAsset, locateBlock }: {
12
+ export declare function FileDiffView({ change, diff, labels, locale, renderBlock, loadAsset, locateBlock, onOpenTabs }: {
13
13
  change: FileChange;
14
14
  diff: FileDiff | null;
15
15
  labels: ReturnType<typeof labelsFor>;
@@ -17,4 +17,6 @@ export declare function FileDiffView({ change, diff, labels, locale, renderBlock
17
17
  renderBlock?: ProjectBlockRenderer;
18
18
  loadAsset?: ProjectAssetLoader;
19
19
  locateBlock?: ProjectBlockLocator;
20
+ /** Opens the comparison as tabs of the host's layout, a tab group for each stage or sprite. */
21
+ onOpenTabs?(before: string | null, after: string | null): void;
20
22
  }): React.JSX.Element;
@@ -1,6 +1,6 @@
1
1
  export declare class GitPanelError extends Error {
2
- code: 'invalid' | 'changed' | 'large' | 'unsupported' | 'pullUnsafe' | 'diverged' | 'session' | 'pushUnknown' | 'pushRefresh' | 'rollbackFailed' | 'remoteFailed' | 'saveFirst' | 'author' | 'nothingStaged' | 'commitMessage';
3
- constructor(code: 'invalid' | 'changed' | 'large' | 'unsupported' | 'pullUnsafe' | 'diverged' | 'session' | 'pushUnknown' | 'pushRefresh' | 'rollbackFailed' | 'remoteFailed' | 'saveFirst' | 'author' | 'nothingStaged' | 'commitMessage', message?: string);
2
+ code: 'invalid' | 'changed' | 'large' | 'unsupported' | 'pullUnsafe' | 'diverged' | 'session' | 'pushUnknown' | 'pushRefresh' | 'rollbackFailed' | 'remoteFailed' | 'saveFirst' | 'author' | 'nothingStaged' | 'commitMessage' | 'switchUnsafe' | 'branchExists' | 'branchName' | 'locked';
3
+ constructor(code: 'invalid' | 'changed' | 'large' | 'unsupported' | 'pullUnsafe' | 'diverged' | 'session' | 'pushUnknown' | 'pushRefresh' | 'rollbackFailed' | 'remoteFailed' | 'saveFirst' | 'author' | 'nothingStaged' | 'commitMessage' | 'switchUnsafe' | 'branchExists' | 'branchName' | 'locked', message?: string);
4
4
  }
5
5
  export declare const fileError: (code: string, path: string) => Error & {
6
6
  code: string;
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import type { HistoryCommit } from './repository.js';
3
+ /** How a write action ended: `error` is the message to show when it did not run to the end. */
4
+ export type HistoryActionResult = {
5
+ done: true;
6
+ } | {
7
+ done: false;
8
+ error?: string;
9
+ };
10
+ export interface HistoryGraphProps {
11
+ /** Commits newest first, each child above its parents, as `Repository.history` returns them page by page. */
12
+ commits: readonly HistoryCommit[];
13
+ /** The commit shown as selected. */
14
+ selected?: string | null;
15
+ onSelect(oid: string): void;
16
+ locale?: string;
17
+ /** While true, selecting and the write actions wait; focus and copying still work. */
18
+ busy?: boolean;
19
+ /** Offers **Show more** when there are more commits to read. */
20
+ hasMore?: boolean;
21
+ loadingMore?: boolean;
22
+ onShowMore?(): void;
23
+ /** Local branch names, so `origin/<name>` is offered as a new branch only when there is none yet. */
24
+ localBranches?: readonly string[];
25
+ /**
26
+ * Write actions. Each is offered only when given. The branch form stays open with the name until `onCreateBranch`
27
+ * resolves `{done: true}` (or nothing); `{done: false, error}` or a rejection shows the reason in the form.
28
+ */
29
+ onCreateBranch?(oid: string, name: string, checkout: boolean): void | Promise<void | HistoryActionResult>;
30
+ onSwitchBranch?(name: string): void | Promise<unknown>;
31
+ onCreateFromRemote?(name: string): void | Promise<unknown>;
32
+ }
33
+ /** Lane colors that read on light and dark backgrounds. */
34
+ export declare const laneColors: string[];
35
+ /**
36
+ * The history as a graph: one row per commit with its lanes drawn in SVG, a button that selects the commit and a
37
+ * button that opens its actions. ArrowUp and ArrowDown move between commits, Home and End to the ends; Enter or
38
+ * Space selects; the context menu key or Shift+F10 opens the actions.
39
+ */
40
+ export declare function HistoryGraph(props: HistoryGraphProps): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Lays out a commit graph in lanes, top to bottom, after the approach DoltHub describes in "Drawing a commit graph"
3
+ * (https://www.dolthub.com/blog/2024-08-07-drawing-a-commit-graph/): each lane waits for one commit; a commit takes
4
+ * the leftmost lane that waits for it, or the first free lane; its first parent continues that lane and each further
5
+ * parent gets the lane that already waits for it, or a free one. Lanes whose commit arrived elsewhere end there and
6
+ * are reused by later commits.
7
+ */
8
+ /** The parts of a commit the layout needs. Commits come newest first, each child above its parents. */
9
+ export interface GraphCommit {
10
+ oid: string;
11
+ parents: readonly string[];
12
+ }
13
+ /**
14
+ * A line in one row's band, between columns. `top` runs from the row's upper edge to the dot's height; `bottom`
15
+ * from the dot's height to the lower edge. `from` is the upper end's column and `to` the lower end's.
16
+ */
17
+ export interface GraphSegment {
18
+ part: 'top' | 'bottom';
19
+ from: number;
20
+ to: number;
21
+ color: number;
22
+ }
23
+ export interface GraphRow {
24
+ oid: string;
25
+ /** The commit's column. */
26
+ column: number;
27
+ /** The color of the commit's lane, an index into a palette (see `laneColors`). */
28
+ color: number;
29
+ segments: GraphSegment[];
30
+ /** Columns this row's band uses: one more than the rightmost lane drawn in it. */
31
+ width: number;
32
+ }
33
+ export interface GraphLayout {
34
+ rows: GraphRow[];
35
+ /** The widest row, for drawing every row with the same width. */
36
+ width: number;
37
+ }
38
+ /** How many lane colors there are. Lanes take them in turn. */
39
+ export declare const laneColorCount = 8;
40
+ /**
41
+ * Lays out commits ordered newest first with every child above its parents. Parents missing from `commits`, such as
42
+ * those on a page not loaded yet or cut off by a shallow clone, keep their lane running to the bottom.
43
+ */
44
+ export declare function layoutHistory(commits: readonly GraphCommit[]): GraphLayout;
package/dist/index.d.ts CHANGED
@@ -8,8 +8,14 @@ export { createScratchBlocksDiffRenderer } from './scratch-block-diff-renderer.j
8
8
  export type { ScratchBlockDiffRendererOptions, ScratchBlocksPort } from './scratch-block-diff-renderer.js';
9
9
  export { openRepository, createReadOnlyFs, GitPanelError } from './repository.js';
10
10
  export { openProjectComparison } from './project-comparison.js';
11
+ export { openProjectSourceTabs } from './project-source-tabs.js';
12
+ export type { ProjectSourceTabsFile, ProjectSourceTabsOptions } from './project-source-tabs.js';
11
13
  export type { ProjectComparisonAction, ProjectComparisonOptions, ProjectComparisonSection } from './project-comparison.js';
12
- export type { Repository, Snapshot, FileChange, FileDiff } from './repository.js';
14
+ export type { Repository, Snapshot, FileChange, FileDiff, HistoryCommit, HistoryCursor, HistoryPage, HistoryRef } from './repository.js';
15
+ export { HistoryGraph, laneColors } from './history-graph-view.js';
16
+ export type { HistoryActionResult, HistoryGraphProps } from './history-graph-view.js';
17
+ export { layoutHistory } from './history-graph.js';
18
+ export type { GraphCommit, GraphLayout, GraphRow, GraphSegment } from './history-graph.js';
13
19
  export type { GitAuthor, LocalOperation } from './local-operations.js';
14
20
  export interface GitHost {
15
21
  connectionSettings?: GitConnectionSettings;
@@ -43,6 +49,17 @@ export interface GitPanelRequest {
43
49
  filename: string;
44
50
  title?: string;
45
51
  transient?: boolean;
52
+ /** Tabs of one area share a split panel of the host's layout. */
53
+ area?: string;
54
+ /** Gathers the tab with the others of the same `id` under a labelled chip; `color` is a palette id such as `'green'`. */
55
+ tabGroup?: {
56
+ id: string;
57
+ label: string;
58
+ color?: string;
59
+ collapsed?: boolean;
60
+ };
61
+ /** Opens the tab behind the active one. */
62
+ inactive?: boolean;
46
63
  mount(element: HTMLElement, close: () => void): {
47
64
  requestClose(): void;
48
65
  dispose(): void;