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,70 @@
|
|
|
1
|
+
import { AutomergeUrl } from "@automerge/automerge-repo";
|
|
2
|
+
/**
|
|
3
|
+
* Entry in a directory document
|
|
4
|
+
*/
|
|
5
|
+
export interface DirectoryEntry {
|
|
6
|
+
name: string;
|
|
7
|
+
type: "file" | "folder";
|
|
8
|
+
url: AutomergeUrl;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Directory document structure
|
|
12
|
+
*/
|
|
13
|
+
export interface DirectoryDocument {
|
|
14
|
+
"@patchwork": {
|
|
15
|
+
type: "folder";
|
|
16
|
+
};
|
|
17
|
+
docs: DirectoryEntry[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* File document structure
|
|
21
|
+
*/
|
|
22
|
+
export interface FileDocument {
|
|
23
|
+
"@patchwork": {
|
|
24
|
+
type: "file";
|
|
25
|
+
};
|
|
26
|
+
name: string;
|
|
27
|
+
extension: string;
|
|
28
|
+
mimeType: string;
|
|
29
|
+
content: string | Uint8Array;
|
|
30
|
+
metadata: {
|
|
31
|
+
permissions: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* File type classification
|
|
36
|
+
*/
|
|
37
|
+
export declare enum FileType {
|
|
38
|
+
TEXT = "text",
|
|
39
|
+
BINARY = "binary",
|
|
40
|
+
DIRECTORY = "directory"
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Change type classification for sync operations
|
|
44
|
+
*/
|
|
45
|
+
export declare enum ChangeType {
|
|
46
|
+
NO_CHANGE = "no_change",
|
|
47
|
+
LOCAL_ONLY = "local_only",
|
|
48
|
+
REMOTE_ONLY = "remote_only",
|
|
49
|
+
BOTH_CHANGED = "both_changed"
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* File system entry metadata
|
|
53
|
+
*/
|
|
54
|
+
export interface FileSystemEntry {
|
|
55
|
+
path: string;
|
|
56
|
+
type: FileType;
|
|
57
|
+
size: number;
|
|
58
|
+
mtime: Date;
|
|
59
|
+
permissions: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Move detection result
|
|
63
|
+
*/
|
|
64
|
+
export interface MoveCandidate {
|
|
65
|
+
fromPath: string;
|
|
66
|
+
toPath: string;
|
|
67
|
+
similarity: number;
|
|
68
|
+
confidence: "auto" | "prompt" | "low";
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/types/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,GAAG,EAAE,YAAY,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE,CAAC;IACjC,IAAI,EAAE,cAAc,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAC7B,QAAQ,EAAE;QACR,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;CACvC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChangeType = exports.FileType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* File type classification
|
|
6
|
+
*/
|
|
7
|
+
var FileType;
|
|
8
|
+
(function (FileType) {
|
|
9
|
+
FileType["TEXT"] = "text";
|
|
10
|
+
FileType["BINARY"] = "binary";
|
|
11
|
+
FileType["DIRECTORY"] = "directory";
|
|
12
|
+
})(FileType || (exports.FileType = FileType = {}));
|
|
13
|
+
/**
|
|
14
|
+
* Change type classification for sync operations
|
|
15
|
+
*/
|
|
16
|
+
var ChangeType;
|
|
17
|
+
(function (ChangeType) {
|
|
18
|
+
ChangeType["NO_CHANGE"] = "no_change";
|
|
19
|
+
ChangeType["LOCAL_ONLY"] = "local_only";
|
|
20
|
+
ChangeType["REMOTE_ONLY"] = "remote_only";
|
|
21
|
+
ChangeType["BOTH_CHANGED"] = "both_changed";
|
|
22
|
+
})(ChangeType || (exports.ChangeType = ChangeType = {}));
|
|
23
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/types/documents.ts"],"names":[],"mappings":";;;AAiCA;;GAEG;AACH,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,yBAAa,CAAA;IACb,6BAAiB,CAAA;IACjB,mCAAuB,CAAA;AACzB,CAAC,EAJW,QAAQ,wBAAR,QAAQ,QAInB;AAED;;GAEG;AACH,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,uCAAyB,CAAA;IACzB,yCAA2B,CAAA;IAC3B,2CAA6B,CAAA;AAC/B,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAG5B,cAAc,YAAY,CAAC;AAG3B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Document types
|
|
18
|
+
__exportStar(require("./documents"), exports);
|
|
19
|
+
// Snapshot and sync types
|
|
20
|
+
__exportStar(require("./snapshot"), exports);
|
|
21
|
+
// Configuration types
|
|
22
|
+
__exportStar(require("./config"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iBAAiB;AACjB,8CAA4B;AAE5B,0BAA0B;AAC1B,6CAA2B;AAE3B,sBAAsB;AACtB,2CAAyB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { AutomergeUrl, UrlHeads } from "@automerge/automerge-repo";
|
|
2
|
+
/**
|
|
3
|
+
* Tracked file entry in the sync snapshot
|
|
4
|
+
*/
|
|
5
|
+
export interface SnapshotFileEntry {
|
|
6
|
+
path: string;
|
|
7
|
+
url: AutomergeUrl;
|
|
8
|
+
head: UrlHeads;
|
|
9
|
+
extension: string;
|
|
10
|
+
mimeType: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Tracked directory entry in the sync snapshot
|
|
14
|
+
*/
|
|
15
|
+
export interface SnapshotDirectoryEntry {
|
|
16
|
+
path: string;
|
|
17
|
+
url: AutomergeUrl;
|
|
18
|
+
head: UrlHeads;
|
|
19
|
+
entries: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sync snapshot for local state management
|
|
23
|
+
*/
|
|
24
|
+
export interface SyncSnapshot {
|
|
25
|
+
timestamp: number;
|
|
26
|
+
rootPath: string;
|
|
27
|
+
rootDirectoryUrl?: AutomergeUrl;
|
|
28
|
+
files: Map<string, SnapshotFileEntry>;
|
|
29
|
+
directories: Map<string, SnapshotDirectoryEntry>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Serializable version of sync snapshot for storage
|
|
33
|
+
*/
|
|
34
|
+
export interface SerializableSyncSnapshot {
|
|
35
|
+
timestamp: number;
|
|
36
|
+
rootPath: string;
|
|
37
|
+
rootDirectoryUrl?: AutomergeUrl;
|
|
38
|
+
files: Array<[string, SnapshotFileEntry]>;
|
|
39
|
+
directories: Array<[string, SnapshotDirectoryEntry]>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sync operation result
|
|
43
|
+
*/
|
|
44
|
+
export interface SyncResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
filesChanged: number;
|
|
47
|
+
directoriesChanged: number;
|
|
48
|
+
errors: SyncError[];
|
|
49
|
+
warnings: string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sync error details
|
|
53
|
+
*/
|
|
54
|
+
export interface SyncError {
|
|
55
|
+
path: string;
|
|
56
|
+
operation: string;
|
|
57
|
+
error: Error;
|
|
58
|
+
recoverable: boolean;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sync operation type
|
|
62
|
+
*/
|
|
63
|
+
export declare enum SyncOperation {
|
|
64
|
+
CREATE_FILE = "create_file",
|
|
65
|
+
UPDATE_FILE = "update_file",
|
|
66
|
+
DELETE_FILE = "delete_file",
|
|
67
|
+
MOVE_FILE = "move_file",
|
|
68
|
+
CREATE_DIRECTORY = "create_directory",
|
|
69
|
+
DELETE_DIRECTORY = "delete_directory",
|
|
70
|
+
MOVE_DIRECTORY = "move_directory"
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Pending sync operation
|
|
74
|
+
*/
|
|
75
|
+
export interface PendingSyncOperation {
|
|
76
|
+
operation: SyncOperation;
|
|
77
|
+
path: string;
|
|
78
|
+
newPath?: string;
|
|
79
|
+
priority: number;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=snapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/types/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEn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K,EAAE,KAAK,CAAC;IACb,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,oBAAY,aAAa;IACvB,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,gBAAgB,qBAAqB;IACrC,gBAAgB,qBAAqB;IACrC,cAAc,mBAAmB;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,aAAa,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SyncOperation = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sync operation type
|
|
6
|
+
*/
|
|
7
|
+
var SyncOperation;
|
|
8
|
+
(function (SyncOperation) {
|
|
9
|
+
SyncOperation["CREATE_FILE"] = "create_file";
|
|
10
|
+
SyncOperation["UPDATE_FILE"] = "update_file";
|
|
11
|
+
SyncOperation["DELETE_FILE"] = "delete_file";
|
|
12
|
+
SyncOperation["MOVE_FILE"] = "move_file";
|
|
13
|
+
SyncOperation["CREATE_DIRECTORY"] = "create_directory";
|
|
14
|
+
SyncOperation["DELETE_DIRECTORY"] = "delete_directory";
|
|
15
|
+
SyncOperation["MOVE_DIRECTORY"] = "move_directory";
|
|
16
|
+
})(SyncOperation || (exports.SyncOperation = SyncOperation = {}));
|
|
17
|
+
//# sourceMappingURL=snapshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/types/snapshot.ts"],"names":[],"mappings":";;;AAkEA;;GAEG;AACH,IAAY,aAQX;AARD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,4CAA2B,CAAA;IAC3B,4CAA2B,CAAA;IAC3B,wCAAuB,CAAA;IACvB,sDAAqC,CAAA;IACrC,sDAAqC,CAAA;IACrC,kDAAiC,CAAA;AACnC,CAAC,EARW,aAAa,6BAAb,aAAa,QAQxB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content similarity calculation for move detection
|
|
3
|
+
*/
|
|
4
|
+
export declare class ContentSimilarity {
|
|
5
|
+
private static readonly CHUNK_SIZE;
|
|
6
|
+
private static readonly AUTO_THRESHOLD;
|
|
7
|
+
private static readonly PROMPT_THRESHOLD;
|
|
8
|
+
/**
|
|
9
|
+
* Calculate similarity between two content pieces
|
|
10
|
+
*/
|
|
11
|
+
static calculateSimilarity(content1: string | Uint8Array, content2: string | Uint8Array): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if two content pieces are identical
|
|
14
|
+
*/
|
|
15
|
+
private static areIdentical;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate similarity for small files using full content
|
|
18
|
+
*/
|
|
19
|
+
private static calculateFullSimilarity;
|
|
20
|
+
/**
|
|
21
|
+
* Calculate similarity for large files using sampling
|
|
22
|
+
*/
|
|
23
|
+
private static calculateSampledSimilarity;
|
|
24
|
+
/**
|
|
25
|
+
* Get representative samples from content
|
|
26
|
+
*/
|
|
27
|
+
private static getSamples;
|
|
28
|
+
/**
|
|
29
|
+
* Calculate Levenshtein similarity (0-1 scale)
|
|
30
|
+
*/
|
|
31
|
+
private static levenshteinSimilarity;
|
|
32
|
+
/**
|
|
33
|
+
* Calculate Levenshtein distance
|
|
34
|
+
*/
|
|
35
|
+
private static levenshteinDistance;
|
|
36
|
+
/**
|
|
37
|
+
* Convert buffer to string for comparison
|
|
38
|
+
*/
|
|
39
|
+
private static bufferToString;
|
|
40
|
+
/**
|
|
41
|
+
* Determine confidence level based on similarity score
|
|
42
|
+
*/
|
|
43
|
+
static getConfidenceLevel(similarity: number): "auto" | "prompt" | "low";
|
|
44
|
+
/**
|
|
45
|
+
* Should auto-apply move based on similarity
|
|
46
|
+
*/
|
|
47
|
+
static shouldAutoApply(similarity: number): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Should prompt user for move confirmation
|
|
50
|
+
*/
|
|
51
|
+
static shouldPromptUser(similarity: number): boolean;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=content-similarity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-similarity.d.ts","sourceRoot":"","sources":["../../src/utils/content-similarity.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAO;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAE/C;;OAEG;WACU,mBAAmB,CAC9B,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,QAAQ,EAAE,MAAM,GAAG,UAAU,GAC5B,OAAO,CAAC,MAAM,CAAC;IA0BlB;;OAEG;mBACkB,YAAY;IASjC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAYtC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAkBzC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAwBzB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAUpC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsBlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B;;OAEG;IACH,MAAM,CAAC,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK;IAUxE;;OAEG;IACH,MAAM,CAAC,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAInD;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;CAKrD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContentSimilarity = void 0;
|
|
4
|
+
const fs_1 = require("./fs");
|
|
5
|
+
/**
|
|
6
|
+
* Content similarity calculation for move detection
|
|
7
|
+
*/
|
|
8
|
+
class ContentSimilarity {
|
|
9
|
+
/**
|
|
10
|
+
* Calculate similarity between two content pieces
|
|
11
|
+
*/
|
|
12
|
+
static async calculateSimilarity(content1, content2) {
|
|
13
|
+
// Quick early exit for identical content
|
|
14
|
+
if (await this.areIdentical(content1, content2)) {
|
|
15
|
+
return 1.0;
|
|
16
|
+
}
|
|
17
|
+
// Size-based quick rejection
|
|
18
|
+
const size1 = typeof content1 === "string" ? content1.length : content1.length;
|
|
19
|
+
const size2 = typeof content2 === "string" ? content2.length : content2.length;
|
|
20
|
+
const sizeDiff = Math.abs(size1 - size2) / Math.max(size1, size2);
|
|
21
|
+
if (sizeDiff > 0.5) {
|
|
22
|
+
return 0.0; // Too different in size
|
|
23
|
+
}
|
|
24
|
+
// For small files, use full content comparison
|
|
25
|
+
if (size1 < this.CHUNK_SIZE * 4 && size2 < this.CHUNK_SIZE * 4) {
|
|
26
|
+
return this.calculateFullSimilarity(content1, content2);
|
|
27
|
+
}
|
|
28
|
+
// For large files, use sampling
|
|
29
|
+
return this.calculateSampledSimilarity(content1, content2);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Check if two content pieces are identical
|
|
33
|
+
*/
|
|
34
|
+
static async areIdentical(content1, content2) {
|
|
35
|
+
const hash1 = await (0, fs_1.calculateContentHash)(content1);
|
|
36
|
+
const hash2 = await (0, fs_1.calculateContentHash)(content2);
|
|
37
|
+
return hash1 === hash2;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Calculate similarity for small files using full content
|
|
41
|
+
*/
|
|
42
|
+
static calculateFullSimilarity(content1, content2) {
|
|
43
|
+
const str1 = typeof content1 === "string" ? content1 : this.bufferToString(content1);
|
|
44
|
+
const str2 = typeof content2 === "string" ? content2 : this.bufferToString(content2);
|
|
45
|
+
return this.levenshteinSimilarity(str1, str2);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Calculate similarity for large files using sampling
|
|
49
|
+
*/
|
|
50
|
+
static calculateSampledSimilarity(content1, content2) {
|
|
51
|
+
const samples1 = this.getSamples(content1);
|
|
52
|
+
const samples2 = this.getSamples(content2);
|
|
53
|
+
let totalSimilarity = 0;
|
|
54
|
+
let comparisons = 0;
|
|
55
|
+
for (let i = 0; i < Math.min(samples1.length, samples2.length); i++) {
|
|
56
|
+
totalSimilarity += this.levenshteinSimilarity(samples1[i], samples2[i]);
|
|
57
|
+
comparisons++;
|
|
58
|
+
}
|
|
59
|
+
return comparisons > 0 ? totalSimilarity / comparisons : 0;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Get representative samples from content
|
|
63
|
+
*/
|
|
64
|
+
static getSamples(content) {
|
|
65
|
+
const str = typeof content === "string" ? content : this.bufferToString(content);
|
|
66
|
+
const length = str.length;
|
|
67
|
+
const samples = [];
|
|
68
|
+
if (length <= this.CHUNK_SIZE) {
|
|
69
|
+
samples.push(str);
|
|
70
|
+
return samples;
|
|
71
|
+
}
|
|
72
|
+
// Beginning
|
|
73
|
+
samples.push(str.slice(0, this.CHUNK_SIZE));
|
|
74
|
+
// Middle
|
|
75
|
+
const midStart = Math.floor(length / 2) - Math.floor(this.CHUNK_SIZE / 2);
|
|
76
|
+
samples.push(str.slice(midStart, midStart + this.CHUNK_SIZE));
|
|
77
|
+
// End
|
|
78
|
+
samples.push(str.slice(-this.CHUNK_SIZE));
|
|
79
|
+
return samples;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Calculate Levenshtein similarity (0-1 scale)
|
|
83
|
+
*/
|
|
84
|
+
static levenshteinSimilarity(str1, str2) {
|
|
85
|
+
if (str1 === str2)
|
|
86
|
+
return 1.0;
|
|
87
|
+
if (str1.length === 0 || str2.length === 0)
|
|
88
|
+
return 0.0;
|
|
89
|
+
const distance = this.levenshteinDistance(str1, str2);
|
|
90
|
+
const maxLength = Math.max(str1.length, str2.length);
|
|
91
|
+
return 1 - distance / maxLength;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Calculate Levenshtein distance
|
|
95
|
+
*/
|
|
96
|
+
static levenshteinDistance(str1, str2) {
|
|
97
|
+
const matrix = Array(str2.length + 1)
|
|
98
|
+
.fill(null)
|
|
99
|
+
.map(() => Array(str1.length + 1).fill(null));
|
|
100
|
+
for (let i = 0; i <= str1.length; i++)
|
|
101
|
+
matrix[0][i] = i;
|
|
102
|
+
for (let j = 0; j <= str2.length; j++)
|
|
103
|
+
matrix[j][0] = j;
|
|
104
|
+
for (let j = 1; j <= str2.length; j++) {
|
|
105
|
+
for (let i = 1; i <= str1.length; i++) {
|
|
106
|
+
const indicator = str1[i - 1] === str2[j - 1] ? 0 : 1;
|
|
107
|
+
matrix[j][i] = Math.min(matrix[j][i - 1] + 1, // deletion
|
|
108
|
+
matrix[j - 1][i] + 1, // insertion
|
|
109
|
+
matrix[j - 1][i - 1] + indicator // substitution
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return matrix[str2.length][str1.length];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Convert buffer to string for comparison
|
|
117
|
+
*/
|
|
118
|
+
static bufferToString(buffer) {
|
|
119
|
+
// For binary content, use hex representation for comparison
|
|
120
|
+
return Array.from(buffer)
|
|
121
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
122
|
+
.join("");
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Determine confidence level based on similarity score
|
|
126
|
+
*/
|
|
127
|
+
static getConfidenceLevel(similarity) {
|
|
128
|
+
if (similarity >= this.AUTO_THRESHOLD) {
|
|
129
|
+
return "auto";
|
|
130
|
+
}
|
|
131
|
+
else if (similarity >= this.PROMPT_THRESHOLD) {
|
|
132
|
+
return "prompt";
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
return "low";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Should auto-apply move based on similarity
|
|
140
|
+
*/
|
|
141
|
+
static shouldAutoApply(similarity) {
|
|
142
|
+
return similarity >= this.AUTO_THRESHOLD;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Should prompt user for move confirmation
|
|
146
|
+
*/
|
|
147
|
+
static shouldPromptUser(similarity) {
|
|
148
|
+
return (similarity >= this.PROMPT_THRESHOLD && similarity < this.AUTO_THRESHOLD);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.ContentSimilarity = ContentSimilarity;
|
|
152
|
+
ContentSimilarity.CHUNK_SIZE = 1024; // 1KB chunks for sampling
|
|
153
|
+
ContentSimilarity.AUTO_THRESHOLD = 0.8;
|
|
154
|
+
ContentSimilarity.PROMPT_THRESHOLD = 0.5;
|
|
155
|
+
//# sourceMappingURL=content-similarity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-similarity.js","sourceRoot":"","sources":["../../src/utils/content-similarity.ts"],"names":[],"mappings":";;;AAAA,6BAA4C;AAE5C;;GAEG;AACH,MAAa,iBAAiB;IAK5B;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAC9B,QAA6B,EAC7B,QAA6B;QAE7B,yCAAyC;QACzC,IAAI,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;YAChD,OAAO,GAAG,CAAC;QACb,CAAC;QAED,6BAA6B;QAC7B,MAAM,KAAK,GACT,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MA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 -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isContentEqual = isContentEqual;
|
|
4
|
+
/**
|
|
5
|
+
* Compare two content pieces for equality
|
|
6
|
+
*/
|
|
7
|
+
function isContentEqual(content1, content2) {
|
|
8
|
+
if (content1 === content2)
|
|
9
|
+
return true;
|
|
10
|
+
if (!content1 || !content2)
|
|
11
|
+
return false;
|
|
12
|
+
if (typeof content1 !== typeof content2)
|
|
13
|
+
return false;
|
|
14
|
+
if (typeof content1 === "string") {
|
|
15
|
+
return content1 === content2;
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// Compare Uint8Array
|
|
19
|
+
const buf1 = content1;
|
|
20
|
+
const buf2 = content2;
|
|
21
|
+
if (buf1.length !== buf2.length)
|
|
22
|
+
return false;
|
|
23
|
+
for (let i = 0; i < buf1.length; i++) {
|
|
24
|
+
if (buf1[i] !== buf2[i])
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/utils/content.ts"],"names":[],"mappings":";;AAGA,wCAwBC;AA3BD;;GAEG;AACH,SAAgB,cAAc,CAC5B,QAAoC,EACpC,QAAoC;IAEpC,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,OAAO,QAAQ,KAAK,OAAO,QAAQ;QAAE,OAAO,KAAK,CAAC;IAEtD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,KAAK,QAAQ,CAAC;IAC/B,CAAC;SAAM,CAAC;QACN,qBAAqB;QACrB,MAAM,IAAI,GAAG,QAAsB,CAAC;QACpC,MAAM,IAAI,GAAG,QAAsB,CAAC;QAEpC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACxC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-specific filesystem utilities using File System Access API
|
|
3
|
+
*/
|
|
4
|
+
import { FileSystemEntry } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Set the root directory handle for browser filesystem operations
|
|
7
|
+
*/
|
|
8
|
+
export declare function setRootDirectoryHandle(handle: any): void;
|
|
9
|
+
/**
|
|
10
|
+
* Get the root directory handle
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRootDirectoryHandle(): any;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a path exists
|
|
15
|
+
*/
|
|
16
|
+
export declare function pathExists(filePath: string): Promise<boolean>;
|
|
17
|
+
/**
|
|
18
|
+
* Get file system entry information
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFileSystemEntry(filePath: string): Promise<FileSystemEntry>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a file is a text file
|
|
23
|
+
*/
|
|
24
|
+
export declare function isTextFile(filePath: string): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Read file content
|
|
27
|
+
*/
|
|
28
|
+
export declare function readFileContent(filePath: string): Promise<string | Uint8Array>;
|
|
29
|
+
/**
|
|
30
|
+
* Write file content
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeFileContent(filePath: string, content: string | Uint8Array): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Ensure directory exists
|
|
35
|
+
*/
|
|
36
|
+
export declare function ensureDirectoryExists(dirPath: string): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Remove a file or directory
|
|
39
|
+
*/
|
|
40
|
+
export declare function removePath(filePath: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* List directory contents
|
|
43
|
+
*/
|
|
44
|
+
export declare function listDirectory(dirPath: string, excludePatterns?: string[]): Promise<FileSystemEntry[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Copy a file (not supported in File System Access API)
|
|
47
|
+
*/
|
|
48
|
+
export declare function copyFile(sourcePath: string, targetPath: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Move a file or directory
|
|
51
|
+
*/
|
|
52
|
+
export declare function movePath(sourcePath: string, targetPath: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Get MIME type
|
|
55
|
+
*/
|
|
56
|
+
export declare function getMimeType(filePath: string): string;
|
|
57
|
+
//# sourceMappingURL=fs-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-browser.d.ts","sourceRoot":"","sources":["../../src/utils/fs-browser.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAY,MAAM,UAAU,CAAC;AAYrD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,GAAG,CAO5C;AAiCD;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,CAAC,CA2B1B;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,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