diff options
| -rw-r--r-- | Cargo.lock | 577 | ||||
| -rw-r--r-- | Cargo.toml | 7 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/Cargo.toml | 14 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/buffer.rs | 42 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/entity.rs | 2 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/input.rs | 47 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/lib.rs | 29 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/process.rs | 1 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/random.rs | 1 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/scene.rs | 2 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/script.rs | 4 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/state.rs | 2 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/storage.rs | 10 | ||||
| -rw-r--r-- | platforms/tortuise-script-compiled/src/time.rs | 4 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/Cargo.toml | 2 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/src/buffer.rs | 46 | ||||
| -rw-r--r-- | platforms/tortuise-script-wasm/src/storage.rs | 4 |
17 files changed, 324 insertions, 470 deletions
@@ -9,15 +9,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" [[package]] -name = "android_system_properties" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" -dependencies = [ - "libc", -] - -[[package]] name = "anyhow" version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -143,15 +134,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] -name = "atomic-polyfill" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" -dependencies = [ - "critical-section", -] - -[[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -174,9 +156,9 @@ dependencies = [ [[package]] name = "bitflags" -version = "2.13.1" +version = "2.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" [[package]] name = "blocking" @@ -193,9 +175,9 @@ dependencies = [ [[package]] name = "bpaf" -version = "0.9.27" +version = "0.9.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c670d65eea33846872d5ccf668c00a94c5c67dbdcc0289ea1c362671ce1ddb82" +checksum = "597e81e56404b7a3e26ef7b449f82a4b7a661ae76c3cac692b42d6bad06a0fbe" dependencies = [ "bpaf_derive", ] @@ -208,17 +190,7 @@ checksum = "2f7e98cee839b19076cb3ce1afdb62bb182e04ff5f71f70188827002fae91094" dependencies = [ "proc-macro2", "quote", - "syn 2.0.118", -] - -[[package]] -name = "bstr" -version = "1.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f" -dependencies = [ - "memchr", - "serde_core", + "syn 2.0.119", ] [[package]] @@ -234,20 +206,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] -name = "cc" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005ec2760ca554fae18df7a11195552ec576cd665632a881bc011d5bb2fd4d80" -dependencies = [ - "find-msvc-tools", - "shlex", -] - -[[package]] name = "cfg-if" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" [[package]] name = "cfg_aliases" @@ -263,20 +225,7 @@ checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures", - "rand_core 0.10.1", -] - -[[package]] -name = "chrono" -version = "0.4.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-link", + "rand_core", ] [[package]] @@ -307,12 +256,6 @@ dependencies = [ ] [[package]] -name = "core-foundation-sys" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" - -[[package]] name = "cpufeatures" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -322,12 +265,6 @@ dependencies = [ ] [[package]] -name = "critical-section" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" - -[[package]] name = "crossbeam-channel" version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -388,7 +325,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.118", + "syn 2.0.119", ] [[package]] @@ -402,9 +339,9 @@ dependencies = [ [[package]] name = "either" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "252afb9ae5eaa683babdc6a068b3f5726eb19e05070c731f9b2a23a7c3e8ed34" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "embedded-io" @@ -420,20 +357,9 @@ checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" [[package]] name = "equivalent" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" - -[[package]] -name = "erased-serde" -version = "0.4.10" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec" -dependencies = [ - "serde", - "serde_core", - "typeid", -] +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" [[package]] name = "errno" @@ -482,12 +408,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" [[package]] -name = "find-msvc-tools" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e0f1c7c3a72c66fd80abe965175f7523475c0489a87d3ff9d6e8c87d87a9d2d" - -[[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -538,17 +458,6 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "getrandom" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" @@ -556,7 +465,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "rand_core 0.10.1", + "rand_core", ] [[package]] @@ -594,74 +503,18 @@ dependencies = [ ] [[package]] -name = "hash32" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" -dependencies = [ - "byteorder", -] - -[[package]] name = "hashbrown" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" [[package]] -name = "heapless" -version = "0.7.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" -dependencies = [ - "atomic-polyfill", - "hash32", - "rustc_version", - "serde", - "spin 0.9.9", - "stable_deref_trait", -] - -[[package]] name = "hermit-abi" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" [[package]] -name = "hex_color" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d37f101bf4c633f7ca2e4b5e136050314503dd198e78e325ea602c327c484ef0" -dependencies = [ - "rand 0.8.8", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.65" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "log", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] name = "indexmap" version = "2.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -701,10 +554,16 @@ dependencies = [ ] [[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] name = "js-sys" -version = "0.3.105" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce57d20d1ea864ce2ac172ab472d409214f4fd359f0b2a2775abdf522e2af99e" +checksum = "8dc09d2154098bbf4ef54eab6b117a3c24cbbffe94046b16ee6d6d4510584d3a" dependencies = [ "cfg-if", "futures-util", @@ -713,9 +572,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.189" +version = "0.2.191" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" [[package]] name = "libm" @@ -741,9 +600,9 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litrs" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d3d7f243d5c5a8b9bb5d6dd2b1602c0cb0b9db1621bafc7ed66e35ff9fe092" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" [[package]] name = "lock_api" @@ -756,28 +615,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" - -[[package]] -name = "lua-src" -version = "551.0.2" +version = "0.4.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d400ffef0e3d4d29287092bdc5a276d0bf468b2c69709d5bab0d469312d9f947" -dependencies = [ - "cc", -] - -[[package]] -name = "luajit-src" -version = "210.7.3+1ee778a" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "869665372263eb337b14f480cfb864b89f12eade4eb42cb415f71517b4a67572" -dependencies = [ - "cc", - "which", -] +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "lz4_flex" @@ -813,9 +653,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.3" +version = "1.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b18443e9c262bfe8fa82f51666e2642c53393f7e5c27b3e1aeab922cff5b9d8" +checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" dependencies = [ "libc", "log", @@ -824,38 +664,6 @@ dependencies = [ ] [[package]] -name = "mlua" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d96e5d00f19d8c46c71ceaced99593b90c31c57aa1fe2cb3e93a8b1698eedba9" -dependencies = [ - "bstr", - "either", - "erased-serde", - "libc", - "mlua-sys", - "num-traits", - "parking_lot", - "rustc-hash", - "serde", - "serde-value", -] - -[[package]] -name = "mlua-sys" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b806d7ade031f5d6607eae3e283fb034cb795a76247dd0d1ba753c8c42debccf" -dependencies = [ - "cc", - "cfg-if", - "libc", - "lua-src", - "luajit-src", - "pkg-config", -] - -[[package]] name = "nix" version = "0.31.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -897,21 +705,6 @@ dependencies = [ ] [[package]] -name = "once_cell" -version = "1.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" - -[[package]] -name = "ordered-float" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" -dependencies = [ - "num-traits", -] - -[[package]] name = "parking" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -978,6 +771,22 @@ dependencies = [ ] [[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", + "serde", +] + +[[package]] name = "postcard" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -986,24 +795,14 @@ dependencies = [ "cobs", "embedded-io 0.4.0", "embedded-io 0.6.1", - "heapless", "serde", ] [[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - -[[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] @@ -1048,9 +847,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -1063,43 +862,13 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.8.8" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" -dependencies = [ - "libc", - "rand_chacha", - "rand_core 0.6.4", -] - -[[package]] -name = "rand" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ "chacha20", - "getrandom 0.4.3", - "rand_core 0.10.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", + "getrandom", + "rand_core", ] [[package]] @@ -1134,9 +903,9 @@ dependencies = [ [[package]] name = "rustix" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags", "errno", @@ -1165,60 +934,48 @@ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", ] [[package]] -name = "serde-value" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" -dependencies = [ - "ordered-float", - "serde", -] - -[[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn 2.0.118", + "syn 3.0.9", ] [[package]] -name = "serde_spanned" -version = "1.1.1" +name = "serde_json" +version = "1.0.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" dependencies = [ + "itoa", + "memchr", + "serde", "serde_core", + "zmij", ] [[package]] -name = "shlex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" - -[[package]] name = "signal-hook" version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1257,9 +1014,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.16.0" +version = "1.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9be42f50aa861c555654aa3a37f52f4b1074bacf4e48fe0ef7fa584e80f1f0f" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" [[package]] name = "smol" @@ -1280,15 +1037,6 @@ dependencies = [ [[package]] name = "spin" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spin" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0134f9043ed38b087ac4f7d4af44c79e2c9e5094421fe3164f435ce585953b10" @@ -1297,16 +1045,19 @@ dependencies = [ ] [[package]] -name = "stable_deref_trait" -version = "1.2.1" +name = "spin_sleep" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +checksum = "9c07347b7c0301b9adba4350bdcf09c039d0e7160922050db0439b3c6723c8ab" +dependencies = [ + "windows-sys", +] [[package]] name = "syn" -version = "2.0.118" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" dependencies = [ "proc-macro2", "quote", @@ -1315,9 +1066,9 @@ dependencies = [ [[package]] name = "syn" -version = "3.0.5" +version = "3.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" dependencies = [ "proc-macro2", "quote", @@ -1326,9 +1077,9 @@ dependencies = [ [[package]] name = "talc" -version = "5.0.4" +version = "5.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a5888b3189a89207eea4190e74387b5db3150d213f84186cac637dcd55259d" +checksum = "53f8ad14fa1c1b8635114abf9721076fe1e869572a5f26a52690f407292c80dc" dependencies = [ "allocator-api2", "lock_api", @@ -1336,113 +1087,73 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.20" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.20" +version = "2.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" dependencies = [ "proc-macro2", "quote", - "syn 3.0.5", + "syn 3.0.9", ] [[package]] name = "tinywasm" -version = "0.11.0-pre.0" +version = "0.11.0" +source = "git+https://botahamec.dev/cgit/tinywasm.git?branch=unsigned-types#bd6837a912e11db9ce8cee01a2d33e9c324992a8" dependencies = [ "libm", - "log", "tinywasm-parser", "tinywasm-types", ] [[package]] name = "tinywasm-parser" -version = "0.11.0-pre.0" +version = "0.11.0" +source = "git+https://botahamec.dev/cgit/tinywasm.git?branch=unsigned-types#bd6837a912e11db9ce8cee01a2d33e9c324992a8" dependencies = [ - "log", "tinywasm-types", "wasmparser", ] [[package]] name = "tinywasm-types" -version = "0.11.0-pre.0" +version = "0.11.0" +source = "git+https://botahamec.dev/cgit/tinywasm.git?branch=unsigned-types#bd6837a912e11db9ce8cee01a2d33e9c324992a8" dependencies = [ - "log", + "portable-atomic-util", "postcard", "serde", ] [[package]] -name = "toml" -version = "1.1.6+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "920602543f0911ab71da12c50d59701da54c196d1a2bf5cb4b75667f137a406a" -dependencies = [ - "indexmap", - "serde_core", - "serde_spanned", - "toml_datetime", - "toml_parser", - "toml_writer", - "winnow", -] - -[[package]] -name = "toml_datetime" -version = "1.1.1+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" -dependencies = [ - "serde_core", -] - -[[package]] -name = "toml_parser" -version = "1.1.3+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" -dependencies = [ - "winnow", -] - -[[package]] -name = "toml_writer" -version = "1.1.2+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" - -[[package]] name = "tortuise" version = "0.1.0" +source = "git+https://botahamec.dev/cgit/tortuise.git#c9e708c00665c09adb93144175f11cc11fa1e7f8" dependencies = [ "bpaf", - "chrono", "crossterm", "etcetera", - "getrandom 0.4.3", + "getrandom", "gilrs", - "hex_color", "log", "messagepack-serde", - "mlua", - "postcard", "prologger", "puffin", "puffin_http", "rustc-hash", "serde", "smol", - "spin 0.12.3", + "spin", + "spin_sleep", "tinywasm", ] @@ -1463,10 +1174,10 @@ dependencies = [ "log", "messagepack-serde", "puffin", - "rand 0.10.2", + "rand", "serde", - "spin 0.12.3", - "toml", + "serde_json", + "spin", "tortuise", ] @@ -1476,24 +1187,18 @@ version = "0.1.0" dependencies = [ "log", "messagepack-serde", - "rand 0.10.2", + "rand", "serde", - "spin 0.12.3", + "serde_json", + "spin", "talc", - "toml", ] [[package]] -name = "typeid" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" - -[[package]] name = "unicode-ident" -version = "1.0.24" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" [[package]] name = "unicode-segmentation" @@ -1525,12 +1230,11 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasm-bindgen" -version = "0.2.128" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aecb87a33d3b0c5e3b7aa46336eaf486cffafbd281b195e4c8b80d50df2351bf" +checksum = "a0181c14ddd6c7b8b0b0132a5f1ea2f32be0d893cd3ea97b6e3b28886b8a3d1c" dependencies = [ "cfg-if", - "once_cell", "rustversion", "wasm-bindgen-macro", "wasm-bindgen-shared", @@ -1538,9 +1242,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.128" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a690d511e3c1a8b3a55e33511e3c2c00c78415cd23650f32b808627f5696b9ed" +checksum = "6e931a02a39abdbf66966fc35902b5ed58344750a70885bed4ebb3d8eaf28ed9" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1548,31 +1252,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.128" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "411e4887f0071ef2d2164a9d5fdf2d20efbef78fccd3a78b0c10a1dc5295e48a" +checksum = "2ca4b54280e455bd831e33a6b8e734baf432fe63fbc35c42ac14ce67a043a53a" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 3.0.5", + "syn 3.0.9", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.128" +version = "0.2.130" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81941cd78d0c92026c33e5e01312845a4cb1e9af3407f9134b100dd03144103e" +checksum = "3b1f9c3798725016c6ee5f2f57869ec0831e8bbc0ab0310a86e787e97f41389e" dependencies = [ "unicode-ident", ] [[package]] name = "wasmparser" -version = "0.255.0" +version = "0.259.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8e329ef4b5d46e73b91d3ac6924417cad55a8cbbf869c199283383427c3320b" +checksum = "0f7c12eac7bb587801590f6a67ff0bc84d0748513864b71108e4b311cc3df694" dependencies = [ "bitflags", "indexmap", @@ -1580,24 +1284,15 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.105" +version = "0.3.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fbddc4a036f00ec4f18c83445bd3115cb306a91da554919a099d9222fe4a7f8" +checksum = "d7d179596ff5ec0f6de4db64d54011bde6289cc49603d3a6e4ce3f329207ab88" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] -name = "which" -version = "8.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae2f2b2b816647a1cab1acc91f5bd20812d53cb344382635ec2181940c8034f" -dependencies = [ - "libc", -] - -[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1672,7 +1367,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.118", + "syn 2.0.119", ] [[package]] @@ -1683,7 +1378,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.118", + "syn 2.0.119", ] [[package]] @@ -1739,27 +1434,7 @@ dependencies = [ ] [[package]] -name = "winnow" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" - -[[package]] -name = "zerocopy" -version = "0.8.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d35102a9f36d089ccae9e4c6802bc118be4487b80aaffc0ab4e0cf5ce92d2873" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.57" +name = "zmij" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c01f5ab44258da43cf276c74a2763db2ff3969c9c652c3f2de07041d0b2bc" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.118", -] +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" @@ -10,5 +10,10 @@ members = ["platforms/tortuise-script-compiled", "platforms/tortuise-script-wasm tortuise-script-wasm = { path = "platforms/tortuise-script-wasm" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tortuise-script-compiled = { path = "platforms/tortuise-script-compiled" } +tortuise-script-compiled = { path = "platforms/tortuise-script-compiled", default-features = false } +[features] +default = ["wasm", "gamepad"] +wasm = ["tortuise-script-compiled/wasm"] +profiling = ["tortuise-script-compiled/profiling"] +gamepad = ["tortuise-script-compiled/gamepad"] diff --git a/platforms/tortuise-script-compiled/Cargo.toml b/platforms/tortuise-script-compiled/Cargo.toml index abdb342..cacc0c9 100644 --- a/platforms/tortuise-script-compiled/Cargo.toml +++ b/platforms/tortuise-script-compiled/Cargo.toml @@ -4,13 +4,19 @@ version = "0.1.0" edition = "2024" [dependencies] -tortuise = { path = "../../../tortuise" } +tortuise = { git = "https://botahamec.dev/cgit/tortuise.git", default-features = false } crossterm = "0.29" -gilrs = "0.11" +gilrs = { version = "0.11", optional = true } log = "0.4" messagepack-serde = "0.2" -puffin = "0.20" +puffin = { version = "0.20", optional = true } rand = "0.10" serde = "1" spin = { version = "0.12", features=["lock_api"] } -toml = "1" +serde_json = { version = "1", default-features = false, features=["alloc"] } + +[features] +default = ["wasm"] +wasm = ["tortuise/tinywasm"] +profiling = ["tortuise/puffin", "dep:puffin"] +gamepad = ["tortuise/gilrs", "dep:gilrs"] diff --git a/platforms/tortuise-script-compiled/src/buffer.rs b/platforms/tortuise-script-compiled/src/buffer.rs index c60ee40..ce3a693 100644 --- a/platforms/tortuise-script-compiled/src/buffer.rs +++ b/platforms/tortuise-script-compiled/src/buffer.rs @@ -262,6 +262,7 @@ impl From<Attributes> for crossterm::style::Attributes { impl ScriptContext<'_> { pub fn add_cell(&mut self, cell: Cell) { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0 .operation_queue @@ -279,7 +280,47 @@ impl ScriptContext<'_> { })); } + pub fn add_eternal_cell(&mut self, cell: Cell) { + #[cfg(feature = "profiling")] + puffin::profile_function!(); + log::info!("Add eternal cell"); + self.0 + .operation_queue + .push(Operation::AddEternalCell(tortuise::buffer::Cell { + character: cell.character, + style: ContentStyle { + foreground_color: Some(cell.foreground_color.into()), + background_color: Some(cell.background_color.into()), + underline_color: Some(cell.underline_color.into()), + attributes: cell.attributes.into(), + }, + x: cell.x, + y: cell.y, + z: cell.z, + })); + } + + pub fn remove_eternal_cell(&mut self, cell: Cell) { + #[cfg(feature = "profiling")] + puffin::profile_function!(); + self.0 + .operation_queue + .push(Operation::RemoveEternalCell(tortuise::buffer::Cell { + character: cell.character, + style: ContentStyle { + foreground_color: Some(cell.foreground_color.into()), + background_color: Some(cell.background_color.into()), + underline_color: Some(cell.underline_color.into()), + attributes: cell.attributes.into(), + }, + x: cell.x, + y: cell.y, + z: cell.z, + })); + } + pub fn window_size(&self) -> WindowSize { + #[cfg(feature = "profiling")] puffin::profile_function!(); let size = &self.0.buffer.window_size; WindowSize { @@ -289,6 +330,7 @@ impl ScriptContext<'_> { } pub fn set_framerate_limit(&mut self, limit: Option<u32>) { + #[cfg(feature = "profiling")] puffin::profile_function!(); let limit = limit.map(|limit| Duration::from_nanos(1_000_000_000 / limit as u64)); self.0.operation_queue.push(Operation::SetFrameLimit(limit)); diff --git a/platforms/tortuise-script-compiled/src/entity.rs b/platforms/tortuise-script-compiled/src/entity.rs index 507690d..fe60ae2 100644 --- a/platforms/tortuise-script-compiled/src/entity.rs +++ b/platforms/tortuise-script-compiled/src/entity.rs @@ -34,6 +34,7 @@ impl<T> Entity<T> { } pub fn get(&self, context: &ScriptContext) -> EntityRef<'_, T> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let data = RwLockWriteGuard::map(self.data.write(), |data| { data.get_or_insert_with(|| (self.default)(context)) @@ -42,6 +43,7 @@ impl<T> Entity<T> { } pub fn get_mut(&self, context: &ScriptContext) -> EntityMut<'_, T> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let data = RwLockWriteGuard::map(self.data.write(), |data| { data.get_or_insert_with(|| (self.default)(context)) diff --git a/platforms/tortuise-script-compiled/src/input.rs b/platforms/tortuise-script-compiled/src/input.rs index a7d7340..da197b9 100644 --- a/platforms/tortuise-script-compiled/src/input.rs +++ b/platforms/tortuise-script-compiled/src/input.rs @@ -102,6 +102,7 @@ pub enum PowerInfo { #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Gamepad(usize); +#[cfg(feature = "gamepad")] impl From<Button> for gilrs::Button { fn from(value: Button) -> Self { match value { @@ -128,6 +129,7 @@ impl From<Button> for gilrs::Button { } } +#[cfg(feature = "gamepad")] impl From<Axis> for gilrs::Axis { fn from(value: Axis) -> Self { match value { @@ -143,6 +145,7 @@ impl From<Axis> for gilrs::Axis { } } +#[cfg(feature = "gamepad")] impl From<Option<gilrs::PowerInfo>> for PowerInfo { fn from(value: Option<gilrs::PowerInfo>) -> Self { match value { @@ -181,6 +184,7 @@ impl From<KeyCode> for crossterm::event::KeyCode { } } +#[cfg(feature = "gamepad")] impl Gamepad { pub fn is_button_pressed_this_frame(&self, context: &ScriptContext, button: Button) -> bool { context @@ -217,43 +221,86 @@ impl Gamepad { } } +#[cfg(not(feature = "gamepad"))] +impl Gamepad { + pub fn is_button_pressed_this_frame(&self, _context: &ScriptContext, _button: Button) -> bool { + false + } + + pub fn is_button_released_this_frame(&self, _context: &ScriptContext, _button: Button) -> bool { + false + } + + pub fn is_button_down(&self, _context: &ScriptContext, _button: Button) -> bool { + false + } + + pub fn axis_value(&self, _context: &ScriptContext, _axis: Axis) -> f32 { + 0.0 + } + + pub fn is_connected(&self, _context: &ScriptContext) -> bool { + false + } + + pub fn power_info(&self, _context: &ScriptContext) -> PowerInfo { + PowerInfo::Unknown + } +} + impl ScriptContext<'_> { pub fn is_key_pressed_this_frame(&self, key_code: KeyCode) -> bool { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.is_key_pressed_this_frame(key_code.into()) } pub fn is_mouse_clicked_this_frame(&self) -> bool { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.is_mouse_clicked_this_frame() } pub fn mouse_location(&self) -> Option<Position> { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.mouse_location() } pub fn scroll_direction_this_frame(&self) -> Option<Direction> { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.scroll_direction_this_frame() } + #[cfg(feature = "gamepad")] pub fn is_gamepad_connected_this_frame(&self) -> Option<Gamepad> { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.is_gamepad_connected_this_frame().map(Gamepad) } + #[cfg(not(feature = "gamepad"))] + pub fn is_gamepad_connected_this_frame(&self) -> Option<Gamepad> { + #[cfg(feature = "profiling")] + puffin::profile_function!(); + None + } + pub fn is_focused(&self) -> bool { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.is_focused() } pub fn was_focused_this_frame(&self) -> bool { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.was_focused_this_frame() } pub fn was_unfocused_this_frame(&self) -> bool { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.input.was_unfocused_this_frame() } diff --git a/platforms/tortuise-script-compiled/src/lib.rs b/platforms/tortuise-script-compiled/src/lib.rs index 47bc926..7fc15bd 100644 --- a/platforms/tortuise-script-compiled/src/lib.rs +++ b/platforms/tortuise-script-compiled/src/lib.rs @@ -1,6 +1,7 @@ use std::sync::Arc; -use tortuise::{file::FileManager, script::WasmRunner}; +#[cfg(feature = "wasm")] +use tortuise::{file::FileManager, script::wasm::WasmRunner}; pub mod buffer; pub mod entity; @@ -92,14 +93,26 @@ pub fn run_game( .collect(), }; - let mut files = FileManager::new(); - let wasm_runner = WasmRunner::new(); - let mut manifest = manifest.into(); - tortuise::init_logger(&manifest); - if let Err(e) = tortuise::apply_patches(&mut manifest, &mut files, &wasm_runner) { - log::error!("{e}"); + #[cfg(feature = "wasm")] + { + let mut files = FileManager::new(); + let wasm_runner = WasmRunner::new(); + let mut manifest = manifest.into(); + tortuise::init_logger(&manifest); + if let Err(e) = tortuise::apply_patches(&mut manifest, &mut files, &wasm_runner) { + log::error!("{e}"); + } + tortuise::run_game( + #[cfg(feature = "wasm")] + files, + #[cfg(feature = "wasm")] + wasm_runner, + manifest, + ) } - tortuise::run_game(files, wasm_runner, manifest) + + #[cfg(not(feature = "wasm"))] + tortuise::run_game(manifest.into()); } #[macro_export] diff --git a/platforms/tortuise-script-compiled/src/process.rs b/platforms/tortuise-script-compiled/src/process.rs index 1ee39f2..115b553 100644 --- a/platforms/tortuise-script-compiled/src/process.rs +++ b/platforms/tortuise-script-compiled/src/process.rs @@ -4,6 +4,7 @@ use crate::ScriptContext; impl ScriptContext<'_> { pub fn exit(&mut self) { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.operation_queue.push(Operation::Exit) } diff --git a/platforms/tortuise-script-compiled/src/random.rs b/platforms/tortuise-script-compiled/src/random.rs index 148f152..4a083c6 100644 --- a/platforms/tortuise-script-compiled/src/random.rs +++ b/platforms/tortuise-script-compiled/src/random.rs @@ -8,6 +8,7 @@ pub struct TortuiseRng(SmallRng); impl TortuiseRng { pub fn new() -> Self { + #[cfg(feature = "profiling")] puffin::profile_function!(); Self::seed_from_u64(rand::make_rng::<StdRng>().next_u64()) } diff --git a/platforms/tortuise-script-compiled/src/scene.rs b/platforms/tortuise-script-compiled/src/scene.rs index fc83d6b..8bea71b 100644 --- a/platforms/tortuise-script-compiled/src/scene.rs +++ b/platforms/tortuise-script-compiled/src/scene.rs @@ -4,11 +4,13 @@ use crate::ScriptContext; impl ScriptContext<'_> { pub fn scene_id(&self, name: &str) -> Option<usize> { + #[cfg(feature = "profiling")] puffin::profile_function!(); tortuise::scene::scene_id_by_name(&self.0.manifest.scenes, name) } pub fn switch_scene(&mut self, name: &str) -> Option<()> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let id = self.scene_id(name)?; self.0.operation_queue.push(Operation::SwitchScene(id)); diff --git a/platforms/tortuise-script-compiled/src/script.rs b/platforms/tortuise-script-compiled/src/script.rs index d316fe5..4782bda 100644 --- a/platforms/tortuise-script-compiled/src/script.rs +++ b/platforms/tortuise-script-compiled/src/script.rs @@ -4,16 +4,19 @@ use crate::ScriptContext; impl ScriptContext<'_> { pub fn current_script_name(&self) -> String { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.manifest.scripts[self.0.script_id].name().to_owned() } pub fn script_id(&self, name: &str) -> Option<usize> { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.scripts.script_id_by_name(name) } pub fn activate_script(&mut self, name: &str) -> Option<()> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let id = self.script_id(name)?; self.0.operation_queue.push(Operation::ActivateScript(id)); @@ -21,6 +24,7 @@ impl ScriptContext<'_> { } pub fn deactivate_script(&mut self, name: &str) -> Option<()> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let id = self.script_id(name)?; self.0.operation_queue.push(Operation::DeactivateScript(id)); diff --git a/platforms/tortuise-script-compiled/src/state.rs b/platforms/tortuise-script-compiled/src/state.rs index 896b836..9e20cf7 100644 --- a/platforms/tortuise-script-compiled/src/state.rs +++ b/platforms/tortuise-script-compiled/src/state.rs @@ -26,6 +26,7 @@ impl<T> ScriptState<T> { } pub fn get(&self, context: &ScriptContext) -> StateRef<'_, T> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let data = MutexGuard::map(self.data.lock(), |data| { data.get_or_insert_with(|| (self.default)(context)) @@ -34,6 +35,7 @@ impl<T> ScriptState<T> { } pub fn get_mut(&self, context: &ScriptContext) -> StateMut<'_, T> { + #[cfg(feature = "profiling")] puffin::profile_function!(); let data = MutexGuard::map(self.data.lock(), |data| { data.get_or_insert_with(|| (self.default)(context)) diff --git a/platforms/tortuise-script-compiled/src/storage.rs b/platforms/tortuise-script-compiled/src/storage.rs index d028a91..033bacb 100644 --- a/platforms/tortuise-script-compiled/src/storage.rs +++ b/platforms/tortuise-script-compiled/src/storage.rs @@ -37,6 +37,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Storage<T> { } pub fn load(&self, context: &ScriptContext) -> T { + #[cfg(feature = "profiling")] puffin::profile_function!(); let mut data = self.data.lock(); data.get_or_insert_with(|| { @@ -78,6 +79,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Config<T> { } pub fn load(&self, context: &ScriptContext) -> T { + #[cfg(feature = "profiling")] puffin::profile_function!(); let mut data = self.data.lock(); data.get_or_insert_with(|| { @@ -85,7 +87,7 @@ impl<T: Serialize + DeserializeOwned + Clone + Eq> Config<T> { .0 .storage .config() - .map(toml::from_slice) + .map(serde_json::from_slice) .and_then(|r| r.ok()) .unwrap_or_else(self.initial_state) }) @@ -126,6 +128,7 @@ impl<T: Serialize + Eq> DerefMut for StorageMut<'_, '_, T> { impl<T: Serialize + Eq> Drop for StorageMut<'_, '_, T> { fn drop(&mut self) { + #[cfg(feature = "profiling")] puffin::profile_function!(); if self.data == self.original { return; @@ -161,13 +164,14 @@ impl<T: Serialize + Eq> DerefMut for ConfigMut<'_, '_, T> { impl<T: Serialize + Eq> Drop for ConfigMut<'_, '_, T> { fn drop(&mut self) { + #[cfg(feature = "profiling")] puffin::profile_function!(); if self.data == self.original { return; } - let new_save = match toml::to_string(&self.data) { - Ok(new_save) => new_save.as_bytes().into(), + let new_save = match serde_json::to_vec_pretty(&self.data) { + Ok(new_save) => new_save.into(), Err(e) => { log::error!("{e}"); return; diff --git a/platforms/tortuise-script-compiled/src/time.rs b/platforms/tortuise-script-compiled/src/time.rs index 72a2f68..9ac7ec6 100644 --- a/platforms/tortuise-script-compiled/src/time.rs +++ b/platforms/tortuise-script-compiled/src/time.rs @@ -19,6 +19,7 @@ pub struct Instant(u128); impl ScriptContext<'_> { pub fn delta_time(&self) -> Duration { + #[cfg(feature = "profiling")] puffin::profile_function!(); Duration::from_nanos_u128(self.0.time.delta_time().as_nanos()) } @@ -28,11 +29,13 @@ impl SystemTime { pub const UNIX_EPOCH: Self = Self(std::time::SystemTime::UNIX_EPOCH); pub fn now(context: &ScriptContext) -> Self { + #[cfg(feature = "profiling")] puffin::profile_function!(); Self(context.0.time.system_now()) } pub fn duration_since(self, earlier: SystemTime) -> Option<Duration> { + #[cfg(feature = "profiling")] puffin::profile_function!(); self.0.duration_since(earlier.0).ok() } @@ -76,6 +79,7 @@ impl SubAssign<Duration> for SystemTime { impl Instant { pub fn now(context: &ScriptContext) -> Self { + #[cfg(feature = "profiling")] puffin::profile_function!(); Self(context.0.time.monotonic_now().as_nanos()) } diff --git a/platforms/tortuise-script-wasm/Cargo.toml b/platforms/tortuise-script-wasm/Cargo.toml index 768cdfe..deee369 100644 --- a/platforms/tortuise-script-wasm/Cargo.toml +++ b/platforms/tortuise-script-wasm/Cargo.toml @@ -10,4 +10,4 @@ rand = { version = "0.10", default-features = false } serde = "1" spin = { version = "0.12", features=["lock_api"] } talc = "5" -toml = "1" +serde_json = { version = "1", default-features = false, features=["alloc"] } diff --git a/platforms/tortuise-script-wasm/src/buffer.rs b/platforms/tortuise-script-wasm/src/buffer.rs index bbcb3ca..fbb63f8 100644 --- a/platforms/tortuise-script-wasm/src/buffer.rs +++ b/platforms/tortuise-script-wasm/src/buffer.rs @@ -15,6 +15,26 @@ mod tortuise { underline_color: u32, attributes: u32, ); + pub safe fn add_eternal_cell( + context: u64, + character: u32, + location: u32, + z: u32, + foreground_color: u32, + background_color: u32, + underline_color: u32, + attributes: u32, + ); + pub safe fn remove_eternal_cell( + context: u64, + character: u32, + location: u32, + z: u32, + foreground_color: u32, + background_color: u32, + underline_color: u32, + attributes: u32, + ); pub safe fn window_size(context: u64) -> u32; pub safe fn set_framerate_limit(context: u64, limit: u32); } @@ -226,6 +246,32 @@ impl ScriptContext<'_> { ); } + pub fn add_eternal_cell(&mut self, cell: Cell) { + tortuise::add_eternal_cell( + self.0, + cell.character as u32, + (cell.x as u32) << 16 | cell.y as u32, + cell.z as u32, + color_to_u32(cell.foreground_color), + color_to_u32(cell.background_color), + color_to_u32(cell.underline_color), + cell.attributes.0, + ); + } + + pub fn remove_eternal_cell(&mut self, cell: Cell) { + tortuise::remove_eternal_cell( + self.0, + cell.character as u32, + (cell.x as u32) << 16 | cell.y as u32, + cell.z as u32, + color_to_u32(cell.foreground_color), + color_to_u32(cell.background_color), + color_to_u32(cell.underline_color), + cell.attributes.0, + ); + } + pub fn window_size(&self) -> WindowSize { let size = tortuise::window_size(self.0); WindowSize { diff --git a/platforms/tortuise-script-wasm/src/storage.rs b/platforms/tortuise-script-wasm/src/storage.rs index 2606e2b..ad48e23 100644 --- a/platforms/tortuise-script-wasm/src/storage.rs +++ b/platforms/tortuise-script-wasm/src/storage.rs @@ -58,7 +58,7 @@ fn load_config<T: DeserializeOwned>(context: u64) -> Option<T> { let ptr = alloc(layout); tortuise::load_config(context, ptr); let data = core::slice::from_raw_parts(ptr, size); - let data = toml::from_slice(data).ok()?; + let data = serde_json::from_slice(data).ok()?; dealloc(ptr, layout); Some(data) } @@ -66,7 +66,7 @@ fn load_config<T: DeserializeOwned>(context: u64) -> Option<T> { fn save_config<T: Serialize>(context: u64, state: &T) { unsafe { - let data = toml::to_string(state).unwrap(); + let data = serde_json::to_vec_pretty(state).unwrap(); tortuise::save_config(context, data.as_ptr(), data.len()); } } |
