Skip to content

Releases: razshare/sveltekit-sse

Correctly invoking onmessage on source

30 Jul 19:19

Choose a tag to compare

Changes

  • fixing an issue where source::options::onmessage would not be invoked, see #70
  • source::options::onopen is no longer async in order to make it consistent with the other event handlers

Escape cached source key non-latin1 characters

27 Jul 05:49

Choose a tag to compare

What's Changed

  • fix: escape cached source key non-latin1 characters by @syail in #69
  • fix: select::json() types are now more consistent with internal logic, in that it no longer returns T|null|undefined, instead it only returns T?
  • tests: adding test for #69

New Contributors

  • @syail made their first contribution in #69

Full Changelog: v0.14.1...v0.14.2

Dropping dependency on @microsoft/fetch-event-source

05 Jul 13:18

Choose a tag to compare

Changes

v0.13.19

19 Apr 21:49

Choose a tag to compare

Changes

Fixing some jsdoc comments and ignoring some "unused" linting errors on the server because they are irrelevant since we don't actually run any actual logic on the server side.

We just fake empty messages, but we still want to implement the same api for userland in order to maintain type hinting consistency.

Adding back some files lost in the previous project refactory.

14 Apr 13:39

Choose a tag to compare

Changes

No technical changes.

In 0daf300 I've push a refactory job, migrating the project template from the old official npm script to the one generated by the new and official sv cli tool offered by the Svelte team, to stay consistent with the new way of doing things in Svelte world.

In that refactory job, the MIT license file was lost, I'm now adding it back and I'm also adding a bit more delay in e2e tests while testing issue #43, to avoid false positives while publishing.

Fixing type inference in .json() for JSDoc users

16 Mar 08:58

Choose a tag to compare

Changes

  • Previously this would not work in JS Doc

    connection.select('stats').json(function or({error}) {
      console.error("Could not parse stats!", error)
      return { cpu_usage: '0.00%', memory: '0.00 MB', time: 0 }
    })

    Because .json() is generic, and T defaults to null in its type definition, but JS Doc's default behavior (and Typescript's) is to infer missing template types as any, thus a type mismatch occurs.

    Generic template in .json() now defaults to any instead of null.

.json() errors logs are now opt in

16 Mar 08:33

Choose a tag to compare

Changes

  • function .json() no longer logs errors by default, you now have to opt in to log these errors.
    For example
    connection.select('stats').json(function or({error}) {
      console.error("Could not parse stats!", error)
      return { cpu_usage: '0.00%', memory: '0.00 MB', time: 0 }
    })

Improving type hints for select::json

22 Feb 02:52

Choose a tag to compare

Changes

  • select::json type hinting now falls back to a nullable empty object as a type and infers the actual type from either the generic type or the result from the predicate.

Initial value of .json now falls back to predicate

22 Feb 02:26

Choose a tag to compare

Changes

  • The initial value of select().json() now fallback to the or predicate on both the server and the client.
    In short, instead of this
    <script>
      import { source } from 'sveltekit-sse';
    
      const connection = source('/events');
      const stats = connection.select('message').json();
    </script>
    
    <main>
      <h2>Admin dashboard page</h2>
    
      {#if $stats}
        <span>Cpu usage - {$stats.cpu_usage}</span><br />
        <span>Memory - {$stats.memory}</span><br />
        <span>Time - {$stats.time}</span><br />
      {/if}
    </main>
    you can now also do something like this
    <script>
      import { source } from 'sveltekit-sse';
    
      const connection = source('/events');
      const stats = connection.select('message').json(function or() {
        return { cpu_usage: '0.00%', memory: '0.00 MB', time: 0 };
      });
    </script>
    
    <main>
      <h2>Admin dashboard page</h2>
    
      <span>Cpu usage - {$stats.cpu_usage}</span><br />
      <span>Memory - {$stats.memory}</span><br />
      <span>Time - {$stats.time}</span><br />
    </main>

Dropping internal uri encoding/decoding

07 Jan 17:10

Choose a tag to compare

Changes

  • Previously emit would internally encode data as uri and source would decode it.
    This behavior is not needed, so it's being removed, instead data will be sent raw from now on.
    Related to #64