Skip to content

Commit be7fc30

Browse files
meta: bump @node-core dependencies to 1.3.0 (#477)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: avivkeller <me@aviv.sh>
1 parent b799808 commit be7fc30

File tree

7 files changed

+263
-317
lines changed

7 files changed

+263
-317
lines changed

package-lock.json

Lines changed: 230 additions & 282 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"@clack/prompts": "^0.11.0",
4343
"@heroicons/react": "^2.2.0",
4444
"@minify-html/node": "^0.16.4",
45-
"@node-core/rehype-shiki": "1.1.0",
46-
"@node-core/ui-components": "1.2.0",
45+
"@node-core/rehype-shiki": "1.3.0",
46+
"@node-core/ui-components": "1.3.0",
4747
"@orama/orama": "^3.1.14",
4848
"@orama/react-components": "^0.8.1",
4949
"@rollup/plugin-virtual": "^3.0.2",

src/generators/jsx-ast/utils/buildSignature.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { highlightToHast } from '@node-core/rehype-shiki';
21
import { h as createElement } from 'hastscript';
32

3+
import { highlighter } from '../../../utils/highlighter.mjs';
44
import createQueries from '../../../utils/queries/index.mjs';
55
import { parseListItem } from '../../legacy-json/utils/parseList.mjs';
66
import parseSignature from '../../legacy-json/utils/parseSignature.mjs';
@@ -50,7 +50,7 @@ export const generateSignature = (
5050
*/
5151
export const createSignatureCodeBlock = (functionName, signature, prefix) => {
5252
const sig = generateSignature(functionName, signature, prefix);
53-
const highlighted = highlightToHast(sig, 'typescript');
53+
const highlighted = highlighter.highlightToHast(sig, 'typescript');
5454

5555
return createElement('div', { class: 'signature' }, [highlighted]);
5656
};

src/generators/web/constants.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ export const JSX_IMPORTS = {
3535
name: 'CodeTabs',
3636
source: '@node-core/ui-components/MDX/CodeTabs',
3737
},
38+
MDXTooltip: {
39+
name: 'MDXTooltip',
40+
isDefaultExport: false,
41+
source: '@node-core/ui-components/MDX/Tooltip',
42+
},
43+
MDXTooltipContent: {
44+
name: 'MDXTooltipContent',
45+
isDefaultExport: false,
46+
source: '@node-core/ui-components/MDX/Tooltip',
47+
},
48+
MDXTooltipTrigger: {
49+
name: 'MDXTooltipTrigger',
50+
isDefaultExport: false,
51+
source: '@node-core/ui-components/MDX/Tooltip',
52+
},
3853
ChangeHistory: {
3954
name: 'ChangeHistory',
4055
source: '@node-core/ui-components/Common/ChangeHistory',

src/generators/web/utils/data.mjs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { shiki } from '@node-core/rehype-shiki';
1+
import { LANGS } from '@node-core/rehype-shiki';
22

33
/**
44
* Constructs a set of static, minimal data to send from server to client.
@@ -14,32 +14,11 @@ export const createStaticData = () => {
1414
// Create a display name map with aliases from Shiki's loaded languages
1515
const shikiDisplayNameMap = [
1616
...new Map(
17-
// 1. Get all currently loaded language identifiers (e.g., 'js', 'ts', 'python')
18-
shiki
19-
.getLoadedLanguages()
20-
21-
// 2. Map each ID to its full language object
22-
.map(shiki.getLanguage)
23-
24-
// 3. Extract:
25-
// - `name`: canonical ID (e.g., "javascript")
26-
// - `_grammar.aliases`: alternate names for the language (e.g., ["js"])
27-
// - `displayName`: user-friendly name for UI (e.g., "JavaScript")
28-
//
29-
// 4. Build key-value pairs of:
30-
// name => [[aliases + name], displayName]
31-
//
32-
// Example output:
33-
// "javascript" => [["js", "javascript"], "JavaScript"]
34-
//
35-
// This structure allows clients to match by any alias and still show a clean label.
36-
.map(({ name, _grammar: { aliases = [], displayName } }) => [
37-
name,
38-
[[...aliases, name], displayName],
39-
])
40-
41-
// Step 5: Deduplicate by canonical name using a `Map`
42-
// The `Map` constructor ensures uniqueness by key (`name`)
17+
// Get all languages, and map aliases to display names
18+
LANGS.map(({ name, aliases = [], displayName }) => [
19+
name,
20+
[[...aliases, name], displayName],
21+
])
4322
).values(), // Get just the values (alias/displayName pairs)
4423
];
4524

src/utils/highlighter.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
import { shiki } from '@node-core/rehype-shiki';
3+
import createHighlighter from '@node-core/rehype-shiki';
44
import { toString } from 'hast-util-to-string';
55
import { h as createElement } from 'hastscript';
66
import { SKIP, visit } from 'unist-util-visit';
@@ -32,6 +32,8 @@ function isCodeBlock(node) {
3232
);
3333
}
3434

35+
export const highlighter = await createHighlighter();
36+
3537
/**
3638
* Creates a HAST transformer for Shiki which is used for transforming our codeboxes
3739
*
@@ -87,7 +89,7 @@ export default function rehypeShikiji() {
8789
const languageId = codeLanguage.slice(languagePrefix.length);
8890

8991
// Parses the <pre> contents and returns a HAST tree with the highlighted code
90-
const { children } = shiki.codeToHast(preElementContents, {
92+
const { children } = highlighter.shiki.codeToHast(preElementContents, {
9193
lang: languageId,
9294
// Allows support for dual themes (light, dark) for Shiki
9395
themes: { light: shikiConfig.themes[0], dark: shikiConfig.themes[1] },

src/utils/remark.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import remarkRehype from 'remark-rehype';
1212
import remarkStringify from 'remark-stringify';
1313
import { unified } from 'unified';
1414

15-
import syntaxHighlighter from './highlighter.mjs';
15+
import syntaxHighlighter, { highlighter } from './highlighter.mjs';
1616
import { AST_NODE_TYPES } from '../generators/jsx-ast/constants.mjs';
1717
import transformElements from '../generators/jsx-ast/utils/transformer.mjs';
1818

@@ -45,6 +45,8 @@ export const getRemarkRehype = () =>
4545
// and we trust the sources of the Markdown files
4646
.use(rehypeStringify, { allowDangerousHtml: true });
4747

48+
const singletonShiki = await rehypeShikiji({ highlighter });
49+
4850
/**
4951
* Retrieves an instance of Remark configured to output JSX code.
5052
* including parsing Code Boxes with syntax highlighting
@@ -62,7 +64,7 @@ export const getRemarkRecma = () =>
6264
})
6365
// Any `raw` HTML in the markdown must be converted to AST in order for Recma to understand it
6466
.use(rehypeRaw, { passThrough })
65-
.use(rehypeShikiji)
67+
.use(() => singletonShiki)
6668
.use(transformElements)
6769
.use(rehypeRecma)
6870
.use(recmaJsx)

0 commit comments

Comments
 (0)