Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

milady

nirholas30f1e33a8ffc
diff --git a/package-lock.json b/package-lock.json
index 0e4ab9d5a..9c2560e79 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -38,6 +38,7 @@
"sharp": "^0.34.5",
"vite": "^7.3.2",
"vite-plugin-pwa": "^1.2.0",
+ "vitest": "^4.1.4",
"workbox-build": "^7.4.0",
"workbox-window": "^7.4.0"
}
@@ -4871,6 +4872,13 @@
"node": ">=18.0.0"
}
},
+ "node_modules/@standard-schema/spec": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",
+ "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@surma/rollup-plugin-off-main-thread": {
"version": "2.2.3",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz",
@@ -4884,6 +4892,24 @@
"string.prototype.matchall": "^4.0.6"
}
},
+ "node_modules/@types/chai": {
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",
+ "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/deep-eql": "*",
+ "assertion-error": "^2.0.1"
+ }
+ },
+ "node_modules/@types/deep-eql": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",
+ "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/@types/estree": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
@@ -4958,6 +4984,149 @@
"uncrypto": "^0.1.3"
}
},
+ "node_modules/@vitest/expect": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.4.tgz",
+ "integrity": "sha512-iPBpra+VDuXmBFI3FMKHSFXp3Gx5HfmSCE8X67Dn+bwephCnQCaB7qWK2ldHa+8ncN8hJU8VTMcxjPpyMkUjww==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@standard-schema/spec": "^1.1.0",
+ "@types/chai": "^5.2.2",
+ "@vitest/spy": "4.1.4",
+ "@vitest/utils": "4.1.4",
+ "chai": "^6.2.2",
+ "tinyrainbow": "^3.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
+ "node_modules/@vitest/mocker": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.4.tgz",
+ "integrity": "sha512-R9HTZBhW6yCSGbGQnDnH3QHfJxokKN4KB+Yvk9Q1le7eQNYwiCyKxmLmurSpFy6BzJanSLuEUDrD+j97Q+ZLPg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vitest/spy": "4.1.4",
+ "estree-walker": "^3.0.3",
+ "magic-string": "^0.30.21"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ },
+ "peerDependencies": {
+ "msw": "^2.4.9",
+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
+ },
+ "peerDependenciesMeta": {
+ "msw": {
+ "optional": true
+ },
+ "vite": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/@vitest/mocker/node_modules/estree-walker": {
+ "version": "3.0.3",
+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",
+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@types/estree": "^1.0.0"
+ }
+ },
+ "node_modules/@vitest/mocker/node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/@vitest/pretty-format": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.4.tgz",
+ "integrity": "sha512-ddmDHU0gjEUyEVLxtZa7xamrpIefdEETu3nZjWtHeZX4QxqJ7tRxSteHVXJOcr8jhiLoGAhkK4WJ3WqBpjx42A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "tinyrainbow": "^3.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
+ "node_modules/@vitest/runner": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.4.tgz",
+ "integrity": "sha512-xTp7VZ5aXP5ZJrn15UtJUWlx6qXLnGtF6jNxHepdPHpMfz/aVPx+htHtgcAL2mDXJgKhpoo2e9/hVJsIeFbytQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vitest/utils": "4.1.4",
+ "pathe": "^2.0.3"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
+ "node_modules/@vitest/snapshot": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.4.tgz",
+ "integrity": "sha512-MCjCFgaS8aZz+m5nTcEcgk/xhWv0rEH4Yl53PPlMXOZ1/Ka2VcZU6CJ+MgYCZbcJvzGhQRjVrGQNZqkGPttIKw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vitest/pretty-format": "4.1.4",
+ "@vitest/utils": "4.1.4",
+ "magic-string": "^0.30.21",
+ "pathe": "^2.0.3"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
+ "node_modules/@vitest/snapshot/node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
+ "node_modules/@vitest/spy": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.4.tgz",
+ "integrity": "sha512-XxNdAsKW7C+FLydqFJLb5KhJtl3PGCMmYwFRfhvIgxJvLSXhhVI1zM8f1qD3Zg7RCjTSzDVyct6sghs9UEgBEQ==",
+ "dev": true,
+ "license": "MIT",
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
+ "node_modules/@vitest/utils": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.4.tgz",
+ "integrity": "sha512-13QMT+eysM5uVGa1rG4kegGYNp6cnQcsTc67ELFbhNLQO+vgsygtYJx2khvdt4gVQqSSpC/KT5FZZxUpP3Oatw==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vitest/pretty-format": "4.1.4",
+ "convert-source-map": "^2.0.0",
+ "tinyrainbow": "^3.1.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ }
+ },
"node_modules/abitype": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/abitype/-/abitype-1.2.3.tgz",
@@ -5054,6 +5223,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/assertion-error": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",
+ "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=12"
+ }
+ },
"node_modules/async": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz",
@@ -5308,6 +5487,16 @@
"canonicalize": "bin/canonicalize.js"
}
},
+ "node_modules/chai": {
+ "version": "6.2.2",
+ "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",
+ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
@@ -5641,6 +5830,13 @@
"node": ">= 0.4"
}
},
+ "node_modules/es-module-lexer": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.0.0.tgz",
+ "integrity": "sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
@@ -5812,6 +6008,16 @@
"integrity": "sha512-mlsTRyGaPBjPedk6Bvw+aqbsXDtoAyAzm5MO7JgU+yVRyMQ5O8bD4Kcci7BS85f93veegeCPkL8R4GLClnjLFw==",
"license": "MIT"
},
+ "node_modules/expect-type": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz",
+ "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=12.0.0"
+ }
+ },
"node_modules/fast-deep-equal": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
@@ -7051,6 +7257,17 @@
"integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==",
"license": "MIT"
},
+ "node_modules/obug": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz",
+ "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==",
+ "dev": true,
+ "funding": [
+ "https://github.com/sponsors/sxzz",
+ "https://opencollective.com/debug"
+ ],
+ "license": "MIT"
+ },
"node_modules/own-keys": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz",
@@ -7210,6 +7427,13 @@
"node": "20 || >=22"
}
},
+ "node_modules/pathe": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",
+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/pg-int8": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
@@ -7884,6 +8108,13 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/siginfo": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",
+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",
+ "dev": true,
+ "license": "ISC"
+ },
"node_modules/signal-exit": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz",
@@ -7979,6 +8210,20 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
+ "node_modules/stackback": {
+ "version": "0.0.2",
+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",
+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/std-env": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz",
+ "integrity": "sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==",
+ "dev": true,
+ "license": "MIT"
+ },
"node_modules/stop-iteration-iterator": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz",
@@ -8184,6 +8429,23 @@
"integrity": "sha512-PWRKYWQo23ojf9oZSlRGH8K09q7nRSWx6LY/HF/UUrMdYgN9i1e2OwJYHoQjwc6HF/4lvvYLC5YC1X8UJL2ZpA==",
"license": "MIT"
},
+ "node_modules/tinybench": {
+ "version": "2.9.0",
+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",
+ "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/tinyexec": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.1.tgz",
+ "integrity": "sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=18"
+ }
+ },
"node_modules/tinyglobby": {
"version": "0.2.16",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz",
@@ -8201,6 +8463,16 @@
"url": "https://github.com/sponsors/SuperchupuDev"
}
},
+ "node_modules/tinyrainbow": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz",
+ "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=14.0.0"
+ }
+ },
"node_modules/tr46": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz",
@@ -8660,6 +8932,106 @@
}
}
},
+ "node_modules/vitest": {
+ "version": "4.1.4",
+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.4.tgz",
+ "integrity": "sha512-tFuJqTxKb8AvfyqMfnavXdzfy3h3sWZRWwfluGbkeR7n0HUev+FmNgZ8SDrRBTVrVCjgH5cA21qGbCffMNtWvg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@vitest/expect": "4.1.4",
+ "@vitest/mocker": "4.1.4",
+ "@vitest/pretty-format": "4.1.4",
+ "@vitest/runner": "4.1.4",
+ "@vitest/snapshot": "4.1.4",
+ "@vitest/spy": "4.1.4",
+ "@vitest/utils": "4.1.4",
+ "es-module-lexer": "^2.0.0",
+ "expect-type": "^1.3.0",
+ "magic-string": "^0.30.21",
+ "obug": "^2.1.1",
+ "pathe": "^2.0.3",
+ "picomatch": "^4.0.3",
+ "std-env": "^4.0.0-rc.1",
+ "tinybench": "^2.9.0",
+ "tinyexec": "^1.0.2",
+ "tinyglobby": "^0.2.15",
+ "tinyrainbow": "^3.1.0",
+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
+ "why-is-node-running": "^2.3.0"
+ },
+ "bin": {
+ "vitest": "vitest.mjs"
+ },
+ "engines": {
+ "node": "^20.0.0 || ^22.0.0 || >=24.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/vitest"
+ },
+ "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.4",
+ "@vitest/browser-preview": "4.1.4",
+ "@vitest/browser-webdriverio": "4.1.4",
+ "@vitest/coverage-istanbul": "4.1.4",
+ "@vitest/coverage-v8": "4.1.4",
+ "@vitest/ui": "4.1.4",
+ "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
+ },
+ "vite": {
+ "optional": false
+ }
+ }
+ },
+ "node_modules/vitest/node_modules/magic-string": {
+ "version": "0.30.21",
+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/sourcemap-codec": "^1.5.5"
+ }
+ },
"node_modules/webidl-conversions": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
@@ -8784,6 +9156,23 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/why-is-node-running": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",
+ "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "siginfo": "^2.0.0",
+ "stackback": "0.0.2"
+ },
+ "bin": {
+ "why-is-node-running": "cli.js"
+ },
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/workbox-background-sync": {
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.4.0.tgz",
diff --git a/package.json b/package.json
index 7044f9bd9..848d4c6c3 100644
--- a/package.json
+++ b/package.json
@@ -43,7 +43,7 @@
"clean": "rm -rf dist/* dist-lib/* || true",
"generate-icons": "node scripts/generate-pwa-icons.mjs",
"fetch-animations": "node scripts/download-animations.mjs",
- "test": "echo 'No tests configured' && exit 0",
+ "test": "vitest run",
"verify": "prettier --check . && vite build",
"format": "prettier --write .",
"deploy": "npm run build:all && vercel --local-config vercel.json --prod",
@@ -79,6 +79,7 @@
"sharp": "^0.34.5",
"vite": "^7.3.2",
"vite-plugin-pwa": "^1.2.0",
+ "vitest": "^4.1.4",
"workbox-build": "^7.4.0",
"workbox-window": "^7.4.0"
}
diff --git a/tests/api/crypto.test.js b/tests/api/crypto.test.js
new file mode 100644
index 000000000..6d0368fa6
--- /dev/null
+++ b/tests/api/crypto.test.js
@@ -0,0 +1,128 @@
+import { describe, it, expect } from 'vitest';
+import {
+ randomToken,
+ sha256,
+ sha256Base64Url,
+ constantTimeEquals,
+ hmacSha256,
+} from '../../api/_lib/crypto.js';
+
+describe('randomToken', () => {
+ it('returns a base64url string', () => {
+ const token = randomToken();
+ expect(typeof token).toBe('string');
+ expect(token.length).toBeGreaterThan(0);
+ expect(token).not.toMatch(/[+/=]/);
+ });
+
+ it('uses default 32 bytes (produces ~43 chars)', () => {
+ const token = randomToken();
+ // 32 bytes base64url = ceil(32 * 4/3) = 43 chars (no padding)
+ expect(token.length).toBeGreaterThanOrEqual(42);
+ });
+
+ it('produces unique tokens each call', () => {
+ const a = randomToken();
+ const b = randomToken();
+ expect(a).not.toBe(b);
+ });
+
+ it('respects custom byte length', () => {
+ const short = randomToken(8);
+ const long = randomToken(64);
+ expect(short.length).toBeLessThan(long.length);
+ });
+});
+
+describe('sha256', () => {
+ it('returns lowercase hex string of length 64', async () => {
+ const hash = await sha256('hello');
+ expect(hash).toMatch(/^[a-f0-9]{64}$/);
+ });
+
+ it('matches known SHA-256 of "hello"', async () => {
+ const hash = await sha256('hello');
+ expect(hash).toBe('2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824');
+ });
+
+ it('accepts Uint8Array input', async () => {
+ const bytes = new TextEncoder().encode('hello');
+ const hash = await sha256(bytes);
+ expect(hash).toBe('2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824');
+ });
+
+ it('produces different hashes for different inputs', async () => {
+ const a = await sha256('foo');
+ const b = await sha256('bar');
+ expect(a).not.toBe(b);
+ });
+});
+
+describe('sha256Base64Url', () => {
+ it('returns base64url string (no +/=)', async () => {
+ const hash = await sha256Base64Url('hello');
+ expect(hash).not.toMatch(/[+/=]/);
+ expect(typeof hash).toBe('string');
+ });
+
+ it('is consistent across calls', async () => {
+ const a = await sha256Base64Url('test');
+ const b = await sha256Base64Url('test');
+ expect(a).toBe(b);
+ });
+
+ it('differs from hex sha256', async () => {
+ const hex = await sha256('hello');
+ const b64 = await sha256Base64Url('hello');
+ expect(hex).not.toBe(b64);
+ });
+});
+
+describe('constantTimeEquals', () => {
+ it('returns true for identical strings', () => {
+ expect(constantTimeEquals('abc', 'abc')).toBe(true);
+ });
+
+ it('returns false for different strings of same length', () => {
+ expect(constantTimeEquals('abc', 'xyz')).toBe(false);
+ });
+
+ it('returns false for different lengths', () => {
+ expect(constantTimeEquals('abc', 'ab')).toBe(false);
+ expect(constantTimeEquals('ab', 'abc')).toBe(false);
+ });
+
+ it('returns true for empty strings', () => {
+ expect(constantTimeEquals('', '')).toBe(true);
+ });
+
+ it('is case-sensitive', () => {
+ expect(constantTimeEquals('ABC', 'abc')).toBe(false);
+ });
+});
+
+describe('hmacSha256', () => {
+ it('returns a base64url string', async () => {
+ const sig = await hmacSha256('secret', 'message');
+ expect(typeof sig).toBe('string');
+ expect(sig).not.toMatch(/[+/=]/);
+ });
+
+ it('is deterministic for same inputs', async () => {
+ const a = await hmacSha256('secret', 'message');
+ const b = await hmacSha256('secret', 'message');
+ expect(a).toBe(b);
+ });
+
+ it('changes with different secret', async () => {
+ const a = await hmacSha256('secret1', 'message');
+ const b = await hmacSha256('secret2', 'message');
+ expect(a).not.toBe(b);
+ });
+
+ it('changes with different message', async () => {
+ const a = await hmacSha256('secret', 'msg1');
+ const b = await hmacSha256('secret', 'msg2');
+ expect(a).not.toBe(b);
+ });
+});
diff --git a/tests/api/embed-policy.test.js b/tests/api/embed-policy.test.js
new file mode 100644
index 000000000..1dff7bcba
--- /dev/null
+++ b/tests/api/embed-policy.test.js
@@ -0,0 +1,176 @@
+import { describe, it, expect, vi } from 'vitest';
+
+// Mock db.js to prevent DB connection on import
+vi.mock('../../api/_lib/db.js', () => ({ sql: vi.fn() }));
+
+import {
+ defaultEmbedPolicy,
+ normalizeLegacyPolicy,
+ validateEmbedPolicy,
+ POLICY_VERSION,
+} from '../../api/_lib/embed-policy.js';
+
+describe('defaultEmbedPolicy', () => {
+ it('returns a policy with version 1', () => {
+ const p = defaultEmbedPolicy();
+ expect(p.version).toBe(1);
+ expect(p.version).toBe(POLICY_VERSION);
+ });
+
+ it('has allowlist mode with empty hosts', () => {
+ const p = defaultEmbedPolicy();
+ expect(p.origins.mode).toBe('allowlist');
+ expect(p.origins.hosts).toEqual([]);
+ });
+
+ it('has all surfaces enabled except mcp', () => {
+ const p = defaultEmbedPolicy();
+ expect(p.surfaces.script).toBe(true);
+ expect(p.surfaces.iframe).toBe(true);
+ expect(p.surfaces.widget).toBe(true);
+ expect(p.surfaces.mcp).toBe(false);
+ });
+
+ it('brain defaults to we-pay mode', () => {
+ const p = defaultEmbedPolicy();
+ expect(p.brain.mode).toBe('we-pay');
+ expect(p.brain.proxy_url).toBeNull();
+ expect(p.brain.monthly_quota).toBe(1000);
+ expect(p.brain.rate_limit_per_min).toBe(10);
+ });
+
+ it('storage defaults to r2', () => {
+ const p = defaultEmbedPolicy();
+ expect(p.storage.primary).toBe('r2');
+ expect(p.storage.pinned_ipfs).toBe(false);
+ expect(p.storage.onchain_attested).toBe(false);
+ });
+});
+
+describe('normalizeLegacyPolicy', () => {
+ it('returns default policy for null input', () => {
+ const result = normalizeLegacyPolicy(null);
+ expect(result).toEqual(defaultEmbedPolicy());
+ });
+
+ it('returns default policy for undefined input', () => {
+ const result = normalizeLegacyPolicy(undefined);
+ expect(result).toEqual(defaultEmbedPolicy());
+ });
+
+ it('handles legacy format (has mode/hosts at root, no version/origins)', () => {
+ const legacy = { mode: 'denylist', hosts: ['evil.com', 'bad.io'] };
+ const result = normalizeLegacyPolicy(legacy);
+ expect(result.origins.mode).toBe('denylist');
+ expect(result.origins.hosts).toEqual(['evil.com', 'bad.io']);
+ expect(result.version).toBe(POLICY_VERSION);
+ // surfaces/brain/storage should come from defaults
+ expect(result.surfaces).toEqual(defaultEmbedPolicy().surfaces);
+ });
+
+ it('merges partial origins into defaults', () => {
+ const partial = { origins: { mode: 'denylist', hosts: ['x.com'] } };
+ const result = normalizeLegacyPolicy(partial);
+ expect(result.origins.mode).toBe('denylist');
+ expect(result.origins.hosts).toEqual(['x.com']);
+ });
+
+ it('merges partial surfaces into defaults', () => {
+ const partial = { surfaces: { mcp: true } };
+ const result = normalizeLegacyPolicy(partial);
+ expect(result.surfaces.mcp).toBe(true);
+ expect(result.surfaces.iframe).toBe(true); // from default
+ });
+
+ it('merges partial brain config into defaults', () => {
+ const partial = { brain: { mode: 'none' } };
+ const result = normalizeLegacyPolicy(partial);
+ expect(result.brain.mode).toBe('none');
+ expect(result.brain.monthly_quota).toBe(1000); // from default
+ });
+});
+
+describe('validateEmbedPolicy', () => {
+ it('accepts a valid full policy', () => {
+ const policy = {
+ origins: { mode: 'allowlist', hosts: ['example.com'] },
+ surfaces: { script: true, iframe: false, widget: true, mcp: false },
+ brain: {
+ mode: 'we-pay',
+ proxy_url: null,
+ monthly_quota: 500,
+ rate_limit_per_min: 5,
+ model: 'claude-sonnet-4-6',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+ };
+ const result = validateEmbedPolicy(policy);
+ expect(result.origins.mode).toBe('allowlist');
+ expect(result.origins.hosts).toEqual(['example.com']);
+ });
+
+ it('requires proxy_url when brain.mode is key-proxy', () => {
+ const policy = {
+ origins: { mode: 'allowlist', hosts: [] },
+ surfaces: { script: true, iframe: true, widget: true, mcp: false },
+ brain: {
+ mode: 'key-proxy',
+ proxy_url: null, // invalid — key-proxy needs a URL
+ monthly_quota: null,
+ rate_limit_per_min: null,
+ model: 'claude-sonnet-4-6',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+ };
+ expect(() => validateEmbedPolicy(policy)).toThrow();
+ });
+
+ it('accepts key-proxy with valid proxy_url', () => {
+ const policy = {
+ origins: { mode: 'allowlist', hosts: [] },
+ surfaces: { script: true, iframe: true, widget: true, mcp: false },
+ brain: {
+ mode: 'key-proxy',
+ proxy_url: 'https://proxy.example.com',
+ monthly_quota: null,
+ rate_limit_per_min: null,
+ model: 'claude-sonnet-4-6',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+ };
+ const result = validateEmbedPolicy(policy);
+ expect(result.brain.mode).toBe('key-proxy');
+ });
+
+ it('rejects invalid origin mode', () => {
+ const policy = {
+ origins: { mode: 'wildcard', hosts: [] }, // invalid
+ surfaces: { script: true, iframe: true, widget: true, mcp: false },
+ brain: {
+ mode: 'we-pay',
+ proxy_url: null,
+ monthly_quota: null,
+ rate_limit_per_min: null,
+ model: 'claude-sonnet-4-6',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+ };
+ expect(() => validateEmbedPolicy(policy)).toThrow();
+ });
+
+ it('rejects more than 100 hosts', () => {
+ const policy = {
+ origins: { mode: 'allowlist', hosts: Array.from({ length: 101 }, (_, i) => `host${i}.com`) },
+ surfaces: { script: true, iframe: true, widget: true, mcp: false },
+ brain: {
+ mode: 'we-pay',
+ proxy_url: null,
+ monthly_quota: null,
+ rate_limit_per_min: null,
+ model: 'claude-sonnet-4-6',
+ },
+ storage: { primary: 'r2', pinned_ipfs: false, onchain_attested: false },
+ };
+ expect(() => validateEmbedPolicy(policy)).toThrow();
+ });
+});
diff --git a/tests/api/siwe.test.js b/tests/api/siwe.test.js
new file mode 100644
index 000000000..420a3a864
--- /dev/null
+++ b/tests/api/siwe.test.js
@@ -0,0 +1,124 @@
+import { describe, it, expect } from 'vitest';
+import { parseSiweMessage } from '../../api/_lib/siwe.js';
+
+const VALID_MSG = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://localhost/login',
+ 'Version: 1',
+ 'Chain ID: 1',
+ 'Nonce: abc123xyz',
+ 'Issued At: 2024-01-01T00:00:00.000Z',
+].join('\n');
+
+describe('parseSiweMessage', () => {
+ it('parses a valid SIWE message', () => {
+ const result = parseSiweMessage(VALID_MSG);
+ expect(result).not.toBeNull();
+ expect(result.domain).toBe('localhost');
+ expect(result.address).toBe('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045');
+ expect(result.uri).toBe('https://localhost/login');
+ expect(result.version).toBe('1');
+ expect(result.chainId).toBe(1);
+ expect(result.nonce).toBe('abc123xyz');
+ expect(result.issuedAt).toBe('2024-01-01T00:00:00.000Z');
+ });
+
+ it('returns null for message with too few lines', () => {
+ expect(parseSiweMessage('line1\nline2')).toBeNull();
+ });
+
+ it('returns null for missing URI', () => {
+ const msg = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'Version: 1',
+ 'Nonce: abc123xyz',
+ ].join('\n');
+ expect(parseSiweMessage(msg)).toBeNull();
+ });
+
+ it('returns null for missing Nonce', () => {
+ const msg = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://localhost/login',
+ 'Version: 1',
+ ].join('\n');
+ expect(parseSiweMessage(msg)).toBeNull();
+ });
+
+ it('returns null for missing Version', () => {
+ const msg = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://localhost/login',
+ 'Nonce: abc123xyz',
+ ].join('\n');
+ expect(parseSiweMessage(msg)).toBeNull();
+ });
+
+ it('returns null for invalid Ethereum address', () => {
+ const msg = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ 'not-an-address',
+ '',
+ 'URI: https://localhost/login',
+ 'Version: 1',
+ 'Nonce: abc123xyz',
+ ].join('\n');
+ expect(parseSiweMessage(msg)).toBeNull();
+ });
+
+ it('returns null for malformed header', () => {
+ const msg = [
+ 'bad header line',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://localhost/login',
+ 'Version: 1',
+ 'Nonce: abc123xyz',
+ ].join('\n');
+ expect(parseSiweMessage(msg)).toBeNull();
+ });
+
+ it('parses optional fields when present', () => {
+ const msg = [
+ 'example.com wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://example.com/login',
+ 'Version: 1',
+ 'Chain ID: 137',
+ 'Nonce: nonce42',
+ 'Issued At: 2024-06-01T12:00:00Z',
+ 'Expiration Time: 2024-06-01T13:00:00Z',
+ 'Not Before: 2024-06-01T11:00:00Z',
+ 'Request ID: req-001',
+ ].join('\n');
+ const result = parseSiweMessage(msg);
+ expect(result.chainId).toBe(137);
+ expect(result.expirationTime).toBe('2024-06-01T13:00:00Z');
+ expect(result.notBefore).toBe('2024-06-01T11:00:00Z');
+ expect(result.requestId).toBe('req-001');
+ });
+
+ it('handles Chain ID of 0 as null', () => {
+ const msg = [
+ 'localhost wants you to sign in with your Ethereum account:',
+ '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
+ '',
+ 'URI: https://localhost/login',
+ 'Version: 1',
+ 'Chain ID: 0',
+ 'Nonce: abc123xyz',
+ ].join('\n');
+ const result = parseSiweMessage(msg);
+ // parseInt('0', 10) is 0, which is falsy → null per the parser logic
+ expect(result.chainId).toBeNull();
+ });
+});
diff --git a/tests/api/validate.test.js b/tests/api/validate.test.js
new file mode 100644
index 000000000..89b1c64ce
--- /dev/null
+++ b/tests/api/validate.test.js
@@ -0,0 +1,227 @@
+import { describe, it, expect } from 'vitest';
+import {
+ email,
+ password,
+ displayName,
+ slug,
+ avatarVisibility,
+ avatarContentType,
+ username,
+ registerBody,
+ loginBody,
+ createAvatarBody,
+ presignUploadBody,
+ parse,
+} from '../../api/_lib/validate.js';
+
+describe('email schema', () => {
+ it('accepts valid email', () => {
+ expect(email.parse('[email protected]')).toBe('[email protected]');
+ });
+
+ it('trims whitespace and lowercases', () => {
+ expect(email.parse(' [email protected] ')).toBe('[email protected]');
+ });
+
+ it('rejects invalid email', () => {
+ expect(() => email.parse('not-an-email')).toThrow();
+ });
+
+ it('rejects email over 254 chars', () => {
+ const long = 'a'.repeat(244) + '@example.com';
+ expect(() => email.parse(long)).toThrow();
+ });
+});
+
+describe('password schema', () => {
+ it('accepts 10-char password', () => {
+ expect(password.parse('1234567890')).toBe('1234567890');
+ });
+
+ it('rejects password under 10 chars', () => {
+ expect(() => password.parse('short')).toThrow();
+ });
+
+ it('rejects password over 200 chars', () => {
+ expect(() => password.parse('a'.repeat(201))).toThrow();
+ });
+});
+
+describe('displayName schema', () => {
+ it('accepts valid display name', () => {
+ expect(displayName.parse(' Alice ')).toBe('Alice');
+ });
+
+ it('rejects empty string', () => {
+ expect(() => displayName.parse('')).toThrow();
+ });
+
+ it('rejects name over 80 chars', () => {
+ expect(() => displayName.parse('a'.repeat(81))).toThrow();
+ });
+});
+
+describe('slug schema', () => {
+ it('accepts valid slugs', () => {
+ expect(slug.parse('my-avatar')).toBe('my-avatar');
+ expect(slug.parse('avatar_1')).toBe('avatar_1');
+ expect(slug.parse('abc123')).toBe('abc123');
+ });
+
+ it('rejects slugs starting with - or _', () => {
+ expect(() => slug.parse('-bad')).toThrow();
+ expect(() => slug.parse('_bad')).toThrow();
+ });
+
+ it('rejects uppercase letters', () => {
+ expect(() => slug.parse('MyAvatar')).toThrow();
+ });
+
+ it('rejects empty string', () => {
+ expect(() => slug.parse('')).toThrow();
+ });
+
+ it('rejects slug over 64 chars', () => {
+ expect(() => slug.parse('a'.repeat(65))).toThrow();
+ });
+});
+
+describe('avatarVisibility schema', () => {
+ it('accepts valid values', () => {
+ expect(avatarVisibility.parse('private')).toBe('private');
+ expect(avatarVisibility.parse('unlisted')).toBe('unlisted');
+ expect(avatarVisibility.parse('public')).toBe('public');
+ });
+
+ it('rejects unknown values', () => {
+ expect(() => avatarVisibility.parse('hidden')).toThrow();
+ });
+});
+
+describe('avatarContentType schema', () => {
+ it('accepts GLB content type', () => {
+ expect(avatarContentType.parse('model/gltf-binary')).toBe('model/gltf-binary');
+ });
+
+ it('accepts GLTF content type', () => {
+ expect(avatarContentType.parse('model/gltf+json')).toBe('model/gltf+json');
+ });
+
+ it('rejects other content types', () => {
+ expect(() => avatarContentType.parse('image/png')).toThrow();
+ expect(() => avatarContentType.parse('text/html')).toThrow();
+ });
+});
+
+describe('username schema', () => {
+ it('accepts valid usernames', () => {
+ expect(username.parse('alice_123')).toBe('alice_123');
+ expect(username.parse('Bob-42')).toBe('Bob-42');
+ });
+
+ it('rejects username under 3 chars', () => {
+ expect(() => username.parse('ab')).toThrow();
+ });
+
+ it('rejects username over 30 chars', () => {
+ expect(() => username.parse('a'.repeat(31))).toThrow();
+ });
+
+ it('rejects special characters', () => {
+ expect(() => username.parse('user@name')).toThrow();
+ expect(() => username.parse('user name')).toThrow();
+ });
+});
+
+describe('registerBody schema', () => {
+ it('accepts valid registration body', () => {
+ const result = registerBody.parse({ email: '[email protected]', password: 'securepassword1' });
+ expect(result.email).toBe('[email protected]');
+ expect(result.password).toBe('securepassword1');
+ });
+
+ it('accepts optional display_name', () => {
+ const result = registerBody.parse({
+ email: '[email protected]',
+ password: 'securepassword1',
+ display_name: 'Alice',
+ });
+ expect(result.display_name).toBe('Alice');
+ });
+
+ it('rejects missing email', () => {
+ expect(() => registerBody.parse({ password: 'securepassword1' })).toThrow();
+ });
+});
+
+describe('loginBody schema', () => {
+ it('accepts email + password', () => {
+ const result = loginBody.parse({ email: '[email protected]', password: 'pass' });
+ expect(result.email).toBe('[email protected]');
+ });
+
+ it('rejects empty password', () => {
+ expect(() => loginBody.parse({ email: '[email protected]', password: '' })).toThrow();
+ });
+});
+
+describe('createAvatarBody schema', () => {
+ const base = { name: 'My Avatar', size_bytes: 1024 };
+
+ it('accepts minimal valid body with defaults', () => {
+ const result = createAvatarBody.parse(base);
+ expect(result.name).toBe('My Avatar');
+ expect(result.visibility).toBe('private');
+ expect(result.tags).toEqual([]);
+ expect(result.source).toBe('upload');
+ expect(result.content_type).toBe('model/gltf-binary');
+ });
+
+ it('rejects size_bytes over 500MB', () => {
+ expect(() => createAvatarBody.parse({ ...base, size_bytes: 500 * 1024 * 1024 + 1 })).toThrow();
+ });
+
+ it('rejects invalid checksum format', () => {
+ expect(() =>
+ createAvatarBody.parse({ ...base, checksum_sha256: 'not-a-hash' }),
+ ).toThrow();
+ });
+
+ it('accepts valid 64-char hex checksum', () => {
+ const result = createAvatarBody.parse({
+ ...base,
+ checksum_sha256: 'a'.repeat(64),
+ });
+ expect(result.checksum_sha256).toBe('a'.repeat(64));
+ });
+});
+
+describe('parse helper', () => {
+ it('returns parsed data on success', () => {
+ const result = parse(email, '[email protected]');
+ expect(result).toBe('[email protected]');
+ });
+
+ it('throws error with status 400 and code validation_error on failure', () => {
+ let err;
+ try {
+ parse(email, 'not-an-email');
+ } catch (e) {
+ err = e;
+ }
+ expect(err).toBeDefined();
+ expect(err.status).toBe(400);
+ expect(err.code).toBe('validation_error');
+ expect(err.message).toBeTruthy();
+ });
+
+ it('includes field path in error message', () => {
+ let err;
+ try {
+ parse(registerBody, { email: 'bad', password: 'short' });
+ } catch (e) {
+ err = e;
+ }
+ expect(err.message).toMatch(/email|password/i);
+ });
+});
diff --git a/tests/src/animation-slots.test.js b/tests/src/animation-slots.test.js
new file mode 100644
index 000000000..c77c66543
--- /dev/null
+++ b/tests/src/animation-slots.test.js
@@ -0,0 +1,71 @@
+import { describe, it, expect } from 'vitest';
+import { SLOTS, DEFAULT_ANIMATION_MAP, resolveSlot } from '../../src/runtime/animation-slots.js';
+
+describe('SLOTS', () => {
+ it('is an array of 10 slot names', () => {
+ expect(Array.isArray(SLOTS)).toBe(true);
+ expect(SLOTS.length).toBe(10);
+ });
+
+ it('contains expected slot names', () => {
+ const expected = ['idle', 'wave', 'nod', 'shake', 'think', 'celebrate', 'concern', 'bow', 'point', 'shrug'];
+ expect(SLOTS).toEqual(expected);
+ });
+
+ it('has no duplicate entries', () => {
+ expect(new Set(SLOTS).size).toBe(SLOTS.length);
+ });
+});
+
+describe('DEFAULT_ANIMATION_MAP', () => {
+ it('has an entry for every slot', () => {
+ for (const slot of SLOTS) {
+ expect(DEFAULT_ANIMATION_MAP).toHaveProperty(slot);
+ expect(typeof DEFAULT_ANIMATION_MAP[slot]).toBe('string');
+ }
+ });
+
+ it('maps idle to idle', () => {
+ expect(DEFAULT_ANIMATION_MAP.idle).toBe('idle');
+ });
+
+ it('maps celebrate to celebrate', () => {
+ expect(DEFAULT_ANIMATION_MAP.celebrate).toBe('celebrate');
+ });
+});
+
+describe('resolveSlot', () => {
+ it('returns default mapping when no override given', () => {
+ expect(resolveSlot('idle', null)).toBe('idle');
+ expect(resolveSlot('celebrate', null)).toBe('celebrate');
+ expect(resolveSlot('wave', null)).toBe(DEFAULT_ANIMATION_MAP.wave);
+ });
+
+ it('uses override map when slot is present', () => {
+ const overrides = { wave: 'custom_wave_clip' };
+ expect(resolveSlot('wave', overrides)).toBe('custom_wave_clip');
+ });
+
+ it('falls through to default when override does not contain slot', () => {
+ const overrides = { wave: 'custom_wave_clip' };
+ expect(resolveSlot('nod', overrides)).toBe(DEFAULT_ANIMATION_MAP.nod);
+ });
+
+ it('returns the slot name itself for unknown slots', () => {
+ expect(resolveSlot('unknown_slot', null)).toBe('unknown_slot');
+ });
+
+ it('returns the slot name for unknown slots even with overrides', () => {
+ const overrides = { wave: 'something' };
+ expect(resolveSlot('mystery', overrides)).toBe('mystery');
+ });
+
+ it('handles empty override map', () => {
+ expect(resolveSlot('think', {})).toBe(DEFAULT_ANIMATION_MAP.think);
+ });
+
+ it('override takes priority over default even if default exists', () => {
+ const overrides = { idle: 'breathing_idle' };
+ expect(resolveSlot('idle', overrides)).toBe('breathing_idle');
+ });
+});
diff --git a/vitest.config.js b/vitest.config.js
new file mode 100644
index 000000000..645deb070
--- /dev/null
+++ b/vitest.config.js
@@ -0,0 +1,8 @@
+import { defineConfig } from 'vitest/config';
+
+export default defineConfig({
+ test: {
+ environment: 'node',
+ include: ['tests/**/*.test.js'],
+ },
+});
diff --git a/yarn.lock b/yarn.lock
index e61a1dcbb..c5aafd2b7 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1472,7 +1472,7 @@
"@jridgewell/gen-mapping" "^0.3.5"
"@jridgewell/trace-mapping" "^0.3.25"
-"@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.5.0":
+"@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.5.0", "@jridgewell/sourcemap-codec@^1.5.5":
version "1.5.5"
resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz"
integrity sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==
@@ -2159,6 +2159,11 @@
dependencies:
tslib "^2.6.2"
+"@standard-schema/spec@^1.1.0":
+ version "1.1.0"
+ resolved "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz"
+ integrity sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==
+
"@surma/rollup-plugin-off-main-thread@^2.2.3":
version "2.2.3"
resolved "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-2.2.3.tgz"
@@ -2169,6 +2174,19 @@
magic-string "^0.25.0"
string.prototype.matchall "^4.0.6"
+"@types/chai@^5.2.2":
+ version "5.2.3"
+ resolved "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz"
+ integrity sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==
+ dependencies:
+ "@types/deep-eql" "*"
+ assertion-error "^2.0.1"
+
+"@types/deep-eql@*":
+ version "4.0.2"
+ resolved "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz"
+ integrity sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==
+
"@types/estree@^1.0.0", "@types/[email protected]":
version "1.0.8"
resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz"
@@ -2233,6 +2251,66 @@
dependencies:
uncrypto "^0.1.3"
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.4.tgz"
+ integrity sha512-iPBpra+VDuXmBFI3FMKHSFXp3Gx5HfmSCE8X67Dn+bwephCnQCaB7qWK2ldHa+8ncN8hJU8VTMcxjPpyMkUjww==
+ dependencies:
+ "@standard-schema/spec" "^1.1.0"
+ "@types/chai" "^5.2.2"
+ "@vitest/spy" "4.1.4"
+ "@vitest/utils" "4.1.4"
+ chai "^6.2.2"
+ tinyrainbow "^3.1.0"
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.4.tgz"
+ integrity sha512-R9HTZBhW6yCSGbGQnDnH3QHfJxokKN4KB+Yvk9Q1le7eQNYwiCyKxmLmurSpFy6BzJanSLuEUDrD+j97Q+ZLPg==
+ dependencies:
+ "@vitest/spy" "4.1.4"
+ estree-walker "^3.0.3"
+ magic-string "^0.30.21"
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.4.tgz"
+ integrity sha512-ddmDHU0gjEUyEVLxtZa7xamrpIefdEETu3nZjWtHeZX4QxqJ7tRxSteHVXJOcr8jhiLoGAhkK4WJ3WqBpjx42A==
+ dependencies:
+ tinyrainbow "^3.1.0"
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.4.tgz"
+ integrity sha512-xTp7VZ5aXP5ZJrn15UtJUWlx6qXLnGtF6jNxHepdPHpMfz/aVPx+htHtgcAL2mDXJgKhpoo2e9/hVJsIeFbytQ==
+ dependencies:
+ "@vitest/utils" "4.1.4"
+ pathe "^2.0.3"
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.4.tgz"
+ integrity sha512-MCjCFgaS8aZz+m5nTcEcgk/xhWv0rEH4Yl53PPlMXOZ1/Ka2VcZU6CJ+MgYCZbcJvzGhQRjVrGQNZqkGPttIKw==
+ dependencies:
+ "@vitest/pretty-format" "4.1.4"
+ "@vitest/utils" "4.1.4"
+ magic-string "^0.30.21"
+ pathe "^2.0.3"
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.4.tgz"
+ integrity sha512-XxNdAsKW7C+FLydqFJLb5KhJtl3PGCMmYwFRfhvIgxJvLSXhhVI1zM8f1qD3Zg7RCjTSzDVyct6sghs9UEgBEQ==
+
+"@vitest/[email protected]":
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.4.tgz"
+ integrity sha512-13QMT+eysM5uVGa1rG4kegGYNp6cnQcsTc67ELFbhNLQO+vgsygtYJx2khvdt4gVQqSSpC/KT5FZZxUpP3Oatw==
+ dependencies:
+ "@vitest/pretty-format" "4.1.4"
+ convert-source-map "^2.0.0"
+ tinyrainbow "^3.1.0"
+
abitype@^1.2.3, [email protected]:
version "1.2.3"
resolved "https://registry.npmjs.org/abitype/-/abitype-1.2.3.tgz"
@@ -2279,6 +2357,11 @@ arraybuffer.prototype.slice@^1.0.4:
get-intrinsic "^1.2.6"
is-array-buffer "^3.0.4"
+assertion-error@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz"
+ integrity sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==
+
async-function@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz"
@@ -2416,6 +2499,11 @@ canonicalize@^2.0.0:
resolved "https://registry.npmjs.org/canonicalize/-/canonicalize-2.1.0.tgz"
integrity sha512-F705O3xrsUtgt98j7leetNhTWPe+5S72rlL5O4jA1pKqBVQ/dT1O1D6PFxmSXvc0SUOinWS57DKx0I3CHrXJHQ==
+chai@^6.2.2:
+ version "6.2.2"
+ resolved "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz"
+ integrity sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==
+
commander@^2.20.0:
version "2.20.3"
resolved "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
@@ -2615,6 +2703,11 @@ es-errors@^1.3.0:
resolved "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz"
integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==
+es-module-lexer@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.0.0.tgz"
+ integrity sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==
+
es-object-atoms@^1.0.0, es-object-atoms@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz"
@@ -2688,6 +2781,13 @@ estree-walker@^2.0.2:
resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz"
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
+estree-walker@^3.0.3:
+ version "3.0.3"
+ resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz"
+ integrity sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==
+ dependencies:
+ "@types/estree" "^1.0.0"
+
esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz"
@@ -2716,6 +2816,11 @@ [email protected]:
resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz"
integrity sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==
+expect-type@^1.3.0:
+ version "1.3.0"
+ resolved "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz"
+ integrity sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==
+
fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz"
@@ -3274,6 +3379,13 @@ magic-string@^0.25.0, magic-string@^0.25.7:
dependencies:
sourcemap-codec "^1.4.8"
+magic-string@^0.30.21:
+ version "0.30.21"
+ resolved "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz"
+ integrity sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==
+ dependencies:
+ "@jridgewell/sourcemap-codec" "^1.5.5"
+
math-intrinsics@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz"
@@ -3340,6 +3452,11 @@ obuf@~1.1.2:
resolved "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz"
integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==
+obug@^2.1.1:
+ version "2.1.1"
+ resolved "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz"
+ integrity sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==
+
own-keys@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz"
@@ -3396,6 +3513,11 @@ path-scurry@^2.0.0:
lru-cache "^11.0.0"
minipass "^7.1.2"
+pathe@^2.0.3:
+ version "2.0.3"
+ resolved "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz"
+ integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==
+
version "1.0.1"
resolved "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz"
@@ -3797,6 +3919,11 @@ side-channel@^1.1.0:
side-channel-map "^1.0.1"
side-channel-weakmap "^1.0.2"
+siginfo@^2.0.0:
+ version "2.0.0"
+ resolved "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz"
+ integrity sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==
+
signal-exit@^4.0.1:
version "4.1.0"
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz"
@@ -3849,6 +3976,16 @@ split-on-first@^3.0.0:
resolved "https://registry.npmjs.org/split-on-first/-/split-on-first-3.0.0.tgz"
integrity sha512-qxQJTx2ryR0Dw0ITYyekNQWpz6f8dGd7vffGNflQQ3Iqj9NJ6qiZ7ELpZsJ/QBhIVAiDfXdag3+Gp8RvWa62AA==
+ version "0.0.2"
+ resolved "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz"
+ integrity sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==
+
+std-env@^4.0.0-rc.1:
+ version "4.1.0"
+ resolved "https://registry.npmjs.org/std-env/-/std-env-4.1.0.tgz"
+ integrity sha512-Rq7ybcX2RuC55r9oaPVEW7/xu3tj8u4GeBYHBWCychFtzMIr86A7e3PPEBPT37sHStKX3+TiX/Fr/ACmJLVlLQ==
+
stop-iteration-iterator@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz"
@@ -3962,6 +4099,16 @@ three@^0.176.0:
resolved "https://registry.npmjs.org/three/-/three-0.176.0.tgz"
integrity sha512-PWRKYWQo23ojf9oZSlRGH8K09q7nRSWx6LY/HF/UUrMdYgN9i1e2OwJYHoQjwc6HF/4lvvYLC5YC1X8UJL2ZpA==
+tinybench@^2.9.0:
+ version "2.9.0"
+ resolved "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz"
+ integrity sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==
+
+tinyexec@^1.0.2:
+ version "1.1.1"
+ resolved "https://registry.npmjs.org/tinyexec/-/tinyexec-1.1.1.tgz"
+ integrity sha512-VKS/ZaQhhkKFMANmAOhhXVoIfBXblQxGX1myCQ2faQrfmobMftXeJPcZGp0gS07ocvGJWDLZGyOZDadDBqYIJg==
+
tinyglobby@^0.2.10, tinyglobby@^0.2.15:
version "0.2.16"
resolved "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.16.tgz"
@@ -3970,6 +4117,11 @@ tinyglobby@^0.2.10, tinyglobby@^0.2.15:
fdir "^6.5.0"
picomatch "^4.0.4"
+tinyrainbow@^3.1.0:
+ version "3.1.0"
+ resolved "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz"
+ integrity sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==
+
tr46@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz"
@@ -4150,7 +4302,7 @@ vite-plugin-pwa@^1.2.0:
workbox-build "^7.4.0"
workbox-window "^7.4.0"
-vite@^7.3.2:
+"vite@^6.0.0 || ^7.0.0 || ^8.0.0", vite@^7.3.2:
version "7.3.2"
resolved "https://registry.npmjs.org/vite/-/vite-7.3.2.tgz"
integrity sha512-Bby3NOsna2jsjfLVOHKes8sGwgl4TT0E6vvpYgnAYDIF/tie7MRaFthmKuHx1NSXjiTueXH3do80FMQgvEktRg==
@@ -4164,6 +4316,32 @@ vite@^7.3.2:
optionalDependencies:
fsevents "~2.3.3"
+vitest@^4.1.4:
+ version "4.1.4"
+ resolved "https://registry.npmjs.org/vitest/-/vitest-4.1.4.tgz"
+ integrity sha512-tFuJqTxKb8AvfyqMfnavXdzfy3h3sWZRWwfluGbkeR7n0HUev+FmNgZ8SDrRBTVrVCjgH5cA21qGbCffMNtWvg==
+ dependencies:
+ "@vitest/expect" "4.1.4"
+ "@vitest/mocker" "4.1.4"
+ "@vitest/pretty-format" "4.1.4"
+ "@vitest/runner" "4.1.4"
+ "@vitest/snapshot" "4.1.4"
+ "@vitest/spy" "4.1.4"
+ "@vitest/utils" "4.1.4"
+ es-module-lexer "^2.0.0"
+ expect-type "^1.3.0"
+ magic-string "^0.30.21"
+ obug "^2.1.1"
+ pathe "^2.0.3"
+ picomatch "^4.0.3"
+ std-env "^4.0.0-rc.1"
+ tinybench "^2.9.0"
+ tinyexec "^1.0.2"
+ tinyglobby "^0.2.15"
+ tinyrainbow "^3.1.0"
+ vite "^6.0.0 || ^7.0.0 || ^8.0.0"
+ why-is-node-running "^2.3.0"
+
webidl-conversions@^4.0.2:
version "4.0.2"
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz"
@@ -4238,6 +4416,14 @@ which@^2.0.1:
dependencies:
isexe "^2.0.0"
+why-is-node-running@^2.3.0:
+ version "2.3.0"
+ resolved "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz"
+ integrity sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==
+ dependencies:
+ siginfo "^2.0.0"
+ stackback "0.0.2"
+
version "7.4.0"
resolved "https://registry.npmjs.org/workbox-background-sync/-/workbox-background-sync-7.4.0.tgz"