diff --git a/Cargo.lock b/Cargo.lock index dadbac2d6de..3a92562f3b0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -176,6 +176,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" + [[package]] name = "arrayref" version = "0.3.7" @@ -220,7 +226,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -425,7 +431,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -442,7 +448,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -759,6 +765,7 @@ version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ + "jobserver", "libc", ] @@ -928,7 +935,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1046,6 +1053,15 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + [[package]] name = "cpp_demangle" version = "0.4.3" @@ -1064,6 +1080,115 @@ dependencies = [ "libc", ] +[[package]] +name = "cranelift-bforest" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b9d1a9e776c27ad55d7792a380785d1fe8c2d7b099eed8dbd8f4af2b598192" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5528483314c2dd5da438576cd8a9d0b3cedad66fb8a4727f90cd319a81950038" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.0", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f46a8318163f7682e35b8730ba93c1b586a2da8ce12a0ed545efc1218550f70" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d1239cfd50eecfaed468d46943f8650e32969591868ad50111613704da6c70" + +[[package]] +name = "cranelift-control" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc530560c8f16cc1d4dd7ea000c56f519c60d1a914977abe849ce555c35a61d" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f333fa641a9ad2bff0b107767dcb972c18c2bfab7969805a1d7e42449ccb0408" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abf6563015a80f03f8bc4df307d0a81363f4eb73108df3a34f6e66fb6d5307" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eb29d0edc8a5c029ed0f7ca77501f272738e3c410020b4a00f42ffe8ad2a8aa" + +[[package]] +name = "cranelift-native" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006056a7fa920870bad06bf8e1b3033d70cbb7ee625b035efa9d90882a931868" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b3d08c05f82903a1f6a04d89c4b9ecb47a4035710f89a39a21a147a80214672" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools 0.10.5", + "log", + "smallvec", + "wasmparser 0.112.0", + "wasmtime-types", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -1184,7 +1309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" dependencies = [ "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1220,7 +1345,7 @@ source = "git+https://github.com/dalek-cryptography/curve25519-dalek/?rev=e44d4b dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1244,7 +1369,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1255,7 +1380,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1359,7 +1484,7 @@ checksum = "5fe87ce4529967e0ba1dcf8450bab64d97dfd5010a6256187ffe2e43e6f0e049" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1383,6 +1508,16 @@ dependencies = [ "subtle", ] +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + [[package]] name = "dirs" version = "5.0.1" @@ -1404,6 +1539,17 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "displaydoc" version = "0.2.4" @@ -1412,7 +1558,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1695,7 +1841,7 @@ checksum = "dd65f1b59dd22d680c7a626cc4a000c1e03d241c51c3e034d2bc9f1e90734f9b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1750,6 +1896,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + [[package]] name = "fallible-streaming-iterator" version = "0.1.9" @@ -1947,7 +2099,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -1995,6 +2147,28 @@ dependencies = [ "thread_local", ] +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "fxprof-processed-profile" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" +dependencies = [ + "bitflags 2.4.0", + "debugid", + "fxhash", + "serde", + "serde_json", +] + [[package]] name = "generic-array" version = "0.14.7" @@ -2065,6 +2239,11 @@ name = "gimli" version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +dependencies = [ + "fallible-iterator 0.3.0", + "indexmap 2.0.0", + "stable_deref_trait", +] [[package]] name = "glob" @@ -2162,6 +2341,15 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.14.0" @@ -2413,6 +2601,12 @@ dependencies = [ "cc", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "ident_case" version = "1.0.1" @@ -2644,12 +2838,68 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +[[package]] +name = "ittapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41e0d0b7b3b53d92a7e8b80ede3400112a6b8b4c98d1f5b8b16bb787c780582c" +dependencies = [ + "anyhow", + "ittapi-sys", + "log", +] + +[[package]] +name = "ittapi-sys" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f8763c96e54e6d6a0dccc2990d8b5e33e3313aaeae6185921a3f4c1614a77c" +dependencies = [ + "cc", +] + +[[package]] +name = "javascriptcore" +version = "0.0.5" +source = "git+https://github.com/endoli/javascriptcore.rs?branch=main#9791f15e5c6c08fcb451f70099ba049cbe439d61" +dependencies = [ + "javascriptcore-macros", + "javascriptcore-sys", + "thiserror", +] + +[[package]] +name = "javascriptcore-macros" +version = "0.0.1" +source = "git+https://github.com/endoli/javascriptcore.rs?branch=main#9791f15e5c6c08fcb451f70099ba049cbe439d61" +dependencies = [ + "quote", + "syn 2.0.39", +] + +[[package]] +name = "javascriptcore-sys" +version = "0.0.5" +source = "git+https://github.com/endoli/javascriptcore.rs?branch=main#9791f15e5c6c08fcb451f70099ba049cbe439d61" +dependencies = [ + "pkg-config", +] + [[package]] name = "jni-sys" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + [[package]] name = "jpeg-decoder" version = "0.1.22" @@ -2756,6 +3006,12 @@ dependencies = [ "spin", ] +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" version = "0.2.148" @@ -2826,6 +3082,15 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "maplit" version = "1.0.2" @@ -3225,6 +3490,28 @@ dependencies = [ "zeroize", ] +[[package]] +name = "matrix-sdk-extensions" +version = "0.0.1" +dependencies = [ + "anyhow", + "javascriptcore", + "matrix-sdk-extensions-macros", + "wasmtime", +] + +[[package]] +name = "matrix-sdk-extensions-macros" +version = "0.0.1" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasmtime-wit-bindgen 14.0.4", + "wit-parser 0.12.2", +] + [[package]] name = "matrix-sdk-ffi" version = "0.2.0" @@ -3448,6 +3735,15 @@ version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix 0.38.13", +] + [[package]] name = "memmap2" version = "0.5.10" @@ -3724,6 +4020,9 @@ version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ + "crc32fast", + "hashbrown 0.14.0", + "indexmap 2.0.0", "memchr", ] @@ -3791,7 +4090,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -4027,7 +4326,7 @@ dependencies = [ "regex", "regex-syntax 0.7.5", "structmeta", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -4143,7 +4442,7 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -4181,7 +4480,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -4444,9 +4743,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.67" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" dependencies = [ "unicode-ident", ] @@ -4491,6 +4790,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + [[package]] name = "pulldown-cmark" version = "0.9.3" @@ -4676,6 +4984,19 @@ dependencies = [ "thiserror", ] +[[package]] +name = "regalloc2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + [[package]] name = "regex" version = "1.9.5" @@ -4982,7 +5303,7 @@ dependencies = [ "quote", "ruma-identifiers-validation", "serde", - "syn 2.0.37", + "syn 2.0.39", "toml 0.7.8", ] @@ -5005,7 +5326,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "01e213bc3ecb39ac32e81e51ebe31fd888a940515173e3a18a35f8c6e896422a" dependencies = [ "bitflags 1.3.2", - "fallible-iterator", + "fallible-iterator 0.2.0", "fallible-streaming-iterator", "hashlink", "libsqlite3-sys", @@ -5018,6 +5339,12 @@ version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustc_version" version = "0.4.0" @@ -5204,7 +5531,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5311,7 +5638,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5407,7 +5734,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5491,6 +5818,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + [[package]] name = "sliding-sync-integration-test" version = "0.1.0" @@ -5550,6 +5883,12 @@ dependencies = [ "der", ] +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -5618,7 +5957,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5629,7 +5968,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5656,7 +5995,7 @@ version = "12.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "691e53bdc0702aba3a5abc2cffff89346fcbd4050748883c7e2f714b33a69045" dependencies = [ - "cpp_demangle", + "cpp_demangle 0.4.3", "rustc-demangle", "symbolic-common", ] @@ -5674,9 +6013,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.37" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -5689,6 +6028,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "target-lexicon" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" + [[package]] name = "tempfile" version = "3.8.0" @@ -5715,22 +6060,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.48" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -5855,7 +6200,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -6073,7 +6418,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -6192,6 +6537,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -6259,7 +6610,7 @@ version = "0.24.1" source = "git+https://github.com/mozilla/uniffi-rs?rev=e20b9c2b72144ef51a381c6b321ac810a4fbfdbe#e20b9c2b72144ef51a381c6b321ac810a4fbfdbe" dependencies = [ "quote", - "syn 2.0.37", + "syn 2.0.39", ] [[package]] @@ -6290,7 +6641,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.37", + "syn 2.0.39", "toml 0.5.11", "uniffi_build", "uniffi_meta", @@ -6520,7 +6871,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -6554,7 +6905,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6589,6 +6940,24 @@ dependencies = [ "quote", ] +[[package]] +name = "wasm-encoder" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34180c89672b3e4825c3a8db4b61a674f1447afd5fe2445b2d22c3d8b6ea086c" +dependencies = [ + "leb128", +] + [[package]] name = "wasm-streams" version = "0.3.0" @@ -6602,6 +6971,376 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmparser" +version = "0.112.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e986b010f47fcce49cf8ea5d5f9e5d2737832f12b53ae8ae785bbe895d0877bf" +dependencies = [ + "indexmap 2.0.0", + "semver", +] + +[[package]] +name = "wasmparser" +version = "0.113.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0d44fab0bd78404e352f3399324eef76516a4580b52bc9031c60f064e98f3" +dependencies = [ + "indexmap 2.0.0", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.2.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6615a5587149e753bf4b93f90fa3c3f41c88597a7a2da72879afcabeda9648f" +dependencies = [ + "anyhow", + "wasmparser 0.113.2", +] + +[[package]] +name = "wasmtime" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ed7db409c1acf60d33128b2a38bee25aaf38c4bd955ab98a5b623c8294593c" +dependencies = [ + "anyhow", + "async-trait", + "bincode", + "bumpalo", + "cfg-if", + "encoding_rs", + "fxprof-processed-profile", + "indexmap 2.0.0", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "rayon", + "serde", + "serde_derive", + "serde_json", + "target-lexicon", + "wasm-encoder 0.32.0", + "wasmparser 0.112.0", + "wasmtime-cache", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-runtime", + "wasmtime-winch", + "wat", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53af0f8f6271bd687fe5632c8fe0a0f061d0aa1b99a0cd4e1df8e4cbeb809d2f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cache" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41376a7c094335ee08abe6a4eff79a32510cc805a249eff1b5e7adf0a42e7cdf" +dependencies = [ + "anyhow", + "base64 0.21.4", + "bincode", + "directories-next", + "log", + "rustix 0.38.13", + "serde", + "serde_derive", + "sha2", + "toml 0.5.11", + "windows-sys", + "zstd", +] + +[[package]] +name = "wasmtime-component-macro" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74ab5b291f2dad56f1e6929cc61fb7cac68845766ca77c3838b5d05d82c33976" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasmtime-component-util", + "wasmtime-wit-bindgen 13.0.0", + "wit-parser 0.11.3", +] + +[[package]] +name = "wasmtime-component-util" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21436177bf19f6b60dc0b83ad5872e849892a4a90c3572785e1a28c0e2e1132c" + +[[package]] +name = "wasmtime-cranelift" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "920e42058862d1f7a3dd3fca73cb495a20d7506e3ada4bbc0a9780cd636da7ca" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser 0.112.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516d63bbe18219e64a9705cf3a2c865afe1fb711454ea03091dc85a1d708194d" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-control", + "cranelift-native", + "gimli", + "object", + "target-lexicon", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cef239d663885f1427f8b8f4fde7be6075249c282580d94b480f11953ca194" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap 2.0.0", + "log", + "object", + "serde", + "serde_derive", + "target-lexicon", + "thiserror", + "wasm-encoder 0.32.0", + "wasmparser 0.112.0", + "wasmprinter", + "wasmtime-component-util", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-fiber" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef118b557df6193cd82cfb45ab57cd12388fedfe2bb76f090b2d77c96c1b56e" +dependencies = [ + "cc", + "cfg-if", + "rustix 0.38.13", + "wasmtime-asm-macros", + "wasmtime-versioned-export-macros", + "windows-sys", +] + +[[package]] +name = "wasmtime-jit" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8089d5909b8f923aad57702ebaacb7b662aa9e43a3f71e83e025c5379a1205f" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle 0.3.5", + "gimli", + "ittapi", + "log", + "object", + "rustc-demangle", + "rustix 0.38.13", + "serde", + "serde_derive", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b13924aedf6799ad66edb25500a20e3226629978b30a958c55285352bad130a" +dependencies = [ + "object", + "once_cell", + "rustix 0.38.13", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6ff5f3707a5e3797deeeeac6ac26b2e1dd32dbc06693c0ab52e8ac4d18ec706" +dependencies = [ + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-runtime" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ab4ce04ac05342edfa7f42895f2a5d8b16ee914330869acb865cd1facf265f" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "encoding_rs", + "indexmap 2.0.0", + "libc", + "log", + "mach", + "memfd", + "memoffset", + "paste", + "rand 0.8.5", + "rustix 0.38.13", + "sptr", + "wasm-encoder 0.32.0", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "wasmtime-versioned-export-macros", + "wasmtime-wmemcheck", + "windows-sys", +] + +[[package]] +name = "wasmtime-types" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecf61e21d5bd95e1ad7fa42b7bdabe21220682d6a6046d376edca29760849222" +dependencies = [ + "cranelift-entity", + "serde", + "serde_derive", + "thiserror", + "wasmparser 0.112.0", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe877472cbdd6d96b4ecdc112af764e3b9d58c2e4175a87828f892ab94c60643" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "wasmtime-winch" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bc5a770003807c55f2187a0092dea01722b0e24151e35816bd5091538bb8e88" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser 0.112.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62003d48822f89cc393e93643366ddbee1766779c0874353b8ba2ede4679fbf9" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.0.0", + "wit-parser 0.11.3", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "14.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d214ca7513d76af2872ad5bba4b0dcc0225821931745fdcb4fc30dd34bc3bf7" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.0.0", + "wit-parser 0.12.2", +] + +[[package]] +name = "wasmtime-wmemcheck" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5412bb464066d64c3398c96e6974348f90fa2a55110ad7da3f9295438cd4de84" + +[[package]] +name = "wast" +version = "65.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55a88724cf8c2c0ebbf32c8e8f4ac0d6aa7ba6d73a1cfd94b254aa8f894317e" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder 0.33.2", +] + +[[package]] +name = "wat" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83e1a8d86d008adc7bafa5cf4332d448699a08fcf2a715a71fbb75e2c5ca188" +dependencies = [ + "wast", +] + [[package]] name = "web-sys" version = "0.3.64" @@ -6669,6 +7408,22 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winch-codegen" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50647204d600a2a112eefac0645ba6653809a15bd362c7e4e6a049a5bdff0de9" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser 0.112.0", + "wasmtime-environ", +] + [[package]] name = "windows" version = "0.48.0" @@ -6785,6 +7540,41 @@ dependencies = [ "tokio", ] +[[package]] +name = "wit-parser" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39edca9abb16309def3843af73b58d47d243fe33a9ceee572446bcc57556b9a" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.0.0", + "log", + "pulldown-cmark", + "semver", + "serde", + "serde_json", + "unicode-xid", + "url", +] + +[[package]] +name = "wit-parser" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43771ee863a16ec4ecf9da0fc65c3bbd4a1235c8e3da5f094b562894843dfa76" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.0.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", +] + [[package]] name = "x25519-dalek" version = "2.0.0-rc.3" @@ -6852,5 +7642,35 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.37", + "syn 2.0.39", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.8+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +dependencies = [ + "cc", + "libc", + "pkg-config", ] diff --git a/Cargo.toml b/Cargo.toml index 74bbc6801f5..ce23861503c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ members = [ # xtask, testing and the bindings should only be built when invoked explicitly. default-members = ["benchmarks", "crates/*"] resolver = "2" +exclude = ["crates/matrix-sdk-extensions/guests"] [workspace.package] rust-version = "1.70" diff --git a/bindings/matrix-sdk-ffi/Cargo.toml b/bindings/matrix-sdk-ffi/Cargo.toml index 2aca140d73b..693c36e801c 100644 --- a/bindings/matrix-sdk-ffi/Cargo.toml +++ b/bindings/matrix-sdk-ffi/Cargo.toml @@ -52,6 +52,7 @@ uniffi = { workspace = true, features = ["tokio"] } url = "2.2.2" zeroize = { workspace = true } uuid = { version = "1.4.1", features = ["v4"] } +javascriptcore = { git = "https://github.com/endoli/javascriptcore.rs", branch = "main" } [target.'cfg(target_os = "android")'.dependencies] log-panics = { version = "2", features = ["with-backtrace"] } diff --git a/bindings/matrix-sdk-ffi/src/client.rs b/bindings/matrix-sdk-ffi/src/client.rs index 664780f999b..966f9cb6b8e 100644 --- a/bindings/matrix-sdk-ffi/src/client.rs +++ b/bindings/matrix-sdk-ffi/src/client.rs @@ -296,6 +296,28 @@ impl Client { Ok(()) } + + pub fn test_wasm(&self) { + use javascriptcore::{JSContext, JSValue}; + + let mut bytes = +b"\x00asm\x01\x00\x00\x00\x01\x07\x01`\x02\x7f\x7f\x01\x7f\x03\x02\x01\x00\x05\x03\x01\x00\x10\x06\x11\x02\x7f\x00A\x80\x80\xc0\x00\x0b\x7f\x00A\x80\x80\xc0\x00\x0b\x07+\x04\x06memory\x02\x00\x03sum\x00\x00\n__data_end\x03\x00\x0b__heap_base\x03\x01\n\t\x01\x07\x00 \x00 \x01j\x0b\x00,\x0ftarget_features\x02+\x0fmutable-globals+\x08sign-ext".to_owned(); + + let ctx = JSContext::default(); + let global = ctx.global_object().unwrap(); + let wasm = global.get_property("WebAssembly").as_object().unwrap(); + let module = wasm.get_property("Module").as_object().unwrap(); + let bytes = unsafe { JSValue::new_typed_array_with_bytes(&ctx, &mut bytes[..]).unwrap() }; + let compiled_module = module.call_as_constructor(&[bytes]).unwrap(); + let instance = wasm.get_property("Instance").as_object().unwrap(); + let instance = instance.call_as_constructor(&[compiled_module]).unwrap().as_object().unwrap(); + let exports = instance.get_property("exports").as_object().unwrap(); + let sum = exports.get_property("sum").as_object().unwrap(); + + let result = sum.call_as_function(None, &[JSValue::new_number(&ctx, 1.), JSValue::new_number(&ctx, 2.)]).unwrap(); + + assert_eq!(result.as_number().unwrap(), 3.); + } } impl Client { diff --git a/crates/matrix-sdk-extensions-macros/Cargo.toml b/crates/matrix-sdk-extensions-macros/Cargo.toml new file mode 100644 index 00000000000..332fccedc9c --- /dev/null +++ b/crates/matrix-sdk-extensions-macros/Cargo.toml @@ -0,0 +1,23 @@ +[package] +authors = ["Ivan Enderlin "] +edition = "2021" +name = "matrix-sdk-extensions-macros" +repository = "https://github.com/matrix-org/matrix-rust-sdk" +rust-version = { workspace = true } +version = "0.0.1" + +[lib] +proc-macro = true + +[features] +default = ["wasmtime", "javascriptcore"] +wasmtime = ["dep:wasmtime-wit-bindgen"] +javascriptcore = [] + +[dependencies] +heck = { version = "0.4.1" } +proc-macro2 = "1.0.69" +quote = "1.0.33" +syn = { version = "2.0.39", features = ["full"] } +wasmtime-wit-bindgen = { version = "14.0.4", optional = true } +wit-parser = "0.12.1" diff --git a/crates/matrix-sdk-extensions-macros/src/lib.rs b/crates/matrix-sdk-extensions-macros/src/lib.rs new file mode 100644 index 00000000000..df190459712 --- /dev/null +++ b/crates/matrix-sdk-extensions-macros/src/lib.rs @@ -0,0 +1,619 @@ +use std::{env, path::PathBuf}; + +use heck::{ToSnakeCase as _, ToUpperCamelCase as _}; +use proc_macro2::{Ident, Span, TokenStream}; +use quote::quote; +use syn::{ + braced, + parse::{Error, Parse, ParseStream, Result}, + parse_macro_input, + punctuated::Punctuated, + LitStr, Token, TypePath, +}; +use wit_parser::{Resolve, Results, Type, WorldId, WorldItem}; + +struct Configuration { + resolve: Resolve, + world: WorldId, + // module_type: TypePath, + environment_type: TypePath, + matrix_sdk_extensions_alias: Option, +} + +mod keyword { + use syn::custom_keyword; + + custom_keyword!(world); + custom_keyword!(module); + custom_keyword!(environment); + custom_keyword!(matrix_sdk_extensions_alias); +} + +impl Parse for Configuration { + fn parse(input: ParseStream<'_>) -> Result { + let call_site = Span::call_site(); + + let mut world = None; + let mut environment_type = None; + // let mut module = None; + let mut matrix_sdk_extensions_alias = None; + + { + let sub_input; + braced!(sub_input in input); + let options = Punctuated::::parse_terminated(&sub_input)?; + + for option in options.into_pairs() { + match option.into_value() { + Opt::World(w) => { + world = Some(w.value()); + } + + // Opt::Module(m) => module = Some(m), + Opt::Environment(e) => environment_type = Some(e), + + Opt::MatrixSdkExtensionsAlias(a) => matrix_sdk_extensions_alias = Some(a), + } + } + } + + let world = world.expect("`world` is missing"); + // let module_type = module.expect("`module` is missing"); + let environment_type = environment_type.expect("`environment` is missing"); + + let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let wit_directory = root.join("wit"); + let mut resolve = Resolve::default(); + + let (pkg, sources) = + resolve.push_dir(&wit_directory).map_err(|e| Error::new(call_site, e))?; + + let world = resolve + .select_world(pkg, Some(&world)) + .map_err(|e| Error::new(call_site, format!("{e:?}")))?; + + Ok(Configuration { + resolve, + world, + // module_type, + environment_type, + matrix_sdk_extensions_alias, + }) + } +} + +enum Opt { + World(LitStr), + // Module(TypePath), + Environment(TypePath), + MatrixSdkExtensionsAlias(TypePath), +} + +impl Parse for Opt { + fn parse(input: ParseStream<'_>) -> Result { + let look = input.lookahead1(); + + if look.peek(keyword::world) { + input.parse::()?; + input.parse::()?; + + Ok(Opt::World(input.parse()?)) + // } else if look.peek(keyword::module) { + // input.parse::()?; + // input.parse::()?; + + // Ok(Opt::Module(input.parse()?)) + } else if look.peek(keyword::environment) { + input.parse::()?; + input.parse::()?; + + Ok(Opt::Environment(input.parse()?)) + } else if look.peek(keyword::matrix_sdk_extensions_alias) { + input.parse::()?; + input.parse::()?; + + Ok(Opt::MatrixSdkExtensionsAlias(input.parse()?)) + } else { + Err(look.error()) + } + } +} + +fn to_rust_upper_camel_case(name: &str) -> String { + match name { + "host" => "Host_".to_owned(), + name => name.to_upper_camel_case(), + } +} + +fn to_rust_type(ty: &Type) -> String { + match ty { + Type::Bool => "bool".to_owned(), + Type::U8 => "u8".to_owned(), + Type::U16 => "u16".to_owned(), + Type::U32 => "u32".to_owned(), + Type::U64 => "u64".to_owned(), + Type::S8 => "i8".to_owned(), + Type::S16 => "i16".to_owned(), + Type::S32 => "i32".to_owned(), + Type::S64 => "i64".to_owned(), + Type::Float32 => "f32".to_owned(), + Type::Float64 => "f64".to_owned(), + Type::Char => "char".to_owned(), + Type::String => "String".to_owned(), + Type::Id(_) => unimplemented!("{:?}", ty), + } +} + +#[cfg(feature = "wasmtime")] +#[proc_macro] +pub fn wasmtime_bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let call_site = Span::call_site(); + + let configuration = parse_macro_input!(input as Configuration); + let opts = wasmtime_wit_bindgen::Opts::default(); + let generated = + opts.generate(&configuration.resolve, configuration.world).parse::().unwrap(); + + let resolve = &configuration.resolve; + let world = &resolve.worlds[configuration.world]; + let world_type_name = to_rust_upper_camel_case(&world.name); + let world_type = Ident::new(&world_type_name, call_site); + let module_type = Ident::new(&format!("{}Module", world_type_name), call_site); + let environment_type = &configuration.environment_type; + + let use_matrix_sdk_extensions = configuration + .matrix_sdk_extensions_alias + .map(|alias| quote! { use #alias as matrix_sdk_extensions; }); + + let private_mod = Ident::new(&format!("__private_{}", world.name), call_site); + + let mut impl_private_host_traits = Vec::new(); + + let host_trait = { + let package = world.package.and_then(|package| resolve.packages.get(package)); + + let package_namespace = + package.map(|package| Ident::new(&package.name.namespace.to_snake_case(), call_site)); + let package_name = + package.map(|package| Ident::new(&package.name.name.to_snake_case(), call_site)); + + let mut imports = Vec::new(); + + for (_import_key, import) in world.imports.iter() { + match import { + WorldItem::Interface(interface_id) => { + let interface = resolve.interfaces.get(*interface_id).unwrap(); + + let interface_name = interface + .name + .as_ref() + .map(|name| Ident::new(&name.to_snake_case(), call_site)); + + let trait_path = { + let mut trait_path = quote! { Host }; + + if let Some(interface_name) = &interface_name { + trait_path = quote! { #interface_name :: #trait_path }; + } + + if let (Some(package_namespace), Some(package_name)) = + (&package_namespace, &package_name) + { + trait_path = + quote! { #package_namespace :: #package_name :: #trait_path }; + } + + trait_path + }; + + let mut trait_functions = Vec::new(); + let mut impl_private_host_trait_functions = Vec::new(); + + for import in interface.functions.values() { + let trait_function_name = + Ident::new(&import.name.to_snake_case(), call_site); + let (argument_names, argument_types) = import + .params + .iter() + .map(|(name, ty)| { + let name = Ident::new(&name.to_snake_case(), call_site); + let ty = Ident::new(&to_rust_type(ty), call_site); + + (name, ty) + }) + .unzip::<_, _, Vec<_>, Vec<_>>(); + let results = match &import.results { + Results::Named(results) => match results.len() { + 0 => "()".to_owned(), + 1 => to_rust_type(&results[0].1), + _ => results.iter().fold(String::new(), |mut acc, (name, ty)| { + acc.push_str(&format!( + "{name}: {ty}, ", + ty = to_rust_type(&ty) + )); + acc + }), + }, + r => unimplemented!("{:?}", r), + } + .parse::() + .unwrap(); + + trait_functions.push(quote! { + fn #trait_function_name( &mut self #( , #argument_names : #argument_types )* ) -> matrix_sdk_extensions::Result< #results >; + }); + + impl_private_host_trait_functions.push(quote! { + fn #trait_function_name( &mut self #( , #argument_names : #argument_types )* ) -> matrix_sdk_extensions::Result< #results > { + #trait_path :: #trait_function_name(self #( , #argument_names )* ) + } + }); + } + + let mut import = quote! { + pub trait Host { + #( #trait_functions )* + } + }; + + if let Some(interface_name) = interface_name { + import = quote! { + pub mod #interface_name { + #use_matrix_sdk_extensions + + #import + } + }; + } + + imports.push(import); + impl_private_host_traits.push(quote! { + impl #private_mod :: #trait_path for #environment_type { + #( #impl_private_host_trait_functions )* + } + }) + } + i => unimplemented!("{:?}", i), + } + } + + let mut output = quote! { + #( #imports )* + }; + + if let (Some(package_namespace), Some(package_name)) = (package_namespace, package_name) { + output = quote! { + pub mod #package_namespace { + pub mod #package_name { + #output + } + } + }; + } + + output + }; + + let impl_module = { + quote! { + struct #module_type; + + impl matrix_sdk_extensions::traits::Module for #module_type { + type Environment = #environment_type; + type Bindings = #private_mod::#world_type; + + fn new_environment() -> Self::Environment { + #environment_type::default() + } + } + + impl matrix_sdk_extensions::native::ModuleExt<#environment_type, #private_mod::#world_type> for #module_type { + fn link( + linker: &mut wasmtime::component::Linker<#environment_type>, + get: impl Fn(&mut #environment_type) -> &mut #environment_type + + Send + + Sync + + Copy + + 'static, + ) -> matrix_sdk_extensions::Result<()> { + #private_mod::#world_type::add_to_linker(linker, get) + } + + fn instantiate_component( + store: &mut wasmtime::Store<#environment_type>, + component: &wasmtime::component::Component, + linker: &wasmtime::component::Linker<#environment_type>, + ) -> matrix_sdk_extensions::Result<#private_mod::#world_type> { + let (bindings, _) = #private_mod::#world_type::instantiate(store, component, linker)?; + + Ok(bindings) + } + } + } + }; + + let instance_alias = { + let ident = Ident::new(&format!("{}Instance", world_type_name), call_site); + + quote! { + type #ident = matrix_sdk_extensions::native::NativeInstance<#module_type>; + } + }; + + quote! { + mod #private_mod { + #generated + }; + + #use_matrix_sdk_extensions; + + #host_trait + + #( #impl_private_host_traits )* + + #impl_module + + #instance_alias + } + .into() +} + +#[cfg(feature = "javascriptcore")] +#[proc_macro] +pub fn javascriptcore_bindgen(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let call_site = Span::call_site(); + + let configuration = parse_macro_input!(input as Configuration); + + let resolve = &configuration.resolve; + let world = &resolve.worlds[configuration.world]; + let world_type_name = to_rust_upper_camel_case(&world.name); + let world_type = Ident::new(&world_type_name, call_site); + let module_type = Ident::new(&format!("{}Module", world_type_name), call_site); + let environment_type = &configuration.environment_type; + + let use_matrix_sdk_extensions = configuration + .matrix_sdk_extensions_alias + .map(|alias| quote! { use #alias as matrix_sdk_extensions; }); + + let private_mod = Ident::new(&format!("__private_{}", world.name), call_site); + + let mut add_to_linkers = Vec::new(); + + let host_trait = { + let package = world.package.and_then(|package| resolve.packages.get(package)); + + let mut imports = Vec::new(); + + for (_import_key, import_item) in world.imports.iter() { + match import_item { + WorldItem::Interface(interface_id) => { + let interface = resolve.interfaces.get(*interface_id).unwrap(); + + let mut trait_functions = Vec::new(); + let mut bindings = Vec::new(); + + for import in interface.functions.values() { + let trait_function_name = + Ident::new(&import.name.to_snake_case(), call_site); + let ((argument_names, argument_indexed_names), argument_types) = import + .params + .iter() + .enumerate() + .map(|(nth, (name, ty))| { + let name = Ident::new(&name.to_snake_case(), call_site); + let indexed_name = Ident::new(&format!("arg{nth}"), call_site); + let ty = Ident::new(&to_rust_type(ty), call_site); + + ((name, indexed_name), ty) + }) + .unzip::<_, _, (Vec<_>, Vec<_>), Vec<_>>(); + let results = match &import.results { + Results::Named(results) => match results.len() { + 0 => "()".to_owned(), + 1 => to_rust_type(&results[0].1), + _ => results.iter().fold(String::new(), |mut acc, (name, ty)| { + acc.push_str(&format!( + "{name}: {ty}, ", + ty = to_rust_type(&ty) + )); + acc + }), + }, + r => unimplemented!("{:?}", r), + } + .parse::() + .unwrap(); + + trait_functions.push(quote! { + fn #trait_function_name( &mut self #( , #argument_names : #argument_types )* ) -> matrix_sdk_extensions::Result< #results >; + }); + + bindings.push(quote! { + { + #[function_callback] + fn js_function( + context: &JSContext, + _function: Option<&JSObject>, + this_object: Option<&JSObject>, + arguments: &[JSValue], + ) -> core::result::Result + where + Environment: Host, + { + #use_matrix_sdk_extensions + + use matrix_sdk_extensions::javascriptcore::from_into::TryIntoRust; + + let this_object = this_object.expect("`this_object` is `None`"); + let env_ptr = this_object.as_number().expect("`this_object` must be a number") as usize; + let env = unsafe { std::sync::Arc::from_raw(env_ptr as *const std::sync::Mutex) }; + let mut env_lock = env.lock().unwrap(); + let env_mut: &mut Environment = &mut env_lock; + + let mut arguments = arguments.iter(); + + #( let #argument_indexed_names: #argument_types = arguments + .next() + .expect(concat!("Argument `", stringify!( #argument_indexed_names ), "` is missing")) + .try_into_rust()?; )* + + Host:: #trait_function_name (env_mut #( , #argument_indexed_names )* ).unwrap(); + + Ok(JSValue::new_undefined(context)) + } + + let js_function_name = stringify!( #trait_function_name ); + let function = JSValue::new_function(&context, js_function_name, Some(js_function::)) + .as_object() + .unwrap(); + + namespace + .set_property( + js_function_name, + function + .get_property("bind") + .as_object() + .unwrap() + .call_as_function( + Some(&function), + &[JSValue::new_number( + context, + // FIXME: converting from u64 to f64 loss precision, and can be dramatic. + // Use the `conv` crate instead? + std::sync::Arc::into_raw(environment.clone()) as usize as u64 as f64, + )], + ) + .unwrap(), + ) + .unwrap(); + } + }) + } + + let import = quote! { + pub trait Host { + #( #trait_functions )* + } + + pub fn add_to_linker( + context: &matrix_sdk_extensions::javascriptcore::JSContext, + imports: &matrix_sdk_extensions::javascriptcore::JSObject, + environment: &std::sync::Arc>, + ) -> matrix_sdk_extensions::Result<()> + where + Environment: Host, + { + use matrix_sdk_extensions::javascriptcore::{function_callback, JSContext, JSException, JSObject, JSValue}; + + imports.set_property("matrix:ui-timeline/std", JSValue::new_from_json(context, "{}").unwrap()).unwrap(); + let namespace = imports.get_property("matrix:ui-timeline/std").as_object().unwrap(); + + #( #bindings )* + + Ok(()) + } + }; + + if let Some(interface_name) = &interface.name { + let interface_name = Ident::new(&interface_name.to_snake_case(), call_site); + + imports.push(quote! { + pub mod #interface_name { + #use_matrix_sdk_extensions + + #import + } + }); + add_to_linkers.push(quote! { #interface_name ::add_to_linker }); + } else { + imports.push(import); + add_to_linkers.push(quote! { add_to_linker }); + } + } + i => unimplemented!("{:?}", i), + } + } + + let mut output = quote! { + #( #imports )* + }; + + if let Some(package) = package { + let package_namespace = Ident::new(&package.name.namespace.to_snake_case(), call_site); + let package_name = Ident::new(&package.name.name.to_snake_case(), call_site); + + output = quote! { + pub mod #package_namespace { + pub mod #package_name { + #output + } + } + }; + + add_to_linkers = add_to_linkers + .iter() + .map(|add_to_linker| { + quote! { + #package_namespace :: #package_name :: #add_to_linker + } + }) + .collect(); + } + + output + }; + + let impl_module = { + quote! { + struct #module_type; + + impl matrix_sdk_extensions::traits::Module for #module_type { + type Environment = #environment_type; + type Bindings = #private_mod :: #world_type; + + fn new_environment() -> Self::Environment { + #environment_type ::default() + } + } + + impl matrix_sdk_extensions::javascriptcore::ModuleExt< #environment_type > for #module_type { + fn link( + context: &matrix_sdk_extensions::javascriptcore::JSContext, + imports: &matrix_sdk_extensions::javascriptcore::JSObject, + environment: &std::sync::Arc>, + ) -> matrix_sdk_extensions::Result<()> { + #( #add_to_linkers ::< #environment_type >(context, imports, environment)?; )* + + Ok(()) + } + } + } + }; + + let instance_alias = { + let ident = Ident::new(&format!("{}Instance", world_type_name), call_site); + + quote! { + type #ident = matrix_sdk_extensions::javascriptcore::JSInstance<#module_type>; + } + }; + + quote! { + mod #private_mod { + #use_matrix_sdk_extensions + + pub struct #world_type; + } + + #use_matrix_sdk_extensions + + #host_trait + + #impl_module + + #instance_alias + } + .into() +} diff --git a/crates/matrix-sdk-extensions/Cargo.toml b/crates/matrix-sdk-extensions/Cargo.toml new file mode 100644 index 00000000000..4a0d7e289b8 --- /dev/null +++ b/crates/matrix-sdk-extensions/Cargo.toml @@ -0,0 +1,18 @@ +[package] +authors = ["Ivan Enderlin "] +edition = "2021" +name = "matrix-sdk-extensions" +repository = "https://github.com/matrix-org/matrix-rust-sdk" +rust-version = { workspace = true } +version = "0.0.1" + +[features] +default = ["native", "javascriptcore"] +native = ["dep:wasmtime", "matrix-sdk-extensions-macros/wasmtime"] +javascriptcore = ["dep:javascriptcore", "matrix-sdk-extensions-macros/javascriptcore"] + +[dependencies] +matrix-sdk-extensions-macros = { path = "../matrix-sdk-extensions-macros", default-features = false } +wasmtime = { version ="13.0.0", features = ["component-model"], optional = true } +javascriptcore = { git = "https://github.com/endoli/javascriptcore.rs", branch = "main", optional = true } +anyhow.workspace = true diff --git a/crates/matrix-sdk-extensions/Makefile b/crates/matrix-sdk-extensions/Makefile new file mode 100644 index 00000000000..916a1753d49 --- /dev/null +++ b/crates/matrix-sdk-extensions/Makefile @@ -0,0 +1,9 @@ +build-all-guests: build-timeline-guest transpile-timeline-guest-to-js + +build-timeline-guest: + cd guests/timeline && \ + cargo build --target wasm32-unknown-unknown --release && \ + wasm-tools component new target/wasm32-unknown-unknown/release/timeline.wasm -o ../../timeline.wasm + +transpile-timeline-guest-to-js: + jco transpile --instantiation sync --optimize --no-typescript --no-nodejs-compat --js --out-dir guests/timeline/js/ timeline.wasm diff --git a/crates/matrix-sdk-extensions/guests/timeline/.gitignore b/crates/matrix-sdk-extensions/guests/timeline/.gitignore new file mode 100644 index 00000000000..7dcbbb0b925 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/.gitignore @@ -0,0 +1 @@ +/timeline.wasm diff --git a/crates/matrix-sdk-extensions/guests/timeline/Cargo.lock b/crates/matrix-sdk-extensions/guests/timeline/Cargo.lock new file mode 100644 index 00000000000..9e94140cdd1 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/Cargo.lock @@ -0,0 +1,1640 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "arbitrary" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d098ff73c1ca148721f37baad5ea6a465a13f9573aba8641fbbbae8164a54e" + +[[package]] +name = "async-trait" +version = "0.1.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b9d1a9e776c27ad55d7792a380785d1fe8c2d7b099eed8dbd8f4af2b598192" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5528483314c2dd5da438576cd8a9d0b3cedad66fb8a4727f90cd319a81950038" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.1", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f46a8318163f7682e35b8730ba93c1b586a2da8ce12a0ed545efc1218550f70" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37d1239cfd50eecfaed468d46943f8650e32969591868ad50111613704da6c70" + +[[package]] +name = "cranelift-control" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcc530560c8f16cc1d4dd7ea000c56f519c60d1a914977abe849ce555c35a61d" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f333fa641a9ad2bff0b107767dcb972c18c2bfab7969805a1d7e42449ccb0408" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abf6563015a80f03f8bc4df307d0a81363f4eb73108df3a34f6e66fb6d5307" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eb29d0edc8a5c029ed0f7ca77501f272738e3c410020b4a00f42ffe8ad2a8aa" + +[[package]] +name = "cranelift-native" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "006056a7fa920870bad06bf8e1b3033d70cbb7ee625b035efa9d90882a931868" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.100.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b3d08c05f82903a1f6a04d89c4b9ecb47a4035710f89a39a21a147a80214672" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser 0.112.0", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "uuid", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "encoding_rs" +version = "0.8.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add4f07d43996f76ef320709726a556a9d4f965d9410d8d0271132d2f8293480" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "fxprof-processed-profile" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27d12c0aed7f1e24276a241aadc4cb8ea9f83000f34bc062b7cc2d51e3b0fabd" +dependencies = [ + "bitflags 2.4.0", + "debugid", + "fxhash", + "serde", + "serde_json", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +dependencies = [ + "ahash", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.1", + "serde", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "ittapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41e0d0b7b3b53d92a7e8b80ede3400112a6b8b4c98d1f5b8b16bb787c780582c" +dependencies = [ + "anyhow", + "ittapi-sys", + "log", +] + +[[package]] +name = "ittapi-sys" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f8763c96e54e6d6a0dccc2990d8b5e33e3313aaeae6185921a3f4c1614a77c" +dependencies = [ + "cc", +] + +[[package]] +name = "jobserver" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "936cfd212a0155903bcbc060e316fb6cc7cbf2e1907329391ebadc1fe0ce77c2" +dependencies = [ + "libc", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.148" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" + +[[package]] +name = "linux-raw-sys" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3852614a3bd9ca9804678ba6be5e3b8ce76dfc902cae004e3e0c44051b6e88db" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "crc32fast", + "hashbrown 0.14.1", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro2" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "pulldown-cmark" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998" +dependencies = [ + "bitflags 1.3.2", + "memchr", + "unicase", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[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", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regalloc2" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4dcbd3a2ae7fb94b5813fa0e957c6ab51bf5d0a8ee1b69e0c2d0f1e6eb8485" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f9da0cbd88f9f09e7814e388301c8414c51c62aa6ce1e4b5c551d49d96e531" +dependencies = [ + "bitflags 2.4.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" + +[[package]] +name = "serde" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "spdx" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b19b32ed6d899ab23174302ff105c1577e45a06b08d4fe0a9dd13ce804bbbf71" +dependencies = [ + "smallvec", +] + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "2.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" + +[[package]] +name = "thiserror" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "timeline" +version = "0.1.0" +dependencies = [ + "wasmtime", + "wit-bindgen", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-encoder" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba64e81215916eaeb48fee292f29401d69235d62d8b8fd92a7b2844ec5ae5f7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-encoder" +version = "0.33.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34180c89672b3e4825c3a8db4b61a674f1447afd5fe2445b2d22c3d8b6ea086c" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasm-metadata" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "577508d8a45bc54ad97efe77c95ba57bb10e7e5c5bac9c31295ce88b8045cd7d" +dependencies = [ + "anyhow", + "indexmap", + "serde", + "serde_json", + "spdx", + "wasm-encoder 0.33.2", + "wasmparser 0.113.2", +] + +[[package]] +name = "wasmparser" +version = "0.112.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e986b010f47fcce49cf8ea5d5f9e5d2737832f12b53ae8ae785bbe895d0877bf" +dependencies = [ + "indexmap", + "semver", +] + +[[package]] +name = "wasmparser" +version = "0.113.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0d44fab0bd78404e352f3399324eef76516a4580b52bc9031c60f064e98f3" +dependencies = [ + "indexmap", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.2.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6615a5587149e753bf4b93f90fa3c3f41c88597a7a2da72879afcabeda9648f" +dependencies = [ + "anyhow", + "wasmparser 0.113.2", +] + +[[package]] +name = "wasmtime" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16ed7db409c1acf60d33128b2a38bee25aaf38c4bd955ab98a5b623c8294593c" +dependencies = [ + "anyhow", + "async-trait", + "bincode", + "bumpalo", + "cfg-if", + "encoding_rs", + "fxprof-processed-profile", + "indexmap", + "libc", + "log", + "object", + "once_cell", + "paste", + "psm", + "rayon", + "serde", + "serde_derive", + "serde_json", + "target-lexicon", + "wasm-encoder 0.32.0", + "wasmparser 0.112.0", + "wasmtime-cache", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-runtime", + "wasmtime-winch", + "wat", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53af0f8f6271bd687fe5632c8fe0a0f061d0aa1b99a0cd4e1df8e4cbeb809d2f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cache" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41376a7c094335ee08abe6a4eff79a32510cc805a249eff1b5e7adf0a42e7cdf" +dependencies = [ + "anyhow", + "base64", + "bincode", + "directories-next", + "log", + "rustix", + "serde", + "serde_derive", + "sha2", + "toml", + "windows-sys", + "zstd", +] + +[[package]] +name = "wasmtime-component-macro" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74ab5b291f2dad56f1e6929cc61fb7cac68845766ca77c3838b5d05d82c33976" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21436177bf19f6b60dc0b83ad5872e849892a4a90c3572785e1a28c0e2e1132c" + +[[package]] +name = "wasmtime-cranelift" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "920e42058862d1f7a3dd3fca73cb495a20d7506e3ada4bbc0a9780cd636da7ca" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser 0.112.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516d63bbe18219e64a9705cf3a2c865afe1fb711454ea03091dc85a1d708194d" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-control", + "cranelift-native", + "gimli", + "object", + "target-lexicon", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cef239d663885f1427f8b8f4fde7be6075249c282580d94b480f11953ca194" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "serde", + "serde_derive", + "target-lexicon", + "thiserror", + "wasm-encoder 0.32.0", + "wasmparser 0.112.0", + "wasmprinter", + "wasmtime-component-util", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-fiber" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef118b557df6193cd82cfb45ab57cd12388fedfe2bb76f090b2d77c96c1b56e" +dependencies = [ + "cc", + "cfg-if", + "rustix", + "wasmtime-asm-macros", + "wasmtime-versioned-export-macros", + "windows-sys", +] + +[[package]] +name = "wasmtime-jit" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8089d5909b8f923aad57702ebaacb7b662aa9e43a3f71e83e025c5379a1205f" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "ittapi", + "log", + "object", + "rustc-demangle", + "rustix", + "serde", + "serde_derive", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b13924aedf6799ad66edb25500a20e3226629978b30a958c55285352bad130a" +dependencies = [ + "object", + "once_cell", + "rustix", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6ff5f3707a5e3797deeeeac6ac26b2e1dd32dbc06693c0ab52e8ac4d18ec706" +dependencies = [ + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-runtime" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ab4ce04ac05342edfa7f42895f2a5d8b16ee914330869acb865cd1facf265f" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "encoding_rs", + "indexmap", + "libc", + "log", + "mach", + "memfd", + "memoffset", + "paste", + "rand", + "rustix", + "sptr", + "wasm-encoder 0.32.0", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "wasmtime-versioned-export-macros", + "wasmtime-wmemcheck", + "windows-sys", +] + +[[package]] +name = "wasmtime-types" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecf61e21d5bd95e1ad7fa42b7bdabe21220682d6a6046d376edca29760849222" +dependencies = [ + "cranelift-entity", + "serde", + "serde_derive", + "thiserror", + "wasmparser 0.112.0", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe877472cbdd6d96b4ecdc112af764e3b9d58c2e4175a87828f892ab94c60643" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "wasmtime-winch" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bc5a770003807c55f2187a0092dea01722b0e24151e35816bd5091538bb8e88" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser 0.112.0", + "wasmtime-cranelift-shared", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62003d48822f89cc393e93643366ddbee1766779c0874353b8ba2ede4679fbf9" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "wasmtime-wmemcheck" +version = "13.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5412bb464066d64c3398c96e6974348f90fa2a55110ad7da3f9295438cd4de84" + +[[package]] +name = "wast" +version = "65.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a55a88724cf8c2c0ebbf32c8e8f4ac0d6aa7ba6d73a1cfd94b254aa8f894317e" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder 0.33.2", +] + +[[package]] +name = "wat" +version = "1.0.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83e1a8d86d008adc7bafa5cf4332d448699a08fcf2a715a71fbb75e2c5ca188" +dependencies = [ + "wast", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winch-codegen" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50647204d600a2a112eefac0645ba6653809a15bd362c7e4e6a049a5bdff0de9" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser 0.112.0", + "wasmtime-environ", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "wit-bindgen" +version = "0.12.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?branch=main#9c834db09a7f0c78ffacceb94c8186e9cec60dda" +dependencies = [ + "bitflags 2.4.0", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.12.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?branch=main#9c834db09a7f0c78ffacceb94c8186e9cec60dda" +dependencies = [ + "anyhow", + "wit-component", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.12.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?branch=main#9c834db09a7f0c78ffacceb94c8186e9cec60dda" +dependencies = [ + "anyhow", + "heck", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.12.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?branch=main#9c834db09a7f0c78ffacceb94c8186e9cec60dda" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", + "wit-component", +] + +[[package]] +name = "wit-component" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee23614740bf871dac9856e3062c7a308506eb3f0a2759939ab8d0aa8436a1c0" +dependencies = [ + "anyhow", + "bitflags 2.4.0", + "indexmap", + "log", + "serde", + "serde_json", + "wasm-encoder 0.33.2", + "wasm-metadata", + "wasmparser 0.113.2", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39edca9abb16309def3843af73b58d47d243fe33a9ceee572446bcc57556b9a" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "pulldown-cmark", + "semver", + "serde", + "serde_json", + "unicode-xid", + "url", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.8+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" +dependencies = [ + "cc", + "libc", + "pkg-config", +] diff --git a/crates/matrix-sdk-extensions/guests/timeline/Cargo.toml b/crates/matrix-sdk-extensions/guests/timeline/Cargo.toml new file mode 100644 index 00000000000..3d565755597 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "timeline" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +wit-bindgen = { git = "https://github.com/bytecodealliance/wit-bindgen", branch = "main" } + +[dev-dependencies] +wasmtime = { version = "13.0.0", features = ["component-model"] } \ No newline at end of file diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/interfaces/matrix-ui-timeline-std.d.ts b/crates/matrix-sdk-extensions/guests/timeline/js/interfaces/matrix-ui-timeline-std.d.ts new file mode 100644 index 00000000000..948c2000a03 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/js/interfaces/matrix-ui-timeline-std.d.ts @@ -0,0 +1,3 @@ +export namespace MatrixUiTimelineStd { + export function print(msg: string): void; +} diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core.wasm b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core.wasm new file mode 100644 index 00000000000..f9caaa8baf7 Binary files /dev/null and b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core.wasm differ diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core2.wasm b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core2.wasm new file mode 100644 index 00000000000..2bf8d22b0a0 Binary files /dev/null and b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core2.wasm differ diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core3.wasm b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core3.wasm new file mode 100644 index 00000000000..f345dda5a93 Binary files /dev/null and b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.core3.wasm differ diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/timeline.d.ts b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.d.ts new file mode 100644 index 00000000000..440aca3a03b --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.d.ts @@ -0,0 +1,33 @@ +import { MatrixUiTimelineStd } from './interfaces/matrix-ui-timeline-std.js'; +export interface ImportObject { + 'matrix:ui-timeline/std': typeof MatrixUiTimelineStd, +} +export interface Root { + greet(who: string): void, +} + +/** +* Instantiates this component with the provided imports and +* returns a map of all the exports of the component. +* +* This function is intended to be similar to the +* `WebAssembly.Instantiate` constructor. The second `imports` +* argument is the "import object" for wasm, except here it +* uses component-model-layer types instead of core wasm +* integers/numbers/etc. +* +* The first argument to this function, `getCoreModule`, is +* used to compile core wasm modules within the component. +* Components are composed of core wasm modules and this callback +* will be invoked per core wasm module. The caller of this +* function is responsible for reading the core wasm module +* identified by `path` and returning its compiled +* `WebAssembly.Module` object. This would use the +* `WebAssembly.Module` constructor on the web, for example. +*/ +export function instantiate( +getCoreModule: (path: string) => WebAssembly.Module, +imports: ImportObject, +instantiateCore?: (module: WebAssembly.Module, imports: Record) => WebAssembly.Instance +): Root; + diff --git a/crates/matrix-sdk-extensions/guests/timeline/js/timeline.js b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.js new file mode 100644 index 00000000000..9f39b17f8f2 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/js/timeline.js @@ -0,0 +1,3519 @@ +const utf8Decoder = new TextDecoder(); + +const utf8Encoder = new TextEncoder(); + +let utf8EncodedLen = 0; +function utf8Encode(s, realloc, memory) { + if (typeof s !== 'string') throw new TypeError('expected a string'); + if (s.length === 0) { + utf8EncodedLen = 0; + return 1; + } + let allocLen = 0; + let ptr = 0; + let writtenTotal = 0; + while (s.length > 0) { + ptr = realloc(ptr, allocLen, 1, allocLen += s.length * 2); + const { read, written } = utf8Encoder.encodeInto( + s, + new Uint8Array(memory.buffer, ptr + writtenTotal, allocLen - writtenTotal), + ); + writtenTotal += written; + s = s.slice(read); + } + utf8EncodedLen = writtenTotal; + return ptr; +} + +function _instantiate(getCoreModule, imports, instantiateCore = WebAssembly.Instance) { + const module0 = getCoreModule('timeline.core.wasm'); + const module1 = getCoreModule('timeline.core2.wasm'); + const module2 = getCoreModule('timeline.core3.wasm'); + + const { print } = imports['matrix:ui-timeline/std']; + let exports0; + let exports1; + + function trampoline0(arg0, arg1) { + var ptr0 = arg0; + var len0 = arg1; + var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0)); + print(result0); + } + let memory0; + let exports2; + let realloc0; + ({ exports: exports0 } = instantiateCore(module1)); + ({ exports: exports1 } = instantiateCore(module0, { + 'matrix:ui-timeline/std': { + print: exports0['$0'], + }, + })); + memory0 = exports1.memory; + ({ exports: exports2 } = instantiateCore(module2, { + '': { + $imports: exports0.$imports, + '0': trampoline0, + }, + })); + realloc0 = exports1.cabi_realloc; + + function greet(arg0) { + var ptr0 = utf8Encode(arg0, realloc0, memory0); + var len0 = utf8EncodedLen; + exports1.greet(ptr0, len0); + } + + return { greet, }; +} + + +const asmInit = [function asm0(imports) { + var bufferView; + var base64ReverseLookup = new Uint8Array(123/*'z'+1*/); + for (var i = 25; i >= 0; --i) { + base64ReverseLookup[48+i] = 52+i; // '0-9' + base64ReverseLookup[65+i] = i; // 'A-Z' + base64ReverseLookup[97+i] = 26+i; // 'a-z' + } + base64ReverseLookup[43] = 62; // '+' + base64ReverseLookup[47] = 63; // '/' + /** @noinline Inlining this function would mean expanding the base64 string 4x times in the source code, which Closure seems to be happy to do. */ + function base64DecodeToExistingUint8Array(uint8Array, offset, b64) { + var b1, b2, i = 0, j = offset, bLength = b64.length, end = offset + (bLength*3>>2) - (b64[bLength-2] == '=') - (b64[bLength-1] == '='); + for (; i < bLength; i += 4) { + b1 = base64ReverseLookup[b64.charCodeAt(i+1)]; + b2 = base64ReverseLookup[b64.charCodeAt(i+2)]; + uint8Array[j++] = base64ReverseLookup[b64.charCodeAt(i)] << 2 | b1 >> 4; + if (j < end) uint8Array[j++] = b1 << 4 | b2 >> 2; + if (j < end) uint8Array[j++] = b2 << 6 | base64ReverseLookup[b64.charCodeAt(i+3)]; + } + return uint8Array; + } +function initActiveSegments(imports) { + base64DecodeToExistingUint8Array(bufferView, 1048576, "SGVsbG8sICEAABAABwAAAAcAEAABAAAABAAAAAQAAAAEAAAABQAAAAYAAAAHAAAAY2FsbGVkIGBPcHRpb246OnVud3JhcCgpYCBvbiBhIGBOb25lYCB2YWx1ZW1lbW9yeSBhbGxvY2F0aW9uIG9mICBieXRlcyBmYWlsZWQAAABbABAAFQAAAHAAEAANAAAAbGlicmFyeS9zdGQvc3JjL2FsbG9jLnJzkAAQABgAAABiAQAACQAAAGxpYnJhcnkvc3RkL3NyYy9wYW5pY2tpbmcucnO4ABAAHAAAAGkCAAAfAAAAuAAQABwAAABqAgAAHgAAAAgAAAAMAAAABAAAAAkAAAAEAAAACAAAAAQAAAAKAAAABAAAAAgAAAAEAAAACwAAAAwAAAANAAAAEAAAAAQAAAAOAAAADwAAABAAAAAAAAAAAQAAABEAAAASAAAABAAAAAQAAAATAAAAFAAAABUAAABsaWJyYXJ5L2FsbG9jL3NyYy9yYXdfdmVjLnJzY2FwYWNpdHkgb3ZlcmZsb3cAAACAARAAEQAAAGQBEAAcAAAAFgIAAAUAAABhIGZvcm1hdHRpbmcgdHJhaXQgaW1wbGVtZW50YXRpb24gcmV0dXJuZWQgYW4gZXJyb3IAFgAAAAAAAAABAAAAFwAAAGxpYnJhcnkvYWxsb2Mvc3JjL2ZtdC5yc/ABEAAYAAAAYgIAACAAAAAbAAAAAAAAAAEAAAAcAAAAOiAAABgCEAAAAAAAKAIQAAIAAAAwMDAxMDIwMzA0MDUwNjA3MDgwOTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMyNDI1MjYyNzI4MjkzMDMxMzIzMzM0MzUzNjM3MzgzOTQwNDE0MjQzNDQ0NTQ2NDc0ODQ5NTA1MTUyNTM1NDU1NTY1NzU4NTk2MDYxNjI2MzY0NjU2NjY3Njg2OTcwNzE3MjczNzQ3NTc2Nzc3ODc5ODA4MTgyODM4NDg1ODY4Nzg4ODk5MDkxOTI5Mzk0OTU5Njk3OTg5OUVycm9y"); +} +function wasm2js_trap() { throw new Error('abort'); } + + + var buffer = new ArrayBuffer(1114112); + var HEAP8 = new Int8Array(buffer); + var HEAP16 = new Int16Array(buffer); + var HEAP32 = new Int32Array(buffer); + var HEAPU8 = new Uint8Array(buffer); + var HEAPU16 = new Uint16Array(buffer); + var HEAPU32 = new Uint32Array(buffer); + var HEAPF32 = new Float32Array(buffer); + var HEAPF64 = new Float64Array(buffer); + var Math_imul = Math.imul; + var Math_fround = Math.fround; + var Math_abs = Math.abs; + var Math_clz32 = Math.clz32; + var Math_min = Math.min; + var Math_max = Math.max; + var Math_floor = Math.floor; + var Math_ceil = Math.ceil; + var Math_trunc = Math.trunc; + var Math_sqrt = Math.sqrt; + var nan = NaN; + var infinity = Infinity; + var matrix_ui_timeline_std = imports["matrix:ui-timeline/std"]; + var fimport$0 = matrix_ui_timeline_std.print; + var global$0 = 1048576; + var global$1 = 1049841; + var global$2 = 1049856; + var i64toi32_i32$HIGH_BITS = 0; + function $1($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return $93($1_1, HEAP32[$0 >> 2], HEAP32[$0 + 8 >> 2]) | 0; + } + + function $2($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0; + $2_1 = global$0 - 80 | 0; + global$0 = $2_1; + if (!HEAPU8[1049358]) { + HEAP8[1049358] = 1 + } + HEAP32[$2_1 + 20 >> 2] = $1_1; + HEAP32[$2_1 + 16 >> 2] = $1_1; + HEAP32[$2_1 + 12 >> 2] = $0; + $1_1 = $2_1 + 12 | 0; + $3_1 = HEAP32[$1_1 + 4 >> 2]; + $0 = $2_1 + 24 | 0; + HEAP32[$0 >> 2] = HEAP32[$1_1 >> 2]; + HEAP32[$0 + 4 >> 2] = $3_1; + HEAP32[$0 + 8 >> 2] = HEAP32[$1_1 + 8 >> 2]; + HEAP32[$2_1 + 60 >> 2] = 1; + HEAP32[$2_1 + 64 >> 2] = 0; + HEAP32[$2_1 + 52 >> 2] = 2; + HEAP32[$2_1 + 48 >> 2] = 1048584; + HEAP32[$2_1 + 76 >> 2] = 1; + HEAP32[$2_1 + 56 >> 2] = $2_1 + 72; + HEAP32[$2_1 + 72 >> 2] = $0; + $6 = $2_1 + 36 | 0; + $3_1 = global$0 - 32 | 0; + global$0 = $3_1; + label$1 : { + label$2 : { + label$3 : { + label$4 : { + label$5 : { + $4 = $2_1 + 48 | 0; + $0 = HEAP32[$4 + 4 >> 2]; + label$6 : { + if (!$0) { + break label$6 + } + $7 = HEAP32[$4 >> 2]; + $5_1 = $0 & 3; + label$7 : { + if ($0 >>> 0 < 4) { + $0 = 0; + break label$7; + } + $1_1 = $7 + 28 | 0; + $9 = $0 & -4; + $0 = 0; + while (1) { + $0 = HEAP32[$1_1 >> 2] + (HEAP32[$1_1 - 8 >> 2] + (HEAP32[$1_1 - 16 >> 2] + (HEAP32[$1_1 - 24 >> 2] + $0 | 0) | 0) | 0) | 0; + $1_1 = $1_1 + 32 | 0; + $8_1 = $8_1 + 4 | 0; + if (($9 | 0) != ($8_1 | 0)) { + continue + } + break; + }; + } + if ($5_1) { + $1_1 = (($8_1 << 3) + $7 | 0) + 4 | 0; + while (1) { + $0 = HEAP32[$1_1 >> 2] + $0 | 0; + $1_1 = $1_1 + 8 | 0; + $5_1 = $5_1 - 1 | 0; + if ($5_1) { + continue + } + break; + }; + } + if (HEAP32[$4 + 12 >> 2]) { + if (!HEAP32[$7 + 4 >> 2] & $0 >>> 0 < 16 | ($0 | 0) < 0) { + break label$6 + } + $0 = $0 << 1; + } + if ($0) { + break label$5 + } + } + $1_1 = 1; + $0 = 0; + break label$4; + } + if (($0 | 0) < 0) { + break label$3 + } + $1_1 = $3($0, 1); + if (!$1_1) { + break label$2 + } + } + HEAP32[$3_1 + 20 >> 2] = 0; + HEAP32[$3_1 + 16 >> 2] = $0; + HEAP32[$3_1 + 12 >> 2] = $1_1; + HEAP32[$3_1 + 24 >> 2] = $3_1 + 12; + if (!$96($3_1 + 24 | 0, 1048908, $4)) { + break label$1 + } + $0 = global$0 + -64 | 0; + global$0 = $0; + HEAP32[$0 + 12 >> 2] = 51; + HEAP32[$0 + 8 >> 2] = 1049004; + HEAP32[$0 + 20 >> 2] = 1049056; + HEAP32[$0 + 16 >> 2] = $3_1 + 31; + HEAP32[$0 + 36 >> 2] = 2; + HEAP32[$0 + 40 >> 2] = 0; + HEAP32[$0 + 60 >> 2] = 25; + HEAP32[$0 + 28 >> 2] = 2; + HEAP32[$0 + 24 >> 2] = 1049132; + HEAP32[$0 + 52 >> 2] = 26; + HEAP32[$0 + 32 >> 2] = $0 + 48; + HEAP32[$0 + 56 >> 2] = $0 + 16; + HEAP32[$0 + 48 >> 2] = $0 + 8; + $92($0 + 24 | 0, 1049096); + wasm2js_trap(); + } + $87(); + wasm2js_trap(); + } + $86(1, $0); + wasm2js_trap(); + } + $0 = HEAP32[$3_1 + 16 >> 2]; + HEAP32[$6 >> 2] = HEAP32[$3_1 + 12 >> 2]; + HEAP32[$6 + 4 >> 2] = $0; + HEAP32[$6 + 8 >> 2] = HEAP32[$3_1 + 20 >> 2]; + global$0 = $3_1 + 32 | 0; + $0 = HEAP32[$2_1 + 40 >> 2]; + $1_1 = HEAP32[$2_1 + 36 >> 2]; + fimport$0($1_1 | 0, HEAP32[$2_1 + 44 >> 2]); + if ($0) { + $26($1_1) + } + if (HEAP32[$2_1 + 28 >> 2]) { + $26(HEAP32[$2_1 + 24 >> 2]) + } + global$0 = $2_1 + 80 | 0; + } + + function $3($0, $1_1) { + __inlined_func$33 : { + if ($1_1 >>> 0 >= 9) { + $0 = $29($1_1, $0); + break __inlined_func$33; + } + $0 = $27($0); + } + return $0; + } + + function $5($0, $1_1, $2_1, $3_1) { + var $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + __inlined_func$35 : { + label$1 : { + label$2 : { + label$3 : { + label$4 : { + label$5 : { + if ($2_1 >>> 0 >= 9) { + $7 = $29($2_1, $3_1); + if ($7) { + break label$5 + } + $1_1 = 0; + break __inlined_func$35; + } + $1_1 = $45(8, 8); + $2_1 = $45(20, 8); + $4 = $45(16, 8); + $5_1 = 0 - ($45(16, 8) << 2) | 0; + $1_1 = (-65536 - ($4 + ($1_1 + $2_1 | 0) | 0) & -9) - 3 | 0; + if (($1_1 >>> 0 > $5_1 >>> 0 ? $5_1 : $1_1) >>> 0 <= $3_1 >>> 0) { + break label$2 + } + $2_1 = $45($45(16, 8) - 5 >>> 0 > $3_1 >>> 0 ? 16 : $3_1 + 4 | 0, 8); + $1_1 = $65($0); + $5_1 = $50($1_1); + $4 = $61($1_1, $5_1); + label$7 : { + label$8 : { + label$9 : { + label$10 : { + label$11 : { + label$12 : { + if (!$55($1_1)) { + if ($2_1 >>> 0 <= $5_1 >>> 0) { + break label$9 + } + if (($4 | 0) == HEAP32[262453]) { + break label$7 + } + if (($4 | 0) == HEAP32[262452]) { + break label$10 + } + if ($51($4)) { + break label$3 + } + $6 = $50($4); + $8_1 = $6 + $5_1 | 0; + if ($8_1 >>> 0 < $2_1 >>> 0) { + break label$3 + } + $5_1 = $8_1 - $2_1 | 0; + if ($6 >>> 0 < 256) { + break label$12 + } + $23($4); + break label$11; + } + $4 = $50($1_1); + if ($2_1 >>> 0 < 256) { + break label$3 + } + if ($4 - $2_1 >>> 0 < 131073 & $4 >>> 0 >= $2_1 + 4 >>> 0) { + break label$8 + } + $5_1 = HEAP32[$1_1 >> 2]; + $45($2_1 + 31 | 0, 65536); + break label$3; + } + $9 = HEAP32[$4 + 12 >> 2]; + $4 = HEAP32[$4 + 8 >> 2]; + if (($9 | 0) != ($4 | 0)) { + HEAP32[$4 + 12 >> 2] = $9; + HEAP32[$9 + 8 >> 2] = $4; + break label$11; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($6 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + if ($45(16, 8) >>> 0 <= $5_1 >>> 0) { + $4 = $61($1_1, $2_1); + $56($1_1, $2_1); + $56($4, $5_1); + $22($4, $5_1); + if ($1_1) { + break label$1 + } + break label$3; + } + $56($1_1, $8_1); + if ($1_1) { + break label$1 + } + break label$3; + } + $5_1 = $5_1 + HEAP32[262450] | 0; + if ($5_1 >>> 0 < $2_1 >>> 0) { + break label$3 + } + $4 = $5_1 - $2_1 | 0; + label$16 : { + if ($45(16, 8) >>> 0 > $4 >>> 0) { + $56($1_1, $5_1); + $4 = 0; + $5_1 = 0; + break label$16; + } + $5_1 = $61($1_1, $2_1); + $6 = $61($5_1, $4); + $56($1_1, $2_1); + $59($5_1, $4); + HEAP32[$6 + 4 >> 2] = HEAP32[$6 + 4 >> 2] & -2; + } + HEAP32[262452] = $5_1; + HEAP32[262450] = $4; + if ($1_1) { + break label$1 + } + break label$3; + } + $4 = $5_1 - $2_1 | 0; + if ($45(16, 8) >>> 0 > $4 >>> 0) { + break label$8 + } + $5_1 = $61($1_1, $2_1); + $56($1_1, $2_1); + $56($5_1, $4); + $22($5_1, $4); + } + if ($1_1) { + break label$1 + } + break label$3; + } + $5_1 = $5_1 + HEAP32[262451] | 0; + if ($5_1 >>> 0 > $2_1 >>> 0) { + break label$4 + } + break label$3; + } + $108($7, $0, $1_1 >>> 0 < $3_1 >>> 0 ? $1_1 : $3_1); + $26($0); + break label$2; + } + $4 = $61($1_1, $2_1); + $56($1_1, $2_1); + $2_1 = $5_1 - $2_1 | 0; + HEAP32[$4 + 4 >> 2] = $2_1 | 1; + HEAP32[262451] = $2_1; + HEAP32[262453] = $4; + if ($1_1) { + break label$1 + } + } + $2_1 = $27($3_1); + if (!$2_1) { + break label$2 + } + $1_1 = $50($1_1) + ($55($1_1) ? -8 : -4) | 0; + $1_1 = $108($2_1, $0, $1_1 >>> 0 < $3_1 >>> 0 ? $1_1 : $3_1); + $26($0); + break __inlined_func$35; + } + $1_1 = $7; + break __inlined_func$35; + } + $55($1_1); + $1_1 = $63($1_1); + } + return $1_1; + } + + function $8($0, $1_1, $2_1, $3_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + $2_1 = $2_1 | 0; + $3_1 = $3_1 | 0; + label$1 : { + label$2 : { + if (!$1_1) { + if (!$3_1) { + break label$1 + } + $2_1 = $3($3_1, $2_1); + break label$2; + } + $2_1 = $5($0, $1_1, $2_1, $3_1); + } + if ($2_1) { + break label$1 + } + wasm2js_trap(); + } + return $2_1 | 0; + } + + function $10($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + HEAP32[$0 + 8 >> 2] = 11661156; + HEAP32[$0 + 12 >> 2] = -38005119; + HEAP32[$0 >> 2] = -853640255; + HEAP32[$0 + 4 >> 2] = -1046296420; + } + + function $11($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + HEAP32[$0 + 8 >> 2] = 1091761936; + HEAP32[$0 + 12 >> 2] = 2141169500; + HEAP32[$0 >> 2] = -1841756907; + HEAP32[$0 + 4 >> 2] = 655034299; + } + + function $12($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + HEAP32[$0 + 8 >> 2] = -1168109704; + HEAP32[$0 + 12 >> 2] = 327792390; + HEAP32[$0 >> 2] = -1786456962; + HEAP32[$0 + 4 >> 2] = 2127965620; + } + + function $13($0, $1_1, $2_1) { + var $3_1 = 0, $4 = 0; + $3_1 = global$0 - 32 | 0; + global$0 = $3_1; + label$1 : { + label$2 : { + $4 = $1_1; + $1_1 = $1_1 + $2_1 | 0; + if ($4 >>> 0 > $1_1 >>> 0) { + break label$2 + } + $2_1 = HEAP32[$0 + 4 >> 2]; + $4 = $2_1 << 1; + $1_1 = $1_1 >>> 0 < $4 >>> 0 ? $4 : $1_1; + $4 = $1_1 >>> 0 <= 8 ? 8 : $1_1; + $1_1 = ($4 ^ -1) >>> 31 | 0; + label$3 : { + if (!$2_1) { + HEAP32[$3_1 + 24 >> 2] = 0; + break label$3; + } + HEAP32[$3_1 + 28 >> 2] = $2_1; + HEAP32[$3_1 + 24 >> 2] = 1; + HEAP32[$3_1 + 20 >> 2] = HEAP32[$0 >> 2]; + } + $21($3_1 + 8 | 0, $1_1, $4, $3_1 + 20 | 0); + $1_1 = HEAP32[$3_1 + 12 >> 2]; + if (!HEAP32[$3_1 + 8 >> 2]) { + HEAP32[$0 + 4 >> 2] = $4; + HEAP32[$0 >> 2] = $1_1; + break label$1; + } + if (($1_1 | 0) == -2147483647) { + break label$1 + } + if (!$1_1) { + break label$2 + } + $86($1_1, HEAP32[$3_1 + 16 >> 2]); + wasm2js_trap(); + } + $87(); + wasm2js_trap(); + } + global$0 = $3_1 + 32 | 0; + } + + function $14($0) { + $0 = $0 | 0; + } + + function $15($0) { + $0 = $0 | 0; + if (HEAP32[$0 + 4 >> 2]) { + $26(HEAP32[$0 >> 2]) + } + } + + function $16($0) { + $0 = $0 | 0; + var $1_1 = 0; + $1_1 = HEAP32[$0 + 4 >> 2]; + if (!(!$1_1 | !HEAP32[$0 + 8 >> 2])) { + $26($1_1) + } + } + + function $17($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0; + $3_1 = global$0 - 16 | 0; + global$0 = $3_1; + $0 = HEAP32[$0 >> 2]; + label$1 : { + label$2 : { + label$3 : { + if ($1_1 >>> 0 >= 128) { + HEAP32[$3_1 + 12 >> 2] = 0; + if ($1_1 >>> 0 < 2048) { + break label$3 + } + if ($1_1 >>> 0 < 65536) { + HEAP8[$3_1 + 14 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 12 | 224; + HEAP8[$3_1 + 13 | 0] = $1_1 >>> 6 & 63 | 128; + $1_1 = 3; + break label$2; + } + HEAP8[$3_1 + 15 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 14 | 0] = $1_1 >>> 6 & 63 | 128; + HEAP8[$3_1 + 13 | 0] = $1_1 >>> 12 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 18 & 7 | 240; + $1_1 = 4; + break label$2; + } + $2_1 = HEAP32[$0 + 8 >> 2]; + if (($2_1 | 0) == HEAP32[$0 + 4 >> 2]) { + $4 = global$0 - 32 | 0; + global$0 = $4; + label$10 : { + label$21 : { + $2_1 = $2_1 + 1 | 0; + if (!$2_1) { + break label$21 + } + $6 = HEAP32[$0 + 4 >> 2]; + $5_1 = $6 << 1; + $2_1 = $2_1 >>> 0 < $5_1 >>> 0 ? $5_1 : $2_1; + $5_1 = $2_1 >>> 0 <= 8 ? 8 : $2_1; + $2_1 = ($5_1 ^ -1) >>> 31 | 0; + label$32 : { + if (!$6) { + HEAP32[$4 + 24 >> 2] = 0; + break label$32; + } + HEAP32[$4 + 28 >> 2] = $6; + HEAP32[$4 + 24 >> 2] = 1; + HEAP32[$4 + 20 >> 2] = HEAP32[$0 >> 2]; + } + $21($4 + 8 | 0, $2_1, $5_1, $4 + 20 | 0); + $2_1 = HEAP32[$4 + 12 >> 2]; + if (!HEAP32[$4 + 8 >> 2]) { + HEAP32[$0 + 4 >> 2] = $5_1; + HEAP32[$0 >> 2] = $2_1; + break label$10; + } + if (($2_1 | 0) == -2147483647) { + break label$10 + } + if (!$2_1) { + break label$21 + } + $86($2_1, HEAP32[$4 + 16 >> 2]); + wasm2js_trap(); + } + $87(); + wasm2js_trap(); + } + global$0 = $4 + 32 | 0; + $2_1 = HEAP32[$0 + 8 >> 2]; + } + HEAP32[$0 + 8 >> 2] = $2_1 + 1; + HEAP8[HEAP32[$0 >> 2] + $2_1 | 0] = $1_1; + break label$1; + } + HEAP8[$3_1 + 13 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 6 | 192; + $1_1 = 2; + } + $2_1 = HEAP32[$0 + 8 >> 2]; + if ($1_1 >>> 0 > HEAP32[$0 + 4 >> 2] - $2_1 >>> 0) { + $13($0, $2_1, $1_1); + $2_1 = HEAP32[$0 + 8 >> 2]; + } + $108(HEAP32[$0 >> 2] + $2_1 | 0, $3_1 + 12 | 0, $1_1); + HEAP32[$0 + 8 >> 2] = $1_1 + $2_1; + } + global$0 = $3_1 + 16 | 0; + return 0; + } + + function $19($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return byn$mgfn_shared$19($0, $1_1, 1048600) | 0; + } + + function $20($0, $1_1, $2_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + $2_1 = $2_1 | 0; + var $3_1 = 0; + $0 = HEAP32[$0 >> 2]; + $3_1 = HEAP32[$0 + 8 >> 2]; + if (HEAP32[$0 + 4 >> 2] - $3_1 >>> 0 < $2_1 >>> 0) { + $13($0, $3_1, $2_1); + $3_1 = HEAP32[$0 + 8 >> 2]; + } + $108(HEAP32[$0 >> 2] + $3_1 | 0, $1_1, $2_1); + HEAP32[$0 + 8 >> 2] = $2_1 + $3_1; + return 0; + } + + function $21($0, $1_1, $2_1, $3_1) { + var $4 = 0; + label$1 : { + label$2 : { + if ($1_1) { + if (($2_1 | 0) < 0) { + break label$2 + } + label$4 : { + if (HEAP32[$3_1 + 4 >> 2]) { + label$5 : { + $4 = HEAP32[$3_1 + 8 >> 2]; + if (!$4) { + break label$5 + } + $3_1 = $5(HEAP32[$3_1 >> 2], $4, $1_1, $2_1); + break label$4; + } + } + $3_1 = $1_1; + if (!$2_1) { + break label$4 + } + $3_1 = $3($2_1, $1_1); + } + if ($3_1) { + HEAP32[$0 + 4 >> 2] = $3_1; + HEAP32[$0 + 8 >> 2] = $2_1; + HEAP32[$0 >> 2] = 0; + return; + } + HEAP32[$0 + 4 >> 2] = $1_1; + HEAP32[$0 + 8 >> 2] = $2_1; + break label$1; + } + HEAP32[$0 + 4 >> 2] = 0; + HEAP32[$0 + 8 >> 2] = $2_1; + break label$1; + } + HEAP32[$0 + 4 >> 2] = 0; + } + HEAP32[$0 >> 2] = 1; + } + + function $22($0, $1_1) { + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + $2_1 = $61($0, $1_1); + label$1 : { + label$2 : { + label$3 : { + label$4 : { + label$5 : { + label$6 : { + label$7 : { + if ($52($0)) { + break label$7 + } + $3_1 = HEAP32[$0 >> 2]; + if ($55($0)) { + break label$6 + } + $1_1 = $1_1 + $3_1 | 0; + $0 = $62($0, $3_1); + if (($0 | 0) == HEAP32[262452]) { + if ((HEAP32[$2_1 + 4 >> 2] & 3) != 3) { + break label$7 + } + HEAP32[262450] = $1_1; + $60($0, $1_1, $2_1); + return; + } + if ($3_1 >>> 0 >= 256) { + $23($0); + break label$7; + } + $4 = HEAP32[$0 + 8 >> 2]; + $5_1 = HEAP32[$0 + 12 >> 2]; + if (($4 | 0) != ($5_1 | 0)) { + HEAP32[$4 + 12 >> 2] = $5_1; + HEAP32[$5_1 + 8 >> 2] = $4; + break label$7; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($3_1 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + if ($51($2_1)) { + break label$4 + } + if (($2_1 | 0) == HEAP32[262453]) { + break label$2 + } + if (($2_1 | 0) != HEAP32[262452]) { + break label$5 + } + HEAP32[262452] = $0; + $1_1 = HEAP32[262450] + $1_1 | 0; + HEAP32[262450] = $1_1; + $59($0, $1_1); + return; + } + break label$1; + } + $3_1 = $50($2_1); + $1_1 = $3_1 + $1_1 | 0; + label$11 : { + if ($3_1 >>> 0 >= 256) { + $23($2_1); + break label$11; + } + $4 = HEAP32[$2_1 + 12 >> 2]; + $2_1 = HEAP32[$2_1 + 8 >> 2]; + if (($4 | 0) != ($2_1 | 0)) { + HEAP32[$2_1 + 12 >> 2] = $4; + HEAP32[$4 + 8 >> 2] = $2_1; + break label$11; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($3_1 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + $59($0, $1_1); + if (HEAP32[262452] != ($0 | 0)) { + break label$3 + } + HEAP32[262450] = $1_1; + return; + } + $60($0, $1_1, $2_1); + } + if ($1_1 >>> 0 >= 256) { + $24($0, $1_1); + return; + } + $2_1 = ($1_1 & -8) + 1049528 | 0; + $3_1 = HEAP32[262448]; + $1_1 = 1 << ($1_1 >>> 3); + label$15 : { + if (!($3_1 & $1_1)) { + HEAP32[262448] = $1_1 | $3_1; + $1_1 = $2_1; + break label$15; + } + $1_1 = HEAP32[$2_1 + 8 >> 2]; + } + HEAP32[$2_1 + 8 >> 2] = $0; + HEAP32[$1_1 + 12 >> 2] = $0; + HEAP32[$0 + 12 >> 2] = $2_1; + HEAP32[$0 + 8 >> 2] = $1_1; + return; + } + HEAP32[262453] = $0; + $1_1 = HEAP32[262451] + $1_1 | 0; + HEAP32[262451] = $1_1; + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + if (HEAP32[262452] != ($0 | 0)) { + break label$1 + } + HEAP32[262450] = 0; + HEAP32[262452] = 0; + } + } + + function $23($0) { + var $1_1 = 0, $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + $4 = HEAP32[$0 + 24 >> 2]; + label$1 : { + label$2 : { + if (($0 | 0) == HEAP32[$0 + 12 >> 2]) { + $1_1 = $0 + 20 | 0; + $3_1 = HEAP32[$1_1 >> 2]; + $2_1 = HEAP32[($3_1 ? 20 : 16) + $0 >> 2]; + if ($2_1) { + break label$2 + } + $1_1 = 0; + break label$1; + } + $2_1 = HEAP32[$0 + 8 >> 2]; + $1_1 = HEAP32[$0 + 12 >> 2]; + HEAP32[$2_1 + 12 >> 2] = $1_1; + HEAP32[$1_1 + 8 >> 2] = $2_1; + break label$1; + } + $3_1 = $3_1 ? $1_1 : $0 + 16 | 0; + while (1) { + $6 = $3_1; + $1_1 = $2_1 + 20 | 0; + $5_1 = HEAP32[$1_1 >> 2]; + $3_1 = $1_1; + $1_1 = $2_1; + $3_1 = $5_1 ? $3_1 : $1_1 + 16 | 0; + $2_1 = HEAP32[($5_1 ? 20 : 16) + $1_1 >> 2]; + if ($2_1) { + continue + } + break; + }; + HEAP32[$6 >> 2] = 0; + } + label$5 : { + if (!$4) { + break label$5 + } + label$6 : { + $2_1 = (HEAP32[$0 + 28 >> 2] << 2) + 1049384 | 0; + if (HEAP32[$2_1 >> 2] != ($0 | 0)) { + HEAP32[(HEAP32[$4 + 16 >> 2] == ($0 | 0) ? 16 : 20) + $4 >> 2] = $1_1; + if ($1_1) { + break label$6 + } + break label$5; + } + HEAP32[$2_1 >> 2] = $1_1; + if ($1_1) { + break label$6 + } + (wasm2js_i32$0 = 1049796, wasm2js_i32$1 = HEAP32[262449] & __wasm_rotl_i32(HEAP32[$0 + 28 >> 2])), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + return; + } + HEAP32[$1_1 + 24 >> 2] = $4; + $2_1 = HEAP32[$0 + 16 >> 2]; + if ($2_1) { + HEAP32[$1_1 + 16 >> 2] = $2_1; + HEAP32[$2_1 + 24 >> 2] = $1_1; + } + $0 = HEAP32[$0 + 20 >> 2]; + if (!$0) { + break label$5 + } + HEAP32[$1_1 + 20 >> 2] = $0; + HEAP32[$0 + 24 >> 2] = $1_1; + } + } + + function $24($0, $1_1) { + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0; + HEAP32[$0 + 16 >> 2] = 0; + HEAP32[$0 + 20 >> 2] = 0; + $2_1 = 0; + label$1 : { + if ($1_1 >>> 0 < 256) { + break label$1 + } + $2_1 = 31; + if ($1_1 >>> 0 > 16777215) { + break label$1 + } + $4 = Math_clz32($1_1 >>> 8 | 0); + $2_1 = (($1_1 >>> 6 - $4 & 1) - ($4 << 1) | 0) + 62 | 0; + } + HEAP32[$0 + 28 >> 2] = $2_1; + $4 = ($2_1 << 2) + 1049384 | 0; + $3_1 = $0; + $0 = HEAP32[262449]; + $5_1 = 1 << $2_1; + label$2 : { + if (!($0 & $5_1)) { + HEAP32[262449] = $0 | $5_1; + HEAP32[$4 >> 2] = $3_1; + break label$2; + } + $4 = HEAP32[$4 >> 2]; + $0 = $48($2_1); + label$4 : { + label$5 : { + if (($50($4) | 0) == ($1_1 | 0)) { + $0 = $4; + break label$5; + } + $2_1 = $1_1 << $0; + while (1) { + $5_1 = (($2_1 >>> 29 & 4) + $4 | 0) + 16 | 0; + $0 = HEAP32[$5_1 >> 2]; + if (!$0) { + break label$4 + } + $2_1 = $2_1 << 1; + $4 = $0; + if (($50($0) | 0) != ($1_1 | 0)) { + continue + } + break; + }; + } + $1_1 = HEAP32[$0 + 8 >> 2]; + HEAP32[$1_1 + 12 >> 2] = $3_1; + HEAP32[$0 + 8 >> 2] = $3_1; + HEAP32[$3_1 + 12 >> 2] = $0; + HEAP32[$3_1 + 8 >> 2] = $1_1; + HEAP32[$3_1 + 24 >> 2] = 0; + return; + } + HEAP32[$5_1 >> 2] = $3_1; + } + HEAP32[$3_1 + 24 >> 2] = $4; + HEAP32[$3_1 + 8 >> 2] = $3_1; + HEAP32[$3_1 + 12 >> 2] = $3_1; + } + + function $25() { + var $0 = 0, $1_1 = 0; + $0 = HEAP32[262380]; + if ($0) { + while (1) { + $1_1 = $1_1 + 1 | 0; + $0 = HEAP32[$0 + 8 >> 2]; + if ($0) { + continue + } + break; + } + } + HEAP32[262458] = $1_1 >>> 0 <= 4095 ? 4095 : $1_1; + return 0; + } + + function $26($0) { + var $1_1 = 0, $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + $0 = $65($0); + $1_1 = $50($0); + $2_1 = $61($0, $1_1); + label$1 : { + label$2 : { + label$3 : { + label$4 : { + label$5 : { + label$6 : { + label$7 : { + label$8 : { + label$9 : { + if ($52($0)) { + break label$9 + } + $3_1 = HEAP32[$0 >> 2]; + if ($55($0)) { + break label$8 + } + $1_1 = $1_1 + $3_1 | 0; + $0 = $62($0, $3_1); + if (($0 | 0) == HEAP32[262452]) { + if ((HEAP32[$2_1 + 4 >> 2] & 3) != 3) { + break label$9 + } + HEAP32[262450] = $1_1; + $60($0, $1_1, $2_1); + break label$1; + } + if ($3_1 >>> 0 >= 256) { + $23($0); + break label$9; + } + $4 = HEAP32[$0 + 12 >> 2]; + $5_1 = HEAP32[$0 + 8 >> 2]; + if (($4 | 0) != ($5_1 | 0)) { + HEAP32[$5_1 + 12 >> 2] = $4; + HEAP32[$4 + 8 >> 2] = $5_1; + break label$9; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($3_1 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + if ($51($2_1)) { + break label$6 + } + if (($2_1 | 0) == HEAP32[262453]) { + break label$4 + } + if (($2_1 | 0) != HEAP32[262452]) { + break label$7 + } + HEAP32[262452] = $0; + $1_1 = HEAP32[262450] + $1_1 | 0; + HEAP32[262450] = $1_1; + $59($0, $1_1); + return; + } + break label$1; + } + $3_1 = $50($2_1); + $1_1 = $3_1 + $1_1 | 0; + label$13 : { + if ($3_1 >>> 0 >= 256) { + $23($2_1); + break label$13; + } + $4 = HEAP32[$2_1 + 12 >> 2]; + $2_1 = HEAP32[$2_1 + 8 >> 2]; + if (($4 | 0) != ($2_1 | 0)) { + HEAP32[$2_1 + 12 >> 2] = $4; + HEAP32[$4 + 8 >> 2] = $2_1; + break label$13; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($3_1 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + $59($0, $1_1); + if (HEAP32[262452] != ($0 | 0)) { + break label$5 + } + HEAP32[262450] = $1_1; + return; + } + $60($0, $1_1, $2_1); + } + if ($1_1 >>> 0 < 256) { + break label$3 + } + $24($0, $1_1); + $0 = HEAP32[262458] - 1 | 0; + HEAP32[262458] = $0; + if ($0) { + break label$1 + } + $25(); + return; + } + HEAP32[262453] = $0; + $1_1 = HEAP32[262451] + $1_1 | 0; + HEAP32[262451] = $1_1; + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + if (HEAP32[262452] == ($0 | 0)) { + HEAP32[262450] = 0; + HEAP32[262452] = 0; + } + if ($1_1 >>> 0 <= HEAPU32[262456]) { + break label$1 + } + $0 = $45(8, 8); + $1_1 = $45(20, 8); + $2_1 = $45(16, 8); + $3_1 = 0 - ($45(16, 8) << 2) | 0; + $0 = (-65536 - ($2_1 + ($0 + $1_1 | 0) | 0) & -9) - 3 | 0; + if (!($0 >>> 0 > $3_1 >>> 0 ? $3_1 : $0) | !HEAP32[262453]) { + break label$1 + } + $0 = $45(8, 8); + $1_1 = $45(20, 8); + $2_1 = $45(16, 8); + if (HEAPU32[262451] <= $2_1 + ($1_1 + ($0 - 8 | 0) | 0) >>> 0) { + break label$2 + } + $1_1 = HEAP32[262453]; + $0 = 1049512; + label$17 : { + while (1) { + if ($1_1 >>> 0 >= HEAPU32[$0 >> 2]) { + if ($73($0) >>> 0 > $1_1 >>> 0) { + break label$17 + } + } + $0 = HEAP32[$0 + 8 >> 2]; + if ($0) { + continue + } + break; + }; + $0 = 0; + } + $70($0); + break label$2; + } + $2_1 = ($1_1 & -8) + 1049528 | 0; + $3_1 = HEAP32[262448]; + $1_1 = 1 << ($1_1 >>> 3); + label$21 : { + if (!($3_1 & $1_1)) { + HEAP32[262448] = $1_1 | $3_1; + $1_1 = $2_1; + break label$21; + } + $1_1 = HEAP32[$2_1 + 8 >> 2]; + } + HEAP32[$2_1 + 8 >> 2] = $0; + HEAP32[$1_1 + 12 >> 2] = $0; + HEAP32[$0 + 12 >> 2] = $2_1; + HEAP32[$0 + 8 >> 2] = $1_1; + return; + } + if ($25() | HEAPU32[262451] <= HEAPU32[262456]) { + break label$1 + } + HEAP32[262456] = -1; + } + } + + function $27($0) { + var $1_1 = 0, $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, $10_1 = 0, $11_1 = 0, $12_1 = 0, $13_1 = 0, $14_1 = 0, $15_1 = 0, wasm2js_i32$0 = 0, wasm2js_i32$1 = 0; + $11_1 = global$0 - 16 | 0; + global$0 = $11_1; + label$1 : { + label$2 : { + label$3 : { + label$4 : { + if ($0 >>> 0 >= 245) { + $6 = $45(8, 8); + $4 = $45(20, 8); + $1_1 = $45(16, 8); + $2_1 = 0 - ($45(16, 8) << 2) | 0; + $1_1 = (-65536 - ($1_1 + ($4 + $6 | 0) | 0) & -9) - 3 | 0; + if (($1_1 >>> 0 > $2_1 >>> 0 ? $2_1 : $1_1) >>> 0 <= $0 >>> 0) { + break label$1 + } + $5_1 = $45($0 + 4 | 0, 8); + if (!HEAP32[262449]) { + break label$2 + } + $3_1 = 0 - $5_1 | 0; + $6 = 0; + label$6 : { + if ($5_1 >>> 0 < 256) { + break label$6 + } + $6 = 31; + if ($5_1 >>> 0 > 16777215) { + break label$6 + } + $0 = Math_clz32($5_1 >>> 8 | 0); + $6 = (($5_1 >>> 6 - $0 & 1) - ($0 << 1) | 0) + 62 | 0; + } + $1_1 = HEAP32[($6 << 2) + 1049384 >> 2]; + if (!$1_1) { + $0 = 0; + $4 = 0; + break label$4; + } + $7 = $5_1 << $48($6); + $0 = 0; + $4 = 0; + while (1) { + label$9 : { + $2_1 = $50($1_1); + if ($2_1 >>> 0 < $5_1 >>> 0) { + break label$9 + } + $2_1 = $2_1 - $5_1 | 0; + if ($2_1 >>> 0 >= $3_1 >>> 0) { + break label$9 + } + $4 = $1_1; + $3_1 = $2_1; + if ($2_1) { + break label$9 + } + $3_1 = 0; + $0 = $1_1; + $1_1 = 0; + break label$3; + } + $2_1 = HEAP32[$1_1 + 20 >> 2]; + $1_1 = HEAP32[(($7 >>> 29 & 4) + $1_1 | 0) + 16 >> 2]; + $0 = $2_1 ? (($2_1 | 0) != ($1_1 | 0) ? $2_1 : $0) : $0; + $7 = $7 << 1; + if ($1_1) { + continue + } + break; + }; + break label$4; + } + $5_1 = $45($45(16, 8) - 5 >>> 0 > $0 >>> 0 ? 16 : $0 + 4 | 0, 8); + $1_1 = HEAP32[262448]; + $0 = $5_1 >>> 3 | 0; + $2_1 = $1_1 >>> $0 | 0; + if ($2_1 & 3) { + $3_1 = $0 + (($2_1 ^ -1) & 1) | 0; + $0 = $3_1 << 3; + $4 = HEAP32[$0 + 1049536 >> 2]; + $2_1 = HEAP32[$4 + 8 >> 2]; + $0 = $0 + 1049528 | 0; + label$11 : { + if (($2_1 | 0) != ($0 | 0)) { + HEAP32[$2_1 + 12 >> 2] = $0; + HEAP32[$0 + 8 >> 2] = $2_1; + break label$11; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = __wasm_rotl_i32($3_1) & $1_1), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + $57($4, $3_1 << 3); + $3_1 = $63($4); + break label$1; + } + if (HEAPU32[262450] >= $5_1 >>> 0) { + break label$2 + } + label$13 : { + label$14 : { + label$15 : { + label$16 : { + label$17 : { + label$18 : { + if (!$2_1) { + $0 = HEAP32[262449]; + if (!$0) { + break label$2 + } + $1_1 = HEAP32[(__wasm_ctz_i32($47($0)) << 2) + 1049384 >> 2]; + $3_1 = $50($1_1) - $5_1 | 0; + $0 = $66($1_1); + if ($0) { + while (1) { + $2_1 = $50($0) - $5_1 | 0; + $4 = $2_1 >>> 0 < $3_1 >>> 0; + $3_1 = $4 ? $2_1 : $3_1; + $1_1 = $4 ? $0 : $1_1; + $0 = $66($0); + if ($0) { + continue + } + break; + } + } + $4 = $61($1_1, $5_1); + $23($1_1); + if ($45(16, 8) >>> 0 > $3_1 >>> 0) { + break label$17 + } + $58($1_1, $5_1); + $59($4, $3_1); + $0 = HEAP32[262450]; + if ($0) { + break label$18 + } + break label$14; + } + $0 = $0 & 31; + $2_1 = __wasm_ctz_i32($47($46(1 << $0) & $2_1 << $0)); + $0 = $2_1 << 3; + $3_1 = HEAP32[$0 + 1049536 >> 2]; + $1_1 = HEAP32[$3_1 + 8 >> 2]; + $0 = $0 + 1049528 | 0; + label$22 : { + if (($1_1 | 0) != ($0 | 0)) { + HEAP32[$1_1 + 12 >> 2] = $0; + HEAP32[$0 + 8 >> 2] = $1_1; + break label$22; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($2_1)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + $58($3_1, $5_1); + $4 = $61($3_1, $5_1); + $2_1 = ($2_1 << 3) - $5_1 | 0; + $59($4, $2_1); + $0 = HEAP32[262450]; + if ($0) { + break label$16 + } + break label$15; + } + $7 = ($0 & -8) + 1049528 | 0; + $6 = HEAP32[262452]; + $2_1 = HEAP32[262448]; + $0 = 1 << ($0 >>> 3); + label$24 : { + if (!($2_1 & $0)) { + HEAP32[262448] = $0 | $2_1; + $0 = $7; + break label$24; + } + $0 = HEAP32[$7 + 8 >> 2]; + } + HEAP32[$7 + 8 >> 2] = $6; + HEAP32[$0 + 12 >> 2] = $6; + HEAP32[$6 + 12 >> 2] = $7; + HEAP32[$6 + 8 >> 2] = $0; + break label$14; + } + $57($1_1, $3_1 + $5_1 | 0); + break label$13; + } + $7 = ($0 & -8) + 1049528 | 0; + $6 = HEAP32[262452]; + $1_1 = HEAP32[262448]; + $0 = 1 << ($0 >>> 3); + label$26 : { + if (!($1_1 & $0)) { + HEAP32[262448] = $0 | $1_1; + $0 = $7; + break label$26; + } + $0 = HEAP32[$7 + 8 >> 2]; + } + HEAP32[$7 + 8 >> 2] = $6; + HEAP32[$0 + 12 >> 2] = $6; + HEAP32[$6 + 12 >> 2] = $7; + HEAP32[$6 + 8 >> 2] = $0; + } + HEAP32[262452] = $4; + HEAP32[262450] = $2_1; + $3_1 = $63($3_1); + break label$1; + } + HEAP32[262452] = $4; + HEAP32[262450] = $3_1; + } + $3_1 = $63($1_1); + if (!$3_1) { + break label$2 + } + break label$1; + } + if (!($0 | $4)) { + $4 = 0; + $0 = $46(1 << $6) & HEAP32[262449]; + if (!$0) { + break label$2 + } + $0 = HEAP32[(__wasm_ctz_i32($47($0)) << 2) + 1049384 >> 2]; + } + $1_1 = 1; + } + while (1) { + if (!$1_1) { + $1_1 = $50($0); + $6 = $1_1 - $5_1 | 0; + $2_1 = $6 >>> 0 < $3_1 >>> 0; + $1_1 = $1_1 >>> 0 < $5_1 >>> 0; + $4 = $1_1 ? $4 : $2_1 ? $0 : $4; + $3_1 = $1_1 ? $3_1 : $2_1 ? $6 : $3_1; + $0 = $66($0); + $1_1 = 1; + continue; + } + if ($0) { + $1_1 = 0; + continue; + } else { + if (!$4) { + break label$2 + } + $0 = HEAP32[262450]; + if ($0 >>> 0 >= $5_1 >>> 0 & $0 - $5_1 >>> 0 <= $3_1 >>> 0) { + break label$2 + } + $6 = $61($4, $5_1); + $23($4); + label$33 : { + if ($45(16, 8) >>> 0 <= $3_1 >>> 0) { + $58($4, $5_1); + $59($6, $3_1); + if ($3_1 >>> 0 >= 256) { + $24($6, $3_1); + break label$33; + } + $2_1 = ($3_1 & -8) + 1049528 | 0; + $1_1 = HEAP32[262448]; + $0 = 1 << ($3_1 >>> 3); + label$36 : { + if (!($1_1 & $0)) { + HEAP32[262448] = $0 | $1_1; + $0 = $2_1; + break label$36; + } + $0 = HEAP32[$2_1 + 8 >> 2]; + } + HEAP32[$2_1 + 8 >> 2] = $6; + HEAP32[$0 + 12 >> 2] = $6; + HEAP32[$6 + 12 >> 2] = $2_1; + HEAP32[$6 + 8 >> 2] = $0; + break label$33; + } + $57($4, $3_1 + $5_1 | 0); + } + $3_1 = $63($4); + if ($3_1) { + break label$1 + } + } + break; + }; + } + label$38 : { + label$39 : { + $0 = HEAP32[262450]; + if ($0 >>> 0 < $5_1 >>> 0) { + $0 = HEAP32[262451]; + if ($0 >>> 0 <= $5_1 >>> 0) { + $0 = $45((($45(8, 8) + $5_1 | 0) + $45(20, 8) | 0) + $45(16, 8) | 0, 65536); + $2_1 = __wasm_memory_grow($0 >>> 16 | 0); + $1_1 = $11_1 + 4 | 0; + HEAP32[$1_1 + 8 >> 2] = 0; + $7 = $0 & -65536; + $0 = ($2_1 | 0) == -1; + HEAP32[$1_1 + 4 >> 2] = $0 ? 0 : $7; + HEAP32[$1_1 >> 2] = $0 ? 0 : $2_1 << 16; + $8_1 = HEAP32[$11_1 + 4 >> 2]; + if (!$8_1) { + $3_1 = 0; + break label$1; + } + $14_1 = HEAP32[$11_1 + 12 >> 2]; + $10_1 = HEAP32[$11_1 + 8 >> 2]; + $1_1 = $10_1 + HEAP32[262454] | 0; + HEAP32[262454] = $1_1; + $0 = HEAP32[262455]; + HEAP32[262455] = $0 >>> 0 > $1_1 >>> 0 ? $0 : $1_1; + label$43 : { + if (HEAP32[262453]) { + $0 = 1049512; + while (1) { + if (($73($0) | 0) == ($8_1 | 0)) { + break label$43 + } + $0 = HEAP32[$0 + 8 >> 2]; + if ($0) { + continue + } + break; + }; + break label$39; + } + $0 = HEAP32[262457]; + if (!($0 >>> 0 <= $8_1 >>> 0 ? $0 : 0)) { + HEAP32[262457] = $8_1 + } + HEAP32[262458] = 4095; + HEAP32[262381] = $14_1; + HEAP32[262379] = $10_1; + HEAP32[262378] = $8_1; + HEAP32[262385] = 1049528; + HEAP32[262387] = 1049536; + HEAP32[262384] = 1049528; + HEAP32[262389] = 1049544; + HEAP32[262386] = 1049536; + HEAP32[262391] = 1049552; + HEAP32[262388] = 1049544; + HEAP32[262393] = 1049560; + HEAP32[262390] = 1049552; + HEAP32[262395] = 1049568; + HEAP32[262392] = 1049560; + HEAP32[262397] = 1049576; + HEAP32[262394] = 1049568; + HEAP32[262399] = 1049584; + HEAP32[262396] = 1049576; + HEAP32[262401] = 1049592; + HEAP32[262398] = 1049584; + HEAP32[262400] = 1049592; + HEAP32[262403] = 1049600; + HEAP32[262402] = 1049600; + HEAP32[262405] = 1049608; + HEAP32[262404] = 1049608; + HEAP32[262407] = 1049616; + HEAP32[262406] = 1049616; + HEAP32[262409] = 1049624; + HEAP32[262408] = 1049624; + HEAP32[262411] = 1049632; + HEAP32[262410] = 1049632; + HEAP32[262413] = 1049640; + HEAP32[262412] = 1049640; + HEAP32[262415] = 1049648; + HEAP32[262414] = 1049648; + HEAP32[262417] = 1049656; + HEAP32[262419] = 1049664; + HEAP32[262416] = 1049656; + HEAP32[262421] = 1049672; + HEAP32[262418] = 1049664; + HEAP32[262423] = 1049680; + HEAP32[262420] = 1049672; + HEAP32[262425] = 1049688; + HEAP32[262422] = 1049680; + HEAP32[262427] = 1049696; + HEAP32[262424] = 1049688; + HEAP32[262429] = 1049704; + HEAP32[262426] = 1049696; + HEAP32[262431] = 1049712; + HEAP32[262428] = 1049704; + HEAP32[262433] = 1049720; + HEAP32[262430] = 1049712; + HEAP32[262435] = 1049728; + HEAP32[262432] = 1049720; + HEAP32[262437] = 1049736; + HEAP32[262434] = 1049728; + HEAP32[262439] = 1049744; + HEAP32[262436] = 1049736; + HEAP32[262441] = 1049752; + HEAP32[262438] = 1049744; + HEAP32[262443] = 1049760; + HEAP32[262440] = 1049752; + HEAP32[262445] = 1049768; + HEAP32[262442] = 1049760; + HEAP32[262447] = 1049776; + HEAP32[262444] = 1049768; + HEAP32[262446] = 1049776; + $4 = $45(8, 8); + $2_1 = $45(20, 8); + $1_1 = $45(16, 8); + $0 = $63($8_1); + $0 = $45($0, 8) - $0 | 0; + $3_1 = $61($8_1, $0); + HEAP32[262453] = $3_1; + $4 = $10_1 + 8 - ($0 + ($1_1 + ($2_1 + $4 | 0) | 0)) | 0; + HEAP32[262451] = $4; + HEAP32[$3_1 + 4 >> 2] = $4 | 1; + $2_1 = $45(8, 8); + $1_1 = $45(20, 8); + $0 = $45(16, 8); + (wasm2js_i32$0 = $61($3_1, $4), wasm2js_i32$1 = $0 + ($1_1 + ($2_1 - 8 | 0) | 0) | 0), HEAP32[wasm2js_i32$0 + 4 >> 2] = wasm2js_i32$1; + HEAP32[262456] = 2097152; + break label$38; + } + if ($70($0)) { + break label$39 + } + if (($71($0) | 0) != ($14_1 | 0)) { + break label$39 + } + $2_1 = HEAP32[262453]; + $1_1 = HEAP32[$0 >> 2]; + if ($2_1 >>> 0 >= $1_1 >>> 0) { + $1_1 = HEAP32[$0 + 4 >> 2] + $1_1 >>> 0 > $2_1 >>> 0 + } else { + $1_1 = 0 + } + if (!$1_1) { + break label$39 + } + HEAP32[$0 + 4 >> 2] = $10_1 + HEAP32[$0 + 4 >> 2]; + $1_1 = $10_1 + HEAP32[262451] | 0; + $0 = HEAP32[262453]; + $2_1 = $0; + $0 = $63($0); + $0 = $45($0, 8) - $0 | 0; + $3_1 = $61($2_1, $0); + $4 = $1_1 - $0 | 0; + HEAP32[262451] = $4; + HEAP32[262453] = $3_1; + HEAP32[$3_1 + 4 >> 2] = $4 | 1; + $2_1 = $45(8, 8); + $1_1 = $45(20, 8); + $0 = $45(16, 8); + (wasm2js_i32$0 = $61($3_1, $4), wasm2js_i32$1 = (($2_1 - 8 | 0) + $1_1 | 0) + $0 | 0), HEAP32[wasm2js_i32$0 + 4 >> 2] = wasm2js_i32$1; + HEAP32[262456] = 2097152; + break label$38; + } + $1_1 = $0 - $5_1 | 0; + HEAP32[262451] = $1_1; + $2_1 = HEAP32[262453]; + $0 = $61($2_1, $5_1); + HEAP32[262453] = $0; + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + $58($2_1, $5_1); + $3_1 = $63($2_1); + break label$1; + } + $2_1 = HEAP32[262452]; + $1_1 = $0 - $5_1 | 0; + if ($45(16, 8) >>> 0 <= $1_1 >>> 0) { + $0 = $61($2_1, $5_1); + HEAP32[262450] = $1_1; + HEAP32[262452] = $0; + $59($0, $1_1); + $58($2_1, $5_1); + $3_1 = $63($2_1); + break label$1; + } + HEAP32[262452] = 0; + $0 = HEAP32[262450]; + HEAP32[262450] = 0; + $57($2_1, $0); + $3_1 = $63($2_1); + break label$1; + } + $0 = HEAP32[262457]; + HEAP32[262457] = $0 >>> 0 < $8_1 >>> 0 ? $0 : $8_1; + $1_1 = $8_1 + $10_1 | 0; + $0 = 1049512; + label$48 : { + while (1) { + if (($1_1 | 0) != HEAP32[$0 >> 2]) { + $0 = HEAP32[$0 + 8 >> 2]; + if ($0) { + continue + } + break label$48; + } + break; + }; + if ($70($0)) { + break label$48 + } + if (($71($0) | 0) != ($14_1 | 0)) { + break label$48 + } + $3_1 = HEAP32[$0 >> 2]; + HEAP32[$0 >> 2] = $8_1; + HEAP32[$0 + 4 >> 2] = $10_1 + HEAP32[$0 + 4 >> 2]; + $4 = $63($8_1); + $2_1 = $45($4, 8); + $1_1 = $63($3_1); + $0 = $45($1_1, 8); + $6 = $8_1 + ($2_1 - $4 | 0) | 0; + $7 = $61($6, $5_1); + $58($6, $5_1); + $0 = $3_1 + ($0 - $1_1 | 0) | 0; + $5_1 = $0 - ($5_1 + $6 | 0) | 0; + label$51 : { + if (HEAP32[262453] != ($0 | 0)) { + if (HEAP32[262452] == ($0 | 0)) { + break label$51 + } + if ((HEAP32[$0 + 4 >> 2] & 3) == 1) { + $4 = $50($0); + label$54 : { + if ($4 >>> 0 >= 256) { + $23($0); + break label$54; + } + $2_1 = HEAP32[$0 + 12 >> 2]; + $1_1 = HEAP32[$0 + 8 >> 2]; + if (($2_1 | 0) != ($1_1 | 0)) { + HEAP32[$1_1 + 12 >> 2] = $2_1; + HEAP32[$2_1 + 8 >> 2] = $1_1; + break label$54; + } + (wasm2js_i32$0 = 1049792, wasm2js_i32$1 = HEAP32[262448] & __wasm_rotl_i32($4 >>> 3 | 0)), HEAP32[wasm2js_i32$0 >> 2] = wasm2js_i32$1; + } + $5_1 = $5_1 + $4 | 0; + $0 = $61($0, $4); + } + $60($7, $5_1, $0); + if ($5_1 >>> 0 >= 256) { + $24($7, $5_1); + $3_1 = $63($6); + break label$1; + } + $2_1 = ($5_1 & -8) + 1049528 | 0; + $1_1 = HEAP32[262448]; + $0 = 1 << ($5_1 >>> 3); + label$58 : { + if (!($1_1 & $0)) { + HEAP32[262448] = $0 | $1_1; + $0 = $2_1; + break label$58; + } + $0 = HEAP32[$2_1 + 8 >> 2]; + } + HEAP32[$2_1 + 8 >> 2] = $7; + HEAP32[$0 + 12 >> 2] = $7; + HEAP32[$7 + 12 >> 2] = $2_1; + HEAP32[$7 + 8 >> 2] = $0; + $3_1 = $63($6); + break label$1; + } + HEAP32[262453] = $7; + $0 = HEAP32[262451] + $5_1 | 0; + HEAP32[262451] = $0; + HEAP32[$7 + 4 >> 2] = $0 | 1; + $3_1 = $63($6); + break label$1; + } + HEAP32[262452] = $7; + $0 = HEAP32[262450] + $5_1 | 0; + HEAP32[262450] = $0; + $59($7, $0); + $3_1 = $63($6); + break label$1; + } + $9 = HEAP32[262453]; + $0 = 1049512; + label$60 : { + while (1) { + if ($9 >>> 0 >= HEAPU32[$0 >> 2]) { + if ($73($0) >>> 0 > $9 >>> 0) { + break label$60 + } + } + $0 = HEAP32[$0 + 8 >> 2]; + if ($0) { + continue + } + break; + }; + $0 = 0; + } + $6 = $73($0); + $15_1 = $45(20, 8); + $1_1 = ($6 - $15_1 | 0) - 23 | 0; + $0 = $63($1_1); + $0 = ($45($0, 8) - $0 | 0) + $1_1 | 0; + $12_1 = $0 >>> 0 < $45(16, 8) + $9 >>> 0 ? $9 : $0; + $13_1 = $63($12_1); + $0 = $61($12_1, $15_1); + $3_1 = $45(8, 8); + $4 = $45(20, 8); + $2_1 = $45(16, 8); + $1_1 = $63($8_1); + $1_1 = $45($1_1, 8) - $1_1 | 0; + $7 = $61($8_1, $1_1); + HEAP32[262453] = $7; + $3_1 = $10_1 + 8 - ($1_1 + ($2_1 + ($3_1 + $4 | 0) | 0)) | 0; + HEAP32[262451] = $3_1; + HEAP32[$7 + 4 >> 2] = $3_1 | 1; + $4 = $45(8, 8); + $2_1 = $45(20, 8); + $1_1 = $45(16, 8); + (wasm2js_i32$0 = $61($7, $3_1), wasm2js_i32$1 = $1_1 + ($2_1 + ($4 - 8 | 0) | 0) | 0), HEAP32[wasm2js_i32$0 + 4 >> 2] = wasm2js_i32$1; + HEAP32[262456] = 2097152; + $58($12_1, $15_1); + $4 = HEAP32[262378]; + $2_1 = HEAP32[262379]; + $1_1 = HEAP32[262381]; + HEAP32[$13_1 + 8 >> 2] = HEAP32[262380]; + HEAP32[$13_1 + 12 >> 2] = $1_1; + HEAP32[$13_1 >> 2] = $4; + HEAP32[$13_1 + 4 >> 2] = $2_1; + HEAP32[262381] = $14_1; + HEAP32[262379] = $10_1; + HEAP32[262378] = $8_1; + HEAP32[262380] = $13_1; + while (1) { + $1_1 = $61($0, 4); + HEAP32[$0 + 4 >> 2] = 7; + $0 = $1_1; + if ($6 >>> 0 > $0 + 4 >>> 0) { + continue + } + break; + }; + if (($9 | 0) == ($12_1 | 0)) { + break label$38 + } + $0 = $12_1 - $9 | 0; + $60($9, $0, $61($9, $0)); + if ($0 >>> 0 >= 256) { + $24($9, $0); + break label$38; + } + $2_1 = ($0 & -8) + 1049528 | 0; + $1_1 = HEAP32[262448]; + $0 = 1 << ($0 >>> 3); + label$65 : { + if (!($1_1 & $0)) { + HEAP32[262448] = $0 | $1_1; + $0 = $2_1; + break label$65; + } + $0 = HEAP32[$2_1 + 8 >> 2]; + } + HEAP32[$2_1 + 8 >> 2] = $9; + HEAP32[$0 + 12 >> 2] = $9; + HEAP32[$9 + 12 >> 2] = $2_1; + HEAP32[$9 + 8 >> 2] = $0; + } + $3_1 = 0; + $0 = HEAP32[262451]; + if ($0 >>> 0 <= $5_1 >>> 0) { + break label$1 + } + $1_1 = $0 - $5_1 | 0; + HEAP32[262451] = $1_1; + $2_1 = HEAP32[262453]; + $0 = $61($2_1, $5_1); + HEAP32[262453] = $0; + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + $58($2_1, $5_1); + $3_1 = $63($2_1); + } + global$0 = $11_1 + 16 | 0; + return $3_1; + } + + function $29($0, $1_1) { + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0; + if ($45(16, 8) >>> 0 > $0 >>> 0) { + $0 = $45(16, 8) + } + $3_1 = $45(8, 8); + $2_1 = $45(20, 8); + $4 = $45(16, 8); + $5_1 = 0 - ($45(16, 8) << 2) | 0; + $3_1 = (-65536 - (($2_1 + $3_1 | 0) + $4 | 0) & -9) - 3 | 0; + label$2 : { + if (($3_1 >>> 0 > $5_1 >>> 0 ? $5_1 : $3_1) - $0 >>> 0 <= $1_1 >>> 0) { + break label$2 + } + $3_1 = $45($45(16, 8) - 5 >>> 0 > $1_1 >>> 0 ? 16 : $1_1 + 4 | 0, 8); + $2_1 = $27((($3_1 + $0 | 0) + $45(16, 8) | 0) - 4 | 0); + if (!$2_1) { + break label$2 + } + $1_1 = $65($2_1); + $4 = $0 - 1 | 0; + label$3 : { + if (!($4 & $2_1)) { + $0 = $1_1; + break label$3; + } + $5_1 = $0; + $0 = $65($2_1 + $4 & 0 - $0); + $0 = ($0 - $1_1 >>> 0 <= $45(16, 8) >>> 0 ? $5_1 : 0) + $0 | 0; + $2_1 = $0 - $1_1 | 0; + $4 = $50($1_1) - $2_1 | 0; + if (!$55($1_1)) { + $56($0, $4); + $56($1_1, $2_1); + $22($1_1, $2_1); + break label$3; + } + $1_1 = HEAP32[$1_1 >> 2]; + HEAP32[$0 + 4 >> 2] = $4; + HEAP32[$0 >> 2] = $1_1 + $2_1; + } + label$6 : { + if ($55($0)) { + break label$6 + } + $1_1 = $50($0); + if ($1_1 >>> 0 <= $45(16, 8) + $3_1 >>> 0) { + break label$6 + } + $2_1 = $61($0, $3_1); + $56($0, $3_1); + $1_1 = $1_1 - $3_1 | 0; + $56($2_1, $1_1); + $22($2_1, $1_1); + } + $6 = $63($0); + $55($0); + } + return $6; + } + + function $32($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + $0 = global$0 - 48 | 0; + global$0 = $0; + if (HEAPU8[1049356]) { + HEAP32[$0 + 24 >> 2] = 1; + HEAP32[$0 + 28 >> 2] = 0; + HEAP32[$0 + 16 >> 2] = 2; + HEAP32[$0 + 12 >> 2] = 1048704; + HEAP32[$0 + 40 >> 2] = 2; + HEAP32[$0 + 44 >> 2] = $1_1; + HEAP32[$0 + 20 >> 2] = $0 + 36; + HEAP32[$0 + 36 >> 2] = $0 + 44; + $92($0 + 12 | 0, 1048744); + wasm2js_trap(); + } + global$0 = $0 + 48 | 0; + } + + function $37($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0; + $2_1 = global$0 - 48 | 0; + global$0 = $2_1; + $3_1 = $1_1 + 4 | 0; + if (!HEAP32[$1_1 + 4 >> 2]) { + $4 = HEAP32[$1_1 >> 2]; + $5_1 = $2_1 + 40 | 0; + HEAP32[$5_1 >> 2] = 0; + HEAP32[$2_1 + 32 >> 2] = 1; + HEAP32[$2_1 + 36 >> 2] = 0; + HEAP32[$2_1 + 44 >> 2] = $2_1 + 32; + $96($2_1 + 44 | 0, 1048600, $4); + $6 = HEAP32[$5_1 >> 2]; + HEAP32[$2_1 + 24 >> 2] = $6; + $5_1 = HEAP32[$2_1 + 36 >> 2]; + $4 = HEAP32[$2_1 + 32 >> 2]; + HEAP32[$2_1 + 16 >> 2] = $4; + HEAP32[$2_1 + 20 >> 2] = $5_1; + HEAP32[$3_1 + 8 >> 2] = $6; + HEAP32[$3_1 >> 2] = $4; + HEAP32[$3_1 + 4 >> 2] = $5_1; + } + $4 = $2_1 + 8 | 0; + HEAP32[$4 >> 2] = HEAP32[$3_1 + 8 >> 2]; + HEAP32[$1_1 + 12 >> 2] = 0; + $5_1 = HEAP32[$3_1 >> 2]; + $3_1 = HEAP32[$3_1 + 4 >> 2]; + HEAP32[$1_1 + 4 >> 2] = 1; + HEAP32[$1_1 + 8 >> 2] = 0; + HEAP32[$2_1 >> 2] = $5_1; + HEAP32[$2_1 + 4 >> 2] = $3_1; + $1_1 = $3(12, 4); + if (!$1_1) { + $86(4, 12); + wasm2js_trap(); + } + $3_1 = HEAP32[$2_1 + 4 >> 2]; + HEAP32[$1_1 >> 2] = HEAP32[$2_1 >> 2]; + HEAP32[$1_1 + 4 >> 2] = $3_1; + HEAP32[$1_1 + 8 >> 2] = HEAP32[$4 >> 2]; + HEAP32[$0 + 4 >> 2] = 1048820; + HEAP32[$0 >> 2] = $1_1; + global$0 = $2_1 + 48 | 0; + } + + function $38($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0; + $2_1 = global$0 - 32 | 0; + global$0 = $2_1; + $4 = $1_1 + 4 | 0; + if (!HEAP32[$1_1 + 4 >> 2]) { + $1_1 = HEAP32[$1_1 >> 2]; + $3_1 = $2_1 + 24 | 0; + HEAP32[$3_1 >> 2] = 0; + HEAP32[$2_1 + 16 >> 2] = 1; + HEAP32[$2_1 + 20 >> 2] = 0; + HEAP32[$2_1 + 28 >> 2] = $2_1 + 16; + $96($2_1 + 28 | 0, 1048600, $1_1); + $5_1 = HEAP32[$3_1 >> 2]; + HEAP32[$2_1 + 8 >> 2] = $5_1; + $1_1 = HEAP32[$2_1 + 20 >> 2]; + $3_1 = HEAP32[$2_1 + 16 >> 2]; + HEAP32[$2_1 >> 2] = $3_1; + HEAP32[$2_1 + 4 >> 2] = $1_1; + HEAP32[$4 + 8 >> 2] = $5_1; + HEAP32[$4 >> 2] = $3_1; + HEAP32[$4 + 4 >> 2] = $1_1; + } + HEAP32[$0 + 4 >> 2] = 1048820; + HEAP32[$0 >> 2] = $4; + global$0 = $2_1 + 32 | 0; + } + + function $39($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0; + $2_1 = HEAP32[$1_1 + 4 >> 2]; + $3_1 = HEAP32[$1_1 >> 2]; + $1_1 = $3(8, 4); + if (!$1_1) { + $86(4, 8); + wasm2js_trap(); + } + HEAP32[$1_1 + 4 >> 2] = $2_1; + HEAP32[$1_1 >> 2] = $3_1; + HEAP32[$0 + 4 >> 2] = 1048836; + HEAP32[$0 >> 2] = $1_1; + } + + function $40($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + HEAP32[$0 + 4 >> 2] = 1048836; + HEAP32[$0 >> 2] = $1_1; + } + + function $41($0, $1_1, $2_1, $3_1, $4, $5_1) { + var $6 = 0, $7 = 0; + $6 = global$0 - 32 | 0; + global$0 = $6; + $7 = HEAP32[262345]; + HEAP32[262345] = $7 + 1; + label$1 : { + label$2 : { + if (HEAPU8[1049840] | ($7 | 0) < 0) { + break label$2 + } + HEAP8[1049840] = 1; + HEAP32[262459] = HEAP32[262459] + 1; + HEAP8[$6 + 29 | 0] = $5_1; + HEAP8[$6 + 28 | 0] = $4; + HEAP32[$6 + 24 >> 2] = $3_1; + HEAP32[$6 + 20 >> 2] = $2_1; + HEAP32[$6 + 16 >> 2] = 1048892; + HEAP32[$6 + 12 >> 2] = 1048624; + $2_1 = HEAP32[262341]; + if (($2_1 | 0) < 0) { + break label$2 + } + HEAP32[262341] = $2_1 + 1; + if (HEAP32[262343]) { + FUNCTION_TABLE[HEAP32[$1_1 + 16 >> 2]]($6, $0); + $0 = HEAP32[$6 + 4 >> 2]; + HEAP32[$6 + 12 >> 2] = HEAP32[$6 >> 2]; + HEAP32[$6 + 16 >> 2] = $0; + FUNCTION_TABLE[HEAP32[HEAP32[262344] + 20 >> 2]](HEAP32[262343], $6 + 12 | 0); + $2_1 = HEAP32[262341] - 1 | 0; + } + HEAP32[262341] = $2_1; + HEAP8[1049840] = 0; + if ($4) { + break label$1 + } + } + wasm2js_trap(); + } + wasm2js_trap(); + } + + function $45($0, $1_1) { + return ($0 + $1_1 | 0) - 1 & 0 - $1_1; + } + + function $46($0) { + $0 = $0 << 1; + return 0 - $0 | $0; + } + + function $47($0) { + return 0 - $0 & $0; + } + + function $48($0) { + return ($0 | 0) != 31 ? 25 - ($0 >>> 1 | 0) | 0 : 0; + } + + function $50($0) { + return HEAP32[$0 + 4 >> 2] & -8; + } + + function $51($0) { + return (HEAPU8[$0 + 4 | 0] & 2) >>> 1 | 0; + } + + function $52($0) { + return HEAP32[$0 + 4 >> 2] & 1; + } + + function $55($0) { + return !(HEAPU8[$0 + 4 | 0] & 3); + } + + function $56($0, $1_1) { + HEAP32[$0 + 4 >> 2] = HEAP32[$0 + 4 >> 2] & 1 | $1_1 | 2; + $0 = $0 + $1_1 | 0; + HEAP32[$0 + 4 >> 2] = HEAP32[$0 + 4 >> 2] | 1; + } + + function $57($0, $1_1) { + HEAP32[$0 + 4 >> 2] = $1_1 | 3; + $0 = $0 + $1_1 | 0; + HEAP32[$0 + 4 >> 2] = HEAP32[$0 + 4 >> 2] | 1; + } + + function $58($0, $1_1) { + HEAP32[$0 + 4 >> 2] = $1_1 | 3; + } + + function $59($0, $1_1) { + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + HEAP32[$0 + $1_1 >> 2] = $1_1; + } + + function $60($0, $1_1, $2_1) { + HEAP32[$2_1 + 4 >> 2] = HEAP32[$2_1 + 4 >> 2] & -2; + HEAP32[$0 + 4 >> 2] = $1_1 | 1; + HEAP32[$0 + $1_1 >> 2] = $1_1; + } + + function $61($0, $1_1) { + return $0 + $1_1 | 0; + } + + function $62($0, $1_1) { + return $0 - $1_1 | 0; + } + + function $63($0) { + return $0 + 8 | 0; + } + + function $65($0) { + return $0 - 8 | 0; + } + + function $66($0) { + var $1_1 = 0; + $1_1 = HEAP32[$0 + 16 >> 2]; + if (!$1_1) { + $1_1 = HEAP32[$0 + 20 >> 2] + } + return $1_1; + } + + function $70($0) { + return HEAP32[$0 + 12 >> 2] & 1; + } + + function $71($0) { + return HEAP32[$0 + 12 >> 2] >>> 1 | 0; + } + + function $73($0) { + return HEAP32[$0 >> 2] + HEAP32[$0 + 4 >> 2] | 0; + } + + function $80($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0; + $0 = HEAP32[$0 >> 2]; + $3_1 = global$0 - 16 | 0; + global$0 = $3_1; + label$1 : { + label$2 : { + label$3 : { + if ($1_1 >>> 0 >= 128) { + HEAP32[$3_1 + 12 >> 2] = 0; + if ($1_1 >>> 0 < 2048) { + break label$3 + } + if ($1_1 >>> 0 < 65536) { + HEAP8[$3_1 + 14 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 12 | 224; + HEAP8[$3_1 + 13 | 0] = $1_1 >>> 6 & 63 | 128; + $1_1 = 3; + break label$2; + } + HEAP8[$3_1 + 15 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 14 | 0] = $1_1 >>> 6 & 63 | 128; + HEAP8[$3_1 + 13 | 0] = $1_1 >>> 12 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 18 & 7 | 240; + $1_1 = 4; + break label$2; + } + $2_1 = HEAP32[$0 + 8 >> 2]; + if (($2_1 | 0) == HEAP32[$0 + 4 >> 2]) { + $4 = global$0 - 32 | 0; + global$0 = $4; + label$10 : { + label$21 : { + $2_1 = $2_1 + 1 | 0; + if (!$2_1) { + break label$21 + } + $6 = HEAP32[$0 + 4 >> 2]; + $5_1 = $6 << 1; + $2_1 = $2_1 >>> 0 < $5_1 >>> 0 ? $5_1 : $2_1; + $5_1 = $2_1 >>> 0 <= 8 ? 8 : $2_1; + $2_1 = ($5_1 ^ -1) >>> 31 | 0; + label$32 : { + if (!$6) { + HEAP32[$4 + 24 >> 2] = 0; + break label$32; + } + HEAP32[$4 + 28 >> 2] = $6; + HEAP32[$4 + 24 >> 2] = 1; + HEAP32[$4 + 20 >> 2] = HEAP32[$0 >> 2]; + } + $85($4 + 8 | 0, $2_1, $5_1, $4 + 20 | 0); + $2_1 = HEAP32[$4 + 12 >> 2]; + if (!HEAP32[$4 + 8 >> 2]) { + HEAP32[$0 + 4 >> 2] = $5_1; + HEAP32[$0 >> 2] = $2_1; + break label$10; + } + if (($2_1 | 0) == -2147483647) { + break label$10 + } + if (!$2_1) { + break label$21 + } + $86($2_1, HEAP32[$4 + 16 >> 2]); + wasm2js_trap(); + } + $87(); + wasm2js_trap(); + } + global$0 = $4 + 32 | 0; + $2_1 = HEAP32[$0 + 8 >> 2]; + } + HEAP32[$0 + 8 >> 2] = $2_1 + 1; + HEAP8[HEAP32[$0 >> 2] + $2_1 | 0] = $1_1; + break label$1; + } + HEAP8[$3_1 + 13 | 0] = $1_1 & 63 | 128; + HEAP8[$3_1 + 12 | 0] = $1_1 >>> 6 | 192; + $1_1 = 2; + } + $2_1 = HEAP32[$0 + 8 >> 2]; + if ($1_1 >>> 0 > HEAP32[$0 + 4 >> 2] - $2_1 >>> 0) { + $84($0, $2_1, $1_1); + $2_1 = HEAP32[$0 + 8 >> 2]; + } + $108(HEAP32[$0 >> 2] + $2_1 | 0, $3_1 + 12 | 0, $1_1); + HEAP32[$0 + 8 >> 2] = $1_1 + $2_1; + } + global$0 = $3_1 + 16 | 0; + return 0; + } + + function $82($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return byn$mgfn_shared$19($0, $1_1, 1048908) | 0; + } + + function $83($0, $1_1, $2_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + $2_1 = $2_1 | 0; + var $3_1 = 0; + $0 = HEAP32[$0 >> 2]; + $3_1 = HEAP32[$0 + 8 >> 2]; + if (HEAP32[$0 + 4 >> 2] - $3_1 >>> 0 < $2_1 >>> 0) { + $84($0, $3_1, $2_1); + $3_1 = HEAP32[$0 + 8 >> 2]; + } + $108(HEAP32[$0 >> 2] + $3_1 | 0, $1_1, $2_1); + HEAP32[$0 + 8 >> 2] = $2_1 + $3_1; + return 0; + } + + function $84($0, $1_1, $2_1) { + var $3_1 = 0, $4 = 0; + $3_1 = global$0 - 32 | 0; + global$0 = $3_1; + label$1 : { + label$2 : { + $4 = $1_1; + $1_1 = $1_1 + $2_1 | 0; + if ($4 >>> 0 > $1_1 >>> 0) { + break label$2 + } + $2_1 = HEAP32[$0 + 4 >> 2]; + $4 = $2_1 << 1; + $1_1 = $1_1 >>> 0 < $4 >>> 0 ? $4 : $1_1; + $4 = $1_1 >>> 0 <= 8 ? 8 : $1_1; + $1_1 = ($4 ^ -1) >>> 31 | 0; + label$3 : { + if (!$2_1) { + HEAP32[$3_1 + 24 >> 2] = 0; + break label$3; + } + HEAP32[$3_1 + 28 >> 2] = $2_1; + HEAP32[$3_1 + 24 >> 2] = 1; + HEAP32[$3_1 + 20 >> 2] = HEAP32[$0 >> 2]; + } + $85($3_1 + 8 | 0, $1_1, $4, $3_1 + 20 | 0); + $1_1 = HEAP32[$3_1 + 12 >> 2]; + if (!HEAP32[$3_1 + 8 >> 2]) { + HEAP32[$0 + 4 >> 2] = $4; + HEAP32[$0 >> 2] = $1_1; + break label$1; + } + if (($1_1 | 0) == -2147483647) { + break label$1 + } + if (!$1_1) { + break label$2 + } + $86($1_1, HEAP32[$3_1 + 16 >> 2]); + wasm2js_trap(); + } + $87(); + wasm2js_trap(); + } + global$0 = $3_1 + 32 | 0; + } + + function $85($0, $1_1, $2_1, $3_1) { + folding_inner0 : { + label$1 : { + if ($1_1) { + if (($2_1 | 0) < 0) { + break label$1 + } + label$3 : { + label$4 : { + label$5 : { + if (HEAP32[$3_1 + 4 >> 2]) { + $1_1 = HEAP32[$3_1 + 8 >> 2]; + if (!$1_1) { + if (!$2_1) { + $1_1 = 1; + break label$4; + } + $1_1 = $3($2_1, 1); + break label$5; + } + $1_1 = $5(HEAP32[$3_1 >> 2], $1_1, 1, $2_1); + break label$5; + } + if (!$2_1) { + $1_1 = 1; + break label$4; + } + $1_1 = $3($2_1, 1); + } + if (!$1_1) { + break label$3 + } + } + HEAP32[$0 + 4 >> 2] = $1_1; + HEAP32[$0 + 8 >> 2] = $2_1; + HEAP32[$0 >> 2] = 0; + return; + } + HEAP32[$0 + 4 >> 2] = 1; + break folding_inner0; + } + HEAP32[$0 + 4 >> 2] = 0; + break folding_inner0; + } + HEAP32[$0 + 4 >> 2] = 0; + HEAP32[$0 >> 2] = 1; + return; + } + HEAP32[$0 + 8 >> 2] = $2_1; + HEAP32[$0 >> 2] = 1; + } + + function $86($0, $1_1) { + var $2_1 = 0; + $2_1 = $0; + $0 = HEAP32[262340]; + FUNCTION_TABLE[($0 ? $0 : 3) | 0]($2_1, $1_1); + wasm2js_trap(); + } + + function $87() { + var $0 = 0; + $0 = global$0 - 32 | 0; + global$0 = $0; + HEAP32[$0 + 20 >> 2] = 0; + HEAP32[$0 + 24 >> 2] = 0; + HEAP32[$0 + 12 >> 2] = 1; + HEAP32[$0 + 8 >> 2] = 1048980; + HEAP32[$0 + 16 >> 2] = 1048932; + $92($0 + 8 | 0, 1048988); + wasm2js_trap(); + } + + function $91($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + wasm2js_trap(); + } + + function $92($0, $1_1) { + var $2_1 = 0, $3_1 = 0; + $2_1 = global$0 - 32 | 0; + global$0 = $2_1; + HEAP16[$2_1 + 28 >> 1] = 1; + HEAP32[$2_1 + 24 >> 2] = $1_1; + HEAP32[$2_1 + 20 >> 2] = $0; + HEAP32[$2_1 + 16 >> 2] = 1049112; + HEAP32[$2_1 + 12 >> 2] = 1049112; + $1_1 = global$0 - 16 | 0; + global$0 = $1_1; + label$1 : { + $0 = $2_1 + 12 | 0; + $2_1 = HEAP32[$0 + 12 >> 2]; + if ($2_1) { + $3_1 = HEAP32[$0 + 8 >> 2]; + if (!$3_1) { + break label$1 + } + HEAP32[$1_1 + 12 >> 2] = $2_1; + HEAP32[$1_1 + 8 >> 2] = $0; + HEAP32[$1_1 + 4 >> 2] = $3_1; + $0 = global$0 - 16 | 0; + global$0 = $0; + $1_1 = $1_1 + 4 | 0; + $2_1 = HEAP32[$1_1 >> 2]; + $3_1 = HEAP32[$2_1 + 12 >> 2]; + label$10 : { + label$2 : { + label$3 : { + switch (HEAP32[$2_1 + 4 >> 2]) { + case 0: + if ($3_1) { + break label$10 + } + $2_1 = 0; + $3_1 = 1048624; + break label$2; + case 1: + break label$3; + default: + break label$10; + }; + } + if ($3_1) { + break label$10 + } + $3_1 = HEAP32[$2_1 >> 2]; + $2_1 = HEAP32[$3_1 + 4 >> 2]; + $3_1 = HEAP32[$3_1 >> 2]; + } + HEAP32[$0 + 4 >> 2] = $2_1; + HEAP32[$0 >> 2] = $3_1; + $3_1 = $0; + $0 = HEAP32[$1_1 + 4 >> 2]; + $41($3_1, 1048852, HEAP32[$0 + 8 >> 2], HEAP32[$1_1 + 8 >> 2], HEAPU8[$0 + 16 | 0], HEAPU8[$0 + 17 | 0]); + wasm2js_trap(); + } + HEAP32[$0 + 4 >> 2] = 0; + HEAP32[$0 >> 2] = $2_1; + $3_1 = $0; + $0 = HEAP32[$1_1 + 4 >> 2]; + $41($3_1, 1048872, HEAP32[$0 + 8 >> 2], HEAP32[$1_1 + 8 >> 2], HEAPU8[$0 + 16 | 0], HEAPU8[$0 + 17 | 0]); + wasm2js_trap(); + } + $94(1048788); + wasm2js_trap(); + } + $94(1048804); + wasm2js_trap(); + } + + function $93($0, $1_1, $2_1) { + var $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, $10_1 = 0, $11_1 = 0, $12_1 = 0, $13_1 = 0; + folding_inner0 : { + $10_1 = HEAP32[$0 >> 2]; + $3_1 = HEAP32[$0 + 8 >> 2]; + if ($10_1 | $3_1) { + label$2 : { + if (!$3_1) { + break label$2 + } + $9 = $1_1 + $2_1 | 0; + $7 = HEAP32[$0 + 12 >> 2] + 1 | 0; + $4 = $1_1; + while (1) { + label$4 : { + $3_1 = $4; + $7 = $7 - 1 | 0; + if (!$7) { + break label$4 + } + if (($3_1 | 0) == ($9 | 0)) { + break label$2 + } + $4 = HEAP8[$3_1 | 0]; + label$5 : { + if (($4 | 0) >= 0) { + $5_1 = $4 & 255; + $4 = $3_1 + 1 | 0; + break label$5; + } + $8_1 = HEAPU8[$3_1 + 1 | 0] & 63; + $5_1 = $4 & 31; + if ($4 >>> 0 <= 4294967263) { + $5_1 = $8_1 | $5_1 << 6; + $4 = $3_1 + 2 | 0; + break label$5; + } + $8_1 = HEAPU8[$3_1 + 2 | 0] & 63 | $8_1 << 6; + if ($4 >>> 0 < 4294967280) { + $5_1 = $8_1 | $5_1 << 12; + $4 = $3_1 + 3 | 0; + break label$5; + } + $5_1 = $5_1 << 18 & 1835008 | (HEAPU8[$3_1 + 3 | 0] & 63 | $8_1 << 6); + if (($5_1 | 0) == 1114112) { + break label$2 + } + $4 = $3_1 + 4 | 0; + } + $6 = $4 + ($6 - $3_1 | 0) | 0; + if (($5_1 | 0) != 1114112) { + continue + } + break label$2; + } + break; + }; + if (($3_1 | 0) == ($9 | 0)) { + break label$2 + } + $4 = HEAP8[$3_1 | 0]; + if (!(($4 | 0) >= 0 | $4 >>> 0 < 4294967264 | $4 >>> 0 < 4294967280) & (($4 & 255) << 18 & 1835008 | (HEAPU8[$3_1 + 3 | 0] & 63 | ((HEAPU8[$3_1 + 2 | 0] & 63) << 6 | (HEAPU8[$3_1 + 1 | 0] & 63) << 12))) == 1114112) { + break label$2 + } + label$10 : { + label$11 : { + if (!$6) { + break label$11 + } + if ($2_1 >>> 0 <= $6 >>> 0) { + $3_1 = 0; + if (($2_1 | 0) == ($6 | 0)) { + break label$11 + } + break label$10; + } + $3_1 = 0; + if (HEAP8[$1_1 + $6 | 0] < -64) { + break label$10 + } + } + $3_1 = $1_1; + } + $2_1 = $3_1 ? $6 : $2_1; + $1_1 = $3_1 ? $3_1 : $1_1; + } + if (!$10_1) { + break folding_inner0 + } + $13_1 = HEAP32[$0 + 4 >> 2]; + label$14 : { + if ($2_1 >>> 0 >= 16) { + $6 = 0; + $7 = 0; + $3_1 = 0; + __inlined_func$102 : { + label$1 : { + label$20 : { + $5_1 = $1_1 + 3 & -4; + $10_1 = $5_1 - $1_1 | 0; + if ($10_1 >>> 0 > $2_1 >>> 0) { + break label$20 + } + $9 = $2_1 - $10_1 | 0; + if ($9 >>> 0 < 4) { + break label$20 + } + $8_1 = $9 & 3; + $4 = 0; + $12_1 = ($1_1 | 0) == ($5_1 | 0); + label$31 : { + if ($12_1) { + break label$31 + } + if ($5_1 + ($1_1 ^ -1) >>> 0 >= 3) { + while (1) { + $7 = $1_1 + $6 | 0; + $4 = ((($4 + (HEAP8[$7 | 0] > -65) | 0) + (HEAP8[$7 + 1 | 0] > -65) | 0) + (HEAP8[$7 + 2 | 0] > -65) | 0) + (HEAP8[$7 + 3 | 0] > -65) | 0; + $6 = $6 + 4 | 0; + if ($6) { + continue + } + break; + } + } + if ($12_1) { + break label$31 + } + $7 = $1_1 - $5_1 | 0; + $5_1 = $1_1 + $6 | 0; + while (1) { + $4 = (HEAP8[$5_1 | 0] > -65) + $4 | 0; + $5_1 = $5_1 + 1 | 0; + $7 = $7 + 1 | 0; + if ($7) { + continue + } + break; + }; + } + $6 = $1_1 + $10_1 | 0; + label$8 : { + if (!$8_1) { + break label$8 + } + $5_1 = ($9 & -4) + $6 | 0; + $3_1 = HEAP8[$5_1 | 0] > -65; + if (($8_1 | 0) == 1) { + break label$8 + } + $3_1 = (HEAP8[$5_1 + 1 | 0] > -65) + $3_1 | 0; + if (($8_1 | 0) == 2) { + break label$8 + } + $3_1 = (HEAP8[$5_1 + 2 | 0] > -65) + $3_1 | 0; + } + $9 = $9 >>> 2 | 0; + $7 = $3_1 + $4 | 0; + while (1) { + $3_1 = $6; + if (!$9) { + break label$1 + } + $8_1 = $9 >>> 0 >= 192 ? 192 : $9; + $10_1 = $8_1 & 3; + $6 = $8_1 << 2; + $5_1 = 0; + if ($8_1 >>> 0 >= 4) { + $12_1 = $3_1 + ($6 & 1008) | 0; + $4 = $3_1; + while (1) { + $11_1 = HEAP32[$4 >> 2]; + $11_1 = $5_1 + ((($11_1 ^ -1) >>> 7 | $11_1 >>> 6) & 16843009) | 0; + $5_1 = HEAP32[$4 + 4 >> 2]; + $11_1 = $11_1 + ((($5_1 ^ -1) >>> 7 | $5_1 >>> 6) & 16843009) | 0; + $5_1 = HEAP32[$4 + 8 >> 2]; + $11_1 = $11_1 + ((($5_1 ^ -1) >>> 7 | $5_1 >>> 6) & 16843009) | 0; + $5_1 = HEAP32[$4 + 12 >> 2]; + $5_1 = $11_1 + ((($5_1 ^ -1) >>> 7 | $5_1 >>> 6) & 16843009) | 0; + $4 = $4 + 16 | 0; + if (($12_1 | 0) != ($4 | 0)) { + continue + } + break; + }; + } + $9 = $9 - $8_1 | 0; + $6 = $3_1 + $6 | 0; + $7 = (Math_imul(($5_1 >>> 8 & 16711935) + ($5_1 & 16711935) | 0, 65537) >>> 16 | 0) + $7 | 0; + if (!$10_1) { + continue + } + break; + }; + $3_1 = $3_1 + (($8_1 & 252) << 2) | 0; + $4 = HEAP32[$3_1 >> 2]; + $4 = (($4 ^ -1) >>> 7 | $4 >>> 6) & 16843009; + label$12 : { + if (($10_1 | 0) == 1) { + break label$12 + } + $6 = HEAP32[$3_1 + 4 >> 2]; + $4 = $4 + ((($6 ^ -1) >>> 7 | $6 >>> 6) & 16843009) | 0; + if (($10_1 | 0) == 2) { + break label$12 + } + $3_1 = HEAP32[$3_1 + 8 >> 2]; + $4 = $4 + ((($3_1 ^ -1) >>> 7 | $3_1 >>> 6) & 16843009) | 0; + } + $3_1 = $4; + $3_1 = (Math_imul(($3_1 >>> 8 & 459007) + ($3_1 & 16711935) | 0, 65537) >>> 16 | 0) + $7 | 0; + break __inlined_func$102; + } + $3_1 = 0; + if (!$2_1) { + break __inlined_func$102 + } + $6 = $2_1 & 3; + label$144 : { + if ($2_1 >>> 0 < 4) { + $5_1 = 0; + break label$144; + } + $4 = $2_1 & -4; + $5_1 = 0; + while (1) { + $3_1 = $1_1 + $5_1 | 0; + $7 = ((((HEAP8[$3_1 | 0] > -65) + $7 | 0) + (HEAP8[$3_1 + 1 | 0] > -65) | 0) + (HEAP8[$3_1 + 2 | 0] > -65) | 0) + (HEAP8[$3_1 + 3 | 0] > -65) | 0; + $5_1 = $5_1 + 4 | 0; + if (($4 | 0) != ($5_1 | 0)) { + continue + } + break; + }; + } + if (!$6) { + break label$1 + } + $4 = $1_1 + $5_1 | 0; + while (1) { + $7 = (HEAP8[$4 | 0] > -65) + $7 | 0; + $4 = $4 + 1 | 0; + $6 = $6 - 1 | 0; + if ($6) { + continue + } + break; + }; + } + $3_1 = $7; + } + break label$14; + } + if (!$2_1) { + $3_1 = 0; + break label$14; + } + $7 = $2_1 & 3; + label$175 : { + if ($2_1 >>> 0 < 4) { + $3_1 = 0; + $5_1 = 0; + break label$175; + } + $4 = $2_1 & -4; + $3_1 = 0; + $5_1 = 0; + while (1) { + $6 = $3_1; + $3_1 = $1_1 + $5_1 | 0; + $3_1 = ((($6 + (HEAP8[$3_1 | 0] > -65) | 0) + (HEAP8[$3_1 + 1 | 0] > -65) | 0) + (HEAP8[$3_1 + 2 | 0] > -65) | 0) + (HEAP8[$3_1 + 3 | 0] > -65) | 0; + $5_1 = $5_1 + 4 | 0; + if (($4 | 0) != ($5_1 | 0)) { + continue + } + break; + }; + } + if (!$7) { + break label$14 + } + $4 = $1_1 + $5_1 | 0; + while (1) { + $3_1 = (HEAP8[$4 | 0] > -65) + $3_1 | 0; + $4 = $4 + 1 | 0; + $7 = $7 - 1 | 0; + if ($7) { + continue + } + break; + }; + } + label$21 : { + if ($3_1 >>> 0 < $13_1 >>> 0) { + $6 = $13_1 - $3_1 | 0; + $3_1 = 0; + label$23 : { + label$24 : { + switch (HEAPU8[$0 + 32 | 0] - 1 | 0) { + case 0: + $3_1 = $6; + $6 = 0; + break label$23; + case 1: + break label$24; + default: + break label$23; + }; + } + $3_1 = $6 >>> 1 | 0; + $6 = $6 + 1 >>> 1 | 0; + } + $3_1 = $3_1 + 1 | 0; + $4 = HEAP32[$0 + 24 >> 2]; + $5_1 = HEAP32[$0 + 16 >> 2]; + $0 = HEAP32[$0 + 20 >> 2]; + while (1) { + $3_1 = $3_1 - 1 | 0; + if (!$3_1) { + break label$21 + } + if (!(FUNCTION_TABLE[HEAP32[$4 + 16 >> 2]]($0, $5_1) | 0)) { + continue + } + break; + }; + return 1; + } + break folding_inner0; + } + if (FUNCTION_TABLE[HEAP32[$4 + 12 >> 2]]($0, $1_1, $2_1) | 0) { + $0 = 1 + } else { + $3_1 = 0; + label$29 : { + while (1) { + $1_1 = $6; + if (($3_1 | 0) == ($6 | 0)) { + break label$29 + } + $3_1 = $3_1 + 1 | 0; + if (!(FUNCTION_TABLE[HEAP32[$4 + 16 >> 2]]($0, $5_1) | 0)) { + continue + } + break; + }; + $1_1 = $3_1 - 1 | 0; + } + $0 = $1_1 >>> 0 < $6 >>> 0; + } + return $0; + } + return FUNCTION_TABLE[HEAP32[HEAP32[$0 + 24 >> 2] + 12 >> 2]](HEAP32[$0 + 20 >> 2], $1_1, $2_1) | 0; + } + return FUNCTION_TABLE[HEAP32[HEAP32[$0 + 24 >> 2] + 12 >> 2]](HEAP32[$0 + 20 >> 2], $1_1, $2_1) | 0; + } + + function $94($0) { + var $1_1 = 0; + $1_1 = global$0 - 32 | 0; + global$0 = $1_1; + HEAP32[$1_1 + 12 >> 2] = 0; + HEAP32[$1_1 + 16 >> 2] = 0; + HEAP32[$1_1 + 4 >> 2] = 1; + HEAP32[$1_1 + 8 >> 2] = 1049112; + HEAP32[$1_1 + 28 >> 2] = 43; + HEAP32[$1_1 + 24 >> 2] = 1048624; + HEAP32[$1_1 >> 2] = $1_1 + 24; + $92($1_1, $0); + wasm2js_trap(); + } + + function $95($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + var $2_1 = 0, $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, $10_1 = 0, $11_1 = 0, $12_1 = 0, $13_1 = 0; + $3_1 = $1_1; + $1_1 = 0; + $10_1 = global$0 - 48 | 0; + global$0 = $10_1; + $5_1 = 39; + $0 = HEAP32[$0 >> 2]; + if ($0 >>> 0 >= 1e4) { + while (1) { + $9 = 0; + __inlined_func$_ZN17compiler_builtins3int4udiv10divmod_u6417h6026910b5ed08e40E : { + if (!$1_1) { + i64toi32_i32$HIGH_BITS = 0; + $2_1 = ($0 >>> 0) / 1e4 | 0; + break __inlined_func$_ZN17compiler_builtins3int4udiv10divmod_u6417h6026910b5ed08e40E; + } + $4 = 51 - Math_clz32($1_1) | 0; + $7 = 0 - $4 | 0; + $8_1 = $4 & 63; + $2_1 = $8_1 & 31; + if ($8_1 >>> 0 >= 32) { + $8_1 = 0; + $6 = $1_1 >>> $2_1 | 0; + } else { + $8_1 = $1_1 >>> $2_1 | 0; + $6 = ((1 << $2_1) - 1 & $1_1) << 32 - $2_1 | $0 >>> $2_1; + } + $7 = $7 & 63; + $2_1 = $7 & 31; + if ($7 >>> 0 >= 32) { + $7 = $0 << $2_1; + $2_1 = 0; + } else { + $7 = (1 << $2_1) - 1 & $0 >>> 32 - $2_1 | $1_1 << $2_1; + $2_1 = $0 << $2_1; + } + if ($4) { + while (1) { + $11_1 = $8_1 << 1 | $6 >>> 31; + $8_1 = $6 << 1 | $7 >>> 31; + $12_1 = 0 - ($11_1 + ($8_1 >>> 0 > 9999) | 0) >> 31; + $13_1 = $12_1 & 1e4; + $6 = $8_1 - $13_1 | 0; + $8_1 = $11_1 - ($8_1 >>> 0 < $13_1 >>> 0) | 0; + $7 = $7 << 1 | $2_1 >>> 31; + $2_1 = $9 | $2_1 << 1; + $9 = $12_1 & 1; + $4 = $4 - 1 | 0; + if ($4) { + continue + } + break; + } + } + i64toi32_i32$HIGH_BITS = $7 << 1 | $2_1 >>> 31; + $2_1 = $9 | $2_1 << 1; + } + $7 = $2_1 >>> 16 | 0; + $8_1 = Math_imul($7, 0); + $6 = Math_imul($2_1 & 65535, 1e4); + $9 = Math_imul($7, 1e4) + ($6 >>> 16 | 0) | 0; + $4 = $9 & 65535; + $7 = i64toi32_i32$HIGH_BITS; + i64toi32_i32$HIGH_BITS = $8_1 + Math_imul($7, 1e4) + ($9 >>> 16) + ($4 >>> 16) | 0; + $11_1 = ($10_1 + 9 | 0) + $5_1 | 0; + $9 = $11_1 - 4 | 0; + $4 = $0 - ($6 & 65535 | $4 << 16) | 0; + $8_1 = (($4 & 65535) >>> 0) / 100 | 0; + $6 = ($8_1 << 1) + 1049148 | 0; + $6 = HEAPU8[$6 | 0] | HEAPU8[$6 + 1 | 0] << 8; + HEAP8[$9 | 0] = $6; + HEAP8[$9 + 1 | 0] = $6 >>> 8; + $6 = $11_1 - 2 | 0; + $4 = (($4 - Math_imul($8_1, 100) & 65535) << 1) + 1049148 | 0; + $4 = HEAPU8[$4 | 0] | HEAPU8[$4 + 1 | 0] << 8; + HEAP8[$6 | 0] = $4; + HEAP8[$6 + 1 | 0] = $4 >>> 8; + $5_1 = $5_1 - 4 | 0; + $4 = !$1_1 & $0 >>> 0 > 99999999 | ($1_1 | 0) != 0; + $0 = $2_1; + $1_1 = $7; + if ($4) { + continue + } + break; + } + } + if ($0 >>> 0 > 99) { + $5_1 = $5_1 - 2 | 0; + $1_1 = $5_1 + ($10_1 + 9 | 0) | 0; + $2_1 = $0; + $0 = (($0 & 65535) >>> 0) / 100 | 0; + $2_1 = (($2_1 - Math_imul($0, 100) & 65535) << 1) + 1049148 | 0; + $2_1 = HEAPU8[$2_1 | 0] | HEAPU8[$2_1 + 1 | 0] << 8; + HEAP8[$1_1 | 0] = $2_1; + HEAP8[$1_1 + 1 | 0] = $2_1 >>> 8; + } + label$5 : { + if ($0 >>> 0 >= 10) { + $5_1 = $5_1 - 2 | 0; + $1_1 = $5_1 + ($10_1 + 9 | 0) | 0; + $0 = ($0 << 1) + 1049148 | 0; + $0 = HEAPU8[$0 | 0] | HEAPU8[$0 + 1 | 0] << 8; + HEAP8[$1_1 | 0] = $0; + HEAP8[$1_1 + 1 | 0] = $0 >>> 8; + break label$5; + } + $5_1 = $5_1 - 1 | 0; + HEAP8[$5_1 + ($10_1 + 9 | 0) | 0] = $0 + 48; + } + $4 = ($10_1 + 9 | 0) + $5_1 | 0; + $0 = HEAP32[$3_1 + 28 >> 2]; + $1_1 = $0 & 1; + $2_1 = $1_1 ? 43 : 1114112; + $8_1 = 39 - $5_1 | 0; + $1_1 = $1_1 + $8_1 | 0; + $7 = $0 & 4 ? 1049112 : 0; + __inlined_func$97 : { + folding_inner0 : { + label$12 : { + if (!HEAP32[$3_1 >> 2]) { + $0 = 1; + $1_1 = HEAP32[$3_1 + 20 >> 2]; + $3_1 = HEAP32[$3_1 + 24 >> 2]; + if ($103($1_1, $3_1, $2_1, $7)) { + break label$12 + } + break folding_inner0; + } + $5_1 = HEAP32[$3_1 + 4 >> 2]; + if ($5_1 >>> 0 <= $1_1 >>> 0) { + $0 = 1; + $1_1 = HEAP32[$3_1 + 20 >> 2]; + $3_1 = HEAP32[$3_1 + 24 >> 2]; + if ($103($1_1, $3_1, $2_1, $7)) { + break label$12 + } + break folding_inner0; + } + if ($0 & 8) { + $12_1 = HEAP32[$3_1 + 16 >> 2]; + HEAP32[$3_1 + 16 >> 2] = 48; + $11_1 = HEAPU8[$3_1 + 32 | 0]; + $0 = 1; + HEAP8[$3_1 + 32 | 0] = 1; + $6 = HEAP32[$3_1 + 20 >> 2]; + $9 = HEAP32[$3_1 + 24 >> 2]; + if ($103($6, $9, $2_1, $7)) { + break label$12 + } + $0 = ($5_1 - $1_1 | 0) + 1 | 0; + label$16 : { + while (1) { + $0 = $0 - 1 | 0; + if (!$0) { + break label$16 + } + if (!(FUNCTION_TABLE[HEAP32[$9 + 16 >> 2]]($6, 48) | 0)) { + continue + } + break; + }; + $2_1 = 1; + break __inlined_func$97; + } + $0 = 1; + if (FUNCTION_TABLE[HEAP32[$9 + 12 >> 2]]($6, $4, $8_1) | 0) { + break label$12 + } + HEAP8[$3_1 + 32 | 0] = $11_1; + HEAP32[$3_1 + 16 >> 2] = $12_1; + $0 = 0; + break label$12; + } + $1_1 = $5_1 - $1_1 | 0; + label$18 : { + label$19 : { + label$20 : { + $0 = HEAPU8[$3_1 + 32 | 0]; + switch ($0 - 1 | 0) { + case 1: + break label$19; + case 0: + case 2: + break label$20; + default: + break label$18; + }; + } + $0 = $1_1; + $1_1 = 0; + break label$18; + } + $0 = $1_1 >>> 1 | 0; + $1_1 = $1_1 + 1 >>> 1 | 0; + } + $0 = $0 + 1 | 0; + $5_1 = HEAP32[$3_1 + 24 >> 2]; + $6 = HEAP32[$3_1 + 16 >> 2]; + $3_1 = HEAP32[$3_1 + 20 >> 2]; + label$21 : { + while (1) { + $0 = $0 - 1 | 0; + if (!$0) { + break label$21 + } + if (!(FUNCTION_TABLE[HEAP32[$5_1 + 16 >> 2]]($3_1, $6) | 0)) { + continue + } + break; + }; + $2_1 = 1; + break __inlined_func$97; + } + $0 = 1; + if ($103($3_1, $5_1, $2_1, $7)) { + break label$12 + } + if (FUNCTION_TABLE[HEAP32[$5_1 + 12 >> 2]]($3_1, $4, $8_1) | 0) { + break label$12 + } + $0 = 0; + while (1) { + $2_1 = 0; + if (($0 | 0) == ($1_1 | 0)) { + break __inlined_func$97 + } + $0 = $0 + 1 | 0; + if (!(FUNCTION_TABLE[HEAP32[$5_1 + 16 >> 2]]($3_1, $6) | 0)) { + continue + } + break; + }; + $2_1 = $0 - 1 >>> 0 < $1_1 >>> 0; + break __inlined_func$97; + } + $2_1 = $0; + break __inlined_func$97; + } + $2_1 = FUNCTION_TABLE[HEAP32[$3_1 + 12 >> 2]]($1_1, $4, $8_1) | 0; + } + $0 = $2_1; + global$0 = $10_1 + 48 | 0; + return $0 | 0; + } + + function $96($0, $1_1, $2_1) { + var $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, $10_1 = 0, $11_1 = 0, $12_1 = 0; + $3_1 = global$0 - 48 | 0; + global$0 = $3_1; + HEAP32[$3_1 + 36 >> 2] = $1_1; + HEAP8[$3_1 + 44 | 0] = 3; + HEAP32[$3_1 + 28 >> 2] = 32; + HEAP32[$3_1 + 40 >> 2] = 0; + HEAP32[$3_1 + 32 >> 2] = $0; + HEAP32[$3_1 + 20 >> 2] = 0; + HEAP32[$3_1 + 12 >> 2] = 0; + label$1 : { + label$2 : { + $9 = HEAP32[$2_1 + 16 >> 2]; + label$3 : { + label$4 : { + if (!$9) { + $0 = HEAP32[$2_1 + 12 >> 2]; + if (!$0) { + break label$4 + } + $1_1 = HEAP32[$2_1 + 8 >> 2]; + $5_1 = $0 << 3; + $7 = ($0 - 1 & 536870911) + 1 | 0; + $0 = HEAP32[$2_1 >> 2]; + while (1) { + $4 = HEAP32[$0 + 4 >> 2]; + if ($4) { + if (FUNCTION_TABLE[HEAP32[HEAP32[$3_1 + 36 >> 2] + 12 >> 2]](HEAP32[$3_1 + 32 >> 2], HEAP32[$0 >> 2], $4) | 0) { + break label$3 + } + } + if (FUNCTION_TABLE[HEAP32[$1_1 + 4 >> 2]](HEAP32[$1_1 >> 2], $3_1 + 12 | 0) | 0) { + break label$3 + } + $1_1 = $1_1 + 8 | 0; + $0 = $0 + 8 | 0; + $5_1 = $5_1 - 8 | 0; + if ($5_1) { + continue + } + break; + }; + break label$4; + } + $0 = HEAP32[$2_1 + 20 >> 2]; + if (!$0) { + break label$4 + } + $12_1 = $0 << 5; + $7 = ($0 - 1 & 134217727) + 1 | 0; + $8_1 = HEAP32[$2_1 + 8 >> 2]; + $0 = HEAP32[$2_1 >> 2]; + while (1) { + $1_1 = HEAP32[$0 + 4 >> 2]; + if ($1_1) { + if (FUNCTION_TABLE[HEAP32[HEAP32[$3_1 + 36 >> 2] + 12 >> 2]](HEAP32[$3_1 + 32 >> 2], HEAP32[$0 >> 2], $1_1) | 0) { + break label$3 + } + } + $1_1 = $5_1 + $9 | 0; + HEAP32[$3_1 + 28 >> 2] = HEAP32[$1_1 + 16 >> 2]; + HEAP8[$3_1 + 44 | 0] = HEAPU8[$1_1 + 28 | 0]; + HEAP32[$3_1 + 40 >> 2] = HEAP32[$1_1 + 24 >> 2]; + $6 = HEAP32[$1_1 + 12 >> 2]; + $10_1 = 0; + $4 = 0; + label$10 : { + label$11 : { + switch (HEAP32[$1_1 + 8 >> 2] - 1 | 0) { + case 0: + $11_1 = ($6 << 3) + $8_1 | 0; + if (HEAP32[$11_1 + 4 >> 2] != 24) { + break label$10 + } + $6 = HEAP32[HEAP32[$11_1 >> 2] >> 2]; + break; + case 1: + break label$10; + default: + break label$11; + }; + } + $4 = 1; + } + HEAP32[$3_1 + 16 >> 2] = $6; + HEAP32[$3_1 + 12 >> 2] = $4; + $4 = HEAP32[$1_1 + 4 >> 2]; + label$13 : { + label$14 : { + switch (HEAP32[$1_1 >> 2] - 1 | 0) { + case 0: + $6 = ($4 << 3) + $8_1 | 0; + if (HEAP32[$6 + 4 >> 2] != 24) { + break label$13 + } + $4 = HEAP32[HEAP32[$6 >> 2] >> 2]; + break; + case 1: + break label$13; + default: + break label$14; + }; + } + $10_1 = 1; + } + HEAP32[$3_1 + 24 >> 2] = $4; + HEAP32[$3_1 + 20 >> 2] = $10_1; + $1_1 = (HEAP32[$1_1 + 20 >> 2] << 3) + $8_1 | 0; + if (FUNCTION_TABLE[HEAP32[$1_1 + 4 >> 2]](HEAP32[$1_1 >> 2], $3_1 + 12 | 0) | 0) { + break label$3 + } + $0 = $0 + 8 | 0; + $5_1 = $5_1 + 32 | 0; + if (($12_1 | 0) != ($5_1 | 0)) { + continue + } + break; + }; + } + if (HEAPU32[$2_1 + 4 >> 2] <= $7 >>> 0) { + break label$2 + } + $0 = HEAP32[$2_1 >> 2] + ($7 << 3) | 0; + if (!(FUNCTION_TABLE[HEAP32[HEAP32[$3_1 + 36 >> 2] + 12 >> 2]](HEAP32[$3_1 + 32 >> 2], HEAP32[$0 >> 2], HEAP32[$0 + 4 >> 2]) | 0)) { + break label$2 + } + } + $0 = 1; + break label$1; + } + $0 = 0; + } + global$0 = $3_1 + 48 | 0; + return $0; + } + + function $99($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return $93($1_1, HEAP32[$0 >> 2], HEAP32[$0 + 4 >> 2]) | 0; + } + + function $101($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return FUNCTION_TABLE[HEAP32[HEAP32[$0 + 4 >> 2] + 12 >> 2]](HEAP32[$0 >> 2], $1_1) | 0; + } + + function $103($0, $1_1, $2_1, $3_1) { + var $4 = 0; + label$1 : { + label$2 : { + if (($2_1 | 0) != 1114112) { + $4 = 1; + if (FUNCTION_TABLE[HEAP32[$1_1 + 16 >> 2]]($0, $2_1) | 0) { + break label$2 + } + } + if ($3_1) { + break label$1 + } + $4 = 0; + } + return $4; + } + return FUNCTION_TABLE[HEAP32[$1_1 + 12 >> 2]]($0, $3_1, 0) | 0; + } + + function $106($0, $1_1) { + $0 = $0 | 0; + $1_1 = $1_1 | 0; + return FUNCTION_TABLE[HEAP32[HEAP32[$1_1 + 24 >> 2] + 12 >> 2]](HEAP32[$1_1 + 20 >> 2], 1049348, 5) | 0; + } + + function $108($0, $1_1, $2_1) { + var $3_1 = 0, $4 = 0, $5_1 = 0, $6 = 0, $7 = 0, $8_1 = 0, $9 = 0, $10_1 = 0; + $6 = $2_1; + label$1 : { + if ($2_1 >>> 0 < 16) { + $2_1 = $0; + break label$1; + } + $3_1 = 0 - $0 & 3; + $4 = $3_1 + $0 | 0; + if ($3_1) { + $2_1 = $0; + $5_1 = $1_1; + while (1) { + HEAP8[$2_1 | 0] = HEAPU8[$5_1 | 0]; + $5_1 = $5_1 + 1 | 0; + $2_1 = $2_1 + 1 | 0; + if ($4 >>> 0 > $2_1 >>> 0) { + continue + } + break; + }; + } + $8_1 = $6 - $3_1 | 0; + $7 = $8_1 & -4; + $2_1 = $7 + $4 | 0; + $3_1 = $1_1 + $3_1 | 0; + label$5 : { + if ($3_1 & 3) { + if (($7 | 0) <= 0) { + break label$5 + } + $6 = $3_1 << 3; + $9 = $6 & 24; + $5_1 = $3_1 & -4; + $1_1 = $5_1 + 4 | 0; + $6 = 0 - $6 & 24; + $5_1 = HEAP32[$5_1 >> 2]; + while (1) { + $10_1 = $5_1 >>> $9 | 0; + $5_1 = HEAP32[$1_1 >> 2]; + HEAP32[$4 >> 2] = $10_1 | $5_1 << $6; + $1_1 = $1_1 + 4 | 0; + $4 = $4 + 4 | 0; + if ($4 >>> 0 < $2_1 >>> 0) { + continue + } + break; + }; + break label$5; + } + if (($7 | 0) <= 0) { + break label$5 + } + $1_1 = $3_1; + while (1) { + HEAP32[$4 >> 2] = HEAP32[$1_1 >> 2]; + $1_1 = $1_1 + 4 | 0; + $4 = $4 + 4 | 0; + if ($4 >>> 0 < $2_1 >>> 0) { + continue + } + break; + }; + } + $6 = $8_1 & 3; + $1_1 = $3_1 + $7 | 0; + } + if ($6) { + $3_1 = $2_1 + $6 | 0; + while (1) { + HEAP8[$2_1 | 0] = HEAPU8[$1_1 | 0]; + $1_1 = $1_1 + 1 | 0; + $2_1 = $2_1 + 1 | 0; + if ($3_1 >>> 0 > $2_1 >>> 0) { + continue + } + break; + }; + } + return $0; + } + + function __wasm_ctz_i32($0) { + if ($0) { + return 31 - Math_clz32($0 - 1 ^ $0) | 0 + } + return 32; + } + + function __wasm_rotl_i32($0) { + var $1_1 = 0; + $1_1 = $0 & 31; + $0 = 0 - $0 & 31; + return (-1 >>> $1_1 & -2) << $1_1 | (-1 << $0 & -2) >>> $0; + } + + function byn$mgfn_shared$19($0, $1_1, $2_1) { + var $3_1 = 0; + $3_1 = global$0 - 16 | 0; + global$0 = $3_1; + HEAP32[$3_1 + 12 >> 2] = HEAP32[$0 >> 2]; + $0 = $96($3_1 + 12 | 0, $2_1, $1_1); + global$0 = $3_1 + 16 | 0; + return $0; + } + + bufferView = HEAPU8; + initActiveSegments(imports); + var FUNCTION_TABLE = [null, $1, $95, $32, $14, $20, $17, $19, $15, $11, $10, $39, $40, $16, $37, $38, $14, $12, $14, $83, $80, $82, $14, $106, $91, $101, $99, $14, $12]; + function __wasm_memory_size() { + return buffer.byteLength / 65536 | 0; + } + + function __wasm_memory_grow(pagesToAdd) { + pagesToAdd = pagesToAdd | 0; + var oldPages = __wasm_memory_size() | 0; + var newPages = oldPages + pagesToAdd | 0; + if ((oldPages < newPages) && (newPages < 65536)) { + var newBuffer = new ArrayBuffer(Math_imul(newPages, 65536)); + var newHEAP8 = new Int8Array(newBuffer); + newHEAP8.set(HEAP8); + HEAP8 = new Int8Array(newBuffer); + HEAP16 = new Int16Array(newBuffer); + HEAP32 = new Int32Array(newBuffer); + HEAPU8 = new Uint8Array(newBuffer); + HEAPU16 = new Uint16Array(newBuffer); + HEAPU32 = new Uint32Array(newBuffer); + HEAPF32 = new Float32Array(newBuffer); + HEAPF64 = new Float64Array(newBuffer); + buffer = newBuffer; + bufferView = HEAPU8; + } + return oldPages; + } + + return { + "memory": Object.create(Object.prototype, { + "grow": { + "value": __wasm_memory_grow + }, + "buffer": { + "get": function () { + return buffer; + } + + } + }), + "greet": $2, + "cabi_realloc": $8, + "__data_end": { + get value() { + return global$1; + }, + set value(_global$1) { + global$1 = _global$1; + } + }, + "__heap_base": { + get value() { + return global$2; + }, + set value(_global$2) { + global$2 = _global$2; + } + } + }; +}, +function asm1(imports) { + function Table(ret) { + // grow method not included; table is not growable + ret.set = function(i, func) { + this[i] = func; + }; + ret.get = function(i) { + return this[i]; + }; + return ret; +} + + + var Math_imul = Math.imul; + var Math_fround = Math.fround; + var Math_abs = Math.abs; + var Math_clz32 = Math.clz32; + var Math_min = Math.min; + var Math_max = Math.max; + var Math_floor = Math.floor; + var Math_ceil = Math.ceil; + var Math_trunc = Math.trunc; + var Math_sqrt = Math.sqrt; + var nan = NaN; + var infinity = Infinity; + function $0($0_1, $1) { + $0_1 = $0_1 | 0; + $1 = $1 | 0; + FUNCTION_TABLE[0]($0_1, $1); + } + + var FUNCTION_TABLE = Table([]); + return { + "$0": $0, + "$imports": FUNCTION_TABLE + }; +}, +function asm2(imports) { + var $ = imports[""]; + var FUNCTION_TABLE = $.$imports; + var Math_imul = Math.imul; + var Math_fround = Math.fround; + var Math_abs = Math.abs; + var Math_clz32 = Math.clz32; + var Math_min = Math.min; + var Math_max = Math.max; + var Math_floor = Math.floor; + var Math_ceil = Math.ceil; + var Math_trunc = Math.trunc; + var Math_sqrt = Math.sqrt; + var nan = NaN; + var infinity = Infinity; + var fimport$0 = $["0"]; + FUNCTION_TABLE[0] = fimport$0; + return { + + }; +}]; + +function instantiate(imports) { + const wasm_file_to_asm_index = { + 'timeline.core.wasm': 0, + 'timeline.core2.wasm': 1, + 'timeline.core3.wasm': 2 + }; + + return _instantiate( + module_name => wasm_file_to_asm_index[module_name], + imports, + (module_index, imports) => ({ exports: asmInit[module_index](imports) }) + ); +} diff --git a/crates/matrix-sdk-extensions/guests/timeline/src/lib.rs b/crates/matrix-sdk-extensions/guests/timeline/src/lib.rs new file mode 100644 index 00000000000..cd5af96d417 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/src/lib.rs @@ -0,0 +1,53 @@ +wit_bindgen::generate!({ + world: "timeline", + exports: { + world: Timeline, + }, +}); + +struct Timeline; + +impl Guest for Timeline { + fn greet(who: String) { + matrix::ui_timeline::std::print(&format!("Hello, {who}!")) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + use wasmtime::{component::*, Config, Engine, Result, Store}; + + bindgen!("timeline"); + + #[derive(Debug, Default)] + struct TimelineState { + output: String, + } + + impl matrix::ui_timeline::std::Host for TimelineState { + fn print(&mut self, msg: String) -> Result<()> { + self.output.push_str(&msg); + self.output.push_str("\n"); + + Ok(()) + } + } + + let mut config = Config::new(); + config.wasm_component_model(true); + let engine = Engine::new(&config).unwrap(); + let component = Component::from_file(&engine, "timeline.wasm").unwrap(); + + let mut linker = Linker::new(&engine); + Timeline::add_to_linker(&mut linker, |state: &mut TimelineState| state).unwrap(); + + let mut store = Store::new(&engine, TimelineState::default()); + let (bindings, _) = Timeline::instantiate(&mut store, &component, &linker).unwrap(); + + bindings.call_greet(&mut store, "Gordon").unwrap(); + + assert_eq!(store.data().output, "Hello, Gordon!\n"); + } +} diff --git a/crates/matrix-sdk-extensions/guests/timeline/wit/timeline.wit b/crates/matrix-sdk-extensions/guests/timeline/wit/timeline.wit new file mode 120000 index 00000000000..bdad51d7963 --- /dev/null +++ b/crates/matrix-sdk-extensions/guests/timeline/wit/timeline.wit @@ -0,0 +1 @@ +../../../wit/timeline.wit \ No newline at end of file diff --git a/crates/matrix-sdk-extensions/src/javascriptcore/from_into.rs b/crates/matrix-sdk-extensions/src/javascriptcore/from_into.rs new file mode 100644 index 00000000000..9c39ea73782 --- /dev/null +++ b/crates/matrix-sdk-extensions/src/javascriptcore/from_into.rs @@ -0,0 +1,15 @@ +use javascriptcore::{JSException, JSValue}; + +pub trait TryIntoRust { + type Error; + + fn try_into_rust(&self) -> Result; +} + +impl TryIntoRust for &JSValue { + type Error = JSException; + + fn try_into_rust(&self) -> Result { + Ok(self.as_string()?.to_string()) + } +} diff --git a/crates/matrix-sdk-extensions/src/javascriptcore/mod.rs b/crates/matrix-sdk-extensions/src/javascriptcore/mod.rs new file mode 100644 index 00000000000..7d164f8343b --- /dev/null +++ b/crates/matrix-sdk-extensions/src/javascriptcore/mod.rs @@ -0,0 +1,209 @@ +mod from_into; +mod web_api; + +use std::{ + error::Error, + fmt, fs, + marker::PhantomData, + ops::Deref, + path::Path, + result::Result as StdResult, + sync::{Arc, Mutex, MutexGuard}, +}; + +use javascriptcore::{evaluate_script, JSClass}; +pub use javascriptcore::{function_callback, JSContext, JSException, JSObject, JSValue}; +pub use matrix_sdk_extensions_macros::javascriptcore_bindgen as bindgen; + +use crate::{ + traits::{Instance, Module}, + Result, +}; + +#[derive(Debug)] +struct JSError { + error: String, +} + +impl fmt::Display for JSError { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(formatter, "JSError: {}", self.error) + } +} + +impl Error for JSError {} + +impl From for JSError { + fn from(exception: JSException) -> Self { + Self { error: exception.to_string() } + } +} + +pub trait ModuleExt { + fn link( + context: &JSContext, + imports: &JSObject, + environment: &Arc>, + ) -> Result<()>; +} + +pub struct JSExports +where + M: Module, +{ + #[doc(hidden)] + pub context: Arc, + + #[doc(hidden)] + pub exports: JSObject, + + phantom: PhantomData, +} + +pub struct JSInstance +where + M: Module, +{ + #[allow(unused)] + context: Arc, + environment: Arc>, + pub exports: JSExports, +} + +pub struct EnvironmentGuard<'a, M>(MutexGuard<'a, M::Environment>) +where + M: Module; + +impl<'a, M> Deref for EnvironmentGuard<'a, M> +where + M: Module, +{ + type Target = M::Environment; + + fn deref(&self) -> &Self::Target { + self.0.deref() + } +} + +impl Instance for JSInstance +where + M: Module + ModuleExt, +{ + type EnvironmentRef<'a> = EnvironmentGuard<'a, M> where Self: 'a; + + fn new

(js_file: P) -> Result + where + P: AsRef, + { + Ok(Self::new_impl(js_file).map_err(JSError::from)?) + } + + fn environment<'a>(&'a self) -> Self::EnvironmentRef<'a> { + EnvironmentGuard(self.environment.lock().unwrap()) + } +} + +impl JSInstance +where + M: Module + ModuleExt, +{ + fn new_impl

(js_file: P) -> StdResult + where + P: AsRef, + { + let js_file = js_file.as_ref(); + let context = JSContext::default(); + let global_object = context.global_object()?; + + // Set up. + { + let text_encoder = JSClass::builder(&context, "TextEncoder")? + .constructor(Some(web_api::text_encoder)) + .build()?; + let text_decoder = JSClass::builder(&context, "TextDecoder")? + .constructor(Some(web_api::text_decoder)) + .build()?; + + global_object.set_property("TextEncoder", text_encoder.new_object().into())?; + global_object.set_property("TextDecoder", text_decoder.new_object().into())?; + } + + let environment = Arc::new(Mutex::new(M::Environment::default())); + + let imports = { + let imports = JSValue::new_from_json(&context, r#"{}"#).unwrap(); + let imports_as_object = imports.as_object()?; + + M::link(&context, &imports_as_object, &environment).unwrap(); + + imports + }; + + // Run the script. + { + let timeline_script = fs::read_to_string(js_file).unwrap().replace("export ", ""); + + let _result = evaluate_script( + &context, + timeline_script, + None, + js_file.to_string_lossy().into_owned(), + 1, + )?; + } + + // Run the `instantiate` function from the script. + let instantiate = global_object.get_property("instantiate"); + + assert!(instantiate.is_object(), "`instantiate` does not exist"); + + let exports = instantiate.as_object()?.call_as_function(None, &[imports])?.as_object()?; + let context = Arc::new(context); + + Ok(Self { + context: context.clone(), + environment, + exports: JSExports { context, exports, phantom: Default::default() }, + }) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_instance() -> Result<()> { + bindgen!({ + world: "timeline", + environment: TimelineEnvironment, + matrix_sdk_extensions_alias: crate, + }); + + #[derive(Default, Debug)] + struct TimelineEnvironment { + output: String, + } + + impl matrix::ui_timeline::std::Host for TimelineEnvironment { + fn print(&mut self, msg: String) -> Result<()> { + self.output.push_str(&msg); + self.output.push_str("\n"); + + Ok(()) + } + } + + let mut instance = TimelineInstance::new("guests/timeline/js/timeline.js").unwrap(); + let result = instance.exports.greet("Gordon"); + + assert!(result.is_ok()); + + { + let env = instance.environment(); + assert_eq!(env.output, "Hello, Gordon!\n"); + } + + Ok(()) + } +} diff --git a/crates/matrix-sdk-extensions/src/javascriptcore/web_api.rs b/crates/matrix-sdk-extensions/src/javascriptcore/web_api.rs new file mode 100644 index 00000000000..e6301b221bc --- /dev/null +++ b/crates/matrix-sdk-extensions/src/javascriptcore/web_api.rs @@ -0,0 +1,125 @@ +use javascriptcore::{constructor_callback, function_callback, JSException, JSTypedArrayType}; + +#[constructor_callback] +pub(super) fn text_encoder( + ctx: &JSContext, + constructor: &JSObject, + _arguments: &[JSValue], +) -> Result { + #[function_callback] + fn encode_into( + ctx: &JSContext, + _function: Option<&JSObject>, + _this_object: Option<&JSObject>, + arguments: &[JSValue], + ) -> Result { + let string = arguments + .get(0) + .ok_or_else(|| -> JSException { + JSValue::new_string(ctx, "The first argument `string` is missing").into() + }) + .and_then(|string| { + if string.is_string() { + string.as_string() + } else { + Err(JSValue::new_string(ctx, "The first argument `string` is not a string") + .into()) + } + })?; + + let mut utf8_array = arguments + .get(1) + .ok_or_else(|| -> JSException { + JSValue::new_string(ctx, "The second argument `utf8Array` is missing").into() + }) + .and_then(|class| { + if class.is_typed_array() + && class.as_typed_array()?.ty()? == JSTypedArrayType::Uint8Array + { + class.as_typed_array() + } else { + Err(JSValue::new_string( + ctx, + "The second argument `uint8Array` is not a `Uint8Array`", + ) + .into()) + } + })?; + + let position = arguments + .get(2) + .map(|number| -> Result { + if number.is_number() { + Ok(number.as_number()? as usize) + } else { + Err(JSValue::new_string(ctx, "The third argument `position` is not a `number`") + .into()) + } + }) + .transpose()? + .unwrap_or_default(); + + let utf8_array_slice = unsafe { utf8_array.as_mut_slice() }?; + + for (nth, char) in string.to_string().as_bytes().iter().enumerate() { + *utf8_array_slice.get_mut(nth + position).unwrap() = *char; + } + + let result = + JSValue::new_from_json(ctx, "{\"read\": 0, \"written\": 0}").unwrap().as_object()?; + + let len = f64::from(string.len() as u32); + result.set_property("read", JSValue::new_number(ctx, len))?; + result.set_property("written", JSValue::new_number(ctx, len))?; + + Ok(result.into()) + } + + constructor + .set_property("encodeInto", JSValue::new_function(ctx, "encodeInto", Some(encode_into)))?; + + Ok(constructor.into()) +} + +#[constructor_callback] +pub(super) fn text_decoder( + ctx: &JSContext, + constructor: &JSObject, + _arguments: &[JSValue], +) -> Result { + #[function_callback] + fn decode( + ctx: &JSContext, + _function: Option<&JSObject>, + _this_object: Option<&JSObject>, + arguments: &[JSValue], + ) -> Result { + let utf8_array = arguments + .get(0) + .ok_or_else(|| -> JSException { + JSValue::new_string(ctx, "The first argument `utf8Array` is missing").into() + }) + .and_then(|class| { + if class.is_typed_array() + && class.as_typed_array()?.ty()? == JSTypedArrayType::Uint8Array + { + class.as_typed_array() + } else { + Err(JSValue::new_string( + ctx, + "The first argument `uint8Array` is not a `Uint8Array`", + ) + .into()) + } + })?; + + let utf8_array_as_vec = utf8_array.to_vec()?; + let string = String::from_utf8_lossy(&utf8_array_as_vec).into_owned(); + + Ok(JSValue::new_string(ctx, string)) + } + + constructor.set_property("decode", JSValue::new_function(ctx, "decode", Some(decode)))?; + + Ok(constructor.into()) +} diff --git a/crates/matrix-sdk-extensions/src/lib.rs b/crates/matrix-sdk-extensions/src/lib.rs new file mode 100644 index 00000000000..46f79e043af --- /dev/null +++ b/crates/matrix-sdk-extensions/src/lib.rs @@ -0,0 +1,14 @@ +pub mod traits; + +#[cfg(feature = "native")] +pub mod native; + +#[cfg(feature = "javascriptcore")] +pub mod javascriptcore; + +// #[cfg(feature = "javascriptcore")] +// pub use javascriptcore::NativeInstance as Instance; +// #[cfg(feature = "native")] +// pub use native::NativeInstance as Instance; + +pub type Result = core::result::Result; diff --git a/crates/matrix-sdk-extensions/src/native.rs b/crates/matrix-sdk-extensions/src/native.rs new file mode 100644 index 00000000000..1f4fabb4092 --- /dev/null +++ b/crates/matrix-sdk-extensions/src/native.rs @@ -0,0 +1,131 @@ +use std::{ + ops::Deref, + path::Path, + sync::{Arc, RwLock, RwLockReadGuard}, +}; + +pub use matrix_sdk_extensions_macros::wasmtime_bindgen as bindgen; +use wasmtime::{ + component::{Component, Linker}, + Config, Engine, Store, +}; + +use crate::{ + traits::{Instance, Module}, + Result, +}; + +pub trait ModuleExt { + fn link( + linker: &mut Linker, + get: impl Fn(&mut Environment) -> &mut Environment + Send + Sync + Copy + 'static, + ) -> Result<()>; + + fn instantiate_component( + store: &mut Store, + component: &Component, + linker: &Linker, + ) -> Result; +} + +pub struct NativeExports +where + M: Module, +{ + #[doc(hidden)] + pub store: Arc>>, + + #[doc(hidden)] + pub bindings: M::Bindings, +} + +pub struct NativeInstance +where + M: Module, +{ + store: Arc>>, + pub exports: NativeExports, +} + +pub struct EnvironmentGuard<'a, M>(RwLockReadGuard<'a, Store>) +where + M: Module; + +impl<'a, M> Deref for EnvironmentGuard<'a, M> +where + M: Module, +{ + type Target = M::Environment; + + fn deref(&self) -> &Self::Target { + self.0.deref().data() + } +} + +impl Instance for NativeInstance +where + M: Module + ModuleExt, +{ + type EnvironmentRef<'a> = EnvironmentGuard<'a, M> where Self: 'a; + + fn new

(wasm_module: P) -> Result + where + P: AsRef, + { + let mut config = Config::new(); + config.wasm_component_model(true); + + let engine = Engine::new(&config)?; + let mut store = Store::new(&engine, M::new_environment()); + let component = Component::from_file(&engine, wasm_module)?; + let mut linker = Linker::new(&engine); + M::link(&mut linker, |state: &mut M::Environment| state)?; + + let bindings = M::instantiate_component(&mut store, &component, &linker)?; + let store = Arc::new(RwLock::new(store)); + + Ok(Self { store: store.clone(), exports: NativeExports { store, bindings } }) + } + + fn environment<'a>(&'a self) -> Self::EnvironmentRef<'a> { + EnvironmentGuard(self.store.read().unwrap()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_instance() { + bindgen!({ + world: "timeline", + environment: TimelineEnvironment, + matrix_sdk_extensions_alias: crate, + }); + + #[derive(Default, Debug)] + struct TimelineEnvironment { + output: String, + } + + impl matrix::ui_timeline::std::Host for TimelineEnvironment { + fn print(&mut self, msg: String) -> Result<()> { + self.output.push_str(&msg); + self.output.push_str("\n"); + + Ok(()) + } + } + + let mut instance = TimelineInstance::new("timeline.wasm").unwrap(); + let result = instance.exports.greet("Gordon"); + + assert!(result.is_ok()); + + { + let env = instance.environment(); + assert_eq!(env.output, "Hello, Gordon!\n"); + } + } +} diff --git a/crates/matrix-sdk-extensions/src/traits.rs b/crates/matrix-sdk-extensions/src/traits.rs new file mode 100644 index 00000000000..a49a31ecf2d --- /dev/null +++ b/crates/matrix-sdk-extensions/src/traits.rs @@ -0,0 +1,26 @@ +use std::{ops::Deref, path::Path}; + +use crate::Result; + +pub trait Module { + type Environment: Default; + type Bindings; + + fn new_environment() -> Self::Environment; +} + +pub trait Instance +where + M: Module, + Self: Sized, +{ + type EnvironmentRef<'a>: Deref + where + Self: 'a; + + fn new

(path_to_entry_point: P) -> Result + where + P: AsRef; + + fn environment<'a>(&'a self) -> Self::EnvironmentRef<'a>; +} diff --git a/crates/matrix-sdk-extensions/test.js b/crates/matrix-sdk-extensions/test.js new file mode 100644 index 00000000000..f81417c5ab4 --- /dev/null +++ b/crates/matrix-sdk-extensions/test.js @@ -0,0 +1,22 @@ +import { instantiate } from './guests/timeline/js/timeline.js'; +import fs from 'fs/promises'; + +async function compile(module_path) { + const path = `./guests/timeline/js/${module_path}`; + console.log(`[log] Loading \`${path}\``); + const buffer = await fs.readFile(path); + return WebAssembly.compile(buffer); +} + +const exports = await instantiate( + compile, + { + 'matrix:ui-timeline/std': { + print: function (msg) { + console.log(msg); + } + } + } +); + +exports.greet('Gordon'); diff --git a/crates/matrix-sdk-extensions/timeline.wasm b/crates/matrix-sdk-extensions/timeline.wasm new file mode 100644 index 00000000000..32e9ab6cc5e Binary files /dev/null and b/crates/matrix-sdk-extensions/timeline.wasm differ diff --git a/crates/matrix-sdk-extensions/wit/timeline.wit b/crates/matrix-sdk-extensions/wit/timeline.wit new file mode 100644 index 00000000000..97a22ccde3d --- /dev/null +++ b/crates/matrix-sdk-extensions/wit/timeline.wit @@ -0,0 +1,10 @@ +package matrix:ui-timeline; + +interface std { + print: func(msg: string); +} + +world timeline { + import std; + export greet: func(who: string); +} \ No newline at end of file