Open source CapCut alternative.
TypeScript
feat(site): a session with no page reads and rasters media [rebuild]
David Le0338ac31b87f
diff --git a/.github/workflows/deploy-cut-worker.yml b/.github/workflows/deploy-cut-worker.ymlindex 82ac4936..c69c5ae8 100644--- a/.github/workflows/deploy-cut-worker.yml+++ b/.github/workflows/deploy-cut-worker.yml@@ -11,6 +11,11 @@ on:branches: [main]paths:- site/src/cut/worker/**+ # The worker bundles the editor's own library for headless runs, so a+ # change to the drawing, decoding or effects code ships in this image.+ - site/src/cut/lib/**+ - site/packages/effects-kit/**+ - site/scripts/fetch-cut-fonts.mjs- site/src/cut/server/exportPipeline.ts- site/src/cut/server/hlsLadder.ts- site/src/cut/server/urlDownload.tsdiff --git a/site/package-lock.json b/site/package-lock.jsonindex 797546da..ee5d12c4 100644--- a/site/package-lock.json+++ b/site/package-lock.json@@ -28,6 +28,7 @@"@google/genai": "^2.6.0","@mdx-js/loader": "^3.1.1","@mdx-js/react": "^3.1.1",+ "@mediabunny/server": "^1.54.0","@mediapipe/tasks-vision": "^1.0.1","@next/mdx": "^16.2.6","@posthog/react": "^1.10.3",@@ -48,6 +49,7 @@"lucide-react": "^1.23.0","mediabunny": "^1.51.0","next": "16.2.6",+ "node-web-audio-api": "^2.2.0","openai": "^6.39.0","pg": "^8.20.0","posthog-js": "^1.407.1",@@ -2432,6 +2434,30 @@"node": "^18.18.0 || ^20.9.0 || >=21.1.0"}},+ "node_modules/@fidm/asn1": {+ "version": "1.0.4",+ "resolved": "https://registry.npmjs.org/@fidm/asn1/-/asn1-1.0.4.tgz",+ "integrity": "sha512-esd1jyNvRb2HVaQGq2Gg8Z0kbQPXzV9Tq5Z14KNIov6KfFD6PTaRIO8UpcsYiTNzOqJpmyzWgVTrUwFV3UF4TQ==",+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">= 8"+ }+ },+ "node_modules/@fidm/x509": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/@fidm/x509/-/x509-1.2.1.tgz",+ "integrity": "sha512-nwc2iesjyc9hkuzcrMCBXQRn653XuAUKorfWM8PZyJawiy1QzLj4vahwzaI25+pfpwOLvMzbJ0uKpWLDNmo16w==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@fidm/asn1": "^1.0.4",+ "tweetnacl": "^1.0.1"+ },+ "engines": {+ "node": ">= 8"+ }+ },"node_modules/@floating-ui/core": {"version": "1.7.5","resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.5.tgz",@@ -3172,6 +3198,13 @@"devOptional": true,"license": "MIT"},+ "node_modules/@leichtgewicht/ip-codec": {+ "version": "2.0.5",+ "resolved": "https://registry.npmjs.org/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz",+ "integrity": "sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==",+ "license": "MIT",+ "optional": true+ },"node_modules/@mdx-js/loader": {"version": "3.1.1","resolved": "https://registry.npmjs.org/@mdx-js/loader/-/loader-3.1.1.tgz",@@ -3266,12 +3299,52 @@"react": ">=16"}},+ "node_modules/@mediabunny/prores": {+ "version": "1.54.0",+ "resolved": "https://registry.npmjs.org/@mediabunny/prores/-/prores-1.54.0.tgz",+ "integrity": "sha512-XhxdPiHriMJVqDRwcZF2geGoHKyQtMd7SIrpB0PNtFw+UQR1yNQYqlRu+kQu72PdlEoAWus0/HOaQBD9TZctmw==",+ "license": "MPL-2.0",+ "dependencies": {+ "turbores": "^1.2.2"+ },+ "funding": {+ "type": "individual",+ "url": "https://github.com/sponsors/Vanilagy"+ },+ "peerDependencies": {+ "mediabunny": "^1.49.0"+ }+ },+ "node_modules/@mediabunny/server": {+ "version": "1.54.0",+ "resolved": "https://registry.npmjs.org/@mediabunny/server/-/server-1.54.0.tgz",+ "integrity": "sha512-AI1b4TL25Y2Ri2d18GxEMFWithVE1k6LQgDiXpiESkK3TvxK8b5sNOG7xKaRaEMFkJ/lFT1bzVI3q1nv31muPA==",+ "license": "MPL-2.0",+ "dependencies": {+ "@mediabunny/prores": "^1.54.0",+ "node-av": "^6.0.0"+ },+ "funding": {+ "type": "individual",+ "url": "https://github.com/sponsors/Vanilagy"+ },+ "peerDependencies": {+ "mediabunny": "^1.45.0"+ }+ },"node_modules/@mediapipe/tasks-vision": {"version": "1.0.1","resolved": "https://registry.npmjs.org/@mediapipe/tasks-vision/-/tasks-vision-1.0.1.tgz","integrity": "sha512-rvRE2FmAZ6ZxKSw7wq+e+jQDpN3t1B/tD2mJz9SmAzb1msoDkd4dMoE4wAh8Z30Um0PQwLiHr9QtomhmXk3aUQ==","license": "Apache-2.0"},+ "node_modules/@minhducsun2002/leb128": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/@minhducsun2002/leb128/-/leb128-1.0.0.tgz",+ "integrity": "sha512-eFrYUPDVHeuwWHluTG1kwNQUEUcFjVKYwPkU8z9DR1JH3AW7JtJsG9cRVGmwz809kKtGfwGJj58juCZxEvnI/g==",+ "license": "MIT",+ "optional": true+ },"node_modules/@mistralai/mistralai": {"version": "2.2.6","resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-2.2.6.tgz",@@ -3919,6 +3992,175 @@"win32"]},+ "node_modules/@peculiar/asn1-cms": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-cms/-/asn1-cms-2.9.0.tgz",+ "integrity": "sha512-VKQz6sJYgSxtGaK6UdnNBUx7hmSdg0K331qrEWh5qxpQsyZGWBjxbq05AJ2bTWWjd7d+nJIxFzwvsR5T7DWC/A==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "@peculiar/asn1-x509-attr": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-csr": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-csr/-/asn1-csr-2.9.0.tgz",+ "integrity": "sha512-SbxRzHiWnRdiDuiiji/RLsJxu2au4hmSZSKK7GQOgNr2BVvheAlFQST9qqzRchUcZ6wvcyRuPXIfYXVzLoZ/5g==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-ecc": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-ecc/-/asn1-ecc-2.9.0.tgz",+ "integrity": "sha512-vNspHtTd9h6e8c2lMW+B/VHEUD+HRFV0fj/Gvz7SaJbwiecA8dxd96UTFPYI1PR8k7qwjjW9AFEyI+LuyVi4Kw==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-pfx": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pfx/-/asn1-pfx-2.9.0.tgz",+ "integrity": "sha512-A6bX+gZr69U38Pg1mWvPrM1eRba6L6kLR8iVG+bJtKj3qSv2rSNmlXLtej7ZOkEWt6xL6PiJD73uFEdQI3BXCg==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-cms": "^2.9.0",+ "@peculiar/asn1-pkcs8": "^2.9.0",+ "@peculiar/asn1-rsa": "^2.9.0",+ "@peculiar/asn1-schema": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-pkcs8": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs8/-/asn1-pkcs8-2.9.0.tgz",+ "integrity": "sha512-1JH4FliKQ3trkMD17X+bKGsph5TsiM+AiiqnVKr1wxA/GoUSDHiWG/zROzLAbDIA7eclBCjQsp8hrBEJk7LRUQ==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-pkcs9": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-pkcs9/-/asn1-pkcs9-2.9.0.tgz",+ "integrity": "sha512-igArY6bpCI6tOPm2EU9QPrXuKq2s1iraLCTym4UlooYdzcRDIPCRUN9TAEcqZ5rZhA+HiPdFKTbDP9vneN/tsg==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-cms": "^2.9.0",+ "@peculiar/asn1-pfx": "^2.9.0",+ "@peculiar/asn1-pkcs8": "^2.9.0",+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "@peculiar/asn1-x509-attr": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-rsa": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-rsa/-/asn1-rsa-2.9.0.tgz",+ "integrity": "sha512-vOD7Q4UmQWhlMYuWJawS2sD+/JcPKJNtyQuFZx09r+KFhm5/HxfGak63y/m56cpBjmb5k6PeRlQf1fvLQAieUA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-schema": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-schema/-/asn1-schema-2.9.0.tgz",+ "integrity": "sha512-AKvPMOM7LfK0uFe1m7o7+veOa8xQGPqsqOrKi3QKgCElzwjGp39mbhr2g7mt/v/mXQHiIvJmDj5cJS173x8Q9Q==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/utils": "^2.0.2",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-x509": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509/-/asn1-x509-2.9.0.tgz",+ "integrity": "sha512-b9Na83rhRFQBd5CuMmuEqokYhmyWUbG7mNZl/thGhBwLpCdiZ85TZ3WFhF7OVgOekC5uKhLk4C3HKtdiScCMdQ==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/utils": "^2.0.2",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/asn1-x509-attr": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/@peculiar/asn1-x509-attr/-/asn1-x509-attr-2.9.0.tgz",+ "integrity": "sha512-f+u+EyGjfPvPzvr0+rlh/TFEO7LWt84mEwQynCUYr4F6urf/8s6+ESJ23qfSn1aamkZR6AuBNaC62iEsGvp0+w==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-schema": "^2.9.0",+ "@peculiar/asn1-x509": "^2.9.0",+ "asn1js": "^3.0.10",+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/utils": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/@peculiar/utils/-/utils-2.0.3.tgz",+ "integrity": "sha512-+oL3HPFRIZ1St2K50lWCXiioIgSoxzz7R1J3uF6neO2yl1sgmpgY6XXJH4BdpoDkMWznQTeYF6oWNDZLCdQ4eQ==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^2.8.1"+ }+ },+ "node_modules/@peculiar/x509": {+ "version": "1.14.3",+ "resolved": "https://registry.npmjs.org/@peculiar/x509/-/x509-1.14.3.tgz",+ "integrity": "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@peculiar/asn1-cms": "^2.6.0",+ "@peculiar/asn1-csr": "^2.6.0",+ "@peculiar/asn1-ecc": "^2.6.0",+ "@peculiar/asn1-pkcs9": "^2.6.0",+ "@peculiar/asn1-rsa": "^2.6.0",+ "@peculiar/asn1-schema": "^2.6.0",+ "@peculiar/asn1-x509": "^2.6.0",+ "pvtsutils": "^1.3.6",+ "reflect-metadata": "^0.2.2",+ "tslib": "^2.8.1",+ "tsyringe": "^4.10.0"+ },+ "engines": {+ "node": ">=20.0.0"+ }+ },"node_modules/@posthog/browser-common": {"version": "0.2.0","resolved": "https://registry.npmjs.org/@posthog/browser-common/-/browser-common-0.2.0.tgz",@@ -4479,6 +4721,19 @@"url": "https://opencollective.com/immer"}},+ "node_modules/@rollup/rollup-linux-x64-gnu": {+ "version": "4.62.1",+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.1.tgz",+ "integrity": "sha512-nVQGk/jStQc2V4rrkI+vPD2J+85boKqS4R4nOdPhc3eWw0kyW/b+AYRGoH8qo057XSVqaTx13AliH5qPeLTtgQ==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ]+ },"node_modules/@rtsao/scc": {"version": "1.1.0","resolved": "https://registry.npmjs.org/@rtsao/scc/-/scc-1.1.0.tgz",@@ -4505,6 +4760,154 @@"url": "https://ko-fi.com/killymxi"}},+ "node_modules/@seydx/node-av-darwin-arm64": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-darwin-arm64/-/node-av-darwin-arm64-6.1.1.tgz",+ "integrity": "sha512-hJ07HDFwz96MI/EY1V89/jVWXMfn/xb/32vocNhAeqnvBRMZio+hDz8lQloGynqv8iow5y9mPb7fOuzt5cW1+w==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-darwin-x64": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-darwin-x64/-/node-av-darwin-x64-6.1.1.tgz",+ "integrity": "sha512-7sfIEA/KkEMPMbfLlU9pGy34vE5iOpWryBFK87jDXeqLo4hB5p5qx2IDKcKfD6WBzEMk5FJScZz4rlT3J546Og==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-linux-arm64": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-linux-arm64/-/node-av-linux-arm64-6.1.1.tgz",+ "integrity": "sha512-E5LopQ+LaTGdjmnk3KYsrKF1qRQHT22xVGijUdAcvbScfLTJz2RuJoevKT53cuNupR1gdmRmvnmq+kac4TkDRA==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-linux-x64": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-linux-x64/-/node-av-linux-x64-6.1.1.tgz",+ "integrity": "sha512-2HkBkMUSmA+1sP0PN7eFSkNJhbejgJDCXx0w0ZMRlTLqF+snz5ptf/gl/tQye9yER6I4OGW/7WVL5Y2PVneNCA==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-win32-arm64-mingw": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-win32-arm64-mingw/-/node-av-win32-arm64-mingw-6.1.1.tgz",+ "integrity": "sha512-inhihhVGetTgpYaUQHfeTbG/PdBzYHqBRz79U/83C/64FHw7+sKQF125B7Hfle7tnTX3w7LoJQ+RxsoAP2RWgw==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-win32-arm64-msvc": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-win32-arm64-msvc/-/node-av-win32-arm64-msvc-6.1.1.tgz",+ "integrity": "sha512-gESbRZhCkldciGV+e08PhgJ3Do2PnL1ZY8ZIIDTjutCZdw+lgZigvZGq8jQ+TnsV6Djf1pdcKx3Z2VGnIGId5Q==",+ "cpu": [+ "arm64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-win32-x64-mingw": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-win32-x64-mingw/-/node-av-win32-x64-mingw-6.1.1.tgz",+ "integrity": "sha512-DqdNMsGTMcmg/y+DwHu+slFdP5VluCFNrefhUoq7mobu2kKk0i3LBN9xz2NdeG15jKB+DCeqFmt0r5iMGymOKA==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@seydx/node-av-win32-x64-msvc": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@seydx/node-av-win32-x64-msvc/-/node-av-win32-x64-msvc-6.1.1.tgz",+ "integrity": "sha512-GLjjoOYTqh1rvTzawgBMVKgY+8OIXMyrgD1eIqKLy3L6rWJhGvsbY+kUy15XbatGTFwStTlHK9ovTi2Xj/+9lQ==",+ "cpu": [+ "x64"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"+ }+ },+ "node_modules/@shinyoshiaki/binary-data": {+ "version": "0.6.1",+ "resolved": "https://registry.npmjs.org/@shinyoshiaki/binary-data/-/binary-data-0.6.1.tgz",+ "integrity": "sha512-7HDb/fQAop2bCmvDIzU5+69i+UJaFgIVp99h1VzK1mpg1JwSODOkjbqD7ilTYnqlnadF8C4XjpwpepxDsGY6+w==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "generate-function": "^2.3.1",+ "is-plain-object": "^2.0.3"+ },+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/@shinyoshiaki/jspack": {+ "version": "0.0.6",+ "resolved": "https://registry.npmjs.org/@shinyoshiaki/jspack/-/jspack-0.0.6.tgz",+ "integrity": "sha512-SdsNhLjQh4onBlyPrn4ia1Pdx5bXT88G/LIEpOYAjx2u4xeY/m/HB5yHqlkJB1uQR3Zw4R3hBWLj46STRAN0rg==",+ "optional": true+ },"node_modules/@sindresorhus/merge-streams": {"version": "4.0.0","resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-4.0.0.tgz",@@ -6039,6 +6442,13 @@"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"}},+ "node_modules/aes-js": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz",+ "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==",+ "license": "MIT",+ "optional": true+ },"node_modules/agent-base": {"version": "7.1.4","resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz",@@ -6324,6 +6734,21 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/asn1js": {+ "version": "3.0.10",+ "resolved": "https://registry.npmjs.org/asn1js/-/asn1js-3.0.10.tgz",+ "integrity": "sha512-S2s3aOytiKdFRdulw2qPE51MzjzVOisppcVv7jVFR+Kw0kxwvFrDcYA0h7Ndqbmj0HkMIXYWaoj7fli8kgx1eg==",+ "license": "BSD-3-Clause",+ "optional": true,+ "dependencies": {+ "pvtsutils": "^1.3.6",+ "pvutils": "^1.1.5",+ "tslib": "^2.8.1"+ },+ "engines": {+ "node": ">=12.0.0"+ }+ },"node_modules/ast-types": {"version": "0.16.1","resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.16.1.tgz",@@ -6641,6 +7066,12 @@"node": "*"}},+ "node_modules/bluebird": {+ "version": "3.7.2",+ "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",+ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",+ "license": "MIT"+ },"node_modules/body-parser": {"version": "2.2.2","resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz",@@ -6759,6 +7190,31 @@"node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"}},+ "node_modules/buffer": {+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",+ "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/feross"+ },+ {+ "type": "patreon",+ "url": "https://www.patreon.com/feross"+ },+ {+ "type": "consulting",+ "url": "https://feross.org/support"+ }+ ],+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "base64-js": "^1.3.1",+ "ieee754": "^1.2.1"+ }+ },"node_modules/buffer-equal-constant-time": {"version": "1.0.1","resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",@@ -6907,6 +7363,12 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/caller": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/caller/-/caller-1.1.0.tgz",+ "integrity": "sha512-n+21IZC3j06YpCWaxmUy5AnVqhmCIM2bQtqQyy00HJlmStRt6kwDX5F9Z97pqwAB+G/tgSz6q/kUBbNyQzIubw==",+ "license": "MIT"+ },"node_modules/callsites": {"version": "3.1.0","resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",@@ -7343,6 +7805,12 @@"url": "https://opencollective.com/core-js"}},+ "node_modules/core-util-is": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",+ "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==",+ "license": "MIT"+ },"node_modules/cors": {"version": "2.8.6","resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",@@ -7943,6 +8411,19 @@"node": ">=0.3.1"}},+ "node_modules/dns-packet": {+ "version": "5.6.1",+ "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz",+ "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@leichtgewicht/ip-codec": "^2.0.1"+ },+ "engines": {+ "node": ">=6"+ }+ },"node_modules/doctrine": {"version": "2.1.0","resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",@@ -8106,6 +8587,15 @@"node": ">= 0.4"}},+ "node_modules/duplexer2": {+ "version": "0.1.4",+ "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz",+ "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "readable-stream": "^2.0.2"+ }+ },"node_modules/ecdsa-sig-formatter": {"version": "1.0.11","resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",@@ -10387,6 +10877,27 @@"url": "https://opencollective.com/express"}},+ "node_modules/ieee754": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",+ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/feross"+ },+ {+ "type": "patreon",+ "url": "https://www.patreon.com/feross"+ },+ {+ "type": "consulting",+ "url": "https://feross.org/support"+ }+ ],+ "license": "BSD-3-Clause",+ "optional": true+ },"node_modules/ignore": {"version": "5.3.2","resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz",@@ -10444,6 +10955,13 @@"integrity": "sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==","license": "MIT"},+ "node_modules/int64-buffer": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/int64-buffer/-/int64-buffer-1.1.0.tgz",+ "integrity": "sha512-94smTCQOvigN4d/2R/YDjz8YVG0Sufvv2aAh8P5m42gwhCsDAJqnbNOrxJsrADuAFAA69Q/ptGzxvNcNuIJcvw==",+ "license": "MIT",+ "optional": true+ },"node_modules/internal-slot": {"version": "1.1.0","resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz",@@ -10468,6 +10986,13 @@"node": ">=12"}},+ "node_modules/ip": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz",+ "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==",+ "license": "MIT",+ "optional": true+ },"node_modules/ip-address": {"version": "10.2.0","resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.2.0.tgz",@@ -10899,6 +11424,19 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/is-plain-object": {+ "version": "2.0.4",+ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",+ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "isobject": "^3.0.1"+ },+ "engines": {+ "node": ">=0.10.0"+ }+ },"node_modules/is-promise": {"version": "4.0.0","resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",@@ -11121,6 +11659,16 @@"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==","license": "ISC"},+ "node_modules/isobject": {+ "version": "3.0.1",+ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",+ "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">=0.10.0"+ }+ },"node_modules/iterator.prototype": {"version": "1.1.5","resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.5.tgz",@@ -12773,6 +13321,13 @@"node": ">=16 || 14 >=14.17"}},+ "node_modules/mp4box": {+ "version": "0.5.4",+ "resolved": "https://registry.npmjs.org/mp4box/-/mp4box-0.5.4.tgz",+ "integrity": "sha512-GcCH0fySxBurJtvr0dfhz0IxHZjc1RP+F+I8xw+LIwkU1a+7HJx8NCDiww1I5u4Hz6g4eR1JlGADEGJ9r4lSfA==",+ "license": "BSD-3-Clause",+ "optional": true+ },"node_modules/ms": {"version": "2.1.3","resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",@@ -12836,6 +13391,20 @@"url": "https://opencollective.com/express"}},+ "node_modules/multicast-dns": {+ "version": "7.2.5",+ "resolved": "https://registry.npmjs.org/multicast-dns/-/multicast-dns-7.2.5.tgz",+ "integrity": "sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "dns-packet": "^5.2.2",+ "thunky": "^1.0.2"+ },+ "bin": {+ "multicast-dns": "cli.js"+ }+ },"node_modules/mute-stream": {"version": "3.0.0","resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-3.0.0.tgz",@@ -13025,6 +13594,27 @@"node": "^10 || ^12 || >=14"}},+ "node_modules/node-av": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/node-av/-/node-av-6.1.1.tgz",+ "integrity": "sha512-nuj2cpAelVZQ8hWJB26i9wYIPI/l+GzIAw8zbZuepFpq52khjYQ8s5S+Qi2cG1D+zjb7TYx7QqKpiZH32tqo2A==",+ "hasInstallScript": true,+ "license": "MIT",+ "dependencies": {+ "unzipper": "^0.12.5"+ },+ "optionalDependencies": {+ "@seydx/node-av-darwin-arm64": "^6.1.1",+ "@seydx/node-av-darwin-x64": "^6.1.1",+ "@seydx/node-av-linux-arm64": "^6.1.1",+ "@seydx/node-av-linux-x64": "^6.1.1",+ "@seydx/node-av-win32-arm64-mingw": "^6.1.1",+ "@seydx/node-av-win32-arm64-msvc": "^6.1.1",+ "@seydx/node-av-win32-x64-mingw": "^6.1.1",+ "@seydx/node-av-win32-x64-msvc": "^6.1.1",+ "werift": "^0.23.0"+ }+ },"node_modules/node-domexception": {"version": "1.0.0","resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",@@ -13082,12 +13672,41 @@"url": "https://opencollective.com/node-fetch"}},+ "node_modules/node-int64": {+ "version": "0.4.0",+ "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",+ "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",+ "license": "MIT"+ },"node_modules/node-releases": {"version": "2.0.44","resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.44.tgz","integrity": "sha512-5WUyunoPMsvvEhS8AxHtRzP+oA8UCkJ7YRxatWKjngndhDGLiqEVAQKWjFAiAiuL8zMRGzGSJxFnLetoa43qGQ==","license": "MIT"},+ "node_modules/node-web-audio-api": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/node-web-audio-api/-/node-web-audio-api-2.2.0.tgz",+ "integrity": "sha512-qM3dW3Z5HIz+O+++Uiia8x0OSNHcfJGUlexpCTdAkw8JlM17Ru1nV9a94wlxNRXqxT0Lr/ewwEnBXUwGMt24AA==",+ "license": "BSD-3-Clause",+ "dependencies": {+ "caller": "^1.1.0",+ "node-fetch": "^3.3.2",+ "webidl-conversions": "^8.0.1"+ },+ "engines": {+ "node": ">= 22"+ }+ },+ "node_modules/node-web-audio-api/node_modules/webidl-conversions": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",+ "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==",+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=20"+ }+ },"node_modules/normalize-path": {"version": "3.0.0","resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",@@ -14094,6 +14713,12 @@"node": ">=6"}},+ "node_modules/process-nextick-args": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",+ "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",+ "license": "MIT"+ },"node_modules/prompts": {"version": "2.4.2","resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",@@ -14221,6 +14846,26 @@],"license": "MIT"},+ "node_modules/pvtsutils": {+ "version": "1.3.6",+ "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.6.tgz",+ "integrity": "sha512-PLgQXQ6H2FWCaeRak8vvk1GW462lMxB5s3Jm673N82zI4vqtVUPuZdffdZbPDFRoU8kAhItWFtPCWiPpp4/EDg==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^2.8.1"+ }+ },+ "node_modules/pvutils": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/pvutils/-/pvutils-1.2.0.tgz",+ "integrity": "sha512-BbubeCEyTuQjVMakvJQ/Sxbc93F2pwmbsxONT/ZRrwU7Ua38d8unYTwXpTVLAKJ4BDuH9IGztCjQcd/N/39Dvg==",+ "license": "MIT",+ "optional": true,+ "engines": {+ "node": ">=16.0.0"+ }+ },"node_modules/qs": {"version": "6.15.2","resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",@@ -14505,6 +15150,33 @@}}},+ "node_modules/readable-stream": {+ "version": "2.3.8",+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz",+ "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==",+ "license": "MIT",+ "dependencies": {+ "core-util-is": "~1.0.0",+ "inherits": "~2.0.3",+ "isarray": "~1.0.0",+ "process-nextick-args": "~2.0.0",+ "safe-buffer": "~5.1.1",+ "string_decoder": "~1.1.1",+ "util-deprecate": "~1.0.1"+ }+ },+ "node_modules/readable-stream/node_modules/isarray": {+ "version": "1.0.0",+ "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",+ "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==",+ "license": "MIT"+ },+ "node_modules/readable-stream/node_modules/safe-buffer": {+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",+ "license": "MIT"+ },"node_modules/readdirp": {"version": "5.0.0","resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",@@ -14653,6 +15325,13 @@"redux": "^5.0.0"}},+ "node_modules/reflect-metadata": {+ "version": "0.2.2",+ "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz",+ "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==",+ "license": "Apache-2.0",+ "optional": true+ },"node_modules/reflect.getprototypeof": {"version": "1.0.10","resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz",@@ -15660,6 +16339,21 @@"integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==","license": "MIT"},+ "node_modules/string_decoder": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",+ "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",+ "license": "MIT",+ "dependencies": {+ "safe-buffer": "~5.1.0"+ }+ },+ "node_modules/string_decoder/node_modules/safe-buffer": {+ "version": "5.1.2",+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",+ "license": "MIT"+ },"node_modules/string-split-by": {"version": "1.0.0","resolved": "https://registry.npmjs.org/string-split-by/-/string-split-by-1.0.0.tgz",@@ -16070,6 +16764,13 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/thunky": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/thunky/-/thunky-1.1.0.tgz",+ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==",+ "license": "MIT",+ "optional": true+ },"node_modules/tiny-invariant": {"version": "1.3.3","resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz",@@ -16271,6 +16972,39 @@"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==","license": "0BSD"},+ "node_modules/tsyringe": {+ "version": "4.10.0",+ "resolved": "https://registry.npmjs.org/tsyringe/-/tsyringe-4.10.0.tgz",+ "integrity": "sha512-axr3IdNuVIxnaK5XGEUFTu3YmAQ6lllgrvqfEoR16g/HGnYY/6We4oWENtAnzK6/LpJ2ur9PAb80RBt7/U4ugw==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "tslib": "^1.9.3"+ },+ "engines": {+ "node": ">= 6.0.0"+ }+ },+ "node_modules/tsyringe/node_modules/tslib": {+ "version": "1.14.1",+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",+ "license": "0BSD",+ "optional": true+ },+ "node_modules/turbores": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/turbores/-/turbores-1.2.2.tgz",+ "integrity": "sha512-dTSKeZ6/BgBKz9T5goMS5ZMcqOiNYO1MbvresYGfWXEF5ZWK+yIZDxNjh86bRj1mnEzhtdsMOJ5GBi8b3Azcpg==",+ "license": "MPL-2.0",+ "funding": {+ "type": "individual",+ "url": "https://github.com/sponsors/Vanilagy"+ },+ "optionalDependencies": {+ "@rollup/rollup-linux-x64-gnu": "4.62.1"+ }+ },"node_modules/turndown": {"version": "7.2.4","resolved": "https://registry.npmjs.org/turndown/-/turndown-7.2.4.tgz",@@ -16294,6 +17028,13 @@"url": "https://github.com/sponsors/Wombosvideo"}},+ "node_modules/tweetnacl": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz",+ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==",+ "license": "Unlicense",+ "optional": true+ },"node_modules/type-check": {"version": "0.4.0","resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",@@ -16692,6 +17433,33 @@"url": "https://github.com/sponsors/kettanaito"}},+ "node_modules/unzipper": {+ "version": "0.12.5",+ "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.12.5.tgz",+ "integrity": "sha512-tXYOi9R57Uj/2Z25SOs5RRSzq886MBQj2gY8dPL+xl/kv6s6SvByoKfAtvfVeEuhntWDgjd2o9p2lb4TVPAz0A==",+ "license": "MIT",+ "dependencies": {+ "bluebird": "~3.7.2",+ "duplexer2": "~0.1.4",+ "fs-extra": "11.3.1",+ "graceful-fs": "^4.2.2",+ "node-int64": "^0.4.0"+ }+ },+ "node_modules/unzipper/node_modules/fs-extra": {+ "version": "11.3.1",+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.1.tgz",+ "integrity": "sha512-eXvGGwZ5CL17ZSwHWd3bbgk7UUpF6IFHtP57NYYakPvHOs8GDgDe5KJI36jIJzDkJ6eJjuzRA8eBQb6SkKue0g==",+ "license": "MIT",+ "dependencies": {+ "graceful-fs": "^4.2.0",+ "jsonfile": "^6.0.1",+ "universalify": "^2.0.0"+ },+ "engines": {+ "node": ">=14.14"+ }+ },"node_modules/update-browserslist-db": {"version": "1.2.3","resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",@@ -16851,6 +17619,181 @@"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==","license": "BSD-2-Clause"},+ "node_modules/werift": {+ "version": "0.23.0",+ "resolved": "https://registry.npmjs.org/werift/-/werift-0.23.0.tgz",+ "integrity": "sha512-/WcIN5DHFG9Ri4anGOmIkp8gxBGFMWSIB/m4sfZ5CWlLfD3iMhiaAUuTBuc+KV3SY9NDmvmLtiN2uaM7k3lVzw==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@fidm/x509": "^1.2.1",+ "@minhducsun2002/leb128": "^1.0.0",+ "@noble/curves": "^1.8.1",+ "@peculiar/x509": "^1.12.3",+ "@shinyoshiaki/binary-data": "^0.6.1",+ "@shinyoshiaki/jspack": "^0.0.6",+ "aes-js": "^3.1.2",+ "buffer": "^6.0.3",+ "debug": "4.4.0",+ "fast-deep-equal": "^3.1.3",+ "int64-buffer": "1.1.0",+ "ip": "^2.0.1",+ "mp4box": "^0.5.3",+ "multicast-dns": "^7.2.5",+ "tweetnacl": "^1.0.3",+ "werift-common": "*",+ "werift-dtls": "*",+ "werift-ice": "*",+ "werift-rtp": "*",+ "werift-sctp": "*"+ },+ "engines": {+ "node": ">=16"+ }+ },+ "node_modules/werift-common": {+ "version": "0.0.3",+ "resolved": "https://registry.npmjs.org/werift-common/-/werift-common-0.0.3.tgz",+ "integrity": "sha512-ma3E4BqKTyZVLhrdfTVs2T1tg9seeUtKMRn5e64LwgrogWa62+3LAUoLBUSl1yPWhgSkXId7GmcHuWDen9IJeQ==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@shinyoshiaki/jspack": "^0.0.6",+ "debug": "^4.4.0"+ },+ "engines": {+ "node": ">=16"+ }+ },+ "node_modules/werift-dtls": {+ "version": "0.5.8",+ "resolved": "https://registry.npmjs.org/werift-dtls/-/werift-dtls-0.5.8.tgz",+ "integrity": "sha512-oH39cdCpVLqKcPZRMGQLcN+tIBixvMGqjCB9qCrH39Tu9Mmu8u2+zTzyl0Fod87EK6PNPgoNqMJt64xlSMfLnw==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@fidm/x509": "^1.2.1",+ "@noble/curves": "^1.8.1",+ "@peculiar/x509": "^1.12.3",+ "@shinyoshiaki/binary-data": "^0.6.1",+ "debug": "4.4.0",+ "tweetnacl": "^1.0.3"+ },+ "engines": {+ "node": ">=16"+ }+ },+ "node_modules/werift-dtls/node_modules/debug": {+ "version": "4.4.0",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "node_modules/werift-ice": {+ "version": "0.2.3",+ "resolved": "https://registry.npmjs.org/werift-ice/-/werift-ice-0.2.3.tgz",+ "integrity": "sha512-k000fIaw8w2D4Xv5EvW6b5h4faJx8p4D8HPuDzRiGTx6UrLv2BuvUkC60LNqxlDf9o3zh90Hx1WZoHbhuw9keA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "debug": "4.4.0",+ "multicast-dns": "^7.2.5"+ }+ },+ "node_modules/werift-ice/node_modules/debug": {+ "version": "4.4.0",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "node_modules/werift-rtp": {+ "version": "0.8.9",+ "resolved": "https://registry.npmjs.org/werift-rtp/-/werift-rtp-0.8.9.tgz",+ "integrity": "sha512-uLFOawIXw8FblIp1akfIVYFuRNtNo7csRxYypLz0t++sUNCN7sPeghVqET/c3Mq7Tg2QA3oAb15fXIIuJEp2AA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "buffer": "^6.0.3",+ "debug": "4.4.0",+ "mediabunny": "^1.45.2"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/werift-rtp/node_modules/debug": {+ "version": "4.4.0",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },+ "node_modules/werift-sctp": {+ "version": "0.0.11",+ "resolved": "https://registry.npmjs.org/werift-sctp/-/werift-sctp-0.0.11.tgz",+ "integrity": "sha512-7109yuI5U7NTEHjqjn0A8VeynytkgVaxM6lRr1Ziv0D8bPcaB8A7U/P88M7WaCpWDoELHoXiRUjQycMWStIgjQ==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "@shinyoshiaki/jspack": "^0.0.6"+ },+ "engines": {+ "node": ">=10"+ }+ },+ "node_modules/werift/node_modules/debug": {+ "version": "4.4.0",+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",+ "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",+ "license": "MIT",+ "optional": true,+ "dependencies": {+ "ms": "^2.1.3"+ },+ "engines": {+ "node": ">=6.0"+ },+ "peerDependenciesMeta": {+ "supports-color": {+ "optional": true+ }+ }+ },"node_modules/whatwg-url": {"version": "5.0.0","resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",diff --git a/site/package.json b/site/package.jsonindex a3119c38..9659509a 100644--- a/site/package.json+++ b/site/package.json@@ -12,14 +12,14 @@"build": "next build","start": "next start","lint": "eslint",- "postinstall": "prisma generate && node scripts/copy-mediapipe-assets.mjs",+ "postinstall": "prisma generate && node scripts/copy-mediapipe-assets.mjs && node scripts/fetch-cut-fonts.mjs","db:generate": "prisma generate","db:pull": "prisma db pull","prisma:dev": "dotenv -e .env.development -- npx prisma migrate dev","prisma:prod": "dotenv -e .env -- prisma db push","engine:dev": "bun run src/cut/engine/main.ts","engine:build": "bash scripts/build-cut-engine.sh",- "worker:build": "bun build --target=node --minify --external=pg-native --external=skia-canvas --loader .css:text src/cut/worker/main.ts --outfile dist/cut-worker/main.js",+ "worker:build": "bun build --target=node --minify --external=pg-native --external=skia-canvas --external=mediabunny --external=@mediabunny/server --external=node-web-audio-api --loader .css:text src/cut/worker/main.ts --outfile dist/cut-worker/main.js","bench:watch": "bun run scripts/bench-watch.ts","eval:cut-chat": "bun run scripts/eval-cut-chat.ts","eval:cut-headless": "bun run scripts/eval-cut-headless.ts",@@ -45,6 +45,7 @@"@google/genai": "^2.6.0","@mdx-js/loader": "^3.1.1","@mdx-js/react": "^3.1.1",+ "@mediabunny/server": "^1.54.0","@mediapipe/tasks-vision": "^1.0.1","@next/mdx": "^16.2.6","@posthog/react": "^1.10.3",@@ -65,6 +66,7 @@"lucide-react": "^1.23.0","mediabunny": "^1.51.0","next": "16.2.6",+ "node-web-audio-api": "^2.2.0","openai": "^6.39.0","pg": "^8.20.0","posthog-js": "^1.407.1",diff --git a/site/packages/effects-kit/src/cutout.ts b/site/packages/effects-kit/src/cutout.tsindex 685d48b8..f84dad6a 100644--- a/site/packages/effects-kit/src/cutout.ts+++ b/site/packages/effects-kit/src/cutout.ts@@ -5,6 +5,8 @@* shapes pixels, so any host with a canvas can reuse it.*/+import { kitCanvas } from "./surface";+/** Die-cut outline radius as a share of the sticker's long side. */export const OUTLINE_SHARE = 0.03;@@ -281,9 +283,7 @@ export function keepLargestSubject(/** A blank canvas and its 2D context, set up for pixel reads. */export function canvasOf(w: number, h: number): [HTMLCanvasElement, CanvasRenderingContext2D] {- const c = document.createElement("canvas");- c.width = w;- c.height = h;+ const c = kitCanvas(w, h);return [c, c.getContext("2d", { willReadFrequently: true })!];}diff --git a/site/packages/effects-kit/src/looks.ts b/site/packages/effects-kit/src/looks.tsindex 88c9f581..91189fbf 100644--- a/site/packages/effects-kit/src/looks.ts+++ b/site/packages/effects-kit/src/looks.ts@@ -1,5 +1,7 @@/** Preset filter looks: a named color/effect treatment baked over a clip's* picture in both preview and export. */+import { kitCanvas } from "./surface";+export type LookStyle =| "vintage"| "vhs"@@ -151,14 +153,11 @@ const GRAIN_SIZE = 1.6;let grainTiles: HTMLCanvasElement[] | null = null;export function grainTile(tick: number): HTMLCanvasElement | null {- if (typeof document === "undefined") return null;if (!grainTiles) {grainTiles = [];const side = Math.round(GRAIN_TILE / GRAIN_SIZE);for (let n = 0; n < GRAIN_COUNT; n++) {- const small = document.createElement("canvas");- small.width = side;- small.height = side;+ const small = kitCanvas(side, side);const sctx = small.getContext("2d");if (!sctx) return null;const img = sctx.createImageData(side, side);@@ -176,9 +175,7 @@ export function grainTile(tick: number): HTMLCanvasElement | null {img.data[i + 3] = 255;}sctx.putImageData(img, 0, 0);- const c = document.createElement("canvas");- c.width = GRAIN_TILE;- c.height = GRAIN_TILE;+ const c = kitCanvas(GRAIN_TILE, GRAIN_TILE);const ctx = c.getContext("2d");if (!ctx) return null;ctx.imageSmoothingEnabled = true;@@ -196,6 +193,7 @@ let grainUrl: string | null = null;* with CSS — the preview stage and the effect tiles. Overlay-blend it and set* the layer's opacity to the effect's grain amount. */export function grainTileUrl(): string | null {+ if (typeof document === "undefined") return null; // a CSS surface, page onlyif (grainUrl) return grainUrl;const tile = grainTile(0);if (!tile) return null;diff --git a/site/packages/effects-kit/src/surface.ts b/site/packages/effects-kit/src/surface.tsnew file mode 100644index 00000000..1208e61b--- /dev/null+++ b/site/packages/effects-kit/src/surface.ts@@ -0,0 +1,21 @@+/**+ * The drawing surface the kit paints on.+ *+ * Most of the kit takes its canvas from the host's RenderEnv. The pieces that+ * make their own — the cutout matting, the grain tiles — allocate it here, so+ * the same code paints in a tab and in a render worker, which puts a server+ * canvas on `OffscreenCanvas`.+ */+export function kitCanvas(w: number, h: number): HTMLCanvasElement {+ const width = Math.max(1, Math.round(w));+ const height = Math.max(1, Math.round(h));+ if (typeof document !== "undefined") {+ const c = document.createElement("canvas");+ c.width = width;+ c.height = height;+ return c;+ }+ if (typeof OffscreenCanvas !== "undefined")+ return new OffscreenCanvas(width, height) as unknown as HTMLCanvasElement;+ throw new Error("No canvas surface is available here.");+}diff --git a/site/src/cut/lib/cutout.ts b/site/src/cut/lib/cutout.tsindex 48083f8f..625520e6 100644--- a/site/src/cut/lib/cutout.ts+++ b/site/src/cut/lib/cutout.ts@@ -21,6 +21,7 @@ import {withOutline,} from "@donkeycut/effects-kit";import { hostedPost } from "./hosted";+import { decodeRasterImage, rasterCanvasToDataUrl, rasterCanvasToPng } from "./raster";import { geminiModelRoles } from "@/lib/inference/gemini-models";const WASM_BASE = "/mediapipe/wasm";@@ -102,26 +103,6 @@ export function personSegmenter(): Promise<Segmenter | null> {return segmenterOnce;}-async function decode(blob: Blob): Promise<HTMLImageElement | null> {- return new Promise((resolve) => {- const url = URL.createObjectURL(blob);- const img = new Image();- img.onload = () => {- URL.revokeObjectURL(url);- resolve(img);- };- img.onerror = () => {- URL.revokeObjectURL(url);- resolve(null);- };- img.src = url;- });-}--function pngOf(canvas: HTMLCanvasElement): Promise<Blob | null> {- return new Promise((resolve) => canvas.toBlob(resolve, "image/png"));-}-/*** Segment one frame and return the subject as an alpha canvas at the mask's* own (small) resolution — white where the person is, transparent elsewhere.@@ -168,12 +149,12 @@ export function segmentSubjectAlpha(/** Person matting, fully on-device. Null when no person registers (callers* fall through to the hosted path). */export async function personCutout(blob: Blob): Promise<HTMLCanvasElement | null> {- const [img, segmenter] = await Promise.all([decode(blob), personSegmenter()]);+ const [img, segmenter] = await Promise.all([decodeRasterImage(blob), personSegmenter()]);if (!img || !segmenter) return null;- const w = img.naturalWidth;- const h = img.naturalHeight;+ const w = img.width;+ const h = img.height;const [canvas, ctx] = canvasOf(w, h);- ctx.drawImage(img, 0, 0);+ ctx.drawImage(img.source, 0, 0);const result = segmenter.segment(canvas);try {const mask = result.confidenceMasks?.[0];@@ -197,17 +178,17 @@ export async function personCutout(blob: Blob): Promise<HTMLCanvasElement | null/** Hosted matting for general subjects: the vision model returns segmentation* masks; the largest subject's mask becomes the alpha. */export async function hostedCutout(blob: Blob): Promise<HTMLCanvasElement | null> {- const img = await decode(blob);+ const img = await decodeRasterImage(blob);if (!img) return null;- const w = img.naturalWidth;- const h = img.naturalHeight;+ const w = img.width;+ const h = img.height;const [canvas, ctx] = canvasOf(w, h);- ctx.drawImage(img, 0, 0);+ ctx.drawImage(img.source, 0, 0);// Fit the upload to the inline budget; masks come back box-relative, so a// downscaled request still masks the full-size picture.const [small, sctx] = canvasOf(Math.min(1024, w), Math.round((Math.min(1024, w) * h) / w));- sctx.drawImage(img, 0, 0, small.width, small.height);- const dataUrl = small.toDataURL("image/jpeg", 0.85);+ sctx.drawImage(img.source, 0, 0, small.width, small.height);+ const dataUrl = await rasterCanvasToDataUrl(small, "image/jpeg", 0.85);const res = await hostedPost("/api/inference/responses", {donkeyProvider: "gemini",model: geminiModelRoles.chat,@@ -242,11 +223,11 @@ export async function hostedCutout(blob: Blob): Promise<HTMLCanvasElement | nullreturn area(b.box_2d!) - area(a.box_2d!);})[0];if (!best) return null;- const maskImg = await decode(await (await fetch(best.mask!)).blob().catch(() => new Blob()));+ const maskImg = await decodeRasterImage(await (await fetch(best.mask!)).blob().catch(() => new Blob()));if (!maskImg) return null;const [y0, x0, y1, x1] = best.box_2d!.map((v) => v / 1000);const [, mctx] = canvasOf(w, h);- mctx.drawImage(maskImg, x0 * w, y0 * h, Math.max(1, (x1 - x0) * w), Math.max(1, (y1 - y0) * h));+ mctx.drawImage(maskImg.source, x0 * w, y0 * h, Math.max(1, (x1 - x0) * w), Math.max(1, (y1 - y0) * h));const maskData = mctx.getImageData(0, 0, w, h).data;const ok = applyAlpha(ctx, w, h, (i) => {const v = maskData[i * 4] / 255; // grayscale probability@@ -258,10 +239,10 @@ export async function hostedCutout(blob: Blob): Promise<HTMLCanvasElement | null/** Knock out a flat studio backdrop — the shape a generated sticker arrives* in. Null when the picture has no such backdrop. */export async function flatBackdropCutout(blob: Blob): Promise<HTMLCanvasElement | null> {- const img = await decode(blob);+ const img = await decodeRasterImage(blob);if (!img) return null;- const [canvas, ctx] = canvasOf(img.naturalWidth, img.naturalHeight);- ctx.drawImage(img, 0, 0);+ const [canvas, ctx] = canvasOf(img.width, img.height);+ ctx.drawImage(img.source, 0, 0);return removeFlatBackdrop(canvas) ? canvas : null;}@@ -294,5 +275,5 @@ export async function makeStickerCutout(// before the crop, which would otherwise frame the strays too.keepLargestSubject(cut);const cropped = cropToContent(cut);- return pngOf(opts.outline === false ? cropped : withOutline(cropped));+ return rasterCanvasToPng(opts.outline === false ? cropped : withOutline(cropped));}diff --git a/site/src/cut/lib/frameSource.ts b/site/src/cut/lib/frameSource.tsindex c3529e6c..1b3b4bd5 100644--- a/site/src/cut/lib/frameSource.ts+++ b/site/src/cut/lib/frameSource.ts@@ -23,8 +23,8 @@* capacity and the pool size move together, and that is the whole memory story.*/-import type { CanvasSink, Input, WrappedCanvas } from "mediabunny";-import { frameSink, openMedia, videoTrackOf } from "./mediaRead";+import type { Input, WrappedCanvas } from "mediabunny";+import { frameSink, openMedia, videoTrackOf, type FrameCanvasSink } from "./mediaRead";import type { MediaAsset } from "./types";/**@@ -183,7 +183,7 @@ export class FrameRing<T extends Timed> {*/export class ClipFrameSource {private input: Input | null = null;- private sink: CanvasSink | null = null;+ private sink: FrameCanvasSink | null = null;private ring = new FrameRing<WrappedCanvas>(RING);/** A still's single frame; stills never stream. */private still: SourceFrame | null = null;diff --git a/site/src/cut/lib/headless/docSession.ts b/site/src/cut/lib/headless/docSession.tsindex f8d46086..ebfb414d 100644--- a/site/src/cut/lib/headless/docSession.ts+++ b/site/src/cut/lib/headless/docSession.ts@@ -1,4 +1,5 @@import type { HeadlessSession } from "./bind";+import { syncFontAssets } from "../fontAssets";import { serializeDoc, useEditor } from "../store";import type { MediaAsset, ProjectDoc } from "../types";@@ -50,6 +51,9 @@ export async function openCloudProject(url: signed.get(a.fileName) ?? `${projectPath(s, projectId)}/media/${encodeURIComponent(a.fileName)}`,}));await useEditor.getState().openProjectDoc(projectId, doc, assets);+ // The page does this from the editor; a run has to do it before it draws,+ // or a title set in the project's own font comes out in the fallback face.+ await syncFontAssets(assets);return { projectId, version };}diff --git a/site/src/cut/lib/headless/nodeMedia.ts b/site/src/cut/lib/headless/nodeMedia.tsnew file mode 100644index 00000000..0f14282c--- /dev/null+++ b/site/src/cut/lib/headless/nodeMedia.ts@@ -0,0 +1,127 @@+import { VideoSampleSink, type InputVideoTrack, type VideoSample, type WrappedCanvas } from "mediabunny";+import { setFrameSinkFactory, type FrameCanvasSink, type FrameSize } from "../mediaRead";+import { createRasterCanvas } from "../raster";++/**+ * The media runtime a headless process needs to read what the page reads.+ *+ * Cut's media layer is mediabunny: containers parsed directly, frames off+ * WebCodecs, audio through Web Audio. Node has neither, so three things get+ * installed here and the rest of the code runs unchanged — the same silence+ * scan, the same watch sampler, the same transcription mixdown:+ *+ * decoders NodeAV, registered into mediabunny as its codec backend+ * audio AudioBuffer and OfflineAudioContext, from node-web-audio-api+ * frames a skia-backed frame sink (below)+ *+ * The frame sink is the one piece that cannot be a polyfill. mediabunny's+ * CanvasSink draws through `VideoFrame`, which Node has no equivalent of, so+ * the sink here goes the other way: decode to a sample, transform it to the+ * requested size (NodeAV does the scaling and rotation), and copy the RGBA+ * out into a server canvas. Geometry matches CanvasSink's — one dimension+ * preserves aspect, rotation from the container is applied — so a frame read+ * headless is framed exactly like the same frame read in a tab.+ */++/** A sink over one video track that hands back server canvases. */+class NodeFrameSink implements FrameCanvasSink {+ private readonly samples: VideoSampleSink;++ constructor(+ private readonly imageData: new (data: Uint8ClampedArray, w: number, h: number) => ImageData,+ track: InputVideoTrack,+ private readonly size?: FrameSize+ ) {+ this.samples = new VideoSampleSink(track);+ }++ private async wrap(sample: VideoSample): Promise<WrappedCanvas> {+ const { width, height, fit } = this.size ?? {};+ // Always a transform, even at native size: it is what bakes the+ // container's rotation into the pixels.+ const out = await sample.transform({+ ...(width !== undefined ? { width: Math.round(width) } : {}),+ ...(height !== undefined ? { height: Math.round(height) } : {}),+ ...(width !== undefined && height !== undefined ? { fit: fit ?? "fill" } : fit ? { fit } : {}),+ });+ sample.close();+ try {+ const pixels = new Uint8Array(out.allocationSize({ format: "RGBA" }));+ await out.copyTo(pixels, { format: "RGBA" });+ const image = new this.imageData(+ new Uint8ClampedArray(pixels.buffer, pixels.byteOffset, pixels.byteLength),+ out.codedWidth,+ out.codedHeight+ );+ const canvas = createRasterCanvas(out.displayWidth, out.displayHeight);+ const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;+ if (!ctx) throw new Error("Could not read a video frame.");+ if (out.codedWidth === out.displayWidth && out.codedHeight === out.displayHeight) {+ ctx.putImageData(image, 0, 0);+ } else {+ // Anamorphic footage: the coded pixels are square-stretched to the+ // display size the rest of Cut measures in.+ const coded = createRasterCanvas(out.codedWidth, out.codedHeight);+ (coded.getContext("2d") as CanvasRenderingContext2D).putImageData(image, 0, 0);+ ctx.drawImage(+ coded as CanvasImageSource,+ 0,+ 0,+ out.displayWidth,+ out.displayHeight+ );+ }+ return {+ canvas: canvas as HTMLCanvasElement,+ timestamp: out.timestamp,+ duration: out.duration,+ };+ } finally {+ out.close();+ }+ }++ async getCanvas(timestamp: number): Promise<WrappedCanvas | null> {+ const sample = await this.samples.getSample(timestamp);+ return sample ? this.wrap(sample) : null;+ }++ async *canvases(start?: number, end?: number): AsyncGenerator<WrappedCanvas, void, unknown> {+ for await (const sample of this.samples.samples(start, end)) yield await this.wrap(sample);+ }++ async *canvasesAtTimestamps(+ timestamps: Iterable<number> | AsyncIterable<number>+ ): AsyncGenerator<WrappedCanvas | null, void, unknown> {+ for await (const sample of this.samples.samplesAtTimestamps(timestamps))+ yield sample ? await this.wrap(sample) : null;+ }+}++/** Install the Node decoders, the Web Audio globals, and the server frame+ * sink. False when the native modules are missing — the process then runs+ * whatever needs no decoding. */+export async function installNodeMedia(): Promise<boolean> {+ try {+ const [server, skia, audio] = await Promise.all([+ import("@mediabunny/server"),+ import("skia-canvas"),+ import("node-web-audio-api"),+ ]);+ server.registerMediabunnyServer();++ const scope = globalThis as Record<string, unknown>;+ scope.AudioBuffer ??= audio.AudioBuffer;+ scope.OfflineAudioContext ??= audio.OfflineAudioContext;++ const imageData = skia.ImageData as unknown as new (+ data: Uint8ClampedArray,+ w: number,+ h: number+ ) => ImageData;+ setFrameSinkFactory((track, size) => new NodeFrameSink(imageData, track, size));+ return true;+ } catch {+ return false;+ }+}diff --git a/site/src/cut/lib/headless/runtime.ts b/site/src/cut/lib/headless/runtime.tsnew file mode 100644index 00000000..bd546d2f--- /dev/null+++ b/site/src/cut/lib/headless/runtime.ts@@ -0,0 +1,37 @@+import { installNodeMedia } from "./nodeMedia";+import { installHeadlessFonts } from "./nodeFonts";+import { installSkiaRaster } from "./skiaRaster";++/**+ * Everything a process without a page needs before it runs Cut's own code.+ *+ * The editor's library is written against browser primitives — canvases,+ * WebCodecs, Web Audio, loaded fonts. Those four are swapped underneath here+ * and the library then runs as written: the same silence scan,+ * the same watch sampler, the same overlay rasterizer, the same mixdown. What+ * a job can do is then what the editor can do, by construction.+ *+ * Everything here degrades on its own. A process missing a native module+ * loses that capability and keeps the rest.+ */+export interface HeadlessRuntime {+ raster: boolean;+ media: boolean;+ fonts: number;+}++let installed: Promise<HeadlessRuntime> | null = null;++export function installHeadlessRuntime(): Promise<HeadlessRuntime> {+ installed ??= (async () => {+ // Raster first: the frame sink draws into canvases the seam hands out.+ const raster = await installSkiaRaster();+ const [media, fonts] = await Promise.all([installNodeMedia(), installHeadlessFonts()]);+ return { raster, media, fonts };+ })();+ return installed;+}++/** One line for a startup log. */+export const describeRuntime = (r: HeadlessRuntime): string =>+ `raster: ${r.raster ? "skia" : "unavailable"}, media: ${r.media ? "nodeav" : "unavailable"}, fonts: ${r.fonts}`;diff --git a/site/src/cut/lib/headless/skiaRaster.ts b/site/src/cut/lib/headless/skiaRaster.tsindex 552df642..1468ea41 100644--- a/site/src/cut/lib/headless/skiaRaster.ts+++ b/site/src/cut/lib/headless/skiaRaster.ts@@ -5,13 +5,55 @@ import { setRasterFactory, type RasterImage, type RasterSurface } from "../raste// code in composite/textRender/exportClient then renders overlay PNGs the// same way the page does. The import is dynamic so the page bundle and any// process without the native module stay unaffected.+//+// The skia canvas also lands on `globalThis.OffscreenCanvas`, wrapped so it+// answers `convertToBlob`. Page code branches on that class to tell a worker+// surface from a DOM one, and a headless process is the worker case: with the+// global in place those branches take the path they were written for instead+// of reaching for a `document` that isn't there.+/** skia names its encoders by extension ("png", "jpeg"); the seam speaks MIME. */+const skiaFormat = (type: string) =>+ type.replace(/^image\//, "") as Parameters<+ import("skia-canvas").Canvas["toBuffer"]+ >[0];++/** True once a skia surface backs the seam (a worker without the native+ * module keeps the DOM factory and runs its ffmpeg-only jobs). */export async function installSkiaRaster(): Promise<boolean> {try {const skia = await import("skia-canvas");++ class ServerCanvas extends skia.Canvas {+ async convertToBlob(opts?: { type?: string; quality?: number }): Promise<Blob> {+ const type = opts?.type ?? "image/png";+ const buf = await this.toBuffer(skiaFormat(type), {+ ...(opts?.quality !== undefined ? { quality: opts.quality } : {}),+ });+ return new Blob([new Uint8Array(buf)], { type });+ }+ }+ const scope = globalThis as Record<string, unknown>;+ scope.OffscreenCanvas ??= ServerCanvas;+ // The rest of the drawing vocabulary page code expects to find lying+ // around: pixel buffers, an image class, and the decoder every cached+ // stamp and still goes through.+ scope.ImageData ??= skia.ImageData;+ scope.Image ??= skia.Image;+ scope.createImageBitmap ??= async (src: unknown) => {+ const bytes =+ src instanceof Blob+ ? Buffer.from(await src.arrayBuffer())+ : Buffer.from(await (src as InstanceType<typeof skia.Canvas>).toBuffer("png"));+ const img = await skia.loadImage(bytes);+ // ImageBitmap is disposable; skia images are collected. A no-op close+ // keeps every `bitmap.close()` in the drawing code honest.+ return Object.assign(img, { close: () => {} });+ };+setRasterFactory({createCanvas: (w, h) =>- new skia.Canvas(Math.max(1, w), Math.max(1, h)) as unknown as RasterSurface,+ new ServerCanvas(Math.max(1, w), Math.max(1, h)) as unknown as RasterSurface,decodeImage: async (blob) => {try {const img = await skia.loadImage(Buffer.from(await blob.arrayBuffer()));@@ -24,9 +66,12 @@ export async function installSkiaRaster(): Promise<boolean> {return null;}},- canvasToPngBlob: async (canvas) => {- const buf = await (canvas as unknown as InstanceType<typeof skia.Canvas>).toBuffer("png");- return new Blob([new Uint8Array(buf)], { type: "image/png" });+ canvasToBlob: async (canvas, type, quality) => {+ const buf = await (canvas as unknown as InstanceType<typeof skia.Canvas>).toBuffer(+ skiaFormat(type),+ { ...(quality !== undefined ? { quality } : {}) }+ );+ return new Blob([new Uint8Array(buf)], { type });},});return true;diff --git a/site/src/cut/lib/maskVideo.ts b/site/src/cut/lib/maskVideo.tsindex e63801cd..52ce19c2 100644--- a/site/src/cut/lib/maskVideo.ts+++ b/site/src/cut/lib/maskVideo.ts@@ -24,6 +24,7 @@ import { FrameCompositor, MISSING_FRAME } from "./composite";import { overlayPlan, trackZeroPlan } from "./framePlan";import { ClipReader, VIDEO_CODECS } from "./exportRender";import type { ExportDoc } from "./exportClient";+import { createRasterCanvas } from "./raster";import { getClipSpans } from "./store";import { frameOf, isEffectOverlay, isFullRect, isTextOverlay, rectOf, subjectMasked, type ClipSpan, type MediaAsset } from "./types";@@ -85,14 +86,10 @@ export async function renderSubjectMask(if (!codec) return null;// A small compositor: the video layers only, at mask resolution.- const compose = document.createElement("canvas");- compose.width = W;- compose.height = H;+ const compose = createRasterCanvas(W, H);const comp = new FrameCompositor(compose);- const mask = document.createElement("canvas");- mask.width = W;- mask.height = H;- const mctx = mask.getContext("2d")!;+ const mask = createRasterCanvas(W, H);+ const mctx = mask.getContext("2d") as CanvasRenderingContext2D;const spans = getClipSpans(doc.clips, doc.assets);const overlayTracks = [...new Set(doc.clips.filter((c) => c.track !== 0).map((c) => c.track))];@@ -142,7 +139,7 @@ export async function renderSubjectMask(mctx.globalCompositeOperation = "source-over";mctx.fillStyle = "#000000";mctx.fillRect(0, 0, W, H);- const alpha = segmentSubjectAlpha(segmenter, compose);+ const alpha = segmentSubjectAlpha(segmenter, compose as HTMLCanvasElement);if (alpha) mctx.drawImage(alpha, 0, 0, W, H);await video.add(i / MASK_FPS, 1 / MASK_FPS);}diff --git a/site/src/cut/lib/media.ts b/site/src/cut/lib/media.tsindex ef6456a7..4ddd5e38 100644--- a/site/src/cut/lib/media.ts+++ b/site/src/cut/lib/media.ts@@ -29,7 +29,14 @@ import {stashCloudMedia,stashUnclaimedMedia,} from "./mediaSync";-import { decodeRasterImage } from "./raster";+import {+ createRasterCanvas,+ decodeRasterImage,+ decodeRasterImageUrl,+ rasterCanvasToBlob,+ rasterCanvasToDataUrl,+ type RasterSurface,+} from "./raster";import { useEditor } from "./store";import type { AssetType, AudioClip, MediaAsset, ProjectSummary, StoredAsset, VideoClip, WatchKeepReason } from "./types";import { IMAGE_CLIP_SECONDS, mediaUrl } from "./types";@@ -611,38 +618,10 @@ export async function importFileToProject(};}-// The frame reader hands back whichever canvas kind its context has — an-// element in the DOM, an OffscreenCanvas in a worker — and these two are the-// only places that difference shows.--function canvasBlob(canvas: HTMLCanvasElement | OffscreenCanvas, type: string): Promise<Blob | null> {- if (canvas instanceof OffscreenCanvas) return canvas.convertToBlob({ type });- return new Promise((resolve) => canvas.toBlob(resolve, type));-}--async function canvasDataUrl(- canvas: HTMLCanvasElement | OffscreenCanvas,- type: string,- quality: number-): Promise<string> {- if (!(canvas instanceof OffscreenCanvas)) return canvas.toDataURL(type, quality);- const blob = await canvas.convertToBlob({ type, quality });- return new Promise((resolve, reject) => {- const reader = new FileReader();- reader.onload = () => resolve(reader.result as string);- reader.onerror = () => reject(reader.error);- reader.readAsDataURL(blob);- });-}-/** Natural pixel size of an image URL, for framing on the timeline. */-function loadImageMeta(url: string): Promise<{ width: number; height: number }> {- return new Promise((resolve) => {- const img = new Image();- img.onload = () => resolve({ width: img.naturalWidth, height: img.naturalHeight });- img.onerror = () => resolve({ width: 0, height: 0 });- img.src = url;- });+async function loadImageMeta(url: string): Promise<{ width: number; height: number }> {+ const img = await decodeRasterImageUrl(url);+ return img ? { width: img.width, height: img.height } : { width: 0, height: 0 };}/** What `importRemote` needs to register a fetchable source as an asset the@@ -939,8 +918,7 @@ export async function captureFreezeFrame(): Promise<MediaAsset> {const frame = await frameAt(sourceUrl, srcTime);if (!frame) throw new Error("Could not render the freeze frame.");- const blob = await canvasBlob(frame.canvas, "image/png");- if (!blob) throw new Error("Could not render the freeze frame.");+ const blob = await rasterCanvasToBlob(frame.canvas, "image/png");const d = new Date();const pad = (n: number) => String(n).padStart(2, "0");const fileName = `freeze-${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}-${uid().slice(0, 4)}.png`;@@ -1042,25 +1020,18 @@ const cellDims = (w: number, h: number): [number, number] =>/** Watch a still image: one downscaled frame, no time axis. */export async function makeStillFrame(sourceUrl: string): Promise<WatchFrames> {- const img = new Image();- img.crossOrigin = "anonymous";- await new Promise<void>((resolve, reject) => {- img.onload = () => resolve();- img.onerror = () => reject(new Error("Could not read the image."));- img.src = sourceUrl;- });- if (img.naturalWidth === 0 || img.naturalHeight === 0)- throw new Error("Could not read the image.");- const [w, h] = cellDims(img.naturalWidth, img.naturalHeight);- const canvas = document.createElement("canvas");- canvas.width = w;- canvas.height = h;- const ctx = canvas.getContext("2d");+ const img = await decodeRasterImageUrl(sourceUrl);+ if (!img || img.width === 0 || img.height === 0) throw new Error("Could not read the image.");+ const [w, h] = cellDims(img.width, img.height);+ const canvas = createRasterCanvas(w, h);+ const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;if (!ctx) throw new Error("Could not read the image.");ctx.imageSmoothingQuality = "high";- ctx.drawImage(img, 0, 0, w, h);+ ctx.drawImage(img.source, 0, 0, w, h);return {- frames: [{ t: 0, image: canvas.toDataURL("image/jpeg", SHEET_QUALITY), via: "first" }],+ frames: [+ { t: 0, image: await rasterCanvasToDataUrl(canvas, "image/jpeg", SHEET_QUALITY), via: "first" },+ ],candidates: 1,sceneChanges: [],coveredTo: 0,@@ -1120,7 +1091,7 @@ export async function sampleWatchFrames(// Cell canvases are held only until the selector rules on them (decisions// run one frame behind), so memory stays near the kept set, never the// candidate sweep.- const held = new Map<number, HTMLCanvasElement>();+ const held = new Map<number, RasterSurface>();const candTimes: number[] = [];const candG16: Float32Array[] = []; // per-candidate coarse grid, for cut refinementlet keptCount = 0;@@ -1131,10 +1102,10 @@ export async function sampleWatchFrames(else keptCount++;},});- const sig = document.createElement("canvas");- sig.width = SIGNATURE_SIZE;- sig.height = SIGNATURE_SIZE;- const sigCtx = sig.getContext("2d", { willReadFrequently: true });+ const sig = createRasterCanvas(SIGNATURE_SIZE, SIGNATURE_SIZE);+ const sigCtx = sig.getContext("2d", {+ willReadFrequently: true,+ }) as CanvasRenderingContext2D | null;if (!sigCtx) throw new Error("Could not sample the video.");const deadline = Date.now() + (opts.budgetMs ?? Infinity);const outOfTime = () => Date.now() > deadline;@@ -1144,7 +1115,7 @@ export async function sampleWatchFrames(.next();if (one.done || !one.value) return null;sigCtx.imageSmoothingQuality = "high";- sigCtx.drawImage(one.value.canvas, 0, 0, SIGNATURE_SIZE, SIGNATURE_SIZE);+ sigCtx.drawImage(one.value.canvas as CanvasImageSource, 0, 0, SIGNATURE_SIZE, SIGNATURE_SIZE);const data = sigCtx.getImageData(0, 0, SIGNATURE_SIZE, SIGNATURE_SIZE).data;return frameSig({ width: SIGNATURE_SIZE, height: SIGNATURE_SIZE, channels: 4, data }).g16;};@@ -1169,17 +1140,15 @@ export async function sampleWatchFrames(const next = await cells.next();if (next.done || !next.value) continue; // a moment the decoder had no frame forif (!opts.metadataOnly) {- const copy = document.createElement("canvas");- copy.width = cw;- copy.height = ch;- const cctx = copy.getContext("2d");+ const copy = createRasterCanvas(cw, ch);+ const cctx = copy.getContext("2d") as CanvasRenderingContext2D | null;if (!cctx) throw new Error("Could not sample the video.");- cctx.drawImage(next.value.canvas, 0, 0);+ cctx.drawImage(next.value.canvas as CanvasImageSource, 0, 0);held.set(candTimes.length, copy);}candTimes.push(times[i]);sigCtx.imageSmoothingQuality = "high";- sigCtx.drawImage(next.value.canvas, 0, 0, SIGNATURE_SIZE, SIGNATURE_SIZE);+ sigCtx.drawImage(next.value.canvas as CanvasImageSource, 0, 0, SIGNATURE_SIZE, SIGNATURE_SIZE);const rgb = {width: SIGNATURE_SIZE,height: SIGNATURE_SIZE,@@ -1202,7 +1171,7 @@ export async function sampleWatchFrames(const verdict = selection.decisions[idx].verdict;frames.push({t: candTimes[idx],- image: canvas ? await canvasDataUrl(canvas, "image/jpeg", SHEET_QUALITY) : "",+ image: canvas ? await rasterCanvasToDataUrl(canvas, "image/jpeg", SHEET_QUALITY) : "",via: verdict === "keep-global" ? "global": verdict === "keep-action" ? "action": verdict === "keep-settled" ? "settled"@@ -1267,18 +1236,14 @@ export async function composeSheets(): Promise<{ image: string; frames: { t: number }[] }[]> {if (cells.length === 0) return [];const images = await Promise.all(- cells.map(- (c) =>- new Promise<HTMLImageElement>((resolve, reject) => {- const img = new Image();- img.onload = () => resolve(img);- img.onerror = () => reject(new Error("Bad frame image."));- img.src = c.image;- })- )+ cells.map(async (c) => {+ const img = await decodeRasterImageUrl(c.image);+ if (!img) throw new Error("Bad frame image.");+ return img;+ }));- const cw = images[0].naturalWidth;- const ch = images[0].naturalHeight;+ const cw = images[0].width;+ const ch = images[0].height;const perSheet = SHEET_GRID * SHEET_GRID;const sheetW = 2 * SHEET_GAP + SHEET_GRID * cw + (SHEET_GRID - 1) * SHEET_GAP;const sheetH = 2 * SHEET_GAP + SHEET_GRID * ch + (SHEET_GRID - 1) * SHEET_GAP;@@ -1286,10 +1251,8 @@ export async function composeSheets(const sheets: { image: string; frames: { t: number }[] }[] = [];for (let s = 0; s < cells.length; s += perSheet) {const batch = cells.slice(s, s + perSheet);- const canvas = document.createElement("canvas");- canvas.width = sheetW;- canvas.height = sheetH;- const ctx = canvas.getContext("2d");+ const canvas = createRasterCanvas(sheetW, sheetH);+ const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;if (!ctx) throw new Error("No 2d context.");ctx.fillStyle = "#000";ctx.fillRect(0, 0, sheetW, sheetH);@@ -1299,7 +1262,7 @@ export async function composeSheets(batch.forEach((c, j) => {const x = SHEET_GAP + (j % SHEET_GRID) * (cw + SHEET_GAP);const y = SHEET_GAP + Math.floor(j / SHEET_GRID) * (ch + SHEET_GAP);- ctx.drawImage(images[s + j], x, y, cw, ch);+ ctx.drawImage(images[s + j].source, x, y, cw, ch);const label = `${round2(c.t)}s`;const w = ctx.measureText(label).width;ctx.fillStyle = "rgba(0,0,0,0.6)";@@ -1308,7 +1271,7 @@ export async function composeSheets(ctx.fillText(label, x + 9, y + ch - 6);});sheets.push({- image: await canvasDataUrl(canvas, "image/jpeg", SHEET_QUALITY),+ image: await rasterCanvasToDataUrl(canvas, "image/jpeg", SHEET_QUALITY),frames: batch.map((c) => ({ t: c.t })),});}@@ -1453,7 +1416,7 @@ async function makeThumbs(url: string, duration: number) {// keeps every index meaning what it says.const captured: (string | null)[] = [];for await (const frame of framesAt(url, times, { height: THUMB_H })) {- captured.push(frame ? await canvasDataUrl(frame.canvas, "image/jpeg", 0.92) : null);+ captured.push(frame ? await rasterCanvasToDataUrl(frame.canvas, "image/jpeg", 0.92) : null);}// Fill gaps from the nearest frame either side, so a strip is either fully// populated or empty.@@ -1588,7 +1551,7 @@ async function pumpEdgeFrames() {const { sinkFor } = await edgeReader(req.url);const frame = await sinkFor(req.height).getCanvas(Math.max(0, req.time));if (!frame) throw new Error("No frame at that time.");- src = await canvasDataUrl(frame.canvas, "image/jpeg", 0.92);+ src = await rasterCanvasToDataUrl(frame.canvas, "image/jpeg", 0.92);edgeCache.set(req.key, src);while (edgeCache.size > EDGE_CACHE_CAP) {edgeCache.delete(edgeCache.keys().next().value!);diff --git a/site/src/cut/lib/mediaRead.ts b/site/src/cut/lib/mediaRead.tsindex d4bb23ce..005f43fc 100644--- a/site/src/cut/lib/mediaRead.ts+++ b/site/src/cut/lib/mediaRead.ts@@ -149,11 +149,55 @@ export async function probeMediaFile(src: string | Blob): Promise<MediaProbe> {});}+/** What every frame reader in Cut asks of a video track: one frame at a+ * time, a span in order, or a set of moments in one pass. mediabunny's+ * CanvasSink is this in a browser; a headless process installs its own,+ * because CanvasSink draws through `VideoFrame`, which Node has no. */+export interface FrameCanvasSink {+ getCanvas(timestamp: number): Promise<WrappedCanvas | null>;+ canvases(start?: number, end?: number): AsyncGenerator<WrappedCanvas, void, unknown>;+ canvasesAtTimestamps(+ timestamps: Iterable<number> | AsyncIterable<number>+ ): AsyncGenerator<WrappedCanvas | null, void, unknown>;+}++export type FrameSinkFactory = (+ track: InputVideoTrack,+ size?: FrameSize,+ poolSize?: number+) => FrameCanvasSink;++const canvasSinkFactory: FrameSinkFactory = (track, size, poolSize) =>+ new CanvasSink(track, { ...size, ...(poolSize ? { poolSize } : {}) });++let sinkFactory: FrameSinkFactory = canvasSinkFactory;++/** Install a replacement frame reader, e.g. the skia-backed one a headless+ * process uses. Affects every later `frameSink` call. */+export function setFrameSinkFactory(f: FrameSinkFactory): void {+ sinkFactory = f;+}+/** A sink that draws this track's frames at `size`. Rotation from the file's* metadata is applied by default, so a phone clip comes back upright and no- * consumer has to know it was ever sideways. */-export function frameSink(track: InputVideoTrack, size?: FrameSize, poolSize?: number): CanvasSink {- return new CanvasSink(track, { ...size, ...(poolSize ? { poolSize } : {}) });+ * consumer has to know it was ever sideways. A requested size is capped at the+ * track's own: a sampler asking 480 wide of a 360-wide file pays for the extra+ * pixels and learns nothing from them. */+export function frameSink(+ track: InputVideoTrack,+ size?: FrameSize,+ poolSize?: number+): FrameCanvasSink {+ return sinkFactory(track, capToTrack(track, size), poolSize);+}++function capToTrack(track: InputVideoTrack, size?: FrameSize): FrameSize | undefined {+ if (!size) return size;+ return {+ ...size,+ ...(size.width !== undefined ? { width: Math.min(size.width, track.displayWidth) } : {}),+ ...(size.height !== undefined ? { height: Math.min(size.height, track.displayHeight) } : {}),+ };}/**diff --git a/site/src/cut/lib/pi/serverDeps.ts b/site/src/cut/lib/pi/serverDeps.tsindex 9966ebff..44fe050b 100644--- a/site/src/cut/lib/pi/serverDeps.ts+++ b/site/src/cut/lib/pi/serverDeps.ts@@ -1,7 +1,7 @@import { geminiModelRoles } from "@/lib/inference/gemini-models";import { AI_SKILL_INDEX, AI_SKILLS } from "@/cut/server/ai/catalog";import { buildAiContext } from "../aiContext";-import { BROWSER_MEDIA_TOOLS, runAiTool, UI_TOOLS } from "../aiTools";+import { runAiTool, UI_TOOLS } from "../aiTools";import { normalizeRef } from "../assetRef";import { NO_CREDITS_MESSAGE } from "../generate";import { hostedPost } from "../hosted";@@ -32,10 +32,6 @@ export function headlessDeps(session: HeadlessSession): CutAgentDeps {noEditor: true,note: "No editor page is attached to this session, so this tool had no effect. The project itself is unchanged — keep working from the editor state.",};- if (BROWSER_MEDIA_TOOLS.has(name))- throw new Error(- "This tool reads media through the editor page and is unavailable in this session. Work from the editor state and the transcript instead."- );return runAiTool(name, args);},models: {diff --git a/site/src/cut/lib/raster.ts b/site/src/cut/lib/raster.tsindex 70ddf7d7..1cc9c024 100644--- a/site/src/cut/lib/raster.ts+++ b/site/src/cut/lib/raster.ts@@ -15,7 +15,9 @@ export interface RasterFactory {createCanvas(w: number, h: number): RasterSurface;/** Decode one image blob; null when the bytes are undecodable. */decodeImage(blob: Blob): Promise<RasterImage | null>;- canvasToPngBlob(canvas: RasterSurface): Promise<Blob>;+ /** Encode a canvas. `type` is a MIME type ("image/png", "image/jpeg");+ * `quality` applies to the lossy ones. */+ canvasToBlob(canvas: RasterSurface, type: string, quality?: number): Promise<Blob>;}const domFactory: RasterFactory = {@@ -41,13 +43,14 @@ const domFactory: RasterFactory = {};img.src = objectUrl;}),- canvasToPngBlob: (canvas) => {+ canvasToBlob: (canvas, type, quality) => {if (typeof OffscreenCanvas !== "undefined" && canvas instanceof OffscreenCanvas)- return canvas.convertToBlob({ type: "image/png" });+ return canvas.convertToBlob({ type, ...(quality !== undefined ? { quality } : {}) });return new Promise((resolve, reject) =>(canvas as HTMLCanvasElement).toBlob((b) => (b ? resolve(b) : reject(new Error("Could not render the image."))),- "image/png"+ type,+ quality));},@@ -63,4 +66,56 @@ export function setRasterFactory(f: RasterFactory): void {export const createRasterCanvas = (w: number, h: number): RasterSurface => factory.createCanvas(w, h);export const decodeRasterImage = (blob: Blob): Promise<RasterImage | null> => factory.decodeImage(blob);-export const rasterCanvasToPng = (canvas: RasterSurface): Promise<Blob> => factory.canvasToPngBlob(canvas);+export const rasterCanvasToPng = (canvas: RasterSurface): Promise<Blob> =>+ factory.canvasToBlob(canvas, "image/png");+export const rasterCanvasToBlob = (+ canvas: RasterSurface,+ type: string,+ quality?: number+): Promise<Blob> => factory.canvasToBlob(canvas, type, quality);++/** Decode an image that lives at a URL. Goes through `fetch` so the same call+ * works on a page and in a process with no `Image` constructor; anonymous CORS+ * is what the DOM decoders use, so a cross-origin read shares their cache+ * entry and never taints what it draws into. */+export async function decodeRasterImageUrl(url: string): Promise<RasterImage | null> {+ try {+ const res = await fetch(url, { mode: "cors" });+ if (res.ok) return await factory.decodeImage(await res.blob());+ } catch {+ // A host that sends no CORS header refuses the fetch; the page can still+ // see the picture through an element load.+ }+ return elementImage(url);+}++/** An `<img>` read of a URL the fetch above could not have — a host that+ * serves pictures with no CORS header still answers one. Enough to measure a+ * picture with; drawing it taints the canvas, so an encode of it fails the way+ * the refused fetch would have. */+function elementImage(url: string): Promise<RasterImage | null> {+ if (typeof document === "undefined") return Promise.resolve(null);+ return new Promise((resolve) => {+ const img = new Image();+ img.onload = () =>+ resolve({ source: img, width: img.naturalWidth || 512, height: img.naturalHeight || 512 });+ img.onerror = () => resolve(null);+ img.src = url;+ });+}++/** A canvas as a data: URL. Encoding rides the same seam as the blob path, so+ * the string a headless render produces is byte-for-byte the page's. */+export async function rasterCanvasToDataUrl(+ canvas: RasterSurface,+ type: string,+ quality?: number+): Promise<string> {+ const blob = await factory.canvasToBlob(canvas, type, quality);+ const bytes = new Uint8Array(await blob.arrayBuffer());+ // Chunked so a multi-megabyte sheet doesn't blow the argument limit.+ let binary = "";+ for (let i = 0; i < bytes.length; i += 0x8000)+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));+ return `data:${type};base64,${btoa(binary)}`;+}diff --git a/site/src/cut/lib/refMedia.ts b/site/src/cut/lib/refMedia.tsindex dd9f2112..726770f3 100644--- a/site/src/cut/lib/refMedia.ts+++ b/site/src/cut/lib/refMedia.ts@@ -12,6 +12,7 @@ import {renderAudioSpanWav,} from "./media";import { frameSink, openMedia, videoTrackOf } from "./mediaRead";+import { createRasterCanvas, rasterCanvasToDataUrl } from "./raster";import { useEditor } from "./store";import { formatTime } from "./time";@@ -76,13 +77,13 @@ function splitDataUrl(dataUrl: string): InlineImage {return { data, mimeType };}-function blobToDataUrl(blob: Blob): Promise<string> {- return new Promise((resolve, reject) => {- const r = new FileReader();- r.onload = () => resolve(String(r.result));- r.onerror = () => reject(new Error("Could not read the file."));- r.readAsDataURL(blob);- });+async function blobToDataUrl(blob: Blob): Promise<string> {+ const bytes = new Uint8Array(await blob.arrayBuffer());+ // Chunked so a large picture doesn't blow the argument limit.+ let binary = "";+ for (let i = 0; i < bytes.length; i += 0x8000)+ binary += String.fromCharCode(...bytes.subarray(i, i + 0x8000));+ return `data:${blob.type || "application/octet-stream"};base64,${btoa(binary)}`;}/** Re-encode a picture down into the inline budget: scaled to the edge cap,@@ -96,10 +97,11 @@ async function encodeWithin(blob: Blob): Promise<InlineImage | null> {let out: InlineImage | null = null;for (const quality of [JPEG_Q, 0.7, 0.55]) {const scale = Math.min(1, edge / Math.max(bitmap.width, bitmap.height));- const canvas = document.createElement("canvas");- canvas.width = Math.max(1, Math.round(bitmap.width * scale));- canvas.height = Math.max(1, Math.round(bitmap.height * scale));- const ctx = canvas.getContext("2d");+ const canvas = createRasterCanvas(+ Math.max(1, Math.round(bitmap.width * scale)),+ Math.max(1, Math.round(bitmap.height * scale))+ );+ const ctx = canvas.getContext("2d") as CanvasRenderingContext2D | null;if (!ctx) return null;ctx.imageSmoothingQuality = "high";// JPEG carries no alpha, so a cut-out sheet composites onto white here@@ -107,7 +109,7 @@ async function encodeWithin(blob: Blob): Promise<InlineImage | null> {ctx.fillStyle = "#fff";ctx.fillRect(0, 0, canvas.width, canvas.height);ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);- out = splitDataUrl(canvas.toDataURL("image/jpeg", quality));+ out = splitDataUrl(await rasterCanvasToDataUrl(canvas, "image/jpeg", quality));if (out.data.length * 0.75 <= MAX_INLINE_BYTES) return out;edge = Math.round(edge * 0.75);}diff --git a/site/src/cut/lib/visualFrames.ts b/site/src/cut/lib/visualFrames.tsindex e9c41424..8ed968cb 100644--- a/site/src/cut/lib/visualFrames.ts+++ b/site/src/cut/lib/visualFrames.ts@@ -1,11 +1,14 @@"use client";+import { framesAt } from "./mediaRead";+import { rasterCanvasToDataUrl } from "./raster";import type { ClipSpan } from "./types";// Sample the cut's picture for the visual-subtitles pipeline: a handful of// small jpeg frames spread along video track 0, each stamped with its-// timeline time. Captured in the browser from the same media elements the-// preview uses, so nothing re-renders server-side.+// timeline time. Frames come off the same container reader the rest of Cut+// uses, so one pass over a file decodes every moment wanted from it and the+// sampler runs wherever the reader does.export interface CapturedFrame {at: number;@@ -20,68 +23,40 @@ const MAX_FRAMES = 20;/** Aim for one frame every ~2.5s of timeline. */const SECONDS_PER_FRAME = 2.5;-function loadVideo(url: string): Promise<HTMLVideoElement> {- return new Promise((resolve, reject) => {- const v = document.createElement("video");- v.preload = "metadata";- v.muted = true;- // Media may come from the engine on another origin; anonymous CORS keeps- // the canvas grab from tainting.- v.crossOrigin = "anonymous";- v.src = url;- v.onloadedmetadata = () => resolve(v);- v.onerror = () => reject(new Error("Could not read a video file for frame capture."));- });-}--function seekTo(v: HTMLVideoElement, t: number): Promise<void> {- return new Promise((resolve) => {- const done = () => {- v.removeEventListener("seeked", done);- clearTimeout(timer);- resolve();- };- const timer = setTimeout(done, 2000);- v.addEventListener("seeked", done);- v.currentTime = t;- });-}--/** Capture small stamped frames from one video file at the given times —- * the dailies-review sampler. Times land in file seconds; unreadable sources- * or tainted canvases yield fewer frames rather than an error. */-export async function captureVideoFrames(url: string, times: number[]): Promise<CapturedFrame[]> {- const canvas = document.createElement("canvas");- const ctx = canvas.getContext("2d");- if (!ctx) return [];- ctx.imageSmoothingQuality = "high";- let v: HTMLVideoElement;- try {- v = await loadVideo(url);- } catch {- return [];- }- const frames: CapturedFrame[] = [];+/** Read the given source times out of one file and stamp each result with the+ * timeline time it answers for. Times must ascend, which is what keeps this+ * to a single decode pass. An unreadable source yields nothing. */+async function readFrames(+ url: string,+ moments: { at: number; srcTime: number }[]+): Promise<CapturedFrame[]> {+ const out: CapturedFrame[] = [];try {- for (const at of times) {- await seekTo(v, Math.max(0, Math.min(at, Math.max(0, v.duration - 0.05))));- if (v.readyState < 2 || !v.videoWidth) continue;- const w = Math.min(FRAME_W, v.videoWidth);- const h = Math.round((w / v.videoWidth) * v.videoHeight);- canvas.width = w;- canvas.height = h;- ctx.drawImage(v, 0, 0, w, h);- try {- frames.push({ at, image: canvas.toDataURL("image/jpeg", JPEG_Q) });- } catch {- // A tainted canvas (unexpected CORS setup) — skip the frame.- }+ let i = 0;+ for await (const frame of framesAt(+ url,+ moments.map((m) => m.srcTime),+ { width: FRAME_W }+ )) {+ const moment = moments[i++];+ if (!frame) continue;+ out.push({ at: moment.at, image: await rasterCanvasToDataUrl(frame.canvas, "image/jpeg", JPEG_Q) });}- } finally {- v.removeAttribute("src");- v.load();+ } catch {+ // One unreadable source yields the frames it managed, never an error:+ // the pipeline reads what it can see and writes captions for that.}- return frames;+ return out;+}++/** Capture small stamped frames from one video file at the given times —+ * the dailies-review sampler. Times land in file seconds. */+export function captureVideoFrames(url: string, times: number[]): Promise<CapturedFrame[]> {+ const moments = [...times]+ .map((t) => Math.max(0, t))+ .sort((a, b) => a - b)+ .map((t) => ({ at: t, srcTime: t }));+ return readFrames(url, moments);}/** Capture timeline frames from video track 0's visible clips. */@@ -94,48 +69,24 @@ export async function captureTimelineFrames(spans: ClipSpan[]): Promise<CapturedMath.max(MIN_FRAMES, Math.round(total / SECONDS_PER_FRAME)));- const canvas = document.createElement("canvas");- const ctx = canvas.getContext("2d");- if (!ctx) return [];- ctx.imageSmoothingQuality = "high";+ // Group the wanted moments by source file, so each file is opened once and+ // swept in order however the clips using it are laid out.+ const bySource = new Map<string, { url: string; moments: { at: number; srcTime: number }[] }>();+ for (let i = 0; i < count; i++) {+ const at = ((i + 0.5) * total) / count;+ const span = visible.find((sp) => at >= sp.start && at < sp.start + sp.len);+ if (!span) continue;+ const speed = span.clip.speed && span.clip.speed > 0 ? span.clip.speed : 1;+ const srcTime = Math.max(0, span.clip.in + (at - span.start) * speed);+ const group = bySource.get(span.asset.url) ?? { url: span.asset.url, moments: [] };+ group.moments.push({ at, srcTime });+ bySource.set(span.asset.url, group);+ }- // One shared element per source file; spans of the same asset reuse it.- const videos = new Map<string, HTMLVideoElement>();const frames: CapturedFrame[] = [];- try {- for (let i = 0; i < count; i++) {- const at = ((i + 0.5) * total) / count;- const span = visible.find((sp) => at >= sp.start && at < sp.start + sp.len);- if (!span) continue;- let v = videos.get(span.asset.id);- if (!v) {- try {- v = await loadVideo(span.asset.url);- } catch {- continue; // one unreadable source shouldn't sink the whole capture- }- videos.set(span.asset.id, v);- }- const speed = span.clip.speed && span.clip.speed > 0 ? span.clip.speed : 1;- const srcTime = span.clip.in + (at - span.start) * speed;- await seekTo(v, Math.max(0, Math.min(srcTime, Math.max(0, v.duration - 0.05))));- if (v.readyState < 2 || !v.videoWidth) continue;- const w = Math.min(FRAME_W, v.videoWidth);- const h = Math.round((w / v.videoWidth) * v.videoHeight);- canvas.width = w;- canvas.height = h;- ctx.drawImage(v, 0, 0, w, h);- try {- frames.push({ at, image: canvas.toDataURL("image/jpeg", JPEG_Q) });- } catch {- // A tainted canvas (unexpected CORS setup) — skip the frame.- }- }- } finally {- for (const v of videos.values()) {- v.removeAttribute("src");- v.load();- }+ for (const group of bySource.values()) {+ group.moments.sort((a, b) => a.srcTime - b.srcTime);+ frames.push(...(await readFrames(group.url, group.moments)));}- return frames;+ return frames.sort((a, b) => a.at - b.at);}diff --git a/site/src/cut/server/ai/headlessTools.ts b/site/src/cut/server/ai/headlessTools.tsindex 640fc233..94a81846 100644--- a/site/src/cut/server/ai/headlessTools.ts+++ b/site/src/cut/server/ai/headlessTools.ts@@ -1,4 +1,4 @@-import { BROWSER_MEDIA_TOOLS, runAiTool, UI_TOOLS } from "../../lib/aiTools";+import { runAiTool, UI_TOOLS } from "../../lib/aiTools";import { serializeDoc, useEditor } from "../../lib/store";import type { MediaAsset, ProjectDoc } from "../../lib/types";import { readProject, writeProject } from "../projects";@@ -11,6 +11,24 @@ import { readProject, writeProject } from "../projects";// or the page's hosted sign-in (generation, library sync) answer with a// typed refusal so the model reports honestly and moves on.+/** Tools that decode or rasterize media. The engine runs on Bun with the+ * bundled tools and no canvas, decoders or Web Audio, so these answer with a+ * typed refusal here; the cloud runner installs those primitives and runs the+ * same tools for real. */+const PAGE_MEDIA_TOOLS: ReadonlySet<string> = new Set([+ "watch_video",+ "listen_audio",+ "detect_silence",+ "refine_speech_cuts",+ "freeze_frame",+ "capture_frame",+ "create_sticker",+ "subtitles_generate",+ "captions_generate",+ "subtitles_from_visuals",+ "stock_add",+]);+const PAGE_SESSION_TOOLS: ReadonlySet<string> = new Set(["generate_image","generate_video",@@ -87,7 +105,7 @@ export async function callHeadlessTool(note: "No editor page is attached to this session, so this tool had no effect. The project itself is unchanged — keep working from the editor state.",},};- if (BROWSER_MEDIA_TOOLS.has(toolName))+ if (PAGE_MEDIA_TOOLS.has(toolName))return {errorText:"This tool reads media through the editor page and is unavailable while no tab is attached. Work from the editor state instead.",diff --git a/site/src/cut/worker/Dockerfile b/site/src/cut/worker/Dockerfileindex 26354367..59185bb3 100644--- a/site/src/cut/worker/Dockerfile+++ b/site/src/cut/worker/Dockerfile@@ -30,11 +30,23 @@ RUN ffmpeg -hide_banner -encoders 2>&1 | grep -q '\blibx264\b' \|| { echo "ffmpeg has no libx264: the share HLS ladder cannot encode." >&2; exit 1; }WORKDIR /app-# The server canvas for headless overlay rasterization. Kept out of the-# bundle (worker:build marks it external) so its native binary installs for-# this platform here.-RUN npm install --no-package-lock --omit=dev skia-canvas@^3.0.8+# The browser primitives a job draws and decodes with: the server canvas, the+# Node decoders behind mediabunny, and Web Audio. All native, so they are kept+# out of the bundle (worker:build marks them external) and installed for this+# platform here. mediabunny itself comes along because its server package+# registers into it — one registry instance, one copy.+RUN npm install --no-package-lock --omit=dev \+ skia-canvas@^3.0.8 \+ mediabunny@^1.51.0 \+ @mediabunny/server@^1.54.0 \+ node-web-audio-api@^2.2.0COPY dist/cut-worker/main.js ./main.js+# The faces the editor shows, staged as files the canvas loads at startup so a+# title renders in its own font. Fetched here so the image carries them+# whatever state the build context is in; a family that will not come down+# leaves the rest staged and falls back at draw time.+COPY scripts/fetch-cut-fonts.mjs ./scripts/fetch-cut-fonts.mjs+RUN node scripts/fetch-cut-fonts.mjsENV NODE_ENV=productionENTRYPOINT ["node", "main.js"]diff --git a/site/src/cut/worker/main.ts b/site/src/cut/worker/main.tsindex de8ba127..d46405dc 100644--- a/site/src/cut/worker/main.ts+++ b/site/src/cut/worker/main.ts@@ -5,7 +5,7 @@ import { overlayKeysOf, runExportJob } from "./exportJob";import { runHlsJob } from "./hlsJob";import { runImportUrlJob } from "./importUrlJob";import { runTurnJob } from "./turnJob";-import { installSkiaRaster } from "../lib/headless/skiaRaster";+import { describeRuntime, installHeadlessRuntime } from "../lib/headless/runtime";import { deleteObjects } from "./r2";// The cloud render worker: a headless loop that claims CutRenderJob rows the@@ -235,11 +235,13 @@ async function stop(): Promise<void> {async function main(): Promise<void> {process.on("SIGTERM", () => void stop());process.on("SIGINT", () => void stop());- // The server canvas backs any turn that rasterizes overlays (an export- // kicked off headless). A worker without the module still runs every- // ffmpeg-only job.- const skia = await installSkiaRaster();- console.log(`[cut-worker] polling for jobs (max ${MAX_RUNNING} concurrent), raster: ${skia ? "skia" : "unavailable"}`);+ // Canvas, decoders, Web Audio, and fonts, standing in for the page a turn+ // would otherwise run in. A worker missing a native module loses that+ // capability and still runs every ffmpeg-only job.+ const runtime = await installHeadlessRuntime();+ console.log(+ `[cut-worker] polling for jobs (max ${MAX_RUNNING} concurrent), ${describeRuntime(runtime)}`+ );const inFlight = new Set<Promise<void>>();let idleSince: number | null = null;let failingSince: number | null = null;