Files
openmotion/scripts/bundle/bootstrap.mjs
open-design-crew[bot] 12ea6c7723 fix: preserve template GSAP and stabilize preview and capture (#473)
Preserve exact template-local GSAP dependencies in immutable export snapshots while retaining native history and concurrency guards.

Accept guarded preview transitions only when they match the pinned engine's deterministic ID stamping and disk-write condition, including existing empty IDs. Retain rejection of real edits and same-content restores.

Support legacy and current accelerated canvas APIs. Use the same-version complete Chrome for Testing application on macOS arm64 and derive complete-ZIP browser paths from the pinned runtime lock.

Validated with focused deterministic checks, real macOS runtime and accelerated-frame comparisons, fresh extracted-package smoke coverage, and all ten PR CI checks.
2026-11-16 21:46:41 +08:00

31 lines
2.0 KiB
JavaScript

import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const root = path.dirname(fileURLToPath(import.meta.url));
const metadata = JSON.parse(fs.readFileSync(path.join(root, 'release.json'), 'utf8'));
const windows = process.platform === 'win32';
if (metadata.target !== (windows ? 'win-x64' : 'mac-arm64') || process.arch !== (windows ? 'x64' : 'arm64')) throw new Error('此测试包与当前系统/CPU 不匹配');
if (windows && Number(os.release().split('.')[2]) < 22000) throw new Error('此测试包要求 Windows 11 或以上');
const runtime = JSON.parse(fs.readFileSync(path.join(root, 'scripts/runtime-lock.json'), 'utf8')).targets[metadata.target];
const media = path.join(root, 'runtime/media/bin'), node = path.join(root, windows ? 'runtime/node' : 'runtime/node/bin');
const suffix = windows ? '.exe' : '';
const values = {
HYPERFRAMES_BROWSER_PATH: path.join(root, 'runtime/browser', runtime.browser.executable),
HYPERFRAMES_FFMPEG_PATH: path.join(media, 'ffmpeg' + suffix),
HYPERFRAMES_FFPROBE_PATH: path.join(media, 'ffprobe' + suffix),
};
for (const [key, filename] of Object.entries(values)) {
if (windows && filename.length >= 260) throw new Error('安装路径过长,Windows 无法启动渲染工具。请将完整包放到较短的用户应用目录后重新安装。');
fs.accessSync(filename, fs.constants.X_OK); process.env[key] = filename;
}
process.env.FFMPEG_PATH = values.HYPERFRAMES_FFMPEG_PATH;
process.env.FFPROBE_PATH = values.HYPERFRAMES_FFPROBE_PATH;
const system = windows ? [path.join(process.env.SystemRoot, 'System32'), path.join(process.env.SystemRoot, 'System32/WindowsPowerShell/v1.0')] : [];
process.env.PATH = [node, media, ...system, process.env.PATH || ''].join(path.delimiter);
process.env.HYPERFRAMES_NO_TELEMETRY = '1';
process.env.HYPERFRAMES_NO_UPDATE_CHECK = '1';
process.env.HYPERFRAMES_NO_AUTO_INSTALL = '1';
process.env.MOTION_DATA_DIR ||= path.join(os.homedir(), 'OpenMotion-test-data');