hypeframe 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +49 -33
  2. package/dist/index.js +306 -155
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  </p>
12
12
 
13
13
  ```bash
14
- npx hypeframe
14
+ curl -fsSL https://hype-frame.com/install | bash
15
15
  ```
16
16
 
17
17
  > **Preview.** HypeFrame Web is opening in stages. The protocol and commands may still change before 1.0.
@@ -52,44 +52,48 @@ npx hypeframe
52
52
 
53
53
  ## Install
54
54
 
55
- | | |
56
- |---|---|
57
- | Node.js | 20.3 or newer ([download](https://nodejs.org)) |
58
- | System | Windows 10/11, macOS, Linux (x64 or arm64) |
59
- | Android | Through Termux (`pkg install nodejs`). Rendering needs Chromium; the HypeFrame app (APK) is the easier route. |
60
- | iPhone / iPad | Cannot run the engine. Use HypeFrame Web with "In this browser" rendering. |
61
- | Chrome | Uses the installed Chrome or Edge. Without one, Chrome for Testing is downloaded once (about 150 MB). |
62
- | RAM | 8 GB or more for 1080p video. 4 GB is enough for small videos. |
63
-
64
- Run it once without installing:
55
+ **macOS and Linux**
65
56
 
66
57
  ```bash
67
- npx hypeframe
58
+ curl -fsSL https://hype-frame.com/install | bash
68
59
  ```
69
60
 
70
- Or install it so `hypeframe` is always there (needed for **Start automatically**):
71
-
72
- ```bash
73
- npm i -g hypeframe
74
- ```
61
+ **Windows** (PowerShell)
75
62
 
76
63
  ```powershell
77
- # Windows, with a check for Node.js first
78
- irm https://raw.githubusercontent.com/sairidev/hypeframe/main/install.ps1 | iex
64
+ irm https://hype-frame.com/install.ps1 | iex
79
65
  ```
80
66
 
67
+ The installer downloads a single `hypeframe` program from
68
+ [GitHub Releases](https://github.com/sairidev/hypeframe/releases), checks it against `SHA256SUMS`, puts it in
69
+ `~/.hypeframe/bin` and adds that folder to your `PATH`. **No Node.js needed.** Open a new terminal afterwards and type
70
+ `hypeframe`. To pick a version: `HYPEFRAME_VERSION=0.3.0` (bash: `curl … | HYPEFRAME_VERSION=0.3.0 bash`). To update
71
+ later: `hypeframe update`.
72
+
73
+ **With Node.js** (20.3 or newer), the npm package works the same:
74
+
81
75
  ```bash
82
- # macOS / Linux, with a check for Node.js first
83
- curl -fsSL https://raw.githubusercontent.com/sairidev/hypeframe/main/install | bash
76
+ npx hypeframe # run once, nothing installed
77
+ npm i -g hypeframe # keep it installed
84
78
  ```
85
79
 
80
+ | | |
81
+ |---|---|
82
+ | System | Windows 10/11 (x64; ARM64 through emulation), macOS (Apple Silicon or Intel), Linux x64 or arm64 (glibc or musl/Alpine) |
83
+ | Android | Through Termux with Node.js (`pkg install nodejs`, then `npx hypeframe`); the installer switches to npm there. Rendering needs Chromium; the HypeFrame app (APK) is the easier route. |
84
+ | iPhone / iPad | Cannot run the engine. Use HypeFrame Web with "In this browser" rendering. |
85
+ | Chrome | Uses the installed Chrome or Edge. Without one, Chrome for Testing is downloaded once (about 150 MB). |
86
+ | ffmpeg | Comes with the npm package. The standalone program downloads the same build once (about 28 MB) and checks its sha256. |
87
+ | RAM | 8 GB or more for 1080p video. 4 GB is enough for small videos. |
88
+ | Disk | About 120 MB for the program, plus Chrome and ffmpeg when they are downloaded. |
89
+
86
90
  ## Quick start
87
91
 
88
92
  1. Open [HypeFrame Web](https://hype-frame.com) and sign in with Google.
89
- 2. On the machine that will do the work, open a terminal and run `hypeframe` (or `npx hypeframe`).
93
+ 2. On the machine that will do the work, [install](#install) hypeframe, open a new terminal and run `hypeframe`.
90
94
 
91
95
  ```
92
- ◆ hypeframe v0.2.0
96
+ ◆ hypeframe v0.3.0
93
97
  local engine for HypeFrame Web
94
98
 
95
99
  Account ▲ not connected
@@ -97,7 +101,7 @@ curl -fsSL https://raw.githubusercontent.com/sairidev/hypeframe/main/install | b
97
101
  Device LAPTOP-RAFI (windows)
98
102
  Render Chrome · GPU off
99
103
  24 hours -
100
- Version 0.2.0 · Node 22.15.0
104
+ Version 0.3.0 · Bun 1.4.4 (standalone)
101
105
 
102
106
  ◆ What would you like to do?
103
107
  │ ● Start the engine (connects your account first)
@@ -156,7 +160,7 @@ engine directly. Every menu item is also a command:
156
160
  | `hypeframe config` | Device name, GPU, language; interactive in a terminal |
157
161
  | `hypeframe clean` | Remove the downloaded Chrome, cached render pages, old logs and failed renders. Finished videos stay |
158
162
  | `hypeframe report` | Write a problem report (versions, settings, recent log) with tokens masked |
159
- | `hypeframe update` | `npm i -g hypeframe@latest` |
163
+ | `hypeframe update` | Update to the latest version (runs the installer again, or `npm i -g hypeframe@latest` for an npm install) |
160
164
 
161
165
  | Option | Meaning |
162
166
  |---|---|
@@ -227,17 +231,21 @@ Found a vulnerability? See [SECURITY.md](SECURITY.md).
227
231
 
228
232
  ```
229
233
  ~/.hypeframe/
234
+ ├── bin/hypeframe the standalone program (curl installer)
230
235
  ├── akun.json device token (owner-readable only)
231
236
  ├── settings.json name, GPU, language, addresses
232
237
  ├── mesin.kunci one engine per folder
233
238
  ├── log/hypeframe.log plain-text log, tokens masked (rotated at 1 MB)
234
239
  ├── cache/
235
240
  │ ├── chrome/ Chrome for Testing (when downloaded)
241
+ │ ├── ffmpeg/ ffmpeg for the standalone program (checked download)
236
242
  │ └── halaman/<ver>/ render page from HypeFrame Web (last 2 versions)
237
243
  └── kerja/render/ render jobs and results (removed automatically)
238
244
  ```
239
245
 
240
- To remove everything: press **Disconnect** on the web, then delete `~/.hypeframe`.
246
+ To remove everything: press **Disconnect** on the web, run `hypeframe autostart off`, delete `~/.hypeframe` and remove
247
+ the `# hypeframe` line the installer added to your shell profile (Windows: the `.hypeframe\bin` entry in the user
248
+ `PATH`). An npm install goes with `npm rm -g hypeframe`.
241
249
 
242
250
  ## Troubleshooting
243
251
 
@@ -245,7 +253,8 @@ Start with `hypeframe doctor`: it checks everything the engine needs and says wh
245
253
 
246
254
  | Symptom | Cause and fix |
247
255
  |---|---|
248
- | `npx` not found | Node.js is missing or too old. Install Node.js 20.3+ |
256
+ | `hypeframe` not found right after installing | Open a new terminal so it picks up the new `PATH` |
257
+ | `npx` not found | Node.js is missing or too old. Use the curl/PowerShell installer instead, or install Node.js 20.3+ |
249
258
  | "Gateway unreachable. Retrying..." | Internet or server trouble. The engine keeps retrying |
250
259
  | "The code expired" | Codes last 10 minutes. Run `hypeframe` again |
251
260
  | "This account already has 5 devices" | Disconnect one under **My devices** |
@@ -262,7 +271,8 @@ Still stuck? Run `hypeframe report` and send the file to the HypeFrame team.
262
271
  ## Development
263
272
 
264
273
  This repository is a small monorepo in the style of [OpenCode](https://opencode.ai): TypeScript, Bun for
265
- tooling, and a package that runs on plain Node.js.
274
+ tooling, an npm package that runs on plain Node.js, and standalone binaries (Bun runtime with the code built in) for
275
+ the curl installer.
266
276
 
267
277
  ```
268
278
  packages/
@@ -272,15 +282,16 @@ packages/
272
282
  │ │ ├── index.ts arguments → command or menu
273
283
  │ │ ├── cli/ menu.ts, args.ts, commands/*.ts
274
284
  │ │ ├── engine/ pairing.ts, connection.ts, handler.ts
275
- │ │ ├── render/ service.ts, job.ts, chrome.ts, page.ts
285
+ │ │ ├── render/ service.ts, job.ts, chrome.ts, page.ts, ffmpeg.ts
276
286
  │ │ ├── config/ paths, account, lock, settings, version
277
287
  │ │ ├── ui/ theme (colors), log, banner, locale (id/en)
278
- │ │ └── util/ open, format
288
+ │ │ └── util/ open, format, runtime
279
289
  │ └── test/ node:test suites (run through tsx)
280
290
  └── protocol/ message shapes, close codes, ticket format, error texts shared with the web
281
- script/build.ts Bun.build → packages/hypeframe/dist/index.js
291
+ script/build.ts npm bundle, or --compile <targets> for standalone binaries + archives
282
292
  script/release.ts typecheck, test, build, npm publish (dry run unless --publish)
283
- install, install.ps1 installers
293
+ install, install.ps1 the installers served at hype-frame.com/install and /install.ps1
294
+ .github/workflows/ ci.yml (every push), release.yml (tag v*: binaries, GitHub Release, installer test)
284
295
  ```
285
296
 
286
297
  ```bash
@@ -290,8 +301,12 @@ npm run typecheck
290
301
  npm test # unit tests + the render service with a fake renderer
291
302
  HF_TEST_CHROME=1 npm test # plus a real render in Chrome (needs HF_DIST_RENDER=<dist-render folder>)
292
303
  npm run build # Bun bundles src into dist (bun comes as a dev dependency)
304
+ npx bun run script/build.ts --compile host # standalone binary for this machine in dist/standalone/
293
305
  ```
294
306
 
307
+ Binary targets: `linux-x64`, `linux-x64-baseline` (CPUs without AVX2), `linux-arm64`, `linux-x64-musl`,
308
+ `linux-arm64-musl`, `darwin-x64`, `darwin-arm64`, `windows-x64`, `windows-x64-baseline`.
309
+
295
310
  See [CONTRIBUTING.md](CONTRIBUTING.md) and [AGENTS.md](AGENTS.md).
296
311
 
297
312
  ### Protocol (version 1)
@@ -329,7 +344,8 @@ A package holds `klip.json` (`{klip}`) or `proyek.json` (`{proyek, setelan}`), p
329
344
  |---|---|
330
345
  | `ws`, `yauzl`, `picocolors`, `@clack/prompts` | MIT |
331
346
  | `puppeteer-core`, `@puppeteer/browsers` | Apache-2.0 |
332
- | `ffmpeg-static` | GPL-3.0-or-later (the package and the ffmpeg binary it downloads) |
347
+ | `ffmpeg-static` | GPL-3.0-or-later (the package and the ffmpeg binary it downloads; the standalone program downloads the same ffmpeg build) |
333
348
 
349
+ The standalone program also contains the [Bun](https://bun.sh) runtime (MIT; it includes JavaScriptCore, LGPL-2.1).
334
350
  Chrome for Testing is downloaded from Google under Google's terms. The HypeFrame render page (including Remotion and
335
351
  GSAP) is **not** in this package; it is fetched from HypeFrame Web when used and follows its own licenses.
package/dist/index.js CHANGED
@@ -167,6 +167,7 @@ var id = {
167
167
  "render.notYet": "Render di mesin ini belum bisa: {reason}. Mesin tetap tersambung; dicoba lagi 10 menit lagi.",
168
168
  "render.noH264": "Chrome {chrome} tidak bisa membuat video H.264",
169
169
  "render.downloading": "Mengunduh Chrome untuk render (sekali saja)",
170
+ "render.downloadingFfmpeg": "Mengunduh ffmpeg untuk render (sekali saja, ± 28 MB)",
170
171
  "render.job": "Render {kind} dimulai {size}",
171
172
  "render.jobDone": "Render selesai dalam {sec} ({size})",
172
173
  "render.jobFailed": "Render gagal: {reason}",
@@ -219,6 +220,7 @@ var id = {
219
220
  "doctor.free": "{size} kosong",
220
221
  "doctor.noFfmpeg": "ffmpeg tidak tersedia untuk sistem ini",
221
222
  "doctor.chromeLater": "belum ada; diunduh otomatis saat mesin menyala",
223
+ "doctor.ffmpegLater": "belum ada; diunduh otomatis saat mesin menyala",
222
224
  "doctor.alpha": "Klip transparan",
223
225
  "doctor.alphaNo": "tidak didukung Chrome ini; dibuat di server atau HP",
224
226
  "doctor.yes": "bisa",
@@ -241,7 +243,7 @@ var id = {
241
243
  "autostart.off": "Nyala otomatis dimatikan.",
242
244
  "autostart.isOn": "Nyala otomatis: nyala.",
243
245
  "autostart.isOff": "Nyala otomatis: mati.",
244
- "autostart.needGlobal": "Nyala otomatis butuh hypeframe yang terpasang tetap, bukan salinan sementara npx.",
246
+ "autostart.needGlobal": "Nyala otomatis butuh hypeframe yang terpasang tetap (pemasang curl atau npm i -g), bukan salinan sementara npx.",
245
247
  "autostart.needLogin": "Sambungkan perangkat ke akun dulu (hypeframe login).",
246
248
  "clean.question": "Hapus Chrome unduhan, cache halaman render, log lama, dan render yang gagal? Video yang sudah jadi tetap disimpan.",
247
249
  "clean.running": "Matikan mesin dulu sebelum membersihkan.",
@@ -251,6 +253,7 @@ var id = {
251
253
  "update.running": "Memperbarui hypeframe...",
252
254
  "update.done": "hypeframe sudah versi terbaru.",
253
255
  "update.failed": "Pembaruan gagal. Coba jalankan sendiri: npm i -g hypeframe@latest",
256
+ "update.failedStandalone": "Pembaruan gagal. Coba jalankan pemasang lagi: curl -fsSL https://hype-frame.com/install | bash",
254
257
  "update.npx": "Kamu menjalankan hypeframe lewat npx; versi terbaru dipakai dengan:",
255
258
  "open.done": "Membuka {web}",
256
259
  "help.usage": "Pakai",
@@ -304,6 +307,7 @@ var en = {
304
307
  "render.notYet": "Rendering is not available yet: {reason}. The engine stays connected; retrying in 10 minutes.",
305
308
  "render.noH264": "Chrome {chrome} cannot encode H.264 video",
306
309
  "render.downloading": "Downloading Chrome for rendering (one time)",
310
+ "render.downloadingFfmpeg": "Downloading ffmpeg for rendering (one time, about 28 MB)",
307
311
  "render.job": "Rendering {kind} {size}",
308
312
  "render.jobDone": "Render finished in {sec} ({size})",
309
313
  "render.jobFailed": "Render failed: {reason}",
@@ -356,6 +360,7 @@ var en = {
356
360
  "doctor.free": "{size} free",
357
361
  "doctor.noFfmpeg": "ffmpeg is not available for this system",
358
362
  "doctor.chromeLater": "not yet; downloaded automatically when the engine starts",
363
+ "doctor.ffmpegLater": "not yet; downloaded automatically when the engine starts",
359
364
  "doctor.alpha": "Transparent clips",
360
365
  "doctor.alphaNo": "not supported by this Chrome; made on the server or phone",
361
366
  "doctor.yes": "yes",
@@ -378,7 +383,7 @@ var en = {
378
383
  "autostart.off": "Autostart off.",
379
384
  "autostart.isOn": "Autostart: on.",
380
385
  "autostart.isOff": "Autostart: off.",
381
- "autostart.needGlobal": "Autostart needs an installed hypeframe, not the temporary npx copy.",
386
+ "autostart.needGlobal": "Autostart needs an installed hypeframe (the curl installer or npm i -g), not the temporary npx copy.",
382
387
  "autostart.needLogin": "Connect this device to an account first (hypeframe login).",
383
388
  "clean.question": "Delete the downloaded Chrome, cached render pages, old logs and failed renders? Finished videos are kept.",
384
389
  "clean.running": "Stop the engine before cleaning up.",
@@ -388,6 +393,7 @@ var en = {
388
393
  "update.running": "Updating hypeframe...",
389
394
  "update.done": "hypeframe is up to date.",
390
395
  "update.failed": "Update failed. Try it yourself: npm i -g hypeframe@latest",
396
+ "update.failedStandalone": "Update failed. Run the installer again: curl -fsSL https://hype-frame.com/install | bash",
391
397
  "update.npx": "You are running hypeframe through npx; the latest version runs with:",
392
398
  "open.done": "Opening {web}",
393
399
  "help.usage": "Usage",
@@ -496,8 +502,7 @@ var log = {
496
502
  };
497
503
 
498
504
  // packages/hypeframe/src/cli/commands/start.ts
499
- import crypto3 from "node:crypto";
500
- import ffmpegPath from "ffmpeg-static";
505
+ import crypto4 from "node:crypto";
501
506
 
502
507
  // packages/protocol/src/index.ts
503
508
  var PROTOCOL_VERSION = 1;
@@ -570,20 +575,61 @@ function singleInstance() {
570
575
  }
571
576
  throw new AlreadyRunning("engine already running");
572
577
  }
578
+ // packages/hypeframe/package.json
579
+ var package_default = {
580
+ name: "hypeframe",
581
+ version: "0.3.0",
582
+ description: "Local engine for HypeFrame Web: code clips, video renders and (soon) AI agents run on your own machine; the web is just the view.",
583
+ keywords: [
584
+ "hypeframe",
585
+ "video",
586
+ "render",
587
+ "motion-graphics",
588
+ "chrome-headless",
589
+ "cli"
590
+ ],
591
+ homepage: "https://hype-frame.com",
592
+ repository: {
593
+ type: "git",
594
+ url: "git+https://github.com/sairidev/hypeframe.git",
595
+ directory: "packages/hypeframe"
596
+ },
597
+ bugs: {
598
+ url: "https://github.com/sairidev/hypeframe/issues"
599
+ },
600
+ author: "SairiDev",
601
+ license: "MIT",
602
+ type: "module",
603
+ bin: {
604
+ hypeframe: "bin/hypeframe.js"
605
+ },
606
+ files: [
607
+ "bin",
608
+ "dist",
609
+ "README.md",
610
+ "LICENSE"
611
+ ],
612
+ engines: {
613
+ node: ">=20.3"
614
+ },
615
+ scripts: {
616
+ build: "bun run ../../script/build.ts",
617
+ typecheck: "tsc --noEmit",
618
+ test: "node --import tsx --test test/*.test.ts"
619
+ },
620
+ dependencies: {
621
+ "@clack/prompts": "1.9.0",
622
+ "@puppeteer/browsers": "2.6.1",
623
+ "ffmpeg-static": "5.2.0",
624
+ picocolors: "1.1.1",
625
+ "puppeteer-core": "23.11.1",
626
+ ws: "8.18.0",
627
+ yauzl: "3.2.0"
628
+ }
629
+ };
573
630
 
574
631
  // packages/hypeframe/src/config/version.ts
575
- import fs6 from "node:fs";
576
- function readPkg() {
577
- for (const rel of ["../package.json", "../../package.json"]) {
578
- try {
579
- const p = JSON.parse(fs6.readFileSync(new URL(rel, import.meta.url), "utf8"));
580
- if (p.name === "hypeframe")
581
- return p;
582
- } catch {}
583
- }
584
- return { version: "0.0.0" };
585
- }
586
- var VERSION = process.env.HF_MESIN_VERSI || readPkg().version;
632
+ var VERSION = process.env.HF_MESIN_VERSI || package_default.version;
587
633
 
588
634
  // packages/hypeframe/src/engine/connection.ts
589
635
  import { EventEmitter } from "node:events";
@@ -784,7 +830,7 @@ async function pair(o) {
784
830
 
785
831
  // packages/hypeframe/src/render/chrome.ts
786
832
  import { execFileSync } from "node:child_process";
787
- import fs7 from "node:fs";
833
+ import fs6 from "node:fs";
788
834
  import http from "node:http";
789
835
  import path3 from "node:path";
790
836
  import { Browser, detectBrowserPlatform, getInstalledBrowsers, install, resolveBuildId } from "@puppeteer/browsers";
@@ -810,13 +856,13 @@ function candidates() {
810
856
  function findChrome() {
811
857
  const forced = process.env.HYPEFRAME_CHROME;
812
858
  if (forced)
813
- return fs7.existsSync(forced) ? forced : null;
814
- return candidates().find((p) => fs7.existsSync(p)) || null;
859
+ return fs6.existsSync(forced) ? forced : null;
860
+ return candidates().find((p) => fs6.existsSync(p)) || null;
815
861
  }
816
862
  async function cachedChrome(cacheDir) {
817
863
  try {
818
864
  const all = await getInstalledBrowsers({ cacheDir: path3.join(cacheDir, "chrome") });
819
- return all.find((b) => b.browser === Browser.CHROME && fs7.existsSync(b.executablePath))?.executablePath ?? null;
865
+ return all.find((b) => b.browser === Browser.CHROME && fs6.existsSync(b.executablePath))?.executablePath ?? null;
820
866
  } catch {
821
867
  return null;
822
868
  }
@@ -879,12 +925,92 @@ async function checkChrome(chrome, { gpu = false } = {}) {
879
925
  }
880
926
  }
881
927
 
882
- // packages/hypeframe/src/render/job.ts
883
- import { spawn } from "node:child_process";
928
+ // packages/hypeframe/src/render/ffmpeg.ts
884
929
  import crypto from "node:crypto";
885
- import fs8 from "node:fs";
930
+ import fs7 from "node:fs";
886
931
  import fsp from "node:fs/promises";
887
932
  import path4 from "node:path";
933
+ import { pipeline } from "node:stream/promises";
934
+ import { Readable } from "node:stream";
935
+ import zlib from "node:zlib";
936
+ var FFMPEG_RELEASE = "b6.0";
937
+ var BASE = `https://github.com/eugeneware/ffmpeg-static/releases/download/${FFMPEG_RELEASE}/`;
938
+ var FFMPEG_PINNED = {
939
+ "win32-x64": { sha256: "450d66226c79405c724e821f291cab0911e934bfa9fa2231adcab587f3e07b50", size: 28894894 },
940
+ "linux-x64": { sha256: "17c1ae10b52ac499180679fe6ba77e17642390c4eedb0f1e3b0ac045da55128f", size: 28928723 },
941
+ "linux-arm64": { sha256: "2b708b2d15041d2a192c1db24c7a8a1d24f645a8242dce1c744ff2392b86ada1", size: 25131803 },
942
+ "darwin-x64": { sha256: "a12354fce7eb62361473bbe10d53a1893695babd35869ec8e92e5dfea8d0440b", size: 25067704 },
943
+ "darwin-arm64": { sha256: "6be74d6f449889c2e87a75873894f8520cad56c08ac76f2a628d85b0519daaca", size: 19253088 }
944
+ };
945
+ var exe = process.platform === "win32" ? "ffmpeg.exe" : "ffmpeg";
946
+ var cached2 = (cacheDir) => path4.join(cacheDir, "ffmpeg", FFMPEG_RELEASE, exe);
947
+ async function findFfmpeg(cacheDir) {
948
+ const forced = process.env.HYPEFRAME_FFMPEG;
949
+ if (forced)
950
+ return fs7.existsSync(forced) ? forced : null;
951
+ try {
952
+ const mod = await import("ffmpeg-static");
953
+ const p = typeof mod.default === "string" ? mod.default : null;
954
+ if (p && fs7.existsSync(p))
955
+ return p;
956
+ } catch {}
957
+ const c = cached2(cacheDir);
958
+ return fs7.existsSync(c) ? c : null;
959
+ }
960
+ async function downloadVerified(url, sha256, dest, progress = () => {
961
+ return;
962
+ }, gunzip = false) {
963
+ const r = await fetch(url, { signal: AbortSignal.timeout(900000) });
964
+ if (!r.ok || !r.body)
965
+ throw new Error(`download ${r.status}`);
966
+ const total = Number(r.headers.get("content-length")) || 0;
967
+ await fsp.mkdir(path4.dirname(dest), { recursive: true });
968
+ const tmp = `${dest}.download`;
969
+ const hash = crypto.createHash("sha256");
970
+ let got = 0;
971
+ let last = -10;
972
+ const body = Readable.fromWeb(r.body).on("data", (c) => {
973
+ hash.update(c);
974
+ got += c.length;
975
+ const pct = total ? Math.floor(got / total * 100) : 0;
976
+ if (pct - last >= 10)
977
+ last = pct, progress(pct);
978
+ });
979
+ await pipeline(body, fs7.createWriteStream(tmp));
980
+ if (hash.digest("hex") !== sha256) {
981
+ await fsp.rm(tmp, { force: true });
982
+ throw new Error("ffmpeg: sidik unduhan tidak cocok, berkas ditolak.");
983
+ }
984
+ if (gunzip) {
985
+ await pipeline(fs7.createReadStream(tmp), zlib.createGunzip(), fs7.createWriteStream(`${tmp}.raw`));
986
+ await fsp.rm(tmp, { force: true });
987
+ await fsp.rename(`${tmp}.raw`, dest);
988
+ } else
989
+ await fsp.rename(tmp, dest);
990
+ if (process.platform !== "win32")
991
+ await fsp.chmod(dest, 493);
992
+ }
993
+ async function prepareFfmpeg(cacheDir, progress = () => {
994
+ return;
995
+ }) {
996
+ const found = await findFfmpeg(cacheDir);
997
+ if (found)
998
+ return found;
999
+ const key = `${process.platform}-${process.arch}`;
1000
+ const pin = FFMPEG_PINNED[key];
1001
+ if (!pin)
1002
+ throw new Error(`ffmpeg tidak tersedia untuk ${key}`);
1003
+ progress(0);
1004
+ await downloadVerified(`${BASE}ffmpeg-${key}.gz`, pin.sha256, cached2(cacheDir), progress, true);
1005
+ return cached2(cacheDir);
1006
+ }
1007
+
1008
+ // packages/hypeframe/src/render/job.ts
1009
+ import { spawn } from "node:child_process";
1010
+ import crypto2 from "node:crypto";
1011
+ import fs8 from "node:fs";
1012
+ import fsp2 from "node:fs/promises";
1013
+ import path5 from "node:path";
888
1014
  import puppeteer2 from "puppeteer-core";
889
1015
  var LIMIT_SECONDS = 1800;
890
1016
  function run(cmd, args, limitSeconds = 600) {
@@ -932,7 +1058,7 @@ function createJobRunner(o) {
932
1058
  const renderer = async (task, { progress, signal }) => {
933
1059
  if (task.kind === "klip" && task.transparent && !transparent)
934
1060
  throw new Error(EngineError.NoTransparent);
935
- const key = crypto.randomBytes(16).toString("hex");
1061
+ const key = crypto2.randomBytes(16).toString("hex");
936
1062
  let finish;
937
1063
  const finished = new Promise((ok) => finish = ok);
938
1064
  running.set(task.job, { key, task, progress, finish });
@@ -943,9 +1069,9 @@ function createJobRunner(o) {
943
1069
  let browser;
944
1070
  try {
945
1071
  progress(0, "Menyiapkan");
946
- const profile = path4.join(task.dir, "profil");
947
- await fsp.mkdir(path4.join(profile, "Default"), { recursive: true });
948
- await fsp.writeFile(path4.join(profile, "Default", "Preferences"), JSON.stringify({ webkit: { webprefs: { fonts: { standard: { Zyyy: "Roboto" }, sansserif: { Zyyy: "Roboto" }, serif: { Zyyy: "Noto Serif" } } } } }));
1072
+ const profile = path5.join(task.dir, "profil");
1073
+ await fsp2.mkdir(path5.join(profile, "Default"), { recursive: true });
1074
+ await fsp2.writeFile(path5.join(profile, "Default", "Preferences"), JSON.stringify({ webkit: { webprefs: { fonts: { standard: { Zyyy: "Roboto" }, sansserif: { Zyyy: "Roboto" }, serif: { Zyyy: "Noto Serif" } } } } }));
949
1075
  browser = await puppeteer2.launch({
950
1076
  executablePath: chrome,
951
1077
  headless: true,
@@ -975,11 +1101,11 @@ function createJobRunner(o) {
975
1101
  if (result.error)
976
1102
  throw new Error(result.error);
977
1103
  progress(99, clip ? "Menyelesaikan klip" : "Menyelesaikan video");
978
- const raw = path4.join(task.dir, "mentah.mp4");
1104
+ const raw = path5.join(task.dir, "mentah.mp4");
979
1105
  const webm = clip && task.transparent;
980
- const file = path4.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
1106
+ const file = path5.join(task.dir, webm ? "hasil.webm" : "hasil.mp4");
981
1107
  if (clip)
982
- await fsp.rename(raw, file);
1108
+ await fsp2.rename(raw, file);
983
1109
  else
984
1110
  await run(ffmpeg, ["-y", "-v", "error", "-i", raw, "-map", "0", "-c:v", "copy", ...result.audio === "opus" ? ["-c:a", "aac", "-b:a", "192k"] : ["-c:a", "copy"], "-movflags", "+faststart", file]);
985
1111
  return { file, type: webm ? "video/webm" : "video/mp4" };
@@ -1004,10 +1130,10 @@ function createJobRunner(o) {
1004
1130
  return res.writeHead(403), res.end(), true;
1005
1131
  const pkg = r.task.packageDir;
1006
1132
  if (m[2] === "proyek.json" || m[2] === "klip.json" || m[3]) {
1007
- const f = m[3] ? path4.join(pkg, "aset", m[3]) : path4.join(pkg, m[2]);
1133
+ const f = m[3] ? path5.join(pkg, "aset", m[3]) : path5.join(pkg, m[2]);
1008
1134
  if (!fs8.existsSync(f))
1009
1135
  return res.writeHead(404), res.end(), true;
1010
- res.writeHead(200, { "content-type": m[3] ? "application/octet-stream" : "application/json", "content-length": (await fsp.stat(f)).size });
1136
+ res.writeHead(200, { "content-type": m[3] ? "application/octet-stream" : "application/json", "content-length": (await fsp2.stat(f)).size });
1011
1137
  fs8.createReadStream(f).pipe(res);
1012
1138
  return true;
1013
1139
  }
@@ -1025,7 +1151,7 @@ function createJobRunner(o) {
1025
1151
  r.finish({ error: String(b.pesan || "Render gagal.").slice(0, 300) });
1026
1152
  return res.writeHead(204), res.end(), true;
1027
1153
  }
1028
- await saveBody(req, path4.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
1154
+ await saveBody(req, path5.join(r.task.dir, "mentah.mp4"), 8 * 1073741824);
1029
1155
  r.finish({ audio: String(req.headers["x-kodek-audio"] || "") });
1030
1156
  res.writeHead(204);
1031
1157
  res.end();
@@ -1036,8 +1162,8 @@ function createJobRunner(o) {
1036
1162
 
1037
1163
  // packages/hypeframe/src/render/page.ts
1038
1164
  import fs9 from "node:fs";
1039
- import fsp2 from "node:fs/promises";
1040
- import path5 from "node:path";
1165
+ import fsp3 from "node:fs/promises";
1166
+ import path6 from "node:path";
1041
1167
  var TYPES = {
1042
1168
  ".html": "text/html; charset=utf-8",
1043
1169
  ".js": "text/javascript",
@@ -1058,12 +1184,12 @@ var SAFE_PATH = /^[\w@.+-]+(?:\/[\w@.+-]+)*$/;
1058
1184
  var VERSION_ID = /^[0-9a-f]{12}$/;
1059
1185
  function createPage({ web, cacheDir }) {
1060
1186
  const base = `${String(web || "").replace(/\/+$/, "")}/render/`;
1061
- const root = path5.join(cacheDir, "halaman");
1187
+ const root = path6.join(cacheDir, "halaman");
1062
1188
  let version = null;
1063
- const versionDir = () => path5.join(root, version);
1189
+ const versionDir = () => path6.join(root, version);
1064
1190
  const pending = new Map;
1065
1191
  async function download(rel) {
1066
- const target = path5.join(versionDir(), rel);
1192
+ const target = path6.join(versionDir(), rel);
1067
1193
  if (fs9.existsSync(target))
1068
1194
  return target;
1069
1195
  if (!pending.has(rel)) {
@@ -1072,9 +1198,9 @@ function createPage({ web, cacheDir }) {
1072
1198
  if (!r.ok)
1073
1199
  throw Object.assign(new Error(`halaman ${rel}: ${r.status}`), { status: r.status });
1074
1200
  const body = Buffer.from(await r.arrayBuffer());
1075
- await fsp2.mkdir(path5.dirname(target), { recursive: true });
1076
- await fsp2.writeFile(`${target}.tmp`, body);
1077
- await fsp2.rename(`${target}.tmp`, target);
1201
+ await fsp3.mkdir(path6.dirname(target), { recursive: true });
1202
+ await fsp3.writeFile(`${target}.tmp`, body);
1203
+ await fsp3.rename(`${target}.tmp`, target);
1078
1204
  return target;
1079
1205
  })().finally(() => pending.delete(rel)));
1080
1206
  }
@@ -1095,11 +1221,11 @@ function createPage({ web, cacheDir }) {
1095
1221
  if (typeof f === "string" && SAFE_PATH.test(f))
1096
1222
  await download(f);
1097
1223
  if (old !== version) {
1098
- const all = (await fsp2.readdir(root).catch(() => [])).filter((d) => VERSION_ID.test(d));
1099
- const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp2.stat(path5.join(root, d))).mtimeMs })));
1224
+ const all = (await fsp3.readdir(root).catch(() => [])).filter((d) => VERSION_ID.test(d));
1225
+ const dated = await Promise.all(all.map(async (d) => ({ d, t: (await fsp3.stat(path6.join(root, d))).mtimeMs })));
1100
1226
  for (const { d } of dated.sort((a, b) => b.t - a.t).slice(2))
1101
1227
  if (d !== version)
1102
- await fsp2.rm(path5.join(root, d), { recursive: true, force: true });
1228
+ await fsp3.rm(path6.join(root, d), { recursive: true, force: true });
1103
1229
  }
1104
1230
  return { version };
1105
1231
  }
@@ -1116,7 +1242,7 @@ function createPage({ web, cacheDir }) {
1116
1242
  return res.writeHead(404), res.end(), true;
1117
1243
  try {
1118
1244
  const f = await download(rel);
1119
- res.writeHead(200, { "content-type": TYPES[path5.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
1245
+ res.writeHead(200, { "content-type": TYPES[path6.extname(f)] || "application/octet-stream", "cache-control": "no-store" });
1120
1246
  fs9.createReadStream(f).pipe(res);
1121
1247
  } catch (e) {
1122
1248
  res.writeHead(e.status === 404 ? 404 : 502);
@@ -1134,14 +1260,14 @@ function createPage({ web, cacheDir }) {
1134
1260
  }
1135
1261
 
1136
1262
  // packages/hypeframe/src/render/service.ts
1137
- import crypto2 from "node:crypto";
1263
+ import crypto3 from "node:crypto";
1138
1264
  import fs10 from "node:fs";
1139
- import fsp3 from "node:fs/promises";
1265
+ import fsp4 from "node:fs/promises";
1140
1266
  import http2 from "node:http";
1141
- import path6 from "node:path";
1267
+ import path7 from "node:path";
1142
1268
  import yauzl from "yauzl";
1143
1269
  var ACTIVE = new Set(["unggah", "antre", "jalan"]);
1144
- var safeEqual = (a, b) => a.length === b.length && crypto2.timingSafeEqual(Buffer.from(a), Buffer.from(b));
1270
+ var safeEqual = (a, b) => a.length === b.length && crypto3.timingSafeEqual(Buffer.from(a), Buffer.from(b));
1145
1271
  var BAD_ENTRY = /relative path|absolute path|invalid characters/i;
1146
1272
  function listZip(f) {
1147
1273
  return new Promise((ok, fail) => {
@@ -1165,10 +1291,10 @@ function extractZip(f, to) {
1165
1291
  zip.on("entry", (en) => {
1166
1292
  if (en.fileName.endsWith("/"))
1167
1293
  return zip.readEntry();
1168
- const target = path6.join(to, en.fileName);
1169
- if (!target.startsWith(to + path6.sep))
1294
+ const target = path7.join(to, en.fileName);
1295
+ if (!target.startsWith(to + path7.sep))
1170
1296
  return fail(new Error(EngineError.BadPackage));
1171
- fs10.mkdirSync(path6.dirname(target), { recursive: true });
1297
+ fs10.mkdirSync(path7.dirname(target), { recursive: true });
1172
1298
  zip.openReadStream(en, (e2, s) => {
1173
1299
  if (e2 || !s)
1174
1300
  return fail(e2 ?? new Error("zip"));
@@ -1221,9 +1347,9 @@ async function createRenderService(o) {
1221
1347
  return;
1222
1348
  } } = o;
1223
1349
  const origins = new Set([].concat(o.origin || []));
1224
- const sign = (kind, body) => crypto2.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
1225
- const dir = (job) => path6.join(folder, job);
1226
- await fsp3.mkdir(folder, { recursive: true });
1350
+ const sign = (kind, body) => crypto3.createHmac("sha256", key).update(`${kind}.${body}`).digest("base64url");
1351
+ const dir = (job) => path7.join(folder, job);
1352
+ await fsp4.mkdir(folder, { recursive: true });
1227
1353
  function readTicket(req) {
1228
1354
  const tk = String(req.headers.authorization || "").replace(/^Bearer\s+/i, "");
1229
1355
  const [v, body, sig] = tk.split(".");
@@ -1244,7 +1370,7 @@ async function createRenderService(o) {
1244
1370
  const jobs = new Map;
1245
1371
  const queue = [];
1246
1372
  let current = null;
1247
- const persist = (t) => fsp3.writeFile(path6.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
1373
+ const persist = (t) => fsp4.writeFile(path7.join(dir(t.job), "status.json"), JSON.stringify(t)).catch(() => {
1248
1374
  return;
1249
1375
  });
1250
1376
  const update = (t, patch) => (Object.assign(t, patch, { diperbarui: Date.now() }), void persist(t));
@@ -1263,19 +1389,19 @@ async function createRenderService(o) {
1263
1389
  });
1264
1390
  async function clearFiles(t, all = false) {
1265
1391
  for (const n of all ? ["."] : ["paket", "paket.zip", "profil", "mentah.mp4", "mentah.webm"])
1266
- await fsp3.rm(path6.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
1392
+ await fsp4.rm(path7.join(dir(t.job), n), { recursive: true, force: true }).catch(() => {
1267
1393
  return;
1268
1394
  });
1269
1395
  if (!all) {
1270
- for (const f of await fsp3.readdir(dir(t.job)).catch(() => []))
1396
+ for (const f of await fsp4.readdir(dir(t.job)).catch(() => []))
1271
1397
  if (/^p\d+$/.test(f))
1272
- await fsp3.rm(path6.join(dir(t.job), f), { force: true });
1398
+ await fsp4.rm(path7.join(dir(t.job), f), { force: true });
1273
1399
  }
1274
1400
  }
1275
1401
  async function openPackage(t) {
1276
1402
  const d = dir(t.job);
1277
1403
  const main = t.tiket.jenis === "klip" ? "klip.json" : "proyek.json";
1278
- const entries = await listZip(path6.join(d, "paket.zip"));
1404
+ const entries = await listZip(path7.join(d, "paket.zip"));
1279
1405
  const names = entries.map((x) => x.name).filter((n) => !n.endsWith("/"));
1280
1406
  if (names.some((n) => n.startsWith("/") || n.includes("..") || n.includes("\\") || n !== main && !/^aset\/[\w-]+$/.test(n)))
1281
1407
  throw new Error(EngineError.BadPackage);
@@ -1283,10 +1409,10 @@ async function createRenderService(o) {
1283
1409
  throw new Error(`Paket tidak berisi ${main}.`);
1284
1410
  if (entries.reduce((a, x) => a + x.size, 0) > maxUnzippedMb * 1048576)
1285
1411
  throw new Error("Isi paket terlalu besar.");
1286
- await extractZip(path6.join(d, "paket.zip"), path6.join(d, "paket"));
1287
- await fsp3.rm(path6.join(d, "paket.zip"), { force: true });
1288
- const j = JSON.parse(await fsp3.readFile(path6.join(d, "paket", main), "utf8"));
1289
- const has = (id) => /^[\w-]+$/.test(id) && fs10.existsSync(path6.join(d, "paket", "aset", id));
1412
+ await extractZip(path7.join(d, "paket.zip"), path7.join(d, "paket"));
1413
+ await fsp4.rm(path7.join(d, "paket.zip"), { force: true });
1414
+ const j = JSON.parse(await fsp4.readFile(path7.join(d, "paket", main), "utf8"));
1415
+ const has = (id) => /^[\w-]+$/.test(id) && fs10.existsSync(path7.join(d, "paket", "aset", id));
1290
1416
  if (main === "klip.json") {
1291
1417
  const k = j.klip || {};
1292
1418
  const seconds = Number(k.durationInFrames) / Number(k.fps);
@@ -1334,7 +1460,7 @@ async function createRenderService(o) {
1334
1460
  job: t.job,
1335
1461
  kind: t.tiket.jenis,
1336
1462
  dir: dir(t.job),
1337
- packageDir: path6.join(dir(t.job), "paket"),
1463
+ packageDir: path7.join(dir(t.job), "paket"),
1338
1464
  transparent: !!t.transparan,
1339
1465
  persen: t.persen,
1340
1466
  width: t.tiket.w,
@@ -1351,10 +1477,10 @@ async function createRenderService(o) {
1351
1477
  const h = await renderer(task, { progress, signal: cancel.signal });
1352
1478
  if (cancel.signal.aborted)
1353
1479
  throw new Error("Dibatalkan.");
1354
- const size = (await fsp3.stat(h.file)).size;
1480
+ const size = (await fsp4.stat(h.file)).size;
1355
1481
  if (size < 200)
1356
1482
  throw new Error(EngineError.EmptyResult);
1357
- update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path6.basename(h.file), hasilJenis: h.type });
1483
+ update(t, { status: "selesai", persen: 100, tahap: "", selesaiPada: Date.now(), hasilUkuran: size, hasilBerkas: path7.basename(h.file), hasilJenis: h.type });
1358
1484
  onJob("done", t);
1359
1485
  } catch (e) {
1360
1486
  if (t.status !== "batal") {
@@ -1383,7 +1509,7 @@ async function createRenderService(o) {
1383
1509
  }
1384
1510
  const json = (req, res, code, body) => (res.writeHead(code, { ...cors(req), "content-type": "application/json", "cache-control": "no-store" }), res.end(JSON.stringify(body)));
1385
1511
  async function sendFile(req, res, f, type, name) {
1386
- const st = await fsp3.stat(f);
1512
+ const st = await fsp4.stat(f);
1387
1513
  const range = /^bytes=(\d+)-(\d*)$/.exec(String(req.headers.range || ""));
1388
1514
  const h = { ...cors(req), "content-type": type, "accept-ranges": "bytes", "cache-control": "no-store", "content-disposition": `attachment; filename="${name}"` };
1389
1515
  if (range) {
@@ -1422,7 +1548,7 @@ async function createRenderService(o) {
1422
1548
  return json(req, res, 200, summary(t));
1423
1549
  if (queue.length >= maxQueue)
1424
1550
  return json(req, res, 503, { galat: EngineError.QueueFull });
1425
- await fsp3.mkdir(dir(job), { recursive: true });
1551
+ await fsp4.mkdir(dir(job), { recursive: true });
1426
1552
  t = { job, tiket: ticket, status: "unggah", dibuat: Date.now(), diperbarui: Date.now(), terunggah: 0 };
1427
1553
  jobs.set(job, t);
1428
1554
  persist(t);
@@ -1434,15 +1560,15 @@ async function createRenderService(o) {
1434
1560
  if (t.status !== "unggah")
1435
1561
  return json(req, res, 409, { galat: "Unggahan sudah ditutup." });
1436
1562
  const n = Number(m[3]);
1437
- const f = path6.join(dir(job), `p${n}`);
1438
- const before = fs10.existsSync(f) ? (await fsp3.stat(f)).size : 0;
1563
+ const f = path7.join(dir(job), `p${n}`);
1564
+ const before = fs10.existsSync(f) ? (await fsp4.stat(f)).size : 0;
1439
1565
  const room = Number(ticket.maksMb) * 1048576 - (t.terunggah - before);
1440
1566
  const size = await saveBody2(req, f, Math.min(partMb * 1048576 + 1024, room));
1441
1567
  const expected = String(req.headers["x-sha256"] || "").toLowerCase();
1442
1568
  if (expected) {
1443
- const digest = crypto2.createHash("sha256").update(await fsp3.readFile(f)).digest("hex");
1569
+ const digest = crypto3.createHash("sha256").update(await fsp4.readFile(f)).digest("hex");
1444
1570
  if (digest !== expected) {
1445
- await fsp3.rm(f, { force: true });
1571
+ await fsp4.rm(f, { force: true });
1446
1572
  update(t, { terunggah: t.terunggah - before });
1447
1573
  return json(req, res, 400, { galat: "Potongan rusak di jalan. Kirim ulang." });
1448
1574
  }
@@ -1457,24 +1583,24 @@ async function createRenderService(o) {
1457
1583
  const count = Number(b.jumlah);
1458
1584
  if (!(count > 0 && count < 1e4))
1459
1585
  return json(req, res, 400, { galat: "Jumlah potongan tidak valid." });
1460
- const zip = path6.join(dir(job), "paket.zip");
1586
+ const zip = path7.join(dir(job), "paket.zip");
1461
1587
  const out = fs10.createWriteStream(zip);
1462
- const hash = crypto2.createHash("sha256");
1588
+ const hash = crypto3.createHash("sha256");
1463
1589
  let total = 0;
1464
1590
  for (let i = 0;i < count; i++) {
1465
- const f = path6.join(dir(job), `p${i}`);
1591
+ const f = path7.join(dir(job), `p${i}`);
1466
1592
  if (!fs10.existsSync(f))
1467
1593
  return out.destroy(), json(req, res, 400, { galat: `Potongan ${i + 1} belum terunggah.` });
1468
- const part = await fsp3.readFile(f);
1594
+ const part = await fsp4.readFile(f);
1469
1595
  hash.update(part);
1470
1596
  total += part.length;
1471
1597
  await new Promise((ok) => out.write(part) ? ok() : out.once("drain", ok));
1472
- await fsp3.rm(f, { force: true });
1598
+ await fsp4.rm(f, { force: true });
1473
1599
  }
1474
1600
  await new Promise((ok) => out.end(ok));
1475
1601
  const digest = hash.digest("hex");
1476
1602
  if (total !== Number(b.ukuran) || b.sha256 && digest !== String(b.sha256).toLowerCase()) {
1477
- await fsp3.rm(zip, { force: true });
1603
+ await fsp4.rm(zip, { force: true });
1478
1604
  update(t, { terunggah: 0 });
1479
1605
  return json(req, res, 400, { galat: "Unggahan rusak di jalan. Coba render lagi." });
1480
1606
  }
@@ -1493,7 +1619,7 @@ async function createRenderService(o) {
1493
1619
  return json(req, res, 200, summary(t));
1494
1620
  }
1495
1621
  if (m[2] === "/hasil" && (req.method === "GET" || req.method === "HEAD")) {
1496
- const f = t.hasilBerkas ? path6.join(dir(job), t.hasilBerkas) : "";
1622
+ const f = t.hasilBerkas ? path7.join(dir(job), t.hasilBerkas) : "";
1497
1623
  if (t.status !== "selesai" || !f || !fs10.existsSync(f))
1498
1624
  return json(req, res, 409, { galat: "Video belum jadi." });
1499
1625
  const webm = t.hasilJenis === "video/webm";
@@ -1521,16 +1647,16 @@ async function createRenderService(o) {
1521
1647
  json(req, res, 500, { galat: EngineError.ServiceError });
1522
1648
  }
1523
1649
  });
1524
- for (const job of await fsp3.readdir(folder).catch(() => [])) {
1650
+ for (const job of await fsp4.readdir(folder).catch(() => [])) {
1525
1651
  if (!JOB_ID.test(job))
1526
1652
  continue;
1527
1653
  try {
1528
- const t = JSON.parse(await fsp3.readFile(path6.join(dir(job), "status.json"), "utf8"));
1654
+ const t = JSON.parse(await fsp4.readFile(path7.join(dir(job), "status.json"), "utf8"));
1529
1655
  if (t.status === "jalan" || t.status === "antre")
1530
1656
  update(t, { status: "gagal", galat: EngineError.Restarted });
1531
1657
  jobs.set(job, t);
1532
1658
  } catch {
1533
- await fsp3.rm(dir(job), { recursive: true, force: true });
1659
+ await fsp4.rm(dir(job), { recursive: true, force: true });
1534
1660
  }
1535
1661
  }
1536
1662
  const sweep = setInterval(async () => {
@@ -1672,7 +1798,7 @@ async function start(args, { fromMenu = false } = {}) {
1672
1798
  else
1673
1799
  log.ok(t("pair.done", { email: color.bold(maskEmail(account.email)) }));
1674
1800
  const capabilities = { render: false, chrome: null, transparan: false };
1675
- const key = crypto3.randomBytes(32).toString("base64url");
1801
+ const key = crypto4.randomBytes(32).toString("base64url");
1676
1802
  const cache = cacheDir();
1677
1803
  const page = createPage({ web: s.web, cacheDir: cache });
1678
1804
  let runner = null;
@@ -1740,14 +1866,18 @@ async function start(args, { fromMenu = false } = {}) {
1740
1866
  };
1741
1867
  async function prepareRender() {
1742
1868
  try {
1743
- if (!ffmpegPath)
1744
- throw new Error(t("doctor.noFfmpeg"));
1869
+ const ffmpeg = await prepareFfmpeg(cache, (percent) => {
1870
+ if (percent === 0)
1871
+ log.info(t("render.downloadingFfmpeg"));
1872
+ else
1873
+ log.detail(`ffmpeg ${percent}%`);
1874
+ });
1745
1875
  const chrome = await prepareChrome(cache, chromeProgress);
1746
1876
  const info = await checkChrome(chrome, { gpu: s.gpu });
1747
1877
  if (!info.avc)
1748
1878
  throw new Error(t("render.noH264", { chrome: info.version }));
1749
1879
  await page.prepare();
1750
- runner = createJobRunner({ chrome, ffmpeg: ffmpegPath, page, gpu: s.gpu, transparent: info.transparent, note: (m) => log.detail(m) });
1880
+ runner = createJobRunner({ chrome, ffmpeg, page, gpu: s.gpu, transparent: info.transparent, note: (m) => log.detail(m) });
1751
1881
  runner.setPort(service.port);
1752
1882
  Object.assign(capabilities, { render: true, chrome: info.version, transparan: info.transparent });
1753
1883
  conn.setInfo({ kemampuan: capabilities });
@@ -1794,31 +1924,47 @@ function logout() {
1794
1924
 
1795
1925
  // packages/hypeframe/src/cli/commands/autostart.ts
1796
1926
  import { spawnSync } from "node:child_process";
1797
- import fs11 from "node:fs";
1927
+ import fs12 from "node:fs";
1798
1928
  import os3 from "node:os";
1799
- import path7 from "node:path";
1929
+ import path9 from "node:path";
1930
+
1931
+ // packages/hypeframe/src/util/runtime.ts
1932
+ import fs11 from "node:fs";
1933
+ import path8 from "node:path";
1934
+ function isStandalone() {
1935
+ return path8.basename(process.execPath).toLowerCase().startsWith("hypeframe");
1936
+ }
1937
+ function runtimeLabel() {
1938
+ const bun = process.versions.bun;
1939
+ return bun && !isStandalone() ? `Bun ${bun}` : isStandalone() ? `Bun ${bun ?? "?"} (standalone)` : `Node ${process.versions.node}`;
1940
+ }
1941
+ function launchCommand() {
1942
+ if (isStandalone())
1943
+ return [process.execPath];
1944
+ try {
1945
+ const script = fs11.realpathSync(process.argv[1] || "");
1946
+ return /[\\/]_npx[\\/]/.test(script) ? null : [process.execPath, script];
1947
+ } catch {
1948
+ return null;
1949
+ }
1950
+ }
1951
+ var INSTALL_URL = "https://hype-frame.com/install";
1952
+
1953
+ // packages/hypeframe/src/cli/commands/autostart.ts
1800
1954
  function entryFile() {
1801
1955
  const home = os3.homedir();
1802
1956
  if (process.platform === "win32")
1803
- return path7.join(process.env.APPDATA || path7.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
1957
+ return path9.join(process.env.APPDATA || path9.join(home, "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "HypeFrame.cmd");
1804
1958
  if (process.platform === "darwin")
1805
- return path7.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
1959
+ return path9.join(home, "Library", "LaunchAgents", "com.hypeframe.engine.plist");
1806
1960
  if (hasSystemd())
1807
- return path7.join(home, ".config", "systemd", "user", "hypeframe.service");
1808
- return path7.join(home, ".config", "autostart", "hypeframe.desktop");
1961
+ return path9.join(home, ".config", "systemd", "user", "hypeframe.service");
1962
+ return path9.join(home, ".config", "autostart", "hypeframe.desktop");
1809
1963
  }
1810
1964
  function hasSystemd() {
1811
1965
  return process.platform === "linux" && spawnSync("systemctl", ["--user", "--version"], { stdio: "ignore" }).status === 0;
1812
1966
  }
1813
- function installedScript() {
1814
- try {
1815
- const script = fs11.realpathSync(process.argv[1] || "");
1816
- return /[\\/]_npx[\\/]/.test(script) ? null : script;
1817
- } catch {
1818
- return null;
1819
- }
1820
- }
1821
- var autostartEnabled = () => fs11.existsSync(entryFile());
1967
+ var autostartEnabled = () => fs12.existsSync(entryFile());
1822
1968
  var xml = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
1823
1969
  function autostart(mode) {
1824
1970
  const file = entryFile();
@@ -1830,45 +1976,45 @@ function autostart(mode) {
1830
1976
  if (mode === "off") {
1831
1977
  if (process.platform === "linux" && file.endsWith(".service"))
1832
1978
  spawnSync("systemctl", ["--user", "disable", "hypeframe.service"], { stdio: "ignore" });
1833
- fs11.rmSync(file, { force: true });
1979
+ fs12.rmSync(file, { force: true });
1834
1980
  log.ok(t("autostart.off"));
1835
1981
  return;
1836
1982
  }
1837
- const script = installedScript();
1838
- if (!script) {
1983
+ const cmd = launchCommand();
1984
+ if (!cmd) {
1839
1985
  log.warn(t("autostart.needGlobal"));
1840
- log.detail("npm i -g hypeframe");
1986
+ log.detail(`curl -fsSL ${INSTALL_URL} | bash`);
1841
1987
  return;
1842
1988
  }
1843
1989
  if (!readAccount()) {
1844
1990
  log.warn(t("autostart.needLogin"));
1845
1991
  return;
1846
1992
  }
1847
- const node = process.execPath;
1848
- fs11.mkdirSync(path7.dirname(file), { recursive: true });
1993
+ const quoted = cmd.map((c) => `"${c}"`).join(" ");
1994
+ fs12.mkdirSync(path9.dirname(file), { recursive: true });
1849
1995
  if (process.platform === "win32") {
1850
- fs11.writeFileSync(file, `@echo off\r
1851
- start "HypeFrame" /min "${node}" "${script}" start --no-browser\r
1996
+ fs12.writeFileSync(file, `@echo off\r
1997
+ start "HypeFrame" /min ${quoted} start --no-browser\r
1852
1998
  `);
1853
1999
  } else if (process.platform === "darwin") {
1854
- const out = path7.join(logDir(), "autostart.log");
1855
- fs11.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
2000
+ const out = path9.join(logDir(), "autostart.log");
2001
+ fs12.writeFileSync(file, `<?xml version="1.0" encoding="UTF-8"?>
1856
2002
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
1857
2003
  <plist version="1.0"><dict>
1858
2004
  <key>Label</key><string>com.hypeframe.engine</string>
1859
- <key>ProgramArguments</key><array><string>${xml(node)}</string><string>${xml(script)}</string><string>start</string><string>--no-browser</string></array>
2005
+ <key>ProgramArguments</key><array>${cmd.map((c) => `<string>${xml(c)}</string>`).join("")}<string>start</string><string>--no-browser</string></array>
1860
2006
  <key>RunAtLoad</key><true/>
1861
2007
  <key>StandardOutPath</key><string>${xml(out)}</string>
1862
2008
  <key>StandardErrorPath</key><string>${xml(out)}</string>
1863
2009
  </dict></plist>
1864
2010
  `);
1865
2011
  } else if (file.endsWith(".service")) {
1866
- fs11.writeFileSync(file, `[Unit]
2012
+ fs12.writeFileSync(file, `[Unit]
1867
2013
  Description=HypeFrame engine
1868
2014
  After=network-online.target
1869
2015
 
1870
2016
  [Service]
1871
- ExecStart="${node}" "${script}" start --no-browser
2017
+ ExecStart=${quoted} start --no-browser
1872
2018
  Restart=on-failure
1873
2019
  RestartSec=60
1874
2020
 
@@ -1878,10 +2024,10 @@ WantedBy=default.target
1878
2024
  spawnSync("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
1879
2025
  spawnSync("systemctl", ["--user", "enable", "hypeframe.service"], { stdio: "ignore" });
1880
2026
  } else {
1881
- fs11.writeFileSync(file, `[Desktop Entry]
2027
+ fs12.writeFileSync(file, `[Desktop Entry]
1882
2028
  Type=Application
1883
2029
  Name=HypeFrame engine
1884
- Exec="${node}" "${script}" start --no-browser
2030
+ Exec=${quoted} start --no-browser
1885
2031
  Terminal=false
1886
2032
  X-GNOME-Autostart-enabled=true
1887
2033
  `);
@@ -2044,9 +2190,8 @@ async function config(args) {
2044
2190
 
2045
2191
  // packages/hypeframe/src/cli/commands/doctor.ts
2046
2192
  import { spawnSync as spawnSync2 } from "node:child_process";
2047
- import fs12 from "node:fs";
2048
- import path8 from "node:path";
2049
- import ffmpegPath2 from "ffmpeg-static";
2193
+ import fs13 from "node:fs";
2194
+ import path10 from "node:path";
2050
2195
  var mark = { ok: color.ok(icon.ok), warn: color.warn(icon.warn), error: color.error(icon.error) };
2051
2196
  async function reach(url) {
2052
2197
  const t0 = Date.now();
@@ -2068,22 +2213,27 @@ async function doctor(args) {
2068
2213
  console.log(`
2069
2214
  ${color.bold(t("doctor.title"))}
2070
2215
  `);
2071
- const [maj, min] = process.versions.node.split(".").map(Number);
2072
- show({ label: "Node.js", result: maj > 20 || maj === 20 && min >= 3 ? "ok" : "error", detail: `${process.versions.node}${maj < 20 || maj === 20 && min < 3 ? ` ${t("doctor.nodeOld")}` : ""}` });
2216
+ if (isStandalone())
2217
+ show({ label: "Runtime", result: "ok", detail: runtimeLabel() });
2218
+ else {
2219
+ const [maj, min] = process.versions.node.split(".").map(Number);
2220
+ show({ label: "Node.js", result: maj > 20 || maj === 20 && min >= 3 ? "ok" : "error", detail: `${process.versions.node}${maj < 20 || maj === 20 && min < 3 ? ` ${t("doctor.nodeOld")}` : ""}` });
2221
+ }
2073
2222
  try {
2074
- const probe = path8.join(dataDir(), `.probe-${process.pid}`);
2075
- fs12.writeFileSync(probe, "x");
2076
- fs12.rmSync(probe);
2077
- const st = fs12.statfsSync(dataDir());
2223
+ const probe = path10.join(dataDir(), `.probe-${process.pid}`);
2224
+ fs13.writeFileSync(probe, "x");
2225
+ fs13.rmSync(probe);
2226
+ const st = fs13.statfsSync(dataDir());
2078
2227
  const free = st.bavail * st.bsize;
2079
2228
  show({ label: t("doctor.disk"), result: free > 2 * 1024 ** 3 ? "ok" : "warn", detail: `${dataDir()} ${color.muted(icon.dot)} ${t("doctor.free", { size: bytes(free) })}` });
2080
2229
  } catch (e) {
2081
2230
  show({ label: t("doctor.disk"), result: "error", detail: e.message });
2082
2231
  }
2083
- const ff = ffmpegPath2;
2084
- if (!ff || !fs12.existsSync(ff))
2085
- show({ label: "ffmpeg", result: "error", detail: t("doctor.noFfmpeg") });
2086
- else {
2232
+ const ff = await findFfmpeg(cacheDir());
2233
+ if (!ff) {
2234
+ const canDownload = !!FFMPEG_PINNED[`${process.platform}-${process.arch}`];
2235
+ show({ label: "ffmpeg", result: canDownload ? "warn" : "error", detail: canDownload ? t("doctor.ffmpegLater") : t("doctor.noFfmpeg") });
2236
+ } else {
2087
2237
  const r = spawnSync2(ff, ["-hide_banner", "-version"], { encoding: "utf8", timeout: 15000 });
2088
2238
  const v = /ffmpeg version (\S+)/.exec(r.stdout || "")?.[1];
2089
2239
  show({ label: "ffmpeg", result: v ? "ok" : "error", detail: v || t("doctor.noFfmpeg") });
@@ -2117,21 +2267,21 @@ async function doctor(args) {
2117
2267
  }
2118
2268
 
2119
2269
  // packages/hypeframe/src/cli/commands/history.ts
2120
- import fs13 from "node:fs";
2121
- import path9 from "node:path";
2270
+ import fs14 from "node:fs";
2271
+ import path11 from "node:path";
2122
2272
  function readHistory(hours = 24) {
2123
2273
  const root = renderDir();
2124
2274
  const since = Date.now() - hours * 3600000;
2125
2275
  const out = [];
2126
- for (const name of fs13.readdirSync(root)) {
2276
+ for (const name of fs14.readdirSync(root)) {
2127
2277
  if (!JOB_ID.test(name))
2128
2278
  continue;
2129
2279
  try {
2130
- const j = JSON.parse(fs13.readFileSync(path9.join(root, name, "status.json"), "utf8"));
2280
+ const j = JSON.parse(fs14.readFileSync(path11.join(root, name, "status.json"), "utf8"));
2131
2281
  if ((j.diperbarui || j.dibuat) < since)
2132
2282
  continue;
2133
- const f = j.hasilBerkas ? path9.join(root, name, j.hasilBerkas) : null;
2134
- out.push({ job: j, file: f && fs13.existsSync(f) ? f : null });
2283
+ const f = j.hasilBerkas ? path11.join(root, name, j.hasilBerkas) : null;
2284
+ out.push({ job: j, file: f && fs14.existsSync(f) ? f : null });
2135
2285
  } catch {}
2136
2286
  }
2137
2287
  return out.sort((a, b) => (b.job.diperbarui || 0) - (a.job.diperbarui || 0));
@@ -2158,30 +2308,30 @@ function history() {
2158
2308
 
2159
2309
  // packages/hypeframe/src/cli/commands/maintenance.ts
2160
2310
  import { spawnSync as spawnSync3 } from "node:child_process";
2161
- import fs14 from "node:fs";
2311
+ import fs15 from "node:fs";
2162
2312
  import os4 from "node:os";
2163
- import path10 from "node:path";
2313
+ import path12 from "node:path";
2164
2314
  async function clean() {
2165
2315
  if (runningPid()) {
2166
2316
  log.warn(t("clean.running"));
2167
2317
  return;
2168
2318
  }
2169
- const targets = [path10.join(cacheDir(), "chrome"), path10.join(cacheDir(), "halaman"), path10.join(logDir(), "hypeframe.log.1")];
2170
- for (const job of fs14.readdirSync(renderDir())) {
2319
+ const targets = [path12.join(cacheDir(), "chrome"), path12.join(cacheDir(), "halaman"), path12.join(logDir(), "hypeframe.log.1")];
2320
+ for (const job of fs15.readdirSync(renderDir())) {
2171
2321
  if (!JOB_ID.test(job))
2172
2322
  continue;
2173
2323
  try {
2174
- const s = JSON.parse(fs14.readFileSync(path10.join(renderDir(), job, "status.json"), "utf8")).status;
2324
+ const s = JSON.parse(fs15.readFileSync(path12.join(renderDir(), job, "status.json"), "utf8")).status;
2175
2325
  if (s === "gagal" || s === "batal" || s === "unggah")
2176
- targets.push(path10.join(renderDir(), job));
2326
+ targets.push(path12.join(renderDir(), job));
2177
2327
  } catch {
2178
- targets.push(path10.join(renderDir(), job));
2328
+ targets.push(path12.join(renderDir(), job));
2179
2329
  }
2180
2330
  }
2181
2331
  let freed = 0;
2182
2332
  for (const p of targets) {
2183
2333
  freed += await sizeOf(p);
2184
- fs14.rmSync(p, { recursive: true, force: true });
2334
+ fs15.rmSync(p, { recursive: true, force: true });
2185
2335
  }
2186
2336
  log.ok(t("clean.done", { size: bytes(freed) }));
2187
2337
  }
@@ -2190,7 +2340,7 @@ function report() {
2190
2340
  const a = readAccount();
2191
2341
  let recent = "";
2192
2342
  try {
2193
- recent = fs14.readFileSync(path10.join(logDir(), "hypeframe.log"), "utf8").split(`
2343
+ recent = fs15.readFileSync(path12.join(logDir(), "hypeframe.log"), "utf8").split(`
2194
2344
  `).slice(-400).join(`
2195
2345
  `);
2196
2346
  } catch {
@@ -2199,7 +2349,7 @@ function report() {
2199
2349
  const lines = [
2200
2350
  `hypeframe ${VERSION}`,
2201
2351
  `created ${new Date().toISOString()}`,
2202
- `node ${process.versions.node} · ${process.platform} ${os4.release()} ${process.arch} · ${os4.cpus()[0]?.model ?? "?"} ×${os4.cpus().length} · ${bytes(os4.totalmem())} RAM`,
2352
+ `${runtimeLabel()} · ${process.platform} ${os4.release()} ${process.arch} · ${os4.cpus()[0]?.model ?? "?"} ×${os4.cpus().length} · ${bytes(os4.totalmem())} RAM`,
2203
2353
  `gateway ${s.gateway}`,
2204
2354
  `web ${s.web}`,
2205
2355
  `gpu ${s.gpu}`,
@@ -2211,25 +2361,26 @@ function report() {
2211
2361
  recent
2212
2362
  ];
2213
2363
  const stamp = new Date().toISOString().slice(0, 19).replace(/[-:T]/g, "");
2214
- const file = path10.join(dataDir(), `laporan-${stamp}.txt`);
2215
- fs14.writeFileSync(file, mask(lines.join(`
2364
+ const file = path12.join(dataDir(), `laporan-${stamp}.txt`);
2365
+ fs15.writeFileSync(file, mask(lines.join(`
2216
2366
  `)), { mode: 384 });
2217
2367
  log.ok(t("report.done", { file }));
2218
2368
  log.detail(t("report.hint"));
2219
2369
  return file;
2220
2370
  }
2221
2371
  function update() {
2222
- if (!installedScript()) {
2372
+ if (!launchCommand()) {
2223
2373
  log.info(t("update.npx"));
2224
2374
  log.detail("npx hypeframe@latest");
2225
2375
  return;
2226
2376
  }
2227
2377
  log.info(t("update.running"));
2228
- const r = spawnSync3("npm", ["i", "-g", "hypeframe@latest"], { stdio: "inherit", shell: process.platform === "win32" });
2378
+ const win = process.platform === "win32";
2379
+ const r = isStandalone() ? win ? spawnSync3("powershell.exe", ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${INSTALL_URL}.ps1 | iex`], { stdio: "inherit" }) : spawnSync3("bash", ["-c", `curl -fsSL ${INSTALL_URL} | bash`], { stdio: "inherit" }) : spawnSync3("npm", ["i", "-g", "hypeframe@latest"], { stdio: "inherit", shell: win });
2229
2380
  if (r.status === 0)
2230
2381
  log.ok(t("update.done"));
2231
2382
  else
2232
- log.error(t("update.failed"));
2383
+ log.error(isStandalone() ? t("update.failedStandalone") : t("update.failed"));
2233
2384
  }
2234
2385
  function openWeb(args) {
2235
2386
  const { web } = resolveSettings(args.flags);
@@ -2240,13 +2391,13 @@ function openWeb(args) {
2240
2391
  }
2241
2392
 
2242
2393
  // packages/hypeframe/src/cli/commands/status.ts
2243
- import fs15 from "node:fs";
2244
- import path11 from "node:path";
2394
+ import fs16 from "node:fs";
2395
+ import path13 from "node:path";
2245
2396
  function statusRows(args) {
2246
2397
  const s = resolveSettings(args?.flags);
2247
2398
  const a = readAccount();
2248
2399
  const pid = runningPid();
2249
- const chrome = findChrome() || fs15.existsSync(path11.join(cacheDir(), "chrome"));
2400
+ const chrome = findChrome() || fs16.existsSync(path13.join(cacheDir(), "chrome"));
2250
2401
  const recent = readHistory();
2251
2402
  const k = (key) => color.muted(t(key));
2252
2403
  return [
@@ -2255,7 +2406,7 @@ function statusRows(args) {
2255
2406
  [k("status.device"), `${s.name} ${color.muted(`(${osName()})`)}`],
2256
2407
  [k("status.render"), `${chrome ? "Chrome" : color.muted(t("status.chromeLater"))} ${color.muted(icon.dot)} ${t("status.gpu")} ${s.gpu ? color.ok(t("status.on")) : color.muted(t("status.off"))}`],
2257
2408
  [k("status.recent"), recent.length ? t("status.recentCount", { n: recent.length }) : color.muted("-")],
2258
- [k("status.version"), `${VERSION} ${color.muted(icon.dot)} Node ${process.versions.node}`]
2409
+ [k("status.version"), `${VERSION} ${color.muted(icon.dot)} ${runtimeLabel()}`]
2259
2410
  ];
2260
2411
  }
2261
2412
  function status(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypeframe",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Local engine for HypeFrame Web: code clips, video renders and (soon) AI agents run on your own machine; the web is just the view.",
5
5
  "keywords": [
6
6
  "hypeframe",