Skip to content

Commit

Permalink
feat: update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed May 14, 2024
1 parent a5dbe29 commit 67b155b
Show file tree
Hide file tree
Showing 18 changed files with 358 additions and 243 deletions.
6 changes: 3 additions & 3 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default withMermaid(defineConfig({
{
name: 'shiki:inline-decorations',
preprocess(code, options) {
const reg = /^\/\/ @decorations:(.*?)\n/
const reg = /^\/\/ @decorations:(.*)\n/
code = code.replace(reg, (match, decorations) => {
options.decorations ||= []
options.decorations.push(...JSON.parse(decorations))
Expand All @@ -117,13 +117,13 @@ export default withMermaid(defineConfig({
processHoverInfo(info) {
return defaultHoverInfoProcessor(info)
// Remove shiki_core namespace
.replace(/_shikijs_core[\w_]*\./g, '')
.replace(/_shikijs_core\w*\./g, '')
},
}),
{
name: 'shiki:remove-escape',
postprocess(code) {
return code.replace(/\[\\\!code/g, '[!code')
return code.replace(/\[\\!code/g, '[!code')
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion docs/.vitepress/store/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const usePlayground = defineStore('playground', () => {
if ((o[0] || !input.value) && n[0] !== o[0]) {
const sample = await fetchSample(lang.value)
if (sample)
input.value = sample.trim().replace(/\n.*?from.*?$/i, '').trim()
input.value = sample.trim().replace(/\n.*?from.*$/i, '').trim()
}
run()
}, { immediate: true })
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "module",
"version": "1.5.1",
"private": true,
"packageManager": "pnpm@9.1.0",
"packageManager": "pnpm@9.1.1",
"scripts": {
"lint": "eslint . --cache",
"release": "bumpp && pnpm -r publish",
Expand All @@ -14,7 +14,7 @@
"prepare": "simple-git-hooks"
},
"devDependencies": {
"@antfu/eslint-config": "^2.17.0",
"@antfu/eslint-config": "^2.18.0",
"@antfu/ni": "^0.21.12",
"@antfu/utils": "^0.7.8",
"@rollup/plugin-alias": "^5.1.0",
Expand All @@ -30,7 +30,7 @@
"@shikijs/vitepress-twoslash": "workspace:*",
"@types/fs-extra": "^11.0.4",
"@types/hast": "^3.0.4",
"@types/node": "^20.12.11",
"@types/node": "^20.12.12",
"@vitest/coverage-v8": "^1.6.0",
"ansi-sequence-parser": "^1.1.1",
"bumpp": "^9.4.1",
Expand All @@ -46,9 +46,9 @@
"mdast-util-gfm": "^3.0.0",
"mdast-util-to-hast": "^13.1.0",
"ofetch": "^1.3.4",
"pnpm": "^9.1.0",
"pnpm": "^9.1.1",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rimraf": "^5.0.7",
"rollup": "^4.17.2",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-dts": "^6.1.0",
Expand All @@ -63,8 +63,8 @@
"vite-tsconfig-paths": "^4.3.2",
"vitepress-plugin-mermaid": "^2.0.16",
"vitest": "^1.6.0",
"vue-tsc": "^2.0.16",
"wrangler": "^3.53.1"
"vue-tsc": "^2.0.17",
"wrangler": "^3.55.0"
},
"resolutions": {
"@shikijs/compat": "workspace:*",
Expand All @@ -75,7 +75,7 @@
"@shikijs/twoslash": "workspace:*",
"@shikijs/vitepress-twoslash": "workspace:*",
"@types/hast": "^3.0.4",
"@types/mdast": "^4.0.3",
"@types/mdast": "^4.0.4",
"@types/unist": "^3.0.2",
"shiki": "workspace:*",
"unified": "^11.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default defineConfig([
dir: 'dist',
format: 'esm',
chunkFileNames: 'chunk-[name].d.mts',
entryFileNames: f => `${f.name.replace(/src[\\\/]/, '')}.d.mts`,
entryFileNames: f => `${f.name.replace(/src[\\/]/, '')}.d.mts`,
},
plugins: [
dts({
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/code-to-hast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ function splitWhitespaceTokens(tokens: ThemedToken[][]) {
return line.flatMap((token) => {
if (token.content.match(/^\s+$/))
return token
// eslint-disable-next-line regexp/no-super-linear-backtracking
const match = token.content.match(/^(\s*)(.*?)(\s*)$/)
if (!match)
return token
Expand Down
2 changes: 1 addition & 1 deletion packages/rehype/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ it('run', async () => {
parseMetaString: (str) => {
return Object.fromEntries(str.split(' ').reduce((prev: [string, boolean | string][], curr: string) => {
const [key, value] = curr.split('=')
const isNormalKey = /^[A-Za-z0-9]+$/.test(key)
const isNormalKey = /^[A-Z0-9]+$/i.test(key)
if (isNormalKey)
prev = [...prev, [key, value || true]]
return prev
Expand Down
4 changes: 2 additions & 2 deletions packages/shiki/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
"@shikijs/core": "workspace:*"
},
"devDependencies": {
"tm-grammars": "^1.11.0",
"tm-themes": "^1.4.1",
"tm-grammars": "^1.11.3",
"tm-themes": "^1.4.3",
"vscode-oniguruma": "^1.7.0"
}
}
8 changes: 4 additions & 4 deletions packages/shiki/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ export default defineConfig([
dir: 'dist',
format: 'esm',
entryFileNames: (f) => {
if (f.facadeModuleId?.match(/[\\\/]langs[\\\/]/))
if (f.facadeModuleId?.match(/[\\/]langs[\\/]/))
return `langs/${f.name}.mjs`
return '[name].mjs'
},
chunkFileNames: (f) => {
if (f.moduleIds.some(i => i.match(/[\\\/]langs[\\\/]/)))
if (f.moduleIds.some(i => i.match(/[\\/]langs[\\/]/)))
return `langs/${f.name}.mjs`
else if (f.moduleIds.some(i => i.match(/[\\\/]themes[\\\/]/)))
else if (f.moduleIds.some(i => i.match(/[\\/]themes[\\/]/)))
return 'themes/[name].mjs'
return 'chunks/[name].mjs'
},
Expand All @@ -75,7 +75,7 @@ export default defineConfig([
dir: 'dist',
format: 'esm',
chunkFileNames: 'types/[name].d.mts',
entryFileNames: f => `${f.name.replace(/src[\\\/]/, '')}.d.mts`,
entryFileNames: f => `${f.name.replace(/src[\\/]/, '')}.d.mts`,
},
plugins: [
dts({
Expand Down
8 changes: 4 additions & 4 deletions packages/shiki/scripts/prepare/langs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ export async function prepareLangs() {
await fs.writeFile(
`./src/assets/langs/${lang.name}.js`,
`${COMMENT_HEAD}
${deps.map(i => `import ${i.replace(/[^\w]/g, '_')} from './${i}'`).join('\n')}
${deps.map(i => `import ${i.replace(/\W/g, '_')} from './${i}'`).join('\n')}
const lang = Object.freeze(${JSON.stringify(json)})
export default [
${[
...deps.map(i => ` ...${i.replace(/[^\w]/g, '_')}`),
...deps.map(i => ` ...${i.replace(/\W/g, '_')}`),
' lang',
].join(',\n') || ''}
]
`.replace(/\n\n+/g, '\n\n'),
`.replace(/\n{2,}/g, '\n\n'),
'utf-8',
)

Expand Down Expand Up @@ -165,5 +165,5 @@ export const bundledLanguages = {
}

function isInvalidFilename(filename: string) {
return !filename.match(/^[a-zA-Z0-9_-]+$/)
return !filename.match(/^[\w-]+$/)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function parseMetaHighlightWords(meta: string): string[] {
return []

// https://regex101.com/r/BHS5fd/1
const match = Array.from(meta.matchAll(/\/((?:\\.|[^\/])+?)\//ig))
const match = Array.from(meta.matchAll(/\/((?:\\.|[^/])+)\//g))

return match
// Escape backslashes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { ShikiTransformer } from 'shiki'
export function parseMetaHighlightString(meta: string) {
if (!meta)
return null
const match = meta.match(/{([\d,-]+)}/)
const match = meta.match(/\{([\d,-]+)\}/)
if (!match)
return null
const lines = match[1].split(',')
Expand Down
4 changes: 2 additions & 2 deletions packages/twoslash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"twoslash": "^0.2.6"
},
"devDependencies": {
"@iconify-json/carbon": "^1.1.32",
"@iconify-json/codicon": "^1.1.47",
"@iconify-json/carbon": "^1.1.33",
"@iconify-json/codicon": "^1.1.48",
"@shikijs/twoslash": "^3.1.2",
"hast-util-from-html": "^2.0.1",
"typescript": "^5.4.5"
Expand Down
8 changes: 4 additions & 4 deletions packages/twoslash/src/renderer-rich.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,20 +633,20 @@ export function rendererRich(options: RendererRichOptions = {}): TwoslashRendere
}
}

const regexType = /^[A-Z][a-zA-Z0-9_]*(\<[^\>]*\>)?:/
const regexFunction = /^[a-zA-Z0-9_]*\(/
const regexType = /^[A-Z]\w*(<[^>]*>)?:/
const regexFunction = /^\w*\(/

/**
* The default hover info processor, which will do some basic cleanup
*/
export function defaultHoverInfoProcessor(type: string) {
let content = type
// remove leading `(property)` or `(method)` on each line
.replace(/^\(([\w-]+?)\)\s+/mg, '')
.replace(/^\(([\w-]+)\)\s+/gm, '')
// remove import statement
.replace(/\nimport .*$/, '')
// remove interface or namespace lines with only the name
.replace(/^(interface|namespace) \w+$/mg, '')
.replace(/^(interface|namespace) \w+$/gm, '')
.trim()

// Add `type` or `function` keyword if needed
Expand Down
2 changes: 1 addition & 1 deletion packages/twoslash/test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('fixtures', () => {
const ext = file.split('.').pop()!

let theme = 'vitesse-dark'
code = code.replace(/\/\/\s+@theme:\s+(.*)\n/, (_, t) => {
code = code.replace(/\/\/\s+@theme:\s+(\S*)\n/, (_, t) => {
theme = t
return ''
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vitepress-twoslash/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function transformerTwoslash(options: VitePressPluginTwoslashOptions = {}
},
postprocess(html) {
if (this.meta.twoslash)
return html.replace(/{/g, '&#123;')
return html.replace(/\{/g, '&#123;')
},
}
}
2 changes: 1 addition & 1 deletion packages/vitepress-twoslash/src/renderer-floating-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function vPre<T extends ElementContent>(el: T): T {

function renderMarkdown(this: ShikiTransformerContextCommon, md: string): ElementContent[] {
const mdast = fromMarkdown(
md.replace(/{@link ([^}]*)}/g, '$1'), // replace jsdoc links
md.replace(/\{@link ([^}]*)\}/g, '$1'), // replace jsdoc links
{ mdastExtensions: [gfmFromMarkdown()] },
)

Expand Down
2 changes: 1 addition & 1 deletion packages/vitepress-twoslash/test/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('fixtures', () => {
const ext = file.split('.').pop()!

let theme = 'vitesse-dark'
code = code.replace(/\/\/\s+@theme:\s+(.*)\n/, (_, t) => {
code = code.replace(/\/\/\s+@theme:\s+(\S*)\n/, (_, t) => {
theme = t
return ''
})
Expand Down
Loading

0 comments on commit 67b155b

Please sign in to comment.