Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
048cbc51b1 | ||
|
|
5865e4cb51 | ||
|
|
46dc8b1bde | ||
|
|
5883b6c1fd | ||
|
|
24bea90921 | ||
|
|
0169781847 | ||
|
|
50e601703e | ||
|
|
53a1115a9a | ||
|
|
4b6c3d1e2c |
No files matched your search
+5
-5
@@ -4,7 +4,7 @@ VectorCraft is a clean-room, open-source, pure-Rust reimplementation of the Adob
|
||||
|
||||
This file tracks **how far we are and what's left**. Time estimates are wall-clock hours of continuous Claude Opus 5.5 agent work (including builds and the CI gate), given both for **one agent** and for **4–6 parallel agents** on disjoint crates. They are counted from the remaining work (see [Parity estimate](#parity-estimate)), calibrated against measured throughput, and updated as work lands.
|
||||
|
||||
_Last updated: 2026-10-08 (after M4.14–M4.98, M8.1–M8.20, M14.4–M14.7, the MCP prompts, resource templates, completions and logging, the 2026-10-07 issue fixes, the Layers panel rework and the 2026-10-08 community contributions: Pen and shape-tool modifiers, path editing, Layers, Artboards, Swatches/Brushes and dialogs, Japanese composition and PDF text, Hebrew/Arabic type, interface languages (Spanish among them), the font menu, saved selections, MCP and EPS; see [Honest assessment](#honest-assessment-2026-10-05))._
|
||||
_Last updated: 2026-10-08 (after M4.14–M4.98, M8.1–M8.20, M14.4–M14.7, the MCP prompts, resource templates, completions and logging, the 2026-10-07 issue fixes, the Layers panel rework and the 2026-10-08 community contributions: Pen and shape-tool modifiers, path editing, Layers, Artboards, Swatches/Brushes and dialogs, Japanese composition and PDF text, Hebrew/Arabic type, interface languages (Spanish among them), the font menu, saved selections, MCP and EPS, and the missing-font export warning (#319); see [Honest assessment](#honest-assessment-2026-10-05))._
|
||||
|
||||
## Where we are
|
||||
|
||||
@@ -119,7 +119,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist
|
||||
- **Editing type:** double-clicking type with a selection tool switches to the Type tool with the caret where it was clicked.
|
||||
- **Temporary tools:** Cmd with any other tool drags with the selection tool used last (Selection, Direct Selection or Group Selection). Held Space pans and Cmd+Space zooms (Cmd+Alt+Space out) whatever the tool.
|
||||
- **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, onto the Swatches panel a pattern swatch and onto the Brushes panel an Art brush; a symbol dragged onto the canvas places an instance where it is dropped, and a brush dragged onto a path is applied to it.
|
||||
- **Tool double-clicks:** double-clicking a tool's button opens its options: Hand fits the artboard in the window, Zoom shows 100 %, Rotate, Scale, Reflect and Shear open their Object › Transform dialogs, Gradient, Eyedropper, Blend and the Liquify tools their panels or options.
|
||||
- **Tool double-clicks:** double-clicking a tool's button opens its options: Hand fits the artboard in the window, Zoom shows 100 %, Rotate, Scale, Reflect and Shear open their Object › Transform dialogs, the Selection, Direct Selection and Group Selection tools the Move dialog (Enter opens these seven tools' dialogs too), Gradient, Eyedropper, Blend and the Liquify tools their panels or options.
|
||||
- **Layers panel:** every layer, sublayer, group and object is a clickable row at any depth: a click highlights it and makes its layer current (new art goes there), Shift-click a range, Ctrl/Cmd-click toggles. Sublayers are no longer treated as objects: clicks, marquees, Select All and the Select menu take the art inside them, and each sublayer selects in its own colour. Selection squares on rows with selected art (click selects a row's art, Shift adds or removes; dragging the square moves the selection to another row, Alt copies), the eye and lock on every row with drag-down-the-column (one undo step), Ctrl/Cmd-click an eye for per-layer Outline, Alt-click an eye or lock to hide or lock the other layers (again: show or unlock them all), triangles with Alt to open or close everything inside, drag and drop rows above, below or into layers and groups with a drop line (Alt copies, the trash deletes), inline rename, Delete key on highlighted rows. Buttons and the full panel menu: New Layer/Sublayer (Alt: options, Ctrl: on top), Duplicate, Delete, Options for Selection, clipping mask, isolation, Locate Object, Merge Selected, Flatten Artwork, Collect in New Layer, Release to Layers (Sequence and Build), Reverse Order, Template, Hide/Outline/Lock Others and Show/Preview/Unlock All, Paste Remembers Layers, Panel Options (row size, thumbnails per kind, Show Layers Only). Layer Options: name, colour (presets or custom), Template, Lock, Show, Print, Preview (outline drawing and clicking) and Dim Images to %. Every operation is a command (`layer.move`, `layer.highlight`, `layer.merge`…) with validation against cycles and invalid nesting.
|
||||
- **Drawing aids:** Smart Guides and snapping (moving, and resizing by the bounding-box handles: the dragged edges align with the other objects; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H), guides dragged out of the rulers, and Draw Normal / Behind / Inside modes.
|
||||
- **Views:** the status bar's artboard navigator (first, previous, next, last; `view.goToArtboard`) goes to an artboard and fits it, and Fit Artboard in Window and Actual Size show the navigator's artboard. The Artboards panel highlights that active artboard: clicking a row makes it active (the Artboard tool's too, while it is chosen) as does clicking an artboard with the Artboard tool, double-clicking its number also fits it in the window and double-clicking its name renames it.
|
||||
@@ -127,7 +127,7 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist
|
||||
- Pathfinder (10 exact curve booleans), Offset, Outline Stroke, Simplify, Clean Up, Split Into Grid, Divide Objects Below. Object › Path › Remove Anchor Points (`path.removeAnchors`) removes the direct-selected anchors without opening their paths (the Delete key still deletes them with their segments): the neighbours keep their handle directions and their facing handles are refitted so one cubic follows the two old segments, and straight sides stay straight. The Delete Anchor Point tool uses the same refit. The Control bar, the contextual task bar, the Properties quick actions and the canvas context menu offer it when anchors are selected.
|
||||
- Live effects with previewing dialogs: Distort & Transform, Path, Convert to Shape, 15 Warp styles, Round Corners, Scribble, Effect → Pathfinder (all 10 operations, live on groups; several loose objects are grouped first, in one undo step), Color Adjustments (Brightness/Contrast, Curves, Levels, Hue/Saturation, Shift to Color, Temperature/Tint, on vectors, live type and embedded images), and raster drop shadow, glows and feather. SVG and PDF export keep live effects (geometry baked; SVG raster effects as filters).
|
||||
- **Type:** Text Wrap, Type on a Path effects (Rainbow/Skew/3D Ribbon/Stair Step/Gravity), Character and Paragraph Styles (override-preserving redefine), Area Type Options (rows/columns/inset/first baseline), threaded text across any closed shapes, Fit Headline. Area type resizes like Illustrator's type areas: a bounding-box handle drag (Selection tool) or Area Type Options Width/Height size the frame and the text reflows at its size (threads too); Direct Selection drags a frame corner or edge (`text.reshapeArea`). Point type still scales. Variable fonts list every named instance as a style of their family (Figtree Light to Black and their italics, Bahnschrift, Segoe UI Variable), and the instance chosen is shaped, drawn, outlined and measured at its axis settings; PDF and SVG embed it as that instance. Variation axis sliders are not done. Hebrew and Arabic are laid out right to left with the Unicode bidirectional algorithm (embedded Latin and numbers keep their direction, lines put in visual order after wrapping) in point, area and path type, with caret, selection and arrow keys in visual order; each paragraph's direction comes from its first strong character unless Paragraph Direction sets it (Paragraph panel with Show Indic Options, `text.setFormat {direction}`), and new type aligns to the start of its direction. SVG export outlines right-to-left text.
|
||||
- **Interface languages, vertical type:** VectorCraft ▸ Language (or Preferences ▸ User Interface) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese and Spanish (neutral international Spanish, for every `es-*` locale) cover the whole interface, Czech and Brazilian Portuguese every menu label, Brazilian Portuguese the shell's `tl!` literals too (tested); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech and Spanish ones from the bundled UI fonts. The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line); kinsoku (the strict set) applies to horizontal and vertical Japanese, and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width, and puts a quarter em between Japanese and Latin letters or digits; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines.
|
||||
- **Interface languages, vertical type:** VectorCraft ▸ Language (or Preferences ▸ User Interface) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese and Spanish (neutral international Spanish, for every `es-*` locale) cover the whole interface, Czech and Brazilian Portuguese every menu label, Brazilian Portuguese the shell's `tl!` literals too (tested); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech and Spanish ones from the bundled UI fonts. The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line); kinsoku (the strict set) applies to horizontal and vertical Japanese, and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width, and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines.
|
||||
- **Transparency:** opacity masks (clip/invert/disable/link), exported as SVG `<mask>` and PDF soft masks.
|
||||
- **Advanced art:** live Blends (steps/distance/smooth colour, editable spine, anchor-targeted Blend tool, faithful interpolation, knockout), Envelope Distort (warp/mesh/top object, Reset, full Envelope Options, mesh handles, Edit Contents; type, images, symbols, gradients, patterns and appearance distorted everywhere), Liquify tools with options and pen pressure, Puppet Warp with rotating pins, Perspective Grid with presets, movable planes and projected type (choosing a perspective tool shows the grid; Hide Grid hides it with the tool still chosen), Gradient Mesh, Shape Builder, Live Paint (every path an edge, open lines included), Image Trace (12 presets), pattern swatches with pattern editing mode, live Repeat (radial/grid/mirror).
|
||||
- **Paint and appearance (M3):**
|
||||
@@ -141,9 +141,9 @@ grade by behaviour against `plan/illustrator/`, not by whether a menu item exist
|
||||
- **Graphic styles:** styles keep opacity and blend mode, capture groups and type, apply on top with Alt, and link to the objects using them; Redefine, Break Link, Graphic Style Options, Select All Unused, Sort by Name, and Select > Same Graphic Style / Appearance Attribute. The panel has list and thumbnail views with rendered previews, merge, reorder and drag and drop, plus a Control bar Style picker; six generated style libraries save and load as `.vcstyles`.
|
||||
- **Neutral wording:** labels, MCP tool text, docs and packaging use neutral names, and `cargo xtask brands` (part of `cargo xtask ci`) fails on vendor names.
|
||||
- **Colour, type and file workflows:** Recolor Artwork (dialog with harmonies), Edit Colors, Find & Replace, Change Case, Smart Punctuation, Guides, Lock/Hide Above, Transform Each, Rasterize.
|
||||
- **Fonts:** a font is found by any of its names (family and style in every language of its name table, legacy family/style pairs, PostScript name), so documents from other apps open with the font they name; Find Font and `text.fonts` say for each font whether it was found exactly, by another name, substituted or missing, and how many glyphs are missing. PDF and `.ai` import brings Japanese text back as live type: CID fonts without a ToUnicode map read through the standard CMaps, vertical columns (WMode 1) as vertical type, letter spacing as tracking; a glyph is live type only when the installed font (in the closest style of its family) draws the same glyph, and text in a font that isn't installed comes in as live type shown in the fallback font until the font is installed.
|
||||
- **Fonts:** a font is found by any of its names (family and style in every language of its name table, legacy family/style pairs, PostScript name), so documents from other apps open with the font they name; Find Font and `text.fonts` say for each font whether it was found exactly, by another name, substituted or missing, and how many glyphs are missing. PDF and `.ai` import brings Japanese text back as live type: CID fonts without a ToUnicode map read through the standard CMaps, vertical columns (WMode 1) as vertical type, letter spacing as tracking; a glyph is live type only when the installed font (in the closest style of its family) draws the same glyph, and text in a font that isn't installed comes in as live type shown in the fallback font until the font is installed (exports that draw it — PDF, EPS, EMF/WMF, raster, SVG outlines or embedded fonts — warn that they wrote the fallback font; `textAs: outlines` keeps the PDF's embedded glyphs).
|
||||
- **Files (M4):**
|
||||
- `.vectorcraft` (lossless JSON, compressed, atomic saves, save down to v1), Save As with a format chooser, Save a Copy, Revert, templates, Data Recovery after a crash, background save and export.
|
||||
- `.vectorcraft` (lossless JSON, compressed, atomic saves, save down to v1), Save As with a format chooser, Save a Copy, Revert, templates, Data Recovery after a crash (browser tabs hold their copies with Web Locks too, so a background tab's copies are never taken for a crash's, and a tab repairs copies another removed when it resumes: #367), background save and export.
|
||||
- SVG/SVGZ in and out with SVG Options, Preserve Editing, symbols, filters, rich text and physical units; PDF and PDF-compatible `.ai` in and out (layers, masks, editable text with type set along a curve coming back as type on a path, each artboard's art on its own page only, an `.ai`'s white page under its layers left out rather than coming in as art, spot colours, presets, security, marks and bleed, ICC output intents, raster effects, subset fonts, PDF/X, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3). CMYK images keep their ink amounts from PDF import (and from placed CMYK TIFFs) to PDF export: a CMYK JPEG passes through unchanged, others stay CMYK (DeviceCMYK, or ICC-based CMYK in PDF/X-3/X-4) unless the Output settings convert them; the canvas shows them through the working CMYK profile (#320).
|
||||
- EPS and DXF in and out, EMF/WMF in and out; PNG (with PNG-8), JPEG, WebP, GIF, TIFF, BMP, Targa and layered PSD export. EPS import runs Illustrator's AGM/CoolType prologs (resource categories, `resourceforall`, `clipsave`/`cliprestore`, subarrays and substrings that share storage, the standard dictionaries in `systemdict`, `dictstack`, `internaldict`, executable filters, `cshow`, metadata skipped with `flushfile`), so Illustrator 30 EPS files open as vectors, and falls back to its palette TIFF preview. DXF TEXT justified Fit or Aligned spans its two points (stretched, or scaled as a whole).
|
||||
- Place and the Links panel, Package, File Info, Print with print presets, PostScript output and print tiling, slices and Save for Web, Export for Screens and Asset Export, CSS Properties, PNG/PDF/SVG/text clipboard flavours.
|
||||
|
||||
@@ -27,4 +27,4 @@ rfd = { workspace = true }
|
||||
wasm-bindgen = "0.2"
|
||||
wasm-bindgen-futures = "0.4"
|
||||
js-sys = "0.3"
|
||||
web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlIFrameElement", "HtmlAnchorElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Event", "EventTarget", "MouseEvent", "DragEvent", "Storage"] }
|
||||
web-sys = { version = "0.3", features = ["Window", "Document", "Element", "HtmlElement", "HtmlCanvasElement", "HtmlIFrameElement", "HtmlAnchorElement", "Blob", "BlobPropertyBag", "Url", "Location", "CssStyleDeclaration", "Event", "EventTarget", "MouseEvent", "DragEvent", "Storage", "Navigator"] }
|
||||
@@ -0,0 +1,122 @@
|
||||
//! The browser's Web Locks (`navigator.locks`), which tell Data Recovery whether another tab still
|
||||
//! runs ([`vectorcraft_engine::cmd::recovery::RecoveryStore::announce`]). A tab holds a lock named
|
||||
//! after its recovery area for as long as it lives; the browser releases it only when the tab is
|
||||
//! gone (closed, crashed or reloaded), not while its timers are paused in the background, which a
|
||||
//! heartbeat can't tell apart.
|
||||
//!
|
||||
//! web-sys has Web Locks only as an unstable API, so they are reached through `js_sys::Reflect`.
|
||||
//! Pages that aren't secure (plain `http://` other than localhost) and older browsers have none:
|
||||
//! heartbeats alone decide there.
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use js_sys::{Function, Promise, Reflect};
|
||||
use vectorcraft_engine::cmd::recovery::Hold;
|
||||
use wasm_bindgen::JsCast as _;
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen::closure::Closure;
|
||||
|
||||
/// How often the snapshot of the locks held is refreshed (ms).
|
||||
const REFRESH_MS: i32 = 10_000;
|
||||
/// How old a snapshot may be and still be trusted (ms). A lock asked for after the snapshot was
|
||||
/// taken comes with a heartbeat, which stays fresh for at least three minutes, so anything under
|
||||
/// that is safe; an older snapshot counts every area as held.
|
||||
const FRESH_MS: f64 = 60_000.0;
|
||||
|
||||
thread_local! {
|
||||
/// What releases each lock this tab holds, by name: it resolves the promise the lock is held
|
||||
/// by (wasm runs on one thread).
|
||||
static RELEASE: RefCell<BTreeMap<String, Function>> = const { RefCell::new(BTreeMap::new()) };
|
||||
}
|
||||
|
||||
/// The locks of the page, named `<prefix><area>`.
|
||||
#[derive(Clone)]
|
||||
pub struct WebLocks {
|
||||
prefix: &'static str,
|
||||
/// The areas whose locks were held at the last snapshot, and when it was asked for (ms since
|
||||
/// the epoch). `navigator.locks.query()` is asynchronous, so the snapshot is refreshed every
|
||||
/// [`REFRESH_MS`] and read from here.
|
||||
seen: Arc<Mutex<(f64, BTreeSet<String>)>>,
|
||||
}
|
||||
|
||||
/// `navigator.locks`, if the browser has it here.
|
||||
fn manager() -> Option<JsValue> {
|
||||
let locks = Reflect::get(&web_sys::window()?.navigator(), &"locks".into()).ok()?;
|
||||
locks.is_object().then_some(locks)
|
||||
}
|
||||
|
||||
/// Method `name` of `obj`.
|
||||
fn method(obj: &JsValue, name: &str) -> Option<Function> {
|
||||
Reflect::get(obj, &name.into()).ok()?.dyn_into().ok()
|
||||
}
|
||||
|
||||
impl WebLocks {
|
||||
/// The page's Web Locks with a first snapshot of them, kept fresh from then on; `None` when
|
||||
/// the browser has none or won't say which are held (heartbeats alone decide then).
|
||||
pub async fn start(prefix: &'static str) -> Option<Self> {
|
||||
let locks = Self { prefix, seen: Arc::new(Mutex::new((f64::NEG_INFINITY, BTreeSet::new()))) };
|
||||
locks.refresh().await?;
|
||||
let again = locks.clone();
|
||||
let tick = Closure::<dyn FnMut()>::new(move || {
|
||||
let locks = again.clone();
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
// A failed refresh leaves the snapshot to age, and every area counts as held.
|
||||
let _ = locks.refresh().await;
|
||||
});
|
||||
});
|
||||
web_sys::window()?.set_interval_with_callback_and_timeout_and_arguments_0(tick.as_ref().unchecked_ref(), REFRESH_MS).ok()?;
|
||||
// The timer lives as long as the page.
|
||||
tick.forget();
|
||||
Some(locks)
|
||||
}
|
||||
|
||||
/// Take a new snapshot of the locks held.
|
||||
async fn refresh(&self) -> Option<()> {
|
||||
let m = manager()?;
|
||||
let asked = js_sys::Date::now();
|
||||
let query: Promise = method(&m, "query")?.call0(&m).ok()?.dyn_into().ok()?;
|
||||
let snapshot = wasm_bindgen_futures::JsFuture::from(query).await.ok()?;
|
||||
let held = js_sys::Array::from(&Reflect::get(&snapshot, &"held".into()).ok()?);
|
||||
let areas = held
|
||||
.iter()
|
||||
.filter_map(|l| Reflect::get(&l, &"name".into()).ok()?.as_string())
|
||||
.filter_map(|n| n.strip_prefix(self.prefix).map(str::to_string))
|
||||
.collect();
|
||||
*self.seen.lock().unwrap_or_else(|e| e.into_inner()) = (asked, areas);
|
||||
Some(())
|
||||
}
|
||||
|
||||
/// Does a tab hold `area`'s lock? Yes when the last snapshot is too old to tell.
|
||||
pub fn held(&self, area: &str) -> bool {
|
||||
let seen = self.seen.lock().unwrap_or_else(|e| e.into_inner());
|
||||
js_sys::Date::now() - seen.0 > FRESH_MS || seen.1.contains(area)
|
||||
}
|
||||
|
||||
/// Hold `area`'s lock until the returned hold is dropped (or the page goes).
|
||||
pub fn hold(&self, area: &str) -> Option<Hold> {
|
||||
let m = manager()?;
|
||||
let name = format!("{}{area}", self.prefix);
|
||||
// The lock is held until this promise resolves: when the hold is dropped.
|
||||
let mut release = None;
|
||||
let until = Promise::new(&mut |resolve, _| release = Some(resolve));
|
||||
let release = release?;
|
||||
let granted = Closure::once_into_js(move |_lock: JsValue| until);
|
||||
method(&m, "request")?.call2(&m, &name.clone().into(), &granted).ok()?;
|
||||
RELEASE.with(|r| r.borrow_mut().insert(name.clone(), release));
|
||||
Some(Box::new(LockHold(name)))
|
||||
}
|
||||
}
|
||||
|
||||
/// A lock this tab holds (by name), released when dropped.
|
||||
struct LockHold(String);
|
||||
|
||||
impl Drop for LockHold {
|
||||
fn drop(&mut self) {
|
||||
if let Some(resolve) = RELEASE.with(|r| r.borrow_mut().remove(&self.0)) {
|
||||
// Resolving can't fail in a way worth reporting: the lock goes with the page anyway.
|
||||
let _ = resolve.call0(&JsValue::NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@
|
||||
//!
|
||||
//! URL query flag: `?webgl` forces the WebGL2 backend instead of WebGPU.
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod locks;
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
mod web;
|
||||
|
||||
|
||||
@@ -6,12 +6,14 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use vectorcraft_engine::Session;
|
||||
use vectorcraft_engine::cmd::fileio;
|
||||
use vectorcraft_engine::cmd::recovery::RecoveryStore;
|
||||
use vectorcraft_engine::cmd::recovery::{Hold, RecoveryStore};
|
||||
use vectorcraft_ui_egui::place::{DropTarget, PlaceArrival, PlaceInbox};
|
||||
use vectorcraft_ui_egui::print::{PrintJob, PrintService, Printer};
|
||||
use vectorcraft_ui_egui::{Services, VectorcraftApp};
|
||||
use wasm_bindgen::JsCast as _;
|
||||
|
||||
use crate::locks::WebLocks;
|
||||
|
||||
type Inbox = Arc<Mutex<Vec<(String, Vec<u8>)>>>;
|
||||
|
||||
/// Where the pointer was over the canvas during the last file drag (CSS px from its top-left) and
|
||||
@@ -33,6 +35,8 @@ pub fn start() {
|
||||
return;
|
||||
};
|
||||
let drag = track_drag(&canvas);
|
||||
// Before the first frame, which looks for copies a crash left behind.
|
||||
let locks = WebLocks::start(RECOVERY_PREFIX).await;
|
||||
let mut options = eframe::WebOptions::default();
|
||||
if query().contains("webgl")
|
||||
&& let eframe::egui_wgpu::WgpuSetup::CreateNew(create) = &mut options.wgpu_options.wgpu_setup
|
||||
@@ -49,7 +53,7 @@ pub fn start() {
|
||||
}
|
||||
let inbox: Inbox = Arc::default();
|
||||
let place_inbox: PlaceInbox = Arc::default();
|
||||
let app = VectorcraftApp::new(Session::new(), services(inbox.clone(), place_inbox.clone(), cc.egui_ctx.clone()));
|
||||
let app = VectorcraftApp::new(Session::new(), services(inbox.clone(), place_inbox.clone(), cc.egui_ctx.clone(), locks));
|
||||
Ok(Box::new(WebShell { app, inbox, place_inbox, drag }))
|
||||
}),
|
||||
)
|
||||
@@ -132,7 +136,7 @@ impl eframe::App for WebShell {
|
||||
}
|
||||
}
|
||||
|
||||
fn services(inbox: Inbox, place_inbox: PlaceInbox, ctx: egui::Context) -> Services {
|
||||
fn services(inbox: Inbox, place_inbox: PlaceInbox, ctx: egui::Context, locks: Option<WebLocks>) -> Services {
|
||||
let open_inbox = inbox.clone();
|
||||
let picked = place_inbox.clone();
|
||||
let place_ctx = ctx.clone();
|
||||
@@ -174,7 +178,7 @@ fn services(inbox: Inbox, place_inbox: PlaceInbox, ctx: egui::Context) -> Servic
|
||||
}
|
||||
})),
|
||||
inbox: Some(inbox),
|
||||
recovery_store: Some(Arc::new(BrowserStore)),
|
||||
recovery_store: Some(Arc::new(BrowserStore { locks })),
|
||||
// File → Print: the browser's print dialog.
|
||||
print: Some(Box::new(BrowserPrint)),
|
||||
..Default::default()
|
||||
@@ -183,8 +187,12 @@ fn services(inbox: Inbox, place_inbox: PlaceInbox, ctx: egui::Context) -> Servic
|
||||
|
||||
/// Data Recovery's store on the web: the browser's local storage (kept across visits and shared by
|
||||
/// the site's tabs), each entry as base64 under [`RECOVERY_PREFIX`]`<area>/<name>`. It has no
|
||||
/// locks: each tab holds its area with a heartbeat, judged by the browser's clock.
|
||||
struct BrowserStore;
|
||||
/// locks: each tab holds its area with a heartbeat, judged by the browser's clock, and with a Web
|
||||
/// Lock named after it where the browser has them (`locks`), which a tab whose timers are paused
|
||||
/// in the background keeps.
|
||||
struct BrowserStore {
|
||||
locks: Option<WebLocks>,
|
||||
}
|
||||
|
||||
const RECOVERY_PREFIX: &str = "vectorcraft-recovery/";
|
||||
|
||||
@@ -220,6 +228,12 @@ impl RecoveryStore for BrowserStore {
|
||||
fn now(&self) -> Option<i64> {
|
||||
Some((js_sys::Date::now() / 1000.0) as i64)
|
||||
}
|
||||
fn announce(&self, area: &str) -> Option<Hold> {
|
||||
self.locks.as_ref()?.hold(area)
|
||||
}
|
||||
fn announced(&self, area: &str) -> Option<bool> {
|
||||
self.locks.as_ref().map(|l| l.held(area))
|
||||
}
|
||||
}
|
||||
|
||||
/// Trigger a browser download of `bytes` named after the last component of `path`.
|
||||
|
||||
@@ -78,8 +78,8 @@ pub use setup::{Background, DocSetup, ExportText, GridSize, Quotes};
|
||||
pub use slices::{CellAlign, CellVAlign, Slice, SliceArea, SliceKind, SliceOptions, SliceSource};
|
||||
pub use style_libs::StyleLibrary;
|
||||
pub use text::{
|
||||
AreaOptions, CharPosition, CharStyle, FirstBaseline, Justify, Mojikumi, ParaDirection, ParaStyle, PathEffect, ScriptMetrics, TabAlign, TabStop,
|
||||
TextKind, TextObject, TextRun, TextStyleDef, TextWrap, WrapShape,
|
||||
AreaOptions, CharPosition, CharStyle, FirstBaseline, Justify, LeadingModel, Mojikumi, ParaDirection, ParaStyle, PathEffect, ScriptMetrics,
|
||||
TabAlign, TabStop, TextKind, TextObject, TextRun, TextStyleDef, TextWrap, WrapShape,
|
||||
};
|
||||
pub use vectorcraft_color as color;
|
||||
pub use vectorcraft_geom as geom;
|
||||
|
||||
+36
-1
@@ -293,6 +293,9 @@ pub struct ParaStyle {
|
||||
/// bidirectional text (UAX #9). None: from each paragraph's first strong character (Hebrew or
|
||||
/// Arabic: right to left).
|
||||
pub direction: Option<ParaDirection>,
|
||||
/// How leading is measured (Paragraph panel menu): from baseline to baseline, or from the top
|
||||
/// of one line's ideographic em box to the next.
|
||||
pub leading_model: LeadingModel,
|
||||
}
|
||||
|
||||
/// [`ParaStyle`] as saved. [`Justify::Auto`] is written as the alignment it has in the paragraph
|
||||
@@ -324,6 +327,8 @@ struct ParaStyleFile {
|
||||
mojikumi: Mojikumi,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
direction: Option<ParaDirection>,
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
leading_model: LeadingModel,
|
||||
}
|
||||
|
||||
impl From<ParaStyle> for ParaStyleFile {
|
||||
@@ -345,6 +350,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
style_name,
|
||||
mojikumi,
|
||||
direction,
|
||||
leading_model,
|
||||
..
|
||||
} = p;
|
||||
Self {
|
||||
@@ -360,6 +366,7 @@ impl From<ParaStyle> for ParaStyleFile {
|
||||
style_name,
|
||||
mojikumi,
|
||||
direction,
|
||||
leading_model,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,9 +385,23 @@ impl From<ParaStyleFile> for ParaStyle {
|
||||
style_name,
|
||||
mojikumi,
|
||||
direction,
|
||||
leading_model,
|
||||
..
|
||||
} = f;
|
||||
Self { justify, left_indent, right_indent, first_line_indent, space_before, space_after, hyphenate, tabs, style_name, mojikumi, direction }
|
||||
Self {
|
||||
justify,
|
||||
left_indent,
|
||||
right_indent,
|
||||
first_line_indent,
|
||||
space_before,
|
||||
space_after,
|
||||
hyphenate,
|
||||
tabs,
|
||||
style_name,
|
||||
mojikumi,
|
||||
direction,
|
||||
leading_model,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,6 +413,20 @@ pub enum ParaDirection {
|
||||
RightToLeft,
|
||||
}
|
||||
|
||||
/// How a paragraph's leading is measured.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum LeadingModel {
|
||||
/// From one line's baseline to the next's: a line's leading is the space above it, and area
|
||||
/// type's first baseline follows Area Type Options › First Baseline.
|
||||
#[default]
|
||||
RomanBaseline,
|
||||
/// From the top of one line's ideographic em box (the right side, in vertical type) to the
|
||||
/// next's: a line's leading is the space below it, and area type's first line touches the top
|
||||
/// of the frame. Japanese layout's usual model.
|
||||
EmBoxTop,
|
||||
}
|
||||
|
||||
/// How Japanese punctuation is spaced (JLREQ 3.1). Full-width punctuation is half a glyph and half
|
||||
/// a space: an opening bracket's space before it, a closing bracket's, a comma's or a full stop's
|
||||
/// after it.
|
||||
|
||||
@@ -355,7 +355,8 @@ pub fn encode(doc: &Document, format: &str, p: &Value) -> Result<Vec<u8>> {
|
||||
}
|
||||
|
||||
/// Like [`encode`], also returning the encoder's warnings (PDF and SVG: options not applied yet,
|
||||
/// features approximated or left out; the other formats have none).
|
||||
/// features approximated or left out; every format that draws type: fonts written in the fallback
|
||||
/// font).
|
||||
pub fn encode_with_warnings(doc: &Document, format: &str, p: &Value) -> Result<(Vec<u8>, Vec<String>)> {
|
||||
let f = super::writable(C, Some(format), None)?;
|
||||
encode_all(doc, f.id, p)?.single(f)
|
||||
@@ -364,6 +365,19 @@ pub fn encode_with_warnings(doc: &Document, format: &str, p: &Value) -> Result<(
|
||||
/// [`encode`], with every file the export writes.
|
||||
pub fn encode_all(doc: &Document, format: &str, p: &Value) -> Result<Encoded> {
|
||||
let f = super::writable(C, Some(format), None)?;
|
||||
let mut enc = encode_files(doc, f, p)?;
|
||||
// Formats that draw type: missing fonts come out in the fallback font (PDF and SVG say so
|
||||
// themselves: SVG only when it outlines or embeds fonts).
|
||||
if (f.raster || matches!(f.id, "eps" | "emf" | "wmf"))
|
||||
&& let Some(w) = crate::cmd::fonts::substitution_warning(doc)
|
||||
{
|
||||
enc.warnings.push(w);
|
||||
}
|
||||
Ok(enc)
|
||||
}
|
||||
|
||||
/// [`encode_all`] without the font substitution warning.
|
||||
fn encode_files(doc: &Document, f: &Format, p: &Value) -> Result<Encoded> {
|
||||
let doc = &*doc.without_edit_modes();
|
||||
let n = doc.artboards.len();
|
||||
// SVG reads its own `useArtboards` (an SVG option).
|
||||
@@ -374,7 +388,7 @@ pub fn encode_all(doc: &Document, format: &str, p: &Value) -> Result<Encoded> {
|
||||
if let Some(o) = q.as_object_mut() {
|
||||
o.remove("useArtboards");
|
||||
}
|
||||
return encode_all(&single_artboard(doc, bounds, "Art"), f.id, &q);
|
||||
return encode_files(&single_artboard(doc, bounds, "Art"), f, &q);
|
||||
}
|
||||
let bytes = match f.id {
|
||||
"vectorcraft" => super::native::encode(C, f, doc, p)?,
|
||||
|
||||
@@ -276,6 +276,7 @@ pub(super) fn encode_carrying(cmd: &str, doc: &Document, p: &Value, native: impl
|
||||
}
|
||||
let r = super::super::rasterfx::export_pdf_with_report(flat.as_ref().unwrap_or(doc), &opts).map_err(|e| pdf_error(cmd, e))?;
|
||||
warnings.extend(r.warnings);
|
||||
warnings.extend(crate::cmd::fonts::substitution_warning(doc));
|
||||
Ok((r.bytes, warnings))
|
||||
}
|
||||
|
||||
|
||||
@@ -166,5 +166,11 @@ pub(super) fn encode(doc: &Document, p: &Value, compressed: bool) -> Result<Enco
|
||||
}
|
||||
enc.files.push((artboard, if compressed { vectorcraft_svg::compress_bytes(&bytes) } else { bytes }));
|
||||
}
|
||||
// Live type names its fonts; outlines and embedded fonts are the fallback font's.
|
||||
if (opts.outline_text || opts.embed_fonts)
|
||||
&& let Some(w) = crate::cmd::fonts::substitution_warning(doc)
|
||||
{
|
||||
enc.warnings.push(w);
|
||||
}
|
||||
Ok(enc)
|
||||
}
|
||||
@@ -67,3 +67,40 @@ fn load_options_read_text_and_layers() {
|
||||
let d = LoadOptions::default();
|
||||
assert_eq!((d.text_as, d.layers, d.is_partial()), (TextAs::Text, true, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exports_that_draw_type_in_a_missing_font_say_it_is_the_fallback_font() {
|
||||
let page = PdfPage {
|
||||
resources: "/Font << /F1 << /Type /Font /Subtype /Type1 /BaseFont /Zyxwvu-Serif >> >>".into(),
|
||||
..PdfPage::new(200.0, 100.0, "BT /F1 12 Tf 10 50 Td (Hello) Tj ET")
|
||||
};
|
||||
let mut s = Session::new();
|
||||
let r = open(&mut s, &pdf(&[page], None), json!({})).unwrap();
|
||||
let fonts = s.execute("text.fonts", &json!({})).unwrap();
|
||||
let family = fonts[0]["family"].as_str().unwrap().to_string();
|
||||
assert_eq!(fonts[0]["status"], "missing", "{fonts}");
|
||||
assert!(r["warnings"].to_string().contains(&family), "opening lists it: {r}");
|
||||
let warned = |s: &mut Session, p: Value| {
|
||||
let w = s.execute("document.serialize", &p).unwrap()["warnings"].to_string();
|
||||
w.contains(&family) && w.contains(vectorcraft_text::FALLBACK_FAMILY)
|
||||
};
|
||||
for p in [
|
||||
json!({"format": "pdf"}),
|
||||
json!({"format": "pdf", "advanced": {"outlineText": false}}),
|
||||
json!({"format": "png"}),
|
||||
json!({"format": "eps"}),
|
||||
json!({"format": "emf"}),
|
||||
json!({"format": "svg", "outlineText": true}),
|
||||
json!({"format": "svg", "embedFonts": true}),
|
||||
] {
|
||||
assert!(warned(&mut s, p.clone()), "{p}");
|
||||
}
|
||||
// Live SVG type and the native file name the font itself.
|
||||
for p in [json!({"format": "svg", "outlineText": false}), json!({"format": "vectorcraft"}), json!({"format": "txt"})] {
|
||||
assert!(!warned(&mut s, p.clone()), "{p}");
|
||||
}
|
||||
let pdf_export = s.execute("document.exportPdf", &json!({})).unwrap();
|
||||
assert!(pdf_export["warnings"].to_string().contains(&family), "{pdf_export}");
|
||||
s.execute("text.replaceFont", &json!({"from": {"family": family}, "to": {"family": "Source Serif 4"}})).unwrap();
|
||||
assert!(!warned(&mut s, json!({"format": "pdf"})), "replaced: nothing is substituted");
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
//! another everywhere or in the selection, and selecting the text that uses a font. Also the fonts
|
||||
//! available (the bundled and installed ones) and rescanning the installed fonts.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Document, NodeId, NodeKind};
|
||||
use vectorcraft_doc::{Document, Node, NodeId, NodeKind};
|
||||
|
||||
use super::typecmd::refresh_bounds;
|
||||
use super::*;
|
||||
@@ -85,6 +85,41 @@ fn scope(s: &Session, selection_only: bool) -> Result<Vec<NodeId>> {
|
||||
Ok(v)
|
||||
}
|
||||
|
||||
/// The fonts (family, style) of the type in the layers and symbols of `d`.
|
||||
pub(super) fn used_fonts(d: &Document) -> BTreeSet<(String, String)> {
|
||||
let mut fonts = BTreeSet::new();
|
||||
let mut add = |n: &Node| {
|
||||
if let NodeKind::Text(t) = &n.kind {
|
||||
fonts.extend(t.runs.iter().map(|r| (r.style.font_family.clone(), r.style.font_style.clone())));
|
||||
}
|
||||
};
|
||||
d.walk(&mut add);
|
||||
for s in &d.symbols {
|
||||
s.art.walk(&mut add);
|
||||
}
|
||||
fonts
|
||||
}
|
||||
|
||||
/// What an export that draws type (as outlines, embedded fonts or pixels) says when `d` uses font
|
||||
/// families that aren't available: their type is drawn in the fallback font, not the font it names.
|
||||
pub(super) fn substitution_warning(d: &Document) -> Option<String> {
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
let mut missing: Vec<String> = used_fonts(d)
|
||||
.into_iter()
|
||||
.filter(|(family, style)| db.resolve(family, style).is_none_or(|(_, m)| m == vectorcraft_text::FontMatch::Missing))
|
||||
.map(|(family, _)| family)
|
||||
.collect();
|
||||
// Sorted by family: its styles are neighbours.
|
||||
missing.dedup();
|
||||
(!missing.is_empty()).then(|| {
|
||||
format!(
|
||||
"fonts that aren't available were written in the fallback font, {}: {} (install them, or replace them with Find Font)",
|
||||
vectorcraft_text::FALLBACK_FAMILY,
|
||||
missing.join(", ")
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn text(d: &Document, id: NodeId) -> Option<&vectorcraft_doc::TextObject> {
|
||||
match d.node(id).map(|n| &n.kind) {
|
||||
Some(NodeKind::Text(t)) => Some(t),
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
//! report). The packaged document links to the copies (Relink); the open document doesn't change.
|
||||
//! Without a folder (the web, agents) the same files come back as a zip archive.
|
||||
|
||||
use std::collections::{BTreeMap, BTreeSet, HashSet};
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{Document, Node, NodeKind};
|
||||
|
||||
use super::fileio::{create_dir, write_file};
|
||||
use super::*;
|
||||
@@ -51,21 +50,6 @@ fn font_ext(bytes: &[u8]) -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
/// The fonts (family, style) of the type in the layers and symbols of `d`.
|
||||
fn used_fonts(d: &Document) -> BTreeSet<(String, String)> {
|
||||
let mut fonts = BTreeSet::new();
|
||||
let mut add = |n: &Node| {
|
||||
if let NodeKind::Text(t) = &n.kind {
|
||||
fonts.extend(t.runs.iter().map(|r| (r.style.font_family.clone(), r.style.font_style.clone())));
|
||||
}
|
||||
};
|
||||
d.walk(&mut add);
|
||||
for s in &d.symbols {
|
||||
s.art.walk(&mut add);
|
||||
}
|
||||
fonts
|
||||
}
|
||||
|
||||
/// The options of a package.
|
||||
struct Options {
|
||||
copy_links: bool,
|
||||
@@ -123,7 +107,7 @@ fn package(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
let mut files = HashSet::new();
|
||||
lines.push("FONTS".to_string());
|
||||
for (family, style) in used_fonts(&st.doc) {
|
||||
for (family, style) in super::fonts::used_fonts(&st.doc) {
|
||||
let font = format!("{family} {style}");
|
||||
let reason = match db.face(&family, &style) {
|
||||
Some(f) if f.family.eq_ignore_ascii_case(&family) && f.embeddable() => {
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Character / Paragraph",
|
||||
[],
|
||||
None,
|
||||
"{ids?|id?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt, hyphenate?: bool, mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character)}",
|
||||
"{ids?|id?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt, hyphenate?: bool, mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character), leadingModel?: \"romanBaseline\"|\"emBoxTop\" (leading measured baseline to baseline, or em box top to top)}",
|
||||
has_doc,
|
||||
set_format
|
||||
),
|
||||
@@ -113,6 +113,7 @@ fn set_format(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"hyphenate",
|
||||
"mojikumi",
|
||||
"direction",
|
||||
"leadingModel",
|
||||
];
|
||||
if !keys.iter().any(|k| p.get(*k).is_some()) {
|
||||
return Err(bad(C, "nothing to change"));
|
||||
@@ -135,6 +136,14 @@ fn set_format(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
_ => return Err(bad(C, "`direction` must be \"auto\", \"leftToRight\" or \"rightToLeft\"")),
|
||||
}),
|
||||
};
|
||||
let leading_model = match p.get("leadingModel") {
|
||||
None => None,
|
||||
Some(v) => Some(match v.as_str() {
|
||||
Some("romanBaseline") => vectorcraft_doc::LeadingModel::RomanBaseline,
|
||||
Some("emBoxTop") => vectorcraft_doc::LeadingModel::EmBoxTop,
|
||||
_ => return Err(bad(C, "`leadingModel` must be \"romanBaseline\" or \"emBoxTop\"")),
|
||||
}),
|
||||
};
|
||||
s.edit("Character", |d, _| {
|
||||
for id in &ids {
|
||||
let Some(NodeKind::Text(t)) = d.node_mut(*id).map(|n| &mut n.kind) else { continue };
|
||||
@@ -196,6 +205,9 @@ fn set_format(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(v) = direction {
|
||||
para.direction = v;
|
||||
}
|
||||
if let Some(v) = leading_model {
|
||||
para.leading_model = v;
|
||||
}
|
||||
super::typecmd::refresh_bounds(t);
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -13,9 +13,17 @@
|
||||
//!
|
||||
//! Every running app (each browser tab) keeps its copies in an area of its own, `<area>/…`, and
|
||||
//! holds it while it runs: a lock on the area for its lifetime where the store has locks (folders:
|
||||
//! [`FolderStore`]), else a heartbeat it refreshes ([`heartbeat`]; browser storage). Only areas
|
||||
//! nobody holds any more (their app is gone) are offered, and while their copies are restored or
|
||||
//! discarded the area is held, so two apps launched together never both take it.
|
||||
//! [`FolderStore`]), else a heartbeat it refreshes ([`heartbeat`]; browser storage) plus, where the
|
||||
//! store can, an announcement that lasts as long as the app ([`RecoveryStore::announce`]: the
|
||||
//! browser's Web Locks). Only areas nobody holds any more (their app is gone) are offered, and
|
||||
//! while their copies are restored or discarded the area is held, so two apps launched together
|
||||
//! never both take it.
|
||||
//!
|
||||
//! A heartbeat alone can't tell a gone app from one whose timers stopped (a background tab), so
|
||||
//! when unsure an area counts as held, and its app repairs what another app did meanwhile: each
|
||||
//! heartbeat and each recovery save write again the copies missing from its area ([`repair`]), and
|
||||
//! a heartbeat newer than the one another app wrote when taking the area over marks it running
|
||||
//! again.
|
||||
//!
|
||||
//! Each copy is two entries: `<area>/<file>.vectorcraft` (the native document, written as a save
|
||||
//! writes it) and `<area>/<file>.json` (its title, original path and format, and when it was
|
||||
@@ -86,6 +94,17 @@ pub trait RecoveryStore: Send + Sync {
|
||||
fn lock(&self, _area: &str) -> std::result::Result<Lock, String> {
|
||||
Ok(Lock::Unsupported)
|
||||
}
|
||||
/// Stores without locks: also hold area `area` in a way other apps can see that lasts exactly as
|
||||
/// long as this app runs, if the store has one (the browser's Web Locks) → it, until dropped.
|
||||
fn announce(&self, _area: &str) -> Option<Hold> {
|
||||
None
|
||||
}
|
||||
/// Stores without locks: does a running app hold area `area` by [`RecoveryStore::announce`]?
|
||||
/// `None`: the store can't tell (heartbeats alone decide). A store that can tell but isn't sure
|
||||
/// right now says `Some(true)`: a copy kept loses nothing, one deleted may.
|
||||
fn announced(&self, _area: &str) -> Option<bool> {
|
||||
None
|
||||
}
|
||||
/// Tidy away area `area` once it holds no copies and nobody holds it (its lock file and folder).
|
||||
fn remove_area(&self, _area: &str) {}
|
||||
/// The clock heartbeats are judged by (Unix seconds; `None`: none, so no area counts as gone).
|
||||
@@ -96,17 +115,19 @@ pub trait RecoveryStore: Send + Sync {
|
||||
|
||||
/// A store in memory (tests, and hosts without storage). Areas are locked in memory, so sessions
|
||||
/// sharing one store behave like apps sharing a folder; [`MemoryStore::without_locks`] uses
|
||||
/// heartbeats like browser storage, judged by a clock tests set ([`MemoryStore::set_now`]).
|
||||
/// heartbeats like browser storage, judged by a clock tests set ([`MemoryStore::set_now`]), and
|
||||
/// [`MemoryStore::announcing`] adds announcements like the browser's Web Locks.
|
||||
pub struct MemoryStore {
|
||||
entries: Mutex<BTreeMap<String, Vec<u8>>>,
|
||||
held: Arc<Mutex<BTreeSet<String>>>,
|
||||
locks: bool,
|
||||
announces: bool,
|
||||
now: Mutex<Option<i64>>,
|
||||
}
|
||||
|
||||
impl Default for MemoryStore {
|
||||
fn default() -> Self {
|
||||
Self { entries: Default::default(), held: Default::default(), locks: true, now: Mutex::new(Some(1_000_000)) }
|
||||
Self { entries: Default::default(), held: Default::default(), locks: true, announces: false, now: Mutex::new(Some(1_000_000)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +137,19 @@ impl MemoryStore {
|
||||
Self { locks: false, ..Self::default() }
|
||||
}
|
||||
|
||||
/// A store without locks whose apps also announce the areas they hold for as long as they run
|
||||
/// (as the browser's Web Locks do).
|
||||
pub fn announcing() -> Self {
|
||||
Self { announces: true, ..Self::without_locks() }
|
||||
}
|
||||
|
||||
fn hold(&self, area: &str) -> Option<Hold> {
|
||||
if !self.held.lock().unwrap_or_else(|e| e.into_inner()).insert(area.to_string()) {
|
||||
return None;
|
||||
}
|
||||
Some(Box::new(MemoryHold { held: self.held.clone(), area: area.to_string() }))
|
||||
}
|
||||
|
||||
/// Set the clock heartbeats are judged by.
|
||||
pub fn set_now(&self, t: i64) {
|
||||
*self.now.lock().unwrap_or_else(|e| e.into_inner()) = Some(t);
|
||||
@@ -160,10 +194,16 @@ impl RecoveryStore for MemoryStore {
|
||||
if !self.locks {
|
||||
return Ok(Lock::Unsupported);
|
||||
}
|
||||
if !self.held.lock().unwrap_or_else(|e| e.into_inner()).insert(area.to_string()) {
|
||||
return Ok(Lock::Busy);
|
||||
Ok(self.hold(area).map_or(Lock::Busy, Lock::Held))
|
||||
}
|
||||
fn announce(&self, area: &str) -> Option<Hold> {
|
||||
if !self.announces {
|
||||
return None;
|
||||
}
|
||||
Ok(Lock::Held(Box::new(MemoryHold { held: self.held.clone(), area: area.to_string() })))
|
||||
self.hold(area)
|
||||
}
|
||||
fn announced(&self, area: &str) -> Option<bool> {
|
||||
self.announces.then(|| self.held.lock().unwrap_or_else(|e| e.into_inner()).contains(area))
|
||||
}
|
||||
fn now(&self) -> Option<i64> {
|
||||
*self.now.lock().unwrap_or_else(|e| e.into_inner())
|
||||
@@ -288,8 +328,11 @@ struct Own {
|
||||
/// The store it is in (copies are removed from there even after the preference moves on).
|
||||
store: Arc<dyn RecoveryStore>,
|
||||
area: String,
|
||||
/// The lock held for the session's lifetime; none in stores with heartbeats.
|
||||
/// What holds the area for the session's lifetime: its lock, else its announcement (stores
|
||||
/// without locks that have them).
|
||||
hold: Option<Hold>,
|
||||
/// Held with a heartbeat (stores without locks).
|
||||
beats: bool,
|
||||
}
|
||||
|
||||
/// The session's recovery store settings and its own area ([`crate::Session::recovery`]).
|
||||
@@ -300,9 +343,10 @@ pub struct Recovery {
|
||||
/// The folder the desktop app keeps copies in when the `recoveryFolder` preference is empty.
|
||||
default_folder: Option<String>,
|
||||
own: Option<Own>,
|
||||
/// Gone apps' areas this session took over by heartbeat (stores without locks), so its own
|
||||
/// fresh heartbeat there doesn't make them look running.
|
||||
adopted: BTreeSet<String>,
|
||||
/// Gone apps' areas this session took over by heartbeat (stores without locks), with the
|
||||
/// heartbeat it wrote there: that one doesn't make them look running, a newer one does (their
|
||||
/// app was only paused and came back).
|
||||
adopted: BTreeMap<String, i64>,
|
||||
}
|
||||
|
||||
impl Recovery {
|
||||
@@ -354,31 +398,52 @@ fn stale_after(s: &Session) -> i64 {
|
||||
(i64::from(s.prefs.autosave_interval.max(1)) * 180).max(MIN_STALE)
|
||||
}
|
||||
|
||||
/// Record that `area`'s app runs (stores without locks).
|
||||
fn beat(store: &dyn RecoveryStore, area: &str) -> std::result::Result<(), String> {
|
||||
/// Record that `area`'s app runs (stores without locks) → the heartbeat written.
|
||||
fn beat(store: &dyn RecoveryStore, area: &str) -> std::result::Result<i64, String> {
|
||||
let now = store.now().ok_or("no clock to keep a heartbeat by")?;
|
||||
store.write(&format!("{area}/{BEAT}"), now.to_string().as_bytes())
|
||||
store.write(&format!("{area}/{BEAT}"), now.to_string().as_bytes())?;
|
||||
Ok(now)
|
||||
}
|
||||
|
||||
/// Has `area`'s app said it runs within `stale` seconds (stores without locks)? Without a clock
|
||||
/// every app counts as running.
|
||||
fn beating(store: &dyn RecoveryStore, area: &str, stale: i64) -> bool {
|
||||
/// Has `area`'s app said it runs within `stale` seconds (stores without locks)? `mine`: the
|
||||
/// heartbeat this session wrote there itself when taking the area over, which doesn't count.
|
||||
/// Without a clock every app counts as running.
|
||||
fn beating(store: &dyn RecoveryStore, area: &str, stale: i64, mine: Option<i64>) -> bool {
|
||||
let Some(now) = store.now() else { return true };
|
||||
let at = store.read(&format!("{area}/{BEAT}")).ok().and_then(|b| String::from_utf8(b).ok()).and_then(|t| t.trim().parse::<i64>().ok());
|
||||
at.is_some_and(|t| now.saturating_sub(t) <= stale)
|
||||
at.is_some_and(|t| now.saturating_sub(t) <= stale && Some(t) != mine)
|
||||
}
|
||||
|
||||
/// Refresh this session's heartbeat in a store without locks (the app does this every
|
||||
/// [`HEARTBEAT_EVERY`] seconds). Best effort: a missed beat only lets another app offer the copies
|
||||
/// once three intervals have passed.
|
||||
pub fn heartbeat(s: &Session) {
|
||||
if let Some(own) = s.recovery.own.as_ref().filter(|o| o.hold.is_none()) {
|
||||
/// Refresh this session's hold on its area (the app does this every [`HEARTBEAT_EVERY`] seconds,
|
||||
/// so also on its first frame after its timers were paused): its heartbeat in a store without
|
||||
/// locks, and its copies ([`repair`]) → the documents whose copies went missing (write them now).
|
||||
/// Best effort: a missed beat only lets another app offer the copies once three intervals have
|
||||
/// passed.
|
||||
pub fn heartbeat(s: &mut Session) -> Vec<u64> {
|
||||
if let Some(own) = s.recovery.own.as_ref().filter(|o| o.beats) {
|
||||
let _ = beat(own.store.as_ref(), &own.area);
|
||||
}
|
||||
repair(s)
|
||||
}
|
||||
|
||||
/// Forget this session's copies that are missing from its area, so the next recovery save writes
|
||||
/// them again → their documents' uids. Another app removes them only when it took this one for
|
||||
/// gone (its heartbeat stopped while its timers were paused, as browsers do to background tabs); a
|
||||
/// copy it restored is its own now, so both are kept. A store that can't be listed changes nothing.
|
||||
pub fn repair(s: &mut Session) -> Vec<u64> {
|
||||
let Some(names) = s.recovery.own.as_ref().and_then(|o| o.store.list().ok()) else { return vec![] };
|
||||
let mut lost = vec![];
|
||||
for st in &mut s.docs {
|
||||
if st.recovery.as_ref().is_some_and(|c| !names.iter().any(|n| n.strip_suffix(DOC_EXT) == Some(c.file.as_str()))) {
|
||||
st.recovery = None;
|
||||
lost.push(st.uid);
|
||||
}
|
||||
}
|
||||
lost
|
||||
}
|
||||
|
||||
/// This session's area in `store`, taken now if it has none there yet: a fresh area, held for the
|
||||
/// session's lifetime (locked, or with a heartbeat).
|
||||
/// session's lifetime (locked, or with a heartbeat and an announcement where the store has them).
|
||||
pub fn claim(s: &mut Session, store: &Arc<dyn RecoveryStore>) -> Result<String> {
|
||||
if let Some(own) = &s.recovery.own {
|
||||
if own.store.location() == store.location() {
|
||||
@@ -394,15 +459,15 @@ pub fn claim(s: &mut Session, store: &Arc<dyn RecoveryStore>) -> Result<String>
|
||||
if taken.contains(&area) {
|
||||
continue;
|
||||
}
|
||||
let hold = match store.lock(&area).map_err(EngineError::Other)? {
|
||||
Lock::Held(h) => Some(h),
|
||||
let (hold, beats) = match store.lock(&area).map_err(EngineError::Other)? {
|
||||
Lock::Held(h) => (Some(h), false),
|
||||
Lock::Busy => continue,
|
||||
Lock::Unsupported => {
|
||||
beat(store.as_ref(), &area).map_err(EngineError::Other)?;
|
||||
None
|
||||
(store.announce(&area), true)
|
||||
}
|
||||
};
|
||||
s.recovery.own = Some(Own { store: store.clone(), area: area.clone(), hold });
|
||||
s.recovery.own = Some(Own { store: store.clone(), area: area.clone(), hold, beats });
|
||||
return Ok(area);
|
||||
}
|
||||
Err(EngineError::Other("no free recovery area".into()))
|
||||
@@ -413,7 +478,7 @@ pub fn release(s: &mut Session) {
|
||||
for st in &mut s.docs {
|
||||
st.recovery = None;
|
||||
}
|
||||
let Some(Own { store, area, hold }) = s.recovery.own.take() else { return };
|
||||
let Some(Own { store, area, hold, .. }) = s.recovery.own.take() else { return };
|
||||
let mine = |n: &String| n.split_once('/').is_some_and(|(a, _)| a == area);
|
||||
for name in store.list().unwrap_or_default().iter().filter(|n| mine(n)) {
|
||||
let _ = store.remove(name);
|
||||
@@ -531,6 +596,8 @@ fn fresh_name(area: &str, stem: &str, taken: &[String]) -> String {
|
||||
/// when it has none and a copy is needed) → (jobs, skipped: `[{title, reason}]` for modified
|
||||
/// documents that get none).
|
||||
pub fn jobs(s: &mut Session, store: &Arc<dyn RecoveryStore>) -> Result<(Vec<RecoveryJob>, Vec<Value>)> {
|
||||
// Copies another app removed are written again.
|
||||
repair(s);
|
||||
let skipped: Vec<Value> = s
|
||||
.documents()
|
||||
.iter()
|
||||
@@ -628,7 +695,9 @@ enum Owner {
|
||||
|
||||
/// Whose `area` of `store` is. A gone app's area is held by the caller (its lock in `hold` until
|
||||
/// dropped) and, with `take` in a store without locks, taken over with a fresh heartbeat, so
|
||||
/// another app leaves it alone meanwhile.
|
||||
/// another app leaves it alone meanwhile. In a store without locks an area is gone only when
|
||||
/// nothing says its app runs: no announcement (or the store can't tell) and no heartbeat for three
|
||||
/// intervals but the one this session wrote taking it over.
|
||||
fn owner(s: &mut Session, store: &dyn RecoveryStore, area: &str, hold: &mut Vec<Hold>, take: bool) -> Owner {
|
||||
if s.recovery.own.as_ref().is_some_and(|o| o.area == area && o.store.location() == store.location()) {
|
||||
return Owner::Mine;
|
||||
@@ -640,14 +709,12 @@ fn owner(s: &mut Session, store: &dyn RecoveryStore, area: &str, hold: &mut Vec<
|
||||
}
|
||||
Ok(Lock::Busy) | Err(_) => Owner::Running,
|
||||
Ok(Lock::Unsupported) => {
|
||||
if !s.recovery.adopted.contains(area) && beating(store, area, stale_after(s)) {
|
||||
if store.announced(area).unwrap_or(false) || beating(store, area, stale_after(s), s.recovery.adopted.get(area).copied()) {
|
||||
return Owner::Running;
|
||||
}
|
||||
if take {
|
||||
// Best effort: without it another app might offer the copies too, which loses
|
||||
// nothing.
|
||||
let _ = beat(store, area);
|
||||
s.recovery.adopted.insert(area.to_string());
|
||||
// Best effort: without it another app might offer the copies too, which loses nothing.
|
||||
if take && let Ok(t) = beat(store, area) {
|
||||
s.recovery.adopted.insert(area.to_string(), t);
|
||||
}
|
||||
Owner::Gone
|
||||
}
|
||||
|
||||
@@ -408,6 +408,31 @@ fn reshape_area(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
mod area_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn leading_model_is_set_per_paragraph_and_saved_only_when_top_to_top() {
|
||||
use vectorcraft_doc::LeadingModel;
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let id = s.execute("text.create", &json!({"x": 10, "y": 10, "text": "一\n二", "area": {"width": 200, "height": 100}})).unwrap()["id"]
|
||||
.as_u64()
|
||||
.unwrap();
|
||||
let text = |s: &Session| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => (**t).clone(),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
assert_eq!(text(&s).para.leading_model, LeadingModel::RomanBaseline);
|
||||
s.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
assert!(s.execute("text.setFormat", &json!({"leadingModel": "middle"})).is_err());
|
||||
let before = text(&s).cached_bounds;
|
||||
s.execute("text.setFormat", &json!({"leadingModel": "emBoxTop"})).unwrap();
|
||||
let t = text(&s);
|
||||
assert_eq!(t.para.leading_model, LeadingModel::EmBoxTop);
|
||||
assert_ne!(t.cached_bounds, before, "the first line moves up to the frame's top");
|
||||
assert_eq!(serde_json::to_value(&t.para).unwrap()["leading_model"], "emBoxTop");
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(serde_json::to_value(&text(&s).para).unwrap().get("leading_model").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_type_is_composed_with_line_end_half_width_punctuation() {
|
||||
use vectorcraft_doc::Mojikumi;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! Data Recovery: `file.recovery.save/list/restore/discard`, copies removed on save, revert and
|
||||
//! close, complex documents skipped, each app's own area (another running app's copies are never
|
||||
//! offered: locks, heartbeats), and the folder store with real file locks.
|
||||
//! offered: locks, heartbeats, announcements; a paused app repairs its copies), and the folder
|
||||
//! store with real file locks.
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -175,7 +176,7 @@ fn heartbeats_hold_areas_where_the_store_has_no_locks() {
|
||||
store.set_now(10_000 + 359);
|
||||
assert!(offered(&mut b).is_empty());
|
||||
// A beats (as the app does every minute): fresh again.
|
||||
cmd::recovery::heartbeat(&a);
|
||||
cmd::recovery::heartbeat(&mut a);
|
||||
store.set_now(10_000 + 359 + 300);
|
||||
assert!(offered(&mut b).is_empty());
|
||||
assert_eq!(restored(b.execute("file.recovery.restore", &json!({})).unwrap()), 0);
|
||||
@@ -203,6 +204,71 @@ fn heartbeats_hold_areas_where_the_store_has_no_locks() {
|
||||
assert_eq!(offered(&mut b), ["Untitled-1"]);
|
||||
}
|
||||
|
||||
/// Issue #367: a tab whose timers were paused (a background tab) long enough for its heartbeat to
|
||||
/// go stale, while another tab discards the copies it takes for crash leftovers.
|
||||
#[test]
|
||||
fn a_paused_app_writes_its_copies_again_and_is_running_again() {
|
||||
let store = Arc::new(MemoryStore::without_locks());
|
||||
let mut a = session_in(&store);
|
||||
a.execute("file.recovery.save", &json!({})).unwrap();
|
||||
let a_file = format!("{}/Untitled-1-1", a.recovery.own_area().unwrap());
|
||||
let mut b = relaunch(&store);
|
||||
b.prefs.autosave_interval = 1;
|
||||
assert!(b.execute("file.recovery.discard", &json!({})).unwrap()["discarded"].as_array().unwrap().is_empty());
|
||||
// A is paused past three minutes: with heartbeats alone, B can't tell it from a crash.
|
||||
store.set_now(1_000_000 + 186);
|
||||
assert_eq!(b.execute("file.recovery.discard", &json!({})).unwrap()["discarded"], json!([a_file.clone()]));
|
||||
assert!(copies(store.as_ref()).is_empty());
|
||||
// A resumes: its heartbeat finds the copy gone and the next save writes it again, unchanged
|
||||
// document or not.
|
||||
store.set_now(1_000_000 + 200);
|
||||
assert_eq!(cmd::recovery::heartbeat(&mut a), [a.doc().unwrap().uid]);
|
||||
assert!(a.doc().unwrap().recovery.is_none());
|
||||
let r = a.execute("file.recovery.save", &json!({})).unwrap();
|
||||
assert_eq!(r["saved"][0]["file"], a_file.as_str(), "{r}");
|
||||
assert_eq!(copies(store.as_ref()), ["Untitled-1-1"]);
|
||||
assert!(cmd::recovery::heartbeat(&mut a).is_empty(), "nothing missing any more");
|
||||
// A's heartbeat is newer than the one B wrote taking the area over: A runs again for B.
|
||||
let l = b.execute("file.recovery.list", &json!({})).unwrap();
|
||||
assert_eq!((l["copies"][0]["file"].as_str(), l["copies"][0]["running"].as_bool()), (Some(a_file.as_str()), Some(true)));
|
||||
assert!(b.execute("file.recovery.discard", &json!({})).unwrap()["discarded"].as_array().unwrap().is_empty());
|
||||
assert!(b.execute("file.recovery.discard", &json!({"file": a_file})).is_err());
|
||||
// A recovery save alone repairs too (no heartbeat in between).
|
||||
store.set_now(1_000_000 + 600);
|
||||
let mut c = relaunch(&store);
|
||||
c.prefs.autosave_interval = 1;
|
||||
c.execute("file.recovery.discard", &json!({})).unwrap();
|
||||
assert!(copies(store.as_ref()).is_empty());
|
||||
assert_eq!(a.execute("file.recovery.save", &json!({})).unwrap()["saved"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(copies(store.as_ref()), ["Untitled-1-1"]);
|
||||
}
|
||||
|
||||
/// Issue #367 where the store can tell a paused app from a gone one (the browser's Web Locks): the
|
||||
/// paused app's copies are never taken, however old its heartbeat.
|
||||
#[test]
|
||||
fn announced_areas_stay_held_while_their_app_is_paused() {
|
||||
let store = Arc::new(MemoryStore::announcing());
|
||||
let mut a = session_in(&store);
|
||||
a.execute("file.recovery.save", &json!({})).unwrap();
|
||||
let a_file = format!("{}/Untitled-1-1", a.recovery.own_area().unwrap());
|
||||
store.set_now(1_000_000 + 3600);
|
||||
let mut b = relaunch(&store);
|
||||
assert!(offered(&mut b).is_empty());
|
||||
assert!(b.execute("file.recovery.discard", &json!({})).unwrap()["discarded"].as_array().unwrap().is_empty());
|
||||
assert_eq!(restored(b.execute("file.recovery.restore", &json!({})).unwrap()), 0);
|
||||
assert!(b.execute("file.recovery.discard", &json!({"file": a_file})).unwrap_err().to_string().contains("running"));
|
||||
assert_eq!(copies(store.as_ref()), ["Untitled-1-1"]);
|
||||
// A crashes: the browser releases its lock, and its copies are offered once its heartbeat is
|
||||
// stale too.
|
||||
drop(a);
|
||||
assert_eq!(offered(&mut b), ["Untitled-1"]);
|
||||
assert_eq!(restored(b.execute("file.recovery.restore", &json!({})).unwrap()), 1);
|
||||
// B's area is announced in turn.
|
||||
let mut c = relaunch(&store);
|
||||
store.set_now(1_000_000 + 7200);
|
||||
assert!(offered(&mut c).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn folder_areas_are_locked_by_running_apps() {
|
||||
let dir = std::env::temp_dir().join(format!("vc-recovery-locks-{}", std::process::id()));
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
use krilla::geom::{Point as KPoint, Transform};
|
||||
use krilla::page::PageSettings;
|
||||
use krilla::text::{Font, TextDirection};
|
||||
use kurbo::Shape;
|
||||
use vectorcraft_doc::{Document, NodeKind, TextObject};
|
||||
|
||||
use crate::*;
|
||||
|
||||
const SOURCE_SANS: &[u8] = include_bytes!("../../../assets/fonts/SourceSans3-Regular.ttf");
|
||||
const SOURCE_SERIF: &[u8] = include_bytes!("../../../assets/fonts/SourceSerif4-Regular.ttf");
|
||||
|
||||
/// A 300 × 200 pt page with `lines` of (x, y from the top, size, text) in Source Sans 3, and the
|
||||
/// same rotated 90° when `rotated`.
|
||||
@@ -157,21 +159,73 @@ fn a_glyph_whose_unicode_names_another_letter_stays_outlined() {
|
||||
assert!(r.warnings.iter().any(|w| w.contains("differ from the installed font")), "{:?}", r.warnings);
|
||||
}
|
||||
|
||||
/// Source Sans 3 renamed `SourceSans9-Regular` (a font no machine has installed).
|
||||
fn uninstalled_font() -> Vec<u8> {
|
||||
let mut bytes = SOURCE_SANS.to_vec();
|
||||
let utf16: Vec<u8> = "SourceSans3-Regular".encode_utf16().flat_map(u16::to_be_bytes).collect();
|
||||
let renamed16: Vec<u8> = "SourceSans9-Regular".encode_utf16().flat_map(u16::to_be_bytes).collect();
|
||||
for (from, to) in [(b"SourceSans3-Regular".to_vec(), b"SourceSans9-Regular".to_vec()), (utf16, renamed16)] {
|
||||
let mut i = 0;
|
||||
while let Some(at) = bytes[i..].windows(from.len()).position(|w| w == from.as_slice()) {
|
||||
bytes[i + at..i + at + from.len()].copy_from_slice(&to);
|
||||
i += at + from.len();
|
||||
/// `font` with each of `names` (`from`, `to`, the same length) replaced, in ASCII and UTF-16.
|
||||
fn renamed(font: &[u8], names: &[(&str, &str)]) -> Vec<u8> {
|
||||
let mut bytes = font.to_vec();
|
||||
let utf16 = |s: &str| s.encode_utf16().flat_map(u16::to_be_bytes).collect::<Vec<u8>>();
|
||||
for &(from, to) in names {
|
||||
assert_eq!(from.len(), to.len());
|
||||
for (from, to) in [(from.as_bytes().to_vec(), to.as_bytes().to_vec()), (utf16(from), utf16(to))] {
|
||||
let mut i = 0;
|
||||
while let Some(at) = bytes[i..].windows(from.len()).position(|w| w == from.as_slice()) {
|
||||
bytes[i + at..i + at + from.len()].copy_from_slice(&to);
|
||||
i += at + from.len();
|
||||
}
|
||||
}
|
||||
}
|
||||
bytes
|
||||
}
|
||||
|
||||
/// Source Sans 3 renamed `SourceSans9-Regular` (a font no machine has installed).
|
||||
fn uninstalled_font() -> Vec<u8> {
|
||||
renamed(SOURCE_SANS, &[("SourceSans3-Regular", "SourceSans9-Regular")])
|
||||
}
|
||||
|
||||
/// Source Serif 4 renamed `SourceSerif9-Regular`, family Source Serif 9: a serif font that isn't
|
||||
/// installed (the fallback font, Source Sans 3, is a sans).
|
||||
fn uninstalled_serif() -> Vec<u8> {
|
||||
renamed(SOURCE_SERIF, &[("SourceSerif4", "SourceSerif9"), ("Source Serif 4", "Source Serif 9")])
|
||||
}
|
||||
|
||||
/// A page with `text` in `font` (24 pt, at 20, 50).
|
||||
fn one_line_pdf(font: Vec<u8>, text: &str) -> Vec<u8> {
|
||||
let mut pdf = krilla::Document::new();
|
||||
let mut page = pdf.start_page_with(PageSettings::from_wh(300.0, 200.0).unwrap());
|
||||
let mut s = page.surface();
|
||||
s.draw_text(KPoint::from_xy(20.0, 50.0), Font::new(font.into(), 0).unwrap(), 24.0, text, false, TextDirection::Auto);
|
||||
s.finish();
|
||||
page.finish();
|
||||
pdf.finish().unwrap()
|
||||
}
|
||||
|
||||
/// The outlines text imported as (`textAs: outlines`), as one path.
|
||||
fn outlines(d: &Document) -> kurbo::BezPath {
|
||||
let mut all = kurbo::BezPath::new();
|
||||
d.walk(|n| {
|
||||
if let NodeKind::Path { path, .. } = &n.kind {
|
||||
all.extend(path.to_bezpath().iter());
|
||||
}
|
||||
});
|
||||
all
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outlined_text_in_a_missing_font_keeps_the_embedded_glyphs() {
|
||||
let outlined = |bytes: &[u8]| {
|
||||
let r = import_with_report(bytes, &ImportOptions { text_as: TextAs::Outlines, ..Default::default() }).unwrap();
|
||||
assert!(texts(&r.document).is_empty());
|
||||
outlines(&r.document)
|
||||
};
|
||||
let missing = outlined(&one_line_pdf(uninstalled_serif(), "Serif Hamburg"));
|
||||
let installed = outlined(&one_line_pdf(SOURCE_SERIF.to_vec(), "Serif Hamburg"));
|
||||
let fallback = outlined(&one_line_pdf(SOURCE_SANS.to_vec(), "Serif Hamburg"));
|
||||
let (m, i, f) = (missing.bounding_box(), installed.bounding_box(), fallback.bounding_box());
|
||||
assert!(m.width() > 50.0, "{m:?}");
|
||||
let near = |a: kurbo::Rect, b: kurbo::Rect| (a.x0 - b.x0).abs() + (a.x1 - b.x1).abs() + (a.y0 - b.y0).abs() + (a.y1 - b.y1).abs() < 0.01;
|
||||
assert!(near(m, i), "the file's own serif glyphs: {m:?} vs {i:?}");
|
||||
assert!(!near(m, f), "not the fallback font's: {m:?} vs {f:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_in_a_missing_font_stays_live_type() {
|
||||
for stroke_only in [false, true] {
|
||||
|
||||
@@ -77,6 +77,8 @@ pub struct FontFace {
|
||||
location: Location,
|
||||
/// [`Self::variations`] for the shaper (advances, kerning, feature variations).
|
||||
pub(crate) instance: Option<harfrust::ShaperInstance>,
|
||||
/// [`Self::ideographic_centre`], read once: layout asks for it per glyph.
|
||||
ideographic_centre: std::sync::OnceLock<f64>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for FontFace {
|
||||
@@ -170,8 +172,10 @@ impl FontFace {
|
||||
/// vertical metrics (an ideograph's cell), else the usual 0.38 (the box running from 0.12 em
|
||||
/// below the baseline to 0.88 em above it).
|
||||
pub fn ideographic_centre(&self) -> f64 {
|
||||
let gid = ['国', 'あ', '一'].into_iter().map(|c| self.glyph_for(c)).find(|g| *g != 0);
|
||||
gid.and_then(|g| self.vertical_glyph(g)).map_or(0.38, |(advance, origin)| (origin - advance * 0.5) / self.upem)
|
||||
*self.ideographic_centre.get_or_init(|| {
|
||||
let gid = ['国', 'あ', '一'].into_iter().map(|c| self.glyph_for(c)).find(|g| *g != 0);
|
||||
gid.and_then(|g| self.vertical_glyph(g)).map_or(0.38, |(advance, origin)| (origin - advance * 0.5) / self.upem)
|
||||
})
|
||||
}
|
||||
/// Glyph id for `c` (0 = .notdef).
|
||||
pub fn glyph_for(&self, c: char) -> u32 {
|
||||
@@ -813,6 +817,7 @@ fn make_face(bytes: FontBytes, index: u32, spec: FaceStyle, path: Option<std::pa
|
||||
bytes,
|
||||
index,
|
||||
path,
|
||||
ideographic_centre: std::sync::OnceLock::new(),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::ops::Range;
|
||||
|
||||
use kurbo::{Affine, BezPath, ParamCurve, ParamCurveArclen, PathEl, PathSeg, Point, Rect, Shape, Vec2};
|
||||
use unicode_bidi::{BidiInfo, Level};
|
||||
use vectorcraft_doc::{CharStyle, Justify, Mojikumi, ParaDirection, ParaStyle, PathEffect, TextKind, TextObject};
|
||||
use vectorcraft_doc::{CharStyle, Justify, LeadingModel, Mojikumi, ParaDirection, ParaStyle, PathEffect, TextKind, TextObject};
|
||||
|
||||
use crate::composer::{Breakpoint, compose};
|
||||
use crate::fontdb::FontDb;
|
||||
@@ -581,11 +581,14 @@ struct Metrics {
|
||||
lead: f64,
|
||||
cap: f64,
|
||||
xh: f64,
|
||||
/// Height of the top of the ideographic em box above the baseline.
|
||||
top: f64,
|
||||
}
|
||||
|
||||
impl Metrics {
|
||||
fn of(g: &SGlyph) -> Self {
|
||||
Self { asc: g.ascent, desc: g.descent, lead: g.leading, cap: g.cap, xh: g.xh }
|
||||
let em = g.face.units_per_em() * g.sy;
|
||||
Self { asc: g.ascent, desc: g.descent, lead: g.leading, cap: g.cap, xh: g.xh, top: (g.face.ideographic_centre() + 0.5) * em }
|
||||
}
|
||||
fn max(g: &[SGlyph]) -> Option<Self> {
|
||||
let mut it = g.iter();
|
||||
@@ -596,6 +599,7 @@ impl Metrics {
|
||||
lead: m.lead.max(g.leading),
|
||||
cap: m.cap.max(g.cap),
|
||||
xh: m.xh.max(g.xh),
|
||||
top: m.top.max(Self::of(g).top),
|
||||
}))
|
||||
}
|
||||
/// Distance from the frame top to the first baseline.
|
||||
@@ -622,6 +626,9 @@ struct Pen<'r> {
|
||||
fb_min: f64,
|
||||
/// Further spans at the current baseline (text wrapping on both sides of an object).
|
||||
queued: Vec<(f64, f64, f64)>,
|
||||
/// Leading measured from em box top to em box top: where the next line's em box top goes.
|
||||
model: LeadingModel,
|
||||
next_top: Option<f64>,
|
||||
}
|
||||
|
||||
impl Pen<'_> {
|
||||
@@ -630,7 +637,7 @@ impl Pen<'_> {
|
||||
/// The `bool` is true for a further span at the previous line's baseline.
|
||||
fn place(&mut self, est: Metrics, ind_l: f64, ind_r: f64) -> Option<(f64, f64, f64, bool)> {
|
||||
let Some(regions) = self.regions else {
|
||||
let b = self.prev.map_or(0.0, |b| b + est.lead + self.pending);
|
||||
let b = self.prev.map_or(0.0, |b| self.next_baseline(b, est));
|
||||
return Some((b, f64::NEG_INFINITY, f64::INFINITY, false));
|
||||
};
|
||||
if !self.queued.is_empty() {
|
||||
@@ -640,8 +647,9 @@ impl Pen<'_> {
|
||||
loop {
|
||||
let r = regions.get(self.ri)?;
|
||||
let mut baseline = match self.prev {
|
||||
None if self.model == LeadingModel::EmBoxTop => r.top() + est.top.max(self.fb_min),
|
||||
None => r.top() + est.first_baseline(self.fb, self.fb_min),
|
||||
Some(b) => b + est.lead + self.pending,
|
||||
Some(b) => self.next_baseline(b, est),
|
||||
};
|
||||
loop {
|
||||
if baseline + est.desc > r.bottom() + 0.01 {
|
||||
@@ -675,6 +683,18 @@ impl Pen<'_> {
|
||||
fn bottom(&self) -> f64 {
|
||||
self.regions.and_then(|r| r.get(self.ri)).map_or(f64::INFINITY, |r| r.bottom())
|
||||
}
|
||||
/// The baseline of the line after the one at `prev`, for a line of metrics `est`.
|
||||
fn next_baseline(&self, prev: f64, est: Metrics) -> f64 {
|
||||
match (self.model, self.next_top) {
|
||||
(LeadingModel::EmBoxTop, Some(top)) => top + est.top + self.pending,
|
||||
_ => prev + est.lead + self.pending,
|
||||
}
|
||||
}
|
||||
/// A line was set at `baseline` with metrics `m`: where the next one goes from.
|
||||
fn settled(&mut self, baseline: f64, m: Metrics) {
|
||||
self.prev = Some(baseline);
|
||||
self.next_top = Some(baseline - m.top + m.lead);
|
||||
}
|
||||
}
|
||||
|
||||
/// Advance of a tab at pen position `x`: up to the next stop after it (explicit stops first, then
|
||||
@@ -873,7 +893,7 @@ fn compose_para(cx: &Ctx<'_>, sg: &[SGlyph], para: &ParaStyle, pen: &Pen<'_>) ->
|
||||
let w = x1 - x0 - ind_l - para.right_indent;
|
||||
widths.push(w);
|
||||
acc += w.max(1.0);
|
||||
sim.prev = Some(b);
|
||||
sim.settled(b, m);
|
||||
sim.pending = 0.0;
|
||||
if acc > total * 1.6 + 4.0 * w.max(1.0) {
|
||||
break;
|
||||
@@ -887,7 +907,17 @@ fn compose_para(cx: &Ctx<'_>, sg: &[SGlyph], para: &ParaStyle, pen: &Pen<'_>) ->
|
||||
}
|
||||
|
||||
fn flow(cx: &mut Ctx<'_>, paras: &[Range<usize>], para: &ParaStyle, regions: Option<&[Region]>) {
|
||||
let mut pen = Pen { regions, ri: 0, prev: None, pending: 0.0, fb: cx.opts.first_baseline, fb_min: cx.opts.first_baseline_min, queued: vec![] };
|
||||
let mut pen = Pen {
|
||||
regions,
|
||||
ri: 0,
|
||||
prev: None,
|
||||
pending: 0.0,
|
||||
fb: cx.opts.first_baseline,
|
||||
fb_min: cx.opts.first_baseline_min,
|
||||
queued: vec![],
|
||||
model: para.leading_model,
|
||||
next_top: None,
|
||||
};
|
||||
'paras: for (pi, pr) in paras.iter().enumerate() {
|
||||
let text = cx.text;
|
||||
let bidi = para_bidi(text.get(pr.clone()).unwrap_or_default(), para.direction);
|
||||
@@ -899,8 +929,10 @@ fn flow(cx: &mut Ctx<'_>, paras: &[Range<usize>], para: &ParaStyle, regions: Opt
|
||||
let wakan = if para.mojikumi == Mojikumi::LineEndHalf { space_japanese_and_latin(&mut sg) } else { vec![] };
|
||||
let pm = {
|
||||
let (asc, desc, lead) = style_metrics(cx.db, cx.style_at(pr.start));
|
||||
let (cap, xh) = cap_x_heights(cx.db, cx.style_at(pr.start));
|
||||
Metrics { asc, desc, lead, cap, xh }
|
||||
let st = cx.style_at(pr.start);
|
||||
let (cap, xh) = cap_x_heights(cx.db, st);
|
||||
let centre = cx.db.face(&st.font_family, &st.font_style).map_or(EM_CENTER, |f| f.ideographic_centre());
|
||||
Metrics { asc, desc, lead, cap, xh, top: (centre + 0.5) * st.size * st.v_scale / 100.0 }
|
||||
};
|
||||
if pi > 0 {
|
||||
pen.pending += para.space_before;
|
||||
@@ -930,6 +962,10 @@ fn flow(cx: &mut Ctx<'_>, paras: &[Range<usize>], para: &ParaStyle, regions: Opt
|
||||
let m = Metrics::max(&sg[i..end]).unwrap_or(pm);
|
||||
baseline += if same_baseline || (pen.regions.is_none() && first_in_region) {
|
||||
0.0
|
||||
} else if pen.model == LeadingModel::EmBoxTop {
|
||||
// The em box top is fixed (the frame's top, or the line above's): the baseline
|
||||
// hangs from it by this line's tallest em box.
|
||||
if first_in_region { m.top.max(pen.fb_min) - est.top.max(pen.fb_min) } else { m.top - est.top }
|
||||
} else if first_in_region {
|
||||
m.first_baseline(pen.fb, pen.fb_min) - est.first_baseline(pen.fb, pen.fb_min)
|
||||
} else {
|
||||
@@ -1077,7 +1113,7 @@ fn flow(cx: &mut Ctx<'_>, paras: &[Range<usize>], para: &ParaStyle, regions: Opt
|
||||
glyph_end: cx.out.glyphs.len(),
|
||||
avail: if regions.is_some() { (ax0, ax1) } else { (start_x, x_end) },
|
||||
});
|
||||
pen.prev = Some(baseline);
|
||||
pen.settled(baseline, m);
|
||||
// Further spans of this line band share the settled baseline.
|
||||
for q in &mut pen.queued {
|
||||
q.0 = baseline;
|
||||
|
||||
@@ -522,3 +522,38 @@ fn justified_japanese_lines_spread_between_characters() {
|
||||
assert!(solid(at) && solid(at + 1), "A–B–C set solid");
|
||||
assert!(g[at].origin.x - g[at - 1].origin.x > a + 0.1, "二–A takes its share");
|
||||
}
|
||||
|
||||
/// Leading measured from em box top to em box top (Japanese layout's model): area type's first line
|
||||
/// touches the frame's top; lines of one size are as far apart as with baseline-to-baseline leading;
|
||||
/// with sizes mixed, a line's leading is the space below it (baseline leading: above it).
|
||||
#[test]
|
||||
fn em_box_top_leading_hangs_lines_from_the_line_above() {
|
||||
use vectorcraft_doc::{LeadingModel, TextRun};
|
||||
let st = |size: f64| CharStyle { size, leading: Some(size * 1.5), ..style(size) };
|
||||
let lay = |t: &TextObject, m: LeadingModel| {
|
||||
let mut t = t.clone();
|
||||
t.para.leading_model = m;
|
||||
layout(db(), &t)
|
||||
};
|
||||
// The em box top: 0.88 em above the baseline (fonts without vertical metrics).
|
||||
let top = |size: f64| 0.88 * size;
|
||||
let one_size = area("一行目\n二行目\n三行目", st(20.0), Rect::new(0.0, 0.0, 300.0, 300.0), Justify::Left);
|
||||
let (roman, em) = (lay(&one_size, LeadingModel::RomanBaseline), lay(&one_size, LeadingModel::EmBoxTop));
|
||||
assert!((em.lines[0].baseline - top(20.0)).abs() < 0.01, "the first line's em box touches the top: {}", em.lines[0].baseline);
|
||||
assert!((roman.lines[0].baseline - em.lines[0].baseline).abs() > 0.5, "baseline leading keeps Area Type Options' first baseline");
|
||||
for l in [&roman, &em] {
|
||||
assert!((l.lines[1].baseline - l.lines[0].baseline - 30.0).abs() < 0.01 && (l.lines[2].baseline - l.lines[1].baseline - 30.0).abs() < 0.01);
|
||||
}
|
||||
// 40 pt over 20 pt (leading 60 and 30).
|
||||
let mut mixed = point("", st(40.0));
|
||||
mixed.runs = vec![TextRun { text: "大\n".into(), style: st(40.0) }, TextRun { text: "小".into(), style: st(20.0) }];
|
||||
let roman = lay(&mixed, LeadingModel::RomanBaseline);
|
||||
assert!((roman.lines[1].baseline - roman.lines[0].baseline - 30.0).abs() < 0.01, "the small line's leading, above it");
|
||||
let em = lay(&mixed, LeadingModel::EmBoxTop);
|
||||
let want = -top(40.0) + 60.0 + top(20.0);
|
||||
assert!(
|
||||
(em.lines[1].baseline - em.lines[0].baseline - want).abs() < 0.01,
|
||||
"the big line's leading, below it: {} vs {want}",
|
||||
em.lines[1].baseline - em.lines[0].baseline
|
||||
);
|
||||
}
|
||||
@@ -2953,3 +2953,7 @@
|
||||
— {n} characters from another font — {n} caracteres de otra fuente
|
||||
[Normal Character Style] [Estilo de carácter normal]
|
||||
[Normal Paragraph Style] [Estilo de párrafo normal]
|
||||
|
||||
# Leading model (Paragraph panel menu, East Asian options).
|
||||
Top-to-Top Leading Interlineado de superior a superior
|
||||
Bottom-to-Bottom Leading Interlineado de inferior a inferior
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -11,6 +11,7 @@
|
||||
About VectorCraft VectorCraft について
|
||||
All Scripts すべての文字
|
||||
Any Kind すべての種類
|
||||
Bottom-to-Bottom Leading 欧文ベースライン基準の行送り
|
||||
Decorative 装飾
|
||||
Favorites お気に入り
|
||||
Japanese 日本語
|
||||
@@ -25,6 +26,7 @@
|
||||
Serif / Mincho 明朝・セリフ
|
||||
Settings… 環境設定…
|
||||
Language 表示言語
|
||||
Top-to-Top Leading 仮想ボディの上基準の行送り
|
||||
UI Brightness UI の明るさ
|
||||
Dark 暗い
|
||||
Medium Dark やや暗い
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -243,6 +243,7 @@
|
||||
Blur 模糊
|
||||
Bottom 下
|
||||
Bottom in Front 下方置前
|
||||
Bottom-to-Bottom Leading 基线至基线行距
|
||||
Bottom: 下:
|
||||
Bounds 边界
|
||||
Bounds (Fill Proportionally) 边界 (按比例填满)
|
||||
@@ -2567,6 +2568,7 @@
|
||||
Tools 工具
|
||||
Top 上
|
||||
Top in Front 上方在前
|
||||
Top-to-Top Leading 上缘至上缘行距
|
||||
Top: 上:
|
||||
Total Width: 总宽度:
|
||||
Touch Type Tool 修饰文字工具
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -254,6 +254,7 @@
|
||||
Blur 模糊
|
||||
Bottom 下
|
||||
Bottom in Front 下方置前
|
||||
Bottom-to-Bottom Leading 基線至基線行距
|
||||
Bottom: 下:
|
||||
Bounds 邊界
|
||||
Bounds (Fill Proportionally) 邊界 (按比例填滿)
|
||||
@@ -2647,6 +2648,7 @@
|
||||
Tools 工具
|
||||
Top 上
|
||||
Top in Front 上方在前
|
||||
Top-to-Top Leading 上緣至上緣行距
|
||||
Top: 上:
|
||||
Total Width: 總寬度:
|
||||
Touch Type Tool 觸控文字工具
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -276,7 +276,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[
|
||||
"tool.options",
|
||||
"Tool Options…",
|
||||
"",
|
||||
"{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), gradient → the Gradient panel (window.panel), eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values})",
|
||||
"{tool: id} what double-clicking a tool button opens: hand → fits the artboard in the window (view.fitArtboard), zoom → 100% (view.actualSize), rotate|scale|reflect|shear → that Object › Transform dialog (dialog `rotate`, `scale`, `reflect` or `shear`; error `nothing selected` without a selection), selection|directSelection|groupSelection → the Move dialog (dialog `move`; the same error), gradient → the Gradient panel (window.panel), eyedropper → Eyedropper Options (dialog `eyedropperOptions`, fields sampleSize, pickUp, apply; OK runs eyedropper.setOptions), printTiling → resets the print tiling (print.tiling.set {reset: true}), warp|twirl|pucker|bloat|scallop|crystallize|wrinkle → that tool's Tool Options (dialog `liquifyOptions`, fields tool, width, height, angle, intensity %, usePressure, detail, simplify, simplifyOn, rate, complexity, horizontal %, vertical %, affectAnchors, affectIn, affectOut, showBrush; OK runs tool.setOption {tool, values})",
|
||||
),
|
||||
(
|
||||
"ui.colorGuideOptions",
|
||||
|
||||
@@ -140,7 +140,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
|
||||
pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
let has = text_style(app).is_some();
|
||||
let style = text_style(app);
|
||||
let has = style.is_some();
|
||||
let hidden: bool = pstate(ui.ctx(), "pa-hide-options");
|
||||
if menu_item(ui, if hidden { tl!("Show Options") } else { tl!("Hide Options") }, true, false) {
|
||||
set_pstate(ui.ctx(), "pa-hide-options", !hidden);
|
||||
@@ -149,6 +150,18 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
for l in [tl!("Roman Hanging Punctuation"), tl!("Justification…"), tl!("Hyphenation…")] {
|
||||
menu_item(ui, l, false, false);
|
||||
}
|
||||
// How leading is measured (Japanese layout measures it from em box top to em box top), with
|
||||
// the East Asian options.
|
||||
if app.session.prefs.show_east_asian_options {
|
||||
ui.separator();
|
||||
let top_to_top = style.as_ref().is_some_and(|(_, p)| p.leading_model == vectorcraft_doc::LeadingModel::EmBoxTop);
|
||||
if menu_item(ui, tl!("Top-to-Top Leading"), has, top_to_top) {
|
||||
format(app, json!({"leadingModel": "emBoxTop"}));
|
||||
}
|
||||
if menu_item(ui, tl!("Bottom-to-Bottom Leading"), has, has && !top_to_top) {
|
||||
format(app, json!({"leadingModel": "romanBaseline"}));
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
menu_item(ui, tl!("Single-line Composer"), false, false);
|
||||
menu_item(ui, tl!("Every-line Composer"), false, true);
|
||||
@@ -157,7 +170,7 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
para_cmd(app, "text.setStyle", json!({"justify": "auto"}));
|
||||
format(
|
||||
app,
|
||||
json!({"leftIndent": 0, "rightIndent": 0, "firstLineIndent": 0, "spaceBefore": 0, "spaceAfter": 0, "hyphenate": false, "direction": "auto"}),
|
||||
json!({"leftIndent": 0, "rightIndent": 0, "firstLineIndent": 0, "spaceBefore": 0, "spaceAfter": 0, "hyphenate": false, "direction": "auto", "leadingModel": "romanBaseline"}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
//! left copies behind (a crash). The copies themselves are the engine's
|
||||
//! ([`vectorcraft_engine::cmd::recovery`]).
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_engine::cmd::recovery;
|
||||
use vectorcraft_engine::cmd::recovery::{self, RecoveryStore};
|
||||
|
||||
use crate::VectorcraftApp;
|
||||
use crate::background::{self, Writer};
|
||||
@@ -36,7 +38,14 @@ pub fn frame(app: &mut VectorcraftApp, now: f64) -> Option<f64> {
|
||||
tick(app, now);
|
||||
if !(0.0..recovery::HEARTBEAT_EVERY).contains(&(now - app.recovery.beat)) {
|
||||
app.recovery.beat = now;
|
||||
recovery::heartbeat(&app.session);
|
||||
// Copies another app removed while this one's timers were paused (it took this one for
|
||||
// gone) are written again at once.
|
||||
let lost = recovery::heartbeat(&mut app.session);
|
||||
if !lost.is_empty()
|
||||
&& let Some(store) = recovery::store(&app.session)
|
||||
{
|
||||
write(app, &store, |uid| lost.contains(&uid));
|
||||
}
|
||||
}
|
||||
let interval = f64::from(app.session.prefs.autosave_interval.max(1)) * 60.0;
|
||||
let next = app.recovery.last.map(|t| t + interval - now)?;
|
||||
@@ -77,10 +86,16 @@ pub fn tick(app: &mut VectorcraftApp, now: f64) -> usize {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
write(app, &store, |_| true)
|
||||
}
|
||||
|
||||
/// Start a recovery copy of every document that needs one and `pick` picks (by uid) → how many
|
||||
/// were started.
|
||||
fn write(app: &mut VectorcraftApp, store: &Arc<dyn RecoveryStore>, pick: impl Fn(u64) -> bool) -> usize {
|
||||
recovery::forget_clean(&mut app.session);
|
||||
let jobs = match recovery::jobs(&mut app.session, &store) {
|
||||
let jobs = match recovery::jobs(&mut app.session, store) {
|
||||
// A document whose save or last copy is still being written waits for the next round.
|
||||
Ok((jobs, _)) => jobs.into_iter().filter(|j| !app.background.busy_with(j.uid)).collect::<Vec<_>>(),
|
||||
Ok((jobs, _)) => jobs.into_iter().filter(|j| pick(j.uid) && !app.background.busy_with(j.uid)).collect::<Vec<_>>(),
|
||||
Err(e) => {
|
||||
app.status(format!("Couldn't save recovery data: {e}"));
|
||||
return 0;
|
||||
|
||||
@@ -211,7 +211,9 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
// A key the tool claims (Esc with a loaded place cursor) is only the tool's.
|
||||
let claimed = app.session.tool_claims_key(tk, view);
|
||||
let r = app.session.tool_key(tk, Mods::default(), view);
|
||||
if claimed {
|
||||
// Enter also takes what the tool asks of the UI: Rotate, Scale, Reflect and Shear open
|
||||
// their dialog with it.
|
||||
if claimed || (k == Key::Enter && !busy) {
|
||||
crate::canvas::apply_requests(app, r);
|
||||
}
|
||||
if k == Key::Escape && !busy && !claimed {
|
||||
@@ -223,6 +225,19 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context) {
|
||||
app.ui.flyout = None;
|
||||
}
|
||||
}
|
||||
if k == Key::Enter && !busy && !claimed {
|
||||
// Enter with a selection tool opens the Move dialog, as a double-click on its button
|
||||
// does.
|
||||
let tool = app.session.tool_id();
|
||||
if app.ui.dialog.is_none() && crate::canvas::is_selection_tool(tool) {
|
||||
// Nothing selected: it fails and nothing opens (the menu item is disabled then too).
|
||||
let _ = crate::toolbar::open_options(app, tool);
|
||||
}
|
||||
// The Enter that opened a dialog isn't also its OK: dialogs take Enter, this frame too.
|
||||
if app.ui.dialog.is_some() {
|
||||
ctx.input_mut(|i| i.consume_key(Modifiers::NONE, Key::Enter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if typing {
|
||||
@@ -526,6 +541,54 @@ mod tests {
|
||||
assert_eq!(grid(&mut app, &[Key::ArrowLeft, Key::ArrowDown]), (rows, columns + 1));
|
||||
}
|
||||
|
||||
/// Enter opens the tool's dialog: the Move dialog for the selection tools, the tool's own for
|
||||
/// Rotate, Scale, Reflect and Shear. The Enter that opens it isn't also its OK.
|
||||
#[test]
|
||||
fn enter_opens_the_tools_dialog_and_leaves_it_open() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let enter = || egui::Event::Key { key: Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE };
|
||||
// A whole app frame: the shortcuts first, then the UI, where a dialog takes its Enter.
|
||||
let frame = |app: &mut VectorcraftApp, events: Vec<egui::Event>| {
|
||||
let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1280.0, 800.0)));
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, screen_rect, ..Default::default() }, |ui| {
|
||||
app.logic(ui.ctx());
|
||||
app.ui(ui);
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
};
|
||||
let kind = |app: &VectorcraftApp| app.ui.dialog.as_ref().map(|d| d.kind.clone());
|
||||
let steps = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len();
|
||||
app.select_tool("selection");
|
||||
frame(&mut app, vec![enter()]);
|
||||
assert_eq!(kind(&app), None, "nothing is selected");
|
||||
app.session.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 50, "height": 30})).unwrap();
|
||||
for (tool, dialog) in [
|
||||
("selection", "move"),
|
||||
("directSelection", "move"),
|
||||
("groupSelection", "move"),
|
||||
("rotate", "rotate"),
|
||||
("scale", "scale"),
|
||||
("reflect", "reflect"),
|
||||
("shear", "shear"),
|
||||
] {
|
||||
app.select_tool(tool);
|
||||
let before = steps(&app);
|
||||
frame(&mut app, vec![enter()]);
|
||||
assert_eq!(kind(&app).as_deref(), Some(dialog), "{tool}: Enter opens it");
|
||||
frame(&mut app, vec![]);
|
||||
assert_eq!(kind(&app).as_deref(), Some(dialog), "{tool}: and it stays open");
|
||||
assert_eq!(steps(&app), before, "{tool}: the Enter that opened it didn't confirm it");
|
||||
// The next Enter is its OK.
|
||||
frame(&mut app, vec![enter()]);
|
||||
assert_eq!((kind(&app), steps(&app)), (None, before + 1), "{tool}: Enter confirms");
|
||||
}
|
||||
app.select_tool("rectangle");
|
||||
frame(&mut app, vec![enter()]);
|
||||
assert_eq!(kind(&app), None, "another tool has its own Enter");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn comma_and_period_reapply_the_last_colour_and_gradient() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
|
||||
@@ -176,3 +176,25 @@ fn the_timer_asks_for_frames_while_idle() {
|
||||
app.session.prefs.autosave_recovery = false;
|
||||
assert!(recovery::frame(&mut app, 1.0).is_none());
|
||||
}
|
||||
|
||||
/// Issue #367: a tab whose timers were paused (in the background) long enough for another tab to
|
||||
/// take it for gone and discard its copy writes the copy again on its first heartbeat after it
|
||||
/// resumes, even with the timer off (the copy was written by hand).
|
||||
#[test]
|
||||
fn a_resumed_tab_writes_again_the_copies_another_tab_discarded() {
|
||||
let store = Arc::new(MemoryStore::without_locks());
|
||||
let mut a = app_with(&store, Services::default());
|
||||
a.session.prefs.autosave_recovery = false;
|
||||
a.run("file.recovery.save", json!({})).unwrap();
|
||||
recovery::frame(&mut a, 0.0);
|
||||
store.set_now(1_000_000 + 400);
|
||||
let mut b = VectorcraftApp::new(Session::new(), Services { recovery_store: Some(store.clone()), ..Default::default() });
|
||||
b.run("file.recovery.discard", json!({})).unwrap();
|
||||
assert_eq!(copies(&store), 0);
|
||||
store.set_now(1_000_000 + 410);
|
||||
recovery::frame(&mut a, 30.0);
|
||||
assert_eq!(copies(&store), 0, "the store is looked at with the heartbeat, not every frame");
|
||||
recovery::frame(&mut a, 410.0);
|
||||
assert_eq!(copies(&store), 1);
|
||||
assert_eq!(a.ui.status, "Saved recovery data for Untitled-1");
|
||||
}
|
||||
@@ -218,19 +218,21 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
/// the Gradient panel, the Eyedropper's the Eyedropper Options dialog, a Liquify tool's its Tool
|
||||
/// Options dialog, the Blend tool's Blend
|
||||
/// Options; the Print Tiling tool's resets the print tiling. As in the reference app, the Hand
|
||||
/// tool's fits the artboard in the window, the Zoom tool's shows it at 100%, and the Rotate, Scale,
|
||||
/// Reflect and Shear tools' are their Object › Transform dialogs.
|
||||
/// tool's fits the artboard in the window, the Zoom tool's shows it at 100%, the Rotate, Scale,
|
||||
/// Reflect and Shear tools' are their Object › Transform dialogs, and the selection tools' are the
|
||||
/// Move dialog.
|
||||
pub fn open_options(app: &mut VectorcraftApp, tool: &str) -> Result<serde_json::Value, String> {
|
||||
match tool {
|
||||
"hand" => app.run("view.fitArtboard", json!({})),
|
||||
"zoom" => app.run("view.actualSize", json!({})),
|
||||
"rotate" | "scale" | "reflect" | "shear" => {
|
||||
let id = format!("object.{tool}");
|
||||
"rotate" | "scale" | "reflect" | "shear" | "selection" | "directSelection" | "groupSelection" => {
|
||||
let dialog = if crate::canvas::is_selection_tool(tool) { "move" } else { tool };
|
||||
let id = format!("object.{dialog}");
|
||||
if let Some(c) = vectorcraft_engine::find_command(&id) {
|
||||
(c.enabled)(&app.session)?;
|
||||
}
|
||||
crate::menus::invoke(app, &id, json!({}));
|
||||
Ok(json!({ "dialog": tool }))
|
||||
Ok(json!({ "dialog": dialog }))
|
||||
}
|
||||
"gradient" if app.ui.open_panel.as_deref() == Some("gradient") => Ok(json!({ "open": "gradient" })),
|
||||
"gradient" => app.run("window.panel", json!({ "panel": "gradient" })),
|
||||
@@ -538,6 +540,33 @@ pub(crate) mod tests {
|
||||
assert!((b.x0 - 20.0).abs() < 1e-9 && (b.y0 - 0.0).abs() < 1e-9 && (b.width() - 20.0).abs() < 1e-9, "{b:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn double_clicking_a_selection_tool_opens_the_move_dialog() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
// The Selection tool's button is the first one.
|
||||
let selection = frame(&mut app, &ctx, 0.0, vec![])[0];
|
||||
// Nothing selected: Move is disabled, so nothing opens.
|
||||
double_click(&mut app, &ctx, 1.0, selection.center());
|
||||
assert!(app.ui.dialog.is_none());
|
||||
assert_eq!(app.run("tool.options", json!({"tool": "directSelection"})), Err("nothing selected".into()));
|
||||
let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 40, "height": 20})).unwrap()["id"].as_u64().unwrap();
|
||||
double_click(&mut app, &ctx, 2.0, selection.center());
|
||||
assert_eq!(app.ui.dialog.take().map(|d| d.kind), Some("move".to_string()));
|
||||
// The Direct Selection and Group Selection tools open it too.
|
||||
for tool in ["directSelection", "groupSelection"] {
|
||||
app.run("tool.options", json!({"tool": tool})).unwrap();
|
||||
assert_eq!(app.ui.dialog.take().map(|d| d.kind), Some("move".to_string()), "{tool}");
|
||||
}
|
||||
// OK moves the selection by what was typed.
|
||||
app.run("tool.options", json!({"tool": "selection"})).unwrap();
|
||||
app.ui.dialog.as_mut().unwrap().fields.insert("dx".into(), json!("25 pt"));
|
||||
crate::dialogs::confirm(&mut app).unwrap();
|
||||
let b = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().geometric_bounds().unwrap();
|
||||
assert_eq!((b.x0, b.y0), (35.0, 10.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn right_clicking_a_tool_group_opens_its_flyout() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
|
||||
@@ -89,8 +89,11 @@ for `eyedropper` it opens Eyedropper Options, an `eyedropperOptions` dialog (fie
|
||||
`apply`, the attribute trees of `eyedropper.setOptions`) whose `ui.dialog.confirm` runs `eyedropper.setOptions` (what
|
||||
`appearance.copyFrom` copies). For `hand` it fits the artboard in the window (`view.fitArtboard`) and for `zoom` it
|
||||
shows 100% (`view.actualSize`). For `rotate`, `scale`, `reflect` and `shear` it opens the same dialog as Object ›
|
||||
Transform (dialog kind = the tool id), or fails with `nothing selected`. Gradient tool handles snap to
|
||||
anchors, edges and smart guides; Shift constrains them to 45° steps from the `constrainAngle` preference.
|
||||
Transform (dialog kind = the tool id), or fails with `nothing selected`. For `selection`, `directSelection` and
|
||||
`groupSelection` it opens the Move dialog (kind `move`), with the same failure. `ui.key` Enter with one of those seven
|
||||
tools opens its dialog too (nothing happens without a selection), with the transform tools' `origin` at their reference
|
||||
point. Gradient tool handles snap to anchors, edges and smart guides; Shift constrains them to 45° steps from the
|
||||
`constrainAngle` preference.
|
||||
|
||||
Effect dialogs: `engine.execute {command: "effect.dialog", params: {effect, index?, item?}}` opens the `effect` dialog
|
||||
(fields: the effect's parameters, `preview`). With `index` it edits that applied effect of `item` (null: the object's
|
||||
|
||||
@@ -21,6 +21,7 @@ How the web shell (`apps/vectorcraft-web/src/web.rs`) differs from desktop:
|
||||
- **Open** sets `Services::open_async`, which shows `rfd::AsyncFileDialog`. The bytes arrive in `Services::inbox`, which the app drains every frame.
|
||||
- **Save / Save As / Export** go through `Services::download`: a Blob, an object URL and a temporary `<a download>`, all created from Rust. There is no save dialog, so the suggested name becomes the download name.
|
||||
- **Drag-and-drop:** `WebShell` takes the frame's `dropped_files` before the app sees them, reads each with `DroppedFile::bytes_async` and pushes the bytes into the inbox (files dropped on a canvas go to `Services::place_inbox` with their `place::DropAt`: the document they were dropped on, by uid, and the point). A file that arrives after another document became active still lands in its own document, which becomes active again; if that document closed meanwhile, the file is not placed and the status bar says so. (The app's synchronous drop path is compiled out on wasm32.)
|
||||
- **Data Recovery** keeps its copies in `localStorage` (`vectorcraft-recovery/<area>/<name>`, shared by the site's tabs), so tabs can't lock their areas the way desktop apps lock a folder (`RecoveryStore::lock`). Each tab holds its area with a heartbeat it refreshes every minute and, where the browser has Web Locks (secure pages: `https://` or localhost), with a Web Lock named after the area (`apps/vectorcraft-web/src/locks.rs`, through `js_sys::Reflect` since web-sys has them only as an unstable API). The browser releases the lock only when the tab is gone, not while its timers are paused in the background, which a heartbeat can't tell apart (#367). `navigator.locks.query()` is asynchronous, so the shell keeps a snapshot refreshed every 10 seconds (taken once before the first frame); a snapshot older than a minute counts every area as held. An area is offered as a crash's leftovers only when no tab holds its lock and its heartbeat is older than three intervals. Without Web Locks a paused tab can still be taken for gone; it repairs that when it resumes: its next heartbeat (or recovery save) writes again the copies missing from its area, and a heartbeat newer than the one the other tab wrote taking the area over makes the area running again for that tab.
|
||||
- **No control server:** browsers can't listen on TCP. To automate the web build, drive headless Chrome with `--remote-debugging-port`.
|
||||
- Quick smoke test: `"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --headless=new --enable-unsafe-webgpu --screenshot=web.png --window-size=1440,900 --virtual-time-budget=15000 http://127.0.0.1:8766/` (headless Chrome on macOS gets a real WebGPU adapter).
|
||||
|
||||
|
||||
+10
-5
@@ -370,8 +370,10 @@ What a PDF holds comes in as editable art: soft masks become opacity masks (an a
|
||||
the backdrop colour gives Clip, an inverting transfer function Invert), transparency groups keep isolation and knockout,
|
||||
tiling patterns become pattern swatches, patch and triangle mesh shadings become gradient meshes, and gradients keep
|
||||
their stop opacity and stop where the shading doesn't extend. Text becomes point type, one object per run of a line in
|
||||
the file's font (by name; fonts that aren't available are listed in `warnings` and show in the fallback font) —
|
||||
`textAs: "outlines"` keeps glyph outlines instead. Optional content groups (the layers of PDF and PDF-compatible `.ai`
|
||||
the file's font (by name; fonts that aren't available are listed in `warnings` and show in the fallback font, and
|
||||
every export that draws that type — PDF, EPS, EMF/WMF, raster images, SVG with outlined or embedded fonts — says in
|
||||
its `warnings` that it wrote the fallback font) — `textAs: "outlines"` keeps the glyph outlines the file draws instead
|
||||
(its embedded fonts, installed or not). Optional content groups (the layers of PDF and PDF-compatible `.ai`
|
||||
files) become layers with their name, visibility, print state and lock, art that is off coming in as a hidden layer;
|
||||
art outside them goes to a layer per page (except the opaque white page a `.ai` paints under its layers, which isn't art). `layers: false` gives one layer per page of only what shows:
|
||||
|
||||
@@ -1552,9 +1554,12 @@ The copies live in the `recoveryFolder` preference's folder (default: `Data Reco
|
||||
none when the app runs with `VECTORCRAFT_NO_PREFS`) or, on the web, in browser storage.
|
||||
|
||||
Each running app (each browser tab) keeps its copies in an area of its own (`<area>/<name>`): a sub-folder whose
|
||||
`.lock` file it keeps locked while it runs, or on the web an area with a heartbeat it refreshes every minute. Only
|
||||
areas nobody holds are offered: their lock is free, or their heartbeat is older than three intervals (at least three
|
||||
minutes). Several apps running at once (agents' instances included) never see each other's copies as crash leftovers,
|
||||
`.lock` file it keeps locked while it runs, or on the web an area with a heartbeat it refreshes every minute and a Web
|
||||
Lock the browser holds until the tab is gone (where the browser has Web Locks: secure pages). Only areas nobody holds
|
||||
are offered: their lock is free, or no tab holds their Web Lock and their heartbeat is older than three intervals (at
|
||||
least three minutes). A background tab whose timers are paused therefore keeps its copies. Without Web Locks another
|
||||
tab can take such a tab for gone; when it resumes, its next heartbeat or recovery save writes its missing copies
|
||||
again. Several apps running at once (agents' instances included) never see each other's copies as crash leftovers,
|
||||
and an area being restored or discarded is held, so two apps launched together never both take it.
|
||||
|
||||
`file.recovery.list` → `{copies: [{file, title, path, format, saved, open, running}], location}` (`open`: the copy of a
|
||||
|
||||
Reference in new issue
Block a user