diff --git a/Cargo.lock b/Cargo.lock index 4d7e36e..7bf018c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.9.35" +version = "0.9.36" dependencies = [ "base64", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index 30a6621..527079d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.9.35" +version = "0.9.36" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/src/theme_packs.rs b/crates/canvas-pilot/src/theme_packs.rs index 1a46eb8..8ab2102 100644 --- a/crates/canvas-pilot/src/theme_packs.rs +++ b/crates/canvas-pilot/src/theme_packs.rs @@ -465,6 +465,51 @@ mod tests { assert_eq!(Theme::current(&ctx), missing); } #[test] + fn complete_collection_imports_every_theme_and_survives_restart() { + let bytes = include_bytes!("../../../docs/theme-packs/extra-themes.zip"); + let dir = tempfile::tempdir().unwrap(); + let source = dir.path().join("extra-themes.zip"); + let packs = dir.path().join("installed"); + std::fs::write(&source, bytes).unwrap(); + let ctx = egui::Context::default(); + install(&ctx, &packs, &source).unwrap(); + assert_eq!(installed(&ctx).len(), 1); + assert_eq!(choices(&ctx).len(), 16); + assert_eq!( + std::fs::read(packs.join("extra-themes.zip")).unwrap(), + bytes + ); + let restarted = egui::Context::default(); + assert!(load(&restarted, &packs).is_empty()); + assert_eq!(choices(&ctx), choices(&restarted)); + let luminance = |c: egui::Color32| { + let rgb = [c.r(), c.g(), c.b()].map(|v| { + let v = f64::from(v) / 255.0; + if v <= 0.04045 { + v / 12.92 + } else { + ((v + 0.055) / 1.055).powf(2.4) + } + }); + rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722 + }; + for theme in parse(bytes).unwrap().manifest.themes { + let choice = Theme::Pack(format!("extra-themes/{}", theme.id)); + choice.select(&restarted); + assert_eq!(Theme::current(&restarted), choice); + assert_eq!(choice.display_name(&restarted), theme.name); + let p = choice.resolved_palette(&restarted); + for bg in [p.bg, p.panel, p.field, p.purple, p.pattern[0], p.pattern[1]] { + let (fg, bg) = (luminance(p.text), luminance(bg)); + assert!( + (fg.max(bg) + 0.05) / (fg.min(bg) + 0.05) >= 4.5, + "{} contrast", + theme.name + ); + } + } + } + #[test] fn updates_require_review_and_detect_disk_changes_before_commit_or_remove() { let dir = tempfile::tempdir().unwrap(); let packs = dir.path().join("packs"); diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index a2d798e..fde7f09 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,15 @@ ## Unreleased +### v0.9.36 + +- Added extra-themes.zip: one import installs all 16 themes, with individual ZIPs + still available. Added Dracula, Nord, Gruvbox Dark, Solarized Dark/Light, One Dark, + GitHub Dark/Light, Monokai and original Dispatch, Helldivers and Deep Rock Galactic + palettes. Included upstream notices, deterministic packaging and regression checks + for full-collection import, restart, selection and text contrast. Uses the existing + version-1 multi-theme format. + ### v0.9.35 - Replaced expanding theme/language pack stacks with a searchable pack browser: diff --git a/docs/canvas-pilot/guide/theme-packs.md b/docs/canvas-pilot/guide/theme-packs.md index 35655ce..dae697d 100644 --- a/docs/canvas-pilot/guide/theme-packs.md +++ b/docs/canvas-pilot/guide/theme-packs.md @@ -4,7 +4,7 @@ Theme packs add palettes without rebuilding Canvas Pilot. They change the app, viewport and source-coordinate helper colors; they do not change projects, device transfers, imported pictures, fonts or interface size. -## Install and try the examples +## Install and try the collection Download a ZIP, leave it zipped, then open **Settings → Theme packs → Install theme pack…**. Select a pack, then click one of its themes to try it immediately. It also @@ -12,17 +12,36 @@ appears in **More themes…** and recent themes. The picker stays open while you try alternatives. Selecting **High Contrast** twice returns to your last theme, including an installed one. +Download [extra-themes.zip](../../theme-packs/extra-themes.zip) to install **all +16 themes in one operation**. It is a single pack: select **extra-themes** in the +manager and scroll its contents to try each palette. Removal or replacement applies +to the whole collection. Individual packs remain available below; installing both +keeps separate copies, so you only need one option. + | Pack | Palette | Editable manifest | | --- | --- | --- | | [Tokyo Night](../../theme-packs/tokyo-night.zip) | Dark blue with cool cyan accents | [manifest.json](../../theme-packs/tokyo-night/manifest.json) | | [Catppuccin Mocha](../../theme-packs/catppuccin.zip) | Soft charcoal and pastel accents | [manifest.json](../../theme-packs/catppuccin/manifest.json) | | [Detroit: Become Human](../../theme-packs/detroit-become-human.zip) | Deep blue, pale text and cyan android-inspired accents | [manifest.json](../../theme-packs/detroit-become-human/manifest.json) | | [Minecraft Overworld](../../theme-packs/minecraft.zip) | Earth and stone surfaces with grass-green accents | [manifest.json](../../theme-packs/minecraft/manifest.json) | +| [Deep Rock Galactic](../../theme-packs/deep-rock-galactic.zip) | Dark | [manifest.json](../../theme-packs/deep-rock-galactic/manifest.json) | +| [Dispatch](../../theme-packs/dispatch.zip) | Dark | [manifest.json](../../theme-packs/dispatch/manifest.json) | +| [Dracula](../../theme-packs/dracula.zip) | Dark | [manifest.json](../../theme-packs/dracula/manifest.json) | +| [GitHub Dark](../../theme-packs/github-dark.zip) | Dark | [manifest.json](../../theme-packs/github-dark/manifest.json) | +| [GitHub Light](../../theme-packs/github-light.zip) | Light | [manifest.json](../../theme-packs/github-light/manifest.json) | +| [Gruvbox Dark](../../theme-packs/gruvbox-dark.zip) | Dark | [manifest.json](../../theme-packs/gruvbox-dark/manifest.json) | +| [Helldivers](../../theme-packs/helldivers.zip) | Dark | [manifest.json](../../theme-packs/helldivers/manifest.json) | +| [Monokai](../../theme-packs/monokai.zip) | Dark | [manifest.json](../../theme-packs/monokai/manifest.json) | +| [Nord](../../theme-packs/nord.zip) | Dark | [manifest.json](../../theme-packs/nord/manifest.json) | +| [One Dark](../../theme-packs/one-dark.zip) | Dark | [manifest.json](../../theme-packs/one-dark/manifest.json) | +| [Solarized Dark](../../theme-packs/solarized-dark.zip) | Dark | [manifest.json](../../theme-packs/solarized-dark/manifest.json) | +| [Solarized Light](../../theme-packs/solarized-light.zip) | Light | [manifest.json](../../theme-packs/solarized-light/manifest.json) | Tokyo Night adapts the [upstream palette](https://github.com/folke/tokyonight.nvim), and Catppuccin uses [Mocha colors](https://catppuccin.com/palette/). Their license notices travel inside the ZIP and can be viewed under **Attribution and licenses**. -The Detroit and Minecraft themes are original, unofficial color interpretations; +The Detroit, Minecraft, Dispatch, Helldivers and Deep Rock Galactic themes are +original, unofficial color interpretations; they include no game artwork, fonts or code and are not endorsed by the games' owners. ## Manage packs @@ -63,4 +82,4 @@ poorly contrasted colors automatically. The [theme-pack contract](../../interfaces/theme-packs.md) lists all palette roles, validation limits, settings compatibility and round-trip behavior. Repository -contributors regenerate the four ZIPs with `python3 scripts/build-theme-packs.py`. +contributors regenerate the individual ZIPs and the combined collection with `python3 scripts/build-theme-packs.py`. diff --git a/docs/interfaces/theme-packs.md b/docs/interfaces/theme-packs.md index 3d608bf..3cbcb94 100644 --- a/docs/interfaces/theme-packs.md +++ b/docs/interfaces/theme-packs.md @@ -95,3 +95,12 @@ The editable manifests and ZIPs contain identical bytes, checked by Rust tests and `python3 scripts/build-theme-packs.py --check`. Lifecycle tests cover startup, selection persistence, live updates, overwrite review/cancellation, changed-file protection, removal, limits, malformed colors/archives and context isolation. + +## Bundled collection + +`docs/theme-packs/extra-themes.zip` is a normal version-1 pack (`extra-themes`, +revision 1), containing all 16 distributed themes. One import validates and installs +all entries atomically; it does not unpack nested ZIPs. The build script combines +individual manifests in sorted path order, prefixes theme IDs with their source +pack ID and preserves all notices. Individual packs and the collection have distinct +saved choices and can coexist. Updates and removal operate on the whole collection. diff --git a/docs/theme-packs/deep-rock-galactic.zip b/docs/theme-packs/deep-rock-galactic.zip new file mode 100644 index 0000000..297e42b Binary files /dev/null and b/docs/theme-packs/deep-rock-galactic.zip differ diff --git a/docs/theme-packs/deep-rock-galactic/manifest.json b/docs/theme-packs/deep-rock-galactic/manifest.json new file mode 100644 index 0000000..7e415bf --- /dev/null +++ b/docs/theme-packs/deep-rock-galactic/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "deep-rock-galactic", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Deep Rock Galactic", + "light": false, + "colors": { + "canvas": "#20251d", + "banner": "#141b15", + "grid": "#60744b", + "layer": "#303b28", + "pattern": [ + "#303b28", + "#20251d" + ], + "bg": "#20251d", + "panel": "#141b15", + "field": "#303b28", + "line": "#60744b", + "text": "#f3edcf", + "muted": "#bfcaab", + "cyan": "#a6d85c", + "amber": "#f0b44d", + "purple": "#303b28" + } + } + ], + "notices": "Original, unofficial color interpretation inspired by Deep Rock Galactic. Reference: https://www.deeprockgalactic.com/\nNo game artwork, fonts, logos or code are included. Not affiliated with or endorsed by the game owners." +} diff --git a/docs/theme-packs/dispatch.zip b/docs/theme-packs/dispatch.zip new file mode 100644 index 0000000..608c296 Binary files /dev/null and b/docs/theme-packs/dispatch.zip differ diff --git a/docs/theme-packs/dispatch/manifest.json b/docs/theme-packs/dispatch/manifest.json new file mode 100644 index 0000000..f07a480 --- /dev/null +++ b/docs/theme-packs/dispatch/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "dispatch", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Dispatch", + "light": false, + "colors": { + "canvas": "#182535", + "banner": "#111b29", + "grid": "#596c80", + "layer": "#25384c", + "pattern": [ + "#25384c", + "#182535" + ], + "bg": "#182535", + "panel": "#111b29", + "field": "#25384c", + "line": "#596c80", + "text": "#f7eedc", + "muted": "#bdcbd9", + "cyan": "#7ec8e3", + "amber": "#f18d72", + "purple": "#25384c" + } + } + ], + "notices": "Original, unofficial color interpretation inspired by Dispatch. Reference: https://adhocstudio.com/\nNo game artwork, fonts, logos or code are included. Not affiliated with or endorsed by the game owners." +} diff --git a/docs/theme-packs/dracula.zip b/docs/theme-packs/dracula.zip new file mode 100644 index 0000000..ea24d06 Binary files /dev/null and b/docs/theme-packs/dracula.zip differ diff --git a/docs/theme-packs/dracula/manifest.json b/docs/theme-packs/dracula/manifest.json new file mode 100644 index 0000000..2581f6c --- /dev/null +++ b/docs/theme-packs/dracula/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "dracula", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Dracula", + "light": false, + "colors": { + "canvas": "#282a36", + "banner": "#21222c", + "grid": "#44475a", + "layer": "#343746", + "pattern": [ + "#343746", + "#282a36" + ], + "bg": "#282a36", + "panel": "#21222c", + "field": "#343746", + "line": "#44475a", + "text": "#f8f8f2", + "muted": "#bfc1d5", + "cyan": "#8be9fd", + "amber": "#f1fa8c", + "purple": "#343746" + } + } + ], + "notices": "Palette adapted from https://github.com/dracula/dracula-theme. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nThe MIT License (MIT)\n\nCopyright (c) 2023 Dracula Theme\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/extra-themes.zip b/docs/theme-packs/extra-themes.zip new file mode 100644 index 0000000..b29c10e Binary files /dev/null and b/docs/theme-packs/extra-themes.zip differ diff --git a/docs/theme-packs/github-dark.zip b/docs/theme-packs/github-dark.zip new file mode 100644 index 0000000..9925e8c Binary files /dev/null and b/docs/theme-packs/github-dark.zip differ diff --git a/docs/theme-packs/github-dark/manifest.json b/docs/theme-packs/github-dark/manifest.json new file mode 100644 index 0000000..f2145c4 --- /dev/null +++ b/docs/theme-packs/github-dark/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "github-dark", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "GitHub Dark", + "light": false, + "colors": { + "canvas": "#0d1117", + "banner": "#010409", + "grid": "#484f58", + "layer": "#161b22", + "pattern": [ + "#161b22", + "#0d1117" + ], + "bg": "#0d1117", + "panel": "#010409", + "field": "#161b22", + "line": "#484f58", + "text": "#e6edf3", + "muted": "#9da7b3", + "cyan": "#58a6ff", + "amber": "#d29922", + "purple": "#161b22" + } + } + ], + "notices": "Palette adapted from https://github.com/primer/github-vscode-theme. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nMIT License\n\nCopyright (c) 2020 Primer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/github-light.zip b/docs/theme-packs/github-light.zip new file mode 100644 index 0000000..f3b74e4 Binary files /dev/null and b/docs/theme-packs/github-light.zip differ diff --git a/docs/theme-packs/github-light/manifest.json b/docs/theme-packs/github-light/manifest.json new file mode 100644 index 0000000..bbd9033 --- /dev/null +++ b/docs/theme-packs/github-light/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "github-light", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "GitHub Light", + "light": true, + "colors": { + "canvas": "#ffffff", + "banner": "#f6f8fa", + "grid": "#8c959f", + "layer": "#eaeef2", + "pattern": [ + "#eaeef2", + "#ffffff" + ], + "bg": "#ffffff", + "panel": "#f6f8fa", + "field": "#eaeef2", + "line": "#8c959f", + "text": "#24292f", + "muted": "#57606a", + "cyan": "#0969da", + "amber": "#9a6700", + "purple": "#eaeef2" + } + } + ], + "notices": "Palette adapted from https://github.com/primer/github-vscode-theme. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nMIT License\n\nCopyright (c) 2020 Primer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/gruvbox-dark.zip b/docs/theme-packs/gruvbox-dark.zip new file mode 100644 index 0000000..98f2a85 Binary files /dev/null and b/docs/theme-packs/gruvbox-dark.zip differ diff --git a/docs/theme-packs/gruvbox-dark/manifest.json b/docs/theme-packs/gruvbox-dark/manifest.json new file mode 100644 index 0000000..9ee33e2 --- /dev/null +++ b/docs/theme-packs/gruvbox-dark/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "gruvbox-dark", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Gruvbox Dark", + "light": false, + "colors": { + "canvas": "#282828", + "banner": "#1d2021", + "grid": "#665c54", + "layer": "#32302f", + "pattern": [ + "#32302f", + "#282828" + ], + "bg": "#282828", + "panel": "#1d2021", + "field": "#32302f", + "line": "#665c54", + "text": "#ebdbb2", + "muted": "#bdae93", + "cyan": "#8ec07c", + "amber": "#fabd2f", + "purple": "#32302f" + } + } + ], + "notices": "Palette adapted from https://github.com/ellisonleao/gruvbox.nvim. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nMIT License\n\nCopyright (c) 2021 NpX\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/helldivers.zip b/docs/theme-packs/helldivers.zip new file mode 100644 index 0000000..7894514 Binary files /dev/null and b/docs/theme-packs/helldivers.zip differ diff --git a/docs/theme-packs/helldivers/manifest.json b/docs/theme-packs/helldivers/manifest.json new file mode 100644 index 0000000..27fd3cd --- /dev/null +++ b/docs/theme-packs/helldivers/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "helldivers", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Helldivers", + "light": false, + "colors": { + "canvas": "#191c1b", + "banner": "#101312", + "grid": "#666c58", + "layer": "#2c302b", + "pattern": [ + "#2c302b", + "#191c1b" + ], + "bg": "#191c1b", + "panel": "#101312", + "field": "#2c302b", + "line": "#666c58", + "text": "#f5f2d8", + "muted": "#c2c6b2", + "cyan": "#ffe44c", + "amber": "#edac49", + "purple": "#2c302b" + } + } + ], + "notices": "Original, unofficial color interpretation inspired by Helldivers. Reference: https://www.playstation.com/en-us/games/helldivers-2/\nNo game artwork, fonts, logos or code are included. Not affiliated with or endorsed by the game owners." +} diff --git a/docs/theme-packs/monokai.zip b/docs/theme-packs/monokai.zip new file mode 100644 index 0000000..890ae75 Binary files /dev/null and b/docs/theme-packs/monokai.zip differ diff --git a/docs/theme-packs/monokai/manifest.json b/docs/theme-packs/monokai/manifest.json new file mode 100644 index 0000000..5a72f8b --- /dev/null +++ b/docs/theme-packs/monokai/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "monokai", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Monokai", + "light": false, + "colors": { + "canvas": "#272822", + "banner": "#1e1f1c", + "grid": "#75715e", + "layer": "#34352e", + "pattern": [ + "#34352e", + "#272822" + ], + "bg": "#272822", + "panel": "#1e1f1c", + "field": "#34352e", + "line": "#75715e", + "text": "#f8f8f2", + "muted": "#c5c6bb", + "cyan": "#66d9ef", + "amber": "#e6db74", + "purple": "#34352e" + } + } + ], + "notices": "Palette adapted from https://github.com/microsoft/vscode. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nMIT License\n\nCopyright (c) 2015 - present Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/nord.zip b/docs/theme-packs/nord.zip new file mode 100644 index 0000000..d19ae19 Binary files /dev/null and b/docs/theme-packs/nord.zip differ diff --git a/docs/theme-packs/nord/manifest.json b/docs/theme-packs/nord/manifest.json new file mode 100644 index 0000000..0150a2b --- /dev/null +++ b/docs/theme-packs/nord/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "nord", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Nord", + "light": false, + "colors": { + "canvas": "#2e3440", + "banner": "#242933", + "grid": "#4c566a", + "layer": "#3b4252", + "pattern": [ + "#3b4252", + "#2e3440" + ], + "bg": "#2e3440", + "panel": "#242933", + "field": "#3b4252", + "line": "#4c566a", + "text": "#eceff4", + "muted": "#d8dee9", + "cyan": "#88c0d0", + "amber": "#ebcb8b", + "purple": "#3b4252" + } + } + ], + "notices": "Palette adapted from https://github.com/nordtheme/nord. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nMIT License (MIT)\n\nCopyright (c) 2016-present Sven Greb (https://www.svengreb.de)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n" +} diff --git a/docs/theme-packs/one-dark.zip b/docs/theme-packs/one-dark.zip new file mode 100644 index 0000000..df9a6a1 Binary files /dev/null and b/docs/theme-packs/one-dark.zip differ diff --git a/docs/theme-packs/one-dark/manifest.json b/docs/theme-packs/one-dark/manifest.json new file mode 100644 index 0000000..ac1d1b4 --- /dev/null +++ b/docs/theme-packs/one-dark/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "one-dark", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "One Dark", + "light": false, + "colors": { + "canvas": "#282c34", + "banner": "#21252b", + "grid": "#5c6370", + "layer": "#303640", + "pattern": [ + "#303640", + "#282c34" + ], + "bg": "#282c34", + "panel": "#21252b", + "field": "#303640", + "line": "#5c6370", + "text": "#d7dae0", + "muted": "#abb2bf", + "cyan": "#61afef", + "amber": "#e5c07b", + "purple": "#303640" + } + } + ], + "notices": "Palette adapted from https://github.com/atom/one-dark-syntax. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nCopyright (c) 2016 GitHub Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" +} diff --git a/docs/theme-packs/solarized-dark.zip b/docs/theme-packs/solarized-dark.zip new file mode 100644 index 0000000..df3341e Binary files /dev/null and b/docs/theme-packs/solarized-dark.zip differ diff --git a/docs/theme-packs/solarized-dark/manifest.json b/docs/theme-packs/solarized-dark/manifest.json new file mode 100644 index 0000000..d056052 --- /dev/null +++ b/docs/theme-packs/solarized-dark/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "solarized-dark", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Solarized Dark", + "light": false, + "colors": { + "canvas": "#002b36", + "banner": "#00212b", + "grid": "#586e75", + "layer": "#073642", + "pattern": [ + "#073642", + "#002b36" + ], + "bg": "#002b36", + "panel": "#00212b", + "field": "#073642", + "line": "#586e75", + "text": "#eee8d5", + "muted": "#93a1a1", + "cyan": "#2aa198", + "amber": "#b58900", + "purple": "#073642" + } + } + ], + "notices": "Palette adapted from https://github.com/altercation/solarized. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nCopyright (c) 2011 Ethan Schoonover\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n" +} diff --git a/docs/theme-packs/solarized-light.zip b/docs/theme-packs/solarized-light.zip new file mode 100644 index 0000000..2dc90f0 Binary files /dev/null and b/docs/theme-packs/solarized-light.zip differ diff --git a/docs/theme-packs/solarized-light/manifest.json b/docs/theme-packs/solarized-light/manifest.json new file mode 100644 index 0000000..5c34c1b --- /dev/null +++ b/docs/theme-packs/solarized-light/manifest.json @@ -0,0 +1,32 @@ +{ + "version": 1, + "id": "solarized-light", + "revision": 1, + "themes": [ + { + "id": "default", + "name": "Solarized Light", + "light": true, + "colors": { + "canvas": "#fdf6e3", + "banner": "#eee8d5", + "grid": "#93a1a1", + "layer": "#f5efdc", + "pattern": [ + "#f5efdc", + "#fdf6e3" + ], + "bg": "#fdf6e3", + "panel": "#eee8d5", + "field": "#f5efdc", + "line": "#93a1a1", + "text": "#073642", + "muted": "#586e75", + "cyan": "#007b83", + "amber": "#906900", + "purple": "#f5efdc" + } + } + ], + "notices": "Palette adapted from https://github.com/altercation/solarized. Canvas Pilot role mapping and contrast adjustments are original; this is not an official port.\n\nCopyright (c) 2011 Ethan Schoonover\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n" +} diff --git a/scripts/build-theme-packs.py b/scripts/build-theme-packs.py index b590ec1..dbf06fe 100644 --- a/scripts/build-theme-packs.py +++ b/scripts/build-theme-packs.py @@ -3,6 +3,7 @@ import argparse from pathlib import Path import io +import json import zipfile ROOT = Path(__file__).resolve().parents[1] @@ -18,13 +19,31 @@ def archive(manifest): return buffer.getvalue() +def collection(sources): + """One normal v1 pack: the existing importer installs every contained theme.""" + themes = [] + notices = [] + for source in sorted(sources): + manifest = json.loads(source.read_bytes()) + for theme in manifest['themes']: + themes.append({**theme, 'id': manifest['id'] + '-' + theme['id']}) + notices.append(manifest['id'] + '\n' + manifest.get('notices', '')) + if not 1 <= len(themes) <= 16: + raise ValueError('The collection must respect the v1 limit of 16 themes') + manifest = dict(version=1, id='extra-themes', revision=1, + themes=themes, notices='\n\n'.join(notices)) + return (json.dumps(manifest, indent=2) + '\n').encode() + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('--check', action='store_true') args = parser.parse_args() - for source in sorted((ROOT / 'docs/theme-packs').glob('*/manifest.json')): - target = source.parent.with_suffix('.zip') - data = archive(source.read_bytes()) + sources = sorted((ROOT / 'docs/theme-packs').glob('*/manifest.json')) + outputs = [(source.parent.with_suffix('.zip'), source.read_bytes()) for source in sources] + outputs.append((ROOT / 'docs/theme-packs/extra-themes.zip', collection(sources))) + for target, manifest in outputs: + data = archive(manifest) if args.check: if not target.exists() or target.read_bytes() != data: raise SystemExit(f'Out-of-date theme pack: {target}') diff --git a/tests/test_theme_packs.py b/tests/test_theme_packs.py index 34457db..efc220a 100644 --- a/tests/test_theme_packs.py +++ b/tests/test_theme_packs.py @@ -1,6 +1,7 @@ """Example ZIPs remain reproducible and contain only their editable manifest.""" import importlib.util import io +import json from pathlib import Path import unittest import zipfile @@ -14,7 +15,7 @@ spec.loader.exec_module(module) class ThemePackExamples(unittest.TestCase): def test_archives_match_sources_and_rebuild_exactly(self): manifests = list((ROOT / 'docs/theme-packs').glob('*/manifest.json')) - self.assertEqual(len(manifests), 4) + self.assertEqual(len(manifests), 16) for source in manifests: with self.subTest(pack=source.parent.name): expected = source.parent.with_suffix('.zip').read_bytes() @@ -22,3 +23,18 @@ class ThemePackExamples(unittest.TestCase): with zipfile.ZipFile(io.BytesIO(expected)) as archive: self.assertEqual(archive.namelist(), ['manifest.json']) self.assertEqual(archive.read('manifest.json'), source.read_bytes()) + + def test_collection_contains_every_theme_and_notice(self): + sources = list((ROOT / 'docs/theme-packs').glob('*/manifest.json')) + data = module.collection(sources) + self.assertEqual(data, module.collection(reversed(sources))) + self.assertEqual(module.archive(data), (ROOT / 'docs/theme-packs/extra-themes.zip').read_bytes()) + combined = json.loads(data) + self.assertEqual(combined['id'], 'extra-themes') + self.assertEqual(len(combined['themes']), 16) + self.assertEqual(len({t['id'] for t in combined['themes']}), 16) + for source in sources: + manifest = json.loads(source.read_bytes()) + self.assertIn(manifest['notices'], combined['notices']) + for theme in manifest['themes']: + self.assertIn({**theme, 'id': manifest['id'] + '-' + theme['id']}, combined['themes'])