strom-research 1.31.0-beta.1 → 1.31.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.cs.md CHANGED
@@ -7,7 +7,7 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
7
7
 
8
8
  ## 1.31.0
9
9
 
10
- *Připravuje se: bety do 1.31.0-beta.1. Oddíl bude úplný s vydáním.*
10
+ *Připravuje se: bety do 1.31.0-beta.2. Oddíl bude úplný s vydáním.*
11
11
 
12
12
  - **`strom repair` už neodstraní práci, kterou poškozená historie skrývá.** Když se dá historie gitu výzkumu číst, ale
13
13
  je starší než jeho záznamy (cloudový disk vrátil starší `.git`, vedle něj kopie iCloudu jako `index 2`), `strom
@@ -22,6 +22,18 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
22
22
  ze kterého běží (dřív každých 16 sekund hlásil chybu). Předání mostu novějšímu stromu je i rychlejší: starý most
23
23
  odpovídá, zatímco se nový strom ověřuje.
24
24
 
25
+ - **Snímek ukládaný ze zobrazovače archivu počká, když prohlížeč jeho kartu nekreslí.** Prohlížeč nekreslí kartu za
26
+ jinou kartou ani v zakrytém či minimalizovaném okně a zobrazovač snímků archivu pak nikdy neohlásil, že má všechny
27
+ dlaždice: ukládání po 30 s vzdalo s „the viewer's tiles did not all come“ (ACTA PUBLICA). Čekání teď počítá jen čas,
28
+ kdy prohlížeč kartu kreslí, a pokračuje, jakmile ji kreslí znovu; karta nekreslená 30 s se ohlásí jako taková. Když
29
+ se zobrazovač mezitím přestránkuje, pod jménem jiného snímku se nic neuloží.
30
+
31
+ - **`strom fetch` ohlásí snímek, který stojí mnoho požadavků, stejně jako `strom connector test`.** Konektor postavený
32
+ před verzí 1.30, který skládá každý snímek z dlaždic (sto požadavků na snímek, hodiny na knihu), stahoval bez varování.
33
+ Teď první snímky stahování agentovi jednou řeknou, kolik stojí jeden snímek a jak dlouho tempem archivu potrvá kniha,
34
+ i jak stahování na pozadí zastavit a co hledat nejdřív (jeden požadavek na snímek). Vychází z vlastního počítání
35
+ stahování: archiv se kvůli tomu na nic dalšího neptá. Říká to i `strom fetch --status` a brief.
36
+
25
37
  - **Drobnosti.** Údaj, jehož ověření uživatel posunul dopředu, je v souboru pro aplikaci Strom označený jako vyžádaný,
26
38
  takže aplikace už znovu nenabízí „Ověřit přednostně“. `strom error --note` skryje i skloňované tvary jmen a míst, která
27
39
  výzkum zná („z Brna“, „v Praze“). `strom task wait --request` najde soubor i tehdy, když je jeho jméno zadané v jiné
package/CHANGELOG.de.md CHANGED
@@ -7,7 +7,7 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
7
7
 
8
8
  ## 1.31.0
9
9
 
10
- *In Vorbereitung: die Betas bis 1.31.0-beta.1. Der Abschnitt ist mit dem Release vollständig.*
10
+ *In Vorbereitung: die Betas bis 1.31.0-beta.2. Der Abschnitt ist mit dem Release vollständig.*
11
11
 
12
12
  - **`strom repair` entfernt keine Arbeit mehr, die eine beschädigte Historie verbirgt.** Ist die Git-Historie einer
13
13
  Forschung lesbar, aber älter als ihre Datensätze (ein Cloud-Laufwerk hat ein älteres `.git` zurückgelegt, daneben
@@ -25,6 +25,20 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
25
25
  Sekunden ein Fehler). Die Übergabe an die Brücke eines neueren strom ist auch schneller: die alte Brücke antwortet
26
26
  weiter, während der neue strom geprüft wird.
27
27
 
28
+ - **Ein Bild aus dem Betrachter eines Archivs wartet, solange der Browser seinen Tab nicht zeichnet.** Ein Browser
29
+ zeichnet nichts in einem Tab hinter einem anderen Tab oder in einem verdeckten oder minimierten Fenster, und der
30
+ Bildbetrachter des Archivs meldete seine Kacheln dann nie als vollständig: Das Speichern gab nach 30 s mit „the
31
+ viewer's tiles did not all come“ auf (ACTA PUBLICA). Das Warten zählt jetzt nur die Zeit, in der der Browser den Tab
32
+ zeichnet, und geht weiter, sobald er ihn wieder zeichnet; ein Tab, der 30 s nicht gezeichnet wird, wird als solcher
33
+ gemeldet. Wird der Betrachter inzwischen umgeblättert, wird nichts unter dem Namen eines anderen Bildes gespeichert.
34
+
35
+ - **`strom fetch` meldet ein Bild, das viele Anfragen kostet, wie `strom connector test`.** Ein Konnektor aus der Zeit
36
+ vor 1.30, der jedes Bild aus Kacheln zusammensetzt (hundert Anfragen pro Bild, Stunden für ein Buch), lud ohne ein
37
+ Wort. Jetzt sagen die ersten Bilder eines Downloads dem Agenten einmal, was ein Bild kostet und wie lange ein Buch im
38
+ Tempo des Archivs dauert, dazu, wie ein Download im Hintergrund angehalten wird und wonach zuerst zu suchen ist (eine
39
+ Anfrage pro Bild). Gezählt wird nur, was der Download selbst sendet: Das Archiv wird dafür nichts weiter gefragt.
40
+ `strom fetch --status` und das Briefing sagen es auch.
41
+
28
42
  - **Kleinigkeiten.** Eine Angabe, deren Prüfung nach vorne gerückt wurde, ist in der Datei für die Strom-App als
29
43
  angefragt markiert, sodass die App nicht noch einmal anbietet, sie vorzuziehen. `strom error --note` verbirgt auch die
30
44
  gebeugten Formen der Namen und Orte, die die Forschung kennt (tschechisch *z Brna*, *v Praze*). `strom task wait
package/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ The changes of each version in short. The full notes and the install lines are o
7
7
 
8
8
  ## 1.31.0
9
9
 
10
- *In preparation: the betas up to 1.31.0-beta.1. The section is complete with the release.*
10
+ *In preparation: the betas up to 1.31.0-beta.2. The section is complete with the release.*
11
11
 
12
12
  - **`strom repair` no longer removes work a damaged history hides.** When a research's git history is readable but
13
13
  older than its records (a cloud drive put back an older `.git`, iCloud's copies such as `index 2` beside it), `strom
@@ -22,6 +22,18 @@ The changes of each version in short. The full notes and the install lines are o
22
22
  update removed the strom it runs from (before, it kept failing every 16 seconds). The hand-over to a newer strom's
23
23
  bridge is quicker too: the old bridge keeps answering while the new strom is checked.
24
24
 
25
+ - **An image saved from an archive's viewer waits while the browser does not draw its tab.** A browser draws nothing
26
+ in a tab behind another tab or in a window covered or minimized, and the archive's viewer then never reported its
27
+ tiles as all there: saving gave up after 30 s with "the viewer's tiles did not all come" (ACTA PUBLICA). The wait
28
+ now counts only the time the browser draws the tab and goes on once it draws it again; a tab not drawn for 30 s is
29
+ said as that. When the viewer is paged meanwhile, nothing is saved under another image's name.
30
+
31
+ - **`strom fetch` says an image that costs many requests, as `strom connector test` does.** A connector built before
32
+ 1.30 that puts each image together from tiles (a hundred requests an image, hours for a book) fetched without a word.
33
+ Now the first images of a fetch tell the agent once what one image costs and how long a book takes at the archive's
34
+ pace, with how to stop a fetch in the background and what to look for first (one request an image). Taken from the
35
+ fetch's own count: nothing more is asked of the archive. `strom fetch --status` and the brief say it too.
36
+
25
37
  - **Smaller things.** A fact whose verification the user moved to the front is marked as asked for in the file for the
26
38
  Strom app, so the app no longer offers to move it forward again. `strom error --note` also hides the inflected forms of
27
39
  the names and places the research knows ("from Brno" said as *z Brna*). `strom task wait --request` finds the file
package/CHANGELOG.pl.md CHANGED
@@ -7,7 +7,7 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
7
7
 
8
8
  ## 1.31.0
9
9
 
10
- *W przygotowaniu: bety do 1.31.0-beta.1. Sekcja będzie kompletna z wydaniem.*
10
+ *W przygotowaniu: bety do 1.31.0-beta.2. Sekcja będzie kompletna z wydaniem.*
11
11
 
12
12
  - **`strom repair` nie usuwa już pracy ukrytej przez uszkodzoną historię.** Gdy historię gita badania da się odczytać,
13
13
  ale jest starsza niż jego rekordy (dysk w chmurze przywrócił starszy `.git`, obok kopie iCloud takie jak `index 2`),
@@ -23,6 +23,19 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
23
23
  aktualizacja usunęła strom, z którego działa (wcześniej co 16 sekund zgłaszał błąd). Przekazanie mostowi nowszego
24
24
  stroma jest też szybsze: stary most odpowiada, podczas gdy nowy strom jest sprawdzany.
25
25
 
26
+ - **Obraz zapisywany z podglądu skanów archiwum czeka, gdy przeglądarka nie rysuje jego karty.** Przeglądarka nie
27
+ rysuje karty schowanej za inną kartą ani w oknie zasłoniętym lub zminimalizowanym, a podgląd skanów archiwum nigdy
28
+ wtedy nie zgłaszał, że ma wszystkie kafelki: zapisywanie poddawało się po 30 s z komunikatem „the viewer's tiles did
29
+ not all come” (ACTA PUBLICA). Oczekiwanie liczy teraz tylko czas, gdy przeglądarka rysuje kartę, i trwa dalej, gdy
30
+ znów ją rysuje; karta nierysowana przez 30 s jest zgłaszana jako taka. Gdy podgląd w międzyczasie przejdzie do
31
+ innego skanu, nic nie zostanie zapisane pod nazwą innego obrazu.
32
+
33
+ - **`strom fetch` zgłasza obraz, który kosztuje wiele zapytań, tak jak `strom connector test`.** Konektor zbudowany
34
+ przed wersją 1.30, który składa każdy obraz z kafelków (sto zapytań na obraz, godziny na księgę), pobierał bez słowa.
35
+ Teraz pierwsze obrazy pobierania mówią agentowi raz, ile kosztuje jeden obraz i jak długo w tempie archiwum potrwa
36
+ księga, a także jak zatrzymać pobieranie w tle i czego szukać najpierw (jedno zapytanie na obraz). Liczone jest tylko
37
+ to, co samo pobieranie wysyła: archiwum nie jest o nic więcej pytane. Mówią to też `strom fetch --status` i brief.
38
+
26
39
  - **Drobiazgi.** Fakt, którego weryfikację przesunięto na początek, jest w pliku dla aplikacji Strom oznaczony jako
27
40
  zamówiony, więc aplikacja nie proponuje już ponownego przesunięcia. `strom error --note` ukrywa też odmienione
28
41
  formy imion i miejsc znanych badaniu (czeskie *z Brna*, *v Praze*). `strom task wait --request` znajduje plik także
@@ -54,7 +54,7 @@ import { sandboxOf, WITHOUT_CLI, WITHOUT_READERS } from "../core/sandbox.js";
54
54
  import { cliMissing } from "../core/agentcli.js";
55
55
  import { WEB_SOFT } from "../core/metrics.js";
56
56
  import { indexBriefLines } from "../core/indexfirst.js";
57
- import { activeFetches, endedFetches, withRegistered } from "../core/fetching.js";
57
+ import { activeFetches, endedFetches, heavySaid, withRegistered } from "../core/fetching.js";
58
58
  /** The hosts of a connector, as its manifest names them (a wildcard without its star). */
59
59
  function connectorHosts(shared, name) {
60
60
  try {
@@ -738,13 +738,13 @@ function fetchingLines(tree) {
738
738
  const active = activeFetches(root);
739
739
  // an interrupted one: what it registered as the research has it
740
740
  const has = (rs) => new Set(tree.list("media").filter((m) => m.recordset === rs && !m.part && !m.retracted && m.image !== undefined).map((m) => m.image));
741
- const out = active.map((m) => `- ${m.recordset}: ${m.registered}/${m.images.length} images registered (${m.background ? `in the background${m.task ? `, for ${m.task}` : ""}` : "in the foreground"}) — strom read ${m.recordset} --images ${runsArg(m.images)} reads them as they come; not fetched again`);
741
+ const out = active.map((m) => `- ${m.recordset}: ${m.registered}/${m.images.length} images registered (${m.background ? `in the background${m.task ? `, for ${m.task}` : ""}` : "in the foreground"}) — strom read ${m.recordset} --images ${runsArg(m.images)} reads them as they come; not fetched again${m.heavy ? `\n · ${heavySaid(m.heavy, m.background ? `strom fetch --stop ${m.recordset}` : undefined)}` : ""}`);
742
742
  for (const e of endedFetches(root).map((x) => withRegistered(x, has(x.recordset))))
743
743
  if (e.missed.length && !active.some((m) => m.recordset === e.recordset))
744
744
  out.push(e.interrupted
745
745
  ? // its process ended without a word (killed, the computer stopped): what it registered stays
746
746
  `- ${e.recordset}: a fetch ${e.background ? "in the background" : "in the foreground"} was interrupted (${e.interrupted === "gone" ? "its process ended without a word" : "nothing heard of it for long"}) with images ${runs(e.missed)} not fetched — strom fetch ${e.connector} ${shellArg(e.book)} --images ${runsArg(e.missed)} --recordset ${e.recordset}${e.background ? " --background" : ""} if they are needed (what is registered is not fetched again)`
747
- : `- ${e.recordset}: a fetch ${e.background ? "in the background" : "in the foreground"} ended with images ${runs(e.missed)} not fetched${e.stopped ? ` (stopped: ${e.stopped})` : ""} — strom fetch ${e.connector} ${shellArg(e.book)} --images ${runsArg(e.missed)} --recordset ${e.recordset} if they are needed`);
747
+ : `- ${e.recordset}: a fetch ${e.background ? "in the background" : "in the foreground"} ended with images ${runs(e.missed)} not fetched${e.stopped ? ` (stopped: ${e.stopped})` : ""} — strom fetch ${e.connector} ${shellArg(e.book)} --images ${runsArg(e.missed)} --recordset ${e.recordset} if they are needed`, ...(e.heavy ? [` · ${heavySaid(e.heavy)}`] : []));
748
748
  return out;
749
749
  }
750
750
  /** What the user put in the shared inbox, waiting to be registered — by folder (one download each). */
@@ -37,7 +37,7 @@ import { PROFILES } from "../agents/profiles.js";
37
37
  import { bareHost, byHandOnly, changedSinceConsent, codeWarning, consentRequired, connectorHash, connectorsDir, directNetwork, ensurePluginsDir, findConnector, hostWarning, imageProblem, INTERFACE, listConnectors, loadConsents, lockedCode, MANIFEST, missingConsents, NAME_RE, readManifest, routeOf, sandboxedRun, treeBrowserConnectors, routesOf, ROUTES, runConnector, saveConsents, scanConnectors, suggestName, } from "../core/connector.js";
38
38
  import { registerImages, wakeWaiting } from "./media.js";
39
39
  import { autoCommit } from "../cli/commit.js";
40
- import { activeFetches, askStop, BACKGROUND_ENV, backgroundLog, backgroundOf, endedFetches, FETCH_BATCH, FETCH_SILENT_MS, isRunWorker, markEnded, markFetch, processAlive, watchBackground, withRegistered } from "../core/fetching.js";
40
+ import { activeFetches, askStop, BACKGROUND_ENV, backgroundLog, backgroundOf, BOOK_GUESS, endedFetches, FETCH_BATCH, FETCH_SILENT_MS, HEAVY_IMAGE, heavySaid, isRunWorker, markEnded, markFetch, processAlive, spanSaid, watchBackground, withRegistered } from "../core/fetching.js";
41
41
  import { finishAsked } from "../core/clock.js";
42
42
  import { isLiveWorker } from "../core/workers.js";
43
43
  import { stromLauncher } from "../core/self.js";
@@ -1740,19 +1740,6 @@ async function testWith(ctx, c, request, max) {
1740
1740
  ...(later(r, "the same command").exitCode ? { exitCode: EXIT.later } : r.stopped && !r.books.length && !r.images.length && !r.located.length ? { exitCode: 1 } : {}),
1741
1741
  };
1742
1742
  }
1743
- /** More requests than this for one whole image: tiles, most likely — hours for a book (DISCOVERY.md, step 2). */
1744
- export const HEAVY_IMAGE = 10;
1745
- /** A book of this many images, for the time a book takes when the book's own number is not known here. */
1746
- const BOOK_GUESS = 200;
1747
- /** A time said: seconds, minutes, else hours. */
1748
- function spanSaid(ms) {
1749
- const secs = Math.round(ms / 1000);
1750
- if (secs < 90)
1751
- return `${secs} s`;
1752
- if (secs < 90 * 60)
1753
- return `${Math.round(secs / 60)} min`;
1754
- return `${Math.round(secs / 360) / 10} h`;
1755
- }
1756
1743
  /**
1757
1744
  * A test's fetch whose one image cost more than HEAVY_IMAGE requests (as this run's measure counted them: what went to
1758
1745
  * the archive's hosts), or that got no image whole within a cap past it: said to the agent with what it means for a
@@ -1766,21 +1753,67 @@ function heavyImage(ctx, c, book, r, sent, max, human) {
1766
1753
  if (got ? sent / got <= HEAVY_IMAGE : !capped)
1767
1754
  return undefined;
1768
1755
  const per = got ? sent / got : undefined;
1769
- const least = per ?? max;
1756
+ const cost = heavyCost(ctx, c, per ?? max, per === undefined, bookImagesOf(ctx, c, book, r.books), human);
1757
+ return {
1758
+ text: lines(`⚠ ${per !== undefined ? `one image cost ${nf(per)} requests` : `not one image whole within ${max} requests: one costs more (--max up to 50 to see how many)`} ${cost.said}`, " before tiles look again for one request an image (DISCOVERY.md, step 2): the portal's own link to the full image, a download of the whole book (ZIP, PDF), a IIIF image (full/max)", " tiles only when nothing else exists: then say in README.md what an image costs, and tell the user how long a book takes"),
1759
+ data: { ...(per !== undefined ? { perImage: cost.data.perImage } : { atLeast: max }), ...(cost.data.bookImages !== undefined ? { bookImages: cost.data.bookImages } : {}), bookMs: cost.data.bookMs },
1760
+ };
1761
+ }
1762
+ /**
1763
+ * What an image of `least` requests means at the connector's pace (`atLeast`: it costs more than that): the rest of
1764
+ * the sentence after the cost ("(tiles, most likely) — at its pace … an image, … for a book"), and its data. `size`:
1765
+ * the book's own number of images where it is known, else a book of BOOK_GUESS.
1766
+ */
1767
+ function heavyCost(ctx, c, least, atLeast, size, human) {
1770
1768
  const pace = connectorPace(ctx, c, human);
1771
- const size = bookImagesOf(ctx, c, book, r);
1772
- const n = size ?? BOOK_GUESS;
1773
- const bookMs = requestsSpan(Math.ceil(least * n), pace, [], 0);
1769
+ const bookMs = requestsSpan(Math.ceil(least * (size ?? BOOK_GUESS)), pace, [], 0);
1774
1770
  const imageMs = requestsSpan(Math.ceil(least) + 1, pace, [], 0);
1775
- const cost = per !== undefined ? `one image cost ${nf(per)} requests` : `not one image whole within ${max} requests: one costs more (--max up to 50 to see how many)`;
1776
1771
  return {
1777
- text: lines(`⚠ ${cost} (tiles, most likely) — at its pace (${paceText(pace)}) ${per !== undefined ? "about" : "at least"} ${spanSaid(imageMs)} an image, ${spanSaid(bookMs)} for ${size !== undefined ? `this book's ${size} images` : `a book of ${BOOK_GUESS} images`}`, " before tiles look again for one request an image (DISCOVERY.md, step 2): the portal's own link to the full image, a download of the whole book (ZIP, PDF), a IIIF image (full/max)", " tiles only when nothing else exists: then say in README.md what an image costs, and tell the user how long a book takes"),
1778
- data: { ...(per !== undefined ? { perImage: Math.round(per * 100) / 100 } : { atLeast: max }), ...(size !== undefined ? { bookImages: size } : {}), bookMs },
1772
+ said: `(tiles, most likely) — at its pace (${paceText(pace)}) ${atLeast ? "at least" : "about"} ${spanSaid(imageMs)} an image, ${spanSaid(bookMs)} for ${size !== undefined ? `this book's ${size} images` : `a book of ${BOOK_GUESS} images`}`,
1773
+ data: { perImage: Math.round(least * 100) / 100, ...(size !== undefined ? { bookImages: size } : {}), bookMs },
1774
+ };
1775
+ }
1776
+ /**
1777
+ * strom fetch's own image of many requests (tiles, most likely), said to the agent once a run as connector test says
1778
+ * it — a connector built before that test said it goes on without a word otherwise. From the run's own measure
1779
+ * (FetchMeter): from its second image what each image after the first cost (a manifest, robots.txt asked once at the
1780
+ * start are no image's), a run of one image at its end; nothing is asked of the archive for it. Said on stderr (a
1781
+ * fetch in the background: into its log), its mark carries it (strom fetch --status, the brief), the result's data too.
1782
+ */
1783
+ function heavyFetch(ctx, c, request, recordset, meter, human, say, background) {
1784
+ let first;
1785
+ let found;
1786
+ const tell = (per, books) => {
1787
+ if (found || per <= HEAVY_IMAGE)
1788
+ return;
1789
+ const book = String(request.book);
1790
+ const own = recordset ? ctx.tree().get(recordset)?.images : undefined;
1791
+ const size = Number.isInteger(own) && own > 0 ? own : bookImagesOf(ctx, c, book, books);
1792
+ const cost = heavyCost(ctx, c, per, false, size, human);
1793
+ found = cost.data;
1794
+ say(lines(` ⚠ connector ${c.name}: one image costs ${nf(per)} requests ${cost.said}`, ` this fetch goes on at that pace${background && recordset ? ` in the background — stop it: strom fetch --stop ${recordset}` : ""}`, ` a connector of one request an image first (DISCOVERY.md, step 2): the portal's own link to the full image, a download of the whole book (ZIP, PDF), a IIIF image (full/max) — then strom connector test ${c.name} --fetch ${shellArg(book)} --images 1`) + "\n");
1795
+ return found;
1796
+ };
1797
+ return {
1798
+ /** An image came (`got`: how many so far): from the second on, what one costs. */
1799
+ image(got) {
1800
+ if (found)
1801
+ return undefined;
1802
+ if (got <= 1) {
1803
+ first = meter.requests();
1804
+ return undefined;
1805
+ }
1806
+ return first === undefined ? undefined : tell((meter.requests() - first) / (got - 1), []);
1807
+ },
1808
+ /** The run ended: one image only — what the whole run cost. */
1809
+ end(r) {
1810
+ return !found && r.images.length === 1 ? tell(meter.requests() + (r.pages ?? 0) || r.requests, r.books) : undefined;
1811
+ },
1779
1812
  };
1780
1813
  }
1781
1814
  /** How many images a book of a connector has, as this run (a book it gave) or the research (a record set of it) knows. */
1782
- function bookImagesOf(ctx, c, book, r) {
1783
- const given = r.books.find((b) => b.id === book && Number.isInteger(b.images) && b.images > 0)?.images;
1815
+ function bookImagesOf(ctx, c, book, books) {
1816
+ const given = books.find((b) => b.id === book && Number.isInteger(b.images) && b.images > 0)?.images;
1784
1817
  if (given)
1785
1818
  return given;
1786
1819
  if (!ctx.hasTree())
@@ -2217,6 +2250,10 @@ function fetchBatches(ctx, c, request, recordset, from, child, task, workDir) {
2217
2250
  waiting(until) {
2218
2251
  mark.beat({ waitUntil: until });
2219
2252
  },
2253
+ /** One image costs many requests (tiles): its mark says it (strom fetch --status, the brief). */
2254
+ heavy(h) {
2255
+ mark.beat({ registered: done.size, heavy: h });
2256
+ },
2220
2257
  /** The run is over: what it gave and no batch holds is registered; a placeholder an earlier batch took withdrawn. */
2221
2258
  finish(images) {
2222
2259
  const kept = new Set(images.map((i) => i.file));
@@ -2485,7 +2522,8 @@ async function joinFetch(ctx, recordset, joined, said) {
2485
2522
  function activeLine(m) {
2486
2523
  const since = m.since ? ` · since ${clock(Date.parse(m.since))}` : "";
2487
2524
  const state = m.waitUntil && m.waitUntil > Date.now() ? ` · waits for the archive until ${clockUp(m.waitUntil)}, then goes on by itself` : m.yielding ? " · waits while a fetch in the foreground asks the archive" : "";
2488
- return `${m.recordset} (${m.connector} ${m.book}): ${m.registered}/${m.images.length} images registered · ${m.background ? `in the background${m.task ? ` for ${m.task}` : ""}${m.session ? ` (session ${m.session})` : ""}` : "in the foreground"}${since}${state} · pid ${m.pid}`;
2525
+ const heavy = m.heavy ? ` · ${heavySaid(m.heavy, m.background ? `strom fetch --stop ${m.recordset}` : undefined)}` : "";
2526
+ return `${m.recordset} (${m.connector} ${m.book}): ${m.registered}/${m.images.length} images registered · ${m.background ? `in the background${m.task ? ` for ${m.task}` : ""}${m.session ? ` (session ${m.session})` : ""}` : "in the foreground"}${since}${state} · pid ${m.pid}${heavy}`;
2489
2527
  }
2490
2528
  function endedLine(e) {
2491
2529
  // ended without a word (its process killed, the computer stopped): found so by a later strom, its last sign of life
@@ -2493,7 +2531,7 @@ function endedLine(e) {
2493
2531
  ? ` · ${e.background ? "in the background" : "in the foreground"}, last heard ${clock(Date.parse(e.at))} — interrupted: ${e.interrupted === "gone" ? `its process (pid ${e.pid}) ended without a word (killed, or the computer stopped)` : `nothing heard of it for ${FETCH_SILENT_MS / 60_000} min (pid ${e.pid})`}`
2494
2532
  : ` · ended ${clock(Date.parse(e.at))}${e.stopped ? ` — stopped: ${e.stopped}` : e.exitCode ? ` — exit ${e.exitCode}` : ""}`;
2495
2533
  const again = `strom fetch ${e.connector} ${shellArg(e.book)} --images ${imagesArg(e.missed)} --recordset ${e.recordset}${e.interrupted && e.background ? " --background" : ""}`;
2496
- return `${e.recordset} (${e.connector} ${e.book}): ${e.registered.length}/${e.images.length} images registered${e.registered.length ? ` (images ${runs(e.registered)})` : ""}${how}${e.missed.length ? ` · not fetched: images ${runs(e.missed)} (${again}${e.interrupted ? " — what is registered is not fetched again" : ""})` : ""}`;
2534
+ return `${e.recordset} (${e.connector} ${e.book}): ${e.registered.length}/${e.images.length} images registered${e.registered.length ? ` (images ${runs(e.registered)})` : ""}${how}${e.missed.length ? ` · not fetched: images ${runs(e.missed)} (${again}${e.interrupted ? " — what is registered is not fetched again" : ""})` : ""}${e.heavy ? ` · ${heavySaid(e.heavy)}` : ""}`;
2497
2535
  }
2498
2536
  /** strom fetch --status: what is being fetched for this research now, and the fetches in the background that ended lately. */
2499
2537
  function fetchStatus(ctx, names) {
@@ -2652,6 +2690,15 @@ async function fetchWith(ctx, c, request, recordset, noIndex = false, again = fa
2652
2690
  const from = (f) => `connector ${c.name} · ${path.basename(f)}`;
2653
2691
  // the images of a book registered as they come, in batches: a reader of the book begins on the first ones
2654
2692
  const batches = request.cmd === "fetch" && recordset ? fetchBatches(ctx, c, request, recordset, from, child, forTask, workDir) : undefined;
2693
+ // an image of many requests (tiles): said once a run, as connector test says it (the run's own measure)
2694
+ const heavy = request.cmd === "fetch" ? heavyFetch(ctx, c, request, recordset, meter, gate.human, count.say, !!child) : undefined;
2695
+ let found;
2696
+ const costly = (h) => {
2697
+ if (!h)
2698
+ return;
2699
+ found = h;
2700
+ batches?.heavy(h);
2701
+ };
2655
2702
  let endCode;
2656
2703
  // why the connector stopped before the end (an error of it, a refusal, a host gone silent) — not a Ctrl-C
2657
2704
  let cut;
@@ -2661,7 +2708,7 @@ async function fetchWith(ctx, c, request, recordset, noIndex = false, again = fa
2661
2708
  workDir,
2662
2709
  netDir: netDir(ctx),
2663
2710
  onLog: (l) => count.say(` · ${l}\n`),
2664
- onImage: (n, im) => (count.got(n), batches?.took(im)),
2711
+ onImage: (n, im) => (count.got(n), batches?.took(im), costly(heavy?.image(n))),
2665
2712
  waitMs: waits.waitMs,
2666
2713
  onWait: (w) => (count.clear(), batches?.waiting(w.until), waits.onWait(w)),
2667
2714
  ...metered(meter),
@@ -2672,6 +2719,7 @@ async function fetchWith(ctx, c, request, recordset, noIndex = false, again = fa
2672
2719
  ...(child ? { background: true, onYield: (w) => batches?.yielding(w) } : {}),
2673
2720
  });
2674
2721
  count.clear();
2722
+ costly(heavy?.end(r));
2675
2723
  if (r.stopped && !batches?.interrupted())
2676
2724
  cut = r.stopped;
2677
2725
  refusalSaid(ctx, c, r.refused);
@@ -2766,7 +2814,7 @@ async function fetchWith(ctx, c, request, recordset, noIndex = false, again = fa
2766
2814
  // the connector stopped with images left: no success — the output says which and how to go on (a refusal: its own advice, as before)
2767
2815
  const code = wait.exitCode ? wait.exitCode : batches?.stopped() ? 0 : batches?.interrupted() ? EXIT.cancelled : r.stopped && (!r.images.length || (missed.length && !r.refused)) ? EXIT.error : after?.exitCode;
2768
2816
  endCode = code ?? 0;
2769
- return { text: lines(describeRun(r, request.cmd), text, advice, wait.line, near, after?.text), data: { ...data, ...wait.data, ...(after ? { joined: after.data } : {}) }, ...(code ? { exitCode: code } : {}) };
2817
+ return { text: lines(describeRun(r, request.cmd), text, advice, wait.line, near, after?.text), data: { ...data, ...wait.data, ...(after ? { joined: after.data } : {}), ...(found ? { heavy: found } : {}) }, ...(code ? { exitCode: code } : {}) };
2770
2818
  }
2771
2819
  finally {
2772
2820
  // a fetch in the background says how it ended (strom fetch --status, the next brief) before its mark goes; one in
@@ -2793,6 +2841,7 @@ async function fetchWith(ctx, c, request, recordset, noIndex = false, again = fa
2793
2841
  since: new Date(t0).toISOString(),
2794
2842
  ...(session ? { session } : {}),
2795
2843
  ...(child?.task ? { task: child.task } : {}),
2844
+ ...(found ? { heavy: found } : {}),
2796
2845
  exitCode: endCode ?? 1,
2797
2846
  });
2798
2847
  }
@@ -150,6 +150,13 @@ const VIEWER_LOAD_MS = 6000;
150
150
  export const VIEWER_WHOLE_PX = 2000;
151
151
  /** The longer side of a part saved from a viewer: as sharp as the image, never more than this. */
152
152
  export const VIEWER_PART_PX = 2400;
153
+ /**
154
+ * How long a tab the browser does not draw may hold a viewer's image up. A browser draws no frame of a tab behind
155
+ * another tab or in a window covered or minimized — also when the page is told it is visible (a covered window) —, and
156
+ * a viewer (OpenSeadragon) counts its tiles only when it draws: they come, yet it never says they are all there. The
157
+ * waits count only the time frames come; no frame for this long in all is said.
158
+ */
159
+ export const VIEWER_HIDDEN_MS = 30_000;
153
160
  const safe = (s) => s.normalize("NFC").replace(/[^\p{L}\p{M}\p{N}._-]+/gu, "_").replace(/^[._]+/, "") || "x";
154
161
  /** The name a planned image is saved under: strom-<connector>-<book>-0009 (a part: …-0009-part). */
155
162
  export function fileBase(connector, book, n, part) {
@@ -382,17 +389,41 @@ export function pageScript(plan) {
382
389
  * cut out and saved as a JPEG under a name. No request of its own: the tiles are the ones the viewer asks for.
383
390
  */
384
391
  const CAPTURE_JS = `const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
385
- const frames = () => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
392
+ // a tab the browser does not draw (another tab in front, its window covered or minimized — the page may still be
393
+ // told it is visible) gets no frame, and the viewer, which counts its tiles only when it draws, never says they are
394
+ // all there: a wait counts only the time frames come (one asked at each look), and gives up once none came for
395
+ // ${VIEWER_HIDDEN_MS / 1000} s in all
396
+ let lastFrame = 0;
397
+ const drawing = () => document.visibilityState !== "hidden" && Date.now() - lastFrame < 1500;
398
+ let unseen = 0;
399
+ const notShown = () => unseen > ${VIEWER_HIDDEN_MS};
400
+ const NOT_SHOWN = "the browser did not draw the tab with the viewer for ${VIEWER_HIDDEN_MS / 1000} s — it draws nothing in a tab behind another tab or in a window covered or minimized, so the viewer never finishes its image: the tab in front, its window uncovered, then the script again";
386
401
  const until = async (ok, ms) => {
387
- const end = Date.now() + ms;
402
+ let left = ms;
403
+ let t = Date.now();
388
404
  for (;;) {
405
+ requestAnimationFrame(() => (lastFrame = Date.now()));
389
406
  try {
390
407
  if (ok()) return true;
391
408
  } catch (e) {}
392
- if (Date.now() > end) return false;
409
+ const now = Date.now();
410
+ if (drawing()) left -= now - t;
411
+ else unseen += now - t;
412
+ t = now;
413
+ if (left <= 0 || notShown()) return false;
393
414
  await sleep(200);
394
415
  }
395
416
  };
417
+ // two frames drawn (none comes while the browser does not draw the tab): at once where it draws, as fast as before
418
+ // the waits counted frames; where it does not, the wait that counts the time without them
419
+ const frames = async () => {
420
+ let drawn = false;
421
+ await new Promise((r) => {
422
+ requestAnimationFrame(() => requestAnimationFrame(() => ((drawn = true), (lastFrame = Date.now()), r())));
423
+ setTimeout(r, 100);
424
+ });
425
+ return drawn || until(() => drawn, 5000);
426
+ };
396
427
  const findViewer = () => {
397
428
  const OSD = window.OpenSeadragon;
398
429
  if (!OSD || !OSD.Viewer) return undefined;
@@ -417,6 +448,7 @@ const CAPTURE_JS = `const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
417
448
  // the viewer's page idx (0: the first; -1: the one it shows), whole or the region, cut out of what it drew
418
449
  const capture = async (v, idx, region, target) => {
419
450
  const pages = Array.isArray(v.tileSources) ? v.tileSources.length : 1;
451
+ unseen = 0;
420
452
  if (idx >= 0 && idx >= pages) return { why: "the viewer has " + pages + " page" + (pages === 1 ? "" : "s") + ", not " + (idx + 1) };
421
453
  // the addresses a viewer's page holds of its images may expire (the archive answers 410): the viewer opens nothing then
422
454
  let gone = false;
@@ -427,15 +459,16 @@ const CAPTURE_JS = `const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
427
459
  if (idx >= 0 && pages > 1 && v.currentPage() !== idx) {
428
460
  const before = v.world.getItemAt(0);
429
461
  v.goToPage(idx);
430
- if (!(await until(() => gone || (v.currentPage() === idx && v.world.getItemCount() > 0 && v.world.getItemAt(0) !== before), 30000))) return { why: "the viewer did not show page " + (idx + 1) + " in 30 s" };
462
+ if (!(await until(() => gone || (v.currentPage() === idx && v.world.getItemCount() > 0 && v.world.getItemAt(0) !== before), 30000))) return { why: notShown() ? NOT_SHOWN : "the viewer did not show page " + (idx + 1) + " in 30 s" };
431
463
  if (gone) return stale;
432
464
  }
433
- if (!(await until(() => gone || v.world.getItemCount() > 0, 30000))) return { why: "the viewer shows no image after 30 s — a check whether a person is there is the user's to pass", check: true };
465
+ if (!(await until(() => gone || v.world.getItemCount() > 0, 30000))) return notShown() ? { why: NOT_SHOWN } : { why: "the viewer shows no image after 30 s — a check whether a person is there is the user's to pass", check: true };
434
466
  if (gone) return stale;
435
467
  } finally {
436
468
  v.removeHandler("open-failed", onGone);
437
469
  }
438
470
  const item = v.world.getItemAt(0);
471
+ const page = typeof v.currentPage === "function" ? v.currentPage() : 0;
439
472
  const canvas = v.drawer && v.drawer.canvas;
440
473
  if (!canvas || !canvas.getContext || (v.drawer.getType && v.drawer.getType() === "webgl")) return { why: "this viewer does not draw on a canvas strom can save" };
441
474
  const dim = item.source && item.source.dimensions ? item.source.dimensions : item.getContentSize();
@@ -452,14 +485,31 @@ const CAPTURE_JS = `const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
452
485
  try {
453
486
  el.style.cssText = (style || "") + ";position:fixed;left:0;top:0;width:" + cw + "px;height:" + ch + "px;max-width:none;max-height:none;z-index:2147483646";
454
487
  await until(() => { const s = v.viewport.getContainerSize(); return Math.abs(s.x - cw) < 2 && Math.abs(s.y - ch) < 2; }, 5000);
488
+ if (notShown()) return { why: NOT_SHOWN };
455
489
  const rect = item.imageToViewportRectangle(r.x * dim.x, r.y * dim.y, rw, rh);
456
490
  v.viewport.fitBounds(rect, true);
457
- await frames();
491
+ if (!(await frames()) && notShown()) return { why: NOT_SHOWN };
458
492
  await sleep(300);
459
- const done = () => (typeof item.getFullyLoaded === "function" ? item.getFullyLoaded() : true) && (!v.imageLoader || v.imageLoader.jobsInProgress === 0);
460
- if (!(await until(done, 30000))) return { why: "the viewer's tiles did not all come in 30 s" };
461
- await frames();
493
+ const loaded = () => (typeof item.getFullyLoaded === "function" ? item.getFullyLoaded() : true);
494
+ const jobs = () => (v.imageLoader ? v.imageLoader.jobsInProgress : 0);
495
+ const done = () => loaded() && jobs() === 0;
496
+ if (!(await until(done, 30000))) {
497
+ if (notShown()) return { why: NOT_SHOWN };
498
+ // what the viewer said when the wait ended (no token of it a result could be taken for: no "n:nnn")
499
+ const said = [];
500
+ try {
501
+ said.push("all there " + (loaded() ? "yes" : "no"), "requests open " + jobs());
502
+ if (typeof item._tilesLoading === "number") said.push("tiles loading " + item._tilesLoading);
503
+ said.push("tab " + (document.visibilityState || "visible"), "last frame " + (lastFrame ? Math.round((Date.now() - lastFrame) / 100) / 10 + " s ago" : "none"), "drawn " + canvas.width + "x" + canvas.height + " px");
504
+ const osd = window.OpenSeadragon && window.OpenSeadragon.version;
505
+ if (osd && osd.versionStr) said.push("OpenSeadragon " + osd.versionStr);
506
+ } catch (e) {}
507
+ return { why: "the viewer's tiles did not all come in 30 s (" + said.join(", ") + ")" };
508
+ }
509
+ if (!(await frames()) && notShown()) return { why: NOT_SHOWN };
462
510
  if (failed) return { why: failed + " tile" + (failed === 1 ? "" : "s") + " of the image did not come — the archive may be busy", stop: true };
511
+ // paged meanwhile (by the person, or the page itself): what it drew is another image — never saved under this name
512
+ if (typeof v.currentPage === "function" && v.currentPage() !== page) return { why: "the viewer was paged to another image while this one was being saved — nothing saved; run the script again" };
463
513
  const ratio = canvas.width / (canvas.clientWidth || cw) || dpr;
464
514
  const a = v.viewport.pixelFromPoint(rect.getTopLeft(), true), b = v.viewport.pixelFromPoint(rect.getBottomRight(), true);
465
515
  const sx = Math.max(0, Math.round(a.x * ratio)), sy = Math.max(0, Math.round(a.y * ratio));
@@ -8,6 +8,24 @@ import os from "node:os";
8
8
  import path from "node:path";
9
9
  /** Images a fetch registers at once (one commit each): readers begin on the first batch, the history grows little. */
10
10
  export const FETCH_BATCH = 10;
11
+ /** More requests than this for one whole image: tiles, most likely — hours for a book (DISCOVERY.md, step 2). */
12
+ export const HEAVY_IMAGE = 10;
13
+ /** A book of this many images, for the time a book takes when the book's own number is not known here. */
14
+ export const BOOK_GUESS = 200;
15
+ /** A time said: seconds, minutes, else hours. */
16
+ export function spanSaid(ms) {
17
+ const secs = Math.round(ms / 1000);
18
+ if (secs < 90)
19
+ return `${secs} s`;
20
+ if (secs < 90 * 60)
21
+ return `${Math.round(secs / 60)} min`;
22
+ return `${Math.round(secs / 360) / 10} h`;
23
+ }
24
+ /** A fetch's costly image said in one short part of a line (strom fetch --status, the brief); `stop`: the command that stops it. */
25
+ export function heavySaid(h, stop) {
26
+ const per = Math.round(h.perImage * 10) / 10;
27
+ return `⚠ ${per} requests an image (tiles, most likely): about ${spanSaid(h.bookMs)} for ${h.bookImages ? `its ${h.bookImages} images` : `a book of ${BOOK_GUESS} images`} — ${stop ? `${stop}; ` : ""}a connector of one request an image first (DISCOVERY.md, step 2)`;
28
+ }
11
29
  /** A fetch nothing was heard of this long (no image, no wait for a limit it said) is taken for gone. */
12
30
  export const FETCH_SILENT_MS = 10 * 60_000;
13
31
  function dir(root) {
@@ -94,6 +112,7 @@ function gone(root, file, m) {
94
112
  ...(m.since ? { since: m.since } : {}),
95
113
  ...(m.session ? { session: m.session } : {}),
96
114
  ...(m.task ? { task: m.task } : {}),
115
+ ...(m.heavy ? { heavy: m.heavy } : {}),
97
116
  exitCode: 1,
98
117
  });
99
118
  }
package/dist/core/tree.js CHANGED
@@ -32,7 +32,7 @@ export const TREE_FILE = "strom.json";
32
32
  export const SEAL_FOREIGN = "seal.foreign";
33
33
  // between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
34
34
  // at a release the release's own (package.json)
35
- export const VERSION = "1.31.0-beta.1";
35
+ export const VERSION = "1.31.0-beta.2";
36
36
  /** What a new research is settled with from the start: nothing an older strom counted otherwise to set right in it. */
37
37
  export const NEW_TREE_SETTLED = ["readers-1", "proven-originals-1", "origins-1", "verify-originals-1", "origins-tree-1"];
38
38
  const GITIGNORE = `# Strom Research — local state and large files are not versioned
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strom-research",
3
- "version": "1.31.0-beta.1",
3
+ "version": "1.31.0-beta.2",
4
4
  "stromDoc": "f9ad9cd5851455e5bdf7b93b7d80907bedc20e79",
5
5
  "description": "Genealogical research toolkit for AI coding agents",
6
6
  "type": "module",