Skip to content

Commit 70a84ef

Browse files
🎉 Release 2.0.0-rc.12
1 parent 939d6e4 commit 70a84ef

File tree

8 files changed

+53
-42
lines changed

8 files changed

+53
-42
lines changed

Cargo.lock

Lines changed: 17 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tauri-specta"
33
description = "Completely typesafe Tauri commands"
4-
version = "2.0.0-rc.11"
4+
version = "2.0.0-rc.12"
55
authors = ["Oscar Beaumont <[email protected]>"]
66
edition = "2021"
77
license = "MIT"
@@ -34,7 +34,7 @@ workspace = true
3434
specta = { workspace = true, features = ["function"] }
3535
specta-typescript = { workspace = true, optional = true }
3636
specta-jsdoc = { workspace = true, optional = true }
37-
tauri-specta-macros = { version = "=2.0.0-rc.5", optional = true, path = "./macros" }
37+
tauri-specta-macros = { version = "=2.0.0-rc.6", optional = true, path = "./macros" }
3838
serde = "1"
3939
serde_json = "1"
4040
thiserror = "1"
@@ -65,18 +65,13 @@ panic_in_result_fn = { level = "warn", priority = -1 }
6565

6666
[workspace.dependencies]
6767
tauri = { version = "=2.0.0-beta.25" }
68-
specta = { version = "=2.0.0-rc.16" }
69-
specta-typescript = { version = "0.0.3" }
70-
specta-jsdoc = { version = "0.0.3" }
68+
specta = { version = "=2.0.0-rc.18" }
69+
specta-typescript = { version = "0.0.5" }
70+
specta-jsdoc = { version = "0.0.5" }
7171

72-
[patch.crates-io]
72+
# [patch.crates-io]
7373
# tauri = { git = "https://github.com/oscartbeaumont/tauri.git", rev = "ddc64b706a7f2db271d40e9b216187b1aa153efa" }
7474
# tauri-build = { git = "https://github.com/oscartbeaumont/tauri.git", rev = "ddc64b706a7f2db271d40e9b216187b1aa153efa" }
75-
76-
# specta = { git = "https://github.com/oscartbeaumont/specta.git", rev = "cfa98fa10484e55923497f3cc21edf7418667c76" }
77-
# specta-util = { git = "https://github.com/oscartbeaumont/specta.git", rev = "cfa98fa10484e55923497f3cc21edf7418667c76" }
78-
# specta-typescript = { git = "https://github.com/oscartbeaumont/specta.git", rev = "cfa98fa10484e55923497f3cc21edf7418667c76" }
79-
80-
specta = { path = "../specta/specta" }
81-
specta-typescript = { path = "../specta/specta-typescript" }
82-
specta-jsdoc = { path = "../specta/specta-jsdoc" }
75+
# specta = { path = "../specta/specta" }
76+
# specta-typescript = { path = "../specta/specta-typescript" }
77+
# specta-jsdoc = { path = "../specta/specta-jsdoc" }

macros/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tauri-specta-macros"
33
description = "Completely typesafe Tauri commands"
4-
version = "2.0.0-rc.5"
4+
version = "2.0.0-rc.6"
55
authors = ["Oscar Beaumont <[email protected]>"]
66
edition = "2021"
77
license = "MIT"

macros/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#![doc(
2+
// TODO: Tauri Specta logo
3+
html_logo_url = "https://github.com/oscartbeaumont/specta/raw/main/.github/logo-128.png",
4+
html_favicon_url = "https://github.com/oscartbeaumont/specta/raw/main/.github/logo-128.png"
5+
)]
6+
17
use heck::ToKebabCase;
28
use quote::quote;
39
use syn::{parse_macro_input, DeriveInput};

src/lang/js.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ impl LanguageExt for specta_jsdoc::JSDoc {
2424
&self.0.header,
2525
render_commands(&self.0, cfg)?,
2626
render_events(&self.0, cfg)?,
27+
false,
2728
)
2829
}
2930
}

src/lang/js_ts.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,50 @@
22
//!
33
//! Typescript is a superset of Javascript so they share a lot of logic.
44
5-
use std::{any::TypeId, borrow::Cow, collections::BTreeMap};
5+
use std::{borrow::Cow, collections::BTreeMap};
66

77
use heck::ToLowerCamelCase;
88
use specta::{
99
datatype::{self, DataType, FunctionResultVariant},
1010
TypeMap,
1111
};
12-
use specta_jsdoc::JSDoc;
1312
use specta_typescript::{self as ts};
1413
use specta_typescript::{ExportError, Typescript};
1514

1615
use crate::{apply_as_prefix, ExportContext, ItemType, LanguageExt};
1716

1817
const DO_NOT_EDIT: &str = "// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.";
1918

20-
pub fn render_all_parts<L: LanguageExt + 'static>(
19+
pub fn render_all_parts<L: LanguageExt>(
2120
cfg: &ExportContext,
2221
dependant_types: &str,
2322
globals: &str,
2423
header: &str,
2524
commands: String,
2625
events: String,
26+
as_const: bool,
2727
) -> Result<String, L::Error> {
2828
let constants = cfg
2929
.constants
3030
.iter()
3131
.map(|(name, value)| {
32-
let mut as_const = None;
33-
match &value {
34-
serde_json::Value::Null => {}
35-
serde_json::Value::Bool(_)
36-
| serde_json::Value::Number(_)
37-
| serde_json::Value::String(_)
38-
| serde_json::Value::Array(_)
39-
| serde_json::Value::Object(_) => as_const = Some(" as const"),
40-
}
41-
42-
if TypeId::of::<L>() == TypeId::of::<JSDoc>() {
43-
as_const = None;
32+
let mut as_constt = None;
33+
if as_const {
34+
match &value {
35+
serde_json::Value::Null => {}
36+
serde_json::Value::Bool(_)
37+
| serde_json::Value::Number(_)
38+
| serde_json::Value::String(_)
39+
| serde_json::Value::Array(_)
40+
| serde_json::Value::Object(_) => as_constt = Some(" as const"),
41+
}
4442
}
4543

4644
format!(
4745
"export const {name} = {}{};",
4846
serde_json::to_string(&value)
4947
.expect("failed to serialize from `serde_json::Value`"),
50-
as_const.unwrap_or("")
48+
as_constt.unwrap_or("")
5149
)
5250
})
5351
.collect::<Vec<_>>()
@@ -188,7 +186,7 @@ pub fn events_map(
188186
) -> String {
189187
events
190188
.iter()
191-
.map(|(name, ty)| {
189+
.map(|(name, _)| {
192190
let name_str = plugin_name
193191
.as_ref()
194192
.map(|n| apply_as_prefix(n, name, ItemType::Event))

src/lang/ts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ impl LanguageExt for specta_typescript::Typescript {
2222
&self.header,
2323
render_commands(self, cfg)?,
2424
render_events(self, cfg)?,
25+
true,
2526
)
2627
}
2728
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
//!
1515
//! ```sh
1616
//! # Always required
17-
//! cargo add tauri@=2.0.0-beta.25 specta@=2.0.0-rc.16
17+
//! cargo add tauri@=2.0.0-beta.25 specta@=2.0.0-rc.18
1818
//!
1919
//! # Typescript
20-
//! cargo add [email protected].3
20+
//! cargo add [email protected].5
2121
//! cargo add tauri-specta@=2.0.0-rc.12 --features derive,typescript
2222
//!
2323
//! # JSDoc
24-
//! cargo add [email protected].3
24+
//! cargo add [email protected].5
2525
//! cargo add tauri-specta@=2.0.0-rc.12 --features derive,javascript
2626
//! ```
2727
//!

0 commit comments

Comments
 (0)