react-cheminfo 0.40.0 → 0.41.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/bin/check-deploy.mjs +3 -1
- package/lib/deploy/core/buildGate.d.ts +18 -0
- package/lib/deploy/core/buildGate.d.ts.map +1 -0
- package/lib/deploy/core/buildGate.js +115 -0
- package/lib/deploy/core/buildGate.js.map +1 -0
- package/lib/deploy/core/checkDeploy.d.ts +2 -1
- package/lib/deploy/core/checkDeploy.d.ts.map +1 -1
- package/lib/deploy/core/checkDeploy.js +4 -1
- package/lib/deploy/core/checkDeploy.js.map +1 -1
- package/lib/deploy/core/index.d.ts +1 -0
- package/lib/deploy/core/index.d.ts.map +1 -1
- package/lib/deploy/core/index.js +1 -0
- package/lib/deploy/core/index.js.map +1 -1
- package/lib/deploy/core/publishedImage.d.ts.map +1 -1
- package/lib/deploy/core/publishedImage.js +5 -1
- package/lib/deploy/core/publishedImage.js.map +1 -1
- package/lib/deploy/core/types.d.ts +1 -1
- package/lib/deploy/core/types.d.ts.map +1 -1
- package/lib/deploy/core/types.js.map +1 -1
- package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
- package/lib/molecule3d/ui/viewer.js +4 -6
- package/lib/molecule3d/ui/viewer.js.map +1 -1
- package/lib/{molecule3d/ui → molstar/core}/captureScene.d.ts +1 -1
- package/lib/molstar/core/captureScene.d.ts.map +1 -0
- package/lib/molstar/core/captureScene.js.map +1 -0
- package/lib/molstar/core/hover.js +2 -1
- package/lib/molstar/core/hover.js.map +1 -1
- package/lib/molstar/core/index.d.ts +19 -0
- package/lib/molstar/core/index.d.ts.map +1 -1
- package/lib/molstar/core/index.js +18 -0
- package/lib/molstar/core/index.js.map +1 -1
- package/lib/{molecule3d/ui → molstar/core}/measurements.d.ts +6 -6
- package/lib/molstar/core/measurements.d.ts.map +1 -0
- package/lib/{molecule3d/ui → molstar/core}/measurements.js +7 -5
- package/lib/molstar/core/measurements.js.map +1 -0
- package/lib/molstar/core/plugin.d.ts +4 -1
- package/lib/molstar/core/plugin.d.ts.map +1 -1
- package/lib/molstar/core/plugin.js +4 -1
- package/lib/molstar/core/plugin.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +1 -1
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +12 -11
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +25 -8
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTableChrome.js +3 -2
- package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
- package/lib/periodic/ui/unit.d.ts +41 -0
- package/lib/periodic/ui/unit.d.ts.map +1 -0
- package/lib/periodic/ui/unit.js +45 -0
- package/lib/periodic/ui/unit.js.map +1 -0
- package/lib/share/ui/SharePartRow.d.ts.map +1 -1
- package/lib/share/ui/SharePartRow.js +2 -1
- package/lib/share/ui/SharePartRow.js.map +1 -1
- package/package.json +2 -2
- package/src/deploy/core/buildGate.ts +122 -0
- package/src/deploy/core/checkDeploy.ts +5 -1
- package/src/deploy/core/index.ts +1 -0
- package/src/deploy/core/publishedImage.ts +5 -1
- package/src/deploy/core/types.ts +5 -1
- package/src/molecule3d/ui/viewer.ts +16 -8
- package/src/{molecule3d/ui → molstar/core}/captureScene.ts +1 -1
- package/src/molstar/core/hover.ts +2 -1
- package/src/molstar/core/index.ts +25 -0
- package/src/{molecule3d/ui → molstar/core}/measurements.ts +10 -9
- package/src/molstar/core/plugin.ts +4 -1
- package/src/periodic/ui/ElementCell.tsx +14 -12
- package/src/periodic/ui/PeriodicTable.tsx +25 -8
- package/src/periodic/ui/PeriodicTableChrome.tsx +4 -2
- package/src/periodic/ui/unit.ts +48 -0
- package/src/share/ui/SharePartRow.tsx +6 -1
- package/styles/chrome.css +15 -6
- package/lib/molecule3d/ui/captureScene.d.ts.map +0 -1
- package/lib/molecule3d/ui/captureScene.js.map +0 -1
- package/lib/molecule3d/ui/measurements.d.ts.map +0 -1
- package/lib/molecule3d/ui/measurements.js.map +0 -1
- package/lib/molstar.d.ts +0 -18
- package/lib/molstar.d.ts.map +0 -1
- package/lib/molstar.js +0 -17
- package/lib/molstar.js.map +0 -1
- package/src/molstar.ts +0 -22
- /package/lib/{molecule3d/ui → molstar/core}/captureScene.js +0 -0
|
@@ -50,7 +50,10 @@ export class MolstarPlugin {
|
|
|
50
50
|
this.#model.mount(container);
|
|
51
51
|
this.ready = this.#model.initialized;
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Whether {@link dispose} has been called.
|
|
55
|
+
* @returns True once the canvas has been torn down.
|
|
56
|
+
*/
|
|
54
57
|
get disposed() {
|
|
55
58
|
return this.#disposed;
|
|
56
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/molstar/core/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AAG9E,4DAA4D;AAC5D,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AA4B5D,6EAA6E;AAC7E,MAAM,OAAO,aAAa;IACf,MAAM,CAAkB;IACjC,SAAS,GAAG,KAAK,CAAC;IAElB,wEAAwE;IAC/D,KAAK,CAAgB;IAE9B;;;;;OAKG;IACH,YAAY,SAAsB,EAAE,UAAgC,EAAE;QACpE,MAAM,EACJ,UAAU,GAAG,SAAS,EAAE,kCAAkC;QAC1D,+BAA+B,EAC/B,IAAI,EAAE,MAAM,GACb,GAAG,OAAO,CAAC;QACZ,MAAM,IAAI,GAAG,iBAAi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
6
6
|
* and a screen reader reads the element's name rather than its symbol.
|
|
7
7
|
*
|
|
8
|
-
* Everything written in it is
|
|
8
|
+
* Everything written in it is a share of the table's width, so a cell shows
|
|
9
9
|
* the same proportions at 280px beside a chart and across a lecture-hall
|
|
10
10
|
* screen — the table a class reads is the same drawing, larger.
|
|
11
11
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementCell.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAK9D,0DAA0D;AAC1D,MAAM,WAAW,gBAAgB;IAC/B,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,sDAAsD;IACtD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CA6EjE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
4
|
+
import { UNIT, ofWidth } from "./unit.js";
|
|
4
5
|
/**
|
|
5
6
|
* A single element of the table.
|
|
6
7
|
* @param props - See {@link ElementCellProps}.
|
|
@@ -35,8 +36,8 @@ export function ElementCell(props) {
|
|
|
35
36
|
outlineColor: swatch.foreground,
|
|
36
37
|
// Thick enough to be seen from the back of a room, and drawn inside
|
|
37
38
|
// the cell so a neighbour never covers it.
|
|
38
|
-
outlineWidth:
|
|
39
|
-
outlineOffset:
|
|
39
|
+
outlineWidth: `max(2px, ${ofWidth(0.3)})`,
|
|
40
|
+
outlineOffset: `max(-3px, ${ofWidth(-0.4)})`,
|
|
40
41
|
// The cell the pointer is on, for a class following a demonstration.
|
|
41
42
|
filter: isHovered ? 'brightness(1.08)' : undefined,
|
|
42
43
|
}, children: [_jsx("span", { style: numberStyle, children: atomicNumber }), _jsx("span", { style: {
|
|
@@ -54,7 +55,7 @@ export function ElementCell(props) {
|
|
|
54
55
|
* @returns A CSS length.
|
|
55
56
|
*/
|
|
56
57
|
function symbolFontSize(symbol) {
|
|
57
|
-
return fitted(symbolWidthInEm(symbol),
|
|
58
|
+
return fitted(symbolWidthInEm(symbol), SYMBOL_CAP, '0.5rem');
|
|
58
59
|
}
|
|
59
60
|
/**
|
|
60
61
|
* The size the third line takes so the whole of it is written.
|
|
@@ -66,7 +67,7 @@ function symbolFontSize(symbol) {
|
|
|
66
67
|
* @returns A CSS length.
|
|
67
68
|
*/
|
|
68
69
|
function detailFontSize(detail) {
|
|
69
|
-
return fitted(detailWidthInEm(detail),
|
|
70
|
+
return fitted(detailWidthInEm(detail), DETAIL_CAP, '0.25rem');
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* The largest size a string of the given width fits its cell at.
|
|
@@ -80,7 +81,7 @@ function detailFontSize(detail) {
|
|
|
80
81
|
* @returns A CSS length.
|
|
81
82
|
*/
|
|
82
83
|
function fitted(widthInEm, cap, floor) {
|
|
83
|
-
const room = `calc((${
|
|
84
|
+
const room = `calc((${UNIT} * ${String(CELL_SHARE)} - ${CELL_CHROME}) / ${widthInEm.toFixed(2)})`;
|
|
84
85
|
return `max(${floor}, min(${cap}, ${room}))`;
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
@@ -118,7 +119,7 @@ function detailWidthInEm(detail) {
|
|
|
118
119
|
/** What one tabular glyph advances, as a share of its own size. */
|
|
119
120
|
const TABULAR_EM = 0.6;
|
|
120
121
|
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
121
|
-
const
|
|
122
|
+
const SYMBOL_CAP = ofWidth(2.4);
|
|
122
123
|
/**
|
|
123
124
|
* The tallest the third line is ever written, as a share of the table.
|
|
124
125
|
*
|
|
@@ -126,7 +127,7 @@ const SYMBOL_CQW = '2.4cqw';
|
|
|
126
127
|
* the value is what the table is being read for, and a value half the size of
|
|
127
128
|
* the symbol is the one thing on the cell a class cannot make out.
|
|
128
129
|
*/
|
|
129
|
-
const
|
|
130
|
+
const DETAIL_CAP = ofWidth(1.6);
|
|
130
131
|
/**
|
|
131
132
|
* The band at each end of a cell: the atomic number at the top, whatever the
|
|
132
133
|
* tool writes at the bottom.
|
|
@@ -135,9 +136,9 @@ const DETAIL_CQW = '1.6cqw';
|
|
|
135
136
|
* sit at the centre of the cell rather than near it — a bottom band wider than
|
|
136
137
|
* the top one by a third lifted every symbol in the table two pixels.
|
|
137
138
|
*/
|
|
138
|
-
const EDGE_BAND =
|
|
139
|
-
/** How wide one column is,
|
|
140
|
-
const
|
|
139
|
+
const EDGE_BAND = ofWidth(1.8);
|
|
140
|
+
/** How wide one column is, in per cent of the table's width. */
|
|
141
|
+
const CELL_SHARE = 4.85;
|
|
141
142
|
/** What the border and the padding of a cell take off that width. */
|
|
142
143
|
const CELL_CHROME = '4px';
|
|
143
144
|
/**
|
|
@@ -165,7 +166,7 @@ const cellStyle = {
|
|
|
165
166
|
};
|
|
166
167
|
const numberStyle = {
|
|
167
168
|
alignSelf: 'start',
|
|
168
|
-
fontSize:
|
|
169
|
+
fontSize: `max(0.33rem, ${ofWidth(1.1)})`,
|
|
169
170
|
fontVariantNumeric: 'tabular-nums',
|
|
170
171
|
justifySelf: 'start',
|
|
171
172
|
lineHeight: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementCell.js","sourceRoot":"","sources":["../../../src/periodic/ui/ElementCell.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA8C1C;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EACJ,SAAS,EACT,YAAY,EACZ,MAAM,EACN,IAAI,EACJ,MAAM,EACN,MAAM,EACN,GAAG,EACH,QAAQ,EACR,MAAM,GAAG,EAAE,EACX,UAAU,GAAG,KAAK,EAClB,UAAU,GAAG,IAAI,EACjB,OAAO,GACR,GAAG,KAAK,CAAC;IACV,MAAM,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,EAAE,gBAAgB,OAAO,CAAC,GAAG,CAAC,GAAG;IACzC,kBAAkB,EAAE,cAAc;IAClC,WAAW,EAAE,OAAO;IACpB,UAAU,EAAE,CAAC;IACb,OAAO,EAAE,GAAG;CACoB,CAAC;AAEnC,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,QAAQ;IACnB,UAAU,EAAE,GAAG;IACf,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,IAAI;CACgB,CAAC;AAEnC,MAAM,WAAW,GAAG;IAClB,SAAS,EAAE,QAAQ;IACnB,kBAAkB,EAAE,cAAc;IAClC,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,QAAQ;CACY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAGV,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"PeriodicTable.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAGV,YAAY,EACZ,SAAS,EACV,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AAI9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAgBtD,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAChD;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,MAAM,CAAC;IAC9C;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC;IACnD;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC9C;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CAyFrE"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { useResizeObserver } from "../../hooks/ui/useResizeObserver.js";
|
|
3
4
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
4
5
|
import { categorySwatch } from "../core/categories.js";
|
|
5
6
|
import { COLUMN_COUNT, EMPTY_BLOCK, elementByArrowKey, placedElements, } from "../core/layout.js";
|
|
6
7
|
import { CategoryLegend } from "./CategoryLegend.js";
|
|
7
8
|
import { ElementCell } from "./ElementCell.js";
|
|
8
9
|
import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js";
|
|
10
|
+
import { UNIT_PROPERTY, ofWidth, unitValue } from "./unit.js";
|
|
9
11
|
/**
|
|
10
12
|
* The 118 elements, laid out as the table.
|
|
11
13
|
* @param props - See {@link PeriodicTableProps}.
|
|
@@ -14,9 +16,21 @@ import { HeaderStrips, InnerTransitionMarkers, } from "./PeriodicTableChrome.js"
|
|
|
14
16
|
export function PeriodicTable(props) {
|
|
15
17
|
const { selected, onSelect, swatchOf = defaultSwatchOf, detailOf, nameOf = defaultNameOf, isIncluded, inset, headers = false, onSelectRange, legend = false, markers = true, keyboard = true, onHover, className, } = props;
|
|
16
18
|
const t = useChromeT();
|
|
19
|
+
const rootRef = useRef(null);
|
|
17
20
|
const gridRef = useRef(null);
|
|
18
21
|
const cameFromKeyRef = useRef(false);
|
|
19
22
|
const offset = headers ? 1 : 0;
|
|
23
|
+
// The drawing is read off this one number, so it is written straight onto
|
|
24
|
+
// the element rather than held as state: a window being dragged would
|
|
25
|
+
// otherwise re-render all 118 cells per frame, and the engine recomputes
|
|
26
|
+
// every length from the custom property on its own. A width of zero is a
|
|
27
|
+
// table in a tab nobody has opened; the last measurement stands until it is
|
|
28
|
+
// shown, and the observer fires again then.
|
|
29
|
+
useResizeObserver(rootRef, ({ width }) => {
|
|
30
|
+
if (width === 0)
|
|
31
|
+
return;
|
|
32
|
+
rootRef.current?.style.setProperty(UNIT_PROPERTY, unitValue(width));
|
|
33
|
+
});
|
|
20
34
|
useEffect(() => {
|
|
21
35
|
if (!cameFromKeyRef.current)
|
|
22
36
|
return;
|
|
@@ -35,7 +49,7 @@ export function PeriodicTable(props) {
|
|
|
35
49
|
cameFromKeyRef.current = true;
|
|
36
50
|
onSelect(next.symbol);
|
|
37
51
|
}
|
|
38
|
-
return (_jsxs("div", { className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, inset === undefined ? null : (_jsx("div", { style: insetStyle(offset), children: inset })), markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
52
|
+
return (_jsxs("div", { ref: rootRef, className: className, style: rootStyle, children: [_jsxs("div", { ref: gridRef, role: "grid", "aria-label": t('periodic.table'), "data-testid": "periodic-table", style: gridStyle(headers), onKeyDown: handleKeyDown, children: [headers ? _jsx(HeaderStrips, { onSelectRange: onSelectRange }) : null, inset === undefined ? null : (_jsx("div", { style: insetStyle(offset), children: inset })), markers ? _jsx(InnerTransitionMarkers, { offset: offset }) : null, placedElements().map(({ element, cell }) => (_jsx(ElementCell, { atomicNumber: element.atomicNumber, symbol: element.symbol, name: nameOf(element), detail: detailOf?.(element), swatch: swatchOf(element), isSelected: element.symbol === selected, isIncluded: isIncluded?.(element), column: cell.column + offset, row: cell.row + offset, onSelect: onSelect ?? noop, onHover: onHover }, element.symbol)))] }), legend ? _jsx(CategoryLegend, {}) : null] }));
|
|
39
53
|
}
|
|
40
54
|
/**
|
|
41
55
|
* Where what the caller writes in the empty block is placed.
|
|
@@ -48,13 +62,13 @@ function insetStyle(offset) {
|
|
|
48
62
|
display: 'flex',
|
|
49
63
|
// A column of air on each side, so the writing reads as sitting in the
|
|
50
64
|
// block rather than as running into the cells beside it.
|
|
51
|
-
padding:
|
|
65
|
+
padding: `0 ${ofWidth(2.4)}`,
|
|
52
66
|
gridColumn: `${String(EMPTY_BLOCK.column + offset)} / span ${String(EMPTY_BLOCK.columnSpan)}`,
|
|
53
67
|
gridRow: `${String(EMPTY_BLOCK.row + offset)} / span ${String(EMPTY_BLOCK.rowSpan)}`,
|
|
54
68
|
// A share of the table, with a floor, exactly as a cell sizes its symbol:
|
|
55
69
|
// the block holds the same three rows at every width, so what is written
|
|
56
70
|
// in it has to shrink with them.
|
|
57
|
-
fontSize:
|
|
71
|
+
fontSize: `max(0.6rem, ${ofWidth(1.8)})`,
|
|
58
72
|
lineHeight: 1.35,
|
|
59
73
|
minWidth: 0,
|
|
60
74
|
overflow: 'hidden',
|
|
@@ -81,9 +95,9 @@ const MIN_WIDTH = 280;
|
|
|
81
95
|
* table: a cell keeps the band it writes a value in whether or not that table
|
|
82
96
|
* writes one.
|
|
83
97
|
*/
|
|
84
|
-
const ROW_HEIGHT =
|
|
98
|
+
const ROW_HEIGHT = ofWidth(6.8);
|
|
85
99
|
/** The band the two inner-transition series were lifted out across. */
|
|
86
|
-
const SERIES_GAP =
|
|
100
|
+
const SERIES_GAP = `max(6px, ${ofWidth(1.1)})`;
|
|
87
101
|
const rootStyle = {
|
|
88
102
|
display: 'flex',
|
|
89
103
|
flexDirection: 'column',
|
|
@@ -91,7 +105,10 @@ const rootStyle = {
|
|
|
91
105
|
minWidth: MIN_WIDTH,
|
|
92
106
|
// Everything inside — the height of a row as much as the type in a cell — is
|
|
93
107
|
// a share of this box rather than of the page, so the same table reads at
|
|
94
|
-
// 280px beside a chart and fills a lecture-hall screen at twice that.
|
|
108
|
+
// 280px beside a chart and fills a lecture-hall screen at twice that. The
|
|
109
|
+
// share is measured (see `unit.ts`); the container is what the `1cqw`
|
|
110
|
+
// fallback and a site's own `@container` rules are answered by, and it keeps
|
|
111
|
+
// this box's width independent of what is written inside it.
|
|
95
112
|
containerType: 'inline-size',
|
|
96
113
|
};
|
|
97
114
|
const baseGridStyle = {
|
|
@@ -118,8 +135,8 @@ function gridStyle(headers) {
|
|
|
118
135
|
}
|
|
119
136
|
return {
|
|
120
137
|
...baseGridStyle,
|
|
121
|
-
gridTemplateColumns: `max(14px, 2.
|
|
122
|
-
gridTemplateRows: `max(12px,
|
|
138
|
+
gridTemplateColumns: `max(14px, ${ofWidth(2.4)}) repeat(${String(COLUMN_COUNT)}, minmax(0, 1fr))`,
|
|
139
|
+
gridTemplateRows: `max(12px, ${ofWidth(2)}) ${rows}`,
|
|
123
140
|
};
|
|
124
141
|
}
|
|
125
142
|
//# sourceMappingURL=PeriodicTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,0BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"PeriodicTable.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTable.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,EACL,YA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AAc,UAAU,GAAG,CAAC;IAC/E,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,GAAG,aAAa;YAChB,mBAAmB,EAAE,UAAU,MAAM,CAAC,YAAY,CAAC,mBAAmB;YACtE,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG,aAAa;QAChB,mBAAmB,EAAE,aAAa,OAAO,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,YAAY,CAAC,mBAAmB;QACjG,gBAAgB,EAAE,aAAa,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;KACrD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTableChrome.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTableChrome.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"PeriodicTableChrome.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTableChrome.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,OAAO,CAAC;AAIzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAStD,uCAAuC;AACvC,UAAU,iBAAiB;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CAsDnE;AAED,iDAAiD;AACjD,UAAU,2BAA2B;IACnC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,2BAA2B,GACjC,YAAY,CAmBd"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useChromeT } from "../../i18n/ui/useT.js";
|
|
3
3
|
import { TOKEN } from "../../tokens/core/familyTokens.js";
|
|
4
4
|
import { COLUMN_COUNT, INNER_TRANSITION_MARKERS, INNER_TRANSITION_ROWS, } from "../core/layout.js";
|
|
5
|
+
import { ofWidth } from "./unit.js";
|
|
5
6
|
/**
|
|
6
7
|
* The 1–18 strip along the top and the 1–7 strip down the left.
|
|
7
8
|
*
|
|
@@ -53,7 +54,7 @@ const headerStyle = {
|
|
|
53
54
|
alignItems: 'center',
|
|
54
55
|
color: TOKEN.textMuted,
|
|
55
56
|
display: 'flex',
|
|
56
|
-
fontSize:
|
|
57
|
+
fontSize: `max(0.45rem, ${ofWidth(1.35)})`,
|
|
57
58
|
justifyContent: 'center',
|
|
58
59
|
padding: 0,
|
|
59
60
|
};
|
|
@@ -69,7 +70,7 @@ const markerStyle = {
|
|
|
69
70
|
borderRadius: 3,
|
|
70
71
|
color: TOKEN.textMuted,
|
|
71
72
|
display: 'flex',
|
|
72
|
-
fontSize:
|
|
73
|
+
fontSize: `max(0.4rem, ${ofWidth(1.15)})`,
|
|
73
74
|
justifyContent: 'center',
|
|
74
75
|
};
|
|
75
76
|
//# sourceMappingURL=PeriodicTableChrome.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PeriodicTableChrome.js","sourceRoot":"","sources":["../../../src/periodic/ui/PeriodicTableChrome.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAE1D,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Period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AAG,KAAK,CAAC;IACrD,MAAM,KAAK,GAAG,EAAE,GAAG,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;IACnE,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,cAAK,KAAK,EAAE,KAAK,YAAG,KAAK,GAAO,CAAC;IACnE,OAAO,CACL,iBACE,IAAI,EAAC,QAAQ,gBACD,KAAK,EACjB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,EAAE,GAAG,KAAK,EAAE,GAAG,iBAAiB,EAAE,YAExC,KAAK,GACC,CACV,CAAC;AACJ,CAAC;AAED,MAAM,WAAW,GAAG;IAClB,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,gBAAgB,OAAO,CAAC,IAAI,CAAC,GAAG;IAC1C,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,CAAC;CACsB,CAAC;AAEnC,MAAM,iBAAiB,GAAG;IACxB,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;CACiB,CAAC;AAEnC,MAAM,WAAW,GAAG;IAClB,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,cAAc,KAAK,CAAC,YAAY,EAAE;IAC1C,YAAY,EAAE,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,SAAS;IACtB,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE,eAAe,OAAO,CAAC,IAAI,CAAC,GAAG;IACzC,cAAc,EAAE,QAAQ;CACQ,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The length the whole table is drawn in multiples of.
|
|
3
|
+
*
|
|
4
|
+
* Every part of the drawing — the height of a row, the type in a cell, the
|
|
5
|
+
* band the inner-transition series were lifted out across — is a share of the
|
|
6
|
+
* table's own width, so the same table reads at 280px beside a chart and fills
|
|
7
|
+
* a lecture-hall screen at twice that.
|
|
8
|
+
*
|
|
9
|
+
* The share is a measured length rather than a container-query unit, because
|
|
10
|
+
* WebKit resolves `cqw` against the container's *zoomed* width and then applies
|
|
11
|
+
* the zoom to the result a second time: inside a host that zooms the page — a
|
|
12
|
+
* PowerPoint add-in frame runs at 1.34 — every cq length came out 34% too
|
|
13
|
+
* large, which fits none of the floors the type is held above and overran the
|
|
14
|
+
* cells. `ResizeObserver` reports the content box in the element's own CSS
|
|
15
|
+
* pixels, which is the space `font-size` is resolved in, so one hundredth of
|
|
16
|
+
* that number is the share, on every engine and at any zoom.
|
|
17
|
+
* `getBoundingClientRect` is not: it reports the zoomed width, which would
|
|
18
|
+
* reproduce the defect.
|
|
19
|
+
*
|
|
20
|
+
* `1cqw` stays as the fallback, so a render that never measures — a server
|
|
21
|
+
* render, a prerendered page before its script runs — is the drawing it has
|
|
22
|
+
* always been.
|
|
23
|
+
*/
|
|
24
|
+
/** The custom property the measured share is published as. */
|
|
25
|
+
export declare const UNIT_PROPERTY = "--periodic-unit";
|
|
26
|
+
/** One per cent of the table's width, as a CSS length. */
|
|
27
|
+
export declare const UNIT = "var(--periodic-unit, 1cqw)";
|
|
28
|
+
/**
|
|
29
|
+
* A share of the table's width, as a CSS length.
|
|
30
|
+
* @param share - The share, in per cent of the width.
|
|
31
|
+
* @returns A CSS length, usable wherever a length is.
|
|
32
|
+
*/
|
|
33
|
+
export declare function ofWidth(share: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* The value the custom property takes for a table of the given width.
|
|
36
|
+
* @param width - The content-box width, in CSS pixels, as `ResizeObserver`
|
|
37
|
+
* reports it.
|
|
38
|
+
* @returns The length one per cent of that width is.
|
|
39
|
+
*/
|
|
40
|
+
export declare function unitValue(width: number): string;
|
|
41
|
+
//# sourceMappingURL=unit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/unit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,8DAA8D;AAC9D,eAAO,MAAM,aAAa,oBAAoB,CAAC;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,IAAI,+BAAgC,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The length the whole table is drawn in multiples of.
|
|
3
|
+
*
|
|
4
|
+
* Every part of the drawing — the height of a row, the type in a cell, the
|
|
5
|
+
* band the inner-transition series were lifted out across — is a share of the
|
|
6
|
+
* table's own width, so the same table reads at 280px beside a chart and fills
|
|
7
|
+
* a lecture-hall screen at twice that.
|
|
8
|
+
*
|
|
9
|
+
* The share is a measured length rather than a container-query unit, because
|
|
10
|
+
* WebKit resolves `cqw` against the container's *zoomed* width and then applies
|
|
11
|
+
* the zoom to the result a second time: inside a host that zooms the page — a
|
|
12
|
+
* PowerPoint add-in frame runs at 1.34 — every cq length came out 34% too
|
|
13
|
+
* large, which fits none of the floors the type is held above and overran the
|
|
14
|
+
* cells. `ResizeObserver` reports the content box in the element's own CSS
|
|
15
|
+
* pixels, which is the space `font-size` is resolved in, so one hundredth of
|
|
16
|
+
* that number is the share, on every engine and at any zoom.
|
|
17
|
+
* `getBoundingClientRect` is not: it reports the zoomed width, which would
|
|
18
|
+
* reproduce the defect.
|
|
19
|
+
*
|
|
20
|
+
* `1cqw` stays as the fallback, so a render that never measures — a server
|
|
21
|
+
* render, a prerendered page before its script runs — is the drawing it has
|
|
22
|
+
* always been.
|
|
23
|
+
*/
|
|
24
|
+
/** The custom property the measured share is published as. */
|
|
25
|
+
export const UNIT_PROPERTY = '--periodic-unit';
|
|
26
|
+
/** One per cent of the table's width, as a CSS length. */
|
|
27
|
+
export const UNIT = `var(${UNIT_PROPERTY}, 1cqw)`;
|
|
28
|
+
/**
|
|
29
|
+
* A share of the table's width, as a CSS length.
|
|
30
|
+
* @param share - The share, in per cent of the width.
|
|
31
|
+
* @returns A CSS length, usable wherever a length is.
|
|
32
|
+
*/
|
|
33
|
+
export function ofWidth(share) {
|
|
34
|
+
return `calc(${UNIT} * ${String(share)})`;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The value the custom property takes for a table of the given width.
|
|
38
|
+
* @param width - The content-box width, in CSS pixels, as `ResizeObserver`
|
|
39
|
+
* reports it.
|
|
40
|
+
* @returns The length one per cent of that width is.
|
|
41
|
+
*/
|
|
42
|
+
export function unitValue(width) {
|
|
43
|
+
return `${(width / 100).toFixed(3)}px`;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../src/periodic/ui/unit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAE/C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,aAAa,SAAS,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,KAAa;IACnC,OAAO,QAAQ,IAAI,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAa;IACrC,OAAO,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharePartRow.d.ts","sourceRoot":"","sources":["../../../src/share/ui/SharePartRow.tsx"],"names":[],"mapp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B,GAAG,YAAY,CAuCnE"}
|
|
@@ -18,7 +18,8 @@ export function SharePartRow(props) {
|
|
|
18
18
|
const { label, description, on, descriptions, onChange, onPointed } = props;
|
|
19
19
|
const t = useChromeT();
|
|
20
20
|
const id = useId();
|
|
21
|
-
|
|
21
|
+
const labelId = `${id}-label`;
|
|
22
|
+
return (_jsxs("div", { className: "share-part", onMouseEnter: () => onPointed?.(true), onMouseLeave: () => onPointed?.(false), onFocus: () => onPointed?.(true), onBlur: () => onPointed?.(false), children: [_jsx("label", { className: "share-part__label", htmlFor: id, id: labelId, children: label }), descriptions === 'help' ? (_jsx(HelpIcon, { content: { title: label, body: description }, label: label })) : null, _jsx(Switch, { id: id, className: "share-part__switch", "aria-labelledby": labelId, checked: on, innerLabel: t('share.off'), innerLabelChecked: t('share.on'), onChange: (event) => {
|
|
22
23
|
onChange(event.currentTarget.checked);
|
|
23
24
|
} }), descriptions === 'inline' ? (_jsx("p", { className: "share-part__description", children: description })) : null] }));
|
|
24
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharePartRow.js","sourceRoot":"","sources":["../../../src/share/ui/SharePartRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA2BnD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAC5E,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"SharePartRow.js","s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b,OAAO,EACxB,OAAO,EAAE,EAAE,EACX,UAAU,EAAE,CAAC,CAAC,WAAW,CAAC,EAC1B,iBAAiB,EAAE,CAAC,CAAC,UAAU,CAAC,EAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oBAClB,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;gBACxC,CAAC,GACD,EACD,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC3B,YAAG,SAAS,EAAC,yBAAyB,YAAE,WAAW,GAAK,CACzD,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.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",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"./core": "./lib/core.js",
|
|
21
21
|
"./ir": "./lib/ir.js",
|
|
22
22
|
"./molecule3d": "./lib/molecule3d.js",
|
|
23
|
-
"./molstar": "./lib/molstar.js",
|
|
23
|
+
"./molstar/*": "./lib/molstar/*/index.js",
|
|
24
24
|
"./orbital": "./lib/orbital.js",
|
|
25
25
|
"./slides": "./lib/slides.js",
|
|
26
26
|
"./spectra": "./lib/spectra.js",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { DeployProblem } from './types.ts';
|
|
2
|
+
|
|
3
|
+
/** The scripts a repository's own `package.json` declares, as npm would run them. */
|
|
4
|
+
type Scripts = Record<string, string>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Report a repository that can bundle, and so publish, code nothing tested.
|
|
8
|
+
*
|
|
9
|
+
* A bundle is what gets published, so `npm run build` is the gate: the unit and
|
|
10
|
+
* static checks, then the browser suite, then `build-only`, which is the pure
|
|
11
|
+
* bundle. The split is what makes the gate possible at all — three callers need
|
|
12
|
+
* the bundle without the suites, and the image build is one of them: it has no
|
|
13
|
+
* browser, and a source build on a deploy host must not re-run a suite CI
|
|
14
|
+
* already ran. A Dockerfile left on `npm run build` therefore either dies in
|
|
15
|
+
* the container or, worse, the `build` it calls was never a gate and the image
|
|
16
|
+
* carries untested code to the registry. Neither is visible until a deploy.
|
|
17
|
+
* @param packageJson - The repository's root `package.json`, unparsed.
|
|
18
|
+
* @param dockerfile - Its Dockerfile, when it has one.
|
|
19
|
+
* @param problems - Where each problem found is appended.
|
|
20
|
+
*/
|
|
21
|
+
export function readBuildGate(
|
|
22
|
+
packageJson: string | undefined,
|
|
23
|
+
dockerfile: string | undefined,
|
|
24
|
+
problems: DeployProblem[],
|
|
25
|
+
): void {
|
|
26
|
+
if (packageJson === undefined) return;
|
|
27
|
+
const scripts = parseScripts(packageJson);
|
|
28
|
+
if (scripts === undefined) return;
|
|
29
|
+
|
|
30
|
+
const build = scripts.build;
|
|
31
|
+
if (build !== undefined && !/\bnpm run test\b/.test(build)) {
|
|
32
|
+
problems.push({
|
|
33
|
+
file: 'package.json',
|
|
34
|
+
line: lineOf(packageJson, '"build"'),
|
|
35
|
+
kind: 'ungated-build',
|
|
36
|
+
message:
|
|
37
|
+
'build writes a bundle without running the tests, so a broken site can be published',
|
|
38
|
+
hint: 'build: "npm run test && npm run test-e2e && npm run build-only", with the bundle in build-only',
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (build !== undefined && scripts['build-only'] === undefined) {
|
|
42
|
+
problems.push({
|
|
43
|
+
file: 'package.json',
|
|
44
|
+
line: lineOf(packageJson, '"build"'),
|
|
45
|
+
kind: 'missing-build-only',
|
|
46
|
+
message: 'there is no build-only, so nothing can bundle without the gate',
|
|
47
|
+
hint: 'move the bundle to build-only and leave build as the gate in front of it',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const test = scripts.test;
|
|
52
|
+
if (test !== undefined && /\bnpm run test-e2e\b/.test(test)) {
|
|
53
|
+
problems.push({
|
|
54
|
+
file: 'package.json',
|
|
55
|
+
line: lineOf(packageJson, '"test"'),
|
|
56
|
+
kind: 'test-runs-e2e',
|
|
57
|
+
message:
|
|
58
|
+
'test runs the browser suite, which build runs next: it runs twice and a failure does not say which gate it came from',
|
|
59
|
+
hint: 'leave test-e2e out of test; build is "npm run test && npm run test-e2e && npm run build-only"',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (dockerfile === undefined) return;
|
|
64
|
+
const line = gatedBuildLine(dockerfile);
|
|
65
|
+
if (line !== undefined) {
|
|
66
|
+
problems.push({
|
|
67
|
+
file: 'Dockerfile',
|
|
68
|
+
line,
|
|
69
|
+
kind: 'gated-image-build',
|
|
70
|
+
message:
|
|
71
|
+
'the image build runs the gated build, which has no browser to run the browser suite in',
|
|
72
|
+
hint: 'RUN npm run build-only — the image builds what CI tested, it does not test again',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The line running the repository's own gated `build`, if the Dockerfile has
|
|
79
|
+
* one. A workspace build (`-w frontend`) is a different script and stays pure.
|
|
80
|
+
* @param dockerfile - The Dockerfile text.
|
|
81
|
+
* @returns Its line number, counting from 1, or undefined.
|
|
82
|
+
*/
|
|
83
|
+
function gatedBuildLine(dockerfile: string): number | undefined {
|
|
84
|
+
const lines = dockerfile.split('\n');
|
|
85
|
+
for (const [index, text] of lines.entries()) {
|
|
86
|
+
if (!/^\s*RUN\s.*\bnpm run build\b/.test(text)) continue;
|
|
87
|
+
if (/\bnpm run build[\w:-]/.test(text)) continue;
|
|
88
|
+
if (/(?:-w|--workspace)[\s=]/.test(text)) continue;
|
|
89
|
+
return index + 1;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The scripts block of a `package.json`.
|
|
96
|
+
* @param text - The file, unparsed.
|
|
97
|
+
* @returns Its scripts, or undefined when the file is not readable as one.
|
|
98
|
+
*/
|
|
99
|
+
function parseScripts(text: string): Scripts | undefined {
|
|
100
|
+
let parsed: unknown;
|
|
101
|
+
try {
|
|
102
|
+
parsed = JSON.parse(text);
|
|
103
|
+
} catch {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (typeof parsed !== 'object' || parsed === null) return undefined;
|
|
107
|
+
const scripts = (parsed as { scripts?: unknown }).scripts;
|
|
108
|
+
if (typeof scripts !== 'object' || scripts === null) return {};
|
|
109
|
+
return scripts as Scripts;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Where a report should point, so the reader lands on the script itself.
|
|
114
|
+
* @param text - The file to search.
|
|
115
|
+
* @param needle - The key to find.
|
|
116
|
+
* @returns Its line, counting from 1, or 0 when it is not there.
|
|
117
|
+
*/
|
|
118
|
+
function lineOf(text: string, needle: string): number {
|
|
119
|
+
const at = text.indexOf(needle);
|
|
120
|
+
if (at === -1) return 0;
|
|
121
|
+
return text.slice(0, at).split('\n').length;
|
|
122
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readBuildGate } from './buildGate.ts';
|
|
1
2
|
import { readComposeFile } from './composeFile.ts';
|
|
2
3
|
import { readEnvExample } from './envExample.ts';
|
|
3
4
|
import { readPageCache } from './pageCache.ts';
|
|
@@ -18,7 +19,8 @@ import { DEPLOY_COMPOSE_FILES } from './types.ts';
|
|
|
18
19
|
* reports it healthy. So a repository has to hand it a selectable tag on every
|
|
19
20
|
* image we build, an `IMAGE_NAME` that names the package our own workflow
|
|
20
21
|
* publishes, a compose file that parses on a checkout with no `.env` yet, and a
|
|
21
|
-
* health probe to read
|
|
22
|
+
* health probe to read, and a `build` that cannot write a bundle until the
|
|
23
|
+
* tests have passed. It also has to publish that image in the first place:
|
|
22
24
|
* with no `latest` to pull the script builds from source on the deploy host,
|
|
23
25
|
* and the install that follows must survive a blip in the registry. It also has to hand the browser a page the browser will
|
|
24
26
|
* not keep, or the next deploy leaves returning visitors on a blank one. Each
|
|
@@ -84,6 +86,8 @@ export function findDeployProblems(
|
|
|
84
86
|
readInstallRetries(dockerfile, problems);
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
readBuildGate(byPath.get('package.json'), dockerfile, problems);
|
|
90
|
+
|
|
87
91
|
readPublishedImage(byPath.get(DOCKER_IMAGE_WORKFLOW), problems);
|
|
88
92
|
|
|
89
93
|
const gitignore = byPath.get('.gitignore');
|
package/src/deploy/core/index.ts
CHANGED