diff --git a/package.json b/package.json index 0109e6a..8cb6a95 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "pnpm build-wasm && astro dev", "start": "pnpm build-wasm && astro dev", - "build-wasm": "wasm-pack build --release --no-pack ./src/wasm/webcompiler -- --features wee_alloc", + "build-wasm": "wasm-pack build --release --no-pack ./src/wasm/webcompiler -- --features lol_alloc", "build": "pnpm build-wasm && astro check && astro build", "preview": "astro preview", "astro": "astro" diff --git a/src/content/docs/guides/getting-started.mdx b/src/content/docs/guides/getting-started.mdx index 64b346e..6340747 100644 --- a/src/content/docs/guides/getting-started.mdx +++ b/src/content/docs/guides/getting-started.mdx @@ -153,6 +153,6 @@ Only functions annotated with `#[tick]`, `#[load]`, `#[deobfuscate]` or called f ```bash shulkerscript build --zip ``` - This will create a ZIP archive containing the compiled project. + This will create a ZIP archive in the `dist` directory containing the compiled project. 3. You can now distribute the archive to your users. diff --git a/src/content/docs/guides/syntax.md b/src/content/docs/guides/syntax.md index 838504b..0d49f8e 100644 --- a/src/content/docs/guides/syntax.md +++ b/src/content/docs/guides/syntax.md @@ -5,7 +5,7 @@ description: Learn the syntax of Shulkerscript ## Comments Single-line comments start with `//` and continue until the end of the line. -Multiline comments start with `/*` and end with `*/`. +Multi-line comments start with `/*` and end with `*/`. ```shulkerscript // This is a single line comment @@ -33,9 +33,11 @@ Literal commands are just syntactic sugar for the [`run`](#run) keyword. ::: ## Functions +!changed[0.2.0] + Functions are blocks of code that can be executed. -They start with `fn` followed by the name of the function, parenthesis and a block of code. -Optionally they can be preceeded by annotations. When a function has the `pub` keyword in front of it, it will be accessible from other files. +They start with `fn` followed by the name of the function, [arguments](../../reference/functions/#arguments) in parentheses and a block of code. +Optionally they can be preceded by annotations. When a function has the `pub` keyword in front of it, it will be accessible from other files. ```shulkerscript title="src/main.shu" #[tick] fn main() { @@ -43,15 +45,48 @@ fn main() { } #[deobfuscate] -pub fn hello() { +pub fn hello(macro name) { /say I can be called from other files! + run `say Hello $(name)`; } ``` This code defines a function called `main` that will be executed every tick. :::note Shulkerscript always requires at least one function annotated with `tick`, `load` or `deobfuscate`. -Otherwise no `.mcfunction` files will be generated. +Otherwise, no `.mcfunction` files will be generated. +::: + +### Function calls +Functions can be called by using their name followed by parenthesis. +Arguments can be specified in the parenthesis separated by commas. +```shulkerscript +#[tick] +fn main() { + hello("World"); +} + +fn hello(macro name) { + run `say Hello, $(name)!`; +} +``` + +### Return +!since[0.2.0] + +To early end a function execution or to return a value, the `return` command was added in Minecraft 1.20. +Similarly, the `return` statement is available in Shulkerscript. + +```shulkerscript +#[deobfuscate = "returns_value"] +fn returnsValue() { + return 5; +} +``` + +:::caution[Important] +This should be always preferred over using the raw `/return` command. +Special handling is done to make returning work in combination with conditionals, groups, etc. ::: ### Annotations @@ -63,22 +98,45 @@ Currently, the following annotations are supported: - `#[deobfuscate]`: The function will keep the original name in the output (path of the `.shu`-file followed by the function name). - `#[deobfuscate = "path/to/function"]`: The function will be named as specified in the argument. -### Function calls -Functions can be called by using their name followed by parenthesis. -```shulkerscript -#[tick] -fn main() { - hello(); -} +### Provided functions +!since[0.2.0] -fn hello() { - /say Hello, world! +Shulkerscript provides some internal functions. +These can be called like user-defined functions, but have access to the compilation process and therefore greater possibilities. + +| Function | Description | +| -------- | ----------- | +| `print` | Allows to print a string or macro string to the chat. Variables in the macro string are substituted at runtime. | + +Example: + +```shulkerscript +#[load] +fn load() { + int x = 5; + print(`Value of x=$(x)`); } ``` +## Macro Strings +!since[0.2.0] + +When inside a function that has a macro as a parameter, this can be used inside strings by using the macro string format. +Instead of normal quotation marks `"`, the backtick `` ` `` is used for this type of string. +Inside a macro string, `$(MACRO NAME)` can be used to place the value of the macro at that position in the string. + +When wanting to use it in a regular command, use the run syntax. + +```shulkerscript +fn macroFunction(macro name) { + run `say Hello $(name)`; +} +``` + + ## Imports -Functions from other files can be imported by using the `from`-`import` syntax. +Functions and global variables from other files can be imported by using the `from`-`import` syntax. ```shulkerscript title="src/main.shu" namespace "foo"; @@ -108,10 +166,12 @@ from "./foo" import bar, baz; ``` ## Tags +!changed[0.2.0] + In Minecraft, tags are used to group multiple items, blocks, entities, etc. together. In Shulkerscript, tags can be defined right in the code, where they are needed. ```shulkerscript -tag "foo" of "block" [ +tag<"block"> "foo" [ "minecraft:stone", "minecraft:dirt" ] @@ -121,7 +181,7 @@ This will result in a tag of type `block` with the name `foo` containing the blo If you want the tag to replace, instead of append to the existing tag, you can use the `replace` keyword. ```shulkerscript -tag "foo" of "block" replace [ +tag<"block"> "foo" replace [ "minecraft:stone", "minecraft:dirt" ] @@ -139,12 +199,12 @@ the types: But you can also use custom types, refer to [this page](https://minecraft.wiki/w/Tag) for more information. :::tip -`of "[type]"` can be omitted and will default to `"function"`. +`<"[type]">` can be omitted and will default to `"function"`. ::: ## Conditional Statements Conditional statements are used to execute code based on a condition. -They start with `if` followed by a condition in parenthesis and a block of code. +They start with `if` followed by a condition in parentheses and a block of code. Optionally they can be followed by an `else` block. ```shulkerscript if ("block ~ ~-1 ~ minecraft:stone") { @@ -158,7 +218,7 @@ To learn more about how to combine or negate conditions, refer to the [if-else s ## Execute Blocks Execute blocks are used to execute a block of code in a specific context. -They consist of the keyword you would pass to the `/execute` command followed the argument as a string in parenthesis and a block of code. +They consist of the keyword you would pass to the `/execute` command followed the argument as a string in parentheses and a block of code. ```shulkerscript as ("@a") { // execute as all players /say Hello, world! @@ -177,7 +237,7 @@ positioned ("0 0 0"), in ("minecraft:overworld") { ``` :::tip[Did you know?] -[Conditionals](#conditional-statements) are also implemented as execute blocks.Therefore you can chain them together with other execute blocks. Keep in mind that an if-else statement can only be used as the last execute block in a chain. +[Conditionals](#conditional-statements) are also implemented as execute blocks. Therefore, you can chain them together with other execute blocks. Keep in mind that an if-else statement can only be used as the last execute block in a chain. ::: ### Supported Execute Blocks @@ -212,6 +272,36 @@ group { } ``` +## Variables +!since[0.2.0] + +Variables can be used to store values. +There are different types available, and they differ in how they are stored, +what data can be stored in them and how they can be used. + +| Keyword | Storage method | Usage | +| ------- | --------------- | ----- | +| `int` | Scoreboard | Single integer values | +| `bool` | Data Storage | Single boolean values | +| `val` | Compiler memory | Can store any data type, but has to be known at compile time | +| `int[NUMBER]` | Scoreboard | Array of `NUMBER` integers | +| `bool[NUMBER]` | Data Storage | Array of `NUMBER` booleans | +| `int[]` | Scoreboard | Map of integers | +| `bool[]` | Entity tag | Map of booleans (keys have to be valid entities in the world) | + +```shulkerscript +int x = 5; +bool y = true; + +int z = x + 2; + +int[2] arr; +arr[0] = 1; +arr[1] = 2; +``` + +Read more in the [reference](../../reference/variables). + ## Run The `run` keyword is used to evaluate the following expression and include the resulting command in the output. ```shulkerscript diff --git a/src/wasm/webcompiler/Cargo.lock b/src/wasm/webcompiler/Cargo.lock index b86eb20..71a5301 100644 --- a/src/wasm/webcompiler/Cargo.lock +++ b/src/wasm/webcompiler/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "adler2" @@ -19,9 +19,9 @@ dependencies = [ [[package]] name = "ansi-to-html" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d73c455ae09fa2223a75114789f30ad605e9e297f79537953523366c05995f5f" +checksum = "12e283a4fc285735ef99577e81a125f738429516161ac33977e466d0d8d40764" dependencies = [ "regex", "thiserror", @@ -29,19 +29,25 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100" [[package]] name = "arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" dependencies = [ "derive_arbitrary", ] +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "base64" version = "0.22.1" @@ -56,15 +62,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "cfg-if" -version = "0.1.10" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" [[package]] name = "chksum-core" @@ -112,13 +112,22 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "colored" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" +dependencies = [ + "windows-sys", +] + [[package]] name = "console_error_panic_hook" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "wasm-bindgen", ] @@ -128,20 +137,14 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - [[package]] name = "derive_arbitrary" -version = "1.3.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67e77553c4162a157adbf834ebae5b415acbecbeafc7a74b0e886657506a7611" +checksum = "30542c1ad912e0e3d22a1935c290e12e8a29d704a420177a31faad4a601a0800" dependencies = [ "proc-macro2", "quote", @@ -168,17 +171,6 @@ dependencies = [ "syn", ] -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "either" version = "1.13.0" @@ -205,11 +197,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "flate2" -version = "1.0.34" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" dependencies = [ "crc32fast", + "libz-rs-sys", "miniz_oxide", ] @@ -278,10 +271,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] -name = "libc" -version = "0.2.159" +name = "libz-rs-sys" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "172a788537a2221661b480fee8dc5f96c580eb34fa88764d3205dc356c7e4221" +dependencies = [ + "zlib-rs", +] + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] [[package]] name = "lockfree-object-pool" @@ -295,23 +301,26 @@ version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +[[package]] +name = "lol_alloc" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e5106554cabc97552dcadf54f57560ae6af3276652f82ca2be06120dc4c5dc" +dependencies = [ + "spin", +] + [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - [[package]] name = "miniz_oxide" -version = "0.8.0" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" dependencies = [ "adler2", ] @@ -443,10 +452,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" [[package]] -name = "serde" -version = "1.0.210" +name = "scopeguard" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] @@ -464,9 +479,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", @@ -487,9 +502,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.8" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +checksum = "40734c41988f7306bb04f0ecf60ec0f3f1caa34290e4e8ea471dcd3346483b83" dependencies = [ "serde", ] @@ -514,7 +529,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1546b5164f154cb0ecb5b676d0f1beeb46b9417b785b2bc43b8e2d07caab01eb" dependencies = [ "chksum-md5", - "colored", + "colored 2.1.0", "derive_more", "enum-as-inner", "getset", @@ -536,6 +551,15 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + [[package]] name = "strsim" version = "0.11.1" @@ -566,9 +590,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -597,38 +621,43 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.19" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.22.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", + "toml_parser", + "toml_writer", "winnow", ] +[[package]] +name = "toml_datetime" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bade1c3e902f58d73d3f294cd7f20391c1cb2fbcb643b73566bc773971df91e3" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_parser" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc842091f2def52017664b53082ecbbeb5c7731092bad69d2c63050401dfd64" + [[package]] name = "tracing" version = "0.1.40" @@ -668,24 +697,24 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "once_cell", + "rustversion", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", "syn", @@ -694,9 +723,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -704,9 +733,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", @@ -717,9 +746,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] [[package]] name = "webcompiler" @@ -728,52 +760,18 @@ dependencies = [ "ansi-to-html", "anyhow", "base64", - "cfg-if 1.0.0", - "colored", + "cfg-if", + "colored 3.0.0", "console_error_panic_hook", + "lol_alloc", "serde", "serde-wasm-bindgen", "shulkerscript", "toml", "wasm-bindgen", - "wee_alloc", "zip", ] -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if 0.1.10", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.48.0" @@ -842,30 +840,30 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.6.20" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" -dependencies = [ - "memchr", -] +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" [[package]] name = "zip" -version = "2.2.0" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc5e4288ea4057ae23afc69a4472434a87a2495cafce6632fd1c4ec9f5cf3494" +checksum = "9aed4ac33e8eb078c89e6cbb1d5c4c7703ec6d299fc3e7c3695af8f8b423468b" dependencies = [ "arbitrary", "crc32fast", - "crossbeam-utils", - "displaydoc", "flate2", "indexmap", "memchr", - "thiserror", "zopfli", ] +[[package]] +name = "zlib-rs" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a" + [[package]] name = "zopfli" version = "0.8.1" diff --git a/src/wasm/webcompiler/Cargo.toml b/src/wasm/webcompiler/Cargo.toml index c78a348..578225f 100644 --- a/src/wasm/webcompiler/Cargo.toml +++ b/src/wasm/webcompiler/Cargo.toml @@ -10,21 +10,24 @@ crate-type = ["cdylib"] opt-level = "z" [features] -wee_alloc = ["dep:wee_alloc"] +lol_alloc = ["dep:lol_alloc"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ansi-to-html = "0.2.1" -anyhow = "1.0.86" +ansi-to-html = "0.2.2" +anyhow = "1.0.99" base64 = "0.22.1" -cfg-if = "1.0.0" -colored = "2.1.0" +cfg-if = "1.0.1" +colored = "3.0.0" console_error_panic_hook = "0.1.7" -serde = "1.0" +lol_alloc = { version = "0.4.1", optional = true } +serde = "1.0.219" serde-wasm-bindgen = "0.6.5" shulkerscript = { version = "0.1.0", default-features = false, features = ["serde", "shulkerbox"] } -toml = "0.8.19" -wasm-bindgen = "0.2.93" -wee_alloc = { version = "0.4.5", optional = true } -zip = { version = "2.1.3", default-features = false, features = ["deflate"] } +toml = "0.9.5" +wasm-bindgen = "0.2.100" +zip = { version = "4.3.0", default-features = false, features = ["deflate"] } + +[package.metadata.wasm-pack.profile.release] +wasm-opt = false \ No newline at end of file diff --git a/src/wasm/webcompiler/src/lib.rs b/src/wasm/webcompiler/src/lib.rs index b2117a4..d6e2418 100644 --- a/src/wasm/webcompiler/src/lib.rs +++ b/src/wasm/webcompiler/src/lib.rs @@ -19,9 +19,9 @@ mod fs; mod pack_toml; cfg_if::cfg_if! { - if #[cfg(feature = "wee_alloc")] { + if #[cfg(feature = "lol_alloc")] { #[global_allocator] - static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; + static ALLOC: lol_alloc::LockedAllocator = lol_alloc::LockedAllocator::new(lol_alloc::FreeListAllocator::new()); } }