truecanvas 0.3.0 → 0.4.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 +31 -2
- package/dist/chunk-M7B3W7EP.js +659 -0
- package/dist/{chunk-XWQ5MS24.js → chunk-OVYSWA2F.js} +27 -7
- package/dist/cli.js +899 -213
- package/dist/core/index.d.ts +14 -1
- package/dist/core/index.js +1 -1
- package/dist/editor/assets/{Menu-DXPm0EXo.css → Menu-BJ3OmqzH.css} +1 -1
- package/dist/editor/assets/{hub-UhU8yp5F.js → hub-B5hqZCM2.js} +1 -1
- package/dist/editor/assets/{main-UtSaCfnK.js → main-woTyWmya.js} +5 -5
- package/dist/editor/hub.html +3 -3
- package/dist/editor/index.html +3 -3
- package/dist/share/index.d.ts +36 -0
- package/dist/share/index.js +6 -0
- package/package.json +5 -1
- /package/dist/editor/assets/{Menu-BFifVcgz.js → Menu-C0Ti-6T2.js} +0 -0
|
@@ -984,21 +984,30 @@ var Comments = class {
|
|
|
984
984
|
file(canvas) {
|
|
985
985
|
return path2.join(this.config.root, this.config.canvasDir, `${assertCanvasName(canvas)}.comments.json`);
|
|
986
986
|
}
|
|
987
|
-
|
|
987
|
+
read(canvas) {
|
|
988
988
|
try {
|
|
989
|
-
|
|
989
|
+
const f = JSON.parse(fs2.readFileSync(this.file(canvas), "utf8"));
|
|
990
|
+
return { version: 1, threads: f.threads ?? [], dismissed: f.dismissed };
|
|
990
991
|
} catch {
|
|
991
|
-
return [];
|
|
992
|
+
return { version: 1, threads: [] };
|
|
992
993
|
}
|
|
993
994
|
}
|
|
994
|
-
|
|
995
|
+
list(canvas) {
|
|
996
|
+
return this.read(canvas).threads;
|
|
997
|
+
}
|
|
998
|
+
/** Ids of client threads deleted here. */
|
|
999
|
+
dismissed(canvas) {
|
|
1000
|
+
return new Set(this.read(canvas).dismissed ?? []);
|
|
1001
|
+
}
|
|
1002
|
+
save(canvas, threads, dismissed = this.read(canvas).dismissed) {
|
|
995
1003
|
const file = this.file(canvas);
|
|
996
|
-
if (!threads.length) {
|
|
1004
|
+
if (!threads.length && !dismissed?.length) {
|
|
997
1005
|
if (fs2.existsSync(file)) fs2.rmSync(file);
|
|
998
1006
|
return;
|
|
999
1007
|
}
|
|
1000
1008
|
fs2.mkdirSync(path2.dirname(file), { recursive: true });
|
|
1001
|
-
|
|
1009
|
+
const data = { version: 1, threads, ...dismissed?.length ? { dismissed } : {} };
|
|
1010
|
+
fs2.writeFileSync(file, `${JSON.stringify(data, null, 2)}
|
|
1002
1011
|
`);
|
|
1003
1012
|
}
|
|
1004
1013
|
update(canvas, id, fn) {
|
|
@@ -1036,12 +1045,23 @@ var Comments = class {
|
|
|
1036
1045
|
return this.update(canvas, id, (t) => {
|
|
1037
1046
|
t.resolved = resolved;
|
|
1038
1047
|
t.resolvedBy = resolved ? author : void 0;
|
|
1048
|
+
t.resolvedAt = Date.now();
|
|
1039
1049
|
});
|
|
1040
1050
|
}
|
|
1051
|
+
/** Applies synced threads (from a share link) in one write; returns whether anything changed. */
|
|
1052
|
+
merge(canvas, fn) {
|
|
1053
|
+
const threads = this.list(canvas);
|
|
1054
|
+
if (!fn(threads)) return false;
|
|
1055
|
+
this.save(canvas, threads);
|
|
1056
|
+
return true;
|
|
1057
|
+
}
|
|
1041
1058
|
remove(canvas, id) {
|
|
1059
|
+
const { threads, dismissed = [] } = this.read(canvas);
|
|
1060
|
+
const gone = threads.find((t) => t.id === id);
|
|
1042
1061
|
this.save(
|
|
1043
1062
|
canvas,
|
|
1044
|
-
|
|
1063
|
+
threads.filter((t) => t.id !== id),
|
|
1064
|
+
gone?.share ? [.../* @__PURE__ */ new Set([...dismissed, id])] : dismissed
|
|
1045
1065
|
);
|
|
1046
1066
|
}
|
|
1047
1067
|
/** Frames keep their comments when renamed. */
|