fumadocs-core 14.4.2 → 14.5.1

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.
@@ -20,11 +20,15 @@ import {
20
20
  // src/mdx-plugins/rehype-code.ts
21
21
  import rehypeShikiFromHighlighter from "@shikijs/rehype/core";
22
22
 
23
- // ../../node_modules/.pnpm/shiki-transformers@1.0.0_shiki@1.22.2/node_modules/shiki-transformers/dist/index.js
23
+ // ../../node_modules/.pnpm/shiki-transformers@1.0.1_shiki@1.23.0/node_modules/shiki-transformers/dist/index.js
24
24
  var matchers = [
25
- [/^(<!--)(.+)(-->)$/, true],
26
- [/^(\/\*)(.+)(\*\/)$/, true],
27
- [/^(\/\/|["']|;{1,2}|%{1,2}|--|#)(.+)$/, false]
25
+ [/^(<!--)(.+)(-->)$/, false],
26
+ [/^(\/\*)(.+)(\*\/)$/, false],
27
+ [/^(\/\/|["']|;{1,2}|%{1,2}|--|#)(.+)$/, true],
28
+ /**
29
+ * for multi-line comments like this
30
+ */
31
+ [/^(\*)(.+)$/, true]
28
32
  ];
29
33
  function parseComments(lines, jsx) {
30
34
  const out = [];
@@ -45,14 +49,14 @@ function parseComments(lines, jsx) {
45
49
  info: match,
46
50
  line,
47
51
  token,
48
- jsxIntercept: isValue(left, "{") && isValue(right, "}")
52
+ isJsxStyle: isValue(left, "{") && isValue(right, "}")
49
53
  });
50
54
  } else {
51
55
  out.push({
52
56
  info: match,
53
57
  line,
54
58
  token,
55
- jsxIntercept: false
59
+ isJsxStyle: false
56
60
  });
57
61
  }
58
62
  }
@@ -66,12 +70,12 @@ function isValue(element, value) {
66
70
  return false;
67
71
  return text.value.trim() === value;
68
72
  }
69
- function matchToken(token, last) {
73
+ function matchToken(token, isLast) {
70
74
  const text = token.children[0];
71
75
  if (text.type !== "text")
72
76
  return;
73
- for (const [matcher, lastOnly] of matchers) {
74
- if (!lastOnly && !last) continue;
77
+ for (const [matcher, endOfLine] of matchers) {
78
+ if (endOfLine && !isLast) continue;
75
79
  let trimmed = text.value.trimStart();
76
80
  const spaceFront = text.value.length - trimmed.length;
77
81
  trimmed = trimmed.trimEnd();
@@ -93,10 +97,11 @@ function createCommentNotationTransformer(name, regex, onMatch) {
93
97
  const linesToRemove = [];
94
98
  code.data ??= {};
95
99
  const data = code.data;
96
- const parsed = data._shiki_notation ??= parseComments(lines, ["jsx", "tsx"].includes(this.options.lang));
100
+ data._shiki_notation ??= parseComments(lines, ["jsx", "tsx"].includes(this.options.lang));
101
+ const parsed = data._shiki_notation;
97
102
  for (const comment of parsed) {
98
103
  if (comment.info[1].length === 0) continue;
99
- const isLineCommentOnly = comment.line.children.length === (comment.jsxIntercept ? 3 : 1);
104
+ const isLineCommentOnly = comment.line.children.length === (comment.isJsxStyle ? 3 : 1);
100
105
  let lineIdx = lines.indexOf(comment.line);
101
106
  if (isLineCommentOnly) lineIdx++;
102
107
  comment.info[1] = comment.info[1].replace(regex, (...match) => {
@@ -109,7 +114,7 @@ function createCommentNotationTransformer(name, regex, onMatch) {
109
114
  if (isEmpty) comment.info[1] = "";
110
115
  if (isEmpty && isLineCommentOnly) {
111
116
  linesToRemove.push(comment.line);
112
- } else if (isEmpty && comment.jsxIntercept) {
117
+ } else if (isEmpty && comment.isJsxStyle) {
113
118
  comment.line.children.splice(comment.line.children.indexOf(comment.token) - 1, 3);
114
119
  } else if (isEmpty) {
115
120
  comment.line.children.splice(comment.line.children.indexOf(comment.token), 1);
@@ -138,9 +143,9 @@ function transformerNotationMap(options = {}, name = "@shikijs/transformers:nota
138
143
  new RegExp(`\\s*\\[!code (${Object.keys(classMap).map(escapeRegExp).join("|")})(:\\d+)?\\]`),
139
144
  function([_, match, range = ":1"], _line, _comment, lines, index) {
140
145
  const lineNum = Number.parseInt(range.slice(1), 10);
141
- lines.slice(index, index + lineNum).forEach((line) => {
142
- this.addClassToHast(line, classMap[match]);
143
- });
146
+ for (let i = index; i < Math.min(index + lineNum, lines.length); i++) {
147
+ this.addClassToHast(lines[i], classMap[match]);
148
+ }
144
149
  if (classActivePre)
145
150
  this.addClassToHast(this.pre, classActivePre);
146
151
  return true;
@@ -257,7 +262,9 @@ function transformerNotationWordHighlight(options = {}) {
257
262
  function([_, word, range], _line, comment, lines, index) {
258
263
  const lineNum = range ? Number.parseInt(range.slice(1), 10) : lines.length;
259
264
  word = word.replace(/\\(.)/g, "$1");
260
- lines.slice(index, index + lineNum).forEach((line) => highlightWordInLine.call(this, line, comment, word, classActiveWord));
265
+ for (let i = index; i < Math.min(index + lineNum, lines.length); i++) {
266
+ highlightWordInLine.call(this, lines[i], comment, word, classActiveWord);
267
+ }
261
268
  if (classActivePre)
262
269
  this.addClassToHast(this.pre, classActivePre);
263
270
  return true;
@@ -1,4 +1,4 @@
1
- import { TypedDocument, Orama, Language, SearchParams, SorterConfig, Tokenizer, DefaultTokenizerConfig, OramaPlugin } from '@orama/orama';
1
+ import { TypedDocument, Orama, Language, SorterConfig, Tokenizer, DefaultTokenizerConfig, OramaPlugin, SearchParams } from '@orama/orama';
2
2
  import { NextRequest } from 'next/server';
3
3
  import { S as StructuredData } from '../remark-structure-mP51W1AN.js';
4
4
  import { S as SortedResult } from '../types-Ch8gnVgO.js';
package/dist/sidebar.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ReactNode, ElementType, ReactElement, ComponentPropsWithoutRef } from 'react';
1
+ import { ReactNode, ElementType, ComponentPropsWithoutRef, ReactElement } from 'react';
2
2
 
3
3
  interface SidebarProviderProps {
4
4
  open?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "14.4.2",
3
+ "version": "14.5.1",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -75,7 +75,7 @@
75
75
  "dependencies": {
76
76
  "@formatjs/intl-localematcher": "^0.5.7",
77
77
  "@orama/orama": "^3.0.1",
78
- "@shikijs/rehype": "^1.22.2",
78
+ "@shikijs/rehype": "^1.23.0",
79
79
  "github-slugger": "^2.0.0",
80
80
  "hast-util-to-estree": "^3.1.0",
81
81
  "hast-util-to-jsx-runtime": "^2.3.2",
@@ -85,7 +85,7 @@
85
85
  "remark": "^15.0.0",
86
86
  "remark-gfm": "^4.0.0",
87
87
  "scroll-into-view-if-needed": "^3.1.0",
88
- "shiki": "^1.22.2",
88
+ "shiki": "^1.23.0",
89
89
  "unist-util-visit": "^5.0.0"
90
90
  },
91
91
  "devDependencies": {
@@ -105,7 +105,7 @@
105
105
  "next": "^15.0.3",
106
106
  "remark-mdx": "^3.1.0",
107
107
  "remark-rehype": "^11.1.1",
108
- "shiki-transformers": "^1.0.0",
108
+ "shiki-transformers": "^1.0.1",
109
109
  "unified": "^11.0.5",
110
110
  "eslint-config-custom": "0.0.0",
111
111
  "tsconfig": "0.0.0"