@tnotesjs/core 0.6.1 → 0.8.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/commands/BaseCommand.ts +58 -0
- package/commands/build/BuildCommand.ts +25 -0
- package/commands/build/PreviewCommand.ts +29 -0
- package/commands/build/index.ts +8 -0
- package/commands/dev/DevCommand.ts +75 -0
- package/commands/dev/index.ts +7 -0
- package/commands/git/PullCommand.ts +25 -0
- package/commands/git/PushCommand.ts +64 -0
- package/commands/git/index.ts +8 -0
- package/commands/index.ts +11 -0
- package/commands/init-sub-repo/InitSubRepoCommand.ts +206 -0
- package/commands/init-sub-repo/index.ts +1 -0
- package/commands/misc/HelpCommand.ts +104 -0
- package/commands/misc/index.ts +7 -0
- package/commands/models.ts +87 -0
- package/commands/note/CreateNoteCommand.ts +160 -0
- package/commands/note/RenameNoteCommand.ts +147 -0
- package/commands/note/UpdateNoteConfigCommand.ts +78 -0
- package/commands/note/index.ts +9 -0
- package/commands/registry.ts +47 -0
- package/commands/update/UpdateCommand.ts +219 -0
- package/commands/update/index.ts +7 -0
- package/commands/update-completed-count/UpdateCompletedCountCommand.ts +208 -0
- package/commands/update-completed-count/index.ts +5 -0
- package/config/templates.ts +0 -5
- package/dist/{chunk-5F5RJ2HV.cjs → chunk-7FEANCT6.cjs} +16 -7
- package/dist/chunk-AGVER5MX.cjs +1746 -0
- package/dist/{chunk-TJ4527KA.cjs → chunk-BL22KD4V.cjs} +324 -950
- package/dist/{chunk-56PKXCOX.js → chunk-GWG75A5M.js} +13 -4
- package/dist/{chunk-DUTS75WQ.js → chunk-XNO3PCEH.js} +374 -1000
- package/dist/chunk-ZEQS64PE.js +1746 -0
- package/dist/cli/index.cjs +76 -155
- package/dist/cli/index.js +10 -89
- package/dist/markdown/index.cjs +8 -12
- package/dist/markdown/index.d.cts +1 -1
- package/dist/markdown/index.d.ts +1 -1
- package/dist/markdown/index.js +7 -11
- package/dist/{types-CwBWwNVv.d.ts → types-C_d0fFeD.d.ts} +8 -1
- package/dist/{types-CpsEy8lA.d.cts → types-MRBGgJTX.d.cts} +8 -1
- package/dist/vitepress/config/index.cjs +402 -178
- package/dist/vitepress/config/index.js +392 -168
- package/dist/workspace/index.cjs +4 -1202
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.ts +2 -2
- package/dist/workspace/index.js +4 -1202
- package/markdown/components.ts +86 -0
- package/markdown/index.ts +17 -0
- package/markdown/noteFormatter.test.ts +44 -0
- package/markdown/noteFormatter.ts +237 -0
- package/package.json +7 -3
- package/services/file-watcher/folderChangeHandler.ts +19 -15
- package/services/file-watcher/globalUpdateCoordinator.ts +21 -27
- package/services/file-watcher/service.ts +1 -6
- package/services/index.ts +0 -1
- package/services/note/service.ts +4 -6
- package/services/readme/service.ts +11 -18
- package/services/reconcileToc.ts +20 -0
- package/utils/index.ts +0 -9
- package/{services/toc → utils}/moveTocInside.test.ts +1 -1
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +9 -18
- package/vitepress/components/EnWordList/EnWordList.vue +16 -662
- package/vitepress/components/Footprints/Footprints.vue +15 -537
- package/vitepress/components/Mermaid/Mermaid.vue +13 -588
- package/vitepress/components/MindmapPreview/MindmapPreview.vue +12 -434
- package/vitepress/components/MindmapPreview/markdown.ts +1 -1
- package/vitepress/components/NotesTable/NotesTable.vue +11 -130
- package/vitepress/components/constants.ts +2 -2
- package/vitepress/components/sidebar.data.ts +8 -5
- package/vitepress/configs/markdown.config.ts +170 -26
- package/vitepress/plugins/sidebarStructurePlugin.ts +242 -145
- package/vitepress/theme/index.ts +9 -13
- package/vitepress/theme/styles/base.scss +15 -0
- package/workspace/atomic.ts +113 -0
- package/workspace/errors.ts +27 -0
- package/workspace/index.ts +40 -0
- package/workspace/mutationQueue.ts +28 -0
- package/workspace/paths.ts +64 -0
- package/workspace/reconcile.test.ts +300 -0
- package/workspace/reconcile.ts +95 -0
- package/workspace/scanner.ts +292 -0
- package/workspace/types.ts +224 -0
- package/workspace/workspace.test.ts +333 -0
- package/workspace/workspace.ts +1020 -0
- package/dist/chunk-3R7QSABB.cjs +0 -502
- package/dist/chunk-CZXRQPFJ.js +0 -11
- package/dist/chunk-HXED7KVT.cjs +0 -11
- package/dist/chunk-U6IBLREL.js +0 -502
- package/services/toc/index.ts +0 -5
- package/services/toc/service.ts +0 -759
- package/utils/migrateReadmeToToc.test.ts +0 -111
- package/utils/migrateReadmeToToc.ts +0 -135
- package/vitepress/components/EnWordList/RightClickMenu.vue +0 -93
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from 'fs'
|
|
13
13
|
|
|
14
14
|
import { ConfigManager } from '../../config/ConfigManager'
|
|
15
|
-
import { ROOT_README_PATH, VP_SIDEBAR_PATH } from '../../config/constants'
|
|
15
|
+
import { ROOT_DIR_PATH, ROOT_README_PATH, VP_SIDEBAR_PATH } from '../../config/constants'
|
|
16
16
|
import { NoteIndexCache } from '../../core/NoteIndexCache'
|
|
17
17
|
import { NoteManager } from '../../core/NoteManager'
|
|
18
18
|
import { ReadmeGenerator } from '../../core/ReadmeGenerator'
|
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
genHierarchicalSidebar,
|
|
25
25
|
processEmptyLines,
|
|
26
26
|
} from '../../utils'
|
|
27
|
-
import {
|
|
27
|
+
import { reconcileTocFromFiles } from '../reconcileToc'
|
|
28
|
+
|
|
28
29
|
|
|
29
30
|
import type { NoteInfo, NoteConfig } from '../../types'
|
|
30
31
|
|
|
@@ -60,14 +61,12 @@ export class ReadmeService {
|
|
|
60
61
|
private readmeGenerator: ReadmeGenerator
|
|
61
62
|
private configManager: ConfigManager
|
|
62
63
|
private noteIndexCache: NoteIndexCache
|
|
63
|
-
private tocService: TocService
|
|
64
64
|
|
|
65
65
|
private constructor() {
|
|
66
66
|
this.noteManager = NoteManager.getInstance()
|
|
67
67
|
this.readmeGenerator = new ReadmeGenerator()
|
|
68
68
|
this.configManager = ConfigManager.getInstance()
|
|
69
69
|
this.noteIndexCache = NoteIndexCache.getInstance()
|
|
70
|
-
this.tocService = TocService.getInstance()
|
|
71
70
|
}
|
|
72
71
|
|
|
73
72
|
static getInstance(): ReadmeService {
|
|
@@ -121,10 +120,9 @@ export class ReadmeService {
|
|
|
121
120
|
await this.updateHomeReadme(notes)
|
|
122
121
|
}
|
|
123
122
|
|
|
124
|
-
//
|
|
123
|
+
// files→TOC 对齐(Workspace):规范化 TOC.md 并重建 sidebar.json
|
|
125
124
|
if (updateSidebar) {
|
|
126
|
-
await
|
|
127
|
-
await this.tocService.regenerateSidebar(notes)
|
|
125
|
+
await reconcileTocFromFiles(ROOT_DIR_PATH)
|
|
128
126
|
}
|
|
129
127
|
|
|
130
128
|
logger.info('知识库更新完成!')
|
|
@@ -618,23 +616,18 @@ export class ReadmeService {
|
|
|
618
616
|
/**
|
|
619
617
|
* 更新 TOC.md 和 sidebar,不重写每篇笔记 README
|
|
620
618
|
*/
|
|
621
|
-
async refreshHomeReadmeAndSidebar(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
(this.noteIndexCache.isInitialized()
|
|
625
|
-
? this.noteIndexCache.toNoteInfoList()
|
|
626
|
-
: this.noteManager.scanNotes())
|
|
627
|
-
|
|
628
|
-
await this.tocService.normalizeToc(allNotes)
|
|
629
|
-
await this.tocService.regenerateSidebar(allNotes)
|
|
619
|
+
async refreshHomeReadmeAndSidebar(_notes?: NoteInfo[]): Promise<void> {
|
|
620
|
+
// files→TOC 对齐(Workspace):TOC.md 规范化 + sidebar 重建
|
|
621
|
+
await reconcileTocFromFiles(ROOT_DIR_PATH)
|
|
630
622
|
}
|
|
631
623
|
|
|
632
624
|
/**
|
|
633
625
|
* 重新生成 sidebar.json(基于当前 TOC.md)
|
|
634
626
|
* @param notes - 可选的笔记列表,不传则内部扫描
|
|
635
627
|
*/
|
|
636
|
-
async regenerateSidebar(
|
|
637
|
-
|
|
628
|
+
async regenerateSidebar(_notes?: NoteInfo[]): Promise<void> {
|
|
629
|
+
// files→TOC 对齐(Workspace):sidebar 由重建的 TOC 派生
|
|
630
|
+
await reconcileTocFromFiles(ROOT_DIR_PATH)
|
|
638
631
|
logger.info('重新生成 sidebar.json')
|
|
639
632
|
}
|
|
640
633
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* services/reconcileToc.ts
|
|
3
|
+
*
|
|
4
|
+
* CLI / 服务侧的「files→TOC 对齐」入口(0004 方案 B):
|
|
5
|
+
* 统一的 TOC/sidebar 写入都收敛到 Core Workspace 的
|
|
6
|
+
* `toc.reconcileFromFiles()`,不再直接操作 TocService。
|
|
7
|
+
*/
|
|
8
|
+
import { createWorkspace, type TNotesWorkspace } from '../workspace'
|
|
9
|
+
|
|
10
|
+
const workspaces = new Map<string, TNotesWorkspace>()
|
|
11
|
+
|
|
12
|
+
/** 知识库根目录 → 常驻 Workspace 实例(幂等,可重复调用)。 */
|
|
13
|
+
export async function reconcileTocFromFiles(repoRoot: string): Promise<void> {
|
|
14
|
+
let workspace = workspaces.get(repoRoot)
|
|
15
|
+
if (!workspace) {
|
|
16
|
+
workspace = createWorkspace({ rootPath: repoRoot })
|
|
17
|
+
workspaces.set(repoRoot, workspace)
|
|
18
|
+
}
|
|
19
|
+
await workspace.toc.reconcileFromFiles()
|
|
20
|
+
}
|
package/utils/index.ts
CHANGED
|
@@ -52,15 +52,6 @@ export type {
|
|
|
52
52
|
TocSidebarItem,
|
|
53
53
|
TocLineKind,
|
|
54
54
|
} from './tocHelpers'
|
|
55
|
-
export {
|
|
56
|
-
migrateReadmeToToc,
|
|
57
|
-
extractReadmeBodyAfterToc,
|
|
58
|
-
README_TOC_END_TAG,
|
|
59
|
-
} from './migrateReadmeToToc'
|
|
60
|
-
export type {
|
|
61
|
-
MigratedTocEntry,
|
|
62
|
-
MigrateReadmeToTocResult,
|
|
63
|
-
} from './migrateReadmeToToc'
|
|
64
55
|
export { isPortInUse, killPortProcess, waitForPort } from './portUtils'
|
|
65
56
|
export {
|
|
66
57
|
parseNoteLine,
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
|
|
1
|
+
<!--
|
|
2
|
+
Deprecated local shell. Canonical implementation lives in @tnotesjs/ui as
|
|
3
|
+
BilibiliVideo. Kept so deep path imports do not break during migration.
|
|
3
4
|
-->
|
|
4
|
-
|
|
5
5
|
<template>
|
|
6
|
-
<
|
|
7
|
-
style="width: 100%; aspect-ratio: 16/9; margin: 1rem 0"
|
|
8
|
-
:src="'//player.bilibili.com/player.html?isOutside=true&bvid=' + id"
|
|
9
|
-
scrolling="no"
|
|
10
|
-
border="0"
|
|
11
|
-
frameborder="no"
|
|
12
|
-
framespacing="0"
|
|
13
|
-
allowfullscreen="true"
|
|
14
|
-
></iframe>
|
|
6
|
+
<BilibiliVideo :id="id" />
|
|
15
7
|
</template>
|
|
16
8
|
|
|
17
9
|
<script setup lang="ts">
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})
|
|
10
|
+
import { BilibiliVideo } from '@tnotesjs/ui'
|
|
11
|
+
|
|
12
|
+
defineProps<{
|
|
13
|
+
id: string
|
|
14
|
+
}>()
|
|
24
15
|
</script>
|