Giter VIP home page Giter VIP logo

Comments (4)

bugzpodder avatar bugzpodder commented on June 20, 2024 2

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.

bhelx avatar bhelx commented on June 20, 2024 2

Started work on this and we have a new proposal extism/proposals#16

from js-pdk.

bhelx avatar bhelx commented on June 20, 2024

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.

bhelx avatar bhelx commented on June 20, 2024

I believe we can call this done

from js-pdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.