Skip to content

Commit 51ee8ad

Browse files
committed
Add fula-js WASM SDK and update workflows for npm package
Introduces the new fula-js crate providing high-level JavaScript/TypeScript APIs for Fula decentralized storage via WASM bindings. Updates GitHub Actions workflows to build, test, and verify the npm package, and bumps all workspace and package versions to 0.2.10. Changelog, podspec, and pubspec are updated to reflect the new release and features.
1 parent ee53ee8 commit 51ee8ad

File tree

10 files changed

+741
-25
lines changed

10 files changed

+741
-25
lines changed

.github/workflows/flutter-ci.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [main]
66
paths:
77
- 'crates/fula-flutter/**'
8+
- 'crates/fula-js/**'
89
- 'crates/fula-client/**'
910
- 'crates/fula-crypto/**'
1011
- 'packages/fula_client/**'
@@ -13,6 +14,7 @@ on:
1314
pull_request:
1415
paths:
1516
- 'crates/fula-flutter/**'
17+
- 'crates/fula-js/**'
1618
- 'crates/fula-client/**'
1719
- 'crates/fula-crypto/**'
1820
- 'packages/fula_client/**'
@@ -41,10 +43,11 @@ jobs:
4143
- name: Run Rust tests
4244
run: |
4345
cargo test -p fula-flutter --lib
46+
cargo test -p fula-js --lib
4447
cargo test -p fula-client --lib
4548
cargo test -p fula-crypto --lib
4649
47-
# Test WASM compilation
50+
# Test WASM compilation (fula-js npm package)
4851
test-wasm:
4952
runs-on: ubuntu-latest
5053
steps:
@@ -60,8 +63,21 @@ jobs:
6063
with:
6164
shared-key: rust-wasm
6265

63-
- name: Build WASM
64-
run: cargo build -p fula-flutter --target wasm32-unknown-unknown --release
66+
- name: Install wasm-pack
67+
run: cargo install wasm-pack
68+
69+
- name: Build WASM (fula-js)
70+
run: |
71+
cd crates/fula-js
72+
wasm-pack build --release --target web
73+
74+
- name: Verify WASM package exports
75+
run: |
76+
echo "Checking TypeScript definitions..."
77+
grep -q "createEncryptedClient" crates/fula-js/pkg/fula_js.d.ts
78+
grep -q "getDecrypted" crates/fula-js/pkg/fula_js.d.ts
79+
grep -q "deriveKey" crates/fula-js/pkg/fula_js.d.ts
80+
echo "All expected exports found!"
6581
6682
# Generate and validate Dart bindings
6783
generate-bindings:

.github/workflows/flutter-release.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ jobs:
209209
path: ios-libs/
210210
retention-days: 1
211211

212-
# Build WASM package
212+
# Build WASM package (fula-js with high-level wasm-bindgen APIs)
213213
build-wasm:
214214
needs: get-version
215215
runs-on: ubuntu-latest
@@ -229,29 +229,32 @@ jobs:
229229
- name: Install wasm-pack
230230
run: cargo install wasm-pack
231231

232-
- name: Build WASM
232+
- name: Build WASM (fula-js)
233233
run: |
234-
cd crates/fula-flutter
234+
cd crates/fula-js
235235
wasm-pack build --release --target web --out-dir ../../wasm-package
236236
237-
- name: Create npm package.json
237+
- name: Update package.json with version
238238
run: |
239239
cd wasm-package
240+
# Update version from tag and ensure correct package name
240241
cat > package.json << INNEREOF
241242
{
242243
"name": "@functionland/fula-client",
243244
"version": "${{ needs.get-version.outputs.version }}",
244-
"description": "Fula encrypted storage SDK for JavaScript/WASM",
245-
"main": "fula_flutter.js",
246-
"types": "fula_flutter.d.ts",
247-
"files": ["*.js", "*.wasm", "*.d.ts", "snippets/**"],
245+
"type": "module",
246+
"description": "JavaScript/TypeScript SDK for Fula decentralized storage - client-side encryption with cross-platform key compatibility",
247+
"main": "fula_js.js",
248+
"types": "fula_js.d.ts",
249+
"files": ["fula_js_bg.wasm", "fula_js.js", "fula_js.d.ts"],
248250
"repository": {
249251
"type": "git",
250252
"url": "https://github.com/functionland/fula-api"
251253
},
252-
"keywords": ["fula", "storage", "encryption", "wasm", "decentralized"],
253-
"author": "Functionland",
254-
"license": "Apache-2.0"
254+
"homepage": "https://github.com/functionland/fula-api#readme",
255+
"keywords": ["fula", "ipfs", "decentralized", "storage", "encryption", "wasm", "web3"],
256+
"author": "Functionland <[email protected]>",
257+
"license": "MIT OR Apache-2.0"
255258
}
256259
INNEREOF
257260

Cargo.lock

Lines changed: 39 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"crates/fula-cli",
88
"crates/fula-client",
99
"crates/fula-flutter",
10+
"crates/fula-js",
1011
]
1112

1213
# Root package for examples
@@ -73,7 +74,7 @@ name = "encrypted_upload_test"
7374
path = "examples/encrypted_upload_test.rs"
7475

7576
[workspace.package]
76-
version = "0.1.0"
77+
version = "0.2.10"
7778
edition = "2021"
7879
license = "MIT OR Apache-2.0"
7980
repository = "https://github.com/functionland/fula-api"

crates/fula-js/Cargo.toml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[package]
2+
name = "fula-js"
3+
description = "JavaScript/TypeScript SDK for Fula decentralized storage - WASM bindings"
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
repository.workspace = true
8+
authors.workspace = true
9+
rust-version.workspace = true
10+
11+
[package.metadata.wasm-pack.profile.release]
12+
wasm-opt = false
13+
14+
[lib]
15+
crate-type = ["cdylib", "rlib"]
16+
17+
[dependencies]
18+
# Internal crates (WASM-compatible configuration)
19+
fula-client = { path = "../fula-client" }
20+
fula-crypto = { path = "../fula-crypto", default-features = false, features = ["wasm"] }
21+
22+
# WASM bindings
23+
wasm-bindgen = "0.2"
24+
wasm-bindgen-futures = "0.4"
25+
js-sys = "0.3"
26+
27+
# Serialization for JS interop
28+
serde = { workspace = true }
29+
serde_json = { workspace = true }
30+
serde-wasm-bindgen = "0.6"
31+
32+
# Error handling
33+
console_error_panic_hook = "0.1"
34+
35+
# Random number generation for WASM
36+
getrandom = { version = "0.2", features = ["js"] }
37+
38+
# Utilities
39+
bytes = { workspace = true }
40+
base64 = { workspace = true }
41+
42+
# Async (WASM-compatible)
43+
futures = { workspace = true }
44+
45+
[dependencies.web-sys]
46+
version = "0.3"
47+
features = ["console"]
48+
49+
[dev-dependencies]
50+
wasm-bindgen-test = "0.3"

0 commit comments

Comments
 (0)