Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"name": "Node.js Website Team and Contributors"
},
"scripts": {
"compile": "turbo compile",
"build": "turbo build",
"cloudflare:deploy": "turbo cloudflare:deploy",
"cloudflare:preview": "turbo cloudflare:preview",
Expand Down
18 changes: 17 additions & 1 deletion packages/rehype-shiki/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
export { default } from '../../eslint.config.js';
import baseConfig from '../../eslint.config.js';

export default baseConfig.concat([
{
files: ['src'],
ignores: ['**/*.test.*', '**/*.stories.tsx'],
languageOptions: {
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/consistent-type-imports': 'error',
},
},
]);
29 changes: 25 additions & 4 deletions packages/rehype-shiki/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
{
"name": "@node-core/rehype-shiki",
"version": "1.4.0",
"version": "1.4.1",
"type": "module",
"types": "./dist/index.d.mts",
"exports": {
".": "./src/index.mjs",
"./index.css": "./src/index.css",
"./*": "./src/*.mjs"
".": {
"types": "./dist/index.d.mts",
"default": "./src/index.mjs"
},
"./*": {
"types": "./dist/*.d.mts",
"default": "./src/*.mjs"
},
"./index.css": "./src/index.css"
},
"repository": {
"type": "git",
"url": "https://github.com/nodejs/nodejs.org",
"directory": "packages/rehype-shiki"
},
"scripts": {
"compile:ts": "tsc",
"compile": "node --run compile:ts",
"release": "node --run compile",
"lint": "node --run lint:js",
"lint:fix": "node --run lint:js:fix",
"lint:js": "eslint \"**/*.mjs\"",
"lint:js:fix": "node --run lint:js -- --fix",
"lint:types": "tsc --noEmit",
"test": "node --run test:unit",
"test:unit": "cross-env NODE_NO_WARNINGS=1 node --experimental-test-coverage --experimental-test-module-mocks --test \"**/*.test.mjs\""
},
Expand All @@ -28,9 +39,19 @@
"classnames": "catalog:",
"hast-util-to-string": "^3.0.1",
"shiki": "~3.22.0",
"typescript": "catalog:",
"unist-util-visit": "^5.1.0"
},
"devDependencies": {
"cross-env": "catalog:"
},
"imports": {
"#rs/*": [
"./src/*",
"./src/*.mjs"
]
},
"engines": {
"node": ">=20"
}
}
8 changes: 7 additions & 1 deletion packages/rehype-shiki/src/highlighter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const DEFAULT_THEME = {
...shikiNordTheme,
};

/**
* @template {{ name: string; aliases?: string[] }} T
* @param {string} language
* @param {ReadonlyArray<T>} langs
* @returns {T | undefined}
*/
export const getLanguageByName = (language, langs) => {
const normalized = language.toLowerCase();

Expand All @@ -20,7 +26,7 @@ export const getLanguageByName = (language, langs) => {

/**
* @typedef {Object} SyntaxHighlighter
* @property {import('@shikijs/core').HighlighterCoreSync} shiki - The underlying shiki core instance.
* @property {import('@shikijs/core').HighlighterCore} shiki - The underlying shiki core instance.
* @property {(code: string, lang: string, meta?: Record<string, any>) => string} highlightToHtml - Highlights code and returns inner HTML of the <code> tag.
* @property {(code: string, lang: string, meta?: Record<string, any>) => any} highlightToHast - Highlights code and returns a HAST tree.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/rehype-shiki/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import shellSessionLanguage from 'shiki/langs/shellsession.mjs';
import typeScriptLanguage from 'shiki/langs/typescript.mjs';
import yamlLanguage from 'shiki/langs/yaml.mjs';

import createHighlighter, { getLanguageByName } from './highlighter.mjs';
import createHighlighter, { getLanguageByName } from '#rs/highlighter.mjs';

/**
* @typedef {Object} HighlighterOptions
Expand Down Expand Up @@ -48,7 +48,7 @@ async function getTransformers({ twoslash = false, twoslashOptions }) {
const transformers = [];

if (twoslash) {
const { twoslash } = await import('./transformers/twoslash/index.mjs');
const { twoslash } = await import('#rs/transformers/twoslash/index.mjs');
transformers.push(twoslash(twoslashOptions));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rehype-shiki/src/minimal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createJavaScriptRegexEngine } from '@shikijs/engine-javascript';
import powershellLanguage from 'shiki/langs/powershell.mjs';
import shellScriptLanguage from 'shiki/langs/shellscript.mjs';

import createHighlighter, { getLanguageByName } from './highlighter.mjs';
import createHighlighter, { getLanguageByName } from '#rs/highlighter.mjs';

export const LANGS = [...powershellLanguage, ...shellScriptLanguage];

Expand Down
4 changes: 2 additions & 2 deletions packages/rehype-shiki/src/plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import { toString } from 'hast-util-to-string';
import { SKIP, visit } from 'unist-util-visit';

import createHighlighter from './index.mjs';
import createHighlighter from '#rs/index.mjs';

// This is what Remark will use as prefix within a <pre> className
// to attribute the current language of the <pre> element
Expand Down Expand Up @@ -54,7 +54,7 @@ function isCodeBlock(node) {
}

/**
* @param {import('./index.mjs').HighlighterOptions & { highlighter: import('./highlighter.mjs').SyntaxHighlighter }} options
* @param {import('#rs/index.mjs').HighlighterOptions & { highlighter: import('#rs/highlighter.mjs').SyntaxHighlighter }} options
*/
export default async function rehypeShikiji(options) {
const highlighter =
Expand Down
22 changes: 22 additions & 0 deletions packages/rehype-shiki/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"jsx": "react-jsx",
"declaration": true,
"emitDeclarationOnly": true,
"baseUrl": "./src",
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src"],
"exclude": ["**/*.test.*", "**/*.stories.tsx"]
}
3 changes: 3 additions & 0 deletions packages/rehype-shiki/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"lint:fix": {
"cache": false
},
"lint:types": {
"cache": false
},
"test:unit": {
"inputs": ["src/**/*.mjs"]
}
Expand Down
59 changes: 29 additions & 30 deletions packages/ui-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,48 @@
},
"dependencies": {
"@heroicons/react": "^2.2.0",
"@orama/core": "^1.2.16",
"@orama/ui": "^1.5.4",
"@radix-ui/react-avatar": "^1.1.11",
"@radix-ui/react-dialog": "^1.1.15",
"@radix-ui/react-dropdown-menu": "~2.1.16",
"@radix-ui/react-label": "~2.1.8",
"@radix-ui/react-select": "~2.2.6",
"@radix-ui/react-separator": "~1.1.8",
"@radix-ui/react-tabs": "~1.1.13",
"@radix-ui/react-tooltip": "~1.2.8",
"@radix-ui/react-dropdown-menu": "^2.1.16",
"@radix-ui/react-label": "^2.1.8",
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-separator": "^1.1.8",
"@radix-ui/react-tabs": "^1.1.13",
"@radix-ui/react-tooltip": "^1.2.8",
"@tailwindcss/postcss": "~4.1.18",
"@types/react": "catalog:",
"@vcarl/remark-headings": "~0.1.0",
"classnames": "catalog:",
"postcss-calc": "^10.1.1",
"tailwindcss": "catalog:"
"postcss-cli": "11.0.1",
"postcss-calc": "10.1.1",
"react": "catalog:",
"tailwindcss": "catalog:",
"typescript": "catalog:"
},
"devDependencies": {
"@orama/core": "^1.2.16",
"@storybook/addon-styling-webpack": "^3.0.0",
"@storybook/addon-themes": "^10.2.6",
"@storybook/addon-webpack5-compiler-swc": "^4.0.2",
"@storybook/react-webpack5": "^10.2.6",
"@storybook/addon-styling-webpack": "~3.0.0",
"@storybook/addon-themes": "~10.2.6",
"@storybook/addon-webpack5-compiler-swc": "~4.0.2",
"@storybook/react-webpack5": "~10.2.6",
"@testing-library/user-event": "~14.6.1",
"@types/node": "catalog:",
"@types/react": "catalog:",
"cross-env": "catalog:",
"concurrently": "^8.2.2",
"css-loader": "~7.1.2",
"eslint-plugin-react": "~7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-storybook": "~10.0.2",
"global-jsdom": "^27.0.0",
"postcss-cli": "^11.0.1",
"postcss-loader": "~8.2.0",
"react": "catalog:",
"storybook": "^10.2.6",
"style-loader": "~4.0.0",
"stylelint": "^17.1.1",
"stylelint-config-standard": "^40.0.0",
"concurrently": "8.2.2",
"css-loader": "7.1.2",
"eslint-plugin-react": "7.37.5",
"eslint-plugin-react-hooks": "7.0.1",
"eslint-plugin-storybook": "10.0.7",
"global-jsdom": "27.0.0",
"postcss-loader": "8.2.0",
"storybook": "~10.2.6",
"style-loader": "4.0.0",
"stylelint": "17.1.1",
"stylelint-config-standard": "40.0.0",
"stylelint-order": "7.0.1",
"stylelint-selector-bem-pattern": "4.0.1",
"tailwindcss": "catalog:",
"tsx": "^4.21.0",
"typescript": "catalog:"
"tsx": "4.21.0"
},
"imports": {
"#ui/*": {
Expand Down
1 change: 0 additions & 1 deletion packages/ui-components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"isolatedModules": true,
"jsx": "react-jsx",
"declaration": true,
"incremental": true,
"baseUrl": "./src",
"rootDir": "./src",
"outDir": "./dist"
Expand Down
Loading
Loading