buddy-workbench 0.1.95 → 0.1.97
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/package.json +1 -1
- package/server/repositories/mind-maps.js +20 -8
- package/server/services/clipboard-history.js +3 -10
- package/ui/dist/assets/{index-CcKx7GkZ.js → index-41Ki6jmf.js} +4 -4
- package/ui/dist/assets/{xmindAdapter-Y1nz1qKM.js → xmindAdapter-gz8L6wua.js} +1 -1
- package/ui/dist/index.html +1 -1
- package/ui/dist/sw.js +2 -2
package/package.json
CHANGED
|
@@ -10,6 +10,10 @@ import { join } from 'node:path';
|
|
|
10
10
|
import { paths } from '../config.js';
|
|
11
11
|
|
|
12
12
|
const getMapFilename = (id) => `${encodeURIComponent(String(id))}.json`;
|
|
13
|
+
const getTimestamp = (value) => {
|
|
14
|
+
const timestamp = Date.parse(String(value || ''));
|
|
15
|
+
return Number.isFinite(timestamp) ? timestamp : 0;
|
|
16
|
+
};
|
|
13
17
|
|
|
14
18
|
function ensureMindMapsDir() {
|
|
15
19
|
mkdirSync(paths.mindMaps, { recursive: true });
|
|
@@ -54,14 +58,22 @@ function migrateLegacyMindMaps() {
|
|
|
54
58
|
export function listMindMaps() {
|
|
55
59
|
try {
|
|
56
60
|
migrateLegacyMindMaps();
|
|
57
|
-
return mapFiles()
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
return mapFiles()
|
|
62
|
+
.flatMap((filename) => {
|
|
63
|
+
try {
|
|
64
|
+
const parsed = JSON.parse(readFileSync(join(paths.mindMaps, filename), 'utf8'));
|
|
65
|
+
return parsed && typeof parsed === 'object' ? [parsed] : [];
|
|
66
|
+
} catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
.sort((left, right) => {
|
|
71
|
+
const updatedDifference = getTimestamp(right.updatedAt) - getTimestamp(left.updatedAt);
|
|
72
|
+
if (updatedDifference) return updatedDifference;
|
|
73
|
+
const createdDifference = getTimestamp(right.createdAt) - getTimestamp(left.createdAt);
|
|
74
|
+
if (createdDifference) return createdDifference;
|
|
75
|
+
return String(left.id || '').localeCompare(String(right.id || ''));
|
|
76
|
+
});
|
|
65
77
|
} catch {
|
|
66
78
|
return [];
|
|
67
79
|
}
|
|
@@ -113,8 +113,7 @@ async function getMacClipboardImageData() {
|
|
|
113
113
|
const base64 = str.slice(secondColon + 1);
|
|
114
114
|
if (!width || !height || !base64) return null;
|
|
115
115
|
return { width, height, rgbaBuf: Buffer.from(base64, 'base64') };
|
|
116
|
-
} catch
|
|
117
|
-
logClipboardError('macOS image clipboard read (osascript)', error);
|
|
116
|
+
} catch {
|
|
118
117
|
// If osascript failed with an error, attempt the Swift fallback for image capture
|
|
119
118
|
const rawBuffer = await getMacClipboardImageBuffer();
|
|
120
119
|
if (rawBuffer && rawBuffer.length > 0) {
|
|
@@ -147,14 +146,10 @@ if let data = pb.data(forType: .png) {
|
|
|
147
146
|
swiftClipboardRetryAt = 0;
|
|
148
147
|
return stdout;
|
|
149
148
|
}
|
|
150
|
-
} catch
|
|
149
|
+
} catch {
|
|
151
150
|
// Back off before trying Swift again. A failed `swift -e` invocation is
|
|
152
151
|
// commonly persistent and clipboard polling runs every two seconds.
|
|
153
152
|
swiftClipboardRetryAt = Date.now() + 5 * 60 * 1000;
|
|
154
|
-
logClipboardError('macOS image clipboard read (Swift)', error);
|
|
155
|
-
// This failure is now rate-limited by the retry window; don't let the
|
|
156
|
-
// displayed "consecutive failures" grow without bound.
|
|
157
|
-
clipboardErrorCounts.delete('macOS image clipboard read (Swift)');
|
|
158
153
|
try {
|
|
159
154
|
const jsaScript = `
|
|
160
155
|
ObjC.import("AppKit");
|
|
@@ -180,9 +175,7 @@ if let data = pb.data(forType: .png) {
|
|
|
180
175
|
markClipboardSuccess('macOS image clipboard fallback read (osascript)');
|
|
181
176
|
return Buffer.from(str, 'base64');
|
|
182
177
|
}
|
|
183
|
-
} catch
|
|
184
|
-
logClipboardError('macOS image clipboard fallback read (osascript)', fallbackError);
|
|
185
|
-
}
|
|
178
|
+
} catch {}
|
|
186
179
|
}
|
|
187
180
|
return null;
|
|
188
181
|
}
|