2
2
3
3
A high-performance API for building Shopify Functions using WebAssembly (WASM).
4
4
5
-
6
5
## Architecture
7
6
8
7
The WASM API consists of these main components:
9
8
10
- 1 . ** Core (` core/ ` )**
11
- - Low-level WASM bindings and memory management
12
- - Handles raw memory operations and string handling
13
- - Provides the foundation for the API layer
14
- - Manages direct WASM imports/exports
9
+ 1 . ** Provider (` provider/ ` )**
10
+ - Implements low-level WASM operations for:
11
+ - Memory management and allocation
12
+ - Input/output serialization
13
+ - Context lifecycle management
14
+ - Used by the API layer for high-level operations
15
+ - Integrates with trampoline for WASM module linking
16
+
17
+ 2 . ** Core (` core/ ` )**
18
+ - Defines fundamental types and interfaces
19
+ - Used by both API and provider layers
15
20
16
- 2 . ** API (` api/ ` )**
17
- - High-level interface for writing Shopify Functions
18
- - Provides the ` #[shopify_function] ` macro
19
- - Handles input/output operations with a user-friendly API
20
- - Built on top of the core package
21
+ 3 . ** API (` api/ ` )**
22
+ - High-level Rust interface for writing Shopify Functions
23
+ - Includes examples and documentation
21
24
22
- 3 . ** Trampoline (` trampoline/ ` )**
23
- - Bridges communication between your WASM module and Shopify's runtime
24
- - Handles memory sharing between guest and provider modules
25
- - Manages string operations and object property access
26
- - Creates the necessary WASM imports/exports
25
+ 4 . ** Trampoline (` trampoline/ ` )**
26
+ - Bridges communication between WASM modules
27
27
28
28
## Getting Started
29
29
@@ -32,13 +32,6 @@ The WASM API consists of these main components:
32
32
- [ Rust] ( https://www.rust-lang.org/tools/install ) (latest stable version)
33
33
- [ wasm-pack] ( https://rustwasm.github.io/wasm-pack/installer/ ) for building WebAssembly modules
34
34
35
- ### Installation
36
-
37
- Add the Shopify Function WASM API to your ` XYZ ` :
38
-
39
- ```
40
- // todo
41
- ```
42
35
43
36
### Basic Usage
44
37
@@ -59,15 +52,21 @@ fn function(context: &mut Context) -> Result<()> {
59
52
}
60
53
```
61
54
62
- The trampoline tool bridges communication between your WASM module and Shopify's runtime. You can trampoline your function by:
55
+ To build a function example, create a new example and build it targeting ` wasm32-wasi ` with ` shopify_function_wasm_api ` as the provider:
56
+
57
+ ``` shell
58
+ cargo build --release --target wasm32-wasip1 -p shopify_function_wasm_api --example echo
59
+ ```
60
+
61
+
62
+ The trampoline tool bridges communication between your WASM module and Shopify's runtime. To trampoline your function wasm:
63
63
64
64
``` shell
65
65
# Short flags
66
66
cargo run -p shopify_function_wasm_api_trampoline -- -i input.wasm -o output.wasm
67
67
```
68
68
69
-
70
- For more examples, check out the [ examples directory] ( ./api/examples/ ) .
69
+ For examples, check out the [ examples directory] ( ./api/examples/ ) .
71
70
72
71
## Documentation
73
72
0 commit comments