#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::notebook::theme;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CodeThemeFile<'a> {
#[serde(borrow)]
pub content: BlobRef<'a>,
#[serde(borrow)]
pub did: Did<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
pub type CodeThemeName<'a> = CowStr<'a>;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Font<'a> {
#[serde(borrow)]
pub value: FontValue<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum FontValue<'a> {
#[serde(rename = "sh.weaver.notebook.theme#fontName")]
FontName(Box<theme::FontName<'a>>),
#[serde(rename = "sh.weaver.notebook.theme#fontFile")]
FontFile(Box<theme::FontFile<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FontFile<'a> {
#[serde(borrow)]
pub content: BlobRef<'a>,
#[serde(borrow)]
pub did: Did<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
pub type FontName<'a> = CowStr<'a>;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", rename = "sh.weaver.notebook.theme", tag = "$type")]
pub struct Theme<'a> {
#[serde(borrow)]
pub dark_code_theme: ThemeDarkCodeTheme<'a>,
#[serde(borrow)]
pub dark_scheme: StrongRef<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default = "_default_theme_default_theme")]
#[serde(borrow)]
pub default_theme: Option<CowStr<'a>>,
#[serde(borrow)]
pub fonts: ThemeFonts<'a>,
#[serde(borrow)]
pub light_code_theme: ThemeLightCodeTheme<'a>,
#[serde(borrow)]
pub light_scheme: StrongRef<'a>,
#[serde(borrow)]
pub spacing: ThemeSpacing<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum ThemeDarkCodeTheme<'a> {
#[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
CodeThemeName(Box<theme::CodeThemeName<'a>>),
#[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
CodeThemeFile(Box<theme::CodeThemeFile<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThemeFonts<'a> {
#[serde(borrow)]
pub body: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
#[serde(borrow)]
pub heading: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
#[serde(borrow)]
pub monospace: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum ThemeLightCodeTheme<'a> {
#[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
CodeThemeName(Box<theme::CodeThemeName<'a>>),
#[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
CodeThemeFile(Box<theme::CodeThemeFile<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ThemeSpacing<'a> {
#[serde(borrow)]
pub base_size: CowStr<'a>,
#[serde(borrow)]
pub line_height: CowStr<'a>,
#[serde(borrow)]
pub scale: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThemeGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Theme<'a>,
}
impl<'a> Theme<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, ThemeRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for CodeThemeFile<'a> {
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<'a> LexiconSchema for Font<'a> {
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<'a> LexiconSchema for FontFile<'a> {
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<'de> = ThemeGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<ThemeGetRecordOutput<'_>> for Theme<'_> {
fn from(output: ThemeGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Theme<'_> {
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<'a> LexiconSchema for Theme<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type Content;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Content = Unset;
type Did = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Content = S::Content;
type Did = S::Did;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type Name = S::Name;
type Content = Set<members::content>;
type Did = S::Did;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Name = S::Name;
type Content = S::Content;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct content(());
pub struct did(());
}
}
pub struct CodeThemeFileBuilder<'a, S: code_theme_file_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>, Option<Did<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> CodeThemeFile<'a> {
pub fn new() -> CodeThemeFileBuilder<'a, code_theme_file_state::Empty> {
CodeThemeFileBuilder::new()
}
}
impl<'a> CodeThemeFileBuilder<'a, code_theme_file_state::Empty> {
pub fn new() -> Self {
CodeThemeFileBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CodeThemeFileBuilder<'a, S>
where
S: code_theme_file_state::State,
S::Content: code_theme_file_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<BlobRef<'a>>,
) -> CodeThemeFileBuilder<'a, code_theme_file_state::SetContent<S>> {
self._fields.0 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CodeThemeFileBuilder<'a, S>
where
S: code_theme_file_state::State,
S::Did: code_theme_file_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> CodeThemeFileBuilder<'a, code_theme_file_state::SetDid<S>> {
self._fields.1 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CodeThemeFileBuilder<'a, S>
where
S: code_theme_file_state::State,
S::Name: code_theme_file_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> CodeThemeFileBuilder<'a, code_theme_file_state::SetName<S>> {
self._fields.2 = Option::Some(value.into());
CodeThemeFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CodeThemeFileBuilder<'a, S>
where
S: code_theme_file_state::State,
S::Name: code_theme_file_state::IsSet,
S::Content: code_theme_file_state::IsSet,
S::Did: code_theme_file_state::IsSet,
{
pub fn build(self) -> CodeThemeFile<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> CodeThemeFile<'a> {
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> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetValue<S> {}
impl<S: State> State for SetValue<S> {
type Value = Set<members::value>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct value(());
}
}
pub struct FontBuilder<'a, S: font_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<FontValue<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Font<'a> {
pub fn new() -> FontBuilder<'a, font_state::Empty> {
FontBuilder::new()
}
}
impl<'a> FontBuilder<'a, font_state::Empty> {
pub fn new() -> Self {
FontBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontBuilder<'a, S>
where
S: font_state::State,
S::Value: font_state::IsUnset,
{
pub fn value(
mut self,
value: impl Into<FontValue<'a>>,
) -> FontBuilder<'a, font_state::SetValue<S>> {
self._fields.0 = Option::Some(value.into());
FontBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontBuilder<'a, S>
where
S: font_state::State,
S::Value: font_state::IsSet,
{
pub fn build(self) -> Font<'a> {
Font {
value: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Font<'a> {
Font {
value: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod font_file_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type Did;
type Content;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Did = Unset;
type Content = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Did = S::Did;
type Content = S::Content;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Name = S::Name;
type Did = Set<members::did>;
type Content = S::Content;
}
pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetContent<S> {}
impl<S: State> State for SetContent<S> {
type Name = S::Name;
type Did = S::Did;
type Content = Set<members::content>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct did(());
pub struct content(());
}
}
pub struct FontFileBuilder<'a, S: font_file_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlobRef<'a>>, Option<Did<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> FontFile<'a> {
pub fn new() -> FontFileBuilder<'a, font_file_state::Empty> {
FontFileBuilder::new()
}
}
impl<'a> FontFileBuilder<'a, font_file_state::Empty> {
pub fn new() -> Self {
FontFileBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontFileBuilder<'a, S>
where
S: font_file_state::State,
S::Content: font_file_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<BlobRef<'a>>,
) -> FontFileBuilder<'a, font_file_state::SetContent<S>> {
self._fields.0 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontFileBuilder<'a, S>
where
S: font_file_state::State,
S::Did: font_file_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> FontFileBuilder<'a, font_file_state::SetDid<S>> {
self._fields.1 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontFileBuilder<'a, S>
where
S: font_file_state::State,
S::Name: font_file_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> FontFileBuilder<'a, font_file_state::SetName<S>> {
self._fields.2 = Option::Some(value.into());
FontFileBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> FontFileBuilder<'a, S>
where
S: font_file_state::State,
S::Name: font_file_state::IsSet,
S::Did: font_file_state::IsSet,
S::Content: font_file_state::IsSet,
{
pub fn build(self) -> FontFile<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> FontFile<'a> {
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() -> Option<CowStr<'static>> {
Some(CowStr::from("auto"))
}
impl<'a> LexiconSchema for ThemeFonts<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Monospace;
type Body;
type Heading;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Monospace = Unset;
type Body = Unset;
type Heading = Unset;
}
pub struct SetMonospace<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMonospace<S> {}
impl<S: State> State for SetMonospace<S> {
type Monospace = Set<members::monospace>;
type Body = S::Body;
type Heading = S::Heading;
}
pub struct SetBody<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBody<S> {}
impl<S: State> State for SetBody<S> {
type Monospace = S::Monospace;
type Body = Set<members::body>;
type Heading = S::Heading;
}
pub struct SetHeading<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHeading<S> {}
impl<S: State> State for SetHeading<S> {
type Monospace = S::Monospace;
type Body = S::Body;
type Heading = Set<members::heading>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct monospace(());
pub struct body(());
pub struct heading(());
}
}
pub struct ThemeFontsBuilder<'a, S: theme_fonts_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ThemeFonts<'a> {
pub fn new() -> ThemeFontsBuilder<'a, theme_fonts_state::Empty> {
ThemeFontsBuilder::new()
}
}
impl<'a> ThemeFontsBuilder<'a, theme_fonts_state::Empty> {
pub fn new() -> Self {
ThemeFontsBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeFontsBuilder<'a, S>
where
S: theme_fonts_state::State,
S::Body: theme_fonts_state::IsUnset,
{
pub fn body(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
) -> ThemeFontsBuilder<'a, theme_fonts_state::SetBody<S>> {
self._fields.0 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeFontsBuilder<'a, S>
where
S: theme_fonts_state::State,
S::Heading: theme_fonts_state::IsUnset,
{
pub fn heading(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
) -> ThemeFontsBuilder<'a, theme_fonts_state::SetHeading<S>> {
self._fields.1 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeFontsBuilder<'a, S>
where
S: theme_fonts_state::State,
S::Monospace: theme_fonts_state::IsUnset,
{
pub fn monospace(
mut self,
value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
) -> ThemeFontsBuilder<'a, theme_fonts_state::SetMonospace<S>> {
self._fields.2 = Option::Some(value.into());
ThemeFontsBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeFontsBuilder<'a, S>
where
S: theme_fonts_state::State,
S::Monospace: theme_fonts_state::IsSet,
S::Body: theme_fonts_state::IsSet,
S::Heading: theme_fonts_state::IsSet,
{
pub fn build(self) -> ThemeFonts<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ThemeFonts<'a> {
ThemeFonts {
body: self._fields.0.unwrap(),
heading: self._fields.1.unwrap(),
monospace: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
impl<'a> LexiconSchema for ThemeSpacing<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type LightScheme;
type DarkCodeTheme;
type DarkScheme;
type Fonts;
type LightCodeTheme;
type Spacing;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LightScheme = Unset;
type DarkCodeTheme = Unset;
type DarkScheme = Unset;
type Fonts = Unset;
type LightCodeTheme = Unset;
type Spacing = Unset;
}
pub struct SetLightScheme<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLightScheme<S> {}
impl<S: State> State for SetLightScheme<S> {
type LightScheme = Set<members::light_scheme>;
type DarkCodeTheme = S::DarkCodeTheme;
type DarkScheme = S::DarkScheme;
type Fonts = S::Fonts;
type LightCodeTheme = S::LightCodeTheme;
type Spacing = S::Spacing;
}
pub struct SetDarkCodeTheme<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDarkCodeTheme<S> {}
impl<S: State> State for SetDarkCodeTheme<S> {
type LightScheme = S::LightScheme;
type DarkCodeTheme = Set<members::dark_code_theme>;
type DarkScheme = S::DarkScheme;
type Fonts = S::Fonts;
type LightCodeTheme = S::LightCodeTheme;
type Spacing = S::Spacing;
}
pub struct SetDarkScheme<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDarkScheme<S> {}
impl<S: State> State for SetDarkScheme<S> {
type LightScheme = S::LightScheme;
type DarkCodeTheme = S::DarkCodeTheme;
type DarkScheme = Set<members::dark_scheme>;
type Fonts = S::Fonts;
type LightCodeTheme = S::LightCodeTheme;
type Spacing = S::Spacing;
}
pub struct SetFonts<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFonts<S> {}
impl<S: State> State for SetFonts<S> {
type LightScheme = S::LightScheme;
type DarkCodeTheme = S::DarkCodeTheme;
type DarkScheme = S::DarkScheme;
type Fonts = Set<members::fonts>;
type LightCodeTheme = S::LightCodeTheme;
type Spacing = S::Spacing;
}
pub struct SetLightCodeTheme<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLightCodeTheme<S> {}
impl<S: State> State for SetLightCodeTheme<S> {
type LightScheme = S::LightScheme;
type DarkCodeTheme = S::DarkCodeTheme;
type DarkScheme = S::DarkScheme;
type Fonts = S::Fonts;
type LightCodeTheme = Set<members::light_code_theme>;
type Spacing = S::Spacing;
}
pub struct SetSpacing<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSpacing<S> {}
impl<S: State> State for SetSpacing<S> {
type LightScheme = S::LightScheme;
type DarkCodeTheme = S::DarkCodeTheme;
type DarkScheme = S::DarkScheme;
type Fonts = S::Fonts;
type LightCodeTheme = S::LightCodeTheme;
type Spacing = Set<members::spacing>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct light_scheme(());
pub struct dark_code_theme(());
pub struct dark_scheme(());
pub struct fonts(());
pub struct light_code_theme(());
pub struct spacing(());
}
}
pub struct ThemeBuilder<'a, S: theme_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ThemeDarkCodeTheme<'a>>,
Option<StrongRef<'a>>,
Option<CowStr<'a>>,
Option<ThemeFonts<'a>>,
Option<ThemeLightCodeTheme<'a>>,
Option<StrongRef<'a>>,
Option<ThemeSpacing<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Theme<'a> {
pub fn new() -> ThemeBuilder<'a, theme_state::Empty> {
ThemeBuilder::new()
}
}
impl<'a> ThemeBuilder<'a, theme_state::Empty> {
pub fn new() -> Self {
ThemeBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::DarkCodeTheme: theme_state::IsUnset,
{
pub fn dark_code_theme(
mut self,
value: impl Into<ThemeDarkCodeTheme<'a>>,
) -> ThemeBuilder<'a, theme_state::SetDarkCodeTheme<S>> {
self._fields.0 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::DarkScheme: theme_state::IsUnset,
{
pub fn dark_scheme(
mut self,
value: impl Into<StrongRef<'a>>,
) -> ThemeBuilder<'a, theme_state::SetDarkScheme<S>> {
self._fields.1 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: theme_state::State> ThemeBuilder<'a, S> {
pub fn default_theme(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_default_theme(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::Fonts: theme_state::IsUnset,
{
pub fn fonts(
mut self,
value: impl Into<ThemeFonts<'a>>,
) -> ThemeBuilder<'a, theme_state::SetFonts<S>> {
self._fields.3 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::LightCodeTheme: theme_state::IsUnset,
{
pub fn light_code_theme(
mut self,
value: impl Into<ThemeLightCodeTheme<'a>>,
) -> ThemeBuilder<'a, theme_state::SetLightCodeTheme<S>> {
self._fields.4 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::LightScheme: theme_state::IsUnset,
{
pub fn light_scheme(
mut self,
value: impl Into<StrongRef<'a>>,
) -> ThemeBuilder<'a, theme_state::SetLightScheme<S>> {
self._fields.5 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::Spacing: theme_state::IsUnset,
{
pub fn spacing(
mut self,
value: impl Into<ThemeSpacing<'a>>,
) -> ThemeBuilder<'a, theme_state::SetSpacing<S>> {
self._fields.6 = Option::Some(value.into());
ThemeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ThemeBuilder<'a, S>
where
S: theme_state::State,
S::LightScheme: theme_state::IsSet,
S::DarkCodeTheme: theme_state::IsSet,
S::DarkScheme: theme_state::IsSet,
S::Fonts: theme_state::IsSet,
S::LightCodeTheme: theme_state::IsSet,
S::Spacing: theme_state::IsSet,
{
pub fn build(self) -> Theme<'a> {
Theme {
dark_code_theme: self._fields.0.unwrap(),
dark_scheme: self._fields.1.unwrap(),
default_theme: self._fields.2.or_else(|| Some(CowStr::from("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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Theme<'a> {
Theme {
dark_code_theme: self._fields.0.unwrap(),
dark_scheme: self._fields.1.unwrap(),
default_theme: self._fields.2.or_else(|| Some(CowStr::from("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),
}
}
}