@tnotesjs/core 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +87 -84
  2. package/dist/{chunk-JDVN2QYW.js → chunk-JUMVJKWV.js} +615 -614
  3. package/dist/cli/index.js +125 -125
  4. package/dist/vitepress/config/index.js +184 -210
  5. package/package.json +15 -3
  6. package/types/config.ts +61 -61
  7. package/types/index.ts +11 -11
  8. package/types/note.ts +33 -33
  9. package/types/shims.d.ts +3 -4
  10. package/vitepress/assets/icons/icon__check.svg +3 -3
  11. package/vitepress/assets/icons/icon__clipboard.svg +7 -7
  12. package/vitepress/assets/icons/icon__close.svg +1 -1
  13. package/vitepress/assets/icons/icon__collapse.svg +1 -1
  14. package/vitepress/assets/icons/icon__confirm.svg +1 -1
  15. package/vitepress/assets/icons/icon__copy.svg +4 -4
  16. package/vitepress/assets/icons/icon__focus.svg +1 -1
  17. package/vitepress/assets/icons/icon__fold.svg +3 -3
  18. package/vitepress/assets/icons/icon__folder.svg +1 -1
  19. package/vitepress/assets/icons/icon__fullscreen.svg +1 -1
  20. package/vitepress/assets/icons/icon__fullscreen_exit.svg +1 -1
  21. package/vitepress/assets/icons/icon__github.svg +3 -3
  22. package/vitepress/assets/icons/icon__mindmap.svg +1 -1
  23. package/vitepress/assets/icons/icon__next.svg +1 -1
  24. package/vitepress/assets/icons/icon__number_gray.svg +1 -1
  25. package/vitepress/assets/icons/icon__number_purple.svg +1 -1
  26. package/vitepress/assets/icons/icon__prev.svg +1 -1
  27. package/vitepress/assets/icons/icon__restore.svg +1 -1
  28. package/vitepress/assets/icons/icon__rotate.svg +4 -4
  29. package/vitepress/assets/icons/icon__search.svg +1 -1
  30. package/vitepress/assets/icons/icon__sidebar_collapsed.svg +1 -1
  31. package/vitepress/assets/icons/icon__sidebar_opened.svg +1 -1
  32. package/vitepress/assets/icons/icon__totop.svg +5 -5
  33. package/vitepress/assets/icons/icon__vscode.svg +5 -5
  34. package/vitepress/assets/icons/icon__zoom_fit.svg +1 -1
  35. package/vitepress/assets/icons/icon__zoom_in.svg +1 -1
  36. package/vitepress/assets/icons/icon__zoom_out.svg +1 -1
  37. package/vitepress/assets/icons/icon__zoom_reset.svg +1 -1
  38. package/vitepress/assets/icons/index.ts +38 -38
  39. package/vitepress/components/BilibiliOutsidePlayer/BilibiliOutsidePlayer.vue +20 -20
  40. package/vitepress/components/CodeBlockFullscreen/CodeBlockFullscreen.vue +373 -372
  41. package/vitepress/components/CodeBlockFullscreen/index.ts +115 -114
  42. package/vitepress/components/CodeBlockFullscreen/styles.css +64 -64
  43. package/vitepress/components/Discussions/Discussions.module.scss +32 -32
  44. package/vitepress/components/Discussions/Discussions.vue +211 -210
  45. package/vitepress/components/EnWordList/EnWordList.module.scss +124 -124
  46. package/vitepress/components/EnWordList/EnWordList.vue +543 -542
  47. package/vitepress/components/EnWordList/RightClickMenu.module.scss +22 -22
  48. package/vitepress/components/EnWordList/RightClickMenu.vue +66 -66
  49. package/vitepress/components/Footprints/Footprints.module.scss +93 -93
  50. package/vitepress/components/Footprints/Footprints.vue +377 -377
  51. package/vitepress/components/Layout/AboutModal.module.scss +233 -233
  52. package/vitepress/components/Layout/AboutModal.vue +105 -105
  53. package/vitepress/components/Layout/AboutPanel.vue +270 -265
  54. package/vitepress/components/Layout/ContentCollapse.vue +603 -602
  55. package/vitepress/components/Layout/CustomSidebar.vue +608 -605
  56. package/vitepress/components/Layout/DocBeforeControls.vue +149 -139
  57. package/vitepress/components/Layout/DocFooter.vue +233 -232
  58. package/vitepress/components/Layout/ImagePreview.module.scss +201 -201
  59. package/vitepress/components/Layout/ImagePreview.vue +281 -280
  60. package/vitepress/components/Layout/Layout.module.scss +661 -661
  61. package/vitepress/components/Layout/Layout.vue +539 -542
  62. package/vitepress/components/Layout/NoteStatus.vue +140 -139
  63. package/vitepress/components/Layout/SidebarItems.vue +267 -262
  64. package/vitepress/components/Layout/SidebarNavBefore.vue +92 -92
  65. package/vitepress/components/Layout/Swiper.vue +167 -167
  66. package/vitepress/components/Layout/ToggleFullContent.module.scss +11 -11
  67. package/vitepress/components/Layout/ToggleFullContent.vue +35 -34
  68. package/vitepress/components/Layout/ToggleSidebar.module.scss +11 -11
  69. package/vitepress/components/Layout/ToggleSidebar.vue +36 -35
  70. package/vitepress/components/Layout/composables/useCollapseControl.ts +88 -88
  71. package/vitepress/components/Layout/composables/useNoteConfig.ts +119 -121
  72. package/vitepress/components/Layout/composables/useNoteSave.ts +173 -172
  73. package/vitepress/components/Layout/composables/useNoteValidation.ts +85 -85
  74. package/vitepress/components/Layout/composables/useRedirect.ts +113 -110
  75. package/vitepress/components/Layout/composables/useVSCodeIntegration.ts +86 -83
  76. package/vitepress/components/Layout/homeReadme.data.ts +124 -124
  77. package/vitepress/components/LoadingPage/LoadingPage.vue +192 -192
  78. package/vitepress/components/MarkMap/MarkMap.module.scss +159 -159
  79. package/vitepress/components/MarkMap/MarkMap.vue +405 -404
  80. package/vitepress/components/Mermaid/Mermaid.module.scss +275 -275
  81. package/vitepress/components/Mermaid/Mermaid.vue +365 -363
  82. package/vitepress/components/NotesTable/NotesTable.module.scss +77 -77
  83. package/vitepress/components/NotesTable/NotesTable.vue +98 -97
  84. package/vitepress/components/NotesTable/README.md +67 -67
  85. package/vitepress/components/Settings/Settings.module.scss +433 -433
  86. package/vitepress/components/Settings/Settings.vue +306 -305
  87. package/vitepress/components/SidebarCard/MindMapView.vue +484 -483
  88. package/vitepress/components/SidebarCard/NotesTrendChart.vue +108 -108
  89. package/vitepress/components/SidebarCard/SidebarCard.vue +946 -948
  90. package/vitepress/components/Tooltip/Tooltip.vue +70 -70
  91. package/vitepress/components/constants.ts +91 -91
  92. package/vitepress/components/notesConfig.data.ts +73 -73
  93. package/vitepress/components/sidebar.data.ts +59 -59
  94. package/vitepress/components/tnotes-config.data.ts +21 -21
  95. package/vitepress/components/utils.ts +26 -26
  96. package/vitepress/config/index.ts +160 -146
  97. package/vitepress/configs/constants.ts +26 -26
  98. package/vitepress/configs/head.config.ts +25 -24
  99. package/vitepress/configs/index.ts +9 -9
  100. package/vitepress/configs/markdown-it.d.ts +23 -20
  101. package/vitepress/configs/markdown.config.ts +366 -365
  102. package/vitepress/configs/theme.config.ts +108 -108
  103. package/vitepress/plugins/buildProgressPlugin.ts +434 -470
  104. package/vitepress/plugins/getNoteByConfigIdPlugin.ts +107 -106
  105. package/vitepress/plugins/renameNotePlugin.ts +60 -59
  106. package/vitepress/plugins/updateConfigPlugin.ts +63 -62
  107. package/vitepress/theme/index.ts +95 -93
  108. package/vitepress/theme/styles/base.scss +50 -50
  109. package/vitepress/theme/styles/components/404.scss +31 -31
  110. package/vitepress/theme/styles/components/collapse.scss +175 -175
  111. package/vitepress/theme/styles/components/markmap.scss +101 -101
  112. package/vitepress/theme/styles/components/swiper.scss +255 -255
  113. package/vitepress/theme/styles/index.scss +25 -25
  114. package/vitepress/theme/styles/layout.scss +62 -62
  115. package/vitepress/theme/styles/utilities.scss +39 -39
  116. package/vitepress/theme/styles/vitepress-override.scss +25 -25
@@ -4,7 +4,7 @@ import {
4
4
  UpdateNoteConfigCommand,
5
5
  generateAnchor,
6
6
  logger
7
- } from "../../chunk-JDVN2QYW.js";
7
+ } from "../../chunk-JUMVJKWV.js";
8
8
  import "../../chunk-NASIL5FY.js";
9
9
 
10
10
  // vitepress/config/index.ts
@@ -39,10 +39,10 @@ function getHeadConfig(config, githubPageUrl) {
39
39
  }
40
40
 
41
41
  // vitepress/configs/markdown.config.ts
42
+ import fs from "fs";
42
43
  import markdownItContainer from "markdown-it-container";
43
44
  import mila from "markdown-it-link-attributes";
44
45
  import markdownItTaskLists from "markdown-it-task-lists";
45
- import fs from "fs";
46
46
  import path from "path";
47
47
  function esc(s = "") {
48
48
  return s.replace(
@@ -100,7 +100,7 @@ function configureMarkMapContainer(md) {
100
100
  const open = t;
101
101
  const startLine = open.map ? open.map[0] + 1 : null;
102
102
  const endLine = open.map ? open.map[1] - 1 : null;
103
- let params = {};
103
+ const params = {};
104
104
  if (open.map && typeof open.map[0] === "number") {
105
105
  const openLine = (lines[open.map[0]] || "").trim();
106
106
  let paramPart = "";
@@ -150,7 +150,7 @@ function configureMarkMapContainer(md) {
150
150
  const firstNonEmptyLine = (content || "").split("\n").find((ln) => ln.trim() !== "") || "";
151
151
  const refMatch = firstNonEmptyLine.trim().match(/^<<<\s*(.+)$/);
152
152
  if (refMatch) {
153
- let refRaw = refMatch[1].trim().replace(/^['"]|['"]$/g, "");
153
+ const refRaw = refMatch[1].trim().replace(/^['"]|['"]$/g, "");
154
154
  try {
155
155
  const env = state.env || {};
156
156
  const possibleRel = env.relativePath || env.path || env.filePath || env.file || "";
@@ -383,190 +383,12 @@ function getThemeConfig(config) {
383
383
  return themeConfig;
384
384
  }
385
385
 
386
- // vitepress/plugins/updateConfigPlugin.ts
387
- function updateConfigPlugin() {
388
- let updateCommand;
389
- return {
390
- name: "tnotes-update-config",
391
- configureServer(server) {
392
- updateCommand = new UpdateNoteConfigCommand();
393
- server.middlewares.use(async (req, res, next) => {
394
- if (req.url === "/__tnotes_update_config" && req.method === "POST") {
395
- let body = "";
396
- req.on("data", (chunk) => {
397
- body += chunk.toString();
398
- });
399
- req.on("end", async () => {
400
- try {
401
- const data = JSON.parse(body);
402
- const { noteIndex, config } = data;
403
- if (!noteIndex || !config) {
404
- res.statusCode = 400;
405
- res.end("Missing noteIndex or config");
406
- return;
407
- }
408
- await updateCommand.updateConfig({
409
- noteIndex,
410
- config: {
411
- done: config.done,
412
- enableDiscussions: config.enableDiscussions,
413
- description: config.description
414
- }
415
- });
416
- res.statusCode = 200;
417
- res.setHeader("Content-Type", "application/json");
418
- res.end(JSON.stringify({ success: true }));
419
- } catch (error) {
420
- console.error("\u66F4\u65B0\u914D\u7F6E\u5931\u8D25:", error);
421
- res.statusCode = 500;
422
- res.end(error instanceof Error ? error.message : String(error));
423
- }
424
- });
425
- } else {
426
- next();
427
- }
428
- });
429
- }
430
- };
431
- }
432
-
433
- // vitepress/plugins/renameNotePlugin.ts
434
- function renameNotePlugin() {
435
- const renameCommand = new RenameNoteCommand();
436
- return {
437
- name: "tnotes-rename-note",
438
- configureServer(server) {
439
- server.middlewares.use(async (req, res, next) => {
440
- if (req.url === "/__tnotes_rename_note" && req.method === "POST") {
441
- let body = "";
442
- req.on("data", (chunk) => {
443
- body += chunk.toString();
444
- });
445
- req.on("end", async () => {
446
- try {
447
- const { noteIndex, newTitle } = JSON.parse(body);
448
- if (!noteIndex || !newTitle) {
449
- res.statusCode = 400;
450
- res.end("Missing noteIndex or newTitle");
451
- return;
452
- }
453
- const startTime = Date.now();
454
- await renameCommand.renameNote({ noteIndex, newTitle });
455
- const duration = Date.now() - startTime;
456
- res.statusCode = 200;
457
- res.setHeader("Content-Type", "application/json");
458
- res.end(
459
- JSON.stringify({
460
- success: true,
461
- duration,
462
- newTitle,
463
- message: "\u91CD\u547D\u540D\u5B8C\u6210"
464
- })
465
- );
466
- } catch (error) {
467
- res.statusCode = 500;
468
- res.end(error instanceof Error ? error.message : "Rename failed");
469
- }
470
- });
471
- } else {
472
- next();
473
- }
474
- });
475
- }
476
- };
477
- }
478
-
479
- // vitepress/plugins/getNoteByConfigIdPlugin.ts
480
- function getNoteByConfigIdPlugin() {
481
- return {
482
- name: "tnotes-get-note-by-config-id",
483
- configureServer(server) {
484
- server.middlewares.use(async (req, res, next) => {
485
- if (req.url?.startsWith("/__tnotes_get_note?") && req.method === "GET") {
486
- try {
487
- const url = new URL(req.url, `http://${req.headers.host}`);
488
- const configId = url.searchParams.get("configId");
489
- if (!configId) {
490
- res.statusCode = 400;
491
- res.setHeader("Content-Type", "application/json");
492
- res.end(
493
- JSON.stringify({
494
- success: false,
495
- error: "Missing configId parameter"
496
- })
497
- );
498
- return;
499
- }
500
- const noteIndexCache = NoteIndexCache.getInstance();
501
- if (!noteIndexCache.isInitialized()) {
502
- res.statusCode = 503;
503
- res.setHeader("Content-Type", "application/json");
504
- res.end(
505
- JSON.stringify({
506
- success: false,
507
- error: "Service not initialized"
508
- })
509
- );
510
- return;
511
- }
512
- const noteItem = noteIndexCache.getByConfigId(configId);
513
- if (!noteItem) {
514
- res.statusCode = 200;
515
- res.setHeader("Content-Type", "application/json");
516
- res.end(
517
- JSON.stringify({
518
- success: true,
519
- found: false,
520
- data: null
521
- })
522
- );
523
- return;
524
- }
525
- res.statusCode = 200;
526
- res.setHeader("Content-Type", "application/json");
527
- res.end(
528
- JSON.stringify({
529
- success: true,
530
- found: true,
531
- data: {
532
- noteIndex: noteItem.noteIndex,
533
- folderName: noteItem.folderName,
534
- // 构建笔记的完整 URL(包含 README)
535
- url: `/notes/${encodeURIComponent(
536
- noteItem.folderName
537
- )}/README`
538
- }
539
- })
540
- );
541
- logger.debug(
542
- `\u67E5\u8BE2\u7B14\u8BB0: configId=${configId}, noteIndex=${noteItem.noteIndex}`
543
- );
544
- } catch (error) {
545
- logger.error("\u67E5\u8BE2\u7B14\u8BB0\u5931\u8D25:", error);
546
- res.statusCode = 500;
547
- res.setHeader("Content-Type", "application/json");
548
- res.end(
549
- JSON.stringify({
550
- success: false,
551
- error: error instanceof Error ? error.message : String(error)
552
- })
553
- );
554
- }
555
- } else {
556
- next();
557
- }
558
- });
559
- }
560
- };
561
- }
562
-
563
386
  // vitepress/plugins/buildProgressPlugin.ts
564
387
  import {
565
388
  existsSync,
566
389
  readFileSync,
567
390
  writeFileSync,
568
- mkdirSync,
569
- readdirSync
391
+ mkdirSync
570
392
  } from "fs";
571
393
  import { join } from "path";
572
394
  var CACHE_DIR = join(process.cwd(), "node_modules", ".tnotes-progress");
@@ -589,26 +411,6 @@ function setCacheData(data) {
589
411
  } catch {
590
412
  }
591
413
  }
592
- function countSourceFiles(srcDir) {
593
- let count = 0;
594
- const extensions = /\.(vue|ts|js|jsx|tsx|css|scss|sass|styl|less|md)$/i;
595
- const scan = (dir) => {
596
- try {
597
- const entries = readdirSync(dir, { withFileTypes: true });
598
- for (const entry of entries) {
599
- const fullPath = join(dir, entry.name);
600
- if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
601
- scan(fullPath);
602
- } else if (entry.isFile() && extensions.test(entry.name)) {
603
- count++;
604
- }
605
- }
606
- } catch {
607
- }
608
- };
609
- scan(srcDir);
610
- return count;
611
- }
612
414
  var globalStartTime = 0;
613
415
  var globalTransformCount = 0;
614
416
  var globalChunkCount = 0;
@@ -616,7 +418,6 @@ var globalHasError = false;
616
418
  var globalIsBuilding = false;
617
419
  var globalOutDir = "";
618
420
  var globalLastPercent = 0;
619
- var globalFileCount = 0;
620
421
  var globalLastLoggedPercent = -1;
621
422
  var globalLastOutputTime = 0;
622
423
  var globalTransformEndTime = 0;
@@ -708,9 +509,6 @@ function buildProgressPlugin(options = {}) {
708
509
  globalTransformEndTime = 0;
709
510
  globalLastHookTime = Date.now();
710
511
  globalOutDir = config.build?.outDir || "dist";
711
- if (!hasCache) {
712
- globalFileCount = countSourceFiles(process.cwd());
713
- }
714
512
  interceptOutput();
715
513
  globalStallTimer = setInterval(() => {
716
514
  if (!globalIsBuilding || globalLastPercent <= 0 || globalLastPercent >= 0.98)
@@ -841,6 +639,183 @@ function buildProgressPlugin(options = {}) {
841
639
  };
842
640
  }
843
641
 
642
+ // vitepress/plugins/getNoteByConfigIdPlugin.ts
643
+ function getNoteByConfigIdPlugin() {
644
+ return {
645
+ name: "tnotes-get-note-by-config-id",
646
+ configureServer(server) {
647
+ server.middlewares.use(async (req, res, next) => {
648
+ if (req.url?.startsWith("/__tnotes_get_note?") && req.method === "GET") {
649
+ try {
650
+ const url = new URL(req.url, `http://${req.headers.host}`);
651
+ const configId = url.searchParams.get("configId");
652
+ if (!configId) {
653
+ res.statusCode = 400;
654
+ res.setHeader("Content-Type", "application/json");
655
+ res.end(
656
+ JSON.stringify({
657
+ success: false,
658
+ error: "Missing configId parameter"
659
+ })
660
+ );
661
+ return;
662
+ }
663
+ const noteIndexCache = NoteIndexCache.getInstance();
664
+ if (!noteIndexCache.isInitialized()) {
665
+ res.statusCode = 503;
666
+ res.setHeader("Content-Type", "application/json");
667
+ res.end(
668
+ JSON.stringify({
669
+ success: false,
670
+ error: "Service not initialized"
671
+ })
672
+ );
673
+ return;
674
+ }
675
+ const noteItem = noteIndexCache.getByConfigId(configId);
676
+ if (!noteItem) {
677
+ res.statusCode = 200;
678
+ res.setHeader("Content-Type", "application/json");
679
+ res.end(
680
+ JSON.stringify({
681
+ success: true,
682
+ found: false,
683
+ data: null
684
+ })
685
+ );
686
+ return;
687
+ }
688
+ res.statusCode = 200;
689
+ res.setHeader("Content-Type", "application/json");
690
+ res.end(
691
+ JSON.stringify({
692
+ success: true,
693
+ found: true,
694
+ data: {
695
+ noteIndex: noteItem.noteIndex,
696
+ folderName: noteItem.folderName,
697
+ // 构建笔记的完整 URL(包含 README)
698
+ url: `/notes/${encodeURIComponent(
699
+ noteItem.folderName
700
+ )}/README`
701
+ }
702
+ })
703
+ );
704
+ logger.debug(
705
+ `\u67E5\u8BE2\u7B14\u8BB0: configId=${configId}, noteIndex=${noteItem.noteIndex}`
706
+ );
707
+ } catch (error) {
708
+ logger.error("\u67E5\u8BE2\u7B14\u8BB0\u5931\u8D25:", error);
709
+ res.statusCode = 500;
710
+ res.setHeader("Content-Type", "application/json");
711
+ res.end(
712
+ JSON.stringify({
713
+ success: false,
714
+ error: error instanceof Error ? error.message : String(error)
715
+ })
716
+ );
717
+ }
718
+ } else {
719
+ next();
720
+ }
721
+ });
722
+ }
723
+ };
724
+ }
725
+
726
+ // vitepress/plugins/renameNotePlugin.ts
727
+ function renameNotePlugin() {
728
+ const renameCommand = new RenameNoteCommand();
729
+ return {
730
+ name: "tnotes-rename-note",
731
+ configureServer(server) {
732
+ server.middlewares.use(async (req, res, next) => {
733
+ if (req.url === "/__tnotes_rename_note" && req.method === "POST") {
734
+ let body = "";
735
+ req.on("data", (chunk) => {
736
+ body += chunk.toString();
737
+ });
738
+ req.on("end", async () => {
739
+ try {
740
+ const { noteIndex, newTitle } = JSON.parse(body);
741
+ if (!noteIndex || !newTitle) {
742
+ res.statusCode = 400;
743
+ res.end("Missing noteIndex or newTitle");
744
+ return;
745
+ }
746
+ const startTime = Date.now();
747
+ await renameCommand.renameNote({ noteIndex, newTitle });
748
+ const duration = Date.now() - startTime;
749
+ res.statusCode = 200;
750
+ res.setHeader("Content-Type", "application/json");
751
+ res.end(
752
+ JSON.stringify({
753
+ success: true,
754
+ duration,
755
+ newTitle,
756
+ message: "\u91CD\u547D\u540D\u5B8C\u6210"
757
+ })
758
+ );
759
+ } catch (error) {
760
+ res.statusCode = 500;
761
+ res.end(error instanceof Error ? error.message : "Rename failed");
762
+ }
763
+ });
764
+ } else {
765
+ next();
766
+ }
767
+ });
768
+ }
769
+ };
770
+ }
771
+
772
+ // vitepress/plugins/updateConfigPlugin.ts
773
+ function updateConfigPlugin() {
774
+ let updateCommand;
775
+ return {
776
+ name: "tnotes-update-config",
777
+ configureServer(server) {
778
+ updateCommand = new UpdateNoteConfigCommand();
779
+ server.middlewares.use(async (req, res, next) => {
780
+ if (req.url === "/__tnotes_update_config" && req.method === "POST") {
781
+ let body = "";
782
+ req.on("data", (chunk) => {
783
+ body += chunk.toString();
784
+ });
785
+ req.on("end", async () => {
786
+ try {
787
+ const data = JSON.parse(body);
788
+ const { noteIndex, config } = data;
789
+ if (!noteIndex || !config) {
790
+ res.statusCode = 400;
791
+ res.end("Missing noteIndex or config");
792
+ return;
793
+ }
794
+ await updateCommand.updateConfig({
795
+ noteIndex,
796
+ config: {
797
+ done: config.done,
798
+ enableDiscussions: config.enableDiscussions,
799
+ description: config.description
800
+ }
801
+ });
802
+ res.statusCode = 200;
803
+ res.setHeader("Content-Type", "application/json");
804
+ res.end(JSON.stringify({ success: true }));
805
+ } catch (error) {
806
+ console.error("\u66F4\u65B0\u914D\u7F6E\u5931\u8D25:", error);
807
+ res.statusCode = 500;
808
+ res.end(error instanceof Error ? error.message : String(error));
809
+ }
810
+ });
811
+ } else {
812
+ next();
813
+ }
814
+ });
815
+ }
816
+ };
817
+ }
818
+
844
819
  // vitepress/config/index.ts
845
820
  function loadTNotesConfig(rootPath) {
846
821
  const configPath = path2.resolve(rootPath, ".tnotes.json");
@@ -929,9 +904,8 @@ function defineNotesConfig(overrides = {}) {
929
904
  const fullPath = path2.resolve(rootPath, pageData.relativePath);
930
905
  try {
931
906
  const raw = fs2.readFileSync(fullPath, "utf-8");
932
- pageData.frontmatter.rawContent = raw.replace(
933
- /<\/(script)/gi,
934
- "<\\/$1"
907
+ pageData.frontmatter.rawContent = Buffer.from(raw, "utf-8").toString(
908
+ "base64"
935
909
  );
936
910
  } catch {
937
911
  pageData.frontmatter.rawContent = null;
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@tnotesjs/core",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "TNotes 知识库核心框架 —— 基于 VitePress 的笔记管理系统",
5
5
  "type": "module",
6
+ "packageManager": "pnpm@10.17.1",
6
7
  "bin": {
7
8
  "tnotes": "./dist/cli/index.js"
8
9
  },
@@ -29,7 +30,9 @@
29
30
  "build": "tsup",
30
31
  "build:check": "tsc --noEmit -p tsconfig.build.json",
31
32
  "dev": "tsup --watch",
32
- "release": "node scripts/release.mjs"
33
+ "release": "node scripts/release.mjs",
34
+ "lint": "eslint . --max-warnings=0",
35
+ "lint:fix": "eslint . --fix"
33
36
  },
34
37
  "peerDependencies": {
35
38
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
@@ -55,10 +58,19 @@
55
58
  "vue-echarts": "^8.0.1"
56
59
  },
57
60
  "devDependencies": {
61
+ "@eslint/js": "^9.39.4",
58
62
  "@types/markdown-it": "^14.1.2",
59
63
  "@types/node": "^24.6.2",
64
+ "@typescript-eslint/parser": "^8.59.0",
65
+ "eslint": "^9.39.4",
66
+ "eslint-plugin-import": "^2.32.0",
67
+ "eslint-plugin-vue": "^10.9.0",
68
+ "globals": "^17.5.0",
60
69
  "tsup": "^8.5.1",
61
- "typescript": "^5.9.3"
70
+ "typescript": "^5.9.3",
71
+ "typescript-eslint": "^8.59.0",
72
+ "vue-eslint-parser": "^10.4.0",
73
+ "vue-tsc": "^3.2.7"
62
74
  },
63
75
  "engines": {
64
76
  "node": ">=18.0.0"
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'