react-cheminfo 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +182 -34
  2. package/lib/ecosystem/core/index.d.ts +1 -1
  3. package/lib/ecosystem/core/index.d.ts.map +1 -1
  4. package/lib/ecosystem/core/index.js +1 -1
  5. package/lib/ecosystem/core/index.js.map +1 -1
  6. package/lib/ecosystem/core/lookup.d.ts +11 -0
  7. package/lib/ecosystem/core/lookup.d.ts.map +1 -1
  8. package/lib/ecosystem/core/lookup.js +15 -0
  9. package/lib/ecosystem/core/lookup.js.map +1 -1
  10. package/lib/ecosystem/core/sites.d.ts +1 -1
  11. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  12. package/lib/ecosystem/core/sites.js +14 -4
  13. package/lib/ecosystem/core/sites.js.map +1 -1
  14. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  15. package/lib/ecosystem/ui/glyphs.js +4 -1
  16. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  17. package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts +5 -0
  18. package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts.map +1 -1
  19. package/lib/orbital/ui/AtomicOrbitalCanvas.js +4 -3
  20. package/lib/orbital/ui/AtomicOrbitalCanvas.js.map +1 -1
  21. package/lib/orbital/ui/AtomicOrbitalViewer.d.ts +5 -0
  22. package/lib/orbital/ui/AtomicOrbitalViewer.d.ts.map +1 -1
  23. package/lib/orbital/ui/AtomicOrbitalViewer.js.map +1 -1
  24. package/lib/orbital/ui/axesGeometry.d.ts +27 -0
  25. package/lib/orbital/ui/axesGeometry.d.ts.map +1 -0
  26. package/lib/orbital/ui/axesGeometry.js +74 -0
  27. package/lib/orbital/ui/axesGeometry.js.map +1 -0
  28. package/lib/orbital/ui/camera.d.ts +7 -0
  29. package/lib/orbital/ui/camera.d.ts.map +1 -1
  30. package/lib/orbital/ui/camera.js +8 -1
  31. package/lib/orbital/ui/camera.js.map +1 -1
  32. package/lib/orbital/ui/renderAxes.d.ts +53 -0
  33. package/lib/orbital/ui/renderAxes.d.ts.map +1 -0
  34. package/lib/orbital/ui/renderAxes.js +110 -0
  35. package/lib/orbital/ui/renderAxes.js.map +1 -0
  36. package/lib/orbital/ui/viewer.d.ts +16 -0
  37. package/lib/orbital/ui/viewer.d.ts.map +1 -1
  38. package/lib/orbital/ui/viewer.js +24 -2
  39. package/lib/orbital/ui/viewer.js.map +1 -1
  40. package/lib/seo/core/documentMeta.d.ts +2 -2
  41. package/lib/seo/core/documentMeta.js +4 -3
  42. package/lib/seo/core/documentMeta.js.map +1 -1
  43. package/lib/seo/core/index.d.ts +15 -0
  44. package/lib/seo/core/index.d.ts.map +1 -1
  45. package/lib/seo/core/index.js +8 -0
  46. package/lib/seo/core/index.js.map +1 -1
  47. package/lib/seo/core/noscript.d.ts +97 -0
  48. package/lib/seo/core/noscript.d.ts.map +1 -0
  49. package/lib/seo/core/noscript.js +93 -0
  50. package/lib/seo/core/noscript.js.map +1 -0
  51. package/lib/seo/core/pageMeta.d.ts +76 -0
  52. package/lib/seo/core/pageMeta.d.ts.map +1 -0
  53. package/lib/seo/core/pageMeta.js +88 -0
  54. package/lib/seo/core/pageMeta.js.map +1 -0
  55. package/lib/seo/core/robots.d.ts +55 -0
  56. package/lib/seo/core/robots.d.ts.map +1 -0
  57. package/lib/seo/core/robots.js +70 -0
  58. package/lib/seo/core/robots.js.map +1 -0
  59. package/lib/seo/core/routes.d.ts +120 -0
  60. package/lib/seo/core/routes.d.ts.map +1 -0
  61. package/lib/seo/core/routes.js +188 -0
  62. package/lib/seo/core/routes.js.map +1 -0
  63. package/lib/seo/core/siteFiles.d.ts +69 -0
  64. package/lib/seo/core/siteFiles.d.ts.map +1 -0
  65. package/lib/seo/core/siteFiles.js +84 -0
  66. package/lib/seo/core/siteFiles.js.map +1 -0
  67. package/lib/seo/core/startDocumentMeta.d.ts +44 -0
  68. package/lib/seo/core/startDocumentMeta.d.ts.map +1 -0
  69. package/lib/seo/core/startDocumentMeta.js +47 -0
  70. package/lib/seo/core/startDocumentMeta.js.map +1 -0
  71. package/lib/seo/core/structuredData.d.ts +48 -0
  72. package/lib/seo/core/structuredData.d.ts.map +1 -0
  73. package/lib/seo/core/structuredData.js +41 -0
  74. package/lib/seo/core/structuredData.js.map +1 -0
  75. package/lib/seo/core/template.d.ts +48 -0
  76. package/lib/seo/core/template.d.ts.map +1 -0
  77. package/lib/seo/core/template.js +53 -0
  78. package/lib/seo/core/template.js.map +1 -0
  79. package/lib/seo/vite/index.d.ts +5 -0
  80. package/lib/seo/vite/index.d.ts.map +1 -0
  81. package/lib/seo/vite/index.js +3 -0
  82. package/lib/seo/vite/index.js.map +1 -0
  83. package/lib/seo/vite/ogCard.d.ts +41 -0
  84. package/lib/seo/vite/ogCard.d.ts.map +1 -0
  85. package/lib/seo/vite/ogCard.js +82 -0
  86. package/lib/seo/vite/ogCard.js.map +1 -0
  87. package/lib/seo/vite/prerender.d.ts +89 -0
  88. package/lib/seo/vite/prerender.d.ts.map +1 -0
  89. package/lib/seo/vite/prerender.js +114 -0
  90. package/lib/seo/vite/prerender.js.map +1 -0
  91. package/lib/vite.d.ts +2 -0
  92. package/lib/vite.d.ts.map +1 -0
  93. package/lib/vite.js +2 -0
  94. package/lib/vite.js.map +1 -0
  95. package/package.json +7 -2
  96. package/src/ecosystem/core/index.ts +1 -1
  97. package/src/ecosystem/core/lookup.ts +16 -0
  98. package/src/ecosystem/core/sites.ts +16 -5
  99. package/src/ecosystem/ui/glyphs.tsx +20 -1
  100. package/src/orbital/ui/AtomicOrbitalCanvas.tsx +9 -2
  101. package/src/orbital/ui/AtomicOrbitalViewer.tsx +5 -0
  102. package/src/orbital/ui/axesGeometry.ts +91 -0
  103. package/src/orbital/ui/camera.ts +9 -1
  104. package/src/orbital/ui/renderAxes.ts +190 -0
  105. package/src/orbital/ui/viewer.ts +32 -2
  106. package/src/seo/core/documentMeta.ts +5 -5
  107. package/src/seo/core/index.ts +27 -0
  108. package/src/seo/core/noscript.ts +195 -0
  109. package/src/seo/core/pageMeta.ts +128 -0
  110. package/src/seo/core/robots.ts +114 -0
  111. package/src/seo/core/routes.ts +246 -0
  112. package/src/seo/core/siteFiles.ts +112 -0
  113. package/src/seo/core/startDocumentMeta.ts +77 -0
  114. package/src/seo/core/structuredData.ts +80 -0
  115. package/src/seo/core/template.ts +54 -0
  116. package/src/seo/vite/index.ts +4 -0
  117. package/src/seo/vite/ogCard.ts +102 -0
  118. package/src/seo/vite/prerender.ts +203 -0
  119. package/src/vite.ts +1 -0
@@ -0,0 +1,188 @@
1
+ /**
2
+ * The addresses a site answers, each with the name and the sentence it is
3
+ * indexed under.
4
+ *
5
+ * One table per site, read by three things: the build, which writes an HTML
6
+ * file per entry and the sitemap listing them; the head injector; and the
7
+ * running app, which retitles the tab after an in-app move. A page missing from
8
+ * the table is a page a search engine only ever sees as the home page.
9
+ */
10
+ import { stripBasePath } from "../../router/core/basePath.js";
11
+ const QUERY_OR_FRAGMENT = /[?#]/;
12
+ const TRAILING_SLASHES = /\/+$/;
13
+ // A scheme and an authority: what `location.href` hands out, and the one shape
14
+ // that cannot be confused with a path. `//host/path` is left as a path, because
15
+ // a route table is free to name one.
16
+ const ABSOLUTE_URL = /^[a-z][\d+.a-z-]*:\/\//i;
17
+ /**
18
+ * The route an address names.
19
+ *
20
+ * An address a route claims exactly always wins over one that claims it as a
21
+ * subtree, and between two subtrees the longer claim wins, so `/molecules/HEM`
22
+ * is a molecule rather than whatever `/` answers.
23
+ * @param routes - Every address the site answers.
24
+ * @param path - Absolute path, without a query string.
25
+ * @returns Its entry, or `undefined` when the site does not know the address.
26
+ */
27
+ export function routeFor(routes, path) {
28
+ return exactRoute(routes, path) ?? prefixRoute(routes, path);
29
+ }
30
+ /**
31
+ * The page an address opens.
32
+ *
33
+ * An address the site does not know is described as the home page rather than
34
+ * invented on the fly, which is what the router does with it too. The query
35
+ * string never reaches the answer: the structure being drawn and the
36
+ * configuration a shared link carries are not pages of their own. An absolute
37
+ * address is read for its path, so an app handing over `location.href` after an
38
+ * in-app move is answered rather than silently described as the home page.
39
+ *
40
+ * The route table is written from the site's own root, and a server behind a
41
+ * mount is handed the address the browser asked for — `/surge/exercises` for a
42
+ * table that names `/exercises`. So the address is read at the site's own root
43
+ * first, and the four lookups run in this order:
44
+ *
45
+ * 1. the mount taken off, claimed exactly;
46
+ * 2. the address as written, claimed exactly;
47
+ * 3. the mount taken off, claimed as a subtree;
48
+ * 4. the address as written, claimed as a subtree.
49
+ *
50
+ * Exact before subtree, or a `prefix` route — a home page answering everything
51
+ * beneath it above all — would claim every mounted address and the mount would
52
+ * never come off. Stripped before as-written, or the mount itself would open
53
+ * whichever page happens to carry the mount's own name rather than the site's
54
+ * front page. Taking the address as written second is what leaves an unmounted
55
+ * caller answering exactly as before, and lets a table whose own paths start
56
+ * with the mount's name still be read.
57
+ * @param routes - Every address the site answers.
58
+ * @param url - The address, query string and fragment included, either as a
59
+ * path or as an absolute `scheme://host/path` address.
60
+ * @param basePath - The path the site is mounted at, when the address carries
61
+ * it, written `surge`, `/surge` or `/surge/`.
62
+ * @default '' — the address is already written from the site's own root
63
+ * @returns The route it is indexed as.
64
+ * @throws {Error} When the table is empty, so there is no page to fall back to.
65
+ */
66
+ export function pageMetaFor(routes, url, basePath = '') {
67
+ const home = homeRoute(routes);
68
+ const path = pathOf(url);
69
+ const own = stripBasePath(basePath, path);
70
+ return (exactRoute(routes, own) ??
71
+ exactRoute(routes, path) ??
72
+ prefixRoute(routes, own) ??
73
+ prefixRoute(routes, path) ??
74
+ home);
75
+ }
76
+ /**
77
+ * The page an unknown address falls back to.
78
+ * @param routes - Every address the site answers.
79
+ * @returns The `/` entry, or the first one when the table names no root.
80
+ * @throws {Error} When the table is empty.
81
+ */
82
+ export function homeRoute(routes) {
83
+ const first = routes[0];
84
+ if (first === undefined)
85
+ throw new Error('a site answers at least one route');
86
+ return exactRoute(routes, '/') ?? first;
87
+ }
88
+ /**
89
+ * Check a route table before a build reads it as a set of file names.
90
+ *
91
+ * An address written twice ships two sitemap entries and two links to a page
92
+ * only the first entry describes, and one carrying a `..` segment writes its
93
+ * file outside the build output — a real build asked for `/../escaped` and got
94
+ * a sibling of `dist`. Two addresses that differ only in an empty segment or in
95
+ * case are the same defect wearing a disguise: `//x` and `/x` both write
96
+ * `dist/x/index.html`, and so do `/About` and `/about` on the case-insensitive
97
+ * filesystem macOS and Windows ship by default — one file, two sitemap entries,
98
+ * and only one of the two descriptions survives. All of it is author
99
+ * configuration read at build time, so it is refused where it is written rather
100
+ * than repaired where it lands.
101
+ * @param routes - Every address the site answers.
102
+ * @throws {Error} When the table is empty, names one address twice — under any
103
+ * of those spellings — or carries a path that is not one.
104
+ */
105
+ export function assertRoutes(routes) {
106
+ if (routes.length === 0)
107
+ throw new Error('a site answers at least one route');
108
+ const claimed = new Set();
109
+ const folded = new Map();
110
+ for (const route of routes) {
111
+ const written = JSON.stringify(route.path);
112
+ assertPath(route.path, written);
113
+ const address = trimTrailingSlash(route.path) || '/';
114
+ if (address.includes('//')) {
115
+ throw new Error(`a route path names no empty segment: ${written}`);
116
+ }
117
+ if (claimed.has(address)) {
118
+ throw new Error(`a route path is written once: ${written}`);
119
+ }
120
+ const first = folded.get(address.toLowerCase());
121
+ if (first !== undefined) {
122
+ throw new Error(`two route paths name one file on a case-insensitive disk: ${first} and ${written}`);
123
+ }
124
+ claimed.add(address);
125
+ folded.set(address.toLowerCase(), written);
126
+ }
127
+ }
128
+ /**
129
+ * Drop the trailing slashes, so `/about/` and `/about` are one page and an
130
+ * origin written `https://host/surge//` composes one address rather than one
131
+ * with an empty segment in it.
132
+ * @param value - A path or an origin.
133
+ * @returns It, without the trailing slashes `/` itself keeps.
134
+ */
135
+ export function trimTrailingSlash(value) {
136
+ const trimmed = value.replace(TRAILING_SLASHES, '');
137
+ return trimmed === '' && value !== '' ? '/' : trimmed;
138
+ }
139
+ function assertPath(path, written) {
140
+ if (!path.startsWith('/')) {
141
+ throw new Error(`a route path starts at the site root: ${written}`);
142
+ }
143
+ if (QUERY_OR_FRAGMENT.test(path)) {
144
+ throw new Error(`a route path carries no query string and no fragment: ${written}`);
145
+ }
146
+ if (path.split('/').includes('..')) {
147
+ throw new Error(`a route path stays inside the site: ${written}`);
148
+ }
149
+ }
150
+ // The path half of whatever the caller had at hand: an absolute address, or a
151
+ // path already, with the query string and the fragment cut off either way.
152
+ function pathOf(url) {
153
+ if (ABSOLUTE_URL.test(url) && URL.canParse(url))
154
+ return new URL(url).pathname;
155
+ const cut = url.search(QUERY_OR_FRAGMENT);
156
+ return cut === -1 ? url : url.slice(0, cut);
157
+ }
158
+ function exactRoute(routes, path) {
159
+ const wanted = trimTrailingSlash(path) || '/';
160
+ for (const route of routes) {
161
+ if ((trimTrailingSlash(route.path) || '/') === wanted)
162
+ return route;
163
+ }
164
+ return undefined;
165
+ }
166
+ function prefixRoute(routes, path) {
167
+ const wanted = trimTrailingSlash(path) || '/';
168
+ let claimed;
169
+ let claimedLength = -1;
170
+ for (const route of routes) {
171
+ if (route.prefix !== true)
172
+ continue;
173
+ const routePath = trimTrailingSlash(route.path) || '/';
174
+ if (!isUnder(routePath, wanted))
175
+ continue;
176
+ if (routePath.length > claimedLength) {
177
+ claimed = route;
178
+ claimedLength = routePath.length;
179
+ }
180
+ }
181
+ return claimed;
182
+ }
183
+ function isUnder(routePath, path) {
184
+ // `/surgeon` is not a page of `/surge`, so a claim only holds when what
185
+ // follows it is a path of its own.
186
+ return routePath === '/' || path.startsWith(`${routePath}/`);
187
+ }
188
+ //# sourceMappingURL=routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.js","sourceRoot":"","sources":["../../../src/seo/core/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,MAAM,gBAA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CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAClB,MAA4B,EAC5B,IAAY;IAEZ,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;IAC9C,IAAI,OAA8B,CAAC;IACnC,IAAI,aAAa,GAAG,CAAC,CAAC,CAAC;IAEvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI;YAAE,SAAS;QACpC,MAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC;QACvD,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;YAAE,SAAS;QAC1C,IAAI,SAAS,CAAC,MAAM,GAAG,aAAa,EAAE,CAAC;YACrC,OAAO,GAAG,KAAK,CAAC;YAChB,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC;QACnC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,OAAO,CAAC,SAAiB,EAAE,IAAY;IAC9C,wEAAwE;IACxE,mCAAmC;IACnC,OAAO,SAAS,KAAK,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The sitemap, and what every other file a crawler fetches on its own is
3
+ * derived from: which site is being written, where it is served, and the path
4
+ * it is mounted at.
5
+ *
6
+ * A deployment names where it serves the site in full — origin and mount path
7
+ * in one value — because the origin is what a canonical link and a sitemap
8
+ * entry need. The mount is read back out of it here, so the addresses these
9
+ * files hand out start where the site actually answers.
10
+ */
11
+ import type { EcosystemSite, SiteId } from '../../ecosystem/core/sites.ts';
12
+ import type { RouteMeta } from './routes.ts';
13
+ /** What a crawler is told about the site as a whole. */
14
+ export interface SiteFilesOptions {
15
+ /** The site, named or passed. */
16
+ site: EcosystemSite | SiteId;
17
+ /** Every address it answers. */
18
+ routes: readonly RouteMeta[];
19
+ /**
20
+ * Where the site is served, mount path included, e.g.
21
+ * `https://learn.cheminfo.org/surge`. Every absolute address is built on it,
22
+ * and every path one of these files writes starts at its mount.
23
+ * @default `https://<the site's host>`
24
+ */
25
+ origin?: string;
26
+ }
27
+ /**
28
+ * Every routed address, as the sitemap lists them.
29
+ *
30
+ * A sitemap names at least one address: `<url>` is required by the sitemaps.org
31
+ * schema, and `robots.txt` advertises the file, so an empty one is reported as
32
+ * an error on every fetch rather than read as a site with nothing to index.
33
+ * @param options - The site and its routes.
34
+ * @returns The `sitemap.xml` document.
35
+ * @throws {Error} When the site answers no route, or names an origin that is
36
+ * not an absolute address.
37
+ */
38
+ export declare function sitemapXml(options: SiteFilesOptions): string;
39
+ /**
40
+ * The site these files are being written for.
41
+ * @param site - The site, named or passed.
42
+ * @returns Its record.
43
+ */
44
+ export declare function resolveSite(site: EcosystemSite | SiteId): EcosystemSite;
45
+ /**
46
+ * Where the site is served, as an absolute address without a trailing slash.
47
+ *
48
+ * It is an absolute `http` or `https` address or it is refused: a canonical
49
+ * link, an `og:url` and a sitemap entry are addresses a crawler resolves on its
50
+ * own, and one written from an origin missing its scheme is resolved against
51
+ * whatever directory the page was fetched from — pointing every page of the
52
+ * site at a sibling of itself. A dev or staging origin written `localhost:3000`
53
+ * is refused for the same reason: it parses, but as a path under a `localhost:`
54
+ * scheme, so the mount read back off it would be `/3000`.
55
+ * @param options - The site and where it is served.
56
+ * @returns The origin, mount path included when the deployment named one.
57
+ * @throws {Error} When the deployment named something that is not an absolute
58
+ * `http` or `https` address.
59
+ */
60
+ export declare function originOf(options: SiteFilesOptions): string;
61
+ /**
62
+ * The path the deployment is mounted at, read off the address it named.
63
+ * @param options - The site and where it is served.
64
+ * @returns `''` for a site owning its host, `/surge` for one mounted under it.
65
+ * @throws {Error} When the deployment named something that is not an absolute
66
+ * address, so there is no path to read off it.
67
+ */
68
+ export declare function mountPathOf(options: SiteFilesOptions): string;
69
+ //# sourceMappingURL=siteFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteFiles.d.ts","sourceRoot":"","sources":["../../../src/seo/core/siteFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAI3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAQ7C,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IAC7B,gCAAgC;IAChC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAgB5D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,GAAG,aAAa,CAEvE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAQ1D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * The sitemap, and what every other file a crawler fetches on its own is
3
+ * derived from: which site is being written, where it is served, and the path
4
+ * it is mounted at.
5
+ *
6
+ * A deployment names where it serves the site in full — origin and mount path
7
+ * in one value — because the origin is what a canonical link and a sitemap
8
+ * entry need. The mount is read back out of it here, so the addresses these
9
+ * files hand out start where the site actually answers.
10
+ */
11
+ import { siteById } from "../../ecosystem/core/lookup.js";
12
+ import { basePathOf } from "../../router/core/basePath.js";
13
+ import { escapeText } from "../../share/core/escape.js";
14
+ import { trimTrailingSlash } from "./routes.js";
15
+ // A crawler fetches what it is given over HTTP, so an origin is written in one
16
+ // of the two schemes it speaks. Parsing alone does not say that: `localhost:3000`
17
+ // parses, with `localhost:` as its scheme and `3000` as its path.
18
+ const HTTP_ORIGIN = /^https?:\/\//i;
19
+ /**
20
+ * Every routed address, as the sitemap lists them.
21
+ *
22
+ * A sitemap names at least one address: `<url>` is required by the sitemaps.org
23
+ * schema, and `robots.txt` advertises the file, so an empty one is reported as
24
+ * an error on every fetch rather than read as a site with nothing to index.
25
+ * @param options - The site and its routes.
26
+ * @returns The `sitemap.xml` document.
27
+ * @throws {Error} When the site answers no route, or names an origin that is
28
+ * not an absolute address.
29
+ */
30
+ export function sitemapXml(options) {
31
+ const origin = originOf(options);
32
+ if (options.routes.length === 0) {
33
+ throw new Error('a sitemap lists at least one address');
34
+ }
35
+ const entries = options.routes
36
+ .map((route) => ` <url><loc>${escapeText(`${origin}${route.path}`)}</loc></url>`)
37
+ .join('\n');
38
+ return `<?xml version="1.0" encoding="UTF-8"?>
39
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
40
+ ${entries}
41
+ </urlset>
42
+ `;
43
+ }
44
+ /**
45
+ * The site these files are being written for.
46
+ * @param site - The site, named or passed.
47
+ * @returns Its record.
48
+ */
49
+ export function resolveSite(site) {
50
+ return typeof site === 'string' ? siteById(site) : site;
51
+ }
52
+ /**
53
+ * Where the site is served, as an absolute address without a trailing slash.
54
+ *
55
+ * It is an absolute `http` or `https` address or it is refused: a canonical
56
+ * link, an `og:url` and a sitemap entry are addresses a crawler resolves on its
57
+ * own, and one written from an origin missing its scheme is resolved against
58
+ * whatever directory the page was fetched from — pointing every page of the
59
+ * site at a sibling of itself. A dev or staging origin written `localhost:3000`
60
+ * is refused for the same reason: it parses, but as a path under a `localhost:`
61
+ * scheme, so the mount read back off it would be `/3000`.
62
+ * @param options - The site and where it is served.
63
+ * @returns The origin, mount path included when the deployment named one.
64
+ * @throws {Error} When the deployment named something that is not an absolute
65
+ * `http` or `https` address.
66
+ */
67
+ export function originOf(options) {
68
+ const origin = options.origin ?? `https://${resolveSite(options.site).host}`;
69
+ if (!HTTP_ORIGIN.test(origin) || !URL.canParse(origin)) {
70
+ throw new Error(`an origin is an absolute address, e.g. https://surge.cheminfo.org: ${JSON.stringify(origin)}`);
71
+ }
72
+ return trimTrailingSlash(origin);
73
+ }
74
+ /**
75
+ * The path the deployment is mounted at, read off the address it named.
76
+ * @param options - The site and where it is served.
77
+ * @returns `''` for a site owning its host, `/surge` for one mounted under it.
78
+ * @throws {Error} When the deployment named something that is not an absolute
79
+ * address, so there is no path to read off it.
80
+ */
81
+ export function mountPathOf(options) {
82
+ return basePathOf(originOf(options));
83
+ }
84
+ //# sourceMappingURL=siteFiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siteFiles.js","sourceRoot":"","sources":["../../../src/seo/core/siteFiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,+EAA+E;AAC/E,kFAAkF;AAClF,kEAAkE;AAClE,MAAM,WAAW,GAAG,eAAe,CAAC;AAiBpC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,OAAyB;IAClD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM;SAC3B,GAAG,CACF,CAAC,KAAK,EAAE,EAAE,CACR,eAAe,UAAU,CAAC,GAAG,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,cAAc,CACpE;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO;;EAEP,OAAO;;CAER,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAA4B;IACtD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAyB;IAChD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,WAAW,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CACb,sEAAsE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAC/F,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAyB;IACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Keep the tab and the canonical link in step with the page on screen.
3
+ *
4
+ * The server, or the build that wrote one file per address, already titled the
5
+ * page it handed out; this is what a move inside the app changes, and what a
6
+ * crawler that renders the page reads afterwards. Every site did the same three
7
+ * things around it — read the address it is on, look it up in its route table,
8
+ * write the head — so all three live here, and a site says only where its
9
+ * address is read and how a change to it is noticed.
10
+ */
11
+ import type { PageMetaOptions } from './pageMeta.ts';
12
+ /** Where a site's address is read, and how a change to it is noticed. */
13
+ export interface StartDocumentMetaOptions extends Omit<PageMetaOptions, 'url' | 'image'> {
14
+ /**
15
+ * The address on screen, query string included: a path, or the absolute
16
+ * address read off the page. It is read again on every write, so a `follow`
17
+ * that tracks what it reads — a signals `effect` — notices the next page.
18
+ */
19
+ url: () => string;
20
+ /**
21
+ * How a change of page is noticed: `effect` from `@preact/signals-react`
22
+ * follows whichever signals `url` reads and hands back the function that
23
+ * stops it. Left out, the head is written once, which is what a site calling
24
+ * this from its own `popstate` handler wants.
25
+ * @default undefined — the head is written once
26
+ */
27
+ follow?: (write: () => void) => () => void;
28
+ }
29
+ /**
30
+ * Write the head of the page on screen, and keep it in step as the page
31
+ * changes.
32
+ *
33
+ * Nothing happens where there is no document — a prerender script, a unit test
34
+ * of the route table — so this is safe to call from a module either of them
35
+ * imports.
36
+ * @param options - The site, its routes, where its address is read and how a
37
+ * change to it is noticed.
38
+ * @returns The function that stops following, which does nothing when nothing
39
+ * was followed.
40
+ * @throws {Error} When the site answers no route, or names an origin that is
41
+ * not an absolute address.
42
+ */
43
+ export declare function startDocumentMeta(options: StartDocumentMetaOptions): () => void;
44
+ //# sourceMappingURL=startDocumentMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startDocumentMeta.d.ts","sourceRoot":"","sources":["../../../src/seo/core/startDocumentMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGrD,yEAAyE;AACzE,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CACpD,eAAe,EACf,KAAK,GAAG,OAAO,CAChB;IACC;;;;OAIG;IACH,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAC5C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,wBAAwB,GAChC,MAAM,IAAI,CAeZ"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Keep the tab and the canonical link in step with the page on screen.
3
+ *
4
+ * The server, or the build that wrote one file per address, already titled the
5
+ * page it handed out; this is what a move inside the app changes, and what a
6
+ * crawler that renders the page reads afterwards. Every site did the same three
7
+ * things around it — read the address it is on, look it up in its route table,
8
+ * write the head — so all three live here, and a site says only where its
9
+ * address is read and how a change to it is noticed.
10
+ */
11
+ import { writeDocumentMeta } from "./documentMeta.js";
12
+ import { pageDocumentMeta } from "./pageMeta.js";
13
+ /**
14
+ * Write the head of the page on screen, and keep it in step as the page
15
+ * changes.
16
+ *
17
+ * Nothing happens where there is no document — a prerender script, a unit test
18
+ * of the route table — so this is safe to call from a module either of them
19
+ * imports.
20
+ * @param options - The site, its routes, where its address is read and how a
21
+ * change to it is noticed.
22
+ * @returns The function that stops following, which does nothing when nothing
23
+ * was followed.
24
+ * @throws {Error} When the site answers no route, or names an origin that is
25
+ * not an absolute address.
26
+ */
27
+ export function startDocumentMeta(options) {
28
+ if (typeof document === 'undefined')
29
+ return stopNothing;
30
+ const write = () => {
31
+ writeDocumentMeta(pageDocumentMeta({
32
+ site: options.site,
33
+ routes: options.routes,
34
+ url: options.url(),
35
+ origin: options.origin,
36
+ }));
37
+ };
38
+ return (options.follow ?? writeOnce)(write);
39
+ }
40
+ function writeOnce(write) {
41
+ write();
42
+ return stopNothing;
43
+ }
44
+ function stopNothing() {
45
+ // Nothing was followed, so there is nothing to stop.
46
+ }
47
+ //# sourceMappingURL=startDocumentMeta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startDocumentMeta.js","sourceRoot":"","sources":["../../../src/seo/core/startDocumentMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAuBjD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAiC;IAEjC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IAExD,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,iBAAiB,CACf,gBAAgB,CAAC;YACf,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;YAClB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,SAAS,CAAC,KAAiB;IAClC,KAAK,EAAE,CAAC;IACR,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,WAAW;IAClB,qDAAqD;AACvD,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * One `application/ld+json` block describing the tool.
3
+ *
4
+ * It is the same on every page of a site — what varies per page is the head —
5
+ * so it is written into the built page once rather than per route.
6
+ */
7
+ import type { SiteFilesOptions } from './siteFiles.ts';
8
+ /** What the structured-data block says the tool is. */
9
+ export interface StructuredDataOptions extends SiteFilesOptions {
10
+ /**
11
+ * The schema.org application category.
12
+ * @default 'EducationalApplication'
13
+ */
14
+ category?: string;
15
+ /**
16
+ * What the tool needs to run.
17
+ * @default 'Any modern browser'
18
+ */
19
+ operatingSystem?: string;
20
+ /**
21
+ * What the tool does, in the words a search result is read in. A site whose
22
+ * indexed sentence says more than the line its tile in the family menu
23
+ * carries writes it here.
24
+ * @default the site's tagline
25
+ */
26
+ description?: string;
27
+ /**
28
+ * What a browser has to offer for the tool to run. Ours run in the page.
29
+ * @default 'Requires JavaScript'
30
+ */
31
+ browserRequirements?: string;
32
+ /**
33
+ * The currency the price is quoted in. The price is zero either way, but the
34
+ * pair has to agree with the audience the site is read by.
35
+ * @default 'EUR'
36
+ */
37
+ currency?: string;
38
+ }
39
+ /**
40
+ * The structured-data block, ready to put in the head.
41
+ *
42
+ * It always says the tool is free: the price is zero, and a block that leaves
43
+ * that implicit is one a rich result declines to show.
44
+ * @param options - The site, and what kind of application it is.
45
+ * @returns The script tag.
46
+ */
47
+ export declare function structuredDataScript(options: StructuredDataOptions): string;
48
+ //# sourceMappingURL=structuredData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structuredData.d.ts","sourceRoot":"","sources":["../../../src/seo/core/structuredData.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMvD,uDAAuD;AACvD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAwB3E"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * One `application/ld+json` block describing the tool.
3
+ *
4
+ * It is the same on every page of a site — what varies per page is the head —
5
+ * so it is written into the built page once rather than per route.
6
+ */
7
+ import { siteDisplayName } from "../../ecosystem/core/lookup.js";
8
+ import { originOf, resolveSite } from "./siteFiles.js";
9
+ /** The sequence that must not appear raw inside a script element. */
10
+ const SCRIPT_SAFE_LESS_THAN = String.raw `\u003c`;
11
+ /**
12
+ * The structured-data block, ready to put in the head.
13
+ *
14
+ * It always says the tool is free: the price is zero, and a block that leaves
15
+ * that implicit is one a rich result declines to show.
16
+ * @param options - The site, and what kind of application it is.
17
+ * @returns The script tag.
18
+ */
19
+ export function structuredDataScript(options) {
20
+ const site = resolveSite(options.site);
21
+ const data = {
22
+ '@context': 'https://schema.org',
23
+ '@type': 'WebApplication',
24
+ name: siteDisplayName(site),
25
+ url: `${originOf(options)}/`,
26
+ description: options.description ?? site.tagline,
27
+ applicationCategory: options.category ?? 'EducationalApplication',
28
+ operatingSystem: options.operatingSystem ?? 'Any modern browser',
29
+ browserRequirements: options.browserRequirements ?? 'Requires JavaScript',
30
+ offers: {
31
+ '@type': 'Offer',
32
+ price: '0',
33
+ priceCurrency: options.currency ?? 'EUR',
34
+ },
35
+ isAccessibleForFree: true,
36
+ publisher: { '@type': 'Organization', name: 'cheminfo' },
37
+ };
38
+ const json = JSON.stringify(data, null, 2).replaceAll('<', SCRIPT_SAFE_LESS_THAN);
39
+ return `<script type="application/ld+json">\n${json}\n</script>`;
40
+ }
41
+ //# sourceMappingURL=structuredData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structuredData.js","sourceRoot":"","sources":["../../../src/seo/core/structuredData.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGjE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEvD,qEAAqE;AACrE,MAAM,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAA,QAAQ,CAAC;AAkCjD;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG;QACX,UAAU,EAAE,oBAAoB;QAChC,OAAO,EAAE,gBAAgB;QACzB,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC;QAC3B,GAAG,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG;QAC5B,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,OAAO;QAChD,mBAAmB,EAAE,OAAO,CAAC,QAAQ,IAAI,wBAAwB;QACjE,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,oBAAoB;QAChE,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,IAAI,qBAAqB;QACzE,MAAM,EAAE;YACN,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,GAAG;YACV,aAAa,EAAE,OAAO,CAAC,QAAQ,IAAI,KAAK;SACzC;QACD,mBAAmB,EAAE,IAAI;QACzB,SAAS,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,UAAU,EAAE;KACzD,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CACnD,GAAG,EACH,qBAAqB,CACtB,CAAC;IACF,OAAO,wCAAwC,IAAI,aAAa,CAAC;AACnE,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Where a built page lets its head and its body be written.
3
+ *
4
+ * Every address of a site needs its own title, description, canonical and card,
5
+ * and a static build ships one `index.html`. Rather than look for the tags a
6
+ * page already carries and operate on them, the template says where they go:
7
+ * two comments, replaced by what the build or the server writes for the address
8
+ * being answered.
9
+ *
10
+ * ```html
11
+ * <head>
12
+ * <meta charset="utf-8" />
13
+ * <link rel="icon" href="%BASE_URL%favicon.svg" />
14
+ * <!--cheminfo:head-->
15
+ * </head>
16
+ * <body>
17
+ * <div id="root"></div>
18
+ * <!--cheminfo:body-->
19
+ * </body>
20
+ * ```
21
+ *
22
+ * The template carries no title and no description of its own, so nothing can
23
+ * be duplicated and nothing has to be taken back out. Nothing is parsed and
24
+ * nothing is searched for but the marker, so what the rest of the page holds — a
25
+ * byte order mark, an implicit head, a `</head>` its prose displays or a script
26
+ * quotes, an unterminated comment — cannot reach the result.
27
+ */
28
+ /** Where the head a crawler reads is written. */
29
+ export declare const PAGE_HEAD_MARKER = "<!--cheminfo:head-->";
30
+ /** Where the crawl path a visitor with no JavaScript reads is written. */
31
+ export declare const PAGE_BODY_MARKER = "<!--cheminfo:body-->";
32
+ /**
33
+ * Write content in the place the template kept for it.
34
+ *
35
+ * The marker is consumed, so a page is always filled from the template and
36
+ * never from a filled page: applying this twice throws rather than writing a
37
+ * second head, which is why idempotence is not something the caller has to
38
+ * defend.
39
+ * @param html - The template.
40
+ * @param marker - {@link PAGE_HEAD_MARKER} or {@link PAGE_BODY_MARKER}.
41
+ * @param content - The markup to write, taken as written: no `$&`, `$1` or
42
+ * `$<name>` is expanded.
43
+ * @returns The page.
44
+ * @throws {Error} When the template carries no such marker, rather than
45
+ * silently shipping a page with no head.
46
+ */
47
+ export declare function fill(html: string, marker: string, content: string): string;
48
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../../../src/seo/core/template.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AAEvD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAI1E"}