Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ jobs:
ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
- run: npm run check
- run: npm test
# The editor in the runner's Chrome (playwright-core drives the installed browser, nothing to download).
- run: npm run test:ui
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ User content (video names, captions, file names, the video itself) is never tran
### Checking your change

`npm test` runs the unit tests (`test/*.test.mjs`, Node's built-in runner, no extra dependencies) and
`npm run check` syntax-checks every script. Both run automatically on every pull request. Before opening a PR,
`npm run check` syntax-checks every script. `npm run test:ui` drives the editor in your installed Chrome or Edge
(`test/ui/`, through playwright-core; without either browser the tests are skipped). All three run automatically on
every pull request. Before opening a PR,
please:

- Run `npm run check` and `npm test`, and add a test when you change `src/` (look at the existing ones, they're short).
Changed how the timeline or undo behaves? Run `npm run test:ui` too, and add a case there.
- Open the editor (`npm run serve` or `npm start`) and try what you changed, plus undo/redo.
- If you touched `src/template.mjs`, render a short video (the Render button) and look at the MP4, not only the
preview.
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ On first start, create a project folder (*New project…*), drop a screen record
| --- | --- |
| `npm start` | Run the app from source (Electron) |
| `npm test` / `npm run check` | Run the tests / syntax-check every script (both run in CI on every pull request) |
| `npm run test:ui` | Editor tests in your installed Chrome or Edge (dragging, trimming, splitting, undo, saving) |
| `npm run serve` | Run the editor in your normal browser at http://localhost:3400, which is handy for development |
| `npm run pack` | Build `dist/Motion Studio-win32-x64/Motion Studio.exe` |
| `npm run sign` | Sign that `.exe` (see [signing](#signing-on-windows)) |
Expand All @@ -90,6 +91,8 @@ On first start, create a project folder (*New project…*), drop a screen record
<kbd>Space</kbd> play · <kbd>S</kbd> split · <kbd>T</kbd> tap mode · <kbd>M</kbd> marker ·
<kbd>[</kbd> <kbd>]</kbd> previous/next marker or beat · <kbd>Ctrl</kbd>+<kbd>C</kbd>/<kbd>V</kbd> copy/paste
(also between videos) · <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>V</kbd> paste at the same time ·
<kbd>,</kbd> <kbd>.</kbd> nudge the selection a frame · <kbd>Alt</kbd> while dragging: no snapping ·
<kbd>Shift</kbd>+<kbd>Del</kbd> ripple delete a clip · <kbd>\</kbd> fit the timeline ·
<kbd>Ctrl</kbd>+<kbd>R</kbd> render · <kbd>Alt</kbd> menu bar. The full list is under *Help → Keyboard shortcuts*.

## 🤝 Where you can help
Expand All @@ -106,7 +109,8 @@ Everything below is open for grabs. Comment on (or open) an issue so others know
**Bigger features**
- 🍎 **macOS and Linux builds**: the code is cross-platform, but packaging and testing aren't there yet
- 🎙️ **Exact word timing** for captions with Whisper (`hyperframes transcribe`) instead of estimates
- 🧪 **Editor tests**: the modules are covered (`npm test`); the editor UI and rendering aren't yet
- 🧪 **More tests**: the modules (`npm test`) and the timeline basics (`npm run test:ui`) are covered; rendering and
most of the inspector aren't yet
- 🎞️ **Transitions between clips**: crossfades, slides and whip pans on the device screen
- 🖼️ **Templates**: save a video as a reusable starting point for the next one

Expand Down
20 changes: 17 additions & 3 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ A video is a JSON **spec**. The editor edits the spec, the server saves it, and
small seekable player. The render feeds the same page to [HyperFrames](https://hyperframes.heygen.com), so the
preview and the MP4 always match.

GSAP comes from the `gsap` npm package, not a CDN: the preview gets it at `/preview/<id>/gsap.min.js` and every
render project gets a copy next to its `index.html`, so neither needs the network (the editor's icon font still
comes from Google Fonts).

`npm run serve` runs the same server without Electron, and you can use the editor in a normal browser at
http://localhost:3400. That's the quickest way to develop the UI.

Expand All @@ -42,9 +46,18 @@ http://localhost:3400. That's the quickest way to develop the UI.
- `scripts/`: Windows code signing, and `check.mjs` (a syntax check of every script).
- `test/`: unit tests for the pure modules (`npm test`, Node's built-in test runner).

Every change in the editor goes through `commit(fn)`. That function takes an undo snapshot, re-renders and saves.
Position-only edits made directly in the preview (taps, callouts, captions) use `commit(fn, { quiet: true })`,
which saves without rebuilding the preview.
Every change in the editor goes through `commit(fn)`. That function takes an undo snapshot (the spec, the
selection and the playhead), re-renders and saves 350 ms later. Position-only edits made directly in the preview
(taps, callouts, captions) use `commit(fn, { quiet: true })`, which saves without rebuilding the preview. Text
fields pass `live` to `field()`: the text is patched into the preview that is on screen (`liveEdit`), and the
preview is rebuilt once typing stops. Undo history is kept per video while the editor is open.

A pending save is not lost when the page goes away: a reload or a closed browser tab sends it with
`navigator.sendBeacon` (a POST to the same route), and the Electron window calls `window.__flushSave()` before it
closes (`main.mjs`).

While dragging on the timeline only the blocks move (`layoutTimeline`); the timeline is rebuilt when the drag ends,
or when the rows change shape.

## Projects (workspaces)

Expand All @@ -58,6 +71,7 @@ Every project is a folder. Motion Studio can switch between them (Bestand → Pr
| `assets/clips/` | screen recordings (converted to H.264 on upload) and screenshots (png/jpg); deleted files go to `.trash/` |
| `assets/vo/` | audio (voice and music); generated voice-overs land here; deleted files go to `.trash/` |
| `renders/` | finished MP4s (`<renderPrefix>-<id>[-4x5\|-1x1\|-16x9].mp4`), plus a `.srt` when the video has captions |
| `.cache/thumbs/` | timeline filmstrips: one JPEG row of frames per clip version (`/api/thumbs/<clip>`), safe to delete |

To build without the app, run `node src/cli.mjs build <workspace> [id,id…]`, then `npx hyperframes render` in
`<workspace>/projects`.
Expand Down
8 changes: 8 additions & 0 deletions main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ async function createWindow() {
webPreferences: { preload: join(here, 'preload.cjs'), contextIsolation: true, nodeIntegration: false, sandbox: true }
});
win.once('ready-to-show', () => { win.maximize(); win.show(); });
// Closing: let the editor write its last change first (it saves 350 ms after an edit), then close for real.
let flushed = false;
win.on('close', e => {
if (flushed || smoke) return;
e.preventDefault(); flushed = true;
const flush = win.webContents.executeJavaScript('window.__flushSave?.()', true).catch(() => {});
Promise.race([flush, new Promise(r => setTimeout(r, 3000))]).finally(() => win.destroy());
});
// Links (e.g. to fonts.google.com) open in the normal browser.
win.webContents.setWindowOpenHandler(({ url: target }) => { shell.openExternal(target); return { action: 'deny' }; });
await win.loadURL(url);
Expand Down
29 changes: 28 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@
"start": "electron .",
"serve": "node src/server.mjs",
"build": "node src/cli.mjs build",
"pack": "electron-packager . \"Motion Studio\" --platform=win32 --arch=x64 --out=dist --overwrite --icon=resources/icon.ico --ignore=^/dist --ignore=^/scripts --ignore=^/docs --ignore=^/test --ignore=^/.git --ignore=^/.claude --no-asar",
"pack": "node scripts/pack.mjs",
"sign": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/sign.ps1",
"sign:cert": "powershell -NoProfile -ExecutionPolicy Bypass -File scripts/make-selfsigned-cert.ps1",
"dist": "npm run pack && npm run sign",
"test": "node --test \"test/*.test.mjs\"",
"test:ui": "node --test \"test/ui/*.test.mjs\"",
"check": "node scripts/check.mjs"
},
"devDependencies": {
"@electron/packager": "^20.3.0",
"electron": "^44.4.5"
"electron": "^44.4.5",
"playwright-core": "^1.63.0"
},
"dependencies": {
"gsap": "3.14.2"
}
}
18 changes: 18 additions & 0 deletions scripts/pack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Packages the Windows app into dist/Motion Studio-win32-x64 (npm run pack).
// The options live here instead of on the command line: npm runs scripts through cmd.exe on Windows, which eats the
// `^` of `--ignore=^/dist`, and an unanchored /dist also threw away node_modules/gsap/dist.
import { packager } from '@electron/packager';

const [out] = await packager({
dir: '.',
name: 'Motion Studio',
platform: 'win32',
arch: 'x64',
out: 'dist',
overwrite: true,
icon: 'resources/icon.ico',
asar: false,
// Paths are relative to the project, starting with /.
ignore: [/^\/dist(\/|$)/, /^\/scripts(\/|$)/, /^\/docs(\/|$)/, /^\/test(\/|$)/, /^\/\.git/, /^\/\.claude(\/|$)/]
});
console.log(`Wrote ${out}`);
Loading
Loading