diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9383a93 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,19 @@ +name: CI + +on: + pull_request: + push: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm test + - run: npm run build diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..76cf1ec --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,36 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run build + - uses: actions/configure-pages@v5 + - uses: actions/upload-pages-artifact@v3 + with: + path: dist + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/README.ja.md b/README.ja.md new file mode 100644 index 0000000..1bab6bd --- /dev/null +++ b/README.ja.md @@ -0,0 +1,68 @@ +[English](README.md) | 日本語 + +# commit-city + +**GitHubのリポジトリを3Dの街にして、その歴史を再生する。** + +リポジトリを入れると、コードがブラウザの中で街になります。フォルダは区画、ファイルはビルで、大きいファイルほど高いビルになります。街を見て回り、ビルをクリックすると、そのファイルをGitHubで開けます。 + +![three.js の街](docs/screenshot.png) + +> 状態:v0.1。今のリポジトリの姿を街にします。コミット履歴の再生は次の版で入れます(ロードマップ参照)。 + +## 街の読み方 + +| 街 | リポジトリ | +|---|---| +| 区画(一段高い台) | フォルダ。深いフォルダほど高い位置にある | +| ビル | ファイル | +| 高さ | ファイルサイズ(対数。巨大なファイル1つで他が見えなくならないように) | +| 敷地の広さ | これもファイルサイズだが、差はずっと小さい。街の印象は高さで決まる | +| 色 | ファイルの種類(JS/TS、Python、ドキュメント、設定など) | + +区画の配置には squarified treemap を使い、すべてのビルを1つのインスタンスメッシュで描くので、数万ファイルのリポジトリでも滑らかに動きます。 + +## 使い方 + +URLにリポジトリを付けてページを開きます。 + +``` +https://keito118.github.io/commit-city/?repo=vitejs/vite +https://keito118.github.io/commit-city/?repo=mrdoob/three.js&theme=cyberpunk +``` + +または、入力欄に `owner/repo`(GitHubのURLでも可)を入れます。URLも一緒に変わるので、見ている街をそのまま共有できます。 + +- ドラッグで回転、右ドラッグで移動、スクロールでズーム +- ビルをクリックすると、パスとサイズ、ファイルへのリンクが出る +- **Theme** で見た目を選べる + +使えるのは公開リポジトリだけです。GitHubの認証なしAPIを使うので、1つのIPから1時間に60回までです(街1つで2回使います)。 + +## テーマ + +見た目は配置とは切り離した「着せ替え」です。v0.1 には **Daylight** と **Cyberpunk** があります。テーマは [`src/themes.ts`](src/themes.ts) の1項目で、空、地面、区画の色、ファイルの種類ごとの色、ビルの光り具合を決めます。日本の町並みや西洋の旧市街も追加予定です。 + +## 手元で動かす + +```bash +npm install +npm run dev # http://localhost:5173/?repo=vitejs/vite +npm test +npm run build # dist/ に静的サイトを出力 +``` + +TypeScript、[Three.js](https://threejs.org/)、[d3-hierarchy](https://github.com/d3/d3-hierarchy)(treemap)、Vite で作っています。サーバーはなく、すべてブラウザで動きます。 + +## ロードマップ + +| 版 | 内容 | +|---|---| +| v0.1 | 今のリポジトリの姿を街にする ← 今ここ | +| v0.2 | 歴史の再生:スライダーで、コミットごとに街が育つ様子を見る | +| v0.3 | テーマを増やす(日本の町並み、西洋の旧市街)、動画やGIFの書き出し | +| v1.0 | 直すべき場所(よく変わる大きいファイル)の表示、有名OSSの街のギャラリー、解説記事 | + +## ライセンス + +[MIT](LICENSE) diff --git a/README.md b/README.md new file mode 100644 index 0000000..eabb0e6 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +English | [日本語](README.ja.md) + +# commit-city + +**Turn any GitHub repository into a 3D city and replay its history.** + +Paste a repository and its code becomes a city in your browser: folders are districts, files are buildings, and bigger files are taller. Fly around, click a building, and jump to that file on GitHub. + +![three.js as a city](docs/screenshot.png) + +> Status: v0.1. The city shows the repository as it is today. Replaying the commit history is next (see the roadmap). + +## How to read the city + +| In the city | In the repository | +|---|---| +| District (raised plate) | Folder. Deeper folders sit higher. | +| Building | File | +| Height | File size (log scale, so one huge bundle doesn't hide everything else) | +| Footprint | Also file size, but much flatter, so the skyline does the talking | +| Color | Kind of file (JS/TS, Python, docs, config, ...) | + +Districts are laid out with a squarified treemap, and all buildings are drawn as one instanced mesh, so repositories with tens of thousands of files stay smooth. + +## Use it + +Open the page with a repository in the URL: + +``` +https://keito118.github.io/commit-city/?repo=vitejs/vite +https://keito118.github.io/commit-city/?repo=mrdoob/three.js&theme=cyberpunk +``` + +Or type `owner/repo` (or a GitHub URL) into the box. The URL updates as you go, so you can share the exact city you're looking at. + +- Drag to orbit, right-drag to pan, scroll to zoom. +- Click a building to see its path and size, with a link to the file. +- Pick a look from **Theme**. + +Only public repositories work, through GitHub's unauthenticated API (60 requests an hour per IP; each city costs 2). + +## Themes + +The look is a swappable skin, separate from the layout. v0.1 ships **Daylight** and **Cyberpunk**. A theme is one entry in [`src/themes.ts`](src/themes.ts): sky, ground, district colors, a color per file kind, and how much the buildings glow. Japanese streets and a European old town are planned. + +## Run locally + +```bash +npm install +npm run dev # http://localhost:5173/?repo=vitejs/vite +npm test +npm run build # static site in dist/ +``` + +Built with TypeScript, [Three.js](https://threejs.org/), [d3-hierarchy](https://github.com/d3/d3-hierarchy) (treemap) and Vite. No server: everything runs in the browser. + +## Roadmap + +| Version | What | +|---|---| +| v0.1 | The city as the repository is today ← now | +| v0.2 | Replay the history: a timeline slider that grows the city commit by commit | +| v0.3 | More themes (Japanese streets, European old town), video/GIF export | +| v1.0 | Highlight hotspots (big files that change often), a gallery of famous open-source cities, and a write-up | + +## License + +[MIT](LICENSE) diff --git a/docs/screenshot-cyberpunk.png b/docs/screenshot-cyberpunk.png new file mode 100644 index 0000000..4c4ada8 Binary files /dev/null and b/docs/screenshot-cyberpunk.png differ diff --git a/docs/screenshot.png b/docs/screenshot.png new file mode 100644 index 0000000..39a9558 Binary files /dev/null and b/docs/screenshot.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..3a167bb --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ + + + + + + commit-city + + + + +
+ +
+

commit-city

+
+ + +
+
+ + Try: vite · three.js · express +
+

+
+ + + + + + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..f51acaa --- /dev/null +++ b/package-lock.json @@ -0,0 +1,1546 @@ +{ + "name": "commit-city", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "commit-city", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "d3-hierarchy": "^3.1.2", + "three": "^0.186.1" + }, + "devDependencies": { + "@types/d3-hierarchy": "^3.1.7", + "@types/three": "^0.186.0", + "typescript": "^7.0.2", + "vite": "^8.3.4", + "vitest": "^5.0.5" + } + }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.154.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.154.0.tgz", + "integrity": "sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.14.tgz", + "integrity": "sha512-aWR+XKH9+rW7m5fWq/5360J3mHycrx/o6xZM2DQFdJnTMdyP7/WzxPjhtLbVWdKo2y612/4U1bWqb3HQhiF7vg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.14.tgz", + "integrity": "sha512-QiVxHofl6A8lQU7WAtOUY4QMVZXohxwz7WJJoeh8NBEUyKfIkMRKhYyq8az/1RypNiIXzNTtiS6KwHz0erxYRQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.14.tgz", + "integrity": "sha512-lTQOzHuBIooh3jIr5XINQkjPGEuGy+Dsy0meXDr6Sjty0b99kYgGh4uBC/8mJX1T0kC8d6S0aPP1Y+bHkh6aBw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.14.tgz", + "integrity": "sha512-hyMKEGatjmBYCs/Q4sbIcL/GqpFEqsX3wc+HYVQ/85A4rxc1o7rPm4DUI4GV4k/h0ITddwFSGpqQunI14GXjTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.14.tgz", + "integrity": "sha512-u371GbXoVXrEgP20PwzoGNOdAOqAMhzo19JzzY+V4YmmnC+DTOoqdbMu+O+54emM59Mik/UdrtWgcuEDKWRPKA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.14.tgz", + "integrity": "sha512-BqwKsdZQf6EqVWr8fv2MrDYzAvOZ7+NYFSJESRGs87fkseEhs0TU9TXgRJTkZoRRkxTizyEg1LKUXfU3/78uqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.14.tgz", + "integrity": "sha512-SD9kY8M009x/7s57Z1dgUVlP5+uYBgKQK0Tkr1WIWngrtUJmRCW1RJFMY7QDla2khXhmg2i5Io7MUjcmZNZ/KQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.14.tgz", + "integrity": "sha512-BJ2CL19M6uuWesMgnqJzgxoI+N+eV7b0A9O9vLV42y+gitC41fNa8KElau1tHVzuLWX5GzEuxMPhAO0tQXQMkg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.14.tgz", + "integrity": "sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.14.tgz", + "integrity": "sha512-V/h8ePq1fKDrmtFMz6xcCN3DKvuvMRrwwD1q0PkBeeo4DpK64biaKvqWGVxqCeYKqeRk7gE7/iKPxLCn08O97A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.14.tgz", + "integrity": "sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.14.tgz", + "integrity": "sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.14.tgz", + "integrity": "sha512-qyr5XiNGxm2ytx17vvtcJ9nXn6v1gENETi503bJx3OGwZ1tSonj7BosxbMa/xeAfSl5iS9X6KjEWYXLu6v1L7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.14.tgz", + "integrity": "sha512-oA4o5o0S2yB199YyYXDzKUv1Z56Rc+mgOjwm7Z/vJ9Z8igiDPYvoOuDyo6g7AK/ZaF09nPhDKVnGBcYHO11GXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.14.tgz", + "integrity": "sha512-9mE94bf2GZUaR/fUSXCMpBoWkctu421Mi0ORpm4zqfbkjKep7RxzPFa5etcGs5h+2KApoWBOA/hAJa/7saGgEQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", + "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "dev": true, + "license": "MIT" + }, + "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/d3-hierarchy": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@types/d3-hierarchy/-/d3-hierarchy-3.1.7.tgz", + "integrity": "sha512-tJFtNoYBtRtkNysX1Xq4sxtjK8YgoWUNpIiUee0/jHGRwqvzYxkq0hGVbbOGSz+JgFxxRu4K8nb3YpG3CMARtg==", + "dev": true, + "license": "MIT" + }, + "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.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.186.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.186.0.tgz", + "integrity": "sha512-mxYSBpDC+D0pLfSP6sW4WZTcT+nrtmZcimMqnVmy36Hte3XpeYSrvgg4TRdaM1GemGog1AWzI5qL2VoIfMXbJQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": ">=0.5.17", + "fflate": "~0.8.3", + "meshoptimizer": "~1.1.1" + } + }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.0.5.tgz", + "integrity": "sha512-xLL3lkDegJZw+MGoGaCCsFayDZthGgpAtr3Vziyfc4p7xH89K7KRPcRBBh/kEYm0Aqkt5DtTmkYpBtRV/FrHZg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.0.5", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.0.5.tgz", + "integrity": "sha512-lwJRExuH417257Q5wv9QYugN9IMJkoxcrKrYxGPQkBzl7wlNpTUxD/5yNX4ESKVUIShKPgkGchYPFMWOOk0wzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "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/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/d3-hierarchy": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/d3-hierarchy/-/d3-hierarchy-3.1.2.tgz", + "integrity": "sha512-FX/9frcub54beBdugHjDCdikxThEqjnR93Qt7PvQTOHxyiNCAlvMrHhclk3cD5VeAaq9fxmfRp+CnWw9rEMBuA==", + "license": "ISC", + "engines": { + "node": ">=12" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "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/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "dev": true, + "license": "MIT" + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "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" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/magic-string": { + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", + "integrity": "sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/meshoptimizer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz", + "integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.31", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz", + "integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rolldown": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.14.tgz", + "integrity": "sha512-eTBTTqMR6uHKLgcUqpJP8ntzDI6V4LYA8negAMBEI7gkgVvOdrx6VsvS2Ym+83KhOPdLCHWJu0w7UQFJZhHKNw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.154.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.14", + "@rolldown/binding-android-arm64": "1.2.14", + "@rolldown/binding-darwin-arm64": "1.2.14", + "@rolldown/binding-darwin-x64": "1.2.14", + "@rolldown/binding-freebsd-x64": "1.2.14", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.14", + "@rolldown/binding-linux-arm64-gnu": "1.2.14", + "@rolldown/binding-linux-arm64-musl": "1.2.14", + "@rolldown/binding-linux-ppc64-gnu": "1.2.14", + "@rolldown/binding-linux-s390x-gnu": "1.2.14", + "@rolldown/binding-linux-x64-gnu": "1.2.14", + "@rolldown/binding-linux-x64-musl": "1.2.14", + "@rolldown/binding-openharmony-arm64": "1.2.14", + "@rolldown/binding-win32-arm64-msvc": "1.2.14", + "@rolldown/binding-win32-x64-msvc": "1.2.14" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/three": { + "version": "0.186.1", + "resolved": "https://registry.npmjs.org/three/-/three-0.186.1.tgz", + "integrity": "sha512-blFeqb49wRCSGUGj7gtpfnSGHy2lwDk94RhUmS1c/hTby70kvChbWpkJ4Pm1390LqzzvTmzgXKHPEafJwCb8jA==", + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.2.tgz", + "integrity": "sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "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" + } + }, + "node_modules/vite": { + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.4.tgz", + "integrity": "sha512-IftLE8phJhdNRIGNEV4JCCvfNScoZQVfcXaN8TQropWGJtOHcu+iAB9pHcuGvmEb/kddw0LBe/jS8ztdC6xdiQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.29", + "rolldown": "~1.2.12", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "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 + } + } + }, + "node_modules/vitest": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.0.5.tgz", + "integrity": "sha512-cPODOMF8YnkiiYtDdHo6n4wWmBrOBBbOIYH2d33M4l3CdNn72h+qMmO6uXffUN6A5AZFXNND/d+krS9mgkXRfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.0.5", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.3", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.2", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.0.5", + "@vitest/browser-preview": "5.0.5", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.0.5", + "@vitest/coverage-v8": "5.0.5", + "@vitest/ui": "5.0.5", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.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/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..429a96e --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "commit-city", + "version": "0.1.0", + "description": "Turn any GitHub repository into a 3D city and replay its history.", + "private": true, + "type": "module", + "license": "MIT", + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && vite build", + "preview": "vite preview", + "test": "vitest run" + }, + "dependencies": { + "d3-hierarchy": "^3.1.2", + "three": "^0.186.1" + }, + "devDependencies": { + "@types/d3-hierarchy": "^3.1.7", + "@types/three": "^0.186.0", + "typescript": "^7.0.2", + "vite": "^8.3.4", + "vitest": "^5.0.5" + } +} diff --git a/src/city.ts b/src/city.ts new file mode 100644 index 0000000..fc628ef --- /dev/null +++ b/src/city.ts @@ -0,0 +1,184 @@ +import * as THREE from "three"; +import { OrbitControls } from "three/addons/controls/OrbitControls.js"; +import type { Building, CityLayout } from "./layout"; +import type { Theme } from "./themes"; + +/** Draws a CityLayout. All buildings share one InstancedMesh so big repos stay fast. */ +export class CityView { + private renderer: THREE.WebGLRenderer; + private scene = new THREE.Scene(); + private camera: THREE.PerspectiveCamera; + private controls: OrbitControls; + private ambient = new THREE.HemisphereLight(0xffffff, 0x444444, 1); + private sun = new THREE.DirectionalLight(0xffffff, 1); + private ground: THREE.Mesh; + private cityGroup = new THREE.Group(); + private buildingMesh: THREE.InstancedMesh | null = null; + private districtMesh: THREE.InstancedMesh | null = null; + private highlight: THREE.LineSegments; + private emissive = { value: 0 }; + private layout: CityLayout | null = null; + private theme: Theme; + + constructor(private container: HTMLElement, theme: Theme) { + this.theme = theme; + this.renderer = new THREE.WebGLRenderer({ antialias: true, preserveDrawingBuffer: true }); + this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)); + container.appendChild(this.renderer.domElement); + + this.camera = new THREE.PerspectiveCamera(45, 1, 1, 5000); + this.camera.position.set(320, 260, 320); + this.controls = new OrbitControls(this.camera, this.renderer.domElement); + this.controls.enableDamping = true; + this.controls.maxPolarAngle = Math.PI * 0.48; + + this.sun.position.set(-200, 400, 150); + this.scene.add(this.ambient, this.sun, this.cityGroup); + + this.ground = new THREE.Mesh( + new THREE.PlaneGeometry(4000, 4000), + new THREE.MeshLambertMaterial({ color: 0xffffff }), + ); + this.ground.rotation.x = -Math.PI / 2; + this.ground.position.y = -0.05; + this.scene.add(this.ground); + + this.highlight = new THREE.LineSegments( + new THREE.EdgesGeometry(new THREE.BoxGeometry(1, 1, 1).translate(0, 0.5, 0)), + new THREE.LineBasicMaterial({ color: 0xffffff }), + ); + this.highlight.visible = false; + this.scene.add(this.highlight); + + this.applyTheme(theme); + new ResizeObserver(() => this.resize()).observe(container); + this.resize(); + this.renderer.setAnimationLoop(() => { + this.controls.update(); + this.renderer.render(this.scene, this.camera); + }); + } + + setTheme(theme: Theme) { + this.theme = theme; + this.applyTheme(theme); + if (this.layout) this.show(this.layout, false); + } + + show(layout: CityLayout, resetCamera = true) { + this.layout = layout; + this.clear(); + this.highlight.visible = false; + + const box = new THREE.BoxGeometry(1, 1, 1).translate(0, 0.5, 0); + const matrix = new THREE.Matrix4(); + const color = new THREE.Color(); + + const districts = new THREE.InstancedMesh( + box, + new THREE.MeshLambertMaterial({ color: 0xffffff }), + Math.max(layout.districts.length, 1), + ); + districts.count = layout.districts.length; + layout.districts.forEach((d, i) => { + // Deeper folders sit on slightly raised plates so nesting is visible. + const plate = 0.25; + matrix.makeScale(d.width, plate, d.length).setPosition(d.x, (d.depth - 1) * plate, d.z); + districts.setMatrixAt(i, matrix); + const palette = this.theme.districts; + districts.setColorAt(i, color.set(palette[Math.min(d.depth - 1, palette.length - 1)])); + }); + + const buildings = new THREE.InstancedMesh(box, this.buildingMaterial(), Math.max(layout.buildings.length, 1)); + buildings.count = layout.buildings.length; + layout.buildings.forEach((b, i) => { + matrix.makeScale(b.width, b.height, b.depth).setPosition(b.x, this.baseOf(b), b.z); + buildings.setMatrixAt(i, matrix); + buildings.setColorAt(i, color.set(this.theme.buildings[b.language])); + }); + + this.districtMesh = districts; + this.buildingMesh = buildings; + this.cityGroup.add(districts, buildings); + + if (resetCamera) { + const tallest = layout.buildings.reduce((max, b) => Math.max(max, b.height), 0); + const r = layout.extent * 0.95; + this.camera.position.set(r, r * 0.9 + tallest * 0.5, r); + this.controls.target.set(0, 0, 0); + } + } + + /** Returns the building under a screen point, or null. */ + pick(clientX: number, clientY: number): Building | null { + if (!this.buildingMesh || !this.layout) return null; + const rect = this.renderer.domElement.getBoundingClientRect(); + const pointer = new THREE.Vector2( + ((clientX - rect.left) / rect.width) * 2 - 1, + -((clientY - rect.top) / rect.height) * 2 + 1, + ); + const raycaster = new THREE.Raycaster(); + raycaster.setFromCamera(pointer, this.camera); + const hit = raycaster.intersectObject(this.buildingMesh)[0]; + return hit?.instanceId !== undefined ? this.layout.buildings[hit.instanceId] : null; + } + + select(building: Building | null) { + this.highlight.visible = building !== null; + if (!building) return; + this.highlight.scale.set(building.width * 1.04, building.height * 1.02, building.depth * 1.04); + this.highlight.position.set(building.x, this.baseOf(building), building.z); + } + + snapshot(): string { + return this.renderer.domElement.toDataURL("image/png"); + } + + private baseOf(b: Building): number { + const depth = b.path.split("/").length - 1; + return depth * 0.25; + } + + private buildingMaterial(): THREE.Material { + const material = new THREE.MeshStandardMaterial({ color: 0xffffff, roughness: 0.75, metalness: 0.05 }); + // Lets night themes make buildings glow in their own color. + material.onBeforeCompile = (shader) => { + shader.uniforms.selfGlow = this.emissive; + shader.fragmentShader = shader.fragmentShader + .replace("void main() {", "uniform float selfGlow;\nvoid main() {") + .replace( + "#include ", + "#include \ntotalEmissiveRadiance += diffuseColor.rgb * selfGlow;", + ); + }; + return material; + } + + private applyTheme(theme: Theme) { + this.scene.background = new THREE.Color(theme.sky); + this.scene.fog = new THREE.Fog(theme.fog, 600, 1800); + (this.ground.material as THREE.MeshLambertMaterial).color.set(theme.ground); + this.ambient.intensity = theme.ambient * 2; + this.sun.intensity = theme.sun; + this.emissive.value = theme.emissive; + } + + private clear() { + for (const mesh of [this.buildingMesh, this.districtMesh]) { + if (!mesh) continue; + this.cityGroup.remove(mesh); + mesh.geometry.dispose(); + (mesh.material as THREE.Material).dispose(); + mesh.dispose(); + } + this.buildingMesh = this.districtMesh = null; + } + + private resize() { + const { clientWidth: w, clientHeight: h } = this.container; + if (!w || !h) return; + this.renderer.setSize(w, h, false); + this.camera.aspect = w / h; + this.camera.updateProjectionMatrix(); + } +} diff --git a/src/github.ts b/src/github.ts new file mode 100644 index 0000000..6d51884 --- /dev/null +++ b/src/github.ts @@ -0,0 +1,48 @@ +export interface RepoFile { + path: string; + size: number; +} + +export interface RepoSnapshot { + owner: string; + name: string; + branch: string; + files: RepoFile[]; + truncated: boolean; +} + +const API = "https://api.github.com"; + +/** Accepts "owner/name" or a github.com URL. Returns null when it can't tell. */ +export function parseRepo(input: string): { owner: string; name: string } | null { + const trimmed = input.trim().replace(/\.git$/, "").replace(/\/+$/, ""); + const match = + trimmed.match(/^(?:https?:\/\/)?(?:www\.)?github\.com\/([\w.-]+)\/([\w.-]+)/) ?? + trimmed.match(/^([\w.-]+)\/([\w.-]+)$/); + if (!match) return null; + return { owner: match[1], name: match[2] }; +} + +async function getJson(url: string): Promise { + const res = await fetch(url, { headers: { Accept: "application/vnd.github+json" } }); + if (res.status === 404) throw new Error("Repository not found (or it is private)."); + if (res.status === 403 || res.status === 429) { + throw new Error("GitHub API rate limit reached. Try again in a while."); + } + if (!res.ok) throw new Error(`GitHub API error: ${res.status}`); + return res.json() as Promise; +} + +export async function fetchSnapshot(owner: string, name: string): Promise { + const repo = await getJson<{ default_branch: string }>(`${API}/repos/${owner}/${name}`); + const branch = repo.default_branch; + const tree = await getJson<{ + tree: { path: string; type: string; size?: number }[]; + truncated: boolean; + }>(`${API}/repos/${owner}/${name}/git/trees/${encodeURIComponent(branch)}?recursive=1`); + + const files = tree.tree + .filter((entry) => entry.type === "blob") + .map((entry) => ({ path: entry.path, size: entry.size ?? 0 })); + return { owner, name, branch, files, truncated: tree.truncated }; +} diff --git a/src/languages.ts b/src/languages.ts new file mode 100644 index 0000000..18c9af0 --- /dev/null +++ b/src/languages.ts @@ -0,0 +1,32 @@ +/** Rough language groups by file extension. Themes pick a color for each group. */ +export type LanguageGroup = + | "script" // JS / TS + | "python" + | "systems" // C, C++, Rust, Go, Zig + | "jvm" // Java, Kotlin, Scala + | "web" // HTML, CSS, Vue, Svelte + | "shell" + | "data" // JSON, YAML, TOML, CSV, SQL + | "docs" // Markdown, text, reStructuredText + | "media" // images, fonts, audio + | "other"; + +const GROUPS: Record = {}; +const add = (group: LanguageGroup, exts: string[]) => exts.forEach((ext) => (GROUPS[ext] = group)); + +add("script", ["js", "jsx", "mjs", "cjs", "ts", "tsx", "mts", "cts"]); +add("python", ["py", "pyi", "ipynb"]); +add("systems", ["c", "h", "cc", "cpp", "cxx", "hpp", "hh", "rs", "go", "zig", "swift", "m", "mm", "cs"]); +add("jvm", ["java", "kt", "kts", "scala", "groovy", "gradle", "clj"]); +add("web", ["html", "htm", "css", "scss", "sass", "less", "vue", "svelte", "astro", "php", "rb", "erb"]); +add("shell", ["sh", "bash", "zsh", "fish", "ps1", "bat", "cmd"]); +add("data", ["json", "yaml", "yml", "toml", "ini", "xml", "csv", "sql", "lock", "proto", "graphql"]); +add("docs", ["md", "mdx", "txt", "rst", "adoc", "tex"]); +add("media", ["png", "jpg", "jpeg", "gif", "svg", "webp", "ico", "ttf", "otf", "woff", "woff2", "mp3", "wav", "mp4"]); + +export function languageOf(path: string): LanguageGroup { + const base = path.slice(path.lastIndexOf("/") + 1).toLowerCase(); + const dot = base.lastIndexOf("."); + if (dot <= 0) return "other"; + return GROUPS[base.slice(dot + 1)] ?? "other"; +} diff --git a/src/layout.ts b/src/layout.ts new file mode 100644 index 0000000..17095e2 --- /dev/null +++ b/src/layout.ts @@ -0,0 +1,111 @@ +import { hierarchy, treemap, treemapSquarify } from "d3-hierarchy"; +import type { RepoFile } from "./github"; +import { languageOf, type LanguageGroup } from "./languages"; + +export interface Building { + path: string; + size: number; + language: LanguageGroup; + /** Center on the ground plane, and footprint. */ + x: number; + z: number; + width: number; + depth: number; + height: number; +} + +export interface District { + path: string; + depth: number; + x: number; + z: number; + width: number; + length: number; +} + +export interface CityLayout { + buildings: Building[]; + districts: District[]; + /** Side length of the square city. */ + extent: number; +} + +interface Node { + name: string; + path: string; + size: number; + children?: Node[]; +} + +/** Turns flat file paths into a folder tree. */ +export function buildTree(files: RepoFile[]): Node { + const root: Node = { name: "", path: "", size: 0, children: [] }; + for (const file of files) { + const parts = file.path.split("/"); + let node = root; + for (let i = 0; i < parts.length - 1; i++) { + const path = parts.slice(0, i + 1).join("/"); + let child = node.children!.find((c) => c.children && c.name === parts[i]); + if (!child) { + child = { name: parts[i], path, size: 0, children: [] }; + node.children!.push(child); + } + node = child; + } + node.children!.push({ name: parts[parts.length - 1], path: file.path, size: file.size }); + } + return root; +} + +/** Building height in world units. Logarithmic, so one huge bundle doesn't dwarf the whole city. */ +export function heightFor(size: number): number { + return 1 + 8 * Math.log2(1 + size / 1000); +} + +/** Ground area a file gets. Grows much slower than size, so the city reads by height, not by footprint. */ +export function areaFor(size: number): number { + return 20 + Math.sqrt(size); +} + +const EXTENT = 400; + +export function layoutCity(files: RepoFile[]): CityLayout { + const root = hierarchy(buildTree(files)) + .sum((d) => (d.children ? 0 : areaFor(d.size))) + .sort((a, b) => (b.value ?? 0) - (a.value ?? 0)); + + const laidOut = treemap() + .tile(treemapSquarify) + .size([EXTENT, EXTENT]) + .paddingInner(1.2) + .paddingOuter((n) => (n.depth === 0 ? 0 : 1.5)) + .round(false)(root); + + const buildings: Building[] = []; + const districts: District[] = []; + const half = EXTENT / 2; + + for (const node of laidOut.descendants()) { + const width = node.x1 - node.x0; + const length = node.y1 - node.y0; + const x = node.x0 + width / 2 - half; + const z = node.y0 + length / 2 - half; + if (node.data.children) { + if (node.depth > 0) districts.push({ path: node.data.path, depth: node.depth, x, z, width, length }); + continue; + } + // Leave a little gap so neighbouring buildings read as separate blocks. + const gap = Math.min(width, length) * 0.12; + buildings.push({ + path: node.data.path, + size: node.data.size, + language: languageOf(node.data.path), + x, + z, + width: Math.max(width - gap, 0.05), + depth: Math.max(length - gap, 0.05), + height: heightFor(node.data.size), + }); + } + return { buildings, districts, extent: EXTENT }; +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..0fa2630 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,162 @@ +import { CityView } from "./city"; +import { fetchSnapshot, parseRepo } from "./github"; +import { layoutCity, type Building } from "./layout"; +import type { LanguageGroup } from "./languages"; +import { THEMES, themeById } from "./themes"; + +/** Above this many files the city gets too heavy for most laptops. */ +const MAX_FILES = 40000; + +const LANGUAGE_LABELS: Record = { + script: "JS / TS", + python: "Python", + systems: "C / C++ / Rust / Go", + jvm: "Java / Kotlin", + web: "Web / Ruby / PHP", + shell: "Shell", + data: "Data / config", + docs: "Docs", + media: "Media", + other: "Other", +}; + +const $ = (id: string) => document.getElementById(id) as T; +const form = $("repo-form"); +const input = $("repo-input"); +const themeSelect = $("theme-select"); +const status = $("status"); +const info = $("info"); +const legend = $("legend"); + +const params = new URLSearchParams(location.search); +let theme = themeById(params.get("theme")); +let current: { owner: string; name: string; branch: string } | null = null; + +const view = new CityView($("city"), theme); + +for (const t of THEMES) themeSelect.add(new Option(t.label, t.id, false, t.id === theme.id)); +themeSelect.addEventListener("change", () => { + theme = themeById(themeSelect.value); + view.setTheme(theme); + renderLegend(); + updateUrl(); +}); + +form.addEventListener("submit", (event) => { + event.preventDefault(); + void build(input.value); +}); + +// Treat a click as a selection only when the camera didn't move (dragging rotates the city). +let downAt: { x: number; y: number } | null = null; +const canvasHost = $("city"); +canvasHost.addEventListener("pointerdown", (e) => (downAt = { x: e.clientX, y: e.clientY })); +canvasHost.addEventListener("pointerup", (e) => { + if (!downAt || Math.hypot(e.clientX - downAt.x, e.clientY - downAt.y) > 4) return; + const building = view.pick(e.clientX, e.clientY); + view.select(building); + showInfo(building); +}); + +function setStatus(text: string, isError = false) { + status.textContent = text; + status.classList.toggle("error", isError); +} + +function updateUrl() { + const next = new URLSearchParams(); + if (current) next.set("repo", `${current.owner}/${current.name}`); + if (theme.id !== THEMES[0].id) next.set("theme", theme.id); + const query = next.toString(); + history.replaceState(null, "", query ? `?${query}` : location.pathname); +} + +async function build(raw: string) { + const repo = parseRepo(raw); + if (!repo) { + setStatus("Enter a repository as owner/repo or a GitHub URL.", true); + return; + } + input.value = `${repo.owner}/${repo.name}`; + setStatus(`Fetching ${repo.owner}/${repo.name}…`); + showInfo(null); + try { + const snapshot = await fetchSnapshot(repo.owner, repo.name); + let files = snapshot.files; + const notes: string[] = []; + if (snapshot.truncated) notes.push("GitHub returned only part of the tree"); + if (files.length > MAX_FILES) { + files = files.slice(0, MAX_FILES); + notes.push(`showing the first ${MAX_FILES.toLocaleString()} files`); + } + const layout = layoutCity(files); + view.show(layout); + current = { owner: snapshot.owner, name: snapshot.name, branch: snapshot.branch }; + updateUrl(); + const folders = layout.districts.length; + setStatus( + `${snapshot.owner}/${snapshot.name}@${snapshot.branch}: ${files.length.toLocaleString()} files in ` + + `${folders.toLocaleString()} folders` + + (notes.length ? ` (${notes.join("; ")})` : "") + + ". Drag to look around, click a building.", + ); + } catch (error) { + setStatus(error instanceof Error ? error.message : String(error), true); + } +} + +function formatBytes(bytes: number): string { + if (bytes < 1024) return `${bytes} B`; + if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`; + return `${(bytes / 1024 / 1024).toFixed(1)} MB`; +} + +function showInfo(building: Building | null) { + info.hidden = building === null; + if (!building || !current) return; + const url = `https://github.com/${current.owner}/${current.name}/blob/${encodeURIComponent(current.branch)}/${building.path + .split("/") + .map(encodeURIComponent) + .join("/")}`; + info.replaceChildren(); + const title = document.createElement("h2"); + title.textContent = building.path.split("/").pop() ?? building.path; + const list = document.createElement("dl"); + for (const [term, value] of [ + ["Path", building.path], + ["Size", formatBytes(building.size)], + ["Kind", LANGUAGE_LABELS[building.language]], + ]) { + const dt = document.createElement("dt"); + dt.textContent = term; + const dd = document.createElement("dd"); + dd.textContent = value; + list.append(dt, dd); + } + const link = document.createElement("a"); + link.href = url; + link.target = "_blank"; + link.rel = "noopener"; + link.textContent = "Open on GitHub"; + info.append(title, list, link); +} + +function renderLegend() { + legend.replaceChildren( + ...(Object.keys(LANGUAGE_LABELS) as LanguageGroup[]).map((group) => { + const item = document.createElement("span"); + const swatch = document.createElement("i"); + swatch.style.background = theme.buildings[group]; + item.append(swatch, LANGUAGE_LABELS[group]); + return item; + }), + ); +} + +renderLegend(); +const initial = params.get("repo"); +if (initial) { + void build(initial); +} else { + setStatus("Enter a public GitHub repository to build its city."); +} diff --git a/src/style.css b/src/style.css new file mode 100644 index 0000000..d2fbd57 --- /dev/null +++ b/src/style.css @@ -0,0 +1,79 @@ +:root { + --panel-bg: rgba(16, 18, 24, 0.82); + --panel-fg: #eef1f5; + --muted: #a3acb9; + --accent: #5fb3ff; + font-family: system-ui, -apple-system, "Segoe UI", sans-serif; + color-scheme: dark; +} + +* { box-sizing: border-box; } + +html, body { + margin: 0; + height: 100%; + overflow: hidden; + background: #111; +} + +#city { + position: fixed; + inset: 0; +} +#city canvas { display: block; width: 100%; height: 100%; } + +.panel { + position: fixed; + background: var(--panel-bg); + color: var(--panel-fg); + border-radius: 10px; + padding: 12px 14px; + backdrop-filter: blur(6px); + font-size: 14px; +} + +#controls { top: 16px; left: 16px; width: min(420px, calc(100vw - 32px)); } +#controls h1 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0.02em; } + +#repo-form { display: flex; gap: 8px; } +#repo-input { + flex: 1; + min-width: 0; + padding: 7px 9px; + border-radius: 6px; + border: 1px solid #3a404c; + background: #0d0f14; + color: inherit; + font: inherit; +} +button, select { + font: inherit; + padding: 6px 12px; + border-radius: 6px; + border: 1px solid #3a404c; + background: #232835; + color: inherit; + cursor: pointer; +} +button[type="submit"] { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; } + +.row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-top: 10px; color: var(--muted); } +.row select { padding: 3px 6px; margin-left: 4px; } +a { color: var(--accent); } + +#status { margin: 10px 0 0; color: var(--muted); min-height: 1.2em; } +#status.error { color: #ff8f8f; } + +#info { right: 16px; top: 16px; width: min(320px, calc(100vw - 32px)); word-break: break-all; } +#info h2 { margin: 0 0 6px; font-size: 15px; } +#info dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 8px; } +#info dt { color: var(--muted); } +#info dd { margin: 0; } + +#legend { left: 16px; bottom: 16px; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: calc(100vw - 32px); font-size: 12px; } +#legend span { display: inline-flex; align-items: center; gap: 5px; } +#legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; } + +@media (max-width: 640px) { + #info { top: auto; bottom: 64px; left: 16px; right: 16px; width: auto; } +} diff --git a/src/themes.ts b/src/themes.ts new file mode 100644 index 0000000..ec9afc7 --- /dev/null +++ b/src/themes.ts @@ -0,0 +1,73 @@ +import type { LanguageGroup } from "./languages"; + +/** + * A theme is the city's "skin". Layout and data never depend on it, so new + * looks (Japanese streets, European old town, ...) only need a new entry here. + */ +export interface Theme { + id: string; + label: string; + sky: string; + fog: string; + ground: string; + /** District plates, from the outermost folder inwards. */ + districts: string[]; + buildings: Record; + /** Extra glow on buildings (0 = none). */ + emissive: number; + ambient: number; + sun: number; +} + +export const THEMES: Theme[] = [ + { + id: "daylight", + label: "Daylight", + sky: "#cfe3f2", + fog: "#cfe3f2", + ground: "#a7b39a", + districts: ["#c9c6bd", "#bdb9ae", "#b1ada1", "#a6a295"], + buildings: { + script: "#e8c25a", + python: "#4f7fbf", + systems: "#b5654a", + jvm: "#c9874a", + web: "#d97a8c", + shell: "#6aa36f", + data: "#9aa3ad", + docs: "#f2efe6", + media: "#a58bc7", + other: "#8a8f96", + }, + emissive: 0, + ambient: 0.7, + sun: 1.6, + }, + { + id: "cyberpunk", + label: "Cyberpunk", + sky: "#07040f", + fog: "#120a24", + ground: "#0b0a14", + districts: ["#1a1430", "#221a3d", "#2a204a", "#332757"], + buildings: { + script: "#ffd23f", + python: "#3fa9ff", + systems: "#ff3f6c", + jvm: "#ff8a3f", + web: "#ff3fd4", + shell: "#3fff9b", + data: "#7a7fff", + docs: "#d6f6ff", + media: "#b23fff", + other: "#5c6a80", + }, + emissive: 0.22, + ambient: 0.25, + sun: 0.6, + }, +]; + +export function themeById(id: string | null): Theme { + return THEMES.find((t) => t.id === id) ?? THEMES[0]; +} diff --git a/tests/github.test.ts b/tests/github.test.ts new file mode 100644 index 0000000..2b40d53 --- /dev/null +++ b/tests/github.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from "vitest"; +import { parseRepo } from "../src/github"; + +describe("parseRepo", () => { + it("accepts owner/name", () => { + expect(parseRepo("vitejs/vite")).toEqual({ owner: "vitejs", name: "vite" }); + }); + + it("accepts GitHub URLs", () => { + expect(parseRepo("https://github.com/mrdoob/three.js")).toEqual({ owner: "mrdoob", name: "three.js" }); + expect(parseRepo("github.com/keito118/commit-city.git")).toEqual({ owner: "keito118", name: "commit-city" }); + expect(parseRepo("https://github.com/vitejs/vite/tree/main/packages")).toEqual({ owner: "vitejs", name: "vite" }); + }); + + it("rejects anything else", () => { + expect(parseRepo("vite")).toBeNull(); + expect(parseRepo("https://gitlab.com/a/b")).toBeNull(); + }); +}); diff --git a/tests/layout.test.ts b/tests/layout.test.ts new file mode 100644 index 0000000..a1e5fb8 --- /dev/null +++ b/tests/layout.test.ts @@ -0,0 +1,70 @@ +import { describe, expect, it } from "vitest"; +import { buildTree, heightFor, layoutCity } from "../src/layout"; +import { languageOf } from "../src/languages"; + +const files = [ + { path: "README.md", size: 2000 }, + { path: "src/main.ts", size: 8000 }, + { path: "src/util/math.ts", size: 500 }, + { path: "tests/main.test.ts", size: 1200 }, +]; + +describe("buildTree", () => { + it("nests files under their folders", () => { + const root = buildTree(files); + const src = root.children!.find((c) => c.name === "src")!; + expect(src.children!.map((c) => c.name).sort()).toEqual(["main.ts", "util"]); + expect(src.children!.find((c) => c.name === "util")!.children![0].path).toBe("src/util/math.ts"); + }); +}); + +describe("layoutCity", () => { + const layout = layoutCity(files); + + it("makes one building per file and one district per folder", () => { + expect(layout.buildings).toHaveLength(4); + expect(layout.districts.map((d) => d.path).sort()).toEqual(["src", "src/util", "tests"]); + }); + + it("keeps every building inside the city", () => { + const half = layout.extent / 2; + for (const b of layout.buildings) { + expect(Math.abs(b.x) + b.width / 2).toBeLessThanOrEqual(half); + expect(Math.abs(b.z) + b.depth / 2).toBeLessThanOrEqual(half); + } + }); + + it("does not overlap buildings", () => { + const bs = layout.buildings; + for (let i = 0; i < bs.length; i++) { + for (let j = i + 1; j < bs.length; j++) { + const a = bs[i]; + const b = bs[j]; + const overlapX = Math.abs(a.x - b.x) < (a.width + b.width) / 2; + const overlapZ = Math.abs(a.z - b.z) < (a.depth + b.depth) / 2; + expect(overlapX && overlapZ).toBe(false); + } + } + }); + + it("makes bigger files taller", () => { + const main = layout.buildings.find((b) => b.path === "src/main.ts")!; + const math = layout.buildings.find((b) => b.path === "src/util/math.ts")!; + expect(main.height).toBeGreaterThan(math.height); + expect(heightFor(0)).toBeGreaterThan(0); + }); + + it("handles an empty repository", () => { + expect(layoutCity([]).buildings).toEqual([]); + }); +}); + +describe("languageOf", () => { + it("groups by extension", () => { + expect(languageOf("src/app.tsx")).toBe("script"); + expect(languageOf("pkg/main.go")).toBe("systems"); + expect(languageOf("docs/README.MD")).toBe("docs"); + expect(languageOf("Makefile")).toBe("other"); + expect(languageOf(".gitignore")).toBe("other"); + }); +}); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..588ec41 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "skipLibCheck": true, + "types": ["vite/client"] + }, + "include": ["src", "tests"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..bd11f73 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from "vite"; + +// Relative paths, so the build works under GitHub Pages (/commit-city/) and locally. +export default defineConfig({ + base: "./", +});