1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (C) 2025 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use crate::*;
#[cfg(feature = "bevy")]
use bevy::prelude::{Component, Deref, DerefMut};
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, sync::Arc};
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Extensions {
/// Hook for downstream extensions to put their own serialized data into
/// the site file.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub data: BTreeMap<Arc<str>, serde_json::Value>,
}
/// Settings for how the site editor interacts with each extension.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExtensionSettings {
/// Always skip this extension while saving.
///
/// This is false by default.
#[serde(default, skip_serializing_if = "is_false")]
pub skip_during_save: bool,
/// When true true, saving will fail if this extension returns an error
/// while saving. When false, a warning will be printed if this extension
/// produces an error while saving.
///
/// This is false by default.
#[serde(default, skip_serializing_if = "is_false")]
pub prevent_saving_on_error: bool,
/// When true, if this extension is missing from the application that tries
/// to load the site or if an error occurs in this extension while trying
/// the site, then the site will not be allowed to load at all.
///
/// If this is false, then the site will load as much as it can and only
/// print a warning in situations where this extension is missing or produces
/// an error while loading.
///
/// This is false by default.
#[serde(default, skip_serializing_if = "is_false")]
pub prevent_loading_on_error: bool,
}
impl Default for ExtensionSettings {
fn default() -> Self {
Self {
skip_during_save: false,
prevent_saving_on_error: false,
prevent_loading_on_error: false,
}
}
}
#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)]
#[serde(transparent)]
#[cfg_attr(feature = "bevy", derive(Component, Deref, DerefMut))]
pub struct SiteExtensionSettings(BTreeMap<Arc<str>, ExtensionSettings>);