import { parseHTML } from 'linkedom' import { build } from 'esbuild' import { parse, compileScript } from '@vue/compiler-sfc' import { readFile, mkdir } from 'node:fs/promises' import { resolve, relative } from 'node:path' import { execFileSync } from 'node:child_process' import { pathToFileURL } from 'node:url' // A DOM-like test host, not a browser or a media decoder. Install it before importing Vue. const { window } = parseHTML('
') for (const key of ['window', 'document', 'HTMLElement', 'Element', 'Node', 'SVGElement', 'Event', 'CustomEvent', 'MutationObserver']) { Object.defineProperty(globalThis, key, { configurable: true, value: key === 'window' ? window : window[key] }) } Object.defineProperty(globalThis, 'navigator', { configurable: true, value: { userAgent: 'offline-video-test' } }) globalThis.location = new URL('http://fixture.invalid/') window.location = globalThis.location window.requestAnimationFrame = globalThis.requestAnimationFrame = (callback) => setTimeout(callback, 0) window.cancelAnimationFrame = globalThis.cancelAnimationFrame = clearTimeout const videoPrototype = Object.getPrototypeOf(document.createElement('video')) videoPrototype.play = () => Promise.resolve() videoPrototype.pause = () => {} videoPrototype.load = () => {} const baselineOnly = process.argv.includes('--baseline-only') const base = 'f437979141947a68c67cbc6797ae31f7aae1188f' const ownSources = new Set([ 'src/modules/cockpit/components/VideoMonitorEntry.vue', 'src/modules/cockpit/components/VideoMonitorPanel.vue', 'src/modules/cockpit/components/VideoPlayer.vue', 'src/modules/cockpit/services/videoApi.js', 'src/modules/cockpit/services/videoLiveSession.js', 'src/modules/cockpit/services/videoPlayer.js', 'src/modules/cockpit/stores/videoStore.js', 'src/pages/cockpit/index.vue', ]) async function sourceAt(path) { const name = relative(process.cwd(), path).replaceAll('\\', '/') if (!baselineOnly || !name.startsWith('src/') || ownSources.has(name)) return readFile(path, 'utf8') let source = execFileSync('git', ['show', `${base}:${name}`], { encoding: 'utf8' }) if (name === 'src/modules/cockpit/components/EquipmentDetailSections.vue') { const anchor = '