react-cheminfo 0.42.0 → 0.43.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.map +1 -1
- package/lib/deploy/core/buildGate.js +4 -34
- package/lib/deploy/core/buildGate.js.map +1 -1
- package/lib/deploy/core/checkDeploy.d.ts.map +1 -1
- package/lib/deploy/core/checkDeploy.js +2 -0
- 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/json.d.ts +27 -0
- package/lib/deploy/core/json.d.ts.map +1 -0
- package/lib/deploy/core/json.js +56 -0
- package/lib/deploy/core/json.js.map +1 -0
- package/lib/deploy/core/reactCopies.d.ts +32 -0
- package/lib/deploy/core/reactCopies.d.ts.map +1 -0
- package/lib/deploy/core/reactCopies.js +212 -0
- package/lib/deploy/core/reactCopies.js.map +1 -0
- 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/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 +1 -1
- package/lib/ecosystem/core/types.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +4 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/periodic/ui/ElementCell.d.ts +22 -2
- package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
- package/lib/periodic/ui/ElementCell.js +20 -145
- package/lib/periodic/ui/ElementCell.js.map +1 -1
- package/lib/periodic/ui/PeriodicTable.d.ts +7 -0
- package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
- package/lib/periodic/ui/PeriodicTable.js +21 -3
- package/lib/periodic/ui/PeriodicTable.js.map +1 -1
- package/lib/periodic/ui/cellStyles.d.ts +79 -0
- package/lib/periodic/ui/cellStyles.d.ts.map +1 -0
- package/lib/periodic/ui/cellStyles.js +90 -0
- package/lib/periodic/ui/cellStyles.js.map +1 -0
- package/lib/periodic/ui/cellType.d.ts +106 -0
- package/lib/periodic/ui/cellType.d.ts.map +1 -0
- package/lib/periodic/ui/cellType.js +181 -0
- package/lib/periodic/ui/cellType.js.map +1 -0
- package/lib/periodic/ui/glyphWidths.d.ts +11 -0
- package/lib/periodic/ui/glyphWidths.d.ts.map +1 -0
- package/lib/periodic/ui/glyphWidths.js +69 -0
- package/lib/periodic/ui/glyphWidths.js.map +1 -0
- package/package.json +9 -1
- package/src/deploy/core/buildGate.ts +4 -35
- package/src/deploy/core/checkDeploy.ts +7 -0
- package/src/deploy/core/index.ts +1 -0
- package/src/deploy/core/json.ts +53 -0
- package/src/deploy/core/reactCopies.ts +243 -0
- package/src/deploy/core/types.ts +5 -1
- package/src/ecosystem/core/sites.ts +13 -0
- package/src/ecosystem/core/types.ts +2 -1
- package/src/ecosystem/ui/glyphs.tsx +16 -0
- package/src/periodic/ui/ElementCell.tsx +69 -160
- package/src/periodic/ui/PeriodicTable.tsx +37 -2
- package/src/periodic/ui/cellStyles.ts +100 -0
- package/src/periodic/ui/cellType.ts +223 -0
- package/src/periodic/ui/glyphWidths.ts +68 -0
- package/styles/chrome.css +10 -2
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How large the writing in a cell is.
|
|
3
|
+
*
|
|
4
|
+
* Everything a cell holds is sized against the table's own width, so the same
|
|
5
|
+
* drawing reads at 280px beside a chart and across a lecture-hall screen.
|
|
6
|
+
*
|
|
7
|
+
* Nothing is ever trimmed: a value cut short by an ellipsis is a wrong value —
|
|
8
|
+
* `0.0899` read as `0.0…` is worse than not writing it at all. A line that is
|
|
9
|
+
* still too wide at the size its table writes is condensed instead, which keeps
|
|
10
|
+
* its height, its weight and its colour — the thing a reader compares two cells
|
|
11
|
+
* on — while giving back the width it was missing.
|
|
12
|
+
*/
|
|
13
|
+
/** The column the electron counts stand in, as a share of the table's width. */
|
|
14
|
+
export declare const SHELLS_SHARE = 1.2;
|
|
15
|
+
/**
|
|
16
|
+
* The air between the symbol and that column, as a share of the table's width.
|
|
17
|
+
*
|
|
18
|
+
* Without it the widest symbols — `Md`, `Tm`, `Cm`, anything carrying an `M` or
|
|
19
|
+
* an `m` — are written at the cap and end a pixel from the first electron, and
|
|
20
|
+
* the cell reads as two things that collided rather than as two columns.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SHELLS_GAP = 0.5;
|
|
23
|
+
/** What the counts and their air together take off the width of a cell. */
|
|
24
|
+
export declare const SHELLS_RESERVED: number;
|
|
25
|
+
/** How the third line of a whole table is written. */
|
|
26
|
+
export interface DetailType {
|
|
27
|
+
/** Size every cell writes it at, as a CSS length. */
|
|
28
|
+
size: string;
|
|
29
|
+
/** How wide one em of it is, in shares of the table's width. */
|
|
30
|
+
sizeShare: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The one size a table writes its third line at.
|
|
34
|
+
*
|
|
35
|
+
* The largest at which the widest of them fits, between a floor and a cap: a
|
|
36
|
+
* table whose values are short writes them large, and one writing names writes
|
|
37
|
+
* every name at the size the longest needs.
|
|
38
|
+
* @param widths - How wide each line is, in ems of its own size.
|
|
39
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
40
|
+
* table's width; zero when none are written.
|
|
41
|
+
* @returns The size, as a CSS length and as the share it was computed from.
|
|
42
|
+
*/
|
|
43
|
+
export declare function detailType(widths: readonly number[], reservedShare: number): DetailType;
|
|
44
|
+
/**
|
|
45
|
+
* How much a line has to be condensed to fit its cell.
|
|
46
|
+
* @param widthInEm - How wide the line is, in ems of its own size.
|
|
47
|
+
* @param type - What the table writes its third line at.
|
|
48
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
49
|
+
* table's width; zero when none are written.
|
|
50
|
+
* @returns A horizontal scale, never above 1.
|
|
51
|
+
*/
|
|
52
|
+
export declare function condensedScale(widthInEm: number, type: DetailType, reservedShare: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* The size the symbol is written at.
|
|
55
|
+
*
|
|
56
|
+
* Every symbol is written at the same size, except the widest of them — the
|
|
57
|
+
* ones whose second letter is an `m` — which are written a tenth smaller rather
|
|
58
|
+
* than run into the edges of their cell.
|
|
59
|
+
* @param symbol - The chemical symbol.
|
|
60
|
+
* @param cap - Largest it is written, as a share of the table's width.
|
|
61
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
62
|
+
* table's width; zero when none are written.
|
|
63
|
+
* @returns A CSS length.
|
|
64
|
+
*/
|
|
65
|
+
export declare function symbolFontSize(symbol: string, cap: number, reservedShare: number): string;
|
|
66
|
+
/**
|
|
67
|
+
* A share, at the precision a length is written to.
|
|
68
|
+
* @param share - The share, in per cent of the table's width.
|
|
69
|
+
* @returns The same share, rounded.
|
|
70
|
+
*/
|
|
71
|
+
export declare function rounded(share: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* How wide a string is, in ems of its own size.
|
|
74
|
+
*
|
|
75
|
+
* A value is written with tabular figures, where every glyph — the decimal
|
|
76
|
+
* point and the minus of an exponent included — advances the same width, so
|
|
77
|
+
* counting its characters is the measurement. A name is proportional, and is
|
|
78
|
+
* measured letter by letter: measured as figures, every name in the table would
|
|
79
|
+
* be sized for a width it does not have.
|
|
80
|
+
* @param text - The string.
|
|
81
|
+
* @returns Its width, never zero.
|
|
82
|
+
*/
|
|
83
|
+
export declare function textWidthInEm(text: string): number;
|
|
84
|
+
/**
|
|
85
|
+
* The size a stack of electron counts is written at.
|
|
86
|
+
*
|
|
87
|
+
* Seven shells have to stand in the height of one cell, so the size is what
|
|
88
|
+
* the deepest stack of the table leaves — francium's seven, wherever the table
|
|
89
|
+
* writes any.
|
|
90
|
+
* @param count - How many shells stand in the tallest stack.
|
|
91
|
+
* @returns A CSS length.
|
|
92
|
+
*/
|
|
93
|
+
export declare function shellFontSize(count: number): string;
|
|
94
|
+
/**
|
|
95
|
+
* A horizontal scale, written as a transform.
|
|
96
|
+
* @param scale - The scale, from {@link condensedScale}.
|
|
97
|
+
* @returns The transform, or nothing at all when the line fits as it is.
|
|
98
|
+
*/
|
|
99
|
+
export declare function scaleX(scale: number): string | undefined;
|
|
100
|
+
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
101
|
+
export declare const SYMBOL_CAP = 2.1;
|
|
102
|
+
/** How tall one row of the table is, as a share of its width. */
|
|
103
|
+
export declare const ROW_SHARE = 6.8;
|
|
104
|
+
/** The height one of them takes, in ems of its own size. */
|
|
105
|
+
export declare const SHELL_LEADING = 1.2;
|
|
106
|
+
//# sourceMappingURL=cellType.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellType.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/cellType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiBH,gFAAgF;AAChF,eAAO,MAAM,YAAY,MAAM,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,2EAA2E;AAC3E,eAAO,MAAM,eAAe,QAA4B,CAAC;AAqBzD,sDAAsD;AACtD,MAAM,WAAW,UAAU;IACzB,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,aAAa,EAAE,MAAM,GACpB,UAAU,CAYZ;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,UAAU,EAChB,aAAa,EAAE,MAAM,GACpB,MAAM,CAGR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,GACpB,MAAM,CAIR;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOlD;AAuBD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKnD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAExD;AAED,mFAAmF;AACnF,eAAO,MAAM,UAAU,MAAM,CAAC;AAE9B,iEAAiE;AACjE,eAAO,MAAM,SAAS,MAAM,CAAC;AAK7B,4DAA4D;AAC5D,eAAO,MAAM,aAAa,MAAM,CAAC"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How large the writing in a cell is.
|
|
3
|
+
*
|
|
4
|
+
* Everything a cell holds is sized against the table's own width, so the same
|
|
5
|
+
* drawing reads at 280px beside a chart and across a lecture-hall screen.
|
|
6
|
+
*
|
|
7
|
+
* Nothing is ever trimmed: a value cut short by an ellipsis is a wrong value —
|
|
8
|
+
* `0.0899` read as `0.0…` is worse than not writing it at all. A line that is
|
|
9
|
+
* still too wide at the size its table writes is condensed instead, which keeps
|
|
10
|
+
* its height, its weight and its colour — the thing a reader compares two cells
|
|
11
|
+
* on — while giving back the width it was missing.
|
|
12
|
+
*/
|
|
13
|
+
import { ADVANCE } from "./glyphWidths.js";
|
|
14
|
+
import { ofWidth } from "./unit.js";
|
|
15
|
+
/**
|
|
16
|
+
* How wide one line of text is, in per cent of the table's width.
|
|
17
|
+
*
|
|
18
|
+
* A column of the grid is 4.85% of it; this is what a cell leaves of that once
|
|
19
|
+
* its border and its padding are allowed for. One share rather than a share
|
|
20
|
+
* less a few pixels, because the size a line is written at and the width it
|
|
21
|
+
* then has are then the same arithmetic — which is what lets the scale that
|
|
22
|
+
* condenses an over-wide line be a plain number rather than a length only the
|
|
23
|
+
* engine can resolve.
|
|
24
|
+
*/
|
|
25
|
+
const TEXT_SHARE = 4.5;
|
|
26
|
+
/** The column the electron counts stand in, as a share of the table's width. */
|
|
27
|
+
export const SHELLS_SHARE = 1.2;
|
|
28
|
+
/**
|
|
29
|
+
* The air between the symbol and that column, as a share of the table's width.
|
|
30
|
+
*
|
|
31
|
+
* Without it the widest symbols — `Md`, `Tm`, `Cm`, anything carrying an `M` or
|
|
32
|
+
* an `m` — are written at the cap and end a pixel from the first electron, and
|
|
33
|
+
* the cell reads as two things that collided rather than as two columns.
|
|
34
|
+
*/
|
|
35
|
+
export const SHELLS_GAP = 0.5;
|
|
36
|
+
/** What the counts and their air together take off the width of a cell. */
|
|
37
|
+
export const SHELLS_RESERVED = SHELLS_SHARE + SHELLS_GAP;
|
|
38
|
+
/** Largest the third line is written, as a share of the table's width. */
|
|
39
|
+
const DETAIL_CAP = 1.5;
|
|
40
|
+
/**
|
|
41
|
+
* Smallest it is written, as a share of the table's width.
|
|
42
|
+
*
|
|
43
|
+
* Under this a name stops being readable at any table size, so the few names
|
|
44
|
+
* that do not fit are condensed rather than written smaller — the table keeps
|
|
45
|
+
* one size for all 118, which is what makes a column of them readable at a
|
|
46
|
+
* glance.
|
|
47
|
+
*/
|
|
48
|
+
const DETAIL_FLOOR = 0.95;
|
|
49
|
+
/** What one tabular glyph advances, as a share of its own size. */
|
|
50
|
+
const TABULAR_EM = 0.6;
|
|
51
|
+
/** A string of digits, a decimal point, a sign, an exponent and nothing else. */
|
|
52
|
+
const NUMERIC = /^[\d\s.,+\-−×^eE]+$/u;
|
|
53
|
+
/**
|
|
54
|
+
* The one size a table writes its third line at.
|
|
55
|
+
*
|
|
56
|
+
* The largest at which the widest of them fits, between a floor and a cap: a
|
|
57
|
+
* table whose values are short writes them large, and one writing names writes
|
|
58
|
+
* every name at the size the longest needs.
|
|
59
|
+
* @param widths - How wide each line is, in ems of its own size.
|
|
60
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
61
|
+
* table's width; zero when none are written.
|
|
62
|
+
* @returns The size, as a CSS length and as the share it was computed from.
|
|
63
|
+
*/
|
|
64
|
+
export function detailType(widths, reservedShare) {
|
|
65
|
+
let widest = 1;
|
|
66
|
+
for (const width of widths) {
|
|
67
|
+
if (width > widest)
|
|
68
|
+
widest = width;
|
|
69
|
+
}
|
|
70
|
+
const room = TEXT_SHARE - reservedShare;
|
|
71
|
+
const share = rounded(Math.min(DETAIL_CAP, Math.max(DETAIL_FLOOR, room / widest)));
|
|
72
|
+
// A floor under which the type is not readable whatever the table is sized
|
|
73
|
+
// to, which is the one case the share alone does not cover.
|
|
74
|
+
return { size: `max(0.4rem, ${ofWidth(share)})`, sizeShare: share };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* How much a line has to be condensed to fit its cell.
|
|
78
|
+
* @param widthInEm - How wide the line is, in ems of its own size.
|
|
79
|
+
* @param type - What the table writes its third line at.
|
|
80
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
81
|
+
* table's width; zero when none are written.
|
|
82
|
+
* @returns A horizontal scale, never above 1.
|
|
83
|
+
*/
|
|
84
|
+
export function condensedScale(widthInEm, type, reservedShare) {
|
|
85
|
+
const room = TEXT_SHARE - reservedShare;
|
|
86
|
+
return Math.min(1, room / (widthInEm * type.sizeShare));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The size the symbol is written at.
|
|
90
|
+
*
|
|
91
|
+
* Every symbol is written at the same size, except the widest of them — the
|
|
92
|
+
* ones whose second letter is an `m` — which are written a tenth smaller rather
|
|
93
|
+
* than run into the edges of their cell.
|
|
94
|
+
* @param symbol - The chemical symbol.
|
|
95
|
+
* @param cap - Largest it is written, as a share of the table's width.
|
|
96
|
+
* @param reservedShare - Width taken by the electron counts, as a share of the
|
|
97
|
+
* table's width; zero when none are written.
|
|
98
|
+
* @returns A CSS length.
|
|
99
|
+
*/
|
|
100
|
+
export function symbolFontSize(symbol, cap, reservedShare) {
|
|
101
|
+
const room = TEXT_SHARE - reservedShare;
|
|
102
|
+
const share = rounded(Math.min(cap, room / (textWidthInEm(symbol) * BOLD)));
|
|
103
|
+
return `max(0.5rem, ${ofWidth(share)})`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A share, at the precision a length is written to.
|
|
107
|
+
* @param share - The share, in per cent of the table's width.
|
|
108
|
+
* @returns The same share, rounded.
|
|
109
|
+
*/
|
|
110
|
+
export function rounded(share) {
|
|
111
|
+
return Number(share.toFixed(3));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* How wide a string is, in ems of its own size.
|
|
115
|
+
*
|
|
116
|
+
* A value is written with tabular figures, where every glyph — the decimal
|
|
117
|
+
* point and the minus of an exponent included — advances the same width, so
|
|
118
|
+
* counting its characters is the measurement. A name is proportional, and is
|
|
119
|
+
* measured letter by letter: measured as figures, every name in the table would
|
|
120
|
+
* be sized for a width it does not have.
|
|
121
|
+
* @param text - The string.
|
|
122
|
+
* @returns Its width, never zero.
|
|
123
|
+
*/
|
|
124
|
+
export function textWidthInEm(text) {
|
|
125
|
+
if (NUMERIC.test(text))
|
|
126
|
+
return Math.max(text.length, 1) * TABULAR_EM * SAFETY;
|
|
127
|
+
let width = 0;
|
|
128
|
+
for (const character of text) {
|
|
129
|
+
width += glyphWidth(character);
|
|
130
|
+
}
|
|
131
|
+
return Math.max(width * SAFETY, TABULAR_EM);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* How wide one glyph is, in ems.
|
|
135
|
+
*
|
|
136
|
+
* Measured in the family's own type rather than guessed at by class: the four
|
|
137
|
+
* classes a glyph can be sorted into put `Tm` an eighth wider than it is, which
|
|
138
|
+
* is a symbol written an eighth smaller than its cell can take.
|
|
139
|
+
* @param character - The glyph.
|
|
140
|
+
* @returns Its advance.
|
|
141
|
+
*/
|
|
142
|
+
function glyphWidth(character) {
|
|
143
|
+
const measured = ADVANCE[character];
|
|
144
|
+
if (measured !== undefined)
|
|
145
|
+
return measured;
|
|
146
|
+
return character >= 'a' && character <= 'z' ? 0.54 : 0.65;
|
|
147
|
+
}
|
|
148
|
+
/** What is added to every measurement, for the faces this one stands in for. */
|
|
149
|
+
const SAFETY = 1.04;
|
|
150
|
+
/** How much wider the same string is when it is set bold, as the symbol is. */
|
|
151
|
+
const BOLD = 1.08;
|
|
152
|
+
/**
|
|
153
|
+
* The size a stack of electron counts is written at.
|
|
154
|
+
*
|
|
155
|
+
* Seven shells have to stand in the height of one cell, so the size is what
|
|
156
|
+
* the deepest stack of the table leaves — francium's seven, wherever the table
|
|
157
|
+
* writes any.
|
|
158
|
+
* @param count - How many shells stand in the tallest stack.
|
|
159
|
+
* @returns A CSS length.
|
|
160
|
+
*/
|
|
161
|
+
export function shellFontSize(count) {
|
|
162
|
+
const share = rounded(Math.min(SHELL_CAP, ROW_SHARE / (Math.max(count, 1) * SHELL_LEADING)));
|
|
163
|
+
return `max(0.3rem, ${ofWidth(share)})`;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* A horizontal scale, written as a transform.
|
|
167
|
+
* @param scale - The scale, from {@link condensedScale}.
|
|
168
|
+
* @returns The transform, or nothing at all when the line fits as it is.
|
|
169
|
+
*/
|
|
170
|
+
export function scaleX(scale) {
|
|
171
|
+
return scale >= 1 ? undefined : `scaleX(${scale.toFixed(3)})`;
|
|
172
|
+
}
|
|
173
|
+
/** The size the symbol is written at wherever it fits, as a share of the table. */
|
|
174
|
+
export const SYMBOL_CAP = 2.1;
|
|
175
|
+
/** How tall one row of the table is, as a share of its width. */
|
|
176
|
+
export const ROW_SHARE = 6.8;
|
|
177
|
+
/** The size the electron counts are written at where they have the room. */
|
|
178
|
+
const SHELL_CAP = 1.1;
|
|
179
|
+
/** The height one of them takes, in ems of its own size. */
|
|
180
|
+
export const SHELL_LEADING = 1.2;
|
|
181
|
+
//# sourceMappingURL=cellType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cellType.js","sourceRoot":"","sources":["../../../src/periodic/ui/cellType.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;;;;GASG;AACH,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,gFAAgF;AAChF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAC;AAE9B,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,CAAC;AAEzD,0EAA0E;AAC1E,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB;;;;;;;GAOG;AACH,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,mEAAmE;AACnE,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,iFAAiF;AACjF,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAUvC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,MAAyB,EACzB,aAAqB;IAErB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,GAAG,MAAM;YAAE,MAAM,GAAG,KAAK,CAAC;IACrC,CAAC;IACD,MAAM,IAAI,GAAG,UAAU,GAAG,aAAa,CAAC;IACxC,MAAM,KAAK,GAAG,OAAO,CACnB,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,GAAG,MAAM,CAAC,CAAC,CAC5D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+1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each letter advances, in ems, in the family's type.
|
|
3
|
+
*
|
|
4
|
+
* Read off the rendered page at 100px, rounded up, because sorting a glyph into
|
|
5
|
+
* one of four width classes puts `Tm` an eighth wider than it is — which is a
|
|
6
|
+
* symbol written an eighth smaller than its cell can take. A platform
|
|
7
|
+
* substituting another face moves these by a few per cent, which the safety
|
|
8
|
+
* margin of `cellType` covers.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ADVANCE: Record<string, number>;
|
|
11
|
+
//# sourceMappingURL=glyphWidths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphWidths.d.ts","sourceRoot":"","sources":["../../../src/periodic/ui/glyphWidths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA0D1C,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What each letter advances, in ems, in the family's type.
|
|
3
|
+
*
|
|
4
|
+
* Read off the rendered page at 100px, rounded up, because sorting a glyph into
|
|
5
|
+
* one of four width classes puts `Tm` an eighth wider than it is — which is a
|
|
6
|
+
* symbol written an eighth smaller than its cell can take. A platform
|
|
7
|
+
* substituting another face moves these by a few per cent, which the safety
|
|
8
|
+
* margin of `cellType` covers.
|
|
9
|
+
*/
|
|
10
|
+
export const ADVANCE = {
|
|
11
|
+
a: 0.5,
|
|
12
|
+
b: 0.57,
|
|
13
|
+
c: 0.52,
|
|
14
|
+
d: 0.57,
|
|
15
|
+
e: 0.52,
|
|
16
|
+
f: 0.33,
|
|
17
|
+
g: 0.56,
|
|
18
|
+
h: 0.54,
|
|
19
|
+
i: 0.22,
|
|
20
|
+
j: 0.22,
|
|
21
|
+
k: 0.5,
|
|
22
|
+
l: 0.23,
|
|
23
|
+
m: 0.8,
|
|
24
|
+
n: 0.54,
|
|
25
|
+
o: 0.54,
|
|
26
|
+
p: 0.56,
|
|
27
|
+
q: 0.56,
|
|
28
|
+
r: 0.35,
|
|
29
|
+
s: 0.47,
|
|
30
|
+
t: 0.33,
|
|
31
|
+
u: 0.54,
|
|
32
|
+
v: 0.5,
|
|
33
|
+
w: 0.72,
|
|
34
|
+
x: 0.48,
|
|
35
|
+
y: 0.5,
|
|
36
|
+
z: 0.5,
|
|
37
|
+
A: 0.62,
|
|
38
|
+
B: 0.6,
|
|
39
|
+
C: 0.66,
|
|
40
|
+
D: 0.67,
|
|
41
|
+
E: 0.55,
|
|
42
|
+
F: 0.53,
|
|
43
|
+
G: 0.69,
|
|
44
|
+
H: 0.69,
|
|
45
|
+
I: 0.24,
|
|
46
|
+
J: 0.49,
|
|
47
|
+
K: 0.6,
|
|
48
|
+
L: 0.52,
|
|
49
|
+
M: 0.81,
|
|
50
|
+
N: 0.69,
|
|
51
|
+
O: 0.71,
|
|
52
|
+
P: 0.59,
|
|
53
|
+
Q: 0.71,
|
|
54
|
+
R: 0.6,
|
|
55
|
+
S: 0.59,
|
|
56
|
+
T: 0.59,
|
|
57
|
+
U: 0.68,
|
|
58
|
+
V: 0.62,
|
|
59
|
+
W: 0.9,
|
|
60
|
+
X: 0.62,
|
|
61
|
+
Y: 0.6,
|
|
62
|
+
Z: 0.61,
|
|
63
|
+
' ': 0.27,
|
|
64
|
+
'-': 0.33,
|
|
65
|
+
'–': 0.54,
|
|
66
|
+
'.': 0.25,
|
|
67
|
+
',': 0.25,
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=glyphWidths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glyphWidths.js","sourceRoot":"","sources":["../../../src/periodic/ui/glyphWidths.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAA2B;IAC7C,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,IAAI;IACP,CAAC,E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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-cheminfo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"react-markdown": "^10.1.0",
|
|
77
77
|
"rehype-raw": "^7.0.0",
|
|
78
78
|
"rehype-sanitize": "^6.0.0",
|
|
79
|
+
"semver": "^7.8.5",
|
|
79
80
|
"yaml": "^2.9.1"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"@types/node": "^26.2.0",
|
|
87
88
|
"@types/react": "^19.2.18",
|
|
88
89
|
"@types/react-dom": "^19.2.4",
|
|
90
|
+
"@types/semver": "^7.8.0",
|
|
89
91
|
"@vitest/coverage-v8": "^4.1.10",
|
|
90
92
|
"@zakodium/tsconfig": "^1.0.5",
|
|
91
93
|
"benchmark": "^2.1.4",
|
|
@@ -154,5 +156,11 @@
|
|
|
154
156
|
"xtb-wasm": {
|
|
155
157
|
"optional": true
|
|
156
158
|
}
|
|
159
|
+
},
|
|
160
|
+
"overrides": {
|
|
161
|
+
"react": "^19.2.8",
|
|
162
|
+
"react-dom": "^19.2.8",
|
|
163
|
+
"@types/react": "^19.2.18",
|
|
164
|
+
"@types/react-dom": "^19.2.4"
|
|
157
165
|
}
|
|
158
166
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
+
import { lineOf, parseJsonObject, stringEntries } from './json.ts';
|
|
1
2
|
import type { DeployProblem } from './types.ts';
|
|
2
3
|
|
|
3
|
-
/** The scripts a repository's own `package.json` declares, as npm would run them. */
|
|
4
|
-
type Scripts = Record<string, string>;
|
|
5
|
-
|
|
6
4
|
/**
|
|
7
5
|
* Report a repository that can bundle, and so publish, code nothing tested.
|
|
8
6
|
*
|
|
@@ -24,8 +22,9 @@ export function readBuildGate(
|
|
|
24
22
|
problems: DeployProblem[],
|
|
25
23
|
): void {
|
|
26
24
|
if (packageJson === undefined) return;
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
25
|
+
const parsed = parseJsonObject(packageJson);
|
|
26
|
+
if (parsed === undefined) return;
|
|
27
|
+
const scripts = stringEntries(parsed.scripts);
|
|
29
28
|
|
|
30
29
|
const build = scripts.build;
|
|
31
30
|
if (build !== undefined && !/\bnpm run test\b/.test(build)) {
|
|
@@ -90,33 +89,3 @@ function gatedBuildLine(dockerfile: string): number | undefined {
|
|
|
90
89
|
}
|
|
91
90
|
return undefined;
|
|
92
91
|
}
|
|
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
|
-
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
readInstallRetries,
|
|
8
8
|
readPublishedImage,
|
|
9
9
|
} from './publishedImage.ts';
|
|
10
|
+
import { readReactCopies } from './reactCopies.ts';
|
|
10
11
|
import type { CheckDeployOptions, DeployFile, DeployProblem } from './types.ts';
|
|
11
12
|
import { DEPLOY_COMPOSE_FILES } from './types.ts';
|
|
12
13
|
|
|
@@ -88,6 +89,12 @@ export function findDeployProblems(
|
|
|
88
89
|
|
|
89
90
|
readBuildGate(byPath.get('package.json'), dockerfile, problems);
|
|
90
91
|
|
|
92
|
+
readReactCopies(
|
|
93
|
+
byPath.get('package.json'),
|
|
94
|
+
byPath.get('package-lock.json'),
|
|
95
|
+
problems,
|
|
96
|
+
);
|
|
97
|
+
|
|
91
98
|
readPublishedImage(byPath.get(DOCKER_IMAGE_WORKFLOW), problems);
|
|
92
99
|
|
|
93
100
|
const gitignore = byPath.get('.gitignore');
|
package/src/deploy/core/index.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading the repository's own JSON files, which a checker must do without ever
|
|
3
|
+
* throwing: the absence of a file, and a file somebody has broken, are both
|
|
4
|
+
* things to report rather than to crash on.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A JSON file the repository may not have, or may have broken.
|
|
9
|
+
* @param text - The file, unparsed.
|
|
10
|
+
* @returns Its object form, or undefined when it is neither.
|
|
11
|
+
*/
|
|
12
|
+
export function parseJsonObject(
|
|
13
|
+
text: string | undefined,
|
|
14
|
+
): Record<string, unknown> | undefined {
|
|
15
|
+
if (text === undefined) return undefined;
|
|
16
|
+
let parsed: unknown;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(text);
|
|
19
|
+
} catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
if (typeof parsed !== 'object' || parsed === null) return undefined;
|
|
23
|
+
return parsed as Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A block of a `package.json` as a map of strings, dropping any entry that is
|
|
28
|
+
* not one — the nested form of `overrides` pins something other than the
|
|
29
|
+
* package it is written under.
|
|
30
|
+
* @param value - The block, as parsed.
|
|
31
|
+
* @returns Its string entries.
|
|
32
|
+
*/
|
|
33
|
+
export function stringEntries(value: unknown): Record<string, string> {
|
|
34
|
+
if (typeof value !== 'object' || value === null) return {};
|
|
35
|
+
const found: Record<string, string> = {};
|
|
36
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
37
|
+
if (typeof entry === 'string') found[key] = entry;
|
|
38
|
+
}
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Where a report should point, so the reader lands on the line itself.
|
|
44
|
+
* @param text - The file to search, when there is one.
|
|
45
|
+
* @param needle - The literal to find.
|
|
46
|
+
* @returns Its line, counting from 1, or 0 when it is not there.
|
|
47
|
+
*/
|
|
48
|
+
export function lineOf(text: string | undefined, needle: string): number {
|
|
49
|
+
if (text === undefined) return 0;
|
|
50
|
+
const at = text.indexOf(needle);
|
|
51
|
+
if (at === -1) return 0;
|
|
52
|
+
return text.slice(0, at).split('\n').length;
|
|
53
|
+
}
|