mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-09-30 20:49:41 +02:00
Bring the Ark0N/codeman-gesture-control repo in-tree as the codeman-gesture-control workspace package so the hand-tracking overlay can be developed in the Codeman repo. New npm run build:gesture bundles src/codeman/entry.ts into the served gesture-codeman.js; scripts/build.mjs reruns it on every production build. Source formatted to Codeman's prettier style. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* @fileoverview Build the opt-in gesture-overlay bundle from its vendored source
|
|
* in `packages/gesture-control/` into the web bundle Codeman actually serves,
|
|
* `src/web/public/gesture/gesture-codeman.js`.
|
|
*
|
|
* The source lives in this repo (workspace package `codeman-gesture-control`,
|
|
* was the standalone `Ark0N/codeman-gesture-control` repo before it was vendored
|
|
* in). `src/codeman/entry.ts` is the Codeman *consumer* entry — it imports the
|
|
* transport-agnostic gesture core (`src/gesture/*`) and maps grab/drag/drop onto
|
|
* Codeman's real session tabs + toolbar buttons. esbuild bundles it (MediaPipe
|
|
* tasks-vision JS included) into a single ESM file; the MediaPipe wasm + model
|
|
* are loaded at runtime from same-origin `/gesture/wasm` + `/gesture/*.task`
|
|
* (fetched separately by scripts/fetch-gesture-assets.mjs), NOT bundled here.
|
|
*
|
|
* Run it after editing anything under packages/gesture-control/src/ and commit
|
|
* the regenerated bundle (the committed copy is what `npm run dev` / tsx serves,
|
|
* since the web UI ships as plain JS with no bundler). `npm run build` also runs
|
|
* this so a production build always reflects the current source.
|
|
*
|
|
* Usage: node scripts/build-gesture-bundle.mjs [--out <path>]
|
|
* --out output file (default src/web/public/gesture/gesture-codeman.js)
|
|
*
|
|
* NOT minified — matches the historical bundle and keeps it debuggable; the
|
|
* build's compress step gzips/brotlis it for production anyway.
|
|
*/
|
|
import { build } from 'esbuild';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { join, dirname, isAbsolute } from 'node:path';
|
|
|
|
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
|
const ENTRY = join(ROOT, 'packages/gesture-control/src/codeman/entry.ts');
|
|
const DEFAULT_OUT = join(ROOT, 'src/web/public/gesture/gesture-codeman.js');
|
|
|
|
const outArg = process.argv[process.argv.indexOf('--out') + 1];
|
|
const outfile =
|
|
process.argv.includes('--out') && outArg
|
|
? isAbsolute(outArg)
|
|
? outArg
|
|
: join(process.cwd(), outArg)
|
|
: DEFAULT_OUT;
|
|
|
|
await build({
|
|
entryPoints: [ENTRY],
|
|
bundle: true,
|
|
format: 'esm',
|
|
target: 'es2020',
|
|
outfile,
|
|
logLevel: 'info',
|
|
});
|
|
|
|
console.log(`[gesture] bundle built → ${outfile}`);
|