#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Did};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::notebook::theme;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CodeThemeFile<S: BosStr = DefaultStr> {
pub content: BlobRef<S>,
pub did: Did<S>,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub type CodeThemeName<S = DefaultStr> = S;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Font<S: BosStr = DefaultStr> {
pub value: FontValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum FontValue<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.notebook.theme#fontName")]
FontName(Box<theme::FontName<S>>),
#[serde(rename = "sh.weaver.notebook.theme#fontFile")]
FontFile(Box<theme::FontFile<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct FontFile<S: BosStr = DefaultStr> {
pub content: BlobRef<S>,
pub did: Did<S>,
pub name: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub type FontName<S = DefaultStr> = S;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "sh.weaver.notebook.theme",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Theme<S: BosStr = DefaultStr> {
pub dark_code_theme: ThemeDarkCodeTheme<S>,
pub dark_scheme: StrongRef<S>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_theme_default_theme")]
pub default_theme: Option<S>,
pub fonts: ThemeFonts<S>,
pub light_code_theme: ThemeLightCodeTheme<S>,
pub light_scheme: StrongRef<S>,
pub spacing: ThemeSpacing<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ThemeDarkCodeTheme<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
CodeThemeName(Box<theme::CodeThemeName<S>>),
#[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
CodeThemeFile(Box<theme::CodeThemeFile<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ThemeFonts<S: BosStr = DefaultStr> {
pub body: Vec<crate::sh_weaver::notebook::theme::Font<S>>,
pub heading: Vec<crate::sh_weaver::notebook::theme::Font<S>>,
pub monospace: Vec<crate::sh_weaver::notebook::theme::Font<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ThemeLightCodeTheme<S: BosStr = DefaultStr> {
#[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
CodeThemeName(Box<theme::CodeThemeName<S>>),
#[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
CodeThemeFile(Box<theme::CodeThemeFile<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ThemeSpacing<S: BosStr = DefaultStr> {
pub base_size: S,
pub line_height: S,
pub scale: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThemeGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Theme<S>,
}
impl<S: BosStr> Theme<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, ThemeRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CodeThemeFile<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"codeThemeFile"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.content;
{
let size = value.blob().size;
if size > 20000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("content"),
max: 20000usize,
actual: size,
});
}
}
}
{
let value = &self.content;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["*/*"];
let matched = accepted.iter().any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix) && mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("content"),
accepted: vec!["*/*".to_string()],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Font<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"font"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for FontFile<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"fontFile"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.content;
{
let size = value.blob().size;
if size > 20000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("content"),
max: 20000usize,
actual: size,
});
}
}
}
{
let value = &self.content;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["*/*"];
let matched = accepted.iter().any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix) && mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("content"),
accepted: vec!["*/*".to_string()],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ThemeRecord;
impl XrpcResp for ThemeRecord {
const NSID: &'static str = "sh.weaver.notebook.theme";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ThemeGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<ThemeGetRecordOutput<S>> for Theme<S> {
fn from(output: ThemeGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Theme<S> {
const NSID: &'static str = "sh.weaver.notebook.theme";
type Record = ThemeRecord;
}
impl Collection for ThemeRecord {
const NSID: &'static str = "sh.weaver.notebook.theme";
type Record = ThemeRecord;
}
impl<S: BosStr> LexiconSchema for Theme<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod code_theme_file_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Content;
type Name;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
type Name = Unset;
type Did = Unset;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Content = Set<members::content>;
type Name = St::Name;
type Did = St::Did;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Content = St::Content;
type Name = Set<members::name>;
type Did = St::Did;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Content = St::Content;
type Name = St::Name;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
pub struct name(());
pub struct did(());
}
}
pub struct CodeThemeFileBuilder<S: BosStr, St: code_theme_file_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<BlobRef<S>>, Option<Did<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> CodeThemeFile<S> {
pub fn new() -> CodeThemeFileBuilder<S, code_theme_file_state::Empty> {
CodeThemeFileBuilder::new()
}
}
impl<S: BosStr> CodeThemeFileBuilder<S, code_theme_file_state::Empty> {
pub fn new() -> Self {
CodeThemeFileBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CodeThemeFileBuilder<S, St>
where
St: code_theme_file_state::State,
St::Content: code_theme_file_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<BlobRef<S>>,
) -> CodeThemeFileBuilder<S, code_theme_file_state::SetContent<St>> {
self._fields.0 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CodeThemeFileBuilder<S, St>
where
St: code_theme_file_state::State,
St::Did: code_theme_file_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> CodeThemeFileBuilder<S, code_theme_file_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CodeThemeFileBuilder<S, St>
where
St: code_theme_file_state::State,
St::Name: code_theme_file_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> CodeThemeFileBuilder<S, code_theme_file_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CodeThemeFileBuilder<S, St>
where
St: code_theme_file_state::State,
St::Content: code_theme_file_state::IsSet,
St::Name: code_theme_file_state::IsSet,
St::Did: code_theme_file_state::IsSet,
{
pub fn build(self) -> CodeThemeFile<S> {
CodeThemeFile {
content: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> CodeThemeFile<S> {
CodeThemeFile {
content: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_weaver_notebook_theme() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("sh.weaver.notebook.theme"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("codeThemeFile"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Custom syntax highlighting theme file (sublime text/textmate theme format)",
),
),
required: Some(
vec![
SmolStr::new_static("name"), SmolStr::new_static("did"),
SmolStr::new_static("content")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codeThemeName"),
LexUserType::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("font"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("value")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("value"),
LexObjectProperty::Union(LexRefUnion {
description: Some(CowStr::new_static("Font for a notebook")),
refs: vec![
CowStr::new_static("#fontName"),
CowStr::new_static("#fontFile"),
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fontFile"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Custom woff(2) or ttf font file")),
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("did"),
SmolStr::new_static("content"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Blob(LexBlob {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fontName"),
LexUserType::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static("Theme for a notebook")),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("darkScheme"),
SmolStr::new_static("lightScheme"),
SmolStr::new_static("fonts"),
SmolStr::new_static("spacing"),
SmolStr::new_static("darkCodeTheme"),
SmolStr::new_static("lightCodeTheme")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("darkCodeTheme"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Syntax highlighting theme for dark mode",
),
),
refs: vec![
CowStr::new_static("#codeThemeName"),
CowStr::new_static("#codeThemeFile")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("darkScheme"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("defaultTheme"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("fonts"),
LexObjectProperty::Object(LexObject {
description: Some(
CowStr::new_static(
"Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.",
),
),
required: Some(
vec![
SmolStr::new_static("body"), SmolStr::new_static("heading"),
SmolStr::new_static("monospace")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("body"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#font"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("heading"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#font"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("monospace"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#font"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lightCodeTheme"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static(
"Syntax highlighting theme for light mode",
),
),
refs: vec![
CowStr::new_static("#codeThemeName"),
CowStr::new_static("#codeThemeFile")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lightScheme"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("spacing"),
LexObjectProperty::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("baseSize"),
SmolStr::new_static("lineHeight"),
SmolStr::new_static("scale")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("baseSize"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("lineHeight"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("scale"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod font_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Value;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Value = Unset;
}
pub struct SetValue<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetValue<St> {}
impl<St: State> State for SetValue<St> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct FontBuilder<S: BosStr, St: font_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<FontValue<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Font<S> {
pub fn new() -> FontBuilder<S, font_state::Empty> {
FontBuilder::new()
}
}
impl<S: BosStr> FontBuilder<S, font_state::Empty> {
pub fn new() -> Self {
FontBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontBuilder<S, St>
where
St: font_state::State,
St::Value: font_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<FontValue<S>>,
) -> FontBuilder<S, font_state::SetValue<St>> {
self._fields.0 = Option::Some(value.into());
FontBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontBuilder<S, St>
where
St: font_state::State,
St::Value: font_state::IsSet,
{
pub fn build(self) -> Font<S> {
Font {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Font<S> {
Font {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod font_file_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Did;
type Content;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
type Content = Unset;
type Name = Unset;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
type Content = St::Content;
type Name = St::Name;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Did = St::Did;
type Content = Set<members::content>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Did = St::Did;
type Content = St::Content;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
pub struct content(());
pub struct name(());
}
}
pub struct FontFileBuilder<S: BosStr, St: font_file_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<BlobRef<S>>, Option<Did<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> FontFile<S> {
pub fn new() -> FontFileBuilder<S, font_file_state::Empty> {
FontFileBuilder::new()
}
}
impl<S: BosStr> FontFileBuilder<S, font_file_state::Empty> {
pub fn new() -> Self {
FontFileBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontFileBuilder<S, St>
where
St: font_file_state::State,
St::Content: font_file_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<BlobRef<S>>,
) -> FontFileBuilder<S, font_file_state::SetContent<St>> {
self._fields.0 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontFileBuilder<S, St>
where
St: font_file_state::State,
St::Did: font_file_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> FontFileBuilder<S, font_file_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontFileBuilder<S, St>
where
St: font_file_state::State,
St::Name: font_file_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> FontFileBuilder<S, font_file_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> FontFileBuilder<S, St>
where
St: font_file_state::State,
St::Did: font_file_state::IsSet,
St::Content: font_file_state::IsSet,
St::Name: font_file_state::IsSet,
{
pub fn build(self) -> FontFile<S> {
FontFile {
content: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> FontFile<S> {
FontFile {
content: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn _default_theme_default_theme<S: FromStaticStr>() -> ::core::option::Option<S> {
Some(S::from_static("auto"))
}
impl<S: BosStr> LexiconSchema for ThemeFonts<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"ThemeFonts"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod theme_fonts_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Heading;
type Body;
type Monospace;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Heading = Unset;
type Body = Unset;
type Monospace = Unset;
}
pub struct SetHeading<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHeading<St> {}
impl<St: State> State for SetHeading<St> {
type Heading = Set<members::heading>;
type Body = St::Body;
type Monospace = St::Monospace;
}
pub struct SetBody<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBody<St> {}
impl<St: State> State for SetBody<St> {
type Heading = St::Heading;
type Body = Set<members::body>;
type Monospace = St::Monospace;
}
pub struct SetMonospace<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMonospace<St> {}
impl<St: State> State for SetMonospace<St> {
type Heading = St::Heading;
type Body = St::Body;
type Monospace = Set<members::monospace>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct heading(());
pub struct body(());
pub struct monospace(());
}
}
pub struct ThemeFontsBuilder<S: BosStr, St: theme_fonts_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
Option<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ThemeFonts<S> {
pub fn new() -> ThemeFontsBuilder<S, theme_fonts_state::Empty> {
ThemeFontsBuilder::new()
}
}
impl<S: BosStr> ThemeFontsBuilder<S, theme_fonts_state::Empty> {
pub fn new() -> Self {
ThemeFontsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeFontsBuilder<S, St>
where
St: theme_fonts_state::State,
St::Body: theme_fonts_state::IsUnset,
{
pub fn body(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
) -> ThemeFontsBuilder<S, theme_fonts_state::SetBody<St>> {
self._fields.0 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeFontsBuilder<S, St>
where
St: theme_fonts_state::State,
St::Heading: theme_fonts_state::IsUnset,
{
pub fn heading(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
) -> ThemeFontsBuilder<S, theme_fonts_state::SetHeading<St>> {
self._fields.1 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeFontsBuilder<S, St>
where
St: theme_fonts_state::State,
St::Monospace: theme_fonts_state::IsUnset,
{
pub fn monospace(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<S>>>,
) -> ThemeFontsBuilder<S, theme_fonts_state::SetMonospace<St>> {
self._fields.2 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeFontsBuilder<S, St>
where
St: theme_fonts_state::State,
St::Heading: theme_fonts_state::IsSet,
St::Body: theme_fonts_state::IsSet,
St::Monospace: theme_fonts_state::IsSet,
{
pub fn build(self) -> ThemeFonts<S> {
ThemeFonts {
body: self._fields.0.unwrap(),
heading: self._fields.1.unwrap(),
monospace: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ThemeFonts<S> {
ThemeFonts {
body: self._fields.0.unwrap(),
heading: self._fields.1.unwrap(),
monospace: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<S: BosStr> LexiconSchema for ThemeSpacing<S> {
fn nsid() -> &'static str {
"sh.weaver.notebook.theme"
}
fn def_name() -> &'static str {
"ThemeSpacing"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_weaver_notebook_theme()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod theme_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type DarkScheme;
type LightScheme;
type Fonts;
type Spacing;
type DarkCodeTheme;
type LightCodeTheme;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type DarkScheme = Unset;
type LightScheme = Unset;
type Fonts = Unset;
type Spacing = Unset;
type DarkCodeTheme = Unset;
type LightCodeTheme = Unset;
}
pub struct SetDarkScheme<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDarkScheme<St> {}
impl<St: State> State for SetDarkScheme<St> {
type DarkScheme = Set<members::dark_scheme>;
type LightScheme = St::LightScheme;
type Fonts = St::Fonts;
type Spacing = St::Spacing;
type DarkCodeTheme = St::DarkCodeTheme;
type LightCodeTheme = St::LightCodeTheme;
}
pub struct SetLightScheme<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLightScheme<St> {}
impl<St: State> State for SetLightScheme<St> {
type DarkScheme = St::DarkScheme;
type LightScheme = Set<members::light_scheme>;
type Fonts = St::Fonts;
type Spacing = St::Spacing;
type DarkCodeTheme = St::DarkCodeTheme;
type LightCodeTheme = St::LightCodeTheme;
}
pub struct SetFonts<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFonts<St> {}
impl<St: State> State for SetFonts<St> {
type DarkScheme = St::DarkScheme;
type LightScheme = St::LightScheme;
type Fonts = Set<members::fonts>;
type Spacing = St::Spacing;
type DarkCodeTheme = St::DarkCodeTheme;
type LightCodeTheme = St::LightCodeTheme;
}
pub struct SetSpacing<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSpacing<St> {}
impl<St: State> State for SetSpacing<St> {
type DarkScheme = St::DarkScheme;
type LightScheme = St::LightScheme;
type Fonts = St::Fonts;
type Spacing = Set<members::spacing>;
type DarkCodeTheme = St::DarkCodeTheme;
type LightCodeTheme = St::LightCodeTheme;
}
pub struct SetDarkCodeTheme<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDarkCodeTheme<St> {}
impl<St: State> State for SetDarkCodeTheme<St> {
type DarkScheme = St::DarkScheme;
type LightScheme = St::LightScheme;
type Fonts = St::Fonts;
type Spacing = St::Spacing;
type DarkCodeTheme = Set<members::dark_code_theme>;
type LightCodeTheme = St::LightCodeTheme;
}
pub struct SetLightCodeTheme<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLightCodeTheme<St> {}
impl<St: State> State for SetLightCodeTheme<St> {
type DarkScheme = St::DarkScheme;
type LightScheme = St::LightScheme;
type Fonts = St::Fonts;
type Spacing = St::Spacing;
type DarkCodeTheme = St::DarkCodeTheme;
type LightCodeTheme = Set<members::light_code_theme>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct dark_scheme(());
pub struct light_scheme(());
pub struct fonts(());
pub struct spacing(());
pub struct dark_code_theme(());
pub struct light_code_theme(());
}
}
pub struct ThemeBuilder<S: BosStr, St: theme_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ThemeDarkCodeTheme<S>>,
Option<StrongRef<S>>,
Option<S>,
Option<ThemeFonts<S>>,
Option<ThemeLightCodeTheme<S>>,
Option<StrongRef<S>>,
Option<ThemeSpacing<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Theme<S> {
pub fn new() -> ThemeBuilder<S, theme_state::Empty> {
ThemeBuilder::new()
}
}
impl<S: BosStr> ThemeBuilder<S, theme_state::Empty> {
pub fn new() -> Self {
ThemeBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::DarkCodeTheme: theme_state::IsUnset,
{
pub fn dark_code_theme(
mut self,
value: impl Into<ThemeDarkCodeTheme<S>>,
) -> ThemeBuilder<S, theme_state::SetDarkCodeTheme<St>> {
self._fields.0 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::DarkScheme: theme_state::IsUnset,
{
pub fn dark_scheme(
mut self,
value: impl Into<StrongRef<S>>,
) -> ThemeBuilder<S, theme_state::SetDarkScheme<St>> {
self._fields.1 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: theme_state::State> ThemeBuilder<S, St> {
pub fn default_theme(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_default_theme(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::Fonts: theme_state::IsUnset,
{
pub fn fonts(
mut self,
value: impl Into<ThemeFonts<S>>,
) -> ThemeBuilder<S, theme_state::SetFonts<St>> {
self._fields.3 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::LightCodeTheme: theme_state::IsUnset,
{
pub fn light_code_theme(
mut self,
value: impl Into<ThemeLightCodeTheme<S>>,
) -> ThemeBuilder<S, theme_state::SetLightCodeTheme<St>> {
self._fields.4 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::LightScheme: theme_state::IsUnset,
{
pub fn light_scheme(
mut self,
value: impl Into<StrongRef<S>>,
) -> ThemeBuilder<S, theme_state::SetLightScheme<St>> {
self._fields.5 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::Spacing: theme_state::IsUnset,
{
pub fn spacing(
mut self,
value: impl Into<ThemeSpacing<S>>,
) -> ThemeBuilder<S, theme_state::SetSpacing<St>> {
self._fields.6 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ThemeBuilder<S, St>
where
St: theme_state::State,
St::DarkScheme: theme_state::IsSet,
St::LightScheme: theme_state::IsSet,
St::Fonts: theme_state::IsSet,
St::Spacing: theme_state::IsSet,
St::DarkCodeTheme: theme_state::IsSet,
St::LightCodeTheme: theme_state::IsSet,
{
pub fn build(self) -> Theme<S> {
Theme {
dark_code_theme: self._fields.0.unwrap(),
dark_scheme: self._fields.1.unwrap(),
default_theme: self._fields.2.or_else(|| Some(S::from_static("auto"))),
fonts: self._fields.3.unwrap(),
light_code_theme: self._fields.4.unwrap(),
light_scheme: self._fields.5.unwrap(),
spacing: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Theme<S> {
Theme {
dark_code_theme: self._fields.0.unwrap(),
dark_scheme: self._fields.1.unwrap(),
default_theme: self._fields.2.or_else(|| Some(S::from_static("auto"))),
fonts: self._fields.3.unwrap(),
light_code_theme: self._fields.4.unwrap(),
light_scheme: self._fields.5.unwrap(),
spacing: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}