@tnotesjs/core 0.0.2 → 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-LZQDLU3S.js → chunk-NI5B4S3T.js} +12 -2
- package/dist/cli/index.js +1 -1
- package/dist/vitepress/config/index.js +60 -17
- package/package.json +1 -1
- 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
|
|
@@ -4077,11 +4077,21 @@ var VitepressService = class _VitepressService {
|
|
|
4077
4077
|
const child = spawn2(pm, ["vitepress", "build"], {
|
|
4078
4078
|
cwd: ROOT_DIR_PATH,
|
|
4079
4079
|
shell: true,
|
|
4080
|
-
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
|
+
}
|
|
4081
4087
|
});
|
|
4088
|
+
let buildSucceeded = false;
|
|
4082
4089
|
const filterOutput = (data) => {
|
|
4083
4090
|
const str = data.toString();
|
|
4084
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
|
+
}
|
|
4085
4095
|
process.stdout.write(data);
|
|
4086
4096
|
return;
|
|
4087
4097
|
}
|
|
@@ -4095,7 +4105,7 @@ var VitepressService = class _VitepressService {
|
|
|
4095
4105
|
reject(err);
|
|
4096
4106
|
});
|
|
4097
4107
|
child.on("close", (code) => {
|
|
4098
|
-
if (code === 0) {
|
|
4108
|
+
if (code === 0 || buildSucceeded) {
|
|
4099
4109
|
resolve2();
|
|
4100
4110
|
} else {
|
|
4101
4111
|
reject(new Error(`Command failed with code ${code}`));
|
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
package/types/config.ts
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/tnotes/types/config.ts
|
|
3
|
-
*
|
|
4
|
-
* 配置相关类型定义
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 知识库的 .tnotes.json 配置文件类型
|
|
9
|
-
*/
|
|
10
|
-
export interface TNotesConfig {
|
|
11
|
-
id?: string
|
|
12
|
-
author: string
|
|
13
|
-
ignore_dirs: string[]
|
|
14
|
-
repoName: string
|
|
15
|
-
keywords: string[]
|
|
16
|
-
socialLinks: SocialLink[]
|
|
17
|
-
menuItems: MenuItem[]
|
|
18
|
-
sidebarShowNoteId: boolean
|
|
19
|
-
port?: number
|
|
20
|
-
packageManager?: 'pnpm' | 'npm' | 'yarn'
|
|
21
|
-
root_item: RootItem
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 图标配置
|
|
26
|
-
*/
|
|
27
|
-
export interface IconConfig {
|
|
28
|
-
svg?: string
|
|
29
|
-
src?: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 社交链接类型
|
|
34
|
-
*/
|
|
35
|
-
export interface SocialLink {
|
|
36
|
-
ariaLabel?: string
|
|
37
|
-
icon: string | IconConfig
|
|
38
|
-
link: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 菜单项类型
|
|
43
|
-
*/
|
|
44
|
-
export interface MenuItem {
|
|
45
|
-
text: string
|
|
46
|
-
link: string
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 根项目配置
|
|
51
|
-
*/
|
|
52
|
-
export interface RootItem {
|
|
53
|
-
icon?: IconConfig
|
|
54
|
-
title: string
|
|
55
|
-
completed_notes_count: Record<string, number>
|
|
56
|
-
details: string
|
|
57
|
-
link: string
|
|
58
|
-
created_at?: number
|
|
59
|
-
updated_at?: number
|
|
60
|
-
days_since_birth?: number
|
|
61
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/tnotes/types/config.ts
|
|
3
|
+
*
|
|
4
|
+
* 配置相关类型定义
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 知识库的 .tnotes.json 配置文件类型
|
|
9
|
+
*/
|
|
10
|
+
export interface TNotesConfig {
|
|
11
|
+
id?: string
|
|
12
|
+
author: string
|
|
13
|
+
ignore_dirs: string[]
|
|
14
|
+
repoName: string
|
|
15
|
+
keywords: string[]
|
|
16
|
+
socialLinks: SocialLink[]
|
|
17
|
+
menuItems: MenuItem[]
|
|
18
|
+
sidebarShowNoteId: boolean
|
|
19
|
+
port?: number
|
|
20
|
+
packageManager?: 'pnpm' | 'npm' | 'yarn'
|
|
21
|
+
root_item: RootItem
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 图标配置
|
|
26
|
+
*/
|
|
27
|
+
export interface IconConfig {
|
|
28
|
+
svg?: string
|
|
29
|
+
src?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 社交链接类型
|
|
34
|
+
*/
|
|
35
|
+
export interface SocialLink {
|
|
36
|
+
ariaLabel?: string
|
|
37
|
+
icon: string | IconConfig
|
|
38
|
+
link: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 菜单项类型
|
|
43
|
+
*/
|
|
44
|
+
export interface MenuItem {
|
|
45
|
+
text: string
|
|
46
|
+
link: string
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 根项目配置
|
|
51
|
+
*/
|
|
52
|
+
export interface RootItem {
|
|
53
|
+
icon?: IconConfig
|
|
54
|
+
title: string
|
|
55
|
+
completed_notes_count: Record<string, number>
|
|
56
|
+
details: string
|
|
57
|
+
link: string
|
|
58
|
+
created_at?: number
|
|
59
|
+
updated_at?: number
|
|
60
|
+
days_since_birth?: number
|
|
61
|
+
}
|
package/types/index.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/tnotes/types/index.ts
|
|
3
|
-
*
|
|
4
|
-
* 类型定义统一导出
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// 配置相关类型
|
|
8
|
-
export type { TNotesConfig } from './config'
|
|
9
|
-
|
|
10
|
-
// 笔记相关类型
|
|
11
|
-
export type { NoteConfig, NoteInfo } from './note'
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/tnotes/types/index.ts
|
|
3
|
+
*
|
|
4
|
+
* 类型定义统一导出
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// 配置相关类型
|
|
8
|
+
export type { TNotesConfig } from './config'
|
|
9
|
+
|
|
10
|
+
// 笔记相关类型
|
|
11
|
+
export type { NoteConfig, NoteInfo } from './note'
|
package/types/note.ts
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .vitepress/tnotes/types/note.ts
|
|
3
|
-
*
|
|
4
|
-
* 笔记相关类型定义
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 笔记的 .tnotes.json 配置类型
|
|
9
|
-
*/
|
|
10
|
-
export interface NoteConfig {
|
|
11
|
-
id: string
|
|
12
|
-
bilibili: string[]
|
|
13
|
-
tnotes: string[]
|
|
14
|
-
yuque: string[]
|
|
15
|
-
done: boolean
|
|
16
|
-
category?: string
|
|
17
|
-
enableDiscussions: boolean
|
|
18
|
-
description?: string // 笔记简介(一句话描述)
|
|
19
|
-
created_at?: number
|
|
20
|
-
updated_at?: number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 笔记信息
|
|
25
|
-
*/
|
|
26
|
-
export interface NoteInfo {
|
|
27
|
-
index: string
|
|
28
|
-
path: string
|
|
29
|
-
dirName: string
|
|
30
|
-
readmePath: string
|
|
31
|
-
configPath: string
|
|
32
|
-
config?: NoteConfig
|
|
33
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* .vitepress/tnotes/types/note.ts
|
|
3
|
+
*
|
|
4
|
+
* 笔记相关类型定义
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 笔记的 .tnotes.json 配置类型
|
|
9
|
+
*/
|
|
10
|
+
export interface NoteConfig {
|
|
11
|
+
id: string
|
|
12
|
+
bilibili: string[]
|
|
13
|
+
tnotes: string[]
|
|
14
|
+
yuque: string[]
|
|
15
|
+
done: boolean
|
|
16
|
+
category?: string
|
|
17
|
+
enableDiscussions: boolean
|
|
18
|
+
description?: string // 笔记简介(一句话描述)
|
|
19
|
+
created_at?: number
|
|
20
|
+
updated_at?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 笔记信息
|
|
25
|
+
*/
|
|
26
|
+
export interface NoteInfo {
|
|
27
|
+
index: string
|
|
28
|
+
path: string
|
|
29
|
+
dirName: string
|
|
30
|
+
readmePath: string
|
|
31
|
+
configPath: string
|
|
32
|
+
config?: NoteConfig
|
|
33
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
-
<polyline points="20 6 9 17 4 12"></polyline>
|
|
3
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
3
|
+
</svg>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<svg t="1735090484450" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4809"
|
|
2
|
-
width="1em" height="1em">
|
|
3
|
-
<path
|
|
4
|
-
d="M752 176V64c0-35.3-28.7-64-64-64H144c-35.3 0-64 28.7-64 64v704c0 35.3 28.7 64 64 64h112c8.8 0 16 7.2 16 16v112c0 35.3 28.7 64 64 64h544c35.3 0 64-28.7 64-64V256c0-35.3-28.7-64-64-64H768c-8.8 0-16-7.2-16-16zM256 768h-96c-8.8 0-16-7.2-16-16V80c0-8.8 7.2-16 16-16h512c8.8 0 16 7.2 16 16v96c0 8.8-7.2 16-16 16H336c-35.3 0-64 28.7-64 64v496c0 8.8-7.2 16-16 16z m608 192H352c-8.8 0-16-7.2-16-16V272c0-8.8 7.2-16 16-16h512c8.8 0 16 7.2 16 16v672c0 8.8-7.2 16-16 16z"
|
|
5
|
-
p-id="4810" fill="#646cff"></path>
|
|
6
|
-
<path d="M704 352H512c-17.7 0-32-14.3-32-32s14.3-32 32-32h192c17.7 0 32 14.3 32 32s-14.3 32-32 32z" p-id="4811"
|
|
7
|
-
fill="#646cff"></path>
|
|
1
|
+
<svg t="1735090484450" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4809"
|
|
2
|
+
width="1em" height="1em">
|
|
3
|
+
<path
|
|
4
|
+
d="M752 176V64c0-35.3-28.7-64-64-64H144c-35.3 0-64 28.7-64 64v704c0 35.3 28.7 64 64 64h112c8.8 0 16 7.2 16 16v112c0 35.3 28.7 64 64 64h544c35.3 0 64-28.7 64-64V256c0-35.3-28.7-64-64-64H768c-8.8 0-16-7.2-16-16zM256 768h-96c-8.8 0-16-7.2-16-16V80c0-8.8 7.2-16 16-16h512c8.8 0 16 7.2 16 16v96c0 8.8-7.2 16-16 16H336c-35.3 0-64 28.7-64 64v496c0 8.8-7.2 16-16 16z m608 192H352c-8.8 0-16-7.2-16-16V272c0-8.8 7.2-16 16-16h512c8.8 0 16 7.2 16 16v672c0 8.8-7.2 16-16 16z"
|
|
5
|
+
p-id="4810" fill="#646cff"></path>
|
|
6
|
+
<path d="M704 352H512c-17.7 0-32-14.3-32-32s14.3-32 32-32h192c17.7 0 32 14.3 32 32s-14.3 32-32 32z" p-id="4811"
|
|
7
|
+
fill="#646cff"></path>
|
|
8
8
|
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="#646cff" stroke-width="2" d="m3 3l18 18M3 21L21 3"/></svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="#646cff" stroke-width="2" d="m3 3l18 18M3 21L21 3"/></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#646cff" d="M17.1 5L14 8.1L29.9 24L14 39.9l3.1 3.1L36 24z"/></svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#646cff" d="M17.1 5L14 8.1L29.9 24L14 39.9l3.1 3.1L36 24z"/></svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="#646cff" stroke-dasharray="24" stroke-dashoffset="24" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 11l6 6l10 -10"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.4s" values="24;0"/></path></svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><path fill="none" stroke="#646cff" stroke-dasharray="24" stroke-dashoffset="24" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 11l6 6l10 -10"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.4s" values="24;0"/></path></svg>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
-
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
|
3
|
-
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
|
4
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
|
|
3
|
+
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
|
|
4
|
+
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><g fill="none"><path d="M19 12a7 7 0 1 1-14 0a7 7 0 0 1 14 0"/><path stroke="#646cff" stroke-linecap="square" stroke-width="2" d="M19 12a7 7 0 0 1-7 7m7-7a7 7 0 0 0-7-7m7 7h3m-10 7a7 7 0 0 1-7-7m7 7v3M5 12a7 7 0 0 1 7-7m-7 7H2m10-7V2m1 10a1 1 0 1 1-2 0a1 1 0 0 1 2 0Z"/></g></svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"><g fill="none"><path d="M19 12a7 7 0 1 1-14 0a7 7 0 0 1 14 0"/><path stroke="#646cff" stroke-linecap="square" stroke-width="2" d="M19 12a7 7 0 0 1-7 7m7-7a7 7 0 0 0-7-7m7 7h3m-10 7a7 7 0 0 1-7-7m7 7v3M5 12a7 7 0 0 1 7-7m-7 7H2m10-7V2m1 10a1 1 0 1 1-2 0a1 1 0 0 1 2 0Z"/></g></svg>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
2
|
-
<path fill="#5961ff" d="M2 4h20v2H2zm0 5.57L5.887 12L2 14.43zM7 11h15v2H7zm-5 7h20v2H2z" />
|
|
3
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
2
|
+
<path fill="#5961ff" d="M2 4h20v2H2zm0 5.57L5.887 12L2 14.43zM7 11h15v2H7zm-5 7h20v2H2z" />
|
|
3
|
+
</svg>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" stroke="#5961ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M2 11V4.6a.6.6 0 0 1 .6-.6h6.178a.6.6 0 0 1 .39.144l3.164 2.712a.6.6 0 0 0 .39.144H21.4a.6.6 0 0 1 .6.6V11M2 11v8.4a.6.6 0 0 0 .6.6h18.8a.6.6 0 0 0 .6-.6V11M2 11h20"/></svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" stroke="#5961ff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M2 11V4.6a.6.6 0 0 1 .6-.6h6.178a.6.6 0 0 1 .39.144l3.164 2.712a.6.6 0 0 0 .39.144H21.4a.6.6 0 0 1 .6.6V11M2 11v8.4a.6.6 0 0 0 .6.6h18.8a.6.6 0 0 0 .6-.6V11M2 11h20"/></svg>
|