Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/build-test-wasm/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ runs:
wasm-pack build --target nodejs ./crates/${{ inputs.crate }} --out-dir ../../prebuilds/${{ inputs.crate }}
shell: bash
- name: Test WASM
run: node test_wasm.js
run: node test_wasm.js ${{ inputs.crate }}
shell: bash
- uses: actions/upload-artifact@v4
with:
name: prebuilds-wasm
name: prebuilds-wasm-${{ inputs.crate }}
if-no-files-found: ignore
path: ./prebuilds/*
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
matrix:
crate:
- library_config
- datadog-js-zstd
steps:
- uses: actions/checkout@v4
- name: 'Use composite action'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
matrix:
crate:
- library_config
- datadog-js-zstd
steps:
- uses: actions/checkout@v4
- name: 'Use composite action'
Expand Down
137 changes: 95 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions crates/datadog-js-zstd/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "datadog-js-zstd"
version = "0.1.0"
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
wasm-bindgen = "0.2.100"
zstd = "0.13.3"
js-sys = "0.3.77"

[dev-dependencies]
wasm-bindgen-test = "0.3.50"
12 changes: 12 additions & 0 deletions crates/datadog-js-zstd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use wasm_bindgen::prelude::*;
use js_sys::Uint8Array;

#[wasm_bindgen]
pub fn zstd_compress(
data: Uint8Array,
level: i32,
) -> Uint8Array {
let vecdata = data.to_vec();
let compressed_data = zstd::encode_all(&vecdata[..], level).expect("Failed to compress data");
Uint8Array::from(compressed_data.as_slice())
}
11 changes: 7 additions & 4 deletions crates/library_config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
[package]
name = "library-config"
version = "0.1.0"
version = "0.2.0"
edition = "2018"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = "1"
datadog-library-config = { git = "https://github.com/DataDog/libdatadog.git", tag = "v16.0.3" }
datadog-library-config = { git = "https://github.com/DataDog/libdatadog.git", tag = "v18.1.0" }

wasm-bindgen = "0.2.84"
wasm-bindgen = "0.2.100"
serde = { version = "1.0", features = ["derive"] }
serde-wasm-bindgen = "0.4"

[dev-dependencies]
wasm-bindgen-test = "0.3.34"
wasm-bindgen-test = "0.3.50"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
2 changes: 1 addition & 1 deletion crates/library_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl JsConfigurator {
let config_entries: Vec<ConfigEntry> = config
.into_iter()
.map(|c| ConfigEntry {
name: c.name.to_str().into(),
name: c.name.to_string().into(),
value: c.value,
source: c.source.to_str().into(),
config_id: c.config_id.unwrap_or_default(),
Expand Down
2 changes: 1 addition & 1 deletion load.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function findWASM (name) {
const prebuilds = path.join(root, 'prebuilds')
const folders = readdirSync(prebuilds)
if (folders.find(f => f === name)) {
return path.join(prebuilds, name, `${name}.js`)
return path.join(prebuilds, name, `${name.replaceAll('-', '_')}.js`)
}
}

Expand Down
Loading
Loading