swiftwasm/JavaScriptKit

Plugin infrastructure

j-f1 opened this issue · 0 comments

j-f1 commented

Currently, JavaScript-based features must be directly implemented in JavaScriptKit to be able to access important features like the heap and the JSValue parsing/serializing routines. This means that less-common things like TypedArray or potential Combine-Promise integration (see #62) would have to increase the bundle size for everyone. One solution to this would be defining some sort of public JS-side API that allows providing custom functions to the WASM runtime. As long as we encourage users of this API to prefix their methods there should be no collision issues.

It would be nice to restructure JavaScriptKit itself to make use of the plugin API too:

  • swjs_core: release
  • swjs_object: get_prop, set_prop, get_subscript, set_subscript, instanceof
  • swjs_string: decode, encode, load
  • swjs_function: call, apply, call_new, create
  • swjs_typedarray: create