@rljson/fs-agent 0.0.4 → 0.0.5
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/README.public.md +31 -0
- package/dist/README.public.md +31 -0
- package/dist/fs-agent.js +10 -0
- package/package.json +11 -11
package/README.public.md
CHANGED
|
@@ -314,6 +314,37 @@ Stops all syncing and cleans up resources.
|
|
|
314
314
|
agent.dispose();
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
+
##### `static fromClient(filePath, treeKey, client, socket, options?): Promise<FsAgent>`
|
|
318
|
+
|
|
319
|
+
Factory method that creates an FsAgent wired to a `@rljson/server` Client. Returns an enhanced agent with simplified sync methods:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { Client } from '@rljson/server';
|
|
323
|
+
|
|
324
|
+
const agent = await FsAgent.fromClient(
|
|
325
|
+
'./my-project',
|
|
326
|
+
'sharedTree',
|
|
327
|
+
client,
|
|
328
|
+
socket,
|
|
329
|
+
{ ignore: ['node_modules', '.git'] },
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// Simplified sync (no need to manage Db/Connector manually)
|
|
333
|
+
const stopToDb = await agent.syncToDbSimple({ notify: true });
|
|
334
|
+
const stopFromDb = await agent.syncFromDbSimple({ cleanTarget: true });
|
|
335
|
+
|
|
336
|
+
// Stop when done
|
|
337
|
+
stopToDb();
|
|
338
|
+
stopFromDb();
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Reconnect handling:** When the Client supports `onDisconnect` / `onReconnect` (available since `@rljson/server` ≥ 0.0.10), `fromClient()` automatically:
|
|
342
|
+
|
|
343
|
+
- **Pauses** the filesystem watcher on disconnect (prevents futile sync attempts while the server is unreachable)
|
|
344
|
+
- **Resumes** the watcher on reconnect (the server's bootstrap message triggers a catch-up sync via the Connector)
|
|
345
|
+
|
|
346
|
+
No application code is needed — the wiring is built into `fromClient()`. Clients created with older server versions that lack these methods continue to work without interruption.
|
|
347
|
+
|
|
317
348
|
### FsScanner
|
|
318
349
|
|
|
319
350
|
Low-level filesystem scanner (usually accessed via `agent.scanner`).
|
package/dist/README.public.md
CHANGED
|
@@ -314,6 +314,37 @@ Stops all syncing and cleans up resources.
|
|
|
314
314
|
agent.dispose();
|
|
315
315
|
```
|
|
316
316
|
|
|
317
|
+
##### `static fromClient(filePath, treeKey, client, socket, options?): Promise<FsAgent>`
|
|
318
|
+
|
|
319
|
+
Factory method that creates an FsAgent wired to a `@rljson/server` Client. Returns an enhanced agent with simplified sync methods:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import { Client } from '@rljson/server';
|
|
323
|
+
|
|
324
|
+
const agent = await FsAgent.fromClient(
|
|
325
|
+
'./my-project',
|
|
326
|
+
'sharedTree',
|
|
327
|
+
client,
|
|
328
|
+
socket,
|
|
329
|
+
{ ignore: ['node_modules', '.git'] },
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
// Simplified sync (no need to manage Db/Connector manually)
|
|
333
|
+
const stopToDb = await agent.syncToDbSimple({ notify: true });
|
|
334
|
+
const stopFromDb = await agent.syncFromDbSimple({ cleanTarget: true });
|
|
335
|
+
|
|
336
|
+
// Stop when done
|
|
337
|
+
stopToDb();
|
|
338
|
+
stopFromDb();
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Reconnect handling:** When the Client supports `onDisconnect` / `onReconnect` (available since `@rljson/server` ≥ 0.0.10), `fromClient()` automatically:
|
|
342
|
+
|
|
343
|
+
- **Pauses** the filesystem watcher on disconnect (prevents futile sync attempts while the server is unreachable)
|
|
344
|
+
- **Resumes** the watcher on reconnect (the server's bootstrap message triggers a catch-up sync via the Connector)
|
|
345
|
+
|
|
346
|
+
No application code is needed — the wiring is built into `fromClient()`. Clients created with older server versions that lack these methods continue to work without interruption.
|
|
347
|
+
|
|
317
348
|
### FsScanner
|
|
318
349
|
|
|
319
350
|
Low-level filesystem scanner (usually accessed via `agent.scanner`).
|
package/dist/fs-agent.js
CHANGED
|
@@ -1116,6 +1116,16 @@ class FsAgent {
|
|
|
1116
1116
|
enhancedAgent.syncFromDbSimple = async (restoreOpts) => {
|
|
1117
1117
|
return agent.syncFromDb(db, connector, treeKey, restoreOpts);
|
|
1118
1118
|
};
|
|
1119
|
+
if (typeof client.onDisconnect === "function") {
|
|
1120
|
+
client.onDisconnect(() => {
|
|
1121
|
+
agent.scanner.pauseWatch();
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
if (typeof client.onReconnect === "function") {
|
|
1125
|
+
client.onReconnect(() => {
|
|
1126
|
+
agent.scanner.resumeWatch();
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1119
1129
|
return enhancedAgent;
|
|
1120
1130
|
}
|
|
1121
1131
|
/** Example instance for test purposes */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rljson/fs-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Rljson fs-agent description",
|
|
5
5
|
"homepage": "https://github.com/rljson/fs-agent",
|
|
6
6
|
"bugs": "https://github.com/rljson/fs-agent/issues",
|
|
@@ -20,20 +20,20 @@
|
|
|
20
20
|
],
|
|
21
21
|
"type": "module",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@rljson/server": "^0.0.
|
|
24
|
-
"@types/node": "^25.
|
|
25
|
-
"@typescript-eslint/eslint-plugin": "^8.56.
|
|
26
|
-
"@typescript-eslint/parser": "^8.56.
|
|
23
|
+
"@rljson/server": "^0.0.10",
|
|
24
|
+
"@types/node": "^25.3.1",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
26
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
27
27
|
"@vitest/coverage-v8": "^4.0.18",
|
|
28
28
|
"cross-env": "^10.1.0",
|
|
29
|
-
"eslint": "~9.39.
|
|
30
|
-
"eslint-plugin-jsdoc": "^62.
|
|
31
|
-
"eslint-plugin-tsdoc": "^0.5.
|
|
29
|
+
"eslint": "~9.39.3",
|
|
30
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
31
|
+
"eslint-plugin-tsdoc": "^0.5.2",
|
|
32
32
|
"globals": "^17.3.0",
|
|
33
33
|
"jsdoc": "^4.0.5",
|
|
34
34
|
"read-pkg": "^10.1.0",
|
|
35
35
|
"typescript": "~5.9.3",
|
|
36
|
-
"typescript-eslint": "^8.56.
|
|
36
|
+
"typescript-eslint": "^8.56.1",
|
|
37
37
|
"vite": "^7.3.1",
|
|
38
38
|
"vite-node": "^5.3.0",
|
|
39
39
|
"vite-plugin-dts": "^4.5.4",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@rljson/bs": "^0.0.21",
|
|
46
|
-
"@rljson/db": "^0.0.
|
|
46
|
+
"@rljson/db": "^0.0.15",
|
|
47
47
|
"@rljson/hash": "^0.0.18",
|
|
48
48
|
"@rljson/io": "^0.0.66",
|
|
49
49
|
"@rljson/json": "^0.0.23",
|
|
50
|
-
"@rljson/rljson": "^0.0.
|
|
50
|
+
"@rljson/rljson": "^0.0.78",
|
|
51
51
|
"socket.io": "^4.8.3",
|
|
52
52
|
"socket.io-client": "^4.8.3"
|
|
53
53
|
},
|