Skip to content

The VS Code of video editing, built for agents.

TypeScript

Integrate TypeGPU support and update ESLint configuration

konstantin-paulus4499f2143266
diff --git a/.gitignore b/.gitignore
index 76fa9d13..cbebb7e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,8 @@ out/
# Vercel
.vercel
+
+# AI
+skills-lock.json
+.agents
+.claude
\ No newline at end of file
diff --git a/apps/web/eslint.config.js b/apps/web/eslint.config.js
index a32e8742..cffe3e68 100644
--- a/apps/web/eslint.config.js
+++ b/apps/web/eslint.config.js
@@ -6,10 +6,15 @@ import js from "@eslint/js";
import tsPlugin from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import solidPlugin from "eslint-plugin-solid";
+import typegpuPlugin from "eslint-plugin-typegpu";
import globals from "globals";
export default [
js.configs.recommended,
+ {
+ ...typegpuPlugin.configs.recommended,
+ files: ["**/*.{js,jsx,ts,tsx}"],
+ },
{
files: ["**/*.{js,jsx,ts,tsx}"],
languageOptions: {
diff --git a/apps/web/package.json b/apps/web/package.json
index a912d390..0f735c0a 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -40,6 +40,7 @@
"tailwind-merge": "^3.4.0",
"tailwindcss": "^4.1.18",
"tw-animate-css": "^1.4.0",
+ "typegpu": "^0.11.9",
"vite-plugin-solid-svg": "^0.8.1",
"zod": "^4.2.1"
},
@@ -55,8 +56,10 @@
"@webgpu/types": "^0.1.71",
"eslint": "^9.39.2",
"eslint-plugin-solid": "^0.14.5",
+ "eslint-plugin-typegpu": "^0.11.1",
"globals": "^17.0.0",
"typescript": "~5.9.3",
+ "unplugin-typegpu": "^0.11.6",
"vite": "^7.2.4",
"vite-plugin-solid": "^2.11.10"
}
diff --git a/apps/web/src/components/timeline/layers/node.tsx b/apps/web/src/components/timeline/layers/node.tsx
index 7199ab67..b25aa1ee 100644
--- a/apps/web/src/components/timeline/layers/node.tsx
+++ b/apps/web/src/components/timeline/layers/node.tsx
@@ -299,7 +299,7 @@ export function NodeLayer(props: NodeLayerProps) {
<Show
when={editing()}
fallback={
- <span class="text-xs px-0.5 shrink-0 whitespace-nowrap" onDblClick={startEditing}>
+ <span class="text-xs px-0.5 shrink-0 whitespace-nowrap text-foreground" onDblClick={startEditing}>
{name()}
</span>
}
@@ -307,7 +307,7 @@ export function NodeLayer(props: NodeLayerProps) {
<input
ref={mountNameInput}
type="text"
- class="text-xs bg-input border border-primary rounded-sm outline-none px-0.5 w-32"
+ class="text-xs bg-input border border-primary rounded-sm outline-none px-0.5 w-32 text-foreground"
value={name()}
onInput={handleNameInput}
onKeyDown={handleNameKeyDown}
diff --git a/apps/web/src/context/editor-api/api.tsx b/apps/web/src/context/editor-api/api.tsx
index a97bb8b6..c2cdd73f 100644
--- a/apps/web/src/context/editor-api/api.tsx
+++ b/apps/web/src/context/editor-api/api.tsx
@@ -58,6 +58,8 @@ export function EditorApiProvider(props: EditorApiProviderProps) {
const getEngine = () => engine;
createEffect(() => {
+ document.documentElement.dataset.fullscreen = String(isFullscreen());
+
if (!window.desktop) return;
const router = createAppRouter({ getEngine, getUser, requireAuth, setParams });
diff --git a/apps/web/src/context/editor-api/frame-triage.ts b/apps/web/src/context/editor-api/frame-triage.ts
index 18c20b55..97a2475f 100644
--- a/apps/web/src/context/editor-api/frame-triage.ts
+++ b/apps/web/src/context/editor-api/frame-triage.ts
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { VideoSampleSink } from "mediabunny";
+import tgpu, { d, std } from "typegpu";
import { assert } from "@/utils";
import type { InputVideoTrack } from "mediabunny";
@@ -37,23 +38,32 @@ const MOTION_EPS = 2 / DIM;
// per run of this many seconds: the calmest, least motion-blurred sample.
const MAX_UNSETTLED = 4;
-const SHADER = /* wgsl */ `
- @group(0) @binding(0) var samp: sampler;
- @group(0) @binding(1) var frame: texture_external;
- @group(0) @binding(2) var<storage, read_write> blocks: array<f32>;
-
- @compute @workgroup_size(8, 8)
- fn main(@builtin(global_invocation_id) id: vec3u) {
- var sum = 0.0;
- for (var y = 0u; y < ${TAPS}u; y++) {
- for (var x = 0u; x < ${TAPS}u; x++) {
- let uv = (vec2f(id.xy) + (vec2f(f32(x), f32(y)) + 0.5) / ${TAPS}.0) / ${GRID}.0;
- sum += dot(textureSampleBaseClampToEdge(frame, samp, uv).rgb, vec3f(0.2126, 0.7152, 0.0722));
- }
+const fingerprintLayout = tgpu.bindGroupLayout({
+ samp: { sampler: "filtering" },
+ frame: { externalTexture: d.textureExternal() },
+ blocks: { storage: d.arrayOf(d.f32), access: "mutable" },
+});
+
+const fingerprintFn = tgpu.computeFn({
+ workgroupSize: [8, 8],
+ in: { id: d.builtin.globalInvocationId },
+})((input) => {
+ "use gpu";
+ let sum = d.f32(0);
+ for (let y = d.u32(0); y < TAPS; y++) {
+ for (let x = d.u32(0); x < TAPS; x++) {
+ const uv = std.div(
+ std.add(d.vec2f(input.id.xy), std.div(std.add(d.vec2f(x, y), 0.5), TAPS)),
+ GRID,
+ );
+ sum += std.dot(
+ std.textureSampleBaseClampToEdge(fingerprintLayout.$.frame, fingerprintLayout.$.samp, uv).rgb,
+ d.vec3f(0.2126, 0.7152, 0.0722), // Rec. 709 luma coefficients
+ );
}
- blocks[id.y * ${GRID}u + id.x] = sum / ${TAPS * TAPS}.0;
}
-`;
+ fingerprintLayout.$.blocks[input.id.y * GRID + input.id.x] = sum / (TAPS * TAPS);
+});
/**
* Scans the track at 2fps within [from, to] (track time) and picks up to
@@ -141,40 +151,23 @@ async function createFingerprinter() {
const adapter = await navigator.gpu.requestAdapter();
assert(adapter, "Auto frame selection requires WebGPU, but no GPU adapter is available.");
const device = await adapter.requestDevice();
- const pipeline = device.createComputePipeline({
- layout: "auto",
- compute: { module: device.createShaderModule({ code: SHADER }) },
- });
- const sampler = device.createSampler({ magFilter: "linear", minFilter: "linear" });
- const blocks = device.createBuffer({ size: DIM * 4, usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC });
- const staging = device.createBuffer({ size: DIM * 4, usage: GPUBufferUsage.COPY_DST | GPUBufferUsage.MAP_READ });
+ const root = tgpu.initFromDevice({ device });
+ const pipeline = root.createComputePipeline({ compute: fingerprintFn });
+ const sampler = root.createSampler({ magFilter: "linear", minFilter: "linear" });
+ const blocks = root.createBuffer(d.arrayOf(d.f32, DIM)).$usage("storage");
return {
async fingerprint(frame: VideoFrame): Promise<Float32Array> {
- // External textures are only valid within the current task, so import,
- // encode, and submit synchronously for every frame.
- const bindGroup = device.createBindGroup({
- layout: pipeline.getBindGroupLayout(0),
- entries: [
- { binding: 0, resource: sampler },
- { binding: 1, resource: device.importExternalTexture({ source: frame }) },
- { binding: 2, resource: { buffer: blocks } },
- ],
+ const bindGroup = root.createBindGroup(fingerprintLayout, {
+ samp: sampler,
+ frame: device.importExternalTexture({ source: frame }),
+ blocks,
});
- const encoder = device.createCommandEncoder();
- const pass = encoder.beginComputePass();
- pass.setPipeline(pipeline);
- pass.setBindGroup(0, bindGroup);
- pass.dispatchWorkgroups(GRID / 8, GRID / 8);
- pass.end();
- encoder.copyBufferToBuffer(blocks, 0, staging, 0, DIM * 4);
- device.queue.submit([encoder.finish()]);
- await staging.mapAsync(GPUMapMode.READ);
- const print = new Float32Array(staging.getMappedRange().slice(0));
- staging.unmap();
- return print;
+ pipeline.with(bindGroup).dispatchWorkgroups(GRID / 8, GRID / 8);
+ return new Float32Array(await blocks.read());
},
dispose() {
+ root.destroy();
device.destroy();
},
};
diff --git a/apps/web/src/index.css b/apps/web/src/index.css
index aa5e0f53..f94db95f 100644
--- a/apps/web/src/index.css
+++ b/apps/web/src/index.css
@@ -171,7 +171,7 @@
[data-kb-theme="dark"] {
--canvas: hsla(0, 0%, 9%, 1);
--background: hsla(0, 0%, 7%, 1);
- --sidebar: hsla(0, 0%, 0%, 1);
+ --sidebar: var(--background);
--foreground: hsla(0, 0%, 95%, 1);
--card: hsla(0, 0%, 7%, 1);
--card-foreground: hsla(0, 0%, 95%, 1);
@@ -228,7 +228,7 @@
background: transparent;
}
-[data-platform="darwin"] {
+[data-platform="darwin"]:not([data-fullscreen="true"]) {
--sidebar: hsla(0, 0%, 0%, 0);
}
diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts
index 0c0c594a..3d71a021 100644
--- a/apps/web/vite.config.ts
+++ b/apps/web/vite.config.ts
@@ -6,6 +6,7 @@ import { defineConfig } from 'vite'
import solid from 'vite-plugin-solid'
import solidSvg from 'vite-plugin-solid-svg'
import tailwindcss from '@tailwindcss/vite'
+import typegpu from 'unplugin-typegpu/vite'
import { resolve } from 'path'
import pkg from '../../package.json'
@@ -14,6 +15,7 @@ export default defineConfig({
solid(),
tailwindcss(),
solidSvg({ defaultAsComponent: true }),
+ typegpu(),
],
define: {
APP_VERSION: JSON.stringify(pkg.version),
diff --git a/package-lock.json b/package-lock.json
index 5c83e7b3..681aad69 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -88,6 +88,7 @@
"tailwind-merge": "^3.4.0",
"tailwindcss": "^4.1.18",
"tw-animate-css": "^1.4.0",
+ "typegpu": "^0.11.9",
"vite-plugin-solid-svg": "^0.8.1",
"zod": "^4.2.1"
},
@@ -103,8 +104,10 @@
"@webgpu/types": "^0.1.71",
"eslint": "^9.39.2",
"eslint-plugin-solid": "^0.14.5",
+ "eslint-plugin-typegpu": "^0.11.1",
"globals": "^17.0.0",
"typescript": "~5.9.3",
+ "unplugin-typegpu": "^0.11.6",
"vite": "^7.2.4",
"vite-plugin-solid": "^2.11.10"
}
@@ -4789,6 +4792,23 @@
"dev": true,
"license": "Python-2.0"
},
+ "node_modules/ast-kit": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/ast-kit/-/ast-kit-2.2.0.tgz",
+ "integrity": "sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/parser": "^7.28.5",
+ "pathe": "^2.0.3"
+ },
+ "engines": {
+ "node": ">=20.19.0"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/sxzz"
+ }
+ },
"node_modules/async": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz",
@@ -5790,6 +5810,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/defu": {
+ "version": "6.1.7",
+ "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz",
+ "integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/deprecation": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
@@ -6326,6 +6353,19 @@
"typescript": ">=4.8.4"
}
},
+ "node_modules/eslint-plugin-typegpu": {
+ "version": "0.11.1",
+ "resolved": "https://registry.npmjs.org/eslint-plugin-typegpu/-/eslint-plugin-typegpu-0.11.1.tgz",
+ "integrity": "sha512-eFAIIlkX+cbcAXXnRqDl4lRmaWTPIjJR9j1mdKEKjaVqAtKDEyjnjXVm736eNGLOdUkryPj5ROQrXVUTADRlFg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@typescript-eslint/utils": "^8.57.2"
+ },
+ "peerDependencies": {
+ "eslint": "^9.0.0"
+ }
+ },
"node_modules/eslint-scope": {
"version": "8.4.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz",
@@ -9397,6 +9437,13 @@
"node": ">=4"
}
},
+ "node_modules/pathe": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/pe-library": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pe-library/-/pe-library-1.0.1.tgz",
@@ -10780,6 +10827,28 @@
"devOptional": true,
"license": "MIT"
},
+ "node_modules/tinyest": {
+ "version": "0.3.2",
+ "resolved": "https://registry.npmjs.org/tinyest/-/tinyest-0.3.2.tgz",
+ "integrity": "sha512-1wqSt97RLezWzeogLSVXHr+E3jpYO8jxyaK2AIdJeGoZZTCubwNxQ9IqU5gbQpJVcxlbPugPAsII+m9/gqpPSA==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
+ "node_modules/tinyest-for-wgsl": {
+ "version": "0.3.3",
+ "resolved": "https://registry.npmjs.org/tinyest-for-wgsl/-/tinyest-for-wgsl-0.3.3.tgz",
+ "integrity": "sha512-fo1oDSWVm901/2oZPZe6TsDjNPDhz/RArGSOLxon58NhkdxtD5GYovFj+gF1qrIDlxMpTxU/mPtYZNhFP2oJZw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tinyest": "~0.3.1"
+ },
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
"node_modules/tinyglobby": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
@@ -10922,6 +10991,12 @@
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
"license": "0BSD"
},
+ "node_modules/tsover-runtime": {
+ "version": "0.0.7",
+ "resolved": "https://registry.npmjs.org/tsover-runtime/-/tsover-runtime-0.0.7.tgz",
+ "integrity": "sha512-FHHwMJzZbnP23+fU1PxXljy7j0RRRosL2r1/CRUNTqfW+l7m35JsUkM615x/cAzw4GqRdXPIl3axKMj9qzpZtQ==",
+ "license": "Apache-2.0"
+ },
"node_modules/tw-animate-css": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/tw-animate-css/-/tw-animate-css-1.4.0.tgz",
@@ -10957,6 +11032,29 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/typed-binary": {
+ "version": "4.3.3",
+ "resolved": "https://registry.npmjs.org/typed-binary/-/typed-binary-4.3.3.tgz",
+ "integrity": "sha512-W2hLsSzt3k/tg38gDE4Fn/QiwcoqGuUHBc2cb3mXuH7KcYxe/GM57vzW14s2/bawB4R5knGgGq8Xb57vsaJ4Sg==",
+ "license": "MIT"
+ },
+ "node_modules/typegpu": {
+ "version": "0.11.9",
+ "resolved": "https://registry.npmjs.org/typegpu/-/typegpu-0.11.9.tgz",
+ "integrity": "sha512-AqBV6P9lW2jA7pEVDeiMD7Qoza9doPgueQbwyUyf09u4ndb9jOttHwpZ18c+BEzwLHaPlV50jw0hx5QsmVJGNg==",
+ "license": "MIT",
+ "dependencies": {
+ "tinyest": "~0.3.2",
+ "tsover-runtime": "^0.0.7",
+ "typed-binary": "^4.3.3"
+ },
+ "bin": {
+ "typegpu": "bin.mjs"
+ },
+ "engines": {
+ "node": ">=12.20.0"
+ }
+ },
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
@@ -11031,6 +11129,110 @@
"node": ">= 0.4.0"
}
},
+ "node_modules/unplugin": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-3.3.0.tgz",
+ "integrity": "sha512-qa66K+crbfyE6JK10GjvbJeRrOsuC/JpbnHctfyp/i4oBTxWOzJfRZyDiOk1PtErMFRu8JhsU/wPvOdBNWe5Rg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/remapping": "^2.3.5",
+ "picomatch": "^4.0.4",
+ "webpack-virtual-modules": "^0.6.2"
+ },
+ "engines": {
+ "node": "^20.19.0 || >=22.12.0"
+ },
+ "peerDependencies": {
+ "@farmfe/core": "*",
+ "@rspack/core": "*",
+ "bun-types-no-globals": "*",
+ "esbuild": "*",
+ "rolldown": "*",
+ "rollup": "*",
+ "unloader": "*",
+ "vite": "*",
+ "webpack": "*"
+ },
+ "peerDependenciesMeta": {
+ "@farmfe/core": {
+ "optional": true
+ },
+ "@rspack/core": {
+ "optional": true
+ },
+ "bun-types-no-globals": {
+ "optional": true
+ },
+ "esbuild": {
+ "optional": true
+ },
+ "rolldown": {
+ "optional": true
+ },
+ "rollup": {
+ "optional": true
+ },
+ "unloader": {
+ "optional": true
+ },
+ "vite": {
+ "optional": true
+ },
+ "webpack": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/unplugin-typegpu": {
+ "version": "0.11.6",
+ "resolved": "https://registry.npmjs.org/unplugin-typegpu/-/unplugin-typegpu-0.11.6.tgz",
+ "integrity": "sha512-vtSqYUDOzlGkrlOTEa7wkaaz8HQdV/A7tktebBbSSxobFjEZqgeRz/GYF1KJXPCreNJ7HwBA+iEdl3xBKHHLPg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@babel/parser": "^7.29.0",
+ "@babel/traverse": "^7.29.0",
+ "@babel/types": "^7.29.0",
+ "ast-kit": "^2.2.0",
+ "defu": "^6.1.4",
+ "magic-string": "^0.30.21",
+ "pathe": "^2.0.3",
+ "picomatch": "^4.0.4",
+ "tinyest": "~0.3.1",
+ "tinyest-for-wgsl": "~0.3.2",
+ "unplugin": "^3.0.0"
+ },
+ "peerDependencies": {
+ "typegpu": "^0.11.9"
+ }
+ },
+ "node_modules/unplugin-typegpu/node_modules/picomatch": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
+ "node_modules/unplugin/node_modules/picomatch": {
+ "version": "4.0.5",
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz",
+ "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/jonschlinkert"
+ }
+ },
"node_modules/update-browserslist-db": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz",
@@ -11360,6 +11562,13 @@
"node": ">=10.13.0"
}
},
+ "node_modules/webpack-virtual-modules": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz",
+ "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/webpack/node_modules/enhanced-resolve": {
"version": "5.24.1",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.1.tgz",