Skip to content

Releases: oscartbeaumont/specta

v2.0.0-rc.12 - Fix bugs with enums

09 May 02:42
Compare
Choose a tag to compare
Pre-release

This release fixes a bug where the following type would cause Specta to crash:

#[derive(Type)]
#[serde(tag = "type", content = "data")]
pub enum SkippedFieldWithinVariant {
    A(#[serde(skip)] String),
    B(String),
}

v2.0.0-rc.10 - Fix bugs in function handling

30 Apr 07:01
Compare
Choose a tag to compare

Changes:

  • Empty collect_commands would throw error "unable to infer type for Vec".
  • collect_commands using a module path (Eg. some_module::function) would not work due to macro visibility

v2.0.0-rc.9 - Nit

02 Apr 15:10
Compare
Choose a tag to compare
v2.0.0-rc.9 - Nit Pre-release
Pre-release

Changes:

  • Rename functions module to function. So it's now specta::function::*.
  • Rename functions feature to function.

v2.0.0-rc.8 - Steady Steady

02 Apr 09:25
Compare
Choose a tag to compare
Pre-release

Changes:

  • Rename SpectaFunction, SpectaFunctionArg and SpectaFunctionResult to Function*
  • Drop tauri feature
  • Make FunctionArg public
  • Add Type implementation for Box<str>
  • Bump bevy and glam versions.
  • Drop Type::definition in favor of Type::inline(type_map, Generics::Definition)
  • Fix #196
  • Fix #205
  • Fix #202
  • Fix #201
  • Fix #191
  • Fix #198
  • Fix #189
  • Fix #194

Thanks to @0HyperCube, @bennoinbeta and @mawallace for contributing to this release!

2.0.0-rc.7 - General improvements

04 Dec 10:05
Compare
Choose a tag to compare
Pre-release

Fixes:

  • Fix internally tagged enums with certain children types - #174
  • serde_json::Value is now an enum of possible value - #176
  • Fix recursive types - #179
  • [T; N] is now a Typescript fixed-size tuple - 7039fba
  • Lock the version of Specta macros correctly. - #173
  • Lazily process #[specta(skip)] types - #167
  • Make transparent + skip work correctly together - #170

New Features:

Breaking Changes:

  • Remove Type::definition_generics function
  • Remove DefOpts
  • Change TypeMap from a type alias of a BTreeMap to a custom type.
  • Move specta::ts::prettier to specta::ts::formatters::prettier

2.0.0-rc.6 - Minor fixes

22 Oct 07:54
Compare
Choose a tag to compare
Pre-release

Fixes:

  • Fix regression in #[specta(skip)] handling leading to compilation errors
  • Fix incorrect Typescript from an enum in vector.

2.0.0-rc.5 - Fix compilation error

05 Oct 05:06
Compare
Choose a tag to compare
Pre-release

When compiling Specta with the typescript feature enabled but not the js_doc feature Specta would fail to compile. This is now fixed.

2.0.0-rc.4 - Minor fixes

04 Oct 06:55
Compare
Choose a tag to compare
Pre-release

This release has some small improvements that were blocking the v2.0.0-rc.1 release of Tauri Specta.

Fixes:

  • Generate BigInt type as bigint - #151

Features:

  • Introduce js_doc:: Builder helper for efficiently constructing JS doc comments.

Breaking Changes:

  • js_doc::format_comment was renamed to js_doc::typedef_named_datatype

Thanks, @avinassh and @Brendonovich for contributing to this release!

2.0.0-rc.3 - A bag of improvements

26 Sep 15:14
Compare
Choose a tag to compare
Pre-release

Features:

  • Helpers for JSDoc comment exporting (still undocumented and untested)
  • Support for (T,) tuples. Turns out (T) and (T,) are completely different types.

Important Breaking Changes:

  • Drop typescript as a default feature. You will now need to go specta = { version = "...", features = ["typescript"] } to use the specta::ts and specta::export::ts modules.

Other Breaking Changes:

  • Drop serde as default feature. It's now temporarily under typescript. I would recommend adding it manually if your using Specta with Serde as I will likely drop this in the future for now Specta's Typescript exporter is not ready for it to be dropped.
  • Rename conf to cfg on ExportContext
  • Rename TsExportError to ExportError
  • Drop thiserror feature, it was a no-op anyway. You can use Specta fine with thiserror but it doesn't require us to do stuff.
  • Move specta::ts::js_doc to specta::ts::comments::js_doc. This was just a mistake.
  • Remove Into<TupleType> for T where T: DataTypeFrom. You can use Into<DataType> for T instead.
  • EnumVariant was renamed to EnumVariants and EnumVariant is now a wrapper struct with shared metadata about the variant such as skip , comments or deprecated.
  • NamedDataType.comments is now NamedDataType.docs and is now Cow<'static, str> instead of Vec<Cow<'static, str>>.
  • CommentFormatterFn now takes CommentFormatterArgs as an argument to allow handling deprecated attributes.
  • Breaking changes to SpectaFunction's argument to handle deprecated exporting although this type shouldn't be used for anything publically

Fixes:

  • Fix a heap of incorrectly handled cases when using serde(skip).
    • Attribute was ignored on unnamed field of enum variants.
    • Move skip handling from the macro into the exporter. A(String) and A(#[serde(skip] (), String) are different types in TS (string and [string] respectively) and the exporter needs to know that.
  • Drop dependency on document-features and indoc to make builds slightly quicker and fix issues while vendoring Specta
  • Fix pub struct A((String)) or pub enum A { A((String)) } causing the macro to error out.
  • Reject invalid names when doing #[specta(rename = "name")] on a container (struct or enum). Eg. names containing @
  • Fix #[specta(rename = "@demo") not working due to an issue with the way the macro processed strings for the rename attribute.
  • Fix the combination of #[specta(inline, transparent)] on a struct that also has #[specta(optional)] on the single field. It would previously act as if #[specta(optional)] was not applied.

2.0.0-rc.2 - New datamodel, who dis?

10 Sep 14:54
19fd7a3
Compare
Choose a tag to compare
Pre-release

Specta v2

I have been really happy with Specta v1 but as with everything in life hindsight is 20/20 and so work on a major refactor of Specta's internals has already begun.

One of my biggest goals of Specta v2 is for it to be the last major release. Well actually as close to it as humanly possible. I really want Specta to be able to develop a stable ecosystem similar to other Rust crates such as Serde and frequent major releases discourage downstream crates from adopting Specta support directly and generally make for a horrible DX cause mismatched majors can cause really hard to understand trait errors.

If you're not using a framework with Specta (rspc, tauri-specta) you should be fine to upgrade if you would like to try out the new improvements. This release is "production ready" but it is not shielded from breaking changes so be aware of that. Major changes are going to happen in the next release but they won't affect many of the "public" API's for people using Specta directly. Release notes will also exist to help you upgrade if you do choose to adopt this RC.

WARNING: This release is stable but you must lock its version (Eg. specta = "=2.0.0-rc.2" in your Cargo.toml) because more breaking changes are going to be coming in future release candidates.

As always thanks to @Brendonovich who did a lot of work to aid with typed-error handling which is coming to rspc and tauri-specta very soon!

DataType remodeling

Specta internally works on what we like to call the "DataType system".

This entire system revolves around this massive enum which holds all of the possible types. Specta's Type macro will pass your Rust type and convert it into a DataType and then you can apply any exporter which is able to pass the DataModel format and convert it a string of another programming language.

At its core this is how Specta works but here in lies the limitations with the existing design. The original "DataType system" was designed to be Typescript and Serde-centric. This made it really easy to build the initial version of Specta but it is making is really hard to properly support other language exporters. Specta v2 is going to launch with a completely Rust-centric system. The system will describe your Rust type as is, and provide extra metadata about how Serde sees your type. It will then be completely up to the exporter to interpret this data, validate it, and export the type. This will make implementing other exporters significantly easier and will also allow using Specta with non-Serde formats as the Serde validation will be optional.

This release includes the first part of this remodelling but much more is still to come. All changes to the types in the datatype module are not documented as there was enough of them that it was not worth it. Most users of Specta do not directly touch this system so they will be shielded from breaking changes but if you need assistance upgrading please jump in the Discord and I can give you a hand.

This refactor has led to dropping Result from the return type of Type::* methods as the checking is now done in a Serde post-processing step. Many structs have also moved to private fields and providing accessor methods to make internal API changes possible without breaking the public API. This will help with reducing the need for a Specta's v3 once v2 launches.

New features

  • Added specta::selection (has been moved here from rspc)
  • Add formatter support to ExportConfiguration with builtin support for Prettier and ESLint
  • Doc comment exporting issue - #97
  • Support destructuring in function arguments Eg. fn demo(Demo { demo }: Demo) {}
  • Fix handling of struct A (null) vs struct B () ([]) and struct C {} ({}) - #88
  • Remove unnecessary generics brackets in TS. Eg. type Demo<> = ... is now type Demo = ... - #88

Added support for new crates:

Fixed bugs

  • Exporting maps with non-string/number keys will now error
  • Significantly stricter checking of valid types - Internally tagged enums will fail to export if they could present as a Serde runtime error.
  • Fix handling of #[repr(transparent)]
  • Completely refactoring the SpectaID system. SpectaIDs are now ordered by type name but default and are os-agnostic. The lack of these has caused endless bugs.

Breaking changes

  • Rename collect_types to collect_functions
  • Implemented Type for Result - This does break a lotta frameworks built on Specta (Eg. rspc and tauri-specta)
  • #[specta(remote = "Type")] is now #[specta(remote = Type)] and supports paths such as #[specta(remote = crate::Type)]
  • Remove SpectaFunctionArg & SpectaFunctionResult from public API
  • Change fn_datatype!(type_map, fn_name) to fn_datatype!(type_map; fn_name)
  • Rename export_datatype to export_named_datatype cause it's misleading. Its differentiation with datatype was confusing.
  • Many occurrences of &'static str in the public API have been moved to Cow<'static, str> to increase flexibility
  • #[specta(crate = "todo")] is now #[specta(crate = todo)]
  • Removed ts::RESERVED_IDENTS from public API
  • Drop old specta::RspcType internal API. rspc::Type is deprecated in v1.x.x in favor of using specta::Type directly. If this affects you, what da hell were you doing?
  • Remove the already deprecated rename_to_value attribute from Type macro. Use rename_from_path instead
  • Make export::TYPE_MAP internal and use accessor functions instead.
  • Add SID and IMPL_LOCATION as constants to the NameDataType trait
  • Rename SpectaSID to SpectaID

To be transparent this is not everything, most of the changes to the "DataType system" are not documented because they will affect very few people, and those people can reach out and I would be happy to aid them with the upgrade.

New Contributors

Full Changelog: v1.0.5...v2.0.0-rc.2