From d7d814015ff7986be0a316662ef22bd66a43fca8 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Thu, 30 Nov 2023 10:14:32 +0100 Subject: [PATCH] we typescript now --- .gitignore | 4 +- .swcrc | 12 + Cargo.lock | 1846 +++++++++- Cargo.toml | 5 + build.rs | 61 + static/js/compose.mjs | 47 - static/js/node-utils.mjs | 17 - static/{js => scripts}/ace.mjs | 0 .../components/editor/script.ts} | 29 +- static/scripts/compose.ts | 36 + .../enhancements/check.ts} | 19 +- static/scripts/node-utils.ts | 16 + static/vendor/ace/ace.d.ts | 3139 +++++++++++++++++ tsconfig.json | 22 + 14 files changed, 5147 insertions(+), 106 deletions(-) create mode 100644 .swcrc create mode 100644 build.rs delete mode 100644 static/js/compose.mjs delete mode 100644 static/js/node-utils.mjs rename static/{js => scripts}/ace.mjs (100%) rename static/{components/editor/script.mjs => scripts/components/editor/script.ts} (77%) create mode 100644 static/scripts/compose.ts rename static/{js/enhancements/check.mjs => scripts/enhancements/check.ts} (65%) create mode 100644 static/scripts/node-utils.ts create mode 100644 static/vendor/ace/ace.d.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore index 9df7f2c..8292133 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ /dist .env .vscode -/result \ No newline at end of file +/result +/static/scripts/**/*.js* +/static/components/**/*.js* \ No newline at end of file diff --git a/.swcrc b/.swcrc new file mode 100644 index 0000000..b9e4c87 --- /dev/null +++ b/.swcrc @@ -0,0 +1,12 @@ +{ + "sourceMaps": true, + "jsc": { + "parser": { + "syntax": "typescript", + "tsx": false, + "decorators": false, + "dynamicImport": false + }, + "target": "esnext" + } +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index d27ab50..c10d8ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.21.0" @@ -17,6 +27,29 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "getrandom", + "once_cell", + "serde", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + [[package]] name = "android-tzdata" version = "0.1.1" @@ -89,6 +122,12 @@ dependencies = [ "backtrace", ] +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + [[package]] name = "askama" version = "0.12.1" @@ -126,7 +165,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.39", ] [[package]] @@ -144,6 +183,19 @@ dependencies = [ "nom", ] +[[package]] +name = "ast_node" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c09c69dffe06d222d072c878c3afe86eee2179806f20503faec97250268b4c24" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + [[package]] name = "async-trait" version = "0.1.74" @@ -152,7 +204,30 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "auto_impl" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fee3da8ef1276b0bee5dd1c7258010d8fffd31801447323115a25560e1327b89" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", ] [[package]] @@ -225,6 +300,12 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + [[package]] name = "base64" version = "0.21.5" @@ -240,6 +321,15 @@ dependencies = [ "serde", ] +[[package]] +name = "better_scoped_tls" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "794edcc9b3fb07bb4aecaa11f093fd45663b4feadb782d68303a2268bc2701de" +dependencies = [ + "scoped-tls", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -252,13 +342,22 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +[[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 = "bollard" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f03db470b3c0213c47e978da93200259a1eb4dae2e5512cba9955e2b540a6fc6" dependencies = [ - "base64", + "base64 0.21.5", "bollard-stubs", "bytes", "futures-core", @@ -294,6 +393,27 @@ dependencies = [ "time", ] +[[package]] +name = "browserslist-rs" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33066f72a558361eeb1077b0aff0f1dce1ac75bdc20b38a642f155f767b2824" +dependencies = [ + "ahash", + "anyhow", + "chrono", + "either", + "itertools", + "nom", + "once_cell", + "quote", + "serde", + "serde_json", + "string_cache", + "string_cache_codegen", + "thiserror", +] + [[package]] name = "bumpalo" version = "3.14.0" @@ -366,7 +486,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -393,6 +513,15 @@ version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -426,6 +555,45 @@ 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 = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.2", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" + +[[package]] +name = "debugid" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d" +dependencies = [ + "serde", + "uuid", +] + [[package]] name = "deranged" version = "0.3.9" @@ -436,6 +604,16 @@ dependencies = [ "serde", ] +[[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 = "dotenvy" version = "0.15.7" @@ -470,6 +648,12 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "fnv" version = "1.0.7" @@ -485,6 +669,18 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "from_variant" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03ec5dc38ee19078d84a692b1c41181ff9f94331c76cee66ff0208c770b5e54f" +dependencies = [ + "pmutil", + "proc-macro2", + "swc_macros_common", + "syn 2.0.39", +] + [[package]] name = "futures-channel" version = "0.3.29" @@ -508,7 +704,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -537,6 +733,27 @@ dependencies = [ "slab", ] +[[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.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "gimli" version = "0.28.0" @@ -556,6 +773,12 @@ dependencies = [ "url", ] +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + [[package]] name = "h2" version = "0.3.22" @@ -581,6 +804,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.2" @@ -593,6 +825,15 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + [[package]] name = "hermit-abi" version = "0.3.3" @@ -605,6 +846,19 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hstr" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de90d3db62411eb62eddabe402d706ac4970f7ac8d088c05f11069cad9be9857" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "phf", + "rustc-hash", + "smallvec", +] + [[package]] name = "http" version = "0.2.11" @@ -718,6 +972,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "if_chain" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" + [[package]] name = "include_dir" version = "0.7.3" @@ -759,6 +1019,34 @@ dependencies = [ "serde", ] +[[package]] +name = "is-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4467ed1321b310c2625c5aa6c1b1ffc5de4d9e42668cf697a08fb033ee8265e" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "is_ci" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "616cde7c720bb2bb5824a224687d8f77bfd38922027f01d825cd7453be5099fb" + +[[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" @@ -783,6 +1071,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "jsonc-parser" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b56a20e76235284255a09fcd1f45cf55d3c524ea657ebd3854735925c57743d" +dependencies = [ + "serde_json", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -847,6 +1144,15 @@ version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +[[package]] +name = "lru" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +dependencies = [ + "hashbrown 0.13.2", +] + [[package]] name = "matchit" version = "0.7.3" @@ -868,6 +1174,37 @@ dependencies = [ "autocfg", ] +[[package]] +name = "miette" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c90329e44f9208b55f45711f9558cec15d7ef8295cc65ecd6d4188ae8edc58c" +dependencies = [ + "atty", + "backtrace", + "miette-derive", + "once_cell", + "owo-colors", + "supports-color", + "supports-hyperlinks", + "supports-unicode", + "terminal_size", + "textwrap", + "thiserror", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b5bc45b761bcf1b5e6e6c4128cd93b84c218721a8d9b894aa0aff4ed180174c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "mime" version = "0.3.17" @@ -910,6 +1247,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nom" version = "7.1.3" @@ -920,6 +1263,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "normpath" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a9da8c9922c35a1033d76f7272dfc2e7ee20392083d75aeea6ced23c6266578" +dependencies = [ + "winapi", +] + [[package]] name = "ntapi" version = "0.4.1" @@ -939,6 +1291,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.17" @@ -954,7 +1328,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.3", "libc", ] @@ -979,6 +1353,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + [[package]] name = "parking_lot" version = "0.12.1" @@ -1002,12 +1382,95 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "path-clean" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd" + +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "percent-encoding" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.1.0", +] + +[[package]] +name = "phf" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc" +dependencies = [ + "phf_macros", + "phf_shared 0.11.2", +] + +[[package]] +name = "phf_generator" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6" +dependencies = [ + "phf_shared 0.10.0", + "rand", +] + +[[package]] +name = "phf_generator" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0" +dependencies = [ + "phf_shared 0.11.2", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b" +dependencies = [ + "phf_generator 0.11.2", + "phf_shared 0.11.2", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "phf_shared" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b" +dependencies = [ + "siphasher", +] + [[package]] name = "pin-project" version = "1.1.3" @@ -1025,7 +1488,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1046,12 +1509,77 @@ version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +[[package]] +name = "pmutil" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52a40bc70c2c58040d2d8b167ba9a5ff59fc9dab7ad44771cfde3dcfde7a09c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "preset_env_base" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "008ae5e91d877e168b73c17bed2e4dc7553cd7cc237a776d9479eab6642352c5" +dependencies = [ + "ahash", + "anyhow", + "browserslist-rs", + "dashmap", + "from_variant", + "once_cell", + "semver 1.0.20", + "serde", + "st-map", + "tracing", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.69" @@ -1061,6 +1589,15 @@ 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 = "quote" version = "1.0.33" @@ -1070,6 +1607,42 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "radix_fmt" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce082a9940a7ace2ad4a8b7d0b1eac6aa378895f18be598230c5f2284ac05426" + +[[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" @@ -1099,6 +1672,35 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + [[package]] name = "rnix" version = "0.11.0" @@ -1133,6 +1735,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + [[package]] name = "rustix" version = "0.38.25" @@ -1158,12 +1769,48 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +[[package]] +name = "ryu-js" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4950d85bc52415f8432144c97c4791bd0c4f7954de32a7270ee9cccd3c22b12b" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + [[package]] name = "serde" version = "1.0.192" @@ -1181,7 +1828,7 @@ checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1213,7 +1860,7 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1234,7 +1881,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64", + "base64 0.21.5", "chrono", "hex", "indexmap 1.9.3", @@ -1244,6 +1891,17 @@ dependencies = [ "time", ] +[[package]] +name = "sha-1" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "sharded-slab" version = "0.1.7" @@ -1262,6 +1920,12 @@ dependencies = [ "libc", ] +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + [[package]] name = "slab" version = "0.4.9" @@ -1277,6 +1941,23 @@ version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +[[package]] +name = "smartstring" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" +dependencies = [ + "autocfg", + "static_assertions", + "version_check", +] + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + [[package]] name = "socket2" version = "0.4.10" @@ -1297,6 +1978,63 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "sourcemap" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4cbf65ca7dc576cf50e21f8d0712d96d4fcfd797389744b7b222a85cdf5bd90" +dependencies = [ + "data-encoding", + "debugid", + "if_chain", + "rustc_version", + "serde", + "serde_json", + "unicode-id", + "url", +] + +[[package]] +name = "st-map" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f352d5d14be5a1f956d76ae0c8060c3487aaa2a080f10a4b4ff023c7c05a9047" +dependencies = [ + "arrayvec", + "static-map-macro", +] + +[[package]] +name = "stacker" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" +dependencies = [ + "cc", + "cfg-if", + "libc", + "psm", + "winapi", +] + +[[package]] +name = "static-map-macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7628ae0bd92555d3de4303da41a5c8b1c5363e892001325f34e4be9ed024d0d7" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "staxman" version = "0.1.0" @@ -1310,11 +2048,14 @@ dependencies = [ "dotenvy", "futures-util", "git2", + "glob", "include_dir", "mime_guess", "rnix", "serde", "serde_json", + "swc", + "swc_common", "sysinfo", "tempfile", "thiserror", @@ -1324,12 +2065,992 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "string_cache" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" +dependencies = [ + "new_debug_unreachable", + "once_cell", + "parking_lot", + "phf_shared 0.10.0", + "precomputed-hash", + "serde", +] + +[[package]] +name = "string_cache_codegen" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988" +dependencies = [ + "phf_generator 0.10.0", + "phf_shared 0.10.0", + "proc-macro2", + "quote", +] + +[[package]] +name = "string_enum" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa4d4f81d7c05b9161f8de839975d3326328b8ba2831164b465524cc2f55252" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "supports-color" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" +dependencies = [ + "atty", + "is_ci", +] + +[[package]] +name = "supports-hyperlinks" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590b34f7c5f01ecc9d78dba4b3f445f31df750a67621cf31626f3b7441ce6406" +dependencies = [ + "atty", +] + +[[package]] +name = "supports-unicode" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8b945e45b417b125a8ec51f1b7df2f8df7920367700d1f98aedd21e5735f8b2" +dependencies = [ + "atty", +] + +[[package]] +name = "swc" +version = "0.269.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "603ad8da1ec4affc1564bc88173f8356f8686f84a3975121d662ee1a6d877e9d" +dependencies = [ + "anyhow", + "base64 0.13.1", + "dashmap", + "either", + "indexmap 1.9.3", + "jsonc-parser", + "lru", + "once_cell", + "parking_lot", + "pathdiff", + "regex", + "rustc-hash", + "serde", + "serde_json", + "sourcemap", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_compiler_base", + "swc_config", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_ext_transforms", + "swc_ecma_lints", + "swc_ecma_loader", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_preset_env", + "swc_ecma_transforms", + "swc_ecma_transforms_base", + "swc_ecma_transforms_compat", + "swc_ecma_transforms_optimization", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_error_reporters", + "swc_node_comments", + "swc_timer", + "swc_visit", + "tracing", + "url", +] + +[[package]] +name = "swc_atoms" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a9e1b6d97f27b6abe5571f8fe3bdbd2fa987299fc2126450c7cde6214896ef" +dependencies = [ + "hstr", + "once_cell", + "rustc-hash", + "serde", +] + +[[package]] +name = "swc_cached" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b357b80879f6c4f4f34879d02eeae63aafc7730293e6eda3686f990d160486" +dependencies = [ + "ahash", + "anyhow", + "dashmap", + "once_cell", + "regex", + "serde", +] + +[[package]] +name = "swc_common" +version = "0.33.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ccb656cd57c93614e4e8b33a60e75ca095383565c1a8d2bbe6a1103942831e0" +dependencies = [ + "ahash", + "ast_node", + "atty", + "better_scoped_tls", + "cfg-if", + "either", + "from_variant", + "new_debug_unreachable", + "num-bigint", + "once_cell", + "parking_lot", + "rustc-hash", + "serde", + "siphasher", + "sourcemap", + "swc_atoms", + "swc_eq_ignore_macros", + "swc_visit", + "termcolor", + "tracing", + "unicode-width", + "url", +] + +[[package]] +name = "swc_compiler_base" +version = "0.3.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ccf3b7641694eb2a13935bfe7d55b5699b63d14f74dd9f104e9bebc01b8bc9b" +dependencies = [ + "anyhow", + "base64 0.13.1", + "pathdiff", + "serde", + "sourcemap", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_minifier", + "swc_ecma_parser", + "swc_ecma_visit", + "swc_timer", +] + +[[package]] +name = "swc_config" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba1c7a40d38f9dd4e9a046975d3faf95af42937b34b2b963be4d8f01239584b" +dependencies = [ + "indexmap 1.9.3", + "serde", + "serde_json", + "swc_config_macro", +] + +[[package]] +name = "swc_config_macro" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5b5aaca9a0082be4515f0fbbecc191bf5829cd25b5b9c0a2810f6a2bb0d6829" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + +[[package]] +name = "swc_ecma_ast" +version = "0.110.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c3d416121da2d56bcbd1b1623725a68890af4552fef0c6d1e4bfa92776ccd6a" +dependencies = [ + "bitflags 2.4.1", + "is-macro", + "num-bigint", + "phf", + "scoped-tls", + "serde", + "string_enum", + "swc_atoms", + "swc_common", + "unicode-id", +] + +[[package]] +name = "swc_ecma_codegen" +version = "0.146.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcec0786daed74647b7097a409c48a5802b6c792b935161e03cc265d120b6154" +dependencies = [ + "memchr", + "num-bigint", + "once_cell", + "rustc-hash", + "serde", + "sourcemap", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_codegen_macros", + "tracing", +] + +[[package]] +name = "swc_ecma_codegen_macros" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcdff076dccca6cc6a0e0b2a2c8acfb066014382bc6df98ec99e755484814384" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + +[[package]] +name = "swc_ecma_compat_bugfixes" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dbf17baec176a787cf69a3a924648575a25737a109dac9ec0be11cdf950e6ec" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_compat_es2015", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_common" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abed404c9425bf0d1f44da426f9fec6fe1833b696275ed4dff85550376a32d4" +dependencies = [ + "swc_common", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", +] + +[[package]] +name = "swc_ecma_compat_es2015" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a0aae6ae6c75701a2f913a5982ad3cb6e81fe7649ab1607de66f4ac2707bb18" +dependencies = [ + "arrayvec", + "indexmap 1.9.3", + "is-macro", + "serde", + "serde_derive", + "smallvec", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_compat_common", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2016" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb62e82eae8cd216a3a99a439020f2418c9407fd62d9ecdb20248aabf1f3f1b8" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2017" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc075f9480a02217427213bae64e6d1cbc1d1c70eddae624d9925a978713f49b" +dependencies = [ + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2018" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2a5064dc35d5d1d9c21b81c2875744fa1425d173a6aba8102505e36ff7a15d7" +dependencies = [ + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_compat_common", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2019" +version = "0.1.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1a77fa885caec46ffedbf9869af297c6506ad242e8e03cd792d0d46ebdc355" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2020" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c62faa7acffbcc05f815a1e4b10fb576e8ca9d900fd3ec220fdfb1509b3e604" +dependencies = [ + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_compat_es2022", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2021" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad73ef18d956d40993cc8a163a3a59ab7fcea995a297fb6f1b6352244cc1b583" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es2022" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e68c83ac83ae0e0583d1ccaef3839d76220747236508e401417554fb60acde" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_compat_common", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_compat_es3" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "544d18792d8cf35bfcedc054c8ff46cc4533855c831150d84b728fe5ab54a334" +dependencies = [ + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_ext_transforms" +version = "0.110.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cc0000e38d2c67772c632f3e0fe1d8c2a63479bcb9d2746b8042af6f65f42c7" +dependencies = [ + "phf", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_lints" +version = "0.89.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7609e6ed425c0db91a16cf8c4a671a12f12d80a29ef24b6a994c11de1f272e2" +dependencies = [ + "auto_impl", + "dashmap", + "parking_lot", + "rayon", + "regex", + "serde", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_loader" +version = "0.45.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31cf7549feec3698d0110a0a71ae547f31ae272dc92db3285ce126d6dcbdadf3" +dependencies = [ + "anyhow", + "dashmap", + "lru", + "normpath", + "once_cell", + "parking_lot", + "path-clean", + "pathdiff", + "serde", + "serde_json", + "swc_cached", + "swc_common", + "tracing", +] + +[[package]] +name = "swc_ecma_minifier" +version = "0.189.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421f7ce6594fc11527091fa097b78a54b0ec77c8c1a1a6523cf1cc307eb2896" +dependencies = [ + "arrayvec", + "indexmap 1.9.3", + "num-bigint", + "num_cpus", + "once_cell", + "parking_lot", + "radix_fmt", + "regex", + "rustc-hash", + "ryu-js", + "serde", + "serde_json", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_codegen", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_optimization", + "swc_ecma_usage_analyzer", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_parser" +version = "0.141.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b8436a58ac9f31068e9bf871e2ce7f3a18fe1d7e3fe8d54abe4896673eae20c" +dependencies = [ + "either", + "new_debug_unreachable", + "num-bigint", + "num-traits", + "phf", + "serde", + "smallvec", + "smartstring", + "stacker", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "tracing", + "typed-arena", +] + +[[package]] +name = "swc_ecma_preset_env" +version = "0.203.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f54bdf8e967e2ff7b7d696e4b1c8c28906ca155582977fa36bc5244e5ebcd7e" +dependencies = [ + "anyhow", + "dashmap", + "indexmap 1.9.3", + "once_cell", + "preset_env_base", + "rustc-hash", + "semver 1.0.20", + "serde", + "serde_json", + "st-map", + "string_enum", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms" +version = "0.226.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a2933569a969b63640c4aac9459868b5c356aed6d929a735b3ca99f468906" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_compat", + "swc_ecma_transforms_module", + "swc_ecma_transforms_optimization", + "swc_ecma_transforms_proposal", + "swc_ecma_transforms_react", + "swc_ecma_transforms_typescript", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_base" +version = "0.134.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "346b97a0b62d0db669d1b4db54cd99bf4c64805009ff89f5d470926410da2668" +dependencies = [ + "better_scoped_tls", + "bitflags 2.4.1", + "indexmap 1.9.3", + "once_cell", + "phf", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_classes" +version = "0.123.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97017de92f42c373ba644395349fa30cac1cc5d5768e93335a4b4668521d9bf7" +dependencies = [ + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_compat" +version = "0.160.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70915ba12b3d41a5666dc315cc8647f2755c567eaa3bbc12f5bb3aba971b393b" +dependencies = [ + "arrayvec", + "indexmap 1.9.3", + "is-macro", + "num-bigint", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_compat_bugfixes", + "swc_ecma_compat_common", + "swc_ecma_compat_es2015", + "swc_ecma_compat_es2016", + "swc_ecma_compat_es2017", + "swc_ecma_compat_es2018", + "swc_ecma_compat_es2019", + "swc_ecma_compat_es2020", + "swc_ecma_compat_es2021", + "swc_ecma_compat_es2022", + "swc_ecma_compat_es3", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_trace_macro", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_macros" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8188eab297da773836ef5cf2af03ee5cca7a563e1be4b146f8141452c28cc690" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + +[[package]] +name = "swc_ecma_transforms_module" +version = "0.177.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7431d6580db8cd145ed30d4a0792e3cafda7d572ebc773b54d632e44d8ec197" +dependencies = [ + "Inflector", + "anyhow", + "bitflags 2.4.1", + "indexmap 1.9.3", + "is-macro", + "path-clean", + "pathdiff", + "regex", + "serde", + "swc_atoms", + "swc_cached", + "swc_common", + "swc_ecma_ast", + "swc_ecma_loader", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_utils", + "swc_ecma_visit", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_optimization" +version = "0.195.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa5689ad6d55eb96eee5ca8e3fc29e905767120f9b073bbe656094fd988d2108" +dependencies = [ + "dashmap", + "indexmap 1.9.3", + "once_cell", + "petgraph", + "rustc-hash", + "serde_json", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_fast_graph", + "tracing", +] + +[[package]] +name = "swc_ecma_transforms_proposal" +version = "0.168.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdd2f3b6416f87367aeae8c5205f6777d8f80460605b6c4cc693c040c8b1c663" +dependencies = [ + "either", + "rustc-hash", + "serde", + "smallvec", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_classes", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_react" +version = "0.180.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d412e4c13799d61170221e581e9f40d8499c853a54bf6fcc5d0c1cea01310522" +dependencies = [ + "base64 0.13.1", + "dashmap", + "indexmap 1.9.3", + "once_cell", + "serde", + "sha-1", + "string_enum", + "swc_atoms", + "swc_common", + "swc_config", + "swc_ecma_ast", + "swc_ecma_parser", + "swc_ecma_transforms_base", + "swc_ecma_transforms_macros", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_transforms_typescript" +version = "0.185.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9095e1fcf44aedf454d5e5ada4244f60d7c81397756313d0577cc0fc7272d2c2" +dependencies = [ + "ryu-js", + "serde", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_transforms_base", + "swc_ecma_transforms_react", + "swc_ecma_utils", + "swc_ecma_visit", +] + +[[package]] +name = "swc_ecma_usage_analyzer" +version = "0.20.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa8d5dc775d4bf35967a0216783058b13ffe5423b807927aa5dbc92251f6839" +dependencies = [ + "indexmap 1.9.3", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_utils", + "swc_ecma_visit", + "swc_timer", + "tracing", +] + +[[package]] +name = "swc_ecma_utils" +version = "0.124.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad013c92a6e05a850db088ae7a17dc667209780b2a1a313544540111f33b5233" +dependencies = [ + "indexmap 1.9.3", + "num_cpus", + "once_cell", + "rustc-hash", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_ecma_visit", + "tracing", + "unicode-id", +] + +[[package]] +name = "swc_ecma_visit" +version = "0.96.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba962f0becf83bab12a17365dface5a4f636c9e1743d479e292b96910a753743" +dependencies = [ + "num-bigint", + "swc_atoms", + "swc_common", + "swc_ecma_ast", + "swc_visit", + "tracing", +] + +[[package]] +name = "swc_eq_ignore_macros" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05a95d367e228d52484c53336991fdcf47b6b553ef835d9159db4ba40efb0ee8" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "swc_error_reporters" +version = "0.17.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29add35412af288be50e1012bbb825a66871bb2b4d960d1c456917ec3ccea32" +dependencies = [ + "anyhow", + "miette", + "once_cell", + "parking_lot", + "swc_common", +] + +[[package]] +name = "swc_fast_graph" +version = "0.21.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8117f6d10bbcb30cb3e549d6fa7637cb6d7c713cb71b2ce1808105a6825c788d" +dependencies = [ + "indexmap 1.9.3", + "petgraph", + "rustc-hash", + "swc_common", +] + +[[package]] +name = "swc_macros_common" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a273205ccb09b51fabe88c49f3b34c5a4631c4c00a16ae20e03111d6a42e832" +dependencies = [ + "pmutil", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "swc_node_comments" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282ef548f602694c4eaa36a1d704282fd9713b9725b58bce7fb41630feefc4f7" +dependencies = [ + "dashmap", + "swc_atoms", + "swc_common", +] + +[[package]] +name = "swc_timer" +version = "0.21.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a200243f3c296f74f52a562342ec0e972376377f4c202b0fa84a0e860a3bff7" +dependencies = [ + "tracing", +] + +[[package]] +name = "swc_trace_macro" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff9719b6085dd2824fd61938a881937be14b08f95e2d27c64c825a9f65e052ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "swc_visit" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e87c337fbb2d191bf371173dea6a957f01899adb8f189c6c31b122a6cfc98fc3" +dependencies = [ + "either", + "swc_visit_macros", +] + +[[package]] +name = "swc_visit_macros" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f322730fb82f3930a450ac24de8c98523af7d34ab8cb2f46bcb405839891a99" +dependencies = [ + "Inflector", + "pmutil", + "proc-macro2", + "quote", + "swc_macros_common", + "syn 2.0.39", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.39" @@ -1375,12 +3096,42 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "termcolor" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "terminal_size" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "text-size" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233" +[[package]] +name = "textwrap" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7b3e525a49ec206798b40326a44121291b530c963cfb01018f63e135bac543d" +dependencies = [ + "smawk", + "unicode-linebreak", + "unicode-width", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -1398,7 +3149,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1482,7 +3233,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1547,7 +3298,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -1591,6 +3342,18 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +[[package]] +name = "typed-arena" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" + +[[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" @@ -1606,12 +3369,24 @@ version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +[[package]] +name = "unicode-id" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1b6def86329695390197b82c1e244a54a131ceb66c996f2088a3876e2ae083f" + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +[[package]] +name = "unicode-linebreak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" + [[package]] name = "unicode-normalization" version = "0.1.22" @@ -1621,6 +3396,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 = "url" version = "2.4.1" @@ -1638,6 +3419,12 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" + [[package]] name = "valuable" version = "0.1.0" @@ -1692,7 +3479,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-shared", ] @@ -1714,7 +3501,7 @@ checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -1741,6 +3528,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1821,3 +3617,23 @@ name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/Cargo.toml b/Cargo.toml index b52a9cd..c8734ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,3 +25,8 @@ time = { version = "0.3", features = ["serde"] } tokio = { version = "1", features = ["full"] } tracing = "0.1" tracing-subscriber = "0.3" + +[build-dependencies] +swc = "0.269" +swc_common = { version = "0.33", features = ["tty-emitter"] } +glob = "0.3" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..2bc0682 --- /dev/null +++ b/build.rs @@ -0,0 +1,61 @@ +use std::{ + fs, + path::{Path, PathBuf}, +}; + +use swc::config::{Options, SourceMapsConfig}; +use swc_common::{ + self, + errors::{ColorConfig, Handler}, + sync::Lrc, + SourceMap, GLOBALS, +}; + +fn main() { + // Find all Typescript files (that are not type declaration) + let ts_files: Vec<_> = glob::glob(&format!("{}/**/*.ts", "static/source")) + .expect("Failed to read glob pattern") + .filter_map(|entry| entry.ok()) + .filter(|entry| !entry.to_string_lossy().ends_with(".d.ts")) + .collect(); + + for ts_file in ts_files { + compile_file(ts_file); + } +} + +fn compile_file(input: PathBuf) { + let cm: Lrc = Default::default(); + let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(cm.clone())); + + let c = swc::Compiler::new(cm.clone()); + + let fm = cm + .load_file(Path::new(&input)) + .expect("failed to load input typescript file"); + + GLOBALS.set(&Default::default(), || { + let output_path = input.with_extension("js"); + let sourcemap_path = input.with_extension("js.map"); + + let res = c + .process_js_file( + fm, + &handler, + &Options { + swcrc: true, + filename: input.to_string_lossy().into_owned(), + output_path: Some(output_path.clone()), + source_maps: Some(SourceMapsConfig::Bool(true)), + ..Default::default() + }, + ) + .expect("parse error"); + + fs::create_dir_all(output_path.parent().unwrap()).expect("failed to create parent dir"); + fs::write(output_path, res.code).expect("failed to write output file"); + if let Some(map) = res.map { + fs::write(sourcemap_path, map).expect("failed to write output file"); + } + }); +} diff --git a/static/js/compose.mjs b/static/js/compose.mjs deleted file mode 100644 index 81fb0c5..0000000 --- a/static/js/compose.mjs +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Checks if a specificied source is a valid arion-compose.nix file - * @param {string} source Source to check - * @returns {Promise} Result of the check - */ -export async function check_compose(source) { - const response = await fetch("/stack/_/check", { - method: "POST", - headers: { - "Accept": "application/json", - "Content-Type": "text/plain", - }, - body: source - }); - - if (response.ok) { - return { ok: true }; - } else { - return { ok: false, error: await response.json() }; - } -} - -/** - * @typedef {Object} APIError - * @property {string} code - Error code - */ - -/** - * @typedef {Object} CheckSuccess - * @property { true } ok - Indicates that the check was successful - * / - -/** - * @typedef {Object} APIError - * @property {string} code - Unique error code - * @property {string} message - Human readable error details - */ - -/** - * @typedef {Object} CheckFailure - * @property {false} ok - Indicates that the check has failed - * @property {APIError} error - Info about the encountered error - */ - -/** - * @typedef {CheckSuccess | CheckFailure} CheckResult - */ \ No newline at end of file diff --git a/static/js/node-utils.mjs b/static/js/node-utils.mjs deleted file mode 100644 index e6e95c4..0000000 --- a/static/js/node-utils.mjs +++ /dev/null @@ -1,17 +0,0 @@ - -/** - * Find nearest parent that satisfies a requirement - * @param {Node|Element} node - * @param {(el: Element) => boolean} findFn - * @returns {HTMLElement | null} Found element, or null if no parent matches - */ -export function findNearestParent(node, findFn) { - let parent = node.parentElement; - while (parent) { - if (findFn(parent)) { - return parent; - } - parent = parent.parentElement; - } - return null; -} \ No newline at end of file diff --git a/static/js/ace.mjs b/static/scripts/ace.mjs similarity index 100% rename from static/js/ace.mjs rename to static/scripts/ace.mjs diff --git a/static/components/editor/script.mjs b/static/scripts/components/editor/script.ts similarity index 77% rename from static/components/editor/script.mjs rename to static/scripts/components/editor/script.ts index c0ade61..a34ee78 100644 --- a/static/components/editor/script.mjs +++ b/static/scripts/components/editor/script.ts @@ -1,24 +1,21 @@ import "/static/vendor/ace/ace.js"; -import { $el } from "../../vendor/domutil/domutil.js"; +import { $el } from "/static/vendor/domutil/domutil.js"; class Editor extends HTMLElement { - editor; - - /** @type {HTMLDivElement} Tab container */ - tabEl; - - /** @type {Map} File name to file session */ - files; + private editor: AceAjax.Editor; + private tabEl: HTMLDivElement; + private files: Record; + private root: ShadowRoot; constructor() { super(); this.files = {}; - this.attachShadow({ mode: "open" }); + this.root = this.attachShadow({ mode: "open" }); } connectedCallback() { this.tabEl = $el("div", { className: "tab-container" }); - this.shadowRoot.append(this.tabEl); + this.root.append(this.tabEl); const style = $el("style"); style.textContent = ` @@ -40,7 +37,7 @@ class Editor extends HTMLElement { } `; const slot = $el("slot", { name: "body" }); - this.shadowRoot.append(style, slot); + this.root.append(style, slot); const editorEl = $el("div", { slot: "body" }); this.append(editorEl); @@ -61,10 +58,10 @@ class Editor extends HTMLElement { /** * Add a file editing session - * @param {string} name File name - * @param {string} content File contents + * @param name File name + * @param content File contents */ - addFile(name, content) { + addFile(name: string, content: string) { // Add to session list this.files[name] = ace.createEditSession(content); @@ -78,10 +75,10 @@ class Editor extends HTMLElement { /** * Create a new tab - * @param {string} name Tab name + * @param name Tab name * @returns Tab element */ - #addTab(name) { + #addTab(name: string) { const tab = $el("div", { className: "tab", "@click": () => { diff --git a/static/scripts/compose.ts b/static/scripts/compose.ts new file mode 100644 index 0000000..596bbf5 --- /dev/null +++ b/static/scripts/compose.ts @@ -0,0 +1,36 @@ +/** + * Checks if a specificied source is a valid arion-compose.nix file + * @param source Source to check + * @returns Result of the check + */ +export async function check_compose(source: string): Promise { + const response = await fetch("/stack/_/check", { + method: "POST", + headers: { + "Accept": "application/json", + "Content-Type": "text/plain", + }, + body: source + }); + + if (response.ok) { + return { ok: true }; + } else { + return { ok: false, error: await response.json() }; + } +} + +export interface APIError { + /** Error code */ + code: string; + + /** Human readable error details */ + message: string; +} + +export type CheckResult = { + ok: true; +} | { + ok: false; + error: APIError; +} diff --git a/static/js/enhancements/check.mjs b/static/scripts/enhancements/check.ts similarity index 65% rename from static/js/enhancements/check.mjs rename to static/scripts/enhancements/check.ts index 505c581..d01d016 100644 --- a/static/js/enhancements/check.mjs +++ b/static/scripts/enhancements/check.ts @@ -1,12 +1,11 @@ -import Editor from "../ace.mjs"; -import { check_compose } from "/static/js/compose.mjs"; +import { check_compose } from "/static/scripts/compose.js"; /** * Makes the form require the stack to be checked before submitting - * @param {HTMLFormElement} form - * @param {Editor} editor + * @param form + * @param editor */ -export function add_check(form, editor) { +export function add_check(form: HTMLFormElement, editor: AceAjax.Editor) { form.addEventListener("submit", (ev) => { ev.preventDefault(); check_stack(editor).then((result) => { @@ -20,15 +19,15 @@ export function add_check(form, editor) { /** * Runs the check function and updates some DOM elements - * @param {Editor} editor Editor instance + * @param editor Editor instance * @returns true if the stack is valid, false otherwise */ -export async function check_stack(editor) { - const source = editor.editor.getValue(); +export async function check_stack(editor: AceAjax.Editor) { + const source = editor.getValue(); const check_result = await check_compose(source); - const editorEl = document.querySelector(".ace_editor"); - const editorErrorEl = document.querySelector("#editor-form .error"); + const editorEl = document.querySelector(".ace_editor")!; + const editorErrorEl = document.querySelector("#editor-form div.error")!; editorEl.classList.remove("err", "checked"); editorErrorEl.style.display = "block"; editorErrorEl.classList.add("pending"); diff --git a/static/scripts/node-utils.ts b/static/scripts/node-utils.ts new file mode 100644 index 0000000..f6f9209 --- /dev/null +++ b/static/scripts/node-utils.ts @@ -0,0 +1,16 @@ +/** + * Find nearest parent that satisfies a requirement + * @param node Node to start from + * @param findFn Matching function + * @returns Found element, or null if no parent matches + */ +export function findNearestParent(node: Node | Element, findFn: (el: Element) => boolean): HTMLElement | null { + let parent = node.parentElement; + while (parent) { + if (findFn(parent)) { + return parent; + } + parent = parent.parentElement; + } + return null; +} \ No newline at end of file diff --git a/static/vendor/ace/ace.d.ts b/static/vendor/ace/ace.d.ts new file mode 100644 index 0000000..dd1649e --- /dev/null +++ b/static/vendor/ace/ace.d.ts @@ -0,0 +1,3139 @@ +declare namespace AceAjax { + export interface Delta { + action: "insert" | "remove"; + start: Position; + end: Position; + lines: string[]; + } + + export interface EditorCommand { + name?: string | undefined; + bindKey?: string | { mac?: string | undefined; win?: string | undefined } | undefined; + exec: (editor: Editor, args?: any) => void; + readOnly?: boolean | undefined; + } + + interface CommandMap { + [name: string]: EditorCommand; + } + + type execEventHandler = (obj: { + editor: Editor; + command: EditorCommand; + args: any[]; + }) => void; + + type CommandLike = EditorCommand | ((editor: Editor) => void); + + export interface CommandManager { + byName: CommandMap; + commands: CommandMap; + on(name: "exec", callback: execEventHandler): Function; + on(name: "afterExec", callback: execEventHandler): Function; + once(name: string, callback: Function): void; + setDefaultHandler(name: string, callback: Function): void; + removeDefaultHandler(name: string, callback: Function): void; + on(name: string, callback: Function, capturing?: boolean): Function; + addEventListener(name: string, callback: Function, capturing?: boolean): void; + off(name: string, callback: Function): void; + removeListener(name: string, callback: Function): void; + removeEventListener(name: string, callback: Function): void; + exec(command: string, editor: Editor, args: any): boolean; + toggleRecording(editor: Editor): void; + replay(editor: Editor): void; + addCommand(command: EditorCommand): void; + addCommands(commands: EditorCommand[]): void; + removeCommand(command: EditorCommand | string, keepCommand?: boolean): void; + removeCommands(command: EditorCommand[]): void; + bindKey( + key: string | { mac?: string | undefined; win?: string | undefined }, + command: CommandLike, + position?: number, + ): void; + bindKeys(keys: { [s: string]: Function }): void; + parseKeys(keyPart: string): { key: string; hashId: number }; + findKeyCommand(hashId: number, keyString: string): string | undefined; + handleKeyboard( + data: {}, + hashId: number, + keyString: string, + keyCode: string | number, + // eslint-disable-next-line @typescript-eslint/no-invalid-void-type + ): void | { command: string }; + getStatusText(editor: Editor, data: {}): string; + platform: string; + } + + export interface Annotation { + row?: number | undefined; + column?: number | undefined; + text: string; + type: string; + } + + export interface TokenInfo { + type: string; + value: string; + index?: number | undefined; + start?: number | undefined; + } + + export interface Position { + row: number; + column: number; + } + + export interface KeyboardHandler { + handleKeyboard: Function; + } + + export interface KeyBinding { + setDefaultHandler(kb: KeyboardHandler): void; + setKeyboardHandler(kb: KeyboardHandler): void; + addKeyboardHandler(kb: KeyboardHandler, pos: number): void; + removeKeyboardHandler(kb: KeyboardHandler): boolean; + getKeyboardHandler(): KeyboardHandler; + onCommandKey(e: any, hashId: number, keyCode: number): boolean; + onTextInput(text: string): boolean; + } + + export interface TextMode { + getTokenizer(): Tokenizer; + toggleCommentLines(state: any, session: IEditSession, startRow: number, endRow: number): void; + toggleBlockComment(state: any, session: IEditSession, range: Range, cursor: Position): void; + getNextLineIndent(state: any, line: string, tab: string): string; + checkOutdent(state: any, line: string, input: string): boolean; + autoOutdent(state: any, doc: Document, row: number): void; + createWorker(session: IEditSession): any; + createModeDelegates(mapping: { [key: string]: string }): void; + transformAction(state: string, action: string, editor: Editor, session: IEditSession, text: string): any; + getKeywords(append?: boolean): Array; + getCompletions(state: string, session: IEditSession, pos: Position, prefix: string): Completion[]; + } + + export interface OptionProvider { + /** + * Sets a Configuration Option + */ + setOption(optionName: string, optionValue: any): void; + + /** + * Sets Configuration Options + */ + setOptions(keyValueTuples: { [key: string]: any }): void; + + /** + * Get a Configuration Option + */ + getOption(name: string): any; + + /** + * Get Configuration Options + */ + getOptions(optionNames?: string[] | { [key: string]: any }): { [key: string]: any }; + } + + //////////////// + /// Ace + //////////////// + + /** + * The main class required to set up an Ace instance in the browser. + */ + export interface Ace { + /** + * Provides access to require in packed noconflict mode + * @param moduleName + */ + require(moduleName: string): any; + + /** + * Embeds the Ace editor into the DOM, at the element provided by `el`. + * @param el Either the id of an element, or the element itself + */ + edit(el: string): Editor; + + /** + * Embeds the Ace editor into the DOM, at the element provided by `el`. + * @param el Either the id of an element, or the element itself + */ + edit(el: HTMLElement): Editor; + + /** + * Creates a new [[EditSession]], and returns the associated [[Document]]. + * @param text {:textParam} + * @param mode {:modeParam} + */ + createEditSession(text: Document | string, mode?: TextMode): IEditSession; + + /** + * Creates a new [[EditSession]], and returns the associated [[Document]]. + * @param text {:textParam} + * @param mode {:modeParam} + */ + createEditSession(text: string, mode: TextMode): IEditSession; + + config: { + set(key: string, value: any): void; + } + } + + //////////////// + /// Anchor + //////////////// + + /** + * Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated. + */ + export interface Anchor { + on(event: string, fn: (e: any) => any): void; + + /** + * Returns an object identifying the `row` and `column` position of the current anchor. + */ + getPosition(): Position; + + /** + * Returns the current document. + */ + getDocument(): Document; + + /** + * Fires whenever the anchor position changes. + * Both of these objects have a `row` and `column` property corresponding to the position. + * Events that can trigger this function include [[Anchor.setPosition `setPosition()`]]. + * @param e An object containing information about the anchor position. It has two properties: + * - `old`: An object describing the old Anchor position + * - `value`: An object describing the new Anchor position + */ + onChange(e: any): void; + + /** + * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped. + * @param row The row index to move the anchor to + * @param column The column index to move the anchor to + * @param noClip Identifies if you want the position to be clipped + */ + setPosition(row: number, column: number, noClip?: boolean): void; + + /** + * When called, the `'change'` event listener is removed. + */ + detach(): void; + + attach(doc: Document): void; + } + var Anchor: { + /** + * Creates a new `Anchor` and associates it with a document. + * @param doc The document to associate with the anchor + * @param row The starting row position + * @param column The starting column position + */ + new(doc: Document, row: number, column: number): Anchor; + }; + + //////////////////////////////// + /// BackgroundTokenizer + //////////////////////////////// + + /** + * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. + * If a certain row is changed, everything below that row is re-tokenized. + */ + export interface BackgroundTokenizer { + states: any[]; + + /** + * Sets a new tokenizer for this object. + * @param tokenizer The new tokenizer to use + */ + setTokenizer(tokenizer: Tokenizer): void; + + /** + * Sets a new document to associate with this object. + * @param doc The new document to associate with + */ + setDocument(doc: Document): void; + + /** + * Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated. + * @param firstRow The starting row region + * @param lastRow The final row region + */ + fireUpdateEvent(firstRow: number, lastRow: number): void; + + /** + * Starts tokenizing at the row indicated. + * @param startRow The row to start at + */ + start(startRow: number): void; + + /** + * Stops tokenizing. + */ + stop(): void; + + /** + * Gives list of tokens of the row. (tokens are cached) + * @param row The row to get tokens at + */ + getTokens(row: number): TokenInfo[]; + + /** + * [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState} + * @param row The row to get state at + */ + getState(row: number): string; + } + var BackgroundTokenizer: { + /** + * Creates a new `BackgroundTokenizer` object. + * @param tokenizer The tokenizer to use + * @param editor The editor to associate with + */ + new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer; + }; + + //////////////// + /// Document + //////////////// + + /** + * Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s. + * At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index. + */ + + type NewLineMode = "auto" | "unix" | "windows"; + + export interface Document { + on(event: string, fn: (e: any) => any): void; + + /** + * Replaces all the lines in the current `Document` with the value of `text`. + * @param text The text to use + */ + setValue(text: string): void; + + /** + * Returns all the lines in the document as a single string, split by the new line character. + */ + getValue(): string; + + /** + * Creates a new `Anchor` to define a floating point in the document. + * @param row The row number to use + * @param column The column number to use + */ + createAnchor(row: number, column: number): void; + + /** + * Returns the newline character that's being used, depending on the value of `newLineMode`. + */ + getNewLineCharacter(): string; + + /** + * [Sets the new line mode.]{: #Document.setNewLineMode.desc} + * @param newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param} + */ + setNewLineMode(newLineMode: NewLineMode): void; + + /** + * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode} + */ + getNewLineMode(): NewLineMode; + + /** + * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`). + * @param text The text to check + */ + isNewLine(text: string): boolean; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param row The row index to retrieve + */ + getLine(row: number): string; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param firstRow The first row index to retrieve + * @param lastRow The final row index to retrieve + */ + getLines(firstRow: number, lastRow: number): string[]; + + /** + * Returns all lines in the document as string array. Warning: The caller should not modify this array! + */ + getAllLines(): string[]; + + /** + * Returns the number of rows in the document. + */ + getLength(): number; + + /** + * [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc} + * @param range The range to work with + */ + getTextRange(range: Range): string; + + getLinesForRange(range: Range): string[]; + + /** + * Inserts a block of `text` and the indicated `position`. + * @param position The position to start inserting at + * @param text A chunk of text to insert + */ + insert(position: Position, text: string): Position; + + /** + * @deprecated Use the insertFullLines method instead. + */ + insertLines(row: number, lines: string[]): Position; + + /** + * Inserts the elements in `lines` into the document as full lines (does not merge with existing line), starting at the row index given by `row`. This method also triggers the `"change"` event. + * @param {Number} row The index of the row to insert at + * @param {Array} lines An array of strings + * @returns {Object} Contains the final row and column, like this: + * ``` + * {row: endRow, column: 0} + * ``` + * If `lines` is empty, this function returns an object containing the current row, and column, like this: + * ``` + * {row: row, column: 0} + * ``` + */ + insertFullLines(row: number, lines: string[]): void; + + /** + * @deprecated Use insertMergedLines(position, ['', '']) instead. + */ + insertNewLine(position: Position): Position; + + /** + * Inserts the elements in `lines` into the document, starting at the position index given by `row`. This method also triggers the `"change"` event. + * @param {Number} row The index of the row to insert at + * @param {Array} lines An array of strings + * @returns {Object} Contains the final row and column, like this: + * ``` + * {row: endRow, column: 0} + * ``` + * If `lines` is empty, this function returns an object containing the current row, and column, like this: + * ``` + * {row: row, column: 0} + * ``` + */ + insertMergedLines(row: number, lines: string[]): Position; + + /** + * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event. + * @param position The position to insert at + * @param text A chunk of text + */ + insertInLine(position: Position, text: string): Position; + + clippedPos(row: number, column: number): Position; + clonePos(pos: Position): Position; + pos(row: number, column: number): Position; + + /** + * Removes the `range` from the document. + * @param range A specified Range to remove + */ + remove(range: Range): Position; + + /** + * Removes the specified columns from the `row`. This method also triggers the `'change'` event. + * @param row The row to remove from + * @param startColumn The column to start removing at + * @param endColumn The column to stop removing at + */ + removeInLine(row: number, startColumn: number, endColumn: number): Position; + + /** + * @deprecated Use the removeFullLines method instead. + */ + removeLines(firstRow: number, lastRow: number): string[]; + + /** + * Removes a range of full lines. This method also triggers the `"change"` event. + * @param {Number} firstRow The first row to be removed + * @param {Number} lastRow The last row to be removed + * @returns {[String]} Returns all the removed lines. + */ + removeFullLines(firstRow: number, lastRow: number): string[]; + + /** + * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event. + * @param row The row to check + */ + removeNewLine(row: number): void; + + /** + * Replaces a range in the document with the new `text`. + * @param range A specified Range to replace + * @param text The new text to use as a replacement + */ + replace(range: Range, text: string): Position; + + /** + * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`. + */ + applyDeltas(deltas: Delta[]): void; + + /** + * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`. + */ + revertDeltas(deltas: Delta[]): void; + + /** + * Converts an index position in a document to a `{row, column}` object. + * Index refers to the "absolute position" of a character in the document. For example: + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * @param index An index to convert + * @param startRow=0 The row from which to start the conversion + */ + indexToPosition(index: number, startRow: number): Position; + + /** + * Converts the `{row, column}` position in a document to the character's index. + * Index refers to the "absolute position" of a character in the document. For example: + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * @param pos The `{row, column}` to convert + * @param startRow=0 The row from which to start the conversion + */ + positionToIndex(pos: Position, startRow?: number): number; + } + var Document: { + /** + * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. + * @param text The starting text + */ + new(text?: string): Document; + /** + * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. + * @param text The starting text + */ + new(text?: string[]): Document; + }; + + //////////////////////////////// + /// EditSession + //////////////////////////////// + + /** + * Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state. + * `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s. + */ + export interface IEditSession extends OptionProvider { + selection: Selection; + + bgTokenizer: BackgroundTokenizer; + + doc: Document; + + on(event: string, fn: (e: any) => any): void; + + findMatchingBracket(position: Position): void; + + addFold(text: string, range: Range): void; + + getFoldAt(row: number, column: number): any; + + removeFold(arg: any): void; + + expandFold(arg: any): void; + + foldAll(startRow?: number, endRow?: number, depth?: number): void; + + unfold(arg1: any, arg2: boolean): void; + + screenToDocumentColumn(row: number, column: number): void; + + getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any; + + getFoldsInRange(range: Range): any; + + highlight(text: string): void; + + /** + * Highlight lines from `startRow` to `EndRow`. + * @param startRow Define the start line of the highlight + * @param endRow Define the end line of the highlight + * @param clazz Set the CSS class for the marker + * @param inFront Set to `true` to establish a front marker + */ + highlightLines(startRow: number, endRow: number, clazz: string, inFront: boolean): Range; + + /** + * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`. + * @param doc The new `Document` to use + */ + setDocument(doc: Document): void; + + /** + * Returns the `Document` associated with this session. + */ + getDocument(): Document; + + /** + * undefined + * @param row The row to work with + */ + $resetRowCache(row: number): void; + + /** + * Sets the session text. + * @param text The new text to place + */ + setValue(text: string): void; + + setMode(mode: string): void; + + /** + * Returns the current [[Document `Document`]] as a string. + */ + getValue(): string; + + /** + * Returns the string of the current selection. + */ + getSelection(): Selection; + + /** + * {:BackgroundTokenizer.getState} + * @param row The row to start at + */ + getState(row: number): string; + + /** + * Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows. + * @param row The row to start at + */ + getTokens(row: number): TokenInfo[]; + + /** + * Returns an object indicating the token at the current row. The object has two properties: `index` and `start`. + * @param row The row number to retrieve from + * @param column The column number to retrieve from + */ + getTokenAt(row: number, column: number): TokenInfo | null; + + /** + * Sets the undo manager. + * @param undoManager The new undo manager + */ + setUndoManager(undoManager: UndoManager): void; + + /** + * Returns the current undo manager. + */ + getUndoManager(): UndoManager; + + /** + * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]): void; otherwise it's simply `'\t'`. + */ + getTabString(): string; + + /** + * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). + * @param useSoftTabs Value indicating whether or not to use soft tabs + */ + setUseSoftTabs(useSoftTabs: boolean): void; + + /** + * Returns `true` if soft tabs are being used, `false` otherwise. + */ + getUseSoftTabs(): boolean; + + /** + * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. + * @param tabSize The new tab size + */ + setTabSize(tabSize: number): void; + + /** + * Returns the current tab size. + */ + getTabSize(): number; + + /** + * Returns `true` if the character at the position is a soft tab. + * @param position The position to check + */ + isTabStop(position: any): boolean; + + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. + * If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event. + * @param overwrite Defines wheter or not to set overwrites + */ + setOverwrite(overwrite: boolean): void; + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + */ + getOverwrite(): boolean; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + */ + toggleOverwrite(): void; + + /** + * Adds `className` to the `row`, to be used for CSS stylings and whatnot. + * @param row The row number + * @param className The class to add + */ + addGutterDecoration(row: number, className: string): void; + + /** + * Removes `className` from the `row`. + * @param row The row number + * @param className The class to add + */ + removeGutterDecoration(row: number, className: string): void; + + /** + * Returns an array of numbers, indicating which rows have breakpoints. + */ + getBreakpoints(): number[]; + + /** + * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param rows An array of row indices + */ + setBreakpoints(rows: any[]): void; + + /** + * Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event. + */ + clearBreakpoints(): void; + + /** + * Sets a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param row A row index + * @param className Class of the breakpoint + */ + setBreakpoint(row: number, className: string): void; + + /** + * Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param row A row index + */ + clearBreakpoint(row: number): void; + + /** + * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires. + * @param range Define the range of the marker + * @param clazz Set the CSS class for the marker + * @param type Identify the type of the marker + * @param inFront Set to `true` to establish a front marker + */ + addMarker(range: Range, clazz: string, type: Function, inFront: boolean): number; + + /** + * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires. + * @param range Define the range of the marker + * @param clazz Set the CSS class for the marker + * @param type Identify the type of the marker + * @param inFront Set to `true` to establish a front marker + */ + addMarker(range: Range, clazz: string, type: string, inFront: boolean): number; + + /** + * Adds a dynamic marker to the session. + * @param marker object with update method + * @param inFront Set to `true` to establish a front marker + */ + addDynamicMarker(marker: any, inFront: boolean): void; + + /** + * Removes the marker with the specified ID. If this marker was in front, the `'changeFrontMarker'` event is emitted. If the marker was in the back, the `'changeBackMarker'` event is emitted. + * @param markerId A number representing a marker + */ + removeMarker(markerId: number): void; + + /** + * Returns an array containing the IDs of all the markers, either front or back. + * @param inFront If `true`, indicates you only want front markers; `false` indicates only back markers + */ + getMarkers(inFront: boolean): any[]; + + /** + * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event. + * @param annotations A list of annotations + */ + setAnnotations(annotations: Annotation[]): void; + + /** + * Returns the annotations for the `EditSession`. + */ + getAnnotations(): any; + + /** + * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event. + */ + clearAnnotations(): void; + + /** + * If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value. + * @param text A block of text + */ + $detectNewLine(text: string): void; + + /** + * Given a starting row and column, this method returns the `Range` of the first word boundary it finds. + * @param row The row to start at + * @param column The column to start at + */ + getWordRange(row: number, column: number): Range; + + /** + * Gets the range of a word, including its right whitespace. + * @param row The row number to start from + * @param column The column number to start from + */ + getAWordRange(row: number, column: number): any; + + /** + * {:Document.setNewLineMode.desc} + * @param newLineMode {:Document.setNewLineMode.param} + */ + setNewLineMode(newLineMode: string): void; + + /** + * Returns the current new line mode. + */ + getNewLineMode(): string; + + /** + * Identifies if you want to use a worker for the `EditSession`. + * @param useWorker Set to `true` to use a worker + */ + setUseWorker(useWorker: boolean): void; + + /** + * Returns `true` if workers are being used. + */ + getUseWorker(): boolean; + + /** + * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event. + */ + onReloadTokenizer(): void; + + /** + * Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted. + * @param mode Set a new text mode + */ + $mode(mode: TextMode): void; + + /** + * Returns the current text mode. + */ + getMode(): TextMode; + + /** + * This function sets the scroll top value. It also emits the `'changeScrollTop'` event. + * @param scrollTop The new scroll top value + */ + setScrollTop(scrollTop: number): void; + + /** + * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop} + */ + getScrollTop(): number; + + /** + * [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft} + * @param scrollLeft The new scroll left value + */ + setScrollLeft(scrollLeft: number): void; + + /** + * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft} + */ + getScrollLeft(): number; + + /** + * Returns the width of the screen. + */ + getScreenWidth(): number; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param row The row to retrieve from + */ + getLine(row: number): string; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param firstRow The first row index to retrieve + * @param lastRow The final row index to retrieve + */ + getLines(firstRow: number, lastRow: number): string[]; + + /** + * Returns the number of rows in the document. + */ + getLength(): number; + + /** + * {:Document.getTextRange.desc} + * @param range The range to work with + */ + getTextRange(range: Range): string; + + /** + * Inserts a block of `text` and the indicated `position`. + * @param position The position {row, column} to start inserting at + * @param text A chunk of text to insert + */ + insert(position: Position, text: string): any; + + /** + * Removes the `range` from the document. + * @param range A specified Range to remove + */ + remove(range: Range): any; + + /** + * Reverts previous changes to your document. + * @param deltas An array of previous changes + * @param dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect} + */ + undoChanges(deltas: any[], dontSelect: boolean): Range; + + /** + * Re-implements a previously undone change to your document. + * @param deltas An array of previous changes + * @param dontSelect {:dontSelect} + */ + redoChanges(deltas: any[], dontSelect: boolean): Range; + + /** + * Enables or disables highlighting of the range where an undo occured. + * @param enable If `true`, selects the range of the reinserted change + */ + setUndoSelect(enable: boolean): void; + + /** + * Replaces a range in the document with the new `text`. + * @param range A specified Range to replace + * @param text The new text to use as a replacement + */ + replace(range: Range, text: string): any; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param fromRange The range of text you want moved within the document + * @param toPosition The location (row and column) where you want to move the text to + */ + moveText(fromRange: Range, toPosition: any): Range; + + /** + * Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`. + * If `indentString` contains the `'\t'` character, it's replaced by whatever is defined by [[EditSession.getTabString `getTabString()`]]. + * @param startRow Starting row + * @param endRow Ending row + * @param indentString The indent token + */ + indentRows(startRow: number, endRow: number, indentString: string): void; + + /** + * Outdents all the rows defined by the `start` and `end` properties of `range`. + * @param range A range of rows + */ + outdentRows(range: Range): void; + + /** + * Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`. + * @param firstRow The starting row to move up + * @param lastRow The final row to move up + */ + moveLinesUp(firstRow: number, lastRow: number): number; + + /** + * Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`. + * @param firstRow The starting row to move down + * @param lastRow The final row to move down + */ + moveLinesDown(firstRow: number, lastRow: number): number; + + /** + * Duplicates all the text between `firstRow` and `lastRow`. + * @param firstRow The starting row to duplicate + * @param lastRow The final row to duplicate + */ + duplicateLines(firstRow: number, lastRow: number): number; + + /** + * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted. + * @param useWrapMode Enable (or disable) wrap mode + */ + setUseWrapMode(useWrapMode: boolean): void; + + /** + * Returns `true` if wrap mode is being used; `false` otherwise. + */ + getUseWrapMode(): boolean; + + /** + * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event. + * @param min The minimum wrap value (the left side wrap) + * @param max The maximum wrap value (the right side wrap) + */ + setWrapLimitRange(min: number, max: number): void; + + /** + * This should generally only be called by the renderer when a resize is detected. + * @param desiredLimit The new wrap limit + */ + adjustWrapLimit(desiredLimit: number): boolean; + + /** + * Returns the value of wrap limit. + */ + getWrapLimit(): number; + + /** + * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: + * { min: wrapLimitRange_min, max: wrapLimitRange_max } + */ + getWrapLimitRange(): any; + + /** + * Given a string, returns an array of the display characters, including tabs and spaces. + * @param str The string to check + * @param offset The value to start at + */ + $getDisplayTokens(str: string, offset: number): void; + + /** + * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen. + * @param str The string to calculate the screen width of + * @param maxScreenColumn + * @param screenColumn + */ + $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[]; + + /** + * Returns number of screenrows in a wrapped line. + * @param row The row number to check + */ + getRowLength(row: number): number; + + /** + * Returns the position (on screen) for the last character in the provided screen row. + * @param screenRow The screen row to check + */ + getScreenLastRowColumn(screenRow: number): number; + + /** + * For the given document row and column, this returns the column position of the last screen row. + * @param docRow + * @param docColumn + */ + getDocumentLastRowColumn(docRow: number, docColumn: number): number; + + /** + * For the given document row and column, this returns the document position of the last row. + * @param docRow + * @param docColumn + */ + getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number; + + /** + * For the given row, this returns the split data. + */ + getRowSplitData(): string; + + /** + * The distance to the next tab stop at the specified screen column. + * @param screenColumn The screen column to check + */ + getScreenTabSize(screenColumn: number): number; + + /** + * Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations} + * @param screenRow The screen row to check + * @param screenColumn The screen column to check + */ + screenToDocumentPosition(screenRow: number, screenColumn: number): any; + + /** + * Converts document coordinates to screen coordinates. {:conversionConsiderations} + * @param docRow The document row to check + * @param docColumn The document column to check + */ + documentToScreenPosition(docRow: number, docColumn: number): any; + + /** + * For the given document row and column, returns the screen column. + * @param row + * @param docColumn + */ + documentToScreenColumn(row: number, docColumn: number): number; + + /** + * For the given document row and column, returns the screen row. + * @param docRow + * @param docColumn + */ + documentToScreenRow(docRow: number, docColumn: number): void; + + /** + * Returns the length of the screen. + */ + getScreenLength(): number; + } + var EditSession: { + /** + * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`. + * @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam} + * @param mode [The inital language mode to use for the document]{: #modeParam} + */ + new(text: string, mode?: TextMode): IEditSession; + + new(content: string, mode?: string): IEditSession; + + new(text: string[], mode?: string): IEditSession; + }; + + //////////////////////////////// + /// Editor + //////////////////////////////// + + /** + * The main entry point into the Ace functionality. + * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. + * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them. + */ + export interface Editor extends OptionProvider { + on(ev: string, callback: (e: any) => any): void; + + addEventListener(ev: "change", callback: (ev: EditorChangeEvent) => any): void; + addEventListener(ev: string, callback: Function): void; + + off(ev: string, callback: Function): void; + + removeListener(ev: string, callback: Function): void; + + removeEventListener(ev: string, callback: Function): void; + + inMultiSelectMode: boolean; + + selectMoreLines(n: number): void; + + onTextInput(text: string): void; + + onCommandKey(e: any, hashId: number, keyCode: number): void; + + commands: CommandManager; + + session: IEditSession; + + selection: Selection; + + renderer: VirtualRenderer; + + keyBinding: KeyBinding; + + container: HTMLElement; + + onSelectionChange(e: any): void; + + onChangeMode(e?: any): void; + + execCommand(command: string, args?: any): void; + + /** + * Get rid of console warning by setting this to Infinity + */ + $blockScrolling: number; + + /** + * Sets a new key handler, such as "vim" or "windows". + * @param keyboardHandler The new key handler + */ + setKeyboardHandler(keyboardHandler: string): void; + + /** + * Returns the keyboard handler, such as "vim" or "windows". + */ + getKeyboardHandler(): string; + + /** + * Sets a new editsession to use. This method also emits the `'changeSession'` event. + * @param session The new session to use + */ + setSession(session: IEditSession): void; + + /** + * Returns the current session being used. + */ + getSession(): IEditSession; + + /** + * Sets the current document to `val`. + * @param val The new value to set for the document + * @param cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end + */ + setValue(val: string, cursorPos?: number): string; + + /** + * Returns the current session's content. + */ + getValue(): string; + + /** + * Returns the currently highlighted selection. + */ + getSelection(): Selection; + + /** + * {:VirtualRenderer.onResize} + * @param force If `true`, recomputes the size, even if the height and width haven't changed + */ + resize(force?: boolean): void; + + /** + * {:VirtualRenderer.setTheme} + * @param theme The path to a theme + */ + setTheme(theme: string): void; + + /** + * {:VirtualRenderer.getTheme} + */ + getTheme(): string; + + /** + * {:VirtualRenderer.setStyle} + * @param style A class name + */ + setStyle(style: string): void; + + /** + * {:VirtualRenderer.unsetStyle} + */ + unsetStyle(): void; + + /** + * Set a new font size (in pixels) for the editor text. + * @param size A font size ( _e.g._ "12px") + */ + setFontSize(size: string): void; + + /** + * Brings the current `textInput` into focus. + */ + focus(): void; + + /** + * Returns `true` if the current `textInput` is in focus. + */ + isFocused(): boolean; + + /** + * Blurs the current `textInput`. + */ + blur(): void; + + /** + * Emitted once the editor comes into focus. + */ + onFocus(): void; + + /** + * Emitted once the editor has been blurred. + */ + onBlur(): void; + + /** + * Emitted whenever the document is changed. + * @param e Contains a single property, `data`, which has the delta of changes + */ + onDocumentChange(e: any): void; + + /** + * Emitted when the selection changes. + */ + onCursorChange(): void; + + /** + * Returns the string of text currently highlighted. + */ + getCopyText(): string; + + /** + * Called whenever a text "copy" happens. + */ + onCopy(): void; + + /** + * Called whenever a text "cut" happens. + */ + onCut(): void; + + /** + * Called whenever a text "paste" happens. + * @param text The pasted text + */ + onPaste(text: string): void; + + /** + * Inserts `text` into wherever the cursor is pointing. + * @param text The new text to add + */ + insert(text: string): void; + + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event. + * @param overwrite Defines wheter or not to set overwrites + */ + setOverwrite(overwrite: boolean): void; + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + */ + getOverwrite(): boolean; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + */ + toggleOverwrite(): void; + + /** + * Sets how fast the mouse scrolling should do. + * @param speed A value indicating the new speed (in milliseconds) + */ + setScrollSpeed(speed: number): void; + + /** + * Returns the value indicating how fast the mouse scroll speed is (in milliseconds). + */ + getScrollSpeed(): number; + + /** + * Sets the delay (in milliseconds) of the mouse drag. + * @param dragDelay A value indicating the new delay + */ + setDragDelay(dragDelay: number): void; + + /** + * Returns the current mouse drag delay. + */ + getDragDelay(): number; + + /** + * Indicates how selections should occur. + * By default, selections are set to "line". There are no other styles at the moment, + * although this code change in the future. + * This function also emits the `'changeSelectionStyle'` event. + * @param style The new selection style + */ + setSelectionStyle(style: string): void; + + /** + * Returns the current selection style. + */ + getSelectionStyle(): string; + + /** + * Determines whether or not the current line should be highlighted. + * @param shouldHighlight Set to `true` to highlight the current line + */ + setHighlightActiveLine(shouldHighlight: boolean): void; + + /** + * Returns `true` if current lines are always highlighted. + */ + getHighlightActiveLine(): boolean; + + /** + * Determines if the currently selected word should be highlighted. + * @param shouldHighlight Set to `true` to highlight the currently selected word + */ + setHighlightSelectedWord(shouldHighlight: boolean): void; + + /** + * Returns `true` if currently highlighted words are to be highlighted. + */ + getHighlightSelectedWord(): boolean; + + /** + * If `showInvisibiles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor. + * @param showInvisibles Specifies whether or not to show invisible characters + */ + setShowInvisibles(showInvisibles: boolean): void; + + /** + * Returns `true` if invisible characters are being shown. + */ + getShowInvisibles(): boolean; + + /** + * If `showPrintMargin` is set to `true`, the print margin is shown in the editor. + * @param showPrintMargin Specifies whether or not to show the print margin + */ + setShowPrintMargin(showPrintMargin: boolean): void; + + /** + * Returns `true` if the print margin is being shown. + */ + getShowPrintMargin(): boolean; + + /** + * Sets the column defining where the print margin should be. + * @param showPrintMargin Specifies the new print margin + */ + setPrintMarginColumn(showPrintMargin: number): void; + + /** + * Returns the column number of where the print margin is. + */ + getPrintMarginColumn(): number; + + /** + * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change. + * @param readOnly Specifies whether the editor can be modified or not + */ + setReadOnly(readOnly: boolean): void; + + /** + * Returns `true` if the editor is set to read-only mode. + */ + getReadOnly(): boolean; + + /** + * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef} + * @param enabled Enables or disables behaviors + */ + setBehavioursEnabled(enabled: boolean): void; + + /** + * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef} + */ + getBehavioursEnabled(): boolean; + + /** + * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets + * when such a character is typed in. + * @param enabled Enables or disables wrapping behaviors + */ + setWrapBehavioursEnabled(enabled: boolean): void; + + /** + * Returns `true` if the wrapping behaviors are currently enabled. + */ + getWrapBehavioursEnabled(): void; + + /** + * Indicates whether the fold widgets are shown or not. + * @param show Specifies whether the fold widgets are shown + */ + setShowFoldWidgets(show: boolean): void; + + /** + * Returns `true` if the fold widgets are shown. + */ + getShowFoldWidgets(): void; + + /** + * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace. + * @param dir The direction of the deletion to occur, either "left" or "right" + */ + remove(dir: string): void; + + /** + * Removes the word directly to the right of the current selection. + */ + removeWordRight(): void; + + /** + * Removes the word directly to the left of the current selection. + */ + removeWordLeft(): void; + + /** + * Removes all the words to the left of the current selection, until the start of the line. + */ + removeToLineStart(): void; + + /** + * Removes all the words to the right of the current selection, until the end of the line. + */ + removeToLineEnd(): void; + + /** + * Splits the line at the current selection (by inserting an `'\n'`). + */ + splitLine(): void; + + /** + * Transposes current line. + */ + transposeLetters(): void; + + /** + * Converts the current selection entirely into lowercase. + */ + toLowerCase(): void; + + /** + * Converts the current selection entirely into uppercase. + */ + toUpperCase(): void; + + /** + * Inserts an indentation into the current cursor position or indents the selected lines. + */ + indent(): void; + + /** + * Indents the current line. + */ + blockIndent(): void; + + /** + * Outdents the current line. + */ + blockOutdent(arg?: string): void; + + /** + * Given the currently selected range, this function either comments all the lines, or uncomments all of them. + */ + toggleCommentLines(): void; + + /** + * Works like [[EditSession.getTokenAt]], except it returns a number. + */ + getNumberAt(): number; + + /** + * If the character before the cursor is a number, this functions changes its value by `amount`. + * @param amount The value to change the numeral by (can be negative to decrease value) + */ + modifyNumber(amount: number): void; + + /** + * Removes all the lines in the current selection + */ + removeLines(): void; + + /** + * Shifts all the selected lines down one row. + */ + moveLinesDown(): number; + + /** + * Shifts all the selected lines up one row. + */ + moveLinesUp(): number; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param fromRange The range of text you want moved within the document + * @param toPosition The location (row and column) where you want to move the text to + */ + moveText(fromRange: Range, toPosition: any): Range; + + /** + * Copies all the selected lines up one row. + */ + copyLinesUp(): number; + + /** + * Copies all the selected lines down one row. + */ + copyLinesDown(): number; + + /** + * {:VirtualRenderer.getFirstVisibleRow} + */ + getFirstVisibleRow(): number; + + /** + * {:VirtualRenderer.getLastVisibleRow} + */ + getLastVisibleRow(): number; + + /** + * Indicates if the row is currently visible on the screen. + * @param row The row to check + */ + isRowVisible(row: number): boolean; + + /** + * Indicates if the entire row is currently visible on the screen. + * @param row The row to check + */ + isRowFullyVisible(row: number): boolean; + + /** + * Selects the text from the current position of the document until where a "page down" finishes. + */ + selectPageDown(): void; + + /** + * Selects the text from the current position of the document until where a "page up" finishes. + */ + selectPageUp(): void; + + /** + * Shifts the document to wherever "page down" is, as well as moving the cursor position. + */ + gotoPageDown(): void; + + /** + * Shifts the document to wherever "page up" is, as well as moving the cursor position. + */ + gotoPageUp(): void; + + /** + * Scrolls the document to wherever "page down" is, without changing the cursor position. + */ + scrollPageDown(): void; + + /** + * Scrolls the document to wherever "page up" is, without changing the cursor position. + */ + scrollPageUp(): void; + + /** + * Moves the editor to the specified row. + */ + scrollToRow(): void; + + /** + * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to). + * @param line The line to scroll to + * @param center If `true` + * @param animate If `true` animates scrolling + * @param callback Function to be called when the animation has finished + */ + scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void; + + /** + * Attempts to center the current selection on the screen. + */ + centerSelection(): void; + + /** + * Gets the current position of the cursor. + */ + getCursorPosition(): Position; + + /** + * Returns the screen position of the cursor. + */ + getCursorPositionScreen(): number; + + /** + * {:Selection.getRange} + */ + getSelectionRange(): Range; + + /** + * Selects all the text in editor. + */ + selectAll(): void; + + /** + * {:Selection.clearSelection} + */ + clearSelection(): void; + + /** + * Moves the cursor to the specified row and column. Note that this does not de-select the current selection. + * @param row The new row number + * @param column The new column number + */ + moveCursorTo(row: number, column?: number, animate?: boolean): void; + + /** + * Moves the cursor to the position indicated by `pos.row` and `pos.column`. + * @param position An object with two properties, row and column + */ + moveCursorToPosition(position: Position): void; + + /** + * Moves the cursor's row and column to the next matching bracket. + */ + jumpToMatching(): void; + + /** + * Moves the cursor to the specified line number, and also into the indiciated column. + * @param lineNumber The line number to go to + * @param column A column number to go to + * @param animate If `true` animates scolling + */ + gotoLine(lineNumber: number, column?: number, animate?: boolean): void; + + /** + * Moves the cursor to the specified row and column. Note that this does de-select the current selection. + * @param row The new row number + * @param column The new column number + */ + navigateTo(row: number, column: number): void; + + /** + * Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + */ + navigateUp(times?: number): void; + + /** + * Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + */ + navigateDown(times?: number): void; + + /** + * Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + */ + navigateLeft(times?: number): void; + + /** + * Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + */ + navigateRight(times: number): void; + + /** + * Moves the cursor to the start of the current line. Note that this does de-select the current selection. + */ + navigateLineStart(): void; + + /** + * Moves the cursor to the end of the current line. Note that this does de-select the current selection. + */ + navigateLineEnd(): void; + + /** + * Moves the cursor to the end of the current file. Note that this does de-select the current selection. + */ + navigateFileEnd(): void; + + /** + * Moves the cursor to the start of the current file. Note that this does de-select the current selection. + */ + navigateFileStart(): void; + + /** + * Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection. + */ + navigateWordRight(): void; + + /** + * Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection. + */ + navigateWordLeft(): void; + + /** + * Replaces the first occurance of `options.needle` with the value in `replacement`. + * @param replacement The text to replace with + * @param options The [[Search `Search`]] options to use + */ + replace(replacement: string, options?: any): void; + + /** + * Replaces all occurances of `options.needle` with the value in `replacement`. + * @param replacement The text to replace with + * @param options The [[Search `Search`]] options to use + */ + replaceAll(replacement: string, options?: any): void; + + /** + * {:Search.getOptions} For more information on `options`, see [[Search `Search`]]. + */ + getLastSearchOptions(): any; + + /** + * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]]. + * @param needle The text to search for (optional) + * @param options An object defining various search properties + * @param animate If `true` animate scrolling + */ + find(needle: string, options?: any, animate?: boolean): void; + + /** + * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]]. + * @param options search options + * @param animate If `true` animate scrolling + */ + findNext(options?: any, animate?: boolean): void; + + /** + * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]]. + * @param options search options + * @param animate If `true` animate scrolling + */ + findPrevious(options?: any, animate?: boolean): void; + + /** + * {:UndoManager.undo} + */ + undo(): void; + + /** + * {:UndoManager.redo} + */ + redo(): void; + + /** + * Cleans up the entire editor. + */ + destroy(): void; + } + + var Editor: { + /** + * Creates a new `Editor` object. + * @param renderer Associated `VirtualRenderer` that draws everything + * @param session The `EditSession` to refer to + */ + new(renderer: VirtualRenderer, session?: IEditSession): Editor; + }; + + interface EditorChangeEvent { + start: Position; + end: Position; + action: string; // insert, remove + lines: any[]; + } + + //////////////////////////////// + /// PlaceHolder + //////////////////////////////// + + export interface PlaceHolder { + on(event: string, fn: (e: any) => any): void; + + /** + * PlaceHolder.setup() + * TODO + */ + setup(): void; + + /** + * PlaceHolder.showOtherMarkers() + * TODO + */ + showOtherMarkers(): void; + + /** + * PlaceHolder.hideOtherMarkers() + * Hides all over markers in the [[EditSession `EditSession`]] that are not the currently selected one. + */ + hideOtherMarkers(): void; + + /** + * PlaceHolder@onUpdate(e) + * Emitted when the place holder updates. + */ + onUpdate(): void; + + /** + * PlaceHolder@onCursorChange(e) + * Emitted when the cursor changes. + */ + onCursorChange(): void; + + /** + * PlaceHolder.detach() + * TODO + */ + detach(): void; + + /** + * PlaceHolder.cancel() + * TODO + */ + cancel(): void; + } + var PlaceHolder: { + /** + * - @param session (Document): The document to associate with the anchor + * - @param length (Number): The starting row position + * - @param pos (Number): The starting column position + * - @param others (String): + * - @param mainClass (String): + * - @param othersClass (String): + */ + new( + session: Document, + length: number, + pos: number, + others: string, + mainClass: string, + othersClass: string, + ): PlaceHolder; + + new(session: IEditSession, length: number, pos: Position, positions: Position[]): PlaceHolder; + }; + + //////////////// + /// RangeList + //////////////// + + export interface IRangeList { + ranges: Range[]; + + pointIndex(pos: Position, startIndex?: number): void; + + addList(ranges: Range[]): void; + + add(ranges: Range): void; + + merge(): Range[]; + + substractPoint(pos: Position): void; + } + export var RangeList: { + new(): IRangeList; + }; + + //////////////// + /// Range + //////////////// + + /** + * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column. + */ + export interface Range { + startRow: number; + + startColumn: number; + + endRow: number; + + endColumn: number; + + start: Position; + + end: Position; + + isEmpty(): boolean; + + /** + * Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`. + * @param range A range to check against + */ + isEqual(range: Range): void; + + /** + * Returns a string containing the range's row and column information, given like this: + * ``` + * [start.row/start.column] -> [end.row/end.column] + * ``` + */ + toString(): void; + + /** + * Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if: + * ```javascript + * this.start.row <= row <= this.end.row && + * this.start.column <= column <= this.end.column + * ``` + * @param row A row to check for + * @param column A column to check for + */ + contains(row: number, column: number): boolean; + + /** + * Compares `this` range (A) with another range (B). + * @param range A range to compare with + */ + compareRange(range: Range): number; + + /** + * Checks the row and column points of `p` with the row and column points of the calling range. + * @param p A point to compare with + */ + comparePoint(p: Range): number; + + /** + * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range. + * @param range A range to compare with + */ + containsRange(range: Range): boolean; + + /** + * Returns `true` if passed in `range` intersects with the one calling this method. + * @param range A range to compare with + */ + intersects(range: Range): boolean; + + /** + * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`. + * @param row A row point to compare with + * @param column A column point to compare with + */ + isEnd(row: number, column: number): boolean; + + /** + * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`. + * @param row A row point to compare with + * @param column A column point to compare with + */ + isStart(row: number, column: number): boolean; + + /** + * Sets the starting row and column for the range. + * @param row A row point to set + * @param column A column point to set + */ + setStart(row: number, column: number): void; + + /** + * Sets the starting row and column for the range. + * @param row A row point to set + * @param column A column point to set + */ + setEnd(row: number, column: number): void; + + /** + * Returns `true` if the `row` and `column` are within the given range. + * @param row A row point to compare with + * @param column A column point to compare with + */ + inside(row: number, column: number): boolean; + + /** + * Returns `true` if the `row` and `column` are within the given range's starting points. + * @param row A row point to compare with + * @param column A column point to compare with + */ + insideStart(row: number, column: number): boolean; + + /** + * Returns `true` if the `row` and `column` are within the given range's ending points. + * @param row A row point to compare with + * @param column A column point to compare with + */ + insideEnd(row: number, column: number): boolean; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + */ + compare(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + */ + compareStart(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + */ + compareEnd(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + */ + compareInside(row: number, column: number): number; + + /** + * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object. + * @param firstRow The starting row + * @param lastRow The ending row + */ + clipRows(firstRow: number, lastRow: number): Range; + + /** + * Changes the row and column points for the calling range for both the starting and ending points. + * @param row A new row to extend to + * @param column A new column to extend to + */ + extend(row: number, column: number): Range; + + /** + * Returns `true` if the range spans across multiple lines. + */ + isMultiLine(): boolean; + + /** + * Returns a duplicate of the calling range. + */ + clone(): Range; + + /** + * Returns a range containing the starting and ending rows of the original range, but with a column value of `0`. + */ + collapseRows(): Range; + + /** + * Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object. + * @param session The `EditSession` to retrieve coordinates from + */ + toScreenRange(session: IEditSession): Range; + + /** + * Creates and returns a new `Range` based on the row and column of the given parameters. + * @param start A starting point to use + * @param end An ending point to use + */ + fromPoints(start: Range, end: Range): Range; + } + /** + * Creates a new `Range` object with the given starting and ending row and column points. + * @param startRow The starting row + * @param startColumn The starting column + * @param endRow The ending row + * @param endColumn The ending column + */ + var Range: { + fromPoints(pos1: Position, pos2: Position): Range; + new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range; + }; + + //////////////// + /// RenderLoop + //////////////// + + export interface RenderLoop { } + var RenderLoop: { + new(): RenderLoop; + }; + + //////////////// + /// ScrollBar + //////////////// + + /** + * A set of methods for setting and retrieving the editor's scrollbar. + */ + export interface ScrollBar { + /** + * Emitted when the scroll bar, well, scrolls. + * @param e Contains one property, `"data"`, which indicates the current scroll top position + */ + onScroll(e: any): void; + + /** + * Returns the width of the scroll bar. + */ + getWidth(): number; + + /** + * Sets the height of the scroll bar, in pixels. + * @param height The new height + */ + setHeight(height: number): void; + + /** + * Sets the inner height of the scroll bar, in pixels. + * @param height The new inner height + */ + setInnerHeight(height: number): void; + + /** + * Sets the scroll top of the scroll bar. + * @param scrollTop The new scroll top + */ + setScrollTop(scrollTop: number): void; + } + var ScrollBar: { + /** + * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar. + * @param parent A DOM element + */ + new(parent: HTMLElement): ScrollBar; + }; + + //////////////// + /// Search + //////////////// + + /** + * A class designed to handle all sorts of text searches within a [[Document `Document`]]. + */ + export interface Search { + /** + * Sets the search options via the `options` parameter. + * @param options An object containing all the new search properties + */ + set(options: any): Search; + + /** + * [Returns an object containing all the search options.]{: #Search.getOptions} + */ + getOptions(): any; + + /** + * Sets the search options via the `options` parameter. + * @param An object containing all the search propertie + */ + setOptions(An: any): void; + + /** + * Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session. + * @param session The session to search with + */ + find(session: IEditSession): Range; + + /** + * Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session. + * @param session The session to search with + */ + findAll(session: IEditSession): Range[]; + + /** + * Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`. + * @param input The text to search in + * @param replacement The replacing text + * + (String): If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.
+ * If `options.needle` was not found, this function returns `null`. + */ + replace(input: string, replacement: string): string; + } + var Search: { + /** + * Creates a new `Search` object. The following search options are avaliable: + * - `needle`: The string or regular expression you're looking for + * - `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`. + * - `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`. + * - `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`. + * - `wholeWord`: Whether the search matches only on whole words. Defaults to `false`. + * - `range`: The [[Range]] to search within. Set this to `null` for the whole document + * - `regExp`: Whether the search is a regular expression or not. Defaults to `false`. + * - `start`: The starting [[Range]] or cursor position to begin the search + * - `skipCurrent`: Whether or not to include the current line in the search. Default to `false`. + */ + new(): Search; + }; + + //////////////// + /// Search + //////////////// + + /** + * Contains the cursor position and the text selection of an edit session. + * The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding. + */ + export interface Selection { + on(ev: string, callback: Function): void; + + addEventListener(ev: string, callback: Function): void; + + off(ev: string, callback: Function): void; + + removeListener(ev: string, callback: Function): void; + + removeEventListener(ev: string, callback: Function): void; + + moveCursorWordLeft(): void; + + moveCursorWordRight(): void; + + fromOrientedRange(range: Range): void; + + setSelectionRange(match: any): void; + + getAllRanges(): Range[]; + + on(event: string, fn: (e: any) => any): void; + + addRange(range: Range): void; + + /** + * Returns `true` if the selection is empty. + */ + isEmpty(): boolean; + + /** + * Returns `true` if the selection is a multi-line. + */ + isMultiLine(): boolean; + + /** + * Gets the current position of the cursor. + */ + getCursor(): Position; + + /** + * Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event. + * @param row The new row + * @param column The new column + */ + setSelectionAnchor(row: number, column: number): void; + + /** + * Returns an object containing the `row` and `column` of the calling selection anchor. + */ + getSelectionAnchor(): any; + + /** + * Returns an object containing the `row` and `column` of the calling selection lead. + */ + getSelectionLead(): any; + + /** + * Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns. + * @param columns The number of columns to shift by + */ + shiftSelection(columns: number): void; + + /** + * Returns `true` if the selection is going backwards in the document. + */ + isBackwards(): boolean; + + /** + * [Returns the [[Range]] for the selected text.]{: #Selection.getRange} + */ + getRange(): Range; + + /** + * [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection} + */ + clearSelection(): void; + + /** + * Selects all the text in the document. + */ + selectAll(): void; + + /** + * Sets the selection to the provided range. + * @param range The range of text to select + * @param reverse Indicates if the range should go backwards (`true`) or not + */ + setRange(range: Range, reverse: boolean): void; + + /** + * Moves the selection cursor to the indicated row and column. + * @param row The row to select to + * @param column The column to select to + */ + selectTo(row: number, column: number): void; + + /** + * Moves the selection cursor to the row and column indicated by `pos`. + * @param pos An object containing the row and column + */ + selectToPosition(pos: any): void; + + /** + * Moves the selection up one row. + */ + selectUp(): void; + + /** + * Moves the selection down one row. + */ + selectDown(): void; + + /** + * Moves the selection right one column. + */ + selectRight(): void; + + /** + * Moves the selection left one column. + */ + selectLeft(): void; + + /** + * Moves the selection to the beginning of the current line. + */ + selectLineStart(): void; + + /** + * Moves the selection to the end of the current line. + */ + selectLineEnd(): void; + + /** + * Moves the selection to the end of the file. + */ + selectFileEnd(): void; + + /** + * Moves the selection to the start of the file. + */ + selectFileStart(): void; + + /** + * Moves the selection to the first word on the right. + */ + selectWordRight(): void; + + /** + * Moves the selection to the first word on the left. + */ + selectWordLeft(): void; + + /** + * Moves the selection to highlight the entire word. + */ + getWordRange(): void; + + /** + * Selects an entire word boundary. + */ + selectWord(): void; + + /** + * Selects a word, including its right whitespace. + */ + selectAWord(): void; + + /** + * Selects the entire line. + */ + selectLine(): void; + + /** + * Moves the cursor up one row. + */ + moveCursorUp(): void; + + /** + * Moves the cursor down one row. + */ + moveCursorDown(): void; + + /** + * Moves the cursor left one column. + */ + moveCursorLeft(): void; + + /** + * Moves the cursor right one column. + */ + moveCursorRight(): void; + + /** + * Moves the cursor to the start of the line. + */ + moveCursorLineStart(): void; + + /** + * Moves the cursor to the end of the line. + */ + moveCursorLineEnd(): void; + + /** + * Moves the cursor to the end of the file. + */ + moveCursorFileEnd(): void; + + /** + * Moves the cursor to the start of the file. + */ + moveCursorFileStart(): void; + + /** + * Moves the cursor to the word on the right. + */ + moveCursorLongWordRight(): void; + + /** + * Moves the cursor to the word on the left. + */ + moveCursorLongWordLeft(): void; + + /** + * Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document. + * @param rows The number of rows to move by + * @param chars The number of characters to move by + */ + moveCursorBy(rows: number, chars: number): void; + + /** + * Moves the selection to the position indicated by its `row` and `column`. + * @param position The position to move to + */ + moveCursorToPosition(position: any): void; + + /** + * Moves the cursor to the row and column provided. [If `preventUpdateDesiredColumn` is `true`, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc} + * @param row The row to move to + * @param column The column to move to + * @param keepDesiredColumn [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool} + */ + moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean): void; + + /** + * Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc} + * @param row The row to move to + * @param column The column to move to + * @param keepDesiredColumn {:preventUpdateBool} + */ + moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean): void; + } + var Selection: { + /** + * Creates a new `Selection` object. + * @param session The session to use + */ + new(session: IEditSession): Selection; + }; + + //////////////// + /// Split + //////////////// + + export interface Split { + BELOW: number; + BESIDE: number; + + /** + * Returns the number of splits. + */ + getSplits(): number; + + /** + * Set the number of splits. + * @param splits The number of splits + */ + setSplits(splits?: number): void; + + /** + * Returns the editor identified by the index `idx`. + * @param idx The index of the editor you want + */ + getEditor(idx: number): Editor; + + /** + * Returns the current editor. + */ + getCurrentEditor(): Editor; + + /** + * Focuses the current editor. + */ + focus(): void; + + /** + * Blurs the current editor. + */ + blur(): void; + + /** + * Sets a theme for each of the available editors. + * @param theme The name of the theme to set + */ + setTheme(theme: string): void; + + /** + * Sets the keyboard handler for the editor. + * @param keybinding + */ + setKeyboardHandler(keybinding: string): void; + + /** + * Executes `callback` on all of the available editors. + * @param callback A callback function to execute + * @param scope The default scope for the callback + */ + forEach(callback: Function, scope: string): void; + + /** + * Sets the font size, in pixels, for all the available editors. + * @param size The new font size + */ + setFontSize(size: number): void; + + /** + * Sets a new [[EditSession `EditSession`]] for the indicated editor. + * @param session The new edit session + * @param idx The editor's index you're interested in + */ + setSession(session: IEditSession, idx: number): void; + + /** + * Returns the orientation. + */ + getOrientation(): number; + + /** + * Sets the orientation. + * @param orientation The new orientation value + */ + setOrientation(orientation: number): void; + + /** + * Resizes the editor. + */ + resize(): void; + } + var Split: { + Split(container: HTMLElement, theme?: any, splits?: number): void; + }; + + ////////////////// + /// TokenIterator + ////////////////// + + /** + * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens. + */ + export interface TokenIterator { + /** + * Tokenizes all the items from the current point to the row prior in the document. + */ + stepBackward(): string[]; + + /** + * Tokenizes all the items from the current point until the next row in the document. If the current point is at the end of the file, this function returns `null`. Otherwise, it returns the tokenized string. + */ + stepForward(): string; + + /** + * Returns the current tokenized string. + */ + getCurrentToken(): TokenInfo; + + /** + * Returns the current row. + */ + getCurrentTokenRow(): number; + + /** + * Returns the current column. + */ + getCurrentTokenColumn(): number; + } + var TokenIterator: { + /** + * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates. + * @param session The session to associate with + * @param initialRow The row to start the tokenizing at + * @param initialColumn The column to start the tokenizing at + */ + new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator; + }; + + ////////////////// + /// Tokenizer + ////////////////// + + /** + * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter). + */ + export interface Tokenizer { + /** + * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state. + */ + removeCapturingGroups(src: string): string; + createSplitterRegexp(src: string, flag?: string): RegExp; + getLineTokens(line: string, startState: string | string[]): TokenInfo[]; + } + var Tokenizer: { + /** + * Constructs a new tokenizer based on the given rules and flags. + * @param rules The highlighting rules + * @param flag Any additional regular expression flags to pass (like "i" for case insensitive) + */ + new(rules: any, flag: string): Tokenizer; + }; + + ////////////////// + /// UndoManager + ////////////////// + + /** + * This object maintains the undo stack for an [[EditSession `EditSession`]]. + */ + export interface UndoManager { + /** + * [Perform an undo operation on the document, reverting the last change.]{: #UndoManager.undo} + * @param session {:session} + * @param dontSelect {:dontSelect} + */ + undo(session?: IEditSession, dontSelect?: boolean): Range; + + /** + * [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo} + * @param session {:session} + * @param dontSelect {:dontSelect} + */ + redo(session?: IEditSession, dontSelect?: boolean): void; + + /** + * Destroys the stack of undo and redo redo operations. + */ + reset(): void; + + /** + * Returns `true` if there are undo operations left to perform. + */ + canUndo(): boolean; + /** + * Alias for canUndo + */ + hasUndo(): boolean; + + /** + * Returns `true` if there are redo operations left to perform. + */ + canRedo(): boolean; + /** + * Alias for canRedo + */ + hasRedo(): boolean; + + /** + * Returns if the current status is clean + */ + isAtBookmark(): boolean; + /** + * Alias for isAtBookmark + */ + isClean(): boolean; + + /** + * Marks the current status clean + * @param rev {:rev} + */ + bookmark(rev?: number): void; + /** + * Alias for bookmark + */ + markClean(rev?: number): void; + } + var UndoManager: { + /** + * Resets the current undo state and creates a new `UndoManager`. + */ + new(): UndoManager; + }; + + //////////////////// + /// VirtualRenderer + //////////////////// + + /** + * The class that is responsible for drawing everything you see on the screen! + */ + export interface VirtualRenderer extends OptionProvider { + scroller: any; + + characterWidth: number; + + lineHeight: number; + + $cursorLayer: Layer.Cursor; + + setScrollMargin(top: number, bottom: number, left: number, right: number): void; + + screenToTextCoordinates(left: number, top: number): void; + + /** + * Associates the renderer with an [[EditSession `EditSession`]]. + */ + setSession(session: IEditSession): void; + + /** + * Triggers a partial update of the text, from the range given by the two parameters. + * @param firstRow The first row to update + * @param lastRow The last row to update + */ + updateLines(firstRow: number, lastRow: number): void; + + /** + * Triggers a full update of the text, for all the rows. + */ + updateText(): void; + + /** + * Triggers a full update of all the layers, for all the rows. + * @param force If `true`, forces the changes through + */ + updateFull(force: boolean): void; + + /** + * Updates the font size. + */ + updateFontSize(): void; + + /** + * [Triggers a resize of the editor.]{: #VirtualRenderer.onResize} + * @param force If `true`, recomputes the size, even if the height and width haven't changed + * @param gutterWidth The width of the gutter in pixels + * @param width The width of the editor in pixels + * @param height The hiehgt of the editor, in pixels + */ + onResize(force: boolean, gutterWidth: number, width: number, height: number): void; + + /** + * Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen. + */ + adjustWrapLimit(): void; + + /** + * Identifies whether you want to have an animated scroll or not. + * @param shouldAnimate Set to `true` to show animated scrolls + */ + setAnimatedScroll(shouldAnimate: boolean): void; + + /** + * Returns whether an animated scroll happens or not. + */ + getAnimatedScroll(): boolean; + + /** + * Identifies whether you want to show invisible characters or not. + * @param showInvisibles Set to `true` to show invisibles + */ + setShowInvisibles(showInvisibles: boolean): void; + + /** + * Returns whether invisible characters are being shown or not. + */ + getShowInvisibles(): boolean; + + /** + * Identifies whether you want to show the print margin or not. + * @param showPrintMargin Set to `true` to show the print margin + */ + setShowPrintMargin(showPrintMargin: boolean): void; + + /** + * Returns whether the print margin is being shown or not. + */ + getShowPrintMargin(): boolean; + + /** + * Identifies whether you want to show the print margin column or not. + * @param showPrintMargin Set to `true` to show the print margin column + */ + setPrintMarginColumn(showPrintMargin: boolean): void; + + /** + * Returns whether the print margin column is being shown or not. + */ + getPrintMarginColumn(): boolean; + + /** + * Returns `true` if the gutter is being shown. + */ + getShowGutter(): boolean; + + /** + * Identifies whether you want to show the gutter or not. + * @param show Set to `true` to show the gutter + */ + setShowGutter(show: boolean): void; + + /** + * Returns the root element containing this renderer. + */ + getContainerElement(): HTMLElement; + + /** + * Returns the element that the mouse events are attached to + */ + getMouseEventTarget(): HTMLElement; + + /** + * Returns the element to which the hidden text area is added. + */ + getTextAreaContainer(): HTMLElement; + + /** + * [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow} + */ + getFirstVisibleRow(): number; + + /** + * Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen. + */ + getFirstFullyVisibleRow(): number; + + /** + * Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen. + */ + getLastFullyVisibleRow(): number; + + /** + * [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow} + */ + getLastVisibleRow(): number; + + /** + * Sets the padding for all the layers. + * @param padding A new padding value (in pixels) + */ + setPadding(padding: number): void; + + /** + * Returns whether the horizontal scrollbar is set to be always visible. + */ + getHScrollBarAlwaysVisible(): boolean; + + /** + * Identifies whether you want to show the horizontal scrollbar or not. + * @param alwaysVisible Set to `true` to make the horizontal scroll bar visible + */ + setHScrollBarAlwaysVisible(alwaysVisible: boolean): void; + + /** + * Schedules an update to all the front markers in the document. + */ + updateFrontMarkers(): void; + + /** + * Schedules an update to all the back markers in the document. + */ + updateBackMarkers(): void; + + /** + * Deprecated; (moved to [[EditSession]]) + */ + addGutterDecoration(): void; + + /** + * Deprecated; (moved to [[EditSession]]) + */ + removeGutterDecoration(): void; + + /** + * Redraw breakpoints. + */ + updateBreakpoints(): void; + + /** + * Sets annotations for the gutter. + * @param annotations An array containing annotations + */ + setAnnotations(annotations: any[]): void; + + /** + * Updates the cursor icon. + */ + updateCursor(): void; + + /** + * Hides the cursor icon. + */ + hideCursor(): void; + + /** + * Shows the cursor icon. + */ + showCursor(): void; + + /** + * Scrolls the cursor into the first visibile area of the editor + */ + scrollCursorIntoView(): void; + + /** + * {:EditSession.getScrollTop} + */ + getScrollTop(): number; + + /** + * {:EditSession.getScrollLeft} + */ + getScrollLeft(): number; + + /** + * Returns the first visible row, regardless of whether it's fully visible or not. + */ + getScrollTopRow(): number; + + /** + * Returns the last visible row, regardless of whether it's fully visible or not. + */ + getScrollBottomRow(): number; + + /** + * Gracefully scrolls from the top of the editor to the row indicated. + * @param row A row id + */ + scrollToRow(row: number): void; + + /** + * Gracefully scrolls the editor to the row indicated. + * @param line A line number + * @param center If `true`, centers the editor the to indicated line + * @param animate If `true` animates scrolling + * @param callback Function to be called after the animation has finished + */ + scrollToLine(line: number, center: boolean, animate: boolean, callback: Function): void; + + /** + * Scrolls the editor to the y pixel indicated. + * @param scrollTop The position to scroll to + */ + scrollToY(scrollTop: number): number; + + /** + * Scrolls the editor across the x-axis to the pixel indicated. + * @param scrollLeft The position to scroll to + */ + scrollToX(scrollLeft: number): number; + + /** + * Scrolls the editor across both x- and y-axes. + * @param deltaX The x value to scroll by + * @param deltaY The y value to scroll by + */ + scrollBy(deltaX: number, deltaY: number): void; + + /** + * Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line. + * @param deltaX The x value to scroll by + * @param deltaY The y value to scroll by + */ + isScrollableBy(deltaX: number, deltaY: number): boolean; + + /** + * Returns an object containing the `pageX` and `pageY` coordinates of the document position. + * @param row The document row position + * @param column The document column position + */ + textToScreenCoordinates(row: number, column: number): any; + + /** + * Focuses the current container. + */ + visualizeFocus(): void; + + /** + * Blurs the current container. + */ + visualizeBlur(): void; + + /** + * undefined + * @param position + */ + showComposition(position: number): void; + + /** + * Sets the inner text of the current composition to `text`. + * @param text A string of text to use + */ + setCompositionText(text: string): void; + + /** + * Hides the current composition. + */ + hideComposition(): void; + + /** + * [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme} + * @param theme The path to a theme + */ + setTheme(theme: string): void; + + /** + * [Returns the path of the current theme.]{: #VirtualRenderer.getTheme} + */ + getTheme(): string; + + /** + * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle} + * @param style A class name + */ + setStyle(style: string): void; + + /** + * [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle} + * @param style A class name + */ + unsetStyle(style: string): void; + + /** + * Destroys the text and cursor layers for this renderer. + */ + destroy(): void; + } + var VirtualRenderer: { + /** + * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`. + * @param container The root element of the editor + * @param theme The starting theme + */ + new(container: HTMLElement, theme?: string): VirtualRenderer; + }; + + export interface Completer { + /** + * Provides possible completion results asynchronously using the given callback. + * @param editor The editor to associate with + * @param session The `EditSession` to refer to + * @param pos An object containing the row and column + * @param prefix The prefixing string before the current position + * @param callback Function to provide the results or error + */ + getCompletions: ( + editor: Editor, + session: IEditSession, + pos: Position, + prefix: string, + callback: CompletionCallback, + ) => void; + + /** + * Provides tooltip information about a completion result. + * @param item The completion result + */ + getDocTooltip?: ((item: Completion) => void) | undefined; + } + + export interface Completion { + value: string; + meta: string; + type?: string | undefined; + caption?: string | undefined; + snippet?: any; + score?: number | undefined; + exactMatch?: number | undefined; + docHTML?: string | undefined; + } + + export type CompletionCallback = (error: Error | null, results: Completion[]) => void; + + //////////////////// + /// Layer + //////////////////// + + export namespace Layer { + //////////////////// + /// Cursor + //////////////////// + + export interface Cursor { + setBlinking(blinking: boolean): void; + setBlinkInterval(blinkInterval: number): void; + hideCursor(): void; + showCursor(): void; + } + } +} + +declare var ace: AceAjax.Ace; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..4481fed --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "target": "esnext", + "paths": { + "/static/*": [ + "./static/*" + ], + }, + "lib": [ + "ESNext", + "DOM" + ], + "rootDir": "./", + "baseUrl": "./", + "strictNullChecks": true, + "declaration": true, + }, + "include": [ + "./static/**/*.ts", + "./static/**/*.d.ts" + ] +} \ No newline at end of file