react-cheminfo 0.122.0 → 0.124.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/lib/ecosystem/core/groups.d.ts +1 -1
- package/lib/ecosystem/core/groups.d.ts.map +1 -1
- package/lib/ecosystem/core/groups.js +11 -1
- package/lib/ecosystem/core/groups.js.map +1 -1
- package/lib/ecosystem/core/index.d.ts +2 -2
- package/lib/ecosystem/core/index.d.ts.map +1 -1
- package/lib/ecosystem/core/index.js +1 -1
- package/lib/ecosystem/core/index.js.map +1 -1
- package/lib/ecosystem/core/lookup.d.ts +6 -0
- package/lib/ecosystem/core/lookup.d.ts.map +1 -1
- package/lib/ecosystem/core/lookup.js +8 -0
- package/lib/ecosystem/core/lookup.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts +1 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +134 -3
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +23 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.js +16 -128
- package/lib/ecosystem/core/unlistedSites.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +3 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/host/core/answerGet.js +1 -1
- package/lib/host/core/answerGet.js.map +1 -1
- package/lib/host/core/datasetKinds.d.ts +246 -0
- package/lib/host/core/datasetKinds.d.ts.map +1 -0
- package/lib/host/core/datasetKinds.js +97 -0
- package/lib/host/core/datasetKinds.js.map +1 -0
- package/lib/host/core/hostOutputs.js +1 -1
- package/lib/host/core/hostOutputs.js.map +1 -1
- package/lib/host/core/index.d.ts +6 -1
- package/lib/host/core/index.d.ts.map +1 -1
- package/lib/host/core/index.js +4 -1
- package/lib/host/core/index.js.map +1 -1
- package/lib/host/core/kindAccepts.d.ts +15 -0
- package/lib/host/core/kindAccepts.d.ts.map +1 -0
- package/lib/host/core/kindAccepts.js +22 -0
- package/lib/host/core/kindAccepts.js.map +1 -0
- package/lib/host/core/kinds.d.ts +7 -10
- package/lib/host/core/kinds.d.ts.map +1 -1
- package/lib/host/core/kinds.js +7 -17
- package/lib/host/core/kinds.js.map +1 -1
- package/lib/host/core/selectInputs.d.ts.map +1 -1
- package/lib/host/core/selectInputs.js +2 -1
- package/lib/host/core/selectInputs.js.map +1 -1
- package/lib/host/core/sendTargets.d.ts +32 -0
- package/lib/host/core/sendTargets.d.ts.map +1 -0
- package/lib/host/core/sendTargets.js +40 -0
- package/lib/host/core/sendTargets.js.map +1 -0
- package/lib/host/ui/SendToButton.d.ts +38 -0
- package/lib/host/ui/SendToButton.d.ts.map +1 -0
- package/lib/host/ui/SendToButton.js +61 -0
- package/lib/host/ui/SendToButton.js.map +1 -0
- package/lib/host/ui/index.d.ts +2 -0
- package/lib/host/ui/index.d.ts.map +1 -1
- package/lib/host/ui/index.js +1 -0
- package/lib/host/ui/index.js.map +1 -1
- package/lib/host/ui/openTool.d.ts +16 -8
- package/lib/host/ui/openTool.d.ts.map +1 -1
- package/lib/host/ui/openTool.js +36 -11
- package/lib/host/ui/openTool.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +11 -2
- package/lib/locales/en.json +11 -2
- package/lib/locales/es.json +11 -2
- package/lib/locales/fr.json +11 -2
- package/lib/locales/it.json +11 -2
- package/package.json +1 -1
- package/src/ecosystem/core/groups.ts +13 -1
- package/src/ecosystem/core/index.ts +2 -0
- package/src/ecosystem/core/lookup.ts +9 -0
- package/src/ecosystem/core/sites.ts +141 -3
- package/src/ecosystem/core/types.ts +24 -0
- package/src/ecosystem/core/unlistedSites.ts +16 -134
- package/src/ecosystem/ui/glyphs.tsx +16 -0
- package/src/host/core/answerGet.ts +1 -1
- package/src/host/core/datasetKinds.ts +202 -0
- package/src/host/core/hostOutputs.ts +1 -1
- package/src/host/core/index.ts +12 -1
- package/src/host/core/kindAccepts.ts +21 -0
- package/src/host/core/kinds.ts +14 -18
- package/src/host/core/selectInputs.ts +2 -1
- package/src/host/core/sendTargets.ts +67 -0
- package/src/host/ui/SendToButton.tsx +147 -0
- package/src/host/ui/index.ts +2 -0
- package/src/host/ui/openTool.ts +57 -16
- package/src/locales/de.json +11 -2
- package/src/locales/en.json +11 -2
- package/src/locales/es.json +11 -2
- package/src/locales/fr.json +11 -2
- package/src/locales/it.json +11 -2
|
@@ -35,6 +35,7 @@ export type SiteId =
|
|
|
35
35
|
| 'wikidata'
|
|
36
36
|
| 'mz'
|
|
37
37
|
| 'plot'
|
|
38
|
+
| 'ml'
|
|
38
39
|
| 'vibrations'
|
|
39
40
|
| 'uv-vis'
|
|
40
41
|
| 'nmrium'
|
|
@@ -124,6 +125,29 @@ export interface EcosystemSite extends SiteRecord {
|
|
|
124
125
|
* in the menu and in the footer.
|
|
125
126
|
*/
|
|
126
127
|
group: SiteGroupId;
|
|
128
|
+
/**
|
|
129
|
+
* What the site takes from another site of the family, which is what a Send
|
|
130
|
+
* menu offers to send it.
|
|
131
|
+
* @default undefined — no site sends it anything
|
|
132
|
+
*/
|
|
133
|
+
receives?: readonly SiteReceiver[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* One way a site takes data from another: the kinds its tool's input accepts,
|
|
138
|
+
* and what it does with them. It mirrors one input the site's own `TOOL`
|
|
139
|
+
* announces in its `hello`, which a sender cannot read before opening it.
|
|
140
|
+
*/
|
|
141
|
+
export interface SiteReceiver {
|
|
142
|
+
/** The kinds it accepts, in order of preference, as its input names them. */
|
|
143
|
+
kinds: readonly string[];
|
|
144
|
+
/** What it does with them, in a few words, as the Send menu says it. */
|
|
145
|
+
does: string;
|
|
146
|
+
/**
|
|
147
|
+
* The page it is opened on.
|
|
148
|
+
* @default '/'
|
|
149
|
+
*/
|
|
150
|
+
page?: string;
|
|
127
151
|
}
|
|
128
152
|
|
|
129
153
|
/** The colours a site's mark is drawn in. */
|
|
@@ -33,35 +33,23 @@ export const UNLISTED_SITES: readonly EcosystemSite[] = [
|
|
|
33
33
|
mark: { plate: '#2200c4', accent: '#f97316' },
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
|
-
id: '
|
|
37
|
-
name: { lead: '
|
|
38
|
-
host: '
|
|
39
|
-
tagline:
|
|
40
|
-
'Plot tables and spectra as charts sized and styled for a journal.',
|
|
41
|
-
group: 'drawing',
|
|
42
|
-
// The blue of the pen a curve is drawn with: 7.9:1 on white, and 10.1
|
|
43
|
-
// Oklab units from isomers and mz, the nearest leads.
|
|
44
|
-
brand: '#0024fc',
|
|
45
|
-
// The orange of millimetre paper's grid answers it, at 5:1 for the name.
|
|
46
|
-
brandAlt: '#b45309',
|
|
47
|
-
// The mark's line takes a brighter amber, so it stands apart from the
|
|
48
|
-
// blue plate at 16 px.
|
|
49
|
-
mark: { plate: '#0024fc', accent: '#fbbf24' },
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
id: 'uv-vis',
|
|
53
|
-
name: { lead: 'uv-', alt: 'vis' },
|
|
54
|
-
host: 'uv-vis.cheminfo.org',
|
|
55
|
-
tagline: 'Overlay UV-vis spectra and read off every λmax.',
|
|
36
|
+
id: 'ml',
|
|
37
|
+
name: { lead: 'ml', alt: 'cheminfo', dot: true },
|
|
38
|
+
host: 'ml.cheminfo.org',
|
|
39
|
+
tagline: 'Machine learning on spectra, in the browser.',
|
|
56
40
|
group: 'spectra',
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// The
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
41
|
+
// A purple plate for the statistics, and the teal of the second half
|
|
42
|
+
// answers it at 5.4:1 on white.
|
|
43
|
+
brand: '#6a3d9a',
|
|
44
|
+
brandAlt: '#00796b',
|
|
45
|
+
// The samples at the foot of the clustering tree take an amber.
|
|
46
|
+
mark: { plate: '#6a3d9a', accent: '#ffb000' },
|
|
47
|
+
receives: [
|
|
48
|
+
{
|
|
49
|
+
kinds: ['data.spectra', 'data.table'],
|
|
50
|
+
does: 'Compare the spectra with PCA, OPLS and clustering',
|
|
51
|
+
},
|
|
52
|
+
],
|
|
65
53
|
},
|
|
66
54
|
{
|
|
67
55
|
id: 'nmrium',
|
|
@@ -75,110 +63,4 @@ export const UNLISTED_SITES: readonly EcosystemSite[] = [
|
|
|
75
63
|
brandAlt: '#2b143e',
|
|
76
64
|
mark: { plate: '#2b143e', accent: '#ea580c' },
|
|
77
65
|
},
|
|
78
|
-
{
|
|
79
|
-
id: 'xps',
|
|
80
|
-
name: { lead: 'xps', alt: 'cheminfo', dot: true },
|
|
81
|
-
host: 'xps.cheminfo.org',
|
|
82
|
-
tagline: 'Read, fit and predict X-ray photoelectron spectra.',
|
|
83
|
-
group: 'spectra',
|
|
84
|
-
// Plum, 7.2:1 on white and 8.7 Oklab units from the nearest lead (tex);
|
|
85
|
-
// symmetry has since taken the rose and amber once kept for this site.
|
|
86
|
-
brand: '#97297b',
|
|
87
|
-
// The green an X-ray screen glows. It sits at 1.5:1 on white, so the
|
|
88
|
-
// wordmark sets its second half in this darker green, at 5:1.
|
|
89
|
-
brandAlt: '#4d7c0f',
|
|
90
|
-
mark: { plate: '#97297b', accent: '#a3e635' },
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'biodraw',
|
|
94
|
-
// The name splits on itself, biology and drawing, so it carries no domain.
|
|
95
|
-
name: { lead: 'bio', alt: 'draw', dot: false },
|
|
96
|
-
host: 'biodraw.cheminfo.org',
|
|
97
|
-
tagline: 'Draw cells and membranes, and snap proteins into them.',
|
|
98
|
-
group: 'drawing',
|
|
99
|
-
// Eosin, the pink a cell's cytoplasm takes in the H&E stain every
|
|
100
|
-
// histology slide is read in: 4.6:1 on white, 7.1 Oklab units from
|
|
101
|
-
// molecules, the nearest pink.
|
|
102
|
-
brand: '#db2777',
|
|
103
|
-
// Haematoxylin, the blue-violet the same stain gives a nucleus, at 9.9:1.
|
|
104
|
-
brandAlt: '#3730a3',
|
|
105
|
-
mark: { plate: '#db2777', accent: '#3730a3' },
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
id: 'diagram',
|
|
109
|
-
name: { lead: 'diagram', alt: 'cheminfo', dot: true },
|
|
110
|
-
host: 'diagram.cheminfo.org',
|
|
111
|
-
tagline:
|
|
112
|
-
'Draw flowcharts and block diagrams, with arrows that follow the blocks.',
|
|
113
|
-
group: 'drawing',
|
|
114
|
-
// Coral, the sticky note a block diagram is first laid out on: 5:1 on
|
|
115
|
-
// white, and 7.4 Oklab units from slides, the nearest lead.
|
|
116
|
-
brand: '#b84c59',
|
|
117
|
-
// The cyan of the arrow joining two notes answers it; the name takes the
|
|
118
|
-
// darker cyan, at 5.4:1.
|
|
119
|
-
brandAlt: '#0e7490',
|
|
120
|
-
mark: { plate: '#b84c59', accent: '#67e8f9' },
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
id: 'peptide',
|
|
124
|
-
name: { lead: 'peptide', alt: 'cheminfo', dot: true },
|
|
125
|
-
host: 'peptide.cheminfo.org',
|
|
126
|
-
tagline:
|
|
127
|
-
'Learn peptide synthesis, from protecting groups to the solid phase.',
|
|
128
|
-
group: 'practice',
|
|
129
|
-
// Ruhemann's purple, the colour ninhydrin turns a free amine on a resin
|
|
130
|
-
// bead: 8.5:1 on white, and 7.3 Oklab units from spectroscopy, the
|
|
131
|
-
// nearest lead.
|
|
132
|
-
brand: '#563d8f',
|
|
133
|
-
// The resin bead the chain grows on is teal in the mark; the name takes
|
|
134
|
-
// the darker teal, at 5.5:1.
|
|
135
|
-
brandAlt: '#0f766e',
|
|
136
|
-
mark: { plate: '#563d8f', accent: '#2dd4bf' },
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: 'optics',
|
|
140
|
-
name: { lead: 'optics', alt: 'cheminfo', dot: true },
|
|
141
|
-
host: 'optics.cheminfo.org',
|
|
142
|
-
tagline:
|
|
143
|
-
'Set lenses and mirrors on a bench, and follow the light to its image.',
|
|
144
|
-
group: 'practice',
|
|
145
|
-
// The blue of a lens seen edge on: 7.9:1 on white, and 6.6 Oklab units
|
|
146
|
-
// from 3d, the nearest lead.
|
|
147
|
-
brand: '#2c518e',
|
|
148
|
-
// The red of a laser beam answers it, at 6.5:1; the mark draws its rays
|
|
149
|
-
// in the paler red.
|
|
150
|
-
brandAlt: '#b91c1c',
|
|
151
|
-
mark: { plate: '#2c518e', accent: '#fca5a5' },
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
id: 'circuits',
|
|
155
|
-
name: { lead: 'circuits', alt: 'cheminfo', dot: true },
|
|
156
|
-
host: 'circuits.cheminfo.org',
|
|
157
|
-
tagline:
|
|
158
|
-
'Wire batteries, bulbs and resistors, and read what the meters show.',
|
|
159
|
-
group: 'practice',
|
|
160
|
-
// Copper, what every wire is drawn in: 5.8:1 on white, and 6.2 Oklab
|
|
161
|
-
// units from inorganic and from slides, the nearest leads.
|
|
162
|
-
brand: '#a84811',
|
|
163
|
-
// The blue of a current answers it, at 5.9:1; the mark draws the current
|
|
164
|
-
// in the paler blue.
|
|
165
|
-
brandAlt: '#0369a1',
|
|
166
|
-
mark: { plate: '#a84811', accent: '#7dd3fc' },
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
id: 'mechanics',
|
|
170
|
-
name: { lead: 'mechanics', alt: 'cheminfo', dot: true },
|
|
171
|
-
host: 'mechanics.cheminfo.org',
|
|
172
|
-
tagline:
|
|
173
|
-
'Put a block on a slope or over a pulley, and see the forces add up.',
|
|
174
|
-
group: 'practice',
|
|
175
|
-
// Brass, the weights of a mechanics lab: 5.5:1 on white, and 6.7 Oklab
|
|
176
|
-
// units from osiris, the nearest lead.
|
|
177
|
-
brand: '#7b672e',
|
|
178
|
-
// Violet answers it, 31 Oklab units away so the two halves of the name
|
|
179
|
-
// never read as one, at 7:1; the mark draws the block in the paler
|
|
180
|
-
// violet.
|
|
181
|
-
brandAlt: '#7e22ce',
|
|
182
|
-
mark: { plate: '#7b672e', accent: '#d8b4fe' },
|
|
183
|
-
},
|
|
184
66
|
];
|
|
@@ -589,6 +589,22 @@ export const GLYPHS: Record<SiteId, (alt: string) => ReactNode> = {
|
|
|
589
589
|
<circle cx="23" cy="9.6" r="2.6" fill="#ffffff" />
|
|
590
590
|
</>
|
|
591
591
|
),
|
|
592
|
+
// A clustering tree, what the site draws, joining three samples, which
|
|
593
|
+
// take the answering colour.
|
|
594
|
+
ml: (alt) => (
|
|
595
|
+
<>
|
|
596
|
+
<path
|
|
597
|
+
d="M8 22V14H16V22M12 14V7.5H24V22"
|
|
598
|
+
fill="none"
|
|
599
|
+
stroke="#ffffff"
|
|
600
|
+
strokeWidth="2.6"
|
|
601
|
+
strokeLinejoin="round"
|
|
602
|
+
/>
|
|
603
|
+
<circle cx="8" cy="24" r="2.7" fill={alt} />
|
|
604
|
+
<circle cx="16" cy="24" r="2.7" fill={alt} />
|
|
605
|
+
<circle cx="24" cy="24" r="2.7" fill={alt} />
|
|
606
|
+
</>
|
|
607
|
+
),
|
|
592
608
|
// An infobox: the structure at its top, a ring, and two rows of data under
|
|
593
609
|
// it. The second row carries the answering colour, the blue of a link. Both
|
|
594
610
|
// rows and the gap between them fall on whole pixels at 16 px.
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import type { FigureStates } from '../../download/core/figureState.ts';
|
|
14
14
|
|
|
15
15
|
import type { HostOutputs } from './hostOutputs.ts';
|
|
16
|
-
import { kindAccepts } from './
|
|
16
|
+
import { kindAccepts } from './kindAccepts.ts';
|
|
17
17
|
import type {
|
|
18
18
|
GetRequest,
|
|
19
19
|
HostItem,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `data.spectra`: a set of spectra already read, with their metadata, in the
|
|
3
|
+
* exchange format of ml.cheminfo.org — what a site that parsed the files hands
|
|
4
|
+
* to one that does the statistics.
|
|
5
|
+
*
|
|
6
|
+
* The points of an axis may be a plain list or a `Float64Array`. A window or a
|
|
7
|
+
* port hands a typed array over as one block, so a sender never converts its
|
|
8
|
+
* spectra into lists only to send them. Whether every value is finite, and
|
|
9
|
+
* whether `x` and `y` are as long, is the reader's to say: it can tell which
|
|
10
|
+
* spectrum is wrong, which a schema cannot.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { DoubleArray } from 'cheminfo-types';
|
|
14
|
+
|
|
15
|
+
/** A value of one spectrum's metadata. */
|
|
16
|
+
export type MetaValue = string | number | boolean | null;
|
|
17
|
+
|
|
18
|
+
/** One spectrum of a `data.spectra`. */
|
|
19
|
+
export interface DatasetSpectrumValue {
|
|
20
|
+
/**
|
|
21
|
+
* The sender's reference, unique in the set.
|
|
22
|
+
* @default its position, from 1
|
|
23
|
+
*/
|
|
24
|
+
id?: string;
|
|
25
|
+
/**
|
|
26
|
+
* What the receiving site shows.
|
|
27
|
+
* @default the id
|
|
28
|
+
*/
|
|
29
|
+
label?: string;
|
|
30
|
+
/** The points; `x` may run either way. */
|
|
31
|
+
data: { x: DoubleArray; y: DoubleArray };
|
|
32
|
+
/**
|
|
33
|
+
* The metadata, one value per column key.
|
|
34
|
+
* @default {}
|
|
35
|
+
*/
|
|
36
|
+
meta?: Record<string, MetaValue>;
|
|
37
|
+
/**
|
|
38
|
+
* The colour the sender drew it in.
|
|
39
|
+
* @default undefined
|
|
40
|
+
*/
|
|
41
|
+
color?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** One metadata column of a `data.spectra`. */
|
|
45
|
+
export interface DatasetColumnValue {
|
|
46
|
+
/** The key every spectrum's `meta` uses. */
|
|
47
|
+
key: string;
|
|
48
|
+
/**
|
|
49
|
+
* What the column is called on screen.
|
|
50
|
+
* @default the key
|
|
51
|
+
*/
|
|
52
|
+
label?: string;
|
|
53
|
+
/**
|
|
54
|
+
* What it holds.
|
|
55
|
+
* @default read from the values
|
|
56
|
+
*/
|
|
57
|
+
type?: 'category' | 'number' | 'text';
|
|
58
|
+
/**
|
|
59
|
+
* The units of a numeric column.
|
|
60
|
+
* @default undefined
|
|
61
|
+
*/
|
|
62
|
+
units?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** How one axis of the spectra is named. */
|
|
66
|
+
export interface DatasetAxisValue {
|
|
67
|
+
/** What the axis is called, e.g. `Wavenumber`. */
|
|
68
|
+
label: string;
|
|
69
|
+
/**
|
|
70
|
+
* Its units, e.g. `cm⁻¹`.
|
|
71
|
+
* @default undefined
|
|
72
|
+
*/
|
|
73
|
+
units?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Whether it is drawn decreasing from left to right.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
reversed?: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** `data.spectra`: a set of spectra and their metadata. */
|
|
82
|
+
export interface SpectraDatasetValue {
|
|
83
|
+
/** The spectra, at least one. */
|
|
84
|
+
spectra: DatasetSpectrumValue[];
|
|
85
|
+
/**
|
|
86
|
+
* What the set is called.
|
|
87
|
+
* @default the item's label
|
|
88
|
+
*/
|
|
89
|
+
title?: string;
|
|
90
|
+
/**
|
|
91
|
+
* One paragraph on what it holds.
|
|
92
|
+
* @default undefined
|
|
93
|
+
*/
|
|
94
|
+
description?: string;
|
|
95
|
+
/**
|
|
96
|
+
* The site that made it.
|
|
97
|
+
* @default undefined
|
|
98
|
+
*/
|
|
99
|
+
source?: { name?: string; url?: string };
|
|
100
|
+
/**
|
|
101
|
+
* How the axes are named.
|
|
102
|
+
* @default undefined — unnamed
|
|
103
|
+
*/
|
|
104
|
+
axes?: { x?: DatasetAxisValue; y?: DatasetAxisValue };
|
|
105
|
+
/**
|
|
106
|
+
* The metadata columns, in the order they are shown.
|
|
107
|
+
* @default read from the spectra's `meta`
|
|
108
|
+
*/
|
|
109
|
+
columns?: DatasetColumnValue[];
|
|
110
|
+
/**
|
|
111
|
+
* The column whose values are the classes.
|
|
112
|
+
* @default undefined
|
|
113
|
+
*/
|
|
114
|
+
classKey?: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The keyword the schema checks an axis with: a list of numbers, or a `Float64Array`. */
|
|
118
|
+
export const NUMBER_ARRAY_KEYWORD = {
|
|
119
|
+
keyword: 'numberArray',
|
|
120
|
+
schemaType: 'boolean',
|
|
121
|
+
errors: false,
|
|
122
|
+
validate: (expected: boolean, data: unknown) =>
|
|
123
|
+
isNumberArray(data) === expected,
|
|
124
|
+
} as const;
|
|
125
|
+
|
|
126
|
+
const AXIS_SCHEMA = {
|
|
127
|
+
type: 'object',
|
|
128
|
+
properties: {
|
|
129
|
+
label: { type: 'string' },
|
|
130
|
+
units: { type: 'string' },
|
|
131
|
+
reversed: { type: 'boolean' },
|
|
132
|
+
},
|
|
133
|
+
required: ['label'],
|
|
134
|
+
} as const;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The schema of `data.spectra`. Fields it does not name are kept: the
|
|
138
|
+
* exchange format carries a version and the sender's own metadata.
|
|
139
|
+
*/
|
|
140
|
+
export const SPECTRA_DATASET_SCHEMA = {
|
|
141
|
+
type: 'object',
|
|
142
|
+
properties: {
|
|
143
|
+
title: { type: 'string' },
|
|
144
|
+
description: { type: 'string' },
|
|
145
|
+
source: {
|
|
146
|
+
type: 'object',
|
|
147
|
+
properties: { name: { type: 'string' }, url: { type: 'string' } },
|
|
148
|
+
},
|
|
149
|
+
axes: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: { x: AXIS_SCHEMA, y: AXIS_SCHEMA },
|
|
152
|
+
},
|
|
153
|
+
columns: {
|
|
154
|
+
type: 'array',
|
|
155
|
+
items: {
|
|
156
|
+
type: 'object',
|
|
157
|
+
properties: {
|
|
158
|
+
key: { type: 'string' },
|
|
159
|
+
label: { type: 'string' },
|
|
160
|
+
type: { enum: ['category', 'number', 'text'] },
|
|
161
|
+
units: { type: 'string' },
|
|
162
|
+
},
|
|
163
|
+
required: ['key'],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
classKey: { type: 'string' },
|
|
167
|
+
spectra: {
|
|
168
|
+
type: 'array',
|
|
169
|
+
minItems: 1,
|
|
170
|
+
items: {
|
|
171
|
+
type: 'object',
|
|
172
|
+
properties: {
|
|
173
|
+
id: { type: 'string' },
|
|
174
|
+
label: { type: 'string' },
|
|
175
|
+
data: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
properties: {
|
|
178
|
+
x: { numberArray: true },
|
|
179
|
+
y: { numberArray: true },
|
|
180
|
+
},
|
|
181
|
+
required: ['x', 'y'],
|
|
182
|
+
},
|
|
183
|
+
// A value of another type is the reader's to leave out with a
|
|
184
|
+
// warning, rather than a reason to refuse the whole set.
|
|
185
|
+
meta: { type: 'object' },
|
|
186
|
+
color: { type: 'string' },
|
|
187
|
+
},
|
|
188
|
+
required: ['data'],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
required: ['spectra'],
|
|
193
|
+
} as const;
|
|
194
|
+
|
|
195
|
+
function isNumberArray(data: unknown): boolean {
|
|
196
|
+
if (data instanceof Float64Array) return true;
|
|
197
|
+
if (!Array.isArray(data)) return false;
|
|
198
|
+
for (let index = 0; index < data.length; index++) {
|
|
199
|
+
if (typeof data[index] !== 'number') return false;
|
|
200
|
+
}
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* and never sent unasked.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { kindAccepts } from './
|
|
15
|
+
import { kindAccepts } from './kindAccepts.ts';
|
|
16
16
|
import type { HostItem, OutputMessage } from './protocol.ts';
|
|
17
17
|
|
|
18
18
|
/** Where a tool's outputs are read, and how their changes are heard. */
|
package/src/host/core/index.ts
CHANGED
|
@@ -33,6 +33,14 @@ export {
|
|
|
33
33
|
} from './hostStructure.ts';
|
|
34
34
|
export type { BandStrength } from './bandStrength.ts';
|
|
35
35
|
export { BAND_STRENGTHS, BAND_STRENGTH_SCHEMA } from './bandStrength.ts';
|
|
36
|
+
export type {
|
|
37
|
+
DatasetAxisValue,
|
|
38
|
+
DatasetColumnValue,
|
|
39
|
+
DatasetSpectrumValue,
|
|
40
|
+
MetaValue,
|
|
41
|
+
SpectraDatasetValue,
|
|
42
|
+
} from './datasetKinds.ts';
|
|
43
|
+
export { SPECTRA_DATASET_SCHEMA } from './datasetKinds.ts';
|
|
36
44
|
export type { IrJdxValue, IrPeakValue, IrPeaksValue } from './irKinds.ts';
|
|
37
45
|
export { IR_JDX_SCHEMA, IR_PEAKS_SCHEMA } from './irKinds.ts';
|
|
38
46
|
export type {
|
|
@@ -44,7 +52,8 @@ export type {
|
|
|
44
52
|
OclIdValue,
|
|
45
53
|
SmilesValue,
|
|
46
54
|
} from './kinds.ts';
|
|
47
|
-
export { checkValue, isKnownKind,
|
|
55
|
+
export { checkValue, isKnownKind, readOutput } from './kinds.ts';
|
|
56
|
+
export { kindAccepts } from './kindAccepts.ts';
|
|
48
57
|
export type {
|
|
49
58
|
MsAssignmentValue,
|
|
50
59
|
MsAssignmentsValue,
|
|
@@ -120,3 +129,5 @@ export { toolAboutUrl, toolPageUrl } from './toolPage.ts';
|
|
|
120
129
|
export type { ToolHello } from './toolMessages.ts';
|
|
121
130
|
export { readSettingFields } from './toolSettings.ts';
|
|
122
131
|
export { readHello, readToolMessage } from './toolMessages.ts';
|
|
132
|
+
export type { SendOffer, SendTarget } from './sendTargets.ts';
|
|
133
|
+
export { sendTargets } from './sendTargets.ts';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How one kind name falls under another, apart from the schemas of
|
|
3
|
+
* `./kinds.ts`, so a page that only matches kinds — a Send menu — never loads
|
|
4
|
+
* ajv.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Whether a kind falls under another: the same name, or a name under it on a
|
|
9
|
+
* segment boundary. A list (`…[]`) never stands for one value, nor one value
|
|
10
|
+
* for a list.
|
|
11
|
+
* @param accepted - The kind a tool declares, e.g. `'chem.molfile'`.
|
|
12
|
+
* @param offered - The kind an item carries, e.g. `'chem.molfile.2d'`.
|
|
13
|
+
* @returns `true` when an item of `offered` can be read as `accepted`.
|
|
14
|
+
*/
|
|
15
|
+
export function kindAccepts(accepted: string, offered: string): boolean {
|
|
16
|
+
const list = accepted.endsWith('[]');
|
|
17
|
+
if (offered.endsWith('[]') !== list) return false;
|
|
18
|
+
const base = list ? accepted.slice(0, -2) : accepted;
|
|
19
|
+
const name = list ? offered.slice(0, -2) : offered;
|
|
20
|
+
return name === base || name.startsWith(`${base}.`);
|
|
21
|
+
}
|
package/src/host/core/kinds.ts
CHANGED
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* kinds of `./irKinds.ts`, the Raman ones of `./ramanKinds.ts`, the UV-vis
|
|
9
9
|
* ones of `./uvKinds.ts` and the mass
|
|
10
10
|
* spectrometry ones of `./msKinds.ts`, the reaction of `./reactionKinds.ts`,
|
|
11
|
-
* the peptide of `./peptideKinds.ts`,
|
|
11
|
+
* the peptide of `./peptideKinds.ts`, the set of spectra of
|
|
12
|
+
* `./datasetKinds.ts`, and
|
|
12
13
|
* the kinds a tool hands back, of `./resultKinds.ts`. A name with children is a category whose
|
|
13
14
|
* schema every child satisfies, so `chem.molfile` reads `chem.molfile.2d` and
|
|
14
15
|
* `chem.molfile.3d.h.energy` alike; the fields a tool does not read are
|
|
@@ -19,8 +20,14 @@
|
|
|
19
20
|
import type { JSONSchemaType, ValidateFunction } from 'ajv';
|
|
20
21
|
import { Ajv } from 'ajv';
|
|
21
22
|
|
|
23
|
+
import type { SpectraDatasetValue } from './datasetKinds.ts';
|
|
24
|
+
import {
|
|
25
|
+
NUMBER_ARRAY_KEYWORD,
|
|
26
|
+
SPECTRA_DATASET_SCHEMA,
|
|
27
|
+
} from './datasetKinds.ts';
|
|
22
28
|
import type { IrJdxValue, IrPeaksValue } from './irKinds.ts';
|
|
23
29
|
import { IR_JDX_SCHEMA, IR_PEAKS_SCHEMA } from './irKinds.ts';
|
|
30
|
+
import { kindAccepts } from './kindAccepts.ts';
|
|
24
31
|
import type { MsAssignmentsValue, MsIonsValue, MsJdxValue } from './msKinds.ts';
|
|
25
32
|
import {
|
|
26
33
|
MS_ASSIGNMENTS_SCHEMA,
|
|
@@ -73,7 +80,10 @@ export type CheckedValue =
|
|
|
73
80
|
| { kind: 'spectra.ms.assignments'; value: MsAssignmentsValue }
|
|
74
81
|
| { kind: 'image.svg'; value: SvgImageValue }
|
|
75
82
|
| { kind: 'chem.name'; value: NameValue }
|
|
76
|
-
| { kind: 'data.table'; value: TableValue }
|
|
83
|
+
| { kind: 'data.table'; value: TableValue }
|
|
84
|
+
| { kind: 'data.spectra'; value: SpectraDatasetValue };
|
|
85
|
+
|
|
86
|
+
export { kindAccepts } from './kindAccepts.ts';
|
|
77
87
|
|
|
78
88
|
/** The name of a kind there is a schema for: one a tool reads, or one it hands back. */
|
|
79
89
|
export type KnownKind = CheckedValue['kind'];
|
|
@@ -88,22 +98,6 @@ type ValueOf<K extends KnownKind> = CheckedOf<K>['value'];
|
|
|
88
98
|
export type CheckOutcome =
|
|
89
99
|
{ valid: true; checked: CheckedValue } | { valid: false; errors: string[] };
|
|
90
100
|
|
|
91
|
-
/**
|
|
92
|
-
* Whether a kind falls under another: the same name, or a name under it on a
|
|
93
|
-
* segment boundary. A list (`…[]`) never stands for one value, nor one value
|
|
94
|
-
* for a list.
|
|
95
|
-
* @param accepted - The kind a tool declares, e.g. `'chem.molfile'`.
|
|
96
|
-
* @param offered - The kind an item carries, e.g. `'chem.molfile.2d'`.
|
|
97
|
-
* @returns `true` when an item of `offered` can be read as `accepted`.
|
|
98
|
-
*/
|
|
99
|
-
export function kindAccepts(accepted: string, offered: string): boolean {
|
|
100
|
-
const list = accepted.endsWith('[]');
|
|
101
|
-
if (offered.endsWith('[]') !== list) return false;
|
|
102
|
-
const base = list ? accepted.slice(0, -2) : accepted;
|
|
103
|
-
const name = list ? offered.slice(0, -2) : offered;
|
|
104
|
-
return name === base || name.startsWith(`${base}.`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
101
|
/**
|
|
108
102
|
* Whether there is a schema for a kind.
|
|
109
103
|
* @param kind - A kind name.
|
|
@@ -194,6 +188,7 @@ const SMILES_SCHEMA: JSONSchemaType<SmilesValue> = {
|
|
|
194
188
|
// `removeAdditional` strips what `additionalProperties: false` would refuse;
|
|
195
189
|
// a table's cell is a string, a number or null, which is a union of types.
|
|
196
190
|
const ajv = new Ajv({ removeAdditional: true, allowUnionTypes: true });
|
|
191
|
+
ajv.addKeyword(NUMBER_ARRAY_KEYWORD);
|
|
197
192
|
|
|
198
193
|
const VALIDATORS: { [K in KnownKind]: ValidateFunction<ValueOf<K>> } = {
|
|
199
194
|
'chem.molfile': ajv.compile(MOLFILE_SCHEMA),
|
|
@@ -217,4 +212,5 @@ const VALIDATORS: { [K in KnownKind]: ValidateFunction<ValueOf<K>> } = {
|
|
|
217
212
|
'image.svg': ajv.compile<SvgImageValue>(SVG_IMAGE_SCHEMA),
|
|
218
213
|
'chem.name': ajv.compile<NameValue>(NAME_SCHEMA),
|
|
219
214
|
'data.table': ajv.compile<TableValue>(TABLE_SCHEMA),
|
|
215
|
+
'data.spectra': ajv.compile<SpectraDatasetValue>(SPECTRA_DATASET_SCHEMA),
|
|
220
216
|
};
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* host is answered with when the request loads nothing.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { kindAccepts } from './kindAccepts.ts';
|
|
6
7
|
import type { CheckedValue, KnownKind } from './kinds.ts';
|
|
7
|
-
import { checkValue, isKnownKind
|
|
8
|
+
import { checkValue, isKnownKind } from './kinds.ts';
|
|
8
9
|
import type {
|
|
9
10
|
HostError,
|
|
10
11
|
HostItem,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which sites of the family can take what a page could send them: matched on
|
|
3
|
+
* the kinds alone, from what the registry says each site receives, before
|
|
4
|
+
* anything is built or any site is opened.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { knownSites } from '../../ecosystem/core/lookup.ts';
|
|
8
|
+
import type {
|
|
9
|
+
EcosystemSite,
|
|
10
|
+
SiteReceiver,
|
|
11
|
+
} from '../../ecosystem/core/types.ts';
|
|
12
|
+
|
|
13
|
+
import { kindAccepts } from './kindAccepts.ts';
|
|
14
|
+
|
|
15
|
+
/** Something a page could send, named before it is built. */
|
|
16
|
+
export interface SendOffer {
|
|
17
|
+
/** The kind it would be sent as, e.g. `'data.spectra'`. */
|
|
18
|
+
kind: string;
|
|
19
|
+
/** What it is, as the menu names it, e.g. `'3 IR spectra'`. */
|
|
20
|
+
label: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A site that can take one of the offers, and how. */
|
|
24
|
+
export interface SendTarget<Offer extends SendOffer = SendOffer> {
|
|
25
|
+
/** The site. */
|
|
26
|
+
site: EcosystemSite;
|
|
27
|
+
/** The way it takes data that matched. */
|
|
28
|
+
receiver: SiteReceiver;
|
|
29
|
+
/** The offer it takes: the first of its kinds that any offer carries. */
|
|
30
|
+
offer: Offer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The sites that can take one of the offers, in the order the family declares
|
|
35
|
+
* them. A site whose receiver accepts several offers takes the one its own
|
|
36
|
+
* order of kinds prefers.
|
|
37
|
+
* @param offers - What the page could send, in its own order of preference.
|
|
38
|
+
* @param from - The site sending, which is never offered to itself.
|
|
39
|
+
* @returns One target per site receiver that accepts an offer.
|
|
40
|
+
*/
|
|
41
|
+
export function sendTargets<Offer extends SendOffer>(
|
|
42
|
+
offers: readonly Offer[],
|
|
43
|
+
from?: string,
|
|
44
|
+
): Array<SendTarget<Offer>> {
|
|
45
|
+
const targets: Array<SendTarget<Offer>> = [];
|
|
46
|
+
if (offers.length === 0) return targets;
|
|
47
|
+
for (const site of knownSites()) {
|
|
48
|
+
if (site.id === from) continue;
|
|
49
|
+
for (const receiver of site.receives ?? []) {
|
|
50
|
+
const offer = preferredOffer(receiver, offers);
|
|
51
|
+
if (offer !== undefined) targets.push({ site, receiver, offer });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return targets;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function preferredOffer<Offer extends SendOffer>(
|
|
58
|
+
receiver: SiteReceiver,
|
|
59
|
+
offers: readonly Offer[],
|
|
60
|
+
): Offer | undefined {
|
|
61
|
+
for (const accepted of receiver.kinds) {
|
|
62
|
+
for (const offer of offers) {
|
|
63
|
+
if (kindAccepts(accepted, offer.kind)) return offer;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|