Skip to content

Releases: bare-ts/bare

v0.6.0

31 Mar 18:07
b0befb2
Compare
Choose a tag to compare
v0.6.0 Pre-release
Pre-release
  • Update BARE syntax

    The new syntax for BARE schema is now supported.

    Legacy syntax is now reported as an error.
    To allow legacy syntax use the option --legacy-syntax.

v0.5.0

30 Mar 21:07
b6af618
Compare
Choose a tag to compare
v0.5.0 Pre-release
Pre-release
  • Forbid circular references with fixed lists

    The following schema is now correctly rejected:

    struct Person {
        bestFriends: [2]Person
    }
    
  • Allow enum type and aliased types for map key type

    The following schema is now valid:

    enum Gender {
        FLUID
        MALE
        FEMALE
    }
    
    type GenderNames map[Gender] string
    
  • Allow unsorted tags for unions and enums

    The following schemas was previously rejected because of unsorted tags.

    enum Gender {
        FLUID = 1
        MALE = 0
               ^ error was reported here
        FEMALE = 2
    }
    
    type UnsignedInt (u8 = 1 | u16 = 0 | u32 = 2 | u64 = 3)
                                     ^ error was reported here
    

    These schemas are now allowed.
    They are still rejected in pedantic mode (option --pedantic)

v0.4.0

25 Mar 23:35
e732e5e
Compare
Choose a tag to compare
v0.4.0 Pre-release
Pre-release
  • Forbid main codecs resolving to void type

    The following BARE schema is no longer valid when 'Message' is
    a main codec (using --main CLI option):

    type Message void
         ^ error is now reported here
    
  • Forbid flat unions which cannot be automatically flatten

    bare-ts is able to automatically compute the tag of simple flat unions
    without any help. A simple union is either:

    • a union of base or void types that can be discriminated by their
      typeof value, or
    • a union of classes (requires the option --use-class).

    Previously, bare-ts asked to the user to provide a tagging function for
    other cases (complex flat unions).
    Now, bare-ts throws an error when it encounters a complex flat union.
    Complex flat unions are no longer supported.

  • Add pedantic mode (option --pedantic)

  • Better code generation

    bare-ts has a normalization step where it alias some types,
    including anonymous structs, data arrays, and typed arrays.

    bare-ts is now able to generate reader and writer without
    aliasing these types.

v0.3.0

02 Mar 21:38
3d42173
Compare
Choose a tag to compare
v0.3.0 Pre-release
Pre-release
  • Fix regression: Forbid bare schema in which a type is repeated in an union

    The following schema is now correctly reported as invalid:

    type X (u8 | u8)
    
  • Deduplicate readers and writers of complex non-aliased types

    @bare-ts/tools generates readers and writers for complex non-aliased types.
    These reader and writer are now de-duplicated.

  • Default to null instead of undefined for optional types

    The use of null seems more common than the use of undefined.

    The option --use-null is removed.
    A new option --use-undefined is added.

  • Make configurable the emitted type for void type

    BARE schema enable use of void types in unions. For example:

    type Union (u8 | void)
    

    Previously, @bare-ts/tools emitted the type undefined for void.
    Now it relies on options --use-undefined and --use-lax-optional to
    choose between null, undefined, and null | undefined.
    Note that these options also modify the emitted types for optionals.

  • Support for quoted properties

    The option --use-quoted-property enables to output
    quoted properties instead of unquoted properties.

    This can be useful when using a JS minifier that differently handles
    quoted and unquoted properties.

v0.2.0

20 Feb 18:26
66c4307
Compare
Choose a tag to compare
v0.2.0 Pre-release
Pre-release
  • Fix invalid code generation for big tags in enums and unions

    bare-ts applies an optimization when tags can be encoded on 7bits.
    The general case was not tested yet.
    The addition of tests enabled to catch typo errors.
    The generated code imported non-existing readers and writers.

  • Fix generator choice

    The option --generator enables to specify which generator is used to
    produce the output.
    When the output is written to stdout, the generator ts is used by
    default.
    The option --generator should override this default.

    Previously the option did not override the default.

  • Fix location report upon compilation errors

    Upon errors the compiler reports the error and a file location.
    Previously, the reported location was shifted by 1 column and at
    the end of a token.
    Now, the compiler reports the correct location and at the start of a
    token.

    For instance, if a type alias is in lowercase in a bare schema,
    then the parser reported an error at the end of the alias.
    The error is now reported at the start of the alias:

    type lowerCaseAlias u8
                      ^ error was previously reported here
         ^ error is now reported here
    
  • Make @bare-ts/tools library platform-agnostic

    Use your favorite ESM-ready CDN and simply import @bare-ts/tools.
    This was made possible by removing the dependency over node:assert.

  • Add --use-class option

    This generates classes instead of interfaces for struct types.

  • Automatically handle simple flat unions

    By default bare-ts generates tagged unions.
    For instance, the following BARE schema:

    type Union (A | B)

    generates the TypeSCript type:

    type Union =
        | { readonly tag: 0, readonly val: A }
        | { readonly tag: 1, readonly val: B }

    You can force the use of flat unions with the option --use-flat-union.
    However, you have to provide a function that computes the tag of the object.
    This function must be exported from a file named ext.{js,ts} and placed
    in the same directory as the file generated by bare-ts.

    export function tagUnion(x: A | B): 0 | 1 {
        // returns 0 if x has type A or 1 if x has type B
    }

    bare-ts is now able to compute the tag of simple flat unions without
    your help. A simple union is either:

    • a union of types that can be discriminated by their typeof value, or
    • a union of classes (requires the option --use-class).
  • Add @bare-ts/lib as peer dependency

    This enables to inform the user of @bare-ts/tools which version of
    @bare-ts/lib is expected.

  • Forbid bare schema with undefined aliases

  • Forbid bare schema in which length and tags are too large

    Length of fixed data and (typed) array must be a u32.
    This is a limitation of the ECMAScript standard.

    Tags of enums and unions must be a safe integers.
    In the future, this requirement could be relaxed by switching to
    bigint for larger integers.

  • Forbid bare schema in which the length of a fixed data is 0

    The following schema is now invalid:

    type EmptyData data<0>
    
  • Forbid bare schema in which a type is repeated in an union

    The following schema is now invalid:

    type X (u8 | u8)
    

    Note that the following schema is still valid:

    type Y u8
    type X (u8 | Y)
    

    Y is a user-defined type.

  • Forbid bare schema in which an enum have several members with the same name

    The following schema is now invalid:

    enum Gender {
        FLUID
        FEMALE
        MALE
        FLUID
    }
    
  • Forbid bare schema in which a struct have several fields with the same name

    The following schema is now invalid:

    struct Person {
        name: string
        name: string
    }
    
  • Forbid bare schema with circular references

  • Better diagnostics when semicolons are used to separate enum or
    struct members

  • BREAKING CHANGE: adapt to @bare-ts/[email protected]

    @bare-ts/[email protected] introduces several breaking changes.
    As a consequence:

    • all decode/encode are renamed into read/write
    • all pack/unpack are renamed into encode/decode
    • decoders (previously unpackers) no longer accept ArrayBuffer as
      type of read buffer

v0.1.1

05 Jan 21:50
56d5a8c
Compare
Choose a tag to compare
v0.1.1 Pre-release
Pre-release
  • Fix array encoders

    Previously array encoders did not encode the first item of a generic array.

v0.1.0

03 Jan 23:05
74bc1dc
Compare
Choose a tag to compare
v0.1.0 Pre-release
Pre-release
  • BARE schema compiler supports all types