@tnotesjs/core 0.0.1 → 0.0.3
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 +84 -84
- package/dist/{chunk-CSSIRO3I.js → chunk-NI5B4S3T.js} +40 -3
- package/dist/cli/index.js +1 -1
- package/dist/vitepress/config/index.js +60 -17
- package/package.json +77 -77
- package/types/config.ts +61 -61
- package/types/index.ts +11 -11
- package/types/note.ts +33 -33
- package/vitepress/assets/icons/icon__check.svg +3 -3
- package/vitepress/assets/icons/icon__clipboard.svg +7 -7
- package/vitepress/assets/icons/icon__close.svg +1 -1
- package/vitepress/assets/icons/icon__collapse.svg +1 -1
- package/vitepress/assets/icons/icon__confirm.svg +1 -1
- package/vitepress/assets/icons/icon__copy.svg +4 -4
- package/vitepress/assets/icons/icon__focus.svg +1 -1
- package/vitepress/assets/icons/icon__fold.svg +3 -3
- package/vitepress/assets/icons/icon__folder.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
- package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
- package/vitepress/assets/icons/icon__github.svg +3 -3
- package/vitepress/assets/icons/icon__mindmap.svg +1 -1
- package/vitepress/assets/icons/icon__next.svg +1 -1
- package/vitepress/assets/icons/icon__number_gray.svg +1 -1
- package/vitepress/assets/icons/icon__number_purple.svg +1 -1
- package/vitepress/assets/icons/icon__prev.svg +1 -1
- package/vitepress/assets/icons/icon__restore.svg +1 -1
- package/vitepress/assets/icons/icon__rotate.svg +4 -4
- package/vitepress/assets/icons/icon__search.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
- package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
- package/vitepress/assets/icons/icon__totop.svg +5 -5
- package/vitepress/assets/icons/icon__vscode.svg +5 -5
- package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
- package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
- package/vitepress/assets/icons/index.ts +38 -38
- package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
- package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -373
- package/vitepress/components/CodeBlockFullscreen/index.ts +115 -115
- package/vitepress/components/CodeBlockFullscreen/styles.css +64 -64
- package/vitepress/components/Discussions/Discussions.module.scss +32 -32
- package/vitepress/components/Discussions/Discussions.vue +211 -211
- package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
- package/vitepress/components/EnWordList/EnWordList.vue +543 -543
- package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
- package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
- package/vitepress/components/Footprints/Footprints.module.scss +93 -93
- package/vitepress/components/Footprints/Footprints.vue +377 -377
- package/vitepress/components/Layout/AboutModal.module.scss +233 -233
- package/vitepress/components/Layout/AboutModal.vue +105 -105
- package/vitepress/components/Layout/AboutPanel.vue +266 -266
- package/vitepress/components/Layout/ContentCollapse.vue +603 -603
- package/vitepress/components/Layout/CustomSidebar.vue +605 -605
- package/vitepress/components/Layout/DocBeforeControls.vue +139 -139
- package/vitepress/components/Layout/DocFooter.vue +225 -225
- package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
- package/vitepress/components/Layout/ImagePreview.vue +281 -281
- package/vitepress/components/Layout/Layout.module.scss +661 -661
- package/vitepress/components/Layout/Layout.vue +542 -542
- package/vitepress/components/Layout/NoteStatus.vue +140 -140
- package/vitepress/components/Layout/SidebarItems.vue +263 -263
- package/vitepress/components/Layout/SidebarNavBefore.vue +92 -92
- package/vitepress/components/Layout/Swiper.vue +167 -167
- package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
- package/vitepress/components/Layout/ToggleFullContent.vue +34 -34
- package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
- package/vitepress/components/Layout/ToggleSidebar.vue +35 -35
- package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
- package/vitepress/components/Layout/composables/useNoteConfig.ts +121 -121
- package/vitepress/components/Layout/composables/useNoteSave.ts +173 -173
- package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
- package/vitepress/components/Layout/composables/useRedirect.ts +110 -110
- package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +85 -85
- package/vitepress/components/Layout/homeReadme.data.ts +124 -124
- package/vitepress/components/LoadingPage/LoadingPage.vue +192 -192
- package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
- package/vitepress/components/MarkMap/MarkMap.vue +404 -404
- package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
- package/vitepress/components/Mermaid/Mermaid.vue +364 -364
- package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
- package/vitepress/components/NotesTable/NotesTable.vue +98 -98
- package/vitepress/components/NotesTable/README.md +67 -67
- package/vitepress/components/Settings/Settings.module.scss +433 -433
- package/vitepress/components/Settings/Settings.vue +306 -306
- package/vitepress/components/SidebarCard/MindMapView.vue +483 -483
- package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
- package/vitepress/components/SidebarCard/SidebarCard.vue +948 -948
- package/vitepress/components/Tooltip/Tooltip.vue +70 -70
- package/vitepress/components/constants.ts +91 -91
- package/vitepress/components/notesConfig.data.ts +73 -73
- package/vitepress/components/sidebar.data.ts +59 -59
- package/vitepress/components/tnotes-config.data.ts +21 -21
- package/vitepress/components/utils.ts +26 -26
- package/vitepress/config/index.ts +141 -141
- package/vitepress/configs/constants.ts +26 -26
- package/vitepress/configs/head.config.ts +25 -25
- package/vitepress/configs/index.ts +9 -9
- package/vitepress/configs/markdown-it.d.ts +23 -23
- package/vitepress/configs/markdown.config.ts +366 -366
- package/vitepress/configs/theme.config.ts +108 -108
- package/vitepress/plugins/buildProgressPlugin.ts +466 -390
- package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -107
- package/vitepress/plugins/renameNotePlugin.ts +60 -60
- package/vitepress/plugins/updateConfigPlugin.ts +63 -63
- package/vitepress/theme/index.ts +95 -95
- package/vitepress/theme/styles/base.scss +50 -50
- package/vitepress/theme/styles/components/404.scss +31 -31
- package/vitepress/theme/styles/components/collapse.scss +175 -175
- package/vitepress/theme/styles/components/markmap.scss +101 -101
- package/vitepress/theme/styles/components/swiper.scss +255 -255
- package/vitepress/theme/styles/index.scss +25 -25
- package/vitepress/theme/styles/layout.scss +62 -62
- package/vitepress/theme/styles/utilities.scss +39 -39
- package/vitepress/theme/styles/vitepress-override.scss +25 -25
package/README.md
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
# @tnotesjs/core
|
|
2
|
-
|
|
3
|
-
TNotes 知识库系统的核心框架,以 NPM 包形式发布,被所有 [TNotes.xxx](https://github.com/orgs/tnotesjs/repositories) 知识库引用。
|
|
4
|
-
|
|
5
|
-
## 简介
|
|
6
|
-
|
|
7
|
-
`@tnotesjs/core` 包含了 TNotes 知识库系统的 CLI 命令、VitePress 配置/主题、服务层、工具函数等核心代码。各 TNotes.xxx 仓库通过 `npm install @tnotesjs/core` 安装即可使用。
|
|
8
|
-
|
|
9
|
-
## 目录结构
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
@tnotesjs/core
|
|
13
|
-
├── commands/ # CLI 命令(dev、build、push、update 等)
|
|
14
|
-
├── config/ # 配置管理(ConfigManager、默认配置、模板)
|
|
15
|
-
├── core/ # 核心模块(GitManager、NoteManager、ReadmeGenerator 等)
|
|
16
|
-
├── services/ # 服务层(file-watcher、git、note、readme、vitepress 等)
|
|
17
|
-
├── types/ # TypeScript 类型定义
|
|
18
|
-
├── utils/ # 工具函数(日志、文件操作、Markdown 解析、校验等)
|
|
19
|
-
├── vitepress/ # VitePress 主题、组件、插件、样式
|
|
20
|
-
│ ├── components/ # 自定义 Vue 组件
|
|
21
|
-
│ ├── config/ # VitePress 配置(defineNotesConfig)
|
|
22
|
-
│ ├── plugins/ # VitePress 插件
|
|
23
|
-
│ └── theme/ # 主题入口与样式
|
|
24
|
-
├── index.ts # CLI 入口
|
|
25
|
-
└── src/index.ts # 公共 API 导出
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## 安装
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# 安装核心包
|
|
32
|
-
pnpm add @tnotesjs/core
|
|
33
|
-
|
|
34
|
-
# 安装 peerDependencies
|
|
35
|
-
pnpm add -D vite vitepress vue
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 使用方式
|
|
39
|
-
|
|
40
|
-
### VitePress 配置
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
// .vitepress/config.mts
|
|
44
|
-
import { defineNotesConfig } from '@tnotesjs/core/vitepress/config'
|
|
45
|
-
export default defineNotesConfig()
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### VitePress 主题
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
// .vitepress/theme/index.ts
|
|
52
|
-
export { default } from '@tnotesjs/core/vitepress/theme'
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### CLI 命令
|
|
56
|
-
|
|
57
|
-
在 `package.json` 中配置脚本:
|
|
58
|
-
|
|
59
|
-
```json
|
|
60
|
-
{
|
|
61
|
-
"scripts": {
|
|
62
|
-
"tn:dev": "tnotes --dev",
|
|
63
|
-
"tn:build": "tnotes --build",
|
|
64
|
-
"tn:preview": "tnotes --preview",
|
|
65
|
-
"tn:update": "tnotes --update",
|
|
66
|
-
"tn:push": "tnotes --push",
|
|
67
|
-
"tn:pull": "tnotes --pull",
|
|
68
|
-
"tn:create-notes": "tnotes --create-notes",
|
|
69
|
-
"tn:fix-timestamps": "tnotes --fix-timestamps",
|
|
70
|
-
"tn:help": "tnotes --help"
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## 版本管理
|
|
76
|
-
|
|
77
|
-
- 版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)
|
|
78
|
-
- 变更记录见 [CHANGELOG.md](./CHANGELOG.md)
|
|
79
|
-
- 发布:`npm publish --access public`
|
|
80
|
-
- 每个版本通过 Git Tag 标记(如 `v1.0.0`)
|
|
81
|
-
|
|
82
|
-
## 许可证
|
|
83
|
-
|
|
84
|
-
MIT
|
|
1
|
+
# @tnotesjs/core
|
|
2
|
+
|
|
3
|
+
TNotes 知识库系统的核心框架,以 NPM 包形式发布,被所有 [TNotes.xxx](https://github.com/orgs/tnotesjs/repositories) 知识库引用。
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
`@tnotesjs/core` 包含了 TNotes 知识库系统的 CLI 命令、VitePress 配置/主题、服务层、工具函数等核心代码。各 TNotes.xxx 仓库通过 `npm install @tnotesjs/core` 安装即可使用。
|
|
8
|
+
|
|
9
|
+
## 目录结构
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
@tnotesjs/core
|
|
13
|
+
├── commands/ # CLI 命令(dev、build、push、update 等)
|
|
14
|
+
├── config/ # 配置管理(ConfigManager、默认配置、模板)
|
|
15
|
+
├── core/ # 核心模块(GitManager、NoteManager、ReadmeGenerator 等)
|
|
16
|
+
├── services/ # 服务层(file-watcher、git、note、readme、vitepress 等)
|
|
17
|
+
├── types/ # TypeScript 类型定义
|
|
18
|
+
├── utils/ # 工具函数(日志、文件操作、Markdown 解析、校验等)
|
|
19
|
+
├── vitepress/ # VitePress 主题、组件、插件、样式
|
|
20
|
+
│ ├── components/ # 自定义 Vue 组件
|
|
21
|
+
│ ├── config/ # VitePress 配置(defineNotesConfig)
|
|
22
|
+
│ ├── plugins/ # VitePress 插件
|
|
23
|
+
│ └── theme/ # 主题入口与样式
|
|
24
|
+
├── index.ts # CLI 入口
|
|
25
|
+
└── src/index.ts # 公共 API 导出
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 安装核心包
|
|
32
|
+
pnpm add @tnotesjs/core
|
|
33
|
+
|
|
34
|
+
# 安装 peerDependencies
|
|
35
|
+
pnpm add -D vite vitepress vue
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 使用方式
|
|
39
|
+
|
|
40
|
+
### VitePress 配置
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
// .vitepress/config.mts
|
|
44
|
+
import { defineNotesConfig } from '@tnotesjs/core/vitepress/config'
|
|
45
|
+
export default defineNotesConfig()
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### VitePress 主题
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
// .vitepress/theme/index.ts
|
|
52
|
+
export { default } from '@tnotesjs/core/vitepress/theme'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### CLI 命令
|
|
56
|
+
|
|
57
|
+
在 `package.json` 中配置脚本:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"scripts": {
|
|
62
|
+
"tn:dev": "tnotes --dev",
|
|
63
|
+
"tn:build": "tnotes --build",
|
|
64
|
+
"tn:preview": "tnotes --preview",
|
|
65
|
+
"tn:update": "tnotes --update",
|
|
66
|
+
"tn:push": "tnotes --push",
|
|
67
|
+
"tn:pull": "tnotes --pull",
|
|
68
|
+
"tn:create-notes": "tnotes --create-notes",
|
|
69
|
+
"tn:fix-timestamps": "tnotes --fix-timestamps",
|
|
70
|
+
"tn:help": "tnotes --help"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 版本管理
|
|
76
|
+
|
|
77
|
+
- 版本号遵循 [Semantic Versioning](https://semver.org/lang/zh-CN/)
|
|
78
|
+
- 变更记录见 [CHANGELOG.md](./CHANGELOG.md)
|
|
79
|
+
- 发布:`npm publish --access public`
|
|
80
|
+
- 每个版本通过 Git Tag 标记(如 `v1.0.0`)
|
|
81
|
+
|
|
82
|
+
## 许可证
|
|
83
|
+
|
|
84
|
+
MIT
|
|
@@ -3355,14 +3355,16 @@ var NoteService = class _NoteService {
|
|
|
3355
3355
|
// services/file-watcher/service.ts
|
|
3356
3356
|
var NOTES_DIR_NOT_SET_ERROR = "NOTES_DIR_PATH \u672A\u8BBE\u7F6E\uFF0C\u65E0\u6CD5\u542F\u52A8\u6587\u4EF6\u76D1\u542C";
|
|
3357
3357
|
var UPDATE_UNLOCK_DELAY_MS2 = 500;
|
|
3358
|
-
var FileWatcherService = class {
|
|
3358
|
+
var FileWatcherService = class _FileWatcherService {
|
|
3359
3359
|
constructor(notesDir = NOTES_DIR_PATH) {
|
|
3360
3360
|
this.notesDir = notesDir;
|
|
3361
3361
|
if (!this.notesDir) {
|
|
3362
3362
|
throw new Error(NOTES_DIR_NOT_SET_ERROR);
|
|
3363
3363
|
}
|
|
3364
3364
|
this.init();
|
|
3365
|
+
_FileWatcherService.instance = this;
|
|
3365
3366
|
}
|
|
3367
|
+
static instance = null;
|
|
3366
3368
|
watchState;
|
|
3367
3369
|
scheduler;
|
|
3368
3370
|
renameDetector;
|
|
@@ -3375,6 +3377,9 @@ var FileWatcherService = class {
|
|
|
3375
3377
|
readmeService;
|
|
3376
3378
|
noteIndexCache;
|
|
3377
3379
|
unlockTimer = null;
|
|
3380
|
+
static getInstance() {
|
|
3381
|
+
return _FileWatcherService.instance;
|
|
3382
|
+
}
|
|
3378
3383
|
init() {
|
|
3379
3384
|
this.noteService = NoteService.getInstance();
|
|
3380
3385
|
this.readmeService = ReadmeService.getInstance();
|
|
@@ -3479,6 +3484,24 @@ var FileWatcherService = class {
|
|
|
3479
3484
|
isWatching() {
|
|
3480
3485
|
return this.adapter.isWatching();
|
|
3481
3486
|
}
|
|
3487
|
+
/**
|
|
3488
|
+
* 挂起文件监听(关闭 fs.watch 句柄),用于需要操作文件夹的场景(如重命名)
|
|
3489
|
+
* Windows 上 fs.watch 会锁住文件夹句柄,必须先关闭才能重命名
|
|
3490
|
+
*/
|
|
3491
|
+
suspend() {
|
|
3492
|
+
this.adapter.stop();
|
|
3493
|
+
this.scheduler.setUpdating(true);
|
|
3494
|
+
logger.info("\u6587\u4EF6\u76D1\u542C\u5DF2\u6302\u8D77\uFF08fs.watch \u5DF2\u5173\u95ED\uFF09");
|
|
3495
|
+
}
|
|
3496
|
+
/**
|
|
3497
|
+
* 恢复文件监听(重新启动 fs.watch)
|
|
3498
|
+
*/
|
|
3499
|
+
unsuspend() {
|
|
3500
|
+
this.watchState.initializeFromDisk();
|
|
3501
|
+
this.scheduler.setUpdating(false);
|
|
3502
|
+
this.adapter.start();
|
|
3503
|
+
logger.info("\u6587\u4EF6\u76D1\u542C\u5DF2\u6062\u590D\uFF08fs.watch \u5DF2\u91CD\u542F\uFF09");
|
|
3504
|
+
}
|
|
3482
3505
|
// #region - 私有实现
|
|
3483
3506
|
onNoteEvent(event) {
|
|
3484
3507
|
if (!this.isNoteFile(event.path)) return;
|
|
@@ -4054,11 +4077,21 @@ var VitepressService = class _VitepressService {
|
|
|
4054
4077
|
const child = spawn2(pm, ["vitepress", "build"], {
|
|
4055
4078
|
cwd: ROOT_DIR_PATH,
|
|
4056
4079
|
shell: true,
|
|
4057
|
-
stdio: ["inherit", "pipe", "pipe"]
|
|
4080
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
4081
|
+
env: {
|
|
4082
|
+
...process.env,
|
|
4083
|
+
NODE_OPTIONS: (process.env.NODE_OPTIONS || "").includes(
|
|
4084
|
+
"--max-old-space-size"
|
|
4085
|
+
) ? process.env.NODE_OPTIONS : [process.env.NODE_OPTIONS, "--max-old-space-size=4096"].filter(Boolean).join(" ")
|
|
4086
|
+
}
|
|
4058
4087
|
});
|
|
4088
|
+
let buildSucceeded = false;
|
|
4059
4089
|
const filterOutput = (data) => {
|
|
4060
4090
|
const str = data.toString();
|
|
4061
4091
|
if (str.includes("\u{1F528}") || str.includes("\u2705 \u6784\u5EFA\u6210\u529F") || str.includes("\u274C \u6784\u5EFA\u5931\u8D25") || str.includes("\u{1F4C1}") || str.includes("\u{1F4CA}") || str.includes("\u{1F4E6}") || str.includes("\u23F1\uFE0F") || str.includes("Building [") || str.includes("error") || str.includes("Error")) {
|
|
4092
|
+
if (str.includes("\u2705 \u6784\u5EFA\u6210\u529F")) {
|
|
4093
|
+
buildSucceeded = true;
|
|
4094
|
+
}
|
|
4062
4095
|
process.stdout.write(data);
|
|
4063
4096
|
return;
|
|
4064
4097
|
}
|
|
@@ -4072,7 +4105,7 @@ var VitepressService = class _VitepressService {
|
|
|
4072
4105
|
reject(err);
|
|
4073
4106
|
});
|
|
4074
4107
|
child.on("close", (code) => {
|
|
4075
|
-
if (code === 0) {
|
|
4108
|
+
if (code === 0 || buildSucceeded) {
|
|
4076
4109
|
resolve2();
|
|
4077
4110
|
} else {
|
|
4078
4111
|
reject(new Error(`Command failed with code ${code}`));
|
|
@@ -4210,7 +4243,9 @@ var RenameNoteCommand = class extends BaseCommand {
|
|
|
4210
4243
|
if (existsSync8(newPath)) {
|
|
4211
4244
|
throw new Error(`\u76EE\u6807\u6587\u4EF6\u5939\u5DF2\u5B58\u5728: ${newDirName}`);
|
|
4212
4245
|
}
|
|
4246
|
+
const watcher = FileWatcherService.getInstance();
|
|
4213
4247
|
try {
|
|
4248
|
+
if (watcher) watcher.suspend();
|
|
4214
4249
|
renameSync(note.path, newPath);
|
|
4215
4250
|
this.logger.info(`\u2705 \u6587\u4EF6\u5939\u5DF2\u91CD\u547D\u540D:`);
|
|
4216
4251
|
this.logger.info(` \u539F\u540D\u79F0: ${note.dirName}`);
|
|
@@ -4219,6 +4254,8 @@ var RenameNoteCommand = class extends BaseCommand {
|
|
|
4219
4254
|
throw new Error(
|
|
4220
4255
|
`\u91CD\u547D\u540D\u6587\u4EF6\u5939\u5931\u8D25: ${error instanceof Error ? error.message : String(error)}`
|
|
4221
4256
|
);
|
|
4257
|
+
} finally {
|
|
4258
|
+
if (watcher) watcher.unsuspend();
|
|
4222
4259
|
}
|
|
4223
4260
|
try {
|
|
4224
4261
|
this.logger.info("\u6B63\u5728\u66F4\u65B0\u7B14\u8BB0\u5185\u90E8\u6807\u9898...");
|
package/dist/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
UpdateNoteConfigCommand,
|
|
5
5
|
generateAnchor,
|
|
6
6
|
logger
|
|
7
|
-
} from "../../chunk-
|
|
7
|
+
} from "../../chunk-NI5B4S3T.js";
|
|
8
8
|
import "../../chunk-NASIL5FY.js";
|
|
9
9
|
|
|
10
10
|
// vitepress/config/index.ts
|
|
@@ -618,6 +618,10 @@ var globalOutDir = "";
|
|
|
618
618
|
var globalLastPercent = 0;
|
|
619
619
|
var globalFileCount = 0;
|
|
620
620
|
var globalLastLoggedPercent = -1;
|
|
621
|
+
var globalLastOutputTime = 0;
|
|
622
|
+
var globalTransformEndTime = 0;
|
|
623
|
+
var globalLastHookTime = 0;
|
|
624
|
+
var globalStallTimer = null;
|
|
621
625
|
var isTTY = !!(process.stdout.isTTY && process.stderr.isTTY);
|
|
622
626
|
var isCI = !!(process.env.CI || process.env.GITHUB_ACTIONS || process.env.GITLAB_CI || process.env.CIRCLECI || process.env.TRAVIS || process.env.JENKINS_URL);
|
|
623
627
|
var useSingleLineMode = isTTY && !isCI;
|
|
@@ -664,10 +668,12 @@ function renderProgress(percent, transforms, chunks, width, complete, incomplete
|
|
|
664
668
|
if (!useSingleLineMode && !isFinal) {
|
|
665
669
|
const currentPercent = Math.floor(percent * 100);
|
|
666
670
|
const currentBucket = Math.floor(currentPercent / 10) * 10;
|
|
667
|
-
|
|
671
|
+
const now = Date.now();
|
|
672
|
+
if (currentBucket <= globalLastLoggedPercent || now - globalLastOutputTime < 500) {
|
|
668
673
|
return;
|
|
669
674
|
}
|
|
670
675
|
globalLastLoggedPercent = currentBucket;
|
|
676
|
+
globalLastOutputTime = now;
|
|
671
677
|
}
|
|
672
678
|
const filled = Math.floor(percent * width);
|
|
673
679
|
const empty = width - filled;
|
|
@@ -698,26 +704,51 @@ function buildProgressPlugin(options = {}) {
|
|
|
698
704
|
globalHasError = false;
|
|
699
705
|
globalLastPercent = 0;
|
|
700
706
|
globalLastLoggedPercent = -1;
|
|
707
|
+
globalLastOutputTime = 0;
|
|
708
|
+
globalTransformEndTime = 0;
|
|
709
|
+
globalLastHookTime = Date.now();
|
|
701
710
|
globalOutDir = config.build?.outDir || "dist";
|
|
702
711
|
if (!hasCache) {
|
|
703
712
|
globalFileCount = countSourceFiles(process.cwd());
|
|
704
713
|
}
|
|
705
714
|
interceptOutput();
|
|
715
|
+
globalStallTimer = setInterval(() => {
|
|
716
|
+
if (!globalIsBuilding || globalLastPercent <= 0 || globalLastPercent >= 0.98)
|
|
717
|
+
return;
|
|
718
|
+
const now = Date.now();
|
|
719
|
+
if (now - globalLastHookTime < 2e3) return;
|
|
720
|
+
const remaining = 0.98 - globalLastPercent;
|
|
721
|
+
globalLastPercent += remaining * 0.02;
|
|
722
|
+
const transformsStr = hasCache ? `${globalTransformCount}/${cache.transformCount * 2}` : `${globalTransformCount}`;
|
|
723
|
+
const chunksStr = hasCache ? `${globalChunkCount}/${cache.chunkCount * 2}` : `${globalChunkCount}`;
|
|
724
|
+
renderProgress(
|
|
725
|
+
globalLastPercent,
|
|
726
|
+
transformsStr,
|
|
727
|
+
chunksStr,
|
|
728
|
+
width,
|
|
729
|
+
complete,
|
|
730
|
+
incomplete
|
|
731
|
+
);
|
|
732
|
+
}, 1e3);
|
|
706
733
|
}
|
|
707
734
|
}
|
|
708
735
|
},
|
|
709
|
-
transform(_code,
|
|
736
|
+
transform(_code, _id) {
|
|
710
737
|
globalTransformCount++;
|
|
738
|
+
globalLastHookTime = Date.now();
|
|
739
|
+
const transformWeight = hasCache && cache.transformEndRatio != null ? Math.max(0.1, Math.min(0.85, cache.transformEndRatio * 0.98)) : 0.85;
|
|
711
740
|
if (hasCache) {
|
|
712
|
-
const
|
|
713
|
-
globalLastPercent = Math.min(
|
|
741
|
+
const totalTransforms = cache.transformCount * 2;
|
|
742
|
+
globalLastPercent = Math.min(
|
|
743
|
+
transformWeight,
|
|
744
|
+
globalTransformCount / totalTransforms * transformWeight
|
|
745
|
+
);
|
|
714
746
|
} else {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
747
|
+
const k = 500;
|
|
748
|
+
globalLastPercent = Math.min(
|
|
749
|
+
transformWeight,
|
|
750
|
+
transformWeight * globalTransformCount / (globalTransformCount + k)
|
|
751
|
+
);
|
|
721
752
|
}
|
|
722
753
|
const transformsStr = hasCache ? `${globalTransformCount}/${cache.transformCount * 2}` : `${globalTransformCount}`;
|
|
723
754
|
const chunksStr = hasCache ? `${globalChunkCount}/${cache.chunkCount * 2}` : `${globalChunkCount}`;
|
|
@@ -733,16 +764,21 @@ function buildProgressPlugin(options = {}) {
|
|
|
733
764
|
},
|
|
734
765
|
renderChunk() {
|
|
735
766
|
globalChunkCount++;
|
|
767
|
+
globalLastHookTime = Date.now();
|
|
768
|
+
if (!globalTransformEndTime) {
|
|
769
|
+
globalTransformEndTime = Date.now();
|
|
770
|
+
}
|
|
771
|
+
const transformWeight = hasCache && cache.transformEndRatio != null ? Math.max(0.1, Math.min(0.85, cache.transformEndRatio * 0.98)) : 0.85;
|
|
772
|
+
const chunkWeight = 0.98 - transformWeight;
|
|
736
773
|
if (hasCache) {
|
|
737
|
-
const
|
|
774
|
+
const totalChunks = cache.chunkCount * 2;
|
|
738
775
|
globalLastPercent = Math.min(
|
|
739
776
|
0.98,
|
|
740
|
-
|
|
777
|
+
transformWeight + globalChunkCount / totalChunks * chunkWeight
|
|
741
778
|
);
|
|
742
779
|
} else {
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}
|
|
780
|
+
globalLastPercent = Math.max(globalLastPercent, transformWeight);
|
|
781
|
+
globalLastPercent = Math.min(0.98, globalLastPercent + 5e-5);
|
|
746
782
|
}
|
|
747
783
|
const transformsStr = hasCache ? `${globalTransformCount}/${cache.transformCount * 2}` : `${globalTransformCount}`;
|
|
748
784
|
const chunksStr = hasCache ? `${globalChunkCount}/${cache.chunkCount * 2}` : `${globalChunkCount}`;
|
|
@@ -764,6 +800,10 @@ function buildProgressPlugin(options = {}) {
|
|
|
764
800
|
closeBundle() {
|
|
765
801
|
setTimeout(() => {
|
|
766
802
|
if (!globalIsBuilding) return;
|
|
803
|
+
if (globalStallTimer) {
|
|
804
|
+
clearInterval(globalStallTimer);
|
|
805
|
+
globalStallTimer = null;
|
|
806
|
+
}
|
|
767
807
|
const elapsed = ((Date.now() - globalStartTime) / 1e3).toFixed(1);
|
|
768
808
|
const totalTransforms = hasCache ? cache.transformCount * 2 : globalTransformCount;
|
|
769
809
|
const totalChunks = hasCache ? cache.chunkCount * 2 : globalChunkCount;
|
|
@@ -780,9 +820,12 @@ function buildProgressPlugin(options = {}) {
|
|
|
780
820
|
);
|
|
781
821
|
restoreOutput();
|
|
782
822
|
if (!globalHasError) {
|
|
823
|
+
const totalTime = Date.now() - globalStartTime;
|
|
824
|
+
const transformTime = globalTransformEndTime ? globalTransformEndTime - globalStartTime : totalTime;
|
|
783
825
|
setCacheData({
|
|
784
826
|
transformCount: Math.floor(globalTransformCount / 2),
|
|
785
|
-
chunkCount: Math.floor(globalChunkCount / 2)
|
|
827
|
+
chunkCount: Math.floor(globalChunkCount / 2),
|
|
828
|
+
transformEndRatio: transformTime / totalTime
|
|
786
829
|
});
|
|
787
830
|
console.log(`\u2705 \u6784\u5EFA\u6210\u529F\uFF01`);
|
|
788
831
|
console.log(` \u{1F4C1} \u8F93\u51FA\u76EE\u5F55: ${globalOutDir}`);
|
package/package.json
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tnotesjs/core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "TNotes 知识库核心框架 —— 基于 VitePress 的笔记管理系统",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"tnotes": "./dist/cli/index.js"
|
|
8
|
-
},
|
|
9
|
-
"exports": {
|
|
10
|
-
".": {
|
|
11
|
-
"types": "./dist/index.d.ts",
|
|
12
|
-
"import": "./dist/index.js"
|
|
13
|
-
},
|
|
14
|
-
"./vitepress/config": {
|
|
15
|
-
"import": "./dist/vitepress/config/index.js"
|
|
16
|
-
},
|
|
17
|
-
"./vitepress/theme": {
|
|
18
|
-
"types": "./vitepress/theme/index.ts",
|
|
19
|
-
"import": "./vitepress/theme/index.ts"
|
|
20
|
-
},
|
|
21
|
-
"./vitepress/*": "./vitepress/*"
|
|
22
|
-
},
|
|
23
|
-
"files": [
|
|
24
|
-
"dist/",
|
|
25
|
-
"vitepress/",
|
|
26
|
-
"types/"
|
|
27
|
-
],
|
|
28
|
-
"scripts": {
|
|
29
|
-
"build": "tsup",
|
|
30
|
-
"build:check": "tsc --noEmit",
|
|
31
|
-
"dev": "tsup --watch",
|
|
32
|
-
"release": "node scripts/release.mjs"
|
|
33
|
-
},
|
|
34
|
-
"peerDependencies": {
|
|
35
|
-
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
36
|
-
"vitepress": "^1.6.0",
|
|
37
|
-
"vue": "^3.5.0"
|
|
38
|
-
},
|
|
39
|
-
"dependencies": {
|
|
40
|
-
"d3": "^7.9.0",
|
|
41
|
-
"echarts": "^6.0.0",
|
|
42
|
-
"github-slugger": "^2.0.0",
|
|
43
|
-
"markdown-it-container": "^4.0.0",
|
|
44
|
-
"markdown-it-link-attributes": "^4.0.1",
|
|
45
|
-
"markdown-it-mathjax3": "^4.3.2",
|
|
46
|
-
"markdown-it-task-lists": "^2.1.1",
|
|
47
|
-
"marked": "^15.0.11",
|
|
48
|
-
"markmap-lib": "^0.18.12",
|
|
49
|
-
"markmap-toolbar": "^0.18.12",
|
|
50
|
-
"markmap-view": "^0.18.12",
|
|
51
|
-
"mermaid": "^11.5.0",
|
|
52
|
-
"sass-embedded": "^1.90.0",
|
|
53
|
-
"swiper": "^11.2.1",
|
|
54
|
-
"uuid": "^11.1.0",
|
|
55
|
-
"vue-echarts": "^8.0.1"
|
|
56
|
-
},
|
|
57
|
-
"devDependencies": {
|
|
58
|
-
"@types/markdown-it": "^14.1.2",
|
|
59
|
-
"@types/node": "^24.6.2",
|
|
60
|
-
"tsup": "^8.5.1",
|
|
61
|
-
"typescript": "^5.9.3"
|
|
62
|
-
},
|
|
63
|
-
"engines": {
|
|
64
|
-
"node": ">=18.0.0"
|
|
65
|
-
},
|
|
66
|
-
"license": "MIT",
|
|
67
|
-
"repository": {
|
|
68
|
-
"type": "git",
|
|
69
|
-
"url": "https://github.com/tnotesjs/core"
|
|
70
|
-
},
|
|
71
|
-
"keywords": [
|
|
72
|
-
"tnotes",
|
|
73
|
-
"vitepress",
|
|
74
|
-
"knowledge-base",
|
|
75
|
-
"notes"
|
|
76
|
-
]
|
|
77
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tnotesjs/core",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "TNotes 知识库核心框架 —— 基于 VitePress 的笔记管理系统",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"tnotes": "./dist/cli/index.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./vitepress/config": {
|
|
15
|
+
"import": "./dist/vitepress/config/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./vitepress/theme": {
|
|
18
|
+
"types": "./vitepress/theme/index.ts",
|
|
19
|
+
"import": "./vitepress/theme/index.ts"
|
|
20
|
+
},
|
|
21
|
+
"./vitepress/*": "./vitepress/*"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/",
|
|
25
|
+
"vitepress/",
|
|
26
|
+
"types/"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsup",
|
|
30
|
+
"build:check": "tsc --noEmit -p tsconfig.build.json",
|
|
31
|
+
"dev": "tsup --watch",
|
|
32
|
+
"release": "node scripts/release.mjs"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
36
|
+
"vitepress": "^1.6.0",
|
|
37
|
+
"vue": "^3.5.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"d3": "^7.9.0",
|
|
41
|
+
"echarts": "^6.0.0",
|
|
42
|
+
"github-slugger": "^2.0.0",
|
|
43
|
+
"markdown-it-container": "^4.0.0",
|
|
44
|
+
"markdown-it-link-attributes": "^4.0.1",
|
|
45
|
+
"markdown-it-mathjax3": "^4.3.2",
|
|
46
|
+
"markdown-it-task-lists": "^2.1.1",
|
|
47
|
+
"marked": "^15.0.11",
|
|
48
|
+
"markmap-lib": "^0.18.12",
|
|
49
|
+
"markmap-toolbar": "^0.18.12",
|
|
50
|
+
"markmap-view": "^0.18.12",
|
|
51
|
+
"mermaid": "^11.5.0",
|
|
52
|
+
"sass-embedded": "^1.90.0",
|
|
53
|
+
"swiper": "^11.2.1",
|
|
54
|
+
"uuid": "^11.1.0",
|
|
55
|
+
"vue-echarts": "^8.0.1"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/markdown-it": "^14.1.2",
|
|
59
|
+
"@types/node": "^24.6.2",
|
|
60
|
+
"tsup": "^8.5.1",
|
|
61
|
+
"typescript": "^5.9.3"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=18.0.0"
|
|
65
|
+
},
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "https://github.com/tnotesjs/core"
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"tnotes",
|
|
73
|
+
"vitepress",
|
|
74
|
+
"knowledge-base",
|
|
75
|
+
"notes"
|
|
76
|
+
]
|
|
77
|
+
}
|