import {build} from 'esbuild'; import assert from 'node:assert/strict'; import {createRequire} from 'node:module'; import {readFile} from 'node:fs/promises'; Object.defineProperty(globalThis,'navigator',{value:{languages:['en-US']},configurable:true}); globalThis.document={documentElement:{lang:''},addEventListener(){}}; globalThis.window={addEventListener(){}}; const bundle=await build({stdin:{contents:`import React from 'react';import {renderToStaticMarkup} from 'react-dom/server';import {SpatialFraming} from './ui/src/cast-spatial-framing';export {loadSpatialFraming} from './ui/src/cast-spatial-framing';export const render=()=>renderToStaticMarkup();`,loader:'tsx',resolveDir:process.cwd()},bundle:true,platform:'node',format:'cjs',loader:{'.css':'empty'},write:false}); const module={exports:{}};new Function('module','exports','require',bundle.outputFiles[0].text)(module,module.exports,createRequire(import.meta.url)); const calls=[]; const geometry={id:'test'}; await module.exports.loadSpatialFraming(async method=>{calls.push(method);return method==='status'?{database:{language:'zh-CN'}}:method==='language.list'?{packs:[]}:geometry;}); assert.deepEqual(calls.sort(),['cast.framing.get','language.list','status']); assert.equal(document.documentElement.lang,'zh-CN'); const chinese=module.exports.render(); for(const text of ['画幅调整','画面比例','录制分辨率','应用取景','重置大小'])assert.ok(chinese.includes(text),text); assert.ok(!chinese.includes('method==='status'?{database:{language:'en-US'}}:method==='language.list'?{packs:[]}:geometry); assert.ok(module.exports.render().includes('Adjust recording frame')); const css=await readFile('ui/src/casting.css','utf8'); assert.match(css,/\.cast-quick-framing-row\{display:flex;align-items:center;justify-content:space-between/); assert.match(css,/\.cast-quick-framing-row \.switch-row\{width:auto;min-width:0/); console.log('PASS: spatial frame loads configured language and uses two in-page dropdowns; quick controls share one row');