diff --git a/schema.json b/schema.json new file mode 100644 index 00000000..2fcdffa7 --- /dev/null +++ b/schema.json @@ -0,0 +1,2566 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "StaticConfig", + "description": "The `komorebi.json` static configuration file reference for `v0.1.40`", + "type": "object", + "properties": { + "animation": { + "description": "Animations configuration options", + "anyOf": [ + { + "$ref": "#/$defs/AnimationsConfig" + }, + { + "type": "null" + } + ] + }, + "app_specific_configuration_path": { + "description": "Path to applications.json from komorebi-application-specific-configurations (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/AppSpecificConfigurationPath" + }, + { + "type": "null" + } + ] + }, + "bar_configurations": { + "description": "Komorebi status bar configuration files for multiple instances on different monitors", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/PathBuf" + } + }, + "border": { + "description": "Display window borders (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "border_colours": { + "description": "Window border colours for different container types (has no effect if a theme is defined)", + "anyOf": [ + { + "$ref": "#/$defs/BorderColours" + }, + { + "type": "null" + } + ] + }, + "border_implementation": { + "description": "Window border implementation (default: Komorebi)", + "anyOf": [ + { + "$ref": "#/$defs/BorderImplementation" + }, + { + "type": "null" + } + ] + }, + "border_offset": { + "description": "Offset of window borders (default: -1)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "border_overflow_applications": { + "description": "Identify border overflow applications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "border_style": { + "description": "Window border style (default: System)", + "anyOf": [ + { + "$ref": "#/$defs/BorderStyle" + }, + { + "type": "null" + } + ] + }, + "border_width": { + "description": "Width of window borders (default: 8)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "border_z_order": { + "description": "DEPRECATED from v0.1.31: no longer required", + "anyOf": [ + { + "$ref": "#/$defs/ZOrder" + }, + { + "type": "null" + } + ] + }, + "cross_boundary_behaviour": { + "description": "Determine what happens when an action is called on a window at a monitor boundary (default: Monitor)", + "anyOf": [ + { + "$ref": "#/$defs/CrossBoundaryBehaviour" + }, + { + "type": "null" + } + ] + }, + "cross_monitor_move_behaviour": { + "description": "Determine what happens when a window is moved across a monitor boundary (default: Swap)", + "anyOf": [ + { + "$ref": "#/$defs/MoveBehaviour" + }, + { + "type": "null" + } + ] + }, + "default_container_padding": { + "description": "Global default container padding (default: 10)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "default_workspace_padding": { + "description": "Global default workspace padding (default: 10)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "display_index_preferences": { + "description": "Set display index preferences", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "type": "string" + } + } + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode\n(default: false)", + "type": [ + "boolean", + "null" + ] + }, + "float_override_placement": { + "description": "Determines the `Placement` to be used when spawning a window with float override active\n(default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "float_rule_placement": { + "description": "Determines the `Placement` to be used when spawning a window that matches a\n'floating_applications' rule (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "floating_applications": { + "description": "Identify applications which should be managed as floating windows", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "floating_layer_behaviour": { + "description": "Determines what happens on a new window when on the `FloatingLayer`\n(default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "floating_layer_placement": { + "description": "Determines the `Placement` to be used when spawning a window on the floating layer with the\n`FloatingLayerBehaviour` set to `FloatingLayerBehaviour::Float` (default: Center)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "floating_window_aspect_ratio": { + "description": "Aspect ratio to resize with when toggling floating mode for a window", + "anyOf": [ + { + "$ref": "#/$defs/AspectRatio" + }, + { + "type": "null" + } + ] + }, + "focus_follows_mouse": { + "description": "END OF LIFE FEATURE: Use https://github.com/LGUG2Z/masir instead", + "anyOf": [ + { + "$ref": "#/$defs/FocusFollowsMouseImplementation" + }, + { + "type": "null" + } + ] + }, + "global_work_area_offset": { + "description": "Global work area (space used for tiling) offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "ignore_rules": { + "description": "Individual window floating rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "invisible_borders": { + "description": "DEPRECATED from v0.1.22: no longer required", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "layered_applications": { + "description": "Identify applications that have the WS_EX_LAYERED extended window style", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "manage_rules": { + "description": "Individual window force-manage rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "minimum_window_height": { + "description": "DISCOURAGED: Minimum height for a window to be eligible for tiling", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "minimum_window_width": { + "description": "DISCOURAGED: Minimum width for a window to be eligible for tiling", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "monitor_index_preferences": { + "description": "Set monitor index preferences", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "$ref": "#/$defs/Rect" + } + } + }, + "monitors": { + "description": "Monitor and workspace configurations", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MonitorConfig" + } + }, + "mouse_follows_focus": { + "description": "Enable or disable mouse follows focus (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "object_name_change_applications": { + "description": "Identify applications that send EVENT_OBJECT_NAMECHANGE on launch (very rare)", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "object_name_change_title_ignore_list": { + "description": "Do not process EVENT_OBJECT_NAMECHANGE events as Show events for identified applications matching these title regexes", + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "remove_titlebar_applications": { + "description": "HEAVILY DISCOURAGED: Identify applications for which komorebi should forcibly remove title bars", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "resize_delta": { + "description": "Delta to resize windows by (default 50)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "slow_application_compensation_time": { + "description": "How long to wait when compensating for slow applications, in milliseconds (default: 20)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "slow_application_identifiers": { + "description": "Identify applications which are slow to send initial event notifications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "stackbar": { + "description": "Stackbar configuration options", + "anyOf": [ + { + "$ref": "#/$defs/StackbarConfig" + }, + { + "type": "null" + } + ] + }, + "theme": { + "description": "Theme configuration options", + "anyOf": [ + { + "$ref": "#/$defs/KomorebiTheme" + }, + { + "type": "null" + } + ] + }, + "toggle_float_placement": { + "description": "Determines the placement of a new window when toggling to float (default: CenterAndResize)", + "anyOf": [ + { + "$ref": "#/$defs/Placement" + }, + { + "type": "null" + } + ] + }, + "transparency": { + "description": "Add transparency to unfocused windows (default: false)", + "type": [ + "boolean", + "null" + ] + }, + "transparency_alpha": { + "description": "Alpha value for unfocused window transparency [[0-255]] (default: 200)", + "type": [ + "integer", + "null" + ], + "format": "uint8", + "maximum": 255, + "minimum": 0 + }, + "transparency_ignore_rules": { + "description": "Individual window transparency ignore rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "tray_and_multi_window_applications": { + "description": "Identify tray and multi-window applications", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "unmanaged_window_operation_behaviour": { + "description": "Determine what happens when commands are sent while an unmanaged window is in the foreground (default: Op)", + "anyOf": [ + { + "$ref": "#/$defs/OperationBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "anyOf": [ + { + "$ref": "#/$defs/WindowContainerBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_handling_behaviour": { + "description": "Which Windows API behaviour to use when manipulating windows (default: Sync)", + "anyOf": [ + { + "$ref": "#/$defs/WindowHandlingBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_hiding_behaviour": { + "description": "Which Windows signal to use when hiding windows (default: Cloak)", + "anyOf": [ + { + "$ref": "#/$defs/HidingBehaviour" + }, + { + "type": "null" + } + ] + } + }, + "$defs": { + "AnimationStyle": { + "oneOf": [ + { + "type": "string", + "enum": [ + "Linear", + "EaseInSine", + "EaseOutSine", + "EaseInOutSine", + "EaseInQuad", + "EaseOutQuad", + "EaseInOutQuad", + "EaseInCubic", + "EaseInOutCubic", + "EaseInQuart", + "EaseOutQuart", + "EaseInOutQuart", + "EaseInQuint", + "EaseOutQuint", + "EaseInOutQuint", + "EaseInExpo", + "EaseOutExpo", + "EaseInOutExpo", + "EaseInCirc", + "EaseOutCirc", + "EaseInOutCirc", + "EaseInBack", + "EaseOutBack", + "EaseInOutBack", + "EaseInElastic", + "EaseOutElastic", + "EaseInOutElastic", + "EaseInBounce", + "EaseOutBounce", + "EaseInOutBounce" + ] + }, + { + "type": "object", + "properties": { + "CubicBezier": { + "type": "array", + "maxItems": 4, + "minItems": 4, + "prefixItems": [ + { + "type": "number", + "format": "double" + }, + { + "type": "number", + "format": "double" + }, + { + "type": "number", + "format": "double" + }, + { + "type": "number", + "format": "double" + } + ] + } + }, + "additionalProperties": false, + "required": [ + "CubicBezier" + ] + } + ] + }, + "AnimationsConfig": { + "type": "object", + "properties": { + "duration": { + "description": "Set the animation duration in ms (default: 250)", + "anyOf": [ + { + "$ref": "#/$defs/PerAnimationPrefixConfig2" + }, + { + "type": "null" + } + ] + }, + "enabled": { + "description": "Enable or disable animations (default: false)", + "$ref": "#/$defs/PerAnimationPrefixConfig" + }, + "fps": { + "description": "Set the animation FPS (default: 60)", + "type": [ + "integer", + "null" + ], + "format": "uint64", + "minimum": 0 + }, + "style": { + "description": "Set the animation style (default: Linear)", + "anyOf": [ + { + "$ref": "#/$defs/PerAnimationPrefixConfig3" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "enabled" + ] + }, + "AppSpecificConfigurationPath": { + "anyOf": [ + { + "description": "A single applications.json file", + "$ref": "#/$defs/PathBuf" + }, + { + "description": "Multiple applications.json files", + "type": "array", + "items": { + "$ref": "#/$defs/PathBuf" + } + } + ] + }, + "ApplicationIdentifier": { + "type": "string", + "enum": [ + "Exe", + "Class", + "Title", + "Path" + ] + }, + "AspectRatio": { + "anyOf": [ + { + "description": "A predefined aspect ratio", + "$ref": "#/$defs/PredefinedAspectRatio" + }, + { + "description": "A custom W:H aspect ratio", + "type": "array", + "maxItems": 2, + "minItems": 2, + "prefixItems": [ + { + "type": "integer", + "format": "int32" + }, + { + "type": "integer", + "format": "int32" + } + ] + } + ] + }, + "Axis": { + "type": "string", + "enum": [ + "Horizontal", + "Vertical", + "HorizontalAndVertical" + ] + }, + "Base16": { + "type": "string", + "enum": [ + "3024", + "Apathy", + "Apprentice", + "Ashes", + "AtelierCaveLight", + "AtelierCave", + "AtelierDuneLight", + "AtelierDune", + "AtelierEstuaryLight", + "AtelierEstuary", + "AtelierForestLight", + "AtelierForest", + "AtelierHeathLight", + "AtelierHeath", + "AtelierLakesideLight", + "AtelierLakeside", + "AtelierPlateauLight", + "AtelierPlateau", + "AtelierSavannaLight", + "AtelierSavanna", + "AtelierSeasideLight", + "AtelierSeaside", + "AtelierSulphurpoolLight", + "AtelierSulphurpool", + "Atlas", + "AyuDark", + "AyuLight", + "AyuMirage", + "Aztec", + "Bespin", + "BlackMetalBathory", + "BlackMetalBurzum", + "BlackMetalDarkFuneral", + "BlackMetalGorgoroth", + "BlackMetalImmortal", + "BlackMetalKhold", + "BlackMetalMarduk", + "BlackMetalMayhem", + "BlackMetalNile", + "BlackMetalVenom", + "BlackMetal", + "Blueforest", + "Blueish", + "Brewer", + "Bright", + "Brogrammer", + "BrushtreesDark", + "Brushtrees", + "Caroline", + "CatppuccinFrappe", + "CatppuccinLatte", + "CatppuccinMacchiato", + "CatppuccinMocha", + "Chalk", + "Circus", + "ClassicDark", + "ClassicLight", + "Codeschool", + "Colors", + "Cupcake", + "Cupertino", + "DaOneBlack", + "DaOneGray", + "DaOneOcean", + "DaOnePaper", + "DaOneSea", + "DaOneWhite", + "DanqingLight", + "Danqing", + "Darcula", + "Darkmoss", + "Darktooth", + "Darkviolet", + "Decaf", + "DefaultDark", + "DefaultLight", + "Dirtysea", + "Dracula", + "EdgeDark", + "EdgeLight", + "Eighties", + "EmbersLight", + "Embers", + "Emil", + "EquilibriumDark", + "EquilibriumGrayDark", + "EquilibriumGrayLight", + "EquilibriumLight", + "Eris", + "Espresso", + "EvaDim", + "Eva", + "EvenokDark", + "EverforestDarkHard", + "Everforest", + "Flat", + "Framer", + "FruitSoda", + "Gigavolt", + "Github", + "GoogleDark", + "GoogleLight", + "Gotham", + "GrayscaleDark", + "GrayscaleLight", + "Greenscreen", + "Gruber", + "GruvboxDarkHard", + "GruvboxDarkMedium", + "GruvboxDarkPale", + "GruvboxDarkSoft", + "GruvboxLightHard", + "GruvboxLightMedium", + "GruvboxLightSoft", + "GruvboxMaterialDarkHard", + "GruvboxMaterialDarkMedium", + "GruvboxMaterialDarkSoft", + "GruvboxMaterialLightHard", + "GruvboxMaterialLightMedium", + "GruvboxMaterialLightSoft", + "Hardcore", + "Harmonic16Dark", + "Harmonic16Light", + "HeetchLight", + "Heetch", + "Helios", + "Hopscotch", + "HorizonDark", + "HorizonLight", + "HorizonTerminalDark", + "HorizonTerminalLight", + "HumanoidDark", + "HumanoidLight", + "IaDark", + "IaLight", + "Icy", + "Irblack", + "Isotope", + "Jabuti", + "Kanagawa", + "Katy", + "Kimber", + "Lime", + "Macintosh", + "Marrakesh", + "Materia", + "MaterialDarker", + "MaterialLighter", + "MaterialPalenight", + "MaterialVivid", + "Material", + "MeasuredDark", + "MeasuredLight", + "MellowPurple", + "MexicoLight", + "Mocha", + "Monokai", + "Moonlight", + "Mountain", + "Nebula", + "NordLight", + "Nord", + "Nova", + "Ocean", + "Oceanicnext", + "OneLight", + "OnedarkDark", + "Onedark", + "OutrunDark", + "OxocarbonDark", + "OxocarbonLight", + "Pandora", + "PapercolorDark", + "PapercolorLight", + "Paraiso", + "Pasque", + "Phd", + "Pico", + "Pinky", + "Pop", + "Porple", + "PreciousDarkEleven", + "PreciousDarkFifteen", + "PreciousLightWarm", + "PreciousLightWhite", + "PrimerDarkDimmed", + "PrimerDark", + "PrimerLight", + "Purpledream", + "Qualia", + "Railscasts", + "Rebecca", + "RosePineDawn", + "RosePineMoon", + "RosePine", + "Saga", + "Sagelight", + "Sakura", + "Sandcastle", + "SelenizedBlack", + "SelenizedDark", + "SelenizedLight", + "SelenizedWhite", + "Seti", + "ShadesOfPurple", + "ShadesmearDark", + "ShadesmearLight", + "Shapeshifter", + "SilkDark", + "SilkLight", + "Snazzy", + "SolarflareLight", + "Solarflare", + "SolarizedDark", + "SolarizedLight", + "Spaceduck", + "Spacemacs", + "Sparky", + "StandardizedDark", + "StandardizedLight", + "Stella", + "StillAlive", + "Summercamp", + "SummerfruitDark", + "SummerfruitLight", + "SynthMidnightDark", + "SynthMidnightLight", + "Tango", + "Tarot", + "Tender", + "TerracottaDark", + "Terracotta", + "TokyoCityDark", + "TokyoCityLight", + "TokyoCityTerminalDark", + "TokyoCityTerminalLight", + "TokyoNightDark", + "TokyoNightLight", + "TokyoNightMoon", + "TokyoNightStorm", + "TokyoNightTerminalDark", + "TokyoNightTerminalLight", + "TokyoNightTerminalStorm", + "TokyodarkTerminal", + "Tokyodark", + "TomorrowNightEighties", + "TomorrowNight", + "Tomorrow", + "Tube", + "Twilight", + "UnikittyDark", + "UnikittyLight", + "UnikittyReversible", + "Uwunicorn", + "Vesper", + "Vice", + "Vulcan", + "Windows10Light", + "Windows10", + "Windows95Light", + "Windows95", + "WindowsHighcontrastLight", + "WindowsHighcontrast", + "WindowsNtLight", + "WindowsNt", + "Woodland", + "XcodeDusk", + "Zenbones", + "Zenburn" + ] + }, + "Base16ColourPalette": { + "type": "object", + "properties": { + "base_00": { + "$ref": "#/$defs/Colour" + }, + "base_01": { + "$ref": "#/$defs/Colour" + }, + "base_02": { + "$ref": "#/$defs/Colour" + }, + "base_03": { + "$ref": "#/$defs/Colour" + }, + "base_04": { + "$ref": "#/$defs/Colour" + }, + "base_05": { + "$ref": "#/$defs/Colour" + }, + "base_06": { + "$ref": "#/$defs/Colour" + }, + "base_07": { + "$ref": "#/$defs/Colour" + }, + "base_08": { + "$ref": "#/$defs/Colour" + }, + "base_09": { + "$ref": "#/$defs/Colour" + }, + "base_0a": { + "$ref": "#/$defs/Colour" + }, + "base_0b": { + "$ref": "#/$defs/Colour" + }, + "base_0c": { + "$ref": "#/$defs/Colour" + }, + "base_0d": { + "$ref": "#/$defs/Colour" + }, + "base_0e": { + "$ref": "#/$defs/Colour" + }, + "base_0f": { + "$ref": "#/$defs/Colour" + } + }, + "required": [ + "base_00", + "base_01", + "base_02", + "base_03", + "base_04", + "base_05", + "base_06", + "base_07", + "base_08", + "base_09", + "base_0a", + "base_0b", + "base_0c", + "base_0d", + "base_0e", + "base_0f" + ] + }, + "Base16Value": { + "type": "string", + "enum": [ + "Base00", + "Base01", + "Base02", + "Base03", + "Base04", + "Base05", + "Base06", + "Base07", + "Base08", + "Base09", + "Base0A", + "Base0B", + "Base0C", + "Base0D", + "Base0E", + "Base0F" + ] + }, + "BorderColours": { + "type": "object", + "properties": { + "floating": { + "description": "Border colour when the container is in floating mode", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "monocle": { + "description": "Border colour when the container is in monocle mode", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "single": { + "description": "Border colour when the container contains a single window", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "stack": { + "description": "Border colour when the container contains multiple windows", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "unfocused": { + "description": "Border colour when the container is unfocused", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked": { + "description": "Border colour when the container is unfocused and locked", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + } + } + }, + "BorderImplementation": { + "oneOf": [ + { + "description": "Use the adjustable komorebi border implementation", + "type": "string", + "const": "Komorebi" + }, + { + "description": "Use the thin Windows accent border implementation", + "type": "string", + "const": "Windows" + } + ] + }, + "BorderStyle": { + "oneOf": [ + { + "description": "Use the system border style", + "type": "string", + "const": "System" + }, + { + "description": "Use the Windows 11-style rounded borders", + "type": "string", + "const": "Rounded" + }, + { + "description": "Use the Windows 10-style square borders", + "type": "string", + "const": "Square" + } + ] + }, + "Catppuccin": { + "type": "string", + "enum": [ + "Frappe", + "Latte", + "Macchiato", + "Mocha" + ] + }, + "CatppuccinValue": { + "type": "string", + "enum": [ + "Rosewater", + "Flamingo", + "Pink", + "Mauve", + "Red", + "Maroon", + "Peach", + "Yellow", + "Green", + "Teal", + "Sky", + "Sapphire", + "Blue", + "Lavender", + "Text", + "Subtext1", + "Subtext0", + "Overlay2", + "Overlay1", + "Overlay0", + "Surface2", + "Surface1", + "Surface0", + "Base", + "Mantle", + "Crust" + ] + }, + "Colour": { + "anyOf": [ + { + "description": "Colour represented as RGB", + "$ref": "#/$defs/Rgb" + }, + { + "description": "Colour represented as Hex", + "$ref": "#/$defs/Hex" + } + ] + }, + "CrossBoundaryBehaviour": { + "oneOf": [ + { + "description": "Attempt to perform actions across a workspace boundary", + "type": "string", + "const": "Workspace" + }, + { + "description": "Attempt to perform actions across a monitor boundary", + "type": "string", + "const": "Monitor" + } + ] + }, + "DefaultLayout": { + "type": "string", + "enum": [ + "BSP", + "Columns", + "Rows", + "VerticalStack", + "HorizontalStack", + "UltrawideVerticalStack", + "Grid", + "RightMainVerticalStack", + "Scrolling" + ] + }, + "FloatingLayerBehaviour": { + "oneOf": [ + { + "description": "Tile new windows (unless they match a float rule or float override is active)", + "type": "string", + "const": "Tile" + }, + { + "description": "Float new windows", + "type": "string", + "const": "Float" + } + ] + }, + "FocusFollowsMouseImplementation": { + "oneOf": [ + { + "description": "A custom FFM implementation (slightly more CPU-intensive)", + "type": "string", + "const": "Komorebi" + }, + { + "description": "The native (legacy) Windows FFM implementation", + "type": "string", + "const": "Windows" + } + ] + }, + "GridLayoutOptions": { + "type": "object", + "properties": { + "rows": { + "description": "Maximum number of rows per grid column", + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "rows" + ] + }, + "Hex": { + "type": "string", + "format": "color-hex" + }, + "HidingBehaviour": { + "oneOf": [ + { + "description": "END OF LIFE FEATURE: Use the SW_HIDE flag to hide windows when switching workspaces (has issues with Electron apps)", + "type": "string", + "const": "Hide" + }, + { + "description": "Use the SW_MINIMIZE flag to hide windows when switching workspaces (has issues with frequent workspace switching)", + "type": "string", + "const": "Minimize" + }, + { + "description": "Use the undocumented SetCloak Win32 function to hide windows when switching workspaces", + "type": "string", + "const": "Cloak" + } + ] + }, + "IdWithIdentifier": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "kind": { + "$ref": "#/$defs/ApplicationIdentifier" + }, + "matching_strategy": { + "anyOf": [ + { + "$ref": "#/$defs/MatchingStrategy" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "kind", + "id" + ] + }, + "KomorebiTheme": { + "oneOf": [ + { + "description": "A theme from catppuccin-egui", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Blue)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Yellow)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Pink)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Catppuccin theme (theme previews: https://github.com/catppuccin/catppuccin)", + "$ref": "#/$defs/Catppuccin" + }, + "palette": { + "type": "string", + "const": "Catppuccin" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Blue)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Green)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Green)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Text)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Red)", + "anyOf": [ + { + "$ref": "#/$defs/CatppuccinValue" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A theme from base16-egui-themes", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "name": { + "description": "Name of the Base16 theme (theme previews: https://tinted-theming.github.io/tinted-gallery/)", + "$ref": "#/$defs/Base16" + }, + "palette": { + "type": "string", + "const": "Base16" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "name" + ] + }, + { + "description": "A custom Base16 theme", + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "colours": { + "description": "Colours of the custom Base16 theme palette", + "$ref": "#/$defs/Base16ColourPalette" + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "palette": { + "type": "string", + "const": "Custom" + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "palette", + "colours" + ] + } + ] + }, + "LayoutOptions": { + "type": "object", + "properties": { + "grid": { + "description": "Options related to the Grid layout", + "anyOf": [ + { + "$ref": "#/$defs/GridLayoutOptions" + }, + { + "type": "null" + } + ] + }, + "scrolling": { + "description": "Options related to the Scrolling layout", + "anyOf": [ + { + "$ref": "#/$defs/ScrollingLayoutOptions" + }, + { + "type": "null" + } + ] + } + } + }, + "MatchingRule": { + "anyOf": [ + { + "$ref": "#/$defs/IdWithIdentifier" + }, + { + "type": "array", + "items": { + "$ref": "#/$defs/IdWithIdentifier" + } + } + ] + }, + "MatchingStrategy": { + "type": "string", + "enum": [ + "Legacy", + "Equals", + "StartsWith", + "EndsWith", + "Contains", + "Regex", + "DoesNotEndWith", + "DoesNotStartWith", + "DoesNotEqual", + "DoesNotContain" + ] + }, + "MonitorConfig": { + "type": "object", + "properties": { + "container_padding": { + "description": "Container padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "wallpaper": { + "description": "Specify a wallpaper for this monitor", + "anyOf": [ + { + "$ref": "#/$defs/Wallpaper" + }, + { + "type": "null" + } + ] + }, + "window_based_work_area_offset": { + "description": "Window based work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "window_based_work_area_offset_limit": { + "description": "Open window limit after which the window based work area offset will no longer be applied (default: 1)", + "type": [ + "integer", + "null" + ], + "format": "int" + }, + "work_area_offset": { + "description": "Monitor-specific work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "workspaces": { + "description": "Workspace configurations", + "type": "array", + "items": { + "$ref": "#/$defs/WorkspaceConfig" + } + } + }, + "required": [ + "workspaces" + ] + }, + "MoveBehaviour": { + "oneOf": [ + { + "description": "Swap the window container with the window container at the edge of the adjacent monitor", + "type": "string", + "const": "Swap" + }, + { + "description": "Insert the window container into the focused workspace on the adjacent monitor", + "type": "string", + "const": "Insert" + }, + { + "description": "Do nothing if trying to move a window container in the direction of an adjacent monitor", + "type": "string", + "const": "NoOp" + } + ] + }, + "OperationBehaviour": { + "oneOf": [ + { + "description": "Process komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "const": "Op" + }, + { + "description": "Ignore komorebic commands on temporarily unmanaged/floated windows", + "type": "string", + "const": "NoOp" + } + ] + }, + "PathBuf": { + "type": "string" + }, + "PerAnimationPrefixConfig": { + "anyOf": [ + { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + { + "type": "boolean" + } + ] + }, + "PerAnimationPrefixConfig2": { + "anyOf": [ + { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + }, + { + "type": "integer", + "format": "uint64", + "minimum": 0 + } + ] + }, + "PerAnimationPrefixConfig3": { + "anyOf": [ + { + "type": "object", + "additionalProperties": { + "$ref": "#/$defs/AnimationStyle" + } + }, + { + "$ref": "#/$defs/AnimationStyle" + } + ] + }, + "Placement": { + "oneOf": [ + { + "description": "Does not change the size or position of the window", + "type": "string", + "const": "None" + }, + { + "description": "Center the window without changing the size", + "type": "string", + "const": "Center" + }, + { + "description": "Center the window and resize it according to the `AspectRatio`", + "type": "string", + "const": "CenterAndResize" + } + ] + }, + "PredefinedAspectRatio": { + "oneOf": [ + { + "description": "21:9", + "type": "string", + "const": "Ultrawide" + }, + { + "description": "16:9", + "type": "string", + "const": "Widescreen" + }, + { + "description": "4:3", + "type": "string", + "const": "Standard" + } + ] + }, + "Rect": { + "type": "object", + "properties": { + "bottom": { + "description": "The bottom point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "left": { + "description": "The left point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "right": { + "description": "The right point in a Win32 Rect", + "type": "integer", + "format": "int32" + }, + "top": { + "description": "The top point in a Win32 Rect", + "type": "integer", + "format": "int32" + } + }, + "required": [ + "left", + "top", + "right", + "bottom" + ] + }, + "Rgb": { + "type": "object", + "properties": { + "b": { + "description": "Blue", + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "g": { + "description": "Green", + "type": "integer", + "format": "uint32", + "minimum": 0 + }, + "r": { + "description": "Red", + "type": "integer", + "format": "uint32", + "minimum": 0 + } + }, + "required": [ + "r", + "g", + "b" + ] + }, + "ScrollingLayoutOptions": { + "type": "object", + "properties": { + "center_focused_column": { + "description": "With an odd number of visible columns, keep the focused window column centered", + "type": [ + "boolean", + "null" + ] + }, + "columns": { + "description": "Desired number of visible columns (default: 3)", + "type": "integer", + "format": "uint", + "minimum": 0 + } + }, + "required": [ + "columns" + ] + }, + "StackbarConfig": { + "type": "object", + "properties": { + "height": { + "description": "Stackbar height", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "label": { + "description": "Stackbar label", + "anyOf": [ + { + "$ref": "#/$defs/StackbarLabel" + }, + { + "type": "null" + } + ] + }, + "mode": { + "description": "Stackbar mode (default: Never)", + "anyOf": [ + { + "$ref": "#/$defs/StackbarMode" + }, + { + "type": "null" + } + ] + }, + "tabs": { + "description": "Stackbar tab configuration options", + "anyOf": [ + { + "$ref": "#/$defs/TabsConfig" + }, + { + "type": "null" + } + ] + } + } + }, + "StackbarLabel": { + "type": "string", + "enum": [ + "Process", + "Title" + ] + }, + "StackbarMode": { + "type": "string", + "enum": [ + "Always", + "Never", + "OnStack" + ] + }, + "TabsConfig": { + "type": "object", + "properties": { + "background": { + "description": "Tab background colour", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "focused_text": { + "description": "Focused tab text colour", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "font_family": { + "description": "Font family", + "type": [ + "string", + "null" + ] + }, + "font_size": { + "description": "Font size", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "unfocused_text": { + "description": "Unfocused tab text colour", + "anyOf": [ + { + "$ref": "#/$defs/Colour" + }, + { + "type": "null" + } + ] + }, + "width": { + "description": "Width of a stackbar tab", + "type": [ + "integer", + "null" + ], + "format": "int32" + } + } + }, + "ThemeOptions": { + "type": "object", + "properties": { + "bar_accent": { + "description": "Komorebi status bar accent (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "floating_border": { + "description": "Border colour when the window is floating (default: Base09)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "monocle_border": { + "description": "Border colour when the container is in monocle mode (default: Base0F)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "single_border": { + "description": "Border colour when the container contains a single window (default: Base0D)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stack_border": { + "description": "Border colour when the container contains multiple windows (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_background": { + "description": "Stackbar tab background colour (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_focused_text": { + "description": "Stackbar focused tab text colour (default: Base0B)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "stackbar_unfocused_text": { + "description": "Stackbar unfocused tab text colour (default: Base05)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "theme_variant": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "anyOf": [ + { + "$ref": "#/$defs/ThemeVariant" + }, + { + "type": "null" + } + ] + }, + "unfocused_border": { + "description": "Border colour when the container is unfocused (default: Base01)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + }, + "unfocused_locked_border": { + "description": "Border colour when the container is unfocused and locked (default: Base08)", + "anyOf": [ + { + "$ref": "#/$defs/Base16Value" + }, + { + "type": "null" + } + ] + } + } + }, + "ThemeVariant": { + "type": "string", + "enum": [ + "Dark", + "Light" + ] + }, + "Wallpaper": { + "type": "object", + "properties": { + "generate_theme": { + "description": "Generate and apply Base16 theme for this wallpaper (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "path": { + "description": "Path to the wallpaper image file", + "$ref": "#/$defs/PathBuf" + }, + "theme_options": { + "description": "Specify Light or Dark variant for theme generation (default: Dark)", + "anyOf": [ + { + "$ref": "#/$defs/ThemeOptions" + }, + { + "type": "null" + } + ] + } + }, + "required": [ + "path" + ] + }, + "WindowContainerBehaviour": { + "oneOf": [ + { + "description": "Create a new container for each new window", + "type": "string", + "const": "Create" + }, + { + "description": "Append new windows to the focused window container", + "type": "string", + "const": "Append" + } + ] + }, + "WindowHandlingBehaviour": { + "type": "string", + "enum": [ + "Sync", + "Async" + ] + }, + "WorkspaceConfig": { + "type": "object", + "properties": { + "apply_window_based_work_area_offset": { + "description": "Apply this monitor's window-based work area offset (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "container_padding": { + "description": "Container padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "custom_layout": { + "description": "END OF LIFE FEATURE: Custom Layout (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/PathBuf" + }, + { + "type": "null" + } + ] + }, + "custom_layout_rules": { + "description": "END OF LIFE FEATURE: Custom layout rules (default: None)", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "type": "string" + } + } + }, + "float_override": { + "description": "Enable or disable float override, which makes it so every new window opens in floating mode (default: false)", + "type": [ + "boolean", + "null" + ] + }, + "floating_layer_behaviour": { + "description": "Determine what happens to a new window when the Floating workspace layer is active (default: Tile)", + "anyOf": [ + { + "$ref": "#/$defs/FloatingLayerBehaviour" + }, + { + "type": "null" + } + ] + }, + "initial_workspace_rules": { + "description": "Initial workspace application rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + }, + "layout": { + "description": "Layout (default: BSP)", + "anyOf": [ + { + "$ref": "#/$defs/DefaultLayout" + }, + { + "type": "null" + } + ] + }, + "layout_flip": { + "description": "Specify an axis on which to flip the selected layout (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Axis" + }, + { + "type": "null" + } + ] + }, + "layout_options": { + "description": "Layout-specific options (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/LayoutOptions" + }, + { + "type": "null" + } + ] + }, + "layout_rules": { + "description": "Layout rules in the format of threshold => layout (default: None)", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "$ref": "#/$defs/DefaultLayout" + } + } + }, + "name": { + "description": "Name", + "type": "string" + }, + "tile": { + "description": "Enable or disable tiling for the workspace (default: true)", + "type": [ + "boolean", + "null" + ] + }, + "wallpaper": { + "description": "Specify a wallpaper for this workspace", + "anyOf": [ + { + "$ref": "#/$defs/Wallpaper" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour": { + "description": "Determine what happens when a new window is opened (default: Create)", + "anyOf": [ + { + "$ref": "#/$defs/WindowContainerBehaviour" + }, + { + "type": "null" + } + ] + }, + "window_container_behaviour_rules": { + "description": "Window container behaviour rules in the format of threshold => behaviour (default: None)", + "type": [ + "object", + "null" + ], + "additionalProperties": false, + "patternProperties": { + "^\\d+$": { + "$ref": "#/$defs/WindowContainerBehaviour" + } + } + }, + "work_area_offset": { + "description": "Workspace specific work area offset (default: None)", + "anyOf": [ + { + "$ref": "#/$defs/Rect" + }, + { + "type": "null" + } + ] + }, + "workspace_padding": { + "description": "Workspace padding (default: global)", + "type": [ + "integer", + "null" + ], + "format": "int32" + }, + "workspace_rules": { + "description": "Permanent workspace application rules", + "type": [ + "array", + "null" + ], + "items": { + "$ref": "#/$defs/MatchingRule" + } + } + }, + "required": [ + "name" + ] + }, + "ZOrder": { + "type": "string", + "enum": [ + "Top", + "NoTopMost", + "Bottom", + "TopMost" + ] + } + } +} diff --git a/src/generator.rs b/src/generator.rs index 37bb61ec..29a608fa 100644 --- a/src/generator.rs +++ b/src/generator.rs @@ -2,6 +2,9 @@ use crate::Error; use crate::Options; +use crate::identifiers::CSS; +use crate::identifiers::IDS; +use crate::identifiers::TYPE_CLASSES; use crate::prepare::NavigationData; use crate::prepare::build_navigation; use crate::prepare::prepare_for_template; @@ -108,6 +111,11 @@ impl Generator { .unwrap_or_default(); context.insert("required_set", &required_set); + // Add CSS classes and HTML IDs from the single source of truth + context.insert("ids", &IDS); + context.insert("css", &CSS); + context.insert("type_classes", &TYPE_CLASSES); + Ok(context) } } diff --git a/src/identifiers.rs b/src/identifiers.rs new file mode 100644 index 00000000..a2c0a70b --- /dev/null +++ b/src/identifiers.rs @@ -0,0 +1,284 @@ +//! Single source of truth for all CSS classes and HTML IDs +//! +//! This module centralizes all identifier strings used in the generated HTML output. +//! By defining them here, we ensure consistency between Rust code, HTML templates, +//! CSS styles, and JavaScript. + +use serde::Serialize; + +/// Static HTML element IDs used for JavaScript interaction +#[derive(Debug, Clone, Serialize)] +pub struct HtmlIds { + pub search: &'static str, + pub search_results: &'static str, + pub sidebar: &'static str, + pub sidebar_toggle: &'static str, + pub root_schema: &'static str, + pub definitions: &'static str, +} + +/// All static HTML IDs +pub const IDS: HtmlIds = HtmlIds { + search: "search", + search_results: "search-results", + sidebar: "sidebar", + sidebar_toggle: "sidebar-toggle", + root_schema: "root-schema", + definitions: "definitions", +}; + +/// CSS class names organized by category +#[derive(Debug, Clone, Serialize)] +pub struct CssClasses { + // Layout + pub header: &'static str, + pub header_content: &'static str, + pub layout: &'static str, + pub main_content: &'static str, + + // Sidebar + pub sidebar: &'static str, + pub sidebar_open: &'static str, + pub sidebar_header: &'static str, + pub sidebar_toggle: &'static str, + pub sidebar_section: &'static str, + pub sidebar_section_title: &'static str, + + // Navigation + pub nav_list: &'static str, + pub nav_link: &'static str, + pub outline_list: &'static str, + pub outline_item: &'static str, + pub outline_children: &'static str, + + // Search + pub search_container: &'static str, + pub search_results: &'static str, + pub search_results_active: &'static str, + pub search_result_item: &'static str, + pub no_results: &'static str, + pub result_name: &'static str, + pub result_path: &'static str, + pub result_type: &'static str, + + // Schema sections + pub schema_section: &'static str, + pub schema_inline: &'static str, + pub properties_container: &'static str, + pub map_entries: &'static str, + + // Property + pub property: &'static str, + pub property_header: &'static str, + pub property_name: &'static str, + pub pattern: &'static str, + pub too_deep: &'static str, + + // Badges + pub badge: &'static str, + pub required: &'static str, + pub deprecated: &'static str, + pub optional: &'static str, + + // Type badges + pub type_badge: &'static str, + pub type_ref: &'static str, + + // Map display + pub map_key: &'static str, + pub key_type: &'static str, + pub map_arrow: &'static str, + + // Nested schema + pub nested_schema: &'static str, + pub enum_details: &'static str, + pub array_items: &'static str, + pub tuple_items: &'static str, + pub tuple_item: &'static str, + pub tuple_index: &'static str, + + // Constraints + pub constraints: &'static str, + pub constraint: &'static str, + pub label: &'static str, + + // Variants + pub variants: &'static str, + pub variant: &'static str, + pub enum_values: &'static str, + + // Values + pub default_value: &'static str, + pub const_value: &'static str, + + // Definition + pub definition: &'static str, + pub definition_name: &'static str, + pub highlight: &'static str, + + // Description + pub description: &'static str, + + // Usages + pub usages: &'static str, + pub usage_section: &'static str, + pub usage_list: &'static str, +} + +/// All CSS class names +pub const CSS: CssClasses = CssClasses { + // Layout + header: "header", + header_content: "header-content", + layout: "layout", + main_content: "main-content", + + // Sidebar + sidebar: "sidebar", + sidebar_open: "open", + sidebar_header: "sidebar-header", + sidebar_toggle: "sidebar-toggle", + sidebar_section: "sidebar-section", + sidebar_section_title: "sidebar-section-title", + + // Navigation + nav_list: "nav-list", + nav_link: "nav-link", + outline_list: "outline-list", + outline_item: "outline-item", + outline_children: "outline-children", + + // Search + search_container: "search-container", + search_results: "search-results", + search_results_active: "active", + search_result_item: "search-result-item", + no_results: "no-results", + result_name: "result-name", + result_path: "result-path", + result_type: "result-type", + + // Schema sections + schema_section: "schema-section", + schema_inline: "schema-inline", + properties_container: "properties-container", + map_entries: "map-entries", + + // Property + property: "property", + property_header: "property-header", + property_name: "property-name", + pattern: "pattern", + too_deep: "too-deep", + + // Badges + badge: "badge", + required: "required", + deprecated: "deprecated", + optional: "optional", + + // Type badges + type_badge: "type-badge", + type_ref: "type-ref", + + // Map display + map_key: "map-key", + key_type: "key-type", + map_arrow: "map-arrow", + + // Nested schema + nested_schema: "nested-schema", + enum_details: "enum-details", + array_items: "array-items", + tuple_items: "tuple-items", + tuple_item: "tuple-item", + tuple_index: "tuple-index", + + // Constraints + constraints: "constraints", + constraint: "constraint", + label: "label", + + // Variants + variants: "variants", + variant: "variant", + enum_values: "enum-values", + + // Values + default_value: "default-value", + const_value: "const-value", + + // Definition + definition: "definition", + definition_name: "definition-name", + highlight: "highlight", + + // Description + description: "description", + + // Usages + usages: "usages", + usage_section: "usage-section", + usage_list: "usage-list", +}; + +/// Type-specific badge class suffixes (used with type-badge prefix) +#[derive(Debug, Clone, Serialize)] +pub struct TypeClasses { + pub string: &'static str, + pub number: &'static str, + pub integer: &'static str, + pub float: &'static str, + pub boolean: &'static str, + pub null: &'static str, + pub object: &'static str, + pub array: &'static str, + pub r#enum: &'static str, + pub union: &'static str, + pub r#const: &'static str, +} + +/// Type-specific badge classes +pub const TYPE_CLASSES: TypeClasses = TypeClasses { + string: "type-string", + number: "type-number", + integer: "type-integer", + float: "type-float", + boolean: "type-boolean", + null: "type-null", + object: "type-object", + array: "type-array", + r#enum: "type-enum", + union: "type-union", + r#const: "type-const", +}; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_ids_are_valid_html_ids() { + // HTML IDs should not contain spaces and should be lowercase + assert!(!IDS.search.contains(' ')); + assert!(!IDS.search_results.contains(' ')); + assert!(!IDS.sidebar.contains(' ')); + assert!(!IDS.sidebar_toggle.contains(' ')); + } + + #[test] + fn test_css_classes_are_valid() { + // CSS classes should not contain spaces (multiple classes are separate fields) + assert!(!CSS.header.contains(' ')); + assert!(!CSS.property.contains(' ')); + assert!(!CSS.type_badge.contains(' ')); + } + + #[test] + fn test_type_classes_have_prefix() { + // All type classes should start with "type-" + assert!(TYPE_CLASSES.string.starts_with("type-")); + assert!(TYPE_CLASSES.integer.starts_with("type-")); + assert!(TYPE_CLASSES.array.starts_with("type-")); + } +} diff --git a/src/lib.rs b/src/lib.rs index c0badde4..0e6eb485 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,9 +29,13 @@ //! ``` mod generator; +pub mod identifiers; mod prepare; pub use generator::Generator; +pub use identifiers::CSS; +pub use identifiers::IDS; +pub use identifiers::TYPE_CLASSES; use schemars::Schema; use serde_json::Value; diff --git a/src/templates/base.html b/src/templates/base.html index 9aaf5863..5072bf06 100644 --- a/src/templates/base.html +++ b/src/templates/base.html @@ -10,53 +10,56 @@
-