bpstrngr / interface

Ecmascript module interface for clients/imports/functions.
0 stars 1 forks source link

Introduce monadic inference and its combinators #7

Closed bpstrngr closed 8 months ago

bpstrngr commented 11 months ago

:horse_racing: Eliminated race conditions between dependency loading and bundling in the Interface module, which also revealed inconsistencies in circular/optional require transpilation (#9) that have been fixed.

:cook: Upgraded Inference module with variadic inference and pertaining monadic combinators (infer, buffer, tether, either, wether, combine, compose etc.). #1 #2 #3

:spaghetti: Introducing the Host module to route http(s) requests to a provided hierarchy of response functions/objects (the local file directory, ie. a static file server by default) on a provided port and protocol.

The only dependencies you need continue to be node.js and git. :white_heart:

To try it out, just get the code and start inferring modules, for example the expose function in host.js with the arguments you want to use (or without; it will just prompt you by keys for the values):

git clone --branch 2024.02 https://github.com/bpstrngr/interface;
cd interface;
echo '{"http":{"port":8000},"https":{"port":4433,"hmac":"secret","certification":{"localhost":["./key.pem","./cert.pem"]},"distinguishedname":{"commonName":"example.org","countryName":"US","ST":"California","localityName":"Mountain View","organizationName":"example","OU":"admin"}}}'>parameters.json;

# to test html: 
echo '<html><head><script src="./test.js"><link rel="stylesheet" href="test.css"></head><body>html</body></html>'>test.html;
echo 'document.write("js")'>index.js;
echo 'html{background:#222222;color:white}'>test.css;

# from node 21.1
node --experimental-detect-module --import=./Blik_2023_interface.js ./Blik_2023_host.js expose ./Blik_2023_interface.js ./parameters.json http;

# from node 20.7 
echo '{"type":"module"}'>package.json;
node --import=./Blik_2023_interface.js ./Blik_2023_host.js expose ./Blik_2023_interface.js ./parameters.json http;

# from node 16 
echo '{"type":"module"}'>package.json;
node --loader=./Blik_2023_interface.js ./Blik_2023_host.js expose ./Blik_2023_interface.js ./parameters.json http;