react-cheminfo 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +182 -34
- 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 +10 -0
- package/lib/ecosystem/core/sites.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/orbital/ui/AtomicOrbitalCanvas.d.ts +5 -0
- package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalCanvas.js +4 -3
- package/lib/orbital/ui/AtomicOrbitalCanvas.js.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalViewer.d.ts +5 -0
- package/lib/orbital/ui/AtomicOrbitalViewer.d.ts.map +1 -1
- package/lib/orbital/ui/AtomicOrbitalViewer.js.map +1 -1
- package/lib/orbital/ui/axesGeometry.d.ts +27 -0
- package/lib/orbital/ui/axesGeometry.d.ts.map +1 -0
- package/lib/orbital/ui/axesGeometry.js +74 -0
- package/lib/orbital/ui/axesGeometry.js.map +1 -0
- package/lib/orbital/ui/camera.d.ts +7 -0
- package/lib/orbital/ui/camera.d.ts.map +1 -1
- package/lib/orbital/ui/camera.js +8 -1
- package/lib/orbital/ui/camera.js.map +1 -1
- package/lib/orbital/ui/renderAxes.d.ts +53 -0
- package/lib/orbital/ui/renderAxes.d.ts.map +1 -0
- package/lib/orbital/ui/renderAxes.js +110 -0
- package/lib/orbital/ui/renderAxes.js.map +1 -0
- package/lib/orbital/ui/viewer.d.ts +16 -0
- package/lib/orbital/ui/viewer.d.ts.map +1 -1
- package/lib/orbital/ui/viewer.js +24 -2
- package/lib/orbital/ui/viewer.js.map +1 -1
- package/lib/seo/core/documentMeta.d.ts +2 -2
- package/lib/seo/core/documentMeta.js +4 -3
- package/lib/seo/core/documentMeta.js.map +1 -1
- package/lib/seo/core/index.d.ts +13 -4
- package/lib/seo/core/index.d.ts.map +1 -1
- package/lib/seo/core/index.js +8 -3
- package/lib/seo/core/index.js.map +1 -1
- package/lib/seo/core/noscript.d.ts +97 -0
- package/lib/seo/core/noscript.d.ts.map +1 -0
- package/lib/seo/core/noscript.js +93 -0
- package/lib/seo/core/noscript.js.map +1 -0
- package/lib/seo/core/pageMeta.d.ts +30 -14
- package/lib/seo/core/pageMeta.d.ts.map +1 -1
- package/lib/seo/core/pageMeta.js +40 -43
- package/lib/seo/core/pageMeta.js.map +1 -1
- package/lib/seo/core/robots.d.ts +55 -0
- package/lib/seo/core/robots.d.ts.map +1 -0
- package/lib/seo/core/robots.js +70 -0
- package/lib/seo/core/robots.js.map +1 -0
- package/lib/seo/core/routes.d.ts +73 -5
- package/lib/seo/core/routes.d.ts.map +1 -1
- package/lib/seo/core/routes.js +142 -16
- package/lib/seo/core/routes.js.map +1 -1
- package/lib/seo/core/siteFiles.d.ts +39 -43
- package/lib/seo/core/siteFiles.d.ts.map +1 -1
- package/lib/seo/core/siteFiles.js +53 -69
- package/lib/seo/core/siteFiles.js.map +1 -1
- package/lib/seo/core/startDocumentMeta.d.ts +44 -0
- package/lib/seo/core/startDocumentMeta.d.ts.map +1 -0
- package/lib/seo/core/startDocumentMeta.js +47 -0
- package/lib/seo/core/startDocumentMeta.js.map +1 -0
- package/lib/seo/core/structuredData.d.ts +48 -0
- package/lib/seo/core/structuredData.d.ts.map +1 -0
- package/lib/seo/core/structuredData.js +41 -0
- package/lib/seo/core/structuredData.js.map +1 -0
- package/lib/seo/core/template.d.ts +48 -0
- package/lib/seo/core/template.d.ts.map +1 -0
- package/lib/seo/core/template.js +53 -0
- package/lib/seo/core/template.js.map +1 -0
- package/lib/seo/vite/ogCard.d.ts +9 -1
- package/lib/seo/vite/ogCard.d.ts.map +1 -1
- package/lib/seo/vite/ogCard.js +14 -4
- package/lib/seo/vite/ogCard.js.map +1 -1
- package/lib/seo/vite/prerender.d.ts +38 -7
- package/lib/seo/vite/prerender.d.ts.map +1 -1
- package/lib/seo/vite/prerender.js +68 -30
- package/lib/seo/vite/prerender.js.map +1 -1
- package/package.json +1 -1
- package/src/ecosystem/core/sites.ts +11 -0
- package/src/ecosystem/ui/glyphs.tsx +19 -0
- package/src/orbital/ui/AtomicOrbitalCanvas.tsx +9 -2
- package/src/orbital/ui/AtomicOrbitalViewer.tsx +5 -0
- package/src/orbital/ui/axesGeometry.ts +91 -0
- package/src/orbital/ui/camera.ts +9 -1
- package/src/orbital/ui/renderAxes.ts +190 -0
- package/src/orbital/ui/viewer.ts +32 -2
- package/src/seo/core/documentMeta.ts +5 -5
- package/src/seo/core/index.ts +19 -12
- package/src/seo/core/noscript.ts +195 -0
- package/src/seo/core/pageMeta.ts +54 -53
- package/src/seo/core/robots.ts +114 -0
- package/src/seo/core/routes.ts +181 -14
- package/src/seo/core/siteFiles.ts +58 -96
- package/src/seo/core/startDocumentMeta.ts +77 -0
- package/src/seo/core/structuredData.ts +80 -0
- package/src/seo/core/template.ts +54 -0
- package/src/seo/vite/ogCard.ts +15 -5
- package/src/seo/vite/prerender.ts +105 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/camera.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"camera.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/camera.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAYtC;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,aAAa,EACrB,UAAU,SAA0B,GACnC,IAAI,CAWN;AAkBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EACrB,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,SAA0B,GACnC,IAAI,CA4BN;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,OAAO,EACjB,KAAK,SAAqB,GACzB,IAAI,CAQN"}
|
package/lib/orbital/ui/camera.js
CHANGED
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
import { Vec3 } from 'molstar/lib/mol-math/linear-algebra.js';
|
|
7
7
|
/** Transition length used when the caller does not pick one, milliseconds. */
|
|
8
8
|
export const DEFAULT_CAMERA_DURATION = 250;
|
|
9
|
+
/**
|
|
10
|
+
* Turn rate used when the caller does not pick one, in molstar's own spin unit.
|
|
11
|
+
*
|
|
12
|
+
* A lobe has to stay in one place long enough to be read; molstar's own 1 turns
|
|
13
|
+
* an orbital fast enough that the phases blur into each other.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_SPIN_SPEED = 0.3;
|
|
9
16
|
/**
|
|
10
17
|
* Fraction of the bounding sphere kept as breathing room around the orbital.
|
|
11
18
|
*
|
|
@@ -86,7 +93,7 @@ export function frameOrbital(plugin, orbitalRadius, durationMs = DEFAULT_CAMERA_
|
|
|
86
93
|
* @param spinning - Whether the scene should keep turning.
|
|
87
94
|
* @param speed - Revolutions per minute-ish; molstar's own unit.
|
|
88
95
|
*/
|
|
89
|
-
export function setSpin(plugin, spinning, speed =
|
|
96
|
+
export function setSpin(plugin, spinning, speed = DEFAULT_SPIN_SPEED) {
|
|
90
97
|
plugin.canvas3d?.setProps({
|
|
91
98
|
trackball: {
|
|
92
99
|
animate: spinning
|
|
@@ -1 +1 @@
|
|
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AAI,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE;SAChC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cartesian frame an atomic orbital is read against.
|
|
3
|
+
*
|
|
4
|
+
* A `3d_xz` is only `3d_xz` because of where its lobes sit relative to x and
|
|
5
|
+
* z, and a lone isosurface on a blank canvas says nothing about that: the
|
|
6
|
+
* student is looking at four identical lobes and has to take the label's word
|
|
7
|
+
* for it. Three labelled axes through the nucleus are what turn the picture
|
|
8
|
+
* back into the diagram their textbook draws.
|
|
9
|
+
*
|
|
10
|
+
* The axes are neutral grey on purpose. The phase palette already owns colour
|
|
11
|
+
* here — blue against red, or blue against amber — so the usual red/green/blue
|
|
12
|
+
* axis convention would compete with the one thing the surface is saying, and
|
|
13
|
+
* the labels tell the three apart anyway.
|
|
14
|
+
*
|
|
15
|
+
* Like the isosurfaces, the representations live outside the state tree and
|
|
16
|
+
* are tracked per plugin.
|
|
17
|
+
*/
|
|
18
|
+
import type { PluginContext } from 'molstar/lib/mol-plugin/context.js';
|
|
19
|
+
/** How the cartesian frame is drawn. */
|
|
20
|
+
export interface AxesStyle {
|
|
21
|
+
/**
|
|
22
|
+
* Colour of the three rods, as `#rrggbb`.
|
|
23
|
+
* @default '#64748b'
|
|
24
|
+
*/
|
|
25
|
+
colour?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Colour of the three labels, as `#rrggbb`.
|
|
28
|
+
* @default '#334155'
|
|
29
|
+
*/
|
|
30
|
+
labelColour?: string;
|
|
31
|
+
/**
|
|
32
|
+
* What the axes are called, in x, y, z order.
|
|
33
|
+
* @default ['x', 'y', 'z']
|
|
34
|
+
*/
|
|
35
|
+
labels?: readonly [string, string, string];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Draw a labelled x, y, z frame through the origin, replacing any previous one.
|
|
39
|
+
* @param plugin - The molstar context.
|
|
40
|
+
* @param reach - How far the orbital reaches, in scene units — what
|
|
41
|
+
* `renderSampledVolume` returned.
|
|
42
|
+
* @param style - See {@link AxesStyle}.
|
|
43
|
+
* @returns How far the frame reaches, labels included, in scene units: what a
|
|
44
|
+
* camera has to frame for the whole of it to be on screen.
|
|
45
|
+
* @throws {Error} When the canvas is not ready.
|
|
46
|
+
*/
|
|
47
|
+
export declare function renderOrbitalAxes(plugin: PluginContext, reach: number, style?: AxesStyle): Promise<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Remove the frame, leaving anything else on the canvas.
|
|
50
|
+
* @param plugin - The molstar context.
|
|
51
|
+
*/
|
|
52
|
+
export declare function clearOrbitalAxes(plugin: PluginContext): void;
|
|
53
|
+
//# sourceMappingURL=renderAxes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderAxes.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/renderAxes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAavE,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5C;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,SAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAQ5D"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cartesian frame an atomic orbital is read against.
|
|
3
|
+
*
|
|
4
|
+
* A `3d_xz` is only `3d_xz` because of where its lobes sit relative to x and
|
|
5
|
+
* z, and a lone isosurface on a blank canvas says nothing about that: the
|
|
6
|
+
* student is looking at four identical lobes and has to take the label's word
|
|
7
|
+
* for it. Three labelled axes through the nucleus are what turn the picture
|
|
8
|
+
* back into the diagram their textbook draws.
|
|
9
|
+
*
|
|
10
|
+
* The axes are neutral grey on purpose. The phase palette already owns colour
|
|
11
|
+
* here — blue against red, or blue against amber — so the usual red/green/blue
|
|
12
|
+
* axis convention would compete with the one thing the surface is saying, and
|
|
13
|
+
* the labels tell the three apart anyway.
|
|
14
|
+
*
|
|
15
|
+
* Like the isosurfaces, the representations live outside the state tree and
|
|
16
|
+
* are tracked per plugin.
|
|
17
|
+
*/
|
|
18
|
+
import { Mesh } from 'molstar/lib/mol-geo/geometry/mesh/mesh.js';
|
|
19
|
+
import { Text } from 'molstar/lib/mol-geo/geometry/text/text.js';
|
|
20
|
+
import { Shape } from 'molstar/lib/mol-model/shape.js';
|
|
21
|
+
// Lowercased on import: it is a factory, not a constructor.
|
|
22
|
+
import { ShapeRepresentation as shapeRepresentation } from 'molstar/lib/mol-repr/shape/representation.js';
|
|
23
|
+
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
24
|
+
import { LABEL_SIZE, ROD_LENGTH, buildAxisLabels, buildAxisRods, } from "./axesGeometry.js";
|
|
25
|
+
/**
|
|
26
|
+
* Draw a labelled x, y, z frame through the origin, replacing any previous one.
|
|
27
|
+
* @param plugin - The molstar context.
|
|
28
|
+
* @param reach - How far the orbital reaches, in scene units — what
|
|
29
|
+
* `renderSampledVolume` returned.
|
|
30
|
+
* @param style - See {@link AxesStyle}.
|
|
31
|
+
* @returns How far the frame reaches, labels included, in scene units: what a
|
|
32
|
+
* camera has to frame for the whole of it to be on screen.
|
|
33
|
+
* @throws {Error} When the canvas is not ready.
|
|
34
|
+
*/
|
|
35
|
+
export async function renderOrbitalAxes(plugin, reach, style = {}) {
|
|
36
|
+
const canvas3d = plugin.canvas3d;
|
|
37
|
+
if (canvas3d === undefined) {
|
|
38
|
+
throw new Error('renderOrbitalAxes: the molstar canvas is not ready.');
|
|
39
|
+
}
|
|
40
|
+
const { colour = '#64748b', labelColour = '#334155', labels = ['x', 'y', 'z'], } = style;
|
|
41
|
+
clearOrbitalAxes(plugin);
|
|
42
|
+
if (reach <= 0)
|
|
43
|
+
return 0;
|
|
44
|
+
const labelSize = reach * LABEL_SIZE;
|
|
45
|
+
const labelAt = reach * ROD_LENGTH + labelSize;
|
|
46
|
+
const drawn = await Promise.all([
|
|
47
|
+
createRods(plugin, buildAxisRods(reach), colour),
|
|
48
|
+
createLabels(plugin, buildAxisLabels(labelAt, labels), labelColour, labelSize),
|
|
49
|
+
]);
|
|
50
|
+
representations.set(plugin, drawn);
|
|
51
|
+
for (const representation of drawn)
|
|
52
|
+
canvas3d.add(representation);
|
|
53
|
+
// add() only queues; nothing appears until the queue is committed.
|
|
54
|
+
canvas3d.commit();
|
|
55
|
+
return labelAt + labelSize / 2;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Remove the frame, leaving anything else on the canvas.
|
|
59
|
+
* @param plugin - The molstar context.
|
|
60
|
+
*/
|
|
61
|
+
export function clearOrbitalAxes(plugin) {
|
|
62
|
+
const previous = representations.get(plugin);
|
|
63
|
+
if (previous === undefined)
|
|
64
|
+
return;
|
|
65
|
+
representations.delete(plugin);
|
|
66
|
+
for (const representation of previous) {
|
|
67
|
+
plugin.canvas3d?.remove(representation);
|
|
68
|
+
}
|
|
69
|
+
plugin.canvas3d?.commit();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The rods, as a representation the canvas can hold.
|
|
73
|
+
* @param plugin - The molstar context.
|
|
74
|
+
* @param mesh - The rod mesh.
|
|
75
|
+
* @param colour - Rod colour, as `#rrggbb`.
|
|
76
|
+
* @returns The representation.
|
|
77
|
+
*/
|
|
78
|
+
async function createRods(plugin, mesh, colour) {
|
|
79
|
+
const value = Color.fromHexStyle(colour);
|
|
80
|
+
const representation = shapeRepresentation((_ctx, data) => Shape.create('orbital axes', {}, data, () => value, () => 1, () => 'axis'), Mesh.Utils);
|
|
81
|
+
await plugin.runTask(
|
|
82
|
+
// Unlit: a shaded rod reads as a cylinder in front of the surface, while a
|
|
83
|
+
// flat one reads as the axis line a textbook draws.
|
|
84
|
+
representation.createOrUpdate({ alpha: 1, ignoreLight: true }, mesh));
|
|
85
|
+
representation.setState({ pickable: false });
|
|
86
|
+
return representation;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The labels, as a representation the canvas can hold.
|
|
90
|
+
* @param plugin - The molstar context.
|
|
91
|
+
* @param text - The label geometry.
|
|
92
|
+
* @param colour - Label colour, as `#rrggbb`.
|
|
93
|
+
* @param size - Label height, in scene units.
|
|
94
|
+
* @returns The representation.
|
|
95
|
+
*/
|
|
96
|
+
async function createLabels(plugin, text, colour, size) {
|
|
97
|
+
const value = Color.fromHexStyle(colour);
|
|
98
|
+
const representation = shapeRepresentation((_ctx, data) => Shape.create('orbital axis labels', {}, data, () => value, () => 1, () => 'axis label'), Text.Utils);
|
|
99
|
+
await plugin.runTask(representation.createOrUpdate({
|
|
100
|
+
sizeFactor: size,
|
|
101
|
+
background: false,
|
|
102
|
+
attachment: 'middle-center',
|
|
103
|
+
fontWeight: 'bold',
|
|
104
|
+
}, text));
|
|
105
|
+
representation.setState({ pickable: false });
|
|
106
|
+
return representation;
|
|
107
|
+
}
|
|
108
|
+
/** One frame per plugin, outside the state tree like the isosurfaces. */
|
|
109
|
+
const representations = new WeakMap();
|
|
110
|
+
//# sourceMappingURL=renderAxes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderAxes.js","sourceRoot":"","sources":["../../../src/orbital/ui/renderAxes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,2CAA2C,CAAC;AACjE,OAAO,E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Ac,CAAC;AACxB,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,YAAY,CACzB,MAAqB,EACrB,IAAU,EACV,MAAc,EACd,IAAY;IAEZ,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,cAAc,GAAG,mBAAmB,CACxC,CAAC,IAAI,EAAE,IAAU,EAAE,EAAE,CACnB,KAAK,CAAC,MAAM,CACV,qBAAqB,EACrB,EAAE,EACF,IAAI,EACJ,GAAG,EAAE,CAAC,KAAK,EACX,GAAG,EAAE,CAAC,CAAC,EACP,GAAG,EAAE,CAAC,YAAY,CACnB,EACH,IAAI,CAAC,KAAK,CACX,CAAC;IACF,MAAM,MAAM,CAAC,OAAO,CAClB,cAAc,CAAC,cAAc,CAC3B;QACE,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,eAAe;QAC3B,UAAU,EAAE,MAAM;KACnB,EACD,IAAI,CACL,CACF,CAAC;IACF,cAAc,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAC7C,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,yEAAyE;AACzE,MAAM,eAAe,GAAG,IAAI,OAAO,EAAuC,CAAC"}
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { OrbitalGrid } from '../core/grid.ts';
|
|
16
16
|
import type { OrbitalContour } from '../core/isovalue.ts';
|
|
17
|
+
import type { AxesStyle } from './renderAxes.ts';
|
|
17
18
|
import type { VolumeStyle } from './renderVolume.ts';
|
|
18
19
|
/** Settings fixed for the life of a viewer. */
|
|
19
20
|
export interface OrbitalViewerOptions {
|
|
@@ -56,6 +57,21 @@ export declare class OrbitalViewer {
|
|
|
56
57
|
* to frame; `undefined` once the viewer has been disposed.
|
|
57
58
|
*/
|
|
58
59
|
showOrbital(field: OrbitalGrid, contour: OrbitalContour, style?: VolumeStyle): Promise<number | undefined>;
|
|
60
|
+
/**
|
|
61
|
+
* Draw the labelled x, y, z frame through the origin, replacing any previous
|
|
62
|
+
* one.
|
|
63
|
+
* @param reach - How far the orbital reaches, in scene units, as
|
|
64
|
+
* `showOrbital` returned it.
|
|
65
|
+
* @param style - See {@link AxesStyle}.
|
|
66
|
+
* @returns How far the frame reaches, labels included, for the camera to
|
|
67
|
+
* frame; `undefined` once the viewer has been disposed.
|
|
68
|
+
*/
|
|
69
|
+
showAxes(reach: number, style?: AxesStyle): Promise<number | undefined>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove the frame.
|
|
72
|
+
* @returns Nothing, once the axes are gone.
|
|
73
|
+
*/
|
|
74
|
+
hideAxes(): Promise<void>;
|
|
59
75
|
/**
|
|
60
76
|
* Remove the isosurface pair.
|
|
61
77
|
* @returns Nothing, once the surfaces are gone.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../../../src/orbital/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQ1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,+CAA+C;AAC/C,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,oBAAyB,GACjC,aAAa,CAEf;AAED;;;;;GAKG;AACH,qBAAa,aAAa;;IAIxB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBAElB,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,oBAAyB;IAiBtE;;;OAGG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;;;;;OAOG;IACH,WAAW,CACT,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,cAAc,EACvB,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAM9B;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIvE;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAMzB;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAM5B;;;;;;;OAOG;IACH,KAAK,CACH,aAAa,CAAC,EAAE,MAAM,EACtB,UAAU,SAA0B,GACnC,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,SAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrE,kEAAkE;IAClE,YAAY,IAAI,IAAI;IAKpB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAkChB"}
|
package/lib/orbital/ui/viewer.js
CHANGED
|
@@ -16,7 +16,8 @@ import { PluginViewModel } from 'molstar/lib/extensions/plugin/view-model.js';
|
|
|
16
16
|
// Lowercased on import: it is a factory, not a constructor.
|
|
17
17
|
import { DefaultPluginSpec as defaultPluginSpec } from 'molstar/lib/mol-plugin/spec.js';
|
|
18
18
|
import { Color } from 'molstar/lib/mol-util/color/color.js';
|
|
19
|
-
import { DEFAULT_CAMERA_DURATION, frameOrbital, setSpin } from "./camera.js";
|
|
19
|
+
import { DEFAULT_CAMERA_DURATION, DEFAULT_SPIN_SPEED, frameOrbital, setSpin, } from "./camera.js";
|
|
20
|
+
import { clearOrbitalAxes, renderOrbitalAxes } from "./renderAxes.js";
|
|
20
21
|
import { clearSampledVolume, renderSampledVolume } from "./renderVolume.js";
|
|
21
22
|
/**
|
|
22
23
|
* Create a viewer inside `container` and start initialising it.
|
|
@@ -73,6 +74,27 @@ export class OrbitalViewer {
|
|
|
73
74
|
showOrbital(field, contour, style) {
|
|
74
75
|
return this.#run((plugin) => renderSampledVolume(plugin, field, contour, style));
|
|
75
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Draw the labelled x, y, z frame through the origin, replacing any previous
|
|
79
|
+
* one.
|
|
80
|
+
* @param reach - How far the orbital reaches, in scene units, as
|
|
81
|
+
* `showOrbital` returned it.
|
|
82
|
+
* @param style - See {@link AxesStyle}.
|
|
83
|
+
* @returns How far the frame reaches, labels included, for the camera to
|
|
84
|
+
* frame; `undefined` once the viewer has been disposed.
|
|
85
|
+
*/
|
|
86
|
+
showAxes(reach, style) {
|
|
87
|
+
return this.#run((plugin) => renderOrbitalAxes(plugin, reach, style));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Remove the frame.
|
|
91
|
+
* @returns Nothing, once the axes are gone.
|
|
92
|
+
*/
|
|
93
|
+
hideAxes() {
|
|
94
|
+
return this.#run((plugin) => {
|
|
95
|
+
clearOrbitalAxes(plugin);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
76
98
|
/**
|
|
77
99
|
* Remove the isosurface pair.
|
|
78
100
|
* @returns Nothing, once the surfaces are gone.
|
|
@@ -101,7 +123,7 @@ export class OrbitalViewer {
|
|
|
101
123
|
* @param speed - molstar's own spin unit.
|
|
102
124
|
* @returns Nothing, once the spin has been switched.
|
|
103
125
|
*/
|
|
104
|
-
setSpin(spinning, speed =
|
|
126
|
+
setSpin(spinning, speed = DEFAULT_SPIN_SPEED) {
|
|
105
127
|
return this.#run((plugin) => {
|
|
106
128
|
setSpin(plugin, spinning, speed);
|
|
107
129
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/orbital/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAK5D,OAAO,
|
|
1
|
+
{"version":3,"file":"viewer.js","sourceRoot":"","sources":["../../../src/orbital/ui/viewer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAE9E,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAK5D,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,YAAY,EACZ,OAAO,GACR,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAW5E;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAsB,EACtB,UAAgC,EAAE;IAElC,OAAO,IAAI,aAAa,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IACf,MAAM,CAAkB;IACjC,SAAS,GAAG,KAAK,CA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AC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,CACR,MAA2D;QAE3D,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QACrC,MAAM,IAAI,CAAC,KAAK,CAAC;QACjB,IAAI,IAAI,CAAC,SAAS;YAAE,OAAO,SAAS,CAAC;QACrC,IAAI,CAAC;YACH,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,SAAS;gBAAE,OAAO,SAAS,CAAC;YACrC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
|
|
@@ -30,8 +30,8 @@ export interface DocumentMeta {
|
|
|
30
30
|
title: string;
|
|
31
31
|
/**
|
|
32
32
|
* One sentence describing this page, in the words someone would search for.
|
|
33
|
-
* Left out, the description the page was served with stays as it is
|
|
34
|
-
* is what every crawler but a rendering one has already read.
|
|
33
|
+
* Left out or empty, the description the page was served with stays as it is
|
|
34
|
+
* — which is what every crawler but a rendering one has already read.
|
|
35
35
|
* @default undefined
|
|
36
36
|
*/
|
|
37
37
|
description?: string;
|
|
@@ -11,10 +11,11 @@
|
|
|
11
11
|
export function writeDocumentMeta(meta) {
|
|
12
12
|
if (typeof document === 'undefined')
|
|
13
13
|
return;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
if (meta.title)
|
|
15
|
+
documentTitle(meta.title);
|
|
16
|
+
if (meta.description)
|
|
16
17
|
metaDescription(meta.description);
|
|
17
|
-
if (meta.canonical
|
|
18
|
+
if (meta.canonical)
|
|
18
19
|
canonicalLink(meta.canonical);
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentMeta.js","sourceRoot":"","sources":["../../../src/seo/core/documentMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,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IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;AACtB,CAAC;AAqBD,SAAS,eAAe,CAAC,OAAe;IACtC,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CACrC,0BAA0B,CAC3B,CAAC;IACF,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;AACzB,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAChD,CAAC"}
|
package/lib/seo/core/index.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
export type { DocumentMeta } from './documentMeta.ts';
|
|
2
2
|
export { canonicalLink, documentTitle, writeDocumentMeta, } from './documentMeta.ts';
|
|
3
|
+
export type { NoscriptEcosystem, NoscriptHrefs, NoscriptOptions, NoscriptRoute, NoscriptText, } from './noscript.ts';
|
|
4
|
+
export { noscriptIndex } from './noscript.ts';
|
|
3
5
|
export type { PageMetaOptions } from './pageMeta.ts';
|
|
4
|
-
export { injectPageMeta,
|
|
6
|
+
export { injectPageMeta, pageDocumentMeta, pageHeadTags } from './pageMeta.ts';
|
|
7
|
+
export type { RobotsDisallow } from './robots.ts';
|
|
8
|
+
export { robotsTxt } from './robots.ts';
|
|
5
9
|
export type { RouteMeta } from './routes.ts';
|
|
6
|
-
export { homeRoute, pageMetaFor, routeFor, trimTrailingSlash, } from './routes.ts';
|
|
7
|
-
export type { SiteFilesOptions
|
|
8
|
-
export {
|
|
10
|
+
export { assertRoutes, homeRoute, pageMetaFor, routeFor, trimTrailingSlash, } from './routes.ts';
|
|
11
|
+
export type { SiteFilesOptions } from './siteFiles.ts';
|
|
12
|
+
export { sitemapXml } from './siteFiles.ts';
|
|
13
|
+
export type { StartDocumentMetaOptions } from './startDocumentMeta.ts';
|
|
14
|
+
export { startDocumentMeta } from './startDocumentMeta.ts';
|
|
15
|
+
export type { StructuredDataOptions } from './structuredData.ts';
|
|
16
|
+
export { structuredDataScript } from './structuredData.ts';
|
|
17
|
+
export { PAGE_BODY_MARKER, PAGE_HEAD_MARKER, fill } from './template.ts';
|
|
9
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC"}
|
package/lib/seo/core/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { canonicalLink, documentTitle, writeDocumentMeta, } from "./documentMeta.js";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
2
|
+
export { noscriptIndex } from "./noscript.js";
|
|
3
|
+
export { injectPageMeta, pageDocumentMeta, pageHeadTags } from "./pageMeta.js";
|
|
4
|
+
export { robotsTxt } from "./robots.js";
|
|
5
|
+
export { assertRoutes, homeRoute, pageMetaFor, routeFor, trimTrailingSlash, } from "./routes.js";
|
|
6
|
+
export { sitemapXml } from "./siteFiles.js";
|
|
7
|
+
export { startDocumentMeta } from "./startDocumentMeta.js";
|
|
8
|
+
export { structuredDataScript } from "./structuredData.js";
|
|
9
|
+
export { PAGE_BODY_MARKER, PAGE_HEAD_MARKER, fill } from "./template.js";
|
|
5
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/seo/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,QAAQ,EACR,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A readable page for a visitor, or a crawler, with no JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* The body of our sites is an empty root element, so this is the only crawl
|
|
5
|
+
* path through them that costs nothing to render — and it is honest: it says
|
|
6
|
+
* the tool needs JavaScript, and links the addresses it answers.
|
|
7
|
+
*/
|
|
8
|
+
import type { SiteId } from '../../ecosystem/core/sites.ts';
|
|
9
|
+
import type { RouteMeta } from './routes.ts';
|
|
10
|
+
import type { SiteFilesOptions } from './siteFiles.ts';
|
|
11
|
+
/** How the addresses of the site's own pages are written. */
|
|
12
|
+
export type NoscriptHrefs = 'absolute' | 'relative';
|
|
13
|
+
/** A page the block links, and the pages listed under it. */
|
|
14
|
+
export interface NoscriptRoute extends RouteMeta {
|
|
15
|
+
/**
|
|
16
|
+
* Pages listed under this one, as a list nested in its item — the sections of
|
|
17
|
+
* an exercise set under the set itself.
|
|
18
|
+
* @default undefined — the item carries no list
|
|
19
|
+
*/
|
|
20
|
+
children?: readonly NoscriptRoute[];
|
|
21
|
+
}
|
|
22
|
+
/** Which of the family's other sites are listed, and how. */
|
|
23
|
+
export interface NoscriptEcosystem {
|
|
24
|
+
/**
|
|
25
|
+
* The sites listed, in the order they are named. The site writing the block
|
|
26
|
+
* is never one of them, whether or not it is named: the list is headed *Our
|
|
27
|
+
* other tools*.
|
|
28
|
+
* @default every other site in the family, in the family's own order
|
|
29
|
+
*/
|
|
30
|
+
sites?: readonly SiteId[];
|
|
31
|
+
/**
|
|
32
|
+
* Whether each host is followed by ` — ` and the site's one-line tagline.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
taglines?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** The prose of the block, where the site says more than its record does. */
|
|
38
|
+
export interface NoscriptText {
|
|
39
|
+
/**
|
|
40
|
+
* The heading the block opens with.
|
|
41
|
+
* @default the site's display name
|
|
42
|
+
*/
|
|
43
|
+
heading?: string;
|
|
44
|
+
/**
|
|
45
|
+
* The paragraph under it, taken as written. It is the one place a reader with
|
|
46
|
+
* no JavaScript is told what the tool is, so it may say more than the tagline
|
|
47
|
+
* — but it still has to say that the tool needs JavaScript.
|
|
48
|
+
* @default the tagline, followed by the sentence naming the requirement
|
|
49
|
+
*/
|
|
50
|
+
intro?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the family's other sites are listed under the site's own pages, and
|
|
53
|
+
* which of them. A crawler that runs no script has no other path from one of
|
|
54
|
+
* our tools to the next, so a site that lists none leaves it with none.
|
|
55
|
+
* `true` lists every other site with its tagline; an object names the sites,
|
|
56
|
+
* or drops the taglines, or both.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
ecosystem?: boolean | NoscriptEcosystem;
|
|
60
|
+
/**
|
|
61
|
+
* How the site's own addresses are written. `'absolute'` writes them from the
|
|
62
|
+
* root of the host, under the mount the origin names. `'relative'` writes
|
|
63
|
+
* `./exercises` and `./`, which the page resolves against its own `<base>` —
|
|
64
|
+
* the only shape that works for an image whose mount is chosen at container
|
|
65
|
+
* startup, because it bakes no mount into the build at all. The `<base>` such
|
|
66
|
+
* a deployment stamps in ends with a slash, or a relative address resolves
|
|
67
|
+
* one directory too high.
|
|
68
|
+
* @default 'absolute'
|
|
69
|
+
*/
|
|
70
|
+
hrefs?: NoscriptHrefs;
|
|
71
|
+
/**
|
|
72
|
+
* The pages the block links, when they are not the site's whole route table.
|
|
73
|
+
* A crawl path is a menu: a site whose table carries an entry per tutorial
|
|
74
|
+
* step lists the tutorial, not its hundred and thirty-seven steps.
|
|
75
|
+
* @default every route the site answers
|
|
76
|
+
*/
|
|
77
|
+
routes?: readonly NoscriptRoute[];
|
|
78
|
+
}
|
|
79
|
+
/** What the block says, and which addresses it links. */
|
|
80
|
+
export interface NoscriptOptions extends Omit<SiteFilesOptions, 'routes'>, Omit<NoscriptText, 'routes'> {
|
|
81
|
+
/** The addresses it links, each with the label it is linked under. */
|
|
82
|
+
routes: readonly NoscriptRoute[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The `noscript` block, ready to put in the body.
|
|
86
|
+
*
|
|
87
|
+
* An absolute address is written under the mount the deployment named, so a
|
|
88
|
+
* build published as one tool among several on a shared host links its own
|
|
89
|
+
* pages rather than the root of the host it shares.
|
|
90
|
+
* @param options - The site, the pages it links, and the prose that opens the
|
|
91
|
+
* block.
|
|
92
|
+
* @returns The block.
|
|
93
|
+
* @throws {Error} When the deployment named an origin that is not an absolute
|
|
94
|
+
* address.
|
|
95
|
+
*/
|
|
96
|
+
export declare function noscriptIndex(options: NoscriptOptions): string;
|
|
97
|
+
//# sourceMappingURL=noscript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noscript.d.ts","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,EAAiB,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAK3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,6DAA6D;AAC7D,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACrC;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC;IACxC;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACnC;AAED,yDAAyD;AACzD,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC;IACtE,sEAAsE;IACtE,MAAM,EAAE,SAAS,aAAa,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAc9D"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A readable page for a visitor, or a crawler, with no JavaScript.
|
|
3
|
+
*
|
|
4
|
+
* The body of our sites is an empty root element, so this is the only crawl
|
|
5
|
+
* path through them that costs nothing to render — and it is honest: it says
|
|
6
|
+
* the tool needs JavaScript, and links the addresses it answers.
|
|
7
|
+
*/
|
|
8
|
+
import { siteById, siteDisplayName } from "../../ecosystem/core/lookup.js";
|
|
9
|
+
import { ECOSYSTEM_SITES, siteUrl } from "../../ecosystem/core/sites.js";
|
|
10
|
+
import { joinBasePath } from "../../router/core/basePath.js";
|
|
11
|
+
import { escapeAttribute, escapeText } from "../../share/core/escape.js";
|
|
12
|
+
import { mountPathOf, resolveSite } from "./siteFiles.js";
|
|
13
|
+
/**
|
|
14
|
+
* The `noscript` block, ready to put in the body.
|
|
15
|
+
*
|
|
16
|
+
* An absolute address is written under the mount the deployment named, so a
|
|
17
|
+
* build published as one tool among several on a shared host links its own
|
|
18
|
+
* pages rather than the root of the host it shares.
|
|
19
|
+
* @param options - The site, the pages it links, and the prose that opens the
|
|
20
|
+
* block.
|
|
21
|
+
* @returns The block.
|
|
22
|
+
* @throws {Error} When the deployment named an origin that is not an absolute
|
|
23
|
+
* address.
|
|
24
|
+
*/
|
|
25
|
+
export function noscriptIndex(options) {
|
|
26
|
+
const site = resolveSite(options.site);
|
|
27
|
+
const hrefs = options.hrefs ?? 'absolute';
|
|
28
|
+
const mount = hrefs === 'absolute' ? mountPathOf(options) : '';
|
|
29
|
+
const heading = escapeText(options.heading ?? siteDisplayName(site));
|
|
30
|
+
const intro = escapeText(options.intro ??
|
|
31
|
+
`${site.tagline} This tool needs JavaScript; these are the pages it offers:`);
|
|
32
|
+
return `<noscript>
|
|
33
|
+
<h1>${heading}</h1>
|
|
34
|
+
<p>${intro}</p>${pageList(options.routes, mount, hrefs, ' ')}${familyList(site.id, options.ecosystem)}
|
|
35
|
+
</noscript>`;
|
|
36
|
+
}
|
|
37
|
+
function pageList(routes, mount, hrefs, indent) {
|
|
38
|
+
// A list with no item is not a list: `<ul>` holds at least one `<li>`.
|
|
39
|
+
if (routes.length === 0)
|
|
40
|
+
return '';
|
|
41
|
+
const items = routes
|
|
42
|
+
.map((route) => pageItem(route, mount, hrefs, `${indent} `))
|
|
43
|
+
.join('\n');
|
|
44
|
+
return `\n${indent}<ul>\n${items}\n${indent}</ul>`;
|
|
45
|
+
}
|
|
46
|
+
function pageItem(route, mount, hrefs, indent) {
|
|
47
|
+
const href = escapeAttribute(pageHref(route.path, mount, hrefs));
|
|
48
|
+
const label = escapeText(labelOf(route));
|
|
49
|
+
const note = route.note === undefined || route.note.trim() === ''
|
|
50
|
+
? ''
|
|
51
|
+
: ` — ${escapeText(route.note)}`;
|
|
52
|
+
const children = route.children ?? [];
|
|
53
|
+
const link = `<a href="${href}">${label}</a>${note}`;
|
|
54
|
+
if (children.length === 0)
|
|
55
|
+
return `${indent}<li>${link}</li>`;
|
|
56
|
+
return `${indent}<li>${link}${pageList(children, mount, hrefs, `${indent} `)}
|
|
57
|
+
${indent}</li>`;
|
|
58
|
+
}
|
|
59
|
+
function pageHref(path, mount, hrefs) {
|
|
60
|
+
if (hrefs === 'absolute')
|
|
61
|
+
return joinBasePath(mount, path);
|
|
62
|
+
return `./${path.startsWith('/') ? path.slice(1) : path}`;
|
|
63
|
+
}
|
|
64
|
+
function labelOf(route) {
|
|
65
|
+
const short = route.short;
|
|
66
|
+
return short !== undefined && short.trim() !== '' ? short : route.title;
|
|
67
|
+
}
|
|
68
|
+
function familyList(current, ecosystem) {
|
|
69
|
+
if (ecosystem === undefined || ecosystem === false)
|
|
70
|
+
return '';
|
|
71
|
+
const listed = ecosystem === true ? {} : ecosystem;
|
|
72
|
+
const taglines = listed.taglines ?? true;
|
|
73
|
+
const items = [];
|
|
74
|
+
for (const site of familySites(listed.sites)) {
|
|
75
|
+
if (site.id === current)
|
|
76
|
+
continue;
|
|
77
|
+
const tagline = taglines ? ` — ${escapeText(site.tagline)}` : '';
|
|
78
|
+
items.push(` <li><a href="${escapeAttribute(siteUrl(site))}">${escapeText(site.host)}</a>${tagline}</li>`);
|
|
79
|
+
}
|
|
80
|
+
if (items.length === 0)
|
|
81
|
+
return '';
|
|
82
|
+
return `
|
|
83
|
+
<h2>Our other tools</h2>
|
|
84
|
+
<ul>
|
|
85
|
+
${items.join('\n')}
|
|
86
|
+
</ul>`;
|
|
87
|
+
}
|
|
88
|
+
function familySites(sites) {
|
|
89
|
+
if (sites === undefined)
|
|
90
|
+
return [...ECOSYSTEM_SITES];
|
|
91
|
+
return sites.map((id) => siteById(id));
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=noscript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noscript.js","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIzE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAiF1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,WAA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