pushwork 1.1.4 → 2.0.0-a.sub.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/CLAUDE.md +9 -5
- package/dist/cli.js +48 -55
- package/dist/cli.js.map +1 -1
- package/dist/commands.d.ts +5 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +262 -263
- package/dist/commands.js.map +1 -1
- package/dist/core/change-detection.d.ts +1 -1
- package/dist/core/change-detection.d.ts.map +1 -1
- package/dist/core/change-detection.js +66 -103
- package/dist/core/change-detection.js.map +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +14 -57
- package/dist/core/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -21
- package/dist/core/index.js.map +1 -1
- package/dist/core/move-detection.d.ts +2 -2
- package/dist/core/move-detection.d.ts.map +1 -1
- package/dist/core/move-detection.js +9 -13
- package/dist/core/move-detection.js.map +1 -1
- package/dist/core/snapshot.d.ts +1 -1
- package/dist/core/snapshot.d.ts.map +1 -1
- package/dist/core/snapshot.js +9 -46
- package/dist/core/snapshot.js.map +1 -1
- package/dist/core/sync-engine.d.ts +8 -2
- package/dist/core/sync-engine.d.ts.map +1 -1
- package/dist/core/sync-engine.js +171 -175
- package/dist/core/sync-engine.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/types/config.d.ts +7 -6
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +1 -5
- package/dist/types/config.js.map +1 -1
- package/dist/types/documents.js +4 -7
- package/dist/types/documents.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -19
- package/dist/types/index.js.map +1 -1
- package/dist/types/snapshot.js +1 -2
- package/dist/utils/content.js +4 -8
- package/dist/utils/content.js.map +1 -1
- package/dist/utils/directory.js +5 -9
- package/dist/utils/directory.js.map +1 -1
- package/dist/utils/fs.d.ts +1 -1
- package/dist/utils/fs.d.ts.map +1 -1
- package/dist/utils/fs.js +34 -84
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +4 -20
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/mime-types.js +5 -43
- package/dist/utils/mime-types.js.map +1 -1
- package/dist/utils/network-sync.d.ts +13 -8
- package/dist/utils/network-sync.d.ts.map +1 -1
- package/dist/utils/network-sync.js +65 -137
- package/dist/utils/network-sync.js.map +1 -1
- package/dist/utils/node-polyfills.d.ts +9 -0
- package/dist/utils/node-polyfills.d.ts.map +1 -0
- package/dist/utils/node-polyfills.js +9 -0
- package/dist/utils/node-polyfills.js.map +1 -0
- package/dist/utils/output.js +32 -39
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/repo-factory.d.ts +8 -2
- package/dist/utils/repo-factory.d.ts.map +1 -1
- package/dist/utils/repo-factory.js +38 -47
- package/dist/utils/repo-factory.js.map +1 -1
- package/dist/utils/string-similarity.js +1 -5
- package/dist/utils/string-similarity.js.map +1 -1
- package/dist/utils/text-diff.js +5 -43
- package/dist/utils/text-diff.js.map +1 -1
- package/dist/utils/trace.js +6 -11
- package/dist/utils/trace.js.map +1 -1
- package/package.json +7 -5
- package/src/cli.ts +25 -34
- package/src/commands.ts +75 -11
- package/src/core/change-detection.ts +4 -4
- package/src/core/config.ts +2 -12
- package/src/core/index.ts +5 -5
- package/src/core/move-detection.ts +4 -4
- package/src/core/snapshot.ts +3 -3
- package/src/core/sync-engine.ts +82 -50
- package/src/index.ts +4 -4
- package/src/types/config.ts +8 -8
- package/src/types/index.ts +3 -3
- package/src/utils/directory.ts +1 -1
- package/src/utils/fs.ts +6 -4
- package/src/utils/index.ts +4 -4
- package/src/utils/network-sync.ts +62 -115
- package/src/utils/node-polyfills.ts +8 -0
- package/src/utils/repo-factory.ts +55 -10
- package/src/utils/trace.ts +1 -1
- package/tsconfig.json +2 -1
|
@@ -1,28 +1,73 @@
|
|
|
1
|
+
import "./node-polyfills.js";
|
|
1
2
|
import { Repo } from "@automerge/automerge-repo";
|
|
2
3
|
import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs";
|
|
3
|
-
import
|
|
4
|
+
import * as subductionModule from "@automerge/automerge-subduction";
|
|
5
|
+
import {
|
|
6
|
+
initSubductionModule,
|
|
7
|
+
SubductionStorageBridge,
|
|
8
|
+
} from "@automerge/automerge-repo-subduction-bridge";
|
|
4
9
|
import * as path from "path";
|
|
5
|
-
import
|
|
10
|
+
import * as os from "os";
|
|
11
|
+
import { DirectoryConfig } from "../types/index.js";
|
|
12
|
+
|
|
13
|
+
const { WebCryptoSigner, Subduction } = subductionModule;
|
|
14
|
+
|
|
15
|
+
let subductionModuleInitialized = false;
|
|
16
|
+
|
|
17
|
+
function ensureSubductionModuleInit() {
|
|
18
|
+
if (!subductionModuleInitialized) {
|
|
19
|
+
initSubductionModule(subductionModule);
|
|
20
|
+
subductionModuleInitialized = true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
6
23
|
|
|
7
24
|
/**
|
|
8
|
-
* Create an Automerge repository with
|
|
25
|
+
* Create an Automerge repository with Subduction-based setup
|
|
9
26
|
*/
|
|
10
27
|
export async function createRepo(
|
|
11
28
|
workingDir: string,
|
|
12
29
|
config: DirectoryConfig
|
|
13
30
|
): Promise<Repo> {
|
|
31
|
+
ensureSubductionModuleInit();
|
|
32
|
+
|
|
14
33
|
const syncToolDir = path.join(workingDir, ".pushwork");
|
|
15
|
-
const
|
|
34
|
+
const nodeStorage = new NodeFSStorageAdapter(path.join(syncToolDir, "automerge"));
|
|
16
35
|
|
|
17
|
-
const
|
|
36
|
+
const signer = await WebCryptoSigner.setup();
|
|
37
|
+
const storageBridge = new SubductionStorageBridge(nodeStorage);
|
|
38
|
+
const subduction = await Subduction.hydrate(signer, storageBridge);
|
|
18
39
|
|
|
19
|
-
//
|
|
40
|
+
// Connect to sync server if sync is enabled
|
|
20
41
|
if (config.sync_enabled && config.sync_server) {
|
|
21
|
-
|
|
22
|
-
config.sync_server
|
|
42
|
+
await subduction.connectDiscover(
|
|
43
|
+
new URL(config.sync_server),
|
|
44
|
+
signer
|
|
23
45
|
);
|
|
24
|
-
repoConfig.network = [networkAdapter];
|
|
25
46
|
}
|
|
26
47
|
|
|
27
|
-
return new Repo(
|
|
48
|
+
return new Repo({ subduction } as any);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Create an ephemeral Automerge repository for remote reads.
|
|
53
|
+
* Uses a temporary directory for storage.
|
|
54
|
+
*/
|
|
55
|
+
export async function createEphemeralRepo(
|
|
56
|
+
syncServer: string
|
|
57
|
+
): Promise<Repo> {
|
|
58
|
+
ensureSubductionModuleInit();
|
|
59
|
+
|
|
60
|
+
const tmpDir = path.join(os.tmpdir(), `pushwork-ephemeral-${Date.now()}`);
|
|
61
|
+
const nodeStorage = new NodeFSStorageAdapter(tmpDir);
|
|
62
|
+
|
|
63
|
+
const signer = await WebCryptoSigner.setup();
|
|
64
|
+
const storageBridge = new SubductionStorageBridge(nodeStorage);
|
|
65
|
+
const subduction = await Subduction.hydrate(signer, storageBridge);
|
|
66
|
+
|
|
67
|
+
await subduction.connectDiscover(
|
|
68
|
+
new URL(syncServer),
|
|
69
|
+
signer
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
return new Repo({ subduction } as any);
|
|
28
73
|
}
|
package/src/utils/trace.ts
CHANGED