Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/egui-ui/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ D32): read a screen's component and its SCSS before changing it, and its capture
forever. Work the core goes on with after an answer is started through `Backend::background`,
so that it is waited for too. No `run_steps(n)`, no `with_max_steps`: a bench with a spinner
runs with reduced motion.
- **The whole window**: `Harness::new_eframe` / `build_eframe` over `DevNotesApp`, through the gate
- **The whole window**: `Harness::new_eframe` / `build_eframe` over `App`, through the gate
like a person (`app.rs` tests).
- **Captures, not snapshots** (D24): `app::captures` renders the window's states in both themes into
`DEVNOTES_CAPTURES` for a look by eye beside the reference's captures; CI uploads them. Nothing
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Principles:
- **Folders** nest inside one space, every rule in `folders::model::Lineage`; deleting hands notes and sub-folders to the parent; board geometry is separate from `Note`/`Folder`. Pinning is the only space order. → "Folders inside a space", "A folder travels; its coordinates do not", "Managing spaces from the switcher".
- **Tools**: a pure Rust function each, called on the `compute` queue; `result` is an output, never an input; secrets are plain values. → "The tools: one contract…".
- ⚠️ **The identity tool's lists are compiled in**: `crates/engine/resources/identity/` is `include_str!`-ed by `tools/identity/data.rs` (the standalone executable is one file) and each list is held whole by a test, not checked at run time. ⚠️ The names are **one list** (`names.txt`): never sort people's names by origin or by country — not in data, file names, order, code or tests. A new country is a file of places there, named in `data.rs`. → "The identity tool is that design…".
- ⚠️ **Request scripts run in the app relaunched as a script host** (`--devnotes-script-host`, read in `main` before any window): QuickJS, one host per request, a phase at a time; `pm.sendRequest` is sent by the parent. What `require` finds is bundled by `crates/engine/sandbox/build.mjs` into the committed `sandbox/dist/`. → "Request scripts, in a process of their own".
- ⚠️ **Request scripts run in the app relaunched as a script host** (`--script-host`, read in `main` before any window): QuickJS, one host per request, a phase at a time; `pm.sendRequest` is sent by the parent. What `require` finds is bundled by `crates/engine/sandbox/build.mjs` into the committed `sandbox/dist/`. → "Request scripts, in a process of their own".
- **JSON explorer/visualiser**: inputs only; Rust owns the model (`explore_json`, nesting capped at 256, node/row caps). → "Exploring a JSON snippet", "The JSON visualiser's model".
- `closed_enum!` declares enums once. **Imports degrade rather than fail**, in one transaction; an added variant does not bump `FORMAT_VERSION`. → "Import, export and copying out".
- ⚠️ **Every name of the application is `brand`'s** (D36): six values of the root `Cargo.toml`'s `[workspace.metadata]`; never type the name, the slug, the identifier, the extension or the site. Other metadata is read from `Cargo.toml` at compile time; the changelog is baked in (`include_str!`). → "The application's names".
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# `clippy::doc_markdown` reads these product names as identifiers and asks for backticks.
# `".."` extends the default list rather than replacing it.
doc-valid-idents = ["SQLite", "DevNotes", "TextMate", "QuickJS", "ProseMirror", "TipTap", ".."]
doc-valid-idents = ["SQLite", "TextMate", "QuickJS", "ProseMirror", "TipTap", ".."]
2 changes: 2 additions & 0 deletions crates/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ image.workspace = true
resvg.workspace = true
tempfile.workspace = true
tokio = { workspace = true, features = ["rt-multi-thread"] }
# `tests/names.rs`, which reads the manifest's literal names.
toml.workspace = true

[lints]
workspace = true
4 changes: 2 additions & 2 deletions crates/app/examples/icons.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Regenerates `crates/app/icons/` from `devnotes.svg`: `cargo run -p app --example icons`.
//! Regenerates `crates/app/icons/` from `<slug>.svg`: `cargo run -p app --example icons`.
//!
//! ⚠️ 16, 24 and 32 px of the Windows `.ico` come from the hand-hinted drawings in
//! `icons/source/`, whose lines sit on whole pixels. Scaled from the master they blur, and 24 px
Expand All @@ -15,7 +15,7 @@ const PNGS: [(&str, u32); 3] = [("32x32.png", 32), ("128x128.png", 128), ("icon.

fn main() {
let icons = Path::new(env!("CARGO_MANIFEST_DIR")).join("icons");
let master = icons.join("devnotes.svg");
let master = icons.join(format!("{}.svg", brand::SLUG));
for (name, size) in PNGS {
let source = if HINTED.contains(&size) { hinted(&icons, size) } else { master.clone() };
write(&icons.join(name), &render(&source, size));
Expand Down
2 changes: 1 addition & 1 deletion crates/app/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ mod tests {
&filed_from(&file, "lines before"),
&[
"— the 3 lines before —",
"devnotes::logging: Logging at",
concat!(env!("CARGO_CRATE_NAME"), "::logging: Logging at"),
"ui::action: #1 Notes::OpenNote",
"ui::backend: db #1 notes::get 2 ms ok",
"] ui::services::errors: the first warning",
Expand Down
7 changes: 3 additions & 4 deletions crates/app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! The `devnotes` binary: a request-script host when relaunched as one, the application
//! otherwise.
//! The binary: a request-script host when relaunched as one, the application otherwise.

// Prevents an additional console window on Windows in release.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
Expand Down Expand Up @@ -149,11 +148,11 @@ fn run(locations: Locations, instance: Instance) -> eframe::Result {
METADATA.name,
options(restored),
#[cfg(not(feature = "e2e"))]
Box::new(move |cc| Ok(Box::new(ui::DevNotesApp::new(cc, startup())?))),
Box::new(move |cc| Ok(Box::new(ui::App::new(cc, startup())?))),
#[cfg(feature = "e2e")]
Box::new(move |cc| {
unpainted::attach(&cc.egui_ctx);
let app = ui::DevNotesApp::new(cc, startup())?;
let app = ui::App::new(cc, startup())?;
pointer::attach(&cc.egui_ctx);
Ok(Box::new(sight::Watched::new(app)))
}),
Expand Down
4 changes: 2 additions & 2 deletions crates/app/src/sight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use egui::{Context, Sense, Ui, Vec2, ViewportCommand, ViewportId, WidgetInfo};
/// minimised, eframe runs `logic` alone, outside any pass, and no plugin hook sees what it asks,
/// the window brought back included. The commands are read after `logic` and again after `ui`.
pub(crate) struct Watched {
app: ui::DevNotesApp,
app: ui::App,
hidden: bool,
put_away: u32,
/// The root's commands of this pass already read: `ui` adds to the list `logic` began.
read: usize,
}

impl Watched {
pub(crate) fn new(app: ui::DevNotesApp) -> Self {
pub(crate) fn new(app: ui::App) -> Self {
Watched { app, hidden: false, put_away: 0, read: 0 }
}

Expand Down
69 changes: 69 additions & 0 deletions crates/app/tests/names.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//! The names Cargo and the file system keep literal (D36): edited by hand at a rename, each is
//! held here against the values, so that none is left behind.

use std::path::{Path, PathBuf};

fn here(file: &str) -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR")).join(file)
}

fn read(file: &str) -> String {
std::fs::read_to_string(here(file)).unwrap()
}

/// A path with the slug written `{slug}`: one still spelling another slug stays as it was.
fn shaped(path: &toml::Value) -> String {
path.as_str().unwrap().replace(brand::SLUG, "{slug}")
}

#[test]
fn the_binary_and_the_packages_are_named_by_the_values() {
let manifest: toml::Table = toml::from_str(&read("Cargo.toml")).unwrap();
let metadata = &manifest["package"]["metadata"];
let packager = &metadata["packager"];
let rpm = &metadata["generate-rpm"];

assert_eq!(manifest["bin"][0]["name"].as_str(), Some(brand::SLUG));
assert_eq!(packager["product-name"].as_str(), Some(brand::NAME));
assert_eq!(packager["identifier"].as_str(), Some(brand::IDENTIFIER));
assert_eq!(packager["binaries"][0]["path"].as_str(), Some(brand::SLUG));
assert_eq!(packager["deb"]["package-name"].as_str(), Some(brand::SLUG));
assert_eq!(rpm["name"].as_str(), Some(brand::SLUG));

let mut deb: Vec<String> = packager["deb"]["files"].as_table().unwrap().values().map(shaped).collect();
deb.sort();
assert_eq!(deb, ["usr/share/doc/{slug}/changelog.gz", "usr/share/doc/{slug}/copyright"]);
let assets: Vec<String> = rpm["assets"]
.as_array()
.unwrap()
.iter()
.map(|asset| format!("{} → {}", shaped(&asset["source"]), shaped(&asset["dest"])))
.collect();
assert_eq!(
assets,
[
"target/release/{slug} → /usr/bin/{slug}",
"packaging/{slug}.desktop → /usr/share/applications/{slug}.desktop",
"icons/32x32.png → /usr/share/icons/hicolor/32x32/apps/{slug}.png",
"icons/128x128.png → /usr/share/icons/hicolor/128x128/apps/{slug}.png",
"icons/icon.png → /usr/share/icons/hicolor/512x512/apps/{slug}.png",
"../../LICENSE → /usr/share/licenses/{slug}/LICENSE",
"target/release/notes/changelog.gz → /usr/share/doc/{slug}/changelog.gz",
]
);
}

#[test]
fn the_desktop_entry_the_copyright_and_the_icon_are_named_by_the_values() {
let entry = read(&format!("packaging/{}.desktop", brand::SLUG));
let copyright = read("packaging/copyright");

for line in
[format!("Exec={}", brand::SLUG), format!("Icon={}", brand::SLUG), format!("Name={}", brand::NAME)]
{
assert!(entry.lines().any(|written| written == line), "{line}");
}
let upstream = format!("Upstream-Name: {}", brand::NAME);
assert!(copyright.lines().any(|written| written == upstream), "{upstream}");
assert!(here(&format!("icons/{}.svg", brand::SLUG)).is_file());
}
2 changes: 1 addition & 1 deletion crates/app/tests/script_host.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The `devnotes` binary started again as a script host, as the application starts it.
//! The binary started again as a script host, as the application starts it.

use std::path::Path;
use std::time::Duration;
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/benches/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ fn disk(c: &mut Criterion) {
// The bundle is ~100 MB, so these two want their own sample size.
group.sample_size(10);

let path = std::env::temp_dir().join("devnotes-bench-export.devnotes");
let path = std::env::temp_dir().join("bench-export.archive");
let target = path.to_string_lossy().to_string();
// The corpus seeds no attachment, so the archive carries the bundle alone. What the
// directory is does not matter; that it exists does.
Expand Down Expand Up @@ -282,7 +282,7 @@ fn attachment(c: &mut Criterion) {
});
});

let profile = std::env::temp_dir().join(format!("devnotes-bench-profile-{}", uuid::Uuid::new_v4()));
let profile = std::env::temp_dir().join(format!("bench-profile-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&profile).expect("a writable temporary directory");
libraries::registry::open_directory_in(&profile).expect("a registry");

Expand Down
2 changes: 1 addition & 1 deletion crates/engine/benches/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub(crate) fn build() -> Corpus {
/// The size is a parameter for `corpus_size` alone: every other group takes [`NOTES`], so
/// its numbers stay comparable across runs.
pub(crate) fn build_of(notes: usize) -> Corpus {
let directory = std::env::temp_dir().join(format!("devnotes-bench-{}", uuid::Uuid::new_v4()));
let directory = std::env::temp_dir().join(format!("bench-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&directory).expect("a writable temporary directory");

// The corpus is sealed like a real library, so the benchmarks measure what the
Expand Down
4 changes: 2 additions & 2 deletions crates/engine/benches/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ fn uuid(n: usize) -> String {
}

pub(crate) fn build(size: Size) -> Reference {
let directory = std::env::temp_dir().join(format!("devnotes-reference-{}", uuid::Uuid::new_v4()));
let directory = std::env::temp_dir().join(format!("reference-{}", uuid::Uuid::new_v4()));
std::fs::create_dir_all(&directory).unwrap();
let vault = engine::vault::file::create(&directory, "a passphrase", Cost::FOR_TESTS).unwrap();
let mut library = db::open(&directory.join("devnotes.sqlite3"), vault).unwrap();
let mut library = db::open(&directory.join(format!("{}.sqlite3", brand::SLUG)), vault).unwrap();
let (space_ids, note_ids) = seed(&mut library, size);
std::fs::create_dir_all(directory.join("attachments")).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions crates/engine/sandbox/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/engine/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "devnotes-script-libraries",
"name": "script-libraries",
"private": true,
"description": "What a request script can require, bundled once into dist/ and compiled into the application.",
"license": "GPL-3.0-only",
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/bin/script-host.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! The script host alone, for this crate's tests: the application relaunches itself with
//! `--devnotes-script-host`, but no application binary is built here.
//! `--script-host`, but no application binary is built here.

fn main() {
std::process::exit(engine::serve_scripts());
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ pub fn open_in_memory() -> Result<Library, StorageError> {
connection,
vault: Arc::new(test_vault()?),
// Named, never created: a test writing beside the library fails loudly.
directory: std::env::temp_dir().join(format!("devnotes-in-memory-{}", uuid::Uuid::new_v4())),
directory: std::env::temp_dir().join(format!("in-memory-library-{}", uuid::Uuid::new_v4())),
number: next_number(),
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/docs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The documentation, compiled in: the Markdown of `docs/content`, which devnotes.fr shows too.
//! The documentation, compiled in: the Markdown of `docs/content`, which the site shows too.

pub mod model;
pub mod search;
Expand Down
6 changes: 3 additions & 3 deletions crates/engine/src/docs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ mod tests {
};
assert_eq!(to("[a](#ici)"), Target::Page { id: "page".to_owned(), section: Some("ici".to_owned()) });
assert_eq!(
to("[a](https://devnotes.fr/telecharger)"),
Target::Address("https://devnotes.fr/telecharger".to_owned())
to("[a](https://example.org/telecharger)"),
Target::Address("https://example.org/telecharger".to_owned())
);
assert!(refused("[a](../autre.txt)").contains("leads nowhere"));
}
Expand Down Expand Up @@ -603,7 +603,7 @@ mod tests {
Block::Paragraph(mut runs) => runs.remove(0),
other => panic!("{other:?}"),
};
for address in ["https://devnotes.fr", "http://localhost:8080"] {
for address in ["https://example.org", "http://localhost:8080"] {
assert!(
matches!(to(address), Inline::Link { to: Target::Address(found), .. } if found == address)
);
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/folders/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub const SCROLLBAR: i32 = 18;

closed_enum! {
/// How many lines a card shows of its note: the library's choice
/// (`devnotes.notes.previewLines`), since the board's loose cards are stored there in pixels.
/// (`<slug>.notes.previewLines`), since the board's loose cards are stored there in pixels.
pub enum PreviewLines {
Three = "3",
#[default]
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/http/scripts/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
use super::engine::{Engine, Host};
use super::model::{FailureKind, Job, LogEntry, Outcome, ScriptFailure};

pub const ARG: &str = "--devnotes-script-host";
pub const ARG: &str = "--script-host";

/// The thread `QuickJS` runs on: a script that recurses meets its own limit long before the
/// thread's end.
Expand Down
20 changes: 10 additions & 10 deletions crates/engine/src/http/scripts/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,14 @@ fn drive(ctx: &Ctx<'_>, job: &Job, deadline: Instant, time: Duration) -> Outcome
Err(failure) => return Outcome::failed(failure),
};
let started = (|| -> rquickjs::Result<(Promise<'_>, Loop<'_>)> {
let devnotes: Object<'_> = ctx.globals().get("__devnotes")?;
let phase: Function<'_> = devnotes.get("phase")?;
let prelude: Object<'_> = ctx.globals().get("__prelude")?;
let phase: Function<'_> = prelude.get("phase")?;
let given = ctx.json_parse(serde_json::to_string(job).unwrap_or_default())?;
let promise: Promise<'_> = phase.call((given, functions))?;
let driven = Loop {
next_timer: devnotes.get("nextTimer")?,
fire_timers: devnotes.get("fireTimers")?,
wake_idle: devnotes.get("wakeIdle")?,
next_timer: prelude.get("nextTimer")?,
fire_timers: prelude.get("fireTimers")?,
wake_idle: prelude.get("wakeIdle")?,
};
Ok((promise, driven))
})();
Expand Down Expand Up @@ -1114,14 +1114,14 @@ mod tests {
("expect({ a: 1 }).toEqual({ a: 2 })", false),
("expect([1]).toStrictEqual([1])", true),
("expect([1]).toStrictEqual([2])", false),
("expect('DevNotes').toContain('Notes')", true),
("expect('MyNotes').toContain('Notes')", true),
("expect([1, 2]).toContain(2)", true),
("expect([{ a: 1 }]).toContain({ a: 1 })", false),
("expect(null).toContain(1)", false),
("expect([{ a: 1 }]).toContainEqual({ a: 1 })", true),
("expect([{ a: 1 }]).toContainEqual({ a: 2 })", false),
("expect('DevNotes').toMatch(/notes/i)", true),
("expect('DevNotes').toMatch('notes')", false),
("expect('MyNotes').toMatch(/notes/i)", true),
("expect('MyNotes').toMatch('notes')", false),
("expect({ a: 1, b: { c: 2, d: 3 } }).toMatchObject({ b: { c: 2 } })", true),
("expect({ a: [1, 2] }).toMatchObject({ a: [1] })", false),
("expect({ a: 1 }).toMatchObject({ b: undefined })", false),
Expand Down Expand Up @@ -1446,8 +1446,8 @@ mod tests {
("require('csv-parse/lib/sync')('a,b\\n1,2', { columns: true })", r#"[{"a":"1","b":"2"}]"#),
("require('csv-parse/sync').parse('a,b\\n1,2')", r#"[["a","b"],["1","2"]]"#),
(
"[Buffer.from('DevNotes').toString('base64'), require('node:buffer').Buffer === Buffer]",
r#"["RGV2Tm90ZXM=",true]"#,
"[Buffer.from('Notebook').toString('base64'), require('node:buffer').Buffer === Buffer]",
r#"["Tm90ZWJvb2s=",true]"#,
),
(
"(() => { const events = new (require('events'))(); let heard = 0; events.on('x', (n) => { heard = n; }); events.emit('x', 3); return heard; })()",
Expand Down
2 changes: 1 addition & 1 deletion crates/engine/src/http/scripts/prelude.js
Original file line number Diff line number Diff line change
Expand Up @@ -1597,5 +1597,5 @@
});
}

define(global, '__devnotes', { phase, nextTimer, fireTimers, wakeIdle });
define(global, '__prelude', { phase, nextTimer, fireTimers, wakeIdle });
})(globalThis.__native);
4 changes: 2 additions & 2 deletions crates/engine/src/notes/language.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ mod tests {
("<?php\n\necho 'hi';", Language::Php),
("SELECT * FROM notes", Language::Sql),
("select 1", Language::Sql),
("[package]\nname = \"devnotes\"", Language::Toml),
("[package]\nname = \"example\"", Language::Toml),
("def run():\n return 1", Language::Py),
("class Note:\n pass", Language::Py),
("export enum Kind { A }", Language::Ts),
Expand All @@ -1340,7 +1340,7 @@ mod tests {
(".card {\n color: red;\n &:hover {\n color: blue;\n }\n}", Language::Scss),
("query GetUser($id: ID!) {\n user(id: $id) {\n name\n }\n}", Language::Graphql),
("type Note {\n id: ID!\n tags: [String!]!\n}", Language::Graphql),
("name: devnotes\nversion: 1", Language::Yml),
("name: example\nversion: 1", Language::Yml),
("---\nsteps:\n - build", Language::Yml),
("# Heading\n\nA paragraph.", Language::Md),
("Un [lien](https://x.dev)", Language::Md),
Expand Down
Loading