@alwith/module-drive 0.0.0-stage → 0.1.0-rc.23

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 (107) hide show
  1. package/LICENSE +94 -0
  2. package/README.md +50 -2
  3. package/THIRD_PARTY_NOTICES.md +7 -0
  4. package/desktop-provenance.json +34 -0
  5. package/dist/badge-react.d.ts +9 -0
  6. package/dist/badge-react.js +1 -0
  7. package/dist/badge.d.ts +10 -0
  8. package/dist/badge.js +1 -0
  9. package/dist/browse.d.ts +33 -0
  10. package/dist/browse.js +1 -0
  11. package/dist/content/chat-condense.d.ts +22 -0
  12. package/dist/content/chat-condense.js +1 -0
  13. package/dist/content/collab.d.ts +34 -0
  14. package/dist/content/collab.js +1 -0
  15. package/dist/content/comment-anchors.d.ts +23 -0
  16. package/dist/content/comment-anchors.js +2 -0
  17. package/dist/content/comment-decorations.d.ts +23 -0
  18. package/dist/content/comment-decorations.js +3 -0
  19. package/dist/content/comment-drawer.d.ts +44 -0
  20. package/dist/content/comment-drawer.js +1 -0
  21. package/dist/content/comment-mentions.d.ts +18 -0
  22. package/dist/content/comment-mentions.js +1 -0
  23. package/dist/content/comment-surface.d.ts +25 -0
  24. package/dist/content/comment-surface.js +1 -0
  25. package/dist/content/condense-task.d.ts +44 -0
  26. package/dist/content/condense-task.js +1 -0
  27. package/dist/content/condense.d.ts +20 -0
  28. package/dist/content/condense.js +1 -0
  29. package/dist/content/editor.d.ts +5 -0
  30. package/dist/content/editor.js +1 -0
  31. package/dist/content/file-actions.d.ts +43 -0
  32. package/dist/content/file-actions.js +1 -0
  33. package/dist/content/file-link.d.ts +4 -0
  34. package/dist/content/file-link.js +1 -0
  35. package/dist/content/frontmatter-panel.d.ts +7 -0
  36. package/dist/content/frontmatter-panel.js +1 -0
  37. package/dist/content/frontmatter.d.ts +9 -0
  38. package/dist/content/frontmatter.js +7 -0
  39. package/dist/content/host.d.ts +49 -0
  40. package/dist/content/host.js +1 -0
  41. package/dist/content/html-bridge.d.ts +1 -0
  42. package/dist/content/html-bridge.js +187 -0
  43. package/dist/content/html-comments.d.ts +5 -0
  44. package/dist/content/html-comments.js +1 -0
  45. package/dist/content/markdown-comments.d.ts +4 -0
  46. package/dist/content/markdown-comments.js +2 -0
  47. package/dist/content/mention-picker.d.ts +10 -0
  48. package/dist/content/mention-picker.js +1 -0
  49. package/dist/content/save-version.d.ts +2 -0
  50. package/dist/content/save-version.js +1 -0
  51. package/dist/content/translations.d.ts +2 -0
  52. package/dist/content/translations.js +1 -0
  53. package/dist/content/use-file-comments.d.ts +12 -0
  54. package/dist/content/use-file-comments.js +1 -0
  55. package/dist/content/yuplink.d.ts +11 -0
  56. package/dist/content/yuplink.js +2 -0
  57. package/dist/content.css +64 -0
  58. package/dist/content.d.ts +10 -0
  59. package/dist/content.js +1 -0
  60. package/dist/contract.d.ts +780 -0
  61. package/dist/contract.js +0 -0
  62. package/dist/core.d.ts +22 -0
  63. package/dist/core.js +1 -0
  64. package/dist/files.d.ts +7 -0
  65. package/dist/files.js +1 -0
  66. package/dist/global-search.d.ts +34 -0
  67. package/dist/global-search.js +1 -0
  68. package/dist/icons.d.ts +5 -0
  69. package/dist/icons.js +1 -0
  70. package/dist/launcher.d.ts +15 -0
  71. package/dist/launcher.js +2 -0
  72. package/dist/locales.d.ts +985 -0
  73. package/dist/locales.js +1 -0
  74. package/dist/mass-delete.d.ts +9 -0
  75. package/dist/mass-delete.js +1 -0
  76. package/dist/notifications.d.ts +14 -0
  77. package/dist/notifications.js +1 -0
  78. package/dist/pinned-docs.d.ts +14 -0
  79. package/dist/pinned-docs.js +1 -0
  80. package/dist/pinned.d.ts +12 -0
  81. package/dist/pinned.js +1 -0
  82. package/dist/react.d.ts +29 -0
  83. package/dist/react.js +1 -0
  84. package/dist/roots.d.ts +10 -0
  85. package/dist/roots.js +1 -0
  86. package/dist/settings.d.ts +14 -0
  87. package/dist/settings.js +1 -0
  88. package/dist/sharing.d.ts +12 -0
  89. package/dist/sharing.js +1 -0
  90. package/dist/status.d.ts +16 -0
  91. package/dist/status.js +1 -0
  92. package/dist/styles.css +458 -0
  93. package/dist/summary.d.ts +10 -0
  94. package/dist/summary.js +1 -0
  95. package/dist/tauri.d.ts +6 -0
  96. package/dist/tauri.js +1 -0
  97. package/dist/transfer-feed.d.ts +36 -0
  98. package/dist/transfer-feed.js +1 -0
  99. package/dist/ui.d.ts +96 -0
  100. package/dist/ui.js +1 -0
  101. package/package.json +117 -4
  102. package/rust/Cargo.toml +14 -0
  103. package/rust/src/contract.rs +366 -0
  104. package/rust/src/lib.rs +5 -0
  105. package/rust/src/ownership.rs +4 -0
  106. package/rust/src/service.rs +140 -0
  107. package/rust/src/sync.rs +1602 -0
@@ -0,0 +1,458 @@
1
+ @import "./content.css";
2
+ .alwith-drive {
3
+ color: var(--foreground);
4
+ display: flex;
5
+ flex-direction: column;
6
+ gap: 0.75rem;
7
+ width: 100%;
8
+ min-width: 0;
9
+ font-size: 0.875rem;
10
+ }
11
+ .alwith-drive h2,
12
+ .alwith-drive h3,
13
+ .alwith-drive h4 {
14
+ font-weight: 500;
15
+ margin: 0;
16
+ }
17
+ .alwith-drive h2 {
18
+ font-size: 1rem;
19
+ }
20
+ .alwith-drive h3,
21
+ .alwith-drive h4 {
22
+ font-size: 0.875rem;
23
+ }
24
+ .alwith-drive p {
25
+ color: var(--muted-foreground);
26
+ font-size: 0.75rem;
27
+ line-height: 1.6;
28
+ overflow-wrap: anywhere;
29
+ margin: 0;
30
+ }
31
+ .alwith-drive small {
32
+ color: var(--muted-foreground);
33
+ font-size: 0.6875rem;
34
+ }
35
+ .alwith-drive header,
36
+ .alwith-drive-row,
37
+ .alwith-drive-actions {
38
+ display: flex;
39
+ align-items: center;
40
+ gap: 0.5rem;
41
+ }
42
+ .alwith-drive header {
43
+ justify-content: space-between;
44
+ }
45
+ .alwith-drive-actions {
46
+ flex-wrap: wrap;
47
+ }
48
+ .alwith-drive-row {
49
+ padding: 0.5rem 0;
50
+ border-bottom: 1px solid var(--border);
51
+ min-width: 0;
52
+ }
53
+ .alwith-drive-row > span:first-child {
54
+ flex: 1;
55
+ min-width: 0;
56
+ overflow-wrap: anywhere;
57
+ }
58
+ .alwith-drive-row small {
59
+ display: block;
60
+ }
61
+ .alwith-drive .alwith-drive-error {
62
+ color: var(--destructive);
63
+ }
64
+ .alwith-drive-form,
65
+ .alwith-drive form {
66
+ display: flex;
67
+ flex-direction: column;
68
+ gap: 0.75rem;
69
+ }
70
+ .alwith-drive label {
71
+ display: flex;
72
+ flex-direction: column;
73
+ gap: 0.375rem;
74
+ font-size: 0.75rem;
75
+ }
76
+ .alwith-drive-form label {
77
+ display: flex;
78
+ flex-direction: column;
79
+ gap: 0.375rem;
80
+ font-size: 0.75rem;
81
+ }
82
+ .alwith-drive input[type="checkbox"] {
83
+ width: 1rem;
84
+ min-width: 1rem;
85
+ height: 1rem;
86
+ accent-color: var(--primary);
87
+ }
88
+ .alwith-drive details > summary {
89
+ cursor: pointer;
90
+ font-size: 0.75rem;
91
+ color: var(--muted-foreground);
92
+ padding: 0.375rem 0;
93
+ }
94
+ .alwith-drive-launcher {
95
+ padding: 0.25rem;
96
+ gap: 0.25rem;
97
+ height: 100%;
98
+ overflow: hidden;
99
+ }
100
+ .alwith-drive-toolbar {
101
+ height: 2rem;
102
+ padding: 0 0.25rem;
103
+ flex-shrink: 0;
104
+ }
105
+ .alwith-drive-toolbar > strong {
106
+ font-size: 0.8125rem;
107
+ font-weight: 500;
108
+ }
109
+ .alwith-drive-search {
110
+ padding: 0 0.25rem 0.25rem;
111
+ }
112
+ .alwith-drive-search input,
113
+ .alwith-drive-group > input {
114
+ height: 1.75rem;
115
+ font-size: 0.75rem;
116
+ }
117
+ .alwith-drive-search-results {
118
+ max-height: 20rem;
119
+ overflow: auto;
120
+ }
121
+ .alwith-drive-search-result {
122
+ width: 100%;
123
+ height: auto !important;
124
+ justify-content: flex-start !important;
125
+ text-align: start;
126
+ padding: 0.375rem !important;
127
+ }
128
+ .alwith-drive-search-result span {
129
+ overflow: hidden;
130
+ text-overflow: ellipsis;
131
+ }
132
+ .alwith-drive-search-result small {
133
+ display: block;
134
+ font-size: 0.625rem;
135
+ }
136
+ .alwith-drive-navigation {
137
+ min-height: 0;
138
+ overflow: auto;
139
+ flex: 1;
140
+ }
141
+ .alwith-drive-group {
142
+ padding: 0.125rem 0;
143
+ }
144
+ .alwith-drive-group > summary {
145
+ list-style: none;
146
+ display: flex;
147
+ align-items: center;
148
+ gap: 0.375rem;
149
+ padding: 0.375rem 0.5rem !important;
150
+ font-size: 0.6875rem !important;
151
+ font-weight: 500;
152
+ }
153
+ .alwith-drive-group > summary::before {
154
+ content: "›";
155
+ width: 0.5rem;
156
+ }
157
+ .alwith-drive-group[open] > summary::before {
158
+ transform: rotate(90deg);
159
+ }
160
+ .alwith-drive-group > summary > span {
161
+ margin-left: auto;
162
+ font-weight: 400;
163
+ }
164
+ .alwith-drive-group > .alwith-drive-group {
165
+ padding-left: 0.5rem;
166
+ }
167
+ .alwith-drive-nav-row {
168
+ min-width: 0;
169
+ height: var(--navigation-row-height, 1.875rem);
170
+ display: flex;
171
+ align-items: center;
172
+ gap: 0.25rem;
173
+ position: relative;
174
+ border-radius: 0.25rem;
175
+ }
176
+ .alwith-drive-nav-row:hover,
177
+ .alwith-drive-nav-row[data-active="true"] {
178
+ background: var(--accent);
179
+ color: var(--accent-foreground);
180
+ }
181
+ .alwith-drive-nav-open {
182
+ flex: 1 1 0%;
183
+ display: flex !important;
184
+ align-items: center;
185
+ gap: 0.375rem;
186
+ height: var(--navigation-row-height, 1.875rem) !important;
187
+ padding: 0 0.375rem !important;
188
+ width: 100%;
189
+ min-width: 0;
190
+ justify-content: flex-start !important;
191
+ font-size: 0.8125rem !important;
192
+ font-weight: 400 !important;
193
+ }
194
+ .alwith-drive-nav-open > span:nth-child(2),
195
+ .alwith-drive-nav-open > span:only-child {
196
+ overflow: hidden;
197
+ text-overflow: ellipsis;
198
+ white-space: nowrap;
199
+ flex: 1;
200
+ min-width: 0;
201
+ text-align: start;
202
+ }
203
+ .alwith-drive-nav-open > small {
204
+ margin-left: auto;
205
+ white-space: nowrap;
206
+ font-size: 0.625rem;
207
+ }
208
+ .alwith-drive-menu {
209
+ position: relative;
210
+ flex-shrink: 0;
211
+ }
212
+ .alwith-drive-menu > summary {
213
+ list-style: none;
214
+ padding: 0.25rem !important;
215
+ font-size: 0.625rem !important;
216
+ }
217
+ .alwith-drive-menu > div {
218
+ position: absolute;
219
+ right: 0;
220
+ top: 100%;
221
+ z-index: 40;
222
+ min-width: 12rem;
223
+ padding: 0.25rem;
224
+ border: 1px solid var(--border);
225
+ border-radius: 0.375rem;
226
+ background: var(--popover);
227
+ color: var(--popover-foreground);
228
+ box-shadow: 0 0.25rem 1rem color-mix(in srgb, var(--foreground) 12%, transparent);
229
+ display: flex;
230
+ flex-direction: column;
231
+ }
232
+ .alwith-drive-menu > div > button {
233
+ justify-content: flex-start !important;
234
+ font-size: 0.75rem;
235
+ }
236
+ .alwith-drive-nav-row > .alwith-drive-menu {
237
+ opacity: 0;
238
+ }
239
+ .alwith-drive-nav-row:hover > .alwith-drive-menu,
240
+ .alwith-drive-nav-row:focus-within > .alwith-drive-menu {
241
+ opacity: 1;
242
+ }
243
+ .alwith-drive-notice {
244
+ border-radius: 0.375rem;
245
+ background: var(--muted);
246
+ padding: 0.5rem;
247
+ }
248
+ .alwith-drive-settings {
249
+ padding: 0.25rem 0;
250
+ gap: 1rem;
251
+ }
252
+ .alwith-drive-setting {
253
+ display: flex !important;
254
+ flex-direction: row !important;
255
+ align-items: center;
256
+ justify-content: space-between;
257
+ gap: 1rem;
258
+ padding: 0.75rem 0;
259
+ border-bottom: 1px solid var(--border);
260
+ }
261
+ .alwith-drive-setting > div:first-child {
262
+ flex: 1;
263
+ min-width: 0;
264
+ }
265
+ .alwith-drive-setting > div:first-child > p {
266
+ margin-top: 0.25rem;
267
+ }
268
+ .alwith-drive-setting input[type="number"] {
269
+ width: 5rem;
270
+ }
271
+ .alwith-drive-setting .alwith-drive-form {
272
+ max-width: 18rem;
273
+ }
274
+ .alwith-drive-status {
275
+ --alwith-drive-upload: #0ea5e9;
276
+ --alwith-drive-download: #10b981;
277
+ padding: 0.75rem;
278
+ gap: 0;
279
+ font-size: 0.75rem;
280
+ line-height: 1rem;
281
+ max-height: 70vh;
282
+ overflow: auto;
283
+ }
284
+ .alwith-drive-status-header h2 {
285
+ font-size: 0.875rem;
286
+ font-weight: 500;
287
+ line-height: 1.25rem;
288
+ }
289
+ .alwith-drive-status-tools {
290
+ display: flex;
291
+ align-items: center;
292
+ gap: 0.25rem;
293
+ }
294
+ .alwith-drive-status .alwith-drive-status-icon {
295
+ width: 1.75rem;
296
+ height: 1.75rem;
297
+ padding: 0;
298
+ flex-shrink: 0;
299
+ }
300
+ .alwith-drive-status .alwith-drive-status-icon svg {
301
+ width: 0.875rem;
302
+ height: 0.875rem;
303
+ }
304
+ .alwith-drive-status-grid {
305
+ display: grid;
306
+ grid-template-columns: auto minmax(0, 1fr);
307
+ gap: 0.25rem 0.75rem;
308
+ margin: 0.5rem 0 0;
309
+ font-size: 0.75rem;
310
+ line-height: 1rem;
311
+ }
312
+ .alwith-drive-status-grid dt,
313
+ .alwith-drive-status-trailing,
314
+ .alwith-drive-status-section h3 {
315
+ color: var(--muted-foreground);
316
+ }
317
+ .alwith-drive-status-grid dd {
318
+ margin: 0;
319
+ text-align: start;
320
+ font-variant-numeric: tabular-nums;
321
+ overflow-wrap: anywhere;
322
+ }
323
+ .alwith-drive-status-section {
324
+ margin-top: 0.75rem;
325
+ }
326
+ .alwith-drive-status-section h3 {
327
+ font-size: 0.75rem;
328
+ font-weight: 500;
329
+ margin-bottom: 0.25rem;
330
+ }
331
+ .alwith-drive-status-list {
332
+ list-style: none;
333
+ padding: 0;
334
+ margin: 0;
335
+ max-height: 10rem;
336
+ overflow: auto;
337
+ }
338
+ .alwith-drive-status-list > li + li {
339
+ margin-top: 0.25rem;
340
+ }
341
+ .alwith-drive-status-active {
342
+ max-height: 8rem;
343
+ }
344
+ .alwith-drive-status-file {
345
+ display: flex;
346
+ align-items: center;
347
+ gap: 0.375rem;
348
+ min-width: 0;
349
+ }
350
+ .alwith-drive-status-file > svg {
351
+ width: 0.75rem;
352
+ height: 0.75rem;
353
+ flex-shrink: 0;
354
+ }
355
+ .alwith-drive-upload {
356
+ color: var(--alwith-drive-upload);
357
+ }
358
+ .alwith-drive-download {
359
+ color: var(--alwith-drive-download);
360
+ }
361
+ .alwith-drive-status .alwith-drive-status-filename {
362
+ display: block;
363
+ flex: 1;
364
+ min-width: 0;
365
+ height: auto;
366
+ padding: 0;
367
+ overflow: hidden;
368
+ text-overflow: ellipsis;
369
+ white-space: nowrap;
370
+ text-align: start;
371
+ font: inherit;
372
+ border: 0;
373
+ border-radius: 0;
374
+ }
375
+ .alwith-drive-status .alwith-drive-status-link {
376
+ height: auto;
377
+ padding: 0;
378
+ font: inherit;
379
+ border: 0;
380
+ border-radius: 0;
381
+ }
382
+ .alwith-drive-status button.alwith-drive-status-filename:hover,
383
+ .alwith-drive-status .alwith-drive-status-link:hover {
384
+ background: transparent;
385
+ text-decoration: underline;
386
+ }
387
+ .alwith-drive-status-trailing {
388
+ flex-shrink: 0;
389
+ font-variant-numeric: tabular-nums;
390
+ }
391
+ .alwith-drive-status .alwith-drive-status-quiet {
392
+ margin-top: 0.75rem;
393
+ text-align: center;
394
+ }
395
+ .alwith-drive-failure {
396
+ padding: 0.5rem 0;
397
+ }
398
+ .alwith-drive-sharing {
399
+ padding: 0.5rem;
400
+ }
401
+ @media (max-width: 480px) {
402
+ .alwith-drive-setting {
403
+ flex-wrap: wrap;
404
+ }
405
+ .alwith-drive-setting > div:first-child {
406
+ flex-basis: 100%;
407
+ }
408
+ }
409
+
410
+ .alwith-drive-condense-trigger {
411
+ opacity: 0;
412
+ }
413
+ .alwith-drive-nav-row:hover .alwith-drive-condense-trigger,
414
+ .alwith-drive-condense-trigger:focus-visible {
415
+ opacity: 1;
416
+ }
417
+
418
+ .alwith-drive-icon {
419
+ width: 1rem;
420
+ height: 1rem;
421
+ flex-shrink: 0;
422
+ display: inline-block;
423
+ vertical-align: middle;
424
+ }
425
+ .alwith-drive-spin {
426
+ animation: alwith-drive-spin 1s linear infinite;
427
+ }
428
+ @keyframes alwith-drive-spin {
429
+ to {
430
+ transform: rotate(360deg);
431
+ }
432
+ }
433
+ .alwith-drive-nav-open > svg + span {
434
+ overflow: hidden;
435
+ text-overflow: ellipsis;
436
+ white-space: nowrap;
437
+ flex: 1;
438
+ min-width: 0;
439
+ text-align: start;
440
+ }
441
+ .alwith-drive-nav-open[data-missing="true"] {
442
+ color: var(--muted-foreground);
443
+ text-decoration: line-through;
444
+ }
445
+ .alwith-drive-badge {
446
+ display: inline-flex;
447
+ align-items: center;
448
+ flex-shrink: 0;
449
+ }
450
+ .alwith-drive-badge.text-primary {
451
+ color: var(--primary);
452
+ }
453
+ .alwith-drive-badge.text-destructive {
454
+ color: var(--destructive);
455
+ }
456
+ .alwith-drive-badge.text-muted-foreground {
457
+ color: var(--muted-foreground);
458
+ }
@@ -0,0 +1,10 @@
1
+ import type { EngineState, FailedUpload, StatusSnapshot } from "./core.js";
2
+ export declare function engineStateKey(state: EngineState): `drive.engine.${EngineState["kind"]}`;
3
+ type SummaryKey = "drive.summary.error" | "drive.summary.conflicts" | "drive.summary.notUploaded" | "drive.summary.notDownloaded" | "drive.summary.transferFailed" | "drive.summary.failed" | "drive.summary.syncing" | "drive.summary.paused" | "drive.summary.scanning" | "drive.summary.upToDate";
4
+ export declare function failureKey(failures: readonly FailedUpload[]): "notUploaded" | "notDownloaded" | "transferFailed";
5
+ export declare function summarize(status: StatusSnapshot | null, failures?: readonly FailedUpload[]): {
6
+ key: SummaryKey;
7
+ count: number;
8
+ tone: "trouble" | "busy" | "calm";
9
+ };
10
+ export {};
@@ -0,0 +1 @@
1
+ function c(n){return`drive.engine.${n.kind}`}function u(n){let o=n.some((r)=>r.direction==="upload"),e=n.some((r)=>r.direction==="download");if(o&&!e)return"notUploaded";if(e&&!o)return"notDownloaded";return"transferFailed"}function a(n,o=[]){let e=n?.state??{kind:"idle"};if(e.kind==="error")return{key:"drive.summary.error",count:0,tone:"trouble"};let r=n?.conflicts.length??0;if(r>0)return{key:"drive.summary.conflicts",count:r,tone:"trouble"};let t=n?.failed??0;if(t>0)return{key:`drive.summary.${u(o)}`,count:t,tone:"trouble"};let i=n?.errors.length??0;if(i>0)return{key:"drive.summary.failed",count:i,tone:"trouble"};let d=(n?.downloading??0)+(n?.uploading??0)+(n?.pending??0);if(d>0)return{key:"drive.summary.syncing",count:d,tone:"busy"};if(e.kind==="paused")return{key:"drive.summary.paused",count:0,tone:"calm"};if(e.kind==="scanning")return{key:"drive.summary.scanning",count:0,tone:"busy"};return{key:"drive.summary.upToDate",count:0,tone:"calm"}}export{c as engineStateKey,u as failureKey,a as summarize};
@@ -0,0 +1,6 @@
1
+ import type { DriveEvent, DriveRequest, DriveResponse, DriveTransport } from "./core.js";
2
+ export interface NativeDriveHost {
3
+ invoke: (request: DriveRequest) => Promise<DriveResponse>;
4
+ listen: (listener: (event: DriveEvent) => void) => Promise<() => void>;
5
+ }
6
+ export declare function createTauriDriveTransport(host: NativeDriveHost): DriveTransport;
package/dist/tauri.js ADDED
@@ -0,0 +1 @@
1
+ function i(r){return{request:(e)=>r.invoke(e),subscribe:(e)=>r.listen(e)}}export{i as createTauriDriveTransport};
@@ -0,0 +1,36 @@
1
+ import type { FileState, RemoteId } from "./core.js";
2
+ export declare const RECENT_LIMIT = 20;
3
+ export type TransferDirection = "up" | "down";
4
+ export interface ActiveTransfer {
5
+ key: string;
6
+ projectId: RemoteId;
7
+ path: string;
8
+ localPath: string;
9
+ name: string;
10
+ direction: TransferDirection;
11
+ size: number;
12
+ startedAt: number;
13
+ }
14
+ export interface RecentTransfer {
15
+ key: string;
16
+ path: string;
17
+ localPath: string;
18
+ name: string;
19
+ direction: TransferDirection;
20
+ size: number;
21
+ completedAt: number;
22
+ }
23
+ export interface TransferFeed {
24
+ active: ActiveTransfer[];
25
+ recent: RecentTransfer[];
26
+ }
27
+ export declare const EMPTY_FEED: TransferFeed;
28
+ export declare function transferKey(projectId: RemoteId, path: string): string;
29
+ export interface FileStateSignal {
30
+ projectId: RemoteId;
31
+ path: string;
32
+ localPath: string;
33
+ state: FileState;
34
+ size?: number;
35
+ }
36
+ export declare function applyFileState(feed: TransferFeed, signal: FileStateSignal, now: number): TransferFeed;
@@ -0,0 +1 @@
1
+ var v=20,z={active:[],recent:[]};function l(t,e){return`${String(t)}\x00${e}`}function s(t){if(t==="uploading")return"up";if(t==="downloading")return"down";return null}function f(t){return t==="synced"||t==="readOnly"||t==="collab"}function h(t){let e=t.split("/").pop();return e!==void 0&&e.length>0?e:t}function E(t,e,a){let r=l(e.projectId,e.path),i=s(e.state);if(i!==null){let n=t.active.find((o)=>o.key===r),p={key:r,projectId:e.projectId,path:e.path,localPath:e.localPath,name:h(e.path),direction:i,size:e.size??n?.size??0,startedAt:n?.direction===i?n.startedAt:a};return{active:[...t.active.filter((o)=>o.key!==r),p],recent:t.recent}}let c=t.active.find((n)=>n.key===r);if(c===void 0)return t;let u=t.active.filter((n)=>n.key!==r);if(!f(e.state))return{active:u,recent:t.recent};let d=[{key:r,path:c.path,localPath:e.localPath||c.localPath,name:c.name,direction:c.direction,size:e.size!==void 0&&e.size>0?e.size:c.size,completedAt:a},...t.recent.filter((n)=>n.key!==r)].slice(0,20);return{active:u,recent:d}}export{z as EMPTY_FEED,v as RECENT_LIMIT,E as applyFileState,l as transferKey};
package/dist/ui.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import { type ButtonHTMLAttributes, type ComponentType, type InputHTMLAttributes, type ReactNode } from "react";
2
+ import type { DriveController, DriveState, RootInfo } from "./core.js";
3
+ import type { ReadDirLike } from "./global-search.js";
4
+ import type { PinnedDoc } from "./pinned-docs.js";
5
+ export interface DriveMenuProps {
6
+ label: string;
7
+ children?: ReactNode;
8
+ items: Array<{
9
+ label: string;
10
+ onSelect: () => void;
11
+ disabled?: boolean;
12
+ }>;
13
+ }
14
+ export interface DriveControls {
15
+ Switch?: ComponentType<{
16
+ checked: boolean;
17
+ onCheckedChange: (checked: boolean) => void;
18
+ disabled?: boolean;
19
+ "aria-label"?: string;
20
+ }>;
21
+ Menu?: ComponentType<DriveMenuProps>;
22
+ ContextMenu?: ComponentType<DriveMenuProps>;
23
+ Button: ComponentType<ButtonHTMLAttributes<HTMLButtonElement> & {
24
+ variant?: "outline" | "ghost" | "destructive";
25
+ size?: "sm" | "icon-xs" | "icon-sm";
26
+ }>;
27
+ Input: ComponentType<InputHTMLAttributes<HTMLInputElement>>;
28
+ Select?: ComponentType<{
29
+ value: string;
30
+ onValueChange: (value: string) => void;
31
+ options: Array<{
32
+ value: string;
33
+ label: string;
34
+ }>;
35
+ disabled?: boolean;
36
+ "aria-label"?: string;
37
+ }>;
38
+ Dialog?: ComponentType<{
39
+ open: boolean;
40
+ onOpenChange: (open: boolean) => void;
41
+ title: string;
42
+ description?: string;
43
+ children?: ReactNode;
44
+ }>;
45
+ }
46
+ export interface DriveHost {
47
+ readDirectory: ReadDirLike;
48
+ pathExists: (path: string) => Promise<boolean>;
49
+ onOpenEntry: (entry: {
50
+ path: string;
51
+ isDirectory: boolean;
52
+ }) => Promise<void>;
53
+ onRevealPath: (path: string) => Promise<void>;
54
+ onOpenExternal: (url: string) => Promise<void>;
55
+ pinnedDocs: PinnedDoc[];
56
+ onPinnedDocsChange: (docs: PinnedDoc[]) => Promise<void>;
57
+ onCondense?: (root: RootInfo) => Promise<void>;
58
+ integrations?: ReactNode;
59
+ }
60
+ export declare function useDrive(controller: DriveController): DriveState;
61
+ export declare function useDriveAction(): {
62
+ busy: boolean;
63
+ error: string | null;
64
+ run: (action: () => Promise<unknown>) => void;
65
+ };
66
+ export declare function requireHost(host: DriveHost | undefined): DriveHost;
67
+ export declare function DriveChoice({ controls, ...props }: {
68
+ controls: DriveControls;
69
+ value: string;
70
+ onValueChange: (value: string) => void;
71
+ options: Array<{
72
+ value: string;
73
+ label: string;
74
+ }>;
75
+ "aria-label"?: string;
76
+ disabled?: boolean;
77
+ }): ReactNode;
78
+ export declare function DriveModal({ controls, ...props }: {
79
+ controls: DriveControls;
80
+ open: boolean;
81
+ onOpenChange: (open: boolean) => void;
82
+ title: string;
83
+ description?: string;
84
+ children?: ReactNode;
85
+ }): ReactNode;
86
+ export declare function DriveMenu({ controls, context, ...props }: DriveMenuProps & {
87
+ controls: DriveControls;
88
+ context?: boolean;
89
+ }): ReactNode;
90
+ export declare function DriveSwitch({ controls, ...props }: {
91
+ controls: DriveControls;
92
+ checked: boolean;
93
+ onCheckedChange: (checked: boolean) => void;
94
+ disabled?: boolean;
95
+ "aria-label"?: string;
96
+ }): ReactNode;
package/dist/ui.js ADDED
@@ -0,0 +1 @@
1
+ import{jsx as o}from"react/jsx-runtime";import{useRef as a,useState as s,useSyncExternalStore as h}from"react";function d(e){return h(e.subscribe,e.getSnapshot,e.getSnapshot)}function p(){let[e,t]=s(!1),[r,n]=s(null),i=a(!1);return{busy:e,error:r,run(c){if(i.current)return;i.current=!0,t(!0),n(null),c().catch((u)=>n(u instanceof Error?u.message:String(u))).finally(()=>{i.current=!1,t(!1)})}}}function w(e){if(!e)throw Error("Drive host integration is required for this action");return e}function S({controls:e,...t}){let r=e.Select;if(!r)throw Error("The host must supply its shadcn Select control");return o(r,{...t})}function g({controls:e,...t}){let r=e.Dialog;if(!r)throw Error("The host must supply its shadcn Dialog control");return o(r,{...t})}function x({controls:e,context:t=!1,...r}){let n=t?e.ContextMenu:e.Menu;if(!n)throw Error(`The host must supply its shadcn ${t?"ContextMenu":"DropdownMenu"} control`);return o(n,{...r})}function D({controls:e,...t}){if(e.Switch){let n=e.Switch;return o(n,{...t})}let r=e.Input;return o(r,{type:"checkbox",role:"switch",checked:t.checked,disabled:t.disabled,"aria-label":t["aria-label"],onChange:(n)=>t.onCheckedChange(n.target.checked)})}export{S as DriveChoice,x as DriveMenu,g as DriveModal,D as DriveSwitch,w as requireHost,d as useDrive,p as useDriveAction};