Releases: oscartbeaumont/specta
v2.0.0-rc.12 - Fix bugs with enums
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
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
Changes:
- Rename
functions
module tofunction
. So it's nowspecta::function::*
. - Rename
functions
feature tofunction
.
v2.0.0-rc.8 - Steady Steady
Changes:
- Rename
SpectaFunction
,SpectaFunctionArg
andSpectaFunctionResult
toFunction*
- Drop
tauri
feature - Make
FunctionArg
public - Add
Type
implementation forBox<str>
- Bump
bevy
andglam
versions. - Drop
Type::definition
in favor ofType::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
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:
DataTypeFrom
now supports#[specta(rename = "")]
- #186- Adding some new remote impls for glam and bevy - Thanks @bennoinbeta
- Added support for ulid - #155 Thanks @beanow-at-crabnebula
Breaking Changes:
- Remove
Type::definition_generics
function - Remove
DefOpts
- Change
TypeMap
from a type alias of aBTreeMap
to a custom type. - Move
specta::ts::prettier
tospecta::ts::formatters::prettier
2.0.0-rc.6 - Minor fixes
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
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
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 tojs_doc::typedef_named_datatype
Thanks, @avinassh and @Brendonovich for contributing to this release!
2.0.0-rc.3 - A bag of improvements
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 gospecta = { version = "...", features = ["typescript"] }
to use thespecta::ts
andspecta::export::ts
modules.
Other Breaking Changes:
- Drop
serde
as default feature. It's now temporarily undertypescript
. 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
tocfg
onExportContext
- Rename
TsExportError
toExportError
- 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
tospecta::ts::comments::js_doc
. This was just a mistake. - Remove
Into<TupleType> for T where T: DataTypeFrom
. You can useInto<DataType> for T
instead. EnumVariant
was renamed toEnumVariants
andEnumVariant
is now a wrapper struct with shared metadata about the variant such asskip
,comments
ordeprecated
.NamedDataType.comments
is nowNamedDataType.docs
and is nowCow<'static, str>
instead ofVec<Cow<'static, str>>
.CommentFormatterFn
now takesCommentFormatterArgs
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)
andA(#[serde(skip] (), String)
are different types in TS (string
and[string]
respectively) and the exporter needs to know that.
- Drop dependency on
document-features
andindoc
to make builds slightly quicker and fix issues while vendoring Specta - Fix
pub struct A((String))
orpub enum A { A((String)) }
causing the macro to error out. - Reject invalid names when doing
#[specta(rename = "name")]
on a container (struct
orenum
). Eg. names containing@
- Fix
#[specta(rename = "@demo")
not working due to an issue with the way the macro processed strings for therename
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?
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
) vsstruct B ()
([]
) andstruct C {}
({}
) - #88 - Remove unnecessary generics brackets in TS. Eg.
type Demo<> = ...
is nowtype 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
tocollect_functions
- Implemented
Type
forResult
- 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)
tofn_datatype!(type_map; fn_name)
- Rename
export_datatype
toexport_named_datatype
cause it's misleading. Its differentiation withdatatype
was confusing. - Many occurrences of
&'static str
in the public API have been moved toCow<'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 usingspecta::Type
directly. If this affects you, what da hell were you doing? - Remove the already deprecated
rename_to_value
attribute fromType
macro. Userename_from_path
instead - Make
export::TYPE_MAP
internal and use accessor functions instead. - Add
SID
andIMPL_LOCATION
as constants to theNameDataType
trait - Rename
SpectaSID
toSpectaID
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
- @0HyperCube made their first contribution in #97
Full Changelog: v1.0.5...v2.0.0-rc.2