pushwork 1.0.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.
- package/README.md +460 -0
- package/dist/browser/browser-sync-engine.d.ts +64 -0
- package/dist/browser/browser-sync-engine.d.ts.map +1 -0
- package/dist/browser/browser-sync-engine.js +303 -0
- package/dist/browser/browser-sync-engine.js.map +1 -0
- package/dist/browser/filesystem-adapter.d.ts +84 -0
- package/dist/browser/filesystem-adapter.d.ts.map +1 -0
- package/dist/browser/filesystem-adapter.js +413 -0
- package/dist/browser/filesystem-adapter.js.map +1 -0
- package/dist/browser/index.d.ts +36 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +90 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/types.d.ts +70 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +6 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/cli/commands.d.ts +71 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +794 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +199 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/index.d.ts +71 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +314 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/change-detection.d.ts +78 -0
- package/dist/core/change-detection.d.ts.map +1 -0
- package/dist/core/change-detection.js +370 -0
- package/dist/core/change-detection.js.map +1 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/isomorphic-snapshot.d.ts +58 -0
- package/dist/core/isomorphic-snapshot.d.ts.map +1 -0
- package/dist/core/isomorphic-snapshot.js +204 -0
- package/dist/core/isomorphic-snapshot.js.map +1 -0
- package/dist/core/move-detection.d.ts +72 -0
- package/dist/core/move-detection.d.ts.map +1 -0
- package/dist/core/move-detection.js +200 -0
- package/dist/core/move-detection.js.map +1 -0
- package/dist/core/snapshot.d.ts +109 -0
- package/dist/core/snapshot.d.ts.map +1 -0
- package/dist/core/snapshot.js +263 -0
- package/dist/core/snapshot.js.map +1 -0
- package/dist/core/sync-engine.d.ts +110 -0
- package/dist/core/sync-engine.d.ts.map +1 -0
- package/dist/core/sync-engine.js +817 -0
- package/dist/core/sync-engine.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/platform/browser-filesystem.d.ts +26 -0
- package/dist/platform/browser-filesystem.d.ts.map +1 -0
- package/dist/platform/browser-filesystem.js +91 -0
- package/dist/platform/browser-filesystem.js.map +1 -0
- package/dist/platform/filesystem.d.ts +29 -0
- package/dist/platform/filesystem.d.ts.map +1 -0
- package/dist/platform/filesystem.js +65 -0
- package/dist/platform/filesystem.js.map +1 -0
- package/dist/platform/node-filesystem.d.ts +21 -0
- package/dist/platform/node-filesystem.d.ts.map +1 -0
- package/dist/platform/node-filesystem.js +93 -0
- package/dist/platform/node-filesystem.js.map +1 -0
- package/dist/types/config.d.ts +119 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/documents.d.ts +70 -0
- package/dist/types/documents.d.ts.map +1 -0
- package/dist/types/documents.js +23 -0
- package/dist/types/documents.js.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +23 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/snapshot.d.ts +81 -0
- package/dist/types/snapshot.d.ts.map +1 -0
- package/dist/types/snapshot.js +17 -0
- package/dist/types/snapshot.js.map +1 -0
- package/dist/utils/content-similarity.d.ts +53 -0
- package/dist/utils/content-similarity.d.ts.map +1 -0
- package/dist/utils/content-similarity.js +155 -0
- package/dist/utils/content-similarity.js.map +1 -0
- package/dist/utils/content.d.ts +5 -0
- package/dist/utils/content.d.ts.map +1 -0
- package/dist/utils/content.js +30 -0
- package/dist/utils/content.js.map +1 -0
- package/dist/utils/fs-browser.d.ts +57 -0
- package/dist/utils/fs-browser.d.ts.map +1 -0
- package/dist/utils/fs-browser.js +311 -0
- package/dist/utils/fs-browser.js.map +1 -0
- package/dist/utils/fs-node.d.ts +53 -0
- package/dist/utils/fs-node.d.ts.map +1 -0
- package/dist/utils/fs-node.js +220 -0
- package/dist/utils/fs-node.js.map +1 -0
- package/dist/utils/fs.d.ts +62 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +293 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/isomorphic.d.ts +29 -0
- package/dist/utils/isomorphic.d.ts.map +1 -0
- package/dist/utils/isomorphic.js +139 -0
- package/dist/utils/isomorphic.js.map +1 -0
- package/dist/utils/mime-types.d.ts +13 -0
- package/dist/utils/mime-types.d.ts.map +1 -0
- package/dist/utils/mime-types.js +240 -0
- package/dist/utils/mime-types.js.map +1 -0
- package/dist/utils/network-sync.d.ts +12 -0
- package/dist/utils/network-sync.d.ts.map +1 -0
- package/dist/utils/network-sync.js +149 -0
- package/dist/utils/network-sync.js.map +1 -0
- package/dist/utils/pure.d.ts +25 -0
- package/dist/utils/pure.d.ts.map +1 -0
- package/dist/utils/pure.js +112 -0
- package/dist/utils/pure.js.map +1 -0
- package/dist/utils/repo-factory.d.ts +11 -0
- package/dist/utils/repo-factory.d.ts.map +1 -0
- package/dist/utils/repo-factory.js +77 -0
- package/dist/utils/repo-factory.js.map +1 -0
- package/package.json +83 -0
- package/src/cli/commands.ts +1053 -0
- package/src/cli/index.ts +2 -0
- package/src/cli.ts +287 -0
- package/src/config/index.ts +334 -0
- package/src/core/change-detection.ts +484 -0
- package/src/core/index.ts +5 -0
- package/src/core/move-detection.ts +269 -0
- package/src/core/snapshot.ts +285 -0
- package/src/core/sync-engine.ts +1167 -0
- package/src/index.ts +14 -0
- package/src/types/config.ts +130 -0
- package/src/types/documents.ts +72 -0
- package/src/types/index.ts +8 -0
- package/src/types/snapshot.ts +88 -0
- package/src/utils/content-similarity.ts +194 -0
- package/src/utils/content.ts +28 -0
- package/src/utils/fs.ts +289 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/mime-types.ts +236 -0
- package/src/utils/network-sync.ts +153 -0
- package/src/utils/repo-factory.ts +58 -0
- package/test/README-TESTING-GAPS.md +174 -0
- package/test/integration/README.md +328 -0
- package/test/integration/clone-test.sh +310 -0
- package/test/integration/conflict-resolution-test.sh +309 -0
- package/test/integration/deletion-behavior-test.sh +487 -0
- package/test/integration/deletion-sync-test-simple.sh +193 -0
- package/test/integration/deletion-sync-test.sh +297 -0
- package/test/integration/exclude-patterns.test.ts +152 -0
- package/test/integration/full-integration-test.sh +363 -0
- package/test/integration/sync-deletion.test.ts +339 -0
- package/test/integration/sync-flow.test.ts +309 -0
- package/test/run-tests.sh +225 -0
- package/test/unit/content-similarity.test.ts +236 -0
- package/test/unit/deletion-behavior.test.ts +260 -0
- package/test/unit/enhanced-mime-detection.test.ts +266 -0
- package/test/unit/snapshot.test.ts +431 -0
- package/test/unit/sync-timing.test.ts +178 -0
- package/test/unit/utils.test.ts +368 -0
- package/tools/browser-sync/README.md +116 -0
- package/tools/browser-sync/package.json +44 -0
- package/tools/browser-sync/patchwork.json +1 -0
- package/tools/browser-sync/pnpm-lock.yaml +4202 -0
- package/tools/browser-sync/src/components/BrowserSyncTool.tsx +599 -0
- package/tools/browser-sync/src/index.ts +20 -0
- package/tools/browser-sync/src/polyfills.ts +31 -0
- package/tools/browser-sync/src/styles.css +290 -0
- package/tools/browser-sync/src/types.ts +27 -0
- package/tools/browser-sync/vite.config.ts +25 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,263 @@
|
|
|
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
|
+
/**
|
|
44
|
+
* Manages sync snapshots for local state tracking
|
|
45
|
+
*/
|
|
46
|
+
class SnapshotManager {
|
|
47
|
+
constructor(rootPath) {
|
|
48
|
+
this.rootPath = rootPath;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get path to sync tool directory
|
|
52
|
+
*/
|
|
53
|
+
getSyncToolDir() {
|
|
54
|
+
return path.join(this.rootPath, SnapshotManager.SYNC_TOOL_DIR);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get path to snapshot file
|
|
58
|
+
*/
|
|
59
|
+
getSnapshotPath() {
|
|
60
|
+
return path.join(this.getSyncToolDir(), SnapshotManager.SNAPSHOT_FILENAME);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if snapshot exists
|
|
64
|
+
*/
|
|
65
|
+
async exists() {
|
|
66
|
+
return await (0, utils_1.pathExists)(this.getSnapshotPath());
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Load snapshot from disk
|
|
70
|
+
*/
|
|
71
|
+
async load() {
|
|
72
|
+
try {
|
|
73
|
+
const snapshotPath = this.getSnapshotPath();
|
|
74
|
+
if (!(await (0, utils_1.pathExists)(snapshotPath))) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const content = await fs.readFile(snapshotPath, "utf8");
|
|
78
|
+
const serializable = JSON.parse(content);
|
|
79
|
+
return this.deserializeSnapshot(serializable);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.warn(`Failed to load snapshot: ${error}`);
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Save snapshot to disk
|
|
88
|
+
*/
|
|
89
|
+
async save(snapshot) {
|
|
90
|
+
try {
|
|
91
|
+
await (0, utils_1.ensureDirectoryExists)(this.getSyncToolDir());
|
|
92
|
+
const serializable = this.serializeSnapshot(snapshot);
|
|
93
|
+
const content = JSON.stringify(serializable, null, 2);
|
|
94
|
+
await fs.writeFile(this.getSnapshotPath(), content, "utf8");
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
throw new Error(`Failed to save snapshot: ${error}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create empty snapshot
|
|
102
|
+
*/
|
|
103
|
+
createEmpty() {
|
|
104
|
+
return {
|
|
105
|
+
timestamp: Date.now(),
|
|
106
|
+
rootPath: this.rootPath,
|
|
107
|
+
rootDirectoryUrl: undefined,
|
|
108
|
+
files: new Map(),
|
|
109
|
+
directories: new Map(),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Update file entry in snapshot
|
|
114
|
+
*/
|
|
115
|
+
updateFileEntry(snapshot, relativePath, entry) {
|
|
116
|
+
snapshot.files.set(relativePath, entry);
|
|
117
|
+
snapshot.timestamp = Date.now();
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Update directory entry in snapshot
|
|
121
|
+
*/
|
|
122
|
+
updateDirectoryEntry(snapshot, relativePath, entry) {
|
|
123
|
+
snapshot.directories.set(relativePath, entry);
|
|
124
|
+
snapshot.timestamp = Date.now();
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Remove file entry from snapshot
|
|
128
|
+
*/
|
|
129
|
+
removeFileEntry(snapshot, relativePath) {
|
|
130
|
+
snapshot.files.delete(relativePath);
|
|
131
|
+
snapshot.timestamp = Date.now();
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Remove directory entry from snapshot
|
|
135
|
+
*/
|
|
136
|
+
removeDirectoryEntry(snapshot, relativePath) {
|
|
137
|
+
snapshot.directories.delete(relativePath);
|
|
138
|
+
snapshot.timestamp = Date.now();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get all file paths in snapshot
|
|
142
|
+
*/
|
|
143
|
+
getFilePaths(snapshot) {
|
|
144
|
+
return Array.from(snapshot.files.keys());
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get all directory paths in snapshot
|
|
148
|
+
*/
|
|
149
|
+
getDirectoryPaths(snapshot) {
|
|
150
|
+
return Array.from(snapshot.directories.keys());
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get file entry by path
|
|
154
|
+
*/
|
|
155
|
+
getFileEntry(snapshot, relativePath) {
|
|
156
|
+
return snapshot.files.get(relativePath);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get directory entry by path
|
|
160
|
+
*/
|
|
161
|
+
getDirectoryEntry(snapshot, relativePath) {
|
|
162
|
+
return snapshot.directories.get(relativePath);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Check if path is tracked in snapshot
|
|
166
|
+
*/
|
|
167
|
+
isTracked(snapshot, relativePath) {
|
|
168
|
+
return (snapshot.files.has(relativePath) || snapshot.directories.has(relativePath));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get snapshot statistics
|
|
172
|
+
*/
|
|
173
|
+
getStats(snapshot) {
|
|
174
|
+
return {
|
|
175
|
+
files: snapshot.files.size,
|
|
176
|
+
directories: snapshot.directories.size,
|
|
177
|
+
timestamp: new Date(snapshot.timestamp),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Backup current snapshot
|
|
182
|
+
*/
|
|
183
|
+
async backup() {
|
|
184
|
+
const snapshotPath = this.getSnapshotPath();
|
|
185
|
+
if (await (0, utils_1.pathExists)(snapshotPath)) {
|
|
186
|
+
const backupPath = `${snapshotPath}.backup.${Date.now()}`;
|
|
187
|
+
await fs.copyFile(snapshotPath, backupPath);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Validate snapshot integrity
|
|
192
|
+
*/
|
|
193
|
+
validate(snapshot) {
|
|
194
|
+
const errors = [];
|
|
195
|
+
if (!snapshot.timestamp || snapshot.timestamp <= 0) {
|
|
196
|
+
errors.push("Invalid timestamp");
|
|
197
|
+
}
|
|
198
|
+
if (!snapshot.rootPath) {
|
|
199
|
+
errors.push("Missing root path");
|
|
200
|
+
}
|
|
201
|
+
if (!snapshot.files || !snapshot.directories) {
|
|
202
|
+
errors.push("Missing files or directories map");
|
|
203
|
+
}
|
|
204
|
+
// Check for path conflicts (file and directory with same path)
|
|
205
|
+
for (const filePath of snapshot.files.keys()) {
|
|
206
|
+
if (snapshot.directories.has(filePath)) {
|
|
207
|
+
errors.push(`Path conflict: ${filePath} exists as both file and directory`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
valid: errors.length === 0,
|
|
212
|
+
errors,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Convert snapshot to serializable format
|
|
217
|
+
*/
|
|
218
|
+
serializeSnapshot(snapshot) {
|
|
219
|
+
return {
|
|
220
|
+
timestamp: snapshot.timestamp,
|
|
221
|
+
rootPath: snapshot.rootPath,
|
|
222
|
+
rootDirectoryUrl: snapshot.rootDirectoryUrl,
|
|
223
|
+
files: Array.from(snapshot.files.entries()),
|
|
224
|
+
directories: Array.from(snapshot.directories.entries()),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Convert serializable format back to snapshot
|
|
229
|
+
*/
|
|
230
|
+
deserializeSnapshot(serializable) {
|
|
231
|
+
return {
|
|
232
|
+
timestamp: serializable.timestamp,
|
|
233
|
+
rootPath: serializable.rootPath,
|
|
234
|
+
rootDirectoryUrl: serializable.rootDirectoryUrl,
|
|
235
|
+
files: new Map(serializable.files),
|
|
236
|
+
directories: new Map(serializable.directories),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Clear all snapshot data
|
|
241
|
+
*/
|
|
242
|
+
clear(snapshot) {
|
|
243
|
+
snapshot.files.clear();
|
|
244
|
+
snapshot.directories.clear();
|
|
245
|
+
snapshot.timestamp = Date.now();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Clone snapshot for safe manipulation
|
|
249
|
+
*/
|
|
250
|
+
clone(snapshot) {
|
|
251
|
+
return {
|
|
252
|
+
timestamp: snapshot.timestamp,
|
|
253
|
+
rootPath: snapshot.rootPath,
|
|
254
|
+
rootDirectoryUrl: snapshot.rootDirectoryUrl,
|
|
255
|
+
files: new Map(snapshot.files),
|
|
256
|
+
directories: new Map(snapshot.directories),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.SnapshotManager = SnapshotManager;
|
|
261
|
+
SnapshotManager.SNAPSHOT_FILENAME = "snapshot.json";
|
|
262
|
+
SnapshotManager.SYNC_TOOL_DIR = ".pushwork";
|
|
263
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/core/snapshot.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAkC;AAClC,2CAA6B;AAO7B,oCAA6D;AAE7D;;GAEG;AACH,MAAa,eAAe;IAI1B,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAExC;;OAEG;IACK,cAAc;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACK,eAAe;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC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Y,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;;AA1QH,0CA2QC;AA1QyB,iCAAiB,GAAG,eAAe,CAAC;AACpC,6BAAa,GAAG,WAAW,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { AutomergeUrl, Repo } from "@automerge/automerge-repo";
|
|
2
|
+
import { SyncSnapshot, SyncResult, MoveCandidate } from "../types";
|
|
3
|
+
import { DetectedChange } from "./change-detection";
|
|
4
|
+
/**
|
|
5
|
+
* Bidirectional sync engine implementing two-phase sync
|
|
6
|
+
*/
|
|
7
|
+
export declare class SyncEngine {
|
|
8
|
+
private repo;
|
|
9
|
+
private rootPath;
|
|
10
|
+
private snapshotManager;
|
|
11
|
+
private changeDetector;
|
|
12
|
+
private moveDetector;
|
|
13
|
+
private networkSyncEnabled;
|
|
14
|
+
private handlesToWaitOn;
|
|
15
|
+
private syncServerStorageId?;
|
|
16
|
+
constructor(repo: Repo, rootPath: string, excludePatterns?: string[], networkSyncEnabled?: boolean, syncServerStorageId?: string);
|
|
17
|
+
/**
|
|
18
|
+
* Determine if content should be treated as text for Automerge text operations
|
|
19
|
+
* Note: This method checks the runtime type. File type detection happens
|
|
20
|
+
* during reading with isEnhancedTextFile() which now has better dev file support.
|
|
21
|
+
*/
|
|
22
|
+
private isTextContent;
|
|
23
|
+
/**
|
|
24
|
+
* Set the root directory URL in the snapshot
|
|
25
|
+
*/
|
|
26
|
+
setRootDirectoryUrl(url: AutomergeUrl): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Commit local changes only (no network sync)
|
|
29
|
+
*/
|
|
30
|
+
commitLocal(dryRun?: boolean): Promise<SyncResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Run full bidirectional sync
|
|
33
|
+
*/
|
|
34
|
+
sync(dryRun?: boolean): Promise<SyncResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Phase 1: Push local changes to Automerge documents
|
|
37
|
+
*/
|
|
38
|
+
private pushLocalChanges;
|
|
39
|
+
/**
|
|
40
|
+
* Phase 2: Pull remote changes to local filesystem
|
|
41
|
+
*/
|
|
42
|
+
private pullRemoteChanges;
|
|
43
|
+
/**
|
|
44
|
+
* Apply local file change to remote Automerge document
|
|
45
|
+
*/
|
|
46
|
+
private applyLocalChangeToRemote;
|
|
47
|
+
/**
|
|
48
|
+
* Apply remote change to local filesystem
|
|
49
|
+
*/
|
|
50
|
+
private applyRemoteChangeToLocal;
|
|
51
|
+
/**
|
|
52
|
+
* Apply move to remote documents
|
|
53
|
+
*/
|
|
54
|
+
private applyMoveToRemote;
|
|
55
|
+
/**
|
|
56
|
+
* Create new remote file document
|
|
57
|
+
*/
|
|
58
|
+
private createRemoteFile;
|
|
59
|
+
/**
|
|
60
|
+
* Update existing remote file document
|
|
61
|
+
*/
|
|
62
|
+
private updateRemoteFile;
|
|
63
|
+
/**
|
|
64
|
+
* Delete remote file document
|
|
65
|
+
*/
|
|
66
|
+
private deleteRemoteFile;
|
|
67
|
+
/**
|
|
68
|
+
* Add file entry to appropriate directory document (maintains hierarchy)
|
|
69
|
+
*/
|
|
70
|
+
private addFileToDirectory;
|
|
71
|
+
/**
|
|
72
|
+
* Ensure directory document exists for the given path, creating hierarchy as needed
|
|
73
|
+
* First checks for existing shared directories before creating new ones
|
|
74
|
+
*/
|
|
75
|
+
private ensureDirectoryDocument;
|
|
76
|
+
/**
|
|
77
|
+
* Remove file entry from directory document
|
|
78
|
+
*/
|
|
79
|
+
private removeFileFromDirectory;
|
|
80
|
+
/**
|
|
81
|
+
* Find a file in the directory hierarchy by path
|
|
82
|
+
*/
|
|
83
|
+
private findFileInDirectoryHierarchy;
|
|
84
|
+
/**
|
|
85
|
+
* Sort changes by dependency order
|
|
86
|
+
*/
|
|
87
|
+
private sortChangesByDependency;
|
|
88
|
+
/**
|
|
89
|
+
* Get sync status
|
|
90
|
+
*/
|
|
91
|
+
getStatus(): Promise<{
|
|
92
|
+
snapshot: SyncSnapshot | null;
|
|
93
|
+
hasChanges: boolean;
|
|
94
|
+
changeCount: number;
|
|
95
|
+
lastSync: Date | null;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Preview changes without applying them
|
|
99
|
+
*/
|
|
100
|
+
previewChanges(): Promise<{
|
|
101
|
+
changes: DetectedChange[];
|
|
102
|
+
moves: MoveCandidate[];
|
|
103
|
+
summary: string;
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Generate human-readable summary of changes
|
|
107
|
+
*/
|
|
108
|
+
private generateChangeSummary;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=sync-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-engine.d.ts","sourceRoot":"","sources":["../../src/core/sync-engine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,IAAI,EAIL,MAAM,2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