[Idea Discussion] Plugins/Packages/Modules
Thinking in adding some module/package manager like support using libuv shared library handling and a build system like Ruby extensions or FFI like, i created a C wrapper for uWebSockets and want to add in txiki.js, but i want to create a more generic way to add packages or extensions because i plan to add, redis and postgres too. http://docs.libuv.org/en/v1.x/dll.html
Proposal: JSON file like gems:
{
"packages": {
"uws": {
"git": "https://github.com/cirospaciari/uWebSockets.qjs.git",
"branch": "v1.0",
"submodules": true
}
}
}
short version:
{
"packages": {
"uws": "github://cirospaciari/uWebSockets.qjs?branch=v1.0&submodules=true"
}
}
Usage:
import { App } from "uws";
App.new()
.get("/", (response, request)=> response.end("Hello World!"))
.listen(8082, (config)=> console.log(`Listening on port ${config.port}`))
.run();
In this case adding the package will clone with submodules, call a make file with can use tcc, clang, gcc or mingw to generate an .so, .dll or .dylib, and at runtime using the libuv uv_dlsym we can call/register the module/extension (and cache)
folder for the packages/ files: modules -> uws -> index.js, uws.so, tmp (temp folder for build)
A package manager could generate the index.js + libuv calls and modifying the import to lookup at modules folder to the index.js file
Hi there!
Sorry for the delay. As you may have noticed the project is still young, and TBH I haven't made my mind up about package management.
It is not something I can think about right now, not at least there is a working WebSocket and HTTP server implementation in here :-)
I'm currently leaning towards an FFI interface for accessing external libraries indeed.
Now that you mentioned uws, I did take a quick look for maybe using it to power the WS server / client, but it looks like it just does servers, right?
My plan at the moment is to go with libwebsockets, because it will allow me to support WS and HTTP client / server with a single library. That would replace curl.
libwebsockets for all in one solution will be great! Another thing is maybe go for an deno/es6 like import for packages aka:
import {
add,
multiply,
} from "https://x.nest.land/[email protected]/source/index.js";
libwebsockets for all in one solution will be great!
Another thing is maybe go for an deno/es6 like import for packages aka:
import { add, multiply, } from "https://x.nest.land/[email protected]/source/index.js";
HTTP imports already work :-) Not sure what Deno does if the imported file imports another one relatively though, that might not work (yet) but I have not tried it.
libwebsockets for all in one solution will be great! Another thing is maybe go for an deno/es6 like import for packages aka:
import { add, multiply, } from "https://x.nest.land/[email protected]/source/index.js";
I had the same idea https://www.reddit.com/r/Deno/comments/106r0v0/how_to_compile_servetls_for_import_into_quickjs/, https://www.reddit.com/r/javascript/comments/106m5i6/askjs_is_there_an_javascript_engine_agnostic/. The source files are downloaded to /home/user/.cache/deno/deps/https/deno.land/. Not sure how to proceed from there besides modifying the code by hand to remove references to Deno.
Closing since I'm leaving packaging completely out of scope, on purpose, for now. FFI is a thing now, and I'm hoping to get back to adding libwebsockets soon.