@backstage/plugin-techdocs 0.11.2 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -2,30 +2,30 @@ import { createApiRef, createRouteRef, useRouteRef, useApi, configApiRef, create
2
2
  import { ResponseError, NotFoundError } from '@backstage/errors';
3
3
  import { EventSourcePolyfill } from 'event-source-polyfill';
4
4
  import * as React from 'react';
5
- import React__default, { useEffect, useState, useReducer, useRef, useMemo, useCallback } from 'react';
5
+ import React__default, { useEffect, useState, useReducer, useRef, useMemo, useContext, createContext, useCallback } from 'react';
6
6
  import { useCopyToClipboard, useDebounce, useAsyncRetry, useAsync } from 'react-use';
7
7
  import { capitalize } from 'lodash';
8
- import { SubvalueCell, Link, Table, EmptyState, Button, WarningPanel, CodeSnippet, PageWithHeader, Content, ContentHeader, SupportButton, ErrorPage, Progress, ItemCardGrid, ItemCardHeader, HeaderTabs, HeaderLabel, Header, Page, MissingAnnotationEmptyState } from '@backstage/core-components';
9
- import { favoriteEntityIcon, favoriteEntityTooltip, EntityRefLinks, getEntityRelations, formatEntityRefTitle, useEntityListProvider, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, UserListPicker, EntityOwnerPicker, EntityTagPicker, catalogApiRef, useOwnUser, isOwnerOf, EntityRefLink, useEntity } from '@backstage/plugin-catalog-react';
8
+ import { SubvalueCell, Link, Table, EmptyState, Button, WarningPanel, CodeSnippet, PageWithHeader, Content, ContentHeader, SupportButton, ErrorPage, Progress, HeaderLabel, Header, Page, ItemCardGrid, ItemCardHeader, HeaderTabs, MissingAnnotationEmptyState } from '@backstage/core-components';
9
+ import { favoriteEntityIcon, favoriteEntityTooltip, EntityRefLinks, getEntityRelations, formatEntityRefTitle, useEntityListProvider, useStarredEntities, CATALOG_FILTER_EXISTS, EntityListProvider, UserListPicker, EntityOwnerPicker, EntityTagPicker, EntityRefLink, catalogApiRef, useOwnUser, isOwnerOf, useEntity } from '@backstage/plugin-catalog-react';
10
10
  import { RELATION_OWNED_BY } from '@backstage/catalog-model';
11
11
  import ShareIcon from '@material-ui/icons/Share';
12
12
  import { FilteredEntityLayout, FilterContainer, EntityListContainer } from '@backstage/plugin-catalog';
13
- import { makeStyles, ListItemText, ListItem, Divider, createStyles, Button as Button$1, Drawer, Grid, Typography, IconButton, TextField, InputAdornment, CircularProgress, useTheme, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
13
+ import { makeStyles, ListItemText, ListItem, Divider, Grid, TextField, InputAdornment, IconButton, CircularProgress, createStyles, Button as Button$1, Drawer, Typography, useTheme, Card, CardMedia, CardContent, CardActions } from '@material-ui/core';
14
14
  import TextTruncate from 'react-text-truncate';
15
+ import { useNavigate as useNavigate$1, useParams, Routes, Route } from 'react-router-dom';
15
16
  import { scmIntegrationsApiRef } from '@backstage/integration-react';
16
- import { Alert } from '@material-ui/lab';
17
- import { useParams, useNavigate as useNavigate$1, Routes, Route } from 'react-router-dom';
18
17
  import { replaceGitHubUrlType } from '@backstage/integration';
19
18
  import FeedbackOutlinedIcon from '@material-ui/icons/FeedbackOutlined';
20
19
  import ReactDOM from 'react-dom';
21
20
  import parseGitUrl from 'git-url-parse';
22
21
  import DOMPurify from 'dompurify';
23
- import Close from '@material-ui/icons/Close';
24
- import { LazyLog } from 'react-lazylog';
25
22
  import Autocomplete from '@material-ui/lab/Autocomplete';
26
23
  import { SearchContextProvider, useSearch } from '@backstage/plugin-search';
27
24
  import SearchIcon from '@material-ui/icons/Search';
28
25
  import { useNavigate, useOutlet } from 'react-router';
26
+ import { Alert } from '@material-ui/lab';
27
+ import Close from '@material-ui/icons/Close';
28
+ import { LazyLog } from 'react-lazylog';
29
29
  import CodeIcon from '@material-ui/icons/Code';
30
30
 
31
31
  const techdocsStorageApiRef = createApiRef({
@@ -185,7 +185,7 @@ function createCopyDocsUrlAction(copyToClipboard) {
185
185
  fontSize: "small"
186
186
  }),
187
187
  tooltip: "Click to copy documentation link to clipboard",
188
- onClick: () => copyToClipboard(`${window.location.origin}${window.location.pathname.replace(/\/?$/, "/")}${row.resolved.docsUrl}`)
188
+ onClick: () => copyToClipboard(`${window.location.origin}${row.resolved.docsUrl}`)
189
189
  };
190
190
  };
191
191
  }
@@ -388,7 +388,7 @@ const DefaultTechDocsHome = ({
388
388
  }))))));
389
389
  };
390
390
 
391
- const useStyles$1 = makeStyles({
391
+ const useStyles$2 = makeStyles({
392
392
  flexContainer: {
393
393
  flexWrap: "wrap"
394
394
  },
@@ -404,7 +404,7 @@ const DocsResultListItem = ({
404
404
  asLink = true,
405
405
  title
406
406
  }) => {
407
- const classes = useStyles$1();
407
+ const classes = useStyles$2();
408
408
  const TextItem = () => /* @__PURE__ */ React__default.createElement(ListItemText, {
409
409
  className: classes.itemText,
410
410
  primaryTypographyProps: {variant: "h6"},
@@ -465,32 +465,39 @@ const techdocsPlugin = createPlugin({
465
465
  }
466
466
  });
467
467
  const TechdocsPage = techdocsPlugin.provide(createRoutableExtension({
468
+ name: "TechdocsPage",
468
469
  component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.Router),
469
470
  mountPoint: rootRouteRef
470
471
  }));
471
472
  const EntityTechdocsContent = techdocsPlugin.provide(createRoutableExtension({
473
+ name: "EntityTechdocsContent",
472
474
  component: () => Promise.resolve().then(function () { return Router$1; }).then((m) => m.EmbeddedDocsRouter),
473
475
  mountPoint: rootCatalogDocsRouteRef
474
476
  }));
475
477
  const DocsCardGrid$2 = techdocsPlugin.provide(createComponentExtension({
478
+ name: "DocsCardGrid",
476
479
  component: {
477
480
  lazy: () => Promise.resolve().then(function () { return DocsCardGrid$1; }).then((m) => m.DocsCardGrid)
478
481
  }
479
482
  }));
480
483
  const DocsTable = techdocsPlugin.provide(createComponentExtension({
484
+ name: "DocsTable",
481
485
  component: {
482
486
  lazy: () => Promise.resolve().then(function () { return DocsTable$2; }).then((m) => m.DocsTable)
483
487
  }
484
488
  }));
485
489
  const TechDocsCustomHome$2 = techdocsPlugin.provide(createRoutableExtension({
490
+ name: "TechDocsCustomHome",
486
491
  component: () => Promise.resolve().then(function () { return TechDocsCustomHome$1; }).then((m) => m.TechDocsCustomHome),
487
492
  mountPoint: rootRouteRef
488
493
  }));
489
494
  const TechDocsIndexPage$2 = techdocsPlugin.provide(createRoutableExtension({
495
+ name: "TechDocsIndexPage",
490
496
  component: () => Promise.resolve().then(function () { return TechDocsIndexPage$1; }).then((m) => m.TechDocsIndexPage),
491
497
  mountPoint: rootRouteRef
492
498
  }));
493
499
  const TechDocsReaderPage = techdocsPlugin.provide(createRoutableExtension({
500
+ name: "TechDocsReaderPage",
494
501
  component: () => Promise.resolve().then(function () { return TechDocsPage$1; }).then((m) => m.TechDocsPage),
495
502
  mountPoint: rootDocsRouteRef
496
503
  }));
@@ -707,6 +714,19 @@ const injectCss = ({css}) => {
707
714
  };
708
715
  };
709
716
 
717
+ const scrollIntoAnchor = () => {
718
+ return (dom) => {
719
+ setTimeout(() => {
720
+ var _a;
721
+ if (window.location.hash) {
722
+ const hash = window.location.hash.slice(1);
723
+ (_a = dom == null ? void 0 : dom.querySelector(`#${hash}`)) == null ? void 0 : _a.scrollIntoView();
724
+ }
725
+ }, 200);
726
+ return dom;
727
+ };
728
+ };
729
+
710
730
  const transform = async (html, transformers) => {
711
731
  let dom;
712
732
  if (typeof html === "string") {
@@ -722,88 +742,9 @@ const transform = async (html, transformers) => {
722
742
  return dom;
723
743
  };
724
744
 
725
- const useDrawerStyles = makeStyles((theme) => createStyles({
726
- paper: {
727
- width: "100%",
728
- [theme.breakpoints.up("sm")]: {
729
- width: "75%"
730
- },
731
- [theme.breakpoints.up("md")]: {
732
- width: "50%"
733
- },
734
- padding: theme.spacing(2.5)
735
- },
736
- root: {
737
- height: "100%",
738
- overflow: "hidden"
739
- }
740
- }));
741
- const TechDocsBuildLogsDrawerContent = ({
742
- buildLog,
743
- onClose
744
- }) => {
745
- const classes = useDrawerStyles();
746
- return /* @__PURE__ */ React.createElement(Grid, {
747
- container: true,
748
- direction: "column",
749
- className: classes.root,
750
- spacing: 0,
751
- wrap: "nowrap"
752
- }, /* @__PURE__ */ React.createElement(Grid, {
753
- item: true,
754
- container: true,
755
- justifyContent: "space-between",
756
- alignItems: "center",
757
- spacing: 0,
758
- wrap: "nowrap"
759
- }, /* @__PURE__ */ React.createElement(Typography, {
760
- variant: "h5"
761
- }, "Build Details"), /* @__PURE__ */ React.createElement(IconButton, {
762
- key: "dismiss",
763
- title: "Close the drawer",
764
- onClick: onClose,
765
- color: "inherit"
766
- }, /* @__PURE__ */ React.createElement(Close, null))), /* @__PURE__ */ React.createElement(LazyLog, {
767
- text: buildLog.length === 0 ? "Waiting for logs..." : buildLog.join("\n"),
768
- extraLines: 1,
769
- follow: true,
770
- selectableLines: true,
771
- enableSearch: true
772
- }));
773
- };
774
- const TechDocsBuildLogs = ({buildLog}) => {
775
- const classes = useDrawerStyles();
776
- const [open, setOpen] = useState(false);
777
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button$1, {
778
- color: "inherit",
779
- onClick: () => setOpen(true)
780
- }, "Show Build Logs"), /* @__PURE__ */ React.createElement(Drawer, {
781
- classes: {paper: classes.paper},
782
- anchor: "right",
783
- open,
784
- onClose: () => setOpen(false)
785
- }, /* @__PURE__ */ React.createElement(TechDocsBuildLogsDrawerContent, {
786
- buildLog,
787
- onClose: () => setOpen(false)
788
- })));
789
- };
790
-
791
- const TechDocsNotFound = ({errorMessage}) => {
792
- const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
793
- let additionalInfo = "";
794
- if (techdocsBuilder !== "local") {
795
- additionalInfo = "Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance.";
796
- }
797
- return /* @__PURE__ */ React__default.createElement(ErrorPage, {
798
- status: "404",
799
- statusMessage: errorMessage || "Documentation not found",
800
- additionalInfo
801
- });
802
- };
803
-
804
745
  const buildInitialFilters = (legacyPaths, entityId) => {
805
746
  return legacyPaths ? entityId : Object.entries(entityId).reduce((acc, [key, value]) => {
806
- return {...acc, [key]: value.toLocaleLowerCase("en-US")};
747
+ return {...acc, [key]: value == null ? void 0 : value.toLocaleLowerCase("en-US")};
807
748
  }, {});
808
749
  };
809
750
  const TechDocsSearchBar = ({
@@ -912,6 +853,161 @@ const TechDocsSearch = (props) => {
912
853
  }));
913
854
  };
914
855
 
856
+ const useDrawerStyles = makeStyles((theme) => createStyles({
857
+ paper: {
858
+ width: "100%",
859
+ [theme.breakpoints.up("sm")]: {
860
+ width: "75%"
861
+ },
862
+ [theme.breakpoints.up("md")]: {
863
+ width: "50%"
864
+ },
865
+ padding: theme.spacing(2.5)
866
+ },
867
+ root: {
868
+ height: "100%",
869
+ overflow: "hidden"
870
+ }
871
+ }));
872
+ const TechDocsBuildLogsDrawerContent = ({
873
+ buildLog,
874
+ onClose
875
+ }) => {
876
+ const classes = useDrawerStyles();
877
+ return /* @__PURE__ */ React.createElement(Grid, {
878
+ container: true,
879
+ direction: "column",
880
+ className: classes.root,
881
+ spacing: 0,
882
+ wrap: "nowrap"
883
+ }, /* @__PURE__ */ React.createElement(Grid, {
884
+ item: true,
885
+ container: true,
886
+ justifyContent: "space-between",
887
+ alignItems: "center",
888
+ spacing: 0,
889
+ wrap: "nowrap"
890
+ }, /* @__PURE__ */ React.createElement(Typography, {
891
+ variant: "h5"
892
+ }, "Build Details"), /* @__PURE__ */ React.createElement(IconButton, {
893
+ key: "dismiss",
894
+ title: "Close the drawer",
895
+ onClick: onClose,
896
+ color: "inherit"
897
+ }, /* @__PURE__ */ React.createElement(Close, null))), /* @__PURE__ */ React.createElement(LazyLog, {
898
+ text: buildLog.length === 0 ? "Waiting for logs..." : buildLog.join("\n"),
899
+ extraLines: 1,
900
+ follow: true,
901
+ selectableLines: true,
902
+ enableSearch: true
903
+ }));
904
+ };
905
+ const TechDocsBuildLogs = ({buildLog}) => {
906
+ const classes = useDrawerStyles();
907
+ const [open, setOpen] = useState(false);
908
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button$1, {
909
+ color: "inherit",
910
+ onClick: () => setOpen(true)
911
+ }, "Show Build Logs"), /* @__PURE__ */ React.createElement(Drawer, {
912
+ classes: {paper: classes.paper},
913
+ anchor: "right",
914
+ open,
915
+ onClose: () => setOpen(false)
916
+ }, /* @__PURE__ */ React.createElement(TechDocsBuildLogsDrawerContent, {
917
+ buildLog,
918
+ onClose: () => setOpen(false)
919
+ })));
920
+ };
921
+
922
+ const TechDocsNotFound = ({errorMessage}) => {
923
+ const techdocsBuilder = useApi(configApiRef).getOptionalString("techdocs.builder");
924
+ let additionalInfo = "";
925
+ if (techdocsBuilder !== "local") {
926
+ additionalInfo = "Note that techdocs.builder is not set to 'local' in your config, which means this Backstage app will not generate docs if they are not found. Make sure the project's docs are generated and published by some external process (e.g. CI/CD pipeline). Or change techdocs.builder to 'local' to generate docs from this Backstage instance.";
927
+ }
928
+ return /* @__PURE__ */ React__default.createElement(ErrorPage, {
929
+ status: "404",
930
+ statusMessage: errorMessage || "Documentation not found",
931
+ additionalInfo
932
+ });
933
+ };
934
+
935
+ const useStyles$1 = makeStyles(() => ({
936
+ message: {
937
+ wordBreak: "break-word",
938
+ overflowWrap: "anywhere"
939
+ }
940
+ }));
941
+ const TechDocsStateIndicator = () => {
942
+ let StateAlert = null;
943
+ const classes = useStyles$1();
944
+ const {
945
+ state,
946
+ contentReload,
947
+ contentErrorMessage,
948
+ syncErrorMessage,
949
+ buildLog
950
+ } = useTechDocsReader();
951
+ const ReaderProgress = state === "CHECKING" ? /* @__PURE__ */ React__default.createElement(Progress, null) : null;
952
+ if (state === "INITIAL_BUILD") {
953
+ StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
954
+ variant: "outlined",
955
+ severity: "info",
956
+ icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
957
+ size: "24px"
958
+ }),
959
+ action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
960
+ buildLog
961
+ })
962
+ }, "Documentation is accessed for the first time and is being prepared. The subsequent loads are much faster.");
963
+ }
964
+ if (state === "CONTENT_STALE_REFRESHING") {
965
+ StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
966
+ variant: "outlined",
967
+ severity: "info",
968
+ icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
969
+ size: "24px"
970
+ }),
971
+ action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
972
+ buildLog
973
+ })
974
+ }, "A newer version of this documentation is being prepared and will be available shortly.");
975
+ }
976
+ if (state === "CONTENT_STALE_READY") {
977
+ StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
978
+ variant: "outlined",
979
+ severity: "success",
980
+ action: /* @__PURE__ */ React__default.createElement(Button$1, {
981
+ color: "inherit",
982
+ onClick: () => contentReload()
983
+ }, "Refresh")
984
+ }, "A newer version of this documentation is now available, please refresh to view.");
985
+ }
986
+ if (state === "CONTENT_STALE_ERROR") {
987
+ StateAlert = /* @__PURE__ */ React__default.createElement(Alert, {
988
+ variant: "outlined",
989
+ severity: "error",
990
+ action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
991
+ buildLog
992
+ }),
993
+ classes: {message: classes.message}
994
+ }, "Building a newer version of this documentation failed.", " ", syncErrorMessage);
995
+ }
996
+ if (state === "CONTENT_NOT_FOUND") {
997
+ StateAlert = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, syncErrorMessage && /* @__PURE__ */ React__default.createElement(Alert, {
998
+ variant: "outlined",
999
+ severity: "error",
1000
+ action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
1001
+ buildLog
1002
+ }),
1003
+ classes: {message: classes.message}
1004
+ }, "Building a newer version of this documentation failed.", " ", syncErrorMessage), /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
1005
+ errorMessage: contentErrorMessage
1006
+ }));
1007
+ }
1008
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, ReaderProgress, StateAlert);
1009
+ };
1010
+
915
1011
  function calculateDisplayState({
916
1012
  contentLoading,
917
1013
  content,
@@ -1059,46 +1155,46 @@ function useReaderState(kind, namespace, name, path) {
1059
1155
  }
1060
1156
 
1061
1157
  const useStyles = makeStyles((theme) => ({
1062
- message: {
1063
- wordBreak: "break-word",
1064
- overflowWrap: "anywhere"
1065
- },
1066
1158
  searchBar: {
1067
1159
  marginLeft: "20rem",
1068
1160
  maxWidth: "calc(100% - 20rem * 2 - 3rem)",
1069
- marginTop: theme.spacing(1)
1161
+ marginTop: theme.spacing(1),
1162
+ "@media screen and (max-width: 76.1875em)": {
1163
+ marginLeft: "10rem",
1164
+ maxWidth: "calc(100% - 10rem)"
1165
+ }
1070
1166
  }
1071
1167
  }));
1072
- const Reader = ({entityId, onReady, withSearch = true}) => {
1073
- var _a, _b;
1074
- const {kind, namespace, name} = entityId;
1168
+ const TechDocsReaderContext = createContext({});
1169
+ const TechDocsReaderProvider = ({children}) => {
1170
+ const {namespace = "", kind = "", name = "", "*": path} = useParams();
1171
+ const value = useReaderState(kind, namespace, name, path);
1172
+ return /* @__PURE__ */ React__default.createElement(TechDocsReaderContext.Provider, {
1173
+ value
1174
+ }, children);
1175
+ };
1176
+ const withTechDocsReaderProvider = (Component) => (props) => /* @__PURE__ */ React__default.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React__default.createElement(Component, {
1177
+ ...props
1178
+ }));
1179
+ const useTechDocsReader = () => useContext(TechDocsReaderContext);
1180
+ const useTechDocsReaderDom = () => {
1181
+ const navigate = useNavigate$1();
1075
1182
  const theme = useTheme();
1076
- const classes = useStyles();
1077
- const {
1078
- state,
1079
- path,
1080
- contentReload,
1081
- content: rawPage,
1082
- contentErrorMessage,
1083
- syncErrorMessage,
1084
- buildLog
1085
- } = useReaderState(kind, namespace, name, useParams()["*"]);
1086
1183
  const techdocsStorageApi = useApi(techdocsStorageApiRef);
1087
- const [sidebars, setSidebars] = useState();
1088
- const navigate = useNavigate$1();
1089
- const shadowDomRef = useRef(null);
1090
1184
  const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
1185
+ const {namespace = "", kind = "", name = ""} = useParams();
1186
+ const {state, path, content: rawPage} = useTechDocsReader();
1187
+ const [sidebars, setSidebars] = useState();
1188
+ const [dom, setDom] = useState(null);
1091
1189
  const updateSidebarPosition = useCallback(() => {
1092
- if (!!shadowDomRef.current && !!sidebars) {
1093
- const shadowDiv = shadowDomRef.current;
1094
- const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
1095
- const mdTabs = shadowRoot.querySelector(".md-container > .md-tabs");
1096
- sidebars.forEach((sidebar) => {
1097
- const newTop = Math.max(shadowDomRef.current.getBoundingClientRect().top, 0);
1098
- sidebar.style.top = mdTabs ? `${newTop + mdTabs.getBoundingClientRect().height}px` : `${newTop}px`;
1099
- });
1100
- }
1101
- }, [shadowDomRef, sidebars]);
1190
+ if (!dom || !sidebars)
1191
+ return;
1192
+ const mdTabs = dom.querySelector(".md-container > .md-tabs");
1193
+ sidebars.forEach((sidebar) => {
1194
+ const newTop = Math.max(dom.getBoundingClientRect().top, 0);
1195
+ sidebar.style.top = mdTabs ? `${newTop + mdTabs.getBoundingClientRect().height}px` : `${newTop}px`;
1196
+ });
1197
+ }, [dom, sidebars]);
1102
1198
  useEffect(() => {
1103
1199
  updateSidebarPosition();
1104
1200
  window.addEventListener("scroll", updateSidebarPosition, true);
@@ -1125,106 +1221,106 @@ const Reader = ({entityId, onReady, withSearch = true}) => {
1125
1221
  addGitFeedbackLink(scmIntegrationsApi),
1126
1222
  injectCss({
1127
1223
  css: `
1128
- body {
1129
- font-family: ${theme.typography.fontFamily};
1130
- --md-text-color: ${theme.palette.text.primary};
1131
- --md-text-link-color: ${theme.palette.primary.main};
1224
+ body {
1225
+ font-family: ${theme.typography.fontFamily};
1226
+ --md-text-color: ${theme.palette.text.primary};
1227
+ --md-text-link-color: ${theme.palette.primary.main};
1132
1228
 
1133
- --md-code-fg-color: ${theme.palette.text.primary};
1134
- --md-code-bg-color: ${theme.palette.background.paper};
1135
- }
1136
- .md-main__inner { margin-top: 0; }
1137
- .md-sidebar { position: fixed; bottom: 100px; width: 20rem; }
1138
- .md-sidebar--secondary { right: 2rem; }
1139
- .md-content { margin-bottom: 50px }
1140
- .md-footer { position: fixed; bottom: 0px; width: 100vw; }
1141
- .md-footer-nav__link { width: 20rem;}
1142
- .md-content { margin-left: 20rem; max-width: calc(100% - 20rem * 2 - 3rem); }
1143
- .md-typeset { font-size: 1rem; }
1144
- .md-nav { font-size: 1rem; }
1145
- .md-grid { max-width: 90vw; margin: 0 }
1146
- .md-typeset table:not([class]) {
1147
- font-size: 1rem;
1148
- border: 1px solid ${theme.palette.text.primary};
1149
- border-bottom: none;
1150
- border-collapse: collapse;
1151
- }
1152
- .md-typeset table:not([class]) td, .md-typeset table:not([class]) th {
1153
- border-bottom: 1px solid ${theme.palette.text.primary};
1154
- }
1155
- .md-typeset table:not([class]) th { font-weight: bold; }
1156
- .md-typeset .admonition, .md-typeset details {
1157
- font-size: 1rem;
1158
- }
1159
- @media screen and (max-width: 76.1875em) {
1160
- .md-nav {
1161
- background-color: ${theme.palette.background.default};
1162
- transition: none !important
1229
+ --md-code-fg-color: ${theme.palette.text.primary};
1230
+ --md-code-bg-color: ${theme.palette.background.paper};
1163
1231
  }
1164
- .md-sidebar--secondary { display: none; }
1165
- .md-sidebar--primary { left: 72px; width: 10rem }
1166
- .md-content { margin-left: 10rem; max-width: calc(100% - 10rem); }
1167
- .md-content__inner { font-size: 0.9rem }
1168
- .md-footer {
1169
- position: static;
1170
- margin-left: 10rem;
1171
- width: calc(100% - 10rem);
1232
+ .md-main__inner { margin-top: 0; }
1233
+ .md-sidebar { position: fixed; bottom: 100px; width: 20rem; }
1234
+ .md-sidebar--secondary { right: 2rem; }
1235
+ .md-content { margin-bottom: 50px }
1236
+ .md-footer { position: fixed; bottom: 0px; width: 100vw; }
1237
+ .md-footer-nav__link { width: 20rem;}
1238
+ .md-content { margin-left: 20rem; max-width: calc(100% - 20rem * 2 - 3rem); }
1239
+ .md-typeset { font-size: 1rem; }
1240
+ .md-nav { font-size: 1rem; }
1241
+ .md-grid { max-width: 90vw; margin: 0 }
1242
+ .md-typeset table:not([class]) {
1243
+ font-size: 1rem;
1244
+ border: 1px solid ${theme.palette.text.primary};
1245
+ border-bottom: none;
1246
+ border-collapse: collapse;
1172
1247
  }
1173
- .md-nav--primary .md-nav__title {
1174
- white-space: normal;
1175
- height: auto;
1176
- line-height: 1rem;
1177
- cursor: auto;
1248
+ .md-typeset table:not([class]) td, .md-typeset table:not([class]) th {
1249
+ border-bottom: 1px solid ${theme.palette.text.primary};
1178
1250
  }
1179
- .md-nav--primary > .md-nav__title [for="none"] {
1180
- padding-top: 0;
1251
+ .md-typeset table:not([class]) th { font-weight: bold; }
1252
+ .md-typeset .admonition, .md-typeset details {
1253
+ font-size: 1rem;
1181
1254
  }
1182
- }
1183
- `
1255
+ @media screen and (max-width: 76.1875em) {
1256
+ .md-nav {
1257
+ background-color: ${theme.palette.background.default};
1258
+ transition: none !important
1259
+ }
1260
+ .md-sidebar--secondary { display: none; }
1261
+ .md-sidebar--primary { left: 72px; width: 10rem }
1262
+ .md-content { margin-left: 10rem; max-width: calc(100% - 10rem); }
1263
+ .md-content__inner { font-size: 0.9rem }
1264
+ .md-footer {
1265
+ position: static;
1266
+ margin-left: 10rem;
1267
+ width: calc(100% - 10rem);
1268
+ }
1269
+ .md-nav--primary .md-nav__title {
1270
+ white-space: normal;
1271
+ height: auto;
1272
+ line-height: 1rem;
1273
+ cursor: auto;
1274
+ }
1275
+ .md-nav--primary > .md-nav__title [for="none"] {
1276
+ padding-top: 0;
1277
+ }
1278
+ }
1279
+ `
1184
1280
  }),
1185
1281
  injectCss({
1186
1282
  css: `
1187
- .md-nav__link, .md-typeset a, .md-typeset a::before, .md-typeset .headerlink {
1188
- transition: none;
1189
- }
1190
- `
1283
+ .md-nav__link, .md-typeset a, .md-typeset a::before, .md-typeset .headerlink {
1284
+ transition: none;
1285
+ }
1286
+ `
1191
1287
  }),
1192
1288
  injectCss({
1193
1289
  css: `
1194
- .md-typeset pre > code::-webkit-scrollbar-thumb {
1195
- background-color: hsla(0, 0%, 0%, 0.32);
1196
- }
1197
- .md-typeset pre > code::-webkit-scrollbar-thumb:hover {
1198
- background-color: hsla(0, 0%, 0%, 0.87);
1199
- }
1290
+ .md-typeset pre > code::-webkit-scrollbar-thumb {
1291
+ background-color: hsla(0, 0%, 0%, 0.32);
1292
+ }
1293
+ .md-typeset pre > code::-webkit-scrollbar-thumb:hover {
1294
+ background-color: hsla(0, 0%, 0%, 0.87);
1295
+ }
1200
1296
  `
1201
1297
  }),
1202
1298
  injectCss({
1203
1299
  css: `
1204
- :host {
1205
- --md-admonition-icon--note: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>');
1206
- --md-admonition-icon--abstract: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 5h16v2H4V5m0 4h16v2H4V9m0 4h16v2H4v-2m0 4h10v2H4v-2z"/></svg>');
1207
- --md-admonition-icon--info: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
1208
- --md-admonition-icon--tip: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.55 11.2c-.23-.3-.5-.56-.76-.82-.65-.6-1.4-1.03-2.03-1.66C13.3 7.26 13 4.85 13.91 3c-.91.23-1.75.75-2.45 1.32-2.54 2.08-3.54 5.75-2.34 8.9.04.1.08.2.08.33 0 .22-.15.42-.35.5-.22.1-.46.04-.64-.12a.83.83 0 01-.15-.17c-1.1-1.43-1.28-3.48-.53-5.12C5.89 10 5 12.3 5.14 14.47c.04.5.1 1 .27 1.5.14.6.4 1.2.72 1.73 1.04 1.73 2.87 2.97 4.84 3.22 2.1.27 4.35-.12 5.96-1.6 1.8-1.66 2.45-4.32 1.5-6.6l-.13-.26c-.2-.46-.47-.87-.8-1.25l.05-.01m-3.1 6.3c-.28.24-.73.5-1.08.6-1.1.4-2.2-.16-2.87-.82 1.19-.28 1.89-1.16 2.09-2.05.17-.8-.14-1.46-.27-2.23-.12-.74-.1-1.37.18-2.06.17.38.37.76.6 1.06.76 1 1.95 1.44 2.2 2.8.04.14.06.28.06.43.03.82-.32 1.72-.92 2.27h.01z"/></svg>');
1209
- --md-admonition-icon--success: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
1210
- --md-admonition-icon--question: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.07 11.25l-.9.92C13.45 12.89 13 13.5 13 15h-2v-.5c0-1.11.45-2.11 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41a2 2 0 00-2-2 2 2 0 00-2 2H8a4 4 0 014-4 4 4 0 014 4 3.2 3.2 0 01-.93 2.25M13 19h-2v-2h2M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10c0-5.53-4.5-10-10-10z"/></svg>');
1211
- --md-admonition-icon--warning: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z"/></svg>');
1212
- --md-admonition-icon--failure: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2c5.53 0 10 4.47 10 10s-4.47 10-10 10S2 17.53 2 12 6.47 2 12 2m3.59 5L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41 15.59 7z"/></svg>');
1213
- --md-admonition-icon--danger: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.5 20l4.86-9.73H13V4l-5 9.73h3.5V20M12 2c2.75 0 5.1 1 7.05 2.95C21 6.9 22 9.25 22 12s-1 5.1-2.95 7.05C17.1 21 14.75 22 12 22s-5.1-1-7.05-2.95C3 17.1 2 14.75 2 12s1-5.1 2.95-7.05C6.9 3 9.25 2 12 2z"/></svg>');
1214
- --md-admonition-icon--bug: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 12h-4v-2h4m0 6h-4v-2h4m6-6h-2.81a5.985 5.985 0 00-1.82-1.96L17 4.41 15.59 3l-2.17 2.17a6.002 6.002 0 00-2.83 0L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8z"/></svg>');
1215
- --md-admonition-icon--example: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.25-7a.75.75 0 01.75.75c0 .2-.08.39-.21.52L3.12 13H5v1H2v-.92L4 11H2v-1h2.25z"/></svg>');
1216
- --md-admonition-icon--quote: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 17h3l2-4V7h-6v6h3M6 17h3l2-4V7H5v6h3l-2 4z"/></svg>');
1217
- }
1218
- :host {
1219
- --md-footnotes-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.42L5.83 13H21V7h-2z"/></svg>');
1220
- }
1221
- :host {
1222
- --md-details-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.58L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.42z"/></svg>');
1223
- }
1224
- :host {
1225
- --md-tasklist-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
1226
- --md-tasklist-icon--checked: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
1227
- }
1300
+ :host {
1301
+ --md-admonition-icon--note: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83 3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z"/></svg>');
1302
+ --md-admonition-icon--abstract: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 5h16v2H4V5m0 4h16v2H4V9m0 4h16v2H4v-2m0 4h10v2H4v-2z"/></svg>');
1303
+ --md-admonition-icon--info: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
1304
+ --md-admonition-icon--tip: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M17.55 11.2c-.23-.3-.5-.56-.76-.82-.65-.6-1.4-1.03-2.03-1.66C13.3 7.26 13 4.85 13.91 3c-.91.23-1.75.75-2.45 1.32-2.54 2.08-3.54 5.75-2.34 8.9.04.1.08.2.08.33 0 .22-.15.42-.35.5-.22.1-.46.04-.64-.12a.83.83 0 01-.15-.17c-1.1-1.43-1.28-3.48-.53-5.12C5.89 10 5 12.3 5.14 14.47c.04.5.1 1 .27 1.5.14.6.4 1.2.72 1.73 1.04 1.73 2.87 2.97 4.84 3.22 2.1.27 4.35-.12 5.96-1.6 1.8-1.66 2.45-4.32 1.5-6.6l-.13-.26c-.2-.46-.47-.87-.8-1.25l.05-.01m-3.1 6.3c-.28.24-.73.5-1.08.6-1.1.4-2.2-.16-2.87-.82 1.19-.28 1.89-1.16 2.09-2.05.17-.8-.14-1.46-.27-2.23-.12-.74-.1-1.37.18-2.06.17.38.37.76.6 1.06.76 1 1.95 1.44 2.2 2.8.04.14.06.28.06.43.03.82-.32 1.72-.92 2.27h.01z"/></svg>');
1305
+ --md-admonition-icon--success: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
1306
+ --md-admonition-icon--question: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M15.07 11.25l-.9.92C13.45 12.89 13 13.5 13 15h-2v-.5c0-1.11.45-2.11 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41a2 2 0 00-2-2 2 2 0 00-2 2H8a4 4 0 014-4 4 4 0 014 4 3.2 3.2 0 01-.93 2.25M13 19h-2v-2h2M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10c0-5.53-4.5-10-10-10z"/></svg>');
1307
+ --md-admonition-icon--warning: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 14h-2v-4h2m0 8h-2v-2h2M1 21h22L12 2 1 21z"/></svg>');
1308
+ --md-admonition-icon--failure: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2c5.53 0 10 4.47 10 10s-4.47 10-10 10S2 17.53 2 12 6.47 2 12 2m3.59 5L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41 15.59 7z"/></svg>');
1309
+ --md-admonition-icon--danger: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11.5 20l4.86-9.73H13V4l-5 9.73h3.5V20M12 2c2.75 0 5.1 1 7.05 2.95C21 6.9 22 9.25 22 12s-1 5.1-2.95 7.05C17.1 21 14.75 22 12 22s-5.1-1-7.05-2.95C3 17.1 2 14.75 2 12s1-5.1 2.95-7.05C6.9 3 9.25 2 12 2z"/></svg>');
1310
+ --md-admonition-icon--bug: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 12h-4v-2h4m0 6h-4v-2h4m6-6h-2.81a5.985 5.985 0 00-1.82-1.96L17 4.41 15.59 3l-2.17 2.17a6.002 6.002 0 00-2.83 0L8.41 3 7 4.41l1.62 1.63C7.88 6.55 7.26 7.22 6.81 8H4v2h2.09c-.05.33-.09.66-.09 1v1H4v2h2v1c0 .34.04.67.09 1H4v2h2.81c1.04 1.79 2.97 3 5.19 3s4.15-1.21 5.19-3H20v-2h-2.09c.05-.33.09-.66.09-1v-1h2v-2h-2v-1c0-.34-.04-.67-.09-1H20V8z"/></svg>');
1311
+ --md-admonition-icon--example: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.25-7a.75.75 0 01.75.75c0 .2-.08.39-.21.52L3.12 13H5v1H2v-.92L4 11H2v-1h2.25z"/></svg>');
1312
+ --md-admonition-icon--quote: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 17h3l2-4V7h-6v6h3M6 17h3l2-4V7H5v6h3l-2 4z"/></svg>');
1313
+ }
1314
+ :host {
1315
+ --md-footnotes-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.42L5.83 13H21V7h-2z"/></svg>');
1316
+ }
1317
+ :host {
1318
+ --md-details-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M8.59 16.58L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.42z"/></svg>');
1319
+ }
1320
+ :host {
1321
+ --md-tasklist-icon: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2A10 10 0 002 12a10 10 0 0010 10 10 10 0 0010-10A10 10 0 0012 2z"/></svg>');
1322
+ --md-tasklist-icon--checked: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2m-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>');
1323
+ }
1228
1324
  `
1229
1325
  })
1230
1326
  ]), [
@@ -1239,25 +1335,16 @@ const Reader = ({entityId, onReady, withSearch = true}) => {
1239
1335
  theme.palette.text.primary,
1240
1336
  theme.typography.fontFamily
1241
1337
  ]);
1242
- const postRender = useCallback(async (shadowRoot) => transform(shadowRoot.children[0], [
1243
- (dom) => {
1244
- setTimeout(() => {
1245
- var _a2;
1246
- if (window.location.hash) {
1247
- const hash = window.location.hash.slice(1);
1248
- (_a2 = shadowRoot == null ? void 0 : shadowRoot.getElementById(hash)) == null ? void 0 : _a2.scrollIntoView();
1249
- }
1250
- }, 200);
1251
- return dom;
1252
- },
1338
+ const postRender = useCallback(async (transformedElement) => transform(transformedElement, [
1339
+ scrollIntoAnchor(),
1253
1340
  addLinkClickListener({
1254
1341
  baseUrl: window.location.origin,
1255
1342
  onClick: (_, url) => {
1256
- var _a2;
1343
+ var _a;
1257
1344
  const parsedUrl = new URL(url);
1258
1345
  if (parsedUrl.hash) {
1259
1346
  navigate(`${parsedUrl.pathname}${parsedUrl.hash}`);
1260
- (_a2 = shadowRoot == null ? void 0 : shadowRoot.getElementById(parsedUrl.hash.slice(1))) == null ? void 0 : _a2.scrollIntoView();
1347
+ (_a = transformedElement == null ? void 0 : transformedElement.querySelector(`#${parsedUrl.hash.slice(1)}`)) == null ? void 0 : _a.scrollIntoView();
1261
1348
  } else {
1262
1349
  navigate(parsedUrl.pathname);
1263
1350
  }
@@ -1265,105 +1352,207 @@ const Reader = ({entityId, onReady, withSearch = true}) => {
1265
1352
  }),
1266
1353
  onCssReady({
1267
1354
  docStorageUrl: await techdocsStorageApi.getApiOrigin(),
1268
- onLoading: (dom) => {
1269
- dom.style.setProperty("opacity", "0");
1355
+ onLoading: (renderedElement) => {
1356
+ renderedElement.style.setProperty("opacity", "0");
1270
1357
  },
1271
- onLoaded: (dom) => {
1272
- var _a2;
1273
- dom.style.removeProperty("opacity");
1274
- (_a2 = dom.querySelector(".md-nav__title")) == null ? void 0 : _a2.removeAttribute("for");
1275
- const sideDivs = Array.from(shadowRoot.querySelectorAll(".md-sidebar"));
1276
- setSidebars(sideDivs);
1277
- const docTopPosition = dom.getBoundingClientRect().top;
1278
- const mdTabs = dom.querySelector(".md-container > .md-tabs");
1279
- sideDivs.forEach((sidebar) => {
1280
- sidebar.style.top = mdTabs ? `${docTopPosition + mdTabs.getBoundingClientRect().height}px` : `${docTopPosition}px`;
1281
- });
1358
+ onLoaded: (renderedElement) => {
1359
+ var _a;
1360
+ renderedElement.style.removeProperty("opacity");
1361
+ (_a = renderedElement.querySelector(".md-nav__title")) == null ? void 0 : _a.removeAttribute("for");
1362
+ setSidebars(Array.from(renderedElement.querySelectorAll(".md-sidebar")));
1282
1363
  }
1283
1364
  })
1284
1365
  ]), [navigate, techdocsStorageApi]);
1285
1366
  useEffect(() => {
1286
- var _a2;
1287
- if (!rawPage || !shadowDomRef.current) {
1288
- if ((_a2 = shadowDomRef.current) == null ? void 0 : _a2.shadowRoot) {
1289
- shadowDomRef.current.shadowRoot.innerHTML = "";
1290
- }
1367
+ if (!rawPage)
1291
1368
  return () => {
1292
1369
  };
1293
- }
1294
- if (onReady) {
1295
- onReady();
1296
- }
1297
1370
  let shouldReplaceContent = true;
1298
- preRender(rawPage, path).then(async (transformedElement) => {
1299
- if (!(transformedElement == null ? void 0 : transformedElement.innerHTML)) {
1371
+ preRender(rawPage, path).then(async (preTransformedDomElement) => {
1372
+ if (!(preTransformedDomElement == null ? void 0 : preTransformedDomElement.innerHTML)) {
1300
1373
  return;
1301
1374
  }
1302
1375
  if (!shouldReplaceContent) {
1303
1376
  return;
1304
1377
  }
1305
- const shadowDiv = shadowDomRef.current;
1306
- const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
1307
- Array.from(shadowRoot.children).forEach((child) => shadowRoot.removeChild(child));
1308
- shadowRoot.appendChild(transformedElement);
1309
1378
  window.scroll({top: 0});
1310
- await postRender(shadowRoot);
1379
+ const postTransformedDomElement = await postRender(preTransformedDomElement);
1380
+ setDom(postTransformedDomElement);
1311
1381
  });
1312
1382
  return () => {
1313
1383
  shouldReplaceContent = false;
1314
1384
  };
1315
- }, [onReady, path, postRender, preRender, rawPage]);
1316
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, state === "CHECKING" && /* @__PURE__ */ React__default.createElement(Progress, null), state === "INITIAL_BUILD" && /* @__PURE__ */ React__default.createElement(Alert, {
1317
- variant: "outlined",
1318
- severity: "info",
1319
- icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
1320
- size: "24px"
1321
- }),
1322
- action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
1323
- buildLog
1324
- })
1325
- }, "Documentation is accessed for the first time and is being prepared. The subsequent loads are much faster."), state === "CONTENT_STALE_REFRESHING" && /* @__PURE__ */ React__default.createElement(Alert, {
1326
- variant: "outlined",
1327
- severity: "info",
1328
- icon: /* @__PURE__ */ React__default.createElement(CircularProgress, {
1329
- size: "24px"
1330
- }),
1331
- action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
1332
- buildLog
1333
- })
1334
- }, "A newer version of this documentation is being prepared and will be available shortly."), state === "CONTENT_STALE_READY" && /* @__PURE__ */ React__default.createElement(Alert, {
1335
- variant: "outlined",
1336
- severity: "success",
1337
- action: /* @__PURE__ */ React__default.createElement(Button$1, {
1338
- color: "inherit",
1339
- onClick: () => contentReload()
1340
- }, "Refresh")
1341
- }, "A newer version of this documentation is now available, please refresh to view."), state === "CONTENT_STALE_ERROR" && /* @__PURE__ */ React__default.createElement(Alert, {
1342
- variant: "outlined",
1343
- severity: "error",
1344
- action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
1345
- buildLog
1346
- }),
1347
- classes: {message: classes.message}
1348
- }, "Building a newer version of this documentation failed.", " ", syncErrorMessage), state === "CONTENT_NOT_FOUND" && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, syncErrorMessage && /* @__PURE__ */ React__default.createElement(Alert, {
1349
- variant: "outlined",
1350
- severity: "error",
1351
- action: /* @__PURE__ */ React__default.createElement(TechDocsBuildLogs, {
1352
- buildLog
1353
- }),
1354
- classes: {message: classes.message}
1355
- }, "Building a newer version of this documentation failed.", " ", syncErrorMessage), /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
1356
- errorMessage: contentErrorMessage
1357
- })), withSearch && ((_b = (_a = shadowDomRef == null ? void 0 : shadowDomRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.innerHTML) && /* @__PURE__ */ React__default.createElement(Grid, {
1385
+ }, [rawPage, path, preRender, postRender]);
1386
+ return dom;
1387
+ };
1388
+ const TheReader = ({
1389
+ entityRef,
1390
+ onReady = () => {
1391
+ },
1392
+ withSearch = true
1393
+ }) => {
1394
+ var _a, _b;
1395
+ const classes = useStyles();
1396
+ const dom = useTechDocsReaderDom();
1397
+ const shadowDomRef = useRef(null);
1398
+ useEffect(() => {
1399
+ if (!dom || !shadowDomRef.current)
1400
+ return;
1401
+ const shadowDiv = shadowDomRef.current;
1402
+ const shadowRoot = shadowDiv.shadowRoot || shadowDiv.attachShadow({mode: "open"});
1403
+ Array.from(shadowRoot.children).forEach((child) => shadowRoot.removeChild(child));
1404
+ shadowRoot.appendChild(dom);
1405
+ onReady();
1406
+ }, [dom, onReady]);
1407
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(TechDocsStateIndicator, null), withSearch && ((_b = (_a = shadowDomRef == null ? void 0 : shadowDomRef.current) == null ? void 0 : _a.shadowRoot) == null ? void 0 : _b.innerHTML) && /* @__PURE__ */ React__default.createElement(Grid, {
1358
1408
  container: true,
1359
1409
  className: classes.searchBar
1360
1410
  }, /* @__PURE__ */ React__default.createElement(TechDocsSearch, {
1361
- entityId
1411
+ entityId: entityRef
1362
1412
  })), /* @__PURE__ */ React__default.createElement("div", {
1363
1413
  "data-testid": "techdocs-content-shadowroot",
1364
1414
  ref: shadowDomRef
1365
1415
  }));
1366
1416
  };
1417
+ const Reader = ({
1418
+ entityRef,
1419
+ onReady = () => {
1420
+ },
1421
+ withSearch = true
1422
+ }) => /* @__PURE__ */ React__default.createElement(TechDocsReaderProvider, null, /* @__PURE__ */ React__default.createElement(TheReader, {
1423
+ entityRef,
1424
+ onReady,
1425
+ withSearch
1426
+ }));
1427
+
1428
+ const TechDocsPageHeader = ({
1429
+ entityRef,
1430
+ entityMetadata,
1431
+ techDocsMetadata
1432
+ }) => {
1433
+ const {name} = entityRef;
1434
+ const {site_name: siteName, site_description: siteDescription} = techDocsMetadata || {};
1435
+ const {locationMetadata, spec} = entityMetadata || {};
1436
+ const lifecycle = spec == null ? void 0 : spec.lifecycle;
1437
+ const ownedByRelations = entityMetadata ? getEntityRelations(entityMetadata, RELATION_OWNED_BY) : [];
1438
+ const docsRootLink = useRouteRef(rootRouteRef)();
1439
+ const labels = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1440
+ label: "Component",
1441
+ value: /* @__PURE__ */ React__default.createElement(EntityRefLink, {
1442
+ color: "inherit",
1443
+ entityRef,
1444
+ defaultKind: "Component"
1445
+ })
1446
+ }), ownedByRelations.length > 0 && /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1447
+ label: "Owner",
1448
+ value: /* @__PURE__ */ React__default.createElement(EntityRefLinks, {
1449
+ color: "inherit",
1450
+ entityRefs: ownedByRelations,
1451
+ defaultKind: "group"
1452
+ })
1453
+ }), lifecycle ? /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1454
+ label: "Lifecycle",
1455
+ value: lifecycle
1456
+ }) : null, locationMetadata && locationMetadata.type !== "dir" && locationMetadata.type !== "file" ? /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1457
+ label: "",
1458
+ value: /* @__PURE__ */ React__default.createElement("a", {
1459
+ href: locationMetadata.target,
1460
+ target: "_blank",
1461
+ rel: "noopener noreferrer"
1462
+ }, /* @__PURE__ */ React__default.createElement(CodeIcon, {
1463
+ style: {marginTop: "-25px", fill: "#fff"}
1464
+ }))
1465
+ }) : null);
1466
+ return /* @__PURE__ */ React__default.createElement(Header, {
1467
+ title: siteName ? siteName : ".",
1468
+ pageTitleOverride: siteName || name,
1469
+ subtitle: siteDescription && siteDescription !== "None" ? siteDescription : "",
1470
+ type: "Docs",
1471
+ typeLink: docsRootLink
1472
+ }, labels);
1473
+ };
1474
+
1475
+ const LegacyTechDocsPage = () => {
1476
+ const [documentReady, setDocumentReady] = useState(false);
1477
+ const {namespace, kind, name} = useParams();
1478
+ const techdocsApi = useApi(techdocsApiRef);
1479
+ const {value: techdocsMetadataValue} = useAsync(() => {
1480
+ if (documentReady) {
1481
+ return techdocsApi.getTechDocsMetadata({kind, namespace, name});
1482
+ }
1483
+ return Promise.resolve(void 0);
1484
+ }, [kind, namespace, name, techdocsApi, documentReady]);
1485
+ const {value: entityMetadataValue, error: entityMetadataError} = useAsync(() => {
1486
+ return techdocsApi.getEntityMetadata({kind, namespace, name});
1487
+ }, [kind, namespace, name, techdocsApi]);
1488
+ const onReady = useCallback(() => {
1489
+ setDocumentReady(true);
1490
+ }, [setDocumentReady]);
1491
+ if (entityMetadataError) {
1492
+ return /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
1493
+ errorMessage: entityMetadataError.message
1494
+ });
1495
+ }
1496
+ return /* @__PURE__ */ React__default.createElement(Page, {
1497
+ themeId: "documentation"
1498
+ }, /* @__PURE__ */ React__default.createElement(TechDocsPageHeader, {
1499
+ techDocsMetadata: techdocsMetadataValue,
1500
+ entityMetadata: entityMetadataValue,
1501
+ entityRef: {
1502
+ kind,
1503
+ namespace,
1504
+ name
1505
+ }
1506
+ }), /* @__PURE__ */ React__default.createElement(Content, {
1507
+ "data-testid": "techdocs-content"
1508
+ }, /* @__PURE__ */ React__default.createElement(Reader, {
1509
+ onReady,
1510
+ entityRef: {
1511
+ kind,
1512
+ namespace,
1513
+ name
1514
+ }
1515
+ })));
1516
+ };
1517
+
1518
+ const TechDocsPage = ({children}) => {
1519
+ const outlet = useOutlet();
1520
+ const [documentReady, setDocumentReady] = useState(false);
1521
+ const {namespace, kind, name} = useParams();
1522
+ const techdocsApi = useApi(techdocsApiRef);
1523
+ const {value: techdocsMetadataValue} = useAsync(() => {
1524
+ if (documentReady) {
1525
+ return techdocsApi.getTechDocsMetadata({kind, namespace, name});
1526
+ }
1527
+ return Promise.resolve(void 0);
1528
+ }, [kind, namespace, name, techdocsApi, documentReady]);
1529
+ const {value: entityMetadataValue, error: entityMetadataError} = useAsync(() => {
1530
+ return techdocsApi.getEntityMetadata({kind, namespace, name});
1531
+ }, [kind, namespace, name, techdocsApi]);
1532
+ const onReady = useCallback(() => {
1533
+ setDocumentReady(true);
1534
+ }, [setDocumentReady]);
1535
+ if (entityMetadataError) {
1536
+ return /* @__PURE__ */ React__default.createElement(TechDocsNotFound, {
1537
+ errorMessage: entityMetadataError.message
1538
+ });
1539
+ }
1540
+ if (!children)
1541
+ return outlet || /* @__PURE__ */ React__default.createElement(LegacyTechDocsPage, null);
1542
+ return /* @__PURE__ */ React__default.createElement(Page, {
1543
+ themeId: "documentation"
1544
+ }, children instanceof Function ? children({
1545
+ techdocsMetadataValue,
1546
+ entityMetadataValue,
1547
+ entityRef: {kind, namespace, name},
1548
+ onReady
1549
+ }) : children);
1550
+ };
1551
+
1552
+ var TechDocsPage$1 = /*#__PURE__*/Object.freeze({
1553
+ __proto__: null,
1554
+ TechDocsPage: TechDocsPage
1555
+ });
1367
1556
 
1368
1557
  const DocsCardGrid = ({
1369
1558
  entities
@@ -1386,7 +1575,8 @@ const DocsCardGrid = ({
1386
1575
  kind: toLowerMaybe(entity.kind),
1387
1576
  name: toLowerMaybe(entity.metadata.name)
1388
1577
  }),
1389
- color: "primary"
1578
+ color: "primary",
1579
+ "data-testid": "read_docs"
1390
1580
  }, "Read Docs")));
1391
1581
  }));
1392
1582
  };
@@ -1429,6 +1619,7 @@ const CustomPanel = ({
1429
1619
  }, index === 0 ? /* @__PURE__ */ React__default.createElement(SupportButton, null, "Discover documentation in your ecosystem.") : null), /* @__PURE__ */ React__default.createElement("div", {
1430
1620
  className: classes.panelContainer
1431
1621
  }, /* @__PURE__ */ React__default.createElement(Panel, {
1622
+ "data-testid": "techdocs-custom-panel",
1432
1623
  entities: shownEntities
1433
1624
  })));
1434
1625
  };
@@ -1480,7 +1671,9 @@ const TechDocsCustomHome = ({
1480
1671
  id: index.toString(),
1481
1672
  label
1482
1673
  }))
1483
- }), /* @__PURE__ */ React__default.createElement(Content, null, currentTabConfig.panels.map((config, index) => /* @__PURE__ */ React__default.createElement(CustomPanel, {
1674
+ }), /* @__PURE__ */ React__default.createElement(Content, {
1675
+ "data-testid": "techdocs-content"
1676
+ }, currentTabConfig.panels.map((config, index) => /* @__PURE__ */ React__default.createElement(CustomPanel, {
1484
1677
  key: index,
1485
1678
  config,
1486
1679
  entities: !!entities ? entities : [],
@@ -1533,101 +1726,11 @@ var TechDocsIndexPage$1 = /*#__PURE__*/Object.freeze({
1533
1726
  TechDocsIndexPage: TechDocsIndexPage
1534
1727
  });
1535
1728
 
1536
- const TechDocsPageHeader = ({
1537
- entityId,
1538
- entityMetadata,
1539
- techDocsMetadata
1540
- }) => {
1541
- const {name} = entityId;
1542
- const {site_name: siteName, site_description: siteDescription} = techDocsMetadata || {};
1543
- const {locationMetadata, spec} = entityMetadata || {};
1544
- const lifecycle = spec == null ? void 0 : spec.lifecycle;
1545
- const ownedByRelations = entityMetadata ? getEntityRelations(entityMetadata, RELATION_OWNED_BY) : [];
1546
- const docsRootLink = useRouteRef(rootRouteRef)();
1547
- const labels = /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1548
- label: "Component",
1549
- value: /* @__PURE__ */ React__default.createElement(EntityRefLink, {
1550
- color: "inherit",
1551
- entityRef: entityId,
1552
- defaultKind: "Component"
1553
- })
1554
- }), ownedByRelations.length > 0 && /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1555
- label: "Owner",
1556
- value: /* @__PURE__ */ React__default.createElement(EntityRefLinks, {
1557
- color: "inherit",
1558
- entityRefs: ownedByRelations,
1559
- defaultKind: "group"
1560
- })
1561
- }), lifecycle ? /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1562
- label: "Lifecycle",
1563
- value: lifecycle
1564
- }) : null, locationMetadata && locationMetadata.type !== "dir" && locationMetadata.type !== "file" ? /* @__PURE__ */ React__default.createElement(HeaderLabel, {
1565
- label: "",
1566
- value: /* @__PURE__ */ React__default.createElement("a", {
1567
- href: locationMetadata.target,
1568
- target: "_blank",
1569
- rel: "noopener noreferrer"
1570
- }, /* @__PURE__ */ React__default.createElement(CodeIcon, {
1571
- style: {marginTop: "-25px", fill: "#fff"}
1572
- }))
1573
- }) : null);
1574
- return /* @__PURE__ */ React__default.createElement(Header, {
1575
- title: siteName ? siteName : ".",
1576
- pageTitleOverride: siteName || name,
1577
- subtitle: siteDescription && siteDescription !== "None" ? siteDescription : "",
1578
- type: "Docs",
1579
- typeLink: docsRootLink
1580
- }, labels);
1581
- };
1582
-
1583
- const TechDocsPage = () => {
1584
- const [documentReady, setDocumentReady] = useState(false);
1585
- const {namespace, kind, name} = useParams();
1586
- const techdocsApi = useApi(techdocsApiRef);
1587
- const {value: techdocsMetadataValue} = useAsync(() => {
1588
- if (documentReady) {
1589
- return techdocsApi.getTechDocsMetadata({kind, namespace, name});
1590
- }
1591
- return Promise.resolve(void 0);
1592
- }, [kind, namespace, name, techdocsApi, documentReady]);
1593
- const {value: entityMetadataValue} = useAsync(() => {
1594
- return techdocsApi.getEntityMetadata({kind, namespace, name});
1595
- }, [kind, namespace, name, techdocsApi]);
1596
- const onReady = useCallback(() => {
1597
- setDocumentReady(true);
1598
- }, [setDocumentReady]);
1599
- return /* @__PURE__ */ React__default.createElement(Page, {
1600
- themeId: "documentation"
1601
- }, /* @__PURE__ */ React__default.createElement(TechDocsPageHeader, {
1602
- techDocsMetadata: techdocsMetadataValue,
1603
- entityMetadata: entityMetadataValue,
1604
- entityId: {
1605
- kind,
1606
- namespace,
1607
- name
1608
- }
1609
- }), /* @__PURE__ */ React__default.createElement(Content, {
1610
- "data-testid": "techdocs-content"
1611
- }, /* @__PURE__ */ React__default.createElement(Reader, {
1612
- onReady,
1613
- entityId: {
1614
- kind,
1615
- namespace,
1616
- name
1617
- }
1618
- })));
1619
- };
1620
-
1621
- var TechDocsPage$1 = /*#__PURE__*/Object.freeze({
1622
- __proto__: null,
1623
- TechDocsPage: TechDocsPage
1624
- });
1625
-
1626
1729
  const EntityPageDocs = ({entity}) => {
1627
1730
  var _a;
1628
1731
  return /* @__PURE__ */ React__default.createElement(Reader, {
1629
1732
  withSearch: false,
1630
- entityId: {
1733
+ entityRef: {
1631
1734
  kind: entity.kind,
1632
1735
  namespace: (_a = entity.metadata.namespace) != null ? _a : "default",
1633
1736
  name: entity.metadata.name
@@ -1636,6 +1739,10 @@ const EntityPageDocs = ({entity}) => {
1636
1739
  };
1637
1740
 
1638
1741
  const TECHDOCS_ANNOTATION = "backstage.io/techdocs-ref";
1742
+ const isTechDocsAvailable = (entity) => {
1743
+ var _a, _b;
1744
+ return Boolean((_b = (_a = entity == null ? void 0 : entity.metadata) == null ? void 0 : _a.annotations) == null ? void 0 : _b[TECHDOCS_ANNOTATION]);
1745
+ };
1639
1746
  const Router = () => {
1640
1747
  return /* @__PURE__ */ React__default.createElement(Routes, null, /* @__PURE__ */ React__default.createElement(Route, {
1641
1748
  path: "/",
@@ -1664,9 +1771,10 @@ const EmbeddedDocsRouter = (_props) => {
1664
1771
 
1665
1772
  var Router$1 = /*#__PURE__*/Object.freeze({
1666
1773
  __proto__: null,
1774
+ isTechDocsAvailable: isTechDocsAvailable,
1667
1775
  Router: Router,
1668
1776
  EmbeddedDocsRouter: EmbeddedDocsRouter
1669
1777
  });
1670
1778
 
1671
- export { DefaultTechDocsHome, DocsCardGrid$2 as DocsCardGrid, DocsResultListItem, DocsTable, EmbeddedDocsRouter, EntityListDocsTable, EntityTechdocsContent, Reader, Router, TechDocsClient, TechDocsCustomHome$2 as TechDocsCustomHome, TechDocsIndexPage$2 as TechDocsIndexPage, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderPage, TechDocsStorageClient, TechdocsPage, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef };
1779
+ export { DefaultTechDocsHome, DocsCardGrid$2 as DocsCardGrid, DocsResultListItem, DocsTable, EmbeddedDocsRouter, EntityListDocsTable, EntityTechdocsContent, Reader, Router, TechDocsClient, TechDocsCustomHome$2 as TechDocsCustomHome, TechDocsIndexPage$2 as TechDocsIndexPage, TechDocsPage, TechDocsPageHeader, TechDocsPageWrapper, TechDocsPicker, TechDocsReaderPage, TechDocsSearch, TechDocsStateIndicator, TechDocsStorageClient, TechdocsPage, isTechDocsAvailable, techdocsPlugin as plugin, techdocsApiRef, techdocsPlugin, techdocsStorageApiRef, useTechDocsReader, useTechDocsReaderDom, withTechDocsReaderProvider };
1672
1780
  //# sourceMappingURL=index.esm.js.map