react-cheminfo 0.18.0 → 0.19.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/about/core/about.d.ts +9 -0
- package/lib/about/core/about.d.ts.map +1 -1
- package/lib/about/core/about.js +1 -0
- package/lib/about/core/about.js.map +1 -1
- package/lib/about/core/index.d.ts +1 -0
- package/lib/about/core/index.d.ts.map +1 -1
- package/lib/about/core/index.js +1 -0
- package/lib/about/core/index.js.map +1 -1
- package/lib/about/core/repository.d.ts +14 -0
- package/lib/about/core/repository.d.ts.map +1 -0
- package/lib/about/core/repository.js +21 -0
- package/lib/about/core/repository.js.map +1 -0
- package/lib/about/ui/AboutBuild.d.ts +5 -4
- package/lib/about/ui/AboutBuild.d.ts.map +1 -1
- package/lib/about/ui/AboutBuild.js +10 -10
- package/lib/about/ui/AboutBuild.js.map +1 -1
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +7 -8
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutVersion.d.ts +25 -0
- package/lib/about/ui/AboutVersion.d.ts.map +1 -0
- package/lib/about/ui/AboutVersion.js +31 -0
- package/lib/about/ui/AboutVersion.js.map +1 -0
- package/lib/about/ui/index.d.ts +2 -0
- package/lib/about/ui/index.d.ts.map +1 -1
- package/lib/about/ui/index.js +1 -0
- package/lib/about/ui/index.js.map +1 -1
- package/lib/build/core/buildInfo.d.ts +16 -0
- package/lib/build/core/buildInfo.d.ts.map +1 -1
- package/lib/build/core/buildInfo.js +21 -0
- package/lib/build/core/buildInfo.js.map +1 -1
- package/lib/build/core/index.d.ts +1 -1
- package/lib/build/core/index.d.ts.map +1 -1
- package/lib/build/core/index.js +1 -1
- package/lib/build/core/index.js.map +1 -1
- package/lib/build/vite/buildInfo.d.ts.map +1 -1
- package/lib/build/vite/buildInfo.js +2 -2
- package/lib/build/vite/buildInfo.js.map +1 -1
- package/lib/ecosystem/core/sites.d.ts.map +1 -1
- package/lib/ecosystem/core/sites.js +12 -0
- package/lib/ecosystem/core/sites.js.map +1 -1
- package/lib/ecosystem/core/types.d.ts +8 -0
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/molecule3d/core/camera.d.ts +89 -0
- package/lib/molecule3d/core/camera.d.ts.map +1 -0
- package/lib/molecule3d/core/camera.js +172 -0
- package/lib/molecule3d/core/camera.js.map +1 -0
- package/lib/molecule3d/core/index.d.ts +2 -0
- package/lib/molecule3d/core/index.d.ts.map +1 -1
- package/lib/molecule3d/core/index.js +1 -0
- package/lib/molecule3d/core/index.js.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
- package/lib/molecule3d/ui/MoleculeCanvas3D.js +14 -37
- package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
- package/lib/molecule3d/ui/camera.d.ts +35 -2
- package/lib/molecule3d/ui/camera.d.ts.map +1 -1
- package/lib/molecule3d/ui/camera.js +113 -4
- package/lib/molecule3d/ui/camera.js.map +1 -1
- package/lib/molecule3d/ui/captureScene.d.ts +14 -0
- package/lib/molecule3d/ui/captureScene.d.ts.map +1 -0
- package/lib/molecule3d/ui/captureScene.js +24 -0
- package/lib/molecule3d/ui/captureScene.js.map +1 -0
- package/lib/molecule3d/ui/createViewer.d.ts +18 -0
- package/lib/molecule3d/ui/createViewer.d.ts.map +1 -0
- package/lib/molecule3d/ui/createViewer.js +19 -0
- package/lib/molecule3d/ui/createViewer.js.map +1 -0
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +21 -0
- package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
- package/lib/molecule3d/ui/useMoleculeScene.d.ts +47 -0
- package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -0
- package/lib/molecule3d/ui/useMoleculeScene.js +82 -0
- package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -0
- package/lib/molecule3d/ui/useSharedCamera.d.ts +52 -0
- package/lib/molecule3d/ui/useSharedCamera.d.ts.map +1 -0
- package/lib/molecule3d/ui/useSharedCamera.js +82 -0
- package/lib/molecule3d/ui/useSharedCamera.js.map +1 -0
- package/lib/molecule3d/ui/viewer.d.ts +21 -15
- package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
- package/lib/molecule3d/ui/viewer.js +41 -47
- package/lib/molecule3d/ui/viewer.js.map +1 -1
- package/lib/molecule3d/ui/viewerSpec.d.ts +17 -0
- package/lib/molecule3d/ui/viewerSpec.d.ts.map +1 -0
- package/lib/molecule3d/ui/viewerSpec.js +34 -0
- package/lib/molecule3d/ui/viewerSpec.js.map +1 -0
- package/package.json +1 -1
- package/src/about/core/about.ts +11 -0
- package/src/about/core/index.ts +1 -0
- package/src/about/core/repository.ts +22 -0
- package/src/about/ui/AboutBuild.tsx +13 -20
- package/src/about/ui/AboutPage.tsx +30 -22
- package/src/about/ui/AboutVersion.tsx +67 -0
- package/src/about/ui/index.ts +2 -0
- package/src/build/core/buildInfo.ts +24 -0
- package/src/build/core/index.ts +6 -1
- package/src/build/vite/buildInfo.ts +2 -2
- package/src/ecosystem/core/sites.ts +12 -0
- package/src/ecosystem/core/types.ts +8 -0
- package/src/molecule3d/core/camera.ts +212 -0
- package/src/molecule3d/core/index.ts +14 -0
- package/src/molecule3d/ui/MoleculeCanvas3D.tsx +14 -43
- package/src/molecule3d/ui/camera.ts +128 -7
- package/src/molecule3d/ui/captureScene.ts +31 -0
- package/src/molecule3d/ui/createViewer.ts +24 -0
- package/src/molecule3d/ui/moleculeViewer3DProps.ts +21 -0
- package/src/molecule3d/ui/useMoleculeScene.ts +141 -0
- package/src/molecule3d/ui/useSharedCamera.ts +121 -0
- package/src/molecule3d/ui/viewer.ts +45 -50
- package/src/molecule3d/ui/viewerSpec.ts +38 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA
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AKG;IACH,WAAW,CACT,oBAAoB,SAA0B,EAC9C,SAAS,UAAQ,GAChB,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,oBAAoB,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAM5E;;;;;OAKG;IACH,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI;IAa5E;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE,kEAAkE;IAClE,YAAY,IAAI,IAAI;IAKpB,sEAAsE;IACtE,OAAO,IAAI,IAAI;CAwBhB"}
|
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Lifecycle of one molstar molecule viewer
|
|
2
|
+
* Lifecycle of one molstar molecule viewer: `createMolecule3DViewer` builds
|
|
3
|
+
* one, and every operation a component performs on it is a method here.
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* always be called; the work is queued behind `ready`.
|
|
9
|
-
*
|
|
10
|
-
* molstar's own UI is not mounted: every control is the component's.
|
|
5
|
+
* The constructor returns before the canvas exists — see `createViewer.ts` —
|
|
6
|
+
* so every method queues its work behind `ready` and resolves to nothing once
|
|
7
|
+
* the viewer has been disposed. molstar's own UI is not mounted: every control
|
|
8
|
+
* is the component's.
|
|
11
9
|
*/
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
import { DefaultPluginSpec as defaultPluginSpec } from 'molstar/lib/mol-plugin/spec.js';
|
|
15
|
-
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
16
|
-
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, resetCamera, setSpin, } from "./camera.js";
|
|
10
|
+
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, applyCamera, resetCamera, setSpin, watchCamera, } from "./camera.js";
|
|
11
|
+
import { captureScene } from "./captureScene.js";
|
|
17
12
|
import { MeasurementPicker, clearMeasurements, renderMeasurements, } from "./measurements.js";
|
|
18
13
|
import { clearMolecule, renderMolecule } from "./renderMolecule.js";
|
|
19
14
|
import { clearSurface, renderSurface } from "./renderSurface.js";
|
|
20
|
-
|
|
21
|
-
* Create a viewer inside `container` and start initialising it.
|
|
22
|
-
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
23
|
-
* @param options - See {@link Molecule3DViewerOptions}.
|
|
24
|
-
* @returns A handle that is safe to dispose immediately.
|
|
25
|
-
*/
|
|
26
|
-
export function createMolecule3DViewer(container, options = {}) {
|
|
27
|
-
return new Molecule3DViewer(container, options);
|
|
28
|
-
}
|
|
15
|
+
import { mountMolecule3DPlugin } from "./viewerSpec.js";
|
|
29
16
|
/**
|
|
30
17
|
* One molstar canvas, and every operation the component performs on it. Every
|
|
31
18
|
* method resolves to nothing once `dispose` has been called.
|
|
@@ -44,18 +31,7 @@ export class Molecule3DViewer {
|
|
|
44
31
|
constructor(container, options = {}) {
|
|
45
32
|
const { background = '#ffffff', // tokens-ok: a WebGL clear colour
|
|
46
33
|
onMeasure = ignore, } = options;
|
|
47
|
-
|
|
48
|
-
this.#model = new PluginViewModel({
|
|
49
|
-
spec: {
|
|
50
|
-
...spec,
|
|
51
|
-
canvas3d: {
|
|
52
|
-
...spec.canvas3d,
|
|
53
|
-
renderer: { backgroundColor: Color.fromHexStyle(background) },
|
|
54
|
-
camera: { helper: { axes: { name: 'off', params: {} } } },
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
this.#model.mount(container);
|
|
34
|
+
this.#model = mountMolecule3DPlugin(container, background);
|
|
59
35
|
this.ready = this.#model.initialized;
|
|
60
36
|
// Registered before any `#run`, so the picker exists by the time one runs.
|
|
61
37
|
this.ready.then(() => {
|
|
@@ -128,19 +104,7 @@ export class Molecule3DViewer {
|
|
|
128
104
|
* @throws {Error} When the plugin has no screenshot helper.
|
|
129
105
|
*/
|
|
130
106
|
captureImage(size) {
|
|
131
|
-
return this.#run(
|
|
132
|
-
const helper = plugin.helpers.viewportScreenshot;
|
|
133
|
-
if (helper === undefined) {
|
|
134
|
-
throw new Error('This viewer cannot take a picture of its scene.');
|
|
135
|
-
}
|
|
136
|
-
helper.behaviors.values.next({
|
|
137
|
-
...helper.values,
|
|
138
|
-
resolution: { name: 'custom', params: size },
|
|
139
|
-
axes: { name: 'off', params: {} },
|
|
140
|
-
transparent: false,
|
|
141
|
-
});
|
|
142
|
-
return helper.getImageDataUri();
|
|
143
|
-
});
|
|
107
|
+
return this.#run((plugin) => captureScene(plugin, size));
|
|
144
108
|
}
|
|
145
109
|
/**
|
|
146
110
|
* Frame everything on screen.
|
|
@@ -153,6 +117,36 @@ export class Molecule3DViewer {
|
|
|
153
117
|
resetCamera(plugin, durationMilliseconds, fromFront);
|
|
154
118
|
});
|
|
155
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* Put the camera where a link says it stood.
|
|
122
|
+
* @param camera - Where to stand.
|
|
123
|
+
* @param durationMilliseconds - Transition length; 0 jumps.
|
|
124
|
+
* @returns Nothing; resolves once the move has been ordered.
|
|
125
|
+
*/
|
|
126
|
+
setCamera(camera, durationMilliseconds = 0) {
|
|
127
|
+
return this.#run((plugin) => {
|
|
128
|
+
applyCamera(plugin, camera, durationMilliseconds);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Follow the camera, however it moves.
|
|
133
|
+
* @param listener - Called after every move.
|
|
134
|
+
* @returns A function that stops calling the listener; safe to call before
|
|
135
|
+
* the canvas exists.
|
|
136
|
+
*/
|
|
137
|
+
watchCamera(listener) {
|
|
138
|
+
let stop = null;
|
|
139
|
+
let cancelled = false;
|
|
140
|
+
void this.#run((plugin) => {
|
|
141
|
+
if (!cancelled)
|
|
142
|
+
stop = watchCamera(plugin, listener);
|
|
143
|
+
});
|
|
144
|
+
return () => {
|
|
145
|
+
cancelled = true;
|
|
146
|
+
stop?.();
|
|
147
|
+
stop = null;
|
|
148
|
+
};
|
|
149
|
+
}
|
|
156
150
|
/**
|
|
157
151
|
* Turn the automatic spin on or off.
|
|
158
152
|
* @param spinning - Whether the scene should keep turning.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,OAAO,EACP,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAOxD;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAClB,MAAM,CAAkB;IACjC,OAAO,CAAgC;IACvC,SAAS,GAAG,KAAK,CAAC;IAElB,0EAA0E;IACjE,KAAK,CAAgB;IAE9B;;;;OAIG;IACH,YAAY,SAAsB,EAAE,UAAmC,EAAE;QACvE,MAAM,EACJ,UAAU,GAAG,SAAS,EAAE,kCAAkC;QAC1D,SAAS,GAAG,MAAM,GACnB,GAAG,OAAO,CAAC;QACZ,IAAI,CAAC,MAAM,GAAG,qBAAqB,CAAC,SAAS,EAAE,UAAU,C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;IACb,iBAAiB;AACnB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the molecule viewer configures molstar: the plugin spec it mounts with.
|
|
3
|
+
*
|
|
4
|
+
* molstar's own UI is not mounted — every control is the component's — and the
|
|
5
|
+
* axes helper is off, since a molecule is read from its own shape rather than
|
|
6
|
+
* from the world axes.
|
|
7
|
+
*/
|
|
8
|
+
import { PluginViewModel } from 'molstar/lib/extensions/plugin/view-model.js';
|
|
9
|
+
/**
|
|
10
|
+
* Build a view model for one canvas and mount it.
|
|
11
|
+
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
12
|
+
* @param background - Scene background as `#rrggbb`; a WebGL clear colour, so
|
|
13
|
+
* it cannot be a CSS custom property.
|
|
14
|
+
* @returns The mounted view model, still initialising.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountMolecule3DPlugin(container: HTMLElement, background: string): PluginViewModel;
|
|
17
|
+
//# sourceMappingURL=viewerSpec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerSpec.d.ts","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewerSpec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAK9E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,WAAW,EACtB,UAAU,EAAE,MAAM,GACjB,eAAe,CAcjB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the molecule viewer configures molstar: the plugin spec it mounts with.
|
|
3
|
+
*
|
|
4
|
+
* molstar's own UI is not mounted — every control is the component's — and the
|
|
5
|
+
* axes helper is off, since a molecule is read from its own shape rather than
|
|
6
|
+
* from the world axes.
|
|
7
|
+
*/
|
|
8
|
+
import { PluginViewModel } from 'molstar/lib/extensions/plugin/view-model.js';
|
|
9
|
+
// Lowercased on import: it is a factory, not a constructor.
|
|
10
|
+
import { DefaultPluginSpec as defaultPluginSpec } from 'molstar/lib/mol-plugin/spec.js';
|
|
11
|
+
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
12
|
+
/**
|
|
13
|
+
* Build a view model for one canvas and mount it.
|
|
14
|
+
* @param container - A positioned element; molstar inserts its canvas into it.
|
|
15
|
+
* @param background - Scene background as `#rrggbb`; a WebGL clear colour, so
|
|
16
|
+
* it cannot be a CSS custom property.
|
|
17
|
+
* @returns The mounted view model, still initialising.
|
|
18
|
+
*/
|
|
19
|
+
export function mountMolecule3DPlugin(container, background) {
|
|
20
|
+
const spec = defaultPluginSpec();
|
|
21
|
+
const model = new PluginViewModel({
|
|
22
|
+
spec: {
|
|
23
|
+
...spec,
|
|
24
|
+
canvas3d: {
|
|
25
|
+
...spec.canvas3d,
|
|
26
|
+
renderer: { backgroundColor: Color.fromHexStyle(background) },
|
|
27
|
+
camera: { helper: { axes: { name: 'off', params: {} } } },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
model.mount(container);
|
|
32
|
+
return model;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=viewerSpec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewerSpec.js","sourceRoot":"","sources":["../../../src/molecule3d/ui/viewerSpec.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAC9E,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACnC,SAAsB,EACtB,UAAkB;IAElB,MAAM,IAAI,GAAG,iBAAiB,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC;QAChC,IAAI,EAAE;YACJ,GAAG,IAAI;YACP,QAAQ,EAAE;gBACR,GAAG,IAAI,CAAC,QAAQ;gBAChB,QAAQ,EAAE,EAAE,eAAe,EAAE,KAAK,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE;gBAC7D,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE;aAC1D;SACF;KACF,CAAC,CAAC;IACH,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.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",
|
package/src/about/core/about.ts
CHANGED
|
@@ -63,6 +63,13 @@ export interface AboutContent {
|
|
|
63
63
|
* @default the repository of the ECOSYSTEM_SITES record
|
|
64
64
|
*/
|
|
65
65
|
repository?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Whether a visitor can open that repository. A site naming a repository of
|
|
68
|
+
* its own says so here too, since the family's record then describes another
|
|
69
|
+
* one.
|
|
70
|
+
* @default the `publicRepository` of the ECOSYSTEM_SITES record
|
|
71
|
+
*/
|
|
72
|
+
publicRepository?: boolean;
|
|
66
73
|
/**
|
|
67
74
|
* Which build is running, from `virtual:cheminfo-build-info` — never written
|
|
68
75
|
* by hand, which is what keeps it true after the next release.
|
|
@@ -108,6 +115,8 @@ export interface ResolvedAbout {
|
|
|
108
115
|
providedBy: ProviderEntry[];
|
|
109
116
|
license: string;
|
|
110
117
|
repository: string;
|
|
118
|
+
/** Whether a visitor can open the repository, and so whether it is named. */
|
|
119
|
+
publicRepository: boolean;
|
|
111
120
|
/** Which build is running, or `undefined` when the site does not say. */
|
|
112
121
|
build: BuildInfo | undefined;
|
|
113
122
|
issues: string;
|
|
@@ -139,6 +148,8 @@ export function resolveAbout(content: AboutContent): ResolvedAbout {
|
|
|
139
148
|
providedBy: providers(content.providedBy ?? []),
|
|
140
149
|
license: content.license ?? DEFAULT_LICENSE,
|
|
141
150
|
repository,
|
|
151
|
+
publicRepository:
|
|
152
|
+
content.publicRepository ?? site.publicRepository ?? false,
|
|
142
153
|
build: content.build,
|
|
143
154
|
issues: content.issues ?? `${withoutTrailingSlash(repository)}/issues`,
|
|
144
155
|
};
|
package/src/about/core/index.ts
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What can be linked to inside a repository, and when.
|
|
3
|
+
*
|
|
4
|
+
* Only GitHub has the addresses the About page builds — a release tag, a
|
|
5
|
+
* commit — and only a repository a visitor can open is worth pointing them at.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Where our repositories live, and the only host whose paths we know. */
|
|
9
|
+
const GITHUB = 'https://github.com/';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The sources as a base a release or a commit can be appended to.
|
|
13
|
+
* @param repository - Where the sources live.
|
|
14
|
+
* @returns The address without its trailing slash, or `undefined` when it is
|
|
15
|
+
* not a GitHub repository and nothing inside it can be addressed.
|
|
16
|
+
*/
|
|
17
|
+
export function githubSources(repository: string): string | undefined {
|
|
18
|
+
const sources = repository.endsWith('/')
|
|
19
|
+
? repository.slice(0, -1)
|
|
20
|
+
: repository;
|
|
21
|
+
return sources.startsWith(GITHUB) ? sources : undefined;
|
|
22
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { BuildInfo } from '../../build/core/buildInfo.ts';
|
|
4
4
|
import { formatBuiltAt, shortCommit } from '../../build/core/buildInfo.ts';
|
|
5
|
+
import { githubSources } from '../core/repository.ts';
|
|
5
6
|
|
|
6
7
|
export interface AboutBuildProps {
|
|
7
8
|
/** What the build published about itself. */
|
|
@@ -11,38 +12,32 @@ export interface AboutBuildProps {
|
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
|
-
* The one line that says
|
|
15
|
+
* The one line that says when the build a visitor has open was made.
|
|
15
16
|
*
|
|
16
17
|
* A report of something going wrong is worth answering only when we know what
|
|
17
|
-
* was running
|
|
18
|
-
*
|
|
19
|
-
* problem is one click from the page
|
|
18
|
+
* was running. The version itself is in the hero, where a reader is asked to
|
|
19
|
+
* quote it from; this line carries the rest, and the commit links into the
|
|
20
|
+
* repository, so the change that caused a problem is one click from the page
|
|
21
|
+
* that shows it.
|
|
20
22
|
* @param props - See {@link AboutBuildProps}.
|
|
21
23
|
* @returns The line.
|
|
22
24
|
*/
|
|
23
25
|
export function AboutBuild(props: AboutBuildProps): ReactElement {
|
|
24
26
|
const { build, repository } = props;
|
|
25
|
-
const sources = repository
|
|
26
|
-
? repository.slice(0, -1)
|
|
27
|
-
: repository;
|
|
28
|
-
const onGitHub = sources.startsWith(GITHUB);
|
|
27
|
+
const sources = githubSources(repository);
|
|
29
28
|
|
|
30
29
|
return (
|
|
31
30
|
<p style={PARAGRAPH_STYLE}>
|
|
32
|
-
|
|
33
|
-
<Reference
|
|
34
|
-
href={
|
|
35
|
-
onGitHub ? `${sources}/releases/tag/v${build.version}` : undefined
|
|
36
|
-
}
|
|
37
|
-
>
|
|
38
|
-
{build.version}
|
|
39
|
-
</Reference>
|
|
40
|
-
, built {formatBuiltAt(build.builtAt)}
|
|
31
|
+
Built {formatBuiltAt(build.builtAt)}
|
|
41
32
|
{build.commit === undefined ? null : (
|
|
42
33
|
<>
|
|
43
34
|
{' from commit '}
|
|
44
35
|
<Reference
|
|
45
|
-
href={
|
|
36
|
+
href={
|
|
37
|
+
sources === undefined
|
|
38
|
+
? undefined
|
|
39
|
+
: `${sources}/commit/${build.commit}`
|
|
40
|
+
}
|
|
46
41
|
>
|
|
47
42
|
{shortCommit(build.commit)}
|
|
48
43
|
</Reference>
|
|
@@ -67,8 +62,6 @@ function Reference(props: {
|
|
|
67
62
|
);
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
const GITHUB = 'https://github.com/';
|
|
71
|
-
|
|
72
65
|
const PARAGRAPH_STYLE = {
|
|
73
66
|
margin: '8px 0 0',
|
|
74
67
|
color: 'var(--text-muted)',
|
|
@@ -10,6 +10,7 @@ import { AboutBuild } from './AboutBuild.tsx';
|
|
|
10
10
|
import { AboutCitations } from './AboutCitations.tsx';
|
|
11
11
|
import { AboutProvidedBy } from './AboutProvidedBy.tsx';
|
|
12
12
|
import { AboutSection } from './AboutSection.tsx';
|
|
13
|
+
import { AboutVersion } from './AboutVersion.tsx';
|
|
13
14
|
|
|
14
15
|
export interface AboutPageProps {
|
|
15
16
|
/** What the site says about itself. */
|
|
@@ -67,20 +68,22 @@ export function AboutPage(props: AboutPageProps): ReactElement {
|
|
|
67
68
|
}
|
|
68
69
|
style={PAGE_STYLE}
|
|
69
70
|
>
|
|
70
|
-
<header
|
|
71
|
-
className="about-hero"
|
|
72
|
-
style={logo === undefined ? HERO_STYLE : LOGO_HERO_STYLE}
|
|
73
|
-
>
|
|
71
|
+
<header className="about-hero" style={HERO_STYLE}>
|
|
74
72
|
{logo === undefined
|
|
75
73
|
? (mark ?? <SiteMark site={site} size={56} />)
|
|
76
74
|
: null}
|
|
77
|
-
<div>
|
|
75
|
+
<div style={HERO_BODY_STYLE}>
|
|
78
76
|
<h1 style={logo === undefined ? NAME_STYLE : LOGO_NAME_STYLE}>
|
|
79
77
|
{logo ?? <Wordmark site={site} size={26} />}
|
|
80
78
|
</h1>
|
|
81
79
|
<p style={TAGLINE_STYLE}>{site.tagline}</p>
|
|
82
80
|
<p style={WHAT_STYLE}>{about.what}</p>
|
|
83
81
|
</div>
|
|
82
|
+
<AboutVersion
|
|
83
|
+
build={about.build}
|
|
84
|
+
repository={about.repository}
|
|
85
|
+
publicRepository={about.publicRepository}
|
|
86
|
+
/>
|
|
84
87
|
</header>
|
|
85
88
|
|
|
86
89
|
{about.people.length === 0 && about.providedBy.length === 0 ? null : (
|
|
@@ -122,16 +125,23 @@ export function AboutPage(props: AboutPageProps): ReactElement {
|
|
|
122
125
|
</AboutSection>
|
|
123
126
|
)}
|
|
124
127
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
128
|
+
{/*
|
|
129
|
+
A repository nobody outside can open is named nowhere: a licence a
|
|
130
|
+
reader cannot act on and a link that answers 404 say less than silence.
|
|
131
|
+
The version stays in the hero, unlinked, so a report still names a build.
|
|
132
|
+
*/}
|
|
133
|
+
{!about.publicRepository ? null : (
|
|
134
|
+
<AboutSection title="Licence and source" className="about-licence">
|
|
135
|
+
<p style={FIRST_PARAGRAPH_STYLE}>
|
|
136
|
+
{about.license}, © cheminfo. Use it in a course, fork it, or lift a
|
|
137
|
+
piece of it into something else. The sources are at{' '}
|
|
138
|
+
<ExternalLink href={about.repository} />.
|
|
139
|
+
</p>
|
|
140
|
+
{about.build === undefined ? null : (
|
|
141
|
+
<AboutBuild build={about.build} repository={about.repository} />
|
|
142
|
+
)}
|
|
143
|
+
</AboutSection>
|
|
144
|
+
)}
|
|
135
145
|
|
|
136
146
|
<AboutSection title="Found a problem?" className="about-issues">
|
|
137
147
|
<p style={FIRST_PARAGRAPH_STYLE}>
|
|
@@ -162,6 +172,11 @@ const PAGE_STYLE = {
|
|
|
162
172
|
gap: 10,
|
|
163
173
|
} as const satisfies CSSProperties;
|
|
164
174
|
|
|
175
|
+
const HERO_BODY_STYLE = {
|
|
176
|
+
flex: '1 1 auto',
|
|
177
|
+
minWidth: 0,
|
|
178
|
+
} as const satisfies CSSProperties;
|
|
179
|
+
|
|
165
180
|
const HERO_STYLE = {
|
|
166
181
|
display: 'flex',
|
|
167
182
|
alignItems: 'flex-start',
|
|
@@ -179,13 +194,6 @@ const NAME_STYLE = {
|
|
|
179
194
|
fontWeight: 700,
|
|
180
195
|
} as const satisfies CSSProperties;
|
|
181
196
|
|
|
182
|
-
// A drawn lockup already carries the mark and the name at its own proportions,
|
|
183
|
-
// so the hero gives it the full width rather than a column beside a mark.
|
|
184
|
-
const LOGO_HERO_STYLE = {
|
|
185
|
-
...HERO_STYLE,
|
|
186
|
-
display: 'block',
|
|
187
|
-
} as const satisfies CSSProperties;
|
|
188
|
-
|
|
189
197
|
const LOGO_NAME_STYLE = {
|
|
190
198
|
margin: '0 0 4px',
|
|
191
199
|
} as const satisfies CSSProperties;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which release of a site a visitor has open, in the corner of its hero.
|
|
3
|
+
*
|
|
4
|
+
* A report of something going wrong is worth answering only when we know what
|
|
5
|
+
* was running, and the version is the one thing an About page cannot say from
|
|
6
|
+
* a hand-written record. It sits at the top of the page rather than at the
|
|
7
|
+
* bottom because it is the one line a reader is asked to quote back.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
11
|
+
|
|
12
|
+
import type { BuildInfo } from '../../build/core/buildInfo.ts';
|
|
13
|
+
import { releasedVersion } from '../../build/core/buildInfo.ts';
|
|
14
|
+
import { githubSources } from '../core/repository.ts';
|
|
15
|
+
|
|
16
|
+
export interface AboutVersionProps {
|
|
17
|
+
/** What the build published about itself, or `undefined` when it published none. */
|
|
18
|
+
build: BuildInfo | undefined;
|
|
19
|
+
/** Where the sources live, which is what the version links into. */
|
|
20
|
+
repository: string;
|
|
21
|
+
/** Whether a visitor can open that repository, and so whether it is linked. */
|
|
22
|
+
publicRepository: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The version badge, or nothing when there is no version worth showing.
|
|
27
|
+
* @param props - See {@link AboutVersionProps}.
|
|
28
|
+
* @returns The badge, or `null`.
|
|
29
|
+
*/
|
|
30
|
+
export function AboutVersion(props: AboutVersionProps): ReactElement | null {
|
|
31
|
+
const { build, repository, publicRepository } = props;
|
|
32
|
+
const version = releasedVersion(build);
|
|
33
|
+
if (version === undefined) return null;
|
|
34
|
+
const sources = publicRepository ? githubSources(repository) : undefined;
|
|
35
|
+
if (sources === undefined) {
|
|
36
|
+
return (
|
|
37
|
+
<span style={BADGE_STYLE} className="about-version">
|
|
38
|
+
{version}
|
|
39
|
+
</span>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<a
|
|
45
|
+
className="about-version"
|
|
46
|
+
href={`${sources}/releases/tag/v${version}`}
|
|
47
|
+
target="_blank"
|
|
48
|
+
rel="noopener noreferrer"
|
|
49
|
+
style={LINK_BADGE_STYLE}
|
|
50
|
+
>
|
|
51
|
+
{version}
|
|
52
|
+
</a>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const BADGE_STYLE = {
|
|
57
|
+
flex: '0 0 auto',
|
|
58
|
+
fontFamily: 'var(--font-mono, ui-monospace, monospace)',
|
|
59
|
+
fontSize: 13,
|
|
60
|
+
color: 'var(--text-muted)',
|
|
61
|
+
whiteSpace: 'nowrap',
|
|
62
|
+
} as const satisfies CSSProperties;
|
|
63
|
+
|
|
64
|
+
const LINK_BADGE_STYLE = {
|
|
65
|
+
...BADGE_STYLE,
|
|
66
|
+
color: 'var(--accent)',
|
|
67
|
+
} as const satisfies CSSProperties;
|
package/src/about/ui/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type { AboutBuildProps } from './AboutBuild.tsx';
|
|
2
2
|
export { AboutBuild } from './AboutBuild.tsx';
|
|
3
|
+
export type { AboutVersionProps } from './AboutVersion.tsx';
|
|
4
|
+
export { AboutVersion } from './AboutVersion.tsx';
|
|
3
5
|
export type { AboutCitationsProps } from './AboutCitations.tsx';
|
|
4
6
|
export { AboutCitations } from './AboutCitations.tsx';
|
|
5
7
|
export type { AboutPageProps } from './AboutPage.tsx';
|
|
@@ -25,6 +25,30 @@ export interface BuildInfo {
|
|
|
25
25
|
reactCheminfo?: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* The version a build reports when the repository has never been released.
|
|
30
|
+
*
|
|
31
|
+
* release-please writes the version into the root `package.json`, so a site
|
|
32
|
+
* whose first release has not happened yet is built from the `0.0.0` it was
|
|
33
|
+
* scaffolded with. That is not a version anybody can look up, so nothing shows
|
|
34
|
+
* it: a page saying `0.0.0` reads as a bug rather than as a release.
|
|
35
|
+
*/
|
|
36
|
+
export const UNRELEASED_VERSION = '0.0.0';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The version to show a reader, if there is one.
|
|
40
|
+
* @param build - What the build published about itself, or `undefined`.
|
|
41
|
+
* @returns The released version, or `undefined` when the build published none
|
|
42
|
+
* or has never been released.
|
|
43
|
+
*/
|
|
44
|
+
export function releasedVersion(
|
|
45
|
+
build: BuildInfo | undefined,
|
|
46
|
+
): string | undefined {
|
|
47
|
+
const version = build?.version;
|
|
48
|
+
if (version === undefined || version === UNRELEASED_VERSION) return undefined;
|
|
49
|
+
return version;
|
|
50
|
+
}
|
|
51
|
+
|
|
28
52
|
/**
|
|
29
53
|
* The commit as it is written for a reader.
|
|
30
54
|
* @param commit - The full hash.
|
package/src/build/core/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { dirname, join, resolve } from 'node:path';
|
|
|
15
15
|
import type { Plugin } from 'vite';
|
|
16
16
|
|
|
17
17
|
import type { BuildInfo } from '../core/buildInfo.ts';
|
|
18
|
+
import { UNRELEASED_VERSION } from '../core/buildInfo.ts';
|
|
18
19
|
|
|
19
20
|
import { commitFromEnvironment, readGitHead } from './gitHead.ts';
|
|
20
21
|
|
|
@@ -92,7 +93,7 @@ export function resolveBuildInfo(root: string): BuildInfo {
|
|
|
92
93
|
const repository = findRepositoryRoot(root);
|
|
93
94
|
|
|
94
95
|
return {
|
|
95
|
-
version: readVersion(repository) ?? readVersion(root) ??
|
|
96
|
+
version: readVersion(repository) ?? readVersion(root) ?? UNRELEASED_VERSION,
|
|
96
97
|
builtAt: buildInstant(),
|
|
97
98
|
commit: readGitHead(repository) ?? commitFromEnvironment(),
|
|
98
99
|
reactCheminfo: readOwnVersion(),
|
|
@@ -174,5 +175,4 @@ function buildInstant(): string {
|
|
|
174
175
|
|
|
175
176
|
const RESOLVED_MODULE = `\0${BUILD_INFO_MODULE}`;
|
|
176
177
|
const OWN_NAME = 'react-cheminfo';
|
|
177
|
-
const UNRELEASED = '0.0.0';
|
|
178
178
|
const SECOND_LENGTH = 19;
|