-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS SDK Beta #1
Merged
Merged
JS SDK Beta #1
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
aa35788
feat: bring code over from extism/browser
mhmd-azeez 67b1cd7
broken
mhmd-azeez e36bc5c
broken
mhmd-azeez 978f6e0
nodejs is working
mhmd-azeez 26960c2
browser works too
mhmd-azeez 7fadb19
bring back PluginOptions, cleanup
mhmd-azeez 4a1013a
more cleanup
mhmd-azeez f3d9c2f
make deno work too
mhmd-azeez 9a9c6b6
add deno to build command
mhmd-azeez d7bda3a
moar cleanup
mhmd-azeez fe2c1cb
moar cleanup x2
mhmd-azeez 182e537
remove old index.html
mhmd-azeez fa5f394
docs: add bun example
mhmd-azeez 358e022
use iife pattern for browser
mhmd-azeez 795b565
we don't bundle deno
mhmd-azeez ed7e555
moar cleanup
mhmd-azeez 2ab5901
fix deno example
mhmd-azeez 843a4e9
bring back browser esm and make the example html nicer
mhmd-azeez dde2f0f
implement http
mhmd-azeez 450c6d3
check for allowed hosts in http
mhmd-azeez aa50eb2
test: add test suite for nodejs
mhmd-azeez e5a557b
add tests for deno
mhmd-azeez 7ed8ec5
hashing
mhmd-azeez 1ec7e56
fix build errors
mhmd-azeez 3056173
cleanup
mhmd-azeez 4130e8b
add more tests
mhmd-azeez abdfbf9
initialize guest runtime
mhmd-azeez 36cc83d
call haskell plugin multiple times
mhmd-azeez 857a03f
bring tests over to deno
mhmd-azeez 18c41bc
make sure deno SDK can run Haskell plugins
mhmd-azeez f161f74
make sure file system access works
mhmd-azeez 7ed6838
embed runtime
mhmd-azeez dc3dfd0
chore: restructure things a bit and add docs
mhmd-azeez 07d839f
fix: return commandInit in wasiRuntime instead of haskellInit
mhmd-azeez 3ea0980
feat: restructure the project to have one package.json for both brows…
mhmd-azeez 39b4332
fix: address PR feedback
mhmd-azeez 1cd02e7
ci: add an action to build & test on main and PRs
mhmd-azeez 4ac0524
ci: run npm install before building
mhmd-azeez c93b39f
ci: fix dir separators
mhmd-azeez 6a4b66b
ci: don't use npm cache
mhmd-azeez 3a18e1a
chore: update extism kernel
zshipko 50cb262
Merge pull request #2 from extism/update-kernel
zshipko 4365ff0
chore: update wasm kernel
mhmd-azeez cab26c2
fix: make sure we copy the memory before setting it to var
mhmd-azeez 4fd8864
fix: make sure getBytes copies the buffer
mhmd-azeez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: JS CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
|
||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
rust: | ||
- stable | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/[email protected] | ||
|
||
- name: Setup Deno | ||
uses: denoland/[email protected] | ||
|
||
- name: NPM install with caching | ||
run: npm install | ||
|
||
- name: Build | ||
run: npm run build | ||
|
||
- name: Node Test | ||
run: npm run test | ||
|
||
- name: Deno Test | ||
run: deno test -A ./tests/mod.test.ts |
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,130 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
web_modules/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
.stylelintcache | ||
|
||
# Microbundle cache | ||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
.parcel-cache | ||
|
||
# Next.js build output | ||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
.cache/ | ||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
# public | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
.temp | ||
.cache | ||
|
||
# Docusaurus cache and generated files | ||
.docusaurus | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# TernJS port file | ||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
.vscode-test | ||
|
||
# yarn v2 | ||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* |
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 @@ | ||
{ | ||
"printWidth": 120, | ||
"trailingComma": "all", | ||
"singleQuote": 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,10 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.lint": true, | ||
"deno.unstable": true, | ||
"deno.enablePaths": [ | ||
"./src/deno/mod.ts", | ||
"./examples/deno.ts", | ||
"./tests/mod.test.ts" | ||
] | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.PHONY: test | ||
|
||
prepare: | ||
npm install | ||
|
||
build: | ||
npm run build | ||
|
||
test: prepare | ||
npm run test | ||
deno test -A .\tests\mod.test.ts | ||
|
||
clean: | ||
echo "No clean implemented" | ||
|
||
publish: clean prepare build | ||
npm publish | ||
|
||
format: | ||
npx prettier --write src | ||
|
||
lint: | ||
npx prettier --check src | ||
|
||
docs: | ||
npx typedoc --out doc src | ||
|
||
show-docs: docs | ||
open doc/index.html | ||
|
||
update-kernel: | ||
node update-kernel.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 |
---|---|---|
@@ -1 +1,19 @@ | ||
# Extism JavaScript SDK | ||
# Extism JS SDK | ||
|
||
## Run Examples: | ||
|
||
``` | ||
npm run build | ||
|
||
node --experimental-wasi-unstable-preview1 ./examples/node.js wasm/config.wasm | ||
|
||
deno run -A ./examples/deno.js ./wasm/config.wasm | ||
|
||
bun run ./examples/node.js wasm/config.wasm | ||
``` | ||
|
||
## Update `extism-kernel.wasm`: | ||
We are shipping an embedded kernel in base64 form in plugin.ts. To update it, you can run these commands: | ||
``` | ||
make update-kernel | ||
``` |
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,29 @@ | ||
const { build } = require("esbuild"); | ||
const { peerDependencies } = require('./package.json') | ||
const fs = require('fs') | ||
|
||
const sharedConfig = { | ||
bundle: true, | ||
minify: true, | ||
drop: [], // preseve debugger statements | ||
external: Object.keys(peerDependencies || {}), | ||
}; | ||
|
||
// NodeJS CSJ | ||
build({ | ||
...sharedConfig, | ||
entryPoints: ["src/node/index.ts"], | ||
platform: 'node', // for CJS | ||
outfile: "dist/node/index.js", | ||
external: [ './src/mod.ts', "sync-fetch", "child_process" ] | ||
}); | ||
|
||
// Browser ESM | ||
build({ | ||
...sharedConfig, | ||
entryPoints: ["src/browser/index.ts"], | ||
outfile: "dist/browser/index.mjs", | ||
platform: 'neutral', | ||
external: [ './src/mod.ts', "sync-fetch", "child_process" ], | ||
format: "esm", | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ExtismPlugin, ExtismPluginOptions } from '../src/deno/mod.ts' | ||
|
||
async function main() { | ||
const filename = Deno.args[0] || "wasm/hello.wasm"; | ||
const funcname = Deno.args[1] || "run_test"; | ||
const input = Deno.args[2] || "this is a test"; | ||
const wasm = { | ||
path: filename | ||
} | ||
|
||
const options = new ExtismPluginOptions() | ||
.withConfig("thing", "testing") | ||
.withWasi(); | ||
|
||
const plugin = await ExtismPlugin.new(wasm, options); | ||
|
||
const res = await plugin.call(funcname, new TextEncoder().encode(input)); | ||
const s = new TextDecoder().decode(res.buffer); | ||
console.log(s) | ||
} | ||
|
||
main(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path may need to change with the latest update to directory structure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, can you elaborate on this? I think the path is correct