-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from superwall/develop
WASM support & Android publishing
- Loading branch information
Showing
24 changed files
with
21,896 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
echo "0% - Building for WASM(browser,node):" | ||
cargo build --lib --release --target wasm32-unknown-unknown | ||
echo " 25% - WASM build successful ✅" | ||
echo " 25% - Ensuring WASM wrapper is built" | ||
cd wasm | ||
cargo build --lib --release --target wasm32-unknown-unknown | ||
echo "50% - WASM wrapper build successful ✅" | ||
|
||
echo "50% - Building JS bundles" | ||
mkdir -p ./target/browser | ||
mkdir -p ./target/node | ||
npm run build | ||
|
||
echo "75% - Build done - ✅" | ||
echo "75% - Installing to example project" | ||
cd example/browser/ | ||
npm install ../../target/browser | ||
|
||
echo "100% - Done - ✅" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[bindings.kotlin] | ||
package_name = 'com.superwall.supercel' | ||
android = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[package] | ||
name = "supercel-wasm" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
cel-eval = { path = ".." } | ||
wasm-bindgen = "0.2.93" | ||
wasm-bindgen-futures = "0.4.43" | ||
futures = "0.3.30" | ||
console_error_panic_hook = "0.1.7" | ||
|
||
[profile.release] | ||
lto = true | ||
opt-level = "z" # Optimize for size. | ||
codegen-units = 1 | ||
panic = "abort" | ||
strip=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Supercel WASM Module | ||
|
||
This project demonstrates how to use WebAssembly (WASM) with Rust and JavaScript to create a dynamic expression evaluator. The evaluator can call host environment functions and compute dynamic properties. | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
- [Node.js](https://nodejs.org/) | ||
- [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) | ||
- [Cargo & Rust](https://www.rust-lang.org/tools/install) | ||
- [wasm-pack](https://github.com/rustwasm/wasm-pack/) | ||
|
||
|
||
### Setup | ||
- Install the prerequisites | ||
- Run `rustup target add wasm32-unknown-unknown` to add the WASM target | ||
|
||
### Building the Project | ||
|
||
To build the project, you need to: | ||
|
||
- Run `./build_wasm.sh` | ||
|
||
**OR** | ||
|
||
- Build the WASM project for the first time: `cargo build --lib --target wasm32-unknown-unknown` | ||
|
||
Then use: | ||
```bash | ||
npm run build | ||
``` | ||
|
||
This will generate targets in the `.target/` directory | ||
* `./target/browser` for browser environments | ||
* `./target/node` for Node.js environments | ||
|
||
|
||
### Running the Project | ||
|
||
For **browsers**: | ||
|
||
- Open `./example/browser/` and run `npm install ../../target/browser && npm run start` | ||
|
||
For **node**: | ||
- Open `./example/` and run `node test_node.js` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
|
||
|
||
## Setup | ||
|
||
- Run `./build_wasm.sh` to build the wasm module. | ||
- Run `npm install ../../target/browser` to install the dependencies. | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
|
||
### `npm start` | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in your browser. | ||
|
||
The page will reload when you make changes.\ | ||
You may also see any lint errors in the console. | ||
|
||
### `npm test` | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
|
||
### `npm run build` | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `npm run eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can't go back!** | ||
|
||
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. | ||
|
||
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. |
Oops, something went wrong.