Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee275eb43e |
No files matched your search
@@ -149,7 +149,10 @@ jobs:
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$v = '${{ steps.version.outputs.version }}'
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:Version=$v -o out/app
|
||||
# beta.12: the App's links into the repository open the documents of THIS release (Services/RepositoryLinks.cs):
|
||||
# the tag, or for a rehearsal - which has no tag - the commit it was built from.
|
||||
$ref = if ('${{ steps.version.outputs.dry_run }}' -eq 'true') { '${{ github.sha }}' } else { "v$v" }
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:Version=$v -p:FrameLedgerSourceRef=$ref -o out/app
|
||||
if ($LASTEXITCODE -ne 0) { throw 'App publish failed' }
|
||||
dotnet publish src/FrameLedger.Agent -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:Version=$v -o out/app
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Agent publish failed' }
|
||||
|
||||
@@ -55,6 +55,17 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
|
||||
· RAM …", for a game that is not measured too; and the CSV export has a `# game_memory:` header line. Where Windows does
|
||||
not report the private working set (before the September 2023 update) the working set is shown in its place and says
|
||||
so. A session recorded before beta.12 reads N/A, and its summary says the statistics table did not exist yet.
|
||||
- **Documents are shown rendered, not as raw Markdown** (owner request 4, beta.12): the Legal Gate, Help ▸ Limitations,
|
||||
the update notes and the new About window draw headings, lists, tables, code and links (Markdig 1.4.0, BSD-2-Clause;
|
||||
HTML in a document is shown as text and no image is fetched). The GPL is shown as written. Selectable and copyable;
|
||||
links open in the browser, scroll to a section, or open another document the window holds; a `file:` or
|
||||
`javascript:` link is never followed. **Help ▸ About** is a window with three tabs: the program's legal notices
|
||||
(copyright, no warranty, the licence with the NOTICE terms, this version's source code), the third-party licences
|
||||
with every shipped package's version and a button that opens the licences folder, and the legal documents (EULA,
|
||||
GPL, Disclaimer, Privacy Policy, NOTICE, Trademarks). Help ▸ Limitations is a window of its own.
|
||||
- **Links into the repository open the documents of the version you run**: a release stamps its tag into the App
|
||||
(`-p:FrameLedgerSourceRef`), so *View on GitHub*, the safety document and every document link go to that tag rather
|
||||
than to `main`, where the text may have changed since.
|
||||
|
||||
- **`NOTICE`, and the licence header in every source file** (owner decision D45, beta.12). FrameLedger's own material is
|
||||
GPL-3.0-only with three additional terms of the kinds GPLv3 §7 permits: keep the copyright line and the attribution in
|
||||
@@ -74,6 +85,11 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
|
||||
|
||||
### Fixed
|
||||
|
||||
- **The Legal Gate showed the documents as raw Markdown** (`**bold**`, `| --- |`) in a text box, and Help ▸ Limitations
|
||||
and the update notes the same; they are rendered now (above). The Legal Gate's *View on GitHub* went around the App's
|
||||
link opener; it goes through it.
|
||||
- **The third-party notices' component table did not render as a table** in a Markdown renderer that follows the spec
|
||||
strictly: a note line sat between its rows. The note is moved below the table, unchanged.
|
||||
- **"Max VRAM (game)" on the Trend never had a point, the live card's VRAM was always empty, and the Sensors chart's
|
||||
"VRAM used by this game" line was never drawn**: all three read the Overlay's in-game per-present figure, which nothing
|
||||
ever produced. They read the game's memory measured from outside it now (above), and the CSV's note no longer calls
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||
<PackageVersion Include="ScottPlot.WPF" Version="5.1.59" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.4.1" />
|
||||
<!--
|
||||
Markdig (Alexandre Mutel): Markdown rendered in the App (beta.12, owner request 4) - the Legal Gate, Help,
|
||||
About and the user guide show their documents rendered, not as raw text. BSD-2-Clause, no dependency on
|
||||
net10.0. The package ships no licence file, so its text is a reviewed override
|
||||
(tools/license-overrides/Markdig.txt). HTML is disabled in the pipeline (App/Markdown/MarkdownRenderer.cs).
|
||||
-->
|
||||
<PackageVersion Include="Markdig" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Label="Hosting and logging">
|
||||
|
||||
+26
-3
@@ -24,11 +24,34 @@ WPF + **WPF UI (Wpf.Ui, Fluent)**. Shell = `ui:FluentWindow` with custom `ui:Tit
|
||||
**Menu bar**
|
||||
- **File:** Add game… · Import library (Steam / GOG / Epic / itch.io) · Export ▸ (Session CSV / Session JSON / Chart PNG) · Exit
|
||||
- **Tools:** Agent status… · Update detection rules · Vulkan layer registration… · Open data folder · Database maintenance…
|
||||
- **Help:** Check for updates · Report a bug… · Documentation · Limitations · About FrameLedger (App / Developer / Third-party licenses tabs)
|
||||
- **Help:** Check for updates · Report a bug… · Documentation · Limitations · About FrameLedger (~~App / Developer / Third-party licenses tabs~~ — built beta.12 as *This app* / *Third-party licences* / *Legal documents*, below)
|
||||
|
||||
> **Help ▸ Limitations, beta.10 (D36):** `LIMITATIONS.md` as the build embeds it (`Services.LimitationsDocument`), in a
|
||||
> read-only, scrolling WPF UI `MessageBox` with *Open on GitHub*. It is information, not one of FR-11's documents:
|
||||
> nothing is accepted or recorded, and the Disclaimer points at it.
|
||||
>
|
||||
> **Documents are rendered, beta.12 (owner request 4, D45).** Every Markdown document the App shows — the Legal Gate's
|
||||
> three texts, Help ▸ Limitations, the update notes, About's documents — is drawn by `Markdown/MarkdownRenderer`
|
||||
> (Markdig 1.4.0, BSD-2-Clause) into a WPF `FlowDocument` inside `Controls/MarkdownView` (a read-only
|
||||
> `FlowDocumentScrollViewer`: selectable, Ctrl+C, Ctrl+wheel zoom): headings, emphasis and strikethrough, inline and
|
||||
> fenced code in monospace, quotes, nested and numbered lists, pipe tables with a header row, rules, links. **HTML is
|
||||
> off** — a tag is shown as the text it is; **no image is fetched** — its description stands in; a node the renderer
|
||||
> does not know is shown as its own source text, and `MarkdownRendererTests` proves for every embedded document that
|
||||
> no word of its plain text is lost and no table is left as `|---|` source. The GPL's `LICENSE` is not Markdown: it is
|
||||
> shown as written, monospace. Colours and the font are theme resources (`16_WPFUI_SYNTAX` §FlowDocument). Links
|
||||
> follow `Markdown/MarkdownLinks`: http, https and mailto through `IUrlOpener`; `#section` scrolls to the heading
|
||||
> (GitHub's anchors); a relative path resolves against the document's place in the repository and opens in the App
|
||||
> when the window holds that page, on GitHub otherwise — **at this build's own source** (`Services/RepositoryLinks`:
|
||||
> the release's tag, stamped by `release.yml`; `main` for a local build — every link said `blob/main` before); any
|
||||
> other scheme (`file:`, `javascript:`, a drive or UNC path) is not followed, its address shown beside its text.
|
||||
> **Help ▸ Limitations** is a window of its own (`Windows/DocumentWindow`, one page, *Open on GitHub*); **Help ▸ About**
|
||||
> is `Windows/AboutWindow`, three tabs: *This app* — the version, and the program's Appropriate Legal Notices (GPLv3
|
||||
> §0, §5(d)): the copyright line, no warranty, the licence with the NOTICE terms, this version's source, *View the
|
||||
> licence* / *View NOTICE* / *Open the source code*; *Third-party licences* — `legal/THIRD_PARTY_NOTICES.md` and the
|
||||
> package index, rendered, and *Open the licences folder* (the published `licenses\`; a development build says it has
|
||||
> none); *Legal documents* — EULA, GPL, Disclaimer, Privacy Policy, NOTICE, Trademarks. Asking again brings the open
|
||||
> window forward (`Services/DocumentWindows`). Tests: `MarkdownRendererTests`, `MarkdownLinksTests`,
|
||||
> `DocumentWindowsTests`.
|
||||
|
||||
The Menu sits in its own row **below** the TitleBar (never inside the drag region — 16 §Gotchas).
|
||||
|
||||
@@ -587,7 +610,7 @@ Agent section: elevation state with a plain explanation of what elevation *optio
|
||||
> is gone. **Refresh** shows only while a row is *Checking…*, the one time it can change anything.
|
||||
|
||||
### First-run flow
|
||||
1. Legal Gate (FR-11): four documents, scrollable, links to GitHub-hosted versions, single Accept.
|
||||
1. Legal Gate (FR-11): four documents, scrollable, links to GitHub-hosted versions, single Accept. **Rendered since beta.12** (§Menu, *Documents are rendered*): the Markdown texts drawn, the GPL as written; a link from one document to another the gate shows opens it in the gate; *View on GitHub* opens the document at this build's source, through `IUrlOpener`.
|
||||
2. Agent setup: runs **unelevated by default** — a short, honest paragraph explains that elevation is optional and unlocks CPU temperature and elevated-game attach. ~~and the Tier-2 ETW fallback. It must be explicit that **without elevation there is no Tier 2**~~ — **struck 2026-08-28: no tier needs elevation, so there is nothing to warn about here.** Capability check results shown afterwards. ~~with Tier-2 availability listed as its own badge~~ — there is no availability to report.
|
||||
3. Hooking explainer: what Tier 1 vs Tier 2 means — **and it must be explicit that Tier 2 measures nothing**, because the honest version of this screen is the one where a user who declines knows what they are declining — and that hooking stays off until enabled per game.
|
||||
4. Optional library import.
|
||||
@@ -598,7 +621,7 @@ Agent section: elevation state with a plain explanation of what elevation *optio
|
||||
> in read-only mode. **(1) The gate:** the four documents ride in the assembly (`LegalDocuments`: `legal/EULA.md`,
|
||||
> the root `LICENSE` as the GPLv3 text, `legal/DISCLAIMER.md`, `legal/PRIVACY_POLICY.md`, embedded at build so the
|
||||
> App shows the text this build was reviewed with; HTML authoring comments stripped; `{{RELEASE_DATE}}` left for
|
||||
> `release.yml`), a list on the left, the text in a read-only box, "View on GitHub" per document, **one Accept**
|
||||
> `release.yml`), a list on the left, the text in a read-only box (~~raw Markdown~~ rendered since beta.12), "View on GitHub" per document, **one Accept**
|
||||
> that writes four `legal_acceptance` rows with each document's own `**Version:**` line (`GPL-3.0-only` for the
|
||||
> licence), and Decline, which ends the host — the shell never appears. Closing the window without deciding is a
|
||||
> decline. **(2) Agent setup:** the honest paragraph (unelevated by default; elevation optional, unlocks CPU
|
||||
|
||||
+4
-4
@@ -8,7 +8,7 @@ Velopack, feeding from GitHub Releases of `https://github.com/poli0981/frameledg
|
||||
- **Manual check** (Help → Check for updates): progress dialog; all failures produce the mapped dialog below.
|
||||
- **Never apply an update while a game is hooked** (FR-12): the Overlay DLL on disk must not change under a running game, and a mid-session swap would invalidate the ring layout handshake. If a capture is active, defer the prompt and the apply until the session ends.
|
||||
- Apply: `WaitExitThenApplyUpdates` on restart. Agent is stopped via `Shutdown` before applying and the scheduled task action path is re-validated after update (Velopack keeps a stable `current` path, but verify in P4 and re-register task if the action path changed).
|
||||
- Release notes (GitHub release body, Markdown) rendered in the update dialog.
|
||||
- Release notes (GitHub release body, Markdown) rendered in the update dialog. ~~(shown as plain text until beta.12 — §Flow and §Limits below said so)~~ **Rendered since beta.12** by `Controls/MarkdownView` (`08_UI` §Menu, *Documents are rendered*), relative links resolved against `CHANGELOG.md` at this build's source.
|
||||
|
||||
## Error mapping (FR-12)
|
||||
|
||||
@@ -55,8 +55,8 @@ flow, and the tests run the flow over a fake client because nothing here may tou
|
||||
window is off screen (`08_UI` §Notifications policy), and the shell's persistent InfoBar carries the download
|
||||
and the **Restart to update** button.
|
||||
- **Manual check:** Help ▸ Check for updates → `UpdateService.CheckInteractivelyAsync` and the dialogs in
|
||||
`UpdatePrompts` (WPF-UI `MessageBox`): the offer with the release notes (the GitHub release body, shown as text —
|
||||
no Markdown renderer is shipped), the unsigned-release footer, Download / Later; "up to date"; "not an
|
||||
`UpdatePrompts` (WPF-UI `MessageBox`): the offer with the release notes (the GitHub release body, ~~shown as text —
|
||||
no Markdown renderer is shipped~~ rendered since beta.12, at most 260 px tall and scrolling), the unsigned-release footer, Download / Later; "up to date"; "not an
|
||||
installed copy"; and the error table below. There is no progress *dialog*: progress is the banner's percent. A
|
||||
package that fails its checksum is downloaded once more before the Corrupt row is shown (the table's "auto-retry
|
||||
once").
|
||||
@@ -104,7 +104,7 @@ flow, and the tests run the flow over a fake client because nothing here may tou
|
||||
empty token — measured on 1.2.0 by reflection, so the request identifies the product and nothing else. When the rules fetch is built
|
||||
(`05_DETECTION` FR-7.3, `20_OPEN_QUESTIONS` §S20 feed half) it needs a client of its own; this paragraph no
|
||||
longer claims the updater provides one.
|
||||
- Release notes are rendered as plain text, not Markdown.
|
||||
- ~~Release notes are rendered as plain text, not Markdown.~~ Corrected 2026-10-03: rendered since beta.12 (Markdig; HTML off, no image fetched).
|
||||
|
||||
`UpdateServiceTests` (App.Tests/Update) cover the two skips, the channels, Deferred ↔ Ready, each error row, and
|
||||
the apply's three endings; `UpdateFailureMapperTests` the table; `UninstallHookTests` the hook; a real feed has
|
||||
|
||||
+5
-3
@@ -172,7 +172,7 @@ assumed to.
|
||||
|
||||
```
|
||||
cmake --build --preset x64-release
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -o out/app
|
||||
dotnet publish src/FrameLedger.App -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -p:FrameLedgerSourceRef={tag} -o out/app
|
||||
dotnet publish src/FrameLedger.Agent -c Release -r win-x64 --self-contained -p:PublishReadyToRun=true -o out/app
|
||||
vpk pack --packId FrameLedger.App --packVersion {ver} --packDir out/app --mainExe FrameLedger.exe --packTitle FrameLedger --releaseNotes out/notes.md --outputDir out/release
|
||||
```
|
||||
@@ -180,7 +180,9 @@ vpk pack --packId FrameLedger.App --packVersion {ver} --packDir out/app --mainEx
|
||||
> **Run by `release.yml` since 2026-09-14 (P4 PR-5)** — `13_CI_CD` §release.yml carries the steps around it
|
||||
> (the version gate, `{{RELEASE_DATE}}`, the published-tree assertion, checksums, the release). Both publishes
|
||||
> take `-p:Version=<tag>` (§Version). No `--icon`: `assets/icon.ico` does not exist, and this line named it
|
||||
> for six weeks.
|
||||
> for six weeks. **Since beta.12 the App also takes `-p:FrameLedgerSourceRef`** — the tag, or for a rehearsal the
|
||||
> commit — stamped as assembly metadata so its links into the repository open THIS version's documents
|
||||
> (`Services/RepositoryLinks`); a build without it links to `main`.
|
||||
>
|
||||
> **The package id is `FrameLedger.App`, and this line said `FrameLedger` until 2026-09-14 — which would have
|
||||
> deleted every user's ledger on uninstall.** Velopack installs into `%LOCALAPPDATA%\<packId>` and removes that
|
||||
@@ -249,7 +251,7 @@ document the app displays for acceptance (FR-11) is a defect, not a template.
|
||||
10. `tools/chokepoint-check.ps1` — injection and evasion primitives confined to one file, native **and** managed, plus the `FL_GUARD_TESTABLE` symbol check against the shipped artifacts
|
||||
11. **`tools/hookinventory-check.ps1`** — three passes: A resolves every vendor symbol the Overlay names against `docs/vendor-exports.json`, B sweeps for stray literals, C reads the BUILT Overlay's import table and asserts it imports no vendor module. C skips loudly under `-SkipNative`. **Missing from this list until 2026-08-28**, which is §R10 happening again
|
||||
12. **`tools/package-closure-check.ps1`** — both halves: the self-test (5 cases, 4 of which must go RED) **and** a live pass over this repository. It walks the transitive `ProjectReference` closure of the two publish roots below and fails on anything outside the allowlist, naming the reference edge. `FrameLedger.CaptureHost` is an injecting entry point kept out of the package by construction, and `20_OPEN_QUESTIONS` §S27 is closed on exactly that basis
|
||||
13. `tools/license-check.ps1` — asserts every vendored third-party has a licence copy in `legal/licenses/`, and that no Intel IGCL / AMD ADLX material has appeared in the tree; since P4 PR-6 (§3) also that `legal/licenses/nuget/` is exactly what `tools/license-gather.ps1` writes for this build's restore output — every NuGet package the App and the Agent ship (77), both directions. `license-gather.ps1 -SelfTest` runs first: fourteen fixture cases, five that must be RED (a hand edit, a package that no longer ships, a URL-only licence with no reviewed override, an applied MPL Exhibit B, a missing restore output), and one run under tr-TR in a child process, because the output must not depend on the machine's culture
|
||||
13. `tools/license-check.ps1` — asserts every vendored third-party has a licence copy in `legal/licenses/`, and that no Intel IGCL / AMD ADLX material has appeared in the tree; since P4 PR-6 (§3) also that `legal/licenses/nuget/` is exactly what `tools/license-gather.ps1` writes for this build's restore output — every NuGet package the App and the Agent ship (77), both directions. `license-gather.ps1 -SelfTest` runs first: ~~fourteen~~ sixteen fixture cases, ~~five~~ six that must be RED (a hand edit, a package that no longer ships, a URL-only licence with no reviewed override, an expression with no text in the script and no reviewed override, an applied MPL Exhibit B, a missing restore output), and one run under tr-TR in a child process, because the output must not depend on the machine's culture. **Since beta.12 (78 packages):** a reviewed override also answers for an expression the script has no text for — Markdig declares BSD-2-Clause and ships no file, and `tools/license-overrides/Markdig.txt` is the project's own `license.txt` at the packaged commit
|
||||
13b. `tools/accuracy-check.ps1 -SelfTest`, then live — the accuracy block is ONE text (`legal/ACCURACY.md`) embedded verbatim in `README.md` and `legal/DISCLAIMER.md` §4; a copy that drifted, a copy with no markers, or an empty source is red. Four self-test cases, both directions (§S23-6, 2026-09-06)
|
||||
13c. **`tools/notice-check.ps1 -SelfTest`, then live** (beta.12, owner decision D45, 2026-10-03) — every first-party source file (`.cs .cpp .h .inl .ps1 .xaml`, tracked or new, minus `src/native/third_party/`) opens with `SPDX-License-Identifier: GPL-3.0-only` and `Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE` in its own comment syntax, because GPLv3 §7 wants additional terms named "in the relevant source files" (`NOTICE` carries them); the second line may name another holder and year in the same form (a contributor's own file).
|
||||
Seven self-test cases, both directions; `./tools/notice-check.ps1 -Fix` writes a missing header, and `tools/resx-gen.ps1` generates the accessor with it
|
||||
|
||||
@@ -154,6 +154,21 @@ Native `Menu`, `TabControl`, `ComboBox`, `Slider`, `ListView` are fine — the `
|
||||
- Do **not** set `Background` on `FluentWindow` (kills Mica). Page backgrounds transparent by default.
|
||||
- Exception to the no-hex rule: the chart palette — defined once per theme in `Styles/ChartPalette.xaml` (two dictionaries), never inline.
|
||||
|
||||
## FlowDocument (rendered documents, beta.12)
|
||||
|
||||
- **WPF UI 4.3.0 styles no `FlowDocument`.** Its own defaults are black Georgia on white, so a document in the dark theme
|
||||
is unreadable unless the document is themed in code: `Markdown/MarkdownRenderer` sets `TextElement.Foreground` to
|
||||
`TextFillColorPrimaryBrush` and `TextElement.FontFamily` to `ContentControlThemeFontFamily` **by resource reference**
|
||||
(`SetResourceReference`, the code form of `DynamicResource`), a transparent background, and resource references for
|
||||
every other colour (`AccentTextFillColorPrimaryBrush` links, `SubtleFillColorSecondaryBrush` code and table headers,
|
||||
`ControlStrokeColorDefaultBrush` rules, quote bars and table borders). Never a literal brush.
|
||||
- Host it in `Controls/MarkdownView` (a `FlowDocumentScrollViewer`, toolbar hidden) — not a `RichTextBox`, which is an
|
||||
editor. A `Hyperlink` there does not navigate by itself: the view handles `RequestNavigate` and decides
|
||||
(`Markdown/MarkdownLinks`).
|
||||
- `AccentTextFillColorPrimaryBrush` is the light accent in the dark theme only after `ApplicationThemeManager.Apply(…,
|
||||
updateAccent: true)` — measured 2026-10-03 in the test host, which skips it: links drew #003E92 on #202020 there and
|
||||
#73C2FF once the accent was applied as `WpfThemeApplier` applies it.
|
||||
|
||||
## Custom controls (`FpsReadout`, `TriStateChip`, sparklines)
|
||||
|
||||
- Derive from `Control` with `ControlTemplate` in `Styles/FrameLedger.xaml`; template uses only theme brushes above → they re-theme for free.
|
||||
|
||||
@@ -4362,7 +4362,7 @@ Each of these is referenced by an existing doc but specified nowhere.
|
||||
| **Error taxonomy** | `07_IPC` lists `CaptureError` codes; no canonical mapping to resx keys and user-facing text, though `09_I18N` requires safety strings to be reviewed as legal text | `07_IPC`, `09_I18N` |
|
||||
| ~~**Threading model**~~ | ~~Which component owns which thread, UI-thread rules, and how the 1 Hz telemetry poller, 10 Hz drain and pipe reader interact~~ **Answered 2026-09-09 (P2 PR-C): `04_CAPTURE` §Threading model** — four threads, one owner per shared object, the pipe reader named as one more producer. This row was not struck when the section was written; struck 2026-09-13. What is still unspecified is the UI thread's own rules, which is `08_UI`'s in P3 | `04_CAPTURE`, `18_GPU_VENDOR_APIS` |
|
||||
| **Pipe/shm security** | Stated as policy ("DACL granting the current user's SID") but not as implementable SDDL, nor who creates the objects with what rights. The shm half is built (`fl_shm_host.h`, the Overlay creates the section under the current user's SID); the pipe half is **built 2026-09-13 (P3 PR-1, HANDOFF §P3 decision D11)**: `D:P(A;;GA;;;<user>)(A;;GA;;;BA)` (with the owner `O:<user>` stated since 2026-09-17, `07_IPC` §C) handed to `CreateNamedPipe` with `PIPE_REJECT_REMOTE_CLIENTS`, and the client's token user compared by impersonation on its first frame (`Infrastructure.Ipc.PipeAccessControl`, pinned by `PipeServerClientTests` including the refused stranger). **Row closed** | `07_IPC` |
|
||||
| ~~**Legal doc versioning**~~ | ~~FR-11 re-shows documents "when a document version increments". Nothing says where the current version lives, who writes `legal_acceptance.version`, or how the markdown is rendered in-app~~ **Answered 2026-09-14 (P3 PR-9):** the version is the document's own `**Version:**` line, read from the copy embedded in the App at build (`App.Services.LegalDocuments`); the App writes `legal_acceptance.version` on the one Accept and re-shows any document whose embedded version differs from its row; the markdown is shown as text with authoring comments stripped, not rendered (`08_UI` §First-run flow built note) | FR-11, `06_DATA_MODEL` |
|
||||
| ~~**Legal doc versioning**~~ | ~~FR-11 re-shows documents "when a document version increments". Nothing says where the current version lives, who writes `legal_acceptance.version`, or how the markdown is rendered in-app~~ **Answered 2026-09-14 (P3 PR-9):** the version is the document's own `**Version:**` line, read from the copy embedded in the App at build (`App.Services.LegalDocuments`); the App writes `legal_acceptance.version` on the one Accept and re-shows any document whose embedded version differs from its row; ~~the markdown is shown as text with authoring comments stripped, not rendered~~ the markdown is shown with authoring comments stripped and, since beta.12, rendered (`08_UI` §Menu, *Documents are rendered*; §First-run flow built note) | FR-11, `06_DATA_MODEL` |
|
||||
| **Accessibility / DPI** | NFR-9 states requirements; no design anywhere | NFR-9, `08_UI` |
|
||||
| **Uninstall / data deletion** | One Velopack clause. No in-app "delete all my data", despite the privacy position | `12_BUILD`, `legal/PRIVACY_POLICY.md` |
|
||||
| **Cover art** | Appears in the schema, the data directory and the UI; nothing says where it comes from or the licence position on downloaded store art | `06_DATA_MODEL`, `05_DETECTION` |
|
||||
|
||||
@@ -29,7 +29,6 @@ FrameLedger is licensed under **GPL-3.0-only**. It includes or depends on the th
|
||||
| Component | Use | License | Notes |
|
||||
|---|---|---|---|
|
||||
| **MinHook** | Inline function hooking in `FrameLedger.Overlay` | BSD-2-Clause | Vendored and built from source, pinned by commit. Copyright notice must ship in `legal/licenses/` |
|
||||
*(The **Intel PresentMon** row was removed on 2026-08-27. It is not bundled, not fetched, not redistributed and no longer used at all — §S31 retired it as a measurement oracle and the owner then dropped it outright — so a notice for it would be over-disclosure, which this document treats as a defect in the same way an omission is. `tools/license-check.ps1`'s matching claim was removed in the same commit, because a bidirectional check whose subject no longer exists cannot go green honestly: it would be asserting agreement about nothing.)*
|
||||
| Vulkan headers / loader interfaces | `FrameLedger.VkLayer` implicit layer | Apache-2.0 | Khronos headers; layer implemented against the documented loader–layer interface |
|
||||
| LibreHardwareMonitorLib | GPU sensors (all vendors) + CPU/motherboard sensors (optional, elevated) | MPL-2.0 | See §GPU telemetry below. Consumed unmodified |
|
||||
| WPF UI (`Wpf.Ui`, lepoco) | Fluent UI theme/controls/navigation | MIT | © lepo.co, Leszek Pomianowski and contributors. License copy must ship with the app (MIT requirement) — `legal/licenses/nuget/WPF-UI.txt`, the package's own LICENSE.md |
|
||||
@@ -43,6 +42,7 @@ FrameLedger is licensed under **GPL-3.0-only**. It includes or depends on the th
|
||||
| CsWin32 (build-time) | Win32 interop source generator | MIT | Build-time only |
|
||||
| NVIDIA NVAPI SDK | NVIDIA GPU telemetry + Reflex latency | MIT | **Vendored 2026-08-05** — nine headers + `amd64/nvapi64.lib`, at `src/native/third_party/nvapi/`. See §GPU telemetry below |
|
||||
| H.NotifyIcon.Wpf | Tray icon | MIT | |
|
||||
| Markdig | Markdown rendering in the App (since beta.12): the Legal Gate, Help, About, the update notes | BSD-2-Clause | © Alexandre Mutel. The package ships no licence file; its text is the project's own `license.txt` at the packaged commit, a reviewed override (`tools/license-overrides/Markdig.txt`) → `legal/licenses/nuget/Markdig.txt`. Consumed unmodified; HTML in a document is shown as text, never interpreted, and no image is fetched |
|
||||
| **Transitive, under LibreHardwareMonitorLib** — BlackSharp.Core, DiskInfoToolkit, RAMSPDToolkit-NDD | Hardware access helpers LHM 0.9.6 depends on | MPL-2.0 | Not named by this table until 2026-09-15. **Exhibit B clear:** authenticated code search of each upstream repository (Blacktempel/BlackSharp, /DiskInfoToolkit, /RAMSPDToolkit) finds the sentence once, in `LICENSE` — the template — and no source file carries an MPL notice at all, so the repository licence governs and §3.3 Secondary Licenses applies. Default branch as searched; the nuspecs pin commits `c70b735c`, `25319eae`, `3b47b960`. Source Code Form links are in each package's text |
|
||||
| **Transitive, under LibreHardwareMonitorLib** — HidSharp; Mono.Posix.NETStandard; System.IO.Ports, System.Management, System.CodeDom, System.IO.FileSystem.AccessControl | USB HID, POSIX helpers, serial ports, WMI | Apache-2.0 (HidSharp's LICENSE.txt); MIT (Mono's LICENSE, reviewed override); MIT (Microsoft) | Mono.Posix.NETStandard declares only a URL; its text is the Mono LICENSE file that URL resolves to, fetched 2026-09-15 and committed as `tools/license-overrides/Mono.Posix.NETStandard.txt` |
|
||||
| **Transitive, under ScottPlot.WPF** — SkiaSharp, HarfBuzzSharp and their Win32 native assets; OpenTK 4.x; OpenTK.GLWpfControl; OpenTK.redist.glfw | 2-D rendering, text shaping, OpenGL host | MIT; GLFW is zlib (its COPYING.md) | The native Skia and HarfBuzz builds carry their own third-party notices, shipped once each in `legal/licenses/nuget/notices-*.txt`. OpenTK.GLWpfControl declares only a URL (reviewed override, like Mono.Posix) |
|
||||
@@ -50,6 +50,8 @@ FrameLedger is licensed under **GPL-3.0-only**. It includes or depends on the th
|
||||
| Roslynator, Meziantou.Analyzer, VS Threading Analyzers (build-time) | Static analysis | Apache-2.0 / MIT | Build-time only |
|
||||
| **Test-time only, never shipped** — xUnit.net v3 4.x (`xunit.v3.mtp-off`, `xunit.runner.visualstudio`), Microsoft.NET.Test.Sdk, coverlet.collector, FluentAssertions 7.x, NSubstitute; Catch2 (native) | Unit and integration tests, coverage | Apache-2.0 (xUnit.net, <https://github.com/xunit/xunit>; FluentAssertions **7.x only**) · MIT (Test.Sdk, coverlet) · BSD-3-Clause (NSubstitute) · BSL-1.0 (Catch2) | Not named by this table until 2026-09-21. None of them is in a published package: `12_BUILD` publishes App and Agent only, `tools/package-closure-check.ps1` keeps the test projects out of that closure, and `legal/licenses/nuget/` therefore lists none of them. xUnit.net moved 3.2.2 → 4.0.1 on 2026-09-21, same licence. **FluentAssertions is pinned to `[7.2.2]` on purpose**: 8.x is Xceed's Community Licence, not an OSI licence (`Directory.Packages.props`, `20_OPEN_QUESTIONS` §G). Catch2's text is `legal/licenses/catch2-BSL-1.0.txt` |
|
||||
|
||||
*(The **Intel PresentMon** row was removed on 2026-08-27. It is not bundled, not fetched, not redistributed and no longer used at all — §S31 retired it as a measurement oracle and the owner then dropped it outright — so a notice for it would be over-disclosure, which this document treats as a defect in the same way an omission is. `tools/license-check.ps1`'s matching claim was removed in the same commit, because a bidirectional check whose subject no longer exists cannot go green honestly: it would be asserting agreement about nothing.)* *(Moved out of the table on 2026-10-03: a line without cells inside a table ended it for Markdig, so the App drew the whole table as text; GitHub draws it either way.)*
|
||||
|
||||
## GPU telemetry — what is bundled and what is not
|
||||
|
||||
Telemetry is layered so no proprietary vendor licence is ever required (`docs/18_GPU_VENDOR_APIS.md`).
|
||||
@@ -99,7 +101,7 @@ All product names, logos, and brands are property of their respective owners and
|
||||
## Attribution requirements checklist (release gate)
|
||||
|
||||
- [x] `legal/licenses/` contains full texts: MIT (per-project copies, **including `nvapi-MIT.txt`**), BSD-2-Clause (MinHook), MPL-2.0, Apache-2.0 — **2026-09-15 (P4 PR-6):** the vendored natives' copies as before, plus one generated text per shipped NuGet package in `legal/licenses/nuget/` (77), gated by `license-check` §3; the .NET runtime's licence and notices are added to the package by `release.yml`. The copies ship: the App's publish carries `legal/licenses/` as `licenses/`
|
||||
- [ ] About → Third-party tab lists this table with versions filled from `Directory.Packages.props` — **not built as of 2026-09-16 and not a gate for the first pre-release**: the texts ship as files (`licenses/` beside the App, `licenses/nuget/INDEX.md` lists every package with its version), and Help ▸ Documentation opens this file; the tab is an open UI item
|
||||
- [x] About → Third-party tab lists this table with versions ~~filled from `Directory.Packages.props`~~ — **built beta.12 (2026-10-03)**: Help ▸ About ▸ *Third-party licences* renders this file and `licenses/nuget/INDEX.md` — every shipped package with its version and licence, generated from what the build restores rather than from `Directory.Packages.props` — with a button that opens the published `licenses\` folder. ~~not built as of 2026-09-16 and not a gate for the first pre-release: the texts ship as files (`licenses/` beside the App, `licenses/nuget/INDEX.md` lists every package with its version), and Help ▸ Documentation opens this file; the tab is an open UI item~~
|
||||
- ~~PresentMon license + copyright shipped beside the bundled binary~~ — **removed 2026-08-27 with the dependency.** Nothing Intel-authored is distributed by this project
|
||||
- [x] MPL-2.0 source-availability note points to upstream LibreHardwareMonitor repository — every MPL-2.0 package text in `legal/licenses/nuget/` names its Source Code Form (MPL-2.0 §3.2), LHM's `https://github.com/LibreHardwareMonitor/LibreHardwareMonitor` included (2026-09-15)
|
||||
- [x] LHM checked for MPL-2.0 Exhibit B on any depended-upon file — clear as of 0.9.6 / commit `3d331e33`, 2026-08-02
|
||||
|
||||
@@ -18,6 +18,7 @@ from the runtime packs the publish used.
|
||||
| HarfBuzzSharp.NativeAssets.Win32 | 8.3.1.1 | MIT | App | [HarfBuzzSharp.NativeAssets.Win32.txt](HarfBuzzSharp.NativeAssets.Win32.txt) |
|
||||
| HidSharp | 2.6.4 | the file LICENSE.txt in the package | Agent, App | [HidSharp.txt](HidSharp.txt) |
|
||||
| LibreHardwareMonitorLib | 0.9.6 | MPL-2.0 | Agent, App | [LibreHardwareMonitorLib.txt](LibreHardwareMonitorLib.txt) |
|
||||
| Markdig | 1.4.0 | BSD-2-Clause | App | [Markdig.txt](Markdig.txt) |
|
||||
| Microsoft.Data.Sqlite.Core | 10.0.12 | MIT | Agent, App | [Microsoft.Data.Sqlite.Core.txt](Microsoft.Data.Sqlite.Core.txt) |
|
||||
| Microsoft.Extensions.Configuration | 10.0.12 | MIT | Agent, App | [Microsoft.Extensions.Configuration.txt](Microsoft.Extensions.Configuration.txt) |
|
||||
| Microsoft.Extensions.Configuration.Abstractions | 10.0.12 | MIT | Agent, App | [Microsoft.Extensions.Configuration.Abstractions.txt](Microsoft.Extensions.Configuration.Abstractions.txt) |
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
Markdig 1.4.0
|
||||
|
||||
Licence declared: BSD-2-Clause
|
||||
Text below: tools/license-overrides/Markdig.txt, a reviewed copy of the project's own licence file; the package ships none
|
||||
Copyright: Alexandre Mutel
|
||||
Authors: Alexandre Mutel
|
||||
Project: https://xoofx.github.io/markdig
|
||||
Ships in: App
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Reviewed override for Markdig 1.4.0 (tools/license-gather.ps1).
|
||||
|
||||
The package declares <license type="expression">BSD-2-Clause</license> and ships no licence file. The text
|
||||
below is the project's own license.txt at the commit the package names (<repository commit=
|
||||
"56e9c238584a44a169f174c881855c049768634c">), fetched on 2026-10-03 from
|
||||
https://raw.githubusercontent.com/xoofx/markdig/56e9c238584a44a169f174c881855c049768634c/license.txt,
|
||||
verbatim. The package's <copyright> field is "Alexandre Mutel"; the file names the same holder.
|
||||
|
||||
Used by the App since beta.12 to render the documents it shows (the Legal Gate, Help, About, the user guide);
|
||||
consumed unmodified.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2016-2026, Alexandre Mutel
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification
|
||||
, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. 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 SOFTWARE 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -392,6 +392,9 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<ILegalAcceptanceStore, SqliteLegalAcceptanceStore>();
|
||||
services.AddSingleton(static sp => new LegalGate(sp.GetRequiredService<ILegalAcceptanceStore>(), LegalDocuments.Load()));
|
||||
services.AddSingleton<IFirstRunFlow, FirstRunFlow>();
|
||||
|
||||
// beta.12: Help ▸ Limitations and Help ▸ About, rendered from what this build embeds.
|
||||
services.AddSingleton<IDocumentWindows, DocumentWindows>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
<!-- Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE -->
|
||||
|
||||
<UserControl x:Class="FrameLedger.App.Controls.DocumentBrowser"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:res="clr-namespace:FrameLedger.App"
|
||||
xmlns:local="clr-namespace:FrameLedger.App.Controls">
|
||||
<!-- beta.12: a list of pages beside one rendered page; the list hides itself when there is one page. -->
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ListBox x:Name="PageList"
|
||||
Grid.Column="0"
|
||||
Width="230"
|
||||
Margin="0,0,12,0"
|
||||
AutomationProperties.Name="{x:Static res:Strings.Document_Pages}"
|
||||
DisplayMemberPath="Title"
|
||||
SelectionChanged="OnPageSelected" />
|
||||
<Border Grid.Column="1" BorderThickness="1" CornerRadius="4" Padding="8,6,0,0"
|
||||
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
||||
Background="{DynamicResource ControlFillColorDefaultBrush}">
|
||||
<local:MarkdownView x:Name="View" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,108 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Pages of embedded documents beside one rendered page (beta.12): Help ▸ Limitations, About's two document tabs, the
|
||||
/// user guide. A link from one page to another page it holds opens that page here (and scrolls to the heading it names);
|
||||
/// a link to any other file of the repository opens on GitHub at this build's source; the rest is
|
||||
/// <see cref="MarkdownView"/>'s.
|
||||
/// </summary>
|
||||
public partial class DocumentBrowser : UserControl
|
||||
{
|
||||
private IReadOnlyList<DocumentPage> _pages = [];
|
||||
|
||||
public DocumentBrowser()
|
||||
{
|
||||
InitializeComponent();
|
||||
View.RepositoryLinkRequested += OnRepositoryLink;
|
||||
}
|
||||
|
||||
/// <summary>Raised when another page is shown.</summary>
|
||||
public event EventHandler? PageChanged;
|
||||
|
||||
/// <summary>The pages, in the order the list shows them.</summary>
|
||||
public IReadOnlyList<DocumentPage> Pages
|
||||
{
|
||||
get => _pages;
|
||||
set
|
||||
{
|
||||
_pages = value ?? [];
|
||||
PageList.ItemsSource = _pages;
|
||||
PageList.Visibility = _pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
|
||||
PageList.SelectedIndex = _pages.Count > 0 ? 0 : -1;
|
||||
if (_pages.Count == 0)
|
||||
{
|
||||
ShowPage(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The page shown.</summary>
|
||||
public DocumentPage? SelectedPage => PageList.SelectedItem as DocumentPage;
|
||||
|
||||
/// <summary>How a link leaves the App.</summary>
|
||||
public IUrlOpener UrlOpener
|
||||
{
|
||||
get => View.UrlOpener;
|
||||
set => View.UrlOpener = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
/// <summary>The viewer, for a test's look at what it drew.</summary>
|
||||
internal MarkdownView Viewer => View;
|
||||
|
||||
/// <summary>Shows the page at <paramref name="path"/> and scrolls to <paramref name="anchor"/>; whether this browser holds that page.</summary>
|
||||
public bool Show(string path, string? anchor = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
DocumentPage? page = _pages.FirstOrDefault(p => string.Equals(p.Path, path, StringComparison.OrdinalIgnoreCase));
|
||||
if (page is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ReferenceEquals(page, SelectedPage))
|
||||
{
|
||||
if (anchor is { Length: > 0 })
|
||||
{
|
||||
_ = View.ScrollTo(anchor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (anchor is { Length: > 0 })
|
||||
{
|
||||
// After the new page's first layout: before it there is nothing to bring into view.
|
||||
void ScrollOnce(object? s, EventArgs e)
|
||||
{
|
||||
View.LayoutUpdated -= ScrollOnce;
|
||||
_ = View.ScrollTo(anchor);
|
||||
}
|
||||
|
||||
View.LayoutUpdated += ScrollOnce;
|
||||
}
|
||||
|
||||
PageList.SelectedItem = page;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void OnPageSelected(object sender, SelectionChangedEventArgs e) => ShowPage(SelectedPage);
|
||||
|
||||
private void ShowPage(DocumentPage? page)
|
||||
{
|
||||
View.DocumentPath = page?.Path;
|
||||
View.IsPlainText = page?.IsPlainText ?? false;
|
||||
View.MarkdownText = page?.Text ?? string.Empty;
|
||||
AutomationProperties.SetName(View, page?.Title ?? string.Empty);
|
||||
PageChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
private void OnRepositoryLink(object? sender, RepositoryLinkEventArgs e) => e.Handled = Show(e.Path, e.Anchor);
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:res="clr-namespace:FrameLedger.App"
|
||||
xmlns:local="clr-namespace:FrameLedger.App.Controls"
|
||||
xmlns:vm="clr-namespace:FrameLedger.App.ViewModels">
|
||||
<!-- 08_UI §First-run flow: four steps in one control; the window is a frame around it. -->
|
||||
<Grid Margin="24,16,24,16">
|
||||
@@ -52,14 +53,16 @@
|
||||
Content="{x:Static res:Strings.FirstRun_Legal_Online}"
|
||||
Icon="{ui:SymbolIcon Open24}" />
|
||||
</StackPanel>
|
||||
<TextBox Grid.Row="1"
|
||||
AutomationProperties.Name="{Binding ViewModel.SelectedDocument.Title}"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
IsReadOnlyCaretVisible="True"
|
||||
Text="{Binding ViewModel.SelectedDocument.Text, Mode=OneWay}"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto" />
|
||||
<!-- beta.12 (owner request 4): rendered, not raw Markdown; the GPL as written. Selectable and copyable. -->
|
||||
<Border Grid.Row="1" BorderThickness="1" CornerRadius="4" Padding="8,6,0,0"
|
||||
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
|
||||
Background="{DynamicResource ControlFillColorDefaultBrush}">
|
||||
<local:MarkdownView x:Name="DocumentView"
|
||||
AutomationProperties.Name="{Binding ViewModel.SelectedDocument.Title}"
|
||||
DocumentPath="{Binding ViewModel.SelectedDocument.Path}"
|
||||
IsPlainText="{Binding ViewModel.SelectedDocument.IsPlainText}"
|
||||
MarkdownText="{Binding ViewModel.SelectedDocument.Text}" />
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.ViewModels;
|
||||
|
||||
namespace FrameLedger.App.Controls;
|
||||
@@ -14,7 +15,20 @@ public partial class FirstRunContent : UserControl
|
||||
ViewModel = viewModel ?? throw new ArgumentNullException(nameof(viewModel));
|
||||
DataContext = this;
|
||||
InitializeComponent();
|
||||
DocumentView.UrlOpener = viewModel.Urls;
|
||||
DocumentView.RepositoryLinkRequested += OnRepositoryLink;
|
||||
}
|
||||
|
||||
public FirstRunViewModel ViewModel { get; }
|
||||
|
||||
/// <summary>A link from one of the documents to another the gate shows opens it here, not on GitHub.</summary>
|
||||
private void OnRepositoryLink(object? sender, RepositoryLinkEventArgs e)
|
||||
{
|
||||
LegalDocument? linked = ViewModel.Documents.FirstOrDefault(d => string.Equals(d.Path, e.Path, StringComparison.OrdinalIgnoreCase));
|
||||
if (linked is not null)
|
||||
{
|
||||
ViewModel.SelectedDocument = linked;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using FrameLedger.App.Markdown;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// A document the App shows, rendered (beta.12, owner request 4): Markdown through <see cref="MarkdownRenderer"/>, or a plain
|
||||
/// text kept exactly as written (<see cref="IsPlainText"/> — the GPL's <c>LICENSE</c>). Read-only, selectable, copyable
|
||||
/// (Ctrl+C), zoomable (Ctrl+wheel). Links follow <see cref="MarkdownLinks"/>: http, https and mailto through
|
||||
/// <see cref="UrlOpener"/>; <c>#section</c> scrolls; a file of the repository is offered to the host first
|
||||
/// (<see cref="RepositoryLinkRequested"/>), which shows it when the App embeds it, and otherwise opens on GitHub at this
|
||||
/// build's source (<see cref="RepositoryLinks"/>); anything else is not followed.
|
||||
/// </summary>
|
||||
public sealed class MarkdownView : FlowDocumentScrollViewer
|
||||
{
|
||||
public static readonly DependencyProperty MarkdownTextProperty =
|
||||
DependencyProperty.Register(nameof(MarkdownText), typeof(string), typeof(MarkdownView), new PropertyMetadata(null, OnSourceChanged));
|
||||
|
||||
public static readonly DependencyProperty IsPlainTextProperty =
|
||||
DependencyProperty.Register(nameof(IsPlainText), typeof(bool), typeof(MarkdownView), new PropertyMetadata(false, OnSourceChanged));
|
||||
|
||||
public static readonly DependencyProperty DocumentPathProperty =
|
||||
DependencyProperty.Register(nameof(DocumentPath), typeof(string), typeof(MarkdownView), new PropertyMetadata(null, OnSourceChanged));
|
||||
|
||||
private IReadOnlyDictionary<string, Block> _anchors = new Dictionary<string, Block>(StringComparer.Ordinal);
|
||||
|
||||
public MarkdownView()
|
||||
{
|
||||
IsToolBarVisible = false;
|
||||
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled;
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto;
|
||||
Focusable = true;
|
||||
AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(OnRequestNavigate));
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
/// <summary>A link to another file of the repository; the host shows it and sets Handled, or it opens on GitHub.</summary>
|
||||
public event EventHandler<RepositoryLinkEventArgs>? RepositoryLinkRequested;
|
||||
|
||||
/// <summary>The document's text.</summary>
|
||||
public string? MarkdownText
|
||||
{
|
||||
get => (string?)GetValue(MarkdownTextProperty);
|
||||
set => SetValue(MarkdownTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>Show the text as written — monospace, every line kept — rather than as Markdown.</summary>
|
||||
public bool IsPlainText
|
||||
{
|
||||
get => (bool)GetValue(IsPlainTextProperty);
|
||||
set => SetValue(IsPlainTextProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>The document's path from the repository root, which its relative links are resolved against.</summary>
|
||||
public string? DocumentPath
|
||||
{
|
||||
get => (string?)GetValue(DocumentPathProperty);
|
||||
set => SetValue(DocumentPathProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>How a link leaves the App; the shell's opener unless the host gives its own.</summary>
|
||||
public IUrlOpener UrlOpener { get; set; } = new ShellUrlOpener();
|
||||
|
||||
/// <summary>The headings this document can scroll to, by anchor.</summary>
|
||||
public IReadOnlyCollection<string> Anchors => [.. _anchors.Keys];
|
||||
|
||||
/// <summary>Brings the heading with <paramref name="anchor"/> into view; whether the document has it.</summary>
|
||||
public bool ScrollTo(string anchor)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(anchor);
|
||||
if (!_anchors.TryGetValue(anchor, out Block? block))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
block.BringIntoView();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void OnSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((MarkdownView)d).Rebuild();
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
string text = MarkdownText ?? string.Empty;
|
||||
RenderedMarkdown rendered = IsPlainText ? MarkdownRenderer.RenderPlainText(text) : MarkdownRenderer.Render(text, DocumentPath);
|
||||
_anchors = rendered.Anchors;
|
||||
Document = rendered.Document;
|
||||
}
|
||||
|
||||
private void OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
e.Handled = true;
|
||||
MarkdownLinkTarget target = MarkdownLinks.Resolve(DocumentPath, e.Uri?.OriginalString);
|
||||
if (target.External is { } external)
|
||||
{
|
||||
_ = UrlOpener.Open(external);
|
||||
}
|
||||
else if (target.RepositoryPath is { } path)
|
||||
{
|
||||
var args = new RepositoryLinkEventArgs(path, target.Anchor);
|
||||
RepositoryLinkRequested?.Invoke(this, args);
|
||||
if (!args.Handled)
|
||||
{
|
||||
_ = UrlOpener.Open(RepositoryLinks.Blob(path, target.Anchor));
|
||||
}
|
||||
}
|
||||
else if (target.Anchor is { } anchor)
|
||||
{
|
||||
_ = ScrollTo(anchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// A link in a shown document to another file of the repository (<see cref="MarkdownView.RepositoryLinkRequested"/>): the
|
||||
/// host sets <see cref="Handled"/> when it shows that file itself; otherwise it opens on GitHub at this build's source.
|
||||
/// </summary>
|
||||
public sealed class RepositoryLinkEventArgs(string path, string? anchor) : EventArgs
|
||||
{
|
||||
/// <summary>From the repository root, forward slashes.</summary>
|
||||
public string Path { get; } = path;
|
||||
|
||||
/// <summary>The heading anchor the link names, without its <c>#</c>; null for none.</summary>
|
||||
public string? Anchor { get; } = anchor;
|
||||
|
||||
public bool Handled { get; set; }
|
||||
}
|
||||
@@ -47,6 +47,19 @@
|
||||
<EmbeddedResource Include="..\..\LICENSE" LogicalName="LICENSE" />
|
||||
<!-- beta.10 (D36): what the whole software cannot do, shown under Help > Limitations; information, not one of FR-11's accepted documents. -->
|
||||
<EmbeddedResource Include="..\..\LIMITATIONS.md" LogicalName="LIMITATIONS.md" />
|
||||
<!-- beta.12: what Help > About shows, rendered from the text this build carries (D45: the copyright line and the GPLv3
|
||||
section 7 terms, the trademark note, the third-party notices and the index of every shipped package's licence). -->
|
||||
<EmbeddedResource Include="..\..\NOTICE" LogicalName="NOTICE" />
|
||||
<EmbeddedResource Include="..\..\legal\TRADEMARKS.md" LogicalName="legal/TRADEMARKS.md" />
|
||||
<EmbeddedResource Include="..\..\legal\THIRD_PARTY_NOTICES.md" LogicalName="legal/THIRD_PARTY_NOTICES.md" />
|
||||
<EmbeddedResource Include="..\..\legal\licenses\nuget\INDEX.md" LogicalName="legal/licenses/nuget/INDEX.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- beta.12: the source this build was made from, so the App's links into the repository open THIS version's documents
|
||||
(Services/RepositoryLinks.cs). release.yml passes the tag (a rehearsal, its commit); a local build has none and links
|
||||
to main. -->
|
||||
<ItemGroup Condition="'$(FrameLedgerSourceRef)' != ''">
|
||||
<AssemblyMetadata Include="FrameLedgerSourceRef" Value="$(FrameLedgerSourceRef)" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -68,6 +81,7 @@
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" />
|
||||
<PackageReference Include="ScottPlot.WPF" />
|
||||
<PackageReference Include="H.NotifyIcon.Wpf" />
|
||||
<PackageReference Include="Markdig" />
|
||||
<PackageReference Include="Velopack" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" />
|
||||
<PackageReference Include="Serilog" />
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Markdown;
|
||||
|
||||
/// <summary>
|
||||
/// Where a link in a shown document leads (<see cref="MarkdownLinks.Resolve"/>): out to the browser (<see cref="External"/>),
|
||||
/// to a section of the same document (<see cref="Anchor"/>), to a file of the repository (<see cref="RepositoryPath"/>,
|
||||
/// shown in the App when it embeds that file, on GitHub at this build's source otherwise) — or nowhere, for a link the App
|
||||
/// refuses to follow (<see cref="IsRefused"/>: a scheme other than http, https or mailto, or a path that leaves the
|
||||
/// repository).
|
||||
/// </summary>
|
||||
public sealed record MarkdownLinkTarget
|
||||
{
|
||||
public Uri? External { get; init; }
|
||||
|
||||
/// <summary>The anchor without its <c>#</c>, lower-case; on its own for a link inside the document, or with <see cref="RepositoryPath"/>.</summary>
|
||||
public string? Anchor { get; init; }
|
||||
|
||||
/// <summary>A path from the repository root with forward slashes, never leaving it (<c>docs/03_METRICS.md</c>).</summary>
|
||||
public string? RepositoryPath { get; init; }
|
||||
|
||||
public bool IsRefused => External is null && Anchor is null && RepositoryPath is null;
|
||||
|
||||
public static MarkdownLinkTarget Refused { get; } = new();
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace FrameLedger.App.Markdown;
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the links of a document the App shows (beta.12): http, https and mailto go to the browser; <c>#section</c>
|
||||
/// scrolls within the document; a relative path is resolved against the document's own place in the repository, the way
|
||||
/// GitHub resolves it, and stays inside the repository. Every other scheme — <c>file:</c>, <c>javascript:</c>, a UNC path —
|
||||
/// is refused: a document is text to read, and nothing in it may start a program or open a local file.
|
||||
/// </summary>
|
||||
public static class MarkdownLinks
|
||||
{
|
||||
/// <summary>Where <paramref name="href"/>, found in the document at <paramref name="documentPath"/>, leads.</summary>
|
||||
/// <param name="documentPath">The document's path from the repository root (<c>legal/EULA.md</c>); null for a text with no place in it.</param>
|
||||
/// <param name="href">The link as written.</param>
|
||||
public static MarkdownLinkTarget Resolve(string? documentPath, string? href)
|
||||
{
|
||||
string link = (href ?? string.Empty).Trim();
|
||||
if (link.Length == 0)
|
||||
{
|
||||
return MarkdownLinkTarget.Refused;
|
||||
}
|
||||
|
||||
if (link[0] == '#')
|
||||
{
|
||||
return link.Length > 1 ? new MarkdownLinkTarget { Anchor = NormaliseAnchor(link[1..]) } : MarkdownLinkTarget.Refused;
|
||||
}
|
||||
|
||||
if (Uri.TryCreate(link, UriKind.Absolute, out Uri? absolute) && !link.StartsWith('/'))
|
||||
{
|
||||
return absolute.Scheme is "http" or "https" or "mailto" ? new MarkdownLinkTarget { External = absolute } : MarkdownLinkTarget.Refused;
|
||||
}
|
||||
|
||||
if (link.Contains(':', StringComparison.Ordinal) || link.StartsWith(@"\\", StringComparison.Ordinal) || link.StartsWith("//", StringComparison.Ordinal))
|
||||
{
|
||||
return MarkdownLinkTarget.Refused; // a scheme Uri did not parse, a drive letter, a UNC or protocol-relative path
|
||||
}
|
||||
|
||||
string? anchor = null;
|
||||
int hash = link.IndexOf('#', StringComparison.Ordinal);
|
||||
if (hash >= 0)
|
||||
{
|
||||
anchor = hash + 1 < link.Length ? NormaliseAnchor(link[(hash + 1)..]) : null;
|
||||
link = link[..hash];
|
||||
}
|
||||
|
||||
int query = link.IndexOf('?', StringComparison.Ordinal);
|
||||
if (query >= 0)
|
||||
{
|
||||
link = link[..query];
|
||||
}
|
||||
|
||||
string? path = Combine(documentPath, Uri.UnescapeDataString(link));
|
||||
return path is null ? MarkdownLinkTarget.Refused : new MarkdownLinkTarget { RepositoryPath = path, Anchor = anchor };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A heading's anchor as GitHub writes it: lower-case, punctuation removed (letters, digits, spaces, hyphens and
|
||||
/// underscores kept), each space a hyphen — "## The game's memory" → <c>the-games-memory</c>.
|
||||
/// </summary>
|
||||
public static string Slug(string heading)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(heading);
|
||||
var slug = new StringBuilder(heading.Length);
|
||||
#pragma warning disable CA1308 // GitHub writes heading anchors LOWER-cased; this matches them, it compares nothing for security
|
||||
string lower = heading.Trim().ToLowerInvariant();
|
||||
#pragma warning restore CA1308
|
||||
foreach (char c in lower)
|
||||
{
|
||||
if (char.IsLetterOrDigit(c) || c is '-' or '_')
|
||||
{
|
||||
slug.Append(c);
|
||||
}
|
||||
else if (c == ' ')
|
||||
{
|
||||
slug.Append('-');
|
||||
}
|
||||
}
|
||||
|
||||
return slug.ToString();
|
||||
}
|
||||
|
||||
#pragma warning disable CA1308 // the same lower-cased form as Slug
|
||||
private static string NormaliseAnchor(string anchor) => Uri.UnescapeDataString(anchor).ToLowerInvariant();
|
||||
#pragma warning restore CA1308
|
||||
|
||||
/// <summary>The target relative to the document's folder (or the root for <c>/path</c>); null when it climbs out of the repository.</summary>
|
||||
private static string? Combine(string? documentPath, string target)
|
||||
{
|
||||
var parts = new List<string>();
|
||||
if (!target.StartsWith('/') && documentPath is { Length: > 0 })
|
||||
{
|
||||
string[] folder = documentPath.Replace('\\', '/').Split('/', StringSplitOptions.RemoveEmptyEntries);
|
||||
parts.AddRange(folder.Take(folder.Length - 1));
|
||||
}
|
||||
|
||||
foreach (string part in target.Replace('\\', '/').Split('/', StringSplitOptions.RemoveEmptyEntries))
|
||||
{
|
||||
if (string.Equals(part, ".", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string.Equals(part, "..", StringComparison.Ordinal))
|
||||
{
|
||||
if (parts.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
parts.RemoveAt(parts.Count - 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
parts.Add(part);
|
||||
}
|
||||
|
||||
return parts.Count == 0 ? null : string.Join('/', parts);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using Markdig.Syntax;
|
||||
using WpfBlock = System.Windows.Documents.Block;
|
||||
|
||||
namespace FrameLedger.App.Markdown;
|
||||
|
||||
/// <summary>One render's state: the source text a node can fall back to, the document's place in the repository, the anchors so far.</summary>
|
||||
internal sealed class MarkdownRenderContext(string source, string? documentPath)
|
||||
{
|
||||
public string? DocumentPath { get; } = documentPath;
|
||||
|
||||
public Dictionary<string, WpfBlock> Anchors { get; } = new(StringComparer.Ordinal);
|
||||
|
||||
/// <summary>The text a node was written as; empty for a span outside the source (a node the parser made up).</summary>
|
||||
public string Source(SourceSpan span) =>
|
||||
span.IsEmpty || span.Start < 0 || span.End >= source.Length ? string.Empty : source.Substring(span.Start, span.Length);
|
||||
}
|
||||
@@ -0,0 +1,408 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using Markdig;
|
||||
using Markdig.Extensions.EmphasisExtras;
|
||||
using Markdig.Extensions.TaskLists;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using MdBlock = Markdig.Syntax.Block;
|
||||
using MdInline = Markdig.Syntax.Inlines.Inline;
|
||||
using MdTable = Markdig.Extensions.Tables.Table;
|
||||
using MdTableCell = Markdig.Extensions.Tables.TableCell;
|
||||
using MdTableRow = Markdig.Extensions.Tables.TableRow;
|
||||
using TableColumnAlign = Markdig.Extensions.Tables.TableColumnAlign;
|
||||
using WpfBlock = System.Windows.Documents.Block;
|
||||
using WpfInline = System.Windows.Documents.Inline;
|
||||
using WpfList = System.Windows.Documents.List;
|
||||
using WpfTable = System.Windows.Documents.Table;
|
||||
using WpfTableCell = System.Windows.Documents.TableCell;
|
||||
using WpfTableRow = System.Windows.Documents.TableRow;
|
||||
|
||||
namespace FrameLedger.App.Markdown;
|
||||
|
||||
/// <summary>
|
||||
/// Markdown as a WPF <see cref="FlowDocument"/> (beta.12, owner request 4): the Legal Gate, Help ▸ Limitations, the update
|
||||
/// notes, the About window and the user guide show their documents rendered rather than as raw text. Markdig parses
|
||||
/// (CommonMark with pipe tables, strikethrough, autolinks and task lists); <b>HTML is off</b> — a tag in a document is shown
|
||||
/// as the text it is, never interpreted; <b>no image is fetched</b> — its description stands in; and a node this renderer
|
||||
/// does not know is shown as its own source text, so the renderer never shortens a document
|
||||
/// (<c>MarkdownRendererTests</c>: nothing dropped, for every document the App embeds).
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Colours and the font come from the theme by resource reference, so a document follows a theme change while it is open;
|
||||
/// WPF-UI 4.3.0 styles no <see cref="FlowDocument"/>, whose own defaults are black Georgia on white.
|
||||
/// </remarks>
|
||||
public static class MarkdownRenderer
|
||||
{
|
||||
/// <summary>The body text size, device-independent pixels.</summary>
|
||||
public const double BodySize = 14;
|
||||
|
||||
private static readonly double[] _headingSizes = [26, 21, 18, 16, 15, BodySize];
|
||||
|
||||
private static readonly FontFamily _mono = new("Cascadia Mono, Consolas, Courier New");
|
||||
|
||||
/// <summary>One pipeline for every document; also what the tests compare the rendered text against.</summary>
|
||||
public static MarkdownPipeline Pipeline { get; } = new MarkdownPipelineBuilder()
|
||||
.UsePipeTables()
|
||||
.UseEmphasisExtras(EmphasisExtraOptions.Strikethrough)
|
||||
.UseAutoLinks()
|
||||
.UseTaskLists()
|
||||
.DisableHtml()
|
||||
.Build();
|
||||
|
||||
/// <summary>The document parsed and drawn, with its headings' anchors.</summary>
|
||||
/// <param name="markdown">The text.</param>
|
||||
/// <param name="documentPath">Its path from the repository root, which its relative links are resolved against.</param>
|
||||
public static RenderedMarkdown Render(string markdown, string? documentPath = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(markdown);
|
||||
MarkdownDocument ast = Markdig.Markdown.Parse(markdown, Pipeline);
|
||||
var context = new MarkdownRenderContext(markdown, documentPath);
|
||||
FlowDocument document = NewDocument();
|
||||
foreach (MdBlock block in ast)
|
||||
{
|
||||
AddBlock(document.Blocks, block, context);
|
||||
}
|
||||
|
||||
return new RenderedMarkdown(document, context.Anchors);
|
||||
}
|
||||
|
||||
/// <summary>A text that is not Markdown — the GPL's own <c>LICENSE</c> — as it is written: monospace, every line kept.</summary>
|
||||
public static RenderedMarkdown RenderPlainText(string text)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(text);
|
||||
FlowDocument document = NewDocument();
|
||||
var paragraph = new Paragraph { FontFamily = _mono, FontSize = BodySize - 1 };
|
||||
AddLines(paragraph.Inlines, text.Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n'));
|
||||
document.Blocks.Add(paragraph);
|
||||
return new RenderedMarkdown(document, new Dictionary<string, WpfBlock>(StringComparer.Ordinal));
|
||||
}
|
||||
|
||||
/// <summary>The text a rendered inline shows, for anchors and image descriptions.</summary>
|
||||
internal static string TextOf(WpfInline inline) => inline switch
|
||||
{
|
||||
Run run => run.Text,
|
||||
LineBreak => " ",
|
||||
Span span => string.Concat(span.Inlines.Select(TextOf)),
|
||||
_ => string.Empty,
|
||||
};
|
||||
|
||||
private static FlowDocument NewDocument()
|
||||
{
|
||||
var document = new FlowDocument
|
||||
{
|
||||
FontSize = BodySize,
|
||||
PagePadding = new Thickness(4, 0, 12, 12),
|
||||
TextAlignment = TextAlignment.Left,
|
||||
Background = Brushes.Transparent,
|
||||
IsOptimalParagraphEnabled = false,
|
||||
IsHyphenationEnabled = false,
|
||||
};
|
||||
document.SetResourceReference(TextElement.ForegroundProperty, "TextFillColorPrimaryBrush");
|
||||
document.SetResourceReference(TextElement.FontFamilyProperty, "ContentControlThemeFontFamily");
|
||||
return document;
|
||||
}
|
||||
|
||||
private static void AddBlock(BlockCollection blocks, MdBlock block, MarkdownRenderContext context)
|
||||
{
|
||||
switch (block)
|
||||
{
|
||||
case HeadingBlock heading:
|
||||
blocks.Add(HeadingOf(heading, context));
|
||||
break;
|
||||
case ParagraphBlock paragraph:
|
||||
blocks.Add(ParagraphOf(paragraph, context));
|
||||
break;
|
||||
case QuoteBlock quote:
|
||||
blocks.Add(QuoteOf(quote, context));
|
||||
break;
|
||||
case ListBlock list:
|
||||
blocks.Add(ListOf(list, context));
|
||||
break;
|
||||
case MdTable table:
|
||||
blocks.Add(TableOf(table, context));
|
||||
break;
|
||||
case CodeBlock code: // fenced or indented
|
||||
blocks.Add(CodeOf(code));
|
||||
break;
|
||||
case ThematicBreakBlock:
|
||||
blocks.Add(RuleOf());
|
||||
break;
|
||||
case LinkReferenceDefinitionGroup:
|
||||
break; // "[label]: url" lines define links; they are not text
|
||||
case ContainerBlock container:
|
||||
foreach (MdBlock child in container)
|
||||
{
|
||||
AddBlock(blocks, child, context);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
// A block this renderer has no drawing for, as the text it was written as — shown, never dropped.
|
||||
blocks.Add(new Paragraph(new Run(context.Source(block.Span))) { Margin = new Thickness(0, 0, 0, 10) });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static Paragraph HeadingOf(HeadingBlock heading, MarkdownRenderContext context)
|
||||
{
|
||||
int level = Math.Clamp(heading.Level, 1, _headingSizes.Length);
|
||||
var paragraph = new Paragraph
|
||||
{
|
||||
FontSize = _headingSizes[level - 1],
|
||||
FontWeight = level <= 2 ? FontWeights.SemiBold : FontWeights.Bold,
|
||||
Margin = new Thickness(0, level == 1 ? 4 : 16, 0, 6),
|
||||
};
|
||||
AddInlines(paragraph.Inlines, heading.Inline, context);
|
||||
string anchor = MarkdownLinks.Slug(string.Concat(paragraph.Inlines.Select(TextOf)));
|
||||
if (anchor.Length > 0)
|
||||
{
|
||||
// GitHub numbers a repeated heading's anchor: the second "Notes" is #notes-1.
|
||||
string unique = anchor;
|
||||
for (int n = 1; context.Anchors.ContainsKey(unique); n++)
|
||||
{
|
||||
unique = anchor + "-" + n.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
context.Anchors[unique] = paragraph;
|
||||
}
|
||||
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
private static Paragraph ParagraphOf(ParagraphBlock block, MarkdownRenderContext context)
|
||||
{
|
||||
var paragraph = new Paragraph { Margin = new Thickness(0, 0, 0, 10), LineHeight = BodySize * 1.45 };
|
||||
AddInlines(paragraph.Inlines, block.Inline, context);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
private static Section QuoteOf(QuoteBlock quote, MarkdownRenderContext context)
|
||||
{
|
||||
var section = new Section { Margin = new Thickness(0, 0, 0, 10), Padding = new Thickness(12, 4, 0, 0), BorderThickness = new Thickness(3, 0, 0, 0) };
|
||||
section.SetResourceReference(WpfBlock.BorderBrushProperty, "ControlStrokeColorDefaultBrush");
|
||||
section.SetResourceReference(TextElement.ForegroundProperty, "TextFillColorSecondaryBrush");
|
||||
foreach (MdBlock child in quote)
|
||||
{
|
||||
AddBlock(section.Blocks, child, context);
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
private static WpfList ListOf(ListBlock list, MarkdownRenderContext context)
|
||||
{
|
||||
var wpf = new WpfList
|
||||
{
|
||||
MarkerStyle = list.IsOrdered ? TextMarkerStyle.Decimal : TextMarkerStyle.Disc,
|
||||
Margin = new Thickness(0, 0, 0, 10),
|
||||
Padding = new Thickness(24, 0, 0, 0),
|
||||
};
|
||||
if (list.IsOrdered && int.TryParse(list.OrderedStart, NumberStyles.Integer, CultureInfo.InvariantCulture, out int start) && start > 1)
|
||||
{
|
||||
wpf.StartIndex = start;
|
||||
}
|
||||
|
||||
foreach (MdBlock item in list)
|
||||
{
|
||||
var listItem = new ListItem();
|
||||
AddBlock(listItem.Blocks, item, context);
|
||||
|
||||
// A list item's paragraphs sit closer together than the document's.
|
||||
foreach (Paragraph p in listItem.Blocks.OfType<Paragraph>())
|
||||
{
|
||||
p.Margin = new Thickness(0, 0, 0, 4);
|
||||
}
|
||||
|
||||
wpf.ListItems.Add(listItem);
|
||||
}
|
||||
|
||||
return wpf;
|
||||
}
|
||||
|
||||
private static WpfTable TableOf(MdTable table, MarkdownRenderContext context)
|
||||
{
|
||||
var wpf = new WpfTable { CellSpacing = 0, Margin = new Thickness(0, 0, 0, 12), BorderThickness = new Thickness(1, 1, 0, 0) };
|
||||
wpf.SetResourceReference(WpfBlock.BorderBrushProperty, "ControlStrokeColorDefaultBrush");
|
||||
MdTableRow[] rows = [.. table.OfType<MdTableRow>()];
|
||||
int columns = Math.Max(table.ColumnDefinitions.Count, rows.Select(static r => r.Count).DefaultIfEmpty(0).Max());
|
||||
for (int i = 0; i < columns; i++)
|
||||
{
|
||||
wpf.Columns.Add(new TableColumn { Width = GridLength.Auto });
|
||||
}
|
||||
|
||||
var group = new TableRowGroup();
|
||||
foreach (MdTableRow row in rows)
|
||||
{
|
||||
var wpfRow = new WpfTableRow();
|
||||
if (row.IsHeader)
|
||||
{
|
||||
wpfRow.FontWeight = FontWeights.SemiBold;
|
||||
wpfRow.SetResourceReference(TextElement.BackgroundProperty, "SubtleFillColorSecondaryBrush");
|
||||
}
|
||||
|
||||
int column = 0;
|
||||
foreach (MdTableCell cell in row.OfType<MdTableCell>())
|
||||
{
|
||||
wpfRow.Cells.Add(CellOf(cell, column < table.ColumnDefinitions.Count ? table.ColumnDefinitions[column].Alignment : null, context));
|
||||
column++;
|
||||
}
|
||||
|
||||
group.Rows.Add(wpfRow);
|
||||
}
|
||||
|
||||
wpf.RowGroups.Add(group);
|
||||
return wpf;
|
||||
}
|
||||
|
||||
private static WpfTableCell CellOf(MdTableCell cell, TableColumnAlign? alignment, MarkdownRenderContext context)
|
||||
{
|
||||
var wpfCell = new WpfTableCell
|
||||
{
|
||||
Padding = new Thickness(8, 4, 8, 4),
|
||||
BorderThickness = new Thickness(0, 0, 1, 1),
|
||||
TextAlignment = alignment switch
|
||||
{
|
||||
TableColumnAlign.Center => TextAlignment.Center,
|
||||
TableColumnAlign.Right => TextAlignment.Right,
|
||||
_ => TextAlignment.Left,
|
||||
},
|
||||
};
|
||||
wpfCell.SetResourceReference(WpfTableCell.BorderBrushProperty, "ControlStrokeColorDefaultBrush");
|
||||
foreach (MdBlock child in cell)
|
||||
{
|
||||
AddBlock(wpfCell.Blocks, child, context);
|
||||
}
|
||||
|
||||
foreach (Paragraph p in wpfCell.Blocks.OfType<Paragraph>())
|
||||
{
|
||||
p.Margin = new Thickness(0);
|
||||
}
|
||||
|
||||
return wpfCell;
|
||||
}
|
||||
|
||||
private static Paragraph CodeOf(CodeBlock code)
|
||||
{
|
||||
var paragraph = new Paragraph { FontFamily = _mono, FontSize = BodySize - 1, Padding = new Thickness(10, 6, 10, 6), Margin = new Thickness(0, 0, 0, 10) };
|
||||
paragraph.SetResourceReference(TextElement.BackgroundProperty, "SubtleFillColorSecondaryBrush");
|
||||
AddLines(paragraph.Inlines, [.. code.Lines.Lines.Take(code.Lines.Count).Select(static l => l.Slice.ToString())]);
|
||||
return paragraph;
|
||||
}
|
||||
|
||||
private static Paragraph RuleOf()
|
||||
{
|
||||
var rule = new Paragraph { Margin = new Thickness(0, 6, 0, 12), BorderThickness = new Thickness(0, 0, 0, 1), FontSize = 2 };
|
||||
rule.SetResourceReference(WpfBlock.BorderBrushProperty, "ControlStrokeColorDefaultBrush");
|
||||
return rule;
|
||||
}
|
||||
|
||||
private static void AddLines(InlineCollection inlines, string[] lines)
|
||||
{
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
inlines.Add(new LineBreak());
|
||||
}
|
||||
|
||||
inlines.Add(new Run(lines[i]));
|
||||
}
|
||||
}
|
||||
|
||||
private static void AddInlines(InlineCollection inlines, ContainerInline? container, MarkdownRenderContext context)
|
||||
{
|
||||
if (container is not null)
|
||||
{
|
||||
inlines.AddRange(ChildrenOf(container, context));
|
||||
}
|
||||
}
|
||||
|
||||
private static List<WpfInline> ChildrenOf(ContainerInline container, MarkdownRenderContext context)
|
||||
{
|
||||
var children = new List<WpfInline>();
|
||||
foreach (MdInline child in container)
|
||||
{
|
||||
children.Add(InlineOf(child, context));
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
private static WpfInline InlineOf(MdInline inline, MarkdownRenderContext context) => inline switch
|
||||
{
|
||||
LiteralInline literal => new Run(literal.Content.ToString()),
|
||||
LineBreakInline lineBreak => lineBreak.IsHard ? new LineBreak() : new Run(" "),
|
||||
CodeInline code => CodeSpanOf(code.Content),
|
||||
HtmlEntityInline entity => new Run(entity.Transcoded.ToString()),
|
||||
TaskList task => new Run(task.Checked ? "☑" : "☐"), // the text after the box keeps its own space
|
||||
AutolinkInline autolink => LinkOf(autolink.IsEmail ? "mailto:" + autolink.Url : autolink.Url, [new Run(autolink.Url)], context),
|
||||
LinkInline { IsImage: true } image => ImageDescriptionOf(image, context),
|
||||
LinkInline link => LinkOf(link.Url, ChildrenOf(link, context), context),
|
||||
EmphasisInline emphasis => EmphasisOf(emphasis, context),
|
||||
ContainerInline container => SpanOf(ChildrenOf(container, context)),
|
||||
|
||||
// An inline this renderer has no drawing for, as the text it was written as.
|
||||
_ => new Run(context.Source(inline.Span)),
|
||||
};
|
||||
|
||||
private static Span SpanOf(IEnumerable<WpfInline> children)
|
||||
{
|
||||
var span = new Span();
|
||||
span.Inlines.AddRange(children);
|
||||
return span;
|
||||
}
|
||||
|
||||
private static Span EmphasisOf(EmphasisInline emphasis, MarkdownRenderContext context)
|
||||
{
|
||||
Span span = emphasis.DelimiterChar == '~'
|
||||
? new Span { TextDecorations = TextDecorations.Strikethrough }
|
||||
: emphasis.DelimiterCount >= 2 ? new Bold() : new Italic();
|
||||
AddInlines(span.Inlines, emphasis, context);
|
||||
return span;
|
||||
}
|
||||
|
||||
private static Run CodeSpanOf(string text)
|
||||
{
|
||||
var run = new Run(text) { FontFamily = _mono, FontSize = BodySize - 1 };
|
||||
run.SetResourceReference(TextElement.BackgroundProperty, "SubtleFillColorSecondaryBrush");
|
||||
return run;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A link the viewer can follow (<see cref="MarkdownLinks"/> decides where to). One the App refuses to follow is its text
|
||||
/// alone, with the address beside it, so nothing the author wrote is lost and nothing it names is opened.
|
||||
/// </summary>
|
||||
private static WpfInline LinkOf(string? url, IReadOnlyList<WpfInline> label, MarkdownRenderContext context)
|
||||
{
|
||||
if (MarkdownLinks.Resolve(context.DocumentPath, url).IsRefused || !Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out Uri? uri))
|
||||
{
|
||||
Span text = SpanOf(label);
|
||||
if (!string.IsNullOrWhiteSpace(url))
|
||||
{
|
||||
text.Inlines.Add(new Run(" (" + url + ")"));
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
var hyperlink = new Hyperlink { NavigateUri = uri, ToolTip = url };
|
||||
hyperlink.Inlines.AddRange(label);
|
||||
hyperlink.SetResourceReference(TextElement.ForegroundProperty, "AccentTextFillColorPrimaryBrush");
|
||||
return hyperlink;
|
||||
}
|
||||
|
||||
/// <summary>An image is never fetched — a document must not reach the network to be read — so its description stands in.</summary>
|
||||
private static Run ImageDescriptionOf(LinkInline image, MarkdownRenderContext context)
|
||||
{
|
||||
string description = string.Concat(ChildrenOf(image, context).Select(TextOf)).Trim();
|
||||
var run = new Run("[" + (description.Length > 0 ? description : image.Url ?? string.Empty) + "]") { FontStyle = FontStyles.Italic };
|
||||
run.SetResourceReference(TextElement.ForegroundProperty, "TextFillColorSecondaryBrush");
|
||||
return run;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows.Documents;
|
||||
|
||||
namespace FrameLedger.App.Markdown;
|
||||
|
||||
/// <summary>
|
||||
/// A document as <see cref="MarkdownRenderer"/> drew it: the <see cref="FlowDocument"/> a viewer shows, and each heading's
|
||||
/// block by its GitHub-style anchor (<c>#the-games-memory</c>), so an in-document link scrolls to its section.
|
||||
/// </summary>
|
||||
public sealed record RenderedMarkdown(FlowDocument Document, IReadOnlyDictionary<string, Block> Anchors);
|
||||
@@ -0,0 +1,15 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// One page a document window shows (beta.12): its title, its text as this build embeds it, its path in the repository
|
||||
/// (which its relative links resolve against, and where "Open on GitHub" goes), and whether it is a plain text shown as
|
||||
/// written rather than Markdown.
|
||||
/// </summary>
|
||||
public sealed record DocumentPage(string Title, string Text, string Path, bool IsPlainText = false)
|
||||
{
|
||||
/// <summary>The same file on GitHub, at this build's source.</summary>
|
||||
public Uri Url => RepositoryLinks.Blob(Path);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Windows;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="IDocumentWindows"/> over <see cref="DocumentWindow"/> and <see cref="AboutWindow"/>: one window of each kind —
|
||||
/// asking again brings the open one forward rather than stacking copies — owned by the shell.
|
||||
/// </summary>
|
||||
public sealed class DocumentWindows(IUrlOpener urls, IThemeApplier theme, AppearanceSettings appearance, ShellHost shell) : IDocumentWindows
|
||||
{
|
||||
private DocumentWindow? _limitations;
|
||||
private AboutWindow? _about;
|
||||
|
||||
public void ShowLimitations()
|
||||
{
|
||||
if (Reveal(_limitations))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_limitations = new DocumentWindow(Strings.Limitations_Title, [new DocumentPage(Strings.Limitations_Title, LimitationsDocument.Load(), LimitationsDocument.ResourceName)], urls, theme, appearance)
|
||||
{
|
||||
Owner = shell.Current,
|
||||
};
|
||||
_limitations.Closed += (_, _) => _limitations = null;
|
||||
_limitations.Show();
|
||||
}
|
||||
|
||||
public void ShowAbout()
|
||||
{
|
||||
if (Reveal(_about))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_about = new AboutWindow(urls, theme, appearance) { Owner = shell.Current };
|
||||
_about.Closed += (_, _) => _about = null;
|
||||
_about.Show();
|
||||
}
|
||||
|
||||
private static bool Reveal(Window? open)
|
||||
{
|
||||
if (open is null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (open.WindowState == WindowState.Minimized)
|
||||
{
|
||||
open.WindowState = WindowState.Normal;
|
||||
}
|
||||
|
||||
_ = open.Activate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.IO;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// The documents this build embeds beyond FR-11's (beta.12): <c>NOTICE</c> (the copyright line and the GPLv3 section 7
|
||||
/// additional terms), <c>legal/TRADEMARKS.md</c>, <c>legal/THIRD_PARTY_NOTICES.md</c> and the package-licence index — what
|
||||
/// Help ▸ About shows, read from the assembly so the App shows exactly the text it was built with.
|
||||
/// </summary>
|
||||
public static class EmbeddedDocuments
|
||||
{
|
||||
public const string Notice = "NOTICE";
|
||||
|
||||
public const string Trademarks = "legal/TRADEMARKS.md";
|
||||
|
||||
public const string ThirdPartyNotices = "legal/THIRD_PARTY_NOTICES.md";
|
||||
|
||||
public const string PackageIndex = "legal/licenses/nuget/INDEX.md";
|
||||
|
||||
/// <summary>An embedded document's text, authoring comments removed.</summary>
|
||||
/// <exception cref="InvalidOperationException">The build did not embed it.</exception>
|
||||
public static string Read(string path)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
using Stream stream = typeof(EmbeddedDocuments).Assembly.GetManifestResourceStream(path)
|
||||
?? throw new InvalidOperationException($"the build did not embed {path}");
|
||||
using var reader = new StreamReader(stream);
|
||||
return LegalDocuments.StripComments(reader.ReadToEnd());
|
||||
}
|
||||
|
||||
/// <summary>One embedded document as a page.</summary>
|
||||
public static DocumentPage Page(string title, string path, bool plainText = false) => new(title, Read(path), path, plainText);
|
||||
|
||||
/// <summary>About ▸ Legal documents: the three texts the Legal Gate shows, the GPL as written, <c>NOTICE</c>, the trademark note.</summary>
|
||||
public static IReadOnlyList<DocumentPage> Legal() =>
|
||||
[
|
||||
.. LegalDocuments.Load().Select(static d => new DocumentPage(d.Title, d.Text, d.Path, d.IsPlainText)),
|
||||
Page(Strings.About_Doc_Notice, Notice, plainText: true),
|
||||
Page(Strings.About_Doc_Trademarks, Trademarks),
|
||||
];
|
||||
|
||||
/// <summary>About ▸ Third-party licences: the notices and the index of every shipped package with its version and licence.</summary>
|
||||
public static IReadOnlyList<DocumentPage> ThirdParty() =>
|
||||
[
|
||||
Page(Strings.About_Doc_ThirdParty, ThirdPartyNotices),
|
||||
Page(Strings.About_Doc_Packages, PackageIndex),
|
||||
];
|
||||
}
|
||||
@@ -15,9 +15,11 @@ public sealed class FirstRunFlow : IFirstRunFlow
|
||||
private readonly IThemeApplier _theme;
|
||||
private readonly AppearanceSettings _appearance;
|
||||
private readonly ShellHost _shell;
|
||||
private readonly IUrlOpener? _urls;
|
||||
|
||||
public FirstRunFlow(LegalGate gate, IAgentLink agent, IThemeApplier theme, AppearanceSettings appearance, ShellHost shell)
|
||||
public FirstRunFlow(LegalGate gate, IAgentLink agent, IThemeApplier theme, AppearanceSettings appearance, ShellHost shell, IUrlOpener? urls = null)
|
||||
{
|
||||
_urls = urls;
|
||||
_gate = gate ?? throw new ArgumentNullException(nameof(gate));
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_theme = theme ?? throw new ArgumentNullException(nameof(theme));
|
||||
@@ -33,7 +35,7 @@ public sealed class FirstRunFlow : IFirstRunFlow
|
||||
|
||||
private async Task<bool> ShowAsync(bool readOnly)
|
||||
{
|
||||
using var viewModel = new FirstRunViewModel(_gate, _agent, readOnly);
|
||||
using var viewModel = new FirstRunViewModel(_gate, _agent, readOnly, _urls);
|
||||
var window = new FirstRunWindow(viewModel, _theme, _appearance) { Owner = readOnly ? _shell.Current : null };
|
||||
window.Show();
|
||||
Log.Information("ui: first-run window shown {Ms} ms after process start", (long)(DateTime.Now - System.Diagnostics.Process.GetCurrentProcess().StartTime).TotalMilliseconds);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>The Help menu's document windows (beta.12), as a port so the shell's commands are testable without a window.</summary>
|
||||
public interface IDocumentWindows
|
||||
{
|
||||
/// <summary>Help ▸ Limitations: <c>LIMITATIONS.md</c>, rendered.</summary>
|
||||
void ShowLimitations();
|
||||
|
||||
/// <summary>Help ▸ About: the legal notices, the third-party licences and the legal documents.</summary>
|
||||
void ShowAbout();
|
||||
}
|
||||
@@ -3,5 +3,10 @@
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>One of FR-11's documents as this build ships it: its key (the <c>legal_acceptance.doc</c> value), the title shown, the version the acceptance row records, the text, and the GitHub-hosted copy.</summary>
|
||||
public sealed record LegalDocument(string Key, string Title, string Version, string Text, Uri Url);
|
||||
/// <summary>
|
||||
/// One of FR-11's documents as this build ships it: its key (the <c>legal_acceptance.doc</c> value), the title shown, the
|
||||
/// version the acceptance row records, the text, and the GitHub-hosted copy — since beta.12 at this build's own source
|
||||
/// (<see cref="RepositoryLinks"/>), with the document's path in the repository (its relative links resolve against it) and
|
||||
/// whether it is a plain text shown as written rather than Markdown (the GPL's <c>LICENSE</c>).
|
||||
/// </summary>
|
||||
public sealed record LegalDocument(string Key, string Title, string Version, string Text, Uri Url, string Path = "", bool IsPlainText = false);
|
||||
@@ -24,8 +24,6 @@ public static partial class LegalDocuments
|
||||
|
||||
public const string GplVersion = "GPL-3.0-only";
|
||||
|
||||
private const string _repository = "https://github.com/poli0981/frameledger/blob/main/";
|
||||
|
||||
public static IReadOnlyList<string> Keys { get; } = [Eula, Gpl, Disclaimer, Privacy];
|
||||
|
||||
/// <summary>The four documents, in the order the gate shows them.</summary>
|
||||
@@ -61,7 +59,8 @@ public static partial class LegalDocuments
|
||||
string version = versioned
|
||||
? VersionOf(raw) ?? throw new InvalidOperationException($"{path} declares no **Version:** line; FR-11 cannot re-show a document that has no version")
|
||||
: GplVersion;
|
||||
return new LegalDocument(key, title, version, StripComments(raw), new Uri(_repository + path));
|
||||
// The GPL is a plain text — Markdown would turn its numbered sections into lists and its indented lines into code.
|
||||
return new LegalDocument(key, title, version, StripComments(raw), RepositoryLinks.Blob(path), path, IsPlainText: !versioned);
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"\*\*Version:\*\*\s*(?<v>[^\s·]+)", RegexOptions.ExplicitCapture | RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)]
|
||||
|
||||
@@ -19,8 +19,8 @@ public static class LimitationsDocument
|
||||
/// <summary>The embedded resource's name (<c>FrameLedger.App.csproj</c>).</summary>
|
||||
public const string ResourceName = "LIMITATIONS.md";
|
||||
|
||||
/// <summary>The same text in the repository, for the dialog's button.</summary>
|
||||
public static readonly Uri OnGitHub = new(IssueLink.Repository + "/blob/main/LIMITATIONS.md");
|
||||
/// <summary>The same text in the repository at this build's source (beta.12: it was <c>main</c>'s), for the window's button.</summary>
|
||||
public static readonly Uri OnGitHub = RepositoryLinks.Blob(ResourceName);
|
||||
|
||||
/// <summary>The document's text, authoring comments removed.</summary>
|
||||
/// <exception cref="InvalidOperationException">The build did not embed it.</exception>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace FrameLedger.App.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Links into the repository at the source THIS build was made from (beta.12): <c>release.yml</c> passes the release's tag
|
||||
/// (<c>-p:FrameLedgerSourceRef=v0.1.0-beta.12</c>, a rehearsal its commit), which the App csproj stamps as assembly
|
||||
/// metadata; a local build carries none and links to <c>main</c>. Until beta.12 every link said <c>blob/main</c>, so an
|
||||
/// installed release opened documents that had moved on since it was built — a different EULA from the one it showed.
|
||||
/// </summary>
|
||||
public static partial class RepositoryLinks
|
||||
{
|
||||
/// <summary>The metadata key the App csproj writes.</summary>
|
||||
public const string MetadataKey = "FrameLedgerSourceRef";
|
||||
|
||||
/// <summary>The branch a build without a stamped source links to.</summary>
|
||||
public const string DefaultRef = "main";
|
||||
|
||||
/// <summary>The tag or commit this build links to; <see cref="DefaultRef"/> when none was stamped, or when what was stamped is not a plain ref.</summary>
|
||||
public static string SourceRef { get; } = Validate(typeof(RepositoryLinks).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
|
||||
.FirstOrDefault(static a => string.Equals(a.Key, MetadataKey, StringComparison.Ordinal))?.Value);
|
||||
|
||||
/// <summary>A file of the repository on GitHub, at <see cref="SourceRef"/>.</summary>
|
||||
/// <param name="path">From the repository root, forward slashes (<c>docs/19_SAFETY_AND_ANTICHEAT.md</c>).</param>
|
||||
/// <param name="anchor">A heading's anchor, without its <c>#</c>.</param>
|
||||
public static Uri Blob(string path, string? anchor = null) => At("blob", path, anchor);
|
||||
|
||||
/// <summary>A folder of the repository on GitHub, at <see cref="SourceRef"/>.</summary>
|
||||
public static Uri Tree(string path) => At("tree", path, null);
|
||||
|
||||
/// <summary>The stamped value if it is a ref GitHub can take in a URL path (a tag, a branch, a commit), else <see cref="DefaultRef"/>.</summary>
|
||||
internal static string Validate(string? stamped) =>
|
||||
stamped is { Length: > 0 and <= 100 } && PlainRef().IsMatch(stamped) && !stamped.Contains("..", StringComparison.Ordinal) ? stamped : DefaultRef;
|
||||
|
||||
private static Uri At(string kind, string path, string? anchor)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(path);
|
||||
string escaped = string.Join('/', path.Replace('\\', '/').Split('/', StringSplitOptions.RemoveEmptyEntries).Select(Uri.EscapeDataString));
|
||||
string url = IssueLink.Repository + "/" + kind + "/" + SourceRef + (escaped.Length > 0 ? "/" + escaped : string.Empty);
|
||||
return new Uri(anchor is { Length: > 0 } ? url + "#" + Uri.EscapeDataString(anchor) : url);
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^[A-Za-z0-9][A-Za-z0-9._\-]*$", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)]
|
||||
private static partial Regex PlainRef();
|
||||
}
|
||||
Generated
+65
-5
@@ -33,8 +33,27 @@ public static class Strings
|
||||
nameof(A11y_Logs_Level),
|
||||
nameof(A11y_Logs_Source),
|
||||
nameof(A11y_Logs_Tail),
|
||||
nameof(About_Body_Format),
|
||||
nameof(About_Doc_Notice),
|
||||
nameof(About_Doc_Packages),
|
||||
nameof(About_Doc_ThirdParty),
|
||||
nameof(About_Doc_Trademarks),
|
||||
nameof(About_NoLicencesFolder),
|
||||
nameof(About_Notices_Copyright),
|
||||
nameof(About_Notices_Header),
|
||||
nameof(About_Notices_Licence),
|
||||
nameof(About_Notices_Source_Format),
|
||||
nameof(About_Notices_Warranty),
|
||||
nameof(About_OpenLicencesFolder),
|
||||
nameof(About_OpenSource),
|
||||
nameof(About_Tab_App),
|
||||
nameof(About_Tab_Legal),
|
||||
nameof(About_Tab_ThirdParty),
|
||||
nameof(About_Tagline),
|
||||
nameof(About_ThirdParty_Body),
|
||||
nameof(About_Title),
|
||||
nameof(About_Version_Format),
|
||||
nameof(About_ViewLicence),
|
||||
nameof(About_ViewNotice),
|
||||
nameof(AddGame_Added_Format),
|
||||
nameof(AddGame_Dialog_Title),
|
||||
nameof(AddGame_Failed_Format),
|
||||
@@ -220,6 +239,8 @@ public static class Strings
|
||||
nameof(Display_Window_Format),
|
||||
nameof(Display_WindowOnMonitor_Format),
|
||||
nameof(Display_WindowOnMonitorHz_Format),
|
||||
nameof(Document_OnGitHub),
|
||||
nameof(Document_Pages),
|
||||
nameof(EditGame_Detected),
|
||||
nameof(EditGame_Name),
|
||||
nameof(EditGame_Notes),
|
||||
@@ -527,7 +548,6 @@ public static class Strings
|
||||
nameof(Launch_Error_740),
|
||||
nameof(Launch_Error_Format),
|
||||
nameof(Launch_Failed_Format),
|
||||
nameof(Limitations_OnGitHub),
|
||||
nameof(Limitations_Title),
|
||||
nameof(Logs_Bundle_Exported_Format),
|
||||
nameof(Logs_Bundle_Failed_Format),
|
||||
@@ -969,10 +989,48 @@ public static class Strings
|
||||
|
||||
public static string A11y_Logs_Tail => ResourceManager.GetString(nameof(A11y_Logs_Tail), Culture) ?? nameof(A11y_Logs_Tail);
|
||||
|
||||
public static string About_Body_Format => ResourceManager.GetString(nameof(About_Body_Format), Culture) ?? nameof(About_Body_Format);
|
||||
public static string About_Doc_Notice => ResourceManager.GetString(nameof(About_Doc_Notice), Culture) ?? nameof(About_Doc_Notice);
|
||||
|
||||
public static string About_Doc_Packages => ResourceManager.GetString(nameof(About_Doc_Packages), Culture) ?? nameof(About_Doc_Packages);
|
||||
|
||||
public static string About_Doc_ThirdParty => ResourceManager.GetString(nameof(About_Doc_ThirdParty), Culture) ?? nameof(About_Doc_ThirdParty);
|
||||
|
||||
public static string About_Doc_Trademarks => ResourceManager.GetString(nameof(About_Doc_Trademarks), Culture) ?? nameof(About_Doc_Trademarks);
|
||||
|
||||
public static string About_NoLicencesFolder => ResourceManager.GetString(nameof(About_NoLicencesFolder), Culture) ?? nameof(About_NoLicencesFolder);
|
||||
|
||||
public static string About_Notices_Copyright => ResourceManager.GetString(nameof(About_Notices_Copyright), Culture) ?? nameof(About_Notices_Copyright);
|
||||
|
||||
public static string About_Notices_Header => ResourceManager.GetString(nameof(About_Notices_Header), Culture) ?? nameof(About_Notices_Header);
|
||||
|
||||
public static string About_Notices_Licence => ResourceManager.GetString(nameof(About_Notices_Licence), Culture) ?? nameof(About_Notices_Licence);
|
||||
|
||||
public static string About_Notices_Source_Format => ResourceManager.GetString(nameof(About_Notices_Source_Format), Culture) ?? nameof(About_Notices_Source_Format);
|
||||
|
||||
public static string About_Notices_Warranty => ResourceManager.GetString(nameof(About_Notices_Warranty), Culture) ?? nameof(About_Notices_Warranty);
|
||||
|
||||
public static string About_OpenLicencesFolder => ResourceManager.GetString(nameof(About_OpenLicencesFolder), Culture) ?? nameof(About_OpenLicencesFolder);
|
||||
|
||||
public static string About_OpenSource => ResourceManager.GetString(nameof(About_OpenSource), Culture) ?? nameof(About_OpenSource);
|
||||
|
||||
public static string About_Tab_App => ResourceManager.GetString(nameof(About_Tab_App), Culture) ?? nameof(About_Tab_App);
|
||||
|
||||
public static string About_Tab_Legal => ResourceManager.GetString(nameof(About_Tab_Legal), Culture) ?? nameof(About_Tab_Legal);
|
||||
|
||||
public static string About_Tab_ThirdParty => ResourceManager.GetString(nameof(About_Tab_ThirdParty), Culture) ?? nameof(About_Tab_ThirdParty);
|
||||
|
||||
public static string About_Tagline => ResourceManager.GetString(nameof(About_Tagline), Culture) ?? nameof(About_Tagline);
|
||||
|
||||
public static string About_ThirdParty_Body => ResourceManager.GetString(nameof(About_ThirdParty_Body), Culture) ?? nameof(About_ThirdParty_Body);
|
||||
|
||||
public static string About_Title => ResourceManager.GetString(nameof(About_Title), Culture) ?? nameof(About_Title);
|
||||
|
||||
public static string About_Version_Format => ResourceManager.GetString(nameof(About_Version_Format), Culture) ?? nameof(About_Version_Format);
|
||||
|
||||
public static string About_ViewLicence => ResourceManager.GetString(nameof(About_ViewLicence), Culture) ?? nameof(About_ViewLicence);
|
||||
|
||||
public static string About_ViewNotice => ResourceManager.GetString(nameof(About_ViewNotice), Culture) ?? nameof(About_ViewNotice);
|
||||
|
||||
public static string AddGame_Added_Format => ResourceManager.GetString(nameof(AddGame_Added_Format), Culture) ?? nameof(AddGame_Added_Format);
|
||||
|
||||
public static string AddGame_Dialog_Title => ResourceManager.GetString(nameof(AddGame_Dialog_Title), Culture) ?? nameof(AddGame_Dialog_Title);
|
||||
@@ -1343,6 +1401,10 @@ public static class Strings
|
||||
|
||||
public static string Display_WindowOnMonitorHz_Format => ResourceManager.GetString(nameof(Display_WindowOnMonitorHz_Format), Culture) ?? nameof(Display_WindowOnMonitorHz_Format);
|
||||
|
||||
public static string Document_OnGitHub => ResourceManager.GetString(nameof(Document_OnGitHub), Culture) ?? nameof(Document_OnGitHub);
|
||||
|
||||
public static string Document_Pages => ResourceManager.GetString(nameof(Document_Pages), Culture) ?? nameof(Document_Pages);
|
||||
|
||||
public static string EditGame_Detected => ResourceManager.GetString(nameof(EditGame_Detected), Culture) ?? nameof(EditGame_Detected);
|
||||
|
||||
public static string EditGame_Name => ResourceManager.GetString(nameof(EditGame_Name), Culture) ?? nameof(EditGame_Name);
|
||||
@@ -1957,8 +2019,6 @@ public static class Strings
|
||||
|
||||
public static string Launch_Failed_Format => ResourceManager.GetString(nameof(Launch_Failed_Format), Culture) ?? nameof(Launch_Failed_Format);
|
||||
|
||||
public static string Limitations_OnGitHub => ResourceManager.GetString(nameof(Limitations_OnGitHub), Culture) ?? nameof(Limitations_OnGitHub);
|
||||
|
||||
public static string Limitations_Title => ResourceManager.GetString(nameof(Limitations_Title), Culture) ?? nameof(Limitations_Title);
|
||||
|
||||
public static string Logs_Bundle_Exported_Format => ResourceManager.GetString(nameof(Logs_Bundle_Exported_Format), Culture) ?? nameof(Logs_Bundle_Exported_Format);
|
||||
|
||||
@@ -17,10 +17,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — 明示的に有効化したゲーム内でグラフィックス API をフックし、ゲーム性能を計測します。GPLv3。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>FrameLedger について</value>
|
||||
<comment>review</comment>
|
||||
@@ -329,10 +325,6 @@
|
||||
<value>FrameLedger にできないこと</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Limitations_OnGitHub" xml:space="preserve">
|
||||
<value>GitHub で開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>不具合を報告…</value>
|
||||
<comment>review</comment>
|
||||
@@ -3753,4 +3745,92 @@
|
||||
<value>このゲーム: VRAM {0} · RAM {1}</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Document_Pages" xml:space="preserve">
|
||||
<value>ページ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="Document_OnGitHub" xml:space="preserve">
|
||||
<value>GitHub で開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Tab_App" xml:space="preserve">
|
||||
<value>このアプリ</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Tab_ThirdParty" xml:space="preserve">
|
||||
<value>サードパーティのライセンス</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Tab_Legal" xml:space="preserve">
|
||||
<value>法的文書</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Version_Format" xml:space="preserve">
|
||||
<value>バージョン {0}</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Tagline" xml:space="preserve">
|
||||
<value>明示的に有効にしたゲームの内部でグラフィックス API をフックしてパフォーマンスを計測し、各セッションをこの PC に記録します。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Notices_Header" xml:space="preserve">
|
||||
<value>法的通知</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Notices_Copyright" xml:space="preserve">
|
||||
<value>Copyright © 2026 poli0981.</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Notices_Warranty" xml:space="preserve">
|
||||
<value>本プログラムは、適用法で認められる範囲において、一切の保証なしに提供されます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Notices_Licence" xml:space="preserve">
|
||||
<value>本ソフトウェアはフリーソフトウェアです。GNU 一般公衆利用許諾書 バージョン 3 のみ、および同許諾書の第 7 条が認める NOTICE の追加条項に従って、再配布および改変できます。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Notices_Source_Format" xml:space="preserve">
|
||||
<value>このバージョンのソースコード: {0}</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_ViewLicence" xml:space="preserve">
|
||||
<value>ライセンスを表示</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_ViewNotice" xml:space="preserve">
|
||||
<value>NOTICE を表示</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_OpenSource" xml:space="preserve">
|
||||
<value>ソースコードを開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_ThirdParty_Body" xml:space="preserve">
|
||||
<value>FrameLedger は以下のオープンソース コンポーネントの上に構築されています。各ライセンスの全文は、アプリと同じ場所の licenses フォルダーに同梱されています。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_OpenLicencesFolder" xml:space="preserve">
|
||||
<value>ライセンス フォルダーを開く</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_NoLicencesFolder" xml:space="preserve">
|
||||
<value>このビルドの横には licenses フォルダーがありません(開発ビルド)。テキストはリポジトリの legal/licenses/ にあります。</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Doc_Notice" xml:space="preserve">
|
||||
<value>NOTICE(著作権と追加条項)</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Doc_Trademarks" xml:space="preserve">
|
||||
<value>商標</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Doc_ThirdParty" xml:space="preserve">
|
||||
<value>サードパーティ通知</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
<data name="About_Doc_Packages" xml:space="preserve">
|
||||
<value>パッケージのライセンス</value>
|
||||
<comment>review</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -18,9 +18,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — measures game performance by hooking graphics APIs inside games you explicitly enabled. GPLv3.</value>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>About FrameLedger</value>
|
||||
</data>
|
||||
@@ -252,9 +249,6 @@
|
||||
<data name="Limitations_Title" xml:space="preserve">
|
||||
<value>What FrameLedger cannot do</value>
|
||||
</data>
|
||||
<data name="Limitations_OnGitHub" xml:space="preserve">
|
||||
<value>Open on GitHub</value>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>Report a bug…</value>
|
||||
</data>
|
||||
@@ -2825,4 +2819,70 @@ The documents below are the full terms; this summary does not replace them.</val
|
||||
<data name="Dashboard_Live_GameMemory_Format" xml:space="preserve">
|
||||
<value>This game: VRAM {0} · RAM {1}</value>
|
||||
</data>
|
||||
<data name="Document_Pages" xml:space="preserve">
|
||||
<value>Pages</value>
|
||||
</data>
|
||||
<data name="Document_OnGitHub" xml:space="preserve">
|
||||
<value>Open on GitHub</value>
|
||||
</data>
|
||||
<data name="About_Tab_App" xml:space="preserve">
|
||||
<value>This app</value>
|
||||
</data>
|
||||
<data name="About_Tab_ThirdParty" xml:space="preserve">
|
||||
<value>Third-party licences</value>
|
||||
</data>
|
||||
<data name="About_Tab_Legal" xml:space="preserve">
|
||||
<value>Legal documents</value>
|
||||
</data>
|
||||
<data name="About_Version_Format" xml:space="preserve">
|
||||
<value>Version {0}</value>
|
||||
</data>
|
||||
<data name="About_Tagline" xml:space="preserve">
|
||||
<value>Measures game performance by hooking graphics APIs inside the games you explicitly enable, and records each session on this PC.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Header" xml:space="preserve">
|
||||
<value>Legal notices</value>
|
||||
</data>
|
||||
<data name="About_Notices_Copyright" xml:space="preserve">
|
||||
<value>Copyright © 2026 poli0981.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Warranty" xml:space="preserve">
|
||||
<value>This program comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Licence" xml:space="preserve">
|
||||
<value>It is free software: you may redistribute it and modify it under the GNU General Public License, version 3 only, with the additional terms in NOTICE that section 7 of that licence allows.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Source_Format" xml:space="preserve">
|
||||
<value>Source code of this version: {0}</value>
|
||||
</data>
|
||||
<data name="About_ViewLicence" xml:space="preserve">
|
||||
<value>View the licence</value>
|
||||
</data>
|
||||
<data name="About_ViewNotice" xml:space="preserve">
|
||||
<value>View NOTICE</value>
|
||||
</data>
|
||||
<data name="About_OpenSource" xml:space="preserve">
|
||||
<value>Open the source code</value>
|
||||
</data>
|
||||
<data name="About_ThirdParty_Body" xml:space="preserve">
|
||||
<value>FrameLedger is built on these open-source components. The full licence text of each ships beside the App, in its licenses folder.</value>
|
||||
</data>
|
||||
<data name="About_OpenLicencesFolder" xml:space="preserve">
|
||||
<value>Open the licences folder</value>
|
||||
</data>
|
||||
<data name="About_NoLicencesFolder" xml:space="preserve">
|
||||
<value>This build has no licences folder beside it (a development build); the texts are in legal/licenses/ in the repository.</value>
|
||||
</data>
|
||||
<data name="About_Doc_Notice" xml:space="preserve">
|
||||
<value>NOTICE (copyright and additional terms)</value>
|
||||
</data>
|
||||
<data name="About_Doc_Trademarks" xml:space="preserve">
|
||||
<value>Trademarks</value>
|
||||
</data>
|
||||
<data name="About_Doc_ThirdParty" xml:space="preserve">
|
||||
<value>Third-party notices</value>
|
||||
</data>
|
||||
<data name="About_Doc_Packages" xml:space="preserve">
|
||||
<value>Package licences</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -13,9 +13,6 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="About_Body_Format" xml:space="preserve">
|
||||
<value>FrameLedger {0} — đo hiệu năng game bằng cách hook API đồ hoạ bên trong những game bạn đã bật rõ ràng. GPLv3.</value>
|
||||
</data>
|
||||
<data name="About_Title" xml:space="preserve">
|
||||
<value>Giới thiệu FrameLedger</value>
|
||||
</data>
|
||||
@@ -247,9 +244,6 @@
|
||||
<data name="Limitations_Title" xml:space="preserve">
|
||||
<value>Những điều FrameLedger không làm được</value>
|
||||
</data>
|
||||
<data name="Limitations_OnGitHub" xml:space="preserve">
|
||||
<value>Mở trên GitHub</value>
|
||||
</data>
|
||||
<data name="Menu_Help_ReportBug" xml:space="preserve">
|
||||
<value>Báo lỗi…</value>
|
||||
</data>
|
||||
@@ -2820,4 +2814,70 @@ Các tài liệu bên dưới là điều khoản đầy đủ; phần tóm tắ
|
||||
<data name="Dashboard_Live_GameMemory_Format" xml:space="preserve">
|
||||
<value>Game này: VRAM {0} · RAM {1}</value>
|
||||
</data>
|
||||
<data name="Document_Pages" xml:space="preserve">
|
||||
<value>Các trang</value>
|
||||
</data>
|
||||
<data name="Document_OnGitHub" xml:space="preserve">
|
||||
<value>Mở trên GitHub</value>
|
||||
</data>
|
||||
<data name="About_Tab_App" xml:space="preserve">
|
||||
<value>Ứng dụng này</value>
|
||||
</data>
|
||||
<data name="About_Tab_ThirdParty" xml:space="preserve">
|
||||
<value>Giấy phép bên thứ ba</value>
|
||||
</data>
|
||||
<data name="About_Tab_Legal" xml:space="preserve">
|
||||
<value>Văn bản pháp lý</value>
|
||||
</data>
|
||||
<data name="About_Version_Format" xml:space="preserve">
|
||||
<value>Phiên bản {0}</value>
|
||||
</data>
|
||||
<data name="About_Tagline" xml:space="preserve">
|
||||
<value>Đo hiệu năng game bằng cách hook API đồ họa bên trong những game bạn bật rõ ràng, và ghi lại từng phiên chơi trên máy này.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Header" xml:space="preserve">
|
||||
<value>Thông báo pháp lý</value>
|
||||
</data>
|
||||
<data name="About_Notices_Copyright" xml:space="preserve">
|
||||
<value>Bản quyền © 2026 poli0981.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Warranty" xml:space="preserve">
|
||||
<value>Chương trình này được cung cấp HOÀN TOÀN KHÔNG CÓ BẢO HÀNH, trong phạm vi pháp luật cho phép.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Licence" xml:space="preserve">
|
||||
<value>Đây là phần mềm tự do: bạn có thể phân phối lại và sửa đổi nó theo Giấy phép Công cộng GNU, chỉ phiên bản 3, cùng các điều khoản bổ sung trong NOTICE mà mục 7 của giấy phép đó cho phép.</value>
|
||||
</data>
|
||||
<data name="About_Notices_Source_Format" xml:space="preserve">
|
||||
<value>Mã nguồn của phiên bản này: {0}</value>
|
||||
</data>
|
||||
<data name="About_ViewLicence" xml:space="preserve">
|
||||
<value>Xem giấy phép</value>
|
||||
</data>
|
||||
<data name="About_ViewNotice" xml:space="preserve">
|
||||
<value>Xem NOTICE</value>
|
||||
</data>
|
||||
<data name="About_OpenSource" xml:space="preserve">
|
||||
<value>Mở mã nguồn</value>
|
||||
</data>
|
||||
<data name="About_ThirdParty_Body" xml:space="preserve">
|
||||
<value>FrameLedger được xây dựng trên các thành phần mã nguồn mở này. Toàn văn giấy phép của từng thành phần được kèm cạnh ứng dụng, trong thư mục licenses.</value>
|
||||
</data>
|
||||
<data name="About_OpenLicencesFolder" xml:space="preserve">
|
||||
<value>Mở thư mục giấy phép</value>
|
||||
</data>
|
||||
<data name="About_NoLicencesFolder" xml:space="preserve">
|
||||
<value>Bản build này không có thư mục giấy phép bên cạnh (bản build phát triển); các văn bản nằm trong legal/licenses/ của kho mã.</value>
|
||||
</data>
|
||||
<data name="About_Doc_Notice" xml:space="preserve">
|
||||
<value>NOTICE (bản quyền và điều khoản bổ sung)</value>
|
||||
</data>
|
||||
<data name="About_Doc_Trademarks" xml:space="preserve">
|
||||
<value>Nhãn hiệu</value>
|
||||
</data>
|
||||
<data name="About_Doc_ThirdParty" xml:space="preserve">
|
||||
<value>Thông báo bên thứ ba</value>
|
||||
</data>
|
||||
<data name="About_Doc_Packages" xml:space="preserve">
|
||||
<value>Giấy phép các gói</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -30,12 +30,11 @@ public sealed class UpdatePrompts(IUrlOpener urls, BugReportFlow bugReports) : I
|
||||
if (!string.IsNullOrWhiteSpace(candidate.NotesMarkdown))
|
||||
{
|
||||
body.Children.Add(new System.Windows.Controls.TextBlock { Text = Strings.Update_Notes_Header, FontWeight = FontWeights.SemiBold, Margin = new Thickness(0, 12, 0, 4) });
|
||||
body.Children.Add(new ScrollViewer
|
||||
{
|
||||
MaxHeight = 260,
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto,
|
||||
Content = new System.Windows.Controls.TextBlock { Text = candidate.NotesMarkdown, TextWrapping = TextWrapping.Wrap },
|
||||
});
|
||||
// beta.12: the release's notes are the CHANGELOG section, rendered rather than shown as raw Markdown; its relative
|
||||
// links resolve the way they do in the repository, against CHANGELOG.md at the root.
|
||||
var notes = new Controls.MarkdownView { MaxHeight = 260, MinHeight = 80, UrlOpener = urls, DocumentPath = "CHANGELOG.md", MarkdownText = candidate.NotesMarkdown };
|
||||
System.Windows.Automation.AutomationProperties.SetName(notes, Strings.Update_Notes_Header);
|
||||
body.Children.Add(notes);
|
||||
}
|
||||
|
||||
body.Children.Add(new System.Windows.Controls.TextBlock { Text = Strings.Update_Unsigned_Footer, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(0, 12, 0, 0), Opacity = 0.7 });
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Diagnostics;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using FrameLedger.App.Services;
|
||||
@@ -25,6 +24,7 @@ public sealed partial class FirstRunViewModel : ObservableObject, IDisposable
|
||||
|
||||
private readonly LegalGate _gate;
|
||||
private readonly IAgentLink _agent;
|
||||
private readonly IUrlOpener _urls;
|
||||
private readonly UiThread _ui = new();
|
||||
private readonly TaskCompletionSource<bool> _outcome = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
@@ -60,10 +60,11 @@ public sealed partial class FirstRunViewModel : ObservableObject, IDisposable
|
||||
[ObservableProperty]
|
||||
private bool _isBusy;
|
||||
|
||||
public FirstRunViewModel(LegalGate gate, IAgentLink agent, bool readOnly)
|
||||
public FirstRunViewModel(LegalGate gate, IAgentLink agent, bool readOnly, IUrlOpener? urls = null)
|
||||
{
|
||||
_gate = gate ?? throw new ArgumentNullException(nameof(gate));
|
||||
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
|
||||
_urls = urls ?? new ShellUrlOpener();
|
||||
ReadOnly = readOnly;
|
||||
SelectedDocument = gate.Documents.Count > 0 ? gate.Documents[0] : null;
|
||||
_agent.Changed += OnAgentChanged;
|
||||
@@ -75,6 +76,9 @@ public sealed partial class FirstRunViewModel : ObservableObject, IDisposable
|
||||
|
||||
public IReadOnlyList<LegalDocument> Documents => _gate.Documents;
|
||||
|
||||
/// <summary>The opener the rendered documents' links leave the App through (beta.12) — the same one View on GitHub uses.</summary>
|
||||
public IUrlOpener Urls => _urls;
|
||||
|
||||
/// <summary>True when the user accepted (and the rows are written), false when they declined or closed the window.</summary>
|
||||
public Task<bool> Outcome => _outcome.Task;
|
||||
|
||||
@@ -152,21 +156,13 @@ public sealed partial class FirstRunViewModel : ObservableObject, IDisposable
|
||||
[RelayCommand]
|
||||
private void Close() => _outcome.TrySetResult(true);
|
||||
|
||||
/// <summary>The document on GitHub at this build's source, through the App's opener (beta.12: it started a process itself).</summary>
|
||||
[RelayCommand]
|
||||
private void OpenOnline()
|
||||
{
|
||||
if (SelectedDocument is null)
|
||||
if (SelectedDocument is not null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using Process? _ = Process.Start(new ProcessStartInfo(SelectedDocument.Url.ToString()) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) when (ex is System.ComponentModel.Win32Exception or InvalidOperationException)
|
||||
{
|
||||
Serilog.Log.Warning(ex, "first run: could not open the document online");
|
||||
_ = _urls.Open(SelectedDocument.Url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
private readonly IDatabaseMaintenancePrompts _maintenance;
|
||||
private readonly BugReportFlow _bugReports;
|
||||
private readonly IUrlOpener _urls;
|
||||
|
||||
private readonly IDocumentWindows _documents;
|
||||
private readonly SessionSelection _selection;
|
||||
private readonly SessionExportService _exports;
|
||||
private readonly ISessionSummaryOpener _summaries;
|
||||
@@ -61,8 +63,9 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
|
||||
public MainWindowViewModel(AgentConnection agent, ISnackbarService snackbar, IShellPresence shell, IPageNavigator navigator, AddGameFlow addGame, SafetyNotices notices,
|
||||
BugReportFlow bugReports, IUrlOpener urls, SessionSelection selection, SessionExportService exports, ISessionSummaryOpener summaries, ImportLibraryFlow import,
|
||||
UpdateService updates, IDatabaseMaintenancePrompts maintenance)
|
||||
UpdateService updates, IDatabaseMaintenancePrompts maintenance, IDocumentWindows documents)
|
||||
{
|
||||
_documents = documents ?? throw new ArgumentNullException(nameof(documents));
|
||||
_maintenance = maintenance ?? throw new ArgumentNullException(nameof(maintenance));
|
||||
Notices = notices ?? throw new ArgumentNullException(nameof(notices));
|
||||
_updates = updates ?? throw new ArgumentNullException(nameof(updates));
|
||||
@@ -171,18 +174,12 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Help ▸ About (beta.12, D45): the program's legal notices, the third-party licences and the legal documents, rendered
|
||||
/// in a window of tabs (<see cref="Windows.AboutWindow"/>); it was a one-line message box.
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format string is a resource that follows the UI culture, which changes at runtime; a cached CompositeFormat would pin the first culture")]
|
||||
private static async Task AboutAsync()
|
||||
{
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = Strings.About_Title,
|
||||
Content = string.Format(CultureInfo.CurrentCulture, Strings.About_Body_Format, UiIdentity.Version),
|
||||
CloseButtonText = Strings.Common_Ok,
|
||||
};
|
||||
await box.ShowDialogAsync().ConfigureAwait(true);
|
||||
}
|
||||
private void About() => _documents.ShowAbout();
|
||||
|
||||
/// <summary>
|
||||
/// Tools ▸ Update detection rules (P4 PR-1): the Agent re-seeds the rules file and wakes its detection sweep, so every
|
||||
@@ -228,34 +225,12 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Help ▸ Limitations (beta.10, D36): <c>LIMITATIONS.md</c> as this build embeds it, read-only and scrollable, with the
|
||||
/// repository's copy one button away. Information, not terms — nothing is recorded.
|
||||
/// Help ▸ Limitations (beta.10, D36): <c>LIMITATIONS.md</c> as this build embeds it — rendered since beta.12, in a window of
|
||||
/// its own with the repository's copy one button away (it was the raw Markdown in a text box). Information, not terms —
|
||||
/// nothing is recorded.
|
||||
/// </summary>
|
||||
[RelayCommand]
|
||||
private async Task LimitationsAsync()
|
||||
{
|
||||
var text = new System.Windows.Controls.TextBox
|
||||
{
|
||||
Text = LimitationsDocument.Load(),
|
||||
IsReadOnly = true,
|
||||
TextWrapping = System.Windows.TextWrapping.Wrap,
|
||||
VerticalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Auto,
|
||||
MaxHeight = 520,
|
||||
Width = 680,
|
||||
};
|
||||
System.Windows.Automation.AutomationProperties.SetName(text, Strings.Limitations_Title);
|
||||
var box = new MessageBox
|
||||
{
|
||||
Title = Strings.Limitations_Title,
|
||||
Content = text,
|
||||
PrimaryButtonText = Strings.Limitations_OnGitHub,
|
||||
CloseButtonText = Strings.Common_Close,
|
||||
};
|
||||
if (await box.ShowDialogAsync().ConfigureAwait(true) == MessageBoxResult.Primary && !_urls.Open(LimitationsDocument.OnGitHub))
|
||||
{
|
||||
_snackbar.Show(Strings.Limitations_Title, Strings.BugReport_BrowserRefused, ControlAppearance.Caution, new SymbolIcon(SymbolRegular.Warning24), TimeSpan.FromSeconds(4));
|
||||
}
|
||||
}
|
||||
private void Limitations() => _documents.ShowLimitations();
|
||||
|
||||
/// <summary>Help ▸ Report a bug… (P4 PR-3): <c>10_LOGGING</c> §Bug report flow steps 2–4, the same flow the Logs page's button runs.</summary>
|
||||
[RelayCommand]
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace FrameLedger.App.ViewModels;
|
||||
public sealed partial class SettingsViewModel : ObservableObject
|
||||
{
|
||||
/// <summary>The safety document (<c>19_SAFETY_AND_ANTICHEAT.md</c>) at the project's public repository — opened by the user's browser, never fetched.</summary>
|
||||
public const string SafetyDocsUrl = "https://github.com/poli0981/frameledger/blob/main/docs/19_SAFETY_AND_ANTICHEAT.md";
|
||||
/// <summary>The safety document at this build's own source (beta.12: it was <c>main</c>'s, which may describe a newer guard).</summary>
|
||||
public static Uri SafetyDocsUrl { get; } = RepositoryLinks.Blob("docs/19_SAFETY_AND_ANTICHEAT.md");
|
||||
|
||||
private readonly AppearanceSettings _appearance;
|
||||
private readonly IThemeApplier _themes;
|
||||
@@ -479,7 +480,7 @@ public sealed partial class SettingsViewModel : ObservableObject
|
||||
{
|
||||
try
|
||||
{
|
||||
using Process? _ = Process.Start(new ProcessStartInfo(SafetyDocsUrl) { UseShellExecute = true });
|
||||
using Process? _ = Process.Start(new ProcessStartInfo(SafetyDocsUrl.AbsoluteUri) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) when (ex is System.ComponentModel.Win32Exception or InvalidOperationException)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
<!-- Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE -->
|
||||
|
||||
<ui:FluentWindow x:Class="FrameLedger.App.Windows.AboutWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:res="clr-namespace:FrameLedger.App"
|
||||
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
|
||||
Title="{x:Static res:Strings.About_Title}"
|
||||
Width="1000"
|
||||
Height="760"
|
||||
MinWidth="640"
|
||||
MinHeight="440"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowCornerPreference="Round"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<!-- beta.12 (D45): the program's Appropriate Legal Notices (GPLv3 section 0), the third-party licences, the legal
|
||||
documents — tabs of one window, where About was a one-line message box. -->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ui:TitleBar Grid.Row="0" Title="{x:Static res:Strings.About_Title}" ShowMaximize="True" ShowMinimize="True" />
|
||||
<TabControl x:Name="Tabs" Grid.Row="1" Margin="16,8,16,8">
|
||||
<TabItem Header="{x:Static res:Strings.About_Tab_App}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel Margin="0,12,0,0" MaxWidth="760" HorizontalAlignment="Left">
|
||||
<ui:TextBlock FontTypography="Title" Text="{x:Static res:Strings.App_Title}" />
|
||||
<ui:TextBlock x:Name="VersionText" Appearance="Secondary" />
|
||||
<ui:TextBlock Margin="0,8,0,0" TextWrapping="Wrap" Text="{x:Static res:Strings.About_Tagline}" />
|
||||
<ui:TextBlock Margin="0,20,0,6" FontTypography="Subtitle" Text="{x:Static res:Strings.About_Notices_Header}" />
|
||||
<ui:TextBlock TextWrapping="Wrap" Text="{x:Static res:Strings.About_Notices_Copyright}" />
|
||||
<ui:TextBlock Margin="0,6,0,0" TextWrapping="Wrap" Text="{x:Static res:Strings.About_Notices_Warranty}" />
|
||||
<ui:TextBlock Margin="0,6,0,0" TextWrapping="Wrap" Text="{x:Static res:Strings.About_Notices_Licence}" />
|
||||
<ui:TextBlock x:Name="SourceText" Margin="0,6,0,0" TextWrapping="Wrap" />
|
||||
<WrapPanel Margin="0,14,0,0">
|
||||
<ui:Button Margin="0,0,8,8" Click="OnViewLicence" Content="{x:Static res:Strings.About_ViewLicence}" />
|
||||
<ui:Button Margin="0,0,8,8" Click="OnViewNotice" Content="{x:Static res:Strings.About_ViewNotice}" />
|
||||
<ui:Button Margin="0,0,8,8" Click="OnOpenSource" Content="{x:Static res:Strings.About_OpenSource}" Icon="{ui:SymbolIcon Open24}" />
|
||||
</WrapPanel>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
<TabItem Header="{x:Static res:Strings.About_Tab_ThirdParty}">
|
||||
<Grid Margin="0,12,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<DockPanel Grid.Row="0" Margin="0,0,0,8" LastChildFill="True">
|
||||
<ui:Button DockPanel.Dock="Right" Margin="12,0,0,0" Click="OnOpenLicencesFolder" Content="{x:Static res:Strings.About_OpenLicencesFolder}" Icon="{ui:SymbolIcon Folder24}" />
|
||||
<ui:TextBlock VerticalAlignment="Center" TextWrapping="Wrap" Text="{x:Static res:Strings.About_ThirdParty_Body}" />
|
||||
</DockPanel>
|
||||
<ui:TextBlock x:Name="NoLicencesFolder" Grid.Row="1" Margin="0,0,0,8" Appearance="Secondary" TextWrapping="Wrap"
|
||||
Text="{x:Static res:Strings.About_NoLicencesFolder}" Visibility="Collapsed" />
|
||||
<controls:DocumentBrowser x:Name="ThirdParty" Grid.Row="2" />
|
||||
</Grid>
|
||||
</TabItem>
|
||||
<TabItem Header="{x:Static res:Strings.About_Tab_Legal}">
|
||||
<controls:DocumentBrowser x:Name="Legal" Margin="0,12,0,0" />
|
||||
</TabItem>
|
||||
</TabControl>
|
||||
<StackPanel Grid.Row="2" Margin="16,0,16,16" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<ui:Button Appearance="Primary" Click="OnClose" Content="{x:Static res:Strings.Common_Close}" IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:FluentWindow>
|
||||
@@ -0,0 +1,93 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Help ▸ About (beta.12, D45): the program's Appropriate Legal Notices — the copyright line, that there is no warranty,
|
||||
/// the licence with the NOTICE terms and how to read both, where this version's source is — then the third-party licences
|
||||
/// and the legal documents, each rendered from what this build embeds. Until beta.12 About was one line in a message box,
|
||||
/// and <c>THIRD_PARTY_NOTICES</c>' "About → Third-party tab" was an open item.
|
||||
/// </summary>
|
||||
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
|
||||
public partial class AboutWindow : FluentWindow
|
||||
{
|
||||
public const int AppTab = 0;
|
||||
public const int ThirdPartyTab = 1;
|
||||
public const int LegalTab = 2;
|
||||
|
||||
private readonly IUrlOpener _urls;
|
||||
|
||||
public AboutWindow(IUrlOpener urls, IThemeApplier theme, AppearanceSettings appearance)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(theme);
|
||||
ArgumentNullException.ThrowIfNull(appearance);
|
||||
_urls = urls ?? throw new ArgumentNullException(nameof(urls));
|
||||
theme.Apply(appearance.Theme, null);
|
||||
InitializeComponent();
|
||||
VersionText.Text = string.Format(CultureInfo.CurrentCulture, Strings.About_Version_Format, UiIdentity.Version);
|
||||
SourceText.Text = string.Format(CultureInfo.CurrentCulture, Strings.About_Notices_Source_Format, SourceCode.AbsoluteUri);
|
||||
ThirdParty.UrlOpener = urls;
|
||||
ThirdParty.Pages = EmbeddedDocuments.ThirdParty();
|
||||
Legal.UrlOpener = urls;
|
||||
Legal.Pages = EmbeddedDocuments.Legal();
|
||||
}
|
||||
|
||||
/// <summary>This version's source: the repository at the tag (or commit) the build was made from.</summary>
|
||||
public static Uri SourceCode => RepositoryLinks.Tree(string.Empty);
|
||||
|
||||
/// <summary>The licences folder a published App carries beside it (<c>FrameLedger.App.csproj</c>: publish only).</summary>
|
||||
public static string LicencesFolder => Path.Combine(AppContext.BaseDirectory, "licenses");
|
||||
|
||||
/// <summary>The tab control, for the host and the tests.</summary>
|
||||
public System.Windows.Controls.TabControl TabView => Tabs;
|
||||
|
||||
/// <summary>The legal documents tab's pages.</summary>
|
||||
public DocumentBrowser LegalPages => Legal;
|
||||
|
||||
/// <summary>The third-party tab's pages.</summary>
|
||||
public DocumentBrowser ThirdPartyPages => ThirdParty;
|
||||
|
||||
/// <summary>Opens the legal documents tab on <paramref name="path"/> (<c>LICENSE</c>, <c>NOTICE</c>, …).</summary>
|
||||
public void ShowLegal(string path)
|
||||
{
|
||||
Tabs.SelectedIndex = LegalTab;
|
||||
_ = Legal.Show(path);
|
||||
}
|
||||
|
||||
private void OnViewLicence(object sender, RoutedEventArgs e) => ShowLegal("LICENSE");
|
||||
|
||||
private void OnViewNotice(object sender, RoutedEventArgs e) => ShowLegal(EmbeddedDocuments.Notice);
|
||||
|
||||
private void OnOpenSource(object sender, RoutedEventArgs e) => _ = _urls.Open(SourceCode);
|
||||
|
||||
private void OnOpenLicencesFolder(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!Directory.Exists(LicencesFolder))
|
||||
{
|
||||
NoLicencesFolder.Visibility = Visibility.Visible;
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using Process? _ = Process.Start(new ProcessStartInfo("explorer.exe", "\"" + LicencesFolder + "\"") { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex) when (ex is Win32Exception or InvalidOperationException)
|
||||
{
|
||||
Serilog.Log.Warning(ex, "ui: could not open the licences folder");
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClose(object sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<!-- SPDX-License-Identifier: GPL-3.0-only -->
|
||||
<!-- Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE -->
|
||||
|
||||
<ui:FluentWindow x:Class="FrameLedger.App.Windows.DocumentWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
xmlns:res="clr-namespace:FrameLedger.App"
|
||||
xmlns:controls="clr-namespace:FrameLedger.App.Controls"
|
||||
Width="1000"
|
||||
Height="760"
|
||||
MinWidth="640"
|
||||
MinHeight="420"
|
||||
ExtendsContentIntoTitleBar="True"
|
||||
WindowBackdropType="Mica"
|
||||
WindowCornerPreference="Round"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
<!-- beta.12: embedded documents, rendered (Help ▸ Limitations, the user guide). -->
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ui:TitleBar x:Name="TitleBarControl" Grid.Row="0" ShowMaximize="True" ShowMinimize="True" />
|
||||
<controls:DocumentBrowser x:Name="Browser" Grid.Row="1" Margin="16,8,16,8" />
|
||||
<StackPanel Grid.Row="2" Margin="16,0,16,16" HorizontalAlignment="Right" Orientation="Horizontal">
|
||||
<ui:Button Margin="0,0,8,0" Click="OnOpenOnline" Content="{x:Static res:Strings.Document_OnGitHub}" Icon="{ui:SymbolIcon Open24}" />
|
||||
<ui:Button Appearance="Primary" Click="OnClose" Content="{x:Static res:Strings.Common_Close}" IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ui:FluentWindow>
|
||||
@@ -0,0 +1,46 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using FrameLedger.App.Controls;
|
||||
using FrameLedger.App.Services;
|
||||
using Wpf.Ui.Controls;
|
||||
|
||||
namespace FrameLedger.App.Windows;
|
||||
|
||||
/// <summary>
|
||||
/// Embedded documents in a window of their own (beta.12): Help ▸ Limitations — until now a message box holding the raw
|
||||
/// Markdown in a text box — and the user guide. The theme is applied before the XAML like every secondary window's.
|
||||
/// </summary>
|
||||
public partial class DocumentWindow : FluentWindow
|
||||
{
|
||||
private readonly IUrlOpener _urls;
|
||||
|
||||
public DocumentWindow(string title, IReadOnlyList<DocumentPage> pages, IUrlOpener urls, IThemeApplier theme, AppearanceSettings appearance)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(title);
|
||||
ArgumentNullException.ThrowIfNull(pages);
|
||||
ArgumentNullException.ThrowIfNull(theme);
|
||||
ArgumentNullException.ThrowIfNull(appearance);
|
||||
_urls = urls ?? throw new ArgumentNullException(nameof(urls));
|
||||
theme.Apply(appearance.Theme, null);
|
||||
InitializeComponent();
|
||||
Title = title;
|
||||
TitleBarControl.Title = title;
|
||||
Browser.UrlOpener = urls;
|
||||
Browser.Pages = pages;
|
||||
}
|
||||
|
||||
/// <summary>The pages and the one shown, for the host and the tests.</summary>
|
||||
public DocumentBrowser Pages => Browser;
|
||||
|
||||
private void OnOpenOnline(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Browser.SelectedPage is { } page)
|
||||
{
|
||||
_ = _urls.Open(page.Url);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClose(object sender, RoutedEventArgs e) => Close();
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Windows;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Services;
|
||||
using FrameLedger.App.Windows;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Help ▸ About and Help ▸ Limitations as windows of rendered documents (beta.12): About carries the program's legal
|
||||
/// notices and opens the licence and NOTICE on its legal tab; its two document tabs hold every page they name; a page's
|
||||
/// link to another page it holds opens that page rather than GitHub; Limitations is one page, with no page list.
|
||||
/// </summary>
|
||||
public sealed class DocumentWindowsTests
|
||||
{
|
||||
private sealed class NoTheme : IThemeApplier
|
||||
{
|
||||
public void Apply(AppTheme theme, Window? window)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AboutShowsTheLegalNoticesAndOpensTheLicenceAndNoticeOnItsLegalTab()
|
||||
{
|
||||
var urls = new NoUrlOpener();
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var about = new AboutWindow(urls, new NoTheme(), new AppearanceSettings(new MemorySettings()));
|
||||
try
|
||||
{
|
||||
string[] legal = [.. about.LegalPages.Pages.Select(static p => p.Path)];
|
||||
string[] thirdParty = [.. about.ThirdPartyPages.Pages.Select(static p => p.Path)];
|
||||
about.ShowLegal("NOTICE");
|
||||
(int Tab, string? Page, bool Plain) notice = (about.TabView.SelectedIndex, about.LegalPages.SelectedPage?.Path, about.LegalPages.SelectedPage?.IsPlainText ?? false);
|
||||
about.ShowLegal("LICENSE");
|
||||
string? licence = about.LegalPages.SelectedPage?.Path;
|
||||
bool linked = about.ThirdPartyPages.Show(EmbeddedDocuments.PackageIndex);
|
||||
return new { legal, thirdParty, notice, licence, linked, Index = about.ThirdPartyPages.SelectedPage?.Path };
|
||||
}
|
||||
finally
|
||||
{
|
||||
about.Close();
|
||||
}
|
||||
});
|
||||
|
||||
facts.legal.Should().Equal("legal/EULA.md", "LICENSE", "legal/DISCLAIMER.md", "legal/PRIVACY_POLICY.md", "NOTICE", "legal/TRADEMARKS.md");
|
||||
facts.thirdParty.Should().Equal(EmbeddedDocuments.ThirdPartyNotices, EmbeddedDocuments.PackageIndex);
|
||||
facts.notice.Should().Be((AboutWindow.LegalTab, "NOTICE", true), "NOTICE is shown as written");
|
||||
facts.licence.Should().Be("LICENSE");
|
||||
facts.linked.Should().BeTrue();
|
||||
facts.Index.Should().Be(EmbeddedDocuments.PackageIndex);
|
||||
urls.Opened.Should().BeEmpty("nothing left the App");
|
||||
AboutWindow.SourceCode.Should().Be(new Uri("https://github.com/poli0981/frameledger/tree/main"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task LimitationsIsOnePageWithNoListAndOpensOnGitHubAtThisBuildsSource()
|
||||
{
|
||||
var urls = new NoUrlOpener();
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var page = new DocumentPage(Strings.Limitations_Title, LimitationsDocument.Load(), LimitationsDocument.ResourceName);
|
||||
var window = new DocumentWindow(Strings.Limitations_Title, [page], urls, new NoTheme(), new AppearanceSettings(new MemorySettings()));
|
||||
try
|
||||
{
|
||||
return new
|
||||
{
|
||||
window.Title,
|
||||
Pages = window.Pages.Pages.Count,
|
||||
Selected = window.Pages.SelectedPage?.Path,
|
||||
ListShown = window.Pages.FindName("PageList") is UIElement { Visibility: Visibility.Visible },
|
||||
Anchors = window.Pages.Viewer.Anchors.Count,
|
||||
};
|
||||
}
|
||||
finally
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
});
|
||||
|
||||
facts.Title.Should().Be(Strings.Limitations_Title);
|
||||
facts.Pages.Should().Be(1);
|
||||
facts.Selected.Should().Be("LIMITATIONS.md");
|
||||
facts.ListShown.Should().BeFalse("one page needs no list");
|
||||
facts.Anchors.Should().BeGreaterThan(3, "every section of LIMITATIONS is a heading a link can scroll to");
|
||||
LimitationsDocument.OnGitHub.Should().Be(new Uri("https://github.com/poli0981/frameledger/blob/main/LIMITATIONS.md"));
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,21 @@ public sealed class FirstRunViewModelTests
|
||||
vm.IsLegalStep.Should().BeTrue();
|
||||
}
|
||||
|
||||
/// <summary>beta.12: View on GitHub goes through the App's opener (it started a process itself), at the document's own URL.</summary>
|
||||
[Fact]
|
||||
public async Task ViewOnGitHubOpensTheSelectedDocumentThroughTheAppsOpener()
|
||||
{
|
||||
await using ScratchLedger s = await ScratchLedger.OpenAsync();
|
||||
var urls = new NoUrlOpener();
|
||||
using var vm = new FirstRunViewModel(new LegalGate(new SqliteLegalAcceptanceStore(s.Db), Docs), new FakeAgentLink(), readOnly: true, urls);
|
||||
|
||||
vm.SelectedDocument = vm.Documents[2];
|
||||
vm.OpenOnlineCommand.Execute(null);
|
||||
|
||||
urls.Opened.Should().Equal(new Uri("https://github.com/x/d"));
|
||||
vm.Urls.Should().BeSameAs(urls, "the rendered documents' links leave through the same opener");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TheAgentStepShowsTheHelloAcksFactsAndNAWithoutOne()
|
||||
{
|
||||
|
||||
@@ -20,6 +20,12 @@ public sealed class LegalDocumentsTests
|
||||
docs.Single(static d => string.Equals(d.Key, LegalDocuments.Gpl, StringComparison.Ordinal)).Version.Should().Be(LegalDocuments.GplVersion);
|
||||
docs.Single(static d => string.Equals(d.Key, LegalDocuments.Eula, StringComparison.Ordinal)).Version.Should().MatchRegex(@"^\d+\.\d+");
|
||||
docs.Should().OnlyContain(static d => d.Url.Host == "github.com");
|
||||
|
||||
// beta.12: at this build's source (main for a test build), with the path the document's relative links resolve against;
|
||||
// the GPL is a plain text shown as written.
|
||||
docs.Select(static d => d.Path).Should().Equal("legal/EULA.md", "LICENSE", "legal/DISCLAIMER.md", "legal/PRIVACY_POLICY.md");
|
||||
docs.Select(static d => d.Url.AbsoluteUri).Should().OnlyContain(static u => u.StartsWith("https://github.com/poli0981/frameledger/blob/main/", StringComparison.Ordinal));
|
||||
docs.Where(static d => d.IsPlainText).Select(static d => d.Key).Should().Equal(LegalDocuments.Gpl);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Markdown;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Where a link in a shown document leads (beta.12): the browser only for http, https and mailto; a relative path resolved
|
||||
/// the way GitHub resolves it and never out of the repository; every other scheme refused — a document must not be able to
|
||||
/// open a local file or start a program. And the repository links of a build that carries no stamped source go to main.
|
||||
/// </summary>
|
||||
public sealed class MarkdownLinksTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("https://github.com/poli0981/frameledger", "https://github.com/poli0981/frameledger")]
|
||||
[InlineData("http://example.invalid/a", "http://example.invalid/a")]
|
||||
[InlineData("mailto:contact@poli0981.dev", "mailto:contact@poli0981.dev")]
|
||||
public void TheBrowserTakesHttpHttpsAndMailto(string href, string expected) =>
|
||||
MarkdownLinks.Resolve("legal/EULA.md", href).External.Should().Be(new Uri(expected));
|
||||
|
||||
[Theory]
|
||||
[InlineData("javascript:alert(1)")]
|
||||
[InlineData("file:///C:/Windows/System32/calc.exe")]
|
||||
[InlineData(@"C:\Windows\notepad.exe")]
|
||||
[InlineData(@"\\server\share\x.md")]
|
||||
[InlineData("//evil.invalid/x")]
|
||||
[InlineData("vbscript:msgbox")]
|
||||
[InlineData("ms-settings:privacy")]
|
||||
[InlineData("../../outside.md")]
|
||||
[InlineData("")]
|
||||
[InlineData("#")]
|
||||
public void EverythingElseIsRefused(string href) => MarkdownLinks.Resolve("legal/EULA.md", href).IsRefused.Should().BeTrue();
|
||||
|
||||
[Theory]
|
||||
[InlineData("legal/EULA.md", "PRIVACY_POLICY.md", "legal/PRIVACY_POLICY.md", null)]
|
||||
[InlineData("legal/EULA.md", "../LICENSE", "LICENSE", null)]
|
||||
[InlineData("legal/EULA.md", "./DISCLAIMER.md#3-no-warranty", "legal/DISCLAIMER.md", "3-no-warranty")]
|
||||
[InlineData("README.md", "docs/03_METRICS.md#The-Games-Memory", "docs/03_METRICS.md", "the-games-memory")]
|
||||
[InlineData("guide/01-install.md", "/LIMITATIONS.md", "LIMITATIONS.md", null)]
|
||||
[InlineData("LIMITATIONS.md", "docs/a%20b.md?plain=1", "docs/a b.md", null)]
|
||||
[InlineData(null, "legal/TRADEMARKS.md", "legal/TRADEMARKS.md", null)]
|
||||
public void ARelativePathResolvesAgainstTheDocumentsFolder(string? document, string href, string path, string? anchor)
|
||||
{
|
||||
MarkdownLinkTarget target = MarkdownLinks.Resolve(document, href);
|
||||
|
||||
target.RepositoryPath.Should().Be(path);
|
||||
target.Anchor.Should().Be(anchor);
|
||||
target.External.Should().BeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnAnchorAloneStaysInTheDocument()
|
||||
{
|
||||
MarkdownLinkTarget target = MarkdownLinks.Resolve("LIMITATIONS.md", "#The-Games-Memory");
|
||||
|
||||
target.Anchor.Should().Be("the-games-memory");
|
||||
target.RepositoryPath.Should().BeNull();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("The game's memory", "the-games-memory")]
|
||||
[InlineData("1. What it observes (Tier 1)", "1-what-it-observes-tier-1")]
|
||||
[InlineData(" FPS & frame generation ", "fps--frame-generation")]
|
||||
[InlineData("snake_case-and-dash", "snake_case-and-dash")]
|
||||
public void HeadingsAreSluggedTheWayGitHubSlugsThem(string heading, string slug) => MarkdownLinks.Slug(heading).Should().Be(slug);
|
||||
|
||||
[Fact]
|
||||
public void ABuildWithNoStampedSourceLinksToMainAndEscapesThePath()
|
||||
{
|
||||
RepositoryLinks.SourceRef.Should().Be("main", "a test build carries no FrameLedgerSourceRef");
|
||||
RepositoryLinks.Blob("docs/a b.md", "x y").Should().Be(new Uri("https://github.com/poli0981/frameledger/blob/main/docs/a%20b.md#x%20y"));
|
||||
RepositoryLinks.Tree(string.Empty).Should().Be(new Uri("https://github.com/poli0981/frameledger/tree/main"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("v0.1.0-beta.12", "v0.1.0-beta.12")]
|
||||
[InlineData("2ce825109f6a7b3c1d2e4f5a6b7c8d9e0f1a2b3c", "2ce825109f6a7b3c1d2e4f5a6b7c8d9e0f1a2b3c")]
|
||||
[InlineData(null, "main")]
|
||||
[InlineData("", "main")]
|
||||
[InlineData("../evil", "main")]
|
||||
[InlineData("v1..2", "main")]
|
||||
[InlineData("a/b", "main")]
|
||||
[InlineData("tag?x=1", "main")]
|
||||
[InlineData("-option", "main")]
|
||||
public void OnlyAPlainRefIsTakenFromTheBuild(string? stamped, string used) => RepositoryLinks.Validate(stamped).Should().Be(used);
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using FluentAssertions;
|
||||
using FrameLedger.App.Markdown;
|
||||
using FrameLedger.App.Services;
|
||||
|
||||
namespace FrameLedger.App.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// The documents the App shows, rendered (beta.12, owner request 4): what each Markdown construct becomes, that HTML is
|
||||
/// text and images are never fetched, that a link the App will not follow keeps its address in view — and that NOTHING
|
||||
/// any embedded document says is lost on the way: every word of its plain text is in the rendered document.
|
||||
/// </summary>
|
||||
public sealed partial class MarkdownRendererTests
|
||||
{
|
||||
private const string _sample = """
|
||||
# Title
|
||||
|
||||
Some **bold**, *italic*, ~~struck~~ and `code` text with a [link](docs/03_METRICS.md#the-games-memory).
|
||||
|
||||
## The game's memory
|
||||
|
||||
- one
|
||||
- two
|
||||
|
||||
3. third
|
||||
4. fourth
|
||||
|
||||
> quoted
|
||||
|
||||
| Name | Value |
|
||||
|:-----|------:|
|
||||
| a | 1 |
|
||||
|
||||
```
|
||||
line one
|
||||
line two
|
||||
```
|
||||
|
||||
- [x] done
|
||||
- [ ] open
|
||||
|
||||
<b>not bold</b> and  and [run](javascript:alert(1)).
|
||||
|
||||
---
|
||||
""";
|
||||
|
||||
private static IEnumerable<T> All<T>(FlowDocument document)
|
||||
where T : DependencyObject => Descend(document).OfType<T>();
|
||||
|
||||
private static IEnumerable<DependencyObject> Descend(DependencyObject node) =>
|
||||
new[] { node }.Concat(LogicalTreeHelper.GetChildren(node).OfType<DependencyObject>().SelectMany(Descend));
|
||||
|
||||
private static string TextOf(FlowDocument document) => new TextRange(document.ContentStart, document.ContentEnd).Text;
|
||||
|
||||
[Fact]
|
||||
public async Task EachConstructBecomesItsFlowElement()
|
||||
{
|
||||
var facts = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
RenderedMarkdown r = MarkdownRenderer.Render(_sample, "README.md");
|
||||
FlowDocument d = r.Document;
|
||||
Paragraph[] paragraphs = [.. All<Paragraph>(d)];
|
||||
Paragraph title = paragraphs.First(p => TextOfInlines(p).StartsWith("Title", StringComparison.Ordinal));
|
||||
List[] lists = [.. All<List>(d)];
|
||||
Table table = All<Table>(d).Single();
|
||||
Hyperlink[] links = [.. All<Hyperlink>(d)];
|
||||
return new
|
||||
{
|
||||
TitleSize = title.FontSize,
|
||||
Anchors = r.Anchors.Keys.ToArray(),
|
||||
Lists = lists.Select(static l => (l.MarkerStyle, l.ListItems.Count, l.StartIndex)).ToArray(),
|
||||
TableRows = table.RowGroups[0].Rows.Count,
|
||||
HeaderWeight = table.RowGroups[0].Rows[0].FontWeight,
|
||||
Quote = All<Section>(d).Any(),
|
||||
Struck = All<Span>(d).Any(static s => s.TextDecorations == TextDecorations.Strikethrough),
|
||||
Links = links.Select(static l => l.NavigateUri?.OriginalString).ToArray(),
|
||||
Text = TextOf(d),
|
||||
Code = paragraphs.Any(static p => p.FontFamily.Source.Contains("Consolas", StringComparison.Ordinal) && TextOfInlines(p).Contains("line one", StringComparison.Ordinal)),
|
||||
Images = Descend(d).OfType<System.Windows.Controls.Image>().Count(),
|
||||
};
|
||||
});
|
||||
|
||||
facts.TitleSize.Should().BeGreaterThan(MarkdownRenderer.BodySize);
|
||||
facts.Anchors.Should().Equal("title", "the-games-memory");
|
||||
facts.Lists.Should().HaveCount(3);
|
||||
facts.Lists[0].Should().Be((TextMarkerStyle.Disc, 2, 1));
|
||||
facts.Lists[1].Should().Be((TextMarkerStyle.Decimal, 2, 3), "an ordered list keeps the number it starts at");
|
||||
facts.TableRows.Should().Be(2);
|
||||
facts.HeaderWeight.Should().Be(FontWeights.SemiBold);
|
||||
facts.Quote.Should().BeTrue();
|
||||
facts.Struck.Should().BeTrue();
|
||||
facts.Code.Should().BeTrue("a fenced block is monospace and keeps its lines");
|
||||
facts.Text.Should().Contain(" line two", "a code block keeps its indentation");
|
||||
facts.Links.Should().Equal(["docs/03_METRICS.md#the-games-memory"], "the image is not a link and javascript: is not followed");
|
||||
facts.Text.Should().Contain("<b>not bold</b>", "HTML is shown as the text it is, never interpreted");
|
||||
facts.Text.Should().Contain("[a chart]", "an image's description stands in for it");
|
||||
facts.Images.Should().Be(0, "no image is fetched");
|
||||
facts.Text.Should().Contain("run (javascript:alert(1))", "a link the App will not follow keeps its address in view");
|
||||
facts.Text.Should().Contain("☑ done").And.Contain("☐ open");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task APlainTextKeepsEveryLineAsWritten()
|
||||
{
|
||||
string text = await PagesLoadTests.OnStaAsync(() => TextOf(MarkdownRenderer.RenderPlainText(" 0. Definitions.\r\n\r\n # not a heading\r\n").Document));
|
||||
|
||||
text.Should().Contain(" 0. Definitions.").And.Contain(" # not a heading", "the GPL is not Markdown: its numbered sections are not a list");
|
||||
}
|
||||
|
||||
/// <summary>Every embedded document — the Legal Gate's four, LIMITATIONS, NOTICE, the trademark note, the third-party notices and the package index: nine.</summary>
|
||||
[Fact]
|
||||
public async Task NothingAnyEmbeddedDocumentSaysIsDropped()
|
||||
{
|
||||
IReadOnlyList<(string Path, string Text, bool Plain)> documents =
|
||||
[
|
||||
.. LegalDocuments.Load().Select(static d => (d.Path, d.Text, d.IsPlainText)),
|
||||
("LIMITATIONS.md", LimitationsDocument.Load(), false),
|
||||
(EmbeddedDocuments.Notice, EmbeddedDocuments.Read(EmbeddedDocuments.Notice), true),
|
||||
(EmbeddedDocuments.Trademarks, EmbeddedDocuments.Read(EmbeddedDocuments.Trademarks), false),
|
||||
(EmbeddedDocuments.ThirdPartyNotices, EmbeddedDocuments.Read(EmbeddedDocuments.ThirdPartyNotices), false),
|
||||
(EmbeddedDocuments.PackageIndex, EmbeddedDocuments.Read(EmbeddedDocuments.PackageIndex), false),
|
||||
];
|
||||
|
||||
List<string> missing = await PagesLoadTests.OnStaAsync(() =>
|
||||
{
|
||||
var problems = new List<string>();
|
||||
foreach ((string path, string text, bool plain) in documents)
|
||||
{
|
||||
string rendered = TextOf((plain ? MarkdownRenderer.RenderPlainText(text) : MarkdownRenderer.Render(text, path)).Document);
|
||||
// Markdig's plain text writes a task's box as "[x]"; the renderer draws it as ☑, which is the same fact.
|
||||
string expected = plain ? text : TaskBox().Replace(Markdig.Markdown.ToPlainText(text, MarkdownRenderer.Pipeline), " ");
|
||||
// A table Markdig did not take as a table shows its delimiter row as text ("|---|---|") — every word kept, the
|
||||
// table lost. GitHub renders such a table; the App must too.
|
||||
if (!plain && TableSource().IsMatch(rendered))
|
||||
{
|
||||
problems.Add($"{path}: a table is shown as its Markdown source: '{TableSource().Match(rendered).Value}'");
|
||||
}
|
||||
|
||||
Dictionary<string, int> have = Count(rendered);
|
||||
foreach ((string word, int count) in Count(expected))
|
||||
{
|
||||
if (have.GetValueOrDefault(word) < count)
|
||||
{
|
||||
problems.Add($"{path}: '{word}' {count}× in the text, {have.GetValueOrDefault(word)}× rendered");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return problems;
|
||||
});
|
||||
|
||||
documents.Should().HaveCount(9);
|
||||
missing.Should().BeEmpty("the renderer must never shorten a document a user reads or accepts");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ARepeatedHeadingGetsGitHubsNumberedAnchor()
|
||||
{
|
||||
string[] anchors = await PagesLoadTests.OnStaAsync(() => MarkdownRenderer.Render("## Notes\n\ntext\n\n## Notes\n").Anchors.Keys.ToArray());
|
||||
|
||||
anchors.Should().Equal("notes", "notes-1");
|
||||
}
|
||||
|
||||
private static string TextOfInlines(Paragraph p) => string.Concat(p.Inlines.Select(MarkdownRenderer.TextOf));
|
||||
|
||||
private static Dictionary<string, int> Count(string text)
|
||||
{
|
||||
var counts = new Dictionary<string, int>(StringComparer.Ordinal);
|
||||
foreach (Match m in Word().Matches(text))
|
||||
{
|
||||
counts[m.Value] = counts.GetValueOrDefault(m.Value) + 1;
|
||||
}
|
||||
|
||||
return counts;
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"[\p{L}\p{N}]+", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)]
|
||||
private static partial Regex Word();
|
||||
|
||||
[GeneratedRegex(@"\[[xX ]\]", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)]
|
||||
private static partial Regex TaskBox();
|
||||
|
||||
[GeneratedRegex(@"\|\s*:?-{3,}:?\s*\|", RegexOptions.CultureInvariant, matchTimeoutMilliseconds: 1000)]
|
||||
private static partial Regex TableSource();
|
||||
}
|
||||
@@ -25,7 +25,9 @@
|
||||
declares an expression, a LICENSE / COPYING file at its root or under Notices/. Verbatim.
|
||||
2. A reviewed override, tools/license-overrides/<id>.txt, for a package that declares only a
|
||||
<licenseUrl>: the text behind that URL, fetched once by a person, with its provenance at the top.
|
||||
A URL-only package with no override is RED -- this script never fetches anything.
|
||||
A URL-only package with no override is RED -- this script never fetches anything. Since beta.12
|
||||
an override also answers for an expression this script has no text for (Markdig: BSD-2-Clause,
|
||||
no file in the package): the project's own licence file, fetched once by a person.
|
||||
3. An SPDX expression with no file: MIT's standard text under the package's own <copyright> field
|
||||
("not stated" when the package states none -- this script never writes a copyright line), or,
|
||||
for Apache-2.0 and MPL-2.0, the statement that the full text is the shared copy beside it
|
||||
@@ -286,7 +288,14 @@ function Build-PackageText($Package, [string]$Roots, [string]$Overrides) {
|
||||
$(if ($p.Copyright) { $p.Copyright } else { "not stated by the package (authors: $($p.Authors))" })
|
||||
}
|
||||
default {
|
||||
throw "$($p.Id) $($p.Version) declares '$($p.Licence)' and ships no licence file; this script has no text for that expression -- add tools/license-overrides/$($p.Id).txt"
|
||||
# An expression with no standard text here (BSD-2-Clause names its holder inside the text, so a
|
||||
# template would be a guess): a reviewed copy of the project's own licence file, or RED.
|
||||
$override = Join-Path $Overrides "$($p.Id).txt"
|
||||
if (-not (Test-Path $override)) {
|
||||
throw "$($p.Id) $($p.Version) declares '$($p.Licence)' and ships no licence file; this script has no text for that expression -- add tools/license-overrides/$($p.Id).txt"
|
||||
}
|
||||
$source = "tools/license-overrides/$($p.Id).txt, a reviewed copy of the project's own licence file; the package ships none"
|
||||
$body = Read-Text $override
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -447,12 +456,13 @@ function Invoke-SelfTest {
|
||||
New-FakePackage 'Fake.Url' '1.0.0' '<licenseUrl>https://example.invalid/licence</licenseUrl>'
|
||||
New-FakePackage 'Fake.MplB' '1.0.0' '<license type="expression">MPL-2.0</license>' @{ 'readme.txt' = 'This Source Code Form is "Incompatible With Secondary Licenses", as defined by the MPL v2.0.' }
|
||||
New-FakePackage 'Fake.Upper' '1.0.0' '<license type="expression">MIT</license>' @{ 'LICENSE.TXT' = 'UPPER-CASE LICENCE FILE' }
|
||||
New-FakePackage 'Fake.Bsd' '1.0.0' '<license type="expression">BSD-2-Clause</license>' @{} 'Fake Bsd Author'
|
||||
New-FakePackage 'Fake.MplText' '1.0.0' '<license type="expression">MPL-2.0</license>' @{ 'LICENSE.txt' = "Mozilla Public License Version 2.0`n...`nExhibit A - Source Code Form License Notice`n...`nExhibit B - `"Incompatible With Secondary Licenses`" Notice`n This Source Code Form is `"Incompatible With Secondary Licenses`", as defined by the Mozilla Public License, v. 2.0." }
|
||||
|
||||
function New-Assets([string]$Project, [string[]]$Ids) {
|
||||
$dir = Join-Path (Join-Path $base "src/$Project") 'obj'
|
||||
New-Item -ItemType Directory -Force $dir | Out-Null
|
||||
$versions = @{ 'Fake.Mit' = '1.0.0'; 'Fake.MitNoHolder' = '1.0.0'; 'Fake.File' = '2.0.0'; 'Fake.Apache' = '3.0.0'; 'Fake.Analyzer' = '1.0.0'; 'Fake.Placeholder' = '1.0.0'; 'Fake.Url' = '1.0.0'; 'Fake.MplB' = '1.0.0'; 'Fake.MplText' = '1.0.0'; 'Fake.Upper' = '1.0.0' }
|
||||
$versions = @{ 'Fake.Mit' = '1.0.0'; 'Fake.MitNoHolder' = '1.0.0'; 'Fake.File' = '2.0.0'; 'Fake.Apache' = '3.0.0'; 'Fake.Analyzer' = '1.0.0'; 'Fake.Placeholder' = '1.0.0'; 'Fake.Url' = '1.0.0'; 'Fake.MplB' = '1.0.0'; 'Fake.MplText' = '1.0.0'; 'Fake.Upper' = '1.0.0'; 'Fake.Bsd' = '1.0.0' }
|
||||
$target = [ordered]@{}
|
||||
foreach ($id in $Ids) {
|
||||
$runtime = if ($id -eq 'Fake.Placeholder') { @{ 'lib/net10.0/_._' = @{} } } else { @{ "lib/net10.0/$id.dll" = @{} } }
|
||||
@@ -548,6 +558,18 @@ function Invoke-SelfTest {
|
||||
$r = Invoke-Gather $assets $packages $overrides (Join-Path $base 'out-url') $false
|
||||
$r.Problems.Count -eq 0 -and (Get-Content (Join-Path $base 'out-url/Fake.Url.txt') -Raw) -match 'REVIEWED URL TEXT'
|
||||
}
|
||||
& $case 'an expression with no text here and no reviewed override is RED' {
|
||||
$assets = @(New-Assets 'FrameLedger.App' @('Fake.Bsd'))
|
||||
$r = Invoke-Gather $assets $packages $overrides (Join-Path $base 'out-bsd') $false
|
||||
@($r.Problems | Where-Object { $_ -like "*Fake.Bsd*BSD-2-Clause*license-overrides*" }).Count -eq 1
|
||||
}
|
||||
& $case 'the same expression with a reviewed override is green and names the override' {
|
||||
Set-Content (Join-Path $overrides 'Fake.Bsd.txt') 'REVIEWED BSD TEXT'
|
||||
$assets = @(New-Assets 'FrameLedger.App' @('Fake.Bsd'))
|
||||
$r = Invoke-Gather $assets $packages $overrides (Join-Path $base 'out-bsd') $false
|
||||
$t = Get-Content (Join-Path $base 'out-bsd/Fake.Bsd.txt') -Raw
|
||||
$r.Problems.Count -eq 0 -and $t -match 'REVIEWED BSD TEXT' -and $t -match 'Licence declared: BSD-2-Clause' -and $t -match "project's own licence file"
|
||||
}
|
||||
& $case 'an MPL-2.0 package carrying Exhibit B is RED' {
|
||||
$assets = @(New-Assets 'FrameLedger.App' @('Fake.MplB'))
|
||||
$r = Invoke-Gather $assets $packages $overrides (Join-Path $base 'out-mpl') $false
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
Reviewed override for Markdig 1.4.0 (tools/license-gather.ps1).
|
||||
|
||||
The package declares <license type="expression">BSD-2-Clause</license> and ships no licence file. The text
|
||||
below is the project's own license.txt at the commit the package names (<repository commit=
|
||||
"56e9c238584a44a169f174c881855c049768634c">), fetched on 2026-10-03 from
|
||||
https://raw.githubusercontent.com/xoofx/markdig/56e9c238584a44a169f174c881855c049768634c/license.txt,
|
||||
verbatim. The package's <copyright> field is "Alexandre Mutel"; the file names the same holder.
|
||||
|
||||
Used by the App since beta.12 to render the documents it shows (the Legal Gate, Help, About, the user guide);
|
||||
consumed unmodified.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2016-2026, Alexandre Mutel
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification
|
||||
, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. 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 SOFTWARE 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Reference in new issue
Block a user