mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-08-17 03:27:00 +08:00
feat: 语音
This commit is contained in:
@@ -5,10 +5,11 @@ import { dirname, join, resolve } from 'path'
|
||||
import { afterAll, describe, expect, it } from 'vitest'
|
||||
|
||||
const nodeRequire = createRequire(import.meta.url)
|
||||
const { validateFfmpegRuntime, validateSilkWasmRuntime } = nodeRequire(
|
||||
const { validateFfmpegRuntime, validateSherpaRuntime, validateSilkWasmRuntime } = nodeRequire(
|
||||
'../../scripts/after-pack.cjs'
|
||||
) as {
|
||||
validateFfmpegRuntime: (runtimeResources: string, platform?: NodeJS.Platform) => void
|
||||
validateSherpaRuntime: (runtimeResources: string, platform: NodeJS.Platform, arch: string) => void
|
||||
validateSilkWasmRuntime: (runtimeResources: string) => void
|
||||
}
|
||||
const root = mkdtempSync(join(tmpdir(), 'wxe-runtime-package-'))
|
||||
@@ -49,4 +50,31 @@ describe('production runtime packaging', () => {
|
||||
const config = readFileSync(resolve(__dirname, '../../electron-builder.yml'), 'utf8')
|
||||
expect(config).toContain('node_modules/ffmpeg-static/**')
|
||||
})
|
||||
|
||||
it('requires the matching Windows and macOS sherpa native runtime', () => {
|
||||
const resources = join(root, 'sherpa-resources')
|
||||
const unpacked = join(resources, 'app.asar.unpacked', 'node_modules')
|
||||
const base = join(unpacked, 'sherpa-onnx-node')
|
||||
mkdirSync(base, { recursive: true })
|
||||
writeFileSync(join(base, 'package.json'), '{}')
|
||||
writeFileSync(join(base, 'sherpa-onnx.js'), 'module.exports = {}')
|
||||
|
||||
expect(() => validateSherpaRuntime(resources, 'win32', 'x64')).toThrow(/win-x64/)
|
||||
const windows = join(unpacked, 'sherpa-onnx-win-x64')
|
||||
mkdirSync(windows, { recursive: true })
|
||||
writeFileSync(join(windows, 'package.json'), '{}')
|
||||
writeFileSync(join(windows, 'sherpa-onnx.node'), 'fixture')
|
||||
expect(() => validateSherpaRuntime(resources, 'win32', 'x64')).not.toThrow()
|
||||
|
||||
expect(() => validateSherpaRuntime(resources, 'darwin', 'arm64')).toThrow(/darwin-arm64/)
|
||||
const mac = join(unpacked, 'sherpa-onnx-darwin-arm64')
|
||||
mkdirSync(mac, { recursive: true })
|
||||
writeFileSync(join(mac, 'package.json'), '{}')
|
||||
writeFileSync(join(mac, 'sherpa-onnx.node'), 'fixture')
|
||||
expect(() => validateSherpaRuntime(resources, 'darwin', 'arm64')).not.toThrow()
|
||||
|
||||
const config = readFileSync(resolve(__dirname, '../../electron-builder.yml'), 'utf8')
|
||||
expect(config).toContain('node_modules/sherpa-onnx-node/**')
|
||||
expect(config).toContain('node_modules/sherpa-onnx-*/**')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user