Skip to content

Commit

Permalink
Move specta::export to `specta_util::export
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Jun 14, 2024
1 parent d1bfae8 commit 0b38b6a
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 14 deletions.
8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@ name = "integration_tests"
path = "tests/lib.rs"
harness = true

[[example]]
name = "export"
required-features = ["export", "typescript"]

# Run `node ./.github/features.js` to update the docs
[features]
default = []

#! Features
## Support for exporting the types of Rust functions.
function = ["serde", "specta-macros/function"]
## Support for collecting up a global type map
export = ["dep:ctor", "specta-macros/export"]

#! Languages
## Support for [TypeScript](https://www.typescriptlang.org) language exporting
Expand Down Expand Up @@ -134,8 +128,6 @@ bevy_ecs = { version = "0.13.2", optional = true, default-features = false }
bevy_input = { version = "0.13.2", optional = true, default-features = false }
thiserror = "1.0.44"
paste = "1.0.14"
ctor = { version = "0.2.4", optional = true }
once_cell = "1.18.0"
specta1 = { package = "specta", version = "1", optional = true, default-features = false }

[dev-dependencies]
Expand Down
33 changes: 33 additions & 0 deletions crates/util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "specta-util"
description = "" # TODO
version = "0.0.1"
authors = ["Oscar Beaumont <[email protected]>"]
edition = "2021"
license = "MIT"
repository = "https://github.com/oscartbeaumont/specta"
documentation = "https://docs.rs/specta-util/latest/specta-util"
keywords = ["async", "specta", "rspc", "typescript", "typesafe"]
categories = ["web-programming", "asynchronous"]

[[example]]
name = "export"
required-features = ["export", "typescript"]

[features]
default = []

#! Features
## Support for collecting up a global type map
export = ["dep:ctor", "specta-macros/export"]

# TODO: Really it would be nice to avoid lanagues in here???
#! Languages
## Support for [TypeScript](https://www.typescriptlang.org) language exporting
typescript = []

[dependencies]
specta = { path = "../../" }
specta-macros = { path = "../../macros" }
ctor = { version = "0.2.4", optional = true }
once_cell = "1.18.0"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/export/export.rs → crates/util/src/export/export.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::*;
use once_cell::sync::Lazy;
use specta::*;
use std::sync::{PoisonError, RwLock, RwLockReadGuard};

// Global type store for collecting custom types to export.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/export/ts.rs → crates/util/src/export/ts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{borrow::Cow, collections::BTreeMap, path::Path};

use crate::{
use specta::{
ts::{self, ExportConfig, ExportError},
TypeMap,
};
Expand Down
12 changes: 12 additions & 0 deletions crates/util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![forbid(unsafe_code)]
#![warn(clippy::all, clippy::unwrap_used, clippy::panic)] // TODO: missing_docs
#![cfg_attr(docsrs2, feature(doc_cfg))]
#![doc(
html_logo_url = "https://github.com/oscartbeaumont/specta/raw/main/.github/logo-128.png",
html_favicon_url = "https://github.com/oscartbeaumont/specta/raw/main/.github/logo-128.png"
)]

/// Provides the global type store and a method to export them to other languages.
#[cfg(feature = "export")]
#[cfg_attr(docsrs2, doc(cfg(feature = "export")))]
pub mod export;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ pub mod internal;

/// Types related to working with [`DataType`](crate::DataType). Exposed for advanced users.
pub mod datatype;
/// Provides the global type store and a method to export them to other languages.
#[cfg(feature = "export")]
#[cfg_attr(docsrs2, doc(cfg(feature = "export")))]
pub mod export;
/// Support for exporting Rust functions.
#[cfg(feature = "function")]
#[cfg_attr(docsrs2, doc(cfg(feature = "function")))]
Expand Down

0 comments on commit 0b38b6a

Please sign in to comment.