@tomradex/files 0.21.0 → 0.23.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.
@@ -83,8 +83,8 @@ declare module "@tomradex/ipc" {
83
83
  "files.readById": (projectId: string, fileId: string) => FileContent | null;
84
84
  }
85
85
  interface Broadcasts {
86
- /** This project's files or their sync state moved; refetch everything keyed by it. */
87
- "files.changed": (projectId: string) => void;
86
+ /** This project's files or their sync state moved. `paths` names the files that changed when the writer knows them; without it, refetch everything keyed by the project. */
87
+ "files.changed": (projectId: string, paths?: string[]) => void;
88
88
  }
89
89
  }
90
90
  //# sourceMappingURL=channels.d.ts.map
@@ -9,7 +9,7 @@ export declare class FolderFileStore implements FileStore {
9
9
  private readonly opts;
10
10
  constructor(dir: string, opts: {
11
11
  detail: string;
12
- onChange(): void;
12
+ onChange(paths?: string[]): void;
13
13
  });
14
14
  private abs;
15
15
  private readDir;
@@ -25,7 +25,7 @@ export interface GitStoreOptions {
25
25
  /** Non-secret, for status lines; the folder when null. */
26
26
  location: string | null;
27
27
  warn(message: string): void;
28
- onChange(): void;
28
+ onChange(paths?: string[]): void;
29
29
  watch?: boolean;
30
30
  /** Outside edits are saved this long after the last one. */
31
31
  settleMs?: number;
@@ -113,6 +113,7 @@ export declare class GitFileStore implements FileStore {
113
113
  private watch;
114
114
  private unwatch;
115
115
  private scheduleSettle;
116
+ /** `paths` when this store's own write knows what it touched. */
116
117
  private afterChange;
117
118
  private schedulePush;
118
119
  head(): Promise<string | null>;
@@ -177,7 +178,10 @@ export declare class GitFileStore implements FileStore {
177
178
  */
178
179
  restore(paths: string[], from: string, to: string, message: string): Promise<string | null>;
179
180
  status(): Promise<FilesStatus>;
180
- sync(): Promise<FilesStatus>;
181
+ watching(): boolean;
182
+ sync(opts?: {
183
+ quiet?: boolean;
184
+ }): Promise<FilesStatus>;
181
185
  /**
182
186
  * Save, then — with a remote — probe, fetch, merge, push. Leaves `problem`
183
187
  * for `status()` to report. Only the steps that touch the index and working
package/dist/service.d.ts CHANGED
@@ -10,6 +10,8 @@ declare module "cordis" {
10
10
  files: Files;
11
11
  }
12
12
  interface Events {
13
+ /** From the desktop shell: whether any of the app's windows can be seen. */
14
+ "desktop/seen"(seen: boolean): void;
13
15
  "files/registered"(backendId: string): void;
14
16
  "files/unregistered"(backendId: string): void;
15
17
  /** A project's files or their sync state moved. */
@@ -22,6 +24,7 @@ declare module "cordis" {
22
24
  export declare const FilesConfig: z.ZodPreprocess<z.ZodObject<{
23
25
  gitBinary: z.ZodDefault<z.ZodString>;
24
26
  autoSyncMs: z.ZodDefault<z.ZodNumber>;
27
+ rareSyncMs: z.ZodDefault<z.ZodNumber>;
25
28
  settleMs: z.ZodDefault<z.ZodNumber>;
26
29
  pushMs: z.ZodDefault<z.ZodNumber>;
27
30
  watch: z.ZodDefault<z.ZodBoolean>;
@@ -41,6 +44,7 @@ export declare class Files extends Service implements FilesReader {
41
44
  static Config: z.ZodPreprocess<z.ZodObject<{
42
45
  gitBinary: z.ZodDefault<z.ZodString>;
43
46
  autoSyncMs: z.ZodDefault<z.ZodNumber>;
47
+ rareSyncMs: z.ZodDefault<z.ZodNumber>;
44
48
  settleMs: z.ZodDefault<z.ZodNumber>;
45
49
  pushMs: z.ZodDefault<z.ZodNumber>;
46
50
  watch: z.ZodDefault<z.ZodBoolean>;
@@ -55,6 +59,10 @@ export declare class Files extends Service implements FilesReader {
55
59
  private readonly lastState;
56
60
  /** How often each project's files were said to change, so a sync knows whether its store said anything. */
57
61
  private readonly told;
62
+ /** When the sweep last synced each project. */
63
+ private readonly swept;
64
+ /** Whether a window of the app can be seen, as the desktop shell last said. */
65
+ private seen;
58
66
  /** Titles cost a read each; a file that has not changed has not retitled itself. */
59
67
  private readonly titles;
60
68
  private remotes;
@@ -62,6 +70,7 @@ export declare class Files extends Service implements FilesReader {
62
70
  constructor(ctx: Context, config: FilesConfig);
63
71
  [Service.init](): () => void;
64
72
  private warn;
73
+ /** `paths`, when the change is known to touch only them, lets a window keep what it read of every other file. */
65
74
  private notify;
66
75
  /** Reversible: the backend, and its option in every project, goes with the plugin that registered it. */
67
76
  register<C>(backend: FilesBackend<C>): () => void;
@@ -177,7 +186,9 @@ export declare class Files extends Service implements FilesReader {
177
186
  * folder kept open whatever that budget is.
178
187
  */
179
188
  indexFor(projectId: string, native: boolean, itemId?: string): Promise<AgentIndex | null>;
180
- sync(projectId: string): Promise<FilesStatus>;
189
+ sync(projectId: string, opts?: {
190
+ quiet?: boolean;
191
+ }): Promise<FilesStatus>;
181
192
  /** The sweep: every project open on this machine with files, or a remote, is saved and synced. */
182
193
  syncAll(): Promise<void>;
183
194
  conflicts(projectId: string): Promise<FileConflict[]>;
package/dist/types.d.ts CHANGED
@@ -181,8 +181,12 @@ export interface FileStore {
181
181
  setAgentRules?(paths: string[], mode: ListMode | "inherit"): Promise<FilesAgentPolicy>;
182
182
  /** Literal or regular-expression search over the working copy. Absent when a backend cannot search. */
183
183
  search?(input: FileSearchInput): Promise<FileSearchResult>;
184
- /** Save, take the remote's changes, push. Conflicts are left for `conflicts()`/`resolve()`. */
185
- sync(): Promise<FilesStatus>;
184
+ /** Save, take the remote's changes, push. Conflicts are left for `conflicts()`/`resolve()`. `quiet`: the periodic sweep, which tells only of what changed. */
185
+ sync(opts?: {
186
+ quiet?: boolean;
187
+ }): Promise<FilesStatus>;
188
+ /** Whether outside edits are being watched, so a sweep is not what saves them. */
189
+ watching?(): boolean;
186
190
  conflicts(): Promise<FileConflict[]>;
187
191
  resolve(path: string, choice: ConflictChoice): Promise<void>;
188
192
  close(): void;
@@ -222,8 +226,8 @@ export interface OpenStoreOptions<C> {
222
226
  remote: C | null;
223
227
  /** Non-fatal trouble goes here, prefixed by the caller. */
224
228
  warn(message: string): void;
225
- /** The store's files changed underneath the app: a sync, an outside edit. */
226
- onChange(): void;
229
+ /** The store's files changed underneath the app: a sync, an outside edit. `paths` when the store knows which. */
230
+ onChange(paths?: string[]): void;
227
231
  /** What the service was configured with; a backend takes what applies to it. */
228
232
  env: StoreEnv;
229
233
  /** The project's own repository, asked on every sync; a backend sharing through git keeps out of its root and the store's folder. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomradex/files",
3
- "version": "0.21.0",
3
+ "version": "0.23.0",
4
4
  "type": "module",
5
5
  "author": "Haoyuan Tang",
6
6
  "engines": {
@@ -27,21 +27,21 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@tomradex/agent": "0.21.0",
31
- "@tomradex/boards": "0.21.0",
32
- "@tomradex/contracts": "0.21.0",
33
- "@tomradex/contributions": "0.21.0",
34
- "@tomradex/db": "0.21.0",
35
- "@tomradex/domain": "0.2.29",
36
- "@tomradex/git": "0.21.0",
37
- "@tomradex/hub": "0.21.0",
38
- "@tomradex/ipc": "0.21.0",
39
- "@tomradex/items": "0.21.0",
40
- "@tomradex/oplog": "0.21.0",
41
- "@tomradex/settings": "0.21.0",
42
- "@tomradex/storage": "0.21.0",
43
- "@tomradex/tools": "0.21.0",
44
- "@tomradex/write": "0.21.0",
30
+ "@tomradex/agent": "0.23.0",
31
+ "@tomradex/boards": "0.23.0",
32
+ "@tomradex/contracts": "0.23.0",
33
+ "@tomradex/contributions": "0.23.0",
34
+ "@tomradex/db": "0.23.0",
35
+ "@tomradex/domain": "0.2.30",
36
+ "@tomradex/git": "0.23.0",
37
+ "@tomradex/hub": "0.23.0",
38
+ "@tomradex/ipc": "0.23.0",
39
+ "@tomradex/items": "0.23.0",
40
+ "@tomradex/oplog": "0.23.0",
41
+ "@tomradex/settings": "0.23.0",
42
+ "@tomradex/storage": "0.23.0",
43
+ "@tomradex/tools": "0.23.0",
44
+ "@tomradex/write": "0.23.0",
45
45
  "cordis": "4.0.0-rc.8",
46
46
  "zod": "^4.4.3"
47
47
  }