Skip to content

Commit

Permalink
new: proto PDK for JavaScript & TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Phault committed May 7, 2024
1 parent 6189708 commit 46c975f
Show file tree
Hide file tree
Showing 58 changed files with 4,330 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/codegen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fn main() {

generator
.generate(
PathBuf::from("package/src/api-types.ts"),
PathBuf::from("package/src/internal/raw-api-types.ts"),
TypeScriptRenderer::default(),
)
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
11 changes: 11 additions & 0 deletions package/.prototools
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node = "20.12.1"
npm = "10.5.0"
extism-js = "1.0.0-rc9"

[plugins]
extism-js = "source:./extism-js.toml"

# TODO: add a binaryen plugin - requires a more fine grain version interpolation though

# silly workaround for root .prototools potentially pointing at non-existing plugin
wasm-test = "source:./extism-js.toml"
26 changes: 26 additions & 0 deletions package/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing to @moonrepo/proto-pdk

## Prerequisites

Everything except [binaryen](https://github.com/WebAssembly/binaryen) is currently
managed via the .prototools.

## Building

```shell
npm run build
```

## Testing

```shell
# run tests and watch for changes
npm test

# run tests and exit
npm test run
```

## E2E tests

Refer to [the test plugin](./test/README.md).
37 changes: 37 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# @moonrepo/proto-pdk

A plugin development kit for creating proto WASM plugins using JS/TS.

> [!IMPORTANT]
> The Extism JavaScript PDK does not currently provide filesystem APIs, hence
> some functionality, such as custom checksumming, is difficult to achieve using
> this PDK.
>
> If you need this you're better off using the [Rust PDK](../crates/pdk) for now.
## Prerequisites

You will need:

- [binaryen >=v117](https://github.com/WebAssembly/binaryen)
- [extism-js >=v1.0.0-rc9](https://github.com/extism/js-pdk)

## Installation

Not yet published, please check back later.

<!--
```shell
npm i @moonrepo/proto-pdk
```
-->

## Usage

[The test plugin](./test) is currently the best reference for a complete TypeScript-based example,
until we get the PDK properly documented.

Neither TypeScript or ESBuild is a requirement. A bundler (like ESBuild) is however, and the bundled output
should target at ES2020 or below, while using CommonJS as the format.

It is strongly recommended to minify your bundled JavaScript, as it greatly affects the final WASM file size.
24 changes: 24 additions & 0 deletions package/extism-js.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name = "extism-js"
type = "cli"

[resolve]
git-url = "https://github.com/extism/js-pdk"

[platform.linux]
archs = ["x86_64", "aarch64"]
download-file = "extism-js-{arch}-linux-v{version}.gz"
checksum-file = "extism-js-{arch}-linux-v{version}.gz.sha256"
bin-path = "extism-js-{arch}-linux-v{version}"

[platform.macos]
archs = ["x86_64", "aarch64"]
download-file = "extism-js-{arch}-macos-v{version}.gz"
checksum-file = "extism-js-{arch}-macos-v{version}.gz.sha256"
bin-path = "extism-js-{arch}-macos-v{version}"

[platform.windows]
archs = []

[install]
download-url = "https://github.com/extism/js-pdk/releases/download/v{version}/{download_file}"
checksum-url = "https://github.com/extism/js-pdk/releases/download/v{version}/{checksum_file}"
Loading

0 comments on commit 46c975f

Please sign in to comment.