dsh-keeper-plugin 0.1.7 → 0.1.8
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 +30 -33
- package/client.js +2067 -238
- package/index.js +81 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -28,7 +28,7 @@ export const inject = [
|
|
|
28
28
|
const NS = 'dsh-keeper';
|
|
29
29
|
const PANEL_ID = 'dsh-keeper';
|
|
30
30
|
const API_PATH = '/dsh-keeper/api';
|
|
31
|
-
const PLUGIN_VERSION = '0.1.
|
|
31
|
+
const PLUGIN_VERSION = '0.1.8';
|
|
32
32
|
const META_NAME = '.dsh-keeper-trash.json';
|
|
33
33
|
/** Pre-rename identifiers. Kept only so existing installs migrate in place. */
|
|
34
34
|
const LEGACY_NS = 'sidebar-studio';
|
|
@@ -101,6 +101,9 @@ const DEFAULT_SETTINGS = {
|
|
|
101
101
|
defaultExportFormat: 'md',
|
|
102
102
|
rowPreview: { enabled: true, delay: 400 },
|
|
103
103
|
notifications: { ...NOTIFY_DEFAULTS },
|
|
104
|
+
// Manual "auto clean" suggestions; the client only previews and executes
|
|
105
|
+
// after an explicit confirmation, never on a background timer.
|
|
106
|
+
autoClean: { enabled: false, idleDays: 30, sizeMb: 100, includeBlank: false, action: 'archive', excludedWorkspaces: [] },
|
|
104
107
|
};
|
|
105
108
|
|
|
106
109
|
function normalizeSoundEntry(value) {
|
|
@@ -317,6 +320,47 @@ function readDisabledPatches() {
|
|
|
317
320
|
return rows;
|
|
318
321
|
}
|
|
319
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Read every profile patch block that toggles one plugin with a literal boolean
|
|
325
|
+
* `disabled`, so the UI can tell a manual override from the installation default.
|
|
326
|
+
* Conditional (`!!js`) patches are reported as conditional and never guessed.
|
|
327
|
+
*/
|
|
328
|
+
function readProfileOverrides() {
|
|
329
|
+
let text = '';
|
|
330
|
+
try {
|
|
331
|
+
text = fs.readFileSync(profilePatchFile(), 'utf8');
|
|
332
|
+
} catch {
|
|
333
|
+
return [];
|
|
334
|
+
}
|
|
335
|
+
const lines = text.split(/\r?\n/);
|
|
336
|
+
const blocks = [];
|
|
337
|
+
let current = null;
|
|
338
|
+
for (const line of lines) {
|
|
339
|
+
if (PATCH_BLOCK_START.test(line) || line.trim() === '-') {
|
|
340
|
+
if (current) blocks.push(current);
|
|
341
|
+
current = { lines: [line] };
|
|
342
|
+
} else if (current) {
|
|
343
|
+
current.lines.push(line);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (current) blocks.push(current);
|
|
347
|
+
const rows = [];
|
|
348
|
+
for (const block of blocks) {
|
|
349
|
+
const body = block.lines.join('\n');
|
|
350
|
+
const idMatch = block.lines.map((line) => line.match(PATCH_BLOCK_ID)).find(Boolean);
|
|
351
|
+
if (!idMatch) continue;
|
|
352
|
+
const literal = body.match(/^\s*disabled:\s*(true|false)\s*$/m);
|
|
353
|
+
const conditional = /^\s*disabled:\s*!!js/m.test(body) || /!!js|!!str/.test(body);
|
|
354
|
+
if (!literal && !conditional) continue;
|
|
355
|
+
rows.push({
|
|
356
|
+
id: idMatch[1],
|
|
357
|
+
disabled: literal ? literal[1] === 'true' : null,
|
|
358
|
+
conditional,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
return rows;
|
|
362
|
+
}
|
|
363
|
+
|
|
320
364
|
/** Remove one pure `- id / disabled: true` override so the Loader mounts it again. */
|
|
321
365
|
function enableDisabledPatch(patchId) {
|
|
322
366
|
let text = '';
|
|
@@ -397,6 +441,7 @@ function readState() {
|
|
|
397
441
|
defaultExportFormat: normalizeExportFormat(settings.defaultExportFormat),
|
|
398
442
|
rowPreview: normalizeRowPreview(settings.rowPreview),
|
|
399
443
|
notifications: normalizeNotificationSettings(settings.notifications),
|
|
444
|
+
autoClean: normalizeAutoCleanSettings(settings.autoClean),
|
|
400
445
|
},
|
|
401
446
|
updatedAt: typeof state.updatedAt === 'number' ? state.updatedAt : 0,
|
|
402
447
|
};
|
|
@@ -412,6 +457,7 @@ function writeState(state) {
|
|
|
412
457
|
defaultExportFormat: normalizeExportFormat(state.settings?.defaultExportFormat),
|
|
413
458
|
rowPreview: normalizeRowPreview(state.settings?.rowPreview),
|
|
414
459
|
notifications: normalizeNotificationSettings(state.settings?.notifications),
|
|
460
|
+
autoClean: normalizeAutoCleanSettings(state.settings?.autoClean),
|
|
415
461
|
},
|
|
416
462
|
updatedAt: Date.now(),
|
|
417
463
|
};
|
|
@@ -1555,6 +1601,33 @@ function normalizeRowPreview(value) {
|
|
|
1555
1601
|
return { enabled: raw.enabled !== false, delay };
|
|
1556
1602
|
}
|
|
1557
1603
|
|
|
1604
|
+
const AUTO_CLEAN_ACTIONS = ['archive', 'trash'];
|
|
1605
|
+
|
|
1606
|
+
function normalizeAutoCleanSettings(value) {
|
|
1607
|
+
const raw = value && typeof value === 'object' ? value : {};
|
|
1608
|
+
const clampInt = (input, min, max, fallback) => {
|
|
1609
|
+
const number = Number(input);
|
|
1610
|
+
if (!Number.isFinite(number)) return fallback;
|
|
1611
|
+
return Math.min(max, Math.max(min, Math.round(number)));
|
|
1612
|
+
};
|
|
1613
|
+
return {
|
|
1614
|
+
enabled: raw.enabled === true,
|
|
1615
|
+
idleDays: clampInt(raw.idleDays, 0, 3650, 30),
|
|
1616
|
+
sizeMb: clampInt(raw.sizeMb, 0, 102400, 100),
|
|
1617
|
+
includeBlank: raw.includeBlank === true,
|
|
1618
|
+
action: AUTO_CLEAN_ACTIONS.includes(raw.action) ? raw.action : 'archive',
|
|
1619
|
+
excludedWorkspaces: Array.isArray(raw.excludedWorkspaces)
|
|
1620
|
+
? [
|
|
1621
|
+
...new Set(
|
|
1622
|
+
raw.excludedWorkspaces.filter(
|
|
1623
|
+
(id) => typeof id === 'string' && id.length > 0 && id.length < 200,
|
|
1624
|
+
),
|
|
1625
|
+
),
|
|
1626
|
+
]
|
|
1627
|
+
: [],
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1558
1631
|
function contentTextOf(content) {
|
|
1559
1632
|
if (!Array.isArray(content)) return '';
|
|
1560
1633
|
const parts = [];
|
|
@@ -2855,6 +2928,7 @@ function createApi(ctx) {
|
|
|
2855
2928
|
}
|
|
2856
2929
|
return readPluginScopes(ctx);
|
|
2857
2930
|
},
|
|
2931
|
+
profileOverrides: () => ({ overrides: readProfileOverrides() }),
|
|
2858
2932
|
notifications: async (payload) => readNotifications(ctx, payload),
|
|
2859
2933
|
debugLog: async (payload) => {
|
|
2860
2934
|
if (payload && typeof payload.message === 'string') {
|
|
@@ -2903,6 +2977,12 @@ function createApi(ctx) {
|
|
|
2903
2977
|
...patch.notifications,
|
|
2904
2978
|
});
|
|
2905
2979
|
}
|
|
2980
|
+
if (patch.autoClean && typeof patch.autoClean === 'object') {
|
|
2981
|
+
state.settings.autoClean = normalizeAutoCleanSettings({
|
|
2982
|
+
...state.settings.autoClean,
|
|
2983
|
+
...patch.autoClean,
|
|
2984
|
+
});
|
|
2985
|
+
}
|
|
2906
2986
|
const saved = writeState(state);
|
|
2907
2987
|
return { state: saved };
|
|
2908
2988
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-keeper-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "DSH Keeper — manage DSH workspace sessions, plugins, sidebar entries, and notifications in one place. DSH 管家:集中管理 DSH 的会话、插件、侧栏入口与通知。",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"type": "module",
|