Skip to content

Releases: lxsmnsyc/seroval

v1.3.0

06 May 16:05
d068e79

Choose a tag to compare

  • Move AbortSignal to seroval-plugins/web
    • This was an implementation mistake in 1.2.0, AbortSignal is a web standard.
  • expose onParse, pushPendingState, popPendingState and parseWithError in Plugin API.
  • Rework serialized Promise format
    • Instead of assigning resolver methods to a Promise, seroval will now keep track of an object that contains those methods and instead will reference that object when resolving in a streaming format.
    • status and value is now replaced with s (0, 1, 2 as pending, success, failure) and v respectively.
  • Fix support for invalid Dates.
    • Turns out, new Date(NaN) is a thing.

v1.2.0

07 Jan 12:10
8554d15

Choose a tag to compare

  • Add AbortSignal to serializable values

v1.1.0

14 Jul 06:12
1746c7b

Choose a tag to compare

This feature adds a very basic OpaqueReference class. The purpose of this class is to wrap user-specified values into "opaque references": references that are hidden from the serializer. An OpaqueReference contains two values: the original value it is trying to hide, and an optional replacement value, which is what the serializer "sees".

A replacement value can only be a value that seroval can serialize. By default, a replacement value is undefined.

Example:

import { serialize, deserialize, OpaqueReference } from 'seroval';

const example = {
  transparent: "This is a transparent value.",
  opaque: new OpaqueReference('This is an opaque value.'),
};

// You can still access the original value:
console.log(example.opaque.value);

// but now it's different
const deserialized = deserialize(serialize(example));
console.log(deserialized.opaque); // undefined

v1.0.0

12 Dec 04:10

Choose a tag to compare

What's Changed

  • Introduce createStream a403955
    • This function provides a universal streaming primitive that users can use. ReadableStream isn't a JS standard and so there was no counterpart to Promise when it comes to streaming data, so I had to introduce a minimal streaming primitive that is both portable and serializable.
  • Create seroval-plugins 22dcc59
    • This package is dedicated for authoring plugins.
    • Given that createStream has been introduced, seroval is no longer dependent from the ReadableStream API, which makes seroval no longer tied to the Web API too.
  • Move the following Web API support to seroval-plugins/web
    • Blob
    • CustomEvent
    • DOMException
    • Event
    • File
    • FormData
    • Headers
    • ReadableStream
    • Request
    • Response
    • URLSearchParams
    • URL
  • Deprecate some feature flags. The following features can no longer be disabled:
    • Set
    • Map
    • Promise
    • BigInt
    • TypedArray
    • Symbol
    • WebAPI
  • Plugin parsing is now on a higher priority, which would allow users to customize serialization for things like plain objects.
  • Promise and AsyncIterable is now supported in sync mode, but will only generate a non-resolving instance.
  • Add extends option to Plugins API. This allows the plugins to require other plugins in case the feature is required (e.g. Request relies on both Headers and ReadableStream)

Fixes

  • Fix RegExp serialization
  • Fix string deserialization
  • Fix plugin tag deserialization check
  • Fix treeshaking for top-level variables

Full Changelog: v0.15.1...v1.0.0

0.13.0

18 Nov 15:01

Choose a tag to compare

  • Add the following APIs:
    • toCrossJSON
    • toCrossJSONAsync
    • toCrossJSONStream
    • fromCrossJSON
  • Add support for ReadableStream in async modes
  • Add support for AsyncIterable in async and streaming modes
  • Add Symbol.toStringTag and Symbol.isConcatSpreadable in serialized properties
  • Deprecate MethodShorthand and ArrayPrototypeValues in Feature
  • Rework Iterable serialization output
  • Dedupe hidden references
  • Fix Plugin API-related behavior
  • Remove Plugin API's isIterable

v0.12.0

19 Oct 06:13

Choose a tag to compare

  • Add the Plugin API
    • This feature allows custom serialization/deserialization API in seroval. The feature required massive restructuring in the core, such as moving the whole parser, serializer and deserializer code from functions to class-based, which will allow deduping and a lot more. It's required so that the underlying methods can be exposed for the plugin methods.
    • This resolves #17
    • This resolves #14
    • Example:
    import {
      createPlugin,
      serialize,
      type SerovalNode,
    } from 'seroval';
    
    const BufferPlugin = createPlugin<Buffer, SerovalNode>({
      tag: 'Buffer',
      test(value) {
        return value instanceof Buffer;
      },
      parse: {
        sync(value, ctx) {
          return ctx.parse(value.toString('base64'));
        },
        async async(value, ctx) {
          return ctx.parse(value.toString('base64'));
        },
        stream(value, ctx) {
          return ctx.parse(value.toString('base64'));
        },
      },
      serialize(node, ctx) {
        return `Buffer.from(${ctx.serialize(node)}, "base64")`;
      },
      deserialize(node, ctx) {
        return Buffer.from(ctx.deserialize(node) as string, 'base64');
      },
      isIterable() {
        return true;
      },
    });
    
    const serializedJS = serialize(
      Buffer.from('Hello World', 'utf-8'),
      {
        plugins: [BufferPlugin],
      },
    );
  • Fixes #27
  • Fixes #28

v0.11.0

11 Oct 08:37

Choose a tag to compare

  • Add Request support
  • Add Response support
  • Add Event support
  • Add CustomEvent support
  • Add DOMException support
  • Fix runtime feature flag check during parsing process
    • This way, the feature flag not only applies to the target runtime of the compiled output, but also for the parsing runtime.
    • This change affects the following behavior:
      • Map and Set now falls back to Symbol.iterator if disabled.
      • ArrayBuffer and DataView to require Feature.TypedArray (due to how both requires Uint8Array)
      • Indirectly, classes like Blob and File is now indirectly affected by the Feature.TypedArray

v0.10.0

18 Sep 02:36

Choose a tag to compare

  • Add the cross-referencing serializer mode
    • This mode allows multiple calls of serialization to share the same reference maps, a behavior that's not present in current existing modes. This introduces crossSerialize and crossSerializeAsync. JSON variants will be introduced in the future.
  • Add the streaming serializer mode (#5)
    • With the addition of the cross-referencing serializer, it's now possible for seroval to stream serialized data but with a new API. This release introduces the crossSerializeStream and the Serializer class, both provides two kinds of streaming format (the former being a one-time read-only stream, while the latter allowing push data).
  • Fix Promise serialization to consider rejected instances.
    • Previously seroval throws on rejected Promises, which shouldn't be the case and is most likely a bad design, given that seroval can also serialize Error instances.
  • Add ReadableStream support.
    • Currently only available in crossSerializeStream and Serializer class.
  • Restructure docs
    • Since there are two READMEs in the repo, it's a bit of redundant work to maintain one of it (and paste it to the other) so I've decided to separate the docs. Docs are still a WIP but most of it is still usable.

Full Changelog: v0.9.0...v0.10.0

v0.9.0

07 Jul 09:14

Choose a tag to compare

  • Adds support for serializing object state (e.g. Object.freeze, Object.seal and Object.preventExtensions)
  • Fix object assign compat

v0.8.0

03 May 09:50

Choose a tag to compare

  • Resolves #16
    • Iterable is no longer a separate kind of node, it's now a subset of either Object or NullConstructor (depending on constructor).
    • Feature.Symbol no longer disables the use of Symbol.iterator in Iterable. Iterable protocol is now skipped.
  • Replace Undefined, Null, Boolean, NaN, NegativeZero, Infinity and NegativeInfinity with the Constant Node.
  • Fix deserialization step for objects with zero properties returning a different reference.
  • Drop support for PromiseLike (aka Thenables) due to the potential DoS
  • Add support for boxed primitives
  • Fix parsing errors to be descriptive
  • optimize serialization

What's Changed

New Contributors

Full Changelog: v0.7.0...v0.8.0