@tnotesjs/core 0.1.6 → 0.1.9

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfigManager,
3
3
  getConfigManager
4
- } from "./chunk-UIXF3LPU.js";
4
+ } from "./chunk-NASIL5FY.js";
5
5
 
6
6
  // commands/models.ts
7
7
  var COMMAND_NAMES = {
@@ -589,7 +589,7 @@ async function waitForPort(port2, timeout = 5e3) {
589
589
  if (!isPortInUse(port2)) {
590
590
  return true;
591
591
  }
592
- await new Promise((resolve3) => setTimeout(resolve3, 100));
592
+ await new Promise((resolve2) => setTimeout(resolve2, 100));
593
593
  }
594
594
  return false;
595
595
  }
@@ -1088,13 +1088,13 @@ function processEmptyLines(lines) {
1088
1088
  // utils/runCommand.ts
1089
1089
  import { exec } from "child_process";
1090
1090
  async function runCommand(command, dir) {
1091
- return new Promise((resolve3, reject) => {
1091
+ return new Promise((resolve2, reject) => {
1092
1092
  exec(command, { cwd: dir }, (error, stdout, stderr) => {
1093
1093
  if (error) {
1094
1094
  console.error(`\u5904\u7406 ${dir} \u65F6\u51FA\u9519\uFF1A${stderr}`);
1095
1095
  reject(error);
1096
1096
  } else {
1097
- resolve3(stdout.trim());
1097
+ resolve2(stdout.trim());
1098
1098
  }
1099
1099
  });
1100
1100
  });
@@ -1763,8 +1763,6 @@ var ReadmeGenerator = class {
1763
1763
  };
1764
1764
 
1765
1765
  // core/GitManager.ts
1766
- import { resolve as resolve2 } from "path";
1767
- import { existsSync as existsSync3 } from "fs";
1768
1766
  var GitManager = class {
1769
1767
  logger;
1770
1768
  dir;
@@ -1958,7 +1956,6 @@ var GitManager = class {
1958
1956
  } else {
1959
1957
  this.logger.info("\u5DF2\u662F\u6700\u65B0\uFF0C\u6CA1\u6709\u9700\u8981\u62C9\u53D6\u7684\u66F4\u65B0");
1960
1958
  }
1961
- await this.updateSubmodules();
1962
1959
  } catch (error) {
1963
1960
  this.logger.error("\u62C9\u53D6\u5931\u8D25");
1964
1961
  handleError(error);
@@ -2032,18 +2029,12 @@ var GitManager = class {
2032
2029
  return;
2033
2030
  }
2034
2031
  try {
2035
- await this.pushSubmodules(commitMessage);
2036
- const latestStatus = await this.getStatus();
2037
- if (!latestStatus.hasChanges) {
2038
- this.logger.info("\u6CA1\u6709\u9700\u8981\u63D0\u4EA4\u7684\u66F4\u6539");
2039
- return;
2040
- }
2041
- this.logger.info(`\u6B63\u5728\u63A8\u9001 ${latestStatus.changedFiles} \u4E2A\u6587\u4EF6...`);
2042
- latestStatus.files.forEach((file, index) => {
2032
+ this.logger.info(`\u6B63\u5728\u63A8\u9001 ${status.changedFiles} \u4E2A\u6587\u4EF6...`);
2033
+ status.files.forEach((file, index) => {
2043
2034
  console.log(` ${index + 1}. ${file.path}`);
2044
2035
  });
2045
2036
  await runCommand("git add .", this.dir);
2046
- const message = commitMessage || `update: ${latestStatus.changedFiles} files modified`;
2037
+ const message = commitMessage || `update: ${status.changedFiles} files modified`;
2047
2038
  await runCommand(`git commit -m "${message}"`, this.dir);
2048
2039
  let cmd = "git push";
2049
2040
  if (options?.force) cmd += " --force";
@@ -2051,10 +2042,10 @@ var GitManager = class {
2051
2042
  const remoteInfo = await this.getRemoteInfo();
2052
2043
  if (remoteInfo) {
2053
2044
  this.logger.success(
2054
- `\u63A8\u9001\u6210\u529F: ${latestStatus.changedFiles} \u4E2A\u6587\u4EF6 \u2192 https://github.com/${remoteInfo.owner}/${remoteInfo.repo}`
2045
+ `\u63A8\u9001\u6210\u529F: ${status.changedFiles} \u4E2A\u6587\u4EF6 \u2192 https://github.com/${remoteInfo.owner}/${remoteInfo.repo}`
2055
2046
  );
2056
2047
  } else {
2057
- this.logger.success(`\u63A8\u9001\u6210\u529F: ${latestStatus.changedFiles} \u4E2A\u6587\u4EF6`);
2048
+ this.logger.success(`\u63A8\u9001\u6210\u529F: ${status.changedFiles} \u4E2A\u6587\u4EF6`);
2058
2049
  }
2059
2050
  } catch (error) {
2060
2051
  this.logger.error(`\u63A8\u9001\u5931\u8D25`);
@@ -2076,83 +2067,6 @@ var GitManager = class {
2076
2067
  throw error;
2077
2068
  }
2078
2069
  }
2079
- // ==================== Submodule 操作 ====================
2080
- /**
2081
- * 检查仓库是否包含 submodule
2082
- */
2083
- hasSubmodules() {
2084
- return existsSync3(resolve2(this.dir, ".gitmodules"));
2085
- }
2086
- /**
2087
- * 获取所有 submodule 的路径
2088
- */
2089
- async getSubmodulePaths() {
2090
- if (!this.hasSubmodules()) return [];
2091
- try {
2092
- const output = await runCommand(
2093
- "git config --file .gitmodules --get-regexp path",
2094
- this.dir
2095
- );
2096
- return output.trim().split("\n").filter((line) => line).map((line) => line.replace(/^submodule\..*\.path\s+/, ""));
2097
- } catch {
2098
- return [];
2099
- }
2100
- }
2101
- /**
2102
- * 推送前处理 submodule:检查未提交/未推送的更改,自动提交并推送
2103
- */
2104
- async pushSubmodules(commitMessage) {
2105
- const paths = await this.getSubmodulePaths();
2106
- if (paths.length === 0) return;
2107
- for (const subPath of paths) {
2108
- const absPath = resolve2(this.dir, subPath);
2109
- let hasChanges = false;
2110
- try {
2111
- const status = await runCommand("git status --porcelain", absPath);
2112
- hasChanges = status.trim().length > 0;
2113
- } catch {
2114
- continue;
2115
- }
2116
- if (hasChanges) {
2117
- const message = commitMessage || "update";
2118
- this.logger.info(`Submodule [${subPath}] \u6709\u672A\u63D0\u4EA4\u7684\u66F4\u6539\uFF0C\u6B63\u5728\u63D0\u4EA4...`);
2119
- await runCommand("git add -A", absPath);
2120
- await runCommand(`git commit -m "${message}"`, absPath);
2121
- }
2122
- let unpushed = 0;
2123
- try {
2124
- const output = await runCommand(
2125
- "git rev-list @{u}..HEAD --count",
2126
- absPath
2127
- );
2128
- unpushed = parseInt(output.trim()) || 0;
2129
- } catch {
2130
- unpushed = 1;
2131
- }
2132
- if (unpushed > 0) {
2133
- this.logger.info(
2134
- `Submodule [${subPath}] \u6709 ${unpushed} \u4E2A\u672A\u63A8\u9001\u7684\u63D0\u4EA4\uFF0C\u6B63\u5728\u63A8\u9001...`
2135
- );
2136
- await runCommand("git push", absPath);
2137
- this.logger.success(`Submodule [${subPath}] \u63A8\u9001\u6210\u529F`);
2138
- }
2139
- }
2140
- }
2141
- /**
2142
- * 拉取后更新 submodule 到父仓库指针指向的 commit
2143
- */
2144
- async updateSubmodules() {
2145
- if (!this.hasSubmodules()) return;
2146
- try {
2147
- this.logger.info("\u6B63\u5728\u66F4\u65B0 submodule...");
2148
- await runCommand("git submodule update --init", this.dir);
2149
- this.logger.success("Submodule \u5DF2\u540C\u6B65\u5230\u6700\u65B0\u6307\u9488");
2150
- } catch (error) {
2151
- this.logger.warn(
2152
- "Submodule \u66F4\u65B0\u5931\u8D25\uFF0C\u8BF7\u624B\u52A8\u6267\u884C git submodule update --init"
2153
- );
2154
- }
2155
- }
2156
2070
  /**
2157
2071
  * 显示状态摘要
2158
2072
  */
@@ -2381,7 +2295,7 @@ async function safeExecute(label, fn, logger2) {
2381
2295
  }
2382
2296
 
2383
2297
  // services/file-watcher/watchState.ts
2384
- import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync3, statSync } from "fs";
2298
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync as readdirSync3, statSync } from "fs";
2385
2299
  import { createHash } from "crypto";
2386
2300
  import { join as join4 } from "path";
2387
2301
  var WatchState = class {
@@ -2402,7 +2316,7 @@ var WatchState = class {
2402
2316
  */
2403
2317
  getFileHash(filePath) {
2404
2318
  try {
2405
- if (!existsSync4(filePath)) return null;
2319
+ if (!existsSync3(filePath)) return null;
2406
2320
  const content = readFileSync3(filePath, "utf-8");
2407
2321
  if (content.length === 0) return null;
2408
2322
  return createHash("md5").update(content).digest("hex");
@@ -2497,7 +2411,7 @@ var WatchState = class {
2497
2411
  */
2498
2412
  readConfigSnapshot(configPath) {
2499
2413
  try {
2500
- if (!existsSync4(configPath)) return null;
2414
+ if (!existsSync3(configPath)) return null;
2501
2415
  const content = readFileSync3(configPath, "utf-8");
2502
2416
  const config2 = JSON.parse(content);
2503
2417
  return {
@@ -2665,7 +2579,7 @@ var EventScheduler = class {
2665
2579
  };
2666
2580
 
2667
2581
  // services/file-watcher/renameDetector.ts
2668
- import { existsSync as existsSync5 } from "fs";
2582
+ import { existsSync as existsSync4 } from "fs";
2669
2583
  import { join as join5 } from "path";
2670
2584
  var FOLDER_RENAME_DETECT_WINDOW_MS = 500;
2671
2585
  var RenameDetector = class {
@@ -2679,7 +2593,7 @@ var RenameDetector = class {
2679
2593
  handleFsRename(folderName) {
2680
2594
  const { notesDir, dirCache, logger: logger2, onDelete, onRename } = this.config;
2681
2595
  const folderPath = join5(notesDir, folderName);
2682
- const folderExists = existsSync5(folderPath);
2596
+ const folderExists = existsSync4(folderPath);
2683
2597
  const noteIndex = NoteManager.extractNoteIndex(folderName);
2684
2598
  if (!noteIndex) {
2685
2599
  logger2.warn(`\u65E0\u6CD5\u4ECE\u6587\u4EF6\u5939\u540D\u79F0\u63D0\u53D6\u7B14\u8BB0\u7D22\u5F15: ${folderName}`);
@@ -2816,7 +2730,7 @@ var GlobalUpdateCoordinator = class {
2816
2730
  };
2817
2731
 
2818
2732
  // services/file-watcher/folderChangeHandler.ts
2819
- import { existsSync as existsSync6, promises as fsPromises } from "fs";
2733
+ import { existsSync as existsSync5, promises as fsPromises } from "fs";
2820
2734
  import { join as join6 } from "path";
2821
2735
  var RENAME_REVERT_DELAY_MS = 2e3;
2822
2736
  var DELETE_REINIT_DELAY_MS = 1e3;
@@ -2953,7 +2867,7 @@ var FolderChangeHandler = class {
2953
2867
  try {
2954
2868
  const oldPath = join6(notesDir, oldName);
2955
2869
  const newPath = join6(notesDir, newName);
2956
- if (existsSync6(newPath)) {
2870
+ if (existsSync5(newPath)) {
2957
2871
  scheduler.setUpdating(true);
2958
2872
  await fsPromises.rename(newPath, oldPath);
2959
2873
  logger2.warn(`\u6587\u4EF6\u5939\u5DF2\u56DE\u9000: ${newName} \u2192 ${oldName}`);
@@ -3048,7 +2962,7 @@ var FsWatcherAdapter = class {
3048
2962
 
3049
2963
  // services/readme/service.ts
3050
2964
  import {
3051
- existsSync as existsSync7,
2965
+ existsSync as existsSync6,
3052
2966
  readFileSync as readFileSync4,
3053
2967
  writeFileSync as writeFileSync3,
3054
2968
  promises as fsPromises2
@@ -3183,7 +3097,7 @@ var ReadmeService = class _ReadmeService {
3183
3097
  * @param notes - 笔记信息数组
3184
3098
  */
3185
3099
  async updateSidebar(notes) {
3186
- if (!existsSync7(ROOT_README_PATH)) {
3100
+ if (!existsSync6(ROOT_README_PATH)) {
3187
3101
  logger.error("\u672A\u627E\u5230\u9996\u9875 README\uFF0C\u65E0\u6CD5\u751F\u6210\u4FA7\u8FB9\u680F");
3188
3102
  return;
3189
3103
  }
@@ -3882,7 +3796,7 @@ var GitService = class {
3882
3796
  };
3883
3797
 
3884
3798
  // services/sync-core/service.ts
3885
- import { existsSync as existsSync8 } from "fs";
3799
+ import { existsSync as existsSync7 } from "fs";
3886
3800
  import { join as join9, basename as basename2 } from "path";
3887
3801
  var SyncCoreService = class {
3888
3802
  /**
@@ -3892,7 +3806,7 @@ var SyncCoreService = class {
3892
3806
  const repoName2 = basename2(targetDir);
3893
3807
  const submodulePath = join9(targetDir, ".vitepress", "tnotes");
3894
3808
  try {
3895
- if (!existsSync8(join9(targetDir, ".gitmodules"))) {
3809
+ if (!existsSync7(join9(targetDir, ".gitmodules"))) {
3896
3810
  return {
3897
3811
  dir: targetDir,
3898
3812
  repoName: repoName2,
@@ -3901,7 +3815,7 @@ var SyncCoreService = class {
3901
3815
  error: "\u672A\u627E\u5230 .gitmodules\uFF0C\u8BE5\u4ED3\u5E93\u672A\u914D\u7F6E submodule"
3902
3816
  };
3903
3817
  }
3904
- if (!existsSync8(submodulePath)) {
3818
+ if (!existsSync7(submodulePath)) {
3905
3819
  await runCommand("git submodule update --init", targetDir);
3906
3820
  }
3907
3821
  const beforeHash = (await runCommand("git rev-parse HEAD", submodulePath)).trim();
@@ -4007,7 +3921,7 @@ var SyncCoreService = class {
4007
3921
 
4008
3922
  // services/timestamp/service.ts
4009
3923
  import {
4010
- existsSync as existsSync9,
3924
+ existsSync as existsSync8,
4011
3925
  readFileSync as readFileSync6,
4012
3926
  writeFileSync as writeFileSync5,
4013
3927
  readdirSync as readdirSync4,
@@ -4066,7 +3980,7 @@ var TimestampService = class {
4066
3980
  */
4067
3981
  fixNoteTimestamps(noteDir, forceUpdate = false) {
4068
3982
  const configPath = join10(NOTES_DIR_PATH, noteDir, ".tnotes.json");
4069
- if (!existsSync9(configPath)) {
3983
+ if (!existsSync8(configPath)) {
4070
3984
  return false;
4071
3985
  }
4072
3986
  try {
@@ -4171,7 +4085,7 @@ var TimestampService = class {
4171
4085
  if (rootConfigFixed) {
4172
4086
  logger.success("\u2705 \u6839\u914D\u7F6E\u6587\u4EF6\u65F6\u95F4\u6233\u5DF2\u4FEE\u590D");
4173
4087
  }
4174
- if (!existsSync9(NOTES_DIR_PATH)) {
4088
+ if (!existsSync8(NOTES_DIR_PATH)) {
4175
4089
  logger.error("notes \u76EE\u5F55\u4E0D\u5B58\u5728");
4176
4090
  return { fixed: 0, skipped: 0, total: 0, rootConfigFixed };
4177
4091
  }
@@ -4214,7 +4128,7 @@ var TimestampService = class {
4214
4128
  let updatedCount = 0;
4215
4129
  for (const noteDir of noteDirNames) {
4216
4130
  const configPath = join10(NOTES_DIR_PATH, noteDir, ".tnotes.json");
4217
- if (!existsSync9(configPath)) {
4131
+ if (!existsSync8(configPath)) {
4218
4132
  continue;
4219
4133
  }
4220
4134
  try {
@@ -4285,7 +4199,7 @@ var VitepressService = class _VitepressService {
4285
4199
  if (this.processManager.has(processId) && this.processManager.isRunning(processId)) {
4286
4200
  this.processManager.kill(processId);
4287
4201
  await new Promise(
4288
- (resolve3) => setTimeout(resolve3, _VitepressService.PROCESS_CLEANUP_DELAY)
4202
+ (resolve2) => setTimeout(resolve2, _VitepressService.PROCESS_CLEANUP_DELAY)
4289
4203
  );
4290
4204
  }
4291
4205
  if (isPortInUse(port2)) {
@@ -4323,7 +4237,7 @@ var VitepressService = class _VitepressService {
4323
4237
  * @param childProcess - 子进程
4324
4238
  */
4325
4239
  waitForServerReady(childProcess) {
4326
- return new Promise((resolve3) => {
4240
+ return new Promise((resolve2) => {
4327
4241
  const startTime = Date.now();
4328
4242
  let serverReady = false;
4329
4243
  let version = "";
@@ -4350,7 +4264,7 @@ var VitepressService = class _VitepressService {
4350
4264
  process.stderr.clearLine?.(0);
4351
4265
  process.stderr.cursorTo?.(0);
4352
4266
  const elapsed = Date.now() - startTime;
4353
- setTimeout(() => resolve3({ version, elapsed }), 200);
4267
+ setTimeout(() => resolve2({ version, elapsed }), 200);
4354
4268
  return;
4355
4269
  }
4356
4270
  if (!serverReady) {
@@ -4376,7 +4290,7 @@ var VitepressService = class _VitepressService {
4376
4290
  process.stderr.clearLine?.(0);
4377
4291
  process.stderr.cursorTo?.(0);
4378
4292
  logger.warn("\u542F\u52A8\u8D85\u65F6\uFF0C\u8BF7\u68C0\u67E5 VitePress \u8F93\u51FA");
4379
- resolve3({ version, elapsed: _VitepressService.SERVER_STARTUP_TIMEOUT });
4293
+ resolve2({ version, elapsed: _VitepressService.SERVER_STARTUP_TIMEOUT });
4380
4294
  }
4381
4295
  }, _VitepressService.SERVER_STARTUP_TIMEOUT);
4382
4296
  });
@@ -4385,7 +4299,7 @@ var VitepressService = class _VitepressService {
4385
4299
  * 构建生产版本
4386
4300
  */
4387
4301
  build() {
4388
- return new Promise((resolve3, reject) => {
4302
+ return new Promise((resolve2, reject) => {
4389
4303
  const pm = this.configManager.get("packageManager") || _VitepressService.DEFAULT_PACKAGE_MANAGER;
4390
4304
  const child = spawn2(pm, ["vitepress", "build"], {
4391
4305
  cwd: ROOT_DIR_PATH,
@@ -4409,7 +4323,7 @@ var VitepressService = class _VitepressService {
4409
4323
  });
4410
4324
  child.on("close", (code) => {
4411
4325
  if (code === 0) {
4412
- resolve3();
4326
+ resolve2();
4413
4327
  } else {
4414
4328
  reject(new Error(`Command failed with code ${code}`));
4415
4329
  }
@@ -4504,7 +4418,7 @@ var UpdateNoteConfigCommand = class extends BaseCommand {
4504
4418
  };
4505
4419
 
4506
4420
  // commands/note/RenameNoteCommand.ts
4507
- import { existsSync as existsSync10, renameSync, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
4421
+ import { existsSync as existsSync9, renameSync, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "fs";
4508
4422
  import { join as join11 } from "path";
4509
4423
  var RenameNoteCommand = class extends BaseCommand {
4510
4424
  noteService;
@@ -4543,7 +4457,7 @@ var RenameNoteCommand = class extends BaseCommand {
4543
4457
  }
4544
4458
  const newDirName = `${noteIndex}. ${newTitle.trim()}`;
4545
4459
  const newPath = join11(NOTES_PATH, newDirName);
4546
- if (existsSync10(newPath)) {
4460
+ if (existsSync9(newPath)) {
4547
4461
  throw new Error(`\u76EE\u6807\u6587\u4EF6\u5939\u5DF2\u5B58\u5728: ${newDirName}`);
4548
4462
  }
4549
4463
  try {
@@ -4559,7 +4473,7 @@ var RenameNoteCommand = class extends BaseCommand {
4559
4473
  try {
4560
4474
  this.logger.info("\u6B63\u5728\u66F4\u65B0\u7B14\u8BB0\u5185\u90E8\u6807\u9898...");
4561
4475
  const readmePath = join11(newPath, "README.md");
4562
- if (existsSync10(readmePath)) {
4476
+ if (existsSync9(readmePath)) {
4563
4477
  const content = readFileSync7(readmePath, "utf-8");
4564
4478
  const lines = content.split("\n");
4565
4479
  let h1Index = -1;
@@ -1,29 +1,3 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
1
  // config/ConfigManager.ts
28
2
  import fs from "fs";
29
3
  import path from "path";
@@ -224,8 +198,6 @@ function getConfigManager() {
224
198
  }
225
199
 
226
200
  export {
227
- __commonJS,
228
- __toESM,
229
201
  ConfigManager,
230
202
  getConfigManager
231
203
  };
package/dist/cli/index.js CHANGED
@@ -28,10 +28,10 @@ import {
28
28
  pushAllRepos,
29
29
  runCommand,
30
30
  syncAllRepos
31
- } from "../chunk-H2NACWVJ.js";
31
+ } from "../chunk-DT6HO7XD.js";
32
32
  import {
33
33
  ConfigManager
34
- } from "../chunk-UIXF3LPU.js";
34
+ } from "../chunk-NASIL5FY.js";
35
35
 
36
36
  // commands/update/UpdateCommand.ts
37
37
  import { existsSync, readFileSync, writeFileSync } from "fs";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfigManager,
3
3
  getConfigManager
4
- } from "./chunk-UIXF3LPU.js";
4
+ } from "./chunk-NASIL5FY.js";
5
5
  export {
6
6
  ConfigManager,
7
7
  getConfigManager
@@ -4,112 +4,8 @@ import {
4
4
  UpdateNoteConfigCommand,
5
5
  generateAnchor,
6
6
  logger
7
- } from "../../chunk-H2NACWVJ.js";
8
- import {
9
- __commonJS,
10
- __toESM
11
- } from "../../chunk-UIXF3LPU.js";
12
-
13
- // node_modules/.pnpm/markdown-it-task-lists@2.1.1/node_modules/markdown-it-task-lists/index.js
14
- var require_markdown_it_task_lists = __commonJS({
15
- "node_modules/.pnpm/markdown-it-task-lists@2.1.1/node_modules/markdown-it-task-lists/index.js"(exports, module) {
16
- var disableCheckboxes = true;
17
- var useLabelWrapper = false;
18
- var useLabelAfter = false;
19
- module.exports = function(md, options) {
20
- if (options) {
21
- disableCheckboxes = !options.enabled;
22
- useLabelWrapper = !!options.label;
23
- useLabelAfter = !!options.labelAfter;
24
- }
25
- md.core.ruler.after("inline", "github-task-lists", function(state) {
26
- var tokens = state.tokens;
27
- for (var i = 2; i < tokens.length; i++) {
28
- if (isTodoItem(tokens, i)) {
29
- todoify(tokens[i], state.Token);
30
- attrSet(tokens[i - 2], "class", "task-list-item" + (!disableCheckboxes ? " enabled" : ""));
31
- attrSet(tokens[parentToken(tokens, i - 2)], "class", "contains-task-list");
32
- }
33
- }
34
- });
35
- };
36
- function attrSet(token, name, value) {
37
- var index = token.attrIndex(name);
38
- var attr = [name, value];
39
- if (index < 0) {
40
- token.attrPush(attr);
41
- } else {
42
- token.attrs[index] = attr;
43
- }
44
- }
45
- function parentToken(tokens, index) {
46
- var targetLevel = tokens[index].level - 1;
47
- for (var i = index - 1; i >= 0; i--) {
48
- if (tokens[i].level === targetLevel) {
49
- return i;
50
- }
51
- }
52
- return -1;
53
- }
54
- function isTodoItem(tokens, index) {
55
- return isInline(tokens[index]) && isParagraph(tokens[index - 1]) && isListItem(tokens[index - 2]) && startsWithTodoMarkdown(tokens[index]);
56
- }
57
- function todoify(token, TokenConstructor) {
58
- token.children.unshift(makeCheckbox(token, TokenConstructor));
59
- token.children[1].content = token.children[1].content.slice(3);
60
- token.content = token.content.slice(3);
61
- if (useLabelWrapper) {
62
- if (useLabelAfter) {
63
- token.children.pop();
64
- var id = "task-item-" + Math.ceil(Math.random() * (1e4 * 1e3) - 1e3);
65
- token.children[0].content = token.children[0].content.slice(0, -1) + ' id="' + id + '">';
66
- token.children.push(afterLabel(token.content, id, TokenConstructor));
67
- } else {
68
- token.children.unshift(beginLabel(TokenConstructor));
69
- token.children.push(endLabel(TokenConstructor));
70
- }
71
- }
72
- }
73
- function makeCheckbox(token, TokenConstructor) {
74
- var checkbox = new TokenConstructor("html_inline", "", 0);
75
- var disabledAttr = disableCheckboxes ? ' disabled="" ' : "";
76
- if (token.content.indexOf("[ ] ") === 0) {
77
- checkbox.content = '<input class="task-list-item-checkbox"' + disabledAttr + 'type="checkbox">';
78
- } else if (token.content.indexOf("[x] ") === 0 || token.content.indexOf("[X] ") === 0) {
79
- checkbox.content = '<input class="task-list-item-checkbox" checked=""' + disabledAttr + 'type="checkbox">';
80
- }
81
- return checkbox;
82
- }
83
- function beginLabel(TokenConstructor) {
84
- var token = new TokenConstructor("html_inline", "", 0);
85
- token.content = "<label>";
86
- return token;
87
- }
88
- function endLabel(TokenConstructor) {
89
- var token = new TokenConstructor("html_inline", "", 0);
90
- token.content = "</label>";
91
- return token;
92
- }
93
- function afterLabel(content, id, TokenConstructor) {
94
- var token = new TokenConstructor("html_inline", "", 0);
95
- token.content = '<label class="task-list-item-label" for="' + id + '">' + content + "</label>";
96
- token.attrs = [{ for: id }];
97
- return token;
98
- }
99
- function isInline(token) {
100
- return token.type === "inline";
101
- }
102
- function isParagraph(token) {
103
- return token.type === "paragraph_open";
104
- }
105
- function isListItem(token) {
106
- return token.type === "list_item_open";
107
- }
108
- function startsWithTodoMarkdown(token) {
109
- return token.content.indexOf("[ ] ") === 0 || token.content.indexOf("[x] ") === 0 || token.content.indexOf("[X] ") === 0;
110
- }
111
- }
112
- });
7
+ } from "../../chunk-DT6HO7XD.js";
8
+ import "../../chunk-NASIL5FY.js";
113
9
 
114
10
  // vitepress/config/index.ts
115
11
  import fs2 from "fs";
@@ -143,9 +39,9 @@ function getHeadConfig(config, githubPageUrl) {
143
39
  }
144
40
 
145
41
  // vitepress/configs/markdown.config.ts
146
- var import_markdown_it_task_lists = __toESM(require_markdown_it_task_lists(), 1);
147
42
  import markdownItContainer from "markdown-it-container";
148
43
  import mila from "markdown-it-link-attributes";
44
+ import markdownItTaskLists from "markdown-it-task-lists";
149
45
  import fs from "fs";
150
46
  import path from "path";
151
47
  function esc(s = "") {
@@ -369,7 +265,7 @@ function getMarkdownConfig() {
369
265
  });
370
266
  simpleMermaidMarkdown(md);
371
267
  configureMarkMapContainer(md);
372
- md.use(import_markdown_it_task_lists.default);
268
+ md.use(markdownItTaskLists);
373
269
  md.use(mila, {
374
270
  attrs: {
375
271
  target: "_self",
@@ -968,12 +864,18 @@ function defineNotesConfig(overrides = {}) {
968
864
  __TNOTES_ROOT_ITEM__: JSON.stringify(config.root_item),
969
865
  ...overrideVite?.define
970
866
  },
867
+ resolve: {
868
+ dedupe: ["vue", "vitepress"],
869
+ ...overrideVite?.resolve
870
+ },
971
871
  optimizeDeps: {
972
872
  include: [
973
- "@vscode/markdown-it-katex",
974
- "dayjs",
975
- "dayjs/plugin/utc",
976
- "dayjs/plugin/localizedFormat"
873
+ // VitePress 内部 CJS 依赖 —— 需要 Vite 预构建为 ESM
874
+ "vitepress > @vscode/markdown-it-katex",
875
+ "vitepress > @braintree/sanitize-url",
876
+ "vitepress > dayjs",
877
+ "vitepress > dayjs/plugin/utc",
878
+ "vitepress > dayjs/plugin/localizedFormat"
977
879
  ],
978
880
  ...overrideVite?.optimizeDeps
979
881
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tnotesjs/core",
3
- "version": "0.1.6",
3
+ "version": "0.1.9",
4
4
  "description": "TNotes 知识库核心框架 —— 基于 VitePress 的笔记管理系统",
5
5
  "type": "module",
6
6
  "bin": {
@@ -41,10 +41,13 @@
41
41
  "markdown-it-container": "^4.0.0",
42
42
  "markdown-it-link-attributes": "^4.0.1",
43
43
  "markdown-it-mathjax3": "^4.3.2",
44
+ "markdown-it-task-lists": "^2.1.1",
44
45
  "marked": "^15.0.11",
45
46
  "markmap-lib": "^0.18.12",
46
47
  "markmap-toolbar": "^0.18.12",
47
48
  "markmap-view": "^0.18.12",
49
+ "mermaid": "^11.5.0",
50
+ "sass-embedded": "^1.90.0",
48
51
  "swiper": "^11.2.1",
49
52
  "uuid": "^11.1.0",
50
53
  "vue-echarts": "^8.0.1"
@@ -52,8 +55,6 @@
52
55
  "devDependencies": {
53
56
  "@types/markdown-it": "^14.1.2",
54
57
  "@types/node": "^24.6.2",
55
- "markdown-it-task-lists": "^2.1.1",
56
- "sass-embedded": "^1.90.0",
57
58
  "tsup": "^8.5.1",
58
59
  "typescript": "^5.9.3"
59
60
  },
@@ -102,12 +102,18 @@ export function defineNotesConfig(overrides: UserConfig = {}) {
102
102
  __TNOTES_ROOT_ITEM__: JSON.stringify(config.root_item),
103
103
  ...overrideVite?.define,
104
104
  },
105
+ resolve: {
106
+ dedupe: ['vue', 'vitepress'],
107
+ ...overrideVite?.resolve,
108
+ },
105
109
  optimizeDeps: {
106
110
  include: [
107
- '@vscode/markdown-it-katex',
108
- 'dayjs',
109
- 'dayjs/plugin/utc',
110
- 'dayjs/plugin/localizedFormat',
111
+ // VitePress 内部 CJS 依赖 —— 需要 Vite 预构建为 ESM
112
+ 'vitepress > @vscode/markdown-it-katex',
113
+ 'vitepress > @braintree/sanitize-url',
114
+ 'vitepress > dayjs',
115
+ 'vitepress > dayjs/plugin/utc',
116
+ 'vitepress > dayjs/plugin/localizedFormat',
111
117
  ],
112
118
  ...overrideVite?.optimizeDeps,
113
119
  },