pushwork 1.2.3 → 1.2.4
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/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 +6 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +114 -4
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/output.d.ts +75 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +182 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/config/remote-manager.d.ts +65 -0
- package/dist/config/remote-manager.d.ts.map +1 -0
- package/dist/config/remote-manager.js +243 -0
- package/dist/config/remote-manager.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +83 -0
- package/dist/config.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/fs-tree.d.ts +6 -0
- package/dist/fs-tree.d.ts.map +1 -0
- package/dist/fs-tree.js +99 -0
- package/dist/fs-tree.js.map +1 -0
- package/dist/ignore.d.ts +6 -0
- package/dist/ignore.d.ts.map +1 -0
- package/dist/ignore.js +74 -0
- package/dist/ignore.js.map +1 -0
- package/dist/log.d.ts +3 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +14 -0
- package/dist/log.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/polyfill-node-window.d.ts +13 -0
- package/dist/polyfill-node-window.d.ts.map +1 -0
- package/dist/polyfill-node-window.js +17 -0
- package/dist/polyfill-node-window.js.map +1 -0
- package/dist/pushwork.d.ts +97 -0
- package/dist/pushwork.d.ts.map +1 -0
- package/dist/pushwork.js +726 -0
- package/dist/pushwork.js.map +1 -0
- package/dist/repo.d.ts +14 -0
- package/dist/repo.d.ts.map +1 -0
- package/dist/repo.js +60 -0
- package/dist/repo.js.map +1 -0
- package/dist/shapes/custom.d.ts +3 -0
- package/dist/shapes/custom.d.ts.map +1 -0
- package/dist/shapes/custom.js +57 -0
- package/dist/shapes/custom.js.map +1 -0
- package/dist/shapes/file.d.ts +20 -0
- package/dist/shapes/file.d.ts.map +1 -0
- package/dist/shapes/file.js +140 -0
- package/dist/shapes/file.js.map +1 -0
- package/dist/shapes/index.d.ts +10 -0
- package/dist/shapes/index.d.ts.map +1 -0
- package/dist/shapes/index.js +35 -0
- package/dist/shapes/index.js.map +1 -0
- package/dist/shapes/patchwork-folder.d.ts +3 -0
- package/dist/shapes/patchwork-folder.d.ts.map +1 -0
- package/dist/shapes/patchwork-folder.js +160 -0
- package/dist/shapes/patchwork-folder.js.map +1 -0
- package/dist/shapes/types.d.ts +38 -0
- package/dist/shapes/types.d.ts.map +1 -0
- package/dist/shapes/types.js +52 -0
- package/dist/shapes/types.js.map +1 -0
- package/dist/shapes/vfs.d.ts +3 -0
- package/dist/shapes/vfs.d.ts.map +1 -0
- package/dist/shapes/vfs.js +92 -0
- package/dist/shapes/vfs.js.map +1 -0
- package/dist/snarf.d.ts +21 -0
- package/dist/snarf.d.ts.map +1 -0
- package/dist/snarf.js +117 -0
- package/dist/snarf.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/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/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.map +1 -1
- package/dist/utils/repo-factory.js +0 -1
- package/dist/utils/repo-factory.js.map +1 -1
- package/dist/version.d.ts +11 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +93 -0
- package/dist/version.js.map +1 -0
- package/package.json +5 -5
- package/src/utils/repo-factory.ts +78 -85
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-manager.d.ts","sourceRoot":"","sources":["../../src/config/remote-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAmB,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxC;;GAEG;AACH,qBAAa,aAAa;IAItB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa;IAJvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAa;gBAGtC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa;IAGtC;;OAEG;IACH,OAAO,CAAC,aAAa;IAIrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAIpB;;OAEG;IACH,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIjD;;OAEG;IACH,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;IAIlD;;OAEG;IACG,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCpD;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6BrD;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAS5C;;OAEG;IACG,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IASjE;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAStD;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKpD;;OAEG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBrD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAKpC;;;OAGG;IACG,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC;CAkE9C"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.RemoteManager = void 0;
|
|
37
|
+
const fs = __importStar(require("fs/promises"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const utils_1 = require("../utils");
|
|
40
|
+
/**
|
|
41
|
+
* Manages multiple remotes for a pushwork directory
|
|
42
|
+
*/
|
|
43
|
+
class RemoteManager {
|
|
44
|
+
constructor(workingDir, configManager) {
|
|
45
|
+
this.workingDir = workingDir;
|
|
46
|
+
this.configManager = configManager;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get path to remotes directory
|
|
50
|
+
*/
|
|
51
|
+
getRemotesDir() {
|
|
52
|
+
return path.join(this.workingDir, ".pushwork", RemoteManager.REMOTES_DIR);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get path to a specific remote's directory
|
|
56
|
+
*/
|
|
57
|
+
getRemoteDir(remoteName) {
|
|
58
|
+
return path.join(this.getRemotesDir(), remoteName);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get path to a remote's snapshot file
|
|
62
|
+
*/
|
|
63
|
+
getRemoteSnapshotPath(remoteName) {
|
|
64
|
+
return path.join(this.getRemoteDir(remoteName), "snapshot.json");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get path to a remote's automerge storage
|
|
68
|
+
*/
|
|
69
|
+
getRemoteAutomergePath(remoteName) {
|
|
70
|
+
return path.join(this.getRemoteDir(remoteName), "automerge");
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Add a new remote
|
|
74
|
+
*/
|
|
75
|
+
async addRemote(remote) {
|
|
76
|
+
const config = await this.configManager.load();
|
|
77
|
+
if (!config) {
|
|
78
|
+
throw new Error("No configuration found. Run 'pushwork init' first.");
|
|
79
|
+
}
|
|
80
|
+
// Initialize remotes object if it doesn't exist
|
|
81
|
+
if (!config.remotes) {
|
|
82
|
+
config.remotes = {};
|
|
83
|
+
}
|
|
84
|
+
// Check if remote already exists
|
|
85
|
+
if (config.remotes[remote.name]) {
|
|
86
|
+
throw new Error(`Remote '${remote.name}' already exists.`);
|
|
87
|
+
}
|
|
88
|
+
// Add the remote
|
|
89
|
+
config.remotes[remote.name] = remote;
|
|
90
|
+
// Set as current remote if it's the first one
|
|
91
|
+
if (!config.current_remote) {
|
|
92
|
+
config.current_remote = remote.name;
|
|
93
|
+
}
|
|
94
|
+
// Create remote directory structure
|
|
95
|
+
const remoteDir = this.getRemoteDir(remote.name);
|
|
96
|
+
await (0, utils_1.ensureDirectoryExists)(remoteDir);
|
|
97
|
+
await (0, utils_1.ensureDirectoryExists)(this.getRemoteAutomergePath(remote.name));
|
|
98
|
+
// Save updated config
|
|
99
|
+
await this.configManager.save(config);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Remove a remote
|
|
103
|
+
*/
|
|
104
|
+
async removeRemote(remoteName) {
|
|
105
|
+
const config = await this.configManager.load();
|
|
106
|
+
if (!config || !config.remotes) {
|
|
107
|
+
throw new Error("No remotes configured.");
|
|
108
|
+
}
|
|
109
|
+
if (!config.remotes[remoteName]) {
|
|
110
|
+
throw new Error(`Remote '${remoteName}' does not exist.`);
|
|
111
|
+
}
|
|
112
|
+
// Can't remove current remote without switching first
|
|
113
|
+
if (config.current_remote === remoteName) {
|
|
114
|
+
throw new Error(`Cannot remove current remote '${remoteName}'. Switch to another remote first.`);
|
|
115
|
+
}
|
|
116
|
+
// Remove remote from config
|
|
117
|
+
delete config.remotes[remoteName];
|
|
118
|
+
// Remove remote directory
|
|
119
|
+
const remoteDir = this.getRemoteDir(remoteName);
|
|
120
|
+
if (await (0, utils_1.pathExists)(remoteDir)) {
|
|
121
|
+
await fs.rm(remoteDir, { recursive: true, force: true });
|
|
122
|
+
}
|
|
123
|
+
await this.configManager.save(config);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* List all remotes
|
|
127
|
+
*/
|
|
128
|
+
async listRemotes() {
|
|
129
|
+
const config = await this.configManager.load();
|
|
130
|
+
if (!config || !config.remotes) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
return Object.values(config.remotes);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Get a specific remote by name
|
|
137
|
+
*/
|
|
138
|
+
async getRemote(remoteName) {
|
|
139
|
+
const config = await this.configManager.load();
|
|
140
|
+
if (!config || !config.remotes) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return config.remotes[remoteName] || null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get current remote
|
|
147
|
+
*/
|
|
148
|
+
async getCurrentRemote() {
|
|
149
|
+
const config = await this.configManager.load();
|
|
150
|
+
if (!config || !config.current_remote || !config.remotes) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return config.remotes[config.current_remote] || null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get current remote name
|
|
157
|
+
*/
|
|
158
|
+
async getCurrentRemoteName() {
|
|
159
|
+
const config = await this.configManager.load();
|
|
160
|
+
return config?.current_remote || null;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Switch to a different remote
|
|
164
|
+
*/
|
|
165
|
+
async switchRemote(remoteName) {
|
|
166
|
+
const config = await this.configManager.load();
|
|
167
|
+
if (!config) {
|
|
168
|
+
throw new Error("No configuration found.");
|
|
169
|
+
}
|
|
170
|
+
if (!config.remotes || !config.remotes[remoteName]) {
|
|
171
|
+
throw new Error(`Remote '${remoteName}' does not exist.`);
|
|
172
|
+
}
|
|
173
|
+
// Ensure remote directory exists
|
|
174
|
+
const remoteDir = this.getRemoteDir(remoteName);
|
|
175
|
+
await (0, utils_1.ensureDirectoryExists)(remoteDir);
|
|
176
|
+
await (0, utils_1.ensureDirectoryExists)(this.getRemoteAutomergePath(remoteName));
|
|
177
|
+
// Update current remote
|
|
178
|
+
config.current_remote = remoteName;
|
|
179
|
+
await this.configManager.save(config);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check if remotes are configured
|
|
183
|
+
*/
|
|
184
|
+
async hasRemotes() {
|
|
185
|
+
const config = await this.configManager.load();
|
|
186
|
+
return !!(config?.remotes && Object.keys(config.remotes).length > 0);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Migrate legacy single-remote setup to new multi-remote format
|
|
190
|
+
* This converts the old root_directory_url to an "origin" remote
|
|
191
|
+
*/
|
|
192
|
+
async migrateLegacyConfig() {
|
|
193
|
+
const config = await this.configManager.load();
|
|
194
|
+
if (!config) {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
// Check if migration is needed
|
|
198
|
+
if (config.remotes && Object.keys(config.remotes).length > 0) {
|
|
199
|
+
return false; // Already migrated
|
|
200
|
+
}
|
|
201
|
+
if (!config.root_directory_url) {
|
|
202
|
+
return false; // Nothing to migrate
|
|
203
|
+
}
|
|
204
|
+
// Create origin remote from legacy config
|
|
205
|
+
const originRemote = {
|
|
206
|
+
name: "origin",
|
|
207
|
+
rootFolderUrl: config.root_directory_url,
|
|
208
|
+
syncServer: config.sync_server,
|
|
209
|
+
syncServerStorageId: config.sync_server_storage_id,
|
|
210
|
+
};
|
|
211
|
+
// Initialize remotes
|
|
212
|
+
config.remotes = {
|
|
213
|
+
origin: originRemote,
|
|
214
|
+
};
|
|
215
|
+
config.current_remote = "origin";
|
|
216
|
+
// Migrate legacy snapshot and automerge data to origin remote
|
|
217
|
+
const legacySnapshotPath = path.join(this.workingDir, ".pushwork", "snapshot.json");
|
|
218
|
+
const legacyAutomergePath = path.join(this.workingDir, ".pushwork", "automerge");
|
|
219
|
+
// Create origin remote directory
|
|
220
|
+
const originDir = this.getRemoteDir("origin");
|
|
221
|
+
await (0, utils_1.ensureDirectoryExists)(originDir);
|
|
222
|
+
// Move snapshot if it exists
|
|
223
|
+
if (await (0, utils_1.pathExists)(legacySnapshotPath)) {
|
|
224
|
+
const newSnapshotPath = this.getRemoteSnapshotPath("origin");
|
|
225
|
+
await fs.rename(legacySnapshotPath, newSnapshotPath);
|
|
226
|
+
}
|
|
227
|
+
// Move automerge data if it exists
|
|
228
|
+
if (await (0, utils_1.pathExists)(legacyAutomergePath)) {
|
|
229
|
+
const newAutomergePath = this.getRemoteAutomergePath("origin");
|
|
230
|
+
// Remove new path if it exists (shouldn't happen but be safe)
|
|
231
|
+
if (await (0, utils_1.pathExists)(newAutomergePath)) {
|
|
232
|
+
await fs.rm(newAutomergePath, { recursive: true, force: true });
|
|
233
|
+
}
|
|
234
|
+
await fs.rename(legacyAutomergePath, newAutomergePath);
|
|
235
|
+
}
|
|
236
|
+
// Save migrated config
|
|
237
|
+
await this.configManager.save(config);
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.RemoteManager = RemoteManager;
|
|
242
|
+
RemoteManager.REMOTES_DIR = "remotes";
|
|
243
|
+
//# sourceMappingURL=remote-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-manager.js","sourceRoot":"","sources":["../../src/config/remote-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,2CAA6B;AAG7B,oCAA6D;AAE7D;;GAEG;AACH,MAAa,aAAa;IAGxB,YACU,UAAkB,EAClB,aAA4B;QAD5B,eAAU,GAAV,UAAU,CAAQ;QAClB,kBAAa,GAAb,aAAa,CAAe;IACnC,CAAC;IAEJ;;OAEG;IACK,aAAa;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,UAAkB;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,qBAAqB,CAAC,UAAkB;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,eAAe,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,UAAkB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAAS,CA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"subduction";
|
|
3
|
+
export declare const CONFIG_VERSION = 4;
|
|
4
|
+
export interface PushworkConfig {
|
|
5
|
+
version: typeof CONFIG_VERSION;
|
|
6
|
+
rootUrl: AutomergeUrl;
|
|
7
|
+
backend: Backend;
|
|
8
|
+
shape: string;
|
|
9
|
+
artifactDirectories: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const pushworkDir: (root: string) => string;
|
|
12
|
+
export declare const storageDir: (root: string) => string;
|
|
13
|
+
export declare function readConfig(root: string): Promise<PushworkConfig>;
|
|
14
|
+
export declare function writeConfig(root: string, config: PushworkConfig): Promise<void>;
|
|
15
|
+
export declare function configExists(root: string): Promise<boolean>;
|
|
16
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE9C,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC,MAAM,WAAW,cAAc;IAC9B,OAAO,EAAE,OAAO,cAAc,CAAC;IAC/B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAMD,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,WAAyB,CAAC;AAClE,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,WAAkC,CAAC;AAE1E,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAkBtE;AAED,wBAAsB,WAAW,CAChC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,cAAc,GACpB,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.storageDir = exports.pushworkDir = exports.CONFIG_VERSION = void 0;
|
|
37
|
+
exports.readConfig = readConfig;
|
|
38
|
+
exports.writeConfig = writeConfig;
|
|
39
|
+
exports.configExists = configExists;
|
|
40
|
+
const fs = __importStar(require("fs/promises"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
exports.CONFIG_VERSION = 4;
|
|
43
|
+
const DIR = ".pushwork";
|
|
44
|
+
const CONFIG = "config.json";
|
|
45
|
+
const STORAGE = "storage";
|
|
46
|
+
const pushworkDir = (root) => path.join(root, DIR);
|
|
47
|
+
exports.pushworkDir = pushworkDir;
|
|
48
|
+
const storageDir = (root) => path.join(root, DIR, STORAGE);
|
|
49
|
+
exports.storageDir = storageDir;
|
|
50
|
+
async function readConfig(root) {
|
|
51
|
+
const text = await fs.readFile(path.join(root, DIR, CONFIG), "utf8");
|
|
52
|
+
const parsed = JSON.parse(text);
|
|
53
|
+
if (parsed.version !== exports.CONFIG_VERSION) {
|
|
54
|
+
throw new Error(`pushwork config version mismatch: expected ${exports.CONFIG_VERSION}, got ${parsed.version ?? "(missing)"}`);
|
|
55
|
+
}
|
|
56
|
+
if (!parsed.rootUrl)
|
|
57
|
+
throw new Error("pushwork config missing rootUrl");
|
|
58
|
+
if (!parsed.backend)
|
|
59
|
+
throw new Error("pushwork config missing backend");
|
|
60
|
+
if (!parsed.shape)
|
|
61
|
+
throw new Error("pushwork config missing shape");
|
|
62
|
+
return {
|
|
63
|
+
version: exports.CONFIG_VERSION,
|
|
64
|
+
rootUrl: parsed.rootUrl,
|
|
65
|
+
backend: parsed.backend,
|
|
66
|
+
shape: parsed.shape,
|
|
67
|
+
artifactDirectories: parsed.artifactDirectories ?? [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function writeConfig(root, config) {
|
|
71
|
+
await fs.mkdir(path.join(root, DIR), { recursive: true });
|
|
72
|
+
await fs.writeFile(path.join(root, DIR, CONFIG), JSON.stringify(config, null, 2) + "\n");
|
|
73
|
+
}
|
|
74
|
+
async function configExists(root) {
|
|
75
|
+
try {
|
|
76
|
+
await fs.access(path.join(root, DIR, CONFIG));
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,gCAkBC;AAED,kCASC;AAED,oCAOC;AA7DD,gDAAkC;AAClC,2CAA6B;AAKhB,QAAA,cAAc,GAAG,CAAC,CAAC;AAUhC,MAAM,GAAG,GAAG,WAAW,CAAC;AACxB,MAAM,MAAM,GAAG,aAAa,CAAC;AAC7B,MAAM,OAAO,GAAG,SAAS,CAAC;AAEnB,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAArD,QAAA,WAAW,eAA0C;AAC3D,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAA7D,QAAA,UAAU,cAAmD;AAEnE,KAAK,UAAU,UAAU,CAAC,IAAY;IAC5C,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA4B,CAAC;IAC3D,IAAI,MAAM,CAAC,OAAO,KAAK,sBAAc,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACd,8CAA8C,sBAAc,SAAS,MAAM,CAAC,OAAO,IAAI,WAAW,EAAE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ser
|
|
3
|
+
*/
|
|
4
|
+
import { SyncSnapshot, SnapshotFileEntry, SnapshotDirectoryEntry } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Platform-agnostic snapshot storage interface
|
|
7
|
+
*/
|
|
8
|
+
export interface SnapshotStorage {
|
|
9
|
+
save(snapshot: SyncSnapshot, key?: string): Promise<void>;
|
|
10
|
+
load(key?: string): Promise<SyncSnapshot | null>;
|
|
11
|
+
backup(key?: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* File-based snapshot storage (for Node.js and browser with file system access)
|
|
15
|
+
*/
|
|
16
|
+
export declare class FileSnapshotStorage implements SnapshotStorage {
|
|
17
|
+
private rootPath;
|
|
18
|
+
private static readonly SNAPSHOT_FILENAME;
|
|
19
|
+
private static readonly SYNC_TOOL_DIR;
|
|
20
|
+
constructor(rootPath: string);
|
|
21
|
+
private getSnapshotPath;
|
|
22
|
+
private getSyncToolDir;
|
|
23
|
+
save(snapshot: SyncSnapshot, key?: string): Promise<void>;
|
|
24
|
+
load(key?: string): Promise<SyncSnapshot | null>;
|
|
25
|
+
backup(key?: string): Promise<void>;
|
|
26
|
+
private toSerializable;
|
|
27
|
+
private fromSerializable;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* IndexedDB-based snapshot storage (for browser environments)
|
|
31
|
+
*/
|
|
32
|
+
export declare class IndexedDBSnapshotStorage implements SnapshotStorage {
|
|
33
|
+
private dbName;
|
|
34
|
+
private storeName;
|
|
35
|
+
private version;
|
|
36
|
+
save(snapshot: SyncSnapshot, key?: string): Promise<void>;
|
|
37
|
+
load(key?: string): Promise<SyncSnapshot | null>;
|
|
38
|
+
backup(key?: string): Promise<void>;
|
|
39
|
+
private openDB;
|
|
40
|
+
private toSerializable;
|
|
41
|
+
private fromSerializable;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Isomorphic snapshot manager that uses appropriate storage for the platform
|
|
45
|
+
*/
|
|
46
|
+
export declare class IsomorphicSnapshotManager {
|
|
47
|
+
private storage;
|
|
48
|
+
constructor(rootPath: string, useIndexedDB?: boolean);
|
|
49
|
+
save(snapshot: SyncSnapshot): Promise<void>;
|
|
50
|
+
load(): Promise<SyncSnapshot | null>;
|
|
51
|
+
backup(): Promise<void>;
|
|
52
|
+
createEmptySnapshot(rootPath: string): Promise<SyncSnapshot>;
|
|
53
|
+
updateFileEntry(snapshot: SyncSnapshot, relativePath: string, entry: SnapshotFileEntry): void;
|
|
54
|
+
updateDirectoryEntry(snapshot: SyncSnapshot, relativePath: string, entry: SnapshotDirectoryEntry): void;
|
|
55
|
+
removeFileEntry(snapshot: SyncSnapshot, relativePath: string): void;
|
|
56
|
+
createEmpty(): SyncSnapshot;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=isomorphic-snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isomorphic-snapshot.d.ts","sourceRoot":"","sources":["../../src/core/isomorphic-snapshot.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,YAAY,EAEZ,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAQlB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;GAEG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAI7C,OAAO,CAAC,QAAQ;IAH5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;IAC5D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAA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AiB,GACvB,IAAI;IAIP,oBAAoB,CAClB,QAAQ,EAAE,YAAY,EACtB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,sBAAsB,GAC5B,IAAI;IAIP,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAInE,WAAW,IAAI,YAAY;CAQ5B"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Isomorphic snapshot manager that works in both Node.js and browser
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IsomorphicSnapshotManager = exports.IndexedDBSnapshotStorage = exports.FileSnapshotStorage = void 0;
|
|
7
|
+
const isomorphic_1 = require("../utils/isomorphic");
|
|
8
|
+
/**
|
|
9
|
+
* File-based snapshot storage (for Node.js and browser with file system access)
|
|
10
|
+
*/
|
|
11
|
+
class FileSnapshotStorage {
|
|
12
|
+
constructor(rootPath) {
|
|
13
|
+
this.rootPath = rootPath;
|
|
14
|
+
}
|
|
15
|
+
getSnapshotPath(key = "current") {
|
|
16
|
+
return `${this.rootPath}/${FileSnapshotStorage.SYNC_TOOL_DIR}/${key}-${FileSnapshotStorage.SNAPSHOT_FILENAME}`;
|
|
17
|
+
}
|
|
18
|
+
getSyncToolDir() {
|
|
19
|
+
return `${this.rootPath}/${FileSnapshotStorage.SYNC_TOOL_DIR}`;
|
|
20
|
+
}
|
|
21
|
+
async save(snapshot, key = "current") {
|
|
22
|
+
await (0, isomorphic_1.ensureDirectoryExists)(this.getSyncToolDir());
|
|
23
|
+
const serializable = this.toSerializable(snapshot);
|
|
24
|
+
const content = JSON.stringify(serializable, null, 2);
|
|
25
|
+
await (0, isomorphic_1.writeFileContent)(this.getSnapshotPath(key), content);
|
|
26
|
+
}
|
|
27
|
+
async load(key = "current") {
|
|
28
|
+
const snapshotPath = this.getSnapshotPath(key);
|
|
29
|
+
if (!(await (0, isomorphic_1.pathExists)(snapshotPath))) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const content = await (0, isomorphic_1.readFileContent)(snapshotPath);
|
|
34
|
+
const contentStr = typeof content === "string"
|
|
35
|
+
? content
|
|
36
|
+
: new TextDecoder().decode(content);
|
|
37
|
+
const serializable = JSON.parse(contentStr);
|
|
38
|
+
return this.fromSerializable(serializable);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
throw new Error(`Failed to load snapshot from ${snapshotPath}: ${error}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async backup(key = "current") {
|
|
45
|
+
const snapshot = await this.load(key);
|
|
46
|
+
if (snapshot) {
|
|
47
|
+
const backupKey = `${key}-backup-${Date.now()}`;
|
|
48
|
+
await this.save(snapshot, backupKey);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
toSerializable(snapshot) {
|
|
52
|
+
return {
|
|
53
|
+
rootPath: snapshot.rootPath,
|
|
54
|
+
timestamp: new Date(snapshot.timestamp).toISOString(),
|
|
55
|
+
files: Array.from(snapshot.files.entries()),
|
|
56
|
+
directories: Array.from(snapshot.directories.entries()),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
fromSerializable(serializable) {
|
|
60
|
+
return {
|
|
61
|
+
rootPath: serializable.rootPath,
|
|
62
|
+
timestamp: new Date(serializable.timestamp).getTime(),
|
|
63
|
+
files: new Map(serializable.files),
|
|
64
|
+
directories: new Map(serializable.directories),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FileSnapshotStorage = FileSnapshotStorage;
|
|
69
|
+
FileSnapshotStorage.SNAPSHOT_FILENAME = "snapshot.json";
|
|
70
|
+
FileSnapshotStorage.SYNC_TOOL_DIR = ".pushwork";
|
|
71
|
+
/**
|
|
72
|
+
* IndexedDB-based snapshot storage (for browser environments)
|
|
73
|
+
*/
|
|
74
|
+
class IndexedDBSnapshotStorage {
|
|
75
|
+
constructor() {
|
|
76
|
+
this.dbName = "pushwork-snapshots";
|
|
77
|
+
this.storeName = "snapshots";
|
|
78
|
+
this.version = 1;
|
|
79
|
+
}
|
|
80
|
+
async save(snapshot, key = "current") {
|
|
81
|
+
const db = await this.openDB();
|
|
82
|
+
const transaction = db.transaction([this.storeName], "readwrite");
|
|
83
|
+
const store = transaction.objectStore(this.storeName);
|
|
84
|
+
const serializable = this.toSerializable(snapshot);
|
|
85
|
+
const putRequest = store.put({
|
|
86
|
+
key,
|
|
87
|
+
snapshot: JSON.stringify(serializable),
|
|
88
|
+
timestamp: Date.now(),
|
|
89
|
+
});
|
|
90
|
+
await new Promise((resolve, reject) => {
|
|
91
|
+
putRequest.onsuccess = () => resolve(undefined);
|
|
92
|
+
putRequest.onerror = () => reject(putRequest.error);
|
|
93
|
+
});
|
|
94
|
+
db.close();
|
|
95
|
+
}
|
|
96
|
+
async load(key = "current") {
|
|
97
|
+
try {
|
|
98
|
+
const db = await this.openDB();
|
|
99
|
+
const transaction = db.transaction([this.storeName], "readonly");
|
|
100
|
+
const store = transaction.objectStore(this.storeName);
|
|
101
|
+
const request = store.get(key);
|
|
102
|
+
const result = await new Promise((resolve, reject) => {
|
|
103
|
+
request.onsuccess = () => resolve(request.result);
|
|
104
|
+
request.onerror = () => reject(request.error);
|
|
105
|
+
});
|
|
106
|
+
db.close();
|
|
107
|
+
if (result) {
|
|
108
|
+
const serializable = JSON.parse(result.snapshot);
|
|
109
|
+
return this.fromSerializable(serializable);
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
console.warn("Failed to load snapshot from IndexedDB:", error);
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async backup(key = "current") {
|
|
119
|
+
const snapshot = await this.load(key);
|
|
120
|
+
if (snapshot) {
|
|
121
|
+
await this.save(snapshot, `${key}-backup-${Date.now()}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
async openDB() {
|
|
125
|
+
return new Promise((resolve, reject) => {
|
|
126
|
+
const request = indexedDB.open(this.dbName, this.version);
|
|
127
|
+
request.onerror = () => reject(request.error);
|
|
128
|
+
request.onsuccess = () => resolve(request.result);
|
|
129
|
+
request.onupgradeneeded = (event) => {
|
|
130
|
+
const db = event.target.result;
|
|
131
|
+
if (!db.objectStoreNames.contains(this.storeName)) {
|
|
132
|
+
db.createObjectStore(this.storeName, { keyPath: "key" });
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
toSerializable(snapshot) {
|
|
138
|
+
return {
|
|
139
|
+
rootPath: snapshot.rootPath,
|
|
140
|
+
timestamp: new Date(snapshot.timestamp).toISOString(),
|
|
141
|
+
files: Array.from(snapshot.files.entries()),
|
|
142
|
+
directories: Array.from(snapshot.directories.entries()),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
fromSerializable(serializable) {
|
|
146
|
+
return {
|
|
147
|
+
rootPath: serializable.rootPath,
|
|
148
|
+
timestamp: new Date(serializable.timestamp).getTime(),
|
|
149
|
+
files: new Map(serializable.files),
|
|
150
|
+
directories: new Map(serializable.directories),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.IndexedDBSnapshotStorage = IndexedDBSnapshotStorage;
|
|
155
|
+
/**
|
|
156
|
+
* Isomorphic snapshot manager that uses appropriate storage for the platform
|
|
157
|
+
*/
|
|
158
|
+
class IsomorphicSnapshotManager {
|
|
159
|
+
constructor(rootPath, useIndexedDB = false) {
|
|
160
|
+
if (useIndexedDB ||
|
|
161
|
+
(typeof window !== "undefined" && typeof indexedDB !== "undefined")) {
|
|
162
|
+
this.storage = new IndexedDBSnapshotStorage();
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this.storage = new FileSnapshotStorage(rootPath);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async save(snapshot) {
|
|
169
|
+
return this.storage.save(snapshot);
|
|
170
|
+
}
|
|
171
|
+
async load() {
|
|
172
|
+
return this.storage.load();
|
|
173
|
+
}
|
|
174
|
+
async backup() {
|
|
175
|
+
return this.storage.backup();
|
|
176
|
+
}
|
|
177
|
+
async createEmptySnapshot(rootPath) {
|
|
178
|
+
return {
|
|
179
|
+
rootPath,
|
|
180
|
+
timestamp: Date.now(),
|
|
181
|
+
files: new Map(),
|
|
182
|
+
directories: new Map(),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
updateFileEntry(snapshot, relativePath, entry) {
|
|
186
|
+
snapshot.files.set(relativePath, entry);
|
|
187
|
+
}
|
|
188
|
+
updateDirectoryEntry(snapshot, relativePath, entry) {
|
|
189
|
+
snapshot.directories.set(relativePath, entry);
|
|
190
|
+
}
|
|
191
|
+
removeFileEntry(snapshot, relativePath) {
|
|
192
|
+
snapshot.files.delete(relativePath);
|
|
193
|
+
}
|
|
194
|
+
createEmpty() {
|
|
195
|
+
return {
|
|
196
|
+
rootPath: "",
|
|
197
|
+
timestamp: Date.now(),
|
|
198
|
+
files: new Map(),
|
|
199
|
+
directories: new Map(),
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.IsomorphicSnapshotManager = IsomorphicSnapshotManager;
|
|
204
|
+
//# sourceMappingURL=isomorphic-snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isomorphic-snapshot.js","sourceRoot":"","sources":["../../src/core/isomorphic-snapshot.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAQH,oDAK6B;AAW7B;;GAEG;AACH,MAAa,mBAAmB;IAI9B,YAAoB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;IAAG,CAAC;IAEhC,eAAe,CAAC,GAAG,GAAG,SAAS;QACrC,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,mBAAmB,CAAC,aAAa,IAAI,GAAG,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IAAI,CAAC,GAAG,EAAE;YACrB,KAAK,EAAE,IAAI,GAAG,EAAE;YAChB,WAAW,EAAE,IAAI,GAAG,EAAE;SACvB,CAAC;IACJ,CAAC;CACF;AA/DD,8DA+DC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Ignore } from "ignore";
|
|
2
|
+
export type FileTree = Map<string, Uint8Array>;
|
|
3
|
+
export declare function walkDir(root: string, ig: Ignore): Promise<FileTree>;
|
|
4
|
+
export declare function byteEq(a: Uint8Array | undefined, b: Uint8Array): boolean;
|
|
5
|
+
export declare function writeFileAtomic(target: string, bytes: Uint8Array): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=fs-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-tree.d.ts","sourceRoot":"","sources":["../src/fs-tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAI/C,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAMzE;AAqCD,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,SAAS,EAAE,CAAC,EAAE,UAAU,GAAG,OAAO,CAKxE;AAED,wBAAsB,eAAe,CACpC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,UAAU,GACf,OAAO,CAAC,IAAI,CAAC,CAGf"}
|