react-cheminfo 0.121.0 → 0.123.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 (118) hide show
  1. package/lib/drawing/core/index.d.ts +2 -0
  2. package/lib/drawing/core/index.d.ts.map +1 -1
  3. package/lib/drawing/core/index.js +1 -0
  4. package/lib/drawing/core/index.js.map +1 -1
  5. package/lib/drawing/core/undoHistory.d.ts +59 -0
  6. package/lib/drawing/core/undoHistory.d.ts.map +1 -0
  7. package/lib/drawing/core/undoHistory.js +68 -0
  8. package/lib/drawing/core/undoHistory.js.map +1 -0
  9. package/lib/ecosystem/core/index.d.ts +2 -2
  10. package/lib/ecosystem/core/index.d.ts.map +1 -1
  11. package/lib/ecosystem/core/index.js +1 -1
  12. package/lib/ecosystem/core/index.js.map +1 -1
  13. package/lib/ecosystem/core/lookup.d.ts +6 -0
  14. package/lib/ecosystem/core/lookup.d.ts.map +1 -1
  15. package/lib/ecosystem/core/lookup.js +8 -0
  16. package/lib/ecosystem/core/lookup.js.map +1 -1
  17. package/lib/ecosystem/core/sites.d.ts +1 -1
  18. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  19. package/lib/ecosystem/core/sites.js.map +1 -1
  20. package/lib/ecosystem/core/types.d.ts +23 -1
  21. package/lib/ecosystem/core/types.d.ts.map +1 -1
  22. package/lib/ecosystem/core/unlistedSites.d.ts.map +1 -1
  23. package/lib/ecosystem/core/unlistedSites.js +77 -0
  24. package/lib/ecosystem/core/unlistedSites.js.map +1 -1
  25. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  26. package/lib/ecosystem/ui/glyphs.js +16 -0
  27. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  28. package/lib/host/core/answerGet.js +1 -1
  29. package/lib/host/core/answerGet.js.map +1 -1
  30. package/lib/host/core/datasetKinds.d.ts +246 -0
  31. package/lib/host/core/datasetKinds.d.ts.map +1 -0
  32. package/lib/host/core/datasetKinds.js +97 -0
  33. package/lib/host/core/datasetKinds.js.map +1 -0
  34. package/lib/host/core/hostOutputs.js +1 -1
  35. package/lib/host/core/hostOutputs.js.map +1 -1
  36. package/lib/host/core/index.d.ts +6 -1
  37. package/lib/host/core/index.d.ts.map +1 -1
  38. package/lib/host/core/index.js +4 -1
  39. package/lib/host/core/index.js.map +1 -1
  40. package/lib/host/core/kindAccepts.d.ts +15 -0
  41. package/lib/host/core/kindAccepts.d.ts.map +1 -0
  42. package/lib/host/core/kindAccepts.js +22 -0
  43. package/lib/host/core/kindAccepts.js.map +1 -0
  44. package/lib/host/core/kinds.d.ts +7 -10
  45. package/lib/host/core/kinds.d.ts.map +1 -1
  46. package/lib/host/core/kinds.js +7 -17
  47. package/lib/host/core/kinds.js.map +1 -1
  48. package/lib/host/core/selectInputs.d.ts.map +1 -1
  49. package/lib/host/core/selectInputs.js +2 -1
  50. package/lib/host/core/selectInputs.js.map +1 -1
  51. package/lib/host/core/sendTargets.d.ts +32 -0
  52. package/lib/host/core/sendTargets.d.ts.map +1 -0
  53. package/lib/host/core/sendTargets.js +40 -0
  54. package/lib/host/core/sendTargets.js.map +1 -0
  55. package/lib/host/ui/SendToButton.d.ts +38 -0
  56. package/lib/host/ui/SendToButton.d.ts.map +1 -0
  57. package/lib/host/ui/SendToButton.js +61 -0
  58. package/lib/host/ui/SendToButton.js.map +1 -0
  59. package/lib/host/ui/index.d.ts +2 -0
  60. package/lib/host/ui/index.d.ts.map +1 -1
  61. package/lib/host/ui/index.js +1 -0
  62. package/lib/host/ui/index.js.map +1 -1
  63. package/lib/host/ui/openTool.d.ts +16 -8
  64. package/lib/host/ui/openTool.d.ts.map +1 -1
  65. package/lib/host/ui/openTool.js +36 -11
  66. package/lib/host/ui/openTool.js.map +1 -1
  67. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  68. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  69. package/lib/locales/de.json +10 -1
  70. package/lib/locales/en.json +10 -1
  71. package/lib/locales/es.json +10 -1
  72. package/lib/locales/fr.json +10 -1
  73. package/lib/locales/it.json +10 -1
  74. package/lib/panel/core/createPanelState.d.ts +58 -0
  75. package/lib/panel/core/createPanelState.d.ts.map +1 -0
  76. package/lib/panel/core/createPanelState.js +74 -0
  77. package/lib/panel/core/createPanelState.js.map +1 -0
  78. package/lib/panel/core/index.d.ts +2 -0
  79. package/lib/panel/core/index.d.ts.map +1 -1
  80. package/lib/panel/core/index.js +1 -0
  81. package/lib/panel/core/index.js.map +1 -1
  82. package/lib/panel/ui/PanelFrame.d.ts +27 -0
  83. package/lib/panel/ui/PanelFrame.d.ts.map +1 -0
  84. package/lib/panel/ui/PanelFrame.js +12 -0
  85. package/lib/panel/ui/PanelFrame.js.map +1 -0
  86. package/lib/panel/ui/index.d.ts +2 -0
  87. package/lib/panel/ui/index.d.ts.map +1 -1
  88. package/lib/panel/ui/index.js +1 -0
  89. package/lib/panel/ui/index.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/drawing/core/index.ts +2 -0
  92. package/src/drawing/core/undoHistory.ts +118 -0
  93. package/src/ecosystem/core/index.ts +2 -0
  94. package/src/ecosystem/core/lookup.ts +9 -0
  95. package/src/ecosystem/core/sites.ts +1 -0
  96. package/src/ecosystem/core/types.ts +28 -0
  97. package/src/ecosystem/core/unlistedSites.ts +81 -0
  98. package/src/ecosystem/ui/glyphs.tsx +97 -0
  99. package/src/host/core/answerGet.ts +1 -1
  100. package/src/host/core/datasetKinds.ts +202 -0
  101. package/src/host/core/hostOutputs.ts +1 -1
  102. package/src/host/core/index.ts +12 -1
  103. package/src/host/core/kindAccepts.ts +21 -0
  104. package/src/host/core/kinds.ts +14 -18
  105. package/src/host/core/selectInputs.ts +2 -1
  106. package/src/host/core/sendTargets.ts +67 -0
  107. package/src/host/ui/SendToButton.tsx +147 -0
  108. package/src/host/ui/index.ts +2 -0
  109. package/src/host/ui/openTool.ts +57 -16
  110. package/src/locales/de.json +10 -1
  111. package/src/locales/en.json +10 -1
  112. package/src/locales/es.json +10 -1
  113. package/src/locales/fr.json +10 -1
  114. package/src/locales/it.json +10 -1
  115. package/src/panel/core/createPanelState.ts +126 -0
  116. package/src/panel/core/index.ts +6 -0
  117. package/src/panel/ui/PanelFrame.tsx +47 -0
  118. package/src/panel/ui/index.ts +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/panel/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAKhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAAgC,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAmB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAM5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/panel/ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAKhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAAgC,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,kBAAmB,CAAC;AAE9E,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAM5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC;AAE5C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAe,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA2B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.121.0",
3
+ "version": "0.123.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
@@ -170,3 +170,5 @@ export { pointMap } from './transform.ts';
170
170
  export type { Box, DrawPage, FigureSize, Point } from './types.ts';
171
171
  export { arrayOf, isFiniteNumber, isRecord } from './values.ts';
172
172
  export { along, leftOf, turnAbout, unit } from './vectors.ts';
173
+ export type { UndoHistory, UndoHistoryOptions } from './undoHistory.ts';
174
+ export { createUndoHistory } from './undoHistory.ts';
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The undo history of an editor's document, kept on the site's own signals: a
3
+ * change that is done is committed and can be undone, and a gesture shows the
4
+ * document as it goes with `preview`, then commits once when it ends, so one
5
+ * drag is one step back.
6
+ */
7
+
8
+ import type { Cell, SignalTools } from '../../storage/core/documentFile.ts';
9
+
10
+ /** What an undo history is kept on. */
11
+ export interface UndoHistoryOptions<D> {
12
+ /** The document on screen: the site's own signal. */
13
+ document: Cell<D>;
14
+ /**
15
+ * A counter the history moves at every step, so `canUndo` and `canRedo`,
16
+ * read inside a `computed`, follow it.
17
+ */
18
+ steps: Cell<number>;
19
+ /** `batch` from the site's signals, so a step is one change. */
20
+ signals: Pick<SignalTools, 'batch'>;
21
+ /**
22
+ * Called once undo or redo has put a step on screen, in the same batch: a
23
+ * site keeps there only the selection the step still holds.
24
+ * @default nothing is called
25
+ */
26
+ shown?: (document: D) => void;
27
+ /**
28
+ * How many steps can be undone.
29
+ * @default 200
30
+ */
31
+ limit?: number;
32
+ }
33
+
34
+ /** The undo history of a document. */
35
+ export interface UndoHistory<D> {
36
+ /** Whether there is a step to undo; a `computed` reading it follows it. */
37
+ canUndo: () => boolean;
38
+ /** Whether there is a step to redo; a `computed` reading it follows it. */
39
+ canRedo: () => boolean;
40
+ /** Show a document while a gesture is under way, without making a step. */
41
+ preview: (next: D) => void;
42
+ /**
43
+ * Commit a change.
44
+ * @param next - The document after it.
45
+ * @param before - What the step goes back to: the document a gesture
46
+ * started from; the one on screen when omitted.
47
+ */
48
+ commit: (next: D, before?: D) => void;
49
+ /** Put a document on screen with no history: a file opened, a draft back. */
50
+ restart: (next: D) => void;
51
+ /** Go back one step. */
52
+ undo: () => void;
53
+ /** Go forward again one step. */
54
+ redo: () => void;
55
+ }
56
+
57
+ /**
58
+ * Keep the undo history of a document.
59
+ * @param options - The document, the step counter and the site's `batch`.
60
+ * @returns The history.
61
+ */
62
+ export function createUndoHistory<D>(
63
+ options: UndoHistoryOptions<D>,
64
+ ): UndoHistory<D> {
65
+ const { document, steps, signals, shown, limit = 200 } = options;
66
+ const past: D[] = [];
67
+ const future: D[] = [];
68
+
69
+ const step = () => {
70
+ steps.value = steps.peek() + 1;
71
+ };
72
+ const showStep = (shownDocument: D) => {
73
+ signals.batch(() => {
74
+ document.value = shownDocument;
75
+ shown?.(shownDocument);
76
+ step();
77
+ });
78
+ };
79
+
80
+ return {
81
+ canUndo: () => steps.value >= 0 && past.length > 0,
82
+ canRedo: () => steps.value >= 0 && future.length > 0,
83
+ preview: (next) => {
84
+ document.value = next;
85
+ },
86
+ commit: (next, before = document.peek()) => {
87
+ signals.batch(() => {
88
+ if (next !== before) {
89
+ past.push(before);
90
+ if (past.length > limit) past.shift();
91
+ future.length = 0;
92
+ step();
93
+ }
94
+ document.value = next;
95
+ });
96
+ },
97
+ restart: (next) => {
98
+ past.length = 0;
99
+ future.length = 0;
100
+ signals.batch(() => {
101
+ document.value = next;
102
+ step();
103
+ });
104
+ },
105
+ undo: () => {
106
+ const previous = past.pop();
107
+ if (previous === undefined) return;
108
+ future.push(document.peek());
109
+ showStep(previous);
110
+ },
111
+ redo: () => {
112
+ const next = future.pop();
113
+ if (next === undefined) return;
114
+ past.push(document.peek());
115
+ showStep(next);
116
+ },
117
+ };
118
+ }
@@ -6,6 +6,7 @@ export {
6
6
  findSiteById,
7
7
  groupedSites,
8
8
  isSameSite,
9
+ knownSites,
9
10
  presentSiteId,
10
11
  siteById,
11
12
  siteDisplayName,
@@ -17,6 +18,7 @@ export type {
17
18
  SiteId,
18
19
  SiteMarkColors,
19
20
  SiteName,
21
+ SiteReceiver,
20
22
  SiteRecord,
21
23
  SiteUrlOptions,
22
24
  } from './sites.ts';
@@ -10,6 +10,15 @@ const KNOWN_SITES: readonly EcosystemSite[] = [
10
10
  ...UNLISTED_SITES,
11
11
  ];
12
12
 
13
+ /**
14
+ * Every site of the family, listed in the menu or not yet: what a lookup
15
+ * searches, and what a Send menu picks the sites that take its data from.
16
+ * @returns The listed sites, then the unlisted ones, in declaration order.
17
+ */
18
+ export function knownSites(): readonly EcosystemSite[] {
19
+ return KNOWN_SITES;
20
+ }
21
+
13
22
  /** One topic and the sites written under it. */
14
23
  export interface GroupedSites {
15
24
  /** The topic. */
@@ -8,6 +8,7 @@ export type {
8
8
  SiteId,
9
9
  SiteMarkColors,
10
10
  SiteName,
11
+ SiteReceiver,
11
12
  SiteRecord,
12
13
  } from './types.ts';
13
14
 
@@ -34,6 +34,8 @@ export type SiteId =
34
34
  | 'chembio'
35
35
  | 'wikidata'
36
36
  | 'mz'
37
+ | 'plot'
38
+ | 'ml'
37
39
  | 'vibrations'
38
40
  | 'uv-vis'
39
41
  | 'nmrium'
@@ -41,6 +43,9 @@ export type SiteId =
41
43
  | 'biodraw'
42
44
  | 'diagram'
43
45
  | 'peptide'
46
+ | 'optics'
47
+ | 'circuits'
48
+ | 'mechanics'
44
49
  | 'draw'
45
50
  | 'plate'
46
51
  | 'glassware'
@@ -120,6 +125,29 @@ export interface EcosystemSite extends SiteRecord {
120
125
  * in the menu and in the footer.
121
126
  */
122
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;
123
151
  }
124
152
 
125
153
  /** The colours a site's mark is drawn in. */
@@ -32,6 +32,41 @@ export const UNLISTED_SITES: readonly EcosystemSite[] = [
32
32
  // the ultramarine plate at 16 px.
33
33
  mark: { plate: '#2200c4', accent: '#f97316' },
34
34
  },
35
+ {
36
+ id: 'plot',
37
+ name: { lead: 'plot', alt: 'cheminfo', dot: true },
38
+ host: 'plot.cheminfo.org',
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: 'ml',
53
+ name: { lead: 'ml', alt: 'cheminfo', dot: true },
54
+ host: 'ml.cheminfo.org',
55
+ tagline: 'Machine learning on spectra, in the browser.',
56
+ group: 'spectra',
57
+ // A purple plate for the statistics, and the teal of the second half
58
+ // answers it at 5.4:1 on white.
59
+ brand: '#6a3d9a',
60
+ brandAlt: '#00796b',
61
+ // The samples at the foot of the clustering tree take an amber.
62
+ mark: { plate: '#6a3d9a', accent: '#ffb000' },
63
+ receives: [
64
+ {
65
+ kinds: ['data.spectra', 'data.table'],
66
+ does: 'Compare the spectra with PCA, OPLS and clustering',
67
+ },
68
+ ],
69
+ },
35
70
  {
36
71
  id: 'uv-vis',
37
72
  name: { lead: 'uv-', alt: 'vis' },
@@ -119,4 +154,50 @@ export const UNLISTED_SITES: readonly EcosystemSite[] = [
119
154
  brandAlt: '#0f766e',
120
155
  mark: { plate: '#563d8f', accent: '#2dd4bf' },
121
156
  },
157
+ {
158
+ id: 'optics',
159
+ name: { lead: 'optics', alt: 'cheminfo', dot: true },
160
+ host: 'optics.cheminfo.org',
161
+ tagline:
162
+ 'Set lenses and mirrors on a bench, and follow the light to its image.',
163
+ group: 'practice',
164
+ // The blue of a lens seen edge on: 7.9:1 on white, and 6.6 Oklab units
165
+ // from 3d, the nearest lead.
166
+ brand: '#2c518e',
167
+ // The red of a laser beam answers it, at 6.5:1; the mark draws its rays
168
+ // in the paler red.
169
+ brandAlt: '#b91c1c',
170
+ mark: { plate: '#2c518e', accent: '#fca5a5' },
171
+ },
172
+ {
173
+ id: 'circuits',
174
+ name: { lead: 'circuits', alt: 'cheminfo', dot: true },
175
+ host: 'circuits.cheminfo.org',
176
+ tagline:
177
+ 'Wire batteries, bulbs and resistors, and read what the meters show.',
178
+ group: 'practice',
179
+ // Copper, what every wire is drawn in: 5.8:1 on white, and 6.2 Oklab
180
+ // units from inorganic and from slides, the nearest leads.
181
+ brand: '#a84811',
182
+ // The blue of a current answers it, at 5.9:1; the mark draws the current
183
+ // in the paler blue.
184
+ brandAlt: '#0369a1',
185
+ mark: { plate: '#a84811', accent: '#7dd3fc' },
186
+ },
187
+ {
188
+ id: 'mechanics',
189
+ name: { lead: 'mechanics', alt: 'cheminfo', dot: true },
190
+ host: 'mechanics.cheminfo.org',
191
+ tagline:
192
+ 'Put a block on a slope or over a pulley, and see the forces add up.',
193
+ group: 'practice',
194
+ // Brass, the weights of a mechanics lab: 5.5:1 on white, and 6.7 Oklab
195
+ // units from osiris, the nearest lead.
196
+ brand: '#7b672e',
197
+ // Violet answers it, 31 Oklab units away so the two halves of the name
198
+ // never read as one, at 7:1; the mark draws the block in the paler
199
+ // violet.
200
+ brandAlt: '#7e22ce',
201
+ mark: { plate: '#7b672e', accent: '#d8b4fe' },
202
+ },
122
203
  ];
@@ -564,6 +564,47 @@ export const GLYPHS: Record<SiteId, (alt: string) => ReactNode> = {
564
564
  <rect x="22" y="12" width="4" height="14" rx="1" fill="#ffffff" />
565
565
  </>
566
566
  ),
567
+ // A calibration line on the two axes of a plot: three measured points in
568
+ // white, scattered about the straight line fitted through them, which
569
+ // carries the answering colour.
570
+ plot: (alt) => (
571
+ <>
572
+ <path
573
+ d="M6 5v21h21"
574
+ fill="none"
575
+ stroke="#ffffff"
576
+ strokeWidth="2.4"
577
+ strokeLinecap="round"
578
+ strokeLinejoin="round"
579
+ />
580
+ <path
581
+ d="M9 22.5 26 8"
582
+ fill="none"
583
+ stroke={alt}
584
+ strokeWidth="2.6"
585
+ strokeLinecap="round"
586
+ />
587
+ <circle cx="12" cy="18.6" r="2.6" fill="#ffffff" />
588
+ <circle cx="17.5" cy="16.4" r="2.6" fill="#ffffff" />
589
+ <circle cx="23" cy="9.6" r="2.6" fill="#ffffff" />
590
+ </>
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
+ ),
567
608
  // An infobox: the structure at its top, a ring, and two rows of data under
568
609
  // it. The second row carries the answering colour, the blue of a link. Both
569
610
  // rows and the gap between them fall on whole pixels at 16 px.
@@ -782,6 +823,62 @@ export const GLYPHS: Record<SiteId, (alt: string) => ReactNode> = {
782
823
  <rect x="12" y="21" width="9" height="1.6" rx="0.8" fill="#0b3d2e" />
783
824
  </>
784
825
  ),
826
+ // A converging lens on its bench: the lens in white, and two rays of a
827
+ // parallel beam it brings to its focus in the answering colour.
828
+ optics: (alt) => (
829
+ <>
830
+ <path
831
+ d="M13 4C17.2 8.5 17.2 23.5 13 28C8.8 23.5 8.8 8.5 13 4Z"
832
+ fill="#ffffff"
833
+ />
834
+ <path
835
+ d="M3 10.5H9.6M3 21.5H9.6M16.4 10.5 27 16 16.4 21.5"
836
+ fill="none"
837
+ stroke={alt}
838
+ strokeWidth="2.4"
839
+ strokeLinecap="round"
840
+ strokeLinejoin="round"
841
+ />
842
+ </>
843
+ ),
844
+ // A circuit as its schematic is drawn: the loop and its resistor in white,
845
+ // and the current running round it in the answering colour.
846
+ circuits: (alt) => (
847
+ <>
848
+ <path
849
+ d="M6 16V7H10.5L12.5 4.5 15.5 9.5 18.5 4.5 20.5 7H26V25H6V16"
850
+ fill="none"
851
+ stroke="#ffffff"
852
+ strokeWidth="2.2"
853
+ strokeLinecap="round"
854
+ strokeLinejoin="round"
855
+ />
856
+ <path
857
+ d="M14 21 18 25 14 29"
858
+ fill="none"
859
+ stroke={alt}
860
+ strokeWidth="2.6"
861
+ strokeLinecap="round"
862
+ strokeLinejoin="round"
863
+ />
864
+ </>
865
+ ),
866
+ // A block on an inclined plane, the first problem of mechanics: the slope
867
+ // in white, and the block in the answering colour.
868
+ mechanics: (alt) => (
869
+ <>
870
+ <path d="M3.5 26.5H28.5V9.8Z" fill="#ffffff" />
871
+ <rect
872
+ x="8.89"
873
+ y="9.57"
874
+ width="9"
875
+ height="9"
876
+ rx="1.4"
877
+ fill={alt}
878
+ transform="rotate(-33.74 13.39 18.57)"
879
+ />
880
+ </>
881
+ ),
785
882
  };
786
883
 
787
884
  /**
@@ -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 './kinds.ts';
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 './kinds.ts';
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. */
@@ -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, kindAccepts, readOutput } from './kinds.ts';
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';