mirror of
https://github.com/SteamFramelyHomebrew/framely.git
synced 2026-10-17 21:01:29 +02:00
Constrain frames to capture-eye visibility, restore menu sizing and add reset. Fix centered resize and trigger release handling, and prevent large native poll responses from losing framing commands.
25 lines
2.1 KiB
JavaScript
25 lines
2.1 KiB
JavaScript
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(<SpatialFraming/>);`,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('<select'));
|
|
assert.equal((chinese.match(/aria-haspopup="listbox"/g)||[]).length,2);
|
|
await module.exports.loadSpatialFraming(async method=>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');
|