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,93 @@
1
+ /**
2
+ * A readable page for a visitor, or a crawler, with no JavaScript.
3
+ *
4
+ * The body of our sites is an empty root element, so this is the only crawl
5
+ * path through them that costs nothing to render — and it is honest: it says
6
+ * the tool needs JavaScript, and links the addresses it answers.
7
+ */
8
+ import { siteById, siteDisplayName } from "../../ecosystem/core/lookup.js";
9
+ import { ECOSYSTEM_SITES, siteUrl } from "../../ecosystem/core/sites.js";
10
+ import { joinBasePath } from "../../router/core/basePath.js";
11
+ import { escapeAttribute, escapeText } from "../../share/core/escape.js";
12
+ import { mountPathOf, resolveSite } from "./siteFiles.js";
13
+ /**
14
+ * The `noscript` block, ready to put in the body.
15
+ *
16
+ * An absolute address is written under the mount the deployment named, so a
17
+ * build published as one tool among several on a shared host links its own
18
+ * pages rather than the root of the host it shares.
19
+ * @param options - The site, the pages it links, and the prose that opens the
20
+ * block.
21
+ * @returns The block.
22
+ * @throws {Error} When the deployment named an origin that is not an absolute
23
+ * address.
24
+ */
25
+ export function noscriptIndex(options) {
26
+ const site = resolveSite(options.site);
27
+ const hrefs = options.hrefs ?? 'absolute';
28
+ const mount = hrefs === 'absolute' ? mountPathOf(options) : '';
29
+ const heading = escapeText(options.heading ?? siteDisplayName(site));
30
+ const intro = escapeText(options.intro ??
31
+ `${site.tagline} This tool needs JavaScript; these are the pages it offers:`);
32
+ return `<noscript>
33
+ <h1>${heading}</h1>
34
+ <p>${intro}</p>${pageList(options.routes, mount, hrefs, ' ')}${familyList(site.id, options.ecosystem)}
35
+ </noscript>`;
36
+ }
37
+ function pageList(routes, mount, hrefs, indent) {
38
+ // A list with no item is not a list: `<ul>` holds at least one `<li>`.
39
+ if (routes.length === 0)
40
+ return '';
41
+ const items = routes
42
+ .map((route) => pageItem(route, mount, hrefs, `${indent} `))
43
+ .join('\n');
44
+ return `\n${indent}<ul>\n${items}\n${indent}</ul>`;
45
+ }
46
+ function pageItem(route, mount, hrefs, indent) {
47
+ const href = escapeAttribute(pageHref(route.path, mount, hrefs));
48
+ const label = escapeText(labelOf(route));
49
+ const note = route.note === undefined || route.note.trim() === ''
50
+ ? ''
51
+ : ` — ${escapeText(route.note)}`;
52
+ const children = route.children ?? [];
53
+ const link = `<a href="${href}">${label}</a>${note}`;
54
+ if (children.length === 0)
55
+ return `${indent}<li>${link}</li>`;
56
+ return `${indent}<li>${link}${pageList(children, mount, hrefs, `${indent} `)}
57
+ ${indent}</li>`;
58
+ }
59
+ function pageHref(path, mount, hrefs) {
60
+ if (hrefs === 'absolute')
61
+ return joinBasePath(mount, path);
62
+ return `./${path.startsWith('/') ? path.slice(1) : path}`;
63
+ }
64
+ function labelOf(route) {
65
+ const short = route.short;
66
+ return short !== undefined && short.trim() !== '' ? short : route.title;
67
+ }
68
+ function familyList(current, ecosystem) {
69
+ if (ecosystem === undefined || ecosystem === false)
70
+ return '';
71
+ const listed = ecosystem === true ? {} : ecosystem;
72
+ const taglines = listed.taglines ?? true;
73
+ const items = [];
74
+ for (const site of familySites(listed.sites)) {
75
+ if (site.id === current)
76
+ continue;
77
+ const tagline = taglines ? ` — ${escapeText(site.tagline)}` : '';
78
+ items.push(` <li><a href="${escapeAttribute(siteUrl(site))}">${escapeText(site.host)}</a>${tagline}</li>`);
79
+ }
80
+ if (items.length === 0)
81
+ return '';
82
+ return `
83
+ <h2>Our other tools</h2>
84
+ <ul>
85
+ ${items.join('\n')}
86
+ </ul>`;
87
+ }
88
+ function familySites(sites) {
89
+ if (sites === undefined)
90
+ return [...ECOSYSTEM_SITES];
91
+ return sites.map((id) => siteById(id));
92
+ }
93
+ //# sourceMappingURL=noscript.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noscript.js","sourceRoot":"","sources":["../../../src/seo/core/noscript.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIzE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAiF1D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,OAAwB;IACpD,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,UAAU,CACtB,OAAO,CAAC,KAAK;QACX,GAAG,IAAI,CAAC,OAAO,6DAA6D,CAC/E,CAAC;IAEF,OAAO;QACD,OAAO;OACR,KAAK,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAA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CAAC,KAAK,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,OAAO,OAAO,CAClG,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAClC,OAAO;;;EAGP,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACV,CAAC;AACT,CAAC;AAED,SAAS,WAAW,CAAC,KAAoC;IACvD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,eAAe,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The head of the page a crawler is handed.
3
+ *
4
+ * Googlebot renders JavaScript, but Bing, a Slack unfurl, an LMS preview and
5
+ * every academic indexer read the HTML that came off the wire — so the title,
6
+ * the description and the canonical of a page must already be in it. A site
7
+ * with a server writes them per request; a static one writes one file per
8
+ * address at build time. Both call this, which is pure string work: no
9
+ * `window`, no `node:fs`.
10
+ *
11
+ * The page it is given is the template, which declares where its head goes and
12
+ * carries none of its own, so this only ever writes — see `./template.ts`.
13
+ */
14
+ import type { EcosystemSite, SiteId } from '../../ecosystem/core/sites.ts';
15
+ import type { DocumentMeta } from './documentMeta.ts';
16
+ import type { RouteMeta } from './routes.ts';
17
+ /** Which site is being served, and what it answers. */
18
+ export interface PageMetaOptions {
19
+ /** The site, named or passed. */
20
+ site: EcosystemSite | SiteId;
21
+ /** Every address it answers, each with its title and description. */
22
+ routes: readonly RouteMeta[];
23
+ /**
24
+ * The address being written, query string included: a path, or the absolute
25
+ * address an app reads off the page it is on.
26
+ */
27
+ url: string;
28
+ /**
29
+ * Where the site is served, mount path included, e.g.
30
+ * `https://learn.cheminfo.org/surge`. A server passes the one the request
31
+ * arrived on; a build leaves it out and the site's own host is used. Every
32
+ * address written here is composed on it, so the mount is carried by the
33
+ * origin rather than applied a second time. It is an absolute address, or it
34
+ * is refused.
35
+ * @default `https://<the site's host>`
36
+ */
37
+ origin?: string;
38
+ /**
39
+ * The card a link to the page unfurls into, as an absolute address or a path.
40
+ * @default '/og.png'
41
+ */
42
+ image?: string;
43
+ }
44
+ /**
45
+ * Give a page the title, the description and the canonical address of the route
46
+ * it answers, plus the card a link to it unfurls into.
47
+ * @param html - The built template.
48
+ * @param options - Which site, which address, and where it is served from.
49
+ * @returns The page, with its head written for that route.
50
+ * @throws {Error} When the page carries no `<!--cheminfo:head-->`, when the
51
+ * site answers no route, or when it names an origin that is not an absolute
52
+ * address.
53
+ */
54
+ export declare function injectPageMeta(html: string, options: PageMetaOptions): string;
55
+ /**
56
+ * The head a route is indexed and shared under, for a caller writing more into
57
+ * the same place — a structured-data block, a tracking snippet.
58
+ * @param options - Which site, which address, and where it is served from.
59
+ * @returns The tags, one per line.
60
+ * @throws {Error} When the site answers no route, or names an origin that is
61
+ * not an absolute address.
62
+ */
63
+ export declare function pageHeadTags(options: PageMetaOptions): string;
64
+ /**
65
+ * What the page on screen is called and where it is indexed, for the app to
66
+ * write after an in-app move.
67
+ *
68
+ * The same title and canonical the build wrote into the file it served, so a
69
+ * click that changes the page cannot disagree with the page a crawler fetched.
70
+ * @param options - Which site, which address, and where it is served from.
71
+ * @returns The title, the description and the canonical of that address.
72
+ * @throws {Error} When the site answers no route, or names an origin that is
73
+ * not an absolute address.
74
+ */
75
+ export declare function pageDocumentMeta(options: PageMetaOptions): Required<DocumentMeta>;
76
+ //# sourceMappingURL=pageMeta.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageMeta.d.ts","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAG3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK7C,uDAAuD;AACvD,MAAM,WAAW,eAAe;IAC9B,iCAAiC;IACjC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IAC7B,qEAAqE;IACrE,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IAC7B;;;OAGG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,MAAM,CAE7E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAmB7D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,eAAe,GACvB,QAAQ,CAAC,YAAY,CAAC,CAQxB"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * The head of the page a crawler is handed.
3
+ *
4
+ * Googlebot renders JavaScript, but Bing, a Slack unfurl, an LMS preview and
5
+ * every academic indexer read the HTML that came off the wire — so the title,
6
+ * the description and the canonical of a page must already be in it. A site
7
+ * with a server writes them per request; a static one writes one file per
8
+ * address at build time. Both call this, which is pure string work: no
9
+ * `window`, no `node:fs`.
10
+ *
11
+ * The page it is given is the template, which declares where its head goes and
12
+ * carries none of its own, so this only ever writes — see `./template.ts`.
13
+ */
14
+ import { siteDisplayName } from "../../ecosystem/core/lookup.js";
15
+ import { escapeAttribute, escapeText } from "../../share/core/escape.js";
16
+ import { pageMetaFor } from "./routes.js";
17
+ import { mountPathOf, originOf, resolveSite } from "./siteFiles.js";
18
+ import { PAGE_HEAD_MARKER, fill } from "./template.js";
19
+ /**
20
+ * Give a page the title, the description and the canonical address of the route
21
+ * it answers, plus the card a link to it unfurls into.
22
+ * @param html - The built template.
23
+ * @param options - Which site, which address, and where it is served from.
24
+ * @returns The page, with its head written for that route.
25
+ * @throws {Error} When the page carries no `<!--cheminfo:head-->`, when the
26
+ * site answers no route, or when it names an origin that is not an absolute
27
+ * address.
28
+ */
29
+ export function injectPageMeta(html, options) {
30
+ return fill(html, PAGE_HEAD_MARKER, pageHeadTags(options));
31
+ }
32
+ /**
33
+ * The head a route is indexed and shared under, for a caller writing more into
34
+ * the same place — a structured-data block, a tracking snippet.
35
+ * @param options - Which site, which address, and where it is served from.
36
+ * @returns The tags, one per line.
37
+ * @throws {Error} When the site answers no route, or names an origin that is
38
+ * not an absolute address.
39
+ */
40
+ export function pageHeadTags(options) {
41
+ const name = siteDisplayName(resolveSite(options.site));
42
+ const description = routeMetaOf(options).description;
43
+ const origin = originOf(options);
44
+ const { title, canonical } = pageDocumentMeta(options);
45
+ const image = absolute(options.image ?? '/og.png', origin);
46
+ return [
47
+ `<title>${escapeText(title)}</title>`,
48
+ `<meta name="description" content="${escapeAttribute(description)}" />`,
49
+ `<link rel="canonical" href="${escapeAttribute(canonical)}" />`,
50
+ '<meta property="og:type" content="website" />',
51
+ `<meta property="og:site_name" content="${escapeAttribute(name)}" />`,
52
+ `<meta property="og:title" content="${escapeAttribute(title)}" />`,
53
+ `<meta property="og:description" content="${escapeAttribute(description)}" />`,
54
+ `<meta property="og:url" content="${escapeAttribute(canonical)}" />`,
55
+ `<meta property="og:image" content="${escapeAttribute(image)}" />`,
56
+ '<meta name="twitter:card" content="summary_large_image" />',
57
+ ].join('\n');
58
+ }
59
+ /**
60
+ * What the page on screen is called and where it is indexed, for the app to
61
+ * write after an in-app move.
62
+ *
63
+ * The same title and canonical the build wrote into the file it served, so a
64
+ * click that changes the page cannot disagree with the page a crawler fetched.
65
+ * @param options - Which site, which address, and where it is served from.
66
+ * @returns The title, the description and the canonical of that address.
67
+ * @throws {Error} When the site answers no route, or names an origin that is
68
+ * not an absolute address.
69
+ */
70
+ export function pageDocumentMeta(options) {
71
+ const site = resolveSite(options.site);
72
+ const meta = routeMetaOf(options);
73
+ return {
74
+ title: `${meta.title} — ${siteDisplayName(site)}`,
75
+ description: meta.description,
76
+ canonical: `${originOf(options)}${meta.path}`,
77
+ };
78
+ }
79
+ // A server behind a mount is handed the address the browser asked for, and the
80
+ // route table is written from the site's own root, so the mount the origin
81
+ // carries is taken off it before the table is read.
82
+ function routeMetaOf(options) {
83
+ return pageMetaFor(options.routes, options.url, mountPathOf(options));
84
+ }
85
+ function absolute(target, origin) {
86
+ return target.startsWith('/') ? `${origin}${target}` : target;
87
+ }
88
+ //# sourceMappingURL=pageMeta.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageMeta.js","sourceRoot":"","sources":["../../../src/seo/core/pageMeta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAIzE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AA8BvD;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,IAAY,EAAE,OAAwB;IACnE,OAAO,IAAI,CAAC,IAAI,EAAE,gBAAgB,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,OAAwB;IACnD,MAAM,IAAI,GAAG,eAAe,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;IACrD,MAAM,MAAM,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AC,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,QAAQ,CAAC,MAAc,EAAE,MAAc;IAC9C,OAAO,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAChE,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The crawl policy.
3
+ *
4
+ * Our tools are meant to be found, so only the endpoints are kept out of the
5
+ * index — an API prefix and its documentation are not pages — and each one may
6
+ * say in a comment why, because a policy nobody can read is a policy nobody
7
+ * maintains.
8
+ *
9
+ * Every line of this file is a directive, so nothing an author writes may
10
+ * become one they did not: a path is a single line that says something, and
11
+ * carries no fragment, or it is refused; and a comment is folded onto the one
12
+ * line it is written as.
13
+ */
14
+ import type { SiteFilesOptions } from './siteFiles.ts';
15
+ /** One address kept out of the index, and why. */
16
+ export interface RobotsDisallow {
17
+ /**
18
+ * The address prefix, from the site's own root, e.g. `/v1/`. It is a path,
19
+ * on one line, saying something, carrying no `#`, and padded by nothing: a
20
+ * blank one would read as `Disallow: /` and keep the whole site out of the
21
+ * index — RFC 9309 eats the trailing whitespace of a line, so `" "` is read
22
+ * as nothing at all — one carrying a line break would write whatever follows
23
+ * it as a directive of its own, everything from a `#` onwards is read as a
24
+ * comment, which truncates the path silently, and a padded one is not the
25
+ * address it looks like: `" /v1/"` does not start at the site root, so it is
26
+ * written `Disallow: / /v1/` and matches no address at all, leaving the
27
+ * endpoint crawled by the very line meant to keep it out.
28
+ */
29
+ path: string;
30
+ /**
31
+ * One sentence written as a `#` line above the directive. The `#` is added
32
+ * when it is not already there, every run of whitespace is folded to a single
33
+ * space so the sentence stays on its own line, and a blank one is written as
34
+ * no line at all.
35
+ * @default undefined — the directive is written on its own
36
+ */
37
+ comment?: string;
38
+ }
39
+ /**
40
+ * The crawl policy of the address the site is served at.
41
+ *
42
+ * Every path is written under the mount, so a build published as one tool among
43
+ * several on a shared host allows what it actually answers rather than claiming
44
+ * the whole host. The sitemap is named only because this module also writes it:
45
+ * a `Sitemap:` line pointing at a 404 is reported as an error on every fetch.
46
+ * @param options - The site, its routes, and where it is served.
47
+ * @param disallow - Addresses to keep out of the index, each optionally with
48
+ * the sentence saying why.
49
+ * @returns The `robots.txt` document.
50
+ * @throws {Error} When a disallowed address is blank, spans more than one line,
51
+ * carries a `#` or is padded with whitespace, or when the deployment named an
52
+ * origin that is not an absolute address.
53
+ */
54
+ export declare function robotsTxt(options: SiteFilesOptions, disallow?: ReadonlyArray<string | RobotsDisallow>): string;
55
+ //# sourceMappingURL=robots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"robots.d.ts","sourceRoot":"","sources":["../../../src/seo/core/robots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGvD,kDAAkD;AAClD,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;OAWG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,GAAE,aAAa,CAAC,MAAM,GAAG,cAAc,CAAM,GACpD,MAAM,CAcR"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The crawl policy.
3
+ *
4
+ * Our tools are meant to be found, so only the endpoints are kept out of the
5
+ * index — an API prefix and its documentation are not pages — and each one may
6
+ * say in a comment why, because a policy nobody can read is a policy nobody
7
+ * maintains.
8
+ *
9
+ * Every line of this file is a directive, so nothing an author writes may
10
+ * become one they did not: a path is a single line that says something, and
11
+ * carries no fragment, or it is refused; and a comment is folded onto the one
12
+ * line it is written as.
13
+ */
14
+ import { joinBasePath } from "../../router/core/basePath.js";
15
+ import { mountPathOf, originOf } from "./siteFiles.js";
16
+ const NEWLINE = /[\n\r]/;
17
+ const WHITESPACE = /\s+/g;
18
+ /**
19
+ * The crawl policy of the address the site is served at.
20
+ *
21
+ * Every path is written under the mount, so a build published as one tool among
22
+ * several on a shared host allows what it actually answers rather than claiming
23
+ * the whole host. The sitemap is named only because this module also writes it:
24
+ * a `Sitemap:` line pointing at a 404 is reported as an error on every fetch.
25
+ * @param options - The site, its routes, and where it is served.
26
+ * @param disallow - Addresses to keep out of the index, each optionally with
27
+ * the sentence saying why.
28
+ * @returns The `robots.txt` document.
29
+ * @throws {Error} When a disallowed address is blank, spans more than one line,
30
+ * carries a `#` or is padded with whitespace, or when the deployment named an
31
+ * origin that is not an absolute address.
32
+ */
33
+ export function robotsTxt(options, disallow = []) {
34
+ const mount = mountPathOf(options);
35
+ const lines = ['User-agent: *', `Allow: ${joinBasePath(mount, '/')}`];
36
+ for (const entry of disallow) {
37
+ const rule = typeof entry === 'string' ? { path: entry } : entry;
38
+ const comment = rule.comment === undefined ? undefined : commentLine(rule.comment);
39
+ if (comment !== undefined)
40
+ lines.push(comment);
41
+ lines.push(`Disallow: ${joinBasePath(mount, disallowPath(rule.path))}`);
42
+ }
43
+ lines.push('', `Sitemap: ${originOf(options)}/sitemap.xml`, '');
44
+ return lines.join('\n');
45
+ }
46
+ function disallowPath(path) {
47
+ if (path === '') {
48
+ throw new Error('a disallowed address is a path, never the empty string');
49
+ }
50
+ if (path.trim() === '') {
51
+ throw new Error(`a disallowed address is a path, never blank: ${JSON.stringify(path)}`);
52
+ }
53
+ if (NEWLINE.test(path)) {
54
+ throw new Error(`a disallowed address is written on one line: ${JSON.stringify(path)}`);
55
+ }
56
+ if (path.includes('#')) {
57
+ throw new Error(`a disallowed address carries no fragment: ${JSON.stringify(path)}`);
58
+ }
59
+ if (path !== path.trim()) {
60
+ throw new Error(`a disallowed address is written without padding: ${JSON.stringify(path)}`);
61
+ }
62
+ return path;
63
+ }
64
+ function commentLine(comment) {
65
+ const text = comment.replaceAll(WHITESPACE, ' ').trim();
66
+ if (text === '')
67
+ return undefined;
68
+ return text.startsWith('#') ? text : `# ${text}`;
69
+ }
70
+ //# sourceMappingURL=robots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"robots.js","sourceRoot":"","sources":["../../../src/seo/core/robots.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAG7D,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA2BvD,MAAM,OAAO,GAAG,QAAQ,CAAC;AAEzB,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACvB,OAAyB,EACzB,WAAmD,EAAE;IAErD,MAAM,KAAK,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,KAAK,GAAG,CAAC,eAAe,EAAE,UAAU,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAEtE,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;QACjE,MAAM,OAAO,GACX,IAAI,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrE,IAAI,OAAO,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC,aAAa,YAAY,CAAC,KAAK,EAAE,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,YAAY,QAA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;AACnD,CAAC"}
@@ -0,0 +1,120 @@
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
+ /** A page, as a crawler and a shared card see it. */
11
+ export interface RouteMeta {
12
+ /** Absolute path, without a trailing slash and without a query string. */
13
+ path: string;
14
+ /** Under ~60 characters: the site name is appended to it. */
15
+ title: string;
16
+ /** One sentence, in the words someone would search for. */
17
+ description: string;
18
+ /**
19
+ * The label the page is linked under where a title written for a search
20
+ * result is too long to read as a menu entry — the `noscript` index.
21
+ * @default the route's own title
22
+ */
23
+ short?: string;
24
+ /**
25
+ * What the page is for, written after an em dash next to its link in the
26
+ * `noscript` index.
27
+ * @default undefined — the link stands on its own
28
+ */
29
+ note?: string;
30
+ /**
31
+ * Whether the route also answers every address beneath it, so a section
32
+ * carrying more pages than a table can hold — an entry per structure, per
33
+ * ligand, per identifier — is indexed under the section rather than under the
34
+ * home page. Those addresses are canonical to the section itself.
35
+ * @default false
36
+ */
37
+ prefix?: boolean;
38
+ }
39
+ /**
40
+ * The route an address names.
41
+ *
42
+ * An address a route claims exactly always wins over one that claims it as a
43
+ * subtree, and between two subtrees the longer claim wins, so `/molecules/HEM`
44
+ * is a molecule rather than whatever `/` answers.
45
+ * @param routes - Every address the site answers.
46
+ * @param path - Absolute path, without a query string.
47
+ * @returns Its entry, or `undefined` when the site does not know the address.
48
+ */
49
+ export declare function routeFor(routes: readonly RouteMeta[], path: string): RouteMeta | undefined;
50
+ /**
51
+ * The page an address opens.
52
+ *
53
+ * An address the site does not know is described as the home page rather than
54
+ * invented on the fly, which is what the router does with it too. The query
55
+ * string never reaches the answer: the structure being drawn and the
56
+ * configuration a shared link carries are not pages of their own. An absolute
57
+ * address is read for its path, so an app handing over `location.href` after an
58
+ * in-app move is answered rather than silently described as the home page.
59
+ *
60
+ * The route table is written from the site's own root, and a server behind a
61
+ * mount is handed the address the browser asked for — `/surge/exercises` for a
62
+ * table that names `/exercises`. So the address is read at the site's own root
63
+ * first, and the four lookups run in this order:
64
+ *
65
+ * 1. the mount taken off, claimed exactly;
66
+ * 2. the address as written, claimed exactly;
67
+ * 3. the mount taken off, claimed as a subtree;
68
+ * 4. the address as written, claimed as a subtree.
69
+ *
70
+ * Exact before subtree, or a `prefix` route — a home page answering everything
71
+ * beneath it above all — would claim every mounted address and the mount would
72
+ * never come off. Stripped before as-written, or the mount itself would open
73
+ * whichever page happens to carry the mount's own name rather than the site's
74
+ * front page. Taking the address as written second is what leaves an unmounted
75
+ * caller answering exactly as before, and lets a table whose own paths start
76
+ * with the mount's name still be read.
77
+ * @param routes - Every address the site answers.
78
+ * @param url - The address, query string and fragment included, either as a
79
+ * path or as an absolute `scheme://host/path` address.
80
+ * @param basePath - The path the site is mounted at, when the address carries
81
+ * it, written `surge`, `/surge` or `/surge/`.
82
+ * @default '' — the address is already written from the site's own root
83
+ * @returns The route it is indexed as.
84
+ * @throws {Error} When the table is empty, so there is no page to fall back to.
85
+ */
86
+ export declare function pageMetaFor(routes: readonly RouteMeta[], url: string, basePath?: string): RouteMeta;
87
+ /**
88
+ * The page an unknown address falls back to.
89
+ * @param routes - Every address the site answers.
90
+ * @returns The `/` entry, or the first one when the table names no root.
91
+ * @throws {Error} When the table is empty.
92
+ */
93
+ export declare function homeRoute(routes: readonly RouteMeta[]): RouteMeta;
94
+ /**
95
+ * Check a route table before a build reads it as a set of file names.
96
+ *
97
+ * An address written twice ships two sitemap entries and two links to a page
98
+ * only the first entry describes, and one carrying a `..` segment writes its
99
+ * file outside the build output — a real build asked for `/../escaped` and got
100
+ * a sibling of `dist`. Two addresses that differ only in an empty segment or in
101
+ * case are the same defect wearing a disguise: `//x` and `/x` both write
102
+ * `dist/x/index.html`, and so do `/About` and `/about` on the case-insensitive
103
+ * filesystem macOS and Windows ship by default — one file, two sitemap entries,
104
+ * and only one of the two descriptions survives. All of it is author
105
+ * configuration read at build time, so it is refused where it is written rather
106
+ * than repaired where it lands.
107
+ * @param routes - Every address the site answers.
108
+ * @throws {Error} When the table is empty, names one address twice — under any
109
+ * of those spellings — or carries a path that is not one.
110
+ */
111
+ export declare function assertRoutes(routes: readonly RouteMeta[]): void;
112
+ /**
113
+ * Drop the trailing slashes, so `/about/` and `/about` are one page and an
114
+ * origin written `https://host/surge//` composes one address rather than one
115
+ * with an empty segment in it.
116
+ * @param value - A path or an origin.
117
+ * @returns It, without the trailing slashes `/` itself keeps.
118
+ */
119
+ export declare function trimTrailingSlash(value: string): string;
120
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../../src/seo/core/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,qDAAqD;AACrD,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,SAAS,CAEvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,SAAS,SAAS,EAAE,EAC5B,GAAG,EAAE,MAAM,EACX,QAAQ,SAAK,GACZ,SAAS,CAWX;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAIjE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,GAAG,IAAI,CAwB/D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAGvD"}