refactor: render the UI with Preact and signals
- Sidebar, legend, status, info panel and tooltip are Preact components (src/components) - App state that the UI or map depends on is held in @preact/signals; the map redraws through a signal effect, pan/zoom still redraw directly - Classification is a computed signal (buildings) instead of manual classifyAll calls - index.html is just a mount point; CSS is imported from main.tsx Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4f9c11039b
commit
5a3ee9ab86
23 changed files with 715 additions and 434 deletions
157
bun.lock
157
bun.lock
|
|
@ -5,16 +5,71 @@
|
|||
"": {
|
||||
"name": "building-use-map",
|
||||
"dependencies": {
|
||||
"oxfmt": "^0.77.0",
|
||||
"oxlint": "^1.92.0",
|
||||
"@preact/signals": "^2.11.4",
|
||||
"preact": "^11.2.0",
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "^2.10.6",
|
||||
"oxfmt": "^0.77.0",
|
||||
"oxlint": "^1.92.0",
|
||||
"typescript": "^7.0.2",
|
||||
"vite": "^8.3.6",
|
||||
},
|
||||
},
|
||||
},
|
||||
"packages": {
|
||||
"@babel/code-frame": ["@babel/code-frame@7.29.7", "", { "dependencies": { "@babel/helper-validator-identifier": "^7.29.7", "js-tokens": "^4.0.0", "picocolors": "^1.1.1" } }, "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw=="],
|
||||
|
||||
"@babel/compat-data": ["@babel/compat-data@7.29.7", "", {}, "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg=="],
|
||||
|
||||
"@babel/core": ["@babel/core@7.29.13", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.13", "@babel/helper-compilation-targets": "^7.29.13", "@babel/helper-module-transforms": "^7.29.13", "@babel/helpers": "^7.29.13", "@babel/parser": "^7.29.13", "@babel/template": "^7.29.7", "@babel/traverse": "^7.29.13", "@babel/types": "^7.29.11", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", "gensync": "^1.0.0-beta.2", "json5": "^2.2.3", "semver": "^6.3.1" } }, "sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw=="],
|
||||
|
||||
"@babel/generator": ["@babel/generator@7.29.13", "", { "dependencies": { "@babel/parser": "^7.29.13", "@babel/types": "^7.29.11", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" } }, "sha512-T5FRo+RzVHvGjWOuF1Ljc44b+NXAOazodHkGUHp4I3zCkQ4/sNVJm56h1S278LMR0bY5xBhztGziSbli8zObIw=="],
|
||||
|
||||
"@babel/helper-annotate-as-pure": ["@babel/helper-annotate-as-pure@7.29.7", "", { "dependencies": { "@babel/types": "^7.29.7" } }, "sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw=="],
|
||||
|
||||
"@babel/helper-compilation-targets": ["@babel/helper-compilation-targets@7.29.13", "", { "dependencies": { "@babel/compat-data": "^7.29.7", "@babel/helper-validator-option": "^7.29.7", "browserslist": "^4.24.0", "lru-cache": "^5.1.1", "semver": "^6.3.1" } }, "sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w=="],
|
||||
|
||||
"@babel/helper-globals": ["@babel/helper-globals@7.29.7", "", {}, "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA=="],
|
||||
|
||||
"@babel/helper-module-imports": ["@babel/helper-module-imports@7.29.7", "", { "dependencies": { "@babel/traverse": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g=="],
|
||||
|
||||
"@babel/helper-module-transforms": ["@babel/helper-module-transforms@7.29.13", "", { "dependencies": { "@babel/helper-module-imports": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7", "@babel/traverse": "^7.29.13" }, "peerDependencies": { "@babel/core": "^7.0.0" } }, "sha512-/U96wOz+SCoZ7Da/8kjDGltcNY280JPQcRNPK0Hk3PTbdpaiBDQImtC6JsbVwb1HGMr3usZQU2WsWVjhYNmRzw=="],
|
||||
|
||||
"@babel/helper-plugin-utils": ["@babel/helper-plugin-utils@7.29.7", "", {}, "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw=="],
|
||||
|
||||
"@babel/helper-string-parser": ["@babel/helper-string-parser@7.29.13", "", {}, "sha512-fWegr+WsEsiMVW4KUNdIIzzMTZSzNiqhy0//6+2MRi2d5NFNsL/AYwBQW8eBnRbTBVRnDVzjaJEUqKaCWjMMdQ=="],
|
||||
|
||||
"@babel/helper-validator-identifier": ["@babel/helper-validator-identifier@7.29.7", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="],
|
||||
|
||||
"@babel/helper-validator-option": ["@babel/helper-validator-option@7.29.7", "", {}, "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw=="],
|
||||
|
||||
"@babel/helpers": ["@babel/helpers@7.29.13", "", { "dependencies": { "@babel/template": "^7.29.7", "@babel/types": "^7.29.11" } }, "sha512-laoRpD/kO/iA4CDlgJbixHekg7oPvWALK0PQyK3Ob2I2njZRvVAD77RfWCIImtqWCq6KijoBoZK7bp/HlTWASQ=="],
|
||||
|
||||
"@babel/parser": ["@babel/parser@7.29.13", "", { "dependencies": { "@babel/types": "^7.29.11" }, "bin": "./bin/babel-parser.js" }, "sha512-fJM50YYjlTiBhgdkGmC1tBpv+FMAyo4annf2X6Aks+0yRlaiVkYW/3f07xAfVVkYIoZ9fFZp+mEThUFnuybhkQ=="],
|
||||
|
||||
"@babel/plugin-syntax-jsx": ["@babel/plugin-syntax-jsx@7.29.7", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A=="],
|
||||
|
||||
"@babel/plugin-transform-react-jsx": ["@babel/plugin-transform-react-jsx@7.29.7", "", { "dependencies": { "@babel/helper-annotate-as-pure": "^7.29.7", "@babel/helper-module-imports": "^7.29.7", "@babel/helper-plugin-utils": "^7.29.7", "@babel/plugin-syntax-jsx": "^7.29.7", "@babel/types": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-WsZulLVBUHXVj2cUcPVx6UE21TpalB6bHbSFErKT0Ib++ax24jjXe73FqlWvdylFOjiuPHYi6VCcgRad1ItN+A=="],
|
||||
|
||||
"@babel/plugin-transform-react-jsx-development": ["@babel/plugin-transform-react-jsx-development@7.29.7", "", { "dependencies": { "@babel/plugin-transform-react-jsx": "^7.29.7" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-Xfy3UVMF04+ypnFbkhvfqtmvwfe92qwQdbGZVonhE+6v35GzlofmOnA1szaZqzb9xYWr0nl1e5EMmzi0DNON1g=="],
|
||||
|
||||
"@babel/template": ["@babel/template@7.29.7", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/parser": "^7.29.7", "@babel/types": "^7.29.7" } }, "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg=="],
|
||||
|
||||
"@babel/traverse": ["@babel/traverse@7.29.13", "", { "dependencies": { "@babel/code-frame": "^7.29.7", "@babel/generator": "^7.29.13", "@babel/helper-globals": "^7.29.7", "@babel/parser": "^7.29.13", "@babel/template": "^7.29.7", "@babel/types": "^7.29.11", "debug": "^4.3.1" } }, "sha512-0ve0xMlFA73dgY1oyJRY6RoW+/bncdcOQqg6jjYcVfXBK90OdLXjm9R6lmRetdZVrPjXkKIoMVBqYFPjcAlZ4Q=="],
|
||||
|
||||
"@babel/types": ["@babel/types@7.29.11", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.11", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ=="],
|
||||
|
||||
"@jridgewell/gen-mapping": ["@jridgewell/gen-mapping@0.3.13", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.0", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA=="],
|
||||
|
||||
"@jridgewell/remapping": ["@jridgewell/remapping@2.3.5", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.5", "@jridgewell/trace-mapping": "^0.3.24" } }, "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ=="],
|
||||
|
||||
"@jridgewell/resolve-uri": ["@jridgewell/resolve-uri@3.1.2", "", {}, "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw=="],
|
||||
|
||||
"@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.6.0", "", {}, "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw=="],
|
||||
|
||||
"@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="],
|
||||
|
||||
"@oxc-project/types": ["@oxc-project/types@0.156.0", "", {}, "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw=="],
|
||||
|
||||
"@oxfmt/binding-android-arm-eabi": ["@oxfmt/binding-android-arm-eabi@0.77.0", "", { "os": "android", "cpu": "arm" }, "sha512-zmPiuOvkuu0csMx4U3gdMunIFWNcWulzikFMdAPBzLazVAA3LhdHzv9yzgUgAckv/zje5vz4XJcseNQKdSsWMw=="],
|
||||
|
|
@ -93,6 +148,20 @@
|
|||
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.92.0", "", { "os": "win32", "cpu": "x64" }, "sha512-0AyhqX0ciFuEnHIL+B4PIMMX3s/IpGHNEbbUqwsNhSrzWUSlEOPw/q7qFnRsEJfiKedcqVfUE/aXYuSMtpiFyw=="],
|
||||
|
||||
"@preact/preset-vite": ["@preact/preset-vite@2.10.6", "", { "dependencies": { "@babel/plugin-transform-react-jsx": "^7.27.1", "@babel/plugin-transform-react-jsx-development": "^7.27.1", "@prefresh/vite": "^2.4.11", "@rollup/pluginutils": "^5.0.0", "babel-plugin-transform-hook-names": "^1.0.2", "debug": "^4.4.3", "magic-string": "^0.30.21", "picocolors": "^1.1.1", "vite-prerender-plugin": "^0.5.8", "zimmerframe": "^1.1.4" }, "peerDependencies": { "@babel/core": "7.x", "vite": "2.x || 3.x || 4.x || 5.x || 6.x || 7.x || 8.x" } }, "sha512-ZZ5RIT2ZVXg8UxRA8VZpoT8CdpDG7RFIqOT4bELqNBp85+HKvQBbgmh3gsoW1UOQXx26TLe+ZRNKI7q281Kckw=="],
|
||||
|
||||
"@preact/signals": ["@preact/signals@2.11.4", "", { "dependencies": { "@preact/signals-core": "^1.14.5" }, "peerDependencies": { "preact": ">= 10.25.0 || >=11.0.0-0" } }, "sha512-Rb+5RPo9gWSaHtzJeauhHxiC8KP/IF2DEPkHPEOGOnuy2wnJzRqyeLRankUCYd6ADqtxS6GnWGv6Ie343d8aYw=="],
|
||||
|
||||
"@preact/signals-core": ["@preact/signals-core@1.14.5", "", {}, "sha512-vcRv7Ityz5JVmeiVqIluLFzT/PDS/AlhHUpw3/aUWqcVUs6bDGIPXE/6RSC4evBNWYvnniozg5Syfj33al3gkg=="],
|
||||
|
||||
"@prefresh/babel-plugin": ["@prefresh/babel-plugin@0.5.4", "", { "peerDependencies": { "@babel/core": "^7.0.0 || ^8.0.0" } }, "sha512-GSwqHGVem7AjnOKAkmLNbAExqZZFddf9S3ySOwowGEsJR8vwNKJ7Z/262fov5wra8LkDVSmFw3CjMGRdLoCmRA=="],
|
||||
|
||||
"@prefresh/core": ["@prefresh/core@1.5.11", "", { "peerDependencies": { "preact": "^10.0.0 || ^11.0.0-0" } }, "sha512-Ml00PP8jeHaADxfQqxUs4+M5JS+T5J26UnvPVfsrmlpGw2I3e9XtM0DMeuzkmvg+Tn7VdHSMpLBrDPG0iHoDqQ=="],
|
||||
|
||||
"@prefresh/utils": ["@prefresh/utils@1.2.1", "", {}, "sha512-vq/sIuN5nYfYzvyayXI4C2QkprfNaHUQ9ZX+3xLD8nL3rWyzpxOm1+K7RtMbhd+66QcaISViK7amjnheQ/4WZw=="],
|
||||
|
||||
"@prefresh/vite": ["@prefresh/vite@2.4.12", "", { "dependencies": { "@babel/core": "^7.22.1", "@prefresh/babel-plugin": "^0.5.2", "@prefresh/core": "^1.5.0", "@prefresh/utils": "^1.2.0", "@rollup/pluginutils": "^4.2.1" }, "peerDependencies": { "preact": "^10.4.0 || ^11.0.0-0", "vite": ">=2.0.0" } }, "sha512-FY1fzXpUjiuosznMV0YM7XAOPZjB5FIdWS0W24+XnlxYkt9hNAwwsiKYn+cuTEoMtD/ZVazS5QVssBr9YhpCQA=="],
|
||||
|
||||
"@rolldown/binding-android-arm-eabi": ["@rolldown/binding-android-arm-eabi@1.2.16", "", { "os": "android", "cpu": "arm" }, "sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA=="],
|
||||
|
||||
"@rolldown/binding-android-arm64": ["@rolldown/binding-android-arm64@1.2.16", "", { "os": "android", "cpu": "arm64" }, "sha512-kx5wBiMB6E7TEvpl2B9gjLU004BkvEm2Dr941BFjx/SontPwSzNuQUIoVKxHHoSjpFIfHMmcguyLOtyn0hObRg=="],
|
||||
|
|
@ -125,6 +194,10 @@
|
|||
|
||||
"@rolldown/pluginutils": ["@rolldown/pluginutils@1.0.1", "", {}, "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw=="],
|
||||
|
||||
"@rollup/pluginutils": ["@rollup/pluginutils@5.5.1", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-P9ZvnfouRu4MSC+ilERaw6FmZs8zqKhpHxEs4aGDGWQAMzQGXnhvCSvoNwokfNvdt7t3Y5Y4p6gStQgezeIqug=="],
|
||||
|
||||
"@types/estree": ["@types/estree@1.0.10", "", {}, "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g=="],
|
||||
|
||||
"@typescript/typescript-aix-ppc64": ["@typescript/typescript-aix-ppc64@7.0.2", "", { "os": "aix", "cpu": "ppc64" }, "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ=="],
|
||||
|
||||
"@typescript/typescript-darwin-arm64": ["@typescript/typescript-darwin-arm64@7.0.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA=="],
|
||||
|
|
@ -165,12 +238,58 @@
|
|||
|
||||
"@typescript/typescript-win32-x64": ["@typescript/typescript-win32-x64@7.0.2", "", { "os": "win32", "cpu": "x64" }, "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g=="],
|
||||
|
||||
"babel-plugin-transform-hook-names": ["babel-plugin-transform-hook-names@1.0.2", "", { "peerDependencies": { "@babel/core": "^7.12.10" } }, "sha512-5gafyjyyBTTdX/tQQ0hRgu4AhNHG/hqWi0ZZmg2xvs2FgRkJXzDNKBZCyoYqgFkovfDrgM8OoKg8karoUvWeCw=="],
|
||||
|
||||
"baseline-browser-mapping": ["baseline-browser-mapping@2.11.35", "", { "bin": { "baseline-browser-mapping": "dist/cli.cjs" } }, "sha512-GNk8KX52CHqeNKGk8+7tZnQab/2k1t/BgrUHPKNdijzpEhF1saPQZHVKb6m5loSAxB39gyrTYw34Qf9CQ3u1qQ=="],
|
||||
|
||||
"boolbase": ["boolbase@1.0.0", "", {}, "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="],
|
||||
|
||||
"browserslist": ["browserslist@4.29.5", "", { "dependencies": { "baseline-browser-mapping": "^2.11.33", "caniuse-lite": "^1.0.30001819", "electron-to-chromium": "^1.5.464", "node-releases": "^2.0.60", "update-browserslist-db": "^1.3.4" }, "bin": { "browserslist": "cli.js" } }, "sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ=="],
|
||||
|
||||
"caniuse-lite": ["caniuse-lite@1.0.30001823", "", {}, "sha512-TQ5s/djDjNk1axreUW+4rULH+BmdCMLiJkhaXnO5wqivG7tITkSUj4ItIdzqdZHKaXcHAV8dhH3JxOM7/7bwqw=="],
|
||||
|
||||
"convert-source-map": ["convert-source-map@2.0.0", "", {}, "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg=="],
|
||||
|
||||
"css-select": ["css-select@5.2.2", "", { "dependencies": { "boolbase": "^1.0.0", "css-what": "^6.1.0", "domhandler": "^5.0.2", "domutils": "^3.0.1", "nth-check": "^2.0.1" } }, "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw=="],
|
||||
|
||||
"css-what": ["css-what@6.2.2", "", {}, "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA=="],
|
||||
|
||||
"debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" }, "peerDependencies": { "supports-color": "*" }, "optionalPeers": ["supports-color"] }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="],
|
||||
|
||||
"detect-libc": ["detect-libc@2.1.2", "", {}, "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ=="],
|
||||
|
||||
"dom-serializer": ["dom-serializer@2.0.0", "", { "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.2", "entities": "^4.2.0" } }, "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg=="],
|
||||
|
||||
"domelementtype": ["domelementtype@2.3.0", "", {}, "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw=="],
|
||||
|
||||
"domhandler": ["domhandler@5.0.3", "", { "dependencies": { "domelementtype": "^2.3.0" } }, "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w=="],
|
||||
|
||||
"domutils": ["domutils@3.2.2", "", { "dependencies": { "dom-serializer": "^2.0.0", "domelementtype": "^2.3.0", "domhandler": "^5.0.3" } }, "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw=="],
|
||||
|
||||
"electron-to-chromium": ["electron-to-chromium@1.5.478", "", {}, "sha512-pftG+ma5Lm8O6/p45bhYT6StBN5ziQymaRzmCZwFl8DwWHKPPD93FdOmP1aqftcepolQYvrcyTLa17kE8Yf+jg=="],
|
||||
|
||||
"entities": ["entities@4.5.0", "", {}, "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw=="],
|
||||
|
||||
"escalade": ["escalade@3.2.0", "", {}, "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA=="],
|
||||
|
||||
"estree-walker": ["estree-walker@2.0.2", "", {}, "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w=="],
|
||||
|
||||
"fdir": ["fdir@6.5.0", "", { "peerDependencies": { "picomatch": "^3 || ^4" }, "optionalPeers": ["picomatch"] }, "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg=="],
|
||||
|
||||
"fsevents": ["fsevents@2.3.3", "", { "os": "darwin" }, "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw=="],
|
||||
|
||||
"gensync": ["gensync@1.0.0-beta.2", "", {}, "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg=="],
|
||||
|
||||
"he": ["he@1.2.0", "", { "bin": { "he": "bin/he" } }, "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="],
|
||||
|
||||
"js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
|
||||
|
||||
"jsesc": ["jsesc@3.1.0", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="],
|
||||
|
||||
"json5": ["json5@2.2.3", "", { "bin": { "json5": "lib/cli.js" } }, "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg=="],
|
||||
|
||||
"kolorist": ["kolorist@1.8.0", "", {}, "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ=="],
|
||||
|
||||
"lightningcss": ["lightningcss@1.33.0", "", { "dependencies": { "detect-libc": "^2.0.3" }, "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" } }, "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA=="],
|
||||
|
||||
"lightningcss-android-arm64": ["lightningcss-android-arm64@1.33.0", "", { "os": "android", "cpu": "arm64" }, "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg=="],
|
||||
|
|
@ -195,8 +314,20 @@
|
|||
|
||||
"lightningcss-win32-x64-msvc": ["lightningcss-win32-x64-msvc@1.33.0", "", { "os": "win32", "cpu": "x64" }, "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA=="],
|
||||
|
||||
"lru-cache": ["lru-cache@5.1.1", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
|
||||
|
||||
"magic-string": ["magic-string@0.30.21", "", { "dependencies": { "@jridgewell/sourcemap-codec": "^1.5.5" } }, "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ=="],
|
||||
|
||||
"ms": ["ms@2.1.3", "", {}, "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="],
|
||||
|
||||
"nanoid": ["nanoid@3.3.20", "", { "bin": { "nanoid": "bin/nanoid.cjs" } }, "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ=="],
|
||||
|
||||
"node-html-parser": ["node-html-parser@6.1.13", "", { "dependencies": { "css-select": "^5.1.0", "he": "1.2.0" } }, "sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg=="],
|
||||
|
||||
"node-releases": ["node-releases@2.0.63", "", {}, "sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q=="],
|
||||
|
||||
"nth-check": ["nth-check@2.1.1", "", { "dependencies": { "boolbase": "^1.0.0" } }, "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w=="],
|
||||
|
||||
"oxfmt": ["oxfmt@0.77.0", "", { "dependencies": { "tinypool": "2.2.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.77.0", "@oxfmt/binding-android-arm64": "0.77.0", "@oxfmt/binding-darwin-arm64": "0.77.0", "@oxfmt/binding-darwin-x64": "0.77.0", "@oxfmt/binding-freebsd-x64": "0.77.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.77.0", "@oxfmt/binding-linux-arm-musleabihf": "0.77.0", "@oxfmt/binding-linux-arm64-gnu": "0.77.0", "@oxfmt/binding-linux-arm64-musl": "0.77.0", "@oxfmt/binding-linux-ppc64-gnu": "0.77.0", "@oxfmt/binding-linux-riscv64-gnu": "0.77.0", "@oxfmt/binding-linux-riscv64-musl": "0.77.0", "@oxfmt/binding-linux-s390x-gnu": "0.77.0", "@oxfmt/binding-linux-x64-gnu": "0.77.0", "@oxfmt/binding-linux-x64-musl": "0.77.0", "@oxfmt/binding-openharmony-arm64": "0.77.0", "@oxfmt/binding-win32-arm64-msvc": "0.77.0", "@oxfmt/binding-win32-ia32-msvc": "0.77.0", "@oxfmt/binding-win32-x64-msvc": "0.77.0" }, "peerDependencies": { "@astrojs/compiler-rs": "^0.5.0", "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["@astrojs/compiler-rs", "svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-3bPDJwLZf4i6dOaQS+6GOI/YUFTHNif7qw4nknbZyzdB0uws57tD8jA/GLGC9J7kjyf6d/eVWm73b43VeMUqGw=="],
|
||||
|
||||
"oxlint": ["oxlint@1.92.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.92.0", "@oxlint/binding-android-arm64": "1.92.0", "@oxlint/binding-darwin-arm64": "1.92.0", "@oxlint/binding-darwin-x64": "1.92.0", "@oxlint/binding-freebsd-x64": "1.92.0", "@oxlint/binding-linux-arm-gnueabihf": "1.92.0", "@oxlint/binding-linux-arm-musleabihf": "1.92.0", "@oxlint/binding-linux-arm64-gnu": "1.92.0", "@oxlint/binding-linux-arm64-musl": "1.92.0", "@oxlint/binding-linux-ppc64-gnu": "1.92.0", "@oxlint/binding-linux-riscv64-gnu": "1.92.0", "@oxlint/binding-linux-riscv64-musl": "1.92.0", "@oxlint/binding-linux-s390x-gnu": "1.92.0", "@oxlint/binding-linux-x64-gnu": "1.92.0", "@oxlint/binding-linux-x64-musl": "1.92.0", "@oxlint/binding-openharmony-arm64": "1.92.0", "@oxlint/binding-win32-arm64-msvc": "1.92.0", "@oxlint/binding-win32-ia32-msvc": "1.92.0", "@oxlint/binding-win32-x64-msvc": "1.92.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2005", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-y9iRiRwVjVFqzKNXZJ9bT/GYRdf+F9Gy+a1Yju2Aq3xqqa4FJYXHI8VrxlpzxKDvkYRohvJX42m/eH+qkQPOFw=="],
|
||||
|
|
@ -207,16 +338,38 @@
|
|||
|
||||
"postcss": ["postcss@8.5.32", "", { "dependencies": { "nanoid": "^3.3.20", "picocolors": "^1.1.1", "source-map-js": "^1.2.2" } }, "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g=="],
|
||||
|
||||
"preact": ["preact@11.2.0", "", { "peerDependencies": { "preact-render-to-string": ">=6.7.0" }, "optionalPeers": ["preact-render-to-string"] }, "sha512-/HfHI/7N84e6GrWBJ3J280z3mLaRJiDcSvj/A+y/4AbLnND/1UlGHe1sR6oYuTGwId0nP7dqDU9OnLxMPZ7xBg=="],
|
||||
|
||||
"rolldown": ["rolldown@1.2.16", "", { "dependencies": { "@oxc-project/types": "=0.156.0", "@rolldown/pluginutils": "^1.0.0" }, "optionalDependencies": { "@rolldown/binding-android-arm-eabi": "1.2.16", "@rolldown/binding-android-arm64": "1.2.16", "@rolldown/binding-darwin-arm64": "1.2.16", "@rolldown/binding-darwin-x64": "1.2.16", "@rolldown/binding-freebsd-x64": "1.2.16", "@rolldown/binding-linux-arm-gnueabihf": "1.2.16", "@rolldown/binding-linux-arm64-gnu": "1.2.16", "@rolldown/binding-linux-arm64-musl": "1.2.16", "@rolldown/binding-linux-ppc64-gnu": "1.2.16", "@rolldown/binding-linux-s390x-gnu": "1.2.16", "@rolldown/binding-linux-x64-gnu": "1.2.16", "@rolldown/binding-linux-x64-musl": "1.2.16", "@rolldown/binding-openharmony-arm64": "1.2.16", "@rolldown/binding-win32-arm64-msvc": "1.2.16", "@rolldown/binding-win32-x64-msvc": "1.2.16" }, "bin": { "rolldown": "./bin/cli.mjs" } }, "sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw=="],
|
||||
|
||||
"semver": ["semver@6.3.2", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ=="],
|
||||
|
||||
"simple-code-frame": ["simple-code-frame@1.3.0", "", { "dependencies": { "kolorist": "^1.6.0" } }, "sha512-MB4pQmETUBlNs62BBeRjIFGeuy/x6gGKh7+eRUemn1rCFhqo7K+4slPqsyizCbcbYLnaYqaoZ2FWsZ/jN06D8w=="],
|
||||
|
||||
"source-map": ["source-map@0.7.6", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],
|
||||
|
||||
"source-map-js": ["source-map-js@1.2.2", "", {}, "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw=="],
|
||||
|
||||
"stack-trace": ["stack-trace@1.0.0", "", {}, "sha512-H6D7134xi6qONvh7ZHKgviXf+rd3vhGBSvebPZCaUkd8zvQ+7PtDw6CljPTe4cXWNf2IKZGNqw6VJXSb9IgBpA=="],
|
||||
|
||||
"tinyglobby": ["tinyglobby@0.2.17", "", { "dependencies": { "fdir": "^6.5.0", "picomatch": "^4.0.4" } }, "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g=="],
|
||||
|
||||
"tinypool": ["tinypool@2.2.0", "", {}, "sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ=="],
|
||||
|
||||
"typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
|
||||
|
||||
"update-browserslist-db": ["update-browserslist-db@1.3.4", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A=="],
|
||||
|
||||
"vite": ["vite@8.3.6", "", { "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", "postcss": "^8.5.32", "rolldown": "~1.2.16", "tinyglobby": "^0.2.17" }, "optionalDependencies": { "fsevents": "~2.3.3" }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", "@vitejs/devtools": "^0.7.1 || ^0.8.0", "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" }, "optionalPeers": ["@types/node", "@vitejs/devtools", "esbuild", "jiti", "less", "sass", "sass-embedded", "stylus", "sugarss", "terser", "tsx", "yaml"], "bin": { "vite": "bin/vite.js" } }, "sha512-UI7dK29NnS54Fk+mmo7o+jI6U8Fp7hDl+X5Q1k45WH+d4dSlbLVUETGQ+hfkNgvLQGyoElPj837nZyv4MBc0VA=="],
|
||||
|
||||
"vite-prerender-plugin": ["vite-prerender-plugin@0.5.14", "", { "dependencies": { "kolorist": "^1.8.0", "magic-string": "0.x >= 0.26.0", "node-html-parser": "^6.1.12", "simple-code-frame": "^1.3.0", "source-map": "^0.7.4", "stack-trace": "^1.0.0-pre2" }, "peerDependencies": { "vite": "5.x || 6.x || 7.x || 8.x" } }, "sha512-X2w9AS1OhwEUec9HSryGAmEnEQJGhW6eFoiCVJv8BfOTVpM8SOjk75cEw/IC28APDHZudeIRbP8Sp7wfABq+Aw=="],
|
||||
|
||||
"yallist": ["yallist@3.1.1", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
|
||||
|
||||
"zimmerframe": ["zimmerframe@1.1.5", "", {}, "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA=="],
|
||||
|
||||
"@prefresh/vite/@rollup/pluginutils": ["@rollup/pluginutils@4.2.1", "", { "dependencies": { "estree-walker": "^2.0.1", "picomatch": "^2.2.2" } }, "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ=="],
|
||||
|
||||
"@prefresh/vite/@rollup/pluginutils/picomatch": ["picomatch@2.3.2", "", {}, "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA=="],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,12 @@
|
|||
"preview": "vite preview",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"@preact/signals": "^2.11.4",
|
||||
"preact": "^11.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@preact/preset-vite": "^2.10.6",
|
||||
"oxfmt": "^0.77.0",
|
||||
"oxlint": "^1.92.0",
|
||||
"typescript": "^7.0.2",
|
||||
|
|
|
|||
57
src/actions.ts
Normal file
57
src/actions.ts
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import { batch } from '@preact/signals'
|
||||
import { fetchArea } from './fetch'
|
||||
import { D2R } from './geo'
|
||||
import { t } from './i18n'
|
||||
import { fitView } from './render'
|
||||
import { base, busy, hidden, radius, rawBuildings, S, sel, status, type Status } from './state'
|
||||
import type { AreaData, LatLon } from './types'
|
||||
import { errMsg } from './util'
|
||||
|
||||
export function setStatus(fn: () => string, cls?: Status['cls']) {
|
||||
status.value = { fn, cls }
|
||||
}
|
||||
|
||||
export function applyData(d: AreaData, lon: number, lat: number) {
|
||||
S.center = [lon, lat]
|
||||
S.K = Math.cos(lat * D2R)
|
||||
S.loaded = true
|
||||
// fitView inside the batch so the map redraw triggered by the new data uses the new view
|
||||
batch(() => {
|
||||
rawBuildings.value = d.buildings
|
||||
base.value = d.base
|
||||
sel.value = null
|
||||
hidden.value = new Set()
|
||||
fitView()
|
||||
})
|
||||
}
|
||||
|
||||
export async function liveLoad(p: LatLon, quietFallback: boolean): Promise<boolean> {
|
||||
busy.value = true
|
||||
setStatus(() => t('st_loading'))
|
||||
try {
|
||||
const d = await fetchArea(p.lon, p.lat, radius.value, (n, m) =>
|
||||
setStatus(() => t('st_progress', n, m)),
|
||||
)
|
||||
if (!d.buildings.length) {
|
||||
setStatus(() => t('st_none'), 'err')
|
||||
return false
|
||||
}
|
||||
applyData(d, p.lon, p.lat)
|
||||
const loc = `${p.lat.toFixed(5)}, ${p.lon.toFixed(5)}`,
|
||||
n = d.buildings.length,
|
||||
fails = d.fails
|
||||
setStatus(
|
||||
() =>
|
||||
t('st_loaded', loc, n) +
|
||||
(fails.length ? '\n' + t('st_baseFail', fails.length) + '\n' + fails.join('\n') : ''),
|
||||
fails.length ? 'err' : 'ok',
|
||||
)
|
||||
return true
|
||||
} catch (e) {
|
||||
const msg = errMsg(e)
|
||||
setStatus(() => (quietFallback ? t('st_fallback', msg) : t('st_err', msg)), 'err')
|
||||
return false
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
import { t, tKey, ruianUseName } from './i18n'
|
||||
import { S } from './state'
|
||||
import { computed } from '@preact/signals'
|
||||
import { mixMin, mode, rawBuildings } from './state'
|
||||
import type { Building } from './types'
|
||||
|
||||
/* ================= categories ================= */
|
||||
// Simple scheme: key, colour, show house number
|
||||
|
|
@ -148,7 +150,7 @@ export function simpleKey(use: number, flats: number | null): string {
|
|||
if (use === 3) return f >= 4 ? 'unit' : 'res' // generic dwelling
|
||||
const base = USE_CAT[use] || 'other'
|
||||
if (base === 'res' || base === 'unit' || base === 'rec') return base
|
||||
if (S.mixMin > 0 && f >= S.mixMin && base !== 'garage' && base !== 'agri') return 'mix'
|
||||
if (mixMin.value > 0 && f >= mixMin.value && base !== 'garage' && base !== 'agri') return 'mix'
|
||||
return base
|
||||
}
|
||||
export function detailKey(use: number, sk: string): string {
|
||||
|
|
@ -157,24 +159,42 @@ export function detailKey(use: number, sk: string): string {
|
|||
if (use >= 22 && use <= 29) return 'uw'
|
||||
return 'u0'
|
||||
}
|
||||
export function classifyAll() {
|
||||
for (const b of S.buildings) {
|
||||
/**
|
||||
* Buildings with `sc`/`cat` set for the current colour mode and mixed-use rule.
|
||||
* Categories are written onto the building objects (so a selected building stays the same object);
|
||||
* a new array is returned so dependants see a change.
|
||||
*/
|
||||
export const buildings = computed(() => {
|
||||
const list = rawBuildings.value,
|
||||
m = mode.value
|
||||
for (const b of list) {
|
||||
b.sc = simpleKey(b.use, b.flats)
|
||||
b.cat = S.mode === 'simple' ? b.sc : detailKey(b.use, b.sc)
|
||||
b.cat = m === 'simple' ? b.sc : detailKey(b.use, b.sc)
|
||||
}
|
||||
return list.slice()
|
||||
})
|
||||
|
||||
/**
|
||||
* Category of a building in the current mode. Reading `buildings` first makes sure the
|
||||
* classification is up to date and subscribes the caller to mode / mixed-use changes.
|
||||
*/
|
||||
export function catOf(b: Building): string {
|
||||
// oxlint-disable-next-line no-unused-expressions
|
||||
buildings.value
|
||||
return b.cat
|
||||
}
|
||||
|
||||
export const catColor = (key: string): string =>
|
||||
(S.mode === 'simple' ? SIMPLE_COLOR[key] : DETAIL_COLOR[key]) || '#bdbdbd'
|
||||
(mode.value === 'simple' ? SIMPLE_COLOR[key] : DETAIL_COLOR[key]) || '#bdbdbd'
|
||||
export function catLabel(key: string): string {
|
||||
if (S.mode === 'simple') return tKey('cat.' + key)
|
||||
if (mode.value === 'simple') return tKey('cat.' + key)
|
||||
if (key === 'mix') return t('cat.mix')
|
||||
if (key === 'uw') return ruianUseName('w')
|
||||
if (key === 'u0') return ruianUseName(0)
|
||||
return key.slice(1) + ' · ' + ruianUseName(+key.slice(1))
|
||||
}
|
||||
export const catList = () => (S.mode === 'simple' ? SIMPLE.map((c) => c[0]) : DETAIL_LIST)
|
||||
export const catOrder = () => (S.mode === 'simple' ? SIMPLE_ORDER : DETAIL_ORDER)
|
||||
export const catList = () => (mode.value === 'simple' ? SIMPLE.map((c) => c[0]) : DETAIL_LIST)
|
||||
export const catOrder = () => (mode.value === 'simple' ? SIMPLE_ORDER : DETAIL_ORDER)
|
||||
export function isDark(hex: string): boolean {
|
||||
const n = parseInt(hex.slice(1), 16),
|
||||
r = n >> 16,
|
||||
|
|
|
|||
17
src/components/App.tsx
Normal file
17
src/components/App.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { useSignalEffect } from '@preact/signals'
|
||||
import { lang, t } from '../i18n'
|
||||
import { MapView } from './MapView'
|
||||
import { Sidebar } from './Sidebar'
|
||||
|
||||
export function App() {
|
||||
useSignalEffect(() => {
|
||||
document.documentElement.lang = lang.value
|
||||
document.title = t('title') + ' – RÚIAN'
|
||||
})
|
||||
return (
|
||||
<div id="app">
|
||||
<Sidebar />
|
||||
<MapView />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
42
src/components/InfoPanel.tsx
Normal file
42
src/components/InfoPanel.tsx
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { catLabel, catOf } from '../categories'
|
||||
import { m2ll } from '../geo'
|
||||
import { ruianUseName, t } from '../i18n'
|
||||
import { sel } from '../state'
|
||||
|
||||
const DASH = '—'
|
||||
const orDash = (v: number | null, unit = '') => (v == null ? DASH : v + unit)
|
||||
|
||||
/** Details of the selected building. */
|
||||
export function InfoPanel() {
|
||||
const b = sel.value
|
||||
if (!b) return null
|
||||
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2)
|
||||
return (
|
||||
<div id="info">
|
||||
<span class="x" title={t('close')} onClick={() => (sel.value = null)}>
|
||||
✕
|
||||
</span>
|
||||
<b>{b.cp ? t('hn', b.cp) : t('nohn')}</b>
|
||||
<dl>
|
||||
<dt>{t('i_cat')}</dt>
|
||||
<dd>{catLabel(catOf(b))}</dd>
|
||||
<dt>{t('i_use')}</dt>
|
||||
<dd>
|
||||
{ruianUseName(b.use) || DASH} ({b.use || '?'})
|
||||
</dd>
|
||||
<dt>{t('i_flats')}</dt>
|
||||
<dd>{orDash(b.flats)}</dd>
|
||||
<dt>{t('i_floors')}</dt>
|
||||
<dd>{orDash(b.floors)}</dd>
|
||||
<dt>{t('i_area')}</dt>
|
||||
<dd>{orDash(b.area, ' m²')}</dd>
|
||||
<dt>{t('i_done')}</dt>
|
||||
<dd>{orDash(b.year)}</dd>
|
||||
<dt>{t('i_pos')}</dt>
|
||||
<dd>
|
||||
{ll[1].toFixed(6)}, {ll[0].toFixed(6)}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
33
src/components/Legend.tsx
Normal file
33
src/components/Legend.tsx
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { catColor, catLabel, catList } from '../categories'
|
||||
import { counts } from '../render'
|
||||
import { hidden } from '../state'
|
||||
|
||||
function toggle(key: string) {
|
||||
const next = new Set(hidden.value)
|
||||
if (next.has(key)) next.delete(key)
|
||||
else next.add(key)
|
||||
hidden.value = next
|
||||
}
|
||||
|
||||
/** Category list with counts; categories absent from the loaded area are not shown. */
|
||||
export function Legend() {
|
||||
const cnt = counts(),
|
||||
hid = hidden.value
|
||||
return (
|
||||
<div id="legend">
|
||||
{catList().map((key) => {
|
||||
const n = cnt[key] || 0
|
||||
if (!n) return null
|
||||
const on = !hid.has(key)
|
||||
return (
|
||||
<label key={key} class={on ? 'leg' : 'leg off'}>
|
||||
<input type="checkbox" checked={on} onChange={() => toggle(key)} />
|
||||
<span class="sw" style={{ background: catColor(key) }} />
|
||||
<span class="lbl">{catLabel(key)}</span>
|
||||
<span class="n">{n}</span>
|
||||
</label>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
64
src/components/MapView.tsx
Normal file
64
src/components/MapView.tsx
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
import { effect } from '@preact/signals'
|
||||
import { useEffect, useRef } from 'preact/hooks'
|
||||
import { catLabel, catOf } from '../categories'
|
||||
import { t } from '../i18n'
|
||||
import { attachPointer, resize, zoomBy, zoomFit } from '../interaction'
|
||||
import { draw } from '../render'
|
||||
import { hover, vp } from '../state'
|
||||
import type { Building } from '../types'
|
||||
import { InfoPanel } from './InfoPanel'
|
||||
|
||||
const describe = (b: Building) => `${b.cp ? t('hn', b.cp) : t('nohn')} – ${catLabel(catOf(b))}`
|
||||
|
||||
export function MapView() {
|
||||
const stage = useRef<HTMLElement>(null),
|
||||
canvas = useRef<HTMLCanvasElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
const s = stage.current!,
|
||||
cv = canvas.current!
|
||||
vp.ctx = cv.getContext('2d')
|
||||
const detach = attachPointer(cv)
|
||||
const ro = new ResizeObserver(() => resize(s, cv))
|
||||
ro.observe(s)
|
||||
resize(s, cv)
|
||||
// Redraw whenever any signal the drawing reads changes (data, layers, mode, selection…).
|
||||
// Pan and zoom are not signals; they call draw() themselves.
|
||||
const stopDrawing = effect(() => draw())
|
||||
return () => {
|
||||
stopDrawing()
|
||||
ro.disconnect()
|
||||
detach()
|
||||
vp.ctx = null
|
||||
}
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<main id="stage" ref={stage}>
|
||||
<canvas id="cv" ref={canvas} />
|
||||
<div class="zoom">
|
||||
<button title={t('zoomIn')} onClick={() => zoomBy(1.5)}>
|
||||
+
|
||||
</button>
|
||||
<button title={t('zoomOut')} onClick={() => zoomBy(1 / 1.5)}>
|
||||
−
|
||||
</button>
|
||||
<button title={t('fit')} style={{ fontSize: 13 }} onClick={zoomFit}>
|
||||
⤢
|
||||
</button>
|
||||
</div>
|
||||
<Tooltip />
|
||||
<InfoPanel />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
function Tooltip() {
|
||||
const h = hover.value
|
||||
if (!h) return null
|
||||
return (
|
||||
<div id="tip" style={{ left: h.x + 14, top: h.y + 14 }}>
|
||||
{describe(h.b)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
170
src/components/Sidebar.tsx
Normal file
170
src/components/Sidebar.tsx
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
import { batch } from '@preact/signals'
|
||||
import { useRef } from 'preact/hooks'
|
||||
import { liveLoad, setStatus } from '../actions'
|
||||
import { buildings } from '../categories'
|
||||
import { exportCsv, exportPng, exportSvg } from '../export'
|
||||
import { parseLoc } from '../geo'
|
||||
import { lang, setLang, t, type Lang } from '../i18n'
|
||||
import {
|
||||
busy,
|
||||
DEFAULT_LOC,
|
||||
hidden,
|
||||
mixMin,
|
||||
mode,
|
||||
radius,
|
||||
showBase,
|
||||
showNums,
|
||||
status,
|
||||
} from '../state'
|
||||
import type { Mode } from '../types'
|
||||
import { Legend } from './Legend'
|
||||
|
||||
export function Sidebar() {
|
||||
return (
|
||||
<aside>
|
||||
<div class="head">
|
||||
<h1>
|
||||
{t('title')} <small>{t('subtitle')}</small>
|
||||
</h1>
|
||||
<select
|
||||
id="lang"
|
||||
aria-label="Language"
|
||||
value={lang.value}
|
||||
onChange={(e) => setLang(e.currentTarget.value as Lang)}
|
||||
>
|
||||
<option value="cs">CS</option>
|
||||
<option value="en">EN</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<LocationForm />
|
||||
|
||||
<h2>
|
||||
{t('layers')}{' '}
|
||||
<span style={{ textTransform: 'none', letterSpacing: 0 }}>
|
||||
{buildings.value.length ? t('nBuildings', buildings.value.length) : ''}
|
||||
</span>
|
||||
</h2>
|
||||
<Legend />
|
||||
|
||||
<DisplayOptions />
|
||||
|
||||
<h2>{t('export')}</h2>
|
||||
<div class="exp">
|
||||
<button class="ghost" onClick={exportPng}>
|
||||
PNG
|
||||
</button>
|
||||
<button class="ghost" onClick={exportSvg}>
|
||||
SVG
|
||||
</button>
|
||||
<button class="ghost" onClick={exportCsv}>
|
||||
{t('csv')}
|
||||
</button>
|
||||
<button class="ghost" onClick={() => window.print()}>
|
||||
{t('print')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* the note contains <br> line breaks and comes only from our own translations */}
|
||||
<p class="note" dangerouslySetInnerHTML={{ __html: t('note') }} />
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
function LocationForm() {
|
||||
const loc = useRef<HTMLInputElement>(null)
|
||||
const load = () => {
|
||||
const p = parseLoc(loc.current?.value ?? '')
|
||||
if (!p) setStatus(() => t('st_badLoc'), 'err')
|
||||
else liveLoad(p, false)
|
||||
}
|
||||
const st = status.value
|
||||
return (
|
||||
<>
|
||||
<label for="loc">{t('locLabel')}</label>
|
||||
<input
|
||||
id="loc"
|
||||
ref={loc}
|
||||
type="text"
|
||||
defaultValue={DEFAULT_LOC}
|
||||
spellcheck={false}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !busy.value) load()
|
||||
}}
|
||||
/>
|
||||
|
||||
<label for="radius">
|
||||
{t('radius')} <output>{radius.value} m</output>
|
||||
</label>
|
||||
<input
|
||||
id="radius"
|
||||
type="range"
|
||||
min={100}
|
||||
max={700}
|
||||
step={50}
|
||||
value={radius.value}
|
||||
onInput={(e) => (radius.value = +e.currentTarget.value)}
|
||||
/>
|
||||
|
||||
<div class="row">
|
||||
<button disabled={busy.value} onClick={load}>
|
||||
{t('load')}
|
||||
</button>
|
||||
</div>
|
||||
<div id="status" class={st?.cls}>
|
||||
{st?.fn()}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function DisplayOptions() {
|
||||
return (
|
||||
<>
|
||||
<h2>{t('display')}</h2>
|
||||
<label for="colormode">{t('colorMode')}</label>
|
||||
<select
|
||||
id="colormode"
|
||||
value={mode.value}
|
||||
onChange={(e) => {
|
||||
const m = e.currentTarget.value as Mode
|
||||
batch(() => {
|
||||
mode.value = m
|
||||
hidden.value = new Set() // category keys differ between modes
|
||||
})
|
||||
}}
|
||||
>
|
||||
<option value="simple">{t('modeSimple')}</option>
|
||||
<option value="detailed">{t('modeDetailed')}</option>
|
||||
</select>
|
||||
|
||||
<label for="mixrule">{t('mixLabel')}</label>
|
||||
<select
|
||||
id="mixrule"
|
||||
value={String(mixMin.value)}
|
||||
onChange={(e) => (mixMin.value = +e.currentTarget.value)}
|
||||
>
|
||||
<option value="1">{t('mix1')}</option>
|
||||
<option value="2">{t('mix2')}</option>
|
||||
<option value="0">{t('mix0')}</option>
|
||||
</select>
|
||||
|
||||
<label class="chk">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showBase.value}
|
||||
onChange={(e) => (showBase.value = e.currentTarget.checked)}
|
||||
/>{' '}
|
||||
{t('optBase')}
|
||||
</label>
|
||||
<label class="chk">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={showNums.value}
|
||||
onChange={(e) => (showNums.value = e.currentTarget.checked)}
|
||||
/>{' '}
|
||||
{t('optNums')}
|
||||
</label>
|
||||
</>
|
||||
)
|
||||
}
|
||||
149
src/controls.ts
149
src/controls.ts
|
|
@ -1,149 +0,0 @@
|
|||
import { classifyAll } from './categories'
|
||||
import { fetchArea } from './fetch'
|
||||
import { D2R, parseLoc } from './geo'
|
||||
import { lang, setLang, t, tKey, type Lang } from './i18n'
|
||||
import { showInfo } from './interaction'
|
||||
import { draw, fitView } from './render'
|
||||
import { buildLegend, updateCounts } from './sidebar'
|
||||
import { $, S } from './state'
|
||||
import type { AreaData, LatLon, Mode } from './types'
|
||||
import { errMsg } from './util'
|
||||
|
||||
/* ================= status line ================= */
|
||||
// Status is stored as a function so it can be re-rendered when the language changes.
|
||||
export function setStatus(fn: () => string, cls?: string) {
|
||||
S.status = { fn, cls }
|
||||
renderStatus()
|
||||
}
|
||||
function renderStatus() {
|
||||
const s = $('status')
|
||||
if (!S.status) {
|
||||
s.textContent = ''
|
||||
s.className = ''
|
||||
return
|
||||
}
|
||||
s.textContent = S.status.fn()
|
||||
s.className = S.status.cls || ''
|
||||
}
|
||||
|
||||
/* ================= language ================= */
|
||||
export function applyLang() {
|
||||
document.documentElement.lang = lang
|
||||
document.querySelectorAll<HTMLElement>('[data-i18n]').forEach((el) => {
|
||||
el.textContent = tKey(el.dataset.i18n!)
|
||||
})
|
||||
$('note').innerHTML = t('note')
|
||||
$('zin').title = t('zoomIn')
|
||||
$('zout').title = t('zoomOut')
|
||||
$('zfit').title = t('fit')
|
||||
$<HTMLSelectElement>('lang').value = lang
|
||||
document.title = t('title') + ' – RÚIAN'
|
||||
buildLegend()
|
||||
renderStatus()
|
||||
if (S.sel) showInfo(S.sel)
|
||||
draw()
|
||||
}
|
||||
|
||||
/* ================= data ================= */
|
||||
export function applyData(d: AreaData, lon: number, lat: number) {
|
||||
S.buildings = d.buildings
|
||||
S.base = d.base
|
||||
S.center = [lon, lat]
|
||||
S.K = Math.cos(lat * D2R)
|
||||
S.sel = null
|
||||
$('info').style.display = 'none'
|
||||
classifyAll()
|
||||
fitView()
|
||||
S.loaded = true
|
||||
S.hidden.clear()
|
||||
buildLegend()
|
||||
draw()
|
||||
}
|
||||
|
||||
export async function liveLoad(p: LatLon, quietFallback: boolean): Promise<boolean> {
|
||||
const btn = $<HTMLButtonElement>('load')
|
||||
btn.disabled = true
|
||||
setStatus(() => t('st_loading'))
|
||||
try {
|
||||
const radius = +$<HTMLInputElement>('radius').value
|
||||
const d = await fetchArea(p.lon, p.lat, radius, (n, m) =>
|
||||
setStatus(() => t('st_progress', n, m)),
|
||||
)
|
||||
if (!d.buildings.length) {
|
||||
setStatus(() => t('st_none'), 'err')
|
||||
return false
|
||||
}
|
||||
applyData(d, p.lon, p.lat)
|
||||
const loc = `${p.lat.toFixed(5)}, ${p.lon.toFixed(5)}`,
|
||||
n = d.buildings.length,
|
||||
fails = d.fails
|
||||
setStatus(
|
||||
() =>
|
||||
t('st_loaded', loc, n) +
|
||||
(fails.length ? '\n' + t('st_baseFail', fails.length) + '\n' + fails.join('\n') : ''),
|
||||
fails.length ? 'err' : 'ok',
|
||||
)
|
||||
return true
|
||||
} catch (e) {
|
||||
const msg = errMsg(e)
|
||||
setStatus(() => (quietFallback ? t('st_fallback', msg) : t('st_err', msg)), 'err')
|
||||
return false
|
||||
} finally {
|
||||
btn.disabled = false
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= controls ================= */
|
||||
export function initControls() {
|
||||
const langSel = $<HTMLSelectElement>('lang')
|
||||
langSel.onchange = () => {
|
||||
setLang(langSel.value as Lang)
|
||||
applyLang()
|
||||
}
|
||||
|
||||
const radius = $<HTMLInputElement>('radius')
|
||||
radius.oninput = () => {
|
||||
$('rv').textContent = radius.value + ' m'
|
||||
}
|
||||
|
||||
const optBase = $<HTMLInputElement>('optBase'),
|
||||
optNums = $<HTMLInputElement>('optNums')
|
||||
optBase.onchange = () => {
|
||||
S.showBase = optBase.checked
|
||||
draw()
|
||||
}
|
||||
optNums.onchange = () => {
|
||||
S.showNums = optNums.checked
|
||||
draw()
|
||||
}
|
||||
|
||||
const mixrule = $<HTMLSelectElement>('mixrule'),
|
||||
colormode = $<HTMLSelectElement>('colormode')
|
||||
mixrule.onchange = () => {
|
||||
S.mixMin = +mixrule.value
|
||||
classifyAll()
|
||||
updateCounts()
|
||||
buildLegend()
|
||||
draw()
|
||||
}
|
||||
colormode.onchange = () => {
|
||||
S.mode = colormode.value as Mode
|
||||
S.hidden.clear()
|
||||
classifyAll()
|
||||
buildLegend()
|
||||
draw()
|
||||
}
|
||||
|
||||
const loc = $<HTMLInputElement>('loc')
|
||||
$('load').onclick = () => {
|
||||
const p = parseLoc(loc.value)
|
||||
if (!p) {
|
||||
setStatus(() => t('st_badLoc'), 'err')
|
||||
return
|
||||
}
|
||||
liveLoad(p, false)
|
||||
}
|
||||
loc.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') $('load').click()
|
||||
})
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import { BASE } from './basemap'
|
||||
import { catColor, catLabel, catOrder } from './categories'
|
||||
import { buildings, catColor, catLabel, catOrder } from './categories'
|
||||
import { m2ll } from './geo'
|
||||
import { ruianUseName } from './i18n'
|
||||
import { drawLegend, drawScene, legendLayout, pxPerMeter } from './render'
|
||||
import { $, S, vp } from './state'
|
||||
import { base, hidden, S, showBase, vp } from './state'
|
||||
import type { Ring } from './types'
|
||||
|
||||
/* ================= export ================= */
|
||||
|
|
@ -17,7 +17,7 @@ function download(blob: Blob, name: string) {
|
|||
setTimeout(() => URL.revokeObjectURL(a.href), 4000)
|
||||
}
|
||||
|
||||
function exportPng() {
|
||||
export function exportPng() {
|
||||
if (!S.loaded) return
|
||||
const { W, H } = vp,
|
||||
r = 2,
|
||||
|
|
@ -33,7 +33,7 @@ function exportPng() {
|
|||
}, 'image/png')
|
||||
}
|
||||
|
||||
function exportSvg() {
|
||||
export function exportSvg() {
|
||||
if (!S.loaded) return
|
||||
const { W, H } = vp,
|
||||
v = S.view,
|
||||
|
|
@ -48,9 +48,9 @@ function exportSvg() {
|
|||
let o = ''
|
||||
o += `<svg xmlns="http://www.w3.org/2000/svg" width="${W}" height="${H + lh}" viewBox="0 0 ${W} ${H + lh}"><defs><clipPath id="c"><rect width="${W}" height="${H}"/></clipPath></defs>`
|
||||
o += `<rect width="${W}" height="${H}" fill="#f5f2ea"/><g clip-path="url(#c)" stroke-linejoin="round" stroke-linecap="round">`
|
||||
if (S.showBase)
|
||||
if (showBase.value)
|
||||
for (const st of BASE) {
|
||||
const rings = S.base[st.k]
|
||||
const rings = base.value[st.k]
|
||||
if (!rings || !rings.length) continue
|
||||
if (st.t === 'poly')
|
||||
o += `<path d="${d(rings, true)}" fill="${st.fill}" fill-rule="evenodd"${st.stroke ? ` stroke="${st.stroke}" stroke-width="1"` : ''}/>`
|
||||
|
|
@ -58,9 +58,9 @@ function exportSvg() {
|
|||
o += `<path d="${d(rings, false)}" fill="none" stroke="${st.c}" stroke-width="${Math.max(st.min, st.m * ppm).toFixed(1)}"${st.dash ? ` stroke-dasharray="${st.dash.map((x) => x * Math.max(1, ppm / 2)).join(' ')}"` : ''}/>`
|
||||
}
|
||||
for (const key of catOrder()) {
|
||||
if (S.hidden.has(key)) continue
|
||||
if (hidden.value.has(key)) continue
|
||||
const rings: Ring[] = []
|
||||
for (const b of S.buildings) if (b.cat === key) for (const r of b.rings) rings.push(r)
|
||||
for (const b of buildings.value) if (b.cat === key) for (const r of b.rings) rings.push(r)
|
||||
if (rings.length)
|
||||
o += `<path d="${d(rings, true)}" fill="${catColor(key)}" fill-rule="evenodd" stroke="${key === 'res' || key === 'u7' ? '#ffffff88' : '#00000088'}" stroke-width=".5"/>`
|
||||
}
|
||||
|
|
@ -77,12 +77,12 @@ function exportSvg() {
|
|||
download(new Blob([o], { type: 'image/svg+xml' }), 'building-use-map.svg')
|
||||
}
|
||||
|
||||
function exportCsv() {
|
||||
export function exportCsv() {
|
||||
if (!S.loaded) return
|
||||
const q = (s: unknown) => '"' + String(s).replace(/"/g, '""') + '"'
|
||||
let o =
|
||||
'house_no,ruian_use_code,ruian_use,category,flats,floors,built_up_area_m2,completed,lat,lon\n'
|
||||
for (const b of S.buildings) {
|
||||
for (const b of buildings.value) {
|
||||
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2)
|
||||
o +=
|
||||
[
|
||||
|
|
@ -100,10 +100,3 @@ function exportCsv() {
|
|||
}
|
||||
download(new Blob(['' + o], { type: 'text/csv;charset=utf-8' }), 'buildings.csv') // BOM so Excel reads UTF-8
|
||||
}
|
||||
|
||||
export function initExport() {
|
||||
$('expPng').onclick = exportPng
|
||||
$('expSvg').onclick = exportSvg
|
||||
$('expCsv').onclick = exportCsv
|
||||
$('expPrint').onclick = () => window.print()
|
||||
}
|
||||
|
|
|
|||
14
src/i18n.ts
14
src/i18n.ts
|
|
@ -1,3 +1,5 @@
|
|||
import { signal } from '@preact/signals'
|
||||
|
||||
/* ================= i18n ================= */
|
||||
export type Lang = 'en' | 'cs'
|
||||
|
||||
|
|
@ -203,9 +205,10 @@ function detectLang(): Lang {
|
|||
? 'cs'
|
||||
: 'en'
|
||||
}
|
||||
export let lang: Lang = detectLang()
|
||||
/** Current UI language. Components that call t() re-render when it changes. */
|
||||
export const lang = signal<Lang>(detectLang())
|
||||
export function setLang(l: Lang) {
|
||||
lang = l
|
||||
lang.value = l
|
||||
try {
|
||||
localStorage.setItem('bum-lang', l)
|
||||
} catch {}
|
||||
|
|
@ -213,13 +216,14 @@ export function setLang(l: Lang) {
|
|||
|
||||
/** Translate a known message key; function-valued messages take typed arguments. */
|
||||
export function t<K extends MsgKey>(k: K, ...a: Args<K>): string {
|
||||
const v = L[lang][k] !== undefined ? L[lang][k] : L.en[k]
|
||||
const v = L[lang.value][k] !== undefined ? L[lang.value][k] : L.en[k]
|
||||
return typeof v === 'function' ? (v as (...x: unknown[]) => string)(...a) : (v as string)
|
||||
}
|
||||
/** Translate a key built at runtime (e.g. from data-i18n); falls back to the key itself. */
|
||||
export function tKey(k: string): string {
|
||||
const get = (d: Dict) => (d as unknown as Record<string, unknown>)[k]
|
||||
const v = get(L[lang]) !== undefined ? get(L[lang]) : get(L.en)
|
||||
const v = get(L[lang.value]) !== undefined ? get(L[lang.value]) : get(L.en)
|
||||
return typeof v === 'function' ? v() : v === undefined ? k : String(v)
|
||||
}
|
||||
export const ruianUseName = (u: number | string): string => L[lang].use[u] || L.en.use[u] || ''
|
||||
export const ruianUseName = (u: number | string): string =>
|
||||
L[lang.value].use[u] || L.en.use[u] || ''
|
||||
|
|
|
|||
|
|
@ -5,84 +5,13 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Building-use map – Czechia (RÚIAN)</title>
|
||||
<!--
|
||||
Vite entry page. `bun run dev` for development, `bun run build` writes the minified app to dist/ (serve it as static files).
|
||||
Vite entry page; the UI is rendered by Preact (src/components). `bun run dev` for development, `bun run build` writes the minified app to dist/ (serve it as static files).
|
||||
Data: live queries to the public ČÚZK ArcGIS services (RÚIAN buildings, ZABAGED roads/water/green), © ČÚZK.
|
||||
A small built-in example area is used as a fallback when the live service cannot be reached.
|
||||
-->
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<aside>
|
||||
<div class="head">
|
||||
<h1>
|
||||
<span data-i18n="title">Building-use map</span> <small data-i18n="subtitle"></small>
|
||||
</h1>
|
||||
<select id="lang" aria-label="Language">
|
||||
<option value="cs">CS</option>
|
||||
<option value="en">EN</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label for="loc" data-i18n="locLabel"></label>
|
||||
<input
|
||||
id="loc"
|
||||
type="text"
|
||||
value="https://mapy.com/en/turisticka?l=0&x=14.9686780&y=50.8171633&z=16.762"
|
||||
spellcheck="false"
|
||||
/>
|
||||
|
||||
<label for="radius"><span data-i18n="radius"></span> <output id="rv">300 m</output></label>
|
||||
<input id="radius" type="range" min="100" max="700" step="50" value="300" />
|
||||
|
||||
<div class="row"><button id="load" data-i18n="load"></button></div>
|
||||
<div id="status"></div>
|
||||
|
||||
<h2>
|
||||
<span data-i18n="layers"></span>
|
||||
<span id="total" style="text-transform: none; letter-spacing: 0"></span>
|
||||
</h2>
|
||||
<div id="legend"></div>
|
||||
|
||||
<h2 data-i18n="display"></h2>
|
||||
<label for="colormode" data-i18n="colorMode"></label>
|
||||
<select id="colormode">
|
||||
<option value="simple" data-i18n="modeSimple"></option>
|
||||
<option value="detailed" data-i18n="modeDetailed"></option>
|
||||
</select>
|
||||
<label for="mixrule" data-i18n="mixLabel"></label>
|
||||
<select id="mixrule">
|
||||
<option value="1" data-i18n="mix1"></option>
|
||||
<option value="2" data-i18n="mix2"></option>
|
||||
<option value="0" data-i18n="mix0"></option>
|
||||
</select>
|
||||
<label class="chk"
|
||||
><input type="checkbox" id="optBase" checked /> <span data-i18n="optBase"></span
|
||||
></label>
|
||||
<label class="chk"
|
||||
><input type="checkbox" id="optNums" checked /> <span data-i18n="optNums"></span
|
||||
></label>
|
||||
|
||||
<h2 data-i18n="export"></h2>
|
||||
<div class="exp">
|
||||
<button id="expPng" class="ghost">PNG</button>
|
||||
<button id="expSvg" class="ghost">SVG</button>
|
||||
<button id="expCsv" class="ghost" data-i18n="csv"></button>
|
||||
<button id="expPrint" class="ghost" data-i18n="print"></button>
|
||||
</div>
|
||||
|
||||
<p class="note" id="note"></p>
|
||||
</aside>
|
||||
<main id="stage">
|
||||
<canvas id="cv"></canvas>
|
||||
<div class="zoom">
|
||||
<button id="zin">+</button><button id="zout">-</button
|
||||
><button id="zfit" style="font-size: 13px">⤢</button>
|
||||
</div>
|
||||
<div id="tip"></div>
|
||||
<div id="info"></div>
|
||||
</main>
|
||||
</div>
|
||||
<script type="module" src="./main.ts"></script>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="./main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { catLabel } from './categories'
|
||||
import { m2ll } from './geo'
|
||||
import { t, ruianUseName } from './i18n'
|
||||
import { buildings } from './categories'
|
||||
import { draw, fitView } from './render'
|
||||
import { $, cv, S, vp } from './state'
|
||||
import { hidden, hover, S, sel, vp } from './state'
|
||||
import type { Building, Point, Ring } from './types'
|
||||
|
||||
/* ================= hit testing ================= */
|
||||
|
|
@ -21,10 +19,12 @@ function pick(px: number, py: number): Building | null {
|
|||
x = (px - vp.W / 2) / v.s + v.cx,
|
||||
y = (vp.H / 2 - py) / v.s + v.cy,
|
||||
pad = 2 / v.s
|
||||
for (let i = S.buildings.length - 1; i >= 0; i--) {
|
||||
const b = S.buildings[i]
|
||||
const list = buildings.value,
|
||||
hid = hidden.value
|
||||
for (let i = list.length - 1; i >= 0; i--) {
|
||||
const b = list[i]
|
||||
if (
|
||||
S.hidden.has(b.cat) ||
|
||||
hid.has(b.cat) ||
|
||||
x < b.bb[0] - pad ||
|
||||
x > b.bb[2] + pad ||
|
||||
y < b.bb[1] - pad ||
|
||||
|
|
@ -38,35 +38,8 @@ function pick(px: number, py: number): Building | null {
|
|||
return null
|
||||
}
|
||||
|
||||
/* ================= info panel ================= */
|
||||
const desc = (b: Building) => `${b.cp ? t('hn', b.cp) : t('nohn')} – ${catLabel(b.cat)}`
|
||||
|
||||
export function showInfo(b: Building | null) {
|
||||
const el = $('info')
|
||||
if (!b) {
|
||||
el.style.display = 'none'
|
||||
return
|
||||
}
|
||||
const ll = m2ll((b.bb[0] + b.bb[2]) / 2, (b.bb[1] + b.bb[3]) / 2),
|
||||
dash = '—'
|
||||
el.innerHTML = `<span class="x" title="${t('close')}">✕</span><b>${b.cp ? t('hn', b.cp) : t('nohn')}</b>
|
||||
<dl><dt>${t('i_cat')}</dt><dd>${catLabel(b.cat)}</dd>
|
||||
<dt>${t('i_use')}</dt><dd>${ruianUseName(b.use) || dash} (${b.use || '?'})</dd>
|
||||
<dt>${t('i_flats')}</dt><dd>${b.flats == null ? dash : b.flats}</dd>
|
||||
<dt>${t('i_floors')}</dt><dd>${b.floors == null ? dash : b.floors}</dd>
|
||||
<dt>${t('i_area')}</dt><dd>${b.area == null ? dash : b.area + ' m²'}</dd>
|
||||
<dt>${t('i_done')}</dt><dd>${b.year == null ? dash : b.year}</dd>
|
||||
<dt>${t('i_pos')}</dt><dd>${ll[1].toFixed(6)}, ${ll[0].toFixed(6)}</dd></dl>`
|
||||
el.style.display = 'block'
|
||||
el.querySelector<HTMLElement>('.x')!.onclick = () => {
|
||||
S.sel = null
|
||||
el.style.display = 'none'
|
||||
draw()
|
||||
}
|
||||
}
|
||||
|
||||
/* ================= pan / zoom ================= */
|
||||
function zoomAt(px: number, py: number, f: number) {
|
||||
export function zoomAt(px: number, py: number, f: number) {
|
||||
const v = S.view,
|
||||
ns = Math.min(Math.max(v.s * f, 0.02), 40)
|
||||
const x = (px - vp.W / 2) / v.s + v.cx,
|
||||
|
|
@ -76,25 +49,32 @@ function zoomAt(px: number, py: number, f: number) {
|
|||
v.cy = y + (py - vp.H / 2) / ns
|
||||
draw()
|
||||
}
|
||||
export const zoomBy = (f: number) => zoomAt(vp.W / 2, vp.H / 2, f)
|
||||
export function zoomFit() {
|
||||
fitView()
|
||||
draw()
|
||||
}
|
||||
|
||||
export function resize() {
|
||||
const r = $('stage').getBoundingClientRect()
|
||||
/** Match the canvas backing store to the stage size and redraw. */
|
||||
export function resize(stage: HTMLElement, cv: HTMLCanvasElement) {
|
||||
const r = stage.getBoundingClientRect()
|
||||
vp.DPR = Math.min(window.devicePixelRatio || 1, 3)
|
||||
const oldW = vp.W
|
||||
vp.W = Math.max(1, Math.floor(r.width))
|
||||
vp.H = Math.max(1, Math.floor(r.height))
|
||||
cv.width = vp.W * vp.DPR
|
||||
cv.height = vp.H * vp.DPR
|
||||
if (S.loaded && !oldW) fitView()
|
||||
if (S.loaded && !oldW) fitView() // data arrived before the canvas had a size
|
||||
draw()
|
||||
}
|
||||
|
||||
export function initInteraction() {
|
||||
/** Pointer/wheel handling on the map canvas. Returns a cleanup function. */
|
||||
export function attachPointer(cv: HTMLCanvasElement): () => void {
|
||||
const ptrs = new Map<number, Point>()
|
||||
let dragMoved = 0,
|
||||
lastPinch = 0
|
||||
const tip = $('tip')
|
||||
cv.addEventListener('pointerdown', (e) => {
|
||||
|
||||
const down = (e: PointerEvent) => {
|
||||
cv.setPointerCapture(e.pointerId)
|
||||
ptrs.set(e.pointerId, [e.offsetX, e.offsetY])
|
||||
dragMoved = 0
|
||||
|
|
@ -103,8 +83,8 @@ export function initInteraction() {
|
|||
const [a, b] = [...ptrs.values()]
|
||||
lastPinch = Math.hypot(a[0] - b[0], a[1] - b[1])
|
||||
}
|
||||
})
|
||||
cv.addEventListener('pointermove', (e) => {
|
||||
}
|
||||
const move = (e: PointerEvent) => {
|
||||
const prev = ptrs.get(e.pointerId)
|
||||
if (prev) {
|
||||
ptrs.set(e.pointerId, [e.offsetX, e.offsetY])
|
||||
|
|
@ -115,7 +95,7 @@ export function initInteraction() {
|
|||
S.view.cx -= dx / S.view.s
|
||||
S.view.cy += dy / S.view.s
|
||||
draw()
|
||||
tip.style.display = 'none'
|
||||
hover.value = null
|
||||
} else if (ptrs.size === 2) {
|
||||
const [a, b] = [...ptrs.values()],
|
||||
d = Math.hypot(a[0] - b[0], a[1] - b[1])
|
||||
|
|
@ -126,43 +106,34 @@ export function initInteraction() {
|
|||
return
|
||||
}
|
||||
const b = pick(e.offsetX, e.offsetY)
|
||||
if (b) {
|
||||
tip.textContent = desc(b)
|
||||
tip.style.left = e.offsetX + 14 + 'px'
|
||||
tip.style.top = e.offsetY + 14 + 'px'
|
||||
tip.style.display = 'block'
|
||||
} else tip.style.display = 'none'
|
||||
})
|
||||
const endPtr = (e: PointerEvent) => {
|
||||
hover.value = b ? { b, x: e.offsetX, y: e.offsetY } : null
|
||||
}
|
||||
const end = (e: PointerEvent) => {
|
||||
const had = ptrs.delete(e.pointerId)
|
||||
cv.classList.remove('drag')
|
||||
lastPinch = 0
|
||||
if (had && dragMoved < 5 && e.type === 'pointerup') {
|
||||
S.sel = pick(e.offsetX, e.offsetY)
|
||||
showInfo(S.sel)
|
||||
draw()
|
||||
if (had && dragMoved < 5 && e.type === 'pointerup') sel.value = pick(e.offsetX, e.offsetY)
|
||||
}
|
||||
const leave = () => {
|
||||
hover.value = null
|
||||
}
|
||||
cv.addEventListener('pointerup', endPtr)
|
||||
cv.addEventListener('pointercancel', endPtr)
|
||||
cv.addEventListener('pointerleave', () => {
|
||||
tip.style.display = 'none'
|
||||
})
|
||||
cv.addEventListener(
|
||||
'wheel',
|
||||
(e) => {
|
||||
const wheel = (e: WheelEvent) => {
|
||||
e.preventDefault()
|
||||
zoomAt(e.offsetX, e.offsetY, Math.exp(-e.deltaY * 0.0015))
|
||||
},
|
||||
{ passive: false },
|
||||
)
|
||||
|
||||
$('zin').onclick = () => zoomAt(vp.W / 2, vp.H / 2, 1.5)
|
||||
$('zout').onclick = () => zoomAt(vp.W / 2, vp.H / 2, 1 / 1.5)
|
||||
$('zfit').onclick = () => {
|
||||
fitView()
|
||||
draw()
|
||||
}
|
||||
|
||||
new ResizeObserver(resize).observe($('stage'))
|
||||
cv.addEventListener('pointerdown', down)
|
||||
cv.addEventListener('pointermove', move)
|
||||
cv.addEventListener('pointerup', end)
|
||||
cv.addEventListener('pointercancel', end)
|
||||
cv.addEventListener('pointerleave', leave)
|
||||
cv.addEventListener('wheel', wheel, { passive: false })
|
||||
return () => {
|
||||
cv.removeEventListener('pointerdown', down)
|
||||
cv.removeEventListener('pointermove', move)
|
||||
cv.removeEventListener('pointerup', end)
|
||||
cv.removeEventListener('pointercancel', end)
|
||||
cv.removeEventListener('pointerleave', leave)
|
||||
cv.removeEventListener('wheel', wheel)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
src/main.ts
20
src/main.ts
|
|
@ -1,20 +0,0 @@
|
|||
import { applyData, applyLang, initControls, liveLoad, setStatus } from './controls'
|
||||
import { initExport } from './export'
|
||||
import { parseLoc } from './geo'
|
||||
import { t } from './i18n'
|
||||
import { initInteraction, resize } from './interaction'
|
||||
import { loadSample } from './sample-data'
|
||||
import { $ } from './state'
|
||||
|
||||
/* ================= start ================= */
|
||||
initInteraction()
|
||||
initControls()
|
||||
initExport()
|
||||
applyLang()
|
||||
resize()
|
||||
|
||||
// Show the built-in example immediately, then replace it with live data for the default location.
|
||||
applyData(loadSample(), 14.968678, 50.8171633)
|
||||
setStatus(() => t('st_init'))
|
||||
const p = parseLoc($<HTMLInputElement>('loc').value)
|
||||
if (p) liveLoad(p, true)
|
||||
16
src/main.tsx
Normal file
16
src/main.tsx
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { render } from 'preact'
|
||||
import { applyData, liveLoad, setStatus } from './actions'
|
||||
import { App } from './components/App'
|
||||
import { parseLoc } from './geo'
|
||||
import { t } from './i18n'
|
||||
import { loadSample } from './sample-data'
|
||||
import { DEFAULT_LOC } from './state'
|
||||
import './style.css'
|
||||
|
||||
render(<App />, document.getElementById('root')!)
|
||||
|
||||
// Show the built-in example immediately, then replace it with live data for the default location.
|
||||
applyData(loadSample(), 14.968678, 50.8171633)
|
||||
setStatus(() => t('st_init'))
|
||||
const p = parseLoc(DEFAULT_LOC)
|
||||
if (p) liveLoad(p, true)
|
||||
|
|
@ -1,17 +1,18 @@
|
|||
import { BASE } from './basemap'
|
||||
import { catColor, catLabel, catList, catOrder, isDark, SIMPLE_NUMS } from './categories'
|
||||
import { buildings, catColor, catLabel, catList, catOrder, isDark, SIMPLE_NUMS } from './categories'
|
||||
import { t } from './i18n'
|
||||
import { ctx0, S, vp } from './state'
|
||||
import { base, hidden, rawBuildings, S, sel, showBase, showNums, vp } from './state'
|
||||
import type { Ring, View } from './types'
|
||||
|
||||
/* ================= view ================= */
|
||||
export function fitView() {
|
||||
if (!S.buildings.length) return
|
||||
const list = rawBuildings.value // bounding boxes do not depend on classification
|
||||
if (!list.length) return
|
||||
let x0 = 1e18,
|
||||
y0 = 1e18,
|
||||
x1 = -1e18,
|
||||
y1 = -1e18
|
||||
for (const b of S.buildings) {
|
||||
for (const b of list) {
|
||||
x0 = Math.min(x0, b.bb[0])
|
||||
y0 = Math.min(y0, b.bb[1])
|
||||
x1 = Math.max(x1, b.bb[2])
|
||||
|
|
@ -64,9 +65,9 @@ export function drawScene(
|
|||
}
|
||||
ctx.lineJoin = 'round'
|
||||
ctx.lineCap = 'round'
|
||||
if (S.showBase) {
|
||||
if (showBase.value) {
|
||||
for (const st of BASE) {
|
||||
const rings = S.base[st.k]
|
||||
const rings = base.value[st.k]
|
||||
if (!rings || !rings.length) continue
|
||||
if (st.t === 'poly') {
|
||||
path(rings, true)
|
||||
|
|
@ -88,9 +89,9 @@ export function drawScene(
|
|||
}
|
||||
}
|
||||
for (const key of catOrder()) {
|
||||
if (S.hidden.has(key)) continue
|
||||
if (hidden.value.has(key)) continue
|
||||
const rings: Ring[] = []
|
||||
for (const b of S.buildings) if (b.cat === key) for (const rg of b.rings) rings.push(rg)
|
||||
for (const b of buildings.value) if (b.cat === key) for (const rg of b.rings) rings.push(rg)
|
||||
if (!rings.length) continue
|
||||
path(rings, true)
|
||||
ctx.fillStyle = catColor(key)
|
||||
|
|
@ -99,13 +100,13 @@ export function drawScene(
|
|||
ctx.lineWidth = 0.5
|
||||
ctx.stroke()
|
||||
}
|
||||
if (S.showNums && ppm >= 1.5) {
|
||||
if (showNums.value && ppm >= 1.5) {
|
||||
const all = ppm >= 3.2
|
||||
ctx.textAlign = 'center'
|
||||
ctx.textBaseline = 'middle'
|
||||
ctx.font = `${Math.min(12, Math.max(8, ppm * 2.2))}px system-ui,sans-serif`
|
||||
for (const b of S.buildings) {
|
||||
if (!b.cp || S.hidden.has(b.cat) || !(all || SIMPLE_NUMS[b.sc])) continue
|
||||
for (const b of buildings.value) {
|
||||
if (!b.cp || hidden.value.has(b.cat) || !(all || SIMPLE_NUMS[b.sc])) continue
|
||||
const cx = sx((b.bb[0] + b.bb[2]) / 2),
|
||||
cy = sy((b.bb[1] + b.bb[3]) / 2)
|
||||
if (cx < -20 || cy < -20 || cx > W + 20 || cy > H + 20) continue
|
||||
|
|
@ -120,8 +121,8 @@ export function drawScene(
|
|||
ctx.fillText(txt, cx, cy)
|
||||
}
|
||||
}
|
||||
if (opts.sel && S.sel) {
|
||||
path(S.sel.rings, true)
|
||||
if (opts.sel && sel.value) {
|
||||
path(sel.value.rings, true)
|
||||
ctx.strokeStyle = '#ffcc00'
|
||||
ctx.lineWidth = 3
|
||||
ctx.stroke()
|
||||
|
|
@ -168,7 +169,7 @@ interface LegendEntry {
|
|||
|
||||
export function counts(): Record<string, number> {
|
||||
const c: Record<string, number> = {}
|
||||
for (const b of S.buildings) c[b.cat] = (c[b.cat] || 0) + 1
|
||||
for (const b of buildings.value) c[b.cat] = (c[b.cat] || 0) + 1
|
||||
return c
|
||||
}
|
||||
function legendEntries(): LegendEntry[] {
|
||||
|
|
@ -176,7 +177,7 @@ function legendEntries(): LegendEntry[] {
|
|||
e: LegendEntry[] = []
|
||||
for (const k of catList())
|
||||
if (cnt[k]) e.push({ color: catColor(k), label: `${catLabel(k)} (${cnt[k]})` })
|
||||
if (S.showBase)
|
||||
if (showBase.value)
|
||||
e.push(
|
||||
{ color: '#a8cfe8', label: t('b_water') },
|
||||
{ color: '#cfe4bd', label: t('b_green') },
|
||||
|
|
@ -219,5 +220,5 @@ export function drawLegend(ctx: CanvasRenderingContext2D, y0: number, W: number,
|
|||
|
||||
/** Redraw the on-screen map. */
|
||||
export function draw() {
|
||||
if (vp.W) drawScene(ctx0, vp.W, vp.H, S.view, vp.DPR, { sel: true })
|
||||
if (vp.W && vp.ctx) drawScene(vp.ctx, vp.W, vp.H, S.view, vp.DPR, { sel: true })
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
import { catColor, catLabel, catList } from './categories'
|
||||
import { t } from './i18n'
|
||||
import { counts, draw } from './render'
|
||||
import { $, S } from './state'
|
||||
|
||||
/* ================= sidebar legend ================= */
|
||||
export function buildLegend() {
|
||||
const box = $('legend')
|
||||
box.innerHTML = ''
|
||||
for (const key of catList()) {
|
||||
const row = document.createElement('label')
|
||||
row.className = 'leg'
|
||||
row.dataset.key = key
|
||||
row.innerHTML =
|
||||
'<input type="checkbox"><span class="sw"></span><span class="lbl"></span><span class="n">0</span>'
|
||||
const inp = row.querySelector('input')!
|
||||
inp.checked = !S.hidden.has(key)
|
||||
row.classList.toggle('off', S.hidden.has(key))
|
||||
row.querySelector<HTMLElement>('.sw')!.style.background = catColor(key)
|
||||
row.querySelector('.lbl')!.textContent = catLabel(key)
|
||||
inp.addEventListener('change', () => {
|
||||
if (inp.checked) S.hidden.delete(key)
|
||||
else S.hidden.add(key)
|
||||
row.classList.toggle('off', !inp.checked)
|
||||
draw()
|
||||
})
|
||||
box.appendChild(row)
|
||||
}
|
||||
updateCounts()
|
||||
}
|
||||
|
||||
export function updateCounts() {
|
||||
const cnt = counts()
|
||||
document.querySelectorAll<HTMLElement>('#legend .leg').forEach((r) => {
|
||||
const n = cnt[r.dataset.key!] || 0
|
||||
r.querySelector('.n')!.textContent = String(n)
|
||||
r.style.display = n ? '' : 'none'
|
||||
})
|
||||
$('total').textContent = S.buildings.length ? t('nBuildings', S.buildings.length) : ''
|
||||
}
|
||||
52
src/state.ts
52
src/state.ts
|
|
@ -1,31 +1,43 @@
|
|||
import { signal } from '@preact/signals'
|
||||
import type { BaseData, Building, Mode, View } from './types'
|
||||
|
||||
/* ================= state ================= */
|
||||
export interface Status {
|
||||
fn: () => string
|
||||
cls?: string
|
||||
}
|
||||
/* ================= reactive state =================
|
||||
* Everything the UI or the map drawing depends on is a signal: components re-render and the
|
||||
* map redraws (see MapView) when they change. Pan/zoom state is plain data and redraws directly.
|
||||
*/
|
||||
|
||||
/** Buildings as loaded, before classification. */
|
||||
export const rawBuildings = signal<Building[]>([])
|
||||
export const base = signal<BaseData>({})
|
||||
export const mode = signal<Mode>('simple')
|
||||
/** Minimum flats for a non-residential building to count as mixed use (0 = off). */
|
||||
export const mixMin = signal(1)
|
||||
// The classified list is `buildings` in categories.ts.
|
||||
|
||||
export const hidden = signal<ReadonlySet<string>>(new Set())
|
||||
export const showBase = signal(true)
|
||||
export const showNums = signal(true)
|
||||
export const sel = signal<Building | null>(null)
|
||||
/** Building under the pointer and where to show the tooltip. */
|
||||
export const hover = signal<{ b: Building; x: number; y: number } | null>(null)
|
||||
|
||||
export const radius = signal(300)
|
||||
export const busy = signal(false)
|
||||
export interface Status {
|
||||
fn: () => string // a function so it is re-rendered in the current language
|
||||
cls?: 'ok' | 'err'
|
||||
}
|
||||
export const status = signal<Status | null>(null)
|
||||
|
||||
/* ================= non-reactive view state ================= */
|
||||
export const S = {
|
||||
buildings: [] as Building[],
|
||||
base: {} as BaseData,
|
||||
K: 0.63, // cos(latitude): Mercator metres → true metres
|
||||
center: [14.9687, 50.8172] as [number, number],
|
||||
view: { cx: 0, cy: 0, s: 1 } as View,
|
||||
hidden: new Set<string>(),
|
||||
mixMin: 1,
|
||||
mode: 'simple' as Mode,
|
||||
showBase: true,
|
||||
showNums: true,
|
||||
sel: null as Building | null,
|
||||
loaded: false,
|
||||
status: null as Status | null, // stored as a function so it can be re-rendered on language change
|
||||
}
|
||||
|
||||
/** Canvas size in CSS pixels and the device pixel ratio; updated by resize(). */
|
||||
export const vp = { W: 0, H: 0, DPR: 1 }
|
||||
/** Canvas size in CSS pixels, device pixel ratio and 2D context; set by MapView. */
|
||||
export const vp = { W: 0, H: 0, DPR: 1, ctx: null as CanvasRenderingContext2D | null }
|
||||
|
||||
export const $ = <T extends HTMLElement = HTMLElement>(id: string) =>
|
||||
document.getElementById(id) as T
|
||||
export const cv = $<HTMLCanvasElement>('cv')
|
||||
export const ctx0 = cv.getContext('2d')!
|
||||
export const DEFAULT_LOC = 'https://mapy.com/en/turisticka?l=0&x=14.9686780&y=50.8171633&z=16.762'
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@
|
|||
box-sizing: border-box;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
body,
|
||||
#root {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
|
@ -199,7 +200,6 @@ canvas.drag {
|
|||
padding: 5px 8px;
|
||||
border-radius: 5px;
|
||||
font-size: 12px;
|
||||
display: none;
|
||||
max-width: 260px;
|
||||
z-index: 3;
|
||||
}
|
||||
|
|
@ -213,7 +213,6 @@ canvas.drag {
|
|||
padding: 10px 12px;
|
||||
font-size: 13px;
|
||||
max-width: 300px;
|
||||
display: none;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
|
||||
z-index: 3;
|
||||
}
|
||||
|
|
|
|||
1
src/vite-env.d.ts
vendored
Normal file
1
src/vite-env.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/// <reference types="vite/client" />
|
||||
|
|
@ -13,7 +13,9 @@
|
|||
"noEmit": true,
|
||||
"isolatedModules": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"skipLibCheck": true
|
||||
"skipLibCheck": true,
|
||||
"jsx": "react-jsx",
|
||||
"jsxImportSource": "preact"
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
import preact from '@preact/preset-vite'
|
||||
import { defineConfig } from 'vite'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [preact()],
|
||||
root: 'src',
|
||||
// relative asset URLs so dist/ works from any sub-path
|
||||
base: './',
|
||||
|
|
|
|||
Loading…
Reference in a new issue