[tasks.build]
clear = true
dependencies = ["pack_build", "pack_rename", "pack_add_keywords"]

[tasks.build_parallel]
clear = true
dependencies = [
    "pack_build_parallel",
    "pack_rename_parallel",
    "pack_add_keywords",
]

[tasks.build_utils]
clear = true
dependencies = ["pack_build_utils", "pack_rename_utils", "pack_add_keywords"]

[tasks.pack_build]
command = "wasm-pack"
args = ["build", "--release", "--target", "web", "--scope", "waku"]

[tasks.pack_rename]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_build_parallel]
command = "env"
args = [
    "CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS=-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--shared-memory -C link-arg=--max-memory=1073741824 -C link-arg=--import-memory -C link-arg=--export=__wasm_init_tls -C link-arg=--export=__tls_size -C link-arg=--export=__tls_align -C link-arg=--export=__tls_base",
    "rustup",
    "run",
    "nightly",
    "wasm-pack",
    "build",
    "--release",
    "--target",
    "web",
    "--scope",
    "waku",
    "--features",
    "parallel",
    "-Z",
    "build-std=panic_abort,std",
]

[tasks.pack_rename_parallel]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm-parallel/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_build_utils]
command = "wasm-pack"
args = [
    "build",
    "--release",
    "--target",
    "web",
    "--scope",
    "waku",
    "--no-default-features",
    "--features",
    "utils",
]

[tasks.pack_rename_utils]
script = "sed -i.bak 's/rln-wasm/zerokit-rln-wasm-utils/g' pkg/package.json && rm pkg/package.json.bak"

[tasks.pack_add_keywords]
script = """
  jq '. + {keywords: ["zerokit", "rln", "wasm"]}' pkg/package.json > pkg/package.json.tmp && \
  mv pkg/package.json.tmp pkg/package.json
"""

[tasks.test]
command = "wasm-pack"
args = [
    "test",
    "--release",
    "--node",
    "--target",
    "wasm32-unknown-unknown",
    "--",
    "--nocapture",
]
dependencies = ["build"]

[tasks.test_browser]
command = "wasm-pack"
args = [
    "test",
    "--release",
    "--chrome",
    "--headless",
    "--target",
    "wasm32-unknown-unknown",
    "--",
    "--nocapture",
]
dependencies = ["build"]

[tasks.test_parallel]
command = "env"
args = [
    "CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS=-C target-feature=+atomics,+bulk-memory,+mutable-globals -C link-arg=--shared-memory -C link-arg=--max-memory=1073741824 -C link-arg=--import-memory -C link-arg=--export=__wasm_init_tls -C link-arg=--export=__tls_size -C link-arg=--export=__tls_align -C link-arg=--export=__tls_base",
    "rustup",
    "run",
    "nightly",
    "wasm-pack",
    "test",
    "--release",
    "--chrome",
    "--headless",
    "--target",
    "wasm32-unknown-unknown",
    "--features",
    "parallel",
    "-Z",
    "build-std=panic_abort,std",
    "--",
    "--nocapture",
]
dependencies = ["build_parallel"]

[tasks.test_utils]
command = "wasm-pack"
args = [
    "test",
    "--release",
    "--node",
    "--target",
    "wasm32-unknown-unknown",
    "--no-default-features",
    "--features",
    "utils",
    "--",
    "--nocapture",
]
dependencies = ["build_utils"]

[tasks.bench]
disabled = true
