From a92ae02454aa09bb17874b6b9182e22e0c00e930 Mon Sep 17 00:00:00 2001 From: lqdev Date: Tue, 20 Feb 2024 23:30:36 +0100 Subject: [PATCH] make tairu work better with noscript --- Cargo.lock | 261 ++++++++++++++++++ content/programming/blog/tairu.tree | 25 +- crates/treehouse/Cargo.toml | 3 +- crates/treehouse/src/cli/generate.rs | 4 +- crates/treehouse/src/config.rs | 35 ++- crates/treehouse/src/html/markdown.rs | 50 +++- crates/treehouse/src/html/tree.rs | 9 +- static/css/main.css | 13 +- static/js/components/literate-programming.js | 23 +- .../components/tairu/cardinal-directions.js | 0 static/js/components/tairu/framework.js | 87 ------ static/js/components/tairu/proto.js | 76 ----- .../js/components/tairu/tilemap-registry.js | 47 ---- static/js/usability.js | 9 + ...520PJNPJ75M793R5G-noscript-placeholder.png | Bin 0 -> 3690 bytes ...FMK719KSE16SG3F7B-noscript-placeholder.png | Bin 0 -> 3826 bytes ...57FNMN3E79FYF8CMG-noscript-placeholder.png | Bin 0 -> 4184 bytes ...QXYSAT5N6P241DG3C-noscript-placeholder.png | Bin 0 -> 4186 bytes ...WR75D85DGHCB34K8E-noscript-placeholder.png | Bin 0 -> 1627 bytes ...PE6JT5ZZFEN9S635W-noscript-placeholder.png | Bin 0 -> 2520 bytes ...RXEQ850598GFBJN0B-noscript-placeholder.png | Bin 0 -> 4749 bytes ...NAEJGCT2WDMQJHK14-noscript-placeholder.png | Bin 0 -> 30242 bytes 22 files changed, 404 insertions(+), 238 deletions(-) delete mode 100644 static/js/components/tairu/cardinal-directions.js delete mode 100644 static/js/components/tairu/framework.js delete mode 100644 static/js/components/tairu/proto.js delete mode 100644 static/js/components/tairu/tilemap-registry.js create mode 100644 static/pic/01HQ47ZX7520PJNPJ75M793R5G-noscript-placeholder.png create mode 100644 static/pic/01HQ49TJZFMK719KSE16SG3F7B-noscript-placeholder.png create mode 100644 static/pic/01HQ49X8Z57FNMN3E79FYF8CMG-noscript-placeholder.png create mode 100644 static/pic/01HQ49YDPQXYSAT5N6P241DG3C-noscript-placeholder.png create mode 100644 static/pic/01HQ49Z8JWR75D85DGHCB34K8E-noscript-placeholder.png create mode 100644 static/pic/01HQ4A01MPE6JT5ZZFEN9S635W-noscript-placeholder.png create mode 100644 static/pic/01HQ4A11RRXEQ850598GFBJN0B-noscript-placeholder.png create mode 100644 static/pic/01HQ4A45WNAEJGCT2WDMQJHK14-noscript-placeholder.png diff --git a/Cargo.lock b/Cargo.lock index c6f8a27..86d9432 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,6 +168,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + [[package]] name = "bitflags" version = "1.3.2" @@ -189,6 +195,18 @@ dependencies = [ "generic-array", ] +[[package]] +name = "bytemuck" +version = "1.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "bytes" version = "1.5.0" @@ -261,6 +279,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.0" @@ -285,6 +309,46 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -305,6 +369,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "either" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" + [[package]] name = "env_logger" version = "0.10.0" @@ -345,6 +415,50 @@ dependencies = [ "libc", ] +[[package]] +name = "exr" +version = "1.72.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "887d93f60543e9a9362ef8a21beedd0a833c5d9610e18c67abe15a5963dcb1a4" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "fdeflate" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f9bfee30e4dedf0ab8b422f03af778d9612b63f502710fc500a334ebe2de645" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "spin", +] + [[package]] name = "fnv" version = "1.0.7" @@ -420,6 +534,16 @@ dependencies = [ "wasi", ] +[[package]] +name = "gif" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.27.3" @@ -445,6 +569,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "handlebars" version = "4.3.7" @@ -570,6 +704,24 @@ dependencies = [ "tokio", ] +[[package]] +name = "image" +version = "0.24.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034bbe799d1909622a74d1193aa50147769440040ff36cb2baa947609b0a4e23" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "exr", + "gif", + "jpeg-decoder", + "num-traits", + "png", + "qoi", + "tiff", +] + [[package]] name = "indexmap" version = "2.0.0" @@ -597,6 +749,21 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "jpeg-decoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" +dependencies = [ + "rayon", +] + +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + [[package]] name = "libc" version = "0.2.153" @@ -660,6 +827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", + "simd-adler32", ] [[package]] @@ -673,6 +841,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "num-traits" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +dependencies = [ + "autocfg", +] + [[package]] name = "num_cpus" version = "1.16.0" @@ -803,6 +980,19 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "png" +version = "0.17.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e4b0d3d1312775e782c86c91a111aa1f910cbb65e1337f9975b5f9a554b5e1" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -829,6 +1019,15 @@ dependencies = [ "unicase", ] +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quote" version = "1.0.33" @@ -868,6 +1067,26 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "redox_syscall" version = "0.3.5" @@ -1034,6 +1253,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + [[package]] name = "slab" version = "0.4.9" @@ -1059,6 +1284,15 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "strsim" version = "0.10.0" @@ -1111,6 +1345,17 @@ dependencies = [ "syn", ] +[[package]] +name = "tiff" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "tokio" version = "1.36.0" @@ -1277,6 +1522,7 @@ dependencies = [ "env_logger", "handlebars", "http-body", + "image", "log", "pulldown-cmark", "rand", @@ -1368,6 +1614,12 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "weezl" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" + [[package]] name = "winapi" version = "0.3.9" @@ -1473,3 +1725,12 @@ checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" dependencies = [ "memchr", ] + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] diff --git a/content/programming/blog/tairu.tree b/content/programming/blog/tairu.tree index 44102c5..3432bc8 100644 --- a/content/programming/blog/tairu.tree +++ b/content/programming/blog/tairu.tree @@ -29,6 +29,13 @@ styles = ["post/tairu.css"] % id = "01HQ162WWAMCPC5M88QAXHX4BT" - so to help us learn, I made a little tile editor so that we can experiment with rendering tiles! have a look: + + ```javascript tairu import { Tilemap } from "tairu/tilemap.js"; import { TileEditor } from "tairu/editor.js"; @@ -47,7 +54,7 @@ styles = ["post/tairu.css"] }); ``` - ```output tairu + ```output tairu 01HQ47ZX7520PJNPJ75M793R5G ``` % id = "01HQ162WWAC3FN565QE3JAB87D" @@ -58,6 +65,8 @@ styles = ["post/tairu.css"] console.log(tilemapSquare.at(3, 1)); ``` ```output tairu + 0 + 1 ``` [`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array @@ -189,7 +198,7 @@ styles = ["post/tairu.css"] borderWidth: 4, }); ``` - ```output tairu + ```output tairu 01HQ49TJZFMK719KSE16SG3F7B ``` % id = "01HQ162WWAAEKW1ECV5G3ZEY47" @@ -407,7 +416,7 @@ styles = ["post/tairu.css"] tilesets: [heavyMetalTileset], }); ``` - ```output tairu + ```output tairu 01HQ49X8Z57FNMN3E79FYF8CMG ``` % id = "01HQ162WWA03JAGJYCT0DRZP24" @@ -429,7 +438,7 @@ styles = ["post/tairu.css"] tilesets: [heavyMetalTileset], }); ``` - ```output tairu + ```output tairu 01HQ49YDPQXYSAT5N6P241DG3C ``` % id = "01HQ162WWAB0AYSPGB4AEVT03Z" @@ -455,7 +464,7 @@ styles = ["post/tairu.css"] tilesets: [heavyMetalTileset], }); ``` - ```output tairu + ```output tairu 01HQ49Z8JWR75D85DGHCB34K8E ``` % id = "01HQ1K39AS4VDW7DVTAGQ03WFM" @@ -550,7 +559,7 @@ styles = ["post/tairu.css"] tilesets: [heavyMetalTileset], }); ``` - ```output tairu + ```output tairu 01HQ4A01MPE6JT5ZZFEN9S635W ``` % id = "01HQ1K39AS7CRBZ67N1VVHCVME" @@ -879,7 +888,7 @@ styles = ["post/tairu.css"] tilesets: [heavyMetalTileset47], }); ``` - ```output tairu + ```output tairu 01HQ4A11RRXEQ850598GFBJN0B ``` % id = "01HQ1M84GSCXTPGVPXY840WCQ6" @@ -907,7 +916,7 @@ new TilesetTileEditor({ tilesets: [heavyMetalTileset47], }); ``` -```output tairu +```output tairu 01HQ4A45WNAEJGCT2WDMQJHK14 ``` :nap: