mirror of
https://github.com/phit/video2webxr.git
synced 2026-10-23 09:01:23 +02:00
The floating panel took focus from video lightboxes, which then closed or lost their state. The toolbar button now opens a popup with the projection (remembered between uses), Enter VR and Stop; the page gets no controls. Since browsers only start VR from a gesture in the page, Enter VR arms the video and the next click on it enters VR and starts playback. When a video's frames can't be read because its <video> doesn't request CORS, reload it with crossorigin="anonymous" at the same position, and restore it if the server doesn't allow that (fixes Wikimedia Commons). Failed VR starts are reported in the popup. The popup replaces the background service worker. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
// Builds the extension into dist/, ready to load unpacked or zip for release.
|
|
// node scripts/build.mjs production build (minified)
|
|
// node scripts/build.mjs --watch unminified with inline source maps, rebuilt on change
|
|
|
|
import fs from 'node:fs';
|
|
import * as esbuild from 'esbuild';
|
|
|
|
const watch = process.argv.includes('--watch');
|
|
const outdir = 'dist';
|
|
|
|
// Files the extension loads as-is
|
|
const STATIC_FILES = [
|
|
'manifest.json',
|
|
'LICENSE',
|
|
'src/popup.html',
|
|
'src/popup.css',
|
|
'icons/icon16.png',
|
|
'icons/icon32.png',
|
|
'icons/icon48.png',
|
|
'icons/icon128.png',
|
|
'icons/tabler-icons.LICENSE',
|
|
];
|
|
|
|
fs.rmSync(outdir, { recursive: true, force: true });
|
|
for (const file of STATIC_FILES) {
|
|
const target = `${outdir}/${file.replace(/^src\//, '')}`;
|
|
fs.mkdirSync(target.slice(0, target.lastIndexOf('/')) || outdir, { recursive: true });
|
|
fs.copyFileSync(file, target);
|
|
}
|
|
|
|
const context = await esbuild.context({
|
|
entryPoints: { script: 'src/youtube.js', generic: 'src/generic.js', popup: 'src/popup.js' },
|
|
outdir,
|
|
bundle: true,
|
|
format: 'iife',
|
|
target: 'chrome120',
|
|
loader: { '.svg': 'text' },
|
|
minify: !watch,
|
|
sourcemap: watch ? 'inline' : false,
|
|
legalComments: 'eof', // keeps three.js' license header in the bundles
|
|
logLevel: 'info',
|
|
});
|
|
|
|
if (watch) {
|
|
await context.watch();
|
|
} else {
|
|
await context.rebuild();
|
|
await context.dispose();
|
|
}
|