archaeopteryx 2.3.2 → 3.1.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.
Files changed (6) hide show
  1. package/LICENSE +160 -499
  2. package/README.md +1205 -99
  3. package/archaeopteryx.d.ts +141 -0
  4. package/archaeopteryx.js +7984 -6469
  5. package/forester.js +3283 -535
  6. package/package.json +42 -12
@@ -0,0 +1,141 @@
1
+ // Type definitions for archaeopteryx (archaeopteryx.js)
2
+ // The public embedding surface only. The tree-object shape is the phyloXML
3
+ // model as produced by the bundled parsers; it is deliberately typed loosely
4
+ // (every element is optional, extra fields allowed) because trees round-trip
5
+ // through several formats.
6
+
7
+ /** A node of the phylogeny (the phyloXML-shaped tree model). The tree handed
8
+ * to launch() is the "super-root": an object whose children array holds the
9
+ * real root. Every parser in this package returns that shape. */
10
+ export interface PhylogenyNode {
11
+ name?: string;
12
+ branch_length?: number;
13
+ children?: PhylogenyNode[];
14
+ parent?: PhylogenyNode;
15
+ confidences?: Array<{ type?: string; value?: number; stddev?: number }>;
16
+ taxonomies?: Array<Record<string, unknown>>;
17
+ sequences?: Array<Record<string, unknown>>;
18
+ properties?: Array<{ ref: string; value: string; datatype?: string; applies_to?: string }>;
19
+ date?: { value?: number; minimum?: number; maximum?: number; unit?: string; desc?: string };
20
+ [key: string]: unknown;
21
+ }
22
+
23
+ /** A parsed phylogeny: the super-root. Also a PhylogenyNode structurally. */
24
+ export interface Phylogeny extends PhylogenyNode {
25
+ children: PhylogenyNode[];
26
+ rooted?: boolean;
27
+ description?: string;
28
+ }
29
+
30
+ export type Layout = 'rectangular' | 'circular' | 'unrooted';
31
+
32
+ /** One custom label-field entry (the config's nodeLabels values).
33
+ *
34
+ * Two modes:
35
+ * - a PANEL CHECKBOX needs label, description AND propertyRef set, plus
36
+ * showButton: true -- omit showButton (or any of the three) and no
37
+ * checkbox appears;
38
+ * - HEADLESS labelling: selected: true with propertyRef (no showButton)
39
+ * labels the nodes with the property's value, with no checkbox offered.
40
+ *
41
+ * The config is deep-copied at launch: the viewer's runtime state never
42
+ * writes back into the caller's object. */
43
+ export interface NodeLabelSpec {
44
+ /** The checkbox's caption in the control panel. */
45
+ label?: string;
46
+ /** Its tooltip. Required (with label and propertyRef) for the checkbox to appear. */
47
+ description?: string;
48
+ /** The node property ref whose value is shown as the label. */
49
+ propertyRef?: string;
50
+ /** true to offer the checkbox at all. */
51
+ showButton?: boolean;
52
+ /** Start (or run) with the labelling on. */
53
+ selected?: boolean;
54
+ }
55
+
56
+ /** The ONE config object. Every key is optional; an unknown or removed key
57
+ * makes launch() throw (deliberately -- a config entry that quietly does
58
+ * nothing is the bug that costs an afternoon). */
59
+ export interface ArchaeopteryxConfig {
60
+ collapseControlPanel?: boolean;
61
+ displayHeight?: number;
62
+ displayWidth?: number;
63
+ enableAccessToDatabases?: boolean;
64
+ enableDownloads?: boolean;
65
+ enableDynamicSizing?: boolean;
66
+ enableManualNodeSelection?: boolean;
67
+ enableSubtreeDeletion?: boolean;
68
+ enableVisualizations?: boolean;
69
+ initialVisualization?: string | null;
70
+ ladderizeTree?: boolean;
71
+ layout?: Layout;
72
+ nhConfidenceValuesAsInternalNames?: boolean;
73
+ nhConfidenceValuesInBrackets?: boolean;
74
+ nhExportWriteConfidences?: boolean;
75
+ nodeLabels?: Record<string, NodeLabelSpec> | null;
76
+ pngExportScale?: number;
77
+ rootOffset?: number;
78
+ searchAinitialValue?: string | null;
79
+ searchBinitialValue?: string | null;
80
+ showMsa?: boolean;
81
+ showSupportDots?: boolean;
82
+ showTimeAxis?: boolean;
83
+ supportDotMinimum?: number;
84
+ timeAxisGrid?: boolean;
85
+ visualizationsLegendXpos?: number;
86
+ visualizationsLegendYpos?: number;
87
+ zoomToFitUponWindowResize?: boolean;
88
+ }
89
+
90
+ /** What launch() returns: the per-viewer surface an embedder needs after
91
+ * launching. */
92
+ export interface ViewerHandle {
93
+ /** The nodes the user has selected via the node menu (when
94
+ * enableManualNodeSelection is on). */
95
+ getSelectedNodes(): PhylogenyNode[];
96
+ /** Unmounts the viewer completely: the DOM inside the container, the
97
+ * body-level pieces, the window resize listener and every page-level
98
+ * key/wheel handler. A later launch() works normally. */
99
+ destroy(): void;
100
+ }
101
+
102
+ export interface Archaeopteryx {
103
+ /** Launch the viewer into a container (a CSS selector or the element
104
+ * itself; an unresolvable container throws). Exactly three arguments. */
105
+ launch(container: string | Element, tree: Phylogeny, config?: ArchaeopteryxConfig): ViewerHandle;
106
+
107
+ /** Parse-and-launch in one step. Fetch the file content yourself; the
108
+ * fileName picks the parser (extension; content is sniffed too).
109
+ * Exactly four arguments. */
110
+ launchArchaeopteryx(container: string | Element, fileName: string, data: string,
111
+ config?: ArchaeopteryxConfig): ViewerHandle;
112
+
113
+ /** Parse tree data, auto-detecting the format from content and fileName:
114
+ * Nexus (#NEXUS / .nex / .nexus), Auspice/Nextstrain v2 JSON ({ / .json),
115
+ * phyloXML (*xml), otherwise New Hampshire (Newick). */
116
+ parseTree(fileName: string, data: string,
117
+ nhConfidenceValuesInBrackets?: boolean,
118
+ nhConfidenceValuesAsInternalNames?: boolean): Phylogeny;
119
+
120
+ parsePhyloXML(data: string): Phylogeny;
121
+ parseNewHampshire(data: string,
122
+ confidenceValuesInBrackets?: boolean,
123
+ confidenceValuesAsInternalNames?: boolean): Phylogeny;
124
+ /** A Nexus file can hold several trees; the FIRST is returned. */
125
+ parseNexus(data: string,
126
+ confidenceValuesInBrackets?: boolean,
127
+ confidenceValuesAsInternalNames?: boolean): Phylogeny;
128
+ parseAuspiceJson(data: string | object): Phylogeny;
129
+
130
+ /** Module-level twin of the handle's getSelectedNodes. */
131
+ getSelectedNodes(): PhylogenyNode[];
132
+ }
133
+
134
+ export const archaeopteryx: Archaeopteryx;
135
+
136
+ declare global {
137
+ interface Window {
138
+ /** Set by the script-tag and AMD loading paths. */
139
+ archaeopteryx: Archaeopteryx;
140
+ }
141
+ }