@tnotesjs/core 0.1.24 → 0.1.26

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.
Files changed (74) hide show
  1. package/config/defaultConfig.ts +145 -0
  2. package/dist/{chunk-BSTQOJVE.js → chunk-4KG6RXFS.js} +113 -130
  3. package/dist/{chunk-O4DCXHOV.js → chunk-AGSL3VZE.js} +1 -4
  4. package/dist/cli/index.js +162 -173
  5. package/dist/index.js +1 -1
  6. package/dist/vitepress/config/index.js +6 -8
  7. package/package.json +5 -1
  8. package/types/config.ts +1 -1
  9. package/types/index.ts +1 -1
  10. package/types/note.ts +1 -1
  11. package/vitepress/assets/icons/index.ts +1 -1
  12. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +4 -0
  13. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +4 -0
  14. package/vitepress/components/CodeBlockFullscreen/index.ts +8 -0
  15. package/vitepress/components/CodeBlockFullscreen/styles.css +4 -0
  16. package/vitepress/components/Discussions/Discussions.vue +4 -0
  17. package/vitepress/components/EnWordList/EnWordList.vue +4 -0
  18. package/vitepress/components/EnWordList/RightClickMenu.vue +4 -0
  19. package/vitepress/components/Footprints/Footprints.vue +4 -0
  20. package/vitepress/components/Layout/AboutModal.vue +4 -0
  21. package/vitepress/components/Layout/AboutPanel.vue +4 -0
  22. package/vitepress/components/Layout/ContentCollapse.vue +4 -0
  23. package/vitepress/components/Layout/CustomSidebar.vue +4 -0
  24. package/vitepress/components/Layout/DocBeforeControls.vue +4 -0
  25. package/vitepress/components/Layout/DocFooter.vue +4 -0
  26. package/vitepress/components/Layout/ImagePreview.vue +4 -0
  27. package/vitepress/components/Layout/Layout.vue +4 -0
  28. package/vitepress/components/Layout/NavBarSettingsTrigger.vue +4 -0
  29. package/vitepress/components/Layout/NoteStatus.vue +4 -0
  30. package/vitepress/components/Layout/SidebarItems.vue +4 -0
  31. package/vitepress/components/Layout/SidebarNavBefore.vue +4 -0
  32. package/vitepress/components/Layout/SidebarResizeHandle.vue +5 -1
  33. package/vitepress/components/Layout/Swiper.vue +4 -0
  34. package/vitepress/components/Layout/ToggleFullContent.vue +4 -0
  35. package/vitepress/components/Layout/ToggleSidebar.vue +4 -1
  36. package/vitepress/components/Layout/composables/useCollapseControl.ts +6 -0
  37. package/vitepress/components/Layout/composables/useNoteConfig.ts +7 -0
  38. package/vitepress/components/Layout/composables/useNoteSave.ts +4 -0
  39. package/vitepress/components/Layout/composables/useNoteValidation.ts +8 -0
  40. package/vitepress/components/Layout/composables/useRedirect.ts +7 -0
  41. package/vitepress/components/Layout/composables/useRenameOverlay.ts +3 -0
  42. package/vitepress/components/Layout/composables/useRenameRedirect.ts +3 -0
  43. package/vitepress/components/Layout/composables/useSidebarLayout.ts +6 -0
  44. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +6 -0
  45. package/vitepress/components/Layout/homeReadme.data.ts +3 -1
  46. package/vitepress/components/LoadingPage/LoadingPage.vue +4 -0
  47. package/vitepress/components/MarkMap/MarkMap.vue +4 -0
  48. package/vitepress/components/Mermaid/Mermaid.vue +6 -0
  49. package/vitepress/components/NotesTable/NotesTable.vue +4 -0
  50. package/vitepress/components/Settings/Settings.vue +6 -0
  51. package/vitepress/components/Settings/SettingsDialog.vue +6 -0
  52. package/vitepress/components/Settings/composables/useSettingsDialog.ts +3 -0
  53. package/vitepress/components/SidebarCard/MindMapView.vue +4 -0
  54. package/vitepress/components/SidebarCard/NotesTrendChart.vue +4 -0
  55. package/vitepress/components/SidebarCard/SidebarCard.vue +4 -0
  56. package/vitepress/components/Tooltip/Tooltip.vue +6 -0
  57. package/vitepress/components/constants.ts +3 -0
  58. package/vitepress/components/notesConfig.data.ts +7 -1
  59. package/vitepress/components/sidebar.data.ts +1 -1
  60. package/vitepress/components/tnotes-config.data.ts +13 -8
  61. package/vitepress/components/utils.ts +6 -0
  62. package/vitepress/config/index.ts +5 -13
  63. package/vitepress/configs/constants.ts +1 -0
  64. package/vitepress/configs/head.config.ts +1 -0
  65. package/vitepress/configs/index.ts +1 -0
  66. package/vitepress/configs/markdown.config.ts +1 -0
  67. package/vitepress/configs/theme.config.ts +1 -0
  68. package/vitepress/plugins/buildProgressPlugin.ts +1 -1
  69. package/vitepress/plugins/fileWatcherBridgePlugin.ts +2 -1
  70. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +2 -1
  71. package/vitepress/plugins/renameNotePlugin.ts +2 -1
  72. package/vitepress/plugins/sidebarStructurePlugin.ts +3 -2
  73. package/vitepress/plugins/updateConfigPlugin.ts +2 -1
  74. package/vitepress/theme/index.ts +1 -4
@@ -0,0 +1,145 @@
1
+ /**
2
+ * config/defaultConfig.ts
3
+ *
4
+ * TNotes 项目配置默认值模板
5
+ */
6
+
7
+ import type { TNotesConfig } from '../types'
8
+
9
+ /**
10
+ * 生成默认配置
11
+ * @param repoName - 仓库名称(必需)
12
+ * @returns 默认配置对象
13
+ */
14
+ export function getDefaultConfig(repoName?: string): TNotesConfig {
15
+ const name = repoName || 'TNotes.default'
16
+ const cleanName = name.replace('TNotes.', '')
17
+
18
+ return {
19
+ // 基础信息
20
+ author: 'tnotesjs',
21
+ repoName: name,
22
+ keywords: [name],
23
+ id: '', // 由外部生成的 UUID
24
+
25
+ // Sidebar 配置
26
+ sidebarShowNoteId: true,
27
+
28
+ // 忽略目录
29
+ ignore_dirs: [
30
+ '.vscode',
31
+ '0000',
32
+ 'assets',
33
+ 'node_modules',
34
+ 'hidden',
35
+ 'demos',
36
+ ],
37
+
38
+ // 根目录项配置
39
+ root_item: {
40
+ icon: {
41
+ src: `https://cdn.jsdelivr.net/gh/tnotesjs/imgs@main/assets/icon--${cleanName}.svg`,
42
+ },
43
+ title: cleanName,
44
+ completed_notes_count: {},
45
+ details: `${name} 知识库`,
46
+ link: `https://tnotesjs.github.io/${name}/`,
47
+ created_at: Date.now(),
48
+ updated_at: Date.now(),
49
+ days_since_birth: 0,
50
+ },
51
+
52
+ // 端口配置(根据仓库名生成)
53
+ port: 8000,
54
+
55
+ // 菜单项
56
+ menuItems: [
57
+ {
58
+ text: '🏠 Home',
59
+ link: '/',
60
+ },
61
+ {
62
+ text: '📒 TNotes',
63
+ link: 'https://tnotesjs.github.io/notes',
64
+ },
65
+ {
66
+ text: '📂 TNotes.yuque',
67
+ link: 'https://www.yuque.com/tdahuyou/tnotes.yuque',
68
+ },
69
+ ],
70
+
71
+ // 社交链接
72
+ socialLinks: [
73
+ {
74
+ link: 'https://www.yuque.com/tdahuyou',
75
+ icon: {
76
+ svg: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="currentColor" d="M17.28 2.955c2.97.203 3.756 2.342 3.84 2.597l1.297.096c.13 0 .169.18.054.236c-1.323.716-1.727 2.17-1.49 3.118c.09.358.254.69.412 1.02c.307.642.651 1.418.707 2.981c.117 3.24-2.51 6.175-5.789 6.593c1.17-1.187 1.815-2.444 2.12-3.375c.606-1.846.508-3.316.055-4.44a4.46 4.46 0 0 0-1.782-2.141c-1.683-1.02-3.22-1.09-4.444-.762c.465-.594.876-1.201 1.2-1.864c.584-1.65-.102-2.848-.704-3.519c-.192-.246-.061-.655.305-.655c1.41 0 2.813.02 4.22.115M3.32 19.107c1.924-2.202 4.712-5.394 7.162-8.15c.559-.63 2.769-2.338 5.748-.533c.878.532 2.43 2.165 1.332 5.51c-.803 2.446-4.408 7.796-15.76 5.844c-.227-.039-.511-.354-.218-.687z"/></svg>',
77
+ },
78
+ },
79
+ {
80
+ link: 'https://space.bilibili.com/407241004',
81
+ icon: {
82
+ svg: '<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024"><g fill="currentColor"><path d="M310.134 596.45c-7.999-4.463-16.498-8.43-24.997-11.9a274 274 0 0 0-26.996-7.438c-2.5-.992-2.5.991-2.5 1.487c0 7.934.5 18.843 1.5 27.768c1 7.438 2 15.372 4 22.81c0 .496 0 .991.5 1.487c.999.992 1.999 1.488 2.999.496c7.999-4.463 15.998-8.43 22.997-13.388c7.499-5.454 15.498-11.9 21.997-18.347c1.5-1.487 0-2.479.5-2.975m323.96-11.9a274 274 0 0 0-26.997-7.438c-2.5-.992-2.5.991-2.5 1.487c0 7.934.5 18.843 1.5 27.768c1 7.438 2 15.372 4 22.81c0 .496 0 .991.5 1.487c1 .992 2 1.488 3 .496c7.999-4.463 15.998-8.43 22.997-13.388c7.499-5.454 15.498-11.9 21.997-18.347c2-1.487.5-2.479.5-2.975c-7.5-4.463-16.498-8.43-24.997-11.9"/><path d="M741.496 112H283c-94.501 0-171 76.5-171 171.5v458c.5 94 77 170.5 170.999 170.5h457.997c94.5 0 171.002-76.5 171.002-170.5v-458c.497-95-76.002-171.5-170.502-171.5m95 343.5h15.5v48h-15.5zm-95.5-1.5l2 43l-13.5 1.5l-5-44.5zm-23.5 0l4 45.5l-14.5 1.5l-6.5-47.5h17zm-230.498 1.5h15v48h-15zm-96-1.5l2 43l-13.5 1.5l-5-44.5zm-23.5 0l4 45.5l-14.5 2l-6-47.5zm-3.5 149C343.498 668.5 216 662.5 204.5 660.5C195.5 499 181.5 464 170 385l54.5-22.5c1 71.5 9 185 9 185s108.5-15.5 132 47c.5 3 0 6-1.5 8.5m20.5 35.5l-23.5-124h35.5l13 123zm44.5-8l-27-235l33.5-1.5l21 236H429zm34-175h17.5v48H467zm41 190h-26.5l-9.5-126h36zm209.998-43C693.496 668 565.997 662 554.497 660c-9-161-23-196-34.5-275l54.5-22.5c1 71.5 9 185 9 185s108.5-15.5 132 46.5c.5 3 0 6-1.5 8.5m19.5 36l-23-124h35.5l13 123zm45.5-8l-27.5-235l33.5-1.5l21 236h-27zm33.5-175h17.5v48h-13zm41 190h-26.5l-9.5-126h36z"/></g></svg>',
83
+ },
84
+ },
85
+ {
86
+ link: `https://github.com/tnotesjs/${name}`,
87
+ icon: 'github',
88
+ },
89
+ ],
90
+ }
91
+ }
92
+
93
+ /**
94
+ * 深度合并配置
95
+ * @param target - 目标对象(现有配置)
96
+ * @param source - 源对象(默认配置)
97
+ * @returns 合并后的配置
98
+ */
99
+ export function mergeConfig(
100
+ target: Record<string, any>,
101
+ source: Record<string, any>
102
+ ): Record<string, any> {
103
+ const result = { ...target }
104
+
105
+ for (const key in source) {
106
+ if (!(key in result)) {
107
+ // 如果字段不存在,直接添加
108
+ result[key] = source[key]
109
+ } else if (
110
+ typeof source[key] === 'object' &&
111
+ source[key] !== null &&
112
+ !Array.isArray(source[key])
113
+ ) {
114
+ // 如果是对象(非数组),递归合并
115
+ result[key] = mergeConfig(result[key] || {}, source[key])
116
+ }
117
+ // 如果字段已存在且不是对象,保留现有值
118
+ }
119
+
120
+ return result
121
+ }
122
+
123
+ /**
124
+ * 验证并补全配置
125
+ * @param config - 现有配置
126
+ * @returns 补全后的配置和是否进行了修改
127
+ */
128
+ export function validateAndCompleteConfig(config: Record<string, any>): {
129
+ config: TNotesConfig
130
+ modified: boolean
131
+ } {
132
+ const repoName = config.repoName || 'TNotes.default'
133
+ const defaultConfig = getDefaultConfig(repoName)
134
+
135
+ // 深度合并配置
136
+ const mergedConfig = mergeConfig(config, defaultConfig as any)
137
+
138
+ // 检查是否有修改
139
+ const modified = JSON.stringify(config) !== JSON.stringify(mergedConfig)
140
+
141
+ return {
142
+ config: mergedConfig as TNotesConfig,
143
+ modified,
144
+ }
145
+ }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfigManager,
3
3
  getConfigManager
4
- } from "./chunk-O4DCXHOV.js";
4
+ } from "./chunk-AGSL3VZE.js";
5
5
 
6
6
  // utils/errorHandler.ts
7
7
  var TNotesError = class _TNotesError extends Error {
@@ -95,10 +95,6 @@ var createError = {
95
95
 
96
96
  // utils/logger.ts
97
97
  var Logger = class _Logger {
98
- level;
99
- prefix;
100
- timestamp;
101
- colors;
102
98
  constructor(config2 = {}) {
103
99
  this.level = config2.level ?? 1 /* INFO */;
104
100
  this.prefix = config2.prefix ?? "";
@@ -624,9 +620,10 @@ var REPO_NOTES_URL = `https://github.com/${author}/${repoName}/tree/main/notes`;
624
620
 
625
621
  // core/NoteManager.ts
626
622
  var NoteManager = class _NoteManager {
627
- static instance;
628
- /** 笔记索引正则:4 位数字开头,后接小数点 */
629
- static NOTE_INDEX_REGEX = /^(\d{4})\./;
623
+ static {
624
+ /** 笔记索引正则:4 位数字开头,后接小数点 */
625
+ this.NOTE_INDEX_REGEX = /^(\d{4})\./;
626
+ }
630
627
  constructor() {
631
628
  }
632
629
  /**
@@ -778,30 +775,36 @@ var NoteManager = class _NoteManager {
778
775
  }
779
776
  return indexMap;
780
777
  }
781
- /** 配置字段顺序 */
782
- static FIELD_ORDER = [
783
- "bilibili",
784
- "tnotes",
785
- "yuque",
786
- "done",
787
- "category",
788
- "enableDiscussions",
789
- "description",
790
- "id",
791
- "created_at",
792
- "updated_at"
793
- ];
794
- /** 默认配置字段 */
795
- static DEFAULT_CONFIG_FIELDS = {
796
- bilibili: [],
797
- tnotes: [],
798
- yuque: [],
799
- done: false,
800
- enableDiscussions: false,
801
- description: ""
802
- };
803
- /** 必需字段(不能缺失) */
804
- static REQUIRED_FIELDS = ["id"];
778
+ static {
779
+ /** 配置字段顺序 */
780
+ this.FIELD_ORDER = [
781
+ "bilibili",
782
+ "tnotes",
783
+ "yuque",
784
+ "done",
785
+ "category",
786
+ "enableDiscussions",
787
+ "description",
788
+ "id",
789
+ "created_at",
790
+ "updated_at"
791
+ ];
792
+ }
793
+ static {
794
+ /** 默认配置字段 */
795
+ this.DEFAULT_CONFIG_FIELDS = {
796
+ bilibili: [],
797
+ tnotes: [],
798
+ yuque: [],
799
+ done: false,
800
+ enableDiscussions: false,
801
+ description: ""
802
+ };
803
+ }
804
+ static {
805
+ /** 必需字段(不能缺失) */
806
+ this.REQUIRED_FIELDS = ["id"];
807
+ }
805
808
  /**
806
809
  * 验证并修复配置文件
807
810
  * @param configPath - 配置文件路径
@@ -1143,14 +1146,16 @@ var COMMAND_OPTIONS = {
1143
1146
  // core/NoteIndexCache.ts
1144
1147
  import { join as join2 } from "path";
1145
1148
  var NoteIndexCache = class _NoteIndexCache {
1146
- static instance = null;
1147
- /** noteIndex -> NoteIndexItem 的映射 */
1148
- byNoteIndex = /* @__PURE__ */ new Map();
1149
- /** configId (UUID) -> noteIndex 的映射,用于快速反向查询 */
1150
- byConfigId = /* @__PURE__ */ new Map();
1151
- /** 是否已完成初始化 */
1152
- _initialized = false;
1153
1149
  constructor() {
1150
+ /** noteIndex -> NoteIndexItem 的映射 */
1151
+ this.byNoteIndex = /* @__PURE__ */ new Map();
1152
+ /** configId (UUID) -> noteIndex 的映射,用于快速反向查询 */
1153
+ this.byConfigId = /* @__PURE__ */ new Map();
1154
+ /** 是否已完成初始化 */
1155
+ this._initialized = false;
1156
+ }
1157
+ static {
1158
+ this.instance = null;
1154
1159
  }
1155
1160
  /**
1156
1161
  * 获取单例实例
@@ -1444,8 +1449,6 @@ var TocGenerator = class {
1444
1449
 
1445
1450
  // core/ReadmeGenerator.ts
1446
1451
  var ReadmeGenerator = class {
1447
- tocGenerator;
1448
- configManager;
1449
1452
  constructor() {
1450
1453
  this.tocGenerator = new TocGenerator();
1451
1454
  this.configManager = ConfigManager.getInstance();
@@ -1582,11 +1585,6 @@ var ReadmeGenerator = class {
1582
1585
 
1583
1586
  // services/readme/service.ts
1584
1587
  var ReadmeService = class _ReadmeService {
1585
- static instance;
1586
- noteManager;
1587
- readmeGenerator;
1588
- configManager;
1589
- noteIndexCache;
1590
1588
  constructor() {
1591
1589
  this.noteManager = NoteManager.getInstance();
1592
1590
  this.readmeGenerator = new ReadmeGenerator();
@@ -2138,11 +2136,8 @@ var NEW_NOTES_README_MD_TEMPLATE = `
2138
2136
  - todo
2139
2137
  `;
2140
2138
  var NoteService = class _NoteService {
2141
- static instance;
2142
- noteManager;
2143
- noteIndexCache;
2144
- ignoredConfigPaths = /* @__PURE__ */ new Set();
2145
2139
  constructor() {
2140
+ this.ignoredConfigPaths = /* @__PURE__ */ new Set();
2146
2141
  this.noteManager = NoteManager.getInstance();
2147
2142
  this.noteIndexCache = NoteIndexCache.getInstance();
2148
2143
  }
@@ -2434,25 +2429,21 @@ var DEFAULT_BATCH_BUFFER_MS = 2e3;
2434
2429
  var EventScheduler = class {
2435
2430
  constructor(config2) {
2436
2431
  this.config = config2;
2432
+ /** 待处理的文件变更事件队列 */
2433
+ this.pendingEvents = /* @__PURE__ */ new Map();
2434
+ /** 防抖定时器 */
2435
+ this.updateTimer = null;
2436
+ /** 批量更新恢复定时器 */
2437
+ this.batchResumeTimer = null;
2438
+ /** 记录最近的变更时间戳 */
2439
+ this.recentChanges = [];
2440
+ /** 标记是否正在更新,避免循环触发 - 类似一把更新行为锁 */
2441
+ this.isUpdating = false;
2437
2442
  this.debounceMs = config2.debounceMs ?? DEFAULT_DEBOUNCE_MS;
2438
2443
  this.batchWindowMs = config2.batchWindowMs ?? DEFAULT_BATCH_WINDOW_MS;
2439
2444
  this.batchThreshold = config2.batchThreshold ?? DEFAULT_BATCH_THRESHOLD;
2440
2445
  this.batchBufferMs = config2.batchBufferMs ?? DEFAULT_BATCH_BUFFER_MS;
2441
2446
  }
2442
- /** 待处理的文件变更事件队列 */
2443
- pendingEvents = /* @__PURE__ */ new Map();
2444
- /** 防抖定时器 */
2445
- updateTimer = null;
2446
- /** 批量更新恢复定时器 */
2447
- batchResumeTimer = null;
2448
- /** 记录最近的变更时间戳 */
2449
- recentChanges = [];
2450
- /** 标记是否正在更新,避免循环触发 - 类似一把更新行为锁 */
2451
- isUpdating = false;
2452
- debounceMs;
2453
- batchWindowMs;
2454
- batchThreshold;
2455
- batchBufferMs;
2456
2447
  /**
2457
2448
  * 设置更新状态锁,用于防止在执行耗时更新操作时被新的文件变更事件打断
2458
2449
  *
@@ -2574,9 +2565,9 @@ var UPDATE_UNLOCK_DELAY_MS = 500;
2574
2565
  var FolderChangeHandler = class {
2575
2566
  constructor(config2) {
2576
2567
  this.config = config2;
2568
+ /** 活跃的定时器 ID 集合,用于统一清理 */
2569
+ this.activeTimers = /* @__PURE__ */ new Set();
2577
2570
  }
2578
- /** 活跃的定时器 ID 集合,用于统一清理 */
2579
- activeTimers = /* @__PURE__ */ new Set();
2580
2571
  /**
2581
2572
  * 清理所有活跃定时器,释放资源
2582
2573
  *
@@ -2773,9 +2764,9 @@ import { basename, dirname, join as join5, sep } from "path";
2773
2764
  var FsWatcherAdapter = class {
2774
2765
  constructor(config2) {
2775
2766
  this.config = config2;
2767
+ /** 文件系统监听器实例 */
2768
+ this.watcher = null;
2776
2769
  }
2777
- /** 文件系统监听器实例 */
2778
- watcher = null;
2779
2770
  start() {
2780
2771
  const { logger: logger2 } = this.config;
2781
2772
  if (this.watcher) {
@@ -2893,11 +2884,11 @@ var FOLDER_RENAME_DETECT_WINDOW_MS = 500;
2893
2884
  var RenameDetector = class {
2894
2885
  constructor(config2) {
2895
2886
  this.config = config2;
2887
+ /** 待处理的文件夹重命名 */
2888
+ this.pendingFolderRename = null;
2889
+ /** 文件夹重命名检测定时器 */
2890
+ this.folderRenameTimer = null;
2896
2891
  }
2897
- /** 待处理的文件夹重命名 */
2898
- pendingFolderRename = null;
2899
- /** 文件夹重命名检测定时器 */
2900
- folderRenameTimer = null;
2901
2892
  handleFsRename(folderName) {
2902
2893
  const { notesDir, dirCache, logger: logger2, onDelete, onRename } = this.config;
2903
2894
  const folderPath = join6(notesDir, folderName);
@@ -2962,13 +2953,13 @@ import { join as join7 } from "path";
2962
2953
  var WatchState = class {
2963
2954
  constructor(config2) {
2964
2955
  this.config = config2;
2956
+ /** 文件哈希缓存 */
2957
+ this.fileHashes = /* @__PURE__ */ new Map();
2958
+ /** 笔记目录缓存 */
2959
+ this.noteDirCache = /* @__PURE__ */ new Set();
2960
+ /** 笔记配置缓存 */
2961
+ this.configCache = /* @__PURE__ */ new Map();
2965
2962
  }
2966
- /** 文件哈希缓存 */
2967
- fileHashes = /* @__PURE__ */ new Map();
2968
- /** 笔记目录缓存 */
2969
- noteDirCache = /* @__PURE__ */ new Set();
2970
- /** 笔记配置缓存 */
2971
- configCache = /* @__PURE__ */ new Map();
2972
2963
  /**
2973
2964
  * 获取指定文件的 MD5 哈希值,若文件不存在或读取失败返回 null
2974
2965
  *
@@ -3124,25 +3115,16 @@ var RENAME_BROADCAST_PATH = "/__tnotes_broadcast_rename";
3124
3115
  var FileWatcherService = class _FileWatcherService {
3125
3116
  constructor(notesDir = NOTES_DIR_PATH) {
3126
3117
  this.notesDir = notesDir;
3118
+ this.unlockTimer = null;
3127
3119
  if (!this.notesDir) {
3128
3120
  throw new Error(NOTES_DIR_NOT_SET_ERROR);
3129
3121
  }
3130
3122
  this.init();
3131
3123
  _FileWatcherService.instance = this;
3132
3124
  }
3133
- static instance = null;
3134
- watchState;
3135
- scheduler;
3136
- renameDetector;
3137
- configHandler;
3138
- readmeHandler;
3139
- coordinator;
3140
- folderHandler;
3141
- adapter;
3142
- noteService;
3143
- readmeService;
3144
- noteIndexCache;
3145
- unlockTimer = null;
3125
+ static {
3126
+ this.instance = null;
3127
+ }
3146
3128
  static getInstance() {
3147
3129
  return _FileWatcherService.instance;
3148
3130
  }
@@ -3367,8 +3349,6 @@ var FileWatcherService = class _FileWatcherService {
3367
3349
 
3368
3350
  // core/GitManager.ts
3369
3351
  var GitManager = class {
3370
- logger;
3371
- dir;
3372
3352
  constructor(dir, logger2) {
3373
3353
  this.dir = dir;
3374
3354
  this.logger = logger2?.child("git") || new Logger({ prefix: "git" });
@@ -3725,9 +3705,8 @@ var GitManager = class {
3725
3705
  // core/ProcessManager.ts
3726
3706
  import { spawn } from "child_process";
3727
3707
  var ProcessManager = class {
3728
- processes = /* @__PURE__ */ new Map();
3729
- logger;
3730
3708
  constructor() {
3709
+ this.processes = /* @__PURE__ */ new Map();
3731
3710
  this.logger = new Logger({ prefix: "process" });
3732
3711
  process.on("exit", () => {
3733
3712
  this.killAll();
@@ -3848,7 +3827,6 @@ var ProcessManager = class {
3848
3827
 
3849
3828
  // services/git/service.ts
3850
3829
  var GitService = class {
3851
- gitManager;
3852
3830
  constructor() {
3853
3831
  this.gitManager = new GitManager(ROOT_DIR_PATH);
3854
3832
  }
@@ -3885,19 +3863,12 @@ var GitService = class {
3885
3863
  await this.gitManager.sync({ commitMessage });
3886
3864
  logger.info("Sync completed successfully");
3887
3865
  }
3888
- /**
3889
- * 获取 Git 状态
3890
- * @returns Git 状态信息
3891
- */
3892
- async getStatus() {
3893
- return await this.gitManager.getStatus();
3894
- }
3895
3866
  /**
3896
3867
  * 检查是否有未提交的更改
3897
3868
  * @returns 是否有未提交的更改
3898
3869
  */
3899
3870
  async hasChanges() {
3900
- const status = await this.getStatus();
3871
+ const status = await this.gitManager.getStatus();
3901
3872
  return status.hasChanges;
3902
3873
  }
3903
3874
  /**
@@ -3935,7 +3906,6 @@ import {
3935
3906
  import { join as join8 } from "path";
3936
3907
  var BIRTH_DATE = (/* @__PURE__ */ new Date("1999-06-29T00:00:00+08:00")).getTime();
3937
3908
  var TimestampService = class {
3938
- noteManager;
3939
3909
  constructor() {
3940
3910
  this.noteManager = NoteManager.getInstance();
3941
3911
  }
@@ -4235,26 +4205,42 @@ var TimestampService = class {
4235
4205
  // services/vitepress/service.ts
4236
4206
  import { spawn as spawn2 } from "child_process";
4237
4207
  var VitepressService = class _VitepressService {
4238
- /** VitePress 开发服务器默认端口 */
4239
- static DEFAULT_DEV_PORT = 5173;
4240
- /** VitePress 预览服务器默认端口 */
4241
- static DEFAULT_PREVIEW_PORT = 4173;
4242
- /** 开发服务器进程 ID 后缀 */
4243
- static PROCESS_ID_DEV_SUFFIX = "vitepress-dev";
4244
- /** 预览服务器进程 ID 后缀 */
4245
- static PROCESS_ID_PREVIEW_SUFFIX = "vitepress-preview";
4246
- /** 服务启动超时时间(毫秒) */
4247
- static SERVER_STARTUP_TIMEOUT = 6e4;
4248
- /** 端口释放等待超时时间(毫秒) */
4249
- static PORT_RELEASE_TIMEOUT = 3e3;
4250
- /** 进程清理等待时间(毫秒) */
4251
- static PROCESS_CLEANUP_DELAY = 3e3;
4252
- /** 显示启动服务状态行间隔(毫秒) */
4253
- static SERVER_STATUS_LINE_INTERVAL = 1e3;
4254
- /** 默认包管理器 */
4255
- static DEFAULT_PACKAGE_MANAGER = "pnpm";
4256
- processManager;
4257
- configManager;
4208
+ static {
4209
+ /** VitePress 开发服务器默认端口 */
4210
+ this.DEFAULT_DEV_PORT = 5173;
4211
+ }
4212
+ static {
4213
+ /** VitePress 预览服务器默认端口 */
4214
+ this.DEFAULT_PREVIEW_PORT = 4173;
4215
+ }
4216
+ static {
4217
+ /** 开发服务器进程 ID 后缀 */
4218
+ this.PROCESS_ID_DEV_SUFFIX = "vitepress-dev";
4219
+ }
4220
+ static {
4221
+ /** 预览服务器进程 ID 后缀 */
4222
+ this.PROCESS_ID_PREVIEW_SUFFIX = "vitepress-preview";
4223
+ }
4224
+ static {
4225
+ /** 服务启动超时时间(毫秒) */
4226
+ this.SERVER_STARTUP_TIMEOUT = 6e4;
4227
+ }
4228
+ static {
4229
+ /** 端口释放等待超时时间(毫秒) */
4230
+ this.PORT_RELEASE_TIMEOUT = 3e3;
4231
+ }
4232
+ static {
4233
+ /** 进程清理等待时间(毫秒) */
4234
+ this.PROCESS_CLEANUP_DELAY = 3e3;
4235
+ }
4236
+ static {
4237
+ /** 显示启动服务状态行间隔(毫秒) */
4238
+ this.SERVER_STATUS_LINE_INTERVAL = 1e3;
4239
+ }
4240
+ static {
4241
+ /** 默认包管理器 */
4242
+ this.DEFAULT_PACKAGE_MANAGER = "pnpm";
4243
+ }
4258
4244
  constructor() {
4259
4245
  this.processManager = new ProcessManager();
4260
4246
  this.configManager = ConfigManager.getInstance();
@@ -4448,10 +4434,9 @@ var VitepressService = class _VitepressService {
4448
4434
  var BaseCommand = class {
4449
4435
  constructor(name) {
4450
4436
  this.name = name;
4437
+ this.options = {};
4451
4438
  this.logger = logger.child(name);
4452
4439
  }
4453
- logger;
4454
- options = {};
4455
4440
  /** 命令描述(从静态配置读取) */
4456
4441
  get description() {
4457
4442
  return COMMAND_DESCRIPTIONS[this.name];
@@ -4481,7 +4466,6 @@ var BaseCommand = class {
4481
4466
 
4482
4467
  // commands/note/UpdateNoteConfigCommand.ts
4483
4468
  var UpdateNoteConfigCommand = class extends BaseCommand {
4484
- noteService;
4485
4469
  constructor() {
4486
4470
  super("update-note-config");
4487
4471
  this.noteService = NoteService.getInstance();
@@ -4533,8 +4517,6 @@ var UpdateNoteConfigCommand = class extends BaseCommand {
4533
4517
  import { existsSync as existsSync8, renameSync, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
4534
4518
  import { join as join9 } from "path";
4535
4519
  var RenameNoteCommand = class extends BaseCommand {
4536
- noteService;
4537
- readmeService;
4538
4520
  constructor() {
4539
4521
  super("rename-note");
4540
4522
  this.noteService = NoteService.getInstance();
@@ -4642,6 +4624,7 @@ export {
4642
4624
  ReadmeService,
4643
4625
  NoteService,
4644
4626
  FileWatcherService,
4627
+ GitManager,
4645
4628
  GitService,
4646
4629
  TimestampService,
4647
4630
  VitepressService,
@@ -99,11 +99,8 @@ function validateAndCompleteConfig(config) {
99
99
 
100
100
  // config/ConfigManager.ts
101
101
  var ConfigManager = class _ConfigManager {
102
- static instance;
103
- config = null;
104
- configPath;
105
- rootPath;
106
102
  constructor(rootPath) {
103
+ this.config = null;
107
104
  if (rootPath) {
108
105
  this.rootPath = rootPath;
109
106
  } else {