react-cheminfo 0.58.0 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/lib/about/ui/AboutBuildDetails.d.ts +15 -0
- package/lib/about/ui/AboutBuildDetails.d.ts.map +1 -0
- package/lib/about/ui/AboutBuildDetails.js +17 -0
- package/lib/about/ui/AboutBuildDetails.js.map +1 -0
- package/lib/about/ui/AboutPage.d.ts +8 -0
- package/lib/about/ui/AboutPage.d.ts.map +1 -1
- package/lib/about/ui/AboutPage.js +12 -3
- package/lib/about/ui/AboutPage.js.map +1 -1
- package/lib/about/ui/AboutSignIn.d.ts +33 -0
- package/lib/about/ui/AboutSignIn.d.ts.map +1 -0
- package/lib/about/ui/AboutSignIn.js +28 -0
- package/lib/about/ui/AboutSignIn.js.map +1 -0
- package/lib/about/ui/AboutVersion.d.ts +4 -2
- package/lib/about/ui/AboutVersion.d.ts.map +1 -1
- package/lib/about/ui/AboutVersion.js +21 -3
- package/lib/about/ui/AboutVersion.js.map +1 -1
- package/lib/about/ui/index.d.ts +2 -2
- package/lib/about/ui/index.d.ts.map +1 -1
- package/lib/about/ui/index.js +1 -1
- package/lib/about/ui/index.js.map +1 -1
- package/lib/chart/ui/ChartTrackingLayer.js +3 -1
- package/lib/chart/ui/ChartTrackingLayer.js.map +1 -1
- package/lib/chart/ui/useChartSize.d.ts +16 -0
- package/lib/chart/ui/useChartSize.d.ts.map +1 -1
- package/lib/chart/ui/useChartSize.js +34 -1
- package/lib/chart/ui/useChartSize.js.map +1 -1
- package/lib/chrome/ui/NavEntry.d.ts +16 -0
- package/lib/chrome/ui/NavEntry.d.ts.map +1 -0
- package/lib/chrome/ui/NavEntry.js +27 -0
- package/lib/chrome/ui/NavEntry.js.map +1 -0
- package/lib/chrome/ui/SiteHeader.d.ts +11 -4
- package/lib/chrome/ui/SiteHeader.d.ts.map +1 -1
- package/lib/chrome/ui/SiteHeader.js +4 -26
- package/lib/chrome/ui/SiteHeader.js.map +1 -1
- package/lib/core.d.ts +2 -0
- package/lib/core.d.ts.map +1 -1
- package/lib/core.js +2 -0
- package/lib/core.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/core/unlistedSites.d.ts.map +1 -1
- package/lib/ecosystem/core/unlistedSites.js +14 -0
- package/lib/ecosystem/core/unlistedSites.js.map +1 -1
- package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
- package/lib/ecosystem/ui/glyphs.js +3 -0
- package/lib/ecosystem/ui/glyphs.js.map +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts +1 -1
- package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
- package/lib/locales/de.json +36 -3
- package/lib/locales/en.json +36 -3
- package/lib/locales/es.json +36 -3
- package/lib/locales/fr.json +36 -3
- package/lib/locales/it.json +36 -3
- package/lib/moleculesSources/core/index.d.ts +3 -0
- package/lib/moleculesSources/core/index.d.ts.map +1 -0
- package/lib/moleculesSources/core/index.js +2 -0
- package/lib/moleculesSources/core/index.js.map +1 -0
- package/lib/moleculesSources/core/moleculesSources.d.ts +55 -0
- package/lib/moleculesSources/core/moleculesSources.d.ts.map +1 -0
- package/lib/moleculesSources/core/moleculesSources.js +63 -0
- package/lib/moleculesSources/core/moleculesSources.js.map +1 -0
- package/lib/moleculesSources/ui/MoleculesSourceBadge.d.ts +18 -0
- package/lib/moleculesSources/ui/MoleculesSourceBadge.d.ts.map +1 -0
- package/lib/moleculesSources/ui/MoleculesSourceBadge.js +22 -0
- package/lib/moleculesSources/ui/MoleculesSourceBadge.js.map +1 -0
- package/lib/moleculesSources/ui/SourceBadge.d.ts +57 -0
- package/lib/moleculesSources/ui/SourceBadge.d.ts.map +1 -0
- package/lib/moleculesSources/ui/SourceBadge.js +29 -0
- package/lib/moleculesSources/ui/SourceBadge.js.map +1 -0
- package/lib/moleculesSources/ui/index.d.ts +7 -0
- package/lib/moleculesSources/ui/index.d.ts.map +1 -0
- package/lib/moleculesSources/ui/index.js +4 -0
- package/lib/moleculesSources/ui/index.js.map +1 -0
- package/lib/moleculesSources/ui/useSourceLooks.d.ts +24 -0
- package/lib/moleculesSources/ui/useSourceLooks.d.ts.map +1 -0
- package/lib/moleculesSources/ui/useSourceLooks.js +53 -0
- package/lib/moleculesSources/ui/useSourceLooks.js.map +1 -0
- package/lib/moleculesToken/core/index.d.ts +4 -0
- package/lib/moleculesToken/core/index.d.ts.map +1 -0
- package/lib/moleculesToken/core/index.js +3 -0
- package/lib/moleculesToken/core/index.js.map +1 -0
- package/lib/moleculesToken/core/moleculesToken.d.ts +101 -0
- package/lib/moleculesToken/core/moleculesToken.d.ts.map +1 -0
- package/lib/moleculesToken/core/moleculesToken.js +137 -0
- package/lib/moleculesToken/core/moleculesToken.js.map +1 -0
- package/lib/moleculesToken/core/tokenFix.d.ts +18 -0
- package/lib/moleculesToken/core/tokenFix.d.ts.map +1 -0
- package/lib/moleculesToken/core/tokenFix.js +27 -0
- package/lib/moleculesToken/core/tokenFix.js.map +1 -0
- package/lib/moleculesToken/ui/MoleculesTokenFix.d.ts +22 -0
- package/lib/moleculesToken/ui/MoleculesTokenFix.d.ts.map +1 -0
- package/lib/moleculesToken/ui/MoleculesTokenFix.js +35 -0
- package/lib/moleculesToken/ui/MoleculesTokenFix.js.map +1 -0
- package/lib/moleculesToken/ui/MoleculesTokenTable.d.ts +37 -0
- package/lib/moleculesToken/ui/MoleculesTokenTable.d.ts.map +1 -0
- package/lib/moleculesToken/ui/MoleculesTokenTable.js +56 -0
- package/lib/moleculesToken/ui/MoleculesTokenTable.js.map +1 -0
- package/lib/moleculesToken/ui/index.d.ts +5 -0
- package/lib/moleculesToken/ui/index.d.ts.map +1 -0
- package/lib/moleculesToken/ui/index.js +3 -0
- package/lib/moleculesToken/ui/index.js.map +1 -0
- package/lib/moleculesToken/ui/tokenDetails.d.ts +13 -0
- package/lib/moleculesToken/ui/tokenDetails.d.ts.map +1 -0
- package/lib/moleculesToken/ui/tokenDetails.js +73 -0
- package/lib/moleculesToken/ui/tokenDetails.js.map +1 -0
- package/lib/ui.d.ts +2 -0
- package/lib/ui.d.ts.map +1 -1
- package/lib/ui.js +2 -0
- package/lib/ui.js.map +1 -1
- package/package.json +1 -1
- package/src/about/ui/AboutBuildDetails.tsx +45 -0
- package/src/about/ui/AboutPage.tsx +27 -13
- package/src/about/ui/AboutSignIn.tsx +63 -0
- package/src/about/ui/AboutVersion.tsx +27 -9
- package/src/about/ui/index.ts +2 -2
- package/src/chart/ui/ChartTrackingLayer.tsx +3 -1
- package/src/chart/ui/useChartSize.ts +44 -1
- package/src/chrome/ui/NavEntry.tsx +41 -0
- package/src/chrome/ui/SiteHeader.tsx +15 -41
- package/src/core.ts +2 -0
- package/src/ecosystem/core/types.ts +2 -1
- package/src/ecosystem/core/unlistedSites.ts +14 -0
- package/src/ecosystem/ui/glyphs.tsx +10 -0
- package/src/locales/de.json +36 -3
- package/src/locales/en.json +36 -3
- package/src/locales/es.json +36 -3
- package/src/locales/fr.json +36 -3
- package/src/locales/it.json +36 -3
- package/src/moleculesSources/core/index.ts +11 -0
- package/src/moleculesSources/core/moleculesSources.ts +102 -0
- package/src/moleculesSources/ui/MoleculesSourceBadge.tsx +44 -0
- package/src/moleculesSources/ui/SourceBadge.tsx +117 -0
- package/src/moleculesSources/ui/index.ts +6 -0
- package/src/moleculesSources/ui/useSourceLooks.ts +70 -0
- package/src/moleculesToken/core/index.ts +12 -0
- package/src/moleculesToken/core/moleculesToken.ts +256 -0
- package/src/moleculesToken/core/tokenFix.ts +37 -0
- package/src/moleculesToken/ui/MoleculesTokenFix.tsx +95 -0
- package/src/moleculesToken/ui/MoleculesTokenTable.tsx +175 -0
- package/src/moleculesToken/ui/index.ts +4 -0
- package/src/moleculesToken/ui/tokenDetails.tsx +91 -0
- package/src/ui.ts +2 -0
- package/styles/chrome.css +194 -0
- package/lib/about/ui/AboutBuild.d.ts +0 -18
- package/lib/about/ui/AboutBuild.d.ts.map +0 -1
- package/lib/about/ui/AboutBuild.js +0 -37
- package/lib/about/ui/AboutBuild.js.map +0 -1
- package/src/about/ui/AboutBuild.tsx +0 -54
package/lib/locales/it.json
CHANGED
|
@@ -107,10 +107,11 @@
|
|
|
107
107
|
"about.providedBy": "Offerto da",
|
|
108
108
|
"about.whatYouCanDo": "Cosa si può fare qui",
|
|
109
109
|
"about.builtOn": "Costruito su",
|
|
110
|
+
"about.buildVersion": "Versione {version}",
|
|
111
|
+
"about.buildBuilt": "Compilato",
|
|
112
|
+
"about.buildCommit": "Commit",
|
|
110
113
|
"about.howToCite": "Come citare",
|
|
111
114
|
"about.citeWork": "Citare {what}",
|
|
112
|
-
"about.built": "Compilato {builtAt}.",
|
|
113
|
-
"about.builtFromCommit": "Compilato {builtAt} dal commit {commit}.",
|
|
114
115
|
"about.nameList": "{names} e {last}",
|
|
115
116
|
"credits.openbabel.description": "legge e scrive i formati di file chimici, ed esegue la conversione stessa.",
|
|
116
117
|
"credits.openchemlib.description": "legge e scrive strutture, e ne calcola le proprietà nel browser.",
|
|
@@ -593,5 +594,37 @@
|
|
|
593
594
|
"taxonomy.rank.noRank": "senza rango",
|
|
594
595
|
"taxonomy.rank.clade": "clade",
|
|
595
596
|
"taxonomy.rank.cellularRoot": "radice cellulare",
|
|
596
|
-
"taxonomy.rank.acellularRoot": "radice acellulare"
|
|
597
|
+
"taxonomy.rank.acellularRoot": "radice acellulare",
|
|
598
|
+
"moleculesToken.title": "Token per molecules.cheminfo.org",
|
|
599
|
+
"moleculesToken.checkedAt": "Verificati il {when}",
|
|
600
|
+
"moleculesToken.checkAgain": "Verifica di nuovo",
|
|
601
|
+
"moleculesToken.notChecked": "Non ancora verificati: il servizio che scrive in molecules.cheminfo.org verifica i suoi token all'avvio.",
|
|
602
|
+
"moleculesToken.column.variable": "Variabile",
|
|
603
|
+
"moleculesToken.column.source": "Fonte",
|
|
604
|
+
"moleculesToken.column.status": "Stato",
|
|
605
|
+
"moleculesToken.column.details": "Dettagli",
|
|
606
|
+
"moleculesToken.anySource": "qualsiasi fonte",
|
|
607
|
+
"moleculesToken.verdict.ok": "valido",
|
|
608
|
+
"moleculesToken.verdict.otherSource": "di un'altra fonte",
|
|
609
|
+
"moleculesToken.verdict.refused": "rifiutato",
|
|
610
|
+
"moleculesToken.verdict.unset": "non impostato",
|
|
611
|
+
"moleculesToken.verdict.uncheckable": "non verificabile",
|
|
612
|
+
"moleculesToken.verdict.unanswered": "nessuna risposta",
|
|
613
|
+
"moleculesToken.forSource": "per {source}",
|
|
614
|
+
"moleculesToken.issued": "emesso il {when}",
|
|
615
|
+
"moleculesToken.issuedTo": "emesso per {email} il {when}",
|
|
616
|
+
"moleculesToken.lastUsed": "usato l'ultima volta il {when}",
|
|
617
|
+
"moleculesToken.neverUsed": "mai usato",
|
|
618
|
+
"moleculesToken.otherSourceDetail": "emesso per {source}: ciò che invia è attribuito a quella fonte",
|
|
619
|
+
"moleculesToken.refusedDetail": "mai emesso, o revocato",
|
|
620
|
+
"moleculesToken.unsetDetail": "Impostare {variable} nel file .env del server.",
|
|
621
|
+
"moleculesToken.uncheckableDetail": "Questo molecules.cheminfo.org non sa ancora verificare un token.",
|
|
622
|
+
"moleculesToken.howToChange": "Un token si cambia nel file .env del server e viene riletto al riavvio del servizio. molecules.cheminfo.org ne emette uno nuovo con",
|
|
623
|
+
"moleculesToken.fix.title": "Impostare un token valido in {variables}",
|
|
624
|
+
"moleculesToken.fix.issueOne": "Emettere un token nella pagina Admin di molecules.cheminfo.org:",
|
|
625
|
+
"moleculesToken.fix.issueMany": "Emettere un token per fonte nella pagina Admin di molecules.cheminfo.org:",
|
|
626
|
+
"moleculesToken.fix.issueOnServer": "Oppure, sul server di molecules.cheminfo.org:",
|
|
627
|
+
"moleculesToken.fix.envOne": "Scriverlo nel file .env del server di questo sito:",
|
|
628
|
+
"moleculesToken.fix.envMany": "Scriverli nel file .env del server di questo sito:",
|
|
629
|
+
"moleculesToken.fix.restart": "Riavviare i servizi, che leggono il file .env solo all'avvio:"
|
|
597
630
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,uBAAuB,EACvB,UAAU,EACV,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/moleculesSources/core/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Where molecules.cheminfo.org answers, which holds the family's sources. */
|
|
2
|
+
export declare const MOLECULES_URL = "https://molecules.cheminfo.org";
|
|
3
|
+
/**
|
|
4
|
+
* How a source is drawn wherever the family names it — PubChem, ChEBI, COCONUT
|
|
5
|
+
* — as molecules.cheminfo.org publishes it. molecules is where a source's
|
|
6
|
+
* colour and logo are kept and edited, so every site reads them from there
|
|
7
|
+
* rather than keeping a copy that drifts the first time one is changed.
|
|
8
|
+
*/
|
|
9
|
+
export interface SourceLook {
|
|
10
|
+
/** What the source is called, as molecules writes it: `ChEBI`. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** The colour its badges are drawn in, as `#rrggbb`; null for none. */
|
|
13
|
+
color: string | null;
|
|
14
|
+
/** The absolute address of its little logo; null when it has none. */
|
|
15
|
+
logo: string | null;
|
|
16
|
+
}
|
|
17
|
+
/** Every source molecules publishes, by its name in lower case. */
|
|
18
|
+
export type SourceLooks = ReadonlyMap<string, SourceLook>;
|
|
19
|
+
/**
|
|
20
|
+
* The sources a `/v1/sources` answer describes, each logo made absolute
|
|
21
|
+
* against the address it was read from, so the badge draws it on any site.
|
|
22
|
+
* Anything not shaped like a source is left out rather than trusted.
|
|
23
|
+
* @param body - The parsed answer of `/v1/sources`.
|
|
24
|
+
* @param baseUrl - Where it was read from.
|
|
25
|
+
* @returns The looks, by lower-case name.
|
|
26
|
+
*/
|
|
27
|
+
export declare function readSourceLooks(body: unknown, baseUrl: string): SourceLooks;
|
|
28
|
+
/**
|
|
29
|
+
* The look of one source, named in any case.
|
|
30
|
+
* @param looks - What molecules publishes, or null while it is being read.
|
|
31
|
+
* @param name - The source's name or key: `chebi`, `ChEBI`.
|
|
32
|
+
* @returns Its look, or `undefined` when molecules does not know it (yet).
|
|
33
|
+
*/
|
|
34
|
+
export declare function sourceLook(looks: SourceLooks | null, name: string): SourceLook | undefined;
|
|
35
|
+
/** Where and how {@link fetchSourceLooks} reads. */
|
|
36
|
+
export interface FetchSourceLooksOptions {
|
|
37
|
+
/**
|
|
38
|
+
* Where molecules answers.
|
|
39
|
+
* @default MOLECULES_URL
|
|
40
|
+
*/
|
|
41
|
+
url?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Aborts the read.
|
|
44
|
+
* @default undefined
|
|
45
|
+
*/
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Read every source's look from molecules.cheminfo.org.
|
|
50
|
+
* @param options - See {@link FetchSourceLooksOptions}.
|
|
51
|
+
* @returns The looks, by lower-case name.
|
|
52
|
+
* @throws {Error} When molecules does not answer, or answers with an error.
|
|
53
|
+
*/
|
|
54
|
+
export declare function fetchSourceLooks(options?: FetchSourceLooksOptions): Promise<SourceLooks>;
|
|
55
|
+
//# sourceMappingURL=moleculesSources.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moleculesSources.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/core/moleculesSources.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,aAAa,mCAAmC,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,sEAAsE;IACtE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,CAc3E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,WAAW,GAAG,IAAI,EACzB,IAAI,EAAE,MAAM,GACX,UAAU,GAAG,SAAS,CAExB;AAED,oDAAoD;AACpD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,WAAW,CAAC,CAOtB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Where molecules.cheminfo.org answers, which holds the family's sources. */
|
|
2
|
+
export const MOLECULES_URL = 'https://molecules.cheminfo.org';
|
|
3
|
+
/**
|
|
4
|
+
* The sources a `/v1/sources` answer describes, each logo made absolute
|
|
5
|
+
* against the address it was read from, so the badge draws it on any site.
|
|
6
|
+
* Anything not shaped like a source is left out rather than trusted.
|
|
7
|
+
* @param body - The parsed answer of `/v1/sources`.
|
|
8
|
+
* @param baseUrl - Where it was read from.
|
|
9
|
+
* @returns The looks, by lower-case name.
|
|
10
|
+
*/
|
|
11
|
+
export function readSourceLooks(body, baseUrl) {
|
|
12
|
+
const looks = new Map();
|
|
13
|
+
const sources = isRecord(body) ? body.sources : undefined;
|
|
14
|
+
if (!Array.isArray(sources))
|
|
15
|
+
return looks;
|
|
16
|
+
for (const source of sources) {
|
|
17
|
+
if (!isRecord(source) || typeof source.name !== 'string')
|
|
18
|
+
continue;
|
|
19
|
+
const { name, color, logo } = source;
|
|
20
|
+
looks.set(name.toLowerCase(), {
|
|
21
|
+
name,
|
|
22
|
+
color: typeof color === 'string' && HEX_COLOR.test(color) ? color : null,
|
|
23
|
+
logo: typeof logo === 'string' ? absolute(logo, baseUrl) : null,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return looks;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The look of one source, named in any case.
|
|
30
|
+
* @param looks - What molecules publishes, or null while it is being read.
|
|
31
|
+
* @param name - The source's name or key: `chebi`, `ChEBI`.
|
|
32
|
+
* @returns Its look, or `undefined` when molecules does not know it (yet).
|
|
33
|
+
*/
|
|
34
|
+
export function sourceLook(looks, name) {
|
|
35
|
+
return looks?.get(name.toLowerCase());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Read every source's look from molecules.cheminfo.org.
|
|
39
|
+
* @param options - See {@link FetchSourceLooksOptions}.
|
|
40
|
+
* @returns The looks, by lower-case name.
|
|
41
|
+
* @throws {Error} When molecules does not answer, or answers with an error.
|
|
42
|
+
*/
|
|
43
|
+
export async function fetchSourceLooks(options = {}) {
|
|
44
|
+
const { url = MOLECULES_URL, signal } = options;
|
|
45
|
+
const response = await fetch(`${url}/v1/sources`, { signal });
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
throw new Error(`${url} answered ${response.status} for its sources`);
|
|
48
|
+
}
|
|
49
|
+
return readSourceLooks(await response.json(), url);
|
|
50
|
+
}
|
|
51
|
+
const HEX_COLOR = /^#[\da-f]{6}$/i;
|
|
52
|
+
function absolute(address, baseUrl) {
|
|
53
|
+
try {
|
|
54
|
+
return new URL(address, baseUrl).href;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function isRecord(value) {
|
|
61
|
+
return typeof value === 'object' && value !== null;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=moleculesSources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moleculesSources.js","sourceRoot":"","sources":["../../../src/moleculesSources/core/moleculesSources.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,aAAa,GAAG,gCAAgC,CAAC;AAoB9D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa,EAAE,OAAe;IAC5D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,SAAS;QACnE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QACrC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YAC5B,IAAI;YACJ,KAAK,EAAE,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;YACxE,IAAI,EAAE,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;SAChE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,KAAyB,EACzB,IAAY;IAEZ,OAAO,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACxC,CAAC;AAgBD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAmC,EAAE;IAErC,MAAM,EAAE,GAAG,GAAG,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAChD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,GAAG,aAAa,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,GAAG,GAAG,aAAa,QAAQ,CAAC,MAAM,kBAAkB,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,SAAS,GAAG,gBAAgB,CAAC;AAEnC,SAAS,QAAQ,CAAC,OAAe,EAAE,OAAe;IAChD,IAAI,CAAC;QACH,OAAO,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import type { SourceBadgeProps } from './SourceBadge.tsx';
|
|
3
|
+
export interface MoleculesSourceBadgeProps extends Omit<SourceBadgeProps, 'color' | 'logo'> {
|
|
4
|
+
/**
|
|
5
|
+
* Where molecules answers, for a site that reads another instance.
|
|
6
|
+
* @default MOLECULES_URL
|
|
7
|
+
*/
|
|
8
|
+
moleculesUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A source named by a site that does not keep its look: the colour and the
|
|
12
|
+
* logo come from molecules.cheminfo.org, where they are edited. A source
|
|
13
|
+
* molecules does not know — or until it has answered — is drawn neutral.
|
|
14
|
+
* @param props - The source, by its name in any case, and the entry it holds.
|
|
15
|
+
* @returns The badge.
|
|
16
|
+
*/
|
|
17
|
+
export declare function MoleculesSourceBadge(props: MoleculesSourceBadgeProps): ReactElement;
|
|
18
|
+
//# sourceMappingURL=MoleculesSourceBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoleculesSourceBadge.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/ui/MoleculesSourceBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,gBAAgB,EAChB,OAAO,GAAG,MAAM,CACjB;IACC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,yBAAyB,GAC/B,YAAY,CAed"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MOLECULES_URL, sourceLook } from "../core/moleculesSources.js";
|
|
3
|
+
import { SourceBadge } from "./SourceBadge.js";
|
|
4
|
+
import { useSourceLooks } from "./useSourceLooks.js";
|
|
5
|
+
/**
|
|
6
|
+
* A source named by a site that does not keep its look: the colour and the
|
|
7
|
+
* logo come from molecules.cheminfo.org, where they are edited. A source
|
|
8
|
+
* molecules does not know — or until it has answered — is drawn neutral.
|
|
9
|
+
* @param props - The source, by its name in any case, and the entry it holds.
|
|
10
|
+
* @returns The badge.
|
|
11
|
+
*/
|
|
12
|
+
export function MoleculesSourceBadge(props) {
|
|
13
|
+
const { moleculesUrl = MOLECULES_URL, ...badge } = props;
|
|
14
|
+
const look = sourceLook(useSourceLooks(moleculesUrl), badge.name);
|
|
15
|
+
if (look === undefined)
|
|
16
|
+
return _jsx(SourceBadge, { ...badge });
|
|
17
|
+
return (_jsx(SourceBadge, { ...badge, label: badge.label ?? look.name,
|
|
18
|
+
// A source molecules draws in no colour of its own is drawn neutral
|
|
19
|
+
// here: the site naming it is not that source.
|
|
20
|
+
color: look.color ?? undefined, logo: look.logo }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=MoleculesSourceBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MoleculesSourceBadge.js","sourceRoot":"","sources":["../../../src/moleculesSources/ui/MoleculesSourceBadge.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAGxE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAarD;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAgC;IAEhC,MAAM,EAAE,YAAY,GAAG,aAAa,EAAE,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;IACzD,MAAM,IAAI,GAAG,UAAU,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAC,WAAW,OAAK,KAAK,GAAI,CAAC;IAE1D,OAAO,CACL,KAAC,WAAW,OACN,KAAK,EACT,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI;QAC/B,oEAAoE;QACpE,+CAA+C;QAC/C,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,EAC9B,IAAI,EAAE,IAAI,CAAC,IAAI,GACf,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export interface SourceBadgeProps {
|
|
3
|
+
/** What the source is called, read in the badge's tooltip. */
|
|
4
|
+
name: string;
|
|
5
|
+
/**
|
|
6
|
+
* What the badge says.
|
|
7
|
+
* @default name
|
|
8
|
+
*/
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* The source's own colour, as `#rrggbb`. `null` draws it in the site's own
|
|
12
|
+
* colour, which is how a site marks a source that is itself.
|
|
13
|
+
* @default undefined — a neutral grey, for a source with no look
|
|
14
|
+
*/
|
|
15
|
+
color?: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The absolute address of its little logo.
|
|
18
|
+
* @default null
|
|
19
|
+
*/
|
|
20
|
+
logo?: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* The entry's identifier there, written after the name.
|
|
23
|
+
* @default null
|
|
24
|
+
*/
|
|
25
|
+
identifier?: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* How many entries the source holds, written after the name when more than
|
|
28
|
+
* one.
|
|
29
|
+
* @default 1
|
|
30
|
+
*/
|
|
31
|
+
count?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Where the badge leads, opened in a new tab.
|
|
34
|
+
* @default null — the badge names the source and leads nowhere
|
|
35
|
+
*/
|
|
36
|
+
href?: string | null;
|
|
37
|
+
/**
|
|
38
|
+
* The tooltip.
|
|
39
|
+
* @default the name, then the identifier
|
|
40
|
+
*/
|
|
41
|
+
title?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The smaller badge of a dense list, whose identifier goes in the tooltip
|
|
44
|
+
* only.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
compact?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A source, as a badge: its name in its own colour, its little logo on a white
|
|
51
|
+
* chip, and the entry it holds — the same badge on every site of the family
|
|
52
|
+
* that names where a molecule comes from.
|
|
53
|
+
* @param props - See {@link SourceBadgeProps}.
|
|
54
|
+
* @returns The badge.
|
|
55
|
+
*/
|
|
56
|
+
export declare function SourceBadge(props: SourceBadgeProps): ReactElement;
|
|
57
|
+
//# sourceMappingURL=SourceBadge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceBadge.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/ui/SourceBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,CA2DjE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A source, as a badge: its name in its own colour, its little logo on a white
|
|
4
|
+
* chip, and the entry it holds — the same badge on every site of the family
|
|
5
|
+
* that names where a molecule comes from.
|
|
6
|
+
* @param props - See {@link SourceBadgeProps}.
|
|
7
|
+
* @returns The badge.
|
|
8
|
+
*/
|
|
9
|
+
export function SourceBadge(props) {
|
|
10
|
+
const { name, label = name, color, logo = null, identifier = null, count = 1, href = null, compact = false, } = props;
|
|
11
|
+
const title = props.title ?? (identifier === null ? name : `${name} ${identifier}`);
|
|
12
|
+
const className = [
|
|
13
|
+
'source-badge',
|
|
14
|
+
compact ? 'source-badge--compact' : '',
|
|
15
|
+
color === undefined ? 'source-badge--neutral' : '',
|
|
16
|
+
]
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join(' ');
|
|
19
|
+
// A source with no colour of its own takes the site's, from the stylesheet.
|
|
20
|
+
const style = typeof color === 'string'
|
|
21
|
+
? { '--source': color }
|
|
22
|
+
: undefined;
|
|
23
|
+
const content = (_jsxs(_Fragment, { children: [logo === null ? null : (_jsx("span", { className: "source-badge__logo", children: _jsx("img", { src: logo, alt: "" }) })), _jsx("span", { className: "source-badge__name", children: label }), compact || identifier === null ? null : (_jsx("span", { className: "source-badge__id", children: identifier })), count > 1 ? _jsx("span", { className: "source-badge__count", children: count }) : null] }));
|
|
24
|
+
if (href === null) {
|
|
25
|
+
return (_jsx("span", { className: className, style: style, title: title, children: content }));
|
|
26
|
+
}
|
|
27
|
+
return (_jsx("a", { className: className, style: style, href: href, target: "_blank", rel: "noopener noreferrer", title: title, children: content }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=SourceBadge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SourceBadge.js","sourceRoot":"","sources":["../../../src/moleculesSources/ui/SourceBadge.tsx"],"names":[],"mappings":";AAkDA;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,MAAM,EACJ,IAAI,EACJ,KAAK,GAAG,IAAI,EACZ,KAAK,EACL,IAAI,GAAG,IAAI,EACX,UAAU,GAAG,IAAI,EACjB,KAAK,GAAG,CAAC,EACT,IAAI,GAAG,IAAI,EACX,OAAO,GAAG,KAAK,GAChB,GAAG,KAAK,CAAC;IACV,MAAM,KAAK,GACT,KAAK,CAAC,KAAK,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,UAAU,EAAE,CAAC,CAAC;IACxE,MAAM,SAAS,GAAG;QAChB,cAAc;QACd,OAAO,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE;QACtC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE;KACnD;SACE,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACb,4EAA4E;IAC5E,MAAM,KAAK,GACT,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAE,EAAE,UAAU,EAAE,KAAK,EAAoB;QAC1C,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,OAAO,GAAG,CACd,8BACG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACtB,eAAM,SAAS,EAAC,oBAAoB,YAClC,cAAK,GAAG,EAAE,IAAI,EAAE,GAAG,EAAC,EAAE,GAAG,GACpB,CACR,EACD,eAAM,SAAS,EAAC,oBAAoB,YAAE,KAAK,GAAQ,EAClD,OAAO,IAAI,UAAU,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACvC,eAAM,SAAS,EAAC,kBAAkB,YAAE,UAAU,GAAQ,CACvD,EACA,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,qBAAqB,YAAE,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,IACvE,CACJ,CAAC;IAEF,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,CACL,eAAM,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,YACnD,OAAO,GACH,CACR,CAAC;IACJ,CAAC;IACD,OAAO,CACL,YACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,IAAI,EACV,MAAM,EAAC,QAAQ,EACf,GAAG,EAAC,qBAAqB,EACzB,KAAK,EAAE,KAAK,YAEX,OAAO,GACN,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { MoleculesSourceBadgeProps } from './MoleculesSourceBadge.tsx';
|
|
2
|
+
export { MoleculesSourceBadge } from './MoleculesSourceBadge.tsx';
|
|
3
|
+
export type { SourceBadgeProps } from './SourceBadge.tsx';
|
|
4
|
+
export { SourceBadge } from './SourceBadge.tsx';
|
|
5
|
+
export type { SourceLooksStore } from './useSourceLooks.ts';
|
|
6
|
+
export { sourceLooksStore, useSourceLooks } from './useSourceLooks.ts';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/moleculesSources/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA4B,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { SourceLooks } from '../core/moleculesSources.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Every source's look, read from molecules.cheminfo.org once per page however
|
|
4
|
+
* many badges ask for it.
|
|
5
|
+
* @param url - Where molecules answers.
|
|
6
|
+
* @returns The looks by lower-case name, or null until molecules has answered;
|
|
7
|
+
* an empty map when it could not be read, so the badges stop waiting and stay
|
|
8
|
+
* neutral.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useSourceLooks(url?: string): SourceLooks | null;
|
|
11
|
+
/** The one read of a molecules address, shared by every badge on the page. */
|
|
12
|
+
export interface SourceLooksStore {
|
|
13
|
+
/** Follow the read, starting it on the first call. */
|
|
14
|
+
subscribe: (listener: () => void) => () => void;
|
|
15
|
+
/** What has been read so far. */
|
|
16
|
+
read: () => SourceLooks | null;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The store behind {@link useSourceLooks}: one per address, read once.
|
|
20
|
+
* @param url - Where molecules answers.
|
|
21
|
+
* @returns The store.
|
|
22
|
+
*/
|
|
23
|
+
export declare function sourceLooksStore(url: string): SourceLooksStore;
|
|
24
|
+
//# sourceMappingURL=useSourceLooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSourceLooks.d.ts","sourceRoot":"","sources":["../../../src/moleculesSources/ui/useSourceLooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAG/D;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,GAAG,GAAE,MAAsB,GAC1B,WAAW,GAAG,IAAI,CAGpB;AAED,8EAA8E;AAC9E,MAAM,WAAW,gBAAgB;IAC/B,sDAAsD;IACtD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,iCAAiC;IACjC,IAAI,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;CAChC;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAO9D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useSyncExternalStore } from 'react';
|
|
2
|
+
import { MOLECULES_URL, fetchSourceLooks } from "../core/moleculesSources.js";
|
|
3
|
+
/**
|
|
4
|
+
* Every source's look, read from molecules.cheminfo.org once per page however
|
|
5
|
+
* many badges ask for it.
|
|
6
|
+
* @param url - Where molecules answers.
|
|
7
|
+
* @returns The looks by lower-case name, or null until molecules has answered;
|
|
8
|
+
* an empty map when it could not be read, so the badges stop waiting and stay
|
|
9
|
+
* neutral.
|
|
10
|
+
*/
|
|
11
|
+
export function useSourceLooks(url = MOLECULES_URL) {
|
|
12
|
+
const store = sourceLooksStore(url);
|
|
13
|
+
return useSyncExternalStore(store.subscribe, store.read, notYet);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The store behind {@link useSourceLooks}: one per address, read once.
|
|
17
|
+
* @param url - Where molecules answers.
|
|
18
|
+
* @returns The store.
|
|
19
|
+
*/
|
|
20
|
+
export function sourceLooksStore(url) {
|
|
21
|
+
let store = STORES.get(url);
|
|
22
|
+
if (store === undefined) {
|
|
23
|
+
store = createStore(url);
|
|
24
|
+
STORES.set(url, store);
|
|
25
|
+
}
|
|
26
|
+
return store;
|
|
27
|
+
}
|
|
28
|
+
const STORES = new Map();
|
|
29
|
+
function createStore(url) {
|
|
30
|
+
let looks = null;
|
|
31
|
+
let started = false;
|
|
32
|
+
const listeners = new Set();
|
|
33
|
+
function settle(value) {
|
|
34
|
+
looks = value;
|
|
35
|
+
for (const listener of listeners)
|
|
36
|
+
listener();
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
subscribe(listener) {
|
|
40
|
+
listeners.add(listener);
|
|
41
|
+
if (!started) {
|
|
42
|
+
started = true;
|
|
43
|
+
fetchSourceLooks({ url }).then(settle, () => settle(new Map()));
|
|
44
|
+
}
|
|
45
|
+
return () => listeners.delete(listener);
|
|
46
|
+
},
|
|
47
|
+
read: () => looks,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function notYet() {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=useSourceLooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSourceLooks.js","sourceRoot":"","sources":["../../../src/moleculesSources/ui/useSourceLooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,aAAa;IAE3B,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACnE,CAAC;AAUD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAA4B,CAAC;AAEnD,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,KAAK,GAAuB,IAAI,CAAC;IACrC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAExC,SAAS,MAAM,CAAC,KAAkB;QAChC,KAAK,GAAG,KAAK,CAAC;QACd,KAAK,MAAM,QAAQ,IAAI,SAAS;YAAE,QAAQ,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO;QACL,SAAS,CAAC,QAAQ;YAChB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,GAAG,IAAI,CAAC;gBACf,gBAAgB,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;YAClE,CAAC;YACD,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK;KAClB,CAAC;AACJ,CAAC;AAED,SAAS,MAAM;IACb,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { CheckMoleculesTokenOptions, MoleculesTokenCheck, MoleculesTokenToCheck, MoleculesTokenVerdict, } from './moleculesToken.ts';
|
|
2
|
+
export { checkMoleculesToken, checkMoleculesTokens, publicTokenCheck, } from './moleculesToken.ts';
|
|
3
|
+
export { issueTokenCommand, tokensToFix } from './tokenFix.ts';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/moleculesToken/core/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/moleculesToken/core/index.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What molecules.cheminfo.org says of a token a site holds:
|
|
3
|
+
*
|
|
4
|
+
* - `ok`: issued for a source the site writes, and not revoked;
|
|
5
|
+
* - `otherSource`: valid, but issued for another source, so what the site
|
|
6
|
+
* sends is credited to that one;
|
|
7
|
+
* - `refused`: never issued, or revoked;
|
|
8
|
+
* - `unset`: the site holds none;
|
|
9
|
+
* - `uncheckable`: molecules.cheminfo.org answers, but cannot check a token
|
|
10
|
+
* yet;
|
|
11
|
+
* - `unanswered`: it did not answer, or failed.
|
|
12
|
+
*/
|
|
13
|
+
export type MoleculesTokenVerdict = 'ok' | 'otherSource' | 'refused' | 'unset' | 'uncheckable' | 'unanswered';
|
|
14
|
+
/** A token a site holds, to be checked. */
|
|
15
|
+
export interface MoleculesTokenToCheck {
|
|
16
|
+
/** The environment variable it is read from, e.g. `MOLECULES_TOKEN_LOTUS`. */
|
|
17
|
+
variable: string;
|
|
18
|
+
/** The token, or undefined when the variable is unset or blank. */
|
|
19
|
+
token: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The sources it may have been issued for, as molecules.cheminfo.org names
|
|
22
|
+
* them: any one of them is right, whatever its case.
|
|
23
|
+
* @default [] — any source
|
|
24
|
+
*/
|
|
25
|
+
sources?: readonly string[];
|
|
26
|
+
}
|
|
27
|
+
/** A token, as molecules.cheminfo.org checked it. Never the token itself. */
|
|
28
|
+
export interface MoleculesTokenCheck {
|
|
29
|
+
/** The environment variable it is read from. */
|
|
30
|
+
variable: string;
|
|
31
|
+
/** The sources it may have been issued for; empty for any source. */
|
|
32
|
+
sources: string[];
|
|
33
|
+
/** What molecules.cheminfo.org says of it. */
|
|
34
|
+
verdict: MoleculesTokenVerdict;
|
|
35
|
+
/**
|
|
36
|
+
* What molecules.cheminfo.org said, or why it could not be asked; null when
|
|
37
|
+
* the verdict says it all.
|
|
38
|
+
*/
|
|
39
|
+
message: string | null;
|
|
40
|
+
/** The source molecules.cheminfo.org knows it for, once it answered. */
|
|
41
|
+
source: string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Its first characters, as molecules.cheminfo.org shows them: what tells two
|
|
44
|
+
* tokens apart without showing either.
|
|
45
|
+
*/
|
|
46
|
+
hint: string | null;
|
|
47
|
+
/** Who it was issued to. */
|
|
48
|
+
email: string | null;
|
|
49
|
+
/** When it was issued, in epoch milliseconds. */
|
|
50
|
+
issuedAt: number | null;
|
|
51
|
+
/** When it last read or wrote, in epoch milliseconds, to within a minute. */
|
|
52
|
+
lastUsedAt: number | null;
|
|
53
|
+
/** When it was checked, in epoch milliseconds. */
|
|
54
|
+
checkedAt: number;
|
|
55
|
+
}
|
|
56
|
+
/** Where molecules.cheminfo.org answers, and how patiently it is asked. */
|
|
57
|
+
export interface CheckMoleculesTokenOptions {
|
|
58
|
+
/** Where it answers, e.g. `https://molecules.cheminfo.org`. */
|
|
59
|
+
baseUrl: string;
|
|
60
|
+
/**
|
|
61
|
+
* How long one check may take.
|
|
62
|
+
* @default 5000
|
|
63
|
+
*/
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
/**
|
|
66
|
+
* The fetch to use, for tests.
|
|
67
|
+
* @default globalThis.fetch
|
|
68
|
+
*/
|
|
69
|
+
fetch?: typeof fetch;
|
|
70
|
+
/**
|
|
71
|
+
* The clock the checks are stamped with, for tests.
|
|
72
|
+
* @default Date.now
|
|
73
|
+
*/
|
|
74
|
+
now?: () => number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Ask molecules.cheminfo.org about a token: `GET /v1/token`, which says which
|
|
78
|
+
* source it was issued for and never counts as using it. A token pasted in
|
|
79
|
+
* another source's place, revoked, or never issued shows here before an import
|
|
80
|
+
* sends anything with it. Never throws: a molecules.cheminfo.org that does not
|
|
81
|
+
* answer is a verdict too.
|
|
82
|
+
* @param entry - The token, where it is read from, and the sources it may be for.
|
|
83
|
+
* @param options - Where molecules.cheminfo.org answers, and how patiently.
|
|
84
|
+
* @returns What it says of the token.
|
|
85
|
+
*/
|
|
86
|
+
export declare function checkMoleculesToken(entry: MoleculesTokenToCheck, options: CheckMoleculesTokenOptions): Promise<MoleculesTokenCheck>;
|
|
87
|
+
/**
|
|
88
|
+
* Check every token a site holds, all at once.
|
|
89
|
+
* @param entries - The tokens. See {@link checkMoleculesToken}.
|
|
90
|
+
* @param options - See {@link CheckMoleculesTokenOptions}.
|
|
91
|
+
* @returns What molecules.cheminfo.org says of each, in the order given.
|
|
92
|
+
*/
|
|
93
|
+
export declare function checkMoleculesTokens(entries: readonly MoleculesTokenToCheck[], options: CheckMoleculesTokenOptions): Promise<MoleculesTokenCheck[]>;
|
|
94
|
+
/**
|
|
95
|
+
* What a page anyone can open may show of a check: the verdict and the source,
|
|
96
|
+
* without who the token was issued to or its first characters.
|
|
97
|
+
* @param check - The check.
|
|
98
|
+
* @returns The check, without them.
|
|
99
|
+
*/
|
|
100
|
+
export declare function publicTokenCheck(check: MoleculesTokenCheck): MoleculesTokenCheck;
|
|
101
|
+
//# sourceMappingURL=moleculesToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moleculesToken.d.ts","sourceRoot":"","sources":["../../../src/moleculesToken/core/moleculesToken.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAC/B,IAAI,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,aAAa,GAAG,YAAY,CAAC;AAE5E,2CAA2C;AAC3C,MAAM,WAAW,qBAAqB;IACpC,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B;AAED,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,8CAA8C;IAC9C,OAAO,EAAE,qBAAqB,CAAC;IAC/B;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,wEAAwE;IACxE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,4BAA4B;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,2EAA2E;AAC3E,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IACrB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,CAAC,CA0E9B;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,SAAS,qBAAqB,EAAE,EACzC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAIhC;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,mBAAmB,GACzB,mBAAmB,CAErB"}
|