Write server-side functions in an isomorphic way
MIT License
Bot releases are visible (Hide)
biome
Blob
and File
support for requestscompile
as the default export
.X-Thaler-ID
headerSince seroval now has built-in support for AsyncIterables, and has JSON streaming API, we can now turn all seroval-based server functions to utilize the streaming feature.
Basically, this is now possible:
const example = fn$(async function* foo(items: string[]) {
for (const item of items) {
yield sleep(item, 1000);
}
});
// client code
const iterator = await example(['foo', 'bar', 'baz']);
for await (const value of iterator) {
console.log('Received: ', value);
}
// This is based on the unplugin integration
thaler.vite({
functions: [
{
// Name of the function
name: 'server$',
// Boolean check if the function needs to perform
// closure extraction
scoping: false,
// Target identifier (to be compiled)
target: {
// Name of the identifier
name: 'server$',
// Where it is imported
source: 'thaler',
// Kind of import (named or default)
kind: 'named',
},
// Compiled function for the client
client: {
// Compiled function identifier
name: '$$server',
// Where it is imported
source: 'thaler/client',
// Kind of import
kind: 'named',
},
// Compiled function for the server
server: {
// Compiled function identifier
name: '$$server',
// Where it is imported
source: 'thaler/server',
// Kind of import
kind: 'named',
},
}
],
});
loader$
and action$
https://github.com/lxsmnsyc/thaler/commit/a84da6071a173f5b3ce02bdf55e8c6e7cd0bc37b
server$
) to receive an event object with a request
property instead of the request
directly https://github.com/lxsmnsyc/thaler/commit/fcc39b9d71db670a73265b4de48d963f3853126f
response
modification for fn$
and pure$
retry
to thaler/utils
https://github.com/lxsmnsyc/thaler/commit/d33e4b47be7cbc0335a41be53d079f698feccb7d
timeout
to thaler/utils
https://github.com/lxsmnsyc/thaler/commit/00c9766bfdd85a7e55dd12da86ac5bb7eed20d2f
debounce
race conditions https://github.com/lxsmnsyc/thaler/pull/6/commits/81af3fff4420b32e3b82474e2565d9693042d921
origin
config https://github.com/lxsmnsyc/thaler/pull/6/commits/0d17d505e2b72a82f0dba8324a67bcd27c5d67f8
Published by lxsmnsyc over 1 year ago
let
variables captured but was updated after it is captured. Calling fn$
sends the stale closure instead of the updated closure.Full Changelog: https://github.com/lxsmnsyc/thaler/compare/v0.1.3...v0.2.0