@trebired/git-host 1.3.0 → 1.4.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +12 -6
  3. package/dist/api/forge/handler.d.ts +6 -0
  4. package/dist/api/forge/handler.d.ts.map +1 -0
  5. package/dist/api/forge/handler.js +260 -0
  6. package/dist/api/forge/handler.js.map +1 -0
  7. package/dist/api/forge/route.d.ts +34 -0
  8. package/dist/api/forge/route.d.ts.map +1 -0
  9. package/dist/api/forge/route.js +94 -0
  10. package/dist/api/forge/route.js.map +1 -0
  11. package/dist/api/handler/response.d.ts +6 -2
  12. package/dist/api/handler/response.d.ts.map +1 -1
  13. package/dist/api/handler/response.js +5 -0
  14. package/dist/api/handler/response.js.map +1 -1
  15. package/dist/browser/index.d.ts +44 -0
  16. package/dist/browser/index.d.ts.map +1 -0
  17. package/dist/browser/index.js +767 -0
  18. package/dist/browser/index.js.map +1 -0
  19. package/dist/browser/styles.css +242 -0
  20. package/dist/core/create_git_forge.d.ts +4 -0
  21. package/dist/core/create_git_forge.d.ts.map +1 -0
  22. package/dist/core/create_git_forge.js +481 -0
  23. package/dist/core/create_git_forge.js.map +1 -0
  24. package/dist/core/git_forge/storage_memory.d.ts +4 -0
  25. package/dist/core/git_forge/storage_memory.d.ts.map +1 -0
  26. package/dist/core/git_forge/storage_memory.js +140 -0
  27. package/dist/core/git_forge/storage_memory.js.map +1 -0
  28. package/dist/index.d.ts +4 -1
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -0
  31. package/dist/index.js.map +1 -1
  32. package/dist/react/client/types.d.ts +45 -1
  33. package/dist/react/client/types.d.ts.map +1 -1
  34. package/dist/react/client.d.ts.map +1 -1
  35. package/dist/react/client.js +135 -2
  36. package/dist/react/client.js.map +1 -1
  37. package/dist/react/hooks/query.d.ts +6 -2
  38. package/dist/react/hooks/query.d.ts.map +1 -1
  39. package/dist/react/hooks/query.js +41 -1
  40. package/dist/react/hooks/query.js.map +1 -1
  41. package/dist/react/hooks/resources.d.ts +50 -3
  42. package/dist/react/hooks/resources.d.ts.map +1 -1
  43. package/dist/react/hooks/resources.js +209 -2
  44. package/dist/react/hooks/resources.js.map +1 -1
  45. package/dist/react/hooks/types.d.ts +15 -2
  46. package/dist/react/hooks/types.d.ts.map +1 -1
  47. package/dist/react/hooks.d.ts +3 -3
  48. package/dist/react/hooks.d.ts.map +1 -1
  49. package/dist/react/hooks.js +2 -2
  50. package/dist/react/hooks.js.map +1 -1
  51. package/dist/react/index.d.ts +2 -2
  52. package/dist/react/index.d.ts.map +1 -1
  53. package/dist/react/index.js +1 -1
  54. package/dist/react/index.js.map +1 -1
  55. package/dist/types/forge.d.ts +220 -0
  56. package/dist/types/forge.d.ts.map +1 -0
  57. package/dist/types/forge.js +2 -0
  58. package/dist/types/forge.js.map +1 -0
  59. package/dist/types/index.d.ts +1 -0
  60. package/dist/types/index.d.ts.map +1 -1
  61. package/dist/types/transports.d.ts +1 -1
  62. package/dist/types/transports.d.ts.map +1 -1
  63. package/package.json +11 -4
@@ -0,0 +1,767 @@
1
+ import { createElement, useDeferredValue, useEffect, useState, } from "react";
2
+ import { createGitApiClient } from "../react/client.js";
3
+ import { GitApiClientProvider, applyGitStarOptimisticState, applyGitWatchOptimisticState, useGitActivity, useGitBlob, useGitCommit, useGitCommits, useGitCreateFork, useGitCreateRelease, useGitForks, useGitOverview, useGitRelease, useGitReleases, useGitSocialState, useGitStarRepository, useGitSyncFork, useGitTree, useGitUnstarRepository, useGitUnwatchRepository, useGitWatchRepository, } from "../react/index.js";
4
+ import { text } from "../utils/text.js";
5
+ const h = createElement;
6
+ function joinClassNames(...values) {
7
+ return values.filter(Boolean).join(" ");
8
+ }
9
+ function GitBrowserProvider(props) {
10
+ const [client] = useState(() => props.client || createGitApiClient({
11
+ baseUrl: text(props.baseUrl),
12
+ headers: props.headers,
13
+ }));
14
+ return h(GitApiClientProvider, {
15
+ client,
16
+ children: props.children,
17
+ });
18
+ }
19
+ function withBrowserProvider(props, render) {
20
+ if (!props.client && !props.baseUrl)
21
+ return render();
22
+ return h(GitBrowserProvider, {
23
+ baseUrl: props.baseUrl,
24
+ client: props.client,
25
+ headers: props.headers,
26
+ children: render(),
27
+ });
28
+ }
29
+ function formatDate(value) {
30
+ const next = text(value);
31
+ if (!next)
32
+ return "Unknown";
33
+ try {
34
+ return new Date(next).toLocaleString("en-US", {
35
+ dateStyle: "medium",
36
+ timeStyle: "short",
37
+ });
38
+ }
39
+ catch {
40
+ return next;
41
+ }
42
+ }
43
+ function LinkButton(props) {
44
+ return h("button", {
45
+ className: joinClassNames("git-browser-nav-link", props.active && "is-active"),
46
+ onClick: () => props.navigate && props.navigate(props.to),
47
+ type: "button",
48
+ children: props.children,
49
+ });
50
+ }
51
+ function StatusBlock(props) {
52
+ if (props.loading)
53
+ return h("div", { className: "git-browser-status", children: "Loading repository data..." });
54
+ if (props.error)
55
+ return h("div", { className: "git-browser-status is-error", children: props.error.message });
56
+ return h("div", { children: props.children });
57
+ }
58
+ function RepositoryNav(props) {
59
+ return h("div", {
60
+ className: "git-browser-nav",
61
+ children: [
62
+ h(LinkButton, { active: props.current === "overview", key: "overview", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/overview`, children: "Overview" }),
63
+ h(LinkButton, { active: props.current === "code", key: "code", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/code`, children: "Code" }),
64
+ h(LinkButton, { active: props.current === "commits", key: "commits", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/commits`, children: "Commits" }),
65
+ h(LinkButton, { active: props.current === "releases", key: "releases", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/releases`, children: "Releases" }),
66
+ h(LinkButton, { active: props.current === "forks", key: "forks", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/forks`, children: "Forks" }),
67
+ h(LinkButton, { active: props.current === "activity", key: "activity", navigate: props.navigate, to: `/repositories/${props.repositoryKey}/activity`, children: "Activity" }),
68
+ ],
69
+ });
70
+ }
71
+ function SocialControls(props) {
72
+ const [optimistic, setOptimistic] = useState(props.social);
73
+ useEffect(() => {
74
+ setOptimistic(props.social);
75
+ }, [props.social]);
76
+ const star = useGitStarRepository(props.repositoryKey, { headers: props.headers });
77
+ const unstar = useGitUnstarRepository(props.repositoryKey, { headers: props.headers });
78
+ const watch = useGitWatchRepository(props.repositoryKey, { headers: props.headers });
79
+ const unwatch = useGitUnwatchRepository(props.repositoryKey, { headers: props.headers });
80
+ const social = optimistic;
81
+ return h("div", {
82
+ className: "git-browser-actions",
83
+ children: [
84
+ h("button", {
85
+ className: joinClassNames("git-browser-action-button", social?.viewer_has_starred && "is-active"),
86
+ disabled: star.loading || unstar.loading,
87
+ key: "star",
88
+ onClick: async () => {
89
+ const next = social?.viewer_has_starred !== true;
90
+ setOptimistic(applyGitStarOptimisticState(social, next));
91
+ try {
92
+ setOptimistic(next ? await star.mutate() : await unstar.mutate());
93
+ }
94
+ catch {
95
+ setOptimistic(props.social);
96
+ }
97
+ },
98
+ type: "button",
99
+ children: `${social?.viewer_has_starred ? "Starred" : "Star"} ${social?.star_count ?? 0}`,
100
+ }),
101
+ h("button", {
102
+ className: joinClassNames("git-browser-action-button", social?.viewer_is_watching && "is-active"),
103
+ disabled: watch.loading || unwatch.loading,
104
+ key: "watch",
105
+ onClick: async () => {
106
+ const next = social?.viewer_is_watching !== true;
107
+ setOptimistic(applyGitWatchOptimisticState(social, next));
108
+ try {
109
+ setOptimistic(next ? await watch.mutate() : await unwatch.mutate());
110
+ }
111
+ catch {
112
+ setOptimistic(props.social);
113
+ }
114
+ },
115
+ type: "button",
116
+ children: `${social?.viewer_is_watching ? "Watching" : "Watch"} ${social?.watcher_count ?? 0}`,
117
+ }),
118
+ ],
119
+ });
120
+ }
121
+ function RepositoryHeader(props) {
122
+ const socialQuery = useGitSocialState(props.repositoryKey, {
123
+ headers: props.headers,
124
+ initialData: props.overview?.social || null,
125
+ });
126
+ const createFork = useGitCreateFork(props.repositoryKey, { headers: props.headers });
127
+ return h("section", {
128
+ className: "git-browser-hero",
129
+ children: [
130
+ h("div", {
131
+ className: "git-browser-hero-top",
132
+ key: "title",
133
+ children: [
134
+ h("div", {
135
+ className: "git-browser-title-block",
136
+ key: "block",
137
+ children: [
138
+ h("div", { className: "git-browser-badge", key: "badge", children: "Embeddable Forge" }),
139
+ h("h1", { className: "git-browser-title", key: "title", children: props.repositoryKey }),
140
+ h("p", {
141
+ className: "git-browser-subtitle",
142
+ key: "subtitle",
143
+ children: props.overview
144
+ ? `${props.overview.repository.repository.current_branch} branch, ${props.overview.release_count} releases, ${props.overview.fork_count} forks`
145
+ : "Repository browser",
146
+ }),
147
+ ],
148
+ }),
149
+ h("div", {
150
+ className: "git-browser-header-actions",
151
+ key: "actions",
152
+ children: [
153
+ h(SocialControls, {
154
+ headers: props.headers,
155
+ key: "social",
156
+ repositoryKey: props.repositoryKey,
157
+ social: socialQuery.data,
158
+ }),
159
+ h("button", {
160
+ className: "git-browser-action-button is-primary",
161
+ disabled: createFork.loading,
162
+ key: "fork",
163
+ onClick: async () => {
164
+ await createFork.mutate();
165
+ },
166
+ type: "button",
167
+ children: createFork.loading ? "Forking..." : "Create Fork",
168
+ }),
169
+ ],
170
+ }),
171
+ ],
172
+ }),
173
+ h(RepositoryNav, {
174
+ current: props.current,
175
+ navigate: props.navigate,
176
+ repositoryKey: props.repositoryKey,
177
+ key: "nav",
178
+ }),
179
+ ],
180
+ });
181
+ }
182
+ function Card(props) {
183
+ return h("section", {
184
+ className: joinClassNames("git-browser-card", props.className),
185
+ children: [
186
+ h("div", {
187
+ className: "git-browser-card-header",
188
+ key: "header",
189
+ children: [
190
+ h("h2", { className: "git-browser-card-title", key: "title", children: props.title }),
191
+ props.subtitle ? h("div", { className: "git-browser-card-subtitle", key: "subtitle", children: props.subtitle }) : null,
192
+ ],
193
+ }),
194
+ h("div", {
195
+ className: "git-browser-card-body",
196
+ key: "body",
197
+ children: props.children,
198
+ }),
199
+ ],
200
+ });
201
+ }
202
+ function DefinitionGrid(props) {
203
+ return h("dl", {
204
+ className: "git-browser-definition-grid",
205
+ children: props.rows.flatMap((row) => ([
206
+ h("dt", { key: `${row.label}:label`, children: row.label }),
207
+ h("dd", { key: `${row.label}:value`, children: row.value }),
208
+ ])),
209
+ });
210
+ }
211
+ function findReadme(entries) {
212
+ const match = entries.find((entry) => entry.type === "blob" && /^readme(\.|$)/i.test(entry.name));
213
+ return match ? match.path : "";
214
+ }
215
+ function GitRepositoryOverviewPageInner(props) {
216
+ const overview = useGitOverview(props.repositoryKey, {
217
+ headers: props.headers,
218
+ initialData: props.initialData || null,
219
+ });
220
+ const tree = useGitTree(props.repositoryKey, {
221
+ headers: props.headers,
222
+ icons: true,
223
+ path: "",
224
+ recursive: true,
225
+ ref: overview.data?.repository.repository.current_branch || "HEAD",
226
+ });
227
+ const readmePath = tree.data ? findReadme(tree.data) : "";
228
+ const readme = useGitBlob(props.repositoryKey, {
229
+ enabled: Boolean(readmePath),
230
+ headers: props.headers,
231
+ path: readmePath,
232
+ ref: overview.data?.repository.repository.current_branch || "HEAD",
233
+ });
234
+ return h("div", {
235
+ className: joinClassNames("git-browser-page", props.className),
236
+ children: [
237
+ h(RepositoryHeader, {
238
+ current: "overview",
239
+ headers: props.headers,
240
+ key: "header",
241
+ navigate: props.navigate,
242
+ overview: overview.data,
243
+ repositoryKey: props.repositoryKey,
244
+ }),
245
+ h(StatusBlock, {
246
+ error: overview.error,
247
+ key: "status",
248
+ loading: overview.loading,
249
+ children: overview.data ? h("div", {
250
+ className: "git-browser-grid",
251
+ children: [
252
+ h(Card, {
253
+ className: "git-browser-span-2",
254
+ key: "summary",
255
+ title: "Repository Summary",
256
+ subtitle: overview.data.repository.repository.path,
257
+ children: h(DefinitionGrid, {
258
+ rows: [
259
+ { label: "Branch", value: overview.data.repository.repository.current_branch },
260
+ { label: "Head", value: overview.data.repository.repository.head_short },
261
+ { label: "Releases", value: String(overview.data.release_count) },
262
+ { label: "Forks", value: String(overview.data.fork_count) },
263
+ { label: "Activity", value: String(overview.data.activity_count) },
264
+ ],
265
+ }),
266
+ }),
267
+ h(Card, {
268
+ key: "latest-release",
269
+ title: "Latest Release",
270
+ children: overview.data.latest_release
271
+ ? [
272
+ h("div", { className: "git-browser-inline-meta", key: "title", children: `${overview.data.latest_release.title} · ${overview.data.latest_release.tag_name}` }),
273
+ h("p", { className: "git-browser-note", key: "notes", children: overview.data.latest_release.notes || "No notes yet." }),
274
+ ]
275
+ : "No releases published yet.",
276
+ }),
277
+ h(Card, {
278
+ className: "git-browser-span-3",
279
+ key: "readme",
280
+ title: "README",
281
+ children: readme.data
282
+ ? h("pre", { className: "git-browser-code-block", children: readme.data.content })
283
+ : "README content not available.",
284
+ }),
285
+ ],
286
+ }) : null,
287
+ }),
288
+ ],
289
+ });
290
+ }
291
+ function GitRepositoryCodePageInner(props) {
292
+ const overview = useGitOverview(props.repositoryKey, {
293
+ headers: props.headers,
294
+ initialData: props.initialData || null,
295
+ });
296
+ const deferredPath = useDeferredValue(text(props.path));
297
+ const tree = useGitTree(props.repositoryKey, {
298
+ headers: props.headers,
299
+ icons: true,
300
+ linguist: true,
301
+ recursive: true,
302
+ ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
303
+ });
304
+ const selectedPath = deferredPath || (tree.data || []).find((entry) => entry.type === "blob")?.path || "";
305
+ const selectedEntry = (tree.data || []).find((entry) => entry.path === selectedPath) || null;
306
+ const blob = useGitBlob(props.repositoryKey, {
307
+ enabled: Boolean(selectedEntry && selectedEntry.type === "blob"),
308
+ headers: props.headers,
309
+ path: selectedPath,
310
+ ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
311
+ });
312
+ return h("div", {
313
+ className: joinClassNames("git-browser-page", props.className),
314
+ children: [
315
+ h(RepositoryHeader, {
316
+ current: "code",
317
+ headers: props.headers,
318
+ key: "header",
319
+ navigate: props.navigate,
320
+ overview: overview.data,
321
+ repositoryKey: props.repositoryKey,
322
+ }),
323
+ h(StatusBlock, {
324
+ error: tree.error || blob.error,
325
+ key: "status",
326
+ loading: overview.loading || tree.loading || blob.loading,
327
+ children: h("div", {
328
+ className: "git-browser-split",
329
+ children: [
330
+ h(Card, {
331
+ key: "tree",
332
+ title: "Repository Tree",
333
+ subtitle: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
334
+ children: h("ul", {
335
+ className: "git-browser-list",
336
+ children: (tree.data || []).map((entry) => (h("li", {
337
+ className: joinClassNames("git-browser-list-item", entry.path === selectedPath && "is-selected"),
338
+ key: entry.path,
339
+ children: `${entry.type === "tree" ? "dir" : "file"} · ${entry.path}${entry.language ? ` · ${entry.language}` : ""}`,
340
+ }))),
341
+ }),
342
+ }),
343
+ h(Card, {
344
+ className: "git-browser-span-2",
345
+ key: "blob",
346
+ title: selectedPath || "File Preview",
347
+ subtitle: selectedEntry?.language || "Plain text",
348
+ children: blob.data
349
+ ? h("pre", { className: "git-browser-code-block", children: blob.data.content })
350
+ : "Select a file path to preview blob content.",
351
+ }),
352
+ ],
353
+ }),
354
+ }),
355
+ ],
356
+ });
357
+ }
358
+ function GitRepositoryCommitsPageInner(props) {
359
+ const overview = useGitOverview(props.repositoryKey, {
360
+ headers: props.headers,
361
+ initialData: props.initialData || null,
362
+ });
363
+ const commits = useGitCommits(props.repositoryKey, {
364
+ headers: props.headers,
365
+ path: props.path,
366
+ ref: props.refName || overview.data?.repository.repository.current_branch || "HEAD",
367
+ });
368
+ return h("div", {
369
+ className: joinClassNames("git-browser-page", props.className),
370
+ children: [
371
+ h(RepositoryHeader, {
372
+ current: "commits",
373
+ headers: props.headers,
374
+ key: "header",
375
+ navigate: props.navigate,
376
+ overview: overview.data,
377
+ repositoryKey: props.repositoryKey,
378
+ }),
379
+ h(StatusBlock, {
380
+ error: commits.error,
381
+ key: "status",
382
+ loading: overview.loading || commits.loading,
383
+ children: h(Card, {
384
+ title: "Commit History",
385
+ subtitle: props.path ? `Filtered to ${props.path}` : "Latest repository activity",
386
+ children: h("ul", {
387
+ className: "git-browser-list",
388
+ children: (commits.data || []).map((commit) => (h("li", {
389
+ className: "git-browser-list-item",
390
+ key: commit.hash,
391
+ children: `${commit.short_hash} · ${commit.subject} · ${commit.author_name} · ${formatDate(commit.authored_at)}`,
392
+ }))),
393
+ }),
394
+ }),
395
+ }),
396
+ ],
397
+ });
398
+ }
399
+ function GitRepositoryCommitPageInner(props) {
400
+ const overview = useGitOverview(props.repositoryKey, {
401
+ headers: props.headers,
402
+ initialData: props.initialData || null,
403
+ });
404
+ const commit = useGitCommit(props.repositoryKey, props.commitRef, {
405
+ headers: props.headers,
406
+ });
407
+ return h("div", {
408
+ className: joinClassNames("git-browser-page", props.className),
409
+ children: [
410
+ h(RepositoryHeader, {
411
+ current: "commits",
412
+ headers: props.headers,
413
+ key: "header",
414
+ navigate: props.navigate,
415
+ overview: overview.data,
416
+ repositoryKey: props.repositoryKey,
417
+ }),
418
+ h(StatusBlock, {
419
+ error: commit.error,
420
+ key: "status",
421
+ loading: overview.loading || commit.loading,
422
+ children: commit.data ? h("div", {
423
+ className: "git-browser-grid",
424
+ children: [
425
+ h(Card, {
426
+ className: "git-browser-span-3",
427
+ key: "meta",
428
+ title: commit.data.commit.subject,
429
+ subtitle: `${commit.data.commit.short_hash} by ${commit.data.commit.author_name}`,
430
+ children: h(DefinitionGrid, {
431
+ rows: [
432
+ { label: "Authored", value: formatDate(commit.data.commit.authored_at) },
433
+ { label: "Files", value: String(commit.data.file_count) },
434
+ { label: "Added", value: String(commit.data.lines_added) },
435
+ { label: "Removed", value: String(commit.data.lines_removed) },
436
+ ],
437
+ }),
438
+ }),
439
+ h(Card, {
440
+ className: "git-browser-span-3",
441
+ key: "diff",
442
+ title: "Diff",
443
+ children: h("pre", { className: "git-browser-code-block", children: commit.data.diff }),
444
+ }),
445
+ ],
446
+ }) : null,
447
+ }),
448
+ ],
449
+ });
450
+ }
451
+ function ReleaseComposer(props) {
452
+ const createRelease = useGitCreateRelease(props.repositoryKey, { headers: props.headers });
453
+ const [title, setTitle] = useState("");
454
+ const [tagName, setTagName] = useState("");
455
+ const [notes, setNotes] = useState("");
456
+ return h("form", {
457
+ className: "git-browser-form",
458
+ onSubmit: async (event) => {
459
+ event.preventDefault();
460
+ const release = await createRelease.mutate({
461
+ createTag: {
462
+ annotatedMessage: notes || title,
463
+ name: tagName,
464
+ targetRef: "HEAD",
465
+ },
466
+ notes,
467
+ title,
468
+ });
469
+ setTitle("");
470
+ setTagName("");
471
+ setNotes("");
472
+ props.onCreated(release);
473
+ },
474
+ children: [
475
+ h("input", {
476
+ className: "git-browser-input",
477
+ key: "title",
478
+ onChange: (event) => setTitle(text(event.target?.value)),
479
+ placeholder: "Release title",
480
+ value: title,
481
+ }),
482
+ h("input", {
483
+ className: "git-browser-input",
484
+ key: "tag",
485
+ onChange: (event) => setTagName(text(event.target?.value)),
486
+ placeholder: "Tag name",
487
+ value: tagName,
488
+ }),
489
+ h("textarea", {
490
+ className: "git-browser-input git-browser-textarea",
491
+ key: "notes",
492
+ onChange: (event) => setNotes(text(event.target?.value)),
493
+ placeholder: "Release notes",
494
+ value: notes,
495
+ }),
496
+ h("button", {
497
+ className: "git-browser-action-button is-primary",
498
+ disabled: createRelease.loading || !title || !tagName,
499
+ key: "submit",
500
+ type: "submit",
501
+ children: createRelease.loading ? "Publishing..." : "Publish Release",
502
+ }),
503
+ ],
504
+ });
505
+ }
506
+ function GitRepositoryReleasesPageInner(props) {
507
+ const overview = useGitOverview(props.repositoryKey, {
508
+ headers: props.headers,
509
+ initialData: props.initialData || null,
510
+ });
511
+ const releases = useGitReleases(props.repositoryKey, {
512
+ headers: props.headers,
513
+ });
514
+ const [createdRelease, setCreatedRelease] = useState(null);
515
+ useEffect(() => {
516
+ if (createdRelease)
517
+ releases.reload();
518
+ }, [createdRelease]);
519
+ return h("div", {
520
+ className: joinClassNames("git-browser-page", props.className),
521
+ children: [
522
+ h(RepositoryHeader, {
523
+ current: "releases",
524
+ headers: props.headers,
525
+ key: "header",
526
+ navigate: props.navigate,
527
+ overview: overview.data,
528
+ repositoryKey: props.repositoryKey,
529
+ }),
530
+ h(StatusBlock, {
531
+ error: releases.error,
532
+ key: "status",
533
+ loading: overview.loading || releases.loading,
534
+ children: h("div", {
535
+ className: "git-browser-grid",
536
+ children: [
537
+ h(Card, {
538
+ key: "composer",
539
+ title: "Publish a Release",
540
+ subtitle: "This creates an annotated tag when needed.",
541
+ children: h(ReleaseComposer, {
542
+ headers: props.headers,
543
+ onCreated: setCreatedRelease,
544
+ repositoryKey: props.repositoryKey,
545
+ }),
546
+ }),
547
+ h(Card, {
548
+ className: "git-browser-span-2",
549
+ key: "list",
550
+ title: "Releases",
551
+ children: h("ul", {
552
+ className: "git-browser-list",
553
+ children: (releases.data || []).map((release) => (h("li", {
554
+ className: "git-browser-list-item",
555
+ key: release.id,
556
+ children: [
557
+ h("strong", { key: "title", children: `${release.title} · ${release.tag_name}` }),
558
+ h("div", { className: "git-browser-note", key: "meta", children: `${release.prerelease ? "Prerelease" : "Stable"} · ${formatDate(release.published_at || release.created_at)}` }),
559
+ h("p", { className: "git-browser-note", key: "notes", children: release.notes || "No release notes." }),
560
+ ],
561
+ }))),
562
+ }),
563
+ }),
564
+ ],
565
+ }),
566
+ }),
567
+ ],
568
+ });
569
+ }
570
+ function GitRepositoryReleasePageInner(props) {
571
+ const overview = useGitOverview(props.repositoryKey, {
572
+ headers: props.headers,
573
+ initialData: props.initialData || null,
574
+ });
575
+ const release = useGitRelease(props.repositoryKey, props.releaseId, {
576
+ headers: props.headers,
577
+ });
578
+ return h("div", {
579
+ className: joinClassNames("git-browser-page", props.className),
580
+ children: [
581
+ h(RepositoryHeader, {
582
+ current: "releases",
583
+ headers: props.headers,
584
+ key: "header",
585
+ navigate: props.navigate,
586
+ overview: overview.data,
587
+ repositoryKey: props.repositoryKey,
588
+ }),
589
+ h(StatusBlock, {
590
+ error: release.error,
591
+ key: "status",
592
+ loading: overview.loading || release.loading,
593
+ children: release.data ? h("div", {
594
+ className: "git-browser-grid",
595
+ children: [
596
+ h(Card, {
597
+ className: "git-browser-span-2",
598
+ key: "details",
599
+ title: release.data.title,
600
+ subtitle: `${release.data.tag_name} · ${release.data.prerelease ? "Prerelease" : "Release"}`,
601
+ children: [
602
+ h("p", { className: "git-browser-note", key: "notes", children: release.data.notes || "No release notes." }),
603
+ h(DefinitionGrid, {
604
+ key: "meta",
605
+ rows: [
606
+ { label: "Published", value: formatDate(release.data.published_at || release.data.created_at) },
607
+ { label: "Target", value: release.data.target_ref },
608
+ { label: "Assets", value: String(release.data.assets.length) },
609
+ ],
610
+ }),
611
+ ],
612
+ }),
613
+ h(Card, {
614
+ key: "assets",
615
+ title: "Assets",
616
+ children: release.data.assets.length
617
+ ? h("ul", {
618
+ className: "git-browser-list",
619
+ children: release.data.assets.map((asset) => (h("li", {
620
+ className: "git-browser-list-item",
621
+ key: asset.id,
622
+ children: `${asset.name}${asset.size ? ` · ${asset.size} bytes` : ""}`,
623
+ }))),
624
+ })
625
+ : "No assets attached.",
626
+ }),
627
+ ],
628
+ }) : null,
629
+ }),
630
+ ],
631
+ });
632
+ }
633
+ function ForkRow(props) {
634
+ const syncFork = useGitSyncFork(props.repositoryKey, props.fork.fork_repository_id, { headers: props.headers });
635
+ const [currentFork, setCurrentFork] = useState(props.fork);
636
+ useEffect(() => {
637
+ setCurrentFork(props.fork);
638
+ }, [props.fork]);
639
+ return h("li", {
640
+ className: "git-browser-list-item",
641
+ children: [
642
+ h("strong", { key: "name", children: currentFork.fork_repository_id }),
643
+ h("div", {
644
+ className: "git-browser-note",
645
+ key: "status",
646
+ children: `Ahead ${currentFork.fork_status.ahead} · Behind ${currentFork.fork_status.behind} · ${currentFork.fork_status.fork_branch} vs ${currentFork.fork_status.upstream_branch}`,
647
+ }),
648
+ h("button", {
649
+ className: "git-browser-action-button",
650
+ disabled: syncFork.loading,
651
+ key: "sync",
652
+ onClick: async () => {
653
+ setCurrentFork(await syncFork.mutate({ strategy: "ff-only" }));
654
+ },
655
+ type: "button",
656
+ children: syncFork.loading ? "Syncing..." : "Sync Fork",
657
+ }),
658
+ ],
659
+ });
660
+ }
661
+ function GitRepositoryForksPageInner(props) {
662
+ const overview = useGitOverview(props.repositoryKey, {
663
+ headers: props.headers,
664
+ initialData: props.initialData || null,
665
+ });
666
+ const forks = useGitForks(props.repositoryKey, {
667
+ headers: props.headers,
668
+ });
669
+ return h("div", {
670
+ className: joinClassNames("git-browser-page", props.className),
671
+ children: [
672
+ h(RepositoryHeader, {
673
+ current: "forks",
674
+ headers: props.headers,
675
+ key: "header",
676
+ navigate: props.navigate,
677
+ overview: overview.data,
678
+ repositoryKey: props.repositoryKey,
679
+ }),
680
+ h(StatusBlock, {
681
+ error: forks.error,
682
+ key: "status",
683
+ loading: overview.loading || forks.loading,
684
+ children: h(Card, {
685
+ title: "Fork Network",
686
+ subtitle: "Create forks, then sync them against upstream from this page.",
687
+ children: h("ul", {
688
+ className: "git-browser-list",
689
+ children: (forks.data || []).map((fork) => h(ForkRow, {
690
+ fork,
691
+ headers: props.headers,
692
+ key: fork.fork_repository_id,
693
+ repositoryKey: props.repositoryKey,
694
+ })),
695
+ }),
696
+ }),
697
+ }),
698
+ ],
699
+ });
700
+ }
701
+ function GitRepositoryActivityPageInner(props) {
702
+ const overview = useGitOverview(props.repositoryKey, {
703
+ headers: props.headers,
704
+ initialData: props.initialData || null,
705
+ });
706
+ const activity = useGitActivity(props.repositoryKey, {
707
+ headers: props.headers,
708
+ });
709
+ return h("div", {
710
+ className: joinClassNames("git-browser-page", props.className),
711
+ children: [
712
+ h(RepositoryHeader, {
713
+ current: "activity",
714
+ headers: props.headers,
715
+ key: "header",
716
+ navigate: props.navigate,
717
+ overview: overview.data,
718
+ repositoryKey: props.repositoryKey,
719
+ }),
720
+ h(StatusBlock, {
721
+ error: activity.error,
722
+ key: "status",
723
+ loading: overview.loading || activity.loading,
724
+ children: h(Card, {
725
+ title: "Activity Timeline",
726
+ children: h("ul", {
727
+ className: "git-browser-list",
728
+ children: (activity.data || []).map((entry) => (h("li", {
729
+ className: "git-browser-list-item",
730
+ key: entry.id,
731
+ children: [
732
+ h("strong", { key: "summary", children: entry.summary }),
733
+ h("div", { className: "git-browser-note", key: "meta", children: `${entry.kind} · actor ${entry.actor_id} · ${formatDate(entry.created_at)}` }),
734
+ ],
735
+ }))),
736
+ }),
737
+ }),
738
+ }),
739
+ ],
740
+ });
741
+ }
742
+ function GitRepositoryOverviewPage(props) {
743
+ return withBrowserProvider(props, () => h(GitRepositoryOverviewPageInner, props));
744
+ }
745
+ function GitRepositoryCodePage(props) {
746
+ return withBrowserProvider(props, () => h(GitRepositoryCodePageInner, props));
747
+ }
748
+ function GitRepositoryCommitsPage(props) {
749
+ return withBrowserProvider(props, () => h(GitRepositoryCommitsPageInner, props));
750
+ }
751
+ function GitRepositoryCommitPage(props) {
752
+ return withBrowserProvider(props, () => h(GitRepositoryCommitPageInner, props));
753
+ }
754
+ function GitRepositoryReleasesPage(props) {
755
+ return withBrowserProvider(props, () => h(GitRepositoryReleasesPageInner, props));
756
+ }
757
+ function GitRepositoryReleasePage(props) {
758
+ return withBrowserProvider(props, () => h(GitRepositoryReleasePageInner, props));
759
+ }
760
+ function GitRepositoryForksPage(props) {
761
+ return withBrowserProvider(props, () => h(GitRepositoryForksPageInner, props));
762
+ }
763
+ function GitRepositoryActivityPage(props) {
764
+ return withBrowserProvider(props, () => h(GitRepositoryActivityPageInner, props));
765
+ }
766
+ export { GitBrowserProvider, GitRepositoryActivityPage, GitRepositoryCodePage, GitRepositoryCommitPage, GitRepositoryCommitsPage, GitRepositoryForksPage, GitRepositoryOverviewPage, GitRepositoryReleasePage, GitRepositoryReleasesPage, };
767
+ //# sourceMappingURL=index.js.map