Comments (4)
Since we have a Host
global, would it make sense to use a similar approach instead of "extism:host"? Like HostCall.host_func1
or HostCall.host_func2
? I also peeked at other PDKs, they are generally light on details on how host function calls are implemented and used other than the default inputString().
If I am a plugin developer, and I want to to call some host_func1
it would be great if I can copy+paste/import some kind of definition so I know for sure what I am calling. But I haven't played with plugins so not sure if that's reasonable suggestion or not.
For exports I see that your code reference looks for a module.exports by eval some JS which seems fairly reasonable to me.
Also see https://github.com/dylibso/pg_extism/blob/main/plugins/chatgpt/script.js#L1 which may or may not be useful.
from js-pdk.
Started work on this and we have a new proposal extism/proposals#16
from js-pdk.
Yes, that's a good point. I think putting the imports on the Host object or having another global makes sense to continue with. So I'd be open to any of those options.
The tricky issue will still be getting the imports defined into the wasm file. So we'll still need to parse something ahead of time and do a similar trick we do with exports. We could also have some conventional structure you're expected to define as a global in the top of your module. Kind of like how rust works with externs
:
#[host_fn]
extern "ExtismHost" {
fn hello_world(input: String) -> Json<Output>;
}
// ^ that gets expanded to this:
extern "C" {
fn hello_world(input: i64) -> i64;
}
The compiler will need to know what all the imports are that the plugin needs and what the wasm type signature of each host function is. So it will need to parse the JS (or wherever you want to put these declarations), look for these imports and signatures, then compile in the imports into the wasm binary.
from js-pdk.
I believe we can call this done
from js-pdk.
Related Issues (20)
- Plugin compilation warning HOT 2
- Explore runtime linking of JS provider
- JS PDK Improvements HOT 2
- Windows Support HOT 2
- JS-PDK polyfill System
- Support Non-WASI plug-ins HOT 1
- Move test files out of root, create build system for them
- Design 1.0 API and release v1.0.0-rc1 HOT 2
- Wasm exception when calling http host fn
- Error: module[extism:host/env] not instantiated HOT 2
- Add support for `Date()` HOT 2
- ESM Support
- Regression bug when exception is thrown HOT 1
- Export mapping relies on the order of declarations HOT 1
- Conform to W3C spec for console.log, error, etc HOT 1
- consider making resulting modules `reactor` modules HOT 2
- Publish compiler as npm package HOT 2
- Install error on macOS
- Move away from quickjs-wasm-rs to an alternative HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-pdk.