dsh-git-ui 0.0.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.
- package/LICENSE +21 -0
- package/README.md +113 -0
- package/README.zh.md +110 -0
- package/cordis.patch.yml +14 -0
- package/lib/.keep +0 -0
- package/lib/client.js +71 -0
- package/lib/client.js.map +7 -0
- package/lib/host/core.d.ts +53 -0
- package/lib/host/git.d.ts +89 -0
- package/lib/host/index.d.ts +23 -0
- package/lib/host/index.js +380 -0
- package/lib/host/index.js.map +7 -0
- package/lib/host/parser.d.ts +57 -0
- package/lib/host/types.d.ts +74 -0
- package/package.json +80 -0
- package/src/client/GitPill.tsx +354 -0
- package/src/client/controller.ts +158 -0
- package/src/client/index.ts +149 -0
- package/src/client/locales.ts +55 -0
- package/src/client/remote.ts +97 -0
- package/src/client/styles.ts +229 -0
- package/src/client/turn-signal.ts +33 -0
- package/src/host/core.ts +199 -0
- package/src/host/git.ts +152 -0
- package/src/host/index.ts +80 -0
- package/src/host/parser.ts +176 -0
- package/src/host/types.ts +74 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-git-ui host data model. This file is the authoritative type source;
|
|
3
|
+
* the client half mirrors it with zod schemas (see src/client/remote.ts) and
|
|
4
|
+
* `tests/remote.spec.ts` keeps the two in sync.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Wire request: the browser never sends paths — only the session identity. */
|
|
8
|
+
export interface GitSnapshotRequest {
|
|
9
|
+
readonly sessionId: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Discriminated outcome of one snapshot attempt. */
|
|
13
|
+
export type GitSnapshotResult =
|
|
14
|
+
| { readonly ok: true; readonly value: GitSnapshot }
|
|
15
|
+
| { readonly ok: false; readonly error: GitSnapshotFailure }
|
|
16
|
+
|
|
17
|
+
export type GitSnapshotFailure =
|
|
18
|
+
| { readonly code: 'session-not-found'; readonly sessionId: string }
|
|
19
|
+
| { readonly code: 'cwd-unavailable'; readonly sessionId: string }
|
|
20
|
+
| { readonly code: 'path-not-found'; readonly path: string }
|
|
21
|
+
| { readonly code: 'git-unavailable'; readonly detail: string }
|
|
22
|
+
| { readonly code: 'timeout' }
|
|
23
|
+
| { readonly code: 'not-a-git-repo' }
|
|
24
|
+
|
|
25
|
+
/** Immutable frozen snapshot of one repository's status at `checkedAt`. */
|
|
26
|
+
export interface GitSnapshot {
|
|
27
|
+
/** Realpath of the repository root (work tree top). */
|
|
28
|
+
readonly root: string
|
|
29
|
+
/** Current branch name; null when detached. */
|
|
30
|
+
readonly branch: string | null
|
|
31
|
+
/** Short HEAD hash; null when the repository has no commits (unborn). */
|
|
32
|
+
readonly head: string | null
|
|
33
|
+
/** True when the repository has no commits yet. */
|
|
34
|
+
readonly unborn: boolean
|
|
35
|
+
/** staged + modified + untracked > 0. */
|
|
36
|
+
readonly dirty: boolean
|
|
37
|
+
readonly staged: number
|
|
38
|
+
readonly modified: number
|
|
39
|
+
readonly untracked: number
|
|
40
|
+
readonly ahead: number
|
|
41
|
+
readonly behind: number
|
|
42
|
+
readonly lastCommit: GitCommit | null
|
|
43
|
+
readonly recentCommits: readonly GitCommit[]
|
|
44
|
+
readonly changes: readonly GitChange[]
|
|
45
|
+
/** True when `changes` was capped at maxChanges or status output overflowed. */
|
|
46
|
+
readonly truncated: boolean
|
|
47
|
+
/** Polling interval the client should use after this snapshot (0 = off). */
|
|
48
|
+
readonly refreshIntervalMs: number
|
|
49
|
+
/** Epoch millis of the snapshot. */
|
|
50
|
+
readonly checkedAt: number
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface GitCommit {
|
|
54
|
+
readonly hash: string
|
|
55
|
+
readonly shortHash: string
|
|
56
|
+
readonly subject: string
|
|
57
|
+
readonly author: string
|
|
58
|
+
readonly dateIso: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface GitChange {
|
|
62
|
+
readonly path: string
|
|
63
|
+
readonly status: GitChangeStatus
|
|
64
|
+
readonly staged: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type GitChangeStatus =
|
|
68
|
+
| 'added'
|
|
69
|
+
| 'modified'
|
|
70
|
+
| 'deleted'
|
|
71
|
+
| 'renamed'
|
|
72
|
+
| 'untracked'
|
|
73
|
+
| 'conflicted'
|
|
74
|
+
| 'typechange'
|