fix(site): [SITE-05] repair search interactions and align peer dependency

This commit is contained in:
Harvey Zhao committed 2026-09-16 09:36:39 +08:00
1 parent 61fe8deb59
commit 6b580d1667
90 files changed
+859 -365

No files matched your search

+19
View File
@@ -1,13 +1,32 @@
import assert from 'node:assert/strict'
import fs from 'node:fs'
// eslint-disable-next-line test/no-import-node-test -- Verify the installed VitePress renderer, not a substitute implementation.
import test from 'node:test'
import { compileScript, compileTemplate, parse } from '@vue/compiler-sfc'
import { parseHTML } from 'linkedom'
import { createMarkdownRenderer } from 'vitepress'
import { stableCodeGroups } from '../packages/artplayer-vitepress/build/markdown.ts'
import { patchSearchComponent } from '../packages/artplayer-vitepress/build/search.ts'
const group
= '::: code-group\n\n```js [One]\nconsole.log(1)\n```\n\n```js [Two]\nconsole.log(2)\n```\n\n:::\n'
test('pinned search adapter compiles against the installed Vue component and rejects source drift', () => {
const source = fs.readFileSync(new URL(import.meta.resolve('vitepress-plugin-search/Search.vue')), 'utf8')
const patched = patchSearchComponent(source)
const { descriptor, errors } = parse(patched)
assert.deepEqual(errors, [])
const script = compileScript(descriptor, { id: 'search-adapter' })
const template = compileTemplate({
source: descriptor.template.content,
filename: 'Search.vue',
id: 'search-adapter',
compilerOptions: { bindingMetadata: script.bindings },
})
assert.deepEqual(template.errors, [])
assert.throws(() => patchSearchComponent(`${source}\n`), /Review the search interaction adapter/)
})
test('installed VitePress random code-group IDs become stable, distinct and label-associated', async () => {
const original = await createMarkdownRenderer(process.cwd())
const before = original.render(group, { relativePath: 'start/i18n.md' })