pushwork 2.0.0-preview.4 → 2.0.0-preview.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/dist/branches.d.ts +2 -1
- package/dist/branches.d.ts.map +1 -1
- package/dist/branches.js +23 -4
- package/dist/branches.js.map +1 -1
- package/dist/checkpoints.d.ts +41 -0
- package/dist/checkpoints.d.ts.map +1 -0
- package/dist/checkpoints.js +210 -0
- package/dist/checkpoints.js.map +1 -0
- package/dist/stash.d.ts +2 -0
- package/dist/stash.d.ts.map +1 -1
- package/dist/stash.js +1 -0
- package/dist/stash.js.map +1 -1
- package/package.json +2 -2
- package/dist/cli/commands.d.ts +0 -71
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -794
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -19
- package/dist/cli/index.js.map +0 -1
- package/dist/commands.d.ts +0 -58
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js +0 -975
- package/dist/commands.js.map +0 -1
- package/dist/config/index.d.ts +0 -71
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -314
- package/dist/config/index.js.map +0 -1
- package/dist/core/change-detection.d.ts +0 -80
- package/dist/core/change-detection.d.ts.map +0 -1
- package/dist/core/change-detection.js +0 -560
- package/dist/core/change-detection.js.map +0 -1
- package/dist/core/config.d.ts +0 -81
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -304
- package/dist/core/config.js.map +0 -1
- package/dist/core/index.d.ts +0 -6
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -22
- package/dist/core/index.js.map +0 -1
- package/dist/core/move-detection.d.ts +0 -34
- package/dist/core/move-detection.d.ts.map +0 -1
- package/dist/core/move-detection.js +0 -128
- package/dist/core/move-detection.js.map +0 -1
- package/dist/core/snapshot.d.ts +0 -105
- package/dist/core/snapshot.d.ts.map +0 -1
- package/dist/core/snapshot.js +0 -254
- package/dist/core/snapshot.js.map +0 -1
- package/dist/core/sync-engine.d.ts +0 -177
- package/dist/core/sync-engine.d.ts.map +0 -1
- package/dist/core/sync-engine.js +0 -1471
- package/dist/core/sync-engine.js.map +0 -1
- package/dist/types/config.d.ts +0 -102
- package/dist/types/config.d.ts.map +0 -1
- package/dist/types/config.js +0 -10
- package/dist/types/config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -88
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -23
- package/dist/types/documents.js.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -20
- package/dist/types/index.js.map +0 -1
- package/dist/types/snapshot.d.ts +0 -64
- package/dist/types/snapshot.d.ts.map +0 -1
- package/dist/types/snapshot.js +0 -3
- package/dist/types/snapshot.js.map +0 -1
- package/dist/utils/content-similarity.d.ts +0 -53
- package/dist/utils/content-similarity.d.ts.map +0 -1
- package/dist/utils/content-similarity.js +0 -155
- package/dist/utils/content-similarity.js.map +0 -1
- package/dist/utils/content.d.ts +0 -10
- package/dist/utils/content.d.ts.map +0 -1
- package/dist/utils/content.js +0 -35
- package/dist/utils/content.js.map +0 -1
- package/dist/utils/directory.d.ts +0 -24
- package/dist/utils/directory.d.ts.map +0 -1
- package/dist/utils/directory.js +0 -56
- package/dist/utils/directory.js.map +0 -1
- package/dist/utils/fs.d.ts +0 -74
- package/dist/utils/fs.d.ts.map +0 -1
- package/dist/utils/fs.js +0 -298
- package/dist/utils/fs.js.map +0 -1
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js +0 -21
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/mime-types.d.ts +0 -13
- package/dist/utils/mime-types.d.ts.map +0 -1
- package/dist/utils/mime-types.js +0 -247
- package/dist/utils/mime-types.js.map +0 -1
- package/dist/utils/network-sync.d.ts +0 -30
- package/dist/utils/network-sync.d.ts.map +0 -1
- package/dist/utils/network-sync.js +0 -391
- package/dist/utils/network-sync.js.map +0 -1
- package/dist/utils/node-polyfills.d.ts +0 -9
- package/dist/utils/node-polyfills.d.ts.map +0 -1
- package/dist/utils/node-polyfills.js +0 -9
- package/dist/utils/node-polyfills.js.map +0 -1
- package/dist/utils/output.d.ts +0 -129
- package/dist/utils/output.d.ts.map +0 -1
- package/dist/utils/output.js +0 -375
- package/dist/utils/output.js.map +0 -1
- package/dist/utils/repo-factory.d.ts +0 -15
- package/dist/utils/repo-factory.d.ts.map +0 -1
- package/dist/utils/repo-factory.js +0 -156
- package/dist/utils/repo-factory.js.map +0 -1
- package/dist/utils/string-similarity.d.ts +0 -14
- package/dist/utils/string-similarity.d.ts.map +0 -1
- package/dist/utils/string-similarity.js +0 -43
- package/dist/utils/string-similarity.js.map +0 -1
- package/dist/utils/text-diff.d.ts +0 -37
- package/dist/utils/text-diff.d.ts.map +0 -1
- package/dist/utils/text-diff.js +0 -131
- package/dist/utils/text-diff.js.map +0 -1
- package/dist/utils/trace.d.ts +0 -19
- package/dist/utils/trace.d.ts.map +0 -1
- package/dist/utils/trace.js +0 -68
- package/dist/utils/trace.js.map +0 -1
- package/patches/@automerge__automerge-repo@2.6.0-subduction.15.patch +0 -26
package/dist/core/snapshot.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* pvh TODO: the files & directories could be unified into a single map of entries with a type field
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
-
var ownKeys = function(o) {
|
|
23
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
-
var ar = [];
|
|
25
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
-
return ar;
|
|
27
|
-
};
|
|
28
|
-
return ownKeys(o);
|
|
29
|
-
};
|
|
30
|
-
return function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.SnapshotManager = void 0;
|
|
40
|
-
const fs = __importStar(require("fs/promises"));
|
|
41
|
-
const path = __importStar(require("path"));
|
|
42
|
-
const utils_1 = require("../utils");
|
|
43
|
-
const output_1 = require("../utils/output");
|
|
44
|
-
/**
|
|
45
|
-
* Manages sync snapshots for local state tracking
|
|
46
|
-
*/
|
|
47
|
-
class SnapshotManager {
|
|
48
|
-
constructor(rootPath) {
|
|
49
|
-
this.rootPath = rootPath;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Get path to sync tool directory
|
|
53
|
-
*/
|
|
54
|
-
getSyncToolDir() {
|
|
55
|
-
return path.join(this.rootPath, SnapshotManager.SYNC_TOOL_DIR);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get path to snapshot file
|
|
59
|
-
*/
|
|
60
|
-
getSnapshotPath() {
|
|
61
|
-
return path.join(this.getSyncToolDir(), SnapshotManager.SNAPSHOT_FILENAME);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Check if snapshot exists
|
|
65
|
-
*/
|
|
66
|
-
async exists() {
|
|
67
|
-
return await (0, utils_1.pathExists)(this.getSnapshotPath());
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Load snapshot from disk
|
|
71
|
-
*/
|
|
72
|
-
async load() {
|
|
73
|
-
try {
|
|
74
|
-
const snapshotPath = this.getSnapshotPath();
|
|
75
|
-
if (!(await (0, utils_1.pathExists)(snapshotPath))) {
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
const content = await fs.readFile(snapshotPath, "utf8");
|
|
79
|
-
const serializable = JSON.parse(content);
|
|
80
|
-
return this.deserializeSnapshot(serializable);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
output_1.out.taskLine(`Failed to load snapshot: ${error}`);
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Save snapshot to disk
|
|
89
|
-
*/
|
|
90
|
-
async save(snapshot) {
|
|
91
|
-
try {
|
|
92
|
-
await (0, utils_1.ensureDirectoryExists)(this.getSyncToolDir());
|
|
93
|
-
const serializable = this.serializeSnapshot(snapshot);
|
|
94
|
-
const content = JSON.stringify(serializable, null, 2);
|
|
95
|
-
await fs.writeFile(this.getSnapshotPath(), content, "utf8");
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
throw new Error(`Failed to save snapshot: ${error}`);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Create empty snapshot
|
|
103
|
-
*/
|
|
104
|
-
createEmpty() {
|
|
105
|
-
return {
|
|
106
|
-
timestamp: Date.now(),
|
|
107
|
-
rootPath: this.rootPath,
|
|
108
|
-
rootDirectoryUrl: undefined,
|
|
109
|
-
files: new Map(),
|
|
110
|
-
directories: new Map(),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Update file entry in snapshot
|
|
115
|
-
*/
|
|
116
|
-
updateFileEntry(snapshot, relativePath, entry) {
|
|
117
|
-
snapshot.files.set(relativePath, entry);
|
|
118
|
-
snapshot.timestamp = Date.now();
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Update directory entry in snapshot
|
|
122
|
-
*/
|
|
123
|
-
updateDirectoryEntry(snapshot, relativePath, entry) {
|
|
124
|
-
snapshot.directories.set(relativePath, entry);
|
|
125
|
-
snapshot.timestamp = Date.now();
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Remove file entry from snapshot
|
|
129
|
-
*/
|
|
130
|
-
removeFileEntry(snapshot, relativePath) {
|
|
131
|
-
snapshot.files.delete(relativePath);
|
|
132
|
-
snapshot.timestamp = Date.now();
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Remove directory entry from snapshot
|
|
136
|
-
*/
|
|
137
|
-
removeDirectoryEntry(snapshot, relativePath) {
|
|
138
|
-
snapshot.directories.delete(relativePath);
|
|
139
|
-
snapshot.timestamp = Date.now();
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Get all file paths in snapshot
|
|
143
|
-
*/
|
|
144
|
-
getFilePaths(snapshot) {
|
|
145
|
-
return Array.from(snapshot.files.keys());
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Get all directory paths in snapshot
|
|
149
|
-
*/
|
|
150
|
-
getDirectoryPaths(snapshot) {
|
|
151
|
-
return Array.from(snapshot.directories.keys());
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get file entry by path
|
|
155
|
-
*/
|
|
156
|
-
getFileEntry(snapshot, relativePath) {
|
|
157
|
-
return snapshot.files.get(relativePath);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Get directory entry by path
|
|
161
|
-
*/
|
|
162
|
-
getDirectoryEntry(snapshot, relativePath) {
|
|
163
|
-
return snapshot.directories.get(relativePath);
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Check if path is tracked in snapshot
|
|
167
|
-
*/
|
|
168
|
-
isTracked(snapshot, relativePath) {
|
|
169
|
-
return (snapshot.files.has(relativePath) || snapshot.directories.has(relativePath));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Get snapshot statistics
|
|
173
|
-
*/
|
|
174
|
-
getStats(snapshot) {
|
|
175
|
-
return {
|
|
176
|
-
files: snapshot.files.size,
|
|
177
|
-
directories: snapshot.directories.size,
|
|
178
|
-
timestamp: new Date(snapshot.timestamp),
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Validate snapshot integrity
|
|
183
|
-
*/
|
|
184
|
-
validate(snapshot) {
|
|
185
|
-
const errors = [];
|
|
186
|
-
if (!snapshot.timestamp || snapshot.timestamp <= 0) {
|
|
187
|
-
errors.push("Invalid timestamp");
|
|
188
|
-
}
|
|
189
|
-
if (!snapshot.rootPath) {
|
|
190
|
-
errors.push("Missing root path");
|
|
191
|
-
}
|
|
192
|
-
if (!snapshot.files || !snapshot.directories) {
|
|
193
|
-
errors.push("Missing files or directories map");
|
|
194
|
-
}
|
|
195
|
-
// Check for path conflicts (file and directory with same path)
|
|
196
|
-
for (const filePath of snapshot.files.keys()) {
|
|
197
|
-
if (snapshot.directories.has(filePath)) {
|
|
198
|
-
errors.push(`Path conflict: ${filePath} exists as both file and directory`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
valid: errors.length === 0,
|
|
203
|
-
errors,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Convert snapshot to serializable format
|
|
208
|
-
*/
|
|
209
|
-
serializeSnapshot(snapshot) {
|
|
210
|
-
return {
|
|
211
|
-
timestamp: snapshot.timestamp,
|
|
212
|
-
rootPath: snapshot.rootPath,
|
|
213
|
-
rootDirectoryUrl: snapshot.rootDirectoryUrl,
|
|
214
|
-
files: Array.from(snapshot.files.entries()),
|
|
215
|
-
directories: Array.from(snapshot.directories.entries()),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Convert serializable format back to snapshot
|
|
220
|
-
*/
|
|
221
|
-
deserializeSnapshot(serializable) {
|
|
222
|
-
return {
|
|
223
|
-
timestamp: serializable.timestamp,
|
|
224
|
-
rootPath: serializable.rootPath,
|
|
225
|
-
rootDirectoryUrl: serializable.rootDirectoryUrl,
|
|
226
|
-
files: new Map(serializable.files),
|
|
227
|
-
directories: new Map(serializable.directories),
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Clear all snapshot data
|
|
232
|
-
*/
|
|
233
|
-
clear(snapshot) {
|
|
234
|
-
snapshot.files.clear();
|
|
235
|
-
snapshot.directories.clear();
|
|
236
|
-
snapshot.timestamp = Date.now();
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Clone snapshot for safe manipulation
|
|
240
|
-
*/
|
|
241
|
-
clone(snapshot) {
|
|
242
|
-
return {
|
|
243
|
-
timestamp: snapshot.timestamp,
|
|
244
|
-
rootPath: snapshot.rootPath,
|
|
245
|
-
rootDirectoryUrl: snapshot.rootDirectoryUrl,
|
|
246
|
-
files: new Map(snapshot.files),
|
|
247
|
-
directories: new Map(snapshot.directories),
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.SnapshotManager = SnapshotManager;
|
|
252
|
-
SnapshotManager.SNAPSHOT_FILENAME = "snapshot.json";
|
|
253
|
-
SnapshotManager.SYNC_TOOL_DIR = ".pushwork";
|
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C3C,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;SACxD,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,mBAAmB,CACzB,YAAsC;QAEtC,OAAO;YACL,SAAS,EAAE,YAAY,CAAC,SAAS;YACjC,QAAQ,EAAE,YAAY,CAAC,QAAQ;YAC/B,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;YAC/C,KAAK,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,KAAK,CAAC;YAClC,WAAW,EAAE,IAAI,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC;SAC/C,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAsB;QAC1B,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACvB,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;QAC7B,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAsB;QAC1B,OAAO;YACL,SAAS,EAAE,QAAQ,CAAC,SAAS;YAC7B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,gBAAgB,EAAE,QAAQ,CAAC,gBAAgB;YAC3C,KAAK,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC9B,WAAW,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC;SAC3C,CAAC;IACJ,CAAC;;AA/PH,0CAgQC;AA/PyB,iCAAiB,GAAG,eAAe,CAAC;AACpC,6BAAa,GAAG,WAAW,CAAC"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { AutomergeUrl, Repo } from "@automerge/automerge-repo";
|
|
2
|
-
import { SyncSnapshot, SyncResult, DirectoryDocument, MoveCandidate, DirectoryConfig, DetectedChange } from "../types";
|
|
3
|
-
/**
|
|
4
|
-
* Nuke an artifact directory's docs array and rebuild it from scratch.
|
|
5
|
-
* Entries must be spread into plain objects — pushing Automerge proxy objects
|
|
6
|
-
* back after splicing them out throws "Cannot create a reference to an
|
|
7
|
-
* existing document object".
|
|
8
|
-
*/
|
|
9
|
-
export declare function nukeAndRebuildDocs(doc: DirectoryDocument, dirPath: string, newEntries: {
|
|
10
|
-
name: string;
|
|
11
|
-
url: AutomergeUrl;
|
|
12
|
-
}[], updatedEntries: {
|
|
13
|
-
name: string;
|
|
14
|
-
url: AutomergeUrl;
|
|
15
|
-
}[], deletedNames: string[], subdirUpdates: {
|
|
16
|
-
name: string;
|
|
17
|
-
url: AutomergeUrl;
|
|
18
|
-
}[]): void;
|
|
19
|
-
/**
|
|
20
|
-
* Bidirectional sync engine implementing two-phase sync
|
|
21
|
-
*/
|
|
22
|
-
export declare class SyncEngine {
|
|
23
|
-
private repo;
|
|
24
|
-
private rootPath;
|
|
25
|
-
private snapshotManager;
|
|
26
|
-
private changeDetector;
|
|
27
|
-
private moveDetector;
|
|
28
|
-
private handlesByPath;
|
|
29
|
-
private config;
|
|
30
|
-
constructor(repo: Repo, rootPath: string, config: DirectoryConfig);
|
|
31
|
-
/**
|
|
32
|
-
* Determine if content should be treated as text for Automerge text operations
|
|
33
|
-
* Note: This method checks the runtime type. File type detection happens
|
|
34
|
-
* during reading with isEnhancedTextFile() which now has better dev file support.
|
|
35
|
-
*/
|
|
36
|
-
private isTextContent;
|
|
37
|
-
/**
|
|
38
|
-
* Get a versioned URL from a handle (includes current heads).
|
|
39
|
-
* This ensures clients can fetch the exact version of the document.
|
|
40
|
-
*/
|
|
41
|
-
private getVersionedUrl;
|
|
42
|
-
/**
|
|
43
|
-
* Determine if a file path is inside an artifact directory.
|
|
44
|
-
* Artifact files are stored as immutable strings (RawString) and
|
|
45
|
-
* referenced with versioned URLs in directory entries.
|
|
46
|
-
*/
|
|
47
|
-
private isArtifactPath;
|
|
48
|
-
/**
|
|
49
|
-
* Get the appropriate URL for a file's directory entry.
|
|
50
|
-
* Artifact paths get versioned URLs (with heads) for exact version fetching.
|
|
51
|
-
* Non-artifact paths get plain URLs for collaborative editing.
|
|
52
|
-
*/
|
|
53
|
-
private getEntryUrl;
|
|
54
|
-
/**
|
|
55
|
-
* Get the appropriate URL for a subdirectory's directory entry.
|
|
56
|
-
* Artifact directories get versioned URLs (with heads) so consumers can
|
|
57
|
-
* fetch the exact snapshotted version, matching how artifact files work.
|
|
58
|
-
* Non-artifact directories get plain URLs for collaborative editing.
|
|
59
|
-
*/
|
|
60
|
-
private getDirEntryUrl;
|
|
61
|
-
/**
|
|
62
|
-
* Set the root directory URL in the snapshot
|
|
63
|
-
*/
|
|
64
|
-
getRootDirectoryUrl(): Promise<AutomergeUrl | undefined>;
|
|
65
|
-
setRootDirectoryUrl(url: AutomergeUrl): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Reset the snapshot, clearing all tracked files and directories.
|
|
68
|
-
* Preserves the rootDirectoryUrl so sync can still operate.
|
|
69
|
-
* Used by --force to re-sync every file.
|
|
70
|
-
*/
|
|
71
|
-
resetSnapshot(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Nuclear reset: clear the snapshot AND wipe the root directory document's
|
|
74
|
-
* entries so that every file and subdirectory gets brand-new Automerge
|
|
75
|
-
* documents. The root directory document itself is preserved.
|
|
76
|
-
*/
|
|
77
|
-
nuclearReset(): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Commit local changes only (no network sync)
|
|
80
|
-
*/
|
|
81
|
-
commitLocal(): Promise<SyncResult>;
|
|
82
|
-
/**
|
|
83
|
-
* Recreate documents that failed to sync. Creates new Automerge documents
|
|
84
|
-
* with the same content and updates all references (snapshot, parent directory).
|
|
85
|
-
* Returns new handles that should be retried for sync.
|
|
86
|
-
*/
|
|
87
|
-
private recreateFailedDocuments;
|
|
88
|
-
/**
|
|
89
|
-
* Run full bidirectional sync
|
|
90
|
-
*/
|
|
91
|
-
sync(options?: {
|
|
92
|
-
sub?: boolean;
|
|
93
|
-
}): Promise<SyncResult>;
|
|
94
|
-
/**
|
|
95
|
-
* Phase 1: Push local changes to Automerge documents.
|
|
96
|
-
*
|
|
97
|
-
* Works depth-first: processes the deepest files first, creates/updates all
|
|
98
|
-
* file docs at each level, then batch-updates the parent directory document
|
|
99
|
-
* in a single change. Propagates subdirectory URL updates as we walk up
|
|
100
|
-
* toward the root. This eliminates the need for a separate URL update pass.
|
|
101
|
-
*/
|
|
102
|
-
private pushLocalChanges;
|
|
103
|
-
/**
|
|
104
|
-
* Phase 2: Pull remote changes to local filesystem
|
|
105
|
-
*/
|
|
106
|
-
private pullRemoteChanges;
|
|
107
|
-
/**
|
|
108
|
-
* Apply remote change to local filesystem
|
|
109
|
-
*/
|
|
110
|
-
private applyRemoteChangeToLocal;
|
|
111
|
-
/**
|
|
112
|
-
* Apply move to remote documents
|
|
113
|
-
*/
|
|
114
|
-
private applyMoveToRemote;
|
|
115
|
-
/**
|
|
116
|
-
* Create new remote file document
|
|
117
|
-
*/
|
|
118
|
-
private createRemoteFile;
|
|
119
|
-
/**
|
|
120
|
-
* Update existing remote file document
|
|
121
|
-
*/
|
|
122
|
-
private updateRemoteFile;
|
|
123
|
-
/**
|
|
124
|
-
* Delete remote file document
|
|
125
|
-
*/
|
|
126
|
-
private deleteRemoteFile;
|
|
127
|
-
/**
|
|
128
|
-
* Add file entry to appropriate directory document (maintains hierarchy)
|
|
129
|
-
*/
|
|
130
|
-
private addFileToDirectory;
|
|
131
|
-
/**
|
|
132
|
-
* Ensure directory document exists for the given path, creating hierarchy as needed
|
|
133
|
-
* First checks for existing shared directories before creating new ones
|
|
134
|
-
*/
|
|
135
|
-
private ensureDirectoryDocument;
|
|
136
|
-
/**
|
|
137
|
-
* Remove file entry from directory document
|
|
138
|
-
*/
|
|
139
|
-
private removeFileFromDirectory;
|
|
140
|
-
/**
|
|
141
|
-
* Batch-update a directory document in a single change: add new file entries,
|
|
142
|
-
* update URLs for modified files, remove deleted entries, and update
|
|
143
|
-
* subdirectory URLs. This replaces the separate per-file directory mutations
|
|
144
|
-
* and the post-hoc URL update pass.
|
|
145
|
-
*/
|
|
146
|
-
private batchUpdateDirectory;
|
|
147
|
-
/**
|
|
148
|
-
* Sort changes by dependency order
|
|
149
|
-
*/
|
|
150
|
-
private sortChangesByDependency;
|
|
151
|
-
/**
|
|
152
|
-
* Get sync status
|
|
153
|
-
*/
|
|
154
|
-
getStatus(): Promise<{
|
|
155
|
-
snapshot: SyncSnapshot | null;
|
|
156
|
-
hasChanges: boolean;
|
|
157
|
-
changeCount: number;
|
|
158
|
-
lastSync: Date | null;
|
|
159
|
-
}>;
|
|
160
|
-
/**
|
|
161
|
-
* Preview changes without applying them
|
|
162
|
-
*/
|
|
163
|
-
previewChanges(): Promise<{
|
|
164
|
-
changes: DetectedChange[];
|
|
165
|
-
moves: MoveCandidate[];
|
|
166
|
-
summary: string;
|
|
167
|
-
}>;
|
|
168
|
-
/**
|
|
169
|
-
* Generate human-readable summary of changes
|
|
170
|
-
*/
|
|
171
|
-
private generateChangeSummary;
|
|
172
|
-
/**
|
|
173
|
-
* Update the lastSyncAt timestamp on the root directory document
|
|
174
|
-
*/
|
|
175
|
-
private touchRootDirectory;
|
|
176
|
-
}
|
|
177
|
-
//# sourceMappingURL=sync-engine.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/core/sync-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,IAAI,EAKJ,MAAM,2BAA2B,CAAA;AAElC,OAAO,EACN,YAAY,EACZ,UAAU,EAEV,iBAAiB,EAIjB,aAAa,EACb,eAAe,EACf,cAAc,EACd,MAAM,UAAU,CAAA;AA0CjB;;;;;GAKG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAA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