-
Notifications
You must be signed in to change notification settings - Fork 1
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 #55 from polywrap/develop
Release 0.4.3
- Loading branch information
Showing
55 changed files
with
9,206 additions
and
114 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
# PWR App Examples | ||
|
||
- [Simple PWR App](../examples/simple-pwr-app/README.md) | ||
- [Simple Storage App](../examples/simple-storage-app/README.md) | ||
- [HTTP Server App](../examples/http-server-app/README.md) | ||
- [Advanced HTTP Server App](../examples/app-with-ui/README.md) | ||
- [PWR App with UI](../examples/app-with-ui/README.md) |
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,57 @@ | ||
# Example PWR CLI usage: | ||
|
||
## Migration | ||
After running `pwrup`, you have to run `pwr migrate` to migrate your configuration to the latest version. | ||
|
||
## Running pwr apps | ||
|
||
### From wrapscan.io | ||
To run a pwr app from wrapscan.io, run: | ||
```bash | ||
pwr wrapscan.io/pwr/say-hello | ||
``` | ||
|
||
### From wrappers.dev | ||
To run a pwr app from wrappers.dev, run: | ||
```bash | ||
pwr @pwr/say-hello | ||
``` | ||
```bash | ||
pwr https/wrappers.dev/u/pwr/say-hello | ||
``` | ||
|
||
### Local directory | ||
To run a pwr app from a local directory (e.g. `./build`), run: | ||
```bash | ||
pwr ./build | ||
``` | ||
```bash | ||
pwr fs/build | ||
``` | ||
|
||
### From IPFS | ||
To run a pwr app from IPFS, run: | ||
```bash | ||
pwr ipfs/Qm... | ||
``` | ||
```bash | ||
pwr Qm... | ||
``` | ||
```bash | ||
pwr ipfs://Qm... | ||
``` | ||
|
||
### From ENS | ||
To run a pwr app from ENS, run: | ||
```bash | ||
pwr ens/say-hello.eth | ||
``` | ||
```bash | ||
pwr say-hello.eth | ||
``` | ||
|
||
## Passing arguments to pwr apps | ||
To pass arguments to a pwr app add them after the WRAP URI, e.g.: | ||
```bash | ||
pwr ./build arg1 arg2 | ||
``` |
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,36 @@ | ||
# Script WRAPS (JS and Python) | ||
{lang} = js | py | ||
|
||
### REPL | ||
`pwr {lang} repl` | ||
Runs a REPL where you can type scripts. | ||
|
||
`pwr {lang} repl -f {name_of_file}` | ||
Runs the repl over a file. | ||
It will read and execute the file first (and create it if it doesn't exist). | ||
It will also store all CLI commands you type inside of it (after evaluating them). | ||
Press enter in the CLI to re-run the whole file (useful if you want to code in the file instead of the CLI). | ||
|
||
`pwr {lang} repl -f {name_of_file} -w` | ||
It will read and execute the file first (and create it if it doesn't exist). | ||
Then it will execute the file every time you save it. | ||
It will not listen to CLI input if you use this option ("-w"). | ||
|
||
### New | ||
`pwr {lang} new -f {name_of_file}` | ||
Creates a new file of the specified name for the script wrap. | ||
It uses a template for that language. | ||
|
||
### Build | ||
`pwr {lang} build -f {name_of_file}` | ||
Builds the target script file. | ||
|
||
### Deploy | ||
`pwr deploy` | ||
Deploys the build directory. | ||
|
||
`pwr {lang} deploy` | ||
Deploys the build directory. (Same as `pwr deploy`) | ||
|
||
`pwr {lang} deploy -f {name_of_file}` | ||
Builds and then deploys the script file. |
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 @@ | ||
!src/wrap |
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 @@ | ||
v16.13.0 |
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,22 @@ | ||
[package] | ||
name = "app_with_ui" | ||
version = "0.1.0" | ||
description = "An example of a PWR HTTP server application with UI" | ||
|
||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
polywrap_msgpack_serde.workspace = true | ||
polywrap-wasm-rs.workspace = true | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_bytes.workspace = true | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[profile.release] | ||
opt-level = 's' | ||
lto = true | ||
panic = 'abort' |
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,2 @@ | ||
# App with UI | ||
An example of a PWR HTTP server application with UI |
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,61 @@ | ||
#!/./bin/sh | ||
set -x | ||
set -e | ||
# Install the wasm32 rust build target | ||
rustup target add wasm32-unknown-unknown | ||
|
||
# Install the toml-cli | ||
cargo install toml-cli | ||
|
||
# Install wasm-snip | ||
cargo install wasm-snip | ||
|
||
# Install wasm-bindgen | ||
cargo install wasm-bindgen-cli | ||
|
||
# Install wasm-tools | ||
cargo install wasm-tools | ||
|
||
cargo install wasm-opt | ||
|
||
# Ensure the module at {{dir}} has the crate-type = ["cdylib"] | ||
# toml set ./Cargo.toml lib.crate-type ["cdylib"] > ./Cargo-local.toml && \ | ||
# mv ./Cargo.toml ./Cargo-bak.toml && \ | ||
# mv ./Cargo-local.toml ./Cargo.toml | ||
|
||
# Clean up artifacts left by the toml CLI program ("["cdylib"]" -> ["cdylib"]) | ||
# sed -i .bak 's/"\[cdylib\]"/\["cdylib"\]/g' ./Cargo.toml && \ | ||
# rm -rf ./Cargo.toml.bak | ||
|
||
# # Ensure the package name = "module" | ||
# toml set ./Cargo.toml package.name "module" > ./Cargo-local.toml && \ | ||
# rm -rf ./Cargo.toml && \ | ||
# mv ./Cargo-local.toml ./Cargo.toml | ||
|
||
# Ensure the Wasm module is configured to use imported memory | ||
export RUSTFLAGS="-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory" | ||
|
||
# Build the module | ||
cargo build --manifest-path Cargo.toml \ | ||
--target wasm32-unknown-unknown --release | ||
|
||
# Enable the "WASM_INTERFACE_TYPES" feature, which will remove the __wbindgen_throw import. | ||
# See: https://github.com/rustwasm/wasm-bindgen/blob/7f4663b70bd492278bf0e7bba4eeddb3d840c868/crates/cli-support/src/lib.rs#L397-L403 | ||
export WASM_INTERFACE_TYPES=1 | ||
|
||
# Run wasm-bindgen over the module, replacing all placeholder __wbindgen_... imports | ||
wasm-bindgen ../../target/wasm32-unknown-unknown/release/app_with_ui.wasm --out-dir ./bin --out-name bg_module.wasm | ||
|
||
# Run wasm-tools strip to remove the wasm-interface-types custom section | ||
wasm-tools strip ./bin/bg_module.wasm -d wasm-interface-types -o ./bin/strip_module.wasm | ||
rm -rf ./bin/bg_module.wasm | ||
|
||
# Run wasm-snip to trip down the size of the binary, removing any dead code | ||
wasm-snip ./bin/strip_module.wasm -o ./bin/snipped_module.wasm | ||
rm -rf ./bin/strip_module.wasm | ||
|
||
# Use wasm-opt to perform the "asyncify" post-processing step over all modules | ||
export ASYNCIFY_STACK_SIZE=65535 | ||
wasm-opt --asyncify -Os ./bin/snipped_module.wasm -o ./bin/wrap.wasm | ||
rm -rf ./bin/snipped_module.wasm | ||
cp ./bin/wrap.wasm ./build/wrap.wasm |
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,16 @@ | ||
{ | ||
"private": true, | ||
"scripts": { | ||
"codegen": "npx polywrap codegen", | ||
"compile": "./build.sh", | ||
"build": "yarn codegen && yarn compile", | ||
"deploy": "pwr deploy" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "26.0.8", | ||
"jest": "26.6.3", | ||
"polywrap": "0.11.2", | ||
"ts-jest": "26.5.4", | ||
"typescript": "4.9.5" | ||
} | ||
} |
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,5 @@ | ||
format: 0.1.0 | ||
description: An example of a PWR HTTP server application with UI | ||
website: https://polywrap.io | ||
repository: https://github.com/polywrap/pwr | ||
readme: ./README.md |
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,9 @@ | ||
#import { Module, Response, KeyValuePair, Request } into HttpServer from "wrap://https/http.wrappers.dev/u/test/http-server" | ||
#import { Module, KeyValuePair } into KeyValueStore from "wrap://https/http.wrappers.dev/u/test/key-value-store" | ||
#import * into InvocationContext from "https/http.wrappers.dev/u/test/invocation-context" | ||
|
||
type Module { | ||
main(args: [String!]!): Int32! | ||
onStart: Boolean! | ||
routeHome(request: HttpServer_Request!): HttpServer_Response! | ||
} |
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,9 @@ | ||
format: 0.4.0 | ||
project: | ||
name: app-with-ui | ||
type: wasm/rust | ||
source: | ||
module: ./Cargo.toml | ||
schema: ./polywrap.graphql | ||
extensions: | ||
docs: ./polywrap.docs.yaml |
Oops, something went wrong.