diff --git a/.github/oversized.txt b/.github/oversized.txt index f67b7c0..b52b46b 100644 --- a/.github/oversized.txt +++ b/.github/oversized.txt @@ -1,2 +1,2 @@ -2157 app/src-tauri/src/lib.rs +2134 app/src-tauri/src/lib.rs 2065 crates/linkunbound-shell/src/main.rs diff --git a/README.md b/README.md index 3a77495..6a98c18 100644 --- a/README.md +++ b/README.md @@ -340,7 +340,9 @@ work. What ships inside the binaries, each under its own licence, is listed in [THIRD-PARTY-BUNDLED.md](THIRD-PARTY-BUNDLED.md); `npm run notices` writes it -from the lockfiles. +from the lockfiles. The application carries it inside its own binary, under +**About → Third-party notices**, wherever it was installed from and with no +network. --- diff --git a/THIRD-PARTY-BUNDLED.md b/THIRD-PARTY-BUNDLED.md index 28ad032..398b31b 100644 --- a/THIRD-PARTY-BUNDLED.md +++ b/THIRD-PARTY-BUNDLED.md @@ -5,15 +5,22 @@ LinkUnbound is GPL-3.0-only. The binary carries the work below, each under its own licence. Nothing of it was copied into LinkUnbound's own source. -## In the window (5 packages) +## In the window (12 packages) | Package | Version | Licence | | --- | --- | --- | | `@tauri-apps/api` | 2.11.1 | Apache-2.0 OR MIT | | `@tauri-apps/plugin-opener` | 2.5.5 | MIT OR Apache-2.0 | +| `argparse` | 3.0.2 | PSF-2.0 | +| `entities` | 8.1.0 | BSD-2-Clause | +| `linkify-it` | 6.1.0 | MIT | +| `markdown-it` | 15.0.2 | MIT | +| `mdurl` | 2.1.0 | MIT | +| `punycode.js` | 2.3.1 | MIT | | `react` | 19.3.0 | MIT | | `react-dom` | 19.3.0 | MIT | | `scheduler` | 0.28.0 | MIT | +| `uc.micro` | 3.0.0 | MIT | ## In the core (541 crates) @@ -668,6 +675,203 @@ PackageDownloadLocation: git+ssh://github.com/tauri-apps/tauri.git Creator: Person: Daniel Thompson-Yvetot ``` +### `argparse` — PSF-2.0 + +```text +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby +grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +analyze, test, perform and/or display publicly, prepare derivative works, +distribute, and otherwise use Python alone or in any derivative version, +provided, however, that PSF's License Agreement and PSF's notice of copyright, +i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software Foundation; +All Rights Reserved" are retained in Python alone or in any derivative version +prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. +``` + +### `entities` — BSD-2-Clause + +```text +Copyright (c) Felix Böhm +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +``` + +### `linkify-it` — MIT + +```text +Copyright (c) 2015 Vitaly Puzrin. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +``` + +### `markdown-it` — MIT + +```text +Copyright (c) 2014 Vitaly Puzrin, Alex Kocharin. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. +``` + +### `mdurl` — MIT + +```text +Copyright (c) 2015 Vitaly Puzrin, Alex Kocharin. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +-------------------------------------------------------------------------------- + +.parse() is based on Joyent's node.js `url` code: + +Copyright Joyent, Inc. and other Node contributors. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. +``` + +### `punycode.js` — MIT + +```text +Copyright Mathias Bynens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` + ### `react` — MIT ```text @@ -745,3 +949,28 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` + +### `uc.micro` — MIT + +```text +Copyright Mathias Bynens + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` diff --git a/app/package-lock.json b/app/package-lock.json index bae07af..e6c69d6 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@tauri-apps/api": "^2", "@tauri-apps/plugin-opener": "^2.5.5", + "markdown-it": "^15.0.2", "react": "^19.3.0", "react-dom": "^19.3.0" }, @@ -22,6 +23,7 @@ "@testing-library/jest-dom": "^7.0.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.3", + "@types/markdown-it": "^14.2.0", "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.1", @@ -3040,6 +3042,31 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/markdown-it": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.2.0.tgz", + "integrity": "sha512-NoQ2yGlLWj4wpxMs+TYmRKk3thDrQ97agr7sFqfLsAlvoS8SNQuTrlObhFqG9iugdTtgOE9jpJ6FNM4ZGsa5xQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/react": { "version": "19.3.0", "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", @@ -3626,6 +3653,22 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/argparse": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-3.0.2.tgz", + "integrity": "sha512-mFdDM6WqWKraGLsVb+C9CahPnzTXOefAOLq3jYcca2YZ8bEWpr++Tzj+zSaKW9+X9L5uSxcm1AZ3Y6aZJ09OhQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "PSF-2.0" + }, "node_modules/aria-query": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", @@ -4036,7 +4079,6 @@ "version": "8.1.0", "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", - "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=20.19.0" @@ -4919,6 +4961,25 @@ "url": "https://opencollective.com/parcel" } }, + "node_modules/linkify-it": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-6.1.0.tgz", + "integrity": "sha512-wJ/TwpSDTLepCrQoYWYIExIKg5Zchex2Nn5yk2mFnB+6PtdkHtyLx742md9csRjjOnGkKIS/RrbY7l8D6gT9Vw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "uc.micro": "^3.0.0" + } + }, "node_modules/lodash.groupby": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.groupby/-/lodash.groupby-4.6.0.tgz", @@ -4985,6 +5046,33 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/markdown-it": { + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-15.0.2.tgz", + "integrity": "sha512-q4IGxMv56jCqT4OCRCADBoDP3LO4MhmTXjFbphHPXs4g3j9Xg5RDnxqN8IF/3vIWEU+VCnUq+7JUg/cfy2E6Qw==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/markdown-it" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^3.0.0", + "entities": "^8.0.0", + "linkify-it": "^6.0.0", + "mdurl": "^2.1.0", + "punycode.js": "^2.3.1", + "uc.micro": "^3.0.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, "node_modules/math-intrinsics": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", @@ -5002,6 +5090,12 @@ "dev": true, "license": "CC0-1.0" }, + "node_modules/mdurl": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.1.0.tgz", + "integrity": "sha512-1+HBaOx0zi/dQWht8rNv9MYf9qqpqL/kxI0hXImU6Y547zM6Sni8BQibt7ifgMcYtQg41ao3Ivd6cnSM86inpg==", + "license": "MIT" + }, "node_modules/min-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", @@ -5312,6 +5406,15 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.16.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz", @@ -5857,6 +5960,12 @@ "@typescript/typescript-win32-x64": "7.0.2" } }, + "node_modules/uc.micro": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-3.0.0.tgz", + "integrity": "sha512-U3PppEkleoTnIfi8BozMx3yju3qc/L6SwqWo2Sw+54PX+PX0q9I+r1Um5HCmqD7n9VDX5/v3vQH/AjA6deDdtw==", + "license": "MIT" + }, "node_modules/underscore": { "version": "1.13.8", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.8.tgz", diff --git a/app/package.json b/app/package.json index 324388f..8d27b56 100644 --- a/app/package.json +++ b/app/package.json @@ -15,6 +15,7 @@ "dependencies": { "@tauri-apps/api": "^2", "@tauri-apps/plugin-opener": "^2.5.5", + "markdown-it": "^15.0.2", "react": "^19.3.0", "react-dom": "^19.3.0" }, @@ -27,6 +28,7 @@ "@testing-library/jest-dom": "^7.0.1", "@testing-library/react": "^16.3.2", "@testing-library/user-event": "^14.6.3", + "@types/markdown-it": "^14.2.0", "@types/react": "^19.3.0", "@types/react-dom": "^19.3.0", "@vitejs/plugin-react": "^6.1.1", diff --git a/app/src-tauri/src/about.rs b/app/src-tauri/src/about.rs new file mode 100644 index 0000000..34e7029 --- /dev/null +++ b/app/src-tauri/src/about.rs @@ -0,0 +1,35 @@ +use serde::Serialize; + +use crate::{HERE, store, update}; + +const NOTICES: &str = include_str!("../../../THIRD-PARTY-BUNDLED.md"); + +#[derive(Serialize)] +#[serde(rename_all = "camelCase")] +pub struct Build { + version: &'static str, + license: &'static str, + repository: &'static str, + candidates: bool, + candidates_apply: bool, + kept_by_the_store: bool, +} + +#[tauri::command] +pub fn about() -> Build { + let kept = update::looked(store().dir()); + let store_copy = update::route().route == update::Route::Store; + Build { + version: HERE, + license: "GPL-3.0-only", + repository: "https://github.com/rgdevment/LinkUnbound", + candidates: update::tracking(HERE, kept.candidates), + candidates_apply: !store_copy, + kept_by_the_store: store_copy, + } +} + +#[tauri::command] +pub fn notices() -> &'static str { + NOTICES +} diff --git a/app/src-tauri/src/lib.rs b/app/src-tauri/src/lib.rs index 64e0361..ae0c6e8 100644 --- a/app/src-tauri/src/lib.rs +++ b/app/src-tauri/src/lib.rs @@ -1,3 +1,4 @@ +mod about; mod shell; mod shop; mod system; @@ -810,36 +811,11 @@ fn system_set_startup(enabled: bool) -> Result { const HERE: &str = env!("CARGO_PKG_VERSION"); -#[derive(Serialize)] -#[serde(rename_all = "camelCase")] -struct Build { - version: &'static str, - license: &'static str, - repository: &'static str, - candidates: bool, - candidates_apply: bool, - kept_by_the_store: bool, -} - #[tauri::command] fn settings_painted(window: tauri::WebviewWindow) { shell::reveal(&window); } -#[tauri::command] -fn about() -> Build { - let kept = update::looked(store().dir()); - let store_copy = update::route().route == update::Route::Store; - Build { - version: HERE, - license: "GPL-3.0-only", - repository: "https://github.com/rgdevment/LinkUnbound", - candidates: update::tracking(HERE, kept.candidates), - candidates_apply: !store_copy, - kept_by_the_store: store_copy, - } -} - fn now_in_seconds() -> Option { std::time::SystemTime::now() .duration_since(std::time::UNIX_EPOCH) @@ -1381,7 +1357,8 @@ pub fn run() { system_repair, system_register_anyway, system_open_elsewhere, - about, + about::about, + about::notices, settings_painted, update_ready, update_install, diff --git a/app/src/i18n.ts b/app/src/i18n.ts index caf57c3..7e2ed18 100644 --- a/app/src/i18n.ts +++ b/app/src/i18n.ts @@ -255,6 +255,7 @@ const ES = { aboutIssue: "Informar de un problema", aboutPrivacyLink: "Privacidad", aboutNotices: "Avisos de terceros", + noticesRefused: "No se pudieron leer los avisos de terceros", aboutIssueNote: "Errores, ideas y navegadores que no detecta", aboutSponsor: "Invítame un café", aboutSponsorNote: @@ -525,6 +526,7 @@ const EN: Record = { aboutIssue: "Report a problem", aboutPrivacyLink: "Privacy", aboutNotices: "Third-party notices", + noticesRefused: "The third-party notices could not be read", aboutIssueNote: "Bugs, ideas and browsers it fails to detect", aboutSponsor: "Buy me a coffee", aboutSponsorNote: diff --git a/app/src/index.css b/app/src/index.css index d6c4cf0..b726ba2 100644 --- a/app/src/index.css +++ b/app/src/index.css @@ -294,6 +294,53 @@ body { color: var(--ink); } +.notices { + display: block; + max-height: 380px; + margin-top: 10px; + padding: 8px 12px; + overflow: auto; + border: 1px solid var(--hair); + border-radius: 10px; + font-size: 12px; + line-height: 1.55; + color: var(--muted); +} + +.notices h1, +.notices h2, +.notices h3 { + margin: 14px 0 6px; + font-size: 13px; + color: var(--ink); +} + +.notices p { + margin: 6px 0; +} + +.notices table { + border-collapse: collapse; + width: 100%; +} + +.notices th, +.notices td { + padding: 2px 6px; + border-bottom: 1px solid var(--hair); + text-align: left; +} + +.notices pre { + white-space: pre-wrap; + overflow-wrap: anywhere; + font-size: 11px; +} + +.notices a { + color: var(--accent); +} + .newer { margin-top: 17px; display: flex; diff --git a/app/src/markdown.ts b/app/src/markdown.ts new file mode 100644 index 0000000..74cca1d --- /dev/null +++ b/app/src/markdown.ts @@ -0,0 +1,6 @@ +import MarkdownIt from "markdown-it"; + +const md = new MarkdownIt({ html: false, linkify: true }); + +export const composed = (text: string): string => + md.render(text.replace(/\s*/g, "")); diff --git a/app/src/settings/About.test.tsx b/app/src/settings/About.test.tsx index 806d16c..6fee3ee 100644 --- a/app/src/settings/About.test.tsx +++ b/app/src/settings/About.test.tsx @@ -379,3 +379,110 @@ describe("about", () => { expect(await screen.findByText(/folder refused/)).toBeInTheDocument(); }); }); + +describe("third-party notices", () => { + beforeEach(() => { + opened.length = 0; + invoke.mockReset(); + answers(); + }); + + function noticesSay(text: () => Promise) { + answers({ notices: text }); + } + + function asked() { + return invoke.mock.calls.filter(([cmd]) => cmd === "notices").length; + } + + it("are read from the binary only when opened, and close again", async () => { + noticesSay(() => Promise.resolve("MIT License\n\nCopyright (c) someone")); + show(); + + const button = await screen.findByRole("button", { name: "Avisos de terceros" }); + expect(asked()).toBe(0); + expect(button).toHaveAttribute("aria-expanded", "false"); + + await userEvent.click(button); + expect(await screen.findByText(/Copyright \(c\) someone/)).toBeInTheDocument(); + expect(asked()).toBe(1); + expect(button).toHaveAttribute("aria-expanded", "true"); + + await userEvent.click(button); + expect(screen.queryByText(/Copyright \(c\) someone/)).not.toBeInTheDocument(); + expect(button).toHaveAttribute("aria-expanded", "false"); + expect(opened).toEqual([]); + }); + + it("are drawn as text and tables, not as the markdown they are written in", async () => { + noticesSay(() => + Promise.resolve( + "# Notices\n\n\n\n## In the window\n\n| Package | Licence |\n| --- | --- |\n| react | MIT |", + ), + ); + show(); + + await userEvent.click(await screen.findByRole("button", { name: "Avisos de terceros" })); + + const cell = await screen.findByRole("cell", { name: "react" }); + expect(cell.closest("table")).not.toBeNull(); + expect(screen.queryByText(/\| --- \|/)).not.toBeInTheDocument(); + expect(screen.queryByText(/^## /)).not.toBeInTheDocument(); + expect(screen.queryByText(/Do not edit by hand/)).not.toBeInTheDocument(); + }); + + it("never run what they carry written as html", async () => { + noticesSay(() => Promise.resolve(" and nothing else")); + show(); + + await userEvent.click(await screen.findByRole("button", { name: "Avisos de terceros" })); + + const section = await screen.findByRole("region", { name: "Avisos de terceros" }); + expect(section).toHaveTextContent("and nothing else"); + expect(section.querySelector("img")).toBeNull(); + }); + + it("open a link inside them in the system browser, not in the window", async () => { + noticesSay(() => Promise.resolve("See https://crates.io/crates/slint")); + show(); + + await userEvent.click(await screen.findByRole("button", { name: "Avisos de terceros" })); + await userEvent.click( + await screen.findByRole("link", { name: "https://crates.io/crates/slint" }), + ); + + expect(opened).toEqual(["https://crates.io/crates/slint"]); + }); + + it("are asked for once while the first answer is still on its way", async () => { + let answer: (text: string) => void = () => {}; + noticesSay( + () => + new Promise((resolve) => { + answer = resolve; + }), + ); + show(); + + const button = await screen.findByRole("button", { name: "Avisos de terceros" }); + await userEvent.click(button); + await userEvent.click(button); + expect(asked()).toBe(1); + + answer("MIT License"); + expect(await screen.findByText("MIT License")).toBeInTheDocument(); + expect(button).toHaveAttribute("aria-expanded", "true"); + }); + + it("say so when they cannot be read", async () => { + noticesSay(() => Promise.reject(new Error("no"))); + show(); + + await userEvent.click(await screen.findByRole("button", { name: "Avisos de terceros" })); + + const alert = await screen.findByRole("alert"); + expect(alert).toHaveTextContent("No se pudieron leer los avisos de terceros"); + expect(alert.previousElementSibling).toHaveClass("links"); + expect(screen.queryByRole("region", { name: "Avisos de terceros" })).not.toBeInTheDocument(); + }); +}); diff --git a/app/src/settings/About.tsx b/app/src/settings/About.tsx index 530e1ff..5f751c3 100644 --- a/app/src/settings/About.tsx +++ b/app/src/settings/About.tsx @@ -1,7 +1,8 @@ import { invoke } from "@tauri-apps/api/core"; import { openUrl } from "@tauri-apps/plugin-opener"; -import { useCallback, useEffect, useState } from "react"; +import { useCallback, useEffect, useRef, useState } from "react"; import { type Key, useSpoken, useWords } from "../i18n"; +import { composed } from "../markdown"; import { offerMoved, saidPlainly } from "../refusal"; import { CloudOff, Code, Gift, Key as KeyIcon } from "./Icons"; import { Card, Line, Switch } from "./parts"; @@ -41,6 +42,26 @@ function External({ href, children }: { href: string; children: string }) { ); } +function Notices({ text, label }: { text: string; label: string }) { + const box = useRef(null); + + useEffect(() => { + const holder = box.current; + if (!holder) return; + holder.innerHTML = composed(text); + const clicked = (event: Event) => { + const link = (event.target as HTMLElement).closest("a"); + if (!link) return; + event.preventDefault(); + void openUrl(link.href).catch(noop); + }; + holder.addEventListener("click", clicked); + return () => holder.removeEventListener("click", clicked); + }, [text]); + + return
; +} + function Rule({ said }: { said: string }) { return
{said}
; } @@ -276,6 +297,20 @@ export default function About({ const [trouble, setTrouble] = useState(null); const [problem, setProblem] = useState(null); const [saved, setSaved] = useState(null); + const [notices, setNotices] = useState(null); + const [readingNotices, setReadingNotices] = useState(false); + const [noticesRefused, setNoticesRefused] = useState(false); + + const toggleNotices = () => { + if (readingNotices) return; + if (notices !== null) return setNotices(null); + setNoticesRefused(false); + setReadingNotices(true); + invoke("notices") + .then(setNotices) + .catch(() => setNoticesRefused(true)) + .finally(() => setReadingNotices(false)); + }; const report = () => { setProblem(null); @@ -452,8 +487,16 @@ export default function About({ {t("aboutRepo")} AlternativeTo {t("aboutPrivacyLink")} - {t("aboutNotices")} + + {noticesRefused && ( +

+ {t("noticesRefused")} +

+ )} + {notices !== null && } ); }