pushwork 2.0.0-preview.5 → 2.0.0-preview.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/branches.d.ts +1 -2
- package/dist/branches.d.ts.map +1 -1
- package/dist/branches.js +4 -23
- package/dist/branches.js.map +1 -1
- 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/commands.d.ts +58 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +975 -0
- package/dist/commands.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 +80 -0
- package/dist/core/change-detection.d.ts.map +1 -0
- package/dist/core/change-detection.js +560 -0
- package/dist/core/change-detection.js.map +1 -0
- package/dist/core/config.d.ts +81 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +304 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +6 -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/move-detection.d.ts +34 -0
- package/dist/core/move-detection.d.ts.map +1 -0
- package/dist/core/move-detection.js +128 -0
- package/dist/core/move-detection.js.map +1 -0
- package/dist/core/snapshot.d.ts +105 -0
- package/dist/core/snapshot.d.ts.map +1 -0
- package/dist/core/snapshot.js +254 -0
- package/dist/core/snapshot.js.map +1 -0
- package/dist/core/sync-engine.d.ts +177 -0
- package/dist/core/sync-engine.d.ts.map +1 -0
- package/dist/core/sync-engine.js +1471 -0
- package/dist/core/sync-engine.js.map +1 -0
- package/dist/stash.d.ts +0 -2
- package/dist/stash.d.ts.map +1 -1
- package/dist/stash.js +0 -1
- package/dist/stash.js.map +1 -1
- package/dist/types/config.d.ts +102 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +10 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/documents.d.ts +88 -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 +20 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/snapshot.d.ts +64 -0
- package/dist/types/snapshot.d.ts.map +1 -0
- package/dist/types/snapshot.js +3 -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 +10 -0
- package/dist/utils/content.d.ts.map +1 -0
- package/dist/utils/content.js +35 -0
- package/dist/utils/content.js.map +1 -0
- package/dist/utils/directory.d.ts +24 -0
- package/dist/utils/directory.d.ts.map +1 -0
- package/dist/utils/directory.js +56 -0
- package/dist/utils/directory.js.map +1 -0
- package/dist/utils/fs.d.ts +74 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +298 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +21 -0
- package/dist/utils/index.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 +247 -0
- package/dist/utils/mime-types.js.map +1 -0
- package/dist/utils/network-sync.d.ts +30 -0
- package/dist/utils/network-sync.d.ts.map +1 -0
- package/dist/utils/network-sync.js +391 -0
- package/dist/utils/network-sync.js.map +1 -0
- package/dist/utils/node-polyfills.d.ts +9 -0
- package/dist/utils/node-polyfills.d.ts.map +1 -0
- package/dist/utils/node-polyfills.js +9 -0
- package/dist/utils/node-polyfills.js.map +1 -0
- package/dist/utils/output.d.ts +129 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +375 -0
- package/dist/utils/output.js.map +1 -0
- package/dist/utils/repo-factory.d.ts +15 -0
- package/dist/utils/repo-factory.d.ts.map +1 -0
- package/dist/utils/repo-factory.js +156 -0
- package/dist/utils/repo-factory.js.map +1 -0
- package/dist/utils/string-similarity.d.ts +14 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +43 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/text-diff.d.ts +37 -0
- package/dist/utils/text-diff.d.ts.map +1 -0
- package/dist/utils/text-diff.js +131 -0
- package/dist/utils/text-diff.js.map +1 -0
- package/dist/utils/trace.d.ts +19 -0
- package/dist/utils/trace.d.ts.map +1 -0
- package/dist/utils/trace.js +68 -0
- package/dist/utils/trace.js.map +1 -0
- package/package.json +5 -5
- package/dist/checkpoints.d.ts +0 -41
- package/dist/checkpoints.d.ts.map +0 -1
- package/dist/checkpoints.js +0 -210
- package/dist/checkpoints.js.map +0 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as A from "@automerge/automerge";
|
|
2
|
+
/**
|
|
3
|
+
* Read content from an Automerge document, normalizing legacy ImmutableString
|
|
4
|
+
* values to plain strings for backwards compatibility.
|
|
5
|
+
*
|
|
6
|
+
* Old documents may store text as ImmutableString. This helper ensures callers
|
|
7
|
+
* always get back `string | Uint8Array | null`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readDocContent(content: unknown): string | Uint8Array | null;
|
|
10
|
+
/**
|
|
11
|
+
* Update text content on an Automerge document property inside a change
|
|
12
|
+
* callback.
|
|
13
|
+
*
|
|
14
|
+
* If the existing value is already a collaborative text string, we diff and
|
|
15
|
+
* splice for minimal CRDT operations. If the existing value is a legacy
|
|
16
|
+
* ImmutableString we can't splice into it, so we assign the whole string
|
|
17
|
+
* which converts the field to a collaborative text CRDT going forward.
|
|
18
|
+
*
|
|
19
|
+
* @param doc - The mutable Automerge document (inside a change callback)
|
|
20
|
+
* @param path - Property path to the text field, e.g. ["content"]
|
|
21
|
+
* @param newContent - The desired new text value
|
|
22
|
+
*/
|
|
23
|
+
export declare function updateTextContent(doc: any, path: A.Prop[], newContent: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Apply a text diff between oldContent and newContent as Automerge splice
|
|
26
|
+
* operations on the given document property path.
|
|
27
|
+
*
|
|
28
|
+
* This preserves the collaborative text CRDT structure by making minimal
|
|
29
|
+
* character-level edits rather than replacing the entire string.
|
|
30
|
+
*
|
|
31
|
+
* @param doc - The Automerge document (inside a change callback)
|
|
32
|
+
* @param path - The property path to the text field, e.g. ["content"]
|
|
33
|
+
* @param oldContent - The previous text content
|
|
34
|
+
* @param newContent - The desired new text content
|
|
35
|
+
*/
|
|
36
|
+
export declare function spliceText(doc: any, path: A.Prop[], oldContent: string, newContent: string): void;
|
|
37
|
+
//# sourceMappingURL=text-diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-diff.d.ts","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,sBAAsB,CAAA;AAGzC;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAO3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,GAChB,IAAI,CAeN;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAChB,IAAI,CA8BN"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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.readDocContent = readDocContent;
|
|
37
|
+
exports.updateTextContent = updateTextContent;
|
|
38
|
+
exports.spliceText = spliceText;
|
|
39
|
+
const A = __importStar(require("@automerge/automerge"));
|
|
40
|
+
const diffLib = __importStar(require("diff"));
|
|
41
|
+
/**
|
|
42
|
+
* Read content from an Automerge document, normalizing legacy ImmutableString
|
|
43
|
+
* values to plain strings for backwards compatibility.
|
|
44
|
+
*
|
|
45
|
+
* Old documents may store text as ImmutableString. This helper ensures callers
|
|
46
|
+
* always get back `string | Uint8Array | null`.
|
|
47
|
+
*/
|
|
48
|
+
function readDocContent(content) {
|
|
49
|
+
if (content == null)
|
|
50
|
+
return null;
|
|
51
|
+
if (typeof content === "string")
|
|
52
|
+
return content;
|
|
53
|
+
if (content instanceof Uint8Array)
|
|
54
|
+
return content;
|
|
55
|
+
// Legacy ImmutableString — convert to plain string
|
|
56
|
+
if (A.isImmutableString(content))
|
|
57
|
+
return content.toString();
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Update text content on an Automerge document property inside a change
|
|
62
|
+
* callback.
|
|
63
|
+
*
|
|
64
|
+
* If the existing value is already a collaborative text string, we diff and
|
|
65
|
+
* splice for minimal CRDT operations. If the existing value is a legacy
|
|
66
|
+
* ImmutableString we can't splice into it, so we assign the whole string
|
|
67
|
+
* which converts the field to a collaborative text CRDT going forward.
|
|
68
|
+
*
|
|
69
|
+
* @param doc - The mutable Automerge document (inside a change callback)
|
|
70
|
+
* @param path - Property path to the text field, e.g. ["content"]
|
|
71
|
+
* @param newContent - The desired new text value
|
|
72
|
+
*/
|
|
73
|
+
function updateTextContent(doc, path, newContent) {
|
|
74
|
+
const target = path.reduce((obj, key) => obj?.[key], doc);
|
|
75
|
+
if (typeof target === "string") {
|
|
76
|
+
// Already a collaborative text string — diff and splice
|
|
77
|
+
spliceText(doc, path, target, newContent);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// Legacy ImmutableString, undefined, or other — assign directly.
|
|
81
|
+
// This converts the field to a collaborative text CRDT.
|
|
82
|
+
let obj = doc;
|
|
83
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
84
|
+
obj = obj[path[i]];
|
|
85
|
+
}
|
|
86
|
+
obj[path[path.length - 1]] = newContent;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Apply a text diff between oldContent and newContent as Automerge splice
|
|
91
|
+
* operations on the given document property path.
|
|
92
|
+
*
|
|
93
|
+
* This preserves the collaborative text CRDT structure by making minimal
|
|
94
|
+
* character-level edits rather than replacing the entire string.
|
|
95
|
+
*
|
|
96
|
+
* @param doc - The Automerge document (inside a change callback)
|
|
97
|
+
* @param path - The property path to the text field, e.g. ["content"]
|
|
98
|
+
* @param oldContent - The previous text content
|
|
99
|
+
* @param newContent - The desired new text content
|
|
100
|
+
*/
|
|
101
|
+
function spliceText(doc, path, oldContent, newContent) {
|
|
102
|
+
if (oldContent === newContent)
|
|
103
|
+
return;
|
|
104
|
+
// Fast path: if old is empty, just insert everything
|
|
105
|
+
if (oldContent === "") {
|
|
106
|
+
A.splice(doc, path, 0, 0, newContent);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
// Fast path: if new is empty, just delete everything
|
|
110
|
+
if (newContent === "") {
|
|
111
|
+
A.splice(doc, path, 0, oldContent.length);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const changes = diffLib.diffChars(oldContent, newContent);
|
|
115
|
+
let pos = 0;
|
|
116
|
+
for (const part of changes) {
|
|
117
|
+
if (part.removed) {
|
|
118
|
+
A.splice(doc, path, pos, part.value.length);
|
|
119
|
+
// Don't advance pos — text shifted left after deletion
|
|
120
|
+
}
|
|
121
|
+
else if (part.added) {
|
|
122
|
+
A.splice(doc, path, pos, 0, part.value);
|
|
123
|
+
pos += part.value.length;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Unchanged text — just advance the cursor
|
|
127
|
+
pos += part.value.length;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=text-diff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-diff.js","sourceRoot":"","sources":["../../src/utils/text-diff.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,wCAOC;AAeD,8CAmBC;AAcD,gCAmCC;AApGD,wDAAyC;AACzC,8CAA+B;AAE/B;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,OAAgB;IAC9C,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,IAAI,CAAA;IAChC,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IAC/C,IAAI,OAAO,YAAY,UAAU;QAAE,OAAO,OAAO,CAAA;IACjD,mDAAmD;IACnD,IAAI,CAAC,CAAC,iBAAiB,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC3D,OAAO,IAAI,CAAA;AACZ,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAChC,GAAQ,EACR,IAAc,EACd,UAAkB;IAElB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;IAE9D,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,wDAAwD;QACxD,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;SAAM,CAAC;QACP,iEAAiE;QACjE,wDAAwD;QACxD,IAAI,GAAG,GAAQ,GAAG,CAAA;QAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,C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AC;aAAM,CAAC;YACP,2CAA2C;YAC3C,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;QACzB,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enable or disable tracing
|
|
3
|
+
*/
|
|
4
|
+
export declare function setTracingEnabled(enabled: boolean): void;
|
|
5
|
+
/**
|
|
6
|
+
* Check if tracing is enabled
|
|
7
|
+
*/
|
|
8
|
+
export declare function isTracingEnabled(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Trace a span of work by outputting to console
|
|
11
|
+
* Works for both sync and async functions
|
|
12
|
+
* Only outputs if tracing is enabled
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* await span("operation", async () => { ... })
|
|
16
|
+
* span("operation", () => { ... })
|
|
17
|
+
*/
|
|
18
|
+
export declare function span<T>(name: string, fn: () => T | Promise<T>): T | Promise<T>;
|
|
19
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAExD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBhB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setTracingEnabled = setTracingEnabled;
|
|
4
|
+
exports.isTracingEnabled = isTracingEnabled;
|
|
5
|
+
exports.span = span;
|
|
6
|
+
const output_1 = require("./output");
|
|
7
|
+
/**
|
|
8
|
+
* Global tracing state
|
|
9
|
+
*/
|
|
10
|
+
let tracingEnabled = false;
|
|
11
|
+
/**
|
|
12
|
+
* Enable or disable tracing
|
|
13
|
+
*/
|
|
14
|
+
function setTracingEnabled(enabled) {
|
|
15
|
+
tracingEnabled = enabled;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if tracing is enabled
|
|
19
|
+
*/
|
|
20
|
+
function isTracingEnabled() {
|
|
21
|
+
return tracingEnabled;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Trace a span of work by outputting to console
|
|
25
|
+
* Works for both sync and async functions
|
|
26
|
+
* Only outputs if tracing is enabled
|
|
27
|
+
*
|
|
28
|
+
* Usage:
|
|
29
|
+
* await span("operation", async () => { ... })
|
|
30
|
+
* span("operation", () => { ... })
|
|
31
|
+
*/
|
|
32
|
+
function span(name, fn) {
|
|
33
|
+
if (!tracingEnabled) {
|
|
34
|
+
return fn();
|
|
35
|
+
}
|
|
36
|
+
const start = performance.now();
|
|
37
|
+
const result = fn();
|
|
38
|
+
// Check if it's a promise (async)
|
|
39
|
+
if (result instanceof Promise) {
|
|
40
|
+
return result.then((value) => {
|
|
41
|
+
const duration = performance.now() - start;
|
|
42
|
+
output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
43
|
+
return value;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Sync case
|
|
47
|
+
const duration = performance.now() - start;
|
|
48
|
+
output_1.out.taskLine(`${name} (${formatDuration(duration)})`, true);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Format duration for display
|
|
53
|
+
*/
|
|
54
|
+
function formatDuration(ms) {
|
|
55
|
+
if (ms < 1) {
|
|
56
|
+
return `${ms.toFixed(2)}ms`;
|
|
57
|
+
}
|
|
58
|
+
else if (ms < 1000) {
|
|
59
|
+
return `${Math.round(ms)}ms`;
|
|
60
|
+
}
|
|
61
|
+
else if (ms < 2000) {
|
|
62
|
+
return `${(ms / 1000).toFixed(2)}s`;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/utils/trace.ts"],"names":[],"mappings":";;AAUA,8CAEC;AAKD,4CAEC;AAWD,oBAwBC;AAtDD,qCAA+B;AAE/B;;GAEG;AACH,IAAI,cAAc,GAAG,KAAK,CAAC;AAE3B;;GAEG;AACH,SAAgB,iBAAiB,CAAC,OAAgB;IAChD,cAAc,GAAG,OAAO,CAAC;AAC3B,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,IAAI,CAClB,IAAY,EACZ,EAAwB;IAExB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAChC,MAAM,MAAM,GAAG,EAAE,EAAE,CAAC;IAEpB,kCAAkC;IAClC,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YAC3C,YAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,KAAK,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAC5D,OAAO,KAAK,CAAC;QACf,CAAC,CAAM,CAAC;IACV,CAAC;IAED,YAAY;IACZ,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;IAC3C,YAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,KAAK,cAAc,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,cAAc,CAAC,EAAU;IAChC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9B,CAAC;SAAM,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACrB,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC;IAC/B,CAAC;SAAM,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;QACrB,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;IACtC,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pushwork",
|
|
3
|
-
"version": "2.0.0-preview.
|
|
3
|
+
"version": "2.0.0-preview.7",
|
|
4
4
|
"description": "Bidirectional directory synchronization using Automerge CRDTs",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@automerge/automerge": "^3.2.6",
|
|
31
|
-
"@automerge/automerge-repo": "2.6.0-subduction.
|
|
32
|
-
"@automerge/automerge-repo-network-websocket": "2.6.0-subduction.
|
|
33
|
-
"@automerge/automerge-repo-storage-nodefs": "2.6.0-subduction.
|
|
34
|
-
"@automerge/automerge-subduction": "0.
|
|
31
|
+
"@automerge/automerge-repo": "2.6.0-subduction.28",
|
|
32
|
+
"@automerge/automerge-repo-network-websocket": "2.6.0-subduction.28",
|
|
33
|
+
"@automerge/automerge-repo-storage-nodefs": "2.6.0-subduction.28",
|
|
34
|
+
"@automerge/automerge-subduction": "0.14.0",
|
|
35
35
|
"@commander-js/extra-typings": "^14.0.0",
|
|
36
36
|
"chalk": "^5.3.0",
|
|
37
37
|
"commander": "^14.0.2",
|
package/dist/checkpoints.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type AutomergeUrl, type DocHandle, type Repo } from "@automerge/automerge-repo";
|
|
2
|
-
export type CheckpointKind = "save" | "merge";
|
|
3
|
-
export type CheckpointSource = {
|
|
4
|
-
name: string;
|
|
5
|
-
url: AutomergeUrl;
|
|
6
|
-
heads: string[];
|
|
7
|
-
};
|
|
8
|
-
export type Checkpoint = {
|
|
9
|
-
id: string;
|
|
10
|
-
ts: number;
|
|
11
|
-
kind: CheckpointKind;
|
|
12
|
-
headsBefore: string[];
|
|
13
|
-
headsAfter: string[];
|
|
14
|
-
message?: string;
|
|
15
|
-
source?: CheckpointSource;
|
|
16
|
-
};
|
|
17
|
-
export type CheckpointsDoc = {
|
|
18
|
-
"@patchwork": {
|
|
19
|
-
type: "checkpoints";
|
|
20
|
-
};
|
|
21
|
-
entries: {
|
|
22
|
-
[id: string]: Checkpoint;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
export declare const isCheckpointsDoc: (doc: unknown) => doc is CheckpointsDoc;
|
|
26
|
-
export declare function makeCheckpointId(ts?: number): string;
|
|
27
|
-
export declare function findOrCreateCheckpoints(repo: Repo, folderHandle: DocHandle<unknown>): Promise<DocHandle<CheckpointsDoc>>;
|
|
28
|
-
export declare function cloneCheckpointsTo(repo: Repo, sourceFolder: DocHandle<unknown>, targetFolder: DocHandle<unknown>): Promise<AutomergeUrl | null>;
|
|
29
|
-
export type AppendArgs = {
|
|
30
|
-
kind: CheckpointKind;
|
|
31
|
-
headsBefore: string[];
|
|
32
|
-
headsAfter: string[];
|
|
33
|
-
message?: string;
|
|
34
|
-
source?: CheckpointSource;
|
|
35
|
-
force?: boolean;
|
|
36
|
-
};
|
|
37
|
-
export declare function appendCheckpointTo(checkpoints: DocHandle<CheckpointsDoc>, args: AppendArgs): Checkpoint | null;
|
|
38
|
-
export declare function listCheckpoints(doc: CheckpointsDoc): Checkpoint[];
|
|
39
|
-
export declare function topoSort(entries: Checkpoint[]): Checkpoint[];
|
|
40
|
-
export declare function getFolderHeads(folderHandle: DocHandle<unknown>): string[];
|
|
41
|
-
//# sourceMappingURL=checkpoints.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoints.d.ts","sourceRoot":"","sources":["../src/checkpoints.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,IAAI,EACT,MAAM,2BAA2B,CAAC;AAQnC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,OAAO,CAAC;AAE9C,MAAM,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,YAAY,CAAC;IAClB,KAAK,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE;QAAE,IAAI,EAAE,aAAa,CAAA;KAAE,CAAC;IACtC,OAAO,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;CACtC,CAAC;AAKF,eAAO,MAAM,gBAAgB,GAAI,KAAK,OAAO,KAAG,GAAG,IAAI,cAQtD,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAAE,SAAa,GAAG,MAAM,CAMxD;AAED,wBAAsB,uBAAuB,CAC5C,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,GAC9B,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAuBpC;AAED,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,EAChC,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,GAC9B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAiB9B;AAED,MAAM,MAAM,UAAU,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,wBAAgB,kBAAkB,CACjC,WAAW,EAAE,SAAS,CAAC,cAAc,CAAC,EACtC,IAAI,EAAE,UAAU,GACd,UAAU,GAAG,IAAI,CAqBnB;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,cAAc,GAAG,UAAU,EAAE,CAEjE;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,UAAU,EAAE,CAuD5D;AAeD,wBAAgB,cAAc,CAAC,YAAY,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,EAAE,CAIzE"}
|
package/dist/checkpoints.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
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.isCheckpointsDoc = void 0;
|
|
37
|
-
exports.makeCheckpointId = makeCheckpointId;
|
|
38
|
-
exports.findOrCreateCheckpoints = findOrCreateCheckpoints;
|
|
39
|
-
exports.cloneCheckpointsTo = cloneCheckpointsTo;
|
|
40
|
-
exports.appendCheckpointTo = appendCheckpointTo;
|
|
41
|
-
exports.listCheckpoints = listCheckpoints;
|
|
42
|
-
exports.topoSort = topoSort;
|
|
43
|
-
exports.getFolderHeads = getFolderHeads;
|
|
44
|
-
const Automerge = __importStar(require("@automerge/automerge"));
|
|
45
|
-
const log_js_1 = require("./log.js");
|
|
46
|
-
const dlog = (0, log_js_1.log)("checkpoints");
|
|
47
|
-
const META = "@patchwork";
|
|
48
|
-
const TYPE = "checkpoints";
|
|
49
|
-
const isCheckpointsDoc = (doc) => {
|
|
50
|
-
if (!doc || typeof doc !== "object")
|
|
51
|
-
return false;
|
|
52
|
-
const meta = doc[META];
|
|
53
|
-
return (!!meta &&
|
|
54
|
-
typeof meta === "object" &&
|
|
55
|
-
meta.type === TYPE);
|
|
56
|
-
};
|
|
57
|
-
exports.isCheckpointsDoc = isCheckpointsDoc;
|
|
58
|
-
function makeCheckpointId(ts = Date.now()) {
|
|
59
|
-
const tsPart = ts.toString(36).padStart(9, "0");
|
|
60
|
-
const rand = Math.floor(Math.random() * 36 ** 6)
|
|
61
|
-
.toString(36)
|
|
62
|
-
.padStart(6, "0");
|
|
63
|
-
return `${tsPart}-${rand}`;
|
|
64
|
-
}
|
|
65
|
-
async function findOrCreateCheckpoints(repo, folderHandle) {
|
|
66
|
-
const folder = folderHandle.doc();
|
|
67
|
-
const existing = folder?.["@patchwork"]?.checkpoints;
|
|
68
|
-
if (existing) {
|
|
69
|
-
const handle = await repo.find(existing);
|
|
70
|
-
const doc = handle.doc();
|
|
71
|
-
if ((0, exports.isCheckpointsDoc)(doc))
|
|
72
|
-
return handle;
|
|
73
|
-
dlog("checkpoints url %s on folder %s is not a checkpoints doc; recreating", existing, folderHandle.url);
|
|
74
|
-
}
|
|
75
|
-
const created = repo.create({
|
|
76
|
-
"@patchwork": { type: TYPE },
|
|
77
|
-
entries: {},
|
|
78
|
-
});
|
|
79
|
-
folderHandle.change((d) => {
|
|
80
|
-
if (!d["@patchwork"])
|
|
81
|
-
d["@patchwork"] = { type: "folder" };
|
|
82
|
-
d["@patchwork"].checkpoints = created.url;
|
|
83
|
-
});
|
|
84
|
-
dlog("created checkpoints %s for folder %s", created.url, folderHandle.url);
|
|
85
|
-
return created;
|
|
86
|
-
}
|
|
87
|
-
async function cloneCheckpointsTo(repo, sourceFolder, targetFolder) {
|
|
88
|
-
const src = sourceFolder.doc();
|
|
89
|
-
const url = src?.["@patchwork"]?.checkpoints;
|
|
90
|
-
if (!url)
|
|
91
|
-
return null;
|
|
92
|
-
const sourceHandle = await repo.find(url);
|
|
93
|
-
const cloned = repo.clone(sourceHandle);
|
|
94
|
-
targetFolder.change((d) => {
|
|
95
|
-
if (!d["@patchwork"])
|
|
96
|
-
d["@patchwork"] = { type: "folder" };
|
|
97
|
-
d["@patchwork"].checkpoints = cloned.url;
|
|
98
|
-
});
|
|
99
|
-
dlog("cloned checkpoints %s → %s for folder %s", url, cloned.url, targetFolder.url);
|
|
100
|
-
return cloned.url;
|
|
101
|
-
}
|
|
102
|
-
function appendCheckpointTo(checkpoints, args) {
|
|
103
|
-
if (!args.force && headsEqual(args.headsBefore, args.headsAfter)) {
|
|
104
|
-
dlog("skip append: heads unchanged");
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
const ts = Date.now();
|
|
108
|
-
const id = makeCheckpointId(ts);
|
|
109
|
-
const entry = {
|
|
110
|
-
id,
|
|
111
|
-
ts,
|
|
112
|
-
kind: args.kind,
|
|
113
|
-
headsBefore: [...args.headsBefore].sort(),
|
|
114
|
-
headsAfter: [...args.headsAfter].sort(),
|
|
115
|
-
};
|
|
116
|
-
if (args.message)
|
|
117
|
-
entry.message = args.message;
|
|
118
|
-
if (args.source)
|
|
119
|
-
entry.source = args.source;
|
|
120
|
-
checkpoints.change((d) => {
|
|
121
|
-
d.entries[id] = entry;
|
|
122
|
-
});
|
|
123
|
-
dlog("appended %s (kind=%s)", id, args.kind);
|
|
124
|
-
return entry;
|
|
125
|
-
}
|
|
126
|
-
function listCheckpoints(doc) {
|
|
127
|
-
return Object.values(doc.entries ?? {});
|
|
128
|
-
}
|
|
129
|
-
function topoSort(entries) {
|
|
130
|
-
// Stable order: build a graph where parents are checkpoints whose
|
|
131
|
-
// headsAfter is a subset of this checkpoint's headsBefore. Topo-sort with
|
|
132
|
-
// ts as tiebreaker. Returns oldest-first.
|
|
133
|
-
const byHeadKey = new Map();
|
|
134
|
-
for (const e of entries) {
|
|
135
|
-
const k = headsKey(e.headsAfter);
|
|
136
|
-
const list = byHeadKey.get(k) ?? [];
|
|
137
|
-
list.push(e);
|
|
138
|
-
byHeadKey.set(k, list);
|
|
139
|
-
}
|
|
140
|
-
const parentsOf = new Map();
|
|
141
|
-
for (const e of entries) {
|
|
142
|
-
const ps = new Set();
|
|
143
|
-
// A checkpoint p is a parent of e if p.headsAfter ⊆ e.headsBefore.
|
|
144
|
-
// Approximation: any p whose headsAfter equals e.headsBefore, OR any
|
|
145
|
-
// proper subset whose union with siblings covers headsBefore. The
|
|
146
|
-
// subset case requires more work; for v1 we just match exact headsAfter
|
|
147
|
-
// → headsBefore equality and headsBefore contains-each-individual-hash.
|
|
148
|
-
const beforeSet = new Set(e.headsBefore);
|
|
149
|
-
for (const candidate of entries) {
|
|
150
|
-
if (candidate.id === e.id)
|
|
151
|
-
continue;
|
|
152
|
-
if (candidate.headsAfter.every((h) => beforeSet.has(h))) {
|
|
153
|
-
ps.add(candidate.id);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
parentsOf.set(e.id, ps);
|
|
157
|
-
}
|
|
158
|
-
const indegree = new Map();
|
|
159
|
-
for (const e of entries)
|
|
160
|
-
indegree.set(e.id, parentsOf.get(e.id).size);
|
|
161
|
-
const ready = entries
|
|
162
|
-
.filter((e) => indegree.get(e.id) === 0)
|
|
163
|
-
.sort(byTs);
|
|
164
|
-
const out = [];
|
|
165
|
-
const seen = new Set();
|
|
166
|
-
while (ready.length) {
|
|
167
|
-
ready.sort(byTs);
|
|
168
|
-
const next = ready.shift();
|
|
169
|
-
if (seen.has(next.id))
|
|
170
|
-
continue;
|
|
171
|
-
seen.add(next.id);
|
|
172
|
-
out.push(next);
|
|
173
|
-
for (const e of entries) {
|
|
174
|
-
if (seen.has(e.id))
|
|
175
|
-
continue;
|
|
176
|
-
const ps = parentsOf.get(e.id);
|
|
177
|
-
if (ps.has(next.id)) {
|
|
178
|
-
const remaining = (indegree.get(e.id) ?? 0) - 1;
|
|
179
|
-
indegree.set(e.id, remaining);
|
|
180
|
-
if (remaining === 0)
|
|
181
|
-
ready.push(e);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
for (const e of entries) {
|
|
186
|
-
if (!seen.has(e.id))
|
|
187
|
-
out.push(e);
|
|
188
|
-
}
|
|
189
|
-
return out;
|
|
190
|
-
}
|
|
191
|
-
const byTs = (a, b) => a.ts - b.ts || a.id.localeCompare(b.id);
|
|
192
|
-
function headsEqual(a, b) {
|
|
193
|
-
if (a.length !== b.length)
|
|
194
|
-
return false;
|
|
195
|
-
const set = new Set(a);
|
|
196
|
-
for (const h of b)
|
|
197
|
-
if (!set.has(h))
|
|
198
|
-
return false;
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
function headsKey(heads) {
|
|
202
|
-
return [...heads].sort().join(",");
|
|
203
|
-
}
|
|
204
|
-
function getFolderHeads(folderHandle) {
|
|
205
|
-
const doc = folderHandle.doc();
|
|
206
|
-
if (!doc)
|
|
207
|
-
return [];
|
|
208
|
-
return Automerge.getHeads(doc);
|
|
209
|
-
}
|
|
210
|
-
//# sourceMappingURL=checkpoints.js.map
|
package/dist/checkpoints.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkpoints.js","sourceRoot":"","sources":["../src/checkpoints.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,4CAMC;AAED,0DA0BC;AAED,gDAqBC;AAWD,gDAwBC;AAED,0CAEC;AAED,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