react-cheminfo 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/lib/about/core/about.d.ts +9 -0
  2. package/lib/about/core/about.d.ts.map +1 -1
  3. package/lib/about/core/about.js +1 -0
  4. package/lib/about/core/about.js.map +1 -1
  5. package/lib/about/core/index.d.ts +1 -0
  6. package/lib/about/core/index.d.ts.map +1 -1
  7. package/lib/about/core/index.js +1 -0
  8. package/lib/about/core/index.js.map +1 -1
  9. package/lib/about/core/repository.d.ts +14 -0
  10. package/lib/about/core/repository.d.ts.map +1 -0
  11. package/lib/about/core/repository.js +21 -0
  12. package/lib/about/core/repository.js.map +1 -0
  13. package/lib/about/ui/AboutBuild.d.ts +5 -4
  14. package/lib/about/ui/AboutBuild.d.ts.map +1 -1
  15. package/lib/about/ui/AboutBuild.js +10 -10
  16. package/lib/about/ui/AboutBuild.js.map +1 -1
  17. package/lib/about/ui/AboutPage.d.ts.map +1 -1
  18. package/lib/about/ui/AboutPage.js +7 -8
  19. package/lib/about/ui/AboutPage.js.map +1 -1
  20. package/lib/about/ui/AboutVersion.d.ts +25 -0
  21. package/lib/about/ui/AboutVersion.d.ts.map +1 -0
  22. package/lib/about/ui/AboutVersion.js +31 -0
  23. package/lib/about/ui/AboutVersion.js.map +1 -0
  24. package/lib/about/ui/index.d.ts +2 -0
  25. package/lib/about/ui/index.d.ts.map +1 -1
  26. package/lib/about/ui/index.js +1 -0
  27. package/lib/about/ui/index.js.map +1 -1
  28. package/lib/build/core/buildInfo.d.ts +16 -0
  29. package/lib/build/core/buildInfo.d.ts.map +1 -1
  30. package/lib/build/core/buildInfo.js +21 -0
  31. package/lib/build/core/buildInfo.js.map +1 -1
  32. package/lib/build/core/index.d.ts +1 -1
  33. package/lib/build/core/index.d.ts.map +1 -1
  34. package/lib/build/core/index.js +1 -1
  35. package/lib/build/core/index.js.map +1 -1
  36. package/lib/build/vite/buildInfo.d.ts.map +1 -1
  37. package/lib/build/vite/buildInfo.js +2 -2
  38. package/lib/build/vite/buildInfo.js.map +1 -1
  39. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  40. package/lib/ecosystem/core/sites.js +12 -0
  41. package/lib/ecosystem/core/sites.js.map +1 -1
  42. package/lib/ecosystem/core/types.d.ts +8 -0
  43. package/lib/ecosystem/core/types.d.ts.map +1 -1
  44. package/lib/molecule3d/core/camera.d.ts +89 -0
  45. package/lib/molecule3d/core/camera.d.ts.map +1 -0
  46. package/lib/molecule3d/core/camera.js +172 -0
  47. package/lib/molecule3d/core/camera.js.map +1 -0
  48. package/lib/molecule3d/core/index.d.ts +2 -0
  49. package/lib/molecule3d/core/index.d.ts.map +1 -1
  50. package/lib/molecule3d/core/index.js +1 -0
  51. package/lib/molecule3d/core/index.js.map +1 -1
  52. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  53. package/lib/molecule3d/ui/MoleculeCanvas3D.js +14 -37
  54. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  55. package/lib/molecule3d/ui/camera.d.ts +35 -2
  56. package/lib/molecule3d/ui/camera.d.ts.map +1 -1
  57. package/lib/molecule3d/ui/camera.js +113 -4
  58. package/lib/molecule3d/ui/camera.js.map +1 -1
  59. package/lib/molecule3d/ui/captureScene.d.ts +14 -0
  60. package/lib/molecule3d/ui/captureScene.d.ts.map +1 -0
  61. package/lib/molecule3d/ui/captureScene.js +24 -0
  62. package/lib/molecule3d/ui/captureScene.js.map +1 -0
  63. package/lib/molecule3d/ui/createViewer.d.ts +18 -0
  64. package/lib/molecule3d/ui/createViewer.d.ts.map +1 -0
  65. package/lib/molecule3d/ui/createViewer.js +19 -0
  66. package/lib/molecule3d/ui/createViewer.js.map +1 -0
  67. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +21 -0
  68. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  69. package/lib/molecule3d/ui/useMoleculeScene.d.ts +47 -0
  70. package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -0
  71. package/lib/molecule3d/ui/useMoleculeScene.js +82 -0
  72. package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -0
  73. package/lib/molecule3d/ui/useSharedCamera.d.ts +52 -0
  74. package/lib/molecule3d/ui/useSharedCamera.d.ts.map +1 -0
  75. package/lib/molecule3d/ui/useSharedCamera.js +82 -0
  76. package/lib/molecule3d/ui/useSharedCamera.js.map +1 -0
  77. package/lib/molecule3d/ui/viewer.d.ts +21 -15
  78. package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
  79. package/lib/molecule3d/ui/viewer.js +41 -47
  80. package/lib/molecule3d/ui/viewer.js.map +1 -1
  81. package/lib/molecule3d/ui/viewerSpec.d.ts +17 -0
  82. package/lib/molecule3d/ui/viewerSpec.d.ts.map +1 -0
  83. package/lib/molecule3d/ui/viewerSpec.js +34 -0
  84. package/lib/molecule3d/ui/viewerSpec.js.map +1 -0
  85. package/lib/structure/core/editorGuide.d.ts +69 -0
  86. package/lib/structure/core/editorGuide.d.ts.map +1 -0
  87. package/lib/structure/core/editorGuide.js +162 -0
  88. package/lib/structure/core/editorGuide.js.map +1 -0
  89. package/lib/structure/core/editorToolbar.d.ts +45 -0
  90. package/lib/structure/core/editorToolbar.d.ts.map +1 -0
  91. package/lib/structure/core/editorToolbar.js +132 -0
  92. package/lib/structure/core/editorToolbar.js.map +1 -0
  93. package/lib/structure/core/editorToolbarGeometry.d.ts +36 -0
  94. package/lib/structure/core/editorToolbarGeometry.d.ts.map +1 -0
  95. package/lib/structure/core/editorToolbarGeometry.js +61 -0
  96. package/lib/structure/core/editorToolbarGeometry.js.map +1 -0
  97. package/lib/structure/core/index.d.ts +6 -0
  98. package/lib/structure/core/index.d.ts.map +1 -1
  99. package/lib/structure/core/index.js +3 -0
  100. package/lib/structure/core/index.js.map +1 -1
  101. package/lib/structure/core/pendingCall.d.ts +21 -0
  102. package/lib/structure/core/pendingCall.d.ts.map +1 -0
  103. package/lib/structure/core/pendingCall.js +37 -0
  104. package/lib/structure/core/pendingCall.js.map +1 -0
  105. package/lib/structure/ui/EditorCanvas.d.ts +1 -16
  106. package/lib/structure/ui/EditorCanvas.d.ts.map +1 -1
  107. package/lib/structure/ui/EditorCanvas.js +5 -18
  108. package/lib/structure/ui/EditorCanvas.js.map +1 -1
  109. package/lib/structure/ui/EditorHelpButton.d.ts +22 -0
  110. package/lib/structure/ui/EditorHelpButton.d.ts.map +1 -0
  111. package/lib/structure/ui/EditorHelpButton.js +38 -0
  112. package/lib/structure/ui/EditorHelpButton.js.map +1 -0
  113. package/lib/structure/ui/KeyCaps.d.ts +12 -0
  114. package/lib/structure/ui/KeyCaps.d.ts.map +1 -0
  115. package/lib/structure/ui/KeyCaps.js +29 -0
  116. package/lib/structure/ui/KeyCaps.js.map +1 -0
  117. package/lib/structure/ui/StructureEditor.d.ts +9 -2
  118. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  119. package/lib/structure/ui/StructureEditor.js +17 -24
  120. package/lib/structure/ui/StructureEditor.js.map +1 -1
  121. package/lib/structure/ui/StructureEditorHelp.d.ts +18 -0
  122. package/lib/structure/ui/StructureEditorHelp.d.ts.map +1 -0
  123. package/lib/structure/ui/StructureEditorHelp.js +68 -0
  124. package/lib/structure/ui/StructureEditorHelp.js.map +1 -0
  125. package/lib/structure/ui/ToolbarTooltip.d.ts +20 -0
  126. package/lib/structure/ui/ToolbarTooltip.d.ts.map +1 -0
  127. package/lib/structure/ui/ToolbarTooltip.js +49 -0
  128. package/lib/structure/ui/ToolbarTooltip.js.map +1 -0
  129. package/lib/structure/ui/editorChange.d.ts +52 -0
  130. package/lib/structure/ui/editorChange.d.ts.map +1 -0
  131. package/lib/structure/ui/editorChange.js +34 -0
  132. package/lib/structure/ui/editorChange.js.map +1 -0
  133. package/lib/structure/ui/index.d.ts +3 -1
  134. package/lib/structure/ui/index.d.ts.map +1 -1
  135. package/lib/structure/ui/index.js +1 -0
  136. package/lib/structure/ui/index.js.map +1 -1
  137. package/lib/structure/ui/useToolbarFloor.d.ts.map +1 -1
  138. package/lib/structure/ui/useToolbarFloor.js +6 -45
  139. package/lib/structure/ui/useToolbarFloor.js.map +1 -1
  140. package/lib/structure/ui/useToolbarHover.d.ts +28 -0
  141. package/lib/structure/ui/useToolbarHover.d.ts.map +1 -0
  142. package/lib/structure/ui/useToolbarHover.js +96 -0
  143. package/lib/structure/ui/useToolbarHover.js.map +1 -0
  144. package/lib/structure/ui/watchToolbar.d.ts +17 -0
  145. package/lib/structure/ui/watchToolbar.d.ts.map +1 -0
  146. package/lib/structure/ui/watchToolbar.js +56 -0
  147. package/lib/structure/ui/watchToolbar.js.map +1 -0
  148. package/package.json +1 -1
  149. package/src/about/core/about.ts +11 -0
  150. package/src/about/core/index.ts +1 -0
  151. package/src/about/core/repository.ts +22 -0
  152. package/src/about/ui/AboutBuild.tsx +13 -20
  153. package/src/about/ui/AboutPage.tsx +30 -22
  154. package/src/about/ui/AboutVersion.tsx +67 -0
  155. package/src/about/ui/index.ts +2 -0
  156. package/src/build/core/buildInfo.ts +24 -0
  157. package/src/build/core/index.ts +6 -1
  158. package/src/build/vite/buildInfo.ts +2 -2
  159. package/src/ecosystem/core/sites.ts +12 -0
  160. package/src/ecosystem/core/types.ts +8 -0
  161. package/src/molecule3d/core/camera.ts +212 -0
  162. package/src/molecule3d/core/index.ts +14 -0
  163. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +14 -43
  164. package/src/molecule3d/ui/camera.ts +128 -7
  165. package/src/molecule3d/ui/captureScene.ts +31 -0
  166. package/src/molecule3d/ui/createViewer.ts +24 -0
  167. package/src/molecule3d/ui/moleculeViewer3DProps.ts +21 -0
  168. package/src/molecule3d/ui/useMoleculeScene.ts +141 -0
  169. package/src/molecule3d/ui/useSharedCamera.ts +121 -0
  170. package/src/molecule3d/ui/viewer.ts +45 -50
  171. package/src/molecule3d/ui/viewerSpec.ts +38 -0
  172. package/src/structure/core/editorGuide.ts +221 -0
  173. package/src/structure/core/editorToolbar.ts +175 -0
  174. package/src/structure/core/editorToolbarGeometry.ts +80 -0
  175. package/src/structure/core/index.ts +29 -0
  176. package/src/structure/core/pendingCall.ts +59 -0
  177. package/src/structure/ui/EditorCanvas.tsx +9 -35
  178. package/src/structure/ui/EditorHelpButton.tsx +70 -0
  179. package/src/structure/ui/KeyCaps.tsx +40 -0
  180. package/src/structure/ui/StructureEditor.tsx +39 -21
  181. package/src/structure/ui/StructureEditorHelp.tsx +136 -0
  182. package/src/structure/ui/ToolbarTooltip.tsx +95 -0
  183. package/src/structure/ui/editorChange.ts +81 -0
  184. package/src/structure/ui/index.ts +5 -1
  185. package/src/structure/ui/useToolbarFloor.ts +7 -46
  186. package/src/structure/ui/useToolbarHover.ts +134 -0
  187. package/src/structure/ui/watchToolbar.ts +59 -0
@@ -63,6 +63,13 @@ export interface AboutContent {
63
63
  * @default the repository of the ECOSYSTEM_SITES record
64
64
  */
65
65
  repository?: string;
66
+ /**
67
+ * Whether a visitor can open that repository. A site naming a repository of
68
+ * its own says so here too, since the family's record then describes another
69
+ * one.
70
+ * @default the `publicRepository` of the ECOSYSTEM_SITES record
71
+ */
72
+ publicRepository?: boolean;
66
73
  /**
67
74
  * Which build is running, from `virtual:cheminfo-build-info` — never written
68
75
  * by hand, which is what keeps it true after the next release.
@@ -108,6 +115,8 @@ export interface ResolvedAbout {
108
115
  providedBy: ProviderEntry[];
109
116
  license: string;
110
117
  repository: string;
118
+ /** Whether a visitor can open the repository, and so whether it is named. */
119
+ publicRepository: boolean;
111
120
  /** Which build is running, or `undefined` when the site does not say. */
112
121
  build: BuildInfo | undefined;
113
122
  issues: string;
@@ -139,6 +148,8 @@ export function resolveAbout(content: AboutContent): ResolvedAbout {
139
148
  providedBy: providers(content.providedBy ?? []),
140
149
  license: content.license ?? DEFAULT_LICENSE,
141
150
  repository,
151
+ publicRepository:
152
+ content.publicRepository ?? site.publicRepository ?? false,
142
153
  build: content.build,
143
154
  issues: content.issues ?? `${withoutTrailingSlash(repository)}/issues`,
144
155
  };
@@ -1,3 +1,4 @@
1
+ export { githubSources } from './repository.ts';
1
2
  export type { AboutContent, AboutPerson, ResolvedAbout } from './about.ts';
2
3
  export { aboutProblems, resolveAbout } from './about.ts';
3
4
  export type { ProviderEntry, ProviderId } from './providers.ts';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * What can be linked to inside a repository, and when.
3
+ *
4
+ * Only GitHub has the addresses the About page builds — a release tag, a
5
+ * commit — and only a repository a visitor can open is worth pointing them at.
6
+ */
7
+
8
+ /** Where our repositories live, and the only host whose paths we know. */
9
+ const GITHUB = 'https://github.com/';
10
+
11
+ /**
12
+ * The sources as a base a release or a commit can be appended to.
13
+ * @param repository - Where the sources live.
14
+ * @returns The address without its trailing slash, or `undefined` when it is
15
+ * not a GitHub repository and nothing inside it can be addressed.
16
+ */
17
+ export function githubSources(repository: string): string | undefined {
18
+ const sources = repository.endsWith('/')
19
+ ? repository.slice(0, -1)
20
+ : repository;
21
+ return sources.startsWith(GITHUB) ? sources : undefined;
22
+ }
@@ -2,6 +2,7 @@ import type { CSSProperties, ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import type { BuildInfo } from '../../build/core/buildInfo.ts';
4
4
  import { formatBuiltAt, shortCommit } from '../../build/core/buildInfo.ts';
5
+ import { githubSources } from '../core/repository.ts';
5
6
 
6
7
  export interface AboutBuildProps {
7
8
  /** What the build published about itself. */
@@ -11,38 +12,32 @@ export interface AboutBuildProps {
11
12
  }
12
13
 
13
14
  /**
14
- * The one line that says which build of the site a visitor has open.
15
+ * The one line that says when the build a visitor has open was made.
15
16
  *
16
17
  * A report of something going wrong is worth answering only when we know what
17
- * was running, and a visitor cannot read that off the page otherwise. The
18
- * version and the commit link into the repository, so the change that caused a
19
- * problem is one click from the page that shows it.
18
+ * was running. The version itself is in the hero, where a reader is asked to
19
+ * quote it from; this line carries the rest, and the commit links into the
20
+ * repository, so the change that caused a problem is one click from the page
21
+ * that shows it.
20
22
  * @param props - See {@link AboutBuildProps}.
21
23
  * @returns The line.
22
24
  */
23
25
  export function AboutBuild(props: AboutBuildProps): ReactElement {
24
26
  const { build, repository } = props;
25
- const sources = repository.endsWith('/')
26
- ? repository.slice(0, -1)
27
- : repository;
28
- const onGitHub = sources.startsWith(GITHUB);
27
+ const sources = githubSources(repository);
29
28
 
30
29
  return (
31
30
  <p style={PARAGRAPH_STYLE}>
32
- Running version{' '}
33
- <Reference
34
- href={
35
- onGitHub ? `${sources}/releases/tag/v${build.version}` : undefined
36
- }
37
- >
38
- {build.version}
39
- </Reference>
40
- , built {formatBuiltAt(build.builtAt)}
31
+ Built {formatBuiltAt(build.builtAt)}
41
32
  {build.commit === undefined ? null : (
42
33
  <>
43
34
  {' from commit '}
44
35
  <Reference
45
- href={onGitHub ? `${sources}/commit/${build.commit}` : undefined}
36
+ href={
37
+ sources === undefined
38
+ ? undefined
39
+ : `${sources}/commit/${build.commit}`
40
+ }
46
41
  >
47
42
  {shortCommit(build.commit)}
48
43
  </Reference>
@@ -67,8 +62,6 @@ function Reference(props: {
67
62
  );
68
63
  }
69
64
 
70
- const GITHUB = 'https://github.com/';
71
-
72
65
  const PARAGRAPH_STYLE = {
73
66
  margin: '8px 0 0',
74
67
  color: 'var(--text-muted)',
@@ -10,6 +10,7 @@ import { AboutBuild } from './AboutBuild.tsx';
10
10
  import { AboutCitations } from './AboutCitations.tsx';
11
11
  import { AboutProvidedBy } from './AboutProvidedBy.tsx';
12
12
  import { AboutSection } from './AboutSection.tsx';
13
+ import { AboutVersion } from './AboutVersion.tsx';
13
14
 
14
15
  export interface AboutPageProps {
15
16
  /** What the site says about itself. */
@@ -67,20 +68,22 @@ export function AboutPage(props: AboutPageProps): ReactElement {
67
68
  }
68
69
  style={PAGE_STYLE}
69
70
  >
70
- <header
71
- className="about-hero"
72
- style={logo === undefined ? HERO_STYLE : LOGO_HERO_STYLE}
73
- >
71
+ <header className="about-hero" style={HERO_STYLE}>
74
72
  {logo === undefined
75
73
  ? (mark ?? <SiteMark site={site} size={56} />)
76
74
  : null}
77
- <div>
75
+ <div style={HERO_BODY_STYLE}>
78
76
  <h1 style={logo === undefined ? NAME_STYLE : LOGO_NAME_STYLE}>
79
77
  {logo ?? <Wordmark site={site} size={26} />}
80
78
  </h1>
81
79
  <p style={TAGLINE_STYLE}>{site.tagline}</p>
82
80
  <p style={WHAT_STYLE}>{about.what}</p>
83
81
  </div>
82
+ <AboutVersion
83
+ build={about.build}
84
+ repository={about.repository}
85
+ publicRepository={about.publicRepository}
86
+ />
84
87
  </header>
85
88
 
86
89
  {about.people.length === 0 && about.providedBy.length === 0 ? null : (
@@ -122,16 +125,23 @@ export function AboutPage(props: AboutPageProps): ReactElement {
122
125
  </AboutSection>
123
126
  )}
124
127
 
125
- <AboutSection title="Licence and source" className="about-licence">
126
- <p style={FIRST_PARAGRAPH_STYLE}>
127
- {about.license}, © cheminfo. Use it in a course, fork it, or lift a
128
- piece of it into something else. The sources are at{' '}
129
- <ExternalLink href={about.repository} />.
130
- </p>
131
- {about.build === undefined ? null : (
132
- <AboutBuild build={about.build} repository={about.repository} />
133
- )}
134
- </AboutSection>
128
+ {/*
129
+ A repository nobody outside can open is named nowhere: a licence a
130
+ reader cannot act on and a link that answers 404 say less than silence.
131
+ The version stays in the hero, unlinked, so a report still names a build.
132
+ */}
133
+ {!about.publicRepository ? null : (
134
+ <AboutSection title="Licence and source" className="about-licence">
135
+ <p style={FIRST_PARAGRAPH_STYLE}>
136
+ {about.license}, © cheminfo. Use it in a course, fork it, or lift a
137
+ piece of it into something else. The sources are at{' '}
138
+ <ExternalLink href={about.repository} />.
139
+ </p>
140
+ {about.build === undefined ? null : (
141
+ <AboutBuild build={about.build} repository={about.repository} />
142
+ )}
143
+ </AboutSection>
144
+ )}
135
145
 
136
146
  <AboutSection title="Found a problem?" className="about-issues">
137
147
  <p style={FIRST_PARAGRAPH_STYLE}>
@@ -162,6 +172,11 @@ const PAGE_STYLE = {
162
172
  gap: 10,
163
173
  } as const satisfies CSSProperties;
164
174
 
175
+ const HERO_BODY_STYLE = {
176
+ flex: '1 1 auto',
177
+ minWidth: 0,
178
+ } as const satisfies CSSProperties;
179
+
165
180
  const HERO_STYLE = {
166
181
  display: 'flex',
167
182
  alignItems: 'flex-start',
@@ -179,13 +194,6 @@ const NAME_STYLE = {
179
194
  fontWeight: 700,
180
195
  } as const satisfies CSSProperties;
181
196
 
182
- // A drawn lockup already carries the mark and the name at its own proportions,
183
- // so the hero gives it the full width rather than a column beside a mark.
184
- const LOGO_HERO_STYLE = {
185
- ...HERO_STYLE,
186
- display: 'block',
187
- } as const satisfies CSSProperties;
188
-
189
197
  const LOGO_NAME_STYLE = {
190
198
  margin: '0 0 4px',
191
199
  } as const satisfies CSSProperties;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Which release of a site a visitor has open, in the corner of its hero.
3
+ *
4
+ * A report of something going wrong is worth answering only when we know what
5
+ * was running, and the version is the one thing an About page cannot say from
6
+ * a hand-written record. It sits at the top of the page rather than at the
7
+ * bottom because it is the one line a reader is asked to quote back.
8
+ */
9
+
10
+ import type { CSSProperties, ReactElement } from 'react';
11
+
12
+ import type { BuildInfo } from '../../build/core/buildInfo.ts';
13
+ import { releasedVersion } from '../../build/core/buildInfo.ts';
14
+ import { githubSources } from '../core/repository.ts';
15
+
16
+ export interface AboutVersionProps {
17
+ /** What the build published about itself, or `undefined` when it published none. */
18
+ build: BuildInfo | undefined;
19
+ /** Where the sources live, which is what the version links into. */
20
+ repository: string;
21
+ /** Whether a visitor can open that repository, and so whether it is linked. */
22
+ publicRepository: boolean;
23
+ }
24
+
25
+ /**
26
+ * The version badge, or nothing when there is no version worth showing.
27
+ * @param props - See {@link AboutVersionProps}.
28
+ * @returns The badge, or `null`.
29
+ */
30
+ export function AboutVersion(props: AboutVersionProps): ReactElement | null {
31
+ const { build, repository, publicRepository } = props;
32
+ const version = releasedVersion(build);
33
+ if (version === undefined) return null;
34
+ const sources = publicRepository ? githubSources(repository) : undefined;
35
+ if (sources === undefined) {
36
+ return (
37
+ <span style={BADGE_STYLE} className="about-version">
38
+ {version}
39
+ </span>
40
+ );
41
+ }
42
+
43
+ return (
44
+ <a
45
+ className="about-version"
46
+ href={`${sources}/releases/tag/v${version}`}
47
+ target="_blank"
48
+ rel="noopener noreferrer"
49
+ style={LINK_BADGE_STYLE}
50
+ >
51
+ {version}
52
+ </a>
53
+ );
54
+ }
55
+
56
+ const BADGE_STYLE = {
57
+ flex: '0 0 auto',
58
+ fontFamily: 'var(--font-mono, ui-monospace, monospace)',
59
+ fontSize: 13,
60
+ color: 'var(--text-muted)',
61
+ whiteSpace: 'nowrap',
62
+ } as const satisfies CSSProperties;
63
+
64
+ const LINK_BADGE_STYLE = {
65
+ ...BADGE_STYLE,
66
+ color: 'var(--accent)',
67
+ } as const satisfies CSSProperties;
@@ -1,5 +1,7 @@
1
1
  export type { AboutBuildProps } from './AboutBuild.tsx';
2
2
  export { AboutBuild } from './AboutBuild.tsx';
3
+ export type { AboutVersionProps } from './AboutVersion.tsx';
4
+ export { AboutVersion } from './AboutVersion.tsx';
3
5
  export type { AboutCitationsProps } from './AboutCitations.tsx';
4
6
  export { AboutCitations } from './AboutCitations.tsx';
5
7
  export type { AboutPageProps } from './AboutPage.tsx';
@@ -25,6 +25,30 @@ export interface BuildInfo {
25
25
  reactCheminfo?: string;
26
26
  }
27
27
 
28
+ /**
29
+ * The version a build reports when the repository has never been released.
30
+ *
31
+ * release-please writes the version into the root `package.json`, so a site
32
+ * whose first release has not happened yet is built from the `0.0.0` it was
33
+ * scaffolded with. That is not a version anybody can look up, so nothing shows
34
+ * it: a page saying `0.0.0` reads as a bug rather than as a release.
35
+ */
36
+ export const UNRELEASED_VERSION = '0.0.0';
37
+
38
+ /**
39
+ * The version to show a reader, if there is one.
40
+ * @param build - What the build published about itself, or `undefined`.
41
+ * @returns The released version, or `undefined` when the build published none
42
+ * or has never been released.
43
+ */
44
+ export function releasedVersion(
45
+ build: BuildInfo | undefined,
46
+ ): string | undefined {
47
+ const version = build?.version;
48
+ if (version === undefined || version === UNRELEASED_VERSION) return undefined;
49
+ return version;
50
+ }
51
+
28
52
  /**
29
53
  * The commit as it is written for a reader.
30
54
  * @param commit - The full hash.
@@ -1,2 +1,7 @@
1
1
  export type { BuildInfo } from './buildInfo.ts';
2
- export { formatBuiltAt, shortCommit } from './buildInfo.ts';
2
+ export {
3
+ UNRELEASED_VERSION,
4
+ formatBuiltAt,
5
+ releasedVersion,
6
+ shortCommit,
7
+ } from './buildInfo.ts';
@@ -15,6 +15,7 @@ import { dirname, join, resolve } from 'node:path';
15
15
  import type { Plugin } from 'vite';
16
16
 
17
17
  import type { BuildInfo } from '../core/buildInfo.ts';
18
+ import { UNRELEASED_VERSION } from '../core/buildInfo.ts';
18
19
 
19
20
  import { commitFromEnvironment, readGitHead } from './gitHead.ts';
20
21
 
@@ -92,7 +93,7 @@ export function resolveBuildInfo(root: string): BuildInfo {
92
93
  const repository = findRepositoryRoot(root);
93
94
 
94
95
  return {
95
- version: readVersion(repository) ?? readVersion(root) ?? UNRELEASED,
96
+ version: readVersion(repository) ?? readVersion(root) ?? UNRELEASED_VERSION,
96
97
  builtAt: buildInstant(),
97
98
  commit: readGitHead(repository) ?? commitFromEnvironment(),
98
99
  reactCheminfo: readOwnVersion(),
@@ -174,5 +175,4 @@ function buildInstant(): string {
174
175
 
175
176
  const RESOLVED_MODULE = `\0${BUILD_INFO_MODULE}`;
176
177
  const OWN_NAME = 'react-cheminfo';
177
- const UNRELEASED = '0.0.0';
178
178
  const SECOND_LENGTH = 19;
@@ -62,6 +62,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
62
62
  name: { lead: 'openbabel', alt: 'cheminfo', dot: true },
63
63
  host: 'openbabel.cheminfo.org',
64
64
  repository: 'https://github.com/cheminfo/openbabel.cheminfo.org',
65
+ publicRepository: true,
65
66
  tagline: 'Convert a structure between any pair of chemical file formats.',
66
67
  group: 'structures',
67
68
  brand: '#0f766e',
@@ -84,6 +85,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
84
85
  name: { lead: 'dbe', alt: 'cheminfo', dot: true },
85
86
  host: 'dbe.cheminfo.org',
86
87
  repository: 'https://github.com/cheminfo/dbe.cheminfo.org',
88
+ publicRepository: true,
87
89
  tagline: 'Count rings and double bonds from a formula or a structure.',
88
90
  group: 'basics',
89
91
  brand: '#63123f',
@@ -97,6 +99,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
97
99
  name: { lead: 'NMR', alt: 'ium' },
98
100
  host: 'www.nmrium.org',
99
101
  repository: 'https://github.com/cheminfo/nmrium',
102
+ publicRepository: true,
100
103
  tagline: 'Process and assign NMR spectra in the browser.',
101
104
  group: 'spectra',
102
105
  brand: '#ea580c',
@@ -133,6 +136,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
133
136
  name: { lead: 'surge', alt: 'cheminfo', dot: true },
134
137
  host: 'surge.cheminfo.org',
135
138
  repository: 'https://github.com/cheminfo/surge.cheminfo.org',
139
+ publicRepository: true,
136
140
  tagline: 'Every constitutional isomer of a molecular formula.',
137
141
  group: 'structures',
138
142
  brand: '#4338ca',
@@ -144,6 +148,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
144
148
  name: { lead: 'tex', alt: 'cheminfo', dot: true },
145
149
  host: 'tex.cheminfo.org',
146
150
  repository: 'https://github.com/cheminfo/tex.cheminfo.org',
151
+ publicRepository: true,
147
152
  tagline: 'LaTeX formulas rendered to SVG or PNG from a URL.',
148
153
  group: 'computing',
149
154
  brand: '#a21caf',
@@ -166,6 +171,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
166
171
  name: { lead: 'regexp', alt: 'cheminfo', dot: true },
167
172
  host: 'regexp.cheminfo.org',
168
173
  repository: 'https://github.com/cheminfo/regexp.cheminfo.org',
174
+ publicRepository: true,
169
175
  tagline: 'Learn regular expressions in a live playground.',
170
176
  group: 'computing',
171
177
  brand: '#1e3a8a',
@@ -177,6 +183,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
177
183
  name: { lead: 'pdb', alt: 'cheminfo', dot: true },
178
184
  host: 'pdb.cheminfo.org',
179
185
  repository: 'https://github.com/cheminfo/pdb.cheminfo.org',
186
+ publicRepository: true,
180
187
  tagline: 'A fast look at any Protein Data Bank entry.',
181
188
  group: 'research',
182
189
  brand: '#2563eb',
@@ -188,6 +195,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
188
195
  name: { lead: 'elucidation', alt: 'cheminfo', dot: true },
189
196
  host: 'elucidation.cheminfo.org',
190
197
  repository: 'https://github.com/cheminfo/elucidation.cheminfo.org',
198
+ publicRepository: true,
191
199
  tagline: 'A structure from a 1H NMR spectrum and a formula.',
192
200
  group: 'spectra',
193
201
  brand: '#7e22ce',
@@ -210,6 +218,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
210
218
  name: { lead: 'Poly', alt: 'Carp' },
211
219
  host: 'polycarp.cheminfo.org',
212
220
  repository: 'https://github.com/cheminfo/polycarp.cheminfo.org',
221
+ publicRepository: true,
213
222
  tagline: 'Predict the microstructure of a radical copolymerisation.',
214
223
  group: 'research',
215
224
  brand: '#701a75',
@@ -243,6 +252,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
243
252
  name: { lead: 'database', alt: 'cheminfo', dot: true },
244
253
  host: 'database.cheminfo.org',
245
254
  repository: 'https://github.com/cheminfo/database.cheminfo.org',
255
+ publicRepository: true,
246
256
  tagline: 'Query a real chemical dataset in SQL and in Mango.',
247
257
  group: 'research',
248
258
  brand: '#7c2d12',
@@ -254,6 +264,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
254
264
  name: { lead: 'Symme', alt: 'Try' },
255
265
  host: 'symmetry.cheminfo.org',
256
266
  repository: 'https://github.com/cheminfo/symmetry.cheminfo.org',
267
+ publicRepository: true,
257
268
  tagline: 'Find the symmetry of a molecule, a crystal or a pattern.',
258
269
  group: 'basics',
259
270
  brand: '#9f1239',
@@ -267,6 +278,7 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
267
278
  name: { lead: 'osiris', alt: 'cheminfo', dot: true },
268
279
  host: 'osiris.cheminfo.org',
269
280
  repository: 'https://github.com/cheminfo/osiris.cheminfo.org',
281
+ publicRepository: true,
270
282
  tagline: 'Predicted toxicity risks and properties, one molecule or many.',
271
283
  group: 'research',
272
284
  brand: '#854d0e',
@@ -60,6 +60,14 @@ export interface EcosystemSite {
60
60
  host: string;
61
61
  /** Where the sources live, and what a Source link opens. */
62
62
  repository: string;
63
+ /**
64
+ * Whether a visitor can open that repository. A private one is named
65
+ * nowhere: no licence-and-source section, no link from the version, no issue
66
+ * tracker a reader cannot reach. It is stated rather than assumed, so a site
67
+ * whose record forgets it advertises nothing rather than a dead link.
68
+ * @default false
69
+ */
70
+ publicRepository?: boolean;
63
71
  /** One line on what the site does. */
64
72
  tagline: string;
65
73
  /**