@curvenote/renderers 1.0.1 → 2.0.1

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 (105) hide show
  1. package/dist/articles.d.ts.map +1 -1
  2. package/dist/articles.js +8 -2
  3. package/dist/components/admonition.d.ts.map +1 -1
  4. package/dist/components/admonition.js +24 -4
  5. package/dist/components/anywidget-host.d.ts +7 -0
  6. package/dist/components/anywidget-host.d.ts.map +1 -0
  7. package/dist/components/anywidget-host.js +11 -0
  8. package/dist/components/bluesky.d.ts +6 -0
  9. package/dist/components/bluesky.d.ts.map +1 -0
  10. package/dist/components/bluesky.js +113 -0
  11. package/dist/components/cite-figurebar.d.ts +2 -1
  12. package/dist/components/cite-figurebar.d.ts.map +1 -1
  13. package/dist/components/cite-figurebar.js +73 -27
  14. package/dist/components/cite.d.ts +11 -0
  15. package/dist/components/cite.d.ts.map +1 -1
  16. package/dist/components/cite.js +130 -8
  17. package/dist/components/copy-icon.d.ts +11 -0
  18. package/dist/components/copy-icon.d.ts.map +1 -0
  19. package/dist/components/copy-icon.js +32 -0
  20. package/dist/components/definition-list.d.ts.map +1 -1
  21. package/dist/components/definition-list.js +3 -2
  22. package/dist/components/faq.js +1 -1
  23. package/dist/components/hash-link.d.ts +3 -0
  24. package/dist/components/hash-link.d.ts.map +1 -0
  25. package/dist/components/hash-link.js +3 -0
  26. package/dist/components/hero.d.ts +1 -1
  27. package/dist/components/hero.d.ts.map +1 -1
  28. package/dist/components/hero.js +14 -2
  29. package/dist/components/hover-popover.d.ts +26 -0
  30. package/dist/components/hover-popover.d.ts.map +1 -0
  31. package/dist/components/hover-popover.js +26 -0
  32. package/dist/components/images.d.ts.map +1 -1
  33. package/dist/components/images.js +7 -2
  34. package/dist/components/index.d.ts +3 -0
  35. package/dist/components/index.d.ts.map +1 -1
  36. package/dist/components/index.js +3 -0
  37. package/dist/components/pdb.d.ts.map +1 -1
  38. package/dist/components/pdb.js +42 -6
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +11 -3
  42. package/dist/myst/abbreviation.d.ts +6 -0
  43. package/dist/myst/abbreviation.d.ts.map +1 -0
  44. package/dist/myst/abbreviation.js +13 -0
  45. package/dist/myst/anywidget.d.ts +5 -0
  46. package/dist/myst/anywidget.d.ts.map +1 -0
  47. package/dist/myst/anywidget.js +12 -0
  48. package/dist/myst/code.d.ts +6 -0
  49. package/dist/myst/code.d.ts.map +1 -0
  50. package/dist/myst/code.js +103 -0
  51. package/dist/myst/container.d.ts +7 -0
  52. package/dist/myst/container.d.ts.map +1 -0
  53. package/dist/myst/container.js +57 -0
  54. package/dist/myst/cross-reference.d.ts +23 -0
  55. package/dist/myst/cross-reference.d.ts.map +1 -0
  56. package/dist/myst/cross-reference.js +140 -0
  57. package/dist/myst/footnotes.d.ts +7 -0
  58. package/dist/myst/footnotes.d.ts.map +1 -0
  59. package/dist/myst/footnotes.js +32 -0
  60. package/dist/myst/index.d.ts +14 -0
  61. package/dist/myst/index.d.ts.map +1 -0
  62. package/dist/myst/index.js +17 -0
  63. package/dist/myst/inline-expression.d.ts +6 -0
  64. package/dist/myst/inline-expression.d.ts.map +1 -0
  65. package/dist/myst/inline-expression.js +20 -0
  66. package/dist/myst/links/figshare.d.ts +8 -0
  67. package/dist/myst/links/figshare.d.ts.map +1 -0
  68. package/dist/myst/links/figshare.js +45 -0
  69. package/dist/myst/links/geo.d.ts +8 -0
  70. package/dist/myst/links/geo.d.ts.map +1 -0
  71. package/dist/myst/links/geo.js +116 -0
  72. package/dist/myst/links/github.d.ts +15 -0
  73. package/dist/myst/links/github.d.ts.map +1 -0
  74. package/dist/myst/links/github.js +156 -0
  75. package/dist/myst/links/huggingface.d.ts +10 -0
  76. package/dist/myst/links/huggingface.d.ts.map +1 -0
  77. package/dist/myst/links/huggingface.js +73 -0
  78. package/dist/myst/links/index.d.ts +12 -0
  79. package/dist/myst/links/index.d.ts.map +1 -0
  80. package/dist/myst/links/index.js +95 -0
  81. package/dist/myst/links/ror.d.ts +7 -0
  82. package/dist/myst/links/ror.d.ts.map +1 -0
  83. package/dist/myst/links/ror.js +34 -0
  84. package/dist/myst/links/rrid.d.ts +5 -0
  85. package/dist/myst/links/rrid.d.ts.map +1 -0
  86. package/dist/myst/links/rrid.js +31 -0
  87. package/dist/myst/links/wiki.d.ts +9 -0
  88. package/dist/myst/links/wiki.d.ts.map +1 -0
  89. package/dist/myst/links/wiki.js +41 -0
  90. package/dist/myst/math.d.ts +15 -0
  91. package/dist/myst/math.d.ts.map +1 -0
  92. package/dist/myst/math.js +53 -0
  93. package/dist/transforms/articles.d.ts +2 -1
  94. package/dist/transforms/articles.d.ts.map +1 -1
  95. package/dist/transforms/articles.js +2 -2
  96. package/dist/transforms/index.d.ts +5 -2
  97. package/dist/transforms/index.d.ts.map +1 -1
  98. package/dist/transforms/index.js +1 -0
  99. package/dist/utils/anywidget-analytics.d.ts +13 -0
  100. package/dist/utils/anywidget-analytics.d.ts.map +1 -0
  101. package/dist/utils/anywidget-analytics.js +15 -0
  102. package/dist/utils/content-analytics.d.ts +44 -0
  103. package/dist/utils/content-analytics.d.ts.map +1 -0
  104. package/dist/utils/content-analytics.js +59 -0
  105. package/package.json +22 -13
@@ -0,0 +1,156 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // @curvenote-fork:myst-to-react
3
+ // MIT — https://github.com/jupyter-book/myst-theme (packages/myst-to-react)
4
+ // Baseline v1.1.4: https://github.com/jupyter-book/myst-theme/blob/e2e1db449c87294775717a8924d4dd1a4d32ceb2/packages/myst-to-react/src/links/github.tsx
5
+ // Patched v1.3.0: https://github.com/jupyter-book/myst-theme/blob/be74efbb7d13b926a2a6c1e67913e1b1029f28e6/packages/myst-to-react/src/links/github.tsx
6
+ import useSWR from 'swr';
7
+ import { ArrowTopRightOnSquareIcon as ExternalLinkIcon, CheckCircleIcon, DocumentCheckIcon, DocumentPlusIcon, NoSymbolIcon, PlusCircleIcon, StarIcon, ScaleIcon, XCircleIcon, } from '@heroicons/react/24/outline';
8
+ import { GithubIcon } from '@scienceicons/react/24/solid';
9
+ import { CodeBlock, LinkCard } from 'myst-to-react';
10
+ import { cn } from '@curvenote/react-utils';
11
+ import { Fragment, useEffect, useState } from 'react';
12
+ import { HoverPopover } from '../../components/hover-popover';
13
+ const fetcher = (...args) => fetch(...args).then((res) => {
14
+ if (res.status === 200)
15
+ return res.text();
16
+ throw new Error(`Content returned with status ${res.status}.`);
17
+ });
18
+ const jsonFetcher = (...args) => fetch(...args).then((res) => {
19
+ if (res.status === 200)
20
+ return res.json();
21
+ throw new Error(`Content returned with status ${res.status}.`);
22
+ });
23
+ function extToLanguage(ext) {
24
+ return ({
25
+ ts: 'typescript',
26
+ js: 'javascript',
27
+ py: 'python',
28
+ md: 'markdown',
29
+ yml: 'yaml',
30
+ }[ext ?? ''] ?? ext);
31
+ }
32
+ function useLoadWhenOpen(open, url, loader) {
33
+ const [cached, setCached] = useState();
34
+ const { data, error } = useSWR(open ? url : null, loader);
35
+ useEffect(() => {
36
+ setCached((current) => current || data);
37
+ }, [cached, url, data]);
38
+ return { data: cached, error };
39
+ }
40
+ function GithubFilePreview({ url, raw, org, repo, file, from, to, open, className, }) {
41
+ const { data, error } = useLoadWhenOpen(open, raw, fetcher);
42
+ let code = data;
43
+ if (error) {
44
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: [_jsx("a", { href: url, className: cn('block text-inherit hover:text-inherit', className), target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { width: "1rem", height: "1rem", className: "float-right" }) }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", file, "\" from GitHub."] })] }));
45
+ }
46
+ const lang = extToLanguage(file?.split('.').pop());
47
+ let startingLineNumber = 1;
48
+ let emphasizeLines = [];
49
+ const offset = 5;
50
+ if (code && from && to) {
51
+ startingLineNumber = from;
52
+ code = code
53
+ .split('\n')
54
+ .slice(from - 1, to)
55
+ .join('\n');
56
+ }
57
+ else if (code && from) {
58
+ startingLineNumber = from + 1 - offset;
59
+ emphasizeLines = [from];
60
+ code = code
61
+ .split('\n')
62
+ .slice(Math.max(0, from - offset), from + offset)
63
+ .join('\n');
64
+ }
65
+ else {
66
+ code = code?.split('\n').slice(0, 10).join('\n');
67
+ }
68
+ const description = code ? (_jsx(Fragment, { children: _jsx(CodeBlock, { value: code, lang: lang, filename: file, showLineNumbers: true, startingLineNumber: startingLineNumber, emphasizeLines: emphasizeLines, showCopy: false }) })) : null;
69
+ return (_jsx(LinkCard, { loading: !code, url: url, title: `GitHub - ${org}/${repo}`, description: description, className: "hover-document article max-w-[80vw]" }));
70
+ }
71
+ // https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
72
+ function useWhiteTextColor(bgColor) {
73
+ const color = bgColor.charAt(0) === '#' ? bgColor.substring(1, 7) : bgColor;
74
+ const r = parseInt(color.substring(0, 2), 16);
75
+ const g = parseInt(color.substring(2, 4), 16);
76
+ const b = parseInt(color.substring(4, 6), 16);
77
+ return r * 0.299 + g * 0.587 + b * 0.114 <= 186;
78
+ }
79
+ function GithubIssuePreview({ url, org, repo, issue_number, open, className, }) {
80
+ const { data, error } = useLoadWhenOpen(open, `https://api.github.com/repos/${org}/${repo}/issues/${issue_number}`, jsonFetcher);
81
+ if (!data && !error) {
82
+ return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
83
+ }
84
+ if (error) {
85
+ return (_jsxs("div", { className: "hover-document article", children: [_jsx("a", { href: url, className: cn('block text-inherit hover:text-inherit', className), target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { className: "float-right w-4 h-4" }) }), _jsx("div", { className: "mt-2", children: "Error loading from GitHub." })] }));
86
+ }
87
+ if (!data) {
88
+ return null;
89
+ }
90
+ const issueData = data;
91
+ const isPullRequest = Boolean(issueData.pull_request);
92
+ const issueState = issueData.state;
93
+ const isOpen = issueState === 'open';
94
+ const isMerged = Boolean(issueData.pull_request?.merged_at);
95
+ const isCompletedIssue = issueData.state_reason === 'completed';
96
+ const isNotPlannedIssue = !isPullRequest && issueState === 'closed' && !isCompletedIssue;
97
+ const dateString = new Date(issueData.created_at).toLocaleDateString('en-US', {
98
+ year: 'numeric',
99
+ month: 'long',
100
+ day: 'numeric',
101
+ });
102
+ const iconClassName = 'inline-block mr-2 -translate-y-px h-6 w-6';
103
+ let stateIcon = null;
104
+ if (isPullRequest) {
105
+ if (isOpen) {
106
+ stateIcon = (_jsx(DocumentPlusIcon, { className: cn(iconClassName, 'text-green-700 dark:text-green-500') }));
107
+ }
108
+ else {
109
+ stateIcon = isMerged ? (_jsx(DocumentCheckIcon, { className: cn(iconClassName, 'text-purple-700 dark:text-purple-500') })) : (_jsx(XCircleIcon, { className: cn(iconClassName, 'text-red-700 dark:text-red-500') }));
110
+ }
111
+ }
112
+ else if (isOpen) {
113
+ stateIcon = (_jsx(PlusCircleIcon, { className: cn(iconClassName, 'text-green-700 dark:text-green-500') }));
114
+ }
115
+ else {
116
+ stateIcon = isNotPlannedIssue ? (_jsx(NoSymbolIcon, { className: cn(iconClassName, 'text-slate-500 dark:text-slate-400') })) : (_jsx(CheckCircleIcon, { className: cn(iconClassName, 'text-purple-700 dark:text-purple-500') }));
117
+ }
118
+ return (_jsxs("div", { className: "hover-document article w-[400px] sm:max-w-[400px] p-3", children: [_jsxs("div", { className: "text-xs font-light", children: [org, "/", repo] }), _jsxs("div", { className: "my-2 text-lg font-bold dark:text-white", children: [stateIcon, issueData.title] }), _jsxs("div", { className: "text-xs font-light", children: ["#", issue_number, " opened on ", dateString, " by", ' ', _jsxs("span", { className: "font-normal", children: ["@", issueData.user.login] })] }), _jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: issueData.body }), (issueData.labels?.length ?? 0) > 0 && (_jsx("div", { className: "flex flex-wrap gap-1", children: issueData.labels?.map((label) => (_jsx("span", { className: cn('text-xs inline-flex items-center px-2 py-0.5 rounded-full', {
119
+ 'text-white': useWhiteTextColor(label.color),
120
+ }), style: { backgroundColor: `#${label.color}` }, children: label.name }, label.id))) }))] }));
121
+ }
122
+ function compactNumber(value) {
123
+ if (!value)
124
+ return '0';
125
+ return Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }).format(value);
126
+ }
127
+ function GithubRepoPreview({ url, org, repo, open, className }) {
128
+ const { data, error } = useLoadWhenOpen(open, `https://api.github.com/repos/${org}/${repo}`, jsonFetcher);
129
+ if (!data && !error) {
130
+ return (_jsx("div", { className: "hover-document article w-[400px] sm:max-w-[400px] animate-pulse", children: "Loading..." }));
131
+ }
132
+ if (error || !data) {
133
+ return (_jsxs("div", { className: "hover-document article", children: [_jsx("a", { href: url, className: cn('block text-inherit hover:text-inherit', className), target: "_blank", rel: "noreferrer", children: _jsx(ExternalLinkIcon, { className: "float-right w-4 h-4" }) }), _jsx("div", { className: "mt-2", children: "Error loading from GitHub." })] }));
134
+ }
135
+ const license = data.license?.spdx_id && data.license.spdx_id !== 'NOASSERTION' && data.license.spdx_id;
136
+ const metaClassName = 'inline-flex items-center gap-1';
137
+ const iconClassName = 'w-4 h-4';
138
+ return (_jsxs("div", { className: "hover-document article w-[400px] sm:max-w-[400px] p-3", children: [_jsx("div", { className: "text-xs font-light", children: org }), _jsxs("div", { className: "my-1 text-lg font-bold dark:text-white", children: [_jsx(GithubIcon, { className: "inline-block mr-2 w-5 h-5 -translate-y-px dark:fill-white" }), _jsxs("a", { href: url, target: "_blank", rel: "noreferrer", className: cn('text-inherit hover:underline', className), children: [org, "/", repo] }), data.archived && (_jsx("span", { className: "ml-2 text-xs font-normal uppercase rounded-full border px-2 py-0.5 align-middle", children: "archived" }))] }), data.description && (_jsx("p", { className: "text-md max-h-[4rem] overflow-hidden", children: data.description })), _jsxs("div", { className: "flex flex-wrap gap-4 mt-2 text-xs font-light", children: [data.language && _jsx("span", { children: data.language }), _jsxs("span", { className: metaClassName, children: [_jsx(StarIcon, { className: iconClassName }), compactNumber(data.stargazers_count)] }), _jsxs("span", { className: metaClassName, children: [compactNumber(data.forks_count), " forks"] }), license && (_jsxs("span", { className: metaClassName, children: [_jsx(ScaleIcon, { className: iconClassName }), license] }))] }), (data.topics?.length ?? 0) > 0 && (_jsx("div", { className: "flex flex-wrap gap-1 mt-2", children: data.topics?.slice(0, 6).map((topic) => (_jsx("span", { className: "text-xs inline-flex items-center px-2 py-0.5 rounded-full border", children: topic }, topic))) }))] }));
139
+ }
140
+ export function GithubLink({ kind, children, url, org, repo, raw, file, from, to, issue_number, className, }) {
141
+ return (_jsx(HoverPopover, { card: ({ load }) => {
142
+ if (kind === 'file') {
143
+ return (_jsx(GithubFilePreview, { url: url, raw: raw ?? '', file: file, from: from, to: to, open: load, org: org, repo: repo, className: className }));
144
+ }
145
+ if (kind === 'issue') {
146
+ return (_jsx(GithubIssuePreview, { url: url, open: load, org: org, issue_number: issue_number ?? 0, repo: repo, className: className }));
147
+ }
148
+ if (kind === 'repo') {
149
+ return (_jsx(GithubRepoPreview, { url: url, open: load, org: org, repo: repo, className: className }));
150
+ }
151
+ return null;
152
+ }, analytics: {
153
+ cardKind: 'github_link',
154
+ properties: { githubKind: kind, githubUrl: url, githubOrg: org, githubRepo: repo },
155
+ }, children: _jsx("a", { href: url, className: cn('hover-link', className), target: "_blank", rel: "noreferrer", children: children }) }));
156
+ }
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ export type HfKind = 'dataset' | 'model' | 'space';
3
+ export declare function HuggingfaceLink({ repo, kind, url, children, className, }: {
4
+ repo: string;
5
+ kind: HfKind;
6
+ url: string;
7
+ children?: ReactNode;
8
+ className?: string;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ //# sourceMappingURL=huggingface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"huggingface.d.ts","sourceRoot":"","sources":["../../../src/myst/links/huggingface.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AA0HnD,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,QAAQ,EACR,SAAS,GACV,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAgBA"}
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import useSWR from 'swr';
3
+ import { cn } from '@curvenote/react-utils';
4
+ import { HoverPopover } from '../../components/hover-popover';
5
+ const API = 'https://huggingface.co/api';
6
+ const KIND_LABEL = { dataset: 'Dataset', model: 'Model', space: 'Space' };
7
+ const fetcher = (...args) => fetch(...args).then((res) => {
8
+ if (res.status === 200)
9
+ return res.json();
10
+ throw new Error(`Content returned with status ${res.status}.`);
11
+ });
12
+ function compactNumber(value) {
13
+ if (!value)
14
+ return undefined;
15
+ return Intl.NumberFormat('en-US', { notation: 'compact', maximumFractionDigits: 1 }).format(value);
16
+ }
17
+ function tagValue(tags, prefix) {
18
+ return tags.find((t) => t.startsWith(prefix))?.slice(prefix.length);
19
+ }
20
+ // HF descriptions are the dataset/model card intro with collapsed whitespace, often a
21
+ // repeated title + section header ("Dataset Description", "Model Card", …) before the real
22
+ // prose, and a trailing "See the full description on the … page: <url>" pointer. Clean all up.
23
+ function cleanDescription(desc) {
24
+ if (!desc)
25
+ return undefined;
26
+ let text = desc
27
+ .replace(/See the full description on the .*? page:.*$/i, '')
28
+ .replace(/\s+/g, ' ')
29
+ .trim();
30
+ const header = text.match(/\b(Dataset Description|Model Card(?: for [^.]*?)?|Model description|Model Details)\b/i);
31
+ if (header?.index !== undefined && header.index < 160) {
32
+ text = text.slice(header.index + header[0].length).trim();
33
+ }
34
+ if (!text)
35
+ return undefined;
36
+ return text.length > 240 ? `${text.slice(0, 240).trimEnd()}…` : text;
37
+ }
38
+ function hfHref(kind, repo) {
39
+ const prefix = kind === 'dataset' ? 'datasets/' : kind === 'space' ? 'spaces/' : '';
40
+ return `https://huggingface.co/${prefix}${repo}`;
41
+ }
42
+ function HuggingfaceChild({ kind, repo }) {
43
+ const { data, error } = useSWR(`hf:${kind}:${repo}`, () => fetcher(`${API}/${kind}s/${repo}`), {
44
+ revalidateOnFocus: false,
45
+ dedupingInterval: 60_000,
46
+ });
47
+ if (!data && !error) {
48
+ return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
49
+ }
50
+ if (error || !data) {
51
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", repo, "."] }));
52
+ }
53
+ const tags = data.tags ?? [];
54
+ const card = data.cardData ?? {};
55
+ const title = card.pretty_name || card.title || data.id || repo;
56
+ const updated = typeof data.lastModified === 'string' ? data.lastModified.slice(0, 10) : undefined;
57
+ const license = data.license || tagValue(tags, 'license:');
58
+ // pipeline_tag for models, sdk for spaces, size for datasets.
59
+ const meta = [
60
+ data.pipeline_tag,
61
+ data.sdk,
62
+ tagValue(tags, 'size_categories:'),
63
+ license,
64
+ compactNumber(data.downloads) && `↓ ${compactNumber(data.downloads)}`,
65
+ compactNumber(data.likes) && `♥ ${compactNumber(data.likes)}`,
66
+ ].filter(Boolean);
67
+ const freeTags = tags.filter((t) => !t.includes(':')).slice(0, 6);
68
+ const description = cleanDescription(data.description);
69
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "text-sm font-light", children: [_jsx("span", { className: "font-semibold", children: "\uD83E\uDD17 Hugging Face" }), " \u00B7 ", KIND_LABEL[kind], updated && _jsxs("span", { children: [" \u00B7 updated ", updated] }), data.gated && data.gated !== false && _jsx("span", { children: " \u00B7 gated" })] }), _jsxs("div", { className: "mb-1 text-xl font-bold", children: [_jsx("a", { href: hfHref(kind, repo), target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:underline", children: title }), ' ', _jsx("code", { children: repo })] }), description && _jsx("p", { className: "text-md line-clamp-3", children: description }), meta.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-3 mt-3 text-xs font-light", children: meta.map((m) => (_jsx("span", { children: m }, m))) })), freeTags.length > 0 && (_jsx("div", { className: "flex flex-wrap gap-1 mt-2", children: freeTags.map((tag) => (_jsx("span", { className: "text-xs inline-flex items-center px-2 py-0.5 rounded-full border", children: tag }, tag))) }))] }));
70
+ }
71
+ export function HuggingfaceLink({ repo, kind, url, children, className, }) {
72
+ return (_jsx(HoverPopover, { card: _jsx(HuggingfaceChild, { kind: kind, repo: repo }), analytics: { cardKind: 'huggingface_link', properties: { repo, kind } }, children: _jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: cn('hover-link', className), children: children }) }));
73
+ }
@@ -0,0 +1,12 @@
1
+ import { type NodeRenderer, type NodeRenderers } from '@myst-theme/providers';
2
+ export declare const WikiLinkRenderer: NodeRenderer;
3
+ export declare const GithubLinkRenderer: NodeRenderer;
4
+ export declare const RRIDLinkRenderer: NodeRenderer;
5
+ export declare const RORLinkRenderer: NodeRenderer;
6
+ export declare const GEOLinkRenderer: NodeRenderer;
7
+ export declare const FigshareLinkRenderer: NodeRenderer;
8
+ export declare const HuggingfaceLinkRenderer: NodeRenderer;
9
+ export declare const SimpleLink: NodeRenderer;
10
+ export declare const linkBlock: NodeRenderer;
11
+ export declare const MYST_LINK_RENDERERS: NodeRenderers;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/myst/links/index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAML,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,uBAAuB,CAAC;AA4E/B,eAAO,MAAM,gBAAgB,EAAE,YAS9B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAehC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,YAE9B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAE7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAQ7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,YAIlC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,YASrC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,YA2BxB,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,YAqCvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,aAmBjC,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // @curvenote-fork:myst-to-react
3
+ // MIT — https://github.com/jupyter-book/myst-theme (packages/myst-to-react)
4
+ // Baseline v1.1.4: https://github.com/jupyter-book/myst-theme/blob/e2e1db449c87294775717a8924d4dd1a4d32ceb2/packages/myst-to-react/src/links/index.tsx
5
+ // Patched v1.3.0: https://github.com/jupyter-book/myst-theme/blob/be74efbb7d13b926a2a6c1e67913e1b1029f28e6/packages/myst-to-react/src/links/index.tsx
6
+ import { ArrowTopRightOnSquareIcon as ExternalLinkIcon, LinkIcon, ArrowDownTrayIcon, } from '@heroicons/react/24/outline';
7
+ import { isExternalUrl, useLinkProvider, useSiteManifest, useBaseurl, withBaseurl, } from '@myst-theme/providers';
8
+ import { LinkCard, MyST } from 'myst-to-react';
9
+ import { cn } from '@curvenote/react-utils';
10
+ import { HoverPopover } from '../../components/hover-popover';
11
+ import { WikiLink } from './wiki';
12
+ import { RRIDLink } from './rrid';
13
+ import { RORLink } from './ror';
14
+ import { GithubLink } from './github';
15
+ import { GEOLink } from './geo';
16
+ import { FigshareLink } from './figshare';
17
+ import { HuggingfaceLink } from './huggingface';
18
+ function getPageInfo(site, path) {
19
+ if (!site)
20
+ return undefined;
21
+ const [projectSlug, pageSlug] = path.replace(/^\//, '').split('/');
22
+ const project = site.projects?.find((p) => p.slug === projectSlug || (!p.slug && !pageSlug));
23
+ if (!project)
24
+ return undefined;
25
+ return project.pages.find((p) => p.slug === (pageSlug || projectSlug));
26
+ }
27
+ function InternalLink({ url, children, className, }) {
28
+ const Link = useLinkProvider();
29
+ const site = useSiteManifest();
30
+ const page = getPageInfo(site, url);
31
+ const baseurl = useBaseurl();
32
+ const skipPreview = !page || (!page.description && !page.thumbnail);
33
+ if (!page || skipPreview) {
34
+ return (_jsx(Link, { to: withBaseurl(url, baseurl), prefetch: "intent", className: cn('link', className), children: children }));
35
+ }
36
+ return (_jsx(HoverPopover
37
+ // Use a () function rather than directly loading the component.
38
+ // This avoids hydration errors in static builds so that card display works
39
+ // See: https://github.com/jupyter-book/myst-theme/issues/771
40
+ , {
41
+ // Use a () function rather than directly loading the component.
42
+ // This avoids hydration errors in static builds so that card display works
43
+ // See: https://github.com/jupyter-book/myst-theme/issues/771
44
+ card: () => (_jsx(LinkCard, { internal: true, url: url, title: page.title, description: page.description, thumbnail: page.thumbnailOptimized || page.thumbnail })), analytics: {
45
+ cardKind: 'internal_link',
46
+ properties: { url },
47
+ }, children: _jsx("span", { children: _jsx(Link, { to: withBaseurl(url, baseurl), prefetch: "intent", className: cn('hover-link', className), children: children }) }) }));
48
+ }
49
+ export const WikiLinkRenderer = ({ node, className }) => (_jsx(WikiLink, { url: node.url, page: node.data?.page, wiki: node.data?.wiki, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
50
+ export const GithubLinkRenderer = ({ node, className }) => (_jsx(GithubLink, { kind: node.data?.kind, url: node.url, org: node.data?.org, repo: node.data?.repo, raw: node.data?.raw, file: node.data?.file, from: node.data?.from, to: node.data?.to, issue_number: node.data?.issue_number, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
51
+ export const RRIDLinkRenderer = ({ node, className }) => (_jsx(RRIDLink, { rrid: node.data?.rrid, className: cn(node.class, className) }));
52
+ export const RORLinkRenderer = ({ node, className }) => (_jsx(RORLink, { node: node, ror: node.data?.ror, className: cn(node.class, className) }));
53
+ export const GEOLinkRenderer = ({ node, className }) => (_jsx(GEOLink, { accession: node.data?.accession, db: node.data?.db, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
54
+ export const FigshareLinkRenderer = ({ node, className }) => (_jsx(FigshareLink, { id: node.data?.figshare, url: node.url, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
55
+ export const HuggingfaceLinkRenderer = ({ node, className }) => (_jsx(HuggingfaceLink, { repo: node.data?.huggingface, kind: node.data?.hfKind, url: node.url, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
56
+ export const SimpleLink = ({ node, className }) => {
57
+ const config = useSiteManifest();
58
+ const internal = node.internal ?? !isExternalUrl(node.url, config?.options?.internal_domains);
59
+ const isStatic = node.static ?? false;
60
+ if (internal && !isStatic) {
61
+ return (_jsx(InternalLink, { url: node.url, className: cn(node.class, className), children: _jsx(MyST, { ast: node.children }) }));
62
+ }
63
+ return (_jsxs("a", { target: "_blank", rel: "noreferrer", href: node.url, className: cn('link whitespace-nowrap', node.class, className), children: [_jsx("span", { className: "whitespace-normal link-text", children: _jsx(MyST, { ast: node.children }) }), isStatic && _jsx(ArrowDownTrayIcon, { className: "link-icon" }), !isStatic && _jsx(ExternalLinkIcon, { className: "link-icon" })] }));
64
+ };
65
+ export const linkBlock = ({ node, className }) => {
66
+ const iconClass = 'self-center transition-transform flex-none ml-3';
67
+ const containerClass = 'flex-1 p-4 my-5 block border font-normal hover:border-blue-500 dark:hover:border-blue-400 no-underline hover:text-blue-600 dark:hover:text-blue-400 text-gray-600 dark:text-gray-100 border-gray-200 dark:border-gray-500 rounded shadow-sm hover:shadow-lg dark:shadow-neutral-700';
68
+ const config = useSiteManifest();
69
+ const internal = node.internal ?? !isExternalUrl(node.url, config?.options?.internal_domains);
70
+ const nested = (_jsxs("div", { className: "flex h-full align-middle", children: [_jsxs("div", { className: "flex-grow", children: [node.title, _jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: _jsx(MyST, { ast: node.children }) })] }), internal && _jsx(LinkIcon, { width: "1.5rem", height: "1.5rem", className: iconClass }), !internal && _jsx(ExternalLinkIcon, { width: "1.5rem", height: "1.5rem", className: iconClass })] }));
71
+ if (internal) {
72
+ return (_jsx("a", { href: node.url, className: cn(containerClass, className), children: nested }));
73
+ }
74
+ return (_jsx("a", { className: cn(containerClass, className), target: "_blank", rel: "noopener noreferrer", href: node.url, children: nested }));
75
+ };
76
+ export const MYST_LINK_RENDERERS = {
77
+ link: {
78
+ base: SimpleLink,
79
+ 'link[protocol=github]': GithubLinkRenderer,
80
+ 'link[protocol=wiki]': WikiLinkRenderer,
81
+ 'link[protocol=rrid]': RRIDLinkRenderer,
82
+ 'link[protocol=ror]': RORLinkRenderer,
83
+ 'link[protocol=geo]': GEOLinkRenderer,
84
+ 'link[protocol=figshare]': FigshareLinkRenderer,
85
+ 'link[protocol=huggingface]': HuggingfaceLinkRenderer,
86
+ 'link[kind=github]': GithubLinkRenderer,
87
+ 'link[kind=wiki]': WikiLinkRenderer,
88
+ 'link[kind=rrid]': RRIDLinkRenderer,
89
+ 'link[kind=ror]': RORLinkRenderer,
90
+ 'link[kind=geo]': GEOLinkRenderer,
91
+ 'link[kind=figshare]': FigshareLinkRenderer,
92
+ 'link[kind=huggingface]': HuggingfaceLinkRenderer,
93
+ },
94
+ linkBlock,
95
+ };
@@ -0,0 +1,7 @@
1
+ import type { GenericNode } from 'myst-common';
2
+ export declare function RORLink({ node, ror, className, }: {
3
+ node: GenericNode;
4
+ ror: string;
5
+ className?: string;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=ror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ror.d.ts","sourceRoot":"","sources":["../../../src/myst/links/ror.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA8F/C,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,GAAG,EACH,SAAS,GACV,EAAE;IACD,IAAI,EAAE,WAAW,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAgBA"}
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // @curvenote-fork:myst-to-react
3
+ // MIT — https://github.com/jupyter-book/myst-theme (packages/myst-to-react)
4
+ // Baseline v1.1.4: https://github.com/jupyter-book/myst-theme/blob/e2e1db449c87294775717a8924d4dd1a4d32ceb2/packages/myst-to-react/src/links/ror.tsx
5
+ // Patched v1.3.0: https://github.com/jupyter-book/myst-theme/blob/be74efbb7d13b926a2a6c1e67913e1b1029f28e6/packages/myst-to-react/src/links/ror.tsx
6
+ import { useMemo } from 'react';
7
+ import useSWR from 'swr';
8
+ import { RorIcon } from '@scienceicons/react/24/solid';
9
+ import { MyST } from 'myst-to-react';
10
+ import { cn } from '@curvenote/react-utils';
11
+ import { HoverPopover } from '../../components/hover-popover';
12
+ const fetcher = (...args) => fetch(...args).then((res) => {
13
+ if (res.status === 200)
14
+ return res.json();
15
+ throw new Error(`Content returned with status ${res.status}.`);
16
+ });
17
+ function RORChild({ ror }) {
18
+ const { data, error } = useSWR(`https://api.ror.org/v2/organizations/${ror}`, fetcher);
19
+ const name = useMemo(() => data?.names.find((n) => n.types.includes('ror_display'))?.value, [data]);
20
+ const countryName = useMemo(() => data?.locations[0]?.geonames_details.country_name, [data]);
21
+ const links = useMemo(() => data?.links ?? [], [data]);
22
+ const labels = useMemo(() => data?.names.filter((n) => n.types.includes('label')) ?? [], [data]);
23
+ const acronyms = useMemo(() => data?.names.filter((n) => n.types.includes('acronym')) ?? [], [data]);
24
+ if (!data && !error) {
25
+ return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
26
+ }
27
+ if (error) {
28
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", ror, "."] }));
29
+ }
30
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "flex gap-2 items-stretch text-sm font-light", children: [_jsx(RorIcon, { width: "1.25rem", height: "1.25rem", className: "inline-block self-center" }), _jsx("a", { href: `https://ror.org/${ror}`, className: "self-center", target: "_blank", rel: "noopener noreferrer", children: _jsx("code", { children: ror }) })] }), _jsx("div", { className: "mb-4 text-xl font-bold", children: name }), _jsxs("dl", { className: "mb-4 text-sm", children: [countryName && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Country" }), _jsx("dd", { children: countryName })] })), links.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Links" }), links.map(({ type, value }) => (_jsx("dd", { children: _jsx("a", { href: value, children: type === 'wikipedia' ? 'Wikipedia' : value }) }, `${type}-${value}`)))] })), acronyms.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Acronyms" }), acronyms.map(({ value }) => (_jsx("dd", { children: value }, value)))] })), labels.length > 0 && (_jsxs(_Fragment, { children: [_jsx("dt", { children: "Labels" }), labels.map(({ value, lang }) => (_jsxs("dd", { children: [value, lang ? ` (${lang})` : null] }, `${value}-${lang ?? ''}`)))] }))] })] }));
31
+ }
32
+ export function RORLink({ node, ror, className, }) {
33
+ return (_jsx(HoverPopover, { card: _jsx(RORChild, { ror: ror }), analytics: { cardKind: 'ror_link', properties: { ror } }, children: _jsx("a", { href: `https://ror.org/${ror}`, target: "_blank", rel: "noopener noreferrer", className: cn('hover-link', className), children: _jsx(MyST, { ast: node.children }) }) }));
34
+ }
@@ -0,0 +1,5 @@
1
+ export declare function RRIDLink({ rrid, className }: {
2
+ rrid: string;
3
+ className?: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ //# sourceMappingURL=rrid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rrid.d.ts","sourceRoot":"","sources":["../../../src/myst/links/rrid.tsx"],"names":[],"mappings":"AAkFA,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAgBjF"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // @curvenote-fork:myst-to-react
3
+ // MIT — https://github.com/jupyter-book/myst-theme (packages/myst-to-react)
4
+ // Baseline v1.1.4: https://github.com/jupyter-book/myst-theme/blob/e2e1db449c87294775717a8924d4dd1a4d32ceb2/packages/myst-to-react/src/links/rrid.tsx
5
+ // Patched v1.3.0: https://github.com/jupyter-book/myst-theme/blob/be74efbb7d13b926a2a6c1e67913e1b1029f28e6/packages/myst-to-react/src/links/rrid.tsx
6
+ import useSWR from 'swr';
7
+ import { cn } from '@curvenote/react-utils';
8
+ import { HoverPopover } from '../../components/hover-popover';
9
+ const fetcher = (...args) => fetch(...args).then((res) => {
10
+ if (res.status === 200)
11
+ return res.json();
12
+ throw new Error(`Content returned with status ${res.status}.`);
13
+ });
14
+ function RRIDChild({ rrid }) {
15
+ const { data, error } = useSWR(`https://scicrunch.org/resolver/${rrid}.json`, fetcher);
16
+ if (!data && !error) {
17
+ return (_jsx("div", { className: "hover-document article w-[500px] sm:max-w-[500px] animate-pulse", children: "Loading..." }));
18
+ }
19
+ const hit = data?.hits?.hits?.[0];
20
+ if (error || !hit) {
21
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px]", children: ["Error loading ", rrid, "."] }));
22
+ }
23
+ const { name: title, curie, description, supercategory, keywords, types: categories, } = hit?._source?.item ?? {};
24
+ const category = supercategory?.[0]?.name;
25
+ const types = categories?.map(({ name }) => name) ?? [];
26
+ const tags = keywords?.map(({ keyword }) => keyword) ?? [];
27
+ return (_jsxs("div", { className: "hover-document article w-[500px] sm:max-w-[500px] p-3", children: [_jsxs("p", { className: "text-sm font-light", children: ["RRID: ", category] }), _jsxs("div", { className: "mb-4 text-xl font-bold", children: [title, " ", _jsx("code", { children: curie })] }), _jsx("p", { className: "text-md", children: description }), types.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Categories" }), _jsx("div", { className: "flex flex-wrap ml-1", children: types.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase rounded-full border", children: tag }, tag))) })] })), tags.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-2 text-xs font-thin", children: "Tags" }), _jsx("div", { className: "flex flex-wrap ml-1", children: tags.map((tag) => (_jsx("span", { className: "inline-flex items-center px-3 py-1 ml-1 text-xs uppercase rounded-full border", children: tag }, tag))) })] }))] }));
28
+ }
29
+ export function RRIDLink({ rrid, className }) {
30
+ return (_jsx(HoverPopover, { card: _jsx(RRIDChild, { rrid: rrid }), analytics: { cardKind: 'rrid_link', properties: { rrid } }, children: _jsxs("a", { href: `https://scicrunch.org/resolver/${rrid}`, target: "_blank", rel: "noopener noreferrer", className: cn('hover-link', className), children: ["RRID: ", _jsx("cite", { className: "italic", children: rrid })] }) }));
31
+ }
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare function WikiLink({ children, page, url, wiki, className, }: {
3
+ children: ReactNode;
4
+ page: string;
5
+ url: string;
6
+ wiki?: string;
7
+ className?: string;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=wiki.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../../src/myst/links/wiki.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAsEvC,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CAcA"}
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // @curvenote-fork:myst-to-react
3
+ // MIT — https://github.com/jupyter-book/myst-theme (packages/myst-to-react)
4
+ // Baseline v1.1.4: https://github.com/jupyter-book/myst-theme/blob/e2e1db449c87294775717a8924d4dd1a4d32ceb2/packages/myst-to-react/src/links/wiki.tsx
5
+ // Patched v1.3.0: https://github.com/jupyter-book/myst-theme/blob/be74efbb7d13b926a2a6c1e67913e1b1029f28e6/packages/myst-to-react/src/links/wiki.tsx
6
+ import useSWR from 'swr';
7
+ import { ArrowTopRightOnSquareIcon } from '@heroicons/react/24/outline';
8
+ import { LinkCard } from 'myst-to-react';
9
+ import { cn } from '@curvenote/react-utils';
10
+ import { HoverPopover } from '../../components/hover-popover';
11
+ const fetcher = (...args) => fetch(...args).then((res) => {
12
+ if (res.status === 200)
13
+ return res.json();
14
+ throw new Error(`Content returned with status ${res.status}.`);
15
+ });
16
+ const ENGLISH_WIKIPEDIA = 'https://en.wikipedia.org/';
17
+ function createWikiUrl(name, wiki) {
18
+ return `${wiki || ENGLISH_WIKIPEDIA}wiki/${name}`;
19
+ }
20
+ function createWikiApiUrl(name, wiki) {
21
+ return `${wiki || ENGLISH_WIKIPEDIA}api/rest_v1/page/summary/${name}`;
22
+ }
23
+ function WikiTextMark() {
24
+ return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", version: "1.1", id: "svg3400", viewBox: "0 0 500 85", className: "h-4", children: _jsx("g", { transform: "translate(-357.71336,-784.65111)", children: _jsx("path", { fill: "currentColor", d: "m 412.98736,806.72288 c 0,0 -1.468,-2.984 -1.968,-3.976 -3.336,-6.612 -3.264,-6.964 -6.636,-7.408 -0.944,-0.124 -1.432,-0.244 -1.432,-0.712 v -2.092 l 0.284,-0.204 c 6.092,-0.008 19.648,-0.008 19.648,-0.008 l 0.52,0.172 v 2.084 c 0,0.476 -0.34,0.72 -1.032,0.72 l -1.424,0.204 c -3.6,0.28 -3.012,1.752 -0.62,6.516 l 22.708,46.46 0.776,0.212 20.16,-47.844 c 0.7,-1.928 0.592,-3.296 -0.308,-4.1 -0.904,-0.784 -1.54,-1.248 -3.876,-1.344 l -1.892,-0.096 c -0.232,0 -0.452,-0.084 -0.664,-0.24 -0.208,-0.148 -0.316,-0.344 -0.316,-0.58 v -1.992 l 0.288,-0.204 c 5.68,0 22.776,0 22.776,0 l 0.232,0.204 v 1.992 c 0,0.54 -0.308,0.812 -0.916,0.812 -2.984,0.132 -5.196,0.78 -6.628,1.936 -1.436,1.164 -2.556,2.768 -3.36,4.852 0,0 -18.54,42.436 -24.884,56.54 -2.428,4.624 -4.816,4.2 -6.916,-0.132 -4.436,-9.136 -16.928,-36.852 -16.928,-36.852 l -7.592,-14.92 z" }) }) }));
25
+ }
26
+ function WikiChild({ page, wiki, load }) {
27
+ const { data, error } = useSWR(load ? createWikiApiUrl(page, wiki) : null, fetcher);
28
+ const { thumbnail, extract, content_urls } = data ?? {};
29
+ const url = content_urls?.desktop?.page ?? createWikiUrl(page, wiki);
30
+ const image = thumbnail?.source;
31
+ if (error) {
32
+ return (_jsxs("span", { children: [_jsxs("a", { href: url, className: "block text-inherit hover:text-inherit", target: "_blank", rel: "noreferrer", children: [_jsx(ArrowTopRightOnSquareIcon, { width: "1rem", height: "1rem", className: "float-right" }), _jsx(WikiTextMark, {})] }), _jsxs("div", { className: "mt-2", children: ["Error loading \"", page, "\" from wikipedia."] })] }));
33
+ }
34
+ return (_jsx(LinkCard, { loading: !data, url: url, title: _jsx(WikiTextMark, {}), thumbnail: image, description: extract }));
35
+ }
36
+ export function WikiLink({ children, page, url, wiki, className, }) {
37
+ return (_jsx(HoverPopover, { card: ({ load }) => _jsx(WikiChild, { wiki: wiki, page: page, load: load }), analytics: {
38
+ cardKind: 'wiki_link',
39
+ properties: { wikiPage: page, wikiUrl: url },
40
+ }, children: _jsx("a", { href: url, className: cn('hover-link', className), target: "_blank", rel: "noreferrer", children: children }) }));
41
+ }
@@ -0,0 +1,15 @@
1
+ import type { InlineMath, Math } from 'myst-spec';
2
+ import type { GenericNode } from 'myst-common';
3
+ import type { NodeRenderer } from '@myst-theme/providers';
4
+ type MathLike = (InlineMath | Math) & {
5
+ error?: boolean;
6
+ message?: string;
7
+ html?: string;
8
+ children?: GenericNode[];
9
+ };
10
+ declare const MATH_RENDERERS: {
11
+ math: NodeRenderer<MathLike>;
12
+ inlineMath: NodeRenderer<MathLike>;
13
+ };
14
+ export default MATH_RENDERERS;
15
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/myst/math.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAgC1D,KAAK,QAAQ,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B,CAAC;AA6GF,QAAA,MAAM,cAAc;;;CAGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ExclamationCircleIcon } from '@heroicons/react/24/outline';
3
+ import { useIsScrollable } from '@myst-theme/providers';
4
+ import { MyST } from 'myst-to-react';
5
+ import { cn } from '@curvenote/react-utils';
6
+ import { HashLink } from '@curvenote/theme-ui';
7
+ import { InlineError } from '../components/inlineError';
8
+ /** First `image` descendant of a node, if any. */
9
+ function findImage(node) {
10
+ if (node.type === 'image')
11
+ return node;
12
+ for (const child of node.children ?? []) {
13
+ const found = findImage(child);
14
+ if (found)
15
+ return found;
16
+ }
17
+ return undefined;
18
+ }
19
+ const SHOW_ENUMERATOR_FOR_IMAGES = false;
20
+ const mathRenderer = ({ node, className }) => {
21
+ const { ref, isScrollable } = useIsScrollable();
22
+ // No TeX/MathML `value` on the math node: the equation is provided as child content
23
+ // (typically an `inline-graphic`/`graphic` image from JATS). Fall back to the children.
24
+ if (!node.value && node.children?.length) {
25
+ const image = findImage(node);
26
+ if (node.type === 'math') {
27
+ const id = node.html_id || node.identifier || node.key;
28
+ return (_jsxs("div", { id: id, className: cn('flex my-5 group', className), children: [_jsx("div", { className: "flex justify-center grow", children: image ? (_jsx("img", { src: image.url, alt: image.alt ?? '', "data-canonical-url": image.urlSource, className: "max-w-full dark:invert" })) : (_jsx(MyST, { ast: node.children })) }), node.enumerator && SHOW_ENUMERATOR_FOR_IMAGES && (_jsx("div", { className: "relative flex-none self-center pl-2 m-0 text-right select-none", children: _jsxs(HashLink, { id: id, kind: "Equation", className: "text-inherit hover:text-inherit", children: ["(", node.enumerator, ")"] }) }))] }));
29
+ }
30
+ return image ? (_jsx("img", { src: image.url, alt: image.alt ?? '', "data-canonical-url": image.urlSource, className: cn('inline align-[-0.25em] max-h-[1.3em] w-auto mt-0 mb-0 dark:invert', className) })) : (_jsx("span", { className: cn('inline', className), children: _jsx(MyST, { ast: node.children }) }));
31
+ }
32
+ if (node.type === 'math') {
33
+ if (node.error || !node.html) {
34
+ return (_jsxs("pre", { title: node.message, className: className, children: [_jsxs("span", { className: "text-red-500", children: [_jsx(ExclamationCircleIcon, { width: "1rem", height: "1rem", className: "inline mr-1" }), node.message, '\n\n'] }), node.value] }));
35
+ }
36
+ const id = node.html_id || node.identifier || node.key;
37
+ return (_jsxs("div", { id: id, className: cn('flex my-5 group', className), children: [_jsx("div", { ref: ref, tabIndex: isScrollable ? 0 : undefined, role: isScrollable ? 'region' : undefined, "aria-label": isScrollable
38
+ ? node.enumerator
39
+ ? `Equation ${node.enumerator}`
40
+ : 'Mathematical Equation'
41
+ : undefined, dangerouslySetInnerHTML: { __html: node.html }, className: "overflow-x-auto overflow-y-hidden flex-grow" }), node.enumerator && (_jsx("div", { className: "relative flex-none self-center pl-2 m-0 text-right select-none", children: _jsxs(HashLink, { id: id, kind: "Equation", className: "text-inherit hover:text-inherit", children: ["(", node.enumerator, ")"] }) }))] }));
42
+ }
43
+ if (node.error || !node.html) {
44
+ return _jsx(InlineError, { value: node.value, message: node.message, className: className });
45
+ }
46
+ return _jsx("span", { dangerouslySetInnerHTML: { __html: node.html }, className: className });
47
+ // return <Math html={node.html} value={node.value as string} />;
48
+ };
49
+ const MATH_RENDERERS = {
50
+ math: mathRenderer,
51
+ inlineMath: mathRenderer,
52
+ };
53
+ export default MATH_RENDERERS;
@@ -31,8 +31,9 @@ export type OutgoingArticlesDirective = IncomingArticlesDirective & {
31
31
  * @param node
32
32
  * @returns
33
33
  */
34
- export declare function transformArticles(node: GenericParent, { apiUrl, venue }: {
34
+ export declare function transformArticles(node: GenericParent, { apiUrl, venue, fetchHeaders, }: {
35
35
  apiUrl: string;
36
36
  venue?: string;
37
+ fetchHeaders?: Record<string, string>;
37
38
  }): Promise<void[]>;
38
39
  //# sourceMappingURL=articles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"articles.d.ts","sourceRoot":"","sources":["../../src/transforms/articles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;IAC9B,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;IAC9B,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC;IAC3B,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG;IAClE,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,aAAa,EACnB,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,mBA0CtD"}
1
+ {"version":3,"file":"articles.d.ts","sourceRoot":"","sources":["../../src/transforms/articles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;IAC9B,CAAC,iBAAiB,CAAC,CAAC,EAAE,OAAO,CAAC;IAC9B,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC;IACxB,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC;IAC3B,CAAC,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG;IAClE,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,aAAa,EACnB,EACE,MAAM,EACN,KAAK,EACL,YAAY,GACb,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,mBA0C7E"}