diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ba046cf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: ci + +on: + push: + branches: [main] + pull_request: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + verify: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + with: + version: 12.4.2 + - uses: actions/setup-node@v5 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm verify + - run: pnpm build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26c4684 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,30 @@ +name: release + +on: + workflow_dispatch: + inputs: + tag: + description: npm dist-tag (leave empty for latest) + required: false + default: '' + +permissions: + contents: read + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: pnpm/action-setup@v4 + with: + version: 12.4.2 + - uses: actions/setup-node@v5 + with: + node-version: 24 + cache: pnpm + - run: pnpm install --frozen-lockfile + - run: pnpm release -- --yes ${TAG:+--tag "$TAG"} + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + TAG: ${{ inputs.tag }} diff --git a/.gitignore b/.gitignore index f787ed6..11dafd6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ coverage/ .DS_Store .env .env.* +npm_release.token +*.orig +*.rej diff --git a/.node-version b/.node-version new file mode 100644 index 0000000..166aae1 --- /dev/null +++ b/.node-version @@ -0,0 +1 @@ +v24.21.0 diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 0000000..aa6d698 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,9 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 100, + "singleQuote": true, + "semi": true, + "trailingComma": "all", + "tabWidth": 2, + "ignorePatterns": ["dist", "coverage", "pnpm-lock.yaml", "packages/avatar/test/fixtures"] +} diff --git a/.oxlintrc.json b/.oxlintrc.json new file mode 100644 index 0000000..ad31a9e --- /dev/null +++ b/.oxlintrc.json @@ -0,0 +1,3 @@ +{ + "ignorePatterns": ["dist", "coverage"] +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..8b21570 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,29 @@ +# AGENTS.md — BotPixel + +Two packages: `packages/morph` (`@botharness/pixel-morph`, generic pixel morph) and `packages/avatar` (`@botharness/pixel-avatar`, the avatar generator and symbols). Both are pure TypeScript with no third-party runtime dependencies; `pixel-avatar` depends only on `pixel-morph` (for `PixelCell` and attribute escaping). + +## Commands + +```bash +pnpm install +pnpm verify # format:check, lint, typecheck, test +pnpm build +``` + +## Rules + +- Output compatibility is the contract. `packages/avatar/test/fixtures/botharness-golden.json` holds hashes of BotHarness's output for every option, preset, seed, symbol and morph. Do not regenerate it to make a change pass; a visual change to existing options needs a new `rigVersion`/`assetVersion`. +- Keep `pixel-morph` free of avatar concepts. +- Tool-to-symbol mapping belongs to the host app, not to this repo. + +## Release + +```bash +bash scripts/npm-token.sh # store the npm publish token (gitignored, mode 600) +pnpm release # build + verify, then print what it would publish +pnpm release -- --yes # publish pixel-morph, then pixel-avatar +``` + +Same flow as BotUI: a granular npm token with _Read and write_ + _Bypass 2FA_, scoped to `@botharness` (a token limited to package names cannot create new packages). To reuse BotUI's saved token, point at it: `NPM_TOKEN_FILE=../BotUI/npm_release.token pnpm release -- --yes`. + +In CI, the `release` workflow (manual, Actions → release → Run workflow) does the same with the `NPM_TOKEN` repo secret. diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..911aecf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +## 0.1.0 + +- `@botharness/pixel-morph`: pixel pairing, frames, SVG markup and a `requestAnimationFrame` player, extracted from BotHarness; grid size is now an option. +- `@botharness/pixel-avatar`: the 32×32 pixel avatar generator, recipes, presets, name seeding and 16 state symbols, extracted from BotHarness with identical output, including split bangs, side and back hair with bounded eye spacing, feature height and hair length. diff --git a/README.md b/README.md index f494154..ceda75b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,72 @@ +

BotPixel: the wordmark ringed by a hundred generated pixel avatars

+ # BotPixel -Pixel art that changes shape: a pixel morph engine and a pixel avatar kit for agent products. +Pixel art that changes shape. Two small, dependency-free packages from [BotHarness](https://github.com/BotHarness/BotHarness): + +| Package | What it does | +| --------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`@botharness/pixel-morph`](packages/morph) | Morphs any set of pixels into any other: every pixel hops along a short arc to a partner and snaps to the grid. Works on plain `{ x, y, c }` cells, so it is not tied to avatars. | +| [`@botharness/pixel-avatar`](packages/avatar) | Seeded, editable 32×32 chibi pixel avatars, plus 16 state symbols (thinking, reading, editing, searching…) the avatar can morph into while an agent works. | + +```bash +npm install @botharness/pixel-avatar +``` + +```ts +import { + faceCells, + pixelAvatarSvg, + pixelSymbolCells, + seededRecipe, +} from '@botharness/pixel-avatar'; +import { morphPixels } from '@botharness/pixel-morph'; + +const recipe = seededRecipe('DeepSeekBot'); // same name, same face, everywhere +element.innerHTML = pixelAvatarSvg(recipe); + +// while a tool runs, turn the face into its symbol and back +const layer = element.querySelector('[data-avatar-pixel-morph]')!; +await morphPixels(layer, faceCells(recipe), pixelSymbolCells('search', recipe.hairColor), 800) + .finished; +``` + +

An avatar morphing into thinking, read, edit, shell and search symbols and back

+ +While an agent works, its avatar becomes the tool it is using, pixel by pixel, and turns back into a face when the turn ends. Several bots each follow their own tool: + +

Six avatars morphing into different tool symbols out of step

+ +## How the morph works + +1. **Pair.** Both pixel sets are sorted by angle around their own centroid, then matched by proportional index. Neighbours fly to neighbours, and the smaller set is reused, so pixels split or merge instead of popping. +2. **Fly.** Each pair eases (`easeInOutCubic`) from start to end, hopping by `sin(kπ)·arc`, starting in 4×4 clumps from the top rows down. +3. **Snap.** Every frame rounds to whole grid cells and switches colour halfway, so it stays pixel art the whole way. + +The engine does not know what it is drawing. Here it morphs one generated face straight into the next: + +

Generated faces morphing into one another

+ +`planPixels` and `pixelFrame` are pure functions, so frames can be rendered offline (video, GIF, canvas) as well as with `morphPixels` in the browser. + +## Custom avatars + +A recipe is plain JSON (`head`, `hair`, `eyes`, `outfit`, `accessory`, colours…). `AVATAR_PARTS`, `AVATAR_SWATCHES` and `AVATAR_PRESETS` list every option, so an app can build its own avatar editor on top; `isPixelAvatarRecipe` validates what users save. + +Hosts add their own state symbols with `symbolArtCells(rows, color)`, which draws 24×24 character art (`A` body, `H` highlight) in the built-in style. + +## Contributing + +```bash +pnpm install +pnpm verify # format, lint, typecheck, test +pnpm build +pnpm assets # re-render the README banner and GIFs (needs ffmpeg) +``` + +- New eyes, brows, mouths and symbols are character art: add rows, and the diff shows the picture. +- `packages/avatar/test/fixtures/botharness-golden.json` locks the output of every existing option and seed. Saved avatars must not change, so a PR that breaks it needs a new recipe version, not a new fixture. + +## License + +MIT diff --git a/README.zh.md b/README.zh.md new file mode 100644 index 0000000..e623344 --- /dev/null +++ b/README.zh.md @@ -0,0 +1,15 @@ +

BotPixel

+ +# BotPixel + +会变形的像素画。来自 [BotHarness](https://github.com/BotHarness/BotHarness) 的两个零依赖小包: + +- **`@botharness/pixel-morph`**:任意一组像素变成另一组像素。每个像素按极角配对,沿小弧线跳到目标,并始终对齐网格。只认 `{ x, y, c }`,不限于头像。 +- **`@botharness/pixel-avatar`**:按名字生成、可编辑的 32×32 Q 版像素头像,加上 16 个状态符号(思考、读文件、编辑、搜索……),Agent 工作时头像可以变形成这些符号。 + +

头像变形成各个工具的符号再变回来

+

多个头像各自变形成不同工具的符号

+ +用法、原理和贡献方式见 [README.md](README.md)。 + +已保存的头像不能变:`packages/avatar/test/fixtures/botharness-golden.json` 锁住了每个选项和种子的输出。 diff --git a/assets/banner.png b/assets/banner.png new file mode 100644 index 0000000..88296b8 Binary files /dev/null and b/assets/banner.png differ diff --git a/assets/morph-crew.gif b/assets/morph-crew.gif new file mode 100644 index 0000000..4e851bd Binary files /dev/null and b/assets/morph-crew.gif differ diff --git a/assets/morph-faces.gif b/assets/morph-faces.gif new file mode 100644 index 0000000..02b3b35 Binary files /dev/null and b/assets/morph-faces.gif differ diff --git a/assets/morph-turn.gif b/assets/morph-turn.gif new file mode 100644 index 0000000..2fe2ae1 Binary files /dev/null and b/assets/morph-turn.gif differ diff --git a/package.json b/package.json new file mode 100644 index 0000000..cf2f1b3 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "botpixel", + "version": "0.0.0", + "private": true, + "description": "BotPixel — a pixel morph engine and a pixel avatar kit for agent products", + "type": "module", + "scripts": { + "build": "pnpm -r --filter \"./packages/*\" build", + "typecheck": "tsc --noEmit -p packages/morph && tsc --noEmit -p packages/avatar", + "lint": "oxlint", + "lint:fix": "oxlint --fix", + "format": "oxfmt --write .", + "format:check": "oxfmt --check .", + "test": "vitest run", + "test:watch": "vitest", + "assets": "pnpm build && node scripts/readme-assets.mjs", + "verify": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm test", + "release": "node scripts/release.mjs" + }, + "devDependencies": { + "@types/node": "^22.20.2", + "oxfmt": "^0.68.0", + "oxlint": "^1.50.0", + "tsdown": "^0.20.0", + "typescript": "7.0.2", + "vitest": "^4.0.18" + }, + "engines": { + "node": ">=22" + }, + "packageManager": "pnpm@12.4.2" +} diff --git a/packages/avatar/LICENSE b/packages/avatar/LICENSE new file mode 100644 index 0000000..34b99b5 --- /dev/null +++ b/packages/avatar/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 BotHarness + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/avatar/README.md b/packages/avatar/README.md new file mode 100644 index 0000000..da032a0 --- /dev/null +++ b/packages/avatar/README.md @@ -0,0 +1,22 @@ +# @botharness/pixel-avatar + +Seeded, editable 32×32 chibi pixel avatars with state symbols they can morph into. + +```ts +import { + pixelAvatarSvg, + seededRecipe, + faceCells, + pixelSymbolCells, +} from '@botharness/pixel-avatar'; + +const recipe = seededRecipe('DeepSeekBot'); +const svg = pixelAvatarSvg(recipe); // 32×32 viewBox, crisp edges, no ids or scripts +``` + +- `seededRecipe(name)`: the same name always gives the same face. `createSeededRecipe(namespace)` makes a factory with its own set of faces. +- `AVATAR_PARTS`, `AVATAR_SWATCHES`, `AVATAR_PRESETS`, `DEFAULT_RECIPE`: everything an editor needs. +- `isPixelAvatarRecipe`, `canonicalRecipe`: validate and normalise saved recipes. +- `AVATAR_HAIR_PARTS`, `AVATAR_RANGES`, `detailedRecipe(recipe)`: optional finer controls. A recipe may carry `bangs`, `sideHair`, `backHair`, `spacing`, `height` and `hairLength`, all six or none; `detailedRecipe` derives them from the plain `hair` so an editor can start from what is on screen. Recipes without them render exactly as before. +- `faceCells`, `pixelSymbolCells`, `symbolArtCells`: pixels for [`@botharness/pixel-morph`](../morph). +- `pixelAvatarSvg(recipe, { turns, classPrefix })`: optional pre-rendered head turns, and rig layer classes (`-body`, `-head`, `-face`, `-gaze`, `-blink`) for CSS animation. diff --git a/packages/avatar/package.json b/packages/avatar/package.json new file mode 100644 index 0000000..1f50321 --- /dev/null +++ b/packages/avatar/package.json @@ -0,0 +1,49 @@ +{ + "name": "@botharness/pixel-avatar", + "version": "0.1.0", + "description": "Seeded, editable 32×32 chibi pixel avatars with state symbols that morph in and out", + "keywords": [ + "agent-ui", + "avatar", + "generator", + "identicon", + "pixel-art", + "svg" + ], + "homepage": "https://github.com/BotHarness/BotPixel", + "bugs": { + "url": "https://github.com/BotHarness/BotPixel/issues" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/BotHarness/BotPixel.git", + "directory": "packages/avatar" + }, + "files": [ + "dist" + ], + "type": "module", + "sideEffects": false, + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "tsdown", + "typecheck": "tsc --noEmit" + }, + "dependencies": { + "@botharness/pixel-morph": "workspace:^" + }, + "devDependencies": { + "tsdown": "^0.20.0", + "typescript": "^5.9.3" + } +} diff --git a/packages/avatar/src/figure.ts b/packages/avatar/src/figure.ts new file mode 100644 index 0000000..cc0b09b --- /dev/null +++ b/packages/avatar/src/figure.ts @@ -0,0 +1,926 @@ +import { escapeAttribute, type PixelCell } from '@botharness/pixel-morph'; +import type { PixelAvatarRecipe } from './recipe.js'; + +type Cell = string | undefined; +type Grid = Cell[][]; +type Mask = (x: number, y: number) => boolean; +type Point = readonly [number, number]; + +const N = 32; +const C = 16; +const INK = '#2a2230'; +const WHITE = '#ffffff'; +const BLUSH = '#f4879a'; +const MOUTH = '#7a2a38'; +const MOUTH_INSIDE = '#b8415a'; +const TONGUE = '#ef6f84'; +const GOLD = '#efb93f'; + +export type PixelGrid = Grid; +const blank = (): Grid => Array.from({ length: N }, () => Array(N).fill(undefined)); +const ellipse = + (cx: number, cy: number, rx: number, ry: number): Mask => + (x, y) => + ((x + 0.5 - cx) / rx) ** 2 + ((y + 0.5 - cy) / ry) ** 2 <= 1; + +function channels(color: string): number[] { + const n = Number.parseInt(color.slice(1), 16); + return [16, 8, 0].map((bit) => (n >> bit) & 255); +} +function hex(values: number[]): string { + return `#${values + .map((v) => + Math.min(255, Math.max(0, Math.round(v))) + .toString(16) + .padStart(2, '0'), + ) + .join('')}`; +} +const shade = (color: string, k: number) => hex(channels(color).map((v) => v * k)); +const mix = (base: string, tint: string, k: number) => { + const t = channels(tint); + return hex(channels(base).map((v, i) => v * (1 - k) + t[i]! * k)); +}; +function paint(grid: Grid, test: Mask, color: string): void { + for (let y = 0; y < N; y++) for (let x = 0; x < N; x++) if (test(x, y)) grid[y]![x] = color; +} +function sprite( + grid: Grid, + rows: readonly string[], + ox: number, + oy: number, + pal: Record, + flip = false, +): void { + rows.forEach((row, y) => + [...row].forEach((code, i) => { + const c = pal[code]; + const x = ox + (flip ? row.length - 1 - i : i); + if (c && x >= 0 && x < N && oy + y >= 0 && oy + y < N) grid[oy + y]![x] = c; + }), + ); +} +function outline(grid: Grid): Grid { + const out = grid.map((row) => [...row]); + for (let y = 0; y < N; y++) + for (let x = 0; x < N; x++) { + if (grid[y]![x]) continue; + const n = [grid[y]?.[x - 1], grid[y]?.[x + 1], grid[y - 1]?.[x], grid[y + 1]?.[x]].find( + Boolean, + ); + if (n) out[y]![x] = mix(shade(n, 0.3), INK, 0.62); + } + return out; +} +const R = 6; +const inTile: Mask = (x, y) => { + const clamp = (v: number) => Math.min(Math.max(v, R), N - R); + return (x + 0.5 - clamp(x + 0.5)) ** 2 + (y + 0.5 - clamp(y + 0.5)) ** 2 <= R * R; +}; +const clip = (g: Grid): Grid => + g.map((row, y) => row.map((c, x) => (inTile(x, y) ? c : undefined))); +function rects(grid: Grid): string { + let m = ''; + for (let y = 0; y < N; y++) { + let x = 0; + while (x < N) { + const c = grid[y]![x]; + if (!c) { + x++; + continue; + } + let w = 1; + while (x + w < N && grid[y]![x + w] === c) w++; + m += ``; + x += w; + } + } + return m; +} + +type Recipe = PixelAvatarRecipe; + +const FACE: Record Mask> = { + round: (s) => ellipse(C + s, 16.6, 8.6, 7.6), + oval: (s) => ellipse(C + s, 16.6, 8, 8), + chubby: (s) => ellipse(C + s, 17, 9.4, 7.2), + long: (s) => ellipse(C + s, 16.6, 7.8, 8.4), + square: (s) => (x, y) => { + if (y < 8 || y > 23) return false; + const dx = Math.abs(x + 0.5 - C - s); + const r = 3; + if (y <= 20) return dx <= 8.5; + return dx <= 8.5 - (y - 20) ** 1.3 * 1.1 + 0.3 - (y === 23 ? 1 : 0) || dx <= 8.5 - r; + }, + heart: (s) => taper(ellipse(C + s, 15.8, 9, 7.4), 16.5, 9, 2.6, 24.4, s), + vchin: (s) => taper(ellipse(C + s, 15.8, 8.6, 7.4), 17.5, 8.6, 2.2, 24.4, s), + diamond: (s) => + taper( + (x, y) => y >= 9 && Math.abs(x + 0.5 - C - s) <= 6.4 + (y - 9) * 0.45, + 15.8, + 9.2, + 2.6, + 24.4, + s, + ), +}; +function taper(top: Mask, from: number, width: number, end: number, chin: number, s: number): Mask { + return (x, y) => { + const cy = y + 0.5; + if (cy <= from) return top(x, y); + if (cy > chin) return false; + const t = (cy - from) / (chin - from); + return Math.abs(x + 0.5 - C - s) <= width - (width - end) * t ** 1.5; + }; +} + +const EYES: Record = { + round: ['KKKK', 'DWDD', 'IDDI', 'LIIL'], + dot: ['....', '.KK.', '.KK.', '....'], + sparkle: ['KKKK', 'DWDW', 'IDDI', 'LIWL'], + lashes: ['KKKKK', 'K.DWD', '..IDD', '..LII'], + sleepy: ['....', 'KKKK', 'IDDI', 'LIIL'], + happy: ['....', '.KK.', 'K..K', '....'], + wink: ['KKKK', 'DWDD', 'IDDI', 'LIIL'], + sharp: ['KK..', '.KKK', '.DWD', '..LI'], +}; +const CLOSED = ['....', '....', 'KKKK', '....']; +const BROWS: Record = { + soft: ['.BBB'], + thick: ['BBBB'], + raised: ['.BB.'], + angry: ['BB..', '..BB'], + worried: ['..BB', 'BB..'], + none: [], +}; +const MOUTHS: Record = { + smile: ['K..K', '.KK.'], + grin: ['KWWK', '.KK.'], + open: ['KKK', 'MTM'], + flat: ['.KK.'], + smirk: ['...K', '.KK.'], + cat: ['K.K.K', '.K.K.'], + tongue: ['KKKK', '.TT.'], + o: ['.K.', 'KMK', '.K.'], +}; + +function hair( + recipe: Recipe, + s: number, + b: number, +): { back: Mask; front: Mask; ties?: Point[]; bands?: boolean } { + const none: Mask = () => false; + const cap = ellipse(C + s, 14, 11, 10.6); + const tip = (x: number, depth = 1) => [0, depth, depth + 1, depth][(x + 40 - s) % 4]!; + const bangs = + (line: number, depth = 1, sides = 22): Mask => + (x, y) => { + if (!cap(x, Math.min(y, 13))) return false; + const dx = x + 0.5 - C - s; + if (Math.abs(dx) >= 7) return y <= sides - [0, 1, 0, 2][(x + 40 - s) % 4]!; + return y <= line + tip(x, depth) - (Math.abs(dx) > 6 ? 0 : 0); + }; + const longBack = + (bottom: number, width = 11.4): Mask => + (x, y) => + (ellipse(C + b, 14, width + 0.4, 11)(x, y) && y <= 16) || + (y > 15 && y <= bottom && Math.abs(x + 0.5 - C - b) <= width - (y > bottom - 2 ? 1 : 0)); + switch (recipe.hair) { + case 'none': + return { back: none, front: none }; + case 'buzz': + return { back: none, front: (x, y) => cap(x, y) && y <= 7 }; + case 'crop': + return { back: none, front: bangs(10, 1, 15) }; + case 'sweep': + return { + back: none, + front: (x, y) => + cap(x, Math.min(y, 13)) && + (y <= 9 + Math.max(0, (x - 6 - s) * 0.45) || (Math.abs(x + 0.5 - C - s) >= 7 && y <= 16)), + }; + case 'spiky': + return { + back: none, + front: (x, y) => + cap(x, Math.max(y, 6)) && + y >= [1, 3, 5, 3][(x + 40 - s) % 4]! && + bangs(11, 2, 15)(x, Math.max(y, 6)), + }; + case 'curly': { + const bumps: Point[] = Array.from({ length: 9 }, (_, i) => { + const a = Math.PI * (1.02 + (i * 0.96) / 8); + return [C + s + 11.5 * Math.cos(a), 14 + 11 * Math.sin(a)] as Point; + }); + return { + back: none, + front: (x, y) => + bangs(11, 1, 18)(x, y) || + (y <= 18 && bumps.some(([bx, by]) => (x + 0.5 - bx) ** 2 + (y + 0.5 - by) ** 2 <= 6.5)), + }; + } + case 'mohawk': + return { back: none, front: (x, y) => Math.abs(x + 0.5 - C - s) <= 2 && y >= 1 && y <= 9 }; + case 'bob': + return { back: longBack(25), front: bangs(13, 1, 24) }; + case 'long': + return { back: longBack(31), front: bangs(13, 1, 26) }; + case 'bun': + return { + back: none, + front: (x, y) => bangs(12, 1, 18)(x, y) || ellipse(C + s, 2.6, 4, 2.6)(x, y), + }; + case 'pigtails': + return { + back: (x, y) => + ellipse(C + s - 11.5, 21, 3, 4.4)(x, y) || ellipse(C + s + 11.5, 21, 3, 4.4)(x, y), + front: bangs(13, 1, 21), + ties: [ + [C + s - 12, 16], + [C + s + 11, 16], + ], + }; + case 'afro': + return { back: ellipse(C + b, 12, 15, 11.5), front: (x, y) => cap(x, y) && y <= 8 }; + case 'twintails': + case 'drills': + return { + back: (x, y) => + y >= 8 && + (ellipse(C + s - 13.2, 20, 2.3, 12)(x, y) || ellipse(C + s + 13.2, 20, 2.3, 12)(x, y)), + front: bangs(13, 1, 24), + ties: [ + [C + s - 13, 9], + [C + s - 12, 9], + [C + s + 11, 9], + [C + s + 12, 9], + ], + bands: recipe.hair === 'drills', + }; + case 'ponytail': + return { + back: (x, y) => ellipse(C + s + 11.5, 19, 3, 9)(x, y) && y >= 8, + front: bangs(12, 1, 20), + ties: [ + [C + s + 10, 9], + [C + s + 11, 9], + ], + }; + case 'sidetail': + return { + back: (x, y) => ellipse(C + s - 11.5, 21, 3, 8)(x, y) && y >= 12, + front: (x, y) => + cap(x, Math.min(y, 13)) && + (y <= 9 + Math.max(0, (C + s - x) * 0.45) || (Math.abs(x + 0.5 - C - s) >= 7 && y <= 18)), + ties: [ + [C + s - 13, 13], + [C + s - 12, 13], + ], + }; + case 'hime': + return { + back: longBack(31), + front: (x, y) => + cap(x, Math.min(y, 13)) && (y <= 12 || (Math.abs(x + 0.5 - C - s) >= 6.5 && y <= 24)), + }; + case 'odango': + return { + back: none, + front: (x, y) => + bangs(12, 1, 18)(x, y) || + ellipse(C + s - 8, 3.5, 3.3, 3)(x, y) || + ellipse(C + s + 8, 3.5, 3.3, 3)(x, y), + }; + case 'messy': + return { + back: none, + front: (x, y) => + cap(x, Math.max(y, 4)) && + y >= [2, 0, 3, 1, 2][(x + 50 - s) % 5]! && + bangs(11, 2, 17)(x, Math.max(y, 4)), + }; + case 'wavy': + return { + back: (x, y) => + longBack(30)(x, y) || + (y >= 16 && y <= 30 && Math.abs(x + 0.5 - C - b) <= 12.4 + Math.sin(y * 0.9) * 0.9), + front: bangs(12, 2, 25), + }; + case 'braids': + return { + back: none, + front: (x, y) => + bangs(13, 1, 20)(x, y) || + [C + s - 9.5, C + s + 9.5].some( + (bx) => + y >= 20 && y <= 30 && Math.abs(x + 0.5 - bx) <= 1.6 - ((y + 1) % 3 === 0 ? 0.6 : 0), + ), + ties: [ + [C + s - 10, 30], + [C + s + 9, 30], + ], + }; + case 'wolf': + return { + back: (x, y) => longBack(24, 11.8)(x, y) && (y < 20 || (x + y) % 3 !== 0), + front: (x, y) => + cap(x, Math.max(y, 5)) && + y >= [1, 2, 0, 2][(x + 40 - s) % 4]! && + bangs(12, 2, 21)(x, Math.max(y, 5)), + }; + case 'ahoge': + return { + back: longBack(23), + front: (x, y) => + bangs(13, 1, 22)(x, y) || + [ + [0, 0], + [1, 0], + [1, 1], + [2, 1], + [2, 2], + [1, 2], + ].some(([ax, ay]) => x === Math.round(C + s) + ax! && y === ay! + 1), + }; + } +} + +function detailedHair( + recipe: Recipe, + s: number, + b: number, +): { back: Mask; front: Mask; ties?: Point[]; bands?: boolean } { + const of = (style: Recipe['hair'] | undefined) => + hair({ ...recipe, hair: style ?? 'none' }, s, b); + const bangs = of(recipe.bangs); + const side = of(recipe.sideHair); + const back = of(recipe.backHair); + const length = (recipe.hairLength ?? 0) * 2; + const lengthen = + (mask: Mask): Mask => + (x, y) => + mask(x, y > 18 ? Math.round(y - length) : y); + return { + front: (x, y) => + y <= 7 + ? bangs.front(x, y) || back.front(x, y) + : Math.abs(x + 0.5 - C - s) < 7 + ? bangs.front(x, y) + : lengthen(side.front)(x, y), + back: length === 0 ? back.back : lengthen(back.back), + ...(back.ties ? { ties: back.ties } : {}), + ...(back.bands ? { bands: back.bands } : {}), + }; +} + +function outfit(recipe: Recipe, g: Grid, s: number): void { + const shirt = recipe.shirtColor; + const skin = recipe.skinColor; + const dark = shade(shirt, 0.75); + const light = mix(shirt, WHITE, 0.8); + const half = (y: number) => 6.5 + (y - 24) * 1.15; + const torso: Mask = (x, y) => y >= 24 && Math.abs(x + 0.5 - C - s * 0.5) <= half(y); + const dx = (x: number) => x + 0.5 - C - s * 0.5; + paint(g, (x, y) => y >= 22 && y <= 25 && Math.abs(dx(x)) <= 2.5, shade(skin, 0.85)); + paint(g, torso, shirt); + const v = + (depth: number, w: number): Mask => + (x, y) => + y >= 24 && y <= 24 + depth && Math.abs(dx(x)) <= w - (y - 24) * (w / (depth + 1)); + switch (recipe.outfit) { + case 'tee': + paint(g, v(1, 2.5), shade(skin, 0.85)); + break; + case 'shirttie': + paint(g, v(3, 4), light); + paint(g, (x, y) => y >= 24 && Math.abs(dx(x)) <= 0.5 && y <= 28, '#d22a5a'); + break; + case 'hoodie': + paint(g, (x, y) => torso(x, y) && y === 24 && Math.abs(dx(x)) >= 3, dark); + paint( + g, + (x, y) => + y >= 25 && y <= 27 && (Math.abs(dx(x) + 1.5) <= 0.5 || Math.abs(dx(x) - 1.5) <= 0.5), + WHITE, + ); + break; + case 'turtleneck': + paint(g, (x, y) => y >= 22 && y <= 25 && Math.abs(dx(x)) <= 3, shade(shirt, 0.88)); + break; + case 'sailor': + paint(g, (x, y) => torso(x, y) && y <= 26 && Math.abs(dx(x)) >= 2, '#2f3a5a'); + paint(g, (x, y) => torso(x, y) && y === 26 && Math.abs(dx(x)) >= 3, WHITE); + sprite(g, ['R.R', '.R.'], Math.round(C + s * 0.5) - 2, 26, { R: '#e2565f' }); + break; + case 'blazer': + paint(g, v(4, 4), light); + paint( + g, + (x, y) => torso(x, y) && y >= 24 && Math.abs(Math.abs(dx(x)) - (4 - (y - 24) * 0.8)) <= 0.5, + dark, + ); + sprite(g, ['G'], Math.round(C + s * 0.5), 28, { G: GOLD }); + break; + case 'overalls': + paint(g, torso, light); + paint(g, (x, y) => torso(x, y) && (y >= 27 || Math.abs(Math.abs(dx(x)) - 4) <= 0.6), shirt); + sprite(g, ['G....G'], Math.round(C + s * 0.5) - 3, 27, { G: GOLD }); + break; + case 'dress': + paint(g, (x, y) => torso(x, y) && y <= 25 && Math.abs(dx(x)) <= 4.5, WHITE); + paint( + g, + (x, y) => torso(x, y) && y === 25 && Math.abs(dx(x)) <= 4.5 && x % 2 === 0, + shade(WHITE, 0.86), + ); + sprite(g, ['RR.RR', '.RRR.', 'R...R'], Math.round(C + s * 0.5) - 2, 25, { R: '#e5566a' }); + paint(g, (x, y) => torso(x, y) && y === 29, mix(shirt, WHITE, 0.5)); + break; + case 'kimono': + paint( + g, + (x, y) => torso(x, y) && y <= 28 && Math.abs(Math.abs(dx(x)) - (y - 23.5)) <= 0.6, + WHITE, + ); + paint(g, (x, y) => torso(x, y) && y >= 28, '#e2565f'); + paint(g, (x, y) => torso(x, y) && y === 28 && x % 3 === 0, GOLD); + paint( + g, + (x, y) => torso(x, y) && y <= 27 && (x * 3 + y * 2) % 7 === 0, + mix(shirt, WHITE, 0.45), + ); + break; + case 'cardigan': + paint(g, v(5, 3.5), light); + paint(g, (x, y) => torso(x, y) && Math.abs(Math.abs(dx(x)) - 2) <= 0.5 && y >= 25, dark); + sprite(g, ['W', '.', 'W', '.', 'W'], Math.round(C + s * 0.5) - 3, 25, { W: WHITE }); + paint(g, (x, y) => torso(x, y) && y === 29, dark); + break; + case 'maid': + paint(g, (x, y) => torso(x, y), '#2f2a3a'); + paint(g, (x, y) => torso(x, y) && y >= 25 && Math.abs(dx(x)) <= 4 - (y - 25) * 0.2, WHITE); + paint(g, (x, y) => y === 24 && Math.abs(dx(x)) <= 4.5, WHITE); + sprite(g, ['RR.RR', '.RRR.'], Math.round(C + s * 0.5) - 2, 24, { R: shirt }); + break; + case 'jacket': + paint(g, v(6, 4.5), WHITE); + paint( + g, + (x, y) => torso(x, y) && Math.abs(Math.abs(dx(x)) - (4.5 - (y - 24) * 0.6)) <= 0.6, + dark, + ); + paint(g, (x, y) => torso(x, y) && y >= 27 && Math.abs(dx(x)) <= 0.5, '#9aa3ad'); + paint( + g, + (x, y) => torso(x, y) && y === 28 && Math.abs(dx(x)) >= half(y) - 2.5, + mix(shirt, WHITE, 0.6), + ); + break; + } + const neck = shade(skin, 0.85); + for (let y = 24; y < N; y++) + for (let x = 0; x < N; x++) { + const cell = g[y]![x]; + if (!cell || cell === neck || !torso(x, y)) continue; + const d = dx(x); + const edge = half(y) - Math.abs(d); + if (y === 24 && Math.abs(d) <= 4.5) g[y]![x] = shade(cell, 0.78); + else if (y >= 26 && edge >= 1.6 && edge < 2.6) g[y]![x] = shade(cell, 0.82); + else if (d > 0 && edge < 1.6) g[y]![x] = shade(cell, 0.84); + else if (d < 0 && edge < 1.6 && y <= 26) g[y]![x] = mix(cell, WHITE, 0.28); + else if (d < -2 && y <= 25) g[y]![x] = mix(cell, WHITE, 0.14); + } +} + +function accessory(recipe: Recipe, g: Grid, s: number, face: Mask): void { + const shirt = recipe.shirtColor; + const cap = ellipse(C + s, 14, 11.6, 11.2); + switch (recipe.accessory) { + case 'none': + return; + case 'beanie': + paint(g, (x, y) => cap(x, y) && y <= 8, shirt); + paint(g, (x, y) => cap(x, y) && (y === 8 || y === 9), shade(shirt, 0.78)); + paint(g, ellipse(C + s, 1.6, 2.2, 1.8), WHITE); + return; + case 'cap': + paint(g, (x, y) => cap(x, y) && y <= 8, shirt); + paint( + g, + (x, y) => y === 9 && x + 0.5 >= C + s - 10 && x + 0.5 <= C + s + 13, + shade(shirt, 0.72), + ); + return; + case 'headphones': { + const band = (x: number, y: number) => + ellipse(C + s, 14, 12, 11.6)(x, y) && !ellipse(C + s, 14, 10.8, 10.4)(x, y) && y <= 13; + paint(g, band, '#5d5b66'); + paint( + g, + (x, y) => + y >= 12 && + y <= 19 && + (Math.abs(x + 0.5 - (C + s - 11)) <= 1.6 || Math.abs(x + 0.5 - (C + s + 11)) <= 1.6), + '#e25d6a', + ); + return; + } + case 'flower': + sprite(g, ['.P.P.', 'PPYPP', '.PPP.'], Math.round(C + s) + 6, 3, { P: '#f59fba', Y: GOLD }); + return; + case 'bow': + sprite(g, ['RR.RR', 'RRrRR', 'RR.RR'], Math.round(C + s) + 6, 3, { + R: '#e5566a', + r: '#b83a50', + }); + return; + case 'earring': { + const xs = [...Array(N).keys()].filter((x) => face(x, 19)); + if (xs.length) { + sprite(g, ['G', 'G'], xs[0]! - 1, 20, { G: GOLD }); + sprite(g, ['G', 'G'], xs.at(-1)! + 1, 20, { G: GOLD }); + } + return; + } + case 'crown': + sprite(g, ['G.G.G.G', 'GGGGGGG', 'GrGbGrG'], Math.round(C + s) - 3, 0, { + G: GOLD, + r: '#e5566a', + b: '#5a9be0', + }); + return; + case 'halo': + paint( + g, + (x, y) => ellipse(C + s, 1.6, 6.5, 1.8)(x, y) && !ellipse(C + s, 1.6, 4.4, 0.8)(x, y), + GOLD, + ); + return; + case 'catears': { + const ear = ['X...', 'XX..', 'XPX.', 'XXXX']; + sprite(g, ear, Math.round(C + s) - 9, 2, { X: recipe.hairColor, P: '#f4a3b5' }); + sprite(g, ear, Math.round(C + s) + 5, 2, { X: recipe.hairColor, P: '#f4a3b5' }, true); + return; + } + case 'hairclip': + sprite(g, ['CC.CC', '.CCC.'], Math.round(C + s) + 3, 9, { C: '#e5566a' }); + return; + case 'horns': { + const horn = ['.H', 'HH', 'Hh']; + sprite(g, horn, Math.round(C + s) - 8, 1, { H: '#5b3a6e', h: '#7d5694' }); + sprite(g, horn, Math.round(C + s) + 6, 1, { H: '#5b3a6e', h: '#7d5694' }, true); + return; + } + case 'beret': + paint(g, (x, y) => ellipse(C + s + 1.5, 4.6, 10.5, 3.6)(x, y), shirt); + paint(g, (x, y) => ellipse(C + s + 1.5, 4.6, 10.5, 3.6)(x, y) && y >= 6, shade(shirt, 0.78)); + paint( + g, + (x, y) => ellipse(C + s + 1.5, 4.6, 10.5, 3.6)(x, y) && y <= 2 && x + 0.5 < C + s, + mix(shirt, WHITE, 0.3), + ); + sprite(g, ['S'], Math.round(C + s) + 1, 0, { S: shade(shirt, 0.6) }); + return; + case 'ribbon': + sprite(g, ['RRR.RRR', 'RrRRRrR', 'RRR.RRR', '.R...R.'], Math.round(C + s) - 3, 0, { + R: '#e5566a', + r: '#f49aa8', + }); + return; + case 'headband': + paint( + g, + (x, y) => + ellipse(C + s, 14, 11.2, 10.8)(x, y) && !ellipse(C + s, 14.2, 10.2, 9.8)(x, y) && y <= 8, + shirt, + ); + paint( + g, + (x, y) => + ellipse(C + s, 14, 11.2, 10.8)(x, y) && !ellipse(C + s, 14.2, 10.2, 9.8)(x, y) && y <= 5, + mix(shirt, WHITE, 0.35), + ); + return; + case 'bunnyears': { + const ear = ['WW', 'WP', 'WP', 'WP', 'WW']; + sprite(g, ear, Math.round(C + s) - 6, 0, { W: '#f4f1ec', P: '#f4a3b5' }); + sprite(g, ear, Math.round(C + s) + 4, 0, { W: '#f4f1ec', P: '#f4a3b5' }, true); + return; + } + case 'horseears': { + const ear = ['.X.', 'XPX', 'XPX', 'XXX']; + sprite(g, ear, Math.round(C + s) - 9, 1, { X: shade(recipe.hairColor, 0.9), P: '#f4a3b5' }); + sprite(g, ear, Math.round(C + s) + 6, 1, { X: shade(recipe.hairColor, 0.9), P: '#f4a3b5' }); + sprite(g, ['BB', 'BB'], Math.round(C + s) + 3, 7, { B: '#5a9be0' }); + return; + } + case 'flowercrown': + for (const [fx, color] of [ + [-8, '#f59fba'], + [-4, GOLD], + [0, '#f4f1ec'], + [4, '#f59fba'], + [8, GOLD], + ] as const) + sprite( + g, + ['.F.', 'FCF', '.F.'], + Math.round(C + s) + fx - 1, + 4 + Math.round(Math.abs(fx) / 4), + { + F: color, + C: color === GOLD ? '#e2565f' : GOLD, + }, + ); + paint( + g, + (x, y) => + y === 6 + Math.round(Math.abs(x + 0.5 - C - s) / 4) && + Math.abs(x + 0.5 - C - s) <= 9 && + x % 2 === 1, + '#5aa36b', + ); + return; + case 'witch': + paint(g, (x, y) => y >= 6 && y <= 7 && Math.abs(x + 0.5 - C - s) <= 13, '#3a2f52'); + paint( + g, + (x, y) => y <= 6 && Math.abs(x + 0.5 - C - s - (6 - y) * 0.5) <= 1 + y * 0.9, + '#4b3d6b', + ); + paint(g, (x, y) => y === 5 && Math.abs(x + 0.5 - C - s - 0.5) <= 5.2, '#efb93f'); + return; + case 'pins': + sprite(g, ['Y.Y', '.Y.', 'Y.Y', '...', 'B.B', '.B.', 'B.B'], Math.round(C + s) + 6, 7, { + Y: GOLD, + B: '#5a9be0', + }); + return; + } +} + +export function pixelTileColor(hair: string): string { + const [r, g, b] = channels(hair).map((v) => v / 255) as [number, number, number]; + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const lightness = (max + min) / 2; + const chroma = max - min; + const saturation = chroma === 0 ? 0 : chroma / (1 - Math.abs(2 * lightness - 1)); + if (saturation < 0.18 || lightness > 0.86 || lightness < 0.16) return '#ece8e1'; + const hue = + max === r + ? ((g - b) / chroma + 6) % 6 + : max === g + ? (b - r) / chroma + 2 + : (r - g) / chroma + 4; + const s = Math.min(0.55, Math.max(0.35, saturation * 0.6)); + const l = 0.88; + const f = (n: number) => { + const k = (n + hue * 2) % 12; + return l - s * Math.min(l, 1 - l) * Math.max(-1, Math.min(k - 3, 9 - k, 1)); + }; + return hex([f(0), f(8), f(4)].map((v) => v * 255)); +} + +export function pixelFigure( + recipe: Recipe, + yawDeg: number, +): { tile: string; body: string; head: string; cells: PixelCell[] } { + const yaw = (yawDeg * Math.PI) / 180; + const sinY = Math.sin(yaw); + const s = Math.round(sinY * 3); + const fs = Math.round(sinY * 10); + const b = -Math.round(sinY * 3.5); + const turned = Math.abs(sinY) >= 0.3; + const d = Math.sign(sinY); + const skin = recipe.skinColor; + const hairColor = recipe.hairColor; + const front = FACE[recipe.head](s * 0.5); + const face: Mask = turned + ? (x, y) => { + const dx = x + 0.5 - C; + const tuck = y >= 17 && d * dx > 4 ? Math.min(2, (y - 16) * 0.35) : 0; + return front(x - Math.round(d * (1 + Math.max(0, y - 20) * 0.4) - d * tuck), y); + } + : front; + const masks = recipe.bangs === undefined ? hair(recipe, s, b) : detailedHair(recipe, s, b); + + const body = blank(); + outfit(recipe, body, s); + + const back = blank(); + paint(back, masks.back, shade(hairColor, 0.82)); + if (masks.bands) + paint( + back, + (x, y) => masks.back(x, y) && (y + Math.floor(x / 2)) % 4 === 0, + shade(hairColor, 0.68), + ); + + const head = blank(); + paint(head, face, skin); + const earY = 15; + const edge = (side: number) => { + const xs = [...Array(N).keys()].filter((x) => face(x, earY)); + return side < 0 ? xs[0]! - 1 : xs.at(-1)! + 1; + }; + if (!turned) + for (const ex of [-1, 1]) + sprite(head, ['E', 'E', 'e'], edge(ex), earY, { E: skin, e: shade(skin, 0.86) }); + else + sprite(head, ['EE', 'Ee', 'Ee', 'E.'], d > 0 ? edge(-d) - 1 : edge(-d), earY, { + E: skin, + e: shade(skin, 0.8), + }); + paint(head, masks.front, hairColor); + for (const [x, y] of masks.ties ?? []) + sprite(back, ['T'], Math.round(x), y, { T: shade(recipe.shirtColor, 0.8) }); + accessory(recipe, head, s, face); + + const shadeHair = (g: Grid) => { + const out = g.map((r) => [...r]); + const cells = g.flatMap((row, y) => row.flatMap((c, x) => (c === hairColor ? [[x, y]] : []))); + const xs = cells.map(([x]) => x!); + const ys = cells.map(([, y]) => y!); + const left = Math.min(...xs); + const right = Math.max(...xs); + const top = Math.min(...ys); + const mid = (left + right) / 2; + const span = Math.max(1, (right - left) / 2); + const light = mix(hairColor, WHITE, 0.2); + const dark = shade(hairColor, 0.8); + const middle = shade(hairColor, 0.9); + for (const [x, y] of cells) { + const side = (x! + 0.5 - mid) / span + (y! - top) * 0.025; + if (side > 0.72) out[y!]![x!] = dark; + else if (side > 0.42) out[y!]![x!] = middle; + else if (side < -0.2 && y! <= top + 4) out[y!]![x!] = light; + } + for (const [x, y] of cells) { + const nearFace = g[y!]![x! - 1] === skin || g[y!]![x! + 1] === skin; + if (nearFace && y! >= 14) out[y!]![x!] = shade(hairColor, 0.74); + else if (Math.abs(x! + 0.5 - C - s) >= 7.5 && y! >= 14 && (x! + 40 - s) % 3 === 0) + out[y!]![x!] = shade(out[y!]![x!]!, 0.86); + } + for (let y = 1; y < N; y++) + for (let x = 0; x < N; x++) { + if (g[y]![x] !== skin) continue; + if (g[y - 1]![x] === hairColor) out[y]![x] = mix(shade(skin, 0.84), BLUSH, 0.12); + else if (x + 1 < N && g[y]![x + 1] !== skin && g[y]![x + 1] !== undefined && x > C + s) + out[y]![x] = shade(skin, 0.9); + else if (x + 1 < N && g[y]![x + 1] === undefined && x > C + s) + out[y]![x] = shade(skin, 0.9); + } + for (let y = 0; y < N - 1; y++) + for (let x = 0; x < N; x++) + if (g[y]![x] === hairColor && g[y + 1]![x] === skin) out[y]![x] = shade(hairColor, 0.62); + for (let x = 0; x < N; x++) + for (let y = 3; y < N; y++) + if (g[y]![x] === hairColor && g[y + 1]?.[x] === skin && (x + 40 - s) % 4 === 0) + for (let k = 1; k <= 3; k++) + if (g[y - k]?.[x] === hairColor) out[y - k]![x] = shade(hairColor, 0.72); + const ring = mix(hairColor, WHITE, 0.45); + for (let x = Math.round(C + s) - 7; x <= Math.round(C + s) + 3; x++) { + const first = g.findIndex((row) => row[x] === hairColor); + if (first < 0) continue; + const y = first + 2 + Math.round(Math.abs(x + 0.5 - (C + s - 2)) / 4); + if (g[y]?.[x] === hairColor && x % 3 !== 0) out[y]![x] = ring; + } + return out; + }; + + const figure = blank(); + for (const layer of [back, body, shadeHair(head)]) + for (let y = 0; y < N; y++) + for (let x = 0; x < N; x++) if (layer[y]![x]) figure[y]![x] = layer[y]![x]; + + const features = blank(); + const eyes = blank(); + const closed = blank(); + const glasses = blank(); + const sp = recipe.spacing ?? 0; + const h = recipe.height ?? 0; + const eyeTop = 15 + h; + const eyeW = (side: -1 | 1) => (turned && Math.sign(fs) === side ? 3 : 4); + const eyeX = (side: -1 | 1) => { + const w = eyeW(side); + return side < 0 + ? Math.round(C + fs * 0.6) - 6 - sp - (w === 3 ? -1 : 0) + : Math.round(C + fs * 0.6) + 2 + sp; + }; + const left = { x: eyeX(-1), w: eyeW(-1) }; + const right = { x: eyeX(1), w: eyeW(1) }; + const fit = (rows: readonly string[], w: number) => + rows.map((r) => r.slice(Math.max(0, r.length - w))); + const pal = { + K: INK, + W: WHITE, + D: shade(recipe.eyeColor, 0.55), + I: recipe.eyeColor, + L: mix(recipe.eyeColor, WHITE, 0.45), + }; + const style = EYES[recipe.eyes]; + const extra = style[0]!.length - 4; + sprite(eyes, fit(style, left.w + extra), left.x - extra, eyeTop, pal); + sprite( + eyes, + recipe.eyes === 'wink' ? fit(CLOSED, right.w) : fit(style, right.w + extra), + right.x, + eyeTop, + pal, + true, + ); + sprite(closed, fit(CLOSED, left.w), left.x, eyeTop, pal); + sprite(closed, fit(CLOSED, right.w), right.x, eyeTop, pal, true); + const browRows = BROWS[recipe.brows]; + if (browRows.length) { + sprite(features, fit(browRows, left.w), left.x, eyeTop - 2, { B: shade(hairColor, 0.55) }); + sprite( + features, + fit(browRows, right.w), + right.x, + eyeTop - 2, + { B: shade(hairColor, 0.55) }, + true, + ); + } + const cx = Math.round(C + fs * (turned ? 0.85 : 0.6)); + if (recipe.nose === 'dot') sprite(features, ['N'], cx, 18 + h, { N: shade(skin, 0.78) }); + if (recipe.nose === 'button') sprite(features, ['N'], cx, 18 + h, { N: shade(skin, 0.88) }); + if (recipe.nose === 'line') sprite(features, ['N', 'N'], cx, 17 + h, { N: shade(skin, 0.82) }); + const mouth = MOUTHS[recipe.mouth]; + const mx = C - 0.5 + fs * 0.6; + sprite(features, mouth, Math.round(mx - (mouth[0]!.length - 1) / 2), 20 + h, { + K: MOUTH, + M: MOUTH_INSIDE, + T: TONGUE, + W: WHITE, + }); + if (recipe.cheeks === 'blush') { + sprite(features, ['PP'], left.x - 1, 19 + h, { P: mix(BLUSH, skin, 0.25) }); + sprite(features, ['PP'], right.x + right.w - 1, 19 + h, { P: mix(BLUSH, skin, 0.25) }); + } + if (recipe.cheeks === 'freckles') { + sprite(features, ['F.F'], left.x, 19 + h, { F: shade(skin, 0.7) }); + sprite(features, ['F.F'], right.x + 1, 19 + h, { F: shade(skin, 0.7) }); + } + const frame = (fx: number, w: number, round: boolean) => + paint( + glasses, + (x, y) => { + const inside = x >= fx && x < fx + w && y >= eyeTop && y <= eyeTop + 3; + const box = x >= fx - 1 && x <= fx + w && y >= eyeTop - 1 && y <= eyeTop + 4; + const corner = (x === fx - 1 || x === fx + w) && (y === eyeTop - 1 || y === eyeTop + 4); + return box && !inside && !(round && corner); + }, + INK, + ); + if (recipe.glasses === 'round' || recipe.glasses === 'square') { + frame(left.x, left.w, recipe.glasses === 'round'); + frame(right.x, right.w, recipe.glasses === 'round'); + paint(glasses, (x, y) => y === eyeTop + 1 && x > left.x + left.w && x < right.x - 1, INK); + } + if (recipe.glasses === 'shades') { + for (const e of [left, right]) + paint( + glasses, + (x, y) => x >= e.x - 1 && x <= e.x + e.w && y >= eyeTop && y <= eyeTop + 2, + INK, + ); + paint(glasses, (x, y) => y === eyeTop && x > left.x + left.w && x < right.x - 1, INK); + for (const e of [left, right]) sprite(glasses, ['W'], e.x, eyeTop, { W: '#7d7b88' }); + } + if (recipe.glasses === 'monocle') { + frame(right.x, right.w, true); + sprite(glasses, ['G', 'G', 'G'], right.x + right.w, eyeTop + 5, { G: GOLD }); + } + + const full = clip(outline(figure)); + const bodyCells = blank(); + const headCells = blank(); + for (let y = 0; y < N; y++) + for (let x = 0; x < N; x++) { + const c = full[y]![x]; + if (!c) continue; + if (y >= 22 && !head[y]![x] && !back[y]![x]) bodyCells[y]![x] = c; + else headCells[y]![x] = c; + } + const cells: PixelCell[] = []; + for (let y = 0; y < N; y++) + for (let x = 0; x < N; x++) { + const c = glasses[y]![x] ?? eyes[y]![x] ?? features[y]![x] ?? full[y]![x]; + if (c) cells.push({ x, y, c }); + } + return { + cells, + tile: ``, + body: `${rects(bodyCells)}`, + head: [ + `${rects(headCells)}`, + `${rects(features)}`, + `${rects(eyes)}`, + `${rects(closed)}`, + `${rects(glasses)}`, + ].join(''), + }; +} diff --git a/packages/avatar/src/index.ts b/packages/avatar/src/index.ts new file mode 100644 index 0000000..aabef65 --- /dev/null +++ b/packages/avatar/src/index.ts @@ -0,0 +1,24 @@ +export type { PixelCell } from '@botharness/pixel-morph'; +export { pixelFigure, pixelTileColor, type PixelGrid } from './figure.js'; +export { + AVATAR_COLORS, + AVATAR_HAIR_PARTS, + AVATAR_PARTS, + AVATAR_PRESETS, + AVATAR_RANGES, + AVATAR_SWATCHES, + DEFAULT_RECIPE, + canonicalRecipe, + createSeededRecipe, + detailedRecipe, + isPixelAvatarRecipe, + seededRecipe, + type AvatarColor, + type AvatarHairPart, + type AvatarPart, + type AvatarRange, + type PixelAvatarRecipe, +} from './recipe.js'; +export { seededRandom } from './random.js'; +export { AVATAR_TURNS, faceCells, pixelAvatarSvg, type PixelAvatarSvgOptions } from './svg.js'; +export { PIXEL_SYMBOLS, pixelSymbolCells, symbolArtCells, type PixelSymbol } from './symbols.js'; diff --git a/packages/avatar/src/random.ts b/packages/avatar/src/random.ts new file mode 100644 index 0000000..a3fb705 --- /dev/null +++ b/packages/avatar/src/random.ts @@ -0,0 +1,13 @@ +export function seededRandom(seed: string): () => number { + let h = 2166136261; + for (const char of seed) { + h ^= char.codePointAt(0)!; + h = Math.imul(h, 16777619); + } + return () => { + h = Math.imul(h ^ (h >>> 15), 2246822507); + h = Math.imul(h ^ (h >>> 13), 3266489909); + h ^= h >>> 16; + return (h >>> 0) / 4294967296; + }; +} diff --git a/packages/avatar/src/recipe.ts b/packages/avatar/src/recipe.ts new file mode 100644 index 0000000..c98c757 --- /dev/null +++ b/packages/avatar/src/recipe.ts @@ -0,0 +1,470 @@ +import { seededRandom } from './random.js'; + +export const AVATAR_PARTS = { + head: ['round', 'oval', 'square', 'long', 'heart', 'vchin', 'chubby', 'diamond'], + pose: ['front', 'left', 'right'], + hair: [ + 'crop', + 'sweep', + 'spiky', + 'buzz', + 'curly', + 'mohawk', + 'bob', + 'long', + 'bun', + 'pigtails', + 'afro', + 'twintails', + 'drills', + 'ponytail', + 'sidetail', + 'hime', + 'odango', + 'messy', + 'wavy', + 'braids', + 'wolf', + 'ahoge', + 'none', + ], + eyes: ['round', 'dot', 'sparkle', 'lashes', 'sleepy', 'happy', 'wink', 'sharp'], + brows: ['soft', 'thick', 'raised', 'angry', 'worried', 'none'], + nose: ['button', 'dot', 'line', 'none'], + mouth: ['smile', 'grin', 'open', 'flat', 'smirk', 'cat', 'tongue', 'o'], + cheeks: ['blush', 'freckles', 'none'], + glasses: ['none', 'round', 'square', 'shades', 'monocle'], + outfit: [ + 'tee', + 'shirttie', + 'hoodie', + 'turtleneck', + 'sailor', + 'blazer', + 'overalls', + 'dress', + 'kimono', + 'cardigan', + 'maid', + 'jacket', + ], + backdrop: ['sparkles', 'hearts', 'stars', 'dots', 'none'], + accessory: [ + 'none', + 'beanie', + 'cap', + 'headphones', + 'flower', + 'bow', + 'earring', + 'crown', + 'halo', + 'catears', + 'hairclip', + 'horns', + 'beret', + 'ribbon', + 'headband', + 'bunnyears', + 'horseears', + 'flowercrown', + 'witch', + 'pins', + ], +} as const; + +export const AVATAR_HAIR_PARTS = { + bangs: [ + 'crop', + 'bob', + 'sweep', + 'spiky', + 'curly', + 'messy', + 'wolf', + 'wavy', + 'ahoge', + 'hime', + 'buzz', + 'mohawk', + 'none', + ], + sideHair: ['crop', 'bun', 'bob', 'long', 'hime', 'curly', 'braids', 'none'], + backHair: [ + 'none', + 'bob', + 'long', + 'wavy', + 'wolf', + 'bun', + 'odango', + 'pigtails', + 'twintails', + 'drills', + 'ponytail', + 'sidetail', + 'afro', + ], +} as const satisfies Record; +const HAIR_SPLIT: Record< + (typeof AVATAR_PARTS)['hair'][number], + { [P in AvatarHairPart]: (typeof AVATAR_HAIR_PARTS)[P][number] } +> = { + crop: { bangs: 'crop', sideHair: 'crop', backHair: 'none' }, + sweep: { bangs: 'sweep', sideHair: 'crop', backHair: 'none' }, + spiky: { bangs: 'spiky', sideHair: 'crop', backHair: 'none' }, + buzz: { bangs: 'buzz', sideHair: 'none', backHair: 'none' }, + curly: { bangs: 'curly', sideHair: 'curly', backHair: 'none' }, + mohawk: { bangs: 'mohawk', sideHair: 'none', backHair: 'none' }, + bob: { bangs: 'bob', sideHair: 'bob', backHair: 'bob' }, + long: { bangs: 'bob', sideHair: 'long', backHair: 'long' }, + bun: { bangs: 'bob', sideHair: 'bun', backHair: 'bun' }, + pigtails: { bangs: 'bob', sideHair: 'bun', backHair: 'pigtails' }, + afro: { bangs: 'buzz', sideHair: 'none', backHair: 'afro' }, + twintails: { bangs: 'bob', sideHair: 'bob', backHair: 'twintails' }, + drills: { bangs: 'bob', sideHair: 'bob', backHair: 'drills' }, + ponytail: { bangs: 'bob', sideHair: 'bun', backHair: 'ponytail' }, + sidetail: { bangs: 'sweep', sideHair: 'bun', backHair: 'sidetail' }, + hime: { bangs: 'hime', sideHair: 'hime', backHair: 'long' }, + odango: { bangs: 'bob', sideHair: 'bun', backHair: 'odango' }, + messy: { bangs: 'messy', sideHair: 'bun', backHair: 'none' }, + wavy: { bangs: 'wavy', sideHair: 'long', backHair: 'wavy' }, + braids: { bangs: 'bob', sideHair: 'braids', backHair: 'none' }, + wolf: { bangs: 'wolf', sideHair: 'bun', backHair: 'wolf' }, + ahoge: { bangs: 'ahoge', sideHair: 'bob', backHair: 'bob' }, + none: { bangs: 'none', sideHair: 'none', backHair: 'none' }, +}; +export const AVATAR_RANGES = { + spacing: [-1, 1], + height: [-1, 1], + hairLength: [-2, 2], +} as const; +export type AvatarHairPart = keyof typeof AVATAR_HAIR_PARTS; +export type AvatarRange = keyof typeof AVATAR_RANGES; +const DETAIL_KEYS = [ + ...(Object.keys(AVATAR_HAIR_PARTS) as AvatarHairPart[]), + ...(Object.keys(AVATAR_RANGES) as AvatarRange[]), +] as const; + +export type AvatarPart = keyof typeof AVATAR_PARTS; +export const AVATAR_COLORS = ['skinColor', 'hairColor', 'eyeColor', 'shirtColor'] as const; +export type AvatarColor = (typeof AVATAR_COLORS)[number]; + +export type PixelAvatarRecipe = { + schemaVersion: 1; + family: 'illustrated'; + assetVersion: 1; + rigVersion: 1; +} & { [P in AvatarPart]: (typeof AVATAR_PARTS)[P][number] } & Record & { + [P in AvatarHairPart]?: (typeof AVATAR_PARTS)['hair'][number]; + } & { [P in AvatarRange]?: number }; + +export const DEFAULT_RECIPE: PixelAvatarRecipe = { + schemaVersion: 1, + family: 'illustrated', + assetVersion: 1, + rigVersion: 1, + head: 'round', + pose: 'front', + hair: 'crop', + eyes: 'round', + brows: 'soft', + nose: 'button', + mouth: 'smile', + cheeks: 'blush', + glasses: 'none', + outfit: 'tee', + backdrop: 'sparkles', + accessory: 'none', + skinColor: '#f2c9a8', + hairColor: '#5a3a2a', + eyeColor: '#3f7fbf', + shirtColor: '#5b8bd6', +}; + +const PART_KEYS = Object.keys(AVATAR_PARTS) as AvatarPart[]; + +export function isPixelAvatarRecipe(value: unknown): value is PixelAvatarRecipe { + if (typeof value !== 'object' || value === null || Array.isArray(value)) return false; + const r = value as Record; + const detailed = DETAIL_KEYS.filter((key) => Object.hasOwn(r, key)).length; + if (detailed !== 0 && detailed !== DETAIL_KEYS.length) return false; + if (Object.keys(r).length !== Object.keys(DEFAULT_RECIPE).length + detailed) return false; + return ( + (detailed === 0 || + ((Object.keys(AVATAR_HAIR_PARTS) as AvatarHairPart[]).every( + (key) => + typeof r[key] === 'string' && + (AVATAR_HAIR_PARTS[key] as readonly string[]).includes(r[key]), + ) && + (Object.keys(AVATAR_RANGES) as AvatarRange[]).every((key) => { + const v = r[key]; + const [min, max] = AVATAR_RANGES[key]; + return typeof v === 'number' && Number.isInteger(v) && v >= min && v <= max; + }))) && + r['schemaVersion'] === 1 && + r['family'] === 'illustrated' && + r['assetVersion'] === 1 && + r['rigVersion'] === 1 && + PART_KEYS.every( + (key) => + typeof r[key] === 'string' && (AVATAR_PARTS[key] as readonly string[]).includes(r[key]), + ) && + AVATAR_COLORS.every((key) => typeof r[key] === 'string' && /^#[\da-f]{6}$/iu.test(r[key])) + ); +} + +export function canonicalRecipe(recipe: PixelAvatarRecipe): PixelAvatarRecipe { + const canonical: Record = { + schemaVersion: 1, + family: 'illustrated', + assetVersion: 1, + rigVersion: 1, + }; + for (const key of PART_KEYS) canonical[key] = recipe[key]; + for (const key of AVATAR_COLORS) canonical[key] = recipe[key].toLowerCase(); + if (recipe.bangs !== undefined) for (const key of DETAIL_KEYS) canonical[key] = recipe[key]; + return canonical as PixelAvatarRecipe; +} + +export function detailedRecipe(recipe: PixelAvatarRecipe): PixelAvatarRecipe { + if (recipe.bangs !== undefined) return recipe; + const pick =

(part: P) => + (AVATAR_HAIR_PARTS[part] as readonly string[]).includes(recipe.hair) + ? (recipe.hair as (typeof AVATAR_HAIR_PARTS)[P][number]) + : HAIR_SPLIT[recipe.hair][part]; + return { + ...recipe, + bangs: pick('bangs'), + sideHair: pick('sideHair'), + backHair: pick('backHair'), + spacing: 0, + height: 0, + hairLength: 0, + }; +} + +export const AVATAR_SWATCHES: Record = { + skinColor: [ + '#ffe3cf', + '#f2c9a8', + '#e0a87e', + '#c68863', + '#9a6142', + '#6e4129', + '#4a2c1c', + '#f4f1ec', + ], + hairColor: [ + '#1d1b22', + '#5a3a2a', + '#8a5a36', + '#e2b04a', + '#c4452f', + '#d9475a', + '#f06292', + '#3fc1b8', + '#5a7be0', + '#9aa3ad', + '#f4f1ec', + ], + eyeColor: [ + '#3f7fbf', + '#5a3a2a', + '#2f9e8f', + '#4c8a3c', + '#8a5ad0', + '#d0533f', + '#d9a13a', + '#2a2230', + ], + shirtColor: [ + '#5b8bd6', + '#e07a5f', + '#3d9970', + '#7a5cc7', + '#f2c14e', + '#2f3a4a', + '#e2565f', + '#9ad0c2', + ], +}; + +const SEEDED_CHOICES: { [P in AvatarPart]: readonly (typeof AVATAR_PARTS)[P][number][] } = { + head: ['round', 'oval', 'square', 'long', 'heart', 'vchin', 'chubby', 'diamond'], + pose: ['front'], + hair: AVATAR_PARTS.hair.filter((hair) => hair !== 'none'), + eyes: ['round', 'round', 'sparkle', 'lashes', 'dot', 'happy', 'sharp'], + brows: ['soft', 'soft', 'thick', 'raised'], + nose: ['button', 'dot', 'none'], + mouth: ['smile', 'smile', 'grin', 'open', 'cat'], + cheeks: ['blush', 'blush', 'freckles', 'none'], + glasses: ['none', 'none', 'none', 'none', 'round', 'square'], + accessory: [ + 'none', + 'none', + 'none', + 'flower', + 'bow', + 'hairclip', + 'catears', + 'headphones', + 'beanie', + 'cap', + ], + outfit: AVATAR_PARTS.outfit, + backdrop: ['sparkles', 'hearts', 'stars', 'dots'], +}; + +/** + * Returns a name-seeded recipe factory. Different namespaces give different faces for the same + * name; the factory takes the name only, so it is safe to pass straight to `Array.map`. + */ +export function createSeededRecipe(namespace: string): (seed: string) => PixelAvatarRecipe { + return (seed) => { + const random = seededRandom(`${namespace}:${seed.trim().toLowerCase()}`); + const pick = (values: readonly T[]) => values[Math.floor(random() * values.length)]!; + const recipe: Record = { + schemaVersion: 1, + family: 'illustrated', + assetVersion: 1, + rigVersion: 1, + }; + for (const part of Object.keys(AVATAR_PARTS) as AvatarPart[]) + recipe[part] = pick(SEEDED_CHOICES[part]); + for (const color of AVATAR_COLORS) recipe[color] = pick(AVATAR_SWATCHES[color].slice(0, 7)); + return recipe as PixelAvatarRecipe; + }; +} + +/** The same name always gives the same face (BotHarness's namespace). */ +export const seededRecipe: (seed: string) => PixelAvatarRecipe = + createSeededRecipe('botharness-avatar'); + +const preset = (parts: Partial): PixelAvatarRecipe => ({ + ...DEFAULT_RECIPE, + ...parts, +}); + +export const AVATAR_PRESETS: readonly PixelAvatarRecipe[] = [ + preset({ + hair: 'wavy', + eyes: 'lashes', + accessory: 'beret', + outfit: 'dress', + skinColor: '#ffe3cf', + hairColor: '#e2b04a', + eyeColor: '#3f7fbf', + shirtColor: '#e2565f', + backdrop: 'stars', + }), + preset({ + hair: 'braids', + accessory: 'flowercrown', + outfit: 'cardigan', + skinColor: '#ffe3cf', + hairColor: '#8a5a36', + eyeColor: '#4c8a3c', + shirtColor: '#9ad0c2', + backdrop: 'hearts', + }), + preset({ + hair: 'twintails', + eyes: 'sparkle', + accessory: 'ribbon', + outfit: 'maid', + skinColor: '#ffe3cf', + hairColor: '#3fc1b8', + eyeColor: '#2f9e8f', + shirtColor: '#e2565f', + backdrop: 'stars', + }), + preset({ + hair: 'long', + accessory: 'horseears', + outfit: 'jacket', + skinColor: '#ffe3cf', + hairColor: '#8a5a36', + eyeColor: '#d0533f', + shirtColor: '#5b8bd6', + backdrop: 'dots', + }), + preset({ + hair: 'hime', + eyes: 'sleepy', + accessory: 'pins', + outfit: 'kimono', + skinColor: '#f4f1ec', + hairColor: '#1d1b22', + eyeColor: '#d0533f', + shirtColor: '#7a5cc7', + backdrop: 'none', + }), + preset({ + hair: 'ahoge', + accessory: 'headband', + outfit: 'sailor', + skinColor: '#ffe3cf', + hairColor: '#f06292', + eyeColor: '#2f9e8f', + shirtColor: '#f4f1ec', + backdrop: 'hearts', + }), + preset({ + hair: 'wolf', + eyes: 'sharp', + outfit: 'jacket', + skinColor: '#e0a87e', + hairColor: '#9aa3ad', + eyeColor: '#5a7be0', + shirtColor: '#2f3a4a', + backdrop: 'stars', + }), + preset({ + hair: 'wavy', + eyes: 'sparkle', + accessory: 'witch', + outfit: 'dress', + skinColor: '#ffe3cf', + hairColor: '#8a5ad0', + eyeColor: '#d9a13a', + shirtColor: '#2f3a4a', + backdrop: 'sparkles', + }), + preset({ + hair: 'bob', + eyes: 'happy', + accessory: 'bunnyears', + outfit: 'cardigan', + skinColor: '#ffe3cf', + hairColor: '#f4f1ec', + eyeColor: '#d9475a', + shirtColor: '#f2c14e', + backdrop: 'hearts', + }), + preset({ + hair: 'spiky', + glasses: 'round', + accessory: 'headphones', + outfit: 'hoodie', + backdrop: 'dots', + }), + preset({ + hair: 'odango', + eyes: 'lashes', + accessory: 'bow', + outfit: 'kimono', + hairColor: '#e2b04a', + shirtColor: '#5b8bd6', + backdrop: 'sparkles', + }), + preset({ + hair: 'crop', + accessory: 'cap', + outfit: 'shirttie', + skinColor: '#9a6142', + hairColor: '#1d1b22', + shirtColor: '#3d9970', + backdrop: 'dots', + }), +]; diff --git a/packages/avatar/src/svg.ts b/packages/avatar/src/svg.ts new file mode 100644 index 0000000..a666214 --- /dev/null +++ b/packages/avatar/src/svg.ts @@ -0,0 +1,52 @@ +import type { PixelCell } from '@botharness/pixel-morph'; +import { pixelFigure } from './figure.js'; +import { isPixelAvatarRecipe, type PixelAvatarRecipe } from './recipe.js'; + +const YAW = { front: 0, left: -25, right: 25 } as const; + +/** Head-turn offsets (degrees) the thinking animation cycles through. */ +export const AVATAR_TURNS = [-14, -7, 7, 14] as const; + +export interface PixelAvatarSvgOptions { + /** Extra yaw offsets to pre-render as hidden `[data-avatar-turn]` layers. */ + turns?: readonly number[]; + /** Class prefix for the rig layers (`-body`, `-head`, `-face`, `-gaze`, `-blink`). */ + classPrefix?: string; +} + +/** Every visible pixel of the face at its pose, in paint order, for morphing. */ +export function faceCells(recipe: PixelAvatarRecipe): PixelCell[] { + return pixelFigure(recipe, YAW[recipe.pose]).cells; +} + +/** A 32×32 SVG of the avatar: tile, body, head rig, optional turn layers and an empty morph layer. */ +export function pixelAvatarSvg( + recipe: PixelAvatarRecipe, + options: PixelAvatarSvgOptions = {}, +): string { + if (!isPixelAvatarRecipe(recipe)) throw new Error('invalid Avatar recipe'); + const base = pixelFigure(recipe, YAW[recipe.pose]); + const turns = (options.turns ?? []) + .map((delta) => { + const figure = pixelFigure(recipe, YAW[recipe.pose] + delta); + const layers = `${figure.body}${figure.head}`.replaceAll( + 'class="bh-illustrated-', + 'data-turn-part="', + ); + return `${layers}`; + }) + .join(''); + const svg = [ + '', + ].join(''); + const prefix = options.classPrefix; + return prefix === undefined || prefix === 'bh-illustrated' + ? svg + : svg.replaceAll('class="bh-illustrated-', `class="${prefix}-`); +} diff --git a/packages/avatar/src/symbols.ts b/packages/avatar/src/symbols.ts new file mode 100644 index 0000000..b427685 --- /dev/null +++ b/packages/avatar/src/symbols.ts @@ -0,0 +1,482 @@ +import type { PixelCell } from '@botharness/pixel-morph'; + +const SYMBOLS = { + thinking: [ + '........................', + '........................', + '........................', + '...........AAAA.........', + '..........AAAAAA........', + '.........AAAAAAAA.......', + '.......AAAAAAAAAAA......', + '.....AAAAAAAAAAAAA......', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAAA..', + '...AAAAHHAAAHHAAAHHAAA..', + '....AAAHHAAAHHAAAHHAAA..', + '....AAAAAAAAAAAAAAAAAA..', + '.....AAAAAAAAAAAAAAAA...', + '.....AAAAAAAAAAAAAAA....', + '.......AAAAAAAAAAA......', + '........................', + '....AA..................', + '...AAAA.................', + '...AAAA.................', + '..A.AA..................', + '.AAA....................', + '..A.....................', + ], + ask: [ + '........................', + '........................', + '...........AAA..........', + '........AAAAAAAA........', + '.......AAAAAAAAAA.......', + '.......AAAAAAAAAA.......', + '......AAAAA...AAAA......', + '......AAAA....AAAA......', + '......AAA.....AAAA......', + '......AAA.....AAAA......', + '..............AAAA......', + '.............AAAAA......', + '............AAAAA.......', + '...........AAAAA........', + '...........AAA..........', + '..........AAAA..........', + '..........AAAA..........', + '...........AA...........', + '........................', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '...........AA...........', + '........................', + ], + read: [ + '........................', + '........................', + '........................', + '........................', + '..AAAAAAA......AAAAAAA..', + '.AAAAAAAAAA..AAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAHHHHHAAAAAAHHHHHAAA.', + '.AAAHHHHHAAAAAAHHHHHAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAHHHHHAAAAAAHHHHHAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '...........AA...........', + '........................', + '........................', + '........................', + '........................', + '........................', + ], + write: [ + '........................', + '.....AAAAAAAAAA.........', + '....AAAAAAAAAAAA........', + '....AAAAAAAAAAAAA.......', + '....AAAAAAAAAAAAAA......', + '....AAAAAAAAAAAAAAA.....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAHHHHHHHHHHAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '.....AAAAAAAAAAAAAA.....', + '........................', + ], + edit: [ + '........................', + '........................', + '........................', + '...............AA.......', + '.............HHAAA......', + '.............HHHAAA.....', + '............AAHHHAAA....', + '...........AAAAHHHAAA...', + '..........AAAAAAHHHAA...', + '.........AAAAAAAAHHH....', + '........AAAAAAAAAAHH....', + '.......AAAAAAAAAAA......', + '......AAAAAAAAAAA.......', + '.....AAAAAAAAAAA........', + '....AAAAAAAAAAA.........', + '...AAAAAAAAAAA..........', + '...AAHHAAAAAA...........', + '...AAHHHAAAA............', + '...AAAHHAAA.............', + '...AAAAAAA..............', + '...AAAAAA...............', + '........................', + '........................', + '........................', + ], + bash: [ + '........................', + '........................', + '........................', + '....AAAAAAAAAAAAAAAA....', + '..AAAAAAAAAAAAAAAAAAAA..', + '..AAAAAAAAAAAAAAAAAAAA..', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAHHAAAAAAAAAAAAAAAA.', + '.AAAAHHHAAAAAAAAAAAAAAA.', + '.AAAAAHHHAAAAAAAAAAAAAA.', + '.AAAAAAHHHAAAAAAAAAAAAA.', + '.AAAAAAHHHAAAAAAAAAAAAA.', + '.AAAAAHHHAAAAAAAAAAAAAA.', + '.AAAAHHHAAAAAAAAAAAAAAA.', + '.AAAAHHAAAAHHHHHHHAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '..AAAAAAAAAAAAAAAAAAAA..', + '..AAAAAAAAAAAAAAAAAAAA..', + '....AAAAAAAAAAAAAAAA....', + '........................', + '........................', + '........................', + ], + search: [ + '........................', + '........................', + '.......AAAAAA...........', + '......AAAAAAAA..........', + '....AAAAAAAAAAAA........', + '....AAAAAAAAAAAA........', + '...AAAA......AAAA.......', + '..AAAA........AAAA......', + '..AAAA........AAAA......', + '..AAAA........AAAA......', + '..AAAA........AAAA......', + '..AAAA........AAAA......', + '..AAAA........AAAA......', + '...AAAA......AAAA.......', + '....AAAAAAAAAAAAA.......', + '....AAAAAAAAAAAAAA......', + '......AAAAAAAAAAAAA.....', + '.......AAAAAA..AAAAA....', + '................AAAAA...', + '.................AAAAA..', + '..................AAAAA.', + '...................AAAA.', + '....................AA..', + '........................', + ], + web: [ + '........................', + '........................', + '.........AHHHHA.........', + '.......AAHHHHHHAA.......', + '.....AAAAHHAAHHAAAA.....', + '....AAAAHHAAAAHHAAAA....', + '....HHHHHHHHHHHHHHHH....', + '...AHHHHHHHHHHHHHHHHA...', + '...AAAAAHAAAAAAHAAAAA...', + '..AAAAAHHAAAAAAHAAAAAA..', + '..AAAAAHHAAAAAAHHAAAAA..', + '..HHHHHHHHHHHHHHHHHHHH..', + '..HHHHHHHHHHHHHHHHHHHH..', + '..AAAAAHHAAAAAAHHAAAAA..', + '..AAAAAHHAAAAAAHAAAAAA..', + '...AAAAAHAAAAAAHAAAAA...', + '...AHHHHHHHHHHHHHHHHA...', + '....HHHHHHHHHHHHHHHH....', + '....AAAAHHAAAAHHAAAA....', + '.....AAAAHHAAHHAAAA.....', + '.......AAHHHHHHAA.......', + '.........AHHHHA.........', + '........................', + '........................', + ], + fetch: [ + '........................', + '..........AAA...........', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '.....AA...AAAA...AA.....', + '....AAAA..AAAA..AAAA....', + '....AAAAA.AAAA.AAAAA....', + '.....AAAAAAAAAAAAAA.....', + '......AAAAAAAAAAAA......', + '.......AAAAAAAAAA.......', + '........AAAAAAAA........', + '.........AAAAAA.........', + '..AAA.....AAAA.....AAA..', + '..AAA......AA......AAA..', + '..AAA..............AAA..', + '..AAA..............AAA..', + '..AAAAAAAAAAAAAAAAAAAA..', + '..AAAAAAAAAAAAAAAAAAAA..', + '..AAAAAAAAAAAAAAAAAAAA..', + '...AAAAAAAAAAAAAAAAAA...', + '........................', + ], + todo: [ + '........................', + '........................', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAHAAAAAAAAA...', + '...AAAAAAAHHAAAAAAAAA...', + '...AAAHHAHHAAHHHHHAAA...', + '...AAAAHHHAAAHHHHHAAA...', + '...AAAAAHAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAHAAAAAAAAA...', + '...AAAAAAAHHAAAAAAAAA...', + '...AAAHHAHHAAHHHHHAAA...', + '...AAAAHHHAAAHHHHHAAA...', + '...AAAAAHAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '....AAAAAAAAAAAAAAAA....', + '.....AAAAAAAAAAAAAA.....', + '........................', + ], + subagent: [ + '........................', + '........................', + '........................', + '........................', + '.....AAAA......AAAA.....', + '....AAAAAA....AAAAAA....', + '....AAAAAAA..AAAAAAA....', + '....AAAAAAA..AAAAAAA....', + '....AAAAAAA..AAAAAAA....', + '....AAAAAA...AAAAAAA....', + '.....AAAAA....AAAAA.....', + '........................', + '........................', + '........................', + '.......A................', + '....AAAAAAA..AAAAAAA....', + '...AAAAAAAAAAAAAAAAAA...', + '..AAAAAAAAAAAAAAAAAAAA..', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '........................', + '........................', + '........................', + ], + workflow: [ + '........................', + '........................', + '........................', + '..AAAAAA.........AAAAA..', + '..AAAAAA........AAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAA....AAA.AAAAAAA.', + '..AAAAAA....AAA..AAAAA..', + '............AAA.........', + '............AAA.........', + '............AAA.........', + '............AAA.........', + '............AAA..AAAAA..', + '............AAA.AAAAAAA.', + '.............AAAAAAAAAA.', + '.............AAAAAAAAAA.', + '...............AAAAAAAA.', + '................AAAAAAA.', + '.................AAAAA..', + '........................', + '........................', + '........................', + ], + goal: [ + '........................', + '....AA..................', + '...AAAA.................', + '...AAAAAAAAAAAAAAAAA....', + '...AAAAAAAAAAAAAAAA.....', + '...AAAAAAAAAAAAAAA......', + '...AAAAAAAAAAAAAAA......', + '...AAAAAAAAAAAAAA.......', + '...AAAAAAAAAAAAAA.......', + '...AAAAAAAAAAAAAAA......', + '...AAAAAAAAAAAAAAAA.....', + '...AAAAAAAAAAAAAAAAA....', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '...AAAA.................', + '....AA..................', + ], + present: [ + '........................', + '........................', + '...AAAAAAAAAAAAAAAAAA...', + '..AAAAAAAAAAAAAAAAAAAA..', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '.AAAAAAAAAAAAAAAAAHAAAA.', + '.AAAAAAAAAAAAAAAAAHAAAA.', + '.AAAAAAAAAHAAAAAAAHAAAA.', + '.AAAAAAAAAHAAAHAAAHAAAA.', + '.AAAAAHAAAHAAAHAAAHAAAA.', + '.AAAAAHAAAHAAAHAAAHAAAA.', + '.AAAAAHAAAHAAAHAAAHAAAA.', + '.AAAAAHAAAHAAAHAAAHAAAA.', + '.AAAAAHAAAHAAAHAAAHAAAA.', + '.AAAAAAAAAAAAAAAAAAAAAA.', + '..AAAAAAAAAAAAAAAAAAAA..', + '...AAAAAAAAAAAAAAAAAA...', + '.........AAAAAA.........', + '........AAAAAAAA........', + '........AAA..AAA........', + '.......AAA....AAA.......', + '.......AAA....AAA.......', + '.......AA......AA.......', + '........................', + ], + approval: [ + '........................', + '........................', + '.........AAAAAA.........', + '......AAAAAAAAAAAA......', + '....AAAAAAAAAAAAAAAA....', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '...AAAAAAAAHHAAAAAAAA...', + '....AAAAAAAHHAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '....AAAAAAAAAAAAAAAA....', + '.....AAAAAAHHAAAAAA.....', + '.....AAAAAAHHAAAAAA.....', + '......AAAAAAAAAAAA......', + '.......AAAAAAAAAA.......', + '........AAAAAAAA........', + '.........AAAAA..........', + '...........AA...........', + '........................', + ], + other: [ + '........................', + '........................', + '........................', + '...........AA...........', + '...........AA...........', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '.........AAAAAA.........', + '........AAAAAAAA........', + '.....AAAAAAAAAAAAAA.....', + '...AAAAAAAAAAAAAAAAAA...', + '...AAAAAAAAAAAAAAAAAA...', + '.....AAAAAAAAAAAAAA.....', + '........AAAAAAAA........', + '.........AAAAAA.........', + '..........AAAA..........', + '..........AAAA..........', + '..........AAAA..........', + '...........AA...........', + '...........AA...........', + '........................', + '........................', + '........................', + ], +} as const satisfies Record; + +export type PixelSymbol = keyof typeof SYMBOLS; +export const PIXEL_SYMBOLS = Object.keys(SYMBOLS) as PixelSymbol[]; + +const INK = '#2a2230'; +const channels = (color: string) => { + const n = Number.parseInt(color.slice(1), 16); + return [16, 8, 0].map((bit) => (n >> bit) & 255); +}; +const mix = (base: string, tint: string, k: number) => { + const t = channels(tint); + return `#${channels(base) + .map((v, i) => + Math.round(v * (1 - k) + t[i]! * k) + .toString(16) + .padStart(2, '0'), + ) + .join('')}`; +}; + +export function pixelSymbolCells(symbol: PixelSymbol, color: string): PixelCell[] { + return symbolArtCells(SYMBOLS[symbol], color); +} + +/** + * Colours a 24×24 character-art symbol (`A` body, `H` highlight, anything else empty) into + * cells on the 32 grid: the body in `color`, highlights lighter, the lower-right edge darker, + * and a one-pixel ink outline. This is how every built-in symbol is drawn, so a host can add + * its own symbols in the same style without touching the package. + */ +export function symbolArtCells(rows: readonly string[], color: string): PixelCell[] { + const body = new Map(); + rows.forEach((row, y) => + [...row].forEach((code, x) => { + if (code === 'A' || code === 'H') body.set(`${x + 4},${y + 4}`, code); + }), + ); + const light = mix(color, '#ffffff', 0.75); + const low = mix(color, INK, 0.25); + const cells: PixelCell[] = []; + for (const [key, code] of body) { + const [x, y] = key.split(',').map(Number) as [number, number]; + const edge = x + y > 34 && !body.has(`${x + 1},${y + 1}`); + cells.push({ x, y, c: code === 'H' ? light : edge ? low : color }); + } + const outline = new Set(); + for (const key of body.keys()) { + const [x, y] = key.split(',').map(Number) as [number, number]; + for (const [dx, dy] of [ + [1, 0], + [-1, 0], + [0, 1], + [0, -1], + ] as const) { + const next = `${x + dx},${y + dy}`; + if (body.has(next) || outline.has(next)) continue; + outline.add(next); + cells.push({ x: x + dx, y: y + dy, c: INK }); + } + } + return cells; +} diff --git a/packages/avatar/test/artwork.test.ts b/packages/avatar/test/artwork.test.ts new file mode 100644 index 0000000..b70a4e9 --- /dev/null +++ b/packages/avatar/test/artwork.test.ts @@ -0,0 +1,218 @@ +import { describe, expect, it } from 'vitest'; + +import { + AVATAR_HAIR_PARTS, + AVATAR_PARTS, + AVATAR_PRESETS, + AVATAR_RANGES, + canonicalRecipe, + detailedRecipe, + DEFAULT_RECIPE, + pixelAvatarSvg, + isPixelAvatarRecipe, + seededRecipe, + createSeededRecipe, + type AvatarPart, + type PixelAvatarRecipe, +} from '../src/index.js'; + +const parts = Object.keys(AVATAR_PARTS) as AvatarPart[]; +const variants: PixelAvatarRecipe[] = parts.flatMap((part) => + AVATAR_PARTS[part].map((value) => ({ ...DEFAULT_RECIPE, [part]: value })), +); +const crowded: PixelAvatarRecipe[] = AVATAR_PARTS.head.flatMap((head) => + AVATAR_PARTS.hair.map((hair, index) => ({ + ...DEFAULT_RECIPE, + head, + hair, + glasses: AVATAR_PARTS.glasses[index % AVATAR_PARTS.glasses.length]!, + accessory: AVATAR_PARTS.accessory[index % AVATAR_PARTS.accessory.length]!, + })), +); + +describe('pixel avatar artwork', () => { + it('renders every catalog option as distinct, inert, id-free pixel markup with stable rig nodes', () => { + for (const part of parts.filter((name) => name !== 'backdrop')) { + const rendered = new Set( + AVATAR_PARTS[part].map((value) => pixelAvatarSvg({ ...DEFAULT_RECIPE, [part]: value })), + ); + expect(rendered.size, part).toBe(AVATAR_PARTS[part].length); + } + for (const recipe of [...variants, ...crowded]) { + const svg = pixelAvatarSvg(recipe); + expect(svg).not.toMatch(/\sid=|'); + expect(svg.match(/ { + for (const [glasses, from, to] of [ + ['round', 14, 17], + ['square', 14, 17], + ] as const) { + const svg = pixelAvatarSvg({ ...DEFAULT_RECIPE, glasses }); + const row = [ + ...svg.matchAll(//gu), + ]; + const covered = new Set( + row.flatMap(([, x, w]) => Array.from({ length: Number(w) }, (_, i) => Number(x) + i)), + ); + for (let x = from; x <= to; x++) expect(covered.has(x), `${glasses} x=${x}`).toBe(true); + } + }); + + it('keeps every static pixel inside the rounded tile', () => { + const inside = (x: number, y: number) => { + const clamp = (v: number) => Math.min(Math.max(v, 6), 26); + return (x + 0.5 - clamp(x + 0.5)) ** 2 + (y + 0.5 - clamp(y + 0.5)) ** 2 <= 36; + }; + for (const recipe of [...variants, ...crowded]) { + const svg = pixelAvatarSvg(recipe).replace( + //gu, + '', + ); + for (const [, x, y, w] of svg.matchAll(/ { + const base = detailedRecipe(DEFAULT_RECIPE); + expect(isPixelAvatarRecipe(base)).toBe(true); + for (const part of Object.keys(AVATAR_HAIR_PARTS) as (keyof typeof AVATAR_HAIR_PARTS)[]) { + const rendered = new Set( + AVATAR_HAIR_PARTS[part].map((value) => + pixelAvatarSvg({ + ...base, + bangs: 'none', + sideHair: 'none', + backHair: 'none', + [part]: value, + }), + ), + ); + expect(rendered.size, part).toBe(AVATAR_HAIR_PARTS[part].length); + } + for (const [key, [min, max]] of Object.entries(AVATAR_RANGES)) { + expect(isPixelAvatarRecipe({ ...base, [key]: min })).toBe(true); + expect(isPixelAvatarRecipe({ ...base, [key]: max })).toBe(true); + expect(isPixelAvatarRecipe({ ...base, [key]: max + 1 })).toBe(false); + expect(isPixelAvatarRecipe({ ...base, [key]: min - 1 })).toBe(false); + expect(isPixelAvatarRecipe({ ...base, [key]: 0.5 })).toBe(false); + } + const { bangs: _bangs, ...partial } = base; + expect(isPixelAvatarRecipe(partial)).toBe(false); + expect(isPixelAvatarRecipe({ ...base, backHair: 'crown' })).toBe(false); + expect(detailedRecipe(base)).toBe(base); + expect(canonicalRecipe({ ...base, backHair: 'twintails' })).toMatchObject({ + bangs: base.bangs, + backHair: 'twintails', + hairLength: 0, + }); + const inside = (x: number, y: number) => { + const clamp = (v: number) => Math.min(Math.max(v, 6), 26); + return (x + 0.5 - clamp(x + 0.5)) ** 2 + (y + 0.5 - clamp(y + 0.5)) ** 2 <= 36; + }; + for (const backHair of AVATAR_HAIR_PARTS.backHair) + for (const pose of AVATAR_PARTS.pose) + for (const extreme of [-1, 1]) { + const recipe = { + ...base, + pose, + backHair, + spacing: extreme, + height: extreme, + hairLength: extreme * 2, + }; + expect(isPixelAvatarRecipe(recipe), `${backHair}/${pose}`).toBe(true); + const svg = pixelAvatarSvg(recipe, { turns: [-14, 14] }); + for (const [, x, y, w] of svg.matchAll(/ { + const ada = seededRecipe('Ada Lovelace'); + expect(isPixelAvatarRecipe(ada)).toBe(true); + expect(seededRecipe(' ada lovelace ')).toEqual(ada); + expect(ada.pose).toBe('front'); + const names = ['Ada', 'Grace', 'Linus', 'Margaret', 'Alan', 'Barbara', '小明', 'Rin']; + const recipes = names.map(seededRecipe); + expect(new Set(recipes.map((recipe) => JSON.stringify(recipe))).size).toBe(names.length); + for (const recipe of recipes) expect(() => pixelAvatarSvg(recipe)).not.toThrow(); + expect(names.map(seededRecipe)[1]).toEqual(seededRecipe(names[1]!)); + expect(createSeededRecipe('other')('Ada')).not.toEqual(seededRecipe('Ada')); + }); + + it('tints the tile from the hair colour and keeps colourless hair on paper', () => { + const tile = (hairColor: string) => + pixelAvatarSvg({ ...DEFAULT_RECIPE, hairColor }).match( + / { + expect(AVATAR_PRESETS.length).toBeGreaterThanOrEqual(12); + expect(new Set(AVATAR_PRESETS.map((recipe) => JSON.stringify(recipe))).size).toBe( + AVATAR_PRESETS.length, + ); + for (const recipe of AVATAR_PRESETS) expect(isPixelAvatarRecipe(recipe)).toBe(true); + }); + + it('rejects unknown parts and keeps the recipe closed', () => { + expect(isPixelAvatarRecipe(DEFAULT_RECIPE)).toBe(true); + for (const invalid of [ + { ...DEFAULT_RECIPE, eyes: 'laser' }, + { ...DEFAULT_RECIPE, accessory: 'glasses' }, + { ...DEFAULT_RECIPE, extra: 'x' }, + { ...DEFAULT_RECIPE, skinColor: 'red' }, + ]) + expect(isPixelAvatarRecipe(invalid)).toBe(false); + }); + + it('applies recipe colours for extreme values', () => { + const svg = pixelAvatarSvg({ + ...DEFAULT_RECIPE, + skinColor: '#000000', + hairColor: '#ffffff', + shirtColor: '#ff00ff', + }); + for (const colour of ['#000000', '#ff00ff']) expect(svg).toContain(`fill="${colour}"`); + }); + + it('renames the rig classes when asked and leaves the default untouched', () => { + const svg = pixelAvatarSvg(DEFAULT_RECIPE, { classPrefix: 'face' }); + for (const node of ['body', 'head', 'face', 'gaze', 'blink']) + expect(svg).toContain(`class="face-${node}"`); + expect(svg).not.toContain('bh-illustrated'); + expect(pixelAvatarSvg(DEFAULT_RECIPE, { classPrefix: 'bh-illustrated' })).toBe( + pixelAvatarSvg(DEFAULT_RECIPE), + ); + }); +}); diff --git a/packages/avatar/test/fixtures/botharness-golden.json b/packages/avatar/test/fixtures/botharness-golden.json new file mode 100644 index 0000000..9d579bb --- /dev/null +++ b/packages/avatar/test/fixtures/botharness-golden.json @@ -0,0 +1,832 @@ +{ + "source": "BotHarness/BotHarness@deabd0a2", + "seeds": [ + "DeepSeekBot", + "claude", + "小明", + "Vain", + "researcher", + "a", + " MixedCase ", + "🤖bot", + "writer-2", + "ops" + ], + "colors": [ + "#3fc1b8", + "#1d1b22", + "#f4f1ec" + ], + "svg": { + "default": "285a563c4c0114e7", + "default+turns": "4ea791c6ee95e657", + "preset-0": "f996a998a967ef06", + "preset-0+turns": "6fb3db71216f12e1", + "preset-1": "cbe44f7801b95b4e", + "preset-1+turns": "c54ab9357ab8babf", + "preset-2": "e09ba9238f45675f", + "preset-2+turns": "21ad8be17ec0776a", + "preset-3": "1345125b20acfb7a", + "preset-3+turns": "1b1d77b12500cb88", + "preset-4": "92927350440e58b6", + "preset-4+turns": "9631b70484c64cbb", + "preset-5": "e4242af4e6d8c333", + "preset-5+turns": "bb149f86723ddb5a", + "preset-6": "247ef444cd406d50", + "preset-6+turns": "35fe638587a3fd5a", + "preset-7": "b801742b6f92f816", + "preset-7+turns": "522ce763dff03191", + "preset-8": "dc02934ec6886d98", + "preset-8+turns": "f7f1c47f42557a82", + "preset-9": "699497b78f98bcf6", + "preset-9+turns": "d7b739cc988ba945", + "preset-10": "178902a33a52e017", + "preset-10+turns": "3fe06c669e617477", + "preset-11": "8fa05c821ce74026", + "preset-11+turns": "0032d0c5e0f3f009", + "head-round": "285a563c4c0114e7", + "head-round+turns": "4ea791c6ee95e657", + "head-oval": "f14567dcf1735e02", + "head-oval+turns": "d5a2c6596cf1f084", + "head-square": "a09ccd0c1b04fb8e", + "head-square+turns": "b3b76c96caed40ad", + "head-long": "f6e1efc95b33bd27", + "head-long+turns": "6cf42cf422e71bcc", + "head-heart": "1c39939f9920980f", + "head-heart+turns": "417a153ef5c28da4", + "head-vchin": "c79802d7888a5cb6", + "head-vchin+turns": "1458835695aae9e5", + "head-chubby": "b6568c3071393ff8", + "head-chubby+turns": "c2f5f49c3c15e9fc", + "head-diamond": "44b8376b1dffba8d", + "head-diamond+turns": "f48f06474ce0f768", + "pose-front": "285a563c4c0114e7", + "pose-front+turns": "4ea791c6ee95e657", + "pose-left": "63bd90920a342ca2", + "pose-left+turns": "ad605d13ae262627", + "pose-right": "1ee4efd800efdf76", + "pose-right+turns": "f5e66d0c9edb0bb0", + "hair-crop": "285a563c4c0114e7", + "hair-crop+turns": "4ea791c6ee95e657", + "hair-sweep": "710cefd4cc85a488", + "hair-sweep+turns": "021ab1a85267333c", + "hair-spiky": "b431c639d6bf2a4b", + "hair-spiky+turns": "a6f31f2aca6b7e8e", + "hair-buzz": "67f3d0eebf3de966", + "hair-buzz+turns": "69f7fe8680f795ee", + "hair-curly": "e0a2988d64261c17", + "hair-curly+turns": "02d44fe9fe6369be", + "hair-mohawk": "5283ecb8f7064dcb", + "hair-mohawk+turns": "ed3dde676108f5e9", + "hair-bob": "f94b5e88b129b0be", + "hair-bob+turns": "2cea0f5f0e54ff09", + "hair-long": "2c995f0a61c3beae", + "hair-long+turns": "d1a938ccaf7973b3", + "hair-bun": "b081acfcaf96c67d", + "hair-bun+turns": "e1a370936be1f2c4", + "hair-pigtails": "78b7407d7d3118bc", + "hair-pigtails+turns": "c62f9d7a8d83a354", + "hair-afro": "a76b9af101b87b35", + "hair-afro+turns": "e2a5eb374cce1627", + "hair-twintails": "2e43b2544f3b170a", + "hair-twintails+turns": "8ab6fecc94a2a764", + "hair-drills": "71a204e1150cfdc8", + "hair-drills+turns": "474c9519964efda0", + "hair-ponytail": "d35bc21669b47f45", + "hair-ponytail+turns": "f85bf65280ff4d73", + "hair-sidetail": "21544dd70bc20410", + "hair-sidetail+turns": "3c2e9d46ab65a9a9", + "hair-hime": "a4e6703d1c53ee12", + "hair-hime+turns": "d939bb19c286a900", + "hair-odango": "8ec3ff47a450a3d1", + "hair-odango+turns": "77191b6b4e1f7487", + "hair-messy": "ae9269f97e96e959", + "hair-messy+turns": "28b5f82affd20a9a", + "hair-wavy": "4a8c3fc543f59c88", + "hair-wavy+turns": "acc73ac11cfa06da", + "hair-braids": "753ae95ee133ae6f", + "hair-braids+turns": "abdf7517aefc8ce4", + "hair-wolf": "a1fa51967d977c19", + "hair-wolf+turns": "feccc5c21cbc4591", + "hair-ahoge": "97f3bc52224ed244", + "hair-ahoge+turns": "85380e5ca87d43f2", + "hair-none": "5471213a3cab8694", + "hair-none+turns": "4d40a0e1c32176d0", + "eyes-round": "285a563c4c0114e7", + "eyes-round+turns": "4ea791c6ee95e657", + "eyes-dot": "b97a1ec7bce27950", + "eyes-dot+turns": "04b4892b66a57e2f", + "eyes-sparkle": "0c73066503569766", + "eyes-sparkle+turns": "f33b976b17c8ce81", + "eyes-lashes": "fcb80068ef5731af", + "eyes-lashes+turns": "def6d4c6cf6a3b7c", + "eyes-sleepy": "1278287aef7a39de", + "eyes-sleepy+turns": "dfc3755fa498fbd6", + "eyes-happy": "74cdd998be7692e5", + "eyes-happy+turns": "2c0d72e9f356e1f5", + "eyes-wink": "b94ffa536bd5518d", + "eyes-wink+turns": "f99e7aa7a69db5cd", + "eyes-sharp": "09aa3d58f647d8f8", + "eyes-sharp+turns": "fcad5834211de141", + "brows-soft": "285a563c4c0114e7", + "brows-soft+turns": "4ea791c6ee95e657", + "brows-thick": "72edad85d442f789", + "brows-thick+turns": "d130591bb30ccf9f", + "brows-raised": "9664a6d0366e5d1b", + "brows-raised+turns": "ffe11f8291d5efee", + "brows-angry": "53489a45c30cc805", + "brows-angry+turns": "94493fc0ebf75654", + "brows-worried": "8ce7e448f39cdafe", + "brows-worried+turns": "aeb904ab92500b49", + "brows-none": "f5c8ff46994012b2", + "brows-none+turns": "22c4a6fb8ca8f01b", + "nose-button": "285a563c4c0114e7", + "nose-button+turns": "4ea791c6ee95e657", + "nose-dot": "4d8de292d5dadca1", + "nose-dot+turns": "e1ce5914edb327ec", + "nose-line": "08e7dc5909847f12", + "nose-line+turns": "b90b40ea687c8203", + "nose-none": "5eef778313d45844", + "nose-none+turns": "81808f723ea31662", + "mouth-smile": "285a563c4c0114e7", + "mouth-smile+turns": "4ea791c6ee95e657", + "mouth-grin": "cbd44ec4d3a45a99", + "mouth-grin+turns": "3643365f2972f203", + "mouth-open": "1b71a93d2a8c5d25", + "mouth-open+turns": "2fe93926d77c2569", + "mouth-flat": "c97538b8f3f8dd0f", + "mouth-flat+turns": "bd13d43ce03308de", + "mouth-smirk": "bf71020e57e138f8", + "mouth-smirk+turns": "b21a6ba82d8fece6", + "mouth-cat": "6c6ee7fa1cddc29a", + "mouth-cat+turns": "637ed42c66e755ee", + "mouth-tongue": "91ea97a4e7877973", + "mouth-tongue+turns": "8dc83617d605c276", + "mouth-o": "f2c49ed30fe404e1", + "mouth-o+turns": "e888dfc5c45010ac", + "cheeks-blush": "285a563c4c0114e7", + "cheeks-blush+turns": "4ea791c6ee95e657", + "cheeks-freckles": "5806c3b8f170ab26", + "cheeks-freckles+turns": "fdeb3cad5feb7fb7", + "cheeks-none": "a49bc30806660488", + "cheeks-none+turns": "b5dee8db43efcf83", + "glasses-none": "285a563c4c0114e7", + "glasses-none+turns": "4ea791c6ee95e657", + "glasses-round": "b7859dfd576d8db7", + "glasses-round+turns": "2bfba8a3cf3603d5", + "glasses-square": "4a995b03dbcb9e80", + "glasses-square+turns": "1468dc9418ee8adc", + "glasses-shades": "1fc5c72c47cc2a55", + "glasses-shades+turns": "54e01115fcd3bcf4", + "glasses-monocle": "86f9f129b90aa46d", + "glasses-monocle+turns": "8431db12e0dcb3a3", + "outfit-tee": "285a563c4c0114e7", + "outfit-tee+turns": "4ea791c6ee95e657", + "outfit-shirttie": "825613453bfe1e55", + "outfit-shirttie+turns": "682696db8feae1b2", + "outfit-hoodie": "ea697082e73d1e2b", + "outfit-hoodie+turns": "40eab4e68cf3ec1c", + "outfit-turtleneck": "87bd15e043a6c706", + "outfit-turtleneck+turns": "769f1302f1301218", + "outfit-sailor": "cfa9f2da4676e415", + "outfit-sailor+turns": "fe626f9e25cb829e", + "outfit-blazer": "8112eaca3b918b96", + "outfit-blazer+turns": "34ea3f1b9333c933", + "outfit-overalls": "00840c9e2b3c97ac", + "outfit-overalls+turns": "52272e42bd0067d1", + "outfit-dress": "975e7af4010a10ad", + "outfit-dress+turns": "955dbb69c2141795", + "outfit-kimono": "deb6eacf4e948bf3", + "outfit-kimono+turns": "d0ac5c3398e46bb4", + "outfit-cardigan": "785af1016831f83a", + "outfit-cardigan+turns": "3d02a6708c54605f", + "outfit-maid": "5d3882167e9998f8", + "outfit-maid+turns": "5107463a87a96328", + "outfit-jacket": "835229408c3ca2db", + "outfit-jacket+turns": "baee8d543842dd9e", + "backdrop-sparkles": "285a563c4c0114e7", + "backdrop-sparkles+turns": "4ea791c6ee95e657", + "backdrop-hearts": "285a563c4c0114e7", + "backdrop-hearts+turns": "4ea791c6ee95e657", + "backdrop-stars": "285a563c4c0114e7", + "backdrop-stars+turns": "4ea791c6ee95e657", + "backdrop-dots": "285a563c4c0114e7", + "backdrop-dots+turns": "4ea791c6ee95e657", + "backdrop-none": "285a563c4c0114e7", + "backdrop-none+turns": "4ea791c6ee95e657", + "accessory-none": "285a563c4c0114e7", + "accessory-none+turns": "4ea791c6ee95e657", + "accessory-beanie": "6b89616098311e0a", + "accessory-beanie+turns": "8983414c3f36de62", + "accessory-cap": "e5b0858a38745f49", + "accessory-cap+turns": "e33a70d5c78733b0", + "accessory-headphones": "a5d362bf010fdd56", + "accessory-headphones+turns": "327fbee34e42fda1", + "accessory-flower": "7d8fb235bf8d0a49", + "accessory-flower+turns": "96c63443d11a8104", + "accessory-bow": "6acb06536c3d7d19", + "accessory-bow+turns": "b074384ecdd1fc18", + "accessory-earring": "6a1623093c272dfa", + "accessory-earring+turns": "70e68f2f8b755174", + "accessory-crown": "4061f4037f308974", + "accessory-crown+turns": "b36ecf0a5765d480", + "accessory-halo": "80e931d14f53cc3e", + "accessory-halo+turns": "07e45b3ce700645c", + "accessory-catears": "f2ac609936d75916", + "accessory-catears+turns": "e447921ab42e7373", + "accessory-hairclip": "ec60268c167c00fa", + "accessory-hairclip+turns": "6f5338e731bca69c", + "accessory-horns": "e76dacd072292f6d", + "accessory-horns+turns": "df807c951646a119", + "accessory-beret": "279c4ea9adb31070", + "accessory-beret+turns": "ec3ba459a7238be1", + "accessory-ribbon": "d14cc32fcb3d9b63", + "accessory-ribbon+turns": "78f041e7a34486fc", + "accessory-headband": "3e0580801a77a9b1", + "accessory-headband+turns": "2cde8e96e6813309", + "accessory-bunnyears": "3b809ed44a336896", + "accessory-bunnyears+turns": "f1bb84b5b26f54d1", + "accessory-horseears": "49f45442151cc3b3", + "accessory-horseears+turns": "eb839d9ba776f1c3", + "accessory-flowercrown": "bec2adf4311e1fa3", + "accessory-flowercrown+turns": "afda6d4d2cb053d3", + "accessory-witch": "90f87235999bfd8d", + "accessory-witch+turns": "9c11c37c392c7f4b", + "accessory-pins": "db8aab9b9157602c", + "accessory-pins+turns": "9c366ba2bd199749" + }, + "detailed": { + "base": "285a563c4c0114e7", + "base+turns": "4ea791c6ee95e657", + "preset-0": "9f8eb208359ad07a", + "preset-0+turns": "f27440f9a0977d53", + "preset-1": "cbe44f7801b95b4e", + "preset-1+turns": "c54ab9357ab8babf", + "preset-2": "e09ba9238f45675f", + "preset-2+turns": "21ad8be17ec0776a", + "preset-3": "1345125b20acfb7a", + "preset-3+turns": "1b1d77b12500cb88", + "preset-4": "92927350440e58b6", + "preset-4+turns": "9631b70484c64cbb", + "preset-5": "885d43db2bc07a8a", + "preset-5+turns": "f163695eeecd22a7", + "preset-6": "ace162e5b0591869", + "preset-6+turns": "a9529e105408609d", + "preset-7": "57dc94bc36228e8b", + "preset-7+turns": "00c30a14a6532329", + "preset-8": "dc02934ec6886d98", + "preset-8+turns": "f7f1c47f42557a82", + "preset-9": "699497b78f98bcf6", + "preset-9+turns": "d7b739cc988ba945", + "preset-10": "fb6cfad714590e61", + "preset-10+turns": "4637dadc042bd5a2", + "preset-11": "8fa05c821ce74026", + "preset-11+turns": "0032d0c5e0f3f009", + "bangs-crop": "f76fb8293db4a0bf", + "bangs-crop+turns": "b2a8af6c807bab04", + "bangs-bob": "3ede980c8452dd35", + "bangs-bob+turns": "0abb23d477bb27e7", + "bangs-sweep": "7ab98bd7b2bea266", + "bangs-sweep+turns": "1a9e8b6577008d12", + "bangs-spiky": "51e489eacbded3d3", + "bangs-spiky+turns": "5ab69a5a8024f7fe", + "bangs-curly": "2927917fba5d848e", + "bangs-curly+turns": "ccda25f44e2cde4c", + "bangs-messy": "65e438f158444608", + "bangs-messy+turns": "e344b2ace925ed29", + "bangs-wolf": "1d4d764cb370f345", + "bangs-wolf+turns": "46835edc6d1d38d0", + "bangs-wavy": "4e32b9788570092e", + "bangs-wavy+turns": "828d4cb77b774814", + "bangs-ahoge": "04f36a05fb003cd1", + "bangs-ahoge+turns": "2813098db77d35f6", + "bangs-hime": "cd54914a0e5f7aab", + "bangs-hime+turns": "eeadd1f42d29ec1b", + "bangs-buzz": "67f3d0eebf3de966", + "bangs-buzz+turns": "69f7fe8680f795ee", + "bangs-mohawk": "5283ecb8f7064dcb", + "bangs-mohawk+turns": "ed3dde676108f5e9", + "bangs-none": "5471213a3cab8694", + "bangs-none+turns": "4d40a0e1c32176d0", + "sideHair-crop": "6db5a6106d0e8263", + "sideHair-crop+turns": "881568fddbd754f9", + "sideHair-bun": "4e4acd843f86f133", + "sideHair-bun+turns": "2a7acc23badc72a7", + "sideHair-bob": "2930991a048ae8db", + "sideHair-bob+turns": "eb4456357f87d9dc", + "sideHair-long": "df53b999933d65ca", + "sideHair-long+turns": "572e829ae138f2ca", + "sideHair-hime": "ce3ce92d3859923f", + "sideHair-hime+turns": "7cdcbd5daac8455f", + "sideHair-curly": "b81321371c7f98eb", + "sideHair-curly+turns": "6991564fe0c66633", + "sideHair-braids": "3e0b7351b3bb9349", + "sideHair-braids+turns": "4ca9498f37da591b", + "sideHair-none": "5471213a3cab8694", + "sideHair-none+turns": "4d40a0e1c32176d0", + "backHair-none": "5471213a3cab8694", + "backHair-none+turns": "4d40a0e1c32176d0", + "backHair-bob": "a79786f913b13044", + "backHair-bob+turns": "7df676bcdc915743", + "backHair-long": "5f9aba8b69a11565", + "backHair-long+turns": "2866ce8ab258e556", + "backHair-wavy": "acbd1f66e6826def", + "backHair-wavy+turns": "ac44ddecb0e99a35", + "backHair-wolf": "4f7c86626003ed81", + "backHair-wolf+turns": "558fd45a156ad9f0", + "backHair-bun": "3539530509f0c553", + "backHair-bun+turns": "adda8e59c068c983", + "backHair-odango": "9f7d2a80ca2c88e2", + "backHair-odango+turns": "42869c88e27f44a5", + "backHair-pigtails": "ad35f8688e5f58c5", + "backHair-pigtails+turns": "c6665a05bc1bfe27", + "backHair-twintails": "7052a827bb826002", + "backHair-twintails+turns": "b8e6102213e6b906", + "backHair-drills": "e0470de7b533be09", + "backHair-drills+turns": "8a9d4a98f9558573", + "backHair-ponytail": "028c086aae9c2365", + "backHair-ponytail+turns": "10b91cb66bd76b1f", + "backHair-sidetail": "7c3d6f85294718fe", + "backHair-sidetail+turns": "3a17f0c01169c4a7", + "backHair-afro": "adc5ea4cc2d10a8f", + "backHair-afro+turns": "04e6f5f5c81078c7", + "spacing=-1": "89fab98f7dce631a", + "spacing=-1+turns": "2b1a2c4ef0dd00ac", + "spacing=1": "d2b6225cf2e96255", + "spacing=1+turns": "f5c3bdf83a24f388", + "height=-1": "c4efb49fb9a4f24e", + "height=-1+turns": "94432dc24a1591aa", + "height=1": "4d51f8d71e117a7e", + "height=1+turns": "b4d8357eec3b2927", + "hairLength=-2": "3048a5868cb301bb", + "hairLength=-2+turns": "11d051b3199c1f86", + "hairLength=2": "bfbc01940c902045", + "hairLength=2+turns": "69e2ce259c817fd8" + }, + "seeded": { + "DeepSeekBot": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "oval", + "pose": "front", + "hair": "bob", + "eyes": "sparkle", + "brows": "thick", + "nose": "button", + "mouth": "smile", + "cheeks": "blush", + "glasses": "none", + "outfit": "overalls", + "backdrop": "sparkles", + "accessory": "hairclip", + "skinColor": "#f2c9a8", + "hairColor": "#1d1b22", + "eyeColor": "#4c8a3c", + "shirtColor": "#2f3a4a" + }, + "claude": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "vchin", + "pose": "front", + "hair": "bob", + "eyes": "round", + "brows": "thick", + "nose": "none", + "mouth": "smile", + "cheeks": "freckles", + "glasses": "none", + "outfit": "cardigan", + "backdrop": "hearts", + "accessory": "hairclip", + "skinColor": "#9a6142", + "hairColor": "#5a3a2a", + "eyeColor": "#d9a13a", + "shirtColor": "#3d9970" + }, + "小明": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "heart", + "pose": "front", + "hair": "twintails", + "eyes": "round", + "brows": "thick", + "nose": "button", + "mouth": "cat", + "cheeks": "blush", + "glasses": "none", + "outfit": "kimono", + "backdrop": "hearts", + "accessory": "headphones", + "skinColor": "#9a6142", + "hairColor": "#5a3a2a", + "eyeColor": "#d9a13a", + "shirtColor": "#7a5cc7" + }, + "Vain": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "chubby", + "pose": "front", + "hair": "pigtails", + "eyes": "sharp", + "brows": "raised", + "nose": "dot", + "mouth": "open", + "cheeks": "blush", + "glasses": "none", + "outfit": "maid", + "backdrop": "hearts", + "accessory": "headphones", + "skinColor": "#c68863", + "hairColor": "#8a5a36", + "eyeColor": "#8a5ad0", + "shirtColor": "#3d9970" + }, + "researcher": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "square", + "pose": "front", + "hair": "ponytail", + "eyes": "sparkle", + "brows": "thick", + "nose": "button", + "mouth": "open", + "cheeks": "freckles", + "glasses": "none", + "outfit": "sailor", + "backdrop": "hearts", + "accessory": "flower", + "skinColor": "#f2c9a8", + "hairColor": "#c4452f", + "eyeColor": "#8a5ad0", + "shirtColor": "#e07a5f" + }, + "a": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "square", + "pose": "front", + "hair": "hime", + "eyes": "sparkle", + "brows": "thick", + "nose": "dot", + "mouth": "open", + "cheeks": "freckles", + "glasses": "none", + "outfit": "tee", + "backdrop": "dots", + "accessory": "flower", + "skinColor": "#9a6142", + "hairColor": "#f06292", + "eyeColor": "#4c8a3c", + "shirtColor": "#5b8bd6" + }, + " MixedCase ": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "square", + "pose": "front", + "hair": "buzz", + "eyes": "round", + "brows": "raised", + "nose": "none", + "mouth": "smile", + "cheeks": "none", + "glasses": "none", + "outfit": "overalls", + "backdrop": "hearts", + "accessory": "hairclip", + "skinColor": "#c68863", + "hairColor": "#8a5a36", + "eyeColor": "#2f9e8f", + "shirtColor": "#2f3a4a" + }, + "🤖bot": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "long", + "pose": "front", + "hair": "sidetail", + "eyes": "round", + "brows": "raised", + "nose": "none", + "mouth": "open", + "cheeks": "blush", + "glasses": "none", + "outfit": "dress", + "backdrop": "sparkles", + "accessory": "hairclip", + "skinColor": "#9a6142", + "hairColor": "#d9475a", + "eyeColor": "#4c8a3c", + "shirtColor": "#3d9970" + }, + "writer-2": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "square", + "pose": "front", + "hair": "pigtails", + "eyes": "lashes", + "brows": "soft", + "nose": "none", + "mouth": "cat", + "cheeks": "freckles", + "glasses": "none", + "outfit": "kimono", + "backdrop": "hearts", + "accessory": "headphones", + "skinColor": "#6e4129", + "hairColor": "#8a5a36", + "eyeColor": "#d9a13a", + "shirtColor": "#5b8bd6" + }, + "ops": { + "schemaVersion": 1, + "family": "illustrated", + "assetVersion": 1, + "rigVersion": 1, + "head": "diamond", + "pose": "front", + "hair": "wavy", + "eyes": "happy", + "brows": "thick", + "nose": "dot", + "mouth": "cat", + "cheeks": "none", + "glasses": "none", + "outfit": "hoodie", + "backdrop": "hearts", + "accessory": "flower", + "skinColor": "#c68863", + "hairColor": "#e2b04a", + "eyeColor": "#4c8a3c", + "shirtColor": "#e2565f" + } + }, + "symbols": { + "thinking#3fc1b8": "4a377e18811f94c0", + "thinking#1d1b22": "9d8dadc904b91dab", + "thinking#f4f1ec": "9c32361bec686b32", + "ask#3fc1b8": "94ce21f274a95f4f", + "ask#1d1b22": "ff32add2ee00aeb5", + "ask#f4f1ec": "b968e1ceb402d9bf", + "read#3fc1b8": "b4065d9770ad8558", + "read#1d1b22": "69affef882e81193", + "read#f4f1ec": "e3e0d9f888dbe420", + "write#3fc1b8": "072c0b4abfab08cc", + "write#1d1b22": "615727c6c14a9d8a", + "write#f4f1ec": "431c35d0dfeda8c6", + "edit#3fc1b8": "52286cbe82fef2a2", + "edit#1d1b22": "35bb4f4dd07df0ea", + "edit#f4f1ec": "82f29c262a65054e", + "bash#3fc1b8": "1d66c179b72f1bc4", + "bash#1d1b22": "2b404460b0fec8c2", + "bash#f4f1ec": "568dcdf580d13458", + "search#3fc1b8": "fd82bc945f999a45", + "search#1d1b22": "497efb0476f6d7c7", + "search#f4f1ec": "5462715683eccf7b", + "web#3fc1b8": "3526ad6f54e1f316", + "web#1d1b22": "44c3c6384e1ad59a", + "web#f4f1ec": "b8459b7366f61c6f", + "fetch#3fc1b8": "ca7052523a0c4607", + "fetch#1d1b22": "bf6a3dfe0de9971e", + "fetch#f4f1ec": "c4ccbcd0cf26a153", + "todo#3fc1b8": "e9fa6cdc352e6a78", + "todo#1d1b22": "612e69afa9c90095", + "todo#f4f1ec": "7f41e4d321c6bf0d", + "subagent#3fc1b8": "f024e103d50e73ea", + "subagent#1d1b22": "d487d1d240cce0c3", + "subagent#f4f1ec": "08067a2157ff1ebc", + "workflow#3fc1b8": "24b484d3fd8d6ec0", + "workflow#1d1b22": "ad89494aa87fed81", + "workflow#f4f1ec": "22cd3e3c22ac7c59", + "goal#3fc1b8": "f2c2117e98634b5f", + "goal#1d1b22": "d7858ada5eb4656d", + "goal#f4f1ec": "8ae1b3e16b86d51f", + "present#3fc1b8": "87383f97477c9425", + "present#1d1b22": "ed4717d9acd8bf5e", + "present#f4f1ec": "4bcbf69ebecda660", + "approval#3fc1b8": "2d792a2e3aab33ce", + "approval#1d1b22": "3973d8147410ab48", + "approval#f4f1ec": "976695ce16f37ec7", + "other#3fc1b8": "45f6d6f569a0a232", + "other#1d1b22": "3b7288df9703c406", + "other#f4f1ec": "a6da0c64aef31a2f" + }, + "morph": { + "preset-0>thinking": "f5617bbf94f2bf99", + "preset-0>ask": "1ad9e7c64cd163f4", + "preset-0>read": "d8854ea950405f88", + "preset-0>write": "5f9376fbc247e76e", + "preset-0>edit": "f6d5078e84e9e29d", + "preset-0>bash": "63d3ae4dd2e68b14", + "preset-0>search": "797f100fffeb6f1a", + "preset-0>web": "91819608c2c4eb25", + "preset-0>fetch": "59590d6475294bc4", + "preset-0>todo": "3ae85fa5e9d75b1f", + "preset-0>subagent": "3ae870805b0ef26e", + "preset-0>workflow": "b39e04fe1c0e40f2", + "preset-0>goal": "0e5689abf1fd4c12", + "preset-0>present": "dd3bd8e4b49ea7b8", + "preset-0>approval": "59c19db66f12d909", + "preset-0>other": "f0c1a90047a7f8ea", + "preset-1>thinking": "3be7ad12ad8a7613", + "preset-1>ask": "0c68fbd291d93fe8", + "preset-1>read": "181e8cb8f1720352", + "preset-1>write": "754f5e6e11dbb22f", + "preset-1>edit": "48bf4579a167b62c", + "preset-1>bash": "6e8a096b23633f73", + "preset-1>search": "1baee8afdf23c236", + "preset-1>web": "993ab19bd52ba4f6", + "preset-1>fetch": "f3f0b41c3c1e1b54", + "preset-1>todo": "031686c209c6d56d", + "preset-1>subagent": "618eb91ada8751e3", + "preset-1>workflow": "3fffb0bd908d83ee", + "preset-1>goal": "2dabb41b0a4d0992", + "preset-1>present": "fe75a172910ffc99", + "preset-1>approval": "eadc04d5826d9047", + "preset-1>other": "0c01430d80ebc166", + "preset-2>thinking": "6a53348dc432d38e", + "preset-2>ask": "2603cf99209fe959", + "preset-2>read": "d6aa29252ab6e5c2", + "preset-2>write": "65c1d82978ff20ed", + "preset-2>edit": "5b67a39a25a9b086", + "preset-2>bash": "8505e371e4dea5a0", + "preset-2>search": "7ca51849ed0c0d5e", + "preset-2>web": "5c51870ca11678b1", + "preset-2>fetch": "08648261c2c52dbb", + "preset-2>todo": "fcf2a7ed372c0254", + "preset-2>subagent": "7f5085a57e0176d5", + "preset-2>workflow": "b9aeda793a956482", + "preset-2>goal": "84193ecf5ed8e7b1", + "preset-2>present": "848d2a1dd27a23f1", + "preset-2>approval": "5a157d432768b726", + "preset-2>other": "0812d2d95d108151", + "preset-3>thinking": "3a91925570504c94", + "preset-3>ask": "024d7256784c1814", + "preset-3>read": "ea905c55d54c7f30", + "preset-3>write": "8fb0daabd1cf2008", + "preset-3>edit": "43e678b5282b952d", + "preset-3>bash": "e51cd29a0a9e5f03", + "preset-3>search": "0f03a10446830355", + "preset-3>web": "3756e75cc6ce086c", + "preset-3>fetch": "c471ecf07139a491", + "preset-3>todo": "b27ce887a208a4e5", + "preset-3>subagent": "ec19d7260c5c2d78", + "preset-3>workflow": "e3467b3866ba9f19", + "preset-3>goal": "9615c55b620366ca", + "preset-3>present": "05fc67d6e0849162", + "preset-3>approval": "edbc3dafa25c769f", + "preset-3>other": "a353921b5ec3d7a3", + "preset-4>thinking": "f680ddbac11b9088", + "preset-4>ask": "9794caa5303e6ae1", + "preset-4>read": "dc91e54f93eafccf", + "preset-4>write": "13b805f417e53c34", + "preset-4>edit": "f97423038d598aac", + "preset-4>bash": "64ea137a4f8431dd", + "preset-4>search": "d77e927cedca99c6", + "preset-4>web": "cd6a8117df390189", + "preset-4>fetch": "13211c0fab1f0465", + "preset-4>todo": "60569b58f4b4f09a", + "preset-4>subagent": "d9bd086fb53ac396", + "preset-4>workflow": "b5d560897d4946d7", + "preset-4>goal": "d28c954aab7387d1", + "preset-4>present": "29a5292553207ce9", + "preset-4>approval": "c0386710805537bd", + "preset-4>other": "31d841049e73206a", + "preset-5>thinking": "84877ab9c1ba199a", + "preset-5>ask": "7a25767da415a4b1", + "preset-5>read": "36464f07a447e663", + "preset-5>write": "094c954353613914", + "preset-5>edit": "de62a1d54b2f1413", + "preset-5>bash": "122645578893566e", + "preset-5>search": "aeb3ad42bcc2a0a9", + "preset-5>web": "42ce0aeb0d261ce6", + "preset-5>fetch": "692cf9a09f03de0b", + "preset-5>todo": "bbbe381d6c6a4a9d", + "preset-5>subagent": "9ee66dcf3fd12d07", + "preset-5>workflow": "8d25d9f898bd277c", + "preset-5>goal": "798c5eb896fdb5b1", + "preset-5>present": "b5ff7a98dc143b41", + "preset-5>approval": "4b195793ac09ba19", + "preset-5>other": "f74efd1cabc79982", + "preset-6>thinking": "11eaf32a26507e85", + "preset-6>ask": "fed1f9f063a1eeb3", + "preset-6>read": "66e8d8f19523645d", + "preset-6>write": "7e16469f79db2ee4", + "preset-6>edit": "e518f89b8b878722", + "preset-6>bash": "adbff0d350fa50e3", + "preset-6>search": "a2454aee53838338", + "preset-6>web": "0a0bcc29426e5f51", + "preset-6>fetch": "37ed264d70c6cd2e", + "preset-6>todo": "eef54304114d9ca2", + "preset-6>subagent": "a61e2d0771aaebdb", + "preset-6>workflow": "87a5bde23d70c725", + "preset-6>goal": "41b1513bc26aa2d9", + "preset-6>present": "e8d0311bb7ed9d07", + "preset-6>approval": "9e1a503b9d3271be", + "preset-6>other": "6e348b28e0452082", + "preset-7>thinking": "732086888387bff7", + "preset-7>ask": "0b7e75fe210fb342", + "preset-7>read": "e87938e265959b31", + "preset-7>write": "1da27ff21ae37a88", + "preset-7>edit": "43a8660d35b6c980", + "preset-7>bash": "dd637965924c5b69", + "preset-7>search": "2cbdfd0b8f0588aa", + "preset-7>web": "fbb08899292231a7", + "preset-7>fetch": "82336989b2247aab", + "preset-7>todo": "d1b21fc21e5bf8f9", + "preset-7>subagent": "91817d9f69517483", + "preset-7>workflow": "872984d8e9372baa", + "preset-7>goal": "7f508026e23f7b60", + "preset-7>present": "aa8a40d0fc9ffbfc", + "preset-7>approval": "4562f853b6d4cb1f", + "preset-7>other": "7d1c474d8d696b8e", + "preset-8>thinking": "40711c6cb7486fcc", + "preset-8>ask": "b7c9756e2e5a1aec", + "preset-8>read": "ef5b19bea52fe956", + "preset-8>write": "a4b9ea4728675d88", + "preset-8>edit": "4eb3554cca868b64", + "preset-8>bash": "4f1b4287c2627baa", + "preset-8>search": "c9b54c1028a8e1b0", + "preset-8>web": "5fd051d26b21ff74", + "preset-8>fetch": "6cbabcc52e915031", + "preset-8>todo": "679e276e2ea26c82", + "preset-8>subagent": "f83318c9df9491b0", + "preset-8>workflow": "49c6205fe392a24a", + "preset-8>goal": "508e9c5e6ec950fd", + "preset-8>present": "6c0e7d3c3347a38a", + "preset-8>approval": "501a7ec8930f5d5a", + "preset-8>other": "31536a6bb32fe696", + "preset-9>thinking": "554522f5cb20a4ae", + "preset-9>ask": "7a3143f197b7cac7", + "preset-9>read": "4b331f996032a662", + "preset-9>write": "605c1baacc094642", + "preset-9>edit": "b46d137b8efdaeb1", + "preset-9>bash": "904af10c042230ff", + "preset-9>search": "e62c3db2cce0a522", + "preset-9>web": "69217f0c73d65a15", + "preset-9>fetch": "0ba6e8c3857abb5f", + "preset-9>todo": "d81ec793e4cef6c7", + "preset-9>subagent": "db3893f90e222f49", + "preset-9>workflow": "bd3318f13988002f", + "preset-9>goal": "c85cbdd449ebad8f", + "preset-9>present": "248962d700cb0e67", + "preset-9>approval": "7846fa4378d86622", + "preset-9>other": "3c332762ba1fcd15", + "preset-10>thinking": "7eebaea4583f4d8f", + "preset-10>ask": "66fe735932f8ac7b", + "preset-10>read": "c9b47d3210a3ab4d", + "preset-10>write": "9f95130c4c0e3683", + "preset-10>edit": "33c897864d933a08", + "preset-10>bash": "cfec054f53d6b8cb", + "preset-10>search": "f1549f387d498f1f", + "preset-10>web": "374caf6d51884743", + "preset-10>fetch": "42cd4ddb8dfd7105", + "preset-10>todo": "f2e9f46546daf342", + "preset-10>subagent": "800523057d74f928", + "preset-10>workflow": "efdfa70ecac66358", + "preset-10>goal": "2d3099c7575ebeb3", + "preset-10>present": "498dc605a52abe47", + "preset-10>approval": "9ae75b6531ef5f2c", + "preset-10>other": "fb650213cfa29f36", + "preset-11>thinking": "0944d8737ef9c0be", + "preset-11>ask": "9029c6c05f22b8f4", + "preset-11>read": "a7b6e39cb0d4dd11", + "preset-11>write": "2b29417dca4b9195", + "preset-11>edit": "8055eb020b7f7c55", + "preset-11>bash": "193a5dfcc4a3885d", + "preset-11>search": "45a2536561687009", + "preset-11>web": "3923a5486b02d0c9", + "preset-11>fetch": "b8d5a5de864a38bd", + "preset-11>todo": "06881a63001778c1", + "preset-11>subagent": "edd11f172d648c72", + "preset-11>workflow": "0d4067ea743023d2", + "preset-11>goal": "6e7261ac963d7ecd", + "preset-11>present": "58661146568b4bf9", + "preset-11>approval": "2c9937a0c042c695", + "preset-11>other": "0c8ac2fac70ad8c6" + } +} diff --git a/packages/avatar/test/golden.test.ts b/packages/avatar/test/golden.test.ts new file mode 100644 index 0000000..4a9b7b1 --- /dev/null +++ b/packages/avatar/test/golden.test.ts @@ -0,0 +1,97 @@ +import { createHash } from 'node:crypto'; +import { readFileSync } from 'node:fs'; +import { pixelFrame, pixelMarkup, planPixels } from '@botharness/pixel-morph'; +import { describe, expect, it } from 'vitest'; +import { + AVATAR_HAIR_PARTS, + AVATAR_PARTS, + AVATAR_PRESETS, + AVATAR_RANGES, + AVATAR_TURNS, + DEFAULT_RECIPE, + detailedRecipe, + PIXEL_SYMBOLS, + faceCells, + pixelAvatarSvg, + pixelSymbolCells, + seededRecipe, + type PixelAvatarRecipe, +} from '../src/index.js'; + +// Hashes of BotHarness's own output before extraction (see `source` in the fixture). Saved +// avatars and name-seeded faces must not change when BotHarness switches to this package. +const golden = JSON.parse( + readFileSync(new URL('./fixtures/botharness-golden.json', import.meta.url), 'utf8'), +) as { + seeds: string[]; + colors: string[]; + svg: Record; + detailed: Record; + seeded: Record; + symbols: Record; + morph: Record; +}; +const hash = (s: string) => createHash('sha256').update(s).digest('hex').slice(0, 16); + +describe('BotHarness compatibility', () => { + it('renders every catalog option and preset exactly as BotHarness did', () => { + const recipes: Record = { default: DEFAULT_RECIPE }; + AVATAR_PRESETS.forEach((recipe, index) => (recipes[`preset-${index}`] = recipe)); + for (const [part, values] of Object.entries(AVATAR_PARTS)) + for (const value of values) + recipes[`${part}-${value}`] = { ...DEFAULT_RECIPE, [part]: value }; + const actual: Record = {}; + for (const [key, recipe] of Object.entries(recipes)) { + actual[key] = hash(pixelAvatarSvg(recipe)); + actual[`${key}+turns`] = hash(pixelAvatarSvg(recipe, { turns: AVATAR_TURNS })); + } + expect(actual).toEqual(golden.svg); + }); + + it('renders split hair and bounded geometry exactly as BotHarness does', () => { + const base = detailedRecipe(DEFAULT_RECIPE); + const recipes: Record = { base }; + AVATAR_PRESETS.forEach( + (recipe, index) => (recipes[`preset-${index}`] = detailedRecipe(recipe)), + ); + for (const [part, values] of Object.entries(AVATAR_HAIR_PARTS)) + for (const value of values) + recipes[`${part}-${value}`] = { + ...base, + bangs: 'none', + sideHair: 'none', + backHair: 'none', + [part]: value, + }; + for (const [key, [min, max]] of Object.entries(AVATAR_RANGES)) + for (const value of [min, max]) + recipes[`${key}=${value}`] = { ...base, backHair: 'long', [key]: value }; + const actual: Record = {}; + for (const [key, recipe] of Object.entries(recipes)) { + actual[key] = hash(pixelAvatarSvg(recipe)); + actual[`${key}+turns`] = hash(pixelAvatarSvg(recipe, { turns: AVATAR_TURNS })); + } + expect(actual).toEqual(golden.detailed); + }); + + it('seeds the same face from the same name', () => { + for (const seed of golden.seeds) expect(seededRecipe(seed), seed).toEqual(golden.seeded[seed]); + }); + + it('draws the same symbols and the same morph frames', () => { + const symbols: Record = {}; + for (const symbol of PIXEL_SYMBOLS) + for (const color of golden.colors) + symbols[`${symbol}${color}`] = hash(JSON.stringify(pixelSymbolCells(symbol, color))); + expect(symbols).toEqual(golden.symbols); + const morph: Record = {}; + for (const [index, recipe] of AVATAR_PRESETS.entries()) + for (const symbol of PIXEL_SYMBOLS) { + const pairs = planPixels(faceCells(recipe), pixelSymbolCells(symbol, recipe.hairColor)); + morph[`preset-${index}>${symbol}`] = hash( + [0, 0.1, 0.25, 0.5, 0.75, 0.9, 1].map((t) => pixelMarkup(pixelFrame(pairs, t))).join('|'), + ); + } + expect(morph).toEqual(golden.morph); + }); +}); diff --git a/packages/avatar/test/symbols.test.ts b/packages/avatar/test/symbols.test.ts new file mode 100644 index 0000000..5440d62 --- /dev/null +++ b/packages/avatar/test/symbols.test.ts @@ -0,0 +1,35 @@ +import { describe, expect, it } from 'vitest'; +import { + DEFAULT_RECIPE, + PIXEL_SYMBOLS, + faceCells, + pixelSymbolCells, + symbolArtCells, +} from '../src/index.js'; + +describe('pixel avatar symbols', () => { + it('draws every symbol inside the 32 grid in the given colour with an ink outline', () => { + for (const symbol of PIXEL_SYMBOLS) { + const cells = pixelSymbolCells(symbol, '#3fc1b8'); + expect(cells.length, symbol).toBeGreaterThan(80); + expect(cells.every((c) => c.x >= 0 && c.x < 32 && c.y >= 0 && c.y < 32)).toBe(true); + expect( + cells.some((c) => c.c === '#3fc1b8'), + symbol, + ).toBe(true); + expect( + cells.some((c) => c.c === '#2a2230'), + symbol, + ).toBe(true); + expect(new Set(cells.map((c) => `${c.x},${c.y}`)).size).toBe(cells.length); + } + expect(faceCells(DEFAULT_RECIPE).length).toBeGreaterThan(400); + }); + + it('draws host-supplied character art in the built-in style', () => { + const cells = symbolArtCells(['AA', 'AH'], '#3fc1b8'); + expect(cells.filter((c) => c.c === '#3fc1b8')).toHaveLength(3); + expect(cells.find((c) => c.x === 5 && c.y === 5)!.c).not.toBe('#3fc1b8'); + expect(cells.filter((c) => c.c === '#2a2230')).toHaveLength(8); + }); +}); diff --git a/packages/avatar/tsconfig.json b/packages/avatar/tsconfig.json new file mode 100644 index 0000000..7680f99 --- /dev/null +++ b/packages/avatar/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["src", "test"] +} diff --git a/packages/avatar/tsdown.config.ts b/packages/avatar/tsdown.config.ts new file mode 100644 index 0000000..a77b5a2 --- /dev/null +++ b/packages/avatar/tsdown.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['esm'], + dts: true, + clean: true, + sourcemap: true, + // the package is type: module, so the ESM output is plain .js + outExtensions: () => ({ js: '.js', dts: '.d.ts' }), +}); diff --git a/packages/morph/LICENSE b/packages/morph/LICENSE new file mode 100644 index 0000000..34b99b5 --- /dev/null +++ b/packages/morph/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 BotHarness + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/morph/README.md b/packages/morph/README.md new file mode 100644 index 0000000..1b786aa --- /dev/null +++ b/packages/morph/README.md @@ -0,0 +1,26 @@ +# @botharness/pixel-morph + +Morph any pixel art into any other, snapped to the grid. No dependencies. + +```ts +import { + cellsFromRows, + morphPixels, + pixelFrame, + pixelMarkup, + planPixels, +} from '@botharness/pixel-morph'; + +const from = cellsFromRows(['XX', 'XX'], { X: '#2a2230' }); +const to = cellsFromRows(['YYYY'], { Y: '#3fc1b8' }, 10, 10); + +// browser: animate an SVG +const run = morphPixels(group, from, to, 800); +await run.finished; + +// anywhere: compute frames yourself +const pairs = planPixels(from, to); +const svgRects = pixelMarkup(pixelFrame(pairs, 0.5)); +``` + +Grids default to 32×32; pass `{ size }` to `planPixels`, `pixelFrame` and `morphPixels` for others. `run.current()` returns the pixels on screen, so a new morph can start mid-flight. diff --git a/packages/morph/package.json b/packages/morph/package.json new file mode 100644 index 0000000..70ddbc5 --- /dev/null +++ b/packages/morph/package.json @@ -0,0 +1,45 @@ +{ + "name": "@botharness/pixel-morph", + "version": "0.1.0", + "description": "Morph any pixel art into any other: pairing, arcs and grid-snapped frames, with an SVG renderer", + "keywords": [ + "animation", + "morph", + "pixel-art", + "svg", + "transition" + ], + "homepage": "https://github.com/BotHarness/BotPixel", + "bugs": { + "url": "https://github.com/BotHarness/BotPixel/issues" + }, + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/BotHarness/BotPixel.git", + "directory": "packages/morph" + }, + "files": [ + "dist" + ], + "type": "module", + "sideEffects": false, + "main": "./dist/index.js", + "module": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "tsdown", + "typecheck": "tsc --noEmit" + }, + "devDependencies": { + "tsdown": "^0.20.0", + "typescript": "^5.9.3" + } +} diff --git a/packages/morph/src/index.ts b/packages/morph/src/index.ts new file mode 100644 index 0000000..6b3df6d --- /dev/null +++ b/packages/morph/src/index.ts @@ -0,0 +1,197 @@ +/** One coloured pixel on an integer grid. */ +export interface PixelCell { + x: number; + y: number; + c: string; +} + +/** A planned flight from one source pixel to one target pixel. */ +export interface PixelPair { + from: PixelCell; + to: PixelCell; + delay: number; + arc: number; +} + +export interface PixelGridOptions { + /** Width and height of the square grid, in pixels. Defaults to 32. */ + size?: number; +} + +export interface PixelMorphRun { + current(): PixelCell[]; + cancel(): void; + finished: Promise; +} + +const STAGGER = 0.67; + +/** + * Pairs every pixel of `from` with one of `to`. Both sets are swept by angle around their own + * centroid, then matched by proportional index, so neighbours fly to neighbours and the + * smaller set is reused (pixels split or merge). Each pair gets a start delay (4×4 clumps, + * top rows first, checkerboard offset) and an arc height of 2–4 pixels. + */ +export function planPixels( + from: readonly PixelCell[], + to: readonly PixelCell[], + options: PixelGridOptions = {}, +): PixelPair[] { + const clumpRows = (options.size ?? 32) / 4; + const sweep = (set: readonly PixelCell[]) => { + const cx = set.reduce((sum, p) => sum + p.x, 0) / set.length; + const cy = set.reduce((sum, p) => sum + p.y, 0) / set.length; + return set + .map((p) => ({ p, a: Math.atan2(p.y - cy, p.x - cx), r: Math.hypot(p.x - cx, p.y - cy) })) + .sort((m, n) => m.a - n.a || m.r - n.r) + .map((item) => item.p); + }; + if (from.length === 0 || to.length === 0) return []; + const source = sweep(from); + const target = sweep(to); + const count = Math.max(source.length, target.length); + return Array.from({ length: count }, (_, index) => { + const a = source[Math.floor((index * source.length) / count)]!; + const b = target[Math.floor((index * target.length) / count)]!; + const by = Math.floor(a.y / 4); + const bx = Math.floor(a.x / 4); + return { + from: a, + to: b, + delay: (by / clumpRows) * 0.28 + ((bx + by) % 2) * 0.04, + arc: 2 + ((bx * 3 + by) % 3), + }; + }); +} + +const ease = (t: number) => + t <= 0 ? 0 : t >= 1 ? 1 : t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2; + +/** + * The pixels shown at progress `t` (0–1): each pair eases along its path, hops by + * `sin(kπ)·arc`, snaps to the grid and switches colour halfway. Later pairs win a shared cell. + */ +export function pixelFrame( + pairs: readonly PixelPair[], + t: number, + options: PixelGridOptions = {}, +): PixelCell[] { + const size = options.size ?? 32; + const grid = new Map(); + for (const pair of pairs) { + const k = ease((t - pair.delay) / STAGGER); + const x = Math.round(pair.from.x + (pair.to.x - pair.from.x) * k); + const y = Math.round( + pair.from.y + (pair.to.y - pair.from.y) * k - Math.sin(k * Math.PI) * pair.arc, + ); + if (x < 0 || y < 0 || x >= size || y >= size) continue; + grid.set(y * size + x, { x, y, c: k < 0.5 ? pair.from.c : pair.to.c }); + } + return [...grid.values()]; +} + +/** Escapes a value for a double-quoted XML attribute. */ +export function escapeAttribute(value: string): string { + return value.replace(/[&<>"']/gu, (char) => `&#${char.charCodeAt(0)};`); +} + +/** + * SVG `` markup for cells, merging horizontal runs of one colour. Colours are escaped and + * cells whose coordinates are not finite numbers are skipped, so the markup is safe to assign to + * `innerHTML` whatever the cells contain. + */ +export function pixelMarkup(cells: readonly PixelCell[]): string { + const rows = new Map>(); + for (const cell of cells) { + if (!Number.isFinite(cell.x) || !Number.isFinite(cell.y)) continue; + let row = rows.get(cell.y); + if (!row) rows.set(cell.y, (row = new Map())); + row.set(cell.x, cell.c); + } + let markup = ''; + for (const [y, row] of rows) { + const xs = [...row.keys()].sort((a, b) => a - b); + for (let i = 0; i < xs.length;) { + const x = xs[i]!; + const color = row.get(x)!; + let width = 1; + while (xs[i + width] === x + width && row.get(x + width) === color) width++; + markup += ``; + i += width; + } + } + return markup; +} + +const active = new WeakMap(); + +/** + * Plays a morph into an SVG group with `requestAnimationFrame`. `current()` returns the pixels + * on screen, so a new morph can start from mid-flight. Starting a morph on a group cancels the + * one already running there, so only the newest run draws. + */ +export function morphPixels( + group: SVGGElement, + from: readonly PixelCell[], + to: readonly PixelCell[], + duration: number, + options: PixelGridOptions = {}, +): PixelMorphRun { + active.get(group)?.cancel(); + const pairs = planPixels(from, to, options); + let frame = 0; + let start = -1; + let shown: PixelCell[] = [...from]; + let drawn = ''; + let settle: (done: boolean) => void = () => undefined; + const finished = new Promise((resolve) => { + settle = resolve; + }); + const tick = (time: number) => { + if (start < 0) start = time; + const t = Math.min(1, (time - start) / duration); + shown = t >= 1 ? [...to] : pixelFrame(pairs, t, options); + const markup = pixelMarkup(shown); + if (markup !== drawn) group.innerHTML = drawn = markup; + if (t >= 1) { + frame = 0; + if (active.get(group) === run) active.delete(group); + settle(true); + return; + } + frame = requestAnimationFrame(tick); + }; + const run: PixelMorphRun = { + current: () => shown, + cancel() { + if (frame) cancelAnimationFrame(frame); + frame = 0; + if (active.get(group) === run) active.delete(group); + settle(false); + }, + finished, + }; + active.set(group, run); + frame = requestAnimationFrame(tick); + return run; +} + +/** + * Cells from character art: each character is looked up in `palette`, and characters without + * an entry are empty. `ox`/`oy` offset the art on the grid. + */ +export function cellsFromRows( + rows: readonly string[], + palette: Readonly>, + ox = 0, + oy = 0, +): PixelCell[] { + const cells: PixelCell[] = []; + rows.forEach((row, y) => + [...row].forEach((code, x) => { + const c = palette[code]; + if (c) cells.push({ x: x + ox, y: y + oy, c }); + }), + ); + return cells; +} diff --git a/packages/morph/test/morph.test.ts b/packages/morph/test/morph.test.ts new file mode 100644 index 0000000..13f4261 --- /dev/null +++ b/packages/morph/test/morph.test.ts @@ -0,0 +1,111 @@ +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { + cellsFromRows, + morphPixels, + pixelFrame, + pixelMarkup, + planPixels, + type PixelCell, +} from '../src/index.js'; + +const key = (cells: readonly PixelCell[]) => + cells + .map((c) => `${c.x},${c.y},${c.c}`) + .sort() + .join(' '); +const square = cellsFromRows(['XX', 'XX'], { X: '#111111' }, 2, 2); +const bar = cellsFromRows(['YYYYYYYY'], { Y: '#eeeeee' }, 20, 25); + +describe('planPixels and pixelFrame', () => { + it('pairs the larger set fully and lands exactly on the target', () => { + const pairs = planPixels(square, bar); + expect(pairs).toHaveLength(8); + expect(key(pixelFrame(pairs, 0))).toBe(key(square)); + expect(key(pixelFrame(pairs, 1.5))).toBe(key(bar)); + }); + + it('stays on whole grid cells, inside the grid, with no duplicates', () => { + const pairs = planPixels(square, bar); + for (let t = 0; t <= 1; t += 0.05) { + const frame = pixelFrame(pairs, t); + expect(frame.every((c) => Number.isInteger(c.x) && Number.isInteger(c.y))).toBe(true); + expect(frame.every((c) => c.x >= 0 && c.x < 32 && c.y >= 0 && c.y < 32)).toBe(true); + expect(new Set(frame.map((c) => `${c.x},${c.y}`)).size).toBe(frame.length); + } + }); + + it('clips to a custom grid size', () => { + const far = cellsFromRows(['Z'], { Z: '#222222' }, 60, 60); + const pairs = planPixels(square, far, { size: 64 }); + expect(key(pixelFrame(pairs, 2, { size: 64 }))).toBe(key(far)); + expect(pixelFrame(pairs, 2)).toEqual([]); + }); + + it('returns no pairs when either side is empty', () => { + expect(planPixels([], bar)).toEqual([]); + expect(planPixels(square, [])).toEqual([]); + }); +}); + +describe('pixelMarkup', () => { + it('merges horizontal runs of one colour', () => { + expect(pixelMarkup(cellsFromRows(['AAB'], { A: '#000000', B: '#ffffff' }))).toBe( + '', + ); + }); + + it('escapes colours so they cannot leave the fill attribute', () => { + const markup = pixelMarkup([{ x: 0, y: 0, c: '"/> { + const hostile = { x: '0" onload="alert(1)', y: 0, c: '#000000' } as unknown as PixelCell; + expect(pixelMarkup([hostile, { x: 1, y: Number.NaN, c: '#000000' }])).toBe(''); + }); +}); + +describe('morphPixels', () => { + afterEach(() => vi.unstubAllGlobals()); + + it('draws frames until the target and can be cancelled mid-flight', async () => { + const callbacks: FrameRequestCallback[] = []; + vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => callbacks.push(cb)); + vi.stubGlobal('cancelAnimationFrame', () => undefined); + const step = (time: number) => callbacks.shift()!(time); + const group = { innerHTML: '' } as unknown as SVGGElement; + + const run = morphPixels(group, square, bar, 100); + step(0); + step(50); + expect(group.innerHTML).not.toBe(pixelMarkup(bar)); + step(100); + await expect(run.finished).resolves.toBe(true); + expect(group.innerHTML).toBe(pixelMarkup(bar)); + + const again = morphPixels(group, bar, square, 100); + step(0); + step(40); + const shown = again.current(); + again.cancel(); + await expect(again.finished).resolves.toBe(false); + expect(shown.length).toBeGreaterThan(0); + }); + + it('lets only the newest run on a group draw', async () => { + const callbacks: FrameRequestCallback[] = []; + vi.stubGlobal('requestAnimationFrame', (cb: FrameRequestCallback) => callbacks.push(cb)); + vi.stubGlobal('cancelAnimationFrame', (id: number) => { + callbacks[id - 1] = () => undefined; + }); + const group = { innerHTML: '' } as unknown as SVGGElement; + const first = morphPixels(group, square, bar, 100); + callbacks[0]!(0); + const second = morphPixels(group, first.current(), square, 100); + await expect(first.finished).resolves.toBe(false); + for (let i = 1, time = 0; i < callbacks.length; i++, time += 50) callbacks[i]!(time); + await expect(second.finished).resolves.toBe(true); + expect(group.innerHTML).toBe(pixelMarkup(square)); + }); +}); diff --git a/packages/morph/tsconfig.json b/packages/morph/tsconfig.json new file mode 100644 index 0000000..7680f99 --- /dev/null +++ b/packages/morph/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../tsconfig.base.json", + "include": ["src", "test"] +} diff --git a/packages/morph/tsdown.config.ts b/packages/morph/tsdown.config.ts new file mode 100644 index 0000000..a77b5a2 --- /dev/null +++ b/packages/morph/tsdown.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsdown'; + +export default defineConfig({ + entry: ['src/index.ts'], + format: ['esm'], + dts: true, + clean: true, + sourcemap: true, + // the package is type: module, so the ESM output is plain .js + outExtensions: () => ({ js: '.js', dts: '.d.ts' }), +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..bd0fa6a --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,2311 @@ +--- +lockfileVersion: '9.0' + +importers: + + .: + configDependencies: {} + packageManagerDependencies: + pnpm: + specifier: 12.4.2 + version: 12.4.2 + +packages: + + '@pnpm/exe.android-arm64@12.4.2': + resolution: {integrity: sha512-E255MbcQ0V1577M2BV0ajWuP7KmTPYA0jqZnk3rK6Lq3kTvZWulMMb7iqRmnLsQbyWTkMEB2CfyM70loVDA8xg==} + cpu: [arm64] + os: [android] + + '@pnpm/exe.android-x64@12.4.2': + resolution: {integrity: sha512-J1pSeCUwuKxMG70ZzpWn8JzElxiEa8NN/3N0SlZRtU2xbztChaJCKF3HaBNIj9yPfeofWzJo/lwNvDDjraQuZw==} + cpu: [x64] + os: [android] + + '@pnpm/exe.darwin-arm64@12.4.2': + resolution: {integrity: sha512-A0WDo8iErfZBXgrLseQxw8i8Y9ctUpOEl/Uu+cubnTzpD8tT9ykIB548L8YTM2WD4OS+ZOHSxy8aGZcvKq8PaQ==} + cpu: [arm64] + os: [darwin] + + '@pnpm/exe.darwin-x64@12.4.2': + resolution: {integrity: sha512-MSgJdovBWHcb5DEOvfPH9yNi/T5O1Xa4ess+E1ESGo/5yuty7S4JoiIjami+fsNXfnoQMlwsMUqYU4zAvBcNCw==} + cpu: [x64] + os: [darwin] + + '@pnpm/exe.freebsd-x64@12.4.2': + resolution: {integrity: sha512-h2YumlQSNvgbRPv+RXwABohX65f9bOBZn+jMIt7bFDISZPCzQ+Nvpt6Awbp4ip5PwQgYxbu5iREJ1fHE39Fm8A==} + cpu: [x64] + os: [freebsd] + + '@pnpm/exe.linux-arm64-musl@12.4.2': + resolution: {integrity: sha512-LwSEtSEDTv6S51YLs3YvSkPyun/QmfMic1UGICUkPWFu6ByP43RdMlkKvmVkfGhAYCpnxO057vrmyJqtfZrPCA==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-arm64@12.4.2': + resolution: {integrity: sha512-2dSiDXyhx+RTHsewxex8f/jVjqQXWJ2oow4kCVHEWdZKeBpgMxvZ6fHkTAUBJXgqhbKIDHvuNlZBP7gJfUWL5A==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-ppc64@12.4.2': + resolution: {integrity: sha512-8Itc+jQk+MTz04LS9D1RcH+VctAWmzM4l1cJQ+Sx7pAJNo7EKHdRMbC0Tok1jyQ7eEHNJZD5EleYneZqWfZM+g==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-riscv64@12.4.2': + resolution: {integrity: sha512-hleOeqhTVpH+z9RVMGnxvU4ZnrkBUClWjCbHD9u6kwyqhGSpevoU1wTGish+CBRhmIgMAy9pAfFpqhbAKOKNfw==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-s390x@12.4.2': + resolution: {integrity: sha512-LAsQRRdP9aToENR6dtcIJ9l+e1zMYOX0tQcLGpRyLPVBQcYRLlvAPcmDshsiIHQjp05SDa9FI0czX1ZQ1a7a/A==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@pnpm/exe.linux-x64-musl@12.4.2': + resolution: {integrity: sha512-kzfzH2/0BWdTABK14Yj5a1xsdkTEQUp2eXEPNakaD9jKL025lq3hyaKHIz/gIZaPDMe/1bFFK/En4ztFlbBJxw==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@pnpm/exe.linux-x64@12.4.2': + resolution: {integrity: sha512-/pbt0UVTa8NMDhzOWLQRfZ6G9ROKXlJPZtx845BqyWfc7hCrWXhTLBd70yO2y8+E+IWN3oHM1s/JsIQNGk1yvg==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@pnpm/exe.win32-arm64@12.4.2': + resolution: {integrity: sha512-PsW19e4dAUNpZ0cS9flaxFuAmpt2dKlH/Vvi8TZ4qyJjjQzue/CEsWm+6wKVP4CJ7IT8RdL4qh+soOPWIgF2Zw==} + cpu: [arm64] + os: [win32] + + '@pnpm/exe.win32-x64@12.4.2': + resolution: {integrity: sha512-+xGoeE0g55ztWvl8i5QqdmNfW3nIrTVcoQrNshEOwxthm9Ag48oXton3uxOA3/SANyz5AXexEjj2KO20NnOrEw==} + cpu: [x64] + os: [win32] + + pnpm@12.4.2: + resolution: {integrity: sha512-CK3GYTGAJ1x8ntraOdzwjJxhrU5+rzMKTzRh8QKw+QdCNFTRF/mOctR/7wYWBwZE17/8lzpqV/UJCm18NosHyQ==} + engines: {node: '>=18.*'} + hasBin: true + +snapshots: + + '@pnpm/exe.android-arm64@12.4.2': + optional: true + + '@pnpm/exe.android-x64@12.4.2': + optional: true + + '@pnpm/exe.darwin-arm64@12.4.2': + optional: true + + '@pnpm/exe.darwin-x64@12.4.2': + optional: true + + '@pnpm/exe.freebsd-x64@12.4.2': + optional: true + + '@pnpm/exe.linux-arm64-musl@12.4.2': + optional: true + + '@pnpm/exe.linux-arm64@12.4.2': + optional: true + + '@pnpm/exe.linux-ppc64@12.4.2': + optional: true + + '@pnpm/exe.linux-riscv64@12.4.2': + optional: true + + '@pnpm/exe.linux-s390x@12.4.2': + optional: true + + '@pnpm/exe.linux-x64-musl@12.4.2': + optional: true + + '@pnpm/exe.linux-x64@12.4.2': + optional: true + + '@pnpm/exe.win32-arm64@12.4.2': + optional: true + + '@pnpm/exe.win32-x64@12.4.2': + optional: true + + pnpm@12.4.2: + optionalDependencies: + '@pnpm/exe.android-arm64': 12.4.2 + '@pnpm/exe.android-x64': 12.4.2 + '@pnpm/exe.darwin-arm64': 12.4.2 + '@pnpm/exe.darwin-x64': 12.4.2 + '@pnpm/exe.freebsd-x64': 12.4.2 + '@pnpm/exe.linux-arm64': 12.4.2 + '@pnpm/exe.linux-arm64-musl': 12.4.2 + '@pnpm/exe.linux-ppc64': 12.4.2 + '@pnpm/exe.linux-riscv64': 12.4.2 + '@pnpm/exe.linux-s390x': 12.4.2 + '@pnpm/exe.linux-x64': 12.4.2 + '@pnpm/exe.linux-x64-musl': 12.4.2 + '@pnpm/exe.win32-arm64': 12.4.2 + '@pnpm/exe.win32-x64': 12.4.2 + +--- +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/node': + specifier: ^22.20.2 + version: 22.20.5 + oxfmt: + specifier: ^0.68.0 + version: 0.68.0 + oxlint: + specifier: ^1.50.0 + version: 1.86.0 + tsdown: + specifier: ^0.20.0 + version: 0.20.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(typescript@7.0.2) + typescript: + specifier: 7.0.2 + version: 7.0.2 + vitest: + specifier: ^4.0.18 + version: 4.1.11(@types/node@22.20.5)(vite@8.3.2(@types/node@22.20.5)) + + packages/avatar: + dependencies: + '@botharness/pixel-morph': + specifier: workspace:^ + version: link:../morph + devDependencies: + tsdown: + specifier: ^0.20.0 + version: 0.20.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(typescript@5.9.3) + typescript: + specifier: ^5.9.3 + version: 5.9.3 + + packages/morph: + devDependencies: + tsdown: + specifier: ^0.20.0 + version: 0.20.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(typescript@5.9.3) + typescript: + specifier: ^5.9.3 + version: 5.9.3 + +packages: + + '@babel/generator@8.0.0-rc.2': + resolution: {integrity: sha512-oCQ1IKPwkzCeJzAPb7Fv8rQ9k5+1sG8mf2uoHiMInPYvkRfrDJxbTIbH51U+jstlkghus0vAi3EBvkfvEsYNLQ==} + engines: {node: ^20.19.0 || >=22.12.0} + + '@babel/helper-string-parser@8.0.6': + resolution: {integrity: sha512-+6HYEBnsDRZHJtUTAEfMQd0zMDqdFHS7C+5vAsEZqBUr3vEMWOWlHJ0Jz1gS8jJIlCvLsuA6ivmeoqzH936YcA==} + engines: {node: ^22.18.0 || >=24.11.0} + + '@babel/helper-validator-identifier@8.0.0-rc.2': + resolution: {integrity: sha512-xExUBkuXWJjVuIbO7z6q7/BA9bgfJDEhVL0ggrggLMbg0IzCUWGT1hZGE8qUH7Il7/RD/a6cZ3AAFrrlp1LF/A==} + engines: {node: ^20.19.0 || >=22.12.0} + + '@babel/helper-validator-identifier@8.0.6': + resolution: {integrity: sha512-HYx0YmuchRxRSpnjvcNffnPS8DCauKNmnumIuHG3jnQAVewRA7kfJGwF13ayEpSZs7s4R/oBH4eppuXcAQd5JQ==} + engines: {node: ^22.18.0 || >=24.11.0} + + '@babel/parser@8.0.0-rc.2': + resolution: {integrity: sha512-29AhEtcq4x8Dp3T72qvUMZHx0OMXCj4Jy/TEReQa+KWLln524Cj1fWb3QFi0l/xSpptQBR6y9RNEXuxpFvwiUQ==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + '@babel/parser@8.0.6': + resolution: {integrity: sha512-LpGDIYJAzc3Y3PT9x+FxBrGYu2PlWxLmyN7SwPTzaX0LSwEmFJBsRnPBqmaXF2r1v+Zhz6lNiEJ+7yKtM5+Ugg==} + engines: {node: ^22.18.0 || >=24.11.0} + hasBin: true + + '@babel/types@8.0.0-rc.2': + resolution: {integrity: sha512-91gAaWRznDwSX4E2tZ1YjBuIfnQVOFDCQ2r0Toby0gu4XEbyF623kXLMA8d4ZbCu+fINcrudkmEcwSUHgDDkNw==} + engines: {node: ^20.19.0 || >=22.12.0} + + '@babel/types@8.0.6': + resolution: {integrity: sha512-c+xgSWboV2pdwXP67BUWDVRHi2BO5Q3KwxyFVs7taVTY+fsK47/L51ZXQoV9rozHJDNHvJ4v4WEsI/IlxV2l2A==} + engines: {node: ^22.18.0 || >=24.11.0} + + '@emnapi/core@1.10.0': + resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} + + '@emnapi/runtime@1.10.0': + resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} + + '@emnapi/wasi-threads@1.2.1': + resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==} + + '@jridgewell/gen-mapping@0.3.13': + resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} + + '@jridgewell/resolve-uri@3.1.2': + resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.6.0': + resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@napi-rs/wasm-runtime@1.2.4': + resolution: {integrity: sha512-AJxoUD2/15ESHbvpcyjU274nsAPLuOtPHCk0vKJM5pj//Fg/B1FXNWjPnXTT9PymCYYiHo4zPj0ZomXBKhoy7g==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || ^2.0.0-alpha.4 + '@emnapi/runtime': ^1.7.1 || ^2.0.0-alpha.4 + + '@oxc-project/types@0.112.0': + resolution: {integrity: sha512-m6RebKHIRsax2iCwVpYW2ErQwa4ywHJrE4sCK3/8JK8ZZAWOKXaRJFl/uP51gaVyyXlaS4+chU1nSCdzYf6QqQ==} + + '@oxc-project/types@0.127.0': + resolution: {integrity: sha512-aIYXQBo4lCbO4z0R3FHeucQHpF46l2LbMdxRvqvuRuW2OxdnSkcng5B8+K12spgLDj93rtN3+J2Vac/TIO+ciQ==} + + '@oxc-project/types@0.152.0': + resolution: {integrity: sha512-oM/5rLBm2tPkg0iBgkH/FOeR3PCDpY19GTgAZjMFM8h9WI9VW7cLgzp6nwtarYKmovavIQZ+Fe/RKX/8C8O/Rw==} + + '@oxfmt/binding-android-arm-eabi@0.68.0': + resolution: {integrity: sha512-dhfYPbzv/h9JgHjNkl2R6sOjUfxDyLGOZVb3g8/ScaTNwwJcYgmHh8kcYFDUhinuy1QAoANCWUvw1jlk+z6gAg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxfmt/binding-android-arm64@0.68.0': + resolution: {integrity: sha512-v3Njdi6qY0O/5eGfg01ww2w6gTn2mUvZ72Bnx1/UN53A9wruh3Nk6otc3WkgJLkXD4Qgz1SOcVQieH1oD03V9Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxfmt/binding-darwin-arm64@0.68.0': + resolution: {integrity: sha512-ei4MCMzHFREmZwPJ7KuWUB4kBuHdsgDrnXGJVcEAopU7fj7S42I8BChdFILWdHvhFqR08FLJtOfbZIr2CDw0cA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxfmt/binding-darwin-x64@0.68.0': + resolution: {integrity: sha512-UrKgzZxYhwB9DSvTX+vdgl9M32wLUNKJcAKIoiyx/Kzn/zveqi7W6kYVcRroFMhS3Kwz0KhTk3WBeSuQn4YCTg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxfmt/binding-freebsd-x64@0.68.0': + resolution: {integrity: sha512-6jrEKgpJbilM1QaRv7hEtKXr4p4AK4jvvyOtajwyhu0kOz3e0O7OLnSTk6tBotRqCcUC4ehZRJ1Zx+Y99wieLw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxfmt/binding-linux-arm-gnueabihf@0.68.0': + resolution: {integrity: sha512-YOIVnKOBaLeGullskS179N12hjSAdFYnzLjOaKiLhAKNWgnShq9w4xRdtmUm6BlnP65l2/EA9Aw/KlftNxDM7Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm-musleabihf@0.68.0': + resolution: {integrity: sha512-xW5XoEHVNqydPBv2KXvk9lmEzyAlOQHVEazKoXUuAacqekjya+OdiaFjjEBl0oJD02raG8g3TRl9OVCh9PDIHA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm64-gnu@0.68.0': + resolution: {integrity: sha512-QCvYwVVQieu6oyJglAgV9vH/YMDxZyR4cwVSYtoq9oOXd5N+D3TDUBjNwxFrLn5AdcJZOcvn/7IB17vJGp+2Og==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-arm64-musl@0.68.0': + resolution: {integrity: sha512-4TVz5iFQ8ndrHnhX50UXiz9BIWAtUSOHJ6Nus4qWFfJBXq/Ed/krXbF/ehJu42BXM5tIvBs99jNIM22s9agY5A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-ppc64-gnu@0.68.0': + resolution: {integrity: sha512-qLe3ao0RP84bnPxBvRI+GnlK/jybo538NWu0Xrm+zYeTmJtpzqLhnnd5BH21NafqKnplbGZjtN1cnrOlWF73lw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-gnu@0.68.0': + resolution: {integrity: sha512-Yvyl7a6gbb0vM6r925KW2dO+/CmXySO5TVbcX7o/uZJ+d108HFOG0TxIyHApmn5USuj5mhDPxzhiVwOlGP7uSA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-riscv64-musl@0.68.0': + resolution: {integrity: sha512-mJlFuFVCxzrYM5sFStN433D/s/mb6Wq4aCQAM02vs/OudHywnaSAd2rb1vlYUJtqdYIciJtiasuxvfbYkv5fLg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-linux-s390x-gnu@0.68.0': + resolution: {integrity: sha512-RlfSg++qs1hbKltRR6lYvV9EoI3MdlfSQD9w1hdHVYjHqjIn1tkH4FWOpMSmjKGN20zr+nI+W9o4ARogCDudGQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-gnu@0.68.0': + resolution: {integrity: sha512-nyzRB9U+dlYUKu3pMo3afHzZBUv/oTHZMG36ZfJViNVfOIzp70Q4GS8FFRGgYJ/p0zcyDCgpBvYISOdJOMh+jQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxfmt/binding-linux-x64-musl@0.68.0': + resolution: {integrity: sha512-iCx3sbZRIvGrL1RafphEiUKBaW1lc0/tAjKOIB/Wjw2+STRBEdu5+fH1Gc1faEWEmc2k5Ks4iUUV54Zd5C9a1A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxfmt/binding-openharmony-arm64@0.68.0': + resolution: {integrity: sha512-x2X5AZez7OgyLLFpwIgItoXBUqudDM7yiaTsxv8R8vKQ6e81l0jVw0NFeUCXzcl1sAJq8h+tC8N4mY8EiMeL4w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxfmt/binding-win32-arm64-msvc@0.68.0': + resolution: {integrity: sha512-AHVPjXkenLPQUh6kB8zSC8pX2ct9r4T1Edk9r/RNJyov6wPsS5uAfYtipwG4chn6+3bPFG5rI/3DxEeH8vib1w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxfmt/binding-win32-ia32-msvc@0.68.0': + resolution: {integrity: sha512-n09SjEk5VH7z8Hl4WVP7hho+cCwGViENkQFiM45vbW85dJd7kEhWaHRUobaPzEmrWyu6uumd4EuNfNyDKLtzDA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxfmt/binding-win32-x64-msvc@0.68.0': + resolution: {integrity: sha512-gPe+dJLXaPuWPWqlpklDAJp0k+K9KhQPYiQLHfb+i2rmFuUGfJ/5Qlj6tr1mO6of5g0DiLjG/XCFHIaPhotqqA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@oxlint/binding-android-arm-eabi@1.86.0': + resolution: {integrity: sha512-63Ozq6yQn79B2UxjSZ9huJmI+3/ZPI7hxAe6TyFh9oQL447KnIMoffOdtog+h4KILbQr61ZRvFPW5gYbAUgpgQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxlint/binding-android-arm64@1.86.0': + resolution: {integrity: sha512-JdLGp44phbf/0Du236Dt06yfK6Qw8xhTFeDvHJdjk167r59OfP5+BL31mgMYVnswS8e+j6tFuccSY0QDC/lgCw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxlint/binding-darwin-arm64@1.86.0': + resolution: {integrity: sha512-h+vkOr4ik6KLFCXdtNVEj9xfnXfNUpPoF95QjORdhiSpLqQePzcN81kGHjAgsw1/G7WBWK5KsFKbI2UK8EyzMA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxlint/binding-darwin-x64@1.86.0': + resolution: {integrity: sha512-wbglRuH5eKsp68keTOOeKDHU1astWSRYFsh2bwKQTAPb44rD6kVgzYI1ZrAJRTc6/7PH55ZXFCQx0rQXrj0UdA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxlint/binding-freebsd-x64@1.86.0': + resolution: {integrity: sha512-yTQ7QSOlNfQsrfbeVweTiegQJLKPjUKgXp/JpGiFzza6Hp29S9LAoH77TM3L0RjK39iQRZB5lk5iq2t241Mfag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxlint/binding-linux-arm-gnueabihf@1.86.0': + resolution: {integrity: sha512-QYJGy0E2Tv8GAayyBIeHFTwQb8u+zrvrOYrifuDGZDr9ad5XsDhiMScpZymhS9fwWjqrgG2ZUwT4vpY0ISqp4Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm-musleabihf@1.86.0': + resolution: {integrity: sha512-oQo83CafLT8p3qh0AGkN0tSUIh5Hm63mfDsoqUmBQUBnSZLNBAbyRaAftfGY5a0cKZ34dG6jAtMYgcY5kZqt5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxlint/binding-linux-arm64-gnu@1.86.0': + resolution: {integrity: sha512-EM6wy5c2UM12qPb7iDJDBAZvHyfEJGH6iosFgaFiaRZpirz99//EHcUyD2KAskz07x1TULuiAtsojf4nvWWksw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-arm64-musl@1.86.0': + resolution: {integrity: sha512-vCiUQb9ZNzZalxYRU4mlZwUqT5f+c7Sk9DwUOplWHtik3Dl4r3DVnUB5tBeRuTAUe6MUVCTylNW7TkkN8J1oTw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-ppc64-gnu@1.86.0': + resolution: {integrity: sha512-T0AzE89yjTYmOhB/hb6i+rWTpe2mYt+xiguBhs9DEPIJTZ1H8OYqsE4VxJHHw2Wlq8Mztwvp2P8NV87ZOuhPRw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-gnu@1.86.0': + resolution: {integrity: sha512-s49r0K2f5Oc7fJoMUO1WkdhYK5Ob79uYRwWQ/XNoGysaOq3RUGmGUbHSuXiyydTTA+P9xEdDEnnlZVXiaSJhlw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-riscv64-musl@1.86.0': + resolution: {integrity: sha512-JIa2tYR8ayb3nvcMSZzn4O/xTy13S7MHllu7cBD+B5qDQXXSRy/Vwk1aNpiTjZmBJGwKCHOy/NvnY5Xcwg27uQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@oxlint/binding-linux-s390x-gnu@1.86.0': + resolution: {integrity: sha512-XwXMyBsAuWZkhZU74UNcfQKr1CJJAKnS80dZzOnjl6A4fKcf91IjFgidegQugMHA5SN8ulwDXEDV1yPntjXgQQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-gnu@1.86.0': + resolution: {integrity: sha512-C1WjukSyMnr66b+w1/tV8RFVv6d9v0MzDf4p9IxVXknqgmTHBgZh1pccN1eHzFr0b9Tbb3OXoPsAAdAuHAQfeA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@oxlint/binding-linux-x64-musl@1.86.0': + resolution: {integrity: sha512-ap6KLmvC38c6MdYzsIh25cXQupqYvjd37tMNftzrX1DCtkX1Gcf2B+S2B17dD4lKa5c5gJog7DQJyDo82PBKyw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@oxlint/binding-openharmony-arm64@1.86.0': + resolution: {integrity: sha512-996Q9w/2GLwNyy5Djs39Jt09aFlr4b7TPhoj7dvo5FHmcyiF68nPz73HNc5UAYKIYeK+M9JzPQ4Wg1r1dXvP6A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxlint/binding-win32-arm64-msvc@1.86.0': + resolution: {integrity: sha512-9uTCHYTknNkug5+46ViSoUMuOuGWK61D87QnblU6CXaWKJC630Z7dbls61vdHxya/cR2ycQZ6Mm6ckgF6Cag5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxlint/binding-win32-ia32-msvc@1.86.0': + resolution: {integrity: sha512-a47ga7EKVfMU8rO0i1m3mGwfNRj3FhQyt1d/ukO/E9u1HHF3KpR3tyb3VhuJBGEVPF8uR4exSyHUyx7xbE+uxw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxlint/binding-win32-x64-msvc@1.86.0': + resolution: {integrity: sha512-az4dzifCRzES1crwu6pDFXzJTIanrdxXFL9TbiJWrx9LKcuacbR83aPvxDA1LKLNswi/RoqitC7Afcflhu3zBQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@quansync/fs@1.1.0': + resolution: {integrity: sha512-qAPG/t3HqML1TlN7sY/pTbEjzFVAKsMjNNMGheyDosro+kT4iw2KCUoHcVdmliwWjorm4elZbgNQyU2eD97eDg==} + + '@rolldown/binding-android-arm-eabi@1.2.12': + resolution: {integrity: sha512-dB/a1214qKfHMXCpgqR4OZT+jS4kTyEXbQGJPqzobt5EwH5rX080pxE37alt3RzvR1bf1Yz/yGqRfrYAxuPw0A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.0.0-rc.17': + resolution: {integrity: sha512-s70pVGhw4zqGeFnXWvAzJDlvxhlRollagdCCKRgOsgUOH3N1l0LIxf83AtGzmb5SiVM4Hjl5HyarMRfdfj3DaQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-android-arm64@1.0.0-rc.3': + resolution: {integrity: sha512-0T1k9FinuBZ/t7rZ8jN6OpUKPnUjNdYHoj/cESWrQ3ZraAJ4OMm6z7QjSfCxqj8mOp9kTKc1zHK3kGz5vMu+nQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-android-arm64@1.2.12': + resolution: {integrity: sha512-7KHFgQ5VJxIHcLlrwrc3Xbds7oTNQT7Pgi9gQCJKrd2VGab/UksIOYp6VD8MzCstGxOKMgNamPwUCfxPdP1OHg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.0.0-rc.17': + resolution: {integrity: sha512-4ksWc9n0mhlZpZ9PMZgTGjeOPRu8MB1Z3Tz0Mo02eWfWCHMW1zN82Qz/pL/rC+yQa+8ZnutMF0JjJe7PjwasYw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-arm64@1.0.0-rc.3': + resolution: {integrity: sha512-JWWLzvcmc/3pe7qdJqPpuPk91SoE/N+f3PcWx/6ZwuyDVyungAEJPvKm/eEldiDdwTmaEzWfIR+HORxYWrCi1A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-arm64@1.2.12': + resolution: {integrity: sha512-3YIhqHD96nA5SaYNRBR16HnGv4oavZvXfD/ayHM+oYZ0WD/8lBAtf6zQua4kEyAvpqrluKXl0lnOBoiNby7x9w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.17': + resolution: {integrity: sha512-SUSDOI6WwUVNcWxd02QEBjLdY1VPHvlEkw6T/8nYG322iYWCTxRb1vzk4E+mWWYehTp7ERibq54LSJGjmouOsw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.0.0-rc.3': + resolution: {integrity: sha512-MTakBxfx3tde5WSmbHxuqlDsIW0EzQym+PJYGF4P6lG2NmKzi128OGynoFUqoD5ryCySEY85dug4v+LWGBElIw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.12': + resolution: {integrity: sha512-UuuJ35MFw4gmFOrE9pEqIV+K3syIKveph+Qc1/ljHZVdoDW4pz/JHR/eMVom+TZGl/5OOvGJOWaOCVt3ZfqhxA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.0.0-rc.17': + resolution: {integrity: sha512-hwnz3nw9dbJ05EDO/PvcjaaewqqDy7Y1rn1UO81l8iIK1GjenME75dl16ajbvSSMfv66WXSRCYKIqfgq2KCfxw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-freebsd-x64@1.0.0-rc.3': + resolution: {integrity: sha512-jje3oopyOLs7IwfvXoS6Lxnmie5JJO7vW29fdGFu5YGY1EDbVDhD+P9vDihqS5X6fFiqL3ZQZCMBg6jyHkSVww==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-freebsd-x64@1.2.12': + resolution: {integrity: sha512-uMvssit0a4W+/7D8CbHUvG719mH3R2jwXAlh/XcPvuHTE0g++LymF88DCGNX0HM2rBOn0xrzgXktIB6fLSJBTQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': + resolution: {integrity: sha512-IS+W7epTcwANmFSQFrS1SivEXHtl1JtuQA9wlxrZTcNi6mx+FDOYrakGevvvTwgj2JvWiK8B29/qD9BELZPyXQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.3': + resolution: {integrity: sha512-A0n8P3hdLAaqzSFrQoA42p23ZKBYQOw+8EH5r15Sa9X1kD9/JXe0YT2gph2QTWvdr0CVK2BOXiK6ENfy6DXOag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.12': + resolution: {integrity: sha512-XcFu0R0xWnwzSf4IQgFH1rJIckPN1pLy2R+4r9IDB7Yfu/ys9cVqfa4pBrMHj7a3gl8mIR4nRNPg0e5IvEVs6g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': + resolution: {integrity: sha512-e6usGaHKW5BMNZOymS1UcEYGowQMWcgZ71Z17Sl/h2+ZziNJ1a9n3Zvcz6LdRyIW5572wBCTH/Z+bKuZouGk9Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.3': + resolution: {integrity: sha512-kWXkoxxarYISBJ4bLNf5vFkEbb4JvccOwxWDxuK9yee8lg5XA7OpvlTptfRuwEvYcOZf+7VS69Uenpmpyo5Bjw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-gnu@1.2.12': + resolution: {integrity: sha512-260UrKgn8tz39ak+SMDOirKzr7V04M9dWPw5llW00SwBivCZoWcRBKV1d8cXnRkUmSZA3BdiUmBHWk7734Ulpw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': + resolution: {integrity: sha512-b/CgbwAJpmrRLp02RPfhbudf5tZnN9nsPWK82znefso832etkem8H7FSZwxrOI9djcdTP7U6YfNhbRnh7djErg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.3': + resolution: {integrity: sha512-Z03/wrqau9Bicfgb3Dbs6SYTHliELk2PM2LpG2nFd+cGupTMF5kanLEcj2vuuJLLhptNyS61rtk7SOZ+lPsTUA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-arm64-musl@1.2.12': + resolution: {integrity: sha512-5YK1I9SqDkbPgc1IA8BgDl34suqUS2q0KWnBrirm0E51YjOs6eo6dV6jbQfNE/argHRSvd0QUGgtpIoYx+WWpw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': + resolution: {integrity: sha512-4EII1iNGRUN5WwGbF/kOh/EIkoDN9HsupgLQoXfY+D1oyJm7/F4t5PYU5n8SWZgG0FEwakyM8pGgwcBYruGTlA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-ppc64-gnu@1.2.12': + resolution: {integrity: sha512-Rkcrmp7eFRg74yL5fXEU91JEWbdEPLevWwGtXpmhbjlD1StScbWTmO94Bhly+Mo+ketKYkdmM1vNUKeWSlx8cQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': + resolution: {integrity: sha512-AH8oq3XqQo4IibpVXvPeLDI5pzkpYn0WiZAfT05kFzoJ6tQNzwRdDYQ45M8I/gslbodRZwW8uxLhbSBbkv96rA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.12': + resolution: {integrity: sha512-qvK4DuAsQc2BSjlx+Xr+IzOIvvxbGZqxFwdWfG6F518Erj0GGISyQbJ6pIappnOxlNPzNHvo/L0BwB30GZ+zVw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': + resolution: {integrity: sha512-cLnjV3xfo7KslbU41Z7z8BH/E1y5mzUYzAqih1d1MDaIGZRCMqTijqLv76/P7fyHuvUcfGsIpqCdddbxLLK9rA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.3': + resolution: {integrity: sha512-iSXXZsQp08CSilff/DCTFZHSVEpEwdicV3W8idHyrByrcsRDVh9sGC3sev6d8BygSGj3vt8GvUKBPCoyMA4tgQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.12': + resolution: {integrity: sha512-Q9uLBO53Xd4QIq1WOycVQyPP1O4HhraEV2qqb3uTrnVw6QZih9duY4vNXOivL1xoUS1/z+W8eF4NMfl2a8Sdjw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': + resolution: {integrity: sha512-0phclDw1spsL7dUB37sIARuis2tAgomCJXAHZlpt8PXZ4Ba0dRP1e+66lsRqrfhISeN9bEGNjQs+T/Fbd7oYGw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.3': + resolution: {integrity: sha512-qaj+MFudtdCv9xZo9znFvkgoajLdc+vwf0Kz5N44g+LU5XMe+IsACgn3UG7uTRlCCvhMAGXm1XlpEA5bZBrOcw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-x64-musl@1.2.12': + resolution: {integrity: sha512-3IBxWFMjbOZskDPKv8Lf9BCnahlKuHthWkYnyIxOH/QcJrFcS4EmcenthApkwr/5+nEqZlLzeYbxeMaX7A5u4g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': + resolution: {integrity: sha512-0ag/hEgXOwgw4t8QyQvUCxvEg+V0KBcA6YuOx9g0r02MprutRF5dyljgm3EmR02O292UX7UeS6HzWHAl6KgyhA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.3': + resolution: {integrity: sha512-U662UnMETyjT65gFmG9ma+XziENrs7BBnENi/27swZPYagubfHRirXHG2oMl+pEax2WvO7Kb9gHZmMakpYqBHQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-openharmony-arm64@1.2.12': + resolution: {integrity: sha512-xtX61xg4LKPkPWilZU1ynKClz5Gj4bf74LML4r3eVLWumKnGjoEr1OSHQhMdbBDoYTi+yjrujvpZe2pUnqCrrA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': + resolution: {integrity: sha512-LEXei6vo0E5wTGwpkJ4KoT3OZJRnglwldt5ziLzOlc6qqb55z4tWNq2A+PFqCJuvWWdP53CVhG1Z9NtToDPJrA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [wasm32] + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.3': + resolution: {integrity: sha512-gekrQ3Q2HiC1T5njGyuUJoGpK/l6B/TNXKed3fZXNf9YRTJn3L5MOZsFBn4bN2+UX+8+7hgdlTcEsexX988G4g==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': + resolution: {integrity: sha512-gUmyzBl3SPMa6hrqFUth9sVfcLBlYsbMzBx5PlexMroZStgzGqlZ26pYG89rBb45Mnia+oil6YAIFeEWGWhoZA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.3': + resolution: {integrity: sha512-85y5JifyMgs8m5K2XzR/VDsapKbiFiohl7s5lEj7nmNGO0pkTXE7q6TQScei96BNAsoK7JC3pA7ukA8WRHVJpg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-arm64-msvc@1.2.12': + resolution: {integrity: sha512-At7fPB6PCaIjzgIhEZFxuT+BBFqiQibJDT4d3PhiR3f4E7bbMZF4aKblbFfEM3sETRDd1YiQx/+U/g/B/ou5Ew==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': + resolution: {integrity: sha512-3hkiolcUAvPB9FLb3UZdfjVVNWherN1f/skkGWJP/fgSQhYUZpSIRr0/I8ZK9TkF3F7kxvJAk0+IcKvPHk9qQg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.3': + resolution: {integrity: sha512-a4VUQZH7LxGbUJ3qJ/TzQG8HxdHvf+jOnqf7B7oFx1TEBm+j2KNL2zr5SQ7wHkNAcaPevF6gf9tQnVBnC4mD+A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.12': + resolution: {integrity: sha512-WIw2haVKwjuYdXkHaoC0mF8Le71TuCBxjrdKqLbJGctbBABj+ClfmNvtbOnzpq3RokNo5+V1qhtSzJyXorsklQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.0.0-rc.17': + resolution: {integrity: sha512-n8iosDOt6Ig1UhJ2AYqoIhHWh/isz0xpicHTzpKBeotdVsTEcxsSA/i3EVM7gQAj0rU27OLAxCjzlj15IWY7bg==} + + '@rolldown/pluginutils@1.0.0-rc.3': + resolution: {integrity: sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q==} + + '@rolldown/pluginutils@1.0.1': + resolution: {integrity: sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==} + + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + + '@tybys/wasm-util@0.10.4': + resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/estree@1.0.9': + resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==} + + '@types/jsesc@2.5.1': + resolution: {integrity: sha512-9VN+6yxLOPLOav+7PwjZbxiID2bVaeq0ED4qSQmdQTdjnXJSaCVKTR58t15oqH1H5t8Ng2ZX1SabJVoN9Q34bw==} + + '@types/node@22.20.5': + resolution: {integrity: sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==} + + '@typescript/typescript-aix-ppc64@7.0.2': + resolution: {integrity: sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [aix] + + '@typescript/typescript-darwin-arm64@7.0.2': + resolution: {integrity: sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [darwin] + + '@typescript/typescript-darwin-x64@7.0.2': + resolution: {integrity: sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [darwin] + + '@typescript/typescript-freebsd-arm64@7.0.2': + resolution: {integrity: sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [freebsd] + + '@typescript/typescript-freebsd-x64@7.0.2': + resolution: {integrity: sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [freebsd] + + '@typescript/typescript-linux-arm64@7.0.2': + resolution: {integrity: sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [linux] + + '@typescript/typescript-linux-arm@7.0.2': + resolution: {integrity: sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==} + engines: {node: '>=16.20.0'} + cpu: [arm] + os: [linux] + + '@typescript/typescript-linux-loong64@7.0.2': + resolution: {integrity: sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==} + engines: {node: '>=16.20.0'} + cpu: [loong64] + os: [linux] + + '@typescript/typescript-linux-mips64el@7.0.2': + resolution: {integrity: sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==} + engines: {node: '>=16.20.0'} + cpu: [mips64el] + os: [linux] + + '@typescript/typescript-linux-ppc64@7.0.2': + resolution: {integrity: sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==} + engines: {node: '>=16.20.0'} + cpu: [ppc64] + os: [linux] + + '@typescript/typescript-linux-riscv64@7.0.2': + resolution: {integrity: sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==} + engines: {node: '>=16.20.0'} + cpu: [riscv64] + os: [linux] + + '@typescript/typescript-linux-s390x@7.0.2': + resolution: {integrity: sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==} + engines: {node: '>=16.20.0'} + cpu: [s390x] + os: [linux] + + '@typescript/typescript-linux-x64@7.0.2': + resolution: {integrity: sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [linux] + + '@typescript/typescript-netbsd-arm64@7.0.2': + resolution: {integrity: sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [netbsd] + + '@typescript/typescript-netbsd-x64@7.0.2': + resolution: {integrity: sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [netbsd] + + '@typescript/typescript-openbsd-arm64@7.0.2': + resolution: {integrity: sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [openbsd] + + '@typescript/typescript-openbsd-x64@7.0.2': + resolution: {integrity: sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [openbsd] + + '@typescript/typescript-sunos-x64@7.0.2': + resolution: {integrity: sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [sunos] + + '@typescript/typescript-win32-arm64@7.0.2': + resolution: {integrity: sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==} + engines: {node: '>=16.20.0'} + cpu: [arm64] + os: [win32] + + '@typescript/typescript-win32-x64@7.0.2': + resolution: {integrity: sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==} + engines: {node: '>=16.20.0'} + cpu: [x64] + os: [win32] + + '@vitest/expect@4.1.11': + resolution: {integrity: sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==} + + '@vitest/mocker@4.1.11': + resolution: {integrity: sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==} + peerDependencies: + msw: ^2.4.9 + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + + '@vitest/pretty-format@4.1.11': + resolution: {integrity: sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==} + + '@vitest/runner@4.1.11': + resolution: {integrity: sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==} + + '@vitest/snapshot@4.1.11': + resolution: {integrity: sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==} + + '@vitest/spy@4.1.11': + resolution: {integrity: sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==} + + '@vitest/utils@4.1.11': + resolution: {integrity: sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==} + + ansis@4.4.0: + resolution: {integrity: sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==} + engines: {node: '>=14'} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + ast-kit@3.0.0: + resolution: {integrity: sha512-8OG92q3R35qjC/4i6BLBMg8IB+fClWu/1PEwg2Z9Rn+BuNaiEgJzpzn+pxWOdHJWDCAwu2JP0wCDTozAM4QirQ==} + engines: {node: ^22.18.0 || >=24.11.0} + + birpc@4.2.0: + resolution: {integrity: sha512-KxgKcZPfrtzJDDALHPguGpGJUrzdgpymyiQQgzFjWreHMOpWrnFNVREr5J48x2DBh8ZVioscrV1SBkDipGiX+Q==} + + cac@6.7.14: + resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==} + engines: {node: '>=8'} + + chai@6.3.0: + resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} + engines: {node: '>=18'} + + convert-source-map@2.0.0: + resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + + defu@6.1.7: + resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + dts-resolver@2.1.3: + resolution: {integrity: sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==} + engines: {node: '>=20.19.0'} + peerDependencies: + oxc-resolver: '>=11.0.0' + peerDependenciesMeta: + oxc-resolver: + optional: true + + empathic@2.1.0: + resolution: {integrity: sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw==} + engines: {node: '>=14'} + + es-module-lexer@2.3.2: + resolution: {integrity: sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==} + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + expect-type@1.4.0: + resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} + engines: {node: '>=12.0.0'} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + get-tsconfig@4.14.3: + resolution: {integrity: sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==} + + hookable@6.1.2: + resolution: {integrity: sha512-+abwxtiEA52GCVIsQqut3S/uKTbUwYIp4Pe/vv+6py5XiXBCqMZHg6pA6Y5qhgLSEys0/cYuPbO0z1QFj5ZCmg==} + + import-without-cache@0.2.5: + resolution: {integrity: sha512-B6Lc2s6yApwnD2/pMzFh/d5AVjdsDXjgkeJ766FmFuJELIGHNycKRj+l3A39yZPM4CchqNCB4RITEAYB1KUM6A==} + engines: {node: '>=20.19.0'} + + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + magic-string@0.30.21: + resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==} + + nanoid@3.3.19: + resolution: {integrity: sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + obug@2.2.1: + resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} + engines: {node: '>=12.20.0'} + + oxfmt@0.68.0: + resolution: {integrity: sha512-Z0XMofcXCGUXbcpBHnWyUiX93BGiw1B+lcHNbQDWEtOhX06ewoFfu4zXkyiLhRrNnMq0twqXRHUcJetf+GsiQQ==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + svelte: ^5.0.0 + vite-plus: '*' + peerDependenciesMeta: + svelte: + optional: true + vite-plus: + optional: true + + oxlint@1.86.0: + resolution: {integrity: sha512-og0lhgvZfgGF//gOOmZXvtr+GmBbAGEnbEhv/QUg7UW2Wi4wHMnJbnMD+zuHgPdJxdklfgpPupdlAaAySyxrZg==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + oxlint-tsgolint: '>=7.0.2003' + vite-plus: '*' + peerDependenciesMeta: + oxlint-tsgolint: + optional: true + vite-plus: + optional: true + + pathe@2.0.3: + resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + postcss@8.5.28: + resolution: {integrity: sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==} + engines: {node: ^10 || ^12 || >=14} + + quansync@1.0.0: + resolution: {integrity: sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + rolldown-plugin-dts@0.22.5: + resolution: {integrity: sha512-M/HXfM4cboo+jONx9Z0X+CUf3B5tCi7ni+kR5fUW50Fp9AlZk0oVLesibGWgCXDKFp5lpgQ9yhKoImUFjl3VZw==} + engines: {node: '>=20.19.0'} + peerDependencies: + '@ts-macro/tsc': ^0.3.6 + '@typescript/native-preview': '>=7.0.0-dev.20250601.1' + rolldown: ^1.0.0-rc.3 + typescript: ^5.0.0 || ^6.0.0-beta + vue-tsc: ~3.2.0 + peerDependenciesMeta: + '@ts-macro/tsc': + optional: true + '@typescript/native-preview': + optional: true + typescript: + optional: true + vue-tsc: + optional: true + + rolldown@1.0.0-rc.17: + resolution: {integrity: sha512-ZrT53oAKrtA4+YtBWPQbtPOxIbVDbxT0orcYERKd63VJTF13zPcgXTvD4843L8pcsI7M6MErt8QtON6lrB9tyA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rolldown@1.0.0-rc.3: + resolution: {integrity: sha512-Po/YZECDOqVXjIXrtC5h++a5NLvKAQNrd9ggrIG3sbDfGO5BqTUsrI6l8zdniKRp3r5Tp/2JTrXqx4GIguFCMw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rolldown@1.2.12: + resolution: {integrity: sha512-8wafseiaG80xmXSfqidUNqZcylTlhmPZZt+za2m+js2sFZ8dTNlhIOV2WcbIPx2hgwPBJpEUGFAMZ9bgBBLTSQ==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + semver@7.8.5: + resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} + engines: {node: '>=10'} + hasBin: true + + siginfo@2.0.0: + resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==} + + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} + engines: {node: '>=0.10.0'} + + stackback@0.0.2: + resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} + + std-env@4.3.0: + resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + + tinybench@2.9.0: + resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==} + + tinyexec@1.3.1: + resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} + engines: {node: '>=18'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tinypool@2.1.2: + resolution: {integrity: sha512-9YodfrxS9g9IbFr/KOjE5bAeJ0p61n3bW6mqvy0jtoeKd1kTW1Cxm0oulm6KX2lyM9Gl6WIe8nEbY7LWv5ZJww==} + engines: {node: ^20.0.0 || >=22.0.0} + + tinyrainbow@3.2.0: + resolution: {integrity: sha512-LgO3D9yZJjApUiuUfl9iFAwrtaX4+lok3wJIqttGoKCHlWUqHqbQpnxCf82L8FjgKsh4iGo78hqJwgL8F6To2A==} + engines: {node: '>=14.0.0'} + + tree-kill@1.2.2: + resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} + hasBin: true + + tsdown@0.20.3: + resolution: {integrity: sha512-qWOUXSbe4jN8JZEgrkc/uhJpC8VN2QpNu3eZkBWwNuTEjc/Ik1kcc54ycfcQ5QPRHeu9OQXaLfCI3o7pEJgB2w==} + engines: {node: '>=20.19.0'} + hasBin: true + peerDependencies: + '@arethetypeswrong/core': ^0.18.1 + '@vitejs/devtools': '*' + publint: ^0.3.0 + typescript: ^5.0.0 + unplugin-lightningcss: ^0.4.0 + unplugin-unused: ^0.5.0 + peerDependenciesMeta: + '@arethetypeswrong/core': + optional: true + '@vitejs/devtools': + optional: true + publint: + optional: true + typescript: + optional: true + unplugin-lightningcss: + optional: true + unplugin-unused: + optional: true + + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + + typescript@5.9.3: + resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==} + engines: {node: '>=14.17'} + hasBin: true + + typescript@7.0.2: + resolution: {integrity: sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==} + engines: {node: '>=16.20.0'} + hasBin: true + + unconfig-core@7.5.0: + resolution: {integrity: sha512-Su3FauozOGP44ZmKdHy2oE6LPjk51M/TRRjHv2HNCWiDvfvCoxC2lno6jevMA91MYAdCdwP05QnWdWpSbncX/w==} + + undici-types@6.21.0: + resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==} + + unrun@0.2.39: + resolution: {integrity: sha512-h9FxYVpztY/wwq+bauLOh6Y3CWu2IVeRLq5lxzneBiIU9Tn86OGp9xiQrGhnYspAmg5dzdY0Cc8+Y70kuTARCg==} + engines: {node: '>=20.19.0'} + hasBin: true + peerDependencies: + synckit: ^0.11.11 + peerDependenciesMeta: + synckit: + optional: true + + vite@8.3.2: + resolution: {integrity: sha512-SQr1x6W5vVSbROg7vsyXIaxK9b0G7zsT68acdWWRmnBUsgDieLCRG+Rep9WdZgcposvv/GSnr4GUUBqB3vXq6w==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + '@types/node': ^20.19.0 || >=22.12.0 + '@vitejs/devtools': ^0.7.1 + esbuild: ^0.27.0 || ^0.28.0 + jiti: '>=1.21.0' + less: ^4.0.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: '>=0.54.8' + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + peerDependenciesMeta: + '@types/node': + optional: true + '@vitejs/devtools': + optional: true + esbuild: + optional: true + jiti: + optional: true + less: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + + vitest@4.1.11: + resolution: {integrity: sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==} + engines: {node: ^20.0.0 || ^22.0.0 || >=24.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@opentelemetry/api': ^1.9.0 + '@types/node': ^20.0.0 || ^22.0.0 || >=24.0.0 + '@vitest/browser-playwright': 4.1.11 + '@vitest/browser-preview': 4.1.11 + '@vitest/browser-webdriverio': 4.1.11 + '@vitest/coverage-istanbul': 4.1.11 + '@vitest/coverage-v8': 4.1.11 + '@vitest/ui': 4.1.11 + happy-dom: '*' + jsdom: '*' + vite: ^6.0.0 || ^7.0.0 || ^8.0.0 + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@opentelemetry/api': + optional: true + '@types/node': + optional: true + '@vitest/browser-playwright': + optional: true + '@vitest/browser-preview': + optional: true + '@vitest/browser-webdriverio': + optional: true + '@vitest/coverage-istanbul': + optional: true + '@vitest/coverage-v8': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} + engines: {node: '>=8'} + hasBin: true + +snapshots: + + '@babel/generator@8.0.0-rc.2': + dependencies: + '@babel/parser': 8.0.0-rc.2 + '@babel/types': 8.0.0-rc.2 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 + '@types/jsesc': 2.5.1 + jsesc: 3.1.0 + + '@babel/helper-string-parser@8.0.6': {} + + '@babel/helper-validator-identifier@8.0.0-rc.2': {} + + '@babel/helper-validator-identifier@8.0.6': {} + + '@babel/parser@8.0.0-rc.2': + dependencies: + '@babel/types': 8.0.0-rc.2 + + '@babel/parser@8.0.6': + dependencies: + '@babel/types': 8.0.6 + + '@babel/types@8.0.0-rc.2': + dependencies: + '@babel/helper-string-parser': 8.0.6 + '@babel/helper-validator-identifier': 8.0.0-rc.2 + + '@babel/types@8.0.6': + dependencies: + '@babel/helper-string-parser': 8.0.6 + '@babel/helper-validator-identifier': 8.0.6 + + '@emnapi/core@1.10.0': + dependencies: + '@emnapi/wasi-threads': 1.2.1 + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.10.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.2.1': + dependencies: + tslib: 2.8.1 + optional: true + + '@jridgewell/gen-mapping@0.3.13': + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + '@jridgewell/trace-mapping': 0.3.31 + + '@jridgewell/resolve-uri@3.1.2': {} + + '@jridgewell/sourcemap-codec@1.6.0': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.2 + '@jridgewell/sourcemap-codec': 1.6.0 + + '@napi-rs/wasm-runtime@1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@tybys/wasm-util': 0.10.4 + optional: true + + '@oxc-project/types@0.112.0': {} + + '@oxc-project/types@0.127.0': {} + + '@oxc-project/types@0.152.0': {} + + '@oxfmt/binding-android-arm-eabi@0.68.0': + optional: true + + '@oxfmt/binding-android-arm64@0.68.0': + optional: true + + '@oxfmt/binding-darwin-arm64@0.68.0': + optional: true + + '@oxfmt/binding-darwin-x64@0.68.0': + optional: true + + '@oxfmt/binding-freebsd-x64@0.68.0': + optional: true + + '@oxfmt/binding-linux-arm-gnueabihf@0.68.0': + optional: true + + '@oxfmt/binding-linux-arm-musleabihf@0.68.0': + optional: true + + '@oxfmt/binding-linux-arm64-gnu@0.68.0': + optional: true + + '@oxfmt/binding-linux-arm64-musl@0.68.0': + optional: true + + '@oxfmt/binding-linux-ppc64-gnu@0.68.0': + optional: true + + '@oxfmt/binding-linux-riscv64-gnu@0.68.0': + optional: true + + '@oxfmt/binding-linux-riscv64-musl@0.68.0': + optional: true + + '@oxfmt/binding-linux-s390x-gnu@0.68.0': + optional: true + + '@oxfmt/binding-linux-x64-gnu@0.68.0': + optional: true + + '@oxfmt/binding-linux-x64-musl@0.68.0': + optional: true + + '@oxfmt/binding-openharmony-arm64@0.68.0': + optional: true + + '@oxfmt/binding-win32-arm64-msvc@0.68.0': + optional: true + + '@oxfmt/binding-win32-ia32-msvc@0.68.0': + optional: true + + '@oxfmt/binding-win32-x64-msvc@0.68.0': + optional: true + + '@oxlint/binding-android-arm-eabi@1.86.0': + optional: true + + '@oxlint/binding-android-arm64@1.86.0': + optional: true + + '@oxlint/binding-darwin-arm64@1.86.0': + optional: true + + '@oxlint/binding-darwin-x64@1.86.0': + optional: true + + '@oxlint/binding-freebsd-x64@1.86.0': + optional: true + + '@oxlint/binding-linux-arm-gnueabihf@1.86.0': + optional: true + + '@oxlint/binding-linux-arm-musleabihf@1.86.0': + optional: true + + '@oxlint/binding-linux-arm64-gnu@1.86.0': + optional: true + + '@oxlint/binding-linux-arm64-musl@1.86.0': + optional: true + + '@oxlint/binding-linux-ppc64-gnu@1.86.0': + optional: true + + '@oxlint/binding-linux-riscv64-gnu@1.86.0': + optional: true + + '@oxlint/binding-linux-riscv64-musl@1.86.0': + optional: true + + '@oxlint/binding-linux-s390x-gnu@1.86.0': + optional: true + + '@oxlint/binding-linux-x64-gnu@1.86.0': + optional: true + + '@oxlint/binding-linux-x64-musl@1.86.0': + optional: true + + '@oxlint/binding-openharmony-arm64@1.86.0': + optional: true + + '@oxlint/binding-win32-arm64-msvc@1.86.0': + optional: true + + '@oxlint/binding-win32-ia32-msvc@1.86.0': + optional: true + + '@oxlint/binding-win32-x64-msvc@1.86.0': + optional: true + + '@quansync/fs@1.1.0': + dependencies: + quansync: 1.0.0 + + '@rolldown/binding-android-arm-eabi@1.2.12': + optional: true + + '@rolldown/binding-android-arm64@1.0.0-rc.17': + optional: true + + '@rolldown/binding-android-arm64@1.0.0-rc.3': + optional: true + + '@rolldown/binding-android-arm64@1.2.12': + optional: true + + '@rolldown/binding-darwin-arm64@1.0.0-rc.17': + optional: true + + '@rolldown/binding-darwin-arm64@1.0.0-rc.3': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.12': + optional: true + + '@rolldown/binding-darwin-x64@1.0.0-rc.17': + optional: true + + '@rolldown/binding-darwin-x64@1.0.0-rc.3': + optional: true + + '@rolldown/binding-darwin-x64@1.2.12': + optional: true + + '@rolldown/binding-freebsd-x64@1.0.0-rc.17': + optional: true + + '@rolldown/binding-freebsd-x64@1.0.0-rc.3': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.12': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.0.0-rc.3': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.12': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.0.0-rc.3': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.12': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.0.0-rc.3': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.12': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.12': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.12': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.0.0-rc.3': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.12': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.17': + optional: true + + '@rolldown/binding-linux-x64-musl@1.0.0-rc.3': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.12': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.17': + optional: true + + '@rolldown/binding-openharmony-arm64@1.0.0-rc.3': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.12': + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.17': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + optional: true + + '@rolldown/binding-wasm32-wasi@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': + dependencies: + '@napi-rs/wasm-runtime': 1.2.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + transitivePeerDependencies: + - '@emnapi/core' + - '@emnapi/runtime' + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.17': + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.0.0-rc.3': + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.12': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.17': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.0.0-rc.3': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.12': + optional: true + + '@rolldown/pluginutils@1.0.0-rc.17': {} + + '@rolldown/pluginutils@1.0.0-rc.3': {} + + '@rolldown/pluginutils@1.0.1': {} + + '@standard-schema/spec@1.1.0': {} + + '@tybys/wasm-util@0.10.4': + dependencies: + tslib: 2.8.1 + optional: true + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/deep-eql@4.0.2': {} + + '@types/estree@1.0.9': {} + + '@types/jsesc@2.5.1': {} + + '@types/node@22.20.5': + dependencies: + undici-types: 6.21.0 + + '@typescript/typescript-aix-ppc64@7.0.2': + optional: true + + '@typescript/typescript-darwin-arm64@7.0.2': + optional: true + + '@typescript/typescript-darwin-x64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-freebsd-x64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm64@7.0.2': + optional: true + + '@typescript/typescript-linux-arm@7.0.2': + optional: true + + '@typescript/typescript-linux-loong64@7.0.2': + optional: true + + '@typescript/typescript-linux-mips64el@7.0.2': + optional: true + + '@typescript/typescript-linux-ppc64@7.0.2': + optional: true + + '@typescript/typescript-linux-riscv64@7.0.2': + optional: true + + '@typescript/typescript-linux-s390x@7.0.2': + optional: true + + '@typescript/typescript-linux-x64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-netbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-arm64@7.0.2': + optional: true + + '@typescript/typescript-openbsd-x64@7.0.2': + optional: true + + '@typescript/typescript-sunos-x64@7.0.2': + optional: true + + '@typescript/typescript-win32-arm64@7.0.2': + optional: true + + '@typescript/typescript-win32-x64@7.0.2': + optional: true + + '@vitest/expect@4.1.11': + dependencies: + '@standard-schema/spec': 1.1.0 + '@types/chai': 5.2.3 + '@vitest/spy': 4.1.11 + '@vitest/utils': 4.1.11 + chai: 6.3.0 + tinyrainbow: 3.2.0 + + '@vitest/mocker@4.1.11(vite@8.3.2(@types/node@22.20.5))': + dependencies: + '@vitest/spy': 4.1.11 + estree-walker: 3.0.3 + magic-string: 0.30.21 + optionalDependencies: + vite: 8.3.2(@types/node@22.20.5) + + '@vitest/pretty-format@4.1.11': + dependencies: + tinyrainbow: 3.2.0 + + '@vitest/runner@4.1.11': + dependencies: + '@vitest/utils': 4.1.11 + pathe: 2.0.3 + + '@vitest/snapshot@4.1.11': + dependencies: + '@vitest/pretty-format': 4.1.11 + '@vitest/utils': 4.1.11 + magic-string: 0.30.21 + pathe: 2.0.3 + + '@vitest/spy@4.1.11': {} + + '@vitest/utils@4.1.11': + dependencies: + '@vitest/pretty-format': 4.1.11 + convert-source-map: 2.0.0 + tinyrainbow: 3.2.0 + + ansis@4.4.0: {} + + assertion-error@2.0.1: {} + + ast-kit@3.0.0: + dependencies: + '@babel/parser': 8.0.6 + estree-walker: 3.0.3 + pathe: 2.0.3 + + birpc@4.2.0: {} + + cac@6.7.14: {} + + chai@6.3.0: {} + + convert-source-map@2.0.0: {} + + defu@6.1.7: {} + + detect-libc@2.1.2: {} + + dts-resolver@2.1.3: {} + + empathic@2.1.0: {} + + es-module-lexer@2.3.2: {} + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.9 + + expect-type@1.4.0: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fsevents@2.3.3: + optional: true + + get-tsconfig@4.14.3: + dependencies: + resolve-pkg-maps: 1.0.0 + + hookable@6.1.2: {} + + import-without-cache@0.2.5: {} + + jsesc@3.1.0: {} + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + optionalDependencies: + lightningcss-android-arm64: 1.33.0 + lightningcss-darwin-arm64: 1.33.0 + lightningcss-darwin-x64: 1.33.0 + lightningcss-freebsd-x64: 1.33.0 + lightningcss-linux-arm-gnueabihf: 1.33.0 + lightningcss-linux-arm64-gnu: 1.33.0 + lightningcss-linux-arm64-musl: 1.33.0 + lightningcss-linux-x64-gnu: 1.33.0 + lightningcss-linux-x64-musl: 1.33.0 + lightningcss-win32-arm64-msvc: 1.33.0 + lightningcss-win32-x64-msvc: 1.33.0 + + magic-string@0.30.21: + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + + nanoid@3.3.19: {} + + obug@2.2.1: {} + + oxfmt@0.68.0: + dependencies: + tinypool: 2.1.2 + optionalDependencies: + '@oxfmt/binding-android-arm-eabi': 0.68.0 + '@oxfmt/binding-android-arm64': 0.68.0 + '@oxfmt/binding-darwin-arm64': 0.68.0 + '@oxfmt/binding-darwin-x64': 0.68.0 + '@oxfmt/binding-freebsd-x64': 0.68.0 + '@oxfmt/binding-linux-arm-gnueabihf': 0.68.0 + '@oxfmt/binding-linux-arm-musleabihf': 0.68.0 + '@oxfmt/binding-linux-arm64-gnu': 0.68.0 + '@oxfmt/binding-linux-arm64-musl': 0.68.0 + '@oxfmt/binding-linux-ppc64-gnu': 0.68.0 + '@oxfmt/binding-linux-riscv64-gnu': 0.68.0 + '@oxfmt/binding-linux-riscv64-musl': 0.68.0 + '@oxfmt/binding-linux-s390x-gnu': 0.68.0 + '@oxfmt/binding-linux-x64-gnu': 0.68.0 + '@oxfmt/binding-linux-x64-musl': 0.68.0 + '@oxfmt/binding-openharmony-arm64': 0.68.0 + '@oxfmt/binding-win32-arm64-msvc': 0.68.0 + '@oxfmt/binding-win32-ia32-msvc': 0.68.0 + '@oxfmt/binding-win32-x64-msvc': 0.68.0 + + oxlint@1.86.0: + optionalDependencies: + '@oxlint/binding-android-arm-eabi': 1.86.0 + '@oxlint/binding-android-arm64': 1.86.0 + '@oxlint/binding-darwin-arm64': 1.86.0 + '@oxlint/binding-darwin-x64': 1.86.0 + '@oxlint/binding-freebsd-x64': 1.86.0 + '@oxlint/binding-linux-arm-gnueabihf': 1.86.0 + '@oxlint/binding-linux-arm-musleabihf': 1.86.0 + '@oxlint/binding-linux-arm64-gnu': 1.86.0 + '@oxlint/binding-linux-arm64-musl': 1.86.0 + '@oxlint/binding-linux-ppc64-gnu': 1.86.0 + '@oxlint/binding-linux-riscv64-gnu': 1.86.0 + '@oxlint/binding-linux-riscv64-musl': 1.86.0 + '@oxlint/binding-linux-s390x-gnu': 1.86.0 + '@oxlint/binding-linux-x64-gnu': 1.86.0 + '@oxlint/binding-linux-x64-musl': 1.86.0 + '@oxlint/binding-openharmony-arm64': 1.86.0 + '@oxlint/binding-win32-arm64-msvc': 1.86.0 + '@oxlint/binding-win32-ia32-msvc': 1.86.0 + '@oxlint/binding-win32-x64-msvc': 1.86.0 + + pathe@2.0.3: {} + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + postcss@8.5.28: + dependencies: + nanoid: 3.3.19 + picocolors: 1.1.1 + source-map-js: 1.2.2 + + quansync@1.0.0: {} + + resolve-pkg-maps@1.0.0: {} + + rolldown-plugin-dts@0.22.5(rolldown@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0))(typescript@5.9.3): + dependencies: + '@babel/generator': 8.0.0-rc.2 + '@babel/helper-validator-identifier': 8.0.0-rc.2 + '@babel/parser': 8.0.0-rc.2 + '@babel/types': 8.0.0-rc.2 + ast-kit: 3.0.0 + birpc: 4.2.0 + dts-resolver: 2.1.3 + get-tsconfig: 4.14.3 + obug: 2.2.1 + rolldown: 1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + optionalDependencies: + typescript: 5.9.3 + transitivePeerDependencies: + - oxc-resolver + + rolldown-plugin-dts@0.22.5(rolldown@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0))(typescript@7.0.2): + dependencies: + '@babel/generator': 8.0.0-rc.2 + '@babel/helper-validator-identifier': 8.0.0-rc.2 + '@babel/parser': 8.0.0-rc.2 + '@babel/types': 8.0.0-rc.2 + ast-kit: 3.0.0 + birpc: 4.2.0 + dts-resolver: 2.1.3 + get-tsconfig: 4.14.3 + obug: 2.2.1 + rolldown: 1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + optionalDependencies: + typescript: 7.0.2 + transitivePeerDependencies: + - oxc-resolver + + rolldown@1.0.0-rc.17: + dependencies: + '@oxc-project/types': 0.127.0 + '@rolldown/pluginutils': 1.0.0-rc.17 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-rc.17 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.17 + '@rolldown/binding-darwin-x64': 1.0.0-rc.17 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.17 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.17 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.17 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.17 + '@rolldown/binding-linux-ppc64-gnu': 1.0.0-rc.17 + '@rolldown/binding-linux-s390x-gnu': 1.0.0-rc.17 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.17 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.17 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.17 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.17 + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.17 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.17 + + rolldown@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0): + dependencies: + '@oxc-project/types': 0.112.0 + '@rolldown/pluginutils': 1.0.0-rc.3 + optionalDependencies: + '@rolldown/binding-android-arm64': 1.0.0-rc.3 + '@rolldown/binding-darwin-arm64': 1.0.0-rc.3 + '@rolldown/binding-darwin-x64': 1.0.0-rc.3 + '@rolldown/binding-freebsd-x64': 1.0.0-rc.3 + '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-rc.3 + '@rolldown/binding-linux-arm64-gnu': 1.0.0-rc.3 + '@rolldown/binding-linux-arm64-musl': 1.0.0-rc.3 + '@rolldown/binding-linux-x64-gnu': 1.0.0-rc.3 + '@rolldown/binding-linux-x64-musl': 1.0.0-rc.3 + '@rolldown/binding-openharmony-arm64': 1.0.0-rc.3 + '@rolldown/binding-wasm32-wasi': 1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + '@rolldown/binding-win32-arm64-msvc': 1.0.0-rc.3 + '@rolldown/binding-win32-x64-msvc': 1.0.0-rc.3 + transitivePeerDependencies: + - '@emnapi/core' + - '@emnapi/runtime' + + rolldown@1.2.12: + dependencies: + '@oxc-project/types': 0.152.0 + '@rolldown/pluginutils': 1.0.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.2.12 + '@rolldown/binding-android-arm64': 1.2.12 + '@rolldown/binding-darwin-arm64': 1.2.12 + '@rolldown/binding-darwin-x64': 1.2.12 + '@rolldown/binding-freebsd-x64': 1.2.12 + '@rolldown/binding-linux-arm-gnueabihf': 1.2.12 + '@rolldown/binding-linux-arm64-gnu': 1.2.12 + '@rolldown/binding-linux-arm64-musl': 1.2.12 + '@rolldown/binding-linux-ppc64-gnu': 1.2.12 + '@rolldown/binding-linux-s390x-gnu': 1.2.12 + '@rolldown/binding-linux-x64-gnu': 1.2.12 + '@rolldown/binding-linux-x64-musl': 1.2.12 + '@rolldown/binding-openharmony-arm64': 1.2.12 + '@rolldown/binding-win32-arm64-msvc': 1.2.12 + '@rolldown/binding-win32-x64-msvc': 1.2.12 + + semver@7.8.5: {} + + siginfo@2.0.0: {} + + source-map-js@1.2.2: {} + + stackback@0.0.2: {} + + std-env@4.3.0: {} + + tinybench@2.9.0: {} + + tinyexec@1.3.1: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tinypool@2.1.2: {} + + tinyrainbow@3.2.0: {} + + tree-kill@1.2.2: {} + + tsdown@0.20.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(typescript@5.9.3): + dependencies: + ansis: 4.4.0 + cac: 6.7.14 + defu: 6.1.7 + empathic: 2.1.0 + hookable: 6.1.2 + import-without-cache: 0.2.5 + obug: 2.2.1 + picomatch: 4.0.7 + rolldown: 1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + rolldown-plugin-dts: 0.22.5(rolldown@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0))(typescript@5.9.3) + semver: 7.8.5 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + tree-kill: 1.2.2 + unconfig-core: 7.5.0 + unrun: 0.2.39 + optionalDependencies: + typescript: 5.9.3 + transitivePeerDependencies: + - '@emnapi/core' + - '@emnapi/runtime' + - '@ts-macro/tsc' + - '@typescript/native-preview' + - oxc-resolver + - synckit + - vue-tsc + + tsdown@0.20.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)(typescript@7.0.2): + dependencies: + ansis: 4.4.0 + cac: 6.7.14 + defu: 6.1.7 + empathic: 2.1.0 + hookable: 6.1.2 + import-without-cache: 0.2.5 + obug: 2.2.1 + picomatch: 4.0.7 + rolldown: 1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + rolldown-plugin-dts: 0.22.5(rolldown@1.0.0-rc.3(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0))(typescript@7.0.2) + semver: 7.8.5 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + tree-kill: 1.2.2 + unconfig-core: 7.5.0 + unrun: 0.2.39 + optionalDependencies: + typescript: 7.0.2 + transitivePeerDependencies: + - '@emnapi/core' + - '@emnapi/runtime' + - '@ts-macro/tsc' + - '@typescript/native-preview' + - oxc-resolver + - synckit + - vue-tsc + + tslib@2.8.1: + optional: true + + typescript@5.9.3: {} + + typescript@7.0.2: + optionalDependencies: + '@typescript/typescript-aix-ppc64': 7.0.2 + '@typescript/typescript-darwin-arm64': 7.0.2 + '@typescript/typescript-darwin-x64': 7.0.2 + '@typescript/typescript-freebsd-arm64': 7.0.2 + '@typescript/typescript-freebsd-x64': 7.0.2 + '@typescript/typescript-linux-arm': 7.0.2 + '@typescript/typescript-linux-arm64': 7.0.2 + '@typescript/typescript-linux-loong64': 7.0.2 + '@typescript/typescript-linux-mips64el': 7.0.2 + '@typescript/typescript-linux-ppc64': 7.0.2 + '@typescript/typescript-linux-riscv64': 7.0.2 + '@typescript/typescript-linux-s390x': 7.0.2 + '@typescript/typescript-linux-x64': 7.0.2 + '@typescript/typescript-netbsd-arm64': 7.0.2 + '@typescript/typescript-netbsd-x64': 7.0.2 + '@typescript/typescript-openbsd-arm64': 7.0.2 + '@typescript/typescript-openbsd-x64': 7.0.2 + '@typescript/typescript-sunos-x64': 7.0.2 + '@typescript/typescript-win32-arm64': 7.0.2 + '@typescript/typescript-win32-x64': 7.0.2 + + unconfig-core@7.5.0: + dependencies: + '@quansync/fs': 1.1.0 + quansync: 1.0.0 + + undici-types@6.21.0: {} + + unrun@0.2.39: + dependencies: + rolldown: 1.0.0-rc.17 + + vite@8.3.2(@types/node@22.20.5): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.28 + rolldown: 1.2.12 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 22.20.5 + fsevents: 2.3.3 + + vitest@4.1.11(@types/node@22.20.5)(vite@8.3.2(@types/node@22.20.5)): + dependencies: + '@vitest/expect': 4.1.11 + '@vitest/mocker': 4.1.11(vite@8.3.2(@types/node@22.20.5)) + '@vitest/pretty-format': 4.1.11 + '@vitest/runner': 4.1.11 + '@vitest/snapshot': 4.1.11 + '@vitest/spy': 4.1.11 + '@vitest/utils': 4.1.11 + es-module-lexer: 2.3.2 + expect-type: 1.4.0 + magic-string: 0.30.21 + obug: 2.2.1 + pathe: 2.0.3 + picomatch: 4.0.7 + std-env: 4.3.0 + tinybench: 2.9.0 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + tinyrainbow: 3.2.0 + vite: 8.3.2(@types/node@22.20.5) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 22.20.5 + transitivePeerDependencies: + - msw + + why-is-node-running@2.3.0: + dependencies: + siginfo: 2.0.0 + stackback: 0.0.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..cbe2dae --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,9 @@ +packages: + - packages/* + +# esbuild ships its platform binary through a postinstall script, and pnpm 12 refuses +# to run a dependency's install script unless it is allowed here +allowBuilds: + esbuild: true + +linkWorkspacePackages: true diff --git a/scripts/npm-secret.sh b/scripts/npm-secret.sh new file mode 100755 index 0000000..124cc2c --- /dev/null +++ b/scripts/npm-secret.sh @@ -0,0 +1,295 @@ +#!/usr/bin/env bash +# +# A wizard walks a human through a manual procedure, step by step. +# Generated by the /wizard skill. +# +# Everything above the "STAGES" marker is the wizard library: do not hand-edit +# it. Author the per-step stages below the marker. + +set -euo pipefail + +# ────────────────────────────────────────────────────────────────────────── +# Wizard library: delightful, consistent UX, identical across every wizard. +# ────────────────────────────────────────────────────────────────────────── + +if [[ -t 1 ]] && command -v tput >/dev/null 2>&1 && [[ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]]; then + BOLD=$(tput bold); DIM=$(tput dim); RESET=$(tput sgr0) + BLUE=$(tput setaf 4); GREEN=$(tput setaf 2); YELLOW=$(tput setaf 3); RED=$(tput setaf 1) +else + BOLD=""; DIM=""; RESET=""; BLUE=""; GREEN=""; YELLOW=""; RED="" +fi + +# Author sets this at the top of the stages section. +TOTAL_STAGES=0 + +_STAGE_INDEX=0 +ENV_FILE="${ENV_FILE:-.env}" +WRITTEN_ENV=() # KEYs written to ENV_FILE this run +WRITTEN_SECRET=() # secret NAMEs set this run +SKIPPED=() # things we couldn't do (e.g. gh missing) + +# _clear wipes the terminal so only the current step is on screen. No-op when +# output isn't a terminal, so piped logs stay readable. +_clear() { + [[ -t 1 ]] || return 0 + if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi +} + +# banner "Title" shows the opening frame: what this wizard does. +banner() { + _clear + printf '\n%s%s %s%s\n' "$BOLD" "$BLUE" "$1" "$RESET" + printf '%s %s stages%s\n\n' "$DIM" "$TOTAL_STAGES" "$RESET" + printf '%s You drive the browser; this wizard tells you exactly what to do and\n' "$DIM" + printf ' captures the values you copy back. Stop any time with Ctrl-C and re-run\n' + printf ' later, since it remembers values already saved.%s\n' "$RESET" + pause "Ready to start?" +} + +# stage "Name" clears the screen, then announces a stage and shows progress. +# Clearing keeps only the current step on screen. +stage() { + _clear + _STAGE_INDEX=$((_STAGE_INDEX + 1)) + printf '\n%s%s▸ Stage %s/%s · %s%s\n' \ + "$BOLD" "$BLUE" "$_STAGE_INDEX" "$TOTAL_STAGES" "$1" "$RESET" +} + +# say "..." prints a plain instruction line. +say() { printf ' %s\n' "$1"; } +# step "..." is a numbered-feeling action the human takes in the browser. +step() { printf ' %s•%s %s\n' "$BLUE" "$RESET" "$1"; } +note() { printf ' %s%s%s\n' "$DIM" "$1" "$RESET"; } +warn() { printf ' %s⚠ %s%s\n' "$YELLOW" "$1" "$RESET"; } + +# open_url URL opens it in the human's browser, cross-platform incl. WSL. +open_url() { + local url="$1" + printf ' %s↗ opening%s %s\n' "$GREEN" "$RESET" "$url" + { if command -v wslview >/dev/null 2>&1; then wslview "$url" + elif command -v explorer.exe >/dev/null 2>&1; then explorer.exe "$url" + elif command -v xdg-open >/dev/null 2>&1; then xdg-open "$url" + elif command -v open >/dev/null 2>&1; then open "$url" + else warn "couldn't open a browser; visit it manually: $url"; fi + } >/dev/null 2>&1 || warn "couldn't open a browser, so visit it manually: $url" +} + +# pause "msg" waits for the human to confirm they've done the manual part. +pause() { + printf ' %s%s%s ' "$DIM" "${1:-Press Enter to continue}" "$RESET" + read -r _ || true +} + +# confirm "question" is a y/N gate; returns success on yes. +confirm() { + local reply="" + printf ' %s? %s [y/N] ' "$YELLOW" "$1" + read -r reply || true + [[ "$reply" =~ ^[Yy] ]] +} + +# _existing KEY: current value of KEY in ENV_FILE, if any. +_existing() { + [[ -f "$ENV_FILE" ]] || return 1 + local line; line=$(grep -E "^${1}=" "$ENV_FILE" | tail -n1) || return 1 + printf '%s' "${line#*=}" +} + +# ask KEY "Prompt" reads a value into $KEY. Offers the existing .env value as +# a default on re-runs (Enter keeps it). Visible input (non-secret). +ask() { + local key="$1" prompt="$2" current input + current=$(_existing "$key" || true) + if [[ -n "$current" ]]; then + printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET" + else + printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET" + fi + read -r input || true + [[ -z "$input" && -n "$current" ]] && input="$current" + printf -v "$key" '%s' "$input" +} + +# ask_secret KEY "Prompt" is like ask, but input is hidden. +ask_secret() { + local key="$1" prompt="$2" current input + current=$(_existing "$key" || true) + if [[ -n "$current" ]]; then + printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET" + else + printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET" + fi + read -rs input || true + printf '\n' + [[ -z "$input" && -n "$current" ]] && input="$current" + printf -v "$key" '%s' "$input" +} + +# write_env KEY VALUE upserts KEY=VALUE into ENV_FILE (creates it; replaces +# any existing line). Idempotent. +write_env() { + local key="$1" value="$2" tmp + touch "$ENV_FILE" + tmp=$(mktemp) + grep -vE "^${key}=" "$ENV_FILE" > "$tmp" || true + printf '%s=%s\n' "$key" "$value" >> "$tmp" + mv "$tmp" "$ENV_FILE" + WRITTEN_ENV+=("$key") + printf ' %s✓ wrote%s %s → %s\n' "$GREEN" "$RESET" "$key" "$ENV_FILE" +} + +# set_secret NAME VALUE sets a GitHub Actions repo secret via gh. Falls back +# to a warning (and records it) if gh is unavailable or unauthenticated. +set_secret() { + local name="$1" value="$2" + if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then + if printf '%s' "$value" | gh secret set "$name" >/dev/null 2>&1; then + WRITTEN_SECRET+=("$name") + printf ' %s✓ set%s GitHub secret %s\n' "$GREEN" "$RESET" "$name" + return + fi + fi + SKIPPED+=("GitHub secret $name (set it manually: gh secret set $name)") + warn "skipped GitHub secret $name: gh not ready; set it later" +} + +# set_var NAME VALUE sets a GitHub Actions repo variable (non-secret). +set_var() { + local name="$1" value="$2" + if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then + if gh variable set "$name" --body "$value" >/dev/null 2>&1; then + printf ' %s✓ set%s GitHub variable %s\n' "$GREEN" "$RESET" "$name" + return + fi + fi + SKIPPED+=("GitHub variable $name") + warn "skipped GitHub variable $name, gh not ready; set it later" +} + +# finish clears, then shows a closing summary of everything configured. +finish() { + _clear + printf '\n%s%s ✓ Setup complete%s\n' "$BOLD" "$GREEN" "$RESET" + (( ${#WRITTEN_ENV[@]} )) && note "wrote ${#WRITTEN_ENV[@]} value(s) to $ENV_FILE: ${WRITTEN_ENV[*]}" + (( ${#WRITTEN_SECRET[@]} )) && note "set ${#WRITTEN_SECRET[@]} GitHub secret(s): ${WRITTEN_SECRET[*]}" + if (( ${#SKIPPED[@]} )); then + printf '\n'; warn "still to do by hand:" + for s in "${SKIPPED[@]}"; do note " - $s"; done + fi + printf '\n' +} + + +# ────────────────────────────────────────────────────────────────────────── +# STAGES: author this section. +# ────────────────────────────────────────────────────────────────────────── + +# Puts the npm publish token into GitHub Actions as the NPM_TOKEN secret on every +# repo that publishes, so a release workflow can publish without anyone's laptop. +# Knobs are overridable from the environment, e.g. REPOS="BotHarness/BotUI". +REPOS="${REPOS:-BotHarness/BotUI BotHarness/BotPixel}" +SECRET_NAME="${SECRET_NAME:-NPM_TOKEN}" +EXPECTED_USER="${EXPECTED_USER:-botharness}" +TOKEN_FILE="${TOKEN_FILE:-$HOME/Documents/code/BotUI/npm_release.token}" +# same patterns as scripts/npm-token.sh: a rejected token vs. no network +REJECTED_PATTERN='401|E401|Unauthorized|ENEEDAUTH|ENOTFOUND|ETIMEDOUT|ENETUNREACH|EAI_AGAIN' + +token_is_valid() { + local candidate="$1" whoami_out + whoami_out=$(npm whoami --//registry.npmjs.org/:_authToken="$candidate" 2>&1) || true + printf '%s' "$whoami_out" | grep -qE "$REJECTED_PATTERN" && return 1 + [[ "$whoami_out" == "$EXPECTED_USER" ]] +} + +# set_repo_secret REPO VALUE — the value goes in on stdin, never on the command line +set_repo_secret() { + local repo="$1" value="$2" + if printf '%s' "$value" | gh secret set "$SECRET_NAME" --repo "$repo" >/dev/null 2>&1; then + WRITTEN_SECRET+=("$repo:$SECRET_NAME") + printf ' %s✓ set%s %s on %s\n' "$GREEN" "$RESET" "$SECRET_NAME" "$repo" + else + SKIPPED+=("$SECRET_NAME on $repo (gh secret set failed — do you have admin on it?)") + warn "could not set $SECRET_NAME on $repo" + fi +} + +TOTAL_STAGES=4 + +banner "npm token → GitHub secret" + +# ── Stage 1: gh can reach every repo ────────────────────────────────────── +stage "GitHub CLI" +say "Setting a repo secret needs gh, signed in as someone with admin on each repo." +if ! command -v gh >/dev/null 2>&1; then + warn "gh is not installed." + note " brew install gh then re-run this script" + exit 1 +fi +if ! gh auth status >/dev/null 2>&1; then + say "gh is installed but not signed in. Signing in now:" + gh auth login +fi +for repo in $REPOS; do + if gh repo view "$repo" >/dev/null 2>&1; then + printf ' %s✓%s %s\n' "$GREEN" "$RESET" "$repo" + else + warn "gh cannot see $repo with the current account." + note " switch accounts with: gh auth switch (or gh auth login)" + exit 1 + fi +done +pause "Continue?" + +# ── Stage 2: find the token ─────────────────────────────────────────────── +stage "The npm token" +say "Reusing the token BotUI's scripts/npm-token.sh already saved, if it still works." +TOKEN="" +if [[ -f "$TOKEN_FILE" ]]; then + note "found $TOKEN_FILE" + CANDIDATE=$(tr -d '[:space:]' < "$TOKEN_FILE") + if [[ -n "$CANDIDATE" ]] && token_is_valid "$CANDIDATE"; then + say "That token still works as $EXPECTED_USER." + TOKEN="$CANDIDATE" + else + warn "the saved token was rejected — expired, revoked, or from another account." + fi +else + note "no token at $TOKEN_FILE (set TOKEN_FILE=... to point elsewhere)" +fi +if [[ -z "$TOKEN" ]]; then + say "" + say "Create one here:" + open_url "https://www.npmjs.com/settings/access-tokens/new" + step "Packages: scope @botharness (all packages, so new ones like pixel-* can be created)" + step "Permissions: Read and write" + step "Tick 'Bypass 2FA' — the account's 2FA is a passkey, which CI cannot answer" + step "Generate token, then copy it (it is shown only once)" + say "" + ask_secret TOKEN "Paste the token (input hidden):" + [[ -n "$TOKEN" ]] || { warn "nothing pasted"; exit 1; } + token_is_valid "$TOKEN" || { warn "npm rejected that token (Bypass 2FA unticked? wrong account? trailing space?)"; exit 1; } + printf ' %s✓%s accepted as %s\n' "$GREEN" "$RESET" "$EXPECTED_USER" +fi + +# ── Stage 3: write the secret everywhere ────────────────────────────────── +stage "Set $SECRET_NAME" +say "Writing $SECRET_NAME to: $REPOS" +say "An existing $SECRET_NAME is replaced." +confirm "Go ahead?" || { say "Nothing changed."; exit 0; } +for repo in $REPOS; do set_repo_secret "$repo" "$TOKEN"; done + +# ── Stage 4: confirm GitHub has it ──────────────────────────────────────── +stage "Check" +for repo in $REPOS; do + if gh secret list --repo "$repo" 2>/dev/null | grep -q "^$SECRET_NAME[[:space:]]"; then + printf ' %s✓%s %s lists %s\n' "$GREEN" "$RESET" "$repo" "$SECRET_NAME" + else + warn "$repo does not list $SECRET_NAME" + fi +done +say "" +note "GitHub only stores the secret; a workflow still has to use it to publish." +note "Whether the token may PUBLISH is only proven by a real publish." +pause "Done?" + +finish diff --git a/scripts/npm-token.sh b/scripts/npm-token.sh new file mode 100755 index 0000000..630b0fd --- /dev/null +++ b/scripts/npm-token.sh @@ -0,0 +1,312 @@ +#!/usr/bin/env bash +# +# A wizard walks a human through a manual procedure, step by step. +# Generated by the /wizard skill. +# +# Everything above the "STAGES" marker is the wizard library: do not hand-edit +# it. Author the per-step stages below the marker. + +set -euo pipefail + +# ────────────────────────────────────────────────────────────────────────── +# Wizard library: delightful, consistent UX, identical across every wizard. +# ────────────────────────────────────────────────────────────────────────── + +if [[ -t 1 ]] && command -v tput >/dev/null 2>&1 && [[ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]]; then + BOLD=$(tput bold); DIM=$(tput dim); RESET=$(tput sgr0) + BLUE=$(tput setaf 4); GREEN=$(tput setaf 2); YELLOW=$(tput setaf 3); RED=$(tput setaf 1) +else + BOLD=""; DIM=""; RESET=""; BLUE=""; GREEN=""; YELLOW=""; RED="" +fi + +# Author sets this at the top of the stages section. +TOTAL_STAGES=0 + +_STAGE_INDEX=0 +ENV_FILE="${ENV_FILE:-.env}" +WRITTEN_ENV=() # KEYs written to ENV_FILE this run +WRITTEN_SECRET=() # secret NAMEs set this run +SKIPPED=() # things we couldn't do (e.g. gh missing) + +# _clear wipes the terminal so only the current step is on screen. No-op when +# output isn't a terminal, so piped logs stay readable. +_clear() { + [[ -t 1 ]] || return 0 + if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi +} + +# banner "Title" shows the opening frame: what this wizard does. +banner() { + _clear + printf '\n%s%s %s%s\n' "$BOLD" "$BLUE" "$1" "$RESET" + printf '%s %s stages%s\n\n' "$DIM" "$TOTAL_STAGES" "$RESET" + printf '%s You drive the browser; this wizard tells you exactly what to do and\n' "$DIM" + printf ' captures the values you copy back. Stop any time with Ctrl-C and re-run\n' + printf ' later, since it remembers values already saved.%s\n' "$RESET" + pause "Ready to start?" +} + +# stage "Name" clears the screen, then announces a stage and shows progress. +# Clearing keeps only the current step on screen. +stage() { + _clear + _STAGE_INDEX=$((_STAGE_INDEX + 1)) + printf '\n%s%s▸ Stage %s/%s · %s%s\n' \ + "$BOLD" "$BLUE" "$_STAGE_INDEX" "$TOTAL_STAGES" "$1" "$RESET" +} + +# say "..." prints a plain instruction line. +say() { printf ' %s\n' "$1"; } +# step "..." is a numbered-feeling action the human takes in the browser. +step() { printf ' %s•%s %s\n' "$BLUE" "$RESET" "$1"; } +note() { printf ' %s%s%s\n' "$DIM" "$1" "$RESET"; } +warn() { printf ' %s⚠ %s%s\n' "$YELLOW" "$1" "$RESET"; } + +# open_url URL opens it in the human's browser, cross-platform incl. WSL. +open_url() { + local url="$1" + printf ' %s↗ opening%s %s\n' "$GREEN" "$RESET" "$url" + { if command -v wslview >/dev/null 2>&1; then wslview "$url" + elif command -v explorer.exe >/dev/null 2>&1; then explorer.exe "$url" + elif command -v xdg-open >/dev/null 2>&1; then xdg-open "$url" + elif command -v open >/dev/null 2>&1; then open "$url" + else warn "couldn't open a browser; visit it manually: $url"; fi + } >/dev/null 2>&1 || warn "couldn't open a browser, so visit it manually: $url" +} + +# pause "msg" waits for the human to confirm they've done the manual part. +pause() { + printf ' %s%s%s ' "$DIM" "${1:-Press Enter to continue}" "$RESET" + read -r _ || true +} + +# confirm "question" is a y/N gate; returns success on yes. +confirm() { + local reply="" + printf ' %s? %s [y/N] ' "$YELLOW" "$1" + read -r reply || true + [[ "$reply" =~ ^[Yy] ]] +} + +# _existing KEY: current value of KEY in ENV_FILE, if any. +_existing() { + [[ -f "$ENV_FILE" ]] || return 1 + local line; line=$(grep -E "^${1}=" "$ENV_FILE" | tail -n1) || return 1 + printf '%s' "${line#*=}" +} + +# ask KEY "Prompt" reads a value into $KEY. Offers the existing .env value as +# a default on re-runs (Enter keeps it). Visible input (non-secret). +ask() { + local key="$1" prompt="$2" current input + current=$(_existing "$key" || true) + if [[ -n "$current" ]]; then + printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET" + else + printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET" + fi + read -r input || true + [[ -z "$input" && -n "$current" ]] && input="$current" + printf -v "$key" '%s' "$input" +} + +# ask_secret KEY "Prompt" is like ask, but input is hidden. +ask_secret() { + local key="$1" prompt="$2" current input + current=$(_existing "$key" || true) + if [[ -n "$current" ]]; then + printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET" + else + printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET" + fi + read -rs input || true + printf '\n' + [[ -z "$input" && -n "$current" ]] && input="$current" + printf -v "$key" '%s' "$input" +} + +# write_env KEY VALUE upserts KEY=VALUE into ENV_FILE (creates it; replaces +# any existing line). Idempotent. +write_env() { + local key="$1" value="$2" tmp + touch "$ENV_FILE" + tmp=$(mktemp) + grep -vE "^${key}=" "$ENV_FILE" > "$tmp" || true + printf '%s=%s\n' "$key" "$value" >> "$tmp" + mv "$tmp" "$ENV_FILE" + WRITTEN_ENV+=("$key") + printf ' %s✓ wrote%s %s → %s\n' "$GREEN" "$RESET" "$key" "$ENV_FILE" +} + +# set_secret NAME VALUE sets a GitHub Actions repo secret via gh. Falls back +# to a warning (and records it) if gh is unavailable or unauthenticated. +set_secret() { + local name="$1" value="$2" + if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then + if printf '%s' "$value" | gh secret set "$name" >/dev/null 2>&1; then + WRITTEN_SECRET+=("$name") + printf ' %s✓ set%s GitHub secret %s\n' "$GREEN" "$RESET" "$name" + return + fi + fi + SKIPPED+=("GitHub secret $name (set it manually: gh secret set $name)") + warn "skipped GitHub secret $name: gh not ready; set it later" +} + +# set_var NAME VALUE sets a GitHub Actions repo variable (non-secret). +set_var() { + local name="$1" value="$2" + if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then + if gh variable set "$name" --body "$value" >/dev/null 2>&1; then + printf ' %s✓ set%s GitHub variable %s\n' "$GREEN" "$RESET" "$name" + return + fi + fi + SKIPPED+=("GitHub variable $name") + warn "skipped GitHub variable $name, gh not ready; set it later" +} + +# finish clears, then shows a closing summary of everything configured. +finish() { + _clear + printf '\n%s%s ✓ Setup complete%s\n' "$BOLD" "$GREEN" "$RESET" + (( ${#WRITTEN_ENV[@]} )) && note "wrote ${#WRITTEN_ENV[@]} value(s) to $ENV_FILE: ${WRITTEN_ENV[*]}" + (( ${#WRITTEN_SECRET[@]} )) && note "set ${#WRITTEN_SECRET[@]} GitHub secret(s): ${WRITTEN_SECRET[*]}" + if (( ${#SKIPPED[@]} )); then + printf '\n'; warn "still to do by hand:" + for s in "${SKIPPED[@]}"; do note " - $s"; done + fi + printf '\n' +} + + +# ────────────────────────────────────────────────────────────────────────── +# STAGES: author this section. +# ────────────────────────────────────────────────────────────────────────── + +# The wizard's own knobs, overridable from the environment so this script can be +# driven by a test or a future CI job rather than a person at a keyboard. +TOKEN_FILE="${TOKEN_FILE:-npm_release.token}" +EXPECTED_USER="${EXPECTED_USER:-botharness}" +# npm's error text is how a rejected token is told from a missing one, and the +# difference decides whether we prompt or warn. Both spellings below were observed +# against registry.npmjs.org: +# rejected → E401 / 401 Unauthorized +# no creds → "need auth This command requires you to be logged in" +# The network cases are here so an offline machine asks for a token instead of +# silently rejecting a perfectly good saved one. +REJECTED_PATTERN='401|E401|Unauthorized|ENEEDAUTH|ENOTFOUND|ETIMEDOUT|ENETUNREACH|EAI_AGAIN' + +# token_is_valid TOKEN — succeed only if the registry accepts this token AND it +# belongs to the account we publish as. Checking the user matters: a valid token +# for someone else would sail past a bare `npm whoami` and publish as them. +token_is_valid() { + local candidate="$1" whoami_out + whoami_out=$(npm whoami --//registry.npmjs.org/:_authToken="$candidate" 2>&1) || true + printf '%s' "$whoami_out" | grep -qE "$REJECTED_PATTERN" && return 1 + # `npm whoami` is the one call that actually discriminates: a fake token gets + # E401 and a real one gets the username. Nothing here can prove the token may + # PUBLISH, and the obvious candidates cannot be trusted to — `npm access` and + # `npm profile` are unknown subcommands that exit 0, so they "succeed" for a + # token that is pure fiction. Only whoami's output was verified to differ. + [[ "$whoami_out" == "$EXPECTED_USER" ]] +} + +read_token() { + [[ -f "$TOKEN_FILE" ]] || return 1 + # trailing whitespace/newlines are easy to paste in and silently break the header + tr -d '[:space:]' < "$TOKEN_FILE" +} + +store_token() { + local value="$1" dir tmp + dir=$(dirname "$TOKEN_FILE") + mkdir -p "$dir" + tmp=$(mktemp "${dir}/.npmtok.XXXXXX") + # written via a temp file in the same directory so the secret is never briefly + # world-readable, then moved into place; umask covers the window before chmod + ( umask 077; printf '%s\n' "$value" > "$tmp" ) + chmod 600 "$tmp" + mv "$tmp" "$TOKEN_FILE" + printf ' %s✓ saved%s %s (mode 600)\n' "$GREEN" "$RESET" "$TOKEN_FILE" +} + +TOTAL_STAGES=2 + +banner "npm release token" + +# ── Stage 1: reuse a saved token, or ask for one ─────────────────────────── +stage "The publish token" +say "Releasing to npm needs a token with write access, because this account's 2FA" +say "is a passkey and the CLI cannot answer a WebAuthn challenge." +note "A saved token is reused automatically; you are only asked when there isn't" +note "a usable one. Ctrl-C at any time — nothing is lost but this run." + +SAVED="" +if [[ -f "$TOKEN_FILE" ]]; then + note "found $TOKEN_FILE" + CANDIDATE=$(read_token || true) + if [[ -n "$CANDIDATE" ]] && token_is_valid "$CANDIDATE"; then + say "That token still works as $EXPECTED_USER." + SAVED="$CANDIDATE" + else + warn "the saved token was rejected — expired, revoked, or from another account." + note "npm tokens can be listed at https://www.npmjs.com/settings/access-tokens" + fi +else + note "no $TOKEN_FILE yet" +fi + +if [[ -z "$SAVED" ]]; then + say "" + say "If you don't have one yet, create it here:" + open_url "https://www.npmjs.com/settings/access-tokens/new" + step "Packages: scope @botharness (a token limited to package names cannot create new @botharness packages)" + step "Permissions: Read and write" + step "Tick 'Bypass 2FA' — without it the token cannot publish, and npm says so" + step "Set the shortest expiry you can live with; bypass tokens lose direct" + step " publishing in January 2027, so plan to move to OIDC trusted publishing" + step "Generate token, then copy it (it is shown only once)" + say "" + ask_secret TOKEN "Paste the token (input hidden):" + say "" + if [[ -z "$TOKEN" ]]; then + say "Nothing pasted. Re-run this script when you have one:" >&2 + note " bash scripts/npm-token.sh" >&2 + exit 1 + fi + if ! token_is_valid "$TOKEN"; then + warn "npm rejected that token." + say "Usual causes, in the order worth checking:" >&2 + note " - 'Bypass 2FA' was left unticked (the default is OFF)" >&2 + note " - the token was copied with a trailing space or newline" >&2 + note " - it belongs to a different npm account than $EXPECTED_USER" >&2 + note " - it has already expired" >&2 + exit 1 + fi + store_token "$TOKEN" + SAVED="$TOKEN" +fi + +# ── Stage 2: report what we know, and what we cannot know ───────────────── +stage "Ready to publish" +printf ' %s✓%s token accepted by the registry as %s\n' "$GREEN" "$RESET" "$EXPECTED_USER" +say "" +say "What this script could NOT check, so you are not misled:" +note " Whether the token can publish. The registry has no such endpoint, and the" +note " commands that look like they would answer it (npm access, npm profile)" +note " are unknown commands that exit 0 — a fake token passes them. Only a real" +note " publish proves it, which is why the release publishes pixel-morph first: a" +note " permission failure lands on the first package, before anything is" +note " half-released." +note "" +warn "If 'Bypass 2FA' was unticked, the publish fails with a 403. Re-create the" +warn "token with it ticked if that happens." +say "" +say "Publish with it:" +printf ' %spnpm release -- --yes%s\n' "$BOLD" "$RESET" +note "scripts/release.mjs reads $TOKEN_FILE on its own — no env var, no flag." +note "The token is never printed, never passed on a command line (so it cannot" +note "leak into ps or a CI log), and never written outside $TOKEN_FILE." + +finish diff --git a/scripts/readme-assets.mjs b/scripts/readme-assets.mjs new file mode 100644 index 0000000..1340538 --- /dev/null +++ b/scripts/readme-assets.mjs @@ -0,0 +1,270 @@ +// Renders the README banner and morph GIFs from the built packages. +// Usage: pnpm build && node scripts/readme-assets.mjs (needs ffmpeg on PATH) +import { spawnSync } from 'node:child_process'; +import { mkdirSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { + AVATAR_PARTS, + AVATAR_PRESETS, + faceCells, + pixelSymbolCells, + pixelTileColor, + seededRecipe, +} from '../packages/avatar/dist/index.js'; +import { pixelFrame, planPixels } from '../packages/morph/dist/index.js'; + +const OUT = new URL('../assets/', import.meta.url); +mkdirSync(OUT, { recursive: true }); + +const BG = '#1d1b22'; +const GOLD = '#f2d675'; +const INK = '#0f0e13'; + +const rgb = (hex) => { + const n = Number.parseInt(hex.slice(1), 16); + return [(n >> 16) & 255, (n >> 8) & 255, n & 255]; +}; + +class Canvas { + constructor(w, h, bg) { + this.w = w; + this.h = h; + this.data = Buffer.alloc(w * h * 3); + this.rect(0, 0, w, h, bg); + } + rect(x, y, w, h, color) { + const [r, g, b] = rgb(color); + for (let j = Math.max(0, y); j < Math.min(this.h, y + h); j++) + for (let i = Math.max(0, x); i < Math.min(this.w, x + w); i++) { + const o = (j * this.w + i) * 3; + this.data[o] = r; + this.data[o + 1] = g; + this.data[o + 2] = b; + } + } +} + +// the rounded 32×32 tile behind every avatar, the same shape the package clips to +const R = 6; +const inTile = (x, y) => { + const clamp = (v) => Math.min(Math.max(v, R), 32 - R); + return (x + 0.5 - clamp(x + 0.5)) ** 2 + (y + 0.5 - clamp(y + 0.5)) ** 2 <= R * R; +}; +function drawTile(canvas, recipe, ox, oy, s) { + const color = pixelTileColor(recipe.hairColor); + for (let y = 0; y < 32; y++) + for (let x = 0; x < 32; x++) if (inTile(x, y)) canvas.rect(ox + x * s, oy + y * s, s, s, color); +} +function drawCells(canvas, cells, ox, oy, s) { + for (const c of cells) canvas.rect(ox + c.x * s, oy + c.y * s, s, s, c.c); +} +function drawAvatar(canvas, recipe, cells, ox, oy, s) { + drawTile(canvas, recipe, ox, oy, s); + drawCells(canvas, cells, ox, oy, s); +} + +// a small hand-drawn pixel face for the wordmark +const GLYPHS = { + B: ['11110', '10001', '10001', '11110', '10001', '10001', '11110'], + o: ['00000', '00000', '01110', '10001', '10001', '10001', '01110'], + t: ['00100', '00100', '11111', '00100', '00100', '00100', '00011'], + P: ['11110', '10001', '10001', '11110', '10000', '10000', '10000'], + i: ['010', '000', '110', '010', '010', '010', '111'], + x: ['00000', '00000', '10001', '01010', '00100', '01010', '10001'], + e: ['00000', '00000', '01110', '10001', '11111', '10000', '01111'], + l: ['110', '010', '010', '010', '010', '010', '111'], +}; +function drawWord(canvas, word, cx, cy, s) { + const width = [...word].reduce((sum, ch) => sum + GLYPHS[ch][0].length + 1, -1); + const x = Math.round(cx - (width * s) / 2); + const y = Math.round(cy - (7 * s) / 2); + const edge = Math.round(s / 4); + for (const pass of ['shadow', 'face']) + [...word].reduce((gx, ch) => { + GLYPHS[ch].forEach((row, j) => + [...row].forEach((bit, i) => { + if (bit !== '1') return; + const px = gx + i * s; + const py = y + j * s; + if (pass === 'shadow') canvas.rect(px + edge, py + edge, s, s, INK); + else { + canvas.rect(px, py, s, s, GOLD); + } + }), + ); + return gx + (GLYPHS[ch][0].length + 1) * s; + }, x); +} + +function ffmpeg(args, input) { + const run = spawnSync('ffmpeg', ['-v', 'error', '-y', ...args], { input, maxBuffer: 1 << 30 }); + if (run.status !== 0) throw new Error(run.stderr.toString()); +} +function savePng(canvas, name) { + ffmpeg( + ['-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', `${canvas.w}x${canvas.h}`, '-i', '-'].concat([ + '-frames:v', + '1', + fileURLToPath(new URL(name, OUT)), + ]), + canvas.data, + ); +} +function saveGif(frames, name, fps = 25) { + const { w, h } = frames[0]; + ffmpeg( + [ + '-f', + 'rawvideo', + '-pix_fmt', + 'rgb24', + '-s', + `${w}x${h}`, + '-r', + String(fps), + '-i', + '-', + '-filter_complex', + '[0]split[a][b];[a]palettegen=max_colors=255:stats_mode=full[p];[b][p]paletteuse=dither=none', + '-loop', + '0', + fileURLToPath(new URL(name, OUT)), + ], + Buffer.concat(frames.map((f) => f.data)), + ); +} + +// ---- the cast: presets plus name-seeded faces, with a few turned heads ---- +const NAMES = + 'DeepSeekBot Ada Grace Linus Margaret Alan Barbara 小明 Rin Kai Mika Theo Juno Iris Otto Nova Sage Remy Luna Felix Hana Yuki Leo Mei Aria Zane Ivy Omar Nia Quinn Rex Tess Uma Vik Wren Yara Zed Bo Cy Dot Eli Fae Gus Hal Ida Jax Kit Lou Max Ned Oli Pip Roz Sol Tam Ula Vee Wes Xia Yen Zoe Ann Ben Cal Dee Eve Fox Gil Hob Ike Jo Ken Liv Mo Nan Ora Pia Ray Sue Tom Val Win Yo Zia Arlo Bea Cleo Dax Edda Finn Gwen Hugo Inez Jude Kira Lars Mila Nico'.split( + ' ', + ); +const POSES = ['front', 'front', 'left', 'front', 'right']; +const cast = [ + ...AVATAR_PRESETS, + ...NAMES.map((name, i) => ({ ...seededRecipe(name), pose: POSES[i % POSES.length] })), +]; + +// ---- banner: the wordmark in a hole, ringed by avatars ---- +{ + const cell = 80; + const s = 2; + const cols = 16; + const rows = 8; + const banner = new Canvas(cols * cell, rows * cell, BG); + let n = 0; + for (let r = 0; r < rows; r++) + for (let c = 0; c < cols; c++) { + if (r >= 3 && r <= 4 && c >= 3 && c <= 12) continue; + const recipe = cast[n++ % cast.length]; + const pad = (cell - 32 * s) / 2; + drawAvatar(banner, recipe, faceCells(recipe), c * cell + pad, r * cell + pad, s); + } + drawWord(banner, 'BotPixel', banner.w / 2, banner.h / 2, 14); + savePng(banner, 'banner.png'); +} + +// ---- morph timelines ---- +const FPS = 25; +const MORPH = Math.round(0.8 * FPS); +// one avatar's script: hold the face, then morph through `keys`, holding each +function timeline(recipe, keys, hold) { + const cellsFor = (key) => + key === 'face' ? faceCells(recipe) : pixelSymbolCells(key, recipe.hairColor); + const frames = []; + let current = cellsFor(keys[0]); + for (let i = 0; i < hold[0]; i++) frames.push(current); + for (let k = 1; k < keys.length; k++) { + const next = cellsFor(keys[k]); + const pairs = planPixels(current, next); + for (let f = 1; f <= MORPH; f++) frames.push(f === MORPH ? next : pixelFrame(pairs, f / MORPH)); + current = next; + for (let i = 0; i < (hold[k] ?? hold[1]); i++) frames.push(current); + } + return frames; +} + +// 1. one avatar working through a turn: thinking, reading, editing, a shell, a search +{ + const recipe = AVATAR_PRESETS[2]; + const keys = ['face', 'thinking', 'read', 'edit', 'bash', 'search', 'face']; + const tl = timeline(recipe, keys, [30, 18, 18, 18, 18, 18, 30]); + const s = 8; + const size = 32 * s + 32; + saveGif( + tl.map((cells) => { + const c = new Canvas(size, size, BG); + drawAvatar(c, recipe, cells, 16, 16, s); + return c; + }), + 'morph-turn.gif', + FPS, + ); +} + +// 2. a row of avatars, each on its own tool, out of step with each other +{ + const s = 4; + const gap = 16; + const crew = [0, 3, 5, 7, 9, 11].map((i) => AVATAR_PRESETS[i]); + const tools = [ + ['face', 'web', 'fetch', 'face'], + ['face', 'edit', 'approval', 'face'], + ['face', 'search', 'read', 'face'], + ['face', 'todo', 'write', 'face'], + ['face', 'subagent', 'workflow', 'face'], + ['face', 'thinking', 'present', 'face'], + ]; + const lines = crew.map((recipe, i) => { + const lead = Array(i * 8).fill(faceCells(recipe)); + return lead.concat(timeline(recipe, tools[i], [20, 22, 22, 20])); + }); + const length = Math.max(...lines.map((l) => l.length)) + 20; + const w = crew.length * (32 * s + gap) + gap; + const h = 32 * s + gap * 2; + const frames = []; + for (let f = 0; f < length; f++) { + const c = new Canvas(w, h, BG); + crew.forEach((recipe, i) => + drawAvatar( + c, + recipe, + lines[i][Math.min(f, lines[i].length - 1)], + gap + i * (32 * s + gap), + gap, + s, + ), + ); + frames.push(c); + } + saveGif(frames, 'morph-crew.gif', FPS); +} + +// 3. the engine alone: one face morphing into the next, nothing avatar-specific about it +{ + const s = 6; + const faces = ['Ada', 'Kai', '小明', 'Luna', 'Ada'].map((name) => seededRecipe(name)); + const frames = []; + for (let k = 0; k < faces.length - 1; k++) { + const a = faces[k]; + const b = faces[k + 1]; + const pairs = planPixels(faceCells(a), faceCells(b)); + for (let i = 0; i < 18; i++) frames.push({ cells: faceCells(a), tile: a }); + for (let f = 1; f <= MORPH; f++) + frames.push({ cells: pixelFrame(pairs, f / MORPH), tile: f < MORPH / 2 ? a : b }); + } + const size = 32 * s + 32; + saveGif( + frames.map(({ cells, tile }) => { + const c = new Canvas(size, size, BG); + drawAvatar(c, tile, cells, 16, 16, s); + return c; + }), + 'morph-faces.gif', + FPS, + ); +} + +console.log( + `rendered banner.png, morph-turn.gif, morph-crew.gif, morph-faces.gif (${AVATAR_PARTS.hair.length} hairstyles in the catalog)`, +); diff --git a/scripts/release.mjs b/scripts/release.mjs new file mode 100644 index 0000000..fe09052 --- /dev/null +++ b/scripts/release.mjs @@ -0,0 +1,75 @@ +#!/usr/bin/env node +/** + * Publish the packages, in dependency order. Ported from BotUI's scripts/release.mjs. + * + * `@botharness/pixel-avatar` depends on `@botharness/pixel-morph` with `workspace:^`, + * which pnpm rewrites to the real version on publish, so morph has to be on npm first. + * + * Dry run unless `--yes`: a publish cannot be undone. + */ +import { execFileSync } from 'node:child_process'; +import { readFileSync } from 'node:fs'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const root = join(dirname(fileURLToPath(import.meta.url)), '..'); +const yes = process.argv.includes('--yes'); +const tag = process.argv.includes('--tag') + ? process.argv[process.argv.indexOf('--tag') + 1] + : undefined; + +// The token only reaches the publish processes, through the environment: argv is +// visible in `ps` and CI logs, and a project .npmrc would apply it to every npm call. +let publishEnv = process.env; +const token = readToken(); +if (token && yes) { + publishEnv = { ...process.env, 'npm_config_//registry.npmjs.org/:_authToken': token }; +} + +const ORDER = [ + { dir: 'packages/morph', name: '@botharness/pixel-morph', why: 'depends on nothing' }, + { dir: 'packages/avatar', name: '@botharness/pixel-avatar', why: 'depends on pixel-morph' }, +]; + +const pnpm = (args, cwd, env) => + execFileSync('pnpm', args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'], env }); + +/** + * The publish token: NPM_TOKEN in CI (the repo secret), else `npm_release.token` (gitignored, written + * by `scripts/npm-token.sh`), or the file named by NPM_TOKEN_FILE, which lets this repo + * reuse the token BotUI already stores. Absent is not an error: a dry run needs none, + * and `npm publish` explains a missing token better than this script could. + */ +function readToken() { + if (process.env.NPM_TOKEN) return process.env.NPM_TOKEN.trim(); + const file = process.env.NPM_TOKEN_FILE ?? join(root, 'npm_release.token'); + try { + return readFileSync(file, 'utf8').trim() || undefined; + } catch { + return undefined; + } +} + +process.stdout.write('building and verifying…\n'); +pnpm(['build'], root); +pnpm(['verify'], root); + +for (const pkg of ORDER) { + const version = JSON.parse(readFileSync(join(root, pkg.dir, 'package.json'), 'utf8')).version; + process.stdout.write(`\n${pkg.name}@${version} — ${pkg.why}\n`); + if (!yes) { + process.stdout.write( + ` would run: pnpm --filter ${pkg.name} publish --access public${tag ? ` --tag ${tag}` : ''}\n`, + ); + continue; + } + const args = ['--filter', pkg.name, 'publish', '--access', 'public', '--no-git-checks']; + if (tag) args.push('--tag', tag); + process.stdout.write(pnpm(args, root, publishEnv)); +} + +process.stdout.write( + yes + ? '\npublished.\n' + : '\ndry run. Re-run with --yes to publish, and --tag next for a prerelease.\n', +); diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..274598c --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2022", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "verbatimModuleSyntax": true, + "isolatedModules": true, + "skipLibCheck": true, + "noEmit": true, + "types": ["node"], + // paths resolve relative to this file at the repo root, so each package typechecks + // against its siblings' source without a build first + "paths": { + "@botharness/pixel-morph": ["./packages/morph/src/index.ts"], + "@botharness/pixel-avatar": ["./packages/avatar/src/index.ts"] + } + } +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..558273c --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,19 @@ +import { fileURLToPath } from 'node:url'; +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + resolve: { + alias: { + '@botharness/pixel-morph': fileURLToPath( + new URL('./packages/morph/src/index.ts', import.meta.url), + ), + '@botharness/pixel-avatar': fileURLToPath( + new URL('./packages/avatar/src/index.ts', import.meta.url), + ), + }, + }, + test: { + include: ['packages/*/test/**/*.test.ts'], + environment: 'node', + }, +});