archaeopteryx 3.26.0 → 3.28.0
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/README.md +151 -99
- package/archaeopteryx.d.ts +56 -0
- package/archaeopteryx.js +1319 -182
- package/forester.js +8 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -297,7 +297,8 @@ The card button in the panel header opens **Control panel**: one row for every
|
|
|
297
297
|
control the panel is currently showing, in the order it shows them, each with
|
|
298
298
|
the control's own glyph or name and the sentence that explains it — the layout
|
|
299
299
|
and display-type buttons included, drawn with the very glyph they carry in the
|
|
300
|
-
panel. The About box has a row for it too
|
|
300
|
+
panel. The About box has a row for it too, and one for
|
|
301
|
+
[Diagnostics](#diagnostics).
|
|
301
302
|
|
|
302
303
|
The display types say what they do and when they are greyed, whether or not
|
|
303
304
|
they are greyed in the view you are looking at: *"phylogram: branch lengths
|
|
@@ -1148,103 +1149,149 @@ names exactly what is missing (including "the loaded d3 is not usable as d3
|
|
|
1148
1149
|
version 7"). The optional export libraries stay page-level globals in every
|
|
1149
1150
|
loading style: `window.Canvg` (PNG), `window.jspdf` + svg2pdf.js (PDF).
|
|
1150
1151
|
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
(
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
the
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1152
|
+
### Diagnostics
|
|
1153
|
+
|
|
1154
|
+
Checking at use rather than at load makes the viewer hard to break — and lets
|
|
1155
|
+
it run half-equipped without a word: no PDF in the Download menu, a retired
|
|
1156
|
+
config key ignored, a forced visualization overruled, each mentioned only in a
|
|
1157
|
+
console nobody has open. **`archaeopteryx.doctor()`** says what state the
|
|
1158
|
+
program is in on this page:
|
|
1159
|
+
|
|
1160
|
+
```javascript
|
|
1161
|
+
var report = archaeopteryx.doctor();
|
|
1162
|
+
report.ok; // false when something is wrong that nobody chooses
|
|
1163
|
+
report.summary; // "nothing to report", or "2 things to check"
|
|
1164
|
+
report.problems; // ['jspdf: loaded without svg2pdf.js: PDF export needs both, so it is off', ...]
|
|
1165
|
+
report.notes; // stated, not flagged
|
|
1166
|
+
report.libraries; // [{name, role, loaded, version, status, detail}, ...]
|
|
1167
|
+
report.functions; // [{name: 'PDF export', available: false, detail: 'jspdf and svg2pdf.js are not loaded'}, ...]
|
|
1168
|
+
report.launch; // {config, tips, tree, trees, container}, or null when no tree is on view
|
|
1169
|
+
report.text; // all of it as plain text, to paste into an issue
|
|
1170
|
+
console.log(archaeopteryx.doctor().text);
|
|
1171
|
+
```
|
|
1172
|
+
|
|
1173
|
+
It works before a launch, after a launch that threw, and in Node, and it never
|
|
1174
|
+
throws. The same report is in the viewer: the **About** box (a click on the
|
|
1175
|
+
program name) has a **Diagnostics** row that opens it, with a **Copy report**
|
|
1176
|
+
button — the copied text adds the keys passed to `launch()` (a string or a
|
|
1177
|
+
number as given, anything else as its kind: a tree or a callback is never
|
|
1178
|
+
copied) and the browser.
|
|
1179
|
+
|
|
1180
|
+
What is a **problem** and what is only stated:
|
|
1181
|
+
|
|
1182
|
+
| | |
|
|
1183
|
+
|---|---|
|
|
1184
|
+
| An optional library that is not loaded (canvg, jspdf, svg2pdf.js) | **stated**: "PNG export: off". Leaving one out is a site's choice. |
|
|
1185
|
+
| Half of a pair: jspdf without svg2pdf.js, or the other way round; svg2pdf.js loaded before jspdf | **problem** |
|
|
1186
|
+
| A library under its 2.x-era global (`window.canvg`, `window.jsPDF`) and not under the one this version reads; a `window.Canvg` without `fromString` | **problem** |
|
|
1187
|
+
| A d3 that is not version 7 (d3 4 to 6 have `d3.zoom` and `d3.cluster` too, so the launch check lets them through) | **problem**; a d3 7 older than 7.9 is a note |
|
|
1188
|
+
| `forester.js` and `archaeopteryx.js` from different releases (`forester.VERSION`) | **problem** |
|
|
1189
|
+
| A phyloxml older than 1.1.7: one that drops something when saving, or writes a node's style as the earlier releases did | **problem** — and "Read and save phyloXML" stays **on**, since it still reads and saves |
|
|
1190
|
+
| A phyloxml that only lays the file out differently from 1.1.7 (a newer release) | **note** |
|
|
1191
|
+
| phyloxml or sax not loaded, or a phyloxml that cannot read or write at all | **problem** |
|
|
1192
|
+
| What the last launch printed about its **config**: a deprecated key, an `initialVisualization` the tree cannot honour or that was overruled, a bad `pngExportScale`, a thrown `onViewChange`, and why a launch threw (`launchArchaeopteryx` included) | **problem** |
|
|
1193
|
+
| An export that failed (a clipboard the browser refused, a canvas too large), what the viewer left out of a tree (a domain or a gene it could not place), a size setting ignored | **note**: nothing a site's configuration decides |
|
|
1194
|
+
|
|
1195
|
+
Only forester, jsPDF and d3's script build state a version; the others are
|
|
1196
|
+
judged by what they do. The d3 the viewer was handed at load is the one
|
|
1197
|
+
reported, as `launch()` uses it — a d3 with no `version` (the ES-module build
|
|
1198
|
+
a bundler imports) is recognised by what only d3 7 has. phyloxml is given a
|
|
1199
|
+
small tree to write, and the result is read for what the older releases are
|
|
1200
|
+
known to do.
|
|
1201
|
+
|
|
1202
|
+
**While the report has a problem, a small dot follows the program name** in
|
|
1203
|
+
the panel header, and the name's tooltip says how many. It is neutral, not a
|
|
1204
|
+
warning colour: most of the people who see it are a site's visitors, who can
|
|
1205
|
+
do nothing about it. Nothing appears when an optional library is merely
|
|
1206
|
+
absent. The dot is brought up to date when a problem is recorded, when the
|
|
1207
|
+
page finishes loading, when the pointer enters the panel, when the About box
|
|
1208
|
+
opens and when `doctor()` is called — so a library that arrives after the
|
|
1209
|
+
launch puts it out without a relaunch.
|
|
1210
|
+
|
|
1211
|
+
The warnings belong to **the tree on view**: `showTree()` starts them afresh
|
|
1212
|
+
for the tree it moves to, and so does a new launch. A launch that is rejected
|
|
1213
|
+
while an earlier viewer is still on the page leaves that viewer's report as
|
|
1214
|
+
it was and adds one line saying what failed.
|
|
1215
|
+
|
|
1216
|
+
### The host page's stylesheet
|
|
1217
|
+
|
|
1218
|
+
The viewer is drawn inside your page, in your page's document, so your
|
|
1219
|
+
stylesheet applies to it. A rule written for something else can reach it: on
|
|
1220
|
+
one site, `.Phylogeny svg { background: #FFFFFF }`, written when the tree was
|
|
1221
|
+
the only svg in that box, put a white square behind every icon of the control
|
|
1222
|
+
panel. The viewer now says for itself what it used to leave to the page:
|
|
1223
|
+
|
|
1224
|
+
* **Everything it puts on the page starts from the browser's own defaults.**
|
|
1225
|
+
The control panel, the dialogs, the menus, the tooltip, the "working" card
|
|
1226
|
+
and the alignment bar are untouched by rules written with element names
|
|
1227
|
+
only, whichever stylesheet comes first: a reset's `* { box-sizing:
|
|
1228
|
+
border-box }`, a framework's `label { font-weight: 700 }` or `button { font:
|
|
1229
|
+
inherit }`, `svg { fill: currentColor }`. And a sheet's `:focus { outline:
|
|
1230
|
+
0 }` no longer takes the keyboard focus ring off the viewer's controls.
|
|
1231
|
+
* **What your page hands down by inheritance stops at the viewer.** A page set
|
|
1232
|
+
in capitals, centred, or in a serif face does not set the panel, the dialogs
|
|
1233
|
+
or the tree that way.
|
|
1234
|
+
* **The tree's svg is `svg.aptx-tree`.** Its size and its font are stated
|
|
1235
|
+
inline (a page whose only svgs were icons, with `svg { width: 24px; height:
|
|
1236
|
+
24px }`, drew the tree 24 px square), and its background is a rectangle the
|
|
1237
|
+
viewer draws, not the svg's own.
|
|
1238
|
+
* **Every shape states its paint as an inline style**, in the tree and in the
|
|
1239
|
+
viewer's other svgs: its fill, its stroke, its opacity, a label's alignment.
|
|
1240
|
+
An svg *attribute* gives way to any rule of the page, so a chart's
|
|
1241
|
+
stylesheet written for a page with one chart on it, `path { fill: none;
|
|
1242
|
+
stroke: #000 }` or `text { font: 10px sans-serif }`, used to repaint the
|
|
1243
|
+
tree: its branches, its labels, its legends. What a shape does not state it
|
|
1244
|
+
has from its parent, whatever the page says of a `path`, a `rect` or a
|
|
1245
|
+
`text`: bare, in a state (`rect:hover`), or inside a container of yours
|
|
1246
|
+
(`.chart text`). Nor does a page-wide `* { transition: all .3s }` make the
|
|
1247
|
+
tree ease behind its own redraws.
|
|
1248
|
+
* **The icons, the logo and the clock plot** are untouched by a rule for a
|
|
1249
|
+
bare `svg` inside a container of yours (`.my-box svg { ... }`).
|
|
1250
|
+
|
|
1251
|
+
What still follows the page, on purpose: `direction`, `cursor`, `visibility`
|
|
1252
|
+
and `pointer-events` on whatever contains the viewer.
|
|
1253
|
+
|
|
1254
|
+
**To restyle the viewer deliberately, name its classes**, inside a container
|
|
1255
|
+
of your own so that your rule outweighs the viewer's: `.my-page svg.aptx-tree
|
|
1256
|
+
{ border: 1px solid #ccc }` (the border fits inside the tree's size),
|
|
1257
|
+
`.my-page .aptx-panel { ... }`.
|
|
1258
|
+
|
|
1259
|
+
**A shape's colours and strokes are not restyled by CSS any more.** Through
|
|
1260
|
+
3.27.0 a rule such as `#tree path { stroke-width: 2px }` thickened the
|
|
1261
|
+
branches, because their width was an attribute; an inline style gives way to
|
|
1262
|
+
nothing but `!important`. Colours, widths and fonts are what the
|
|
1263
|
+
configuration and the control panel are for; a rule that must override them
|
|
1264
|
+
says `!important`.
|
|
1265
|
+
|
|
1266
|
+
**What the viewer cannot do from inside your document:**
|
|
1267
|
+
|
|
1268
|
+
* A rule that names **a class of yours and an element** (`.content button {
|
|
1269
|
+
text-transform: uppercase }`, `.page label { ... }`) still reaches the
|
|
1270
|
+
viewer's buttons, labels and fields wherever the viewer's own rule for that
|
|
1271
|
+
control does not state the same property: the defaults above weigh less than
|
|
1272
|
+
one class, or they would outweigh the viewer's own rules. If your page has
|
|
1273
|
+
such rules around the viewer, scope them to your own content.
|
|
1274
|
+
* For a shape it takes more: a rule with two classes of yours, or an `id`,
|
|
1275
|
+
still reaches what a shape does not state itself (`.page .chart text {
|
|
1276
|
+
letter-spacing: 1px }` spaces the tree's labels).
|
|
1277
|
+
* Where a shape is, and how large, is still in its attributes (`x`, `y`,
|
|
1278
|
+
`width`, `d`, `r`, `transform`): a rule such as `rect { width: 100% }` or
|
|
1279
|
+
`circle { r: 4px }` moves or resizes the viewer's shapes too.
|
|
1280
|
+
* Nothing outranks a rule scoped by an `id`, or marked `!important`.
|
|
1281
|
+
|
|
1282
|
+
A file is another matter: it has no page around it. In an exported SVG file a
|
|
1283
|
+
shape's colours, strokes, opacities and text alignment are attributes
|
|
1284
|
+
(`fill="..."`, `stroke-opacity="..."`), the form every program that opens an
|
|
1285
|
+
svg reads; only fonts and `paint-order` are in `style`. Its colours are those
|
|
1286
|
+
SVG 1.1 has: what is `transparent` on the page is `none` in the file, and a
|
|
1287
|
+
translucent colour is the colour with a `fill-opacity` or `stroke-opacity`
|
|
1288
|
+
(Inkscape 1.1 draws `transparent` and `rgba(...)` as black).
|
|
1289
|
+
|
|
1290
|
+
`test/browser/host_css.html` launches the viewer under real stylesheets (the
|
|
1291
|
+
BV-BRC website's, Bootstrap 3 and 5, Tailwind's reset, and a sheet of single
|
|
1292
|
+
rules of kinds found on real pages), each added after the viewer's own, and
|
|
1293
|
+
fails on any difference from a launch in a clean page: in what any element
|
|
1294
|
+
computes to, and in where it sits.
|
|
1248
1295
|
|
|
1249
1296
|
### Downloads
|
|
1250
1297
|
|
|
@@ -1296,6 +1343,11 @@ tree, with the same columns, and a table that joins back onto the tree as
|
|
|
1296
1343
|
A full-size PDF taller or wider than 200 inches (14,400 pt, the PDF page
|
|
1297
1344
|
limit) is scaled onto the largest page; it is vector, so nothing is lost.
|
|
1298
1345
|
|
|
1346
|
+
**The SVG file is written for programs other than a browser**: a shape's
|
|
1347
|
+
paint is in attributes, and its colours are those SVG 1.1 has (no
|
|
1348
|
+
`transparent`, no `rgba(...)`, which Inkscape 1.1 draws as black). See [The
|
|
1349
|
+
host page's stylesheet](#the-host-pages-stylesheet).
|
|
1350
|
+
|
|
1299
1351
|
Newick and Nexus files usually carry branch support as a bare internal label
|
|
1300
1352
|
(`)100:0.05`). Archaeopteryx.js recognises those automatically and treats them
|
|
1301
1353
|
as confidence values, so support-based features work without any setup. If your
|
|
@@ -1633,7 +1685,7 @@ All 118 of them, alphabetically:
|
|
|
1633
1685
|
| `allowManualNodeSelection` | Renamed to `enableManualNodeSelection`. |
|
|
1634
1686
|
| `backgroundColorDefault` | The background is fixed. |
|
|
1635
1687
|
| `backgroundColorForPrintExportDefault` | The export background is fixed. |
|
|
1636
|
-
| `border` | Style the tree's svg with CSS instead. |
|
|
1688
|
+
| `border` | Style the tree's svg with CSS instead: it is `svg.aptx-tree` (a rule for a bare `svg` reaches the panel's icons too). |
|
|
1637
1689
|
| `branchColorDefault` | The default branch colour is fixed. |
|
|
1638
1690
|
| `branchDataFontSize` | Font size is fixed at launch (derived: 2px smaller than labels, floor 6px) and changed only via the in-panel Font slider — not a launch config key. |
|
|
1639
1691
|
| `branchWidthDefault` | Branch width follows the size of the tree. |
|
package/archaeopteryx.d.ts
CHANGED
|
@@ -259,6 +259,57 @@ export interface ViewerHandle {
|
|
|
259
259
|
* value, 'label' keeps them as names. */
|
|
260
260
|
export type InternalNumericLabels = 'auto' | 'confidence' | 'label';
|
|
261
261
|
|
|
262
|
+
/** One library's row in the diagnostics report. `status`: 'ok'; 'absent'
|
|
263
|
+
* (not loaded, and that is no fault: an optional library, or d3 outside a
|
|
264
|
+
* page); 'note' (stated, not flagged); 'problem' (lights the dot). */
|
|
265
|
+
export interface DoctorLibrary {
|
|
266
|
+
name: 'forester.js' | 'd3' | 'phyloxml' | 'sax' | 'canvg' | 'jspdf' | 'svg2pdf.js' | string;
|
|
267
|
+
role: 'required' | 'optional';
|
|
268
|
+
loaded: boolean;
|
|
269
|
+
/** Only d3 (its script build), jsPDF and forester state one. */
|
|
270
|
+
version: string | null;
|
|
271
|
+
status: 'ok' | 'absent' | 'note' | 'problem';
|
|
272
|
+
detail: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** What the user gets or does not get, with the reason when it is off. */
|
|
276
|
+
export interface DoctorFunction {
|
|
277
|
+
name: 'Read and save phyloXML' | 'PNG export' | 'Copy PNG' | 'PDF export' | string;
|
|
278
|
+
available: boolean;
|
|
279
|
+
detail: string;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The tree on view. A config value is given as passed when it is a
|
|
283
|
+
* string, a number, a boolean or null, and otherwise as its kind:
|
|
284
|
+
* '(function)', '(list of 3)', '(object)'. */
|
|
285
|
+
export interface DoctorLaunch {
|
|
286
|
+
config: Record<string, string | number | boolean | null>;
|
|
287
|
+
tips: number | null;
|
|
288
|
+
/** 1-based, of `trees`. */
|
|
289
|
+
tree: number;
|
|
290
|
+
trees: number;
|
|
291
|
+
container: { width: number; height: number } | null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** archaeopteryx.doctor(): the state of the program on this page. */
|
|
295
|
+
export interface DoctorReport {
|
|
296
|
+
program: string;
|
|
297
|
+
version: string;
|
|
298
|
+
/** false when something is wrong that nobody chooses. */
|
|
299
|
+
ok: boolean;
|
|
300
|
+
/** 'nothing to report', or '2 things to check'. */
|
|
301
|
+
summary: string;
|
|
302
|
+
problems: string[];
|
|
303
|
+
notes: string[];
|
|
304
|
+
libraries: DoctorLibrary[];
|
|
305
|
+
functions: DoctorFunction[];
|
|
306
|
+
/** null while no tree is on view. */
|
|
307
|
+
launch: DoctorLaunch | null;
|
|
308
|
+
environment: { userAgent: string | null; secureContext: boolean | null };
|
|
309
|
+
/** The whole report as plain text, for pasting into an issue. */
|
|
310
|
+
text: string;
|
|
311
|
+
}
|
|
312
|
+
|
|
262
313
|
export interface Archaeopteryx {
|
|
263
314
|
/** Launch the viewer into a container (a CSS selector or the element
|
|
264
315
|
* itself; an unresolvable container throws). Exactly three arguments.
|
|
@@ -297,6 +348,11 @@ export interface Archaeopteryx {
|
|
|
297
348
|
/** Module-level twin of the handle's getSelectedNodes. */
|
|
298
349
|
getSelectedNodes(): PhylogenyNode[];
|
|
299
350
|
|
|
351
|
+
/** The state of the program on this page: the libraries, the functions
|
|
352
|
+
* they switch off, what the launch on view warned about. Works before a
|
|
353
|
+
* launch, after one that threw, and in Node; never throws. */
|
|
354
|
+
doctor(): DoctorReport;
|
|
355
|
+
|
|
300
356
|
/** A view as a "key=value&..." string for a URL hash, and back. decode
|
|
301
357
|
* accepts a leading '#', ignores what it does not know, and returns
|
|
302
358
|
* null for nothing. */
|