thaler

Write server-side functions in an isomorphic way

MIT License

Downloads
96
Stars
64
Committers
1

Bot releases are hidden (Show)

thaler - Latest Release

Published by lxsmnsyc 9 months ago

  • Move to biome
  • Fix proper chunking algorithm
  • Add proper "handshake" for server-client communication
  • Remove Blob and File support for requests
  • Remove compile as the default export.
  • Fix server functions to have the correct MIME type
  • Add X-Thaler-ID header
  • Update demos
thaler -

Published by lxsmnsyc 11 months ago

Since 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);
}
thaler -

Published by lxsmnsyc over 1 year ago

  • Add support for defining custom server functions. The configuration follows the same internal definition for the built-in server functions, and can be defined through the plugin integrations (e.g. Vite). Functions defined in the configuration must call one of the "internally-defined" functions for Thaler to recognize the function call.
// 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',
      },
    }
  ],
});
thaler -

Published by lxsmnsyc over 1 year ago

thaler -

Published by lxsmnsyc over 1 year ago

  • Add thaler/utils
    • Add debounce
    • Add throttle
    • Move json and text utils from thaler/server to thaler/utils
  • Add ref$ (createReference in seroval but with auto id)
  • Add sveltekit demo
  • Add solidstart demo
thaler -

Published by lxsmnsyc over 1 year ago

  • Deprecate thaler/babel in favor of thaler/compiler
  • Add unplugin
  • Fix fn$ scoping to skip top-level values
thaler - v0.2.0

Published by lxsmnsyc over 1 year ago

  • Add support for Promise serialization
  • Fix closure extraction to support live binding
    • 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