feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as a monorepo subdirectory under desktop/. Source only — node_modules, dist, Cargo target and the upstream .git history are excluded. desktop/ keeps its own independent Cargo workspace (desktop/src-tauri with crates/*); it is not part of the backend boosapi crate, so a `cargo check` at the metapi root still compiles only the backend. Build the desktop app from desktop/src-tauri per desktop/README.md. Note: app icons are still placeholder assets pending the final BoosAPI logo. The updater signing keys live outside the repo and are not included.
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { buildMermaidCDNWorkerSource, createMermaidWorkerFromCDN } from '../../src/workers/mermaidCdnWorker'
|
||||
|
||||
describe('mermaid CDN worker factory', () => {
|
||||
it('builds classic worker source with importScripts', () => {
|
||||
const src = buildMermaidCDNWorkerSource({
|
||||
mermaidUrl: 'https://cdn.example.com/mermaid.min.js',
|
||||
mode: 'classic',
|
||||
})
|
||||
expect(src).toContain('importScripts(')
|
||||
expect(src).toContain('mermaid.min.js')
|
||||
})
|
||||
|
||||
it('builds module worker source with dynamic import(url)', () => {
|
||||
const src = buildMermaidCDNWorkerSource({
|
||||
mermaidUrl: 'https://cdn.example.com/mermaid.esm.min.mjs',
|
||||
mode: 'module',
|
||||
workerOptions: { type: 'module' },
|
||||
})
|
||||
expect(src).toContain('await import(')
|
||||
expect(src).toContain('mermaid.esm.min.mjs')
|
||||
})
|
||||
|
||||
it('is SSR-safe and returns null worker when Worker is unavailable', () => {
|
||||
const prev = (globalThis as any).Worker
|
||||
try {
|
||||
;(globalThis as any).Worker = undefined
|
||||
const handle = createMermaidWorkerFromCDN({
|
||||
mermaidUrl: 'https://cdn.example.com/mermaid.esm.min.mjs',
|
||||
mode: 'module',
|
||||
})
|
||||
expect(handle.worker).toBeNull()
|
||||
expect(typeof handle.dispose).toBe('function')
|
||||
}
|
||||
finally {
|
||||
;(globalThis as any).Worker = prev
|
||||
}
|
||||
})
|
||||
|
||||
it('creates a Worker instance when Worker exists (stubbed in tests)', () => {
|
||||
const handle = createMermaidWorkerFromCDN({
|
||||
mermaidUrl: 'https://cdn.example.com/mermaid.esm.min.mjs',
|
||||
mode: 'module',
|
||||
debug: true,
|
||||
})
|
||||
expect(handle.worker).toBeTruthy()
|
||||
expect(typeof handle.dispose).toBe('function')
|
||||
})
|
||||
|
||||
it('defaults module workerOptions.type to "module"', () => {
|
||||
const prev = (globalThis as any).Worker
|
||||
const calls: any[] = []
|
||||
class CaptureWorker {
|
||||
onmessage: ((event: MessageEvent) => void) | null = null
|
||||
onerror: ((event: ErrorEvent) => void) | null = null
|
||||
constructor(_url: string, opts?: WorkerOptions) {
|
||||
calls.push({ opts })
|
||||
}
|
||||
|
||||
addEventListener() {}
|
||||
removeEventListener() {}
|
||||
postMessage() {}
|
||||
terminate() {}
|
||||
}
|
||||
try {
|
||||
;(globalThis as any).Worker = CaptureWorker as any
|
||||
const handle = createMermaidWorkerFromCDN({
|
||||
mermaidUrl: 'https://cdn.example.com/mermaid.esm.min.mjs',
|
||||
mode: 'module',
|
||||
})
|
||||
expect(handle.worker).toBeTruthy()
|
||||
expect(calls[0]?.opts?.type).toBe('module')
|
||||
}
|
||||
finally {
|
||||
;(globalThis as any).Worker = prev
|
||||
}
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user