Files
Recordly/scripts/build-native-helpers.mjs
webadderall 5d040fbf2c refactor: split large files into focused modules
Split all source files exceeding 500 lines into smaller, focused modules:

- electron/main.ts → mainBootstrapHelpers, mainRuntimeState, mainUpdateIntegration, mainWindowControls
- electron/windows.ts → editorWindows, hudWindows, windowShared
- electron/updater.ts → updaterDialogs, updaterEventHandlers, updaterShared
- electron/preload.ts → preloadExtensionsBridge, preloadUpdateBridge
- electron/ipc/register/recording.ts → recording/ directory with focused handlers
- src/components/video-editor/VideoEditor.tsx → EditorContent, EditorHeader, EditorSidebar, EditorToolbar, hooks/
- src/components/video-editor/SettingsPanel.tsx → settings/ directory with per-section components
- src/components/video-editor/AnnotationSettingsPanel.tsx → tab components
- src/components/video-editor/ExtensionManager.tsx → extension-manager/ directory
- src/components/video-editor/VideoPlayback.tsx → videoPlaybackComponent/ directory
- src/components/video-editor/projectPersistence.ts → projectPersistence{Normalization,Paths,Regions,Shared}.ts
- src/components/video-editor/timeline/TimelineEditor.tsx → TimelineEditor/ directory
- src/components/video-editor/types.ts → focused type modules
- src/components/launch/LaunchWindow.tsx → LaunchWindow/ directory
- src/hooks/useScreenRecorder.ts → useScreenRecorder/ directory
- src/lib/exporter/audioEncoder.ts → audioEncoder/ directory
- src/lib/exporter/frameRenderer.ts → frameRenderer modules
- src/lib/exporter/modernFrameRenderer.ts → filters and lifecycle modules
- src/lib/exporter/modernVideoExporter.ts → modernVideoExporter/ directory
- src/lib/exporter/videoExporter.ts → video-exporter/ directory
- src/lib/exporter/streamingDecoder.ts → streamingDecoderHelpers.ts
- src/lib/extensions/extensionHost.ts → extensionHost{ApiFactory,QueryApi,RegistrationApi,Shared,State}.ts
- src/lib/extensions/types.ts → focused type modules
- electron/native/ScreenCaptureKitRecorder.swift → ScreenCaptureKitRecorder/ directory
- scripts/benchmark-export-queues.mjs → benchmark-export-queues/ directory
- .github/workflows/release.yml → extracted merge-macos-metadata composite action
- scripts/build-native-helpers.mjs → updated for multi-file Swift compilation

Also incorporates upstream default export quality change (good → source).
2026-04-20 20:41:42 +10:00

84 lines
2.3 KiB
JavaScript

import { spawnSync } from "node:child_process";
import { chmod, mkdir } from "node:fs/promises";
import path from "node:path";
const projectRoot = process.cwd();
const nativeRoot = path.join(projectRoot, "electron", "native");
if (process.platform !== "darwin") {
console.log("[build-native-helpers] Skipping: host platform is not macOS.");
process.exit(0);
}
function getTargetConfigs() {
return [
{
archTag: "darwin-arm64",
swiftTarget: "arm64-apple-macos14.0",
},
{
archTag: "darwin-x64",
swiftTarget: "x86_64-apple-macos14.0",
},
];
}
const helpers = [
{
sources: [
"ScreenCaptureKitRecorder.swift",
"ScreenCaptureKitRecorder/ScreenCaptureRecorder.swift",
"ScreenCaptureKitRecorder/ScreenCaptureRecorder+Stream.swift",
"ScreenCaptureKitRecorder/RecorderService.swift",
],
output: "recordly-screencapturekit-helper",
},
{
sources: ["ScreenCaptureKitWindowList.swift"],
output: "recordly-window-list",
},
{
sources: ["SystemCursorAssets.swift"],
output: "recordly-system-cursors",
},
{
sources: ["NativeCursorMonitor.swift"],
output: "recordly-native-cursor-monitor",
},
];
const swiftcCheck = spawnSync("swiftc", ["--version"], { encoding: "utf8" });
if (swiftcCheck.status !== 0) {
const details = [swiftcCheck.stderr, swiftcCheck.stdout].filter(Boolean).join("\n").trim();
throw new Error(details || "swiftc is unavailable; install Xcode Command Line Tools.");
}
for (const target of getTargetConfigs()) {
const outputDir = path.join(nativeRoot, "bin", target.archTag);
await mkdir(outputDir, { recursive: true });
for (const helper of helpers) {
const sourcePaths = helper.sources.map((source) => path.join(nativeRoot, source));
const outputPath = path.join(outputDir, helper.output);
const result = spawnSync(
"swiftc",
["-O", "-target", target.swiftTarget, ...sourcePaths, "-o", outputPath],
{
encoding: "utf8",
timeout: 120000,
},
);
if (result.status !== 0) {
const details = [result.stderr, result.stdout].filter(Boolean).join("\n").trim();
throw new Error(details || `Failed to compile ${helper.sources[0]} for ${target.archTag}`);
}
await chmod(outputPath, 0o755);
console.log(
`[build-native-helpers] Built ${helper.output} (${target.archTag}) -> ${outputPath}`,
);
}
}