@backstage/plugin-techdocs 1.11.1-next.2 → 1.11.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.
- package/CHANGELOG.md +54 -0
- package/dist/alpha.esm.js +2 -2
- package/dist/client.esm.js +1 -1
- package/dist/plugin.esm.js +2 -2
- package/dist/reader/components/TechDocsReaderPageContent/dom.esm.js +4 -2
- package/dist/reader/components/TechDocsReaderPageContent/dom.esm.js.map +1 -1
- package/dist/reader/components/useReaderState.esm.js +20 -9
- package/dist/reader/components/useReaderState.esm.js.map +1 -1
- package/dist/reader/transformers/html/transformer.esm.js +1 -1
- package/dist/reader/transformers/styles/transformer.esm.js +1 -1
- package/package.json +33 -24
- package/alpha/package.json +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs
|
|
2
2
|
|
|
3
|
+
## 1.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 37a7810: Fixed an issue where `<TechDocsReaderPageContent />` would re-render infinitely under certain conditions.
|
|
8
|
+
- e937ae7: Fix an issue with index page of documentation site being re-rendered.
|
|
9
|
+
- 90246a9: Fix techdocs config schema for custom elements sanitizer
|
|
10
|
+
- 605bdc0: Avoid page re-rendering when clicking on anchor links in the same documentation page.
|
|
11
|
+
- 4f0cb89: Added DomPurify sanitizer configuration for custom elements implementing RFC https://github.com/backstage/backstage/issues/26988.
|
|
12
|
+
See https://backstage.io/docs/features/techdocs/how-to-guides#how-to-enable-custom-elements-in-techdocs for how to enable it in the configuration.
|
|
13
|
+
- f246178: Removed `canvas` dev dependency.
|
|
14
|
+
- 4a2f73a: Fix an issue that caused the current documentation page to be re-rendered when navigating to
|
|
15
|
+
another one.
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @backstage/config@1.3.0
|
|
18
|
+
- @backstage/theme@0.6.1
|
|
19
|
+
- @backstage/plugin-catalog-react@1.14.1
|
|
20
|
+
- @backstage/core-components@0.16.0
|
|
21
|
+
- @backstage/plugin-techdocs-react@1.2.10
|
|
22
|
+
- @backstage/catalog-model@1.7.1
|
|
23
|
+
- @backstage/core-compat-api@0.3.2
|
|
24
|
+
- @backstage/core-plugin-api@1.10.1
|
|
25
|
+
- @backstage/errors@1.2.5
|
|
26
|
+
- @backstage/frontend-plugin-api@0.9.1
|
|
27
|
+
- @backstage/integration@1.15.2
|
|
28
|
+
- @backstage/integration-react@1.2.1
|
|
29
|
+
- @backstage/plugin-auth-react@0.1.8
|
|
30
|
+
- @backstage/plugin-search-common@1.2.15
|
|
31
|
+
- @backstage/plugin-search-react@1.8.2
|
|
32
|
+
- @backstage/plugin-techdocs-common@0.1.0
|
|
33
|
+
|
|
34
|
+
## 1.11.1-next.3
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- e937ae7: Fix an issue with index page of documentation site being re-rendered.
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- @backstage/core-components@0.16.0-next.2
|
|
41
|
+
- @backstage/plugin-catalog-react@1.14.1-next.3
|
|
42
|
+
- @backstage/core-compat-api@0.3.2-next.2
|
|
43
|
+
- @backstage/catalog-model@1.7.0
|
|
44
|
+
- @backstage/config@1.2.0
|
|
45
|
+
- @backstage/core-plugin-api@1.10.0
|
|
46
|
+
- @backstage/errors@1.2.4
|
|
47
|
+
- @backstage/frontend-plugin-api@0.9.1-next.2
|
|
48
|
+
- @backstage/integration@1.15.1
|
|
49
|
+
- @backstage/integration-react@1.2.0
|
|
50
|
+
- @backstage/theme@0.6.1-next.0
|
|
51
|
+
- @backstage/plugin-auth-react@0.1.8-next.2
|
|
52
|
+
- @backstage/plugin-search-common@1.2.14
|
|
53
|
+
- @backstage/plugin-search-react@1.8.2-next.2
|
|
54
|
+
- @backstage/plugin-techdocs-common@0.1.0
|
|
55
|
+
- @backstage/plugin-techdocs-react@1.2.10-next.2
|
|
56
|
+
|
|
3
57
|
## 1.11.1-next.2
|
|
4
58
|
|
|
5
59
|
### Patch Changes
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LibraryBooks from '@material-ui/icons/LibraryBooks';
|
|
3
|
-
import { ApiBlueprint, PageBlueprint,
|
|
4
|
-
import { createApiFactory,
|
|
3
|
+
import { ApiBlueprint, PageBlueprint, coreExtensionData, createExtensionInput, createExtension, NavItemBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
4
|
+
import { createApiFactory, fetchApiRef, discoveryApiRef, configApiRef } from '@backstage/core-plugin-api';
|
|
5
5
|
import { compatWrapper, convertLegacyRouteRef, convertLegacyRouteRefs } from '@backstage/core-compat-api';
|
|
6
6
|
import { EntityContentBlueprint } from '@backstage/plugin-catalog-react/alpha';
|
|
7
7
|
import { SearchResultListItemBlueprint } from '@backstage/plugin-search-react/alpha';
|
package/dist/client.esm.js
CHANGED
package/dist/plugin.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { techdocsStorageApiRef, techdocsApiRef } from '@backstage/plugin-techdocs-react';
|
|
2
2
|
import { TechDocsStorageClient, TechDocsClient } from './client.esm.js';
|
|
3
|
-
import {
|
|
4
|
-
import { createPlugin, createApiFactory,
|
|
3
|
+
import { rootCatalogDocsRouteRef, rootDocsRouteRef, rootRouteRef } from './routes.esm.js';
|
|
4
|
+
import { createPlugin, createApiFactory, fetchApiRef, discoveryApiRef, configApiRef, createRoutableExtension } from '@backstage/core-plugin-api';
|
|
5
5
|
import { createSearchResultListItemExtension } from '@backstage/plugin-search-react';
|
|
6
6
|
|
|
7
7
|
const techdocsPlugin = createPlugin({
|
|
@@ -20,6 +20,7 @@ import { scrollIntoNavigation } from '../../transformers/scrollIntoNavigation.es
|
|
|
20
20
|
import { transform } from '../../transformers/transformer.esm.js';
|
|
21
21
|
import { handleMetaRedirects } from '../../transformers/handleMetaRedirects.esm.js';
|
|
22
22
|
import { useNavigateUrl } from './useNavigateUrl.esm.js';
|
|
23
|
+
import { useParams } from 'react-router-dom';
|
|
23
24
|
|
|
24
25
|
const MOBILE_MEDIA_QUERY = "screen and (max-width: 76.1875em)";
|
|
25
26
|
const useTechDocsReaderDom = (entityRef) => {
|
|
@@ -32,6 +33,7 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
32
33
|
const techdocsStorageApi = useApi(techdocsStorageApiRef);
|
|
33
34
|
const scmIntegrationsApi = useApi(scmIntegrationsApiRef);
|
|
34
35
|
const { state, path, content: rawPage } = useTechDocsReader();
|
|
36
|
+
const { "*": currPath = "" } = useParams();
|
|
35
37
|
const [dom, setDom] = useState(null);
|
|
36
38
|
const isStyleLoading = useShadowDomStylesLoading(dom);
|
|
37
39
|
const updateSidebarPositionAndHeight = useCallback(() => {
|
|
@@ -190,7 +192,7 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
190
192
|
if (!shouldReplaceContent) {
|
|
191
193
|
return;
|
|
192
194
|
}
|
|
193
|
-
if (
|
|
195
|
+
if (currPath !== path) {
|
|
194
196
|
return;
|
|
195
197
|
}
|
|
196
198
|
window.scroll({ top: 0 });
|
|
@@ -202,7 +204,7 @@ const useTechDocsReaderDom = (entityRef) => {
|
|
|
202
204
|
return () => {
|
|
203
205
|
shouldReplaceContent = false;
|
|
204
206
|
};
|
|
205
|
-
}, [rawPage, path, preRender, postRender]);
|
|
207
|
+
}, [rawPage, currPath, path, preRender, postRender]);
|
|
206
208
|
return dom;
|
|
207
209
|
};
|
|
208
210
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/dom.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\n\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\n\nimport {\n techdocsStorageApiRef,\n useShadowDomStylesLoading,\n} from '@backstage/plugin-techdocs-react';\n\nimport { useTechDocsReader } from '../TechDocsReaderProvider';\n\nimport {\n addBaseUrl,\n addGitFeedbackLink,\n addLinkClickListener,\n addSidebarToggle,\n onCssReady,\n removeMkdocsHeader,\n rewriteDocLinks,\n simplifyMkdocsFooter,\n scrollIntoNavigation,\n transform as transformer,\n copyToClipboard,\n useSanitizerTransformer,\n useStylesTransformer,\n handleMetaRedirects,\n} from '../../transformers';\nimport { useNavigateUrl } from './useNavigateUrl';\n\nconst MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)';\n\n/**\n * Hook that encapsulates the behavior of getting raw HTML and applying\n * transforms to it in order to make it function at a basic level in the\n * Backstage UI.\n */\nexport const useTechDocsReaderDom = (\n entityRef: CompoundEntityRef,\n): Element | null => {\n const navigate = useNavigateUrl();\n const theme = useTheme();\n const isMobileMedia = useMediaQuery(MOBILE_MEDIA_QUERY);\n const sanitizerTransformer = useSanitizerTransformer();\n const stylesTransformer = useStylesTransformer();\n const analytics = useAnalytics();\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n const scmIntegrationsApi = useApi(scmIntegrationsApiRef);\n\n const { state, path, content: rawPage } = useTechDocsReader();\n\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isStyleLoading = useShadowDomStylesLoading(dom);\n\n const updateSidebarPositionAndHeight = useCallback(() => {\n if (!dom) return;\n\n const sidebars = dom.querySelectorAll<HTMLElement>('.md-sidebar');\n\n sidebars.forEach(element => {\n // set sidebar position to render in correct position\n if (isMobileMedia) {\n element.style.top = '0px';\n } else {\n const page = document?.querySelector('.techdocs-reader-page');\n const pageTop = page?.getBoundingClientRect().top ?? 0;\n let domTop = dom.getBoundingClientRect().top ?? 0;\n\n const tabs = dom.querySelector('.md-container > .md-tabs');\n const tabsHeight = tabs?.getBoundingClientRect().height ?? 0;\n\n // the sidebars should not scroll beyond the total height of the header and tabs\n if (domTop < pageTop) {\n domTop = pageTop;\n }\n\n const scrollbarTopPx = Math.max(domTop, 0) + tabsHeight;\n\n element.style.top = `${scrollbarTopPx}px`;\n\n // set scrollbar height to ensure all links can be seen when content is small\n const footer = dom.querySelector('.md-container > .md-footer');\n // if no footer, fallback to using the bottom of the window\n const scrollbarEndPx =\n footer?.getBoundingClientRect().top ?? window.innerHeight;\n\n element.style.height = `${scrollbarEndPx - scrollbarTopPx}px`;\n }\n\n // show the sidebar only after updating its position\n element.style.setProperty('opacity', '1');\n });\n }, [dom, isMobileMedia]);\n\n useEffect(() => {\n window.addEventListener('resize', updateSidebarPositionAndHeight);\n window.addEventListener('scroll', updateSidebarPositionAndHeight, true);\n return () => {\n window.removeEventListener('resize', updateSidebarPositionAndHeight);\n window.removeEventListener(\n 'scroll',\n updateSidebarPositionAndHeight,\n true,\n );\n };\n }, [dom, updateSidebarPositionAndHeight]);\n\n // dynamically set width of footer to accommodate for pinning of the sidebar\n const updateFooterWidth = useCallback(() => {\n if (!dom) return;\n const footer = dom.querySelector<HTMLElement>('.md-footer');\n if (footer) {\n footer.style.width = `${dom.getBoundingClientRect().width}px`;\n }\n }, [dom]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFooterWidth);\n return () => {\n window.removeEventListener('resize', updateFooterWidth);\n };\n }, [dom, updateFooterWidth]);\n\n // an update to \"state\" might lead to an updated UI so we include it as a trigger\n useEffect(() => {\n if (!isStyleLoading) {\n updateFooterWidth();\n updateSidebarPositionAndHeight();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state,\n isStyleLoading,\n updateFooterWidth,\n updateSidebarPositionAndHeight,\n ]);\n\n // a function that performs transformations that are executed prior to adding it to the DOM\n const preRender = useCallback(\n (rawContent: string, contentPath: string) =>\n transformer(rawContent, [\n sanitizerTransformer,\n addBaseUrl({\n techdocsStorageApi,\n entityId: entityRef,\n path: contentPath,\n }),\n rewriteDocLinks(),\n addSidebarToggle(),\n removeMkdocsHeader(),\n simplifyMkdocsFooter(),\n addGitFeedbackLink(scmIntegrationsApi),\n stylesTransformer,\n ]),\n [\n // only add dependencies that are in state or memorized variables to avoid unnecessary calls between re-renders\n entityRef,\n scmIntegrationsApi,\n techdocsStorageApi,\n sanitizerTransformer,\n stylesTransformer,\n ],\n );\n\n // a function that performs transformations that are executed after adding it to the DOM\n const postRender = useCallback(\n async (transformedElement: Element) =>\n transformer(transformedElement, [\n handleMetaRedirects(navigate, entityRef.name),\n scrollIntoNavigation(),\n copyToClipboard(theme),\n addLinkClickListener({\n baseUrl: window.location.origin,\n onClick: (event: MouseEvent, url: string) => {\n // detect if CTRL or META keys are pressed so that links can be opened in a new tab with `window.open`\n const modifierActive = event.ctrlKey || event.metaKey;\n const parsedUrl = new URL(url);\n\n // capture link clicks within documentation\n const linkText =\n (event.target as HTMLAnchorElement | undefined)?.innerText || url;\n const to = url.replace(window.location.origin, '');\n analytics.captureEvent('click', linkText, { attributes: { to } });\n\n // hash exists when anchor is clicked on secondary sidebar\n if (parsedUrl.hash) {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n // If it's in a different page, we navigate to it\n if (window.location.pathname !== parsedUrl.pathname) {\n navigate(url);\n } else {\n // If it's in the same page we avoid using navigate that causes\n // the page to rerender.\n window.history.pushState(\n null,\n document.title,\n parsedUrl.hash,\n );\n }\n // Scroll to hash if it's on the current page\n transformedElement\n ?.querySelector(`[id=\"${parsedUrl.hash.slice(1)}\"]`)\n ?.scrollIntoView();\n }\n } else {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n navigate(url);\n }\n }\n },\n }),\n // disable MkDocs drawer toggling ('for' attribute => checkbox mechanism)\n onCssReady({\n onLoading: () => {},\n onLoaded: () => {\n transformedElement\n .querySelector('.md-nav__title')\n ?.removeAttribute('for');\n },\n }),\n // hide sidebars until their positions are updated\n onCssReady({\n onLoading: () => {\n const sidebars = Array.from(\n transformedElement.querySelectorAll<HTMLElement>('.md-sidebar'),\n );\n sidebars.forEach(element => {\n element.style.setProperty('opacity', '0');\n });\n },\n onLoaded: () => {},\n }),\n ]),\n [theme, navigate, analytics, entityRef.name],\n );\n\n useEffect(() => {\n if (!rawPage) return () => {};\n\n // if false, there is already a newer execution of this effect\n let shouldReplaceContent = true;\n\n // Pre-render\n preRender(rawPage, path).then(async preTransformedDomElement => {\n if (!preTransformedDomElement?.innerHTML) {\n return; // An unexpected error occurred\n }\n\n // don't manipulate the shadow dom if this isn't the latest effect execution\n if (!shouldReplaceContent) {\n return;\n }\n\n // Skip this update if the location's path has changed but the state\n // contains a page for another page that isn't loaded yet.\n if (!window.location.pathname.endsWith(path)) {\n return;\n }\n\n // Scroll to top after render\n window.scroll({ top: 0 });\n\n // Post-render\n const postTransformedDomElement = await postRender(\n preTransformedDomElement,\n );\n\n setDom(postTransformedDomElement as HTMLElement);\n });\n\n // cancel this execution\n return () => {\n shouldReplaceContent = false;\n };\n }, [rawPage, path, preRender, postRender]);\n\n return dom;\n};\n"],"names":["transformer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkDA,MAAM,kBAAqB,GAAA,mCAAA;AAOd,MAAA,oBAAA,GAAuB,CAClC,SACmB,KAAA;AACnB,EAAA,MAAM,WAAW,cAAe,EAAA;AAChC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,cAAc,kBAAkB,CAAA;AACtD,EAAA,MAAM,uBAAuB,uBAAwB,EAAA;AACrD,EAAA,MAAM,oBAAoB,o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;AAGD,IAAA,OAAO,MAAM;AACX,MAAuB,oBAAA,GAAA,KAAA;AAAA,KACzB;AAAA,KACC,CAAC,OAAA,EAAS,IAAM,EAAA,SAAA,EAAW,UAAU,CAAC,CAAA;AAEzC,EAAO,OAAA,GAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"dom.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/dom.tsx"],"sourcesContent":["/*\n * Copyright 2022 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useEffect, useState } from 'react';\n\nimport useMediaQuery from '@material-ui/core/useMediaQuery';\nimport { useTheme } from '@material-ui/core/styles';\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { useAnalytics, useApi } from '@backstage/core-plugin-api';\nimport { scmIntegrationsApiRef } from '@backstage/integration-react';\n\nimport {\n techdocsStorageApiRef,\n useShadowDomStylesLoading,\n} from '@backstage/plugin-techdocs-react';\n\nimport { useTechDocsReader } from '../TechDocsReaderProvider';\n\nimport {\n addBaseUrl,\n addGitFeedbackLink,\n addLinkClickListener,\n addSidebarToggle,\n onCssReady,\n removeMkdocsHeader,\n rewriteDocLinks,\n simplifyMkdocsFooter,\n scrollIntoNavigation,\n transform as transformer,\n copyToClipboard,\n useSanitizerTransformer,\n useStylesTransformer,\n handleMetaRedirects,\n} from '../../transformers';\nimport { useNavigateUrl } from './useNavigateUrl';\nimport { useParams } from 'react-router-dom';\n\nconst MOBILE_MEDIA_QUERY = 'screen and (max-width: 76.1875em)';\n\n/**\n * Hook that encapsulates the behavior of getting raw HTML and applying\n * transforms to it in order to make it function at a basic level in the\n * Backstage UI.\n */\nexport const useTechDocsReaderDom = (\n entityRef: CompoundEntityRef,\n): Element | null => {\n const navigate = useNavigateUrl();\n const theme = useTheme();\n const isMobileMedia = useMediaQuery(MOBILE_MEDIA_QUERY);\n const sanitizerTransformer = useSanitizerTransformer();\n const stylesTransformer = useStylesTransformer();\n const analytics = useAnalytics();\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n const scmIntegrationsApi = useApi(scmIntegrationsApiRef);\n\n const { state, path, content: rawPage } = useTechDocsReader();\n const { '*': currPath = '' } = useParams();\n\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isStyleLoading = useShadowDomStylesLoading(dom);\n\n const updateSidebarPositionAndHeight = useCallback(() => {\n if (!dom) return;\n\n const sidebars = dom.querySelectorAll<HTMLElement>('.md-sidebar');\n\n sidebars.forEach(element => {\n // set sidebar position to render in correct position\n if (isMobileMedia) {\n element.style.top = '0px';\n } else {\n const page = document?.querySelector('.techdocs-reader-page');\n const pageTop = page?.getBoundingClientRect().top ?? 0;\n let domTop = dom.getBoundingClientRect().top ?? 0;\n\n const tabs = dom.querySelector('.md-container > .md-tabs');\n const tabsHeight = tabs?.getBoundingClientRect().height ?? 0;\n\n // the sidebars should not scroll beyond the total height of the header and tabs\n if (domTop < pageTop) {\n domTop = pageTop;\n }\n\n const scrollbarTopPx = Math.max(domTop, 0) + tabsHeight;\n\n element.style.top = `${scrollbarTopPx}px`;\n\n // set scrollbar height to ensure all links can be seen when content is small\n const footer = dom.querySelector('.md-container > .md-footer');\n // if no footer, fallback to using the bottom of the window\n const scrollbarEndPx =\n footer?.getBoundingClientRect().top ?? window.innerHeight;\n\n element.style.height = `${scrollbarEndPx - scrollbarTopPx}px`;\n }\n\n // show the sidebar only after updating its position\n element.style.setProperty('opacity', '1');\n });\n }, [dom, isMobileMedia]);\n\n useEffect(() => {\n window.addEventListener('resize', updateSidebarPositionAndHeight);\n window.addEventListener('scroll', updateSidebarPositionAndHeight, true);\n return () => {\n window.removeEventListener('resize', updateSidebarPositionAndHeight);\n window.removeEventListener(\n 'scroll',\n updateSidebarPositionAndHeight,\n true,\n );\n };\n }, [dom, updateSidebarPositionAndHeight]);\n\n // dynamically set width of footer to accommodate for pinning of the sidebar\n const updateFooterWidth = useCallback(() => {\n if (!dom) return;\n const footer = dom.querySelector<HTMLElement>('.md-footer');\n if (footer) {\n footer.style.width = `${dom.getBoundingClientRect().width}px`;\n }\n }, [dom]);\n\n useEffect(() => {\n window.addEventListener('resize', updateFooterWidth);\n return () => {\n window.removeEventListener('resize', updateFooterWidth);\n };\n }, [dom, updateFooterWidth]);\n\n // an update to \"state\" might lead to an updated UI so we include it as a trigger\n useEffect(() => {\n if (!isStyleLoading) {\n updateFooterWidth();\n updateSidebarPositionAndHeight();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state,\n isStyleLoading,\n updateFooterWidth,\n updateSidebarPositionAndHeight,\n ]);\n\n // a function that performs transformations that are executed prior to adding it to the DOM\n const preRender = useCallback(\n (rawContent: string, contentPath: string) =>\n transformer(rawContent, [\n sanitizerTransformer,\n addBaseUrl({\n techdocsStorageApi,\n entityId: entityRef,\n path: contentPath,\n }),\n rewriteDocLinks(),\n addSidebarToggle(),\n removeMkdocsHeader(),\n simplifyMkdocsFooter(),\n addGitFeedbackLink(scmIntegrationsApi),\n stylesTransformer,\n ]),\n [\n // only add dependencies that are in state or memorized variables to avoid unnecessary calls between re-renders\n entityRef,\n scmIntegrationsApi,\n techdocsStorageApi,\n sanitizerTransformer,\n stylesTransformer,\n ],\n );\n\n // a function that performs transformations that are executed after adding it to the DOM\n const postRender = useCallback(\n async (transformedElement: Element) =>\n transformer(transformedElement, [\n handleMetaRedirects(navigate, entityRef.name),\n scrollIntoNavigation(),\n copyToClipboard(theme),\n addLinkClickListener({\n baseUrl: window.location.origin,\n onClick: (event: MouseEvent, url: string) => {\n // detect if CTRL or META keys are pressed so that links can be opened in a new tab with `window.open`\n const modifierActive = event.ctrlKey || event.metaKey;\n const parsedUrl = new URL(url);\n\n // capture link clicks within documentation\n const linkText =\n (event.target as HTMLAnchorElement | undefined)?.innerText || url;\n const to = url.replace(window.location.origin, '');\n analytics.captureEvent('click', linkText, { attributes: { to } });\n\n // hash exists when anchor is clicked on secondary sidebar\n if (parsedUrl.hash) {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n // If it's in a different page, we navigate to it\n if (window.location.pathname !== parsedUrl.pathname) {\n navigate(url);\n } else {\n // If it's in the same page we avoid using navigate that causes\n // the page to rerender.\n window.history.pushState(\n null,\n document.title,\n parsedUrl.hash,\n );\n }\n // Scroll to hash if it's on the current page\n transformedElement\n ?.querySelector(`[id=\"${parsedUrl.hash.slice(1)}\"]`)\n ?.scrollIntoView();\n }\n } else {\n if (modifierActive) {\n window.open(url, '_blank');\n } else {\n navigate(url);\n }\n }\n },\n }),\n // disable MkDocs drawer toggling ('for' attribute => checkbox mechanism)\n onCssReady({\n onLoading: () => {},\n onLoaded: () => {\n transformedElement\n .querySelector('.md-nav__title')\n ?.removeAttribute('for');\n },\n }),\n // hide sidebars until their positions are updated\n onCssReady({\n onLoading: () => {\n const sidebars = Array.from(\n transformedElement.querySelectorAll<HTMLElement>('.md-sidebar'),\n );\n sidebars.forEach(element => {\n element.style.setProperty('opacity', '0');\n });\n },\n onLoaded: () => {},\n }),\n ]),\n [theme, navigate, analytics, entityRef.name],\n );\n\n useEffect(() => {\n if (!rawPage) return () => {};\n\n // if false, there is already a newer execution of this effect\n let shouldReplaceContent = true;\n\n // Pre-render\n preRender(rawPage, path).then(async preTransformedDomElement => {\n if (!preTransformedDomElement?.innerHTML) {\n return; // An unexpected error occurred\n }\n\n // don't manipulate the shadow dom if this isn't the latest effect execution\n if (!shouldReplaceContent) {\n return;\n }\n\n // Skip this update if the location's path has changed but the state\n // contains a page that isn't loaded yet.\n if (currPath !== path) {\n return;\n }\n\n // Scroll to top after render\n window.scroll({ top: 0 });\n\n // Post-render\n const postTransformedDomElement = await postRender(\n preTransformedDomElement,\n );\n\n setDom(postTransformedDomElement as HTMLElement);\n });\n\n // cancel this execution\n return () => {\n shouldReplaceContent = false;\n };\n }, [rawPage, currPath, path, preRender, postRender]);\n\n return dom;\n};\n"],"names":["transformer"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAM,kBAAqB,GAAA,mCAAA;AAOd,MAAA,oBAAA,GAAuB,CAClC,SACmB,KAAA;AACnB,EAAA,MAAM,WAAW,cAAe,EAAA;AAChC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,cAAc,kBAAkB,CAAA;AACtD,EAAA,MAAM,uBAAuB,uBAAwB,EAAA;AACrD,EAAA,MAAM,oBAAoB,oBAAqB,EAAA;AAC/C,EAAA,MAAM,YAAY,YAAa,EAAA;AAE/B,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AACvD,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAA,MAAM,EAAE,KAAO,EAAA,IAAA,EAAM,OAAS,EAAA,OAAA,KAAY,iBAAkB,EAAA;AAC5D,EAAA,MAAM,EAAE,GAAA,EAAK,QAAW,GAAA,EAAA,KAAO,SAAU,EAAA;AAEzC,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAA6B,IAAI,CAAA;AACvD,EAAM,MAAA,cAAA,GAAiB,0BAA0B,GAAG,CAAA;AAEpD,EAAM,MAAA,8BAAA,GAAiC,YAAY,MAAM;AACvD,IAAA,IAAI,CAAC,GAAK,EAAA;AAEV,IAAM,MAAA,QAAA,GAAW,GAAI,CAAA,gBAAA,CAA8B,aAAa,CAAA;AAEhE,IAAA,QAAA,CAAS,QAAQ,CAAW,OAAA,KAAA;AAE1B,MAAA,IAAI,aAAe,EAAA;AACjB,QAAA,OAAA,CAAQ,MAAM,GAAM,GAAA,KAAA;AAAA,OACf,MAAA;AACL,QAAM,MAAA,IAAA,GAAO,Q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AI,oBAAuB,GAAA,IAAA;AAG3B,IAAA,SAAA,CAAU,OAAS,EAAA,IAAI,CAAE,CAAA,IAAA,CAAK,OAAM,wBAA4B,KAAA;AAC9D,MAAI,IAAA,CAAC,0BAA0B,SAAW,EAAA;AACxC,QAAA;AAAA;AAIF,MAAA,IAAI,CAAC,oBAAsB,EAAA;AACzB,QAAA;AAAA;AAKF,MAAA,IAAI,aAAa,IAAM,EAAA;AACrB,QAAA;AAAA;AAIF,MAAA,MAAA,CAAO,MAAO,CAAA,EAAE,GAAK,EAAA,CAAA,EAAG,CAAA;AAGxB,MAAA,MAAM,4BAA4B,MAAM,UAAA;AAAA,QACtC;AAAA,OACF;AAEA,MAAA,MAAA,CAAO,yBAAwC,CAAA;AAAA,KAChD,CAAA;AAGD,IAAA,OAAO,MAAM;AACX,MAAuB,oBAAA,GAAA,KAAA;AAAA,KACzB;AAAA,KACC,CAAC,OAAA,EAAS,UAAU,IAAM,EAAA,SAAA,EAAW,UAAU,CAAC,CAAA;AAEnD,EAAO,OAAA,GAAA;AACT;;;;"}
|
|
@@ -147,15 +147,26 @@ function useReaderState(kind, namespace, name, path) {
|
|
|
147
147
|
}),
|
|
148
148
|
[state.activeSyncState, state.content, state.contentLoading]
|
|
149
149
|
);
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
150
|
+
return useMemo(
|
|
151
|
+
() => ({
|
|
152
|
+
state: displayState,
|
|
153
|
+
contentReload,
|
|
154
|
+
path: state.path,
|
|
155
|
+
content: state.content,
|
|
156
|
+
contentErrorMessage: state.contentError?.toString(),
|
|
157
|
+
syncErrorMessage: state.syncError?.toString(),
|
|
158
|
+
buildLog: state.buildLog
|
|
159
|
+
}),
|
|
160
|
+
[
|
|
161
|
+
displayState,
|
|
162
|
+
contentReload,
|
|
163
|
+
state.path,
|
|
164
|
+
state.content,
|
|
165
|
+
state.contentError,
|
|
166
|
+
state.syncError,
|
|
167
|
+
state.buildLog
|
|
168
|
+
]
|
|
169
|
+
);
|
|
159
170
|
}
|
|
160
171
|
|
|
161
172
|
export { calculateDisplayState, reducer, useReaderState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReaderState.esm.js","sources":["../../../src/reader/components/useReaderState.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { useMemo, useReducer, useRef } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { techdocsStorageApiRef } from '@backstage/plugin-techdocs-react';\n\n/**\n * @public\n * A state representation that is used to configure the UI of <Reader />\n */\nexport type ContentStateTypes =\n /** There is nothing to display but a loading indicator */\n | 'CHECKING'\n\n /** There is no content yet -> present a full screen loading page */\n | 'INITIAL_BUILD'\n\n /** There is content, but the backend is about to update it */\n | 'CONTENT_STALE_REFRESHING'\n\n /** There is content, but after a reload, the content will be different */\n | 'CONTENT_STALE_READY'\n\n /** There is content, the backend tried to update it, but failed */\n | 'CONTENT_STALE_ERROR'\n\n /** There is nothing to see but a \"not found\" page. Is also shown on page load errors */\n | 'CONTENT_NOT_FOUND'\n\n /** There is only the latest and greatest content */\n | 'CONTENT_FRESH';\n\n/**\n * Calculate the state that should be reported to the display component.\n */\nexport function calculateDisplayState({\n contentLoading,\n content,\n activeSyncState,\n}: Pick<\n ReducerState,\n 'contentLoading' | 'content' | 'activeSyncState'\n>): ContentStateTypes {\n // we have nothing to display yet\n if (contentLoading) {\n return 'CHECKING';\n }\n\n // the build is ready, but it triggered a content reload and the content variable is not trusted\n if (activeSyncState === 'BUILD_READY_RELOAD') {\n return 'CHECKING';\n }\n\n // there is no content, but the sync process is still evaluating\n if (!content && activeSyncState === 'CHECKING') {\n return 'CHECKING';\n }\n\n // there is no content yet so we assume that we are building it for the first time\n if (!content && activeSyncState === 'BUILDING') {\n return 'INITIAL_BUILD';\n }\n\n // if there is still no content after building, it might just not exist\n if (!content) {\n return 'CONTENT_NOT_FOUND';\n }\n\n // we are still building, but we already show stale content\n if (activeSyncState === 'BUILDING') {\n return 'CONTENT_STALE_REFRESHING';\n }\n\n // the build is ready, but the content is still stale\n if (activeSyncState === 'BUILD_READY') {\n return 'CONTENT_STALE_READY';\n }\n\n // the build failed, but the content is still stale\n if (activeSyncState === 'ERROR') {\n return 'CONTENT_STALE_ERROR';\n }\n\n // seems like the content is up-to-date (or we don't know yet and the sync process is still evaluating in the background)\n return 'CONTENT_FRESH';\n}\n\n/**\n * The state of the synchronization task. It checks whether the docs are\n * up-to-date. If they aren't, it triggers a build.\n */\ntype SyncStates =\n /** Checking if it should be synced */\n | 'CHECKING'\n\n /** Building the documentation */\n | 'BUILDING'\n\n /** Finished building the documentation */\n | 'BUILD_READY'\n\n /**\n * Finished building the documentation and triggered a content reload.\n * This state is left toward UP_TO_DATE when the content loading has finished.\n */\n | 'BUILD_READY_RELOAD'\n\n /** No need for a sync. The content was already up-to-date. */\n | 'UP_TO_DATE'\n\n /** An error occurred */\n | 'ERROR';\n\ntype ReducerActions =\n | {\n type: 'sync';\n state: SyncStates;\n syncError?: Error;\n }\n | { type: 'contentLoading' }\n | {\n type: 'content';\n path?: string;\n content?: string;\n contentError?: Error;\n }\n | { type: 'buildLog'; log: string };\n\ntype ReducerState = {\n /**\n * The path of the current page\n */\n path: string;\n\n /**\n * The current sync state\n */\n activeSyncState: SyncStates;\n\n /**\n * If true, the content is downloading from the storage.\n */\n contentLoading: boolean;\n /**\n * The content that has been downloaded and should be displayed.\n */\n content?: string;\n\n contentError?: Error;\n syncError?: Error;\n\n /**\n * A list of log messages that were emitted by the build process.\n */\n buildLog: string[];\n};\n\nexport function reducer(\n oldState: ReducerState,\n action: ReducerActions,\n): ReducerState {\n const newState = { ...oldState };\n\n switch (action.type) {\n case 'sync':\n // reset the build log when a new check starts\n if (action.state === 'CHECKING') {\n newState.buildLog = [];\n }\n\n newState.activeSyncState = action.state;\n newState.syncError = action.syncError;\n break;\n\n case 'contentLoading':\n newState.contentLoading = true;\n\n // only reset errors but keep the old content until it is replaced by the 'content' action\n newState.contentError = undefined;\n break;\n\n case 'content':\n // only override the path if it is part of the action\n if (typeof action.path === 'string') {\n newState.path = action.path;\n }\n\n newState.contentLoading = false;\n newState.content = action.content;\n newState.contentError = action.contentError;\n break;\n\n case 'buildLog':\n newState.buildLog = newState.buildLog.concat(action.log);\n break;\n\n default:\n throw new Error();\n }\n\n // a content update loads fresh content so the build is updated to being up-to-date\n if (\n ['BUILD_READY', 'BUILD_READY_RELOAD'].includes(newState.activeSyncState) &&\n ['contentLoading', 'content'].includes(action.type)\n ) {\n newState.activeSyncState = 'UP_TO_DATE';\n newState.buildLog = [];\n }\n\n return newState;\n}\n/**\n * @public shared reader state\n */\nexport type ReaderState = {\n state: ContentStateTypes;\n path: string;\n contentReload: () => void;\n content?: string;\n contentErrorMessage?: string;\n syncErrorMessage?: string;\n buildLog: string[];\n};\n\nexport function useReaderState(\n kind: string,\n namespace: string,\n name: string,\n path: string,\n): ReaderState {\n const [state, dispatch] = useReducer(reducer, {\n activeSyncState: 'CHECKING',\n path,\n contentLoading: true,\n buildLog: [],\n });\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n\n // try to load the content. the function will fire events and we don't care for the return values\n const { retry: contentReload } = useAsyncRetry(async () => {\n dispatch({ type: 'contentLoading' });\n\n try {\n const entityDocs = await techdocsStorageApi.getEntityDocs(\n { kind, namespace, name },\n path,\n );\n\n // update content and path at the same time\n dispatch({ type: 'content', content: entityDocs, path });\n\n return entityDocs;\n } catch (e) {\n dispatch({ type: 'content', contentError: e, path });\n }\n\n return undefined;\n }, [techdocsStorageApi, kind, namespace, name, path]);\n\n // create a ref that holds the latest content. This provides a useAsync hook\n // with the latest content without restarting the useAsync hook.\n const contentRef = useRef<{ content?: string; reload: () => void }>({\n content: undefined,\n reload: () => {},\n });\n contentRef.current = { content: state.content, reload: contentReload };\n\n // try to derive the state. the function will fire events and we don't care for the return values\n useAsync(async () => {\n dispatch({ type: 'sync', state: 'CHECKING' });\n\n // should only switch to BUILDING if the request takes more than 1 seconds\n const buildingTimeout = setTimeout(() => {\n dispatch({ type: 'sync', state: 'BUILDING' });\n }, 1000);\n\n try {\n const result = await techdocsStorageApi.syncEntityDocs(\n {\n kind,\n namespace,\n name,\n },\n log => {\n dispatch({ type: 'buildLog', log });\n },\n );\n\n switch (result) {\n case 'updated':\n // if there was no content prior to building, retry the loading\n if (!contentRef.current.content) {\n contentRef.current.reload();\n dispatch({ type: 'sync', state: 'BUILD_READY_RELOAD' });\n } else {\n dispatch({ type: 'sync', state: 'BUILD_READY' });\n }\n break;\n case 'cached':\n dispatch({ type: 'sync', state: 'UP_TO_DATE' });\n break;\n\n default:\n dispatch({\n type: 'sync',\n state: 'ERROR',\n syncError: new Error('Unexpected return state'),\n });\n break;\n }\n } catch (e) {\n dispatch({ type: 'sync', state: 'ERROR', syncError: e });\n } finally {\n // Cancel the timer that sets the state \"BUILDING\"\n clearTimeout(buildingTimeout);\n }\n }, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);\n\n const displayState = useMemo(\n () =>\n calculateDisplayState({\n activeSyncState: state.activeSyncState,\n contentLoading: state.contentLoading,\n content: state.content,\n }),\n [state.activeSyncState, state.content, state.contentLoading],\n );\n\n return {\n state: displayState,\n contentReload,\n path: state.path,\n content: state.content,\n contentErrorMessage: state.contentError?.toString(),\n syncErrorMessage: state.syncError?.toString(),\n buildLog: state.buildLog,\n };\n}\n"],"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,KAAM,CAAA,IAAA;AAAA,IACZ,SAAS,KAAM,CAAA,OAAA;AAAA,IACf,mBAAA,EAAqB,KAAM,CAAA,YAAA,EAAc,QAAS,EAAA;AAAA,IAClD,gBAAA,EAAkB,KAAM,CAAA,SAAA,EAAW,QAAS,EAAA;AAAA,IAC5C,UAAU,KAAM,CAAA;AAAA,GAClB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useReaderState.esm.js","sources":["../../../src/reader/components/useReaderState.ts"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { useMemo, useReducer, useRef } from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\nimport { techdocsStorageApiRef } from '@backstage/plugin-techdocs-react';\n\n/**\n * @public\n * A state representation that is used to configure the UI of <Reader />\n */\nexport type ContentStateTypes =\n /** There is nothing to display but a loading indicator */\n | 'CHECKING'\n\n /** There is no content yet -> present a full screen loading page */\n | 'INITIAL_BUILD'\n\n /** There is content, but the backend is about to update it */\n | 'CONTENT_STALE_REFRESHING'\n\n /** There is content, but after a reload, the content will be different */\n | 'CONTENT_STALE_READY'\n\n /** There is content, the backend tried to update it, but failed */\n | 'CONTENT_STALE_ERROR'\n\n /** There is nothing to see but a \"not found\" page. Is also shown on page load errors */\n | 'CONTENT_NOT_FOUND'\n\n /** There is only the latest and greatest content */\n | 'CONTENT_FRESH';\n\n/**\n * Calculate the state that should be reported to the display component.\n */\nexport function calculateDisplayState({\n contentLoading,\n content,\n activeSyncState,\n}: Pick<\n ReducerState,\n 'contentLoading' | 'content' | 'activeSyncState'\n>): ContentStateTypes {\n // we have nothing to display yet\n if (contentLoading) {\n return 'CHECKING';\n }\n\n // the build is ready, but it triggered a content reload and the content variable is not trusted\n if (activeSyncState === 'BUILD_READY_RELOAD') {\n return 'CHECKING';\n }\n\n // there is no content, but the sync process is still evaluating\n if (!content && activeSyncState === 'CHECKING') {\n return 'CHECKING';\n }\n\n // there is no content yet so we assume that we are building it for the first time\n if (!content && activeSyncState === 'BUILDING') {\n return 'INITIAL_BUILD';\n }\n\n // if there is still no content after building, it might just not exist\n if (!content) {\n return 'CONTENT_NOT_FOUND';\n }\n\n // we are still building, but we already show stale content\n if (activeSyncState === 'BUILDING') {\n return 'CONTENT_STALE_REFRESHING';\n }\n\n // the build is ready, but the content is still stale\n if (activeSyncState === 'BUILD_READY') {\n return 'CONTENT_STALE_READY';\n }\n\n // the build failed, but the content is still stale\n if (activeSyncState === 'ERROR') {\n return 'CONTENT_STALE_ERROR';\n }\n\n // seems like the content is up-to-date (or we don't know yet and the sync process is still evaluating in the background)\n return 'CONTENT_FRESH';\n}\n\n/**\n * The state of the synchronization task. It checks whether the docs are\n * up-to-date. If they aren't, it triggers a build.\n */\ntype SyncStates =\n /** Checking if it should be synced */\n | 'CHECKING'\n\n /** Building the documentation */\n | 'BUILDING'\n\n /** Finished building the documentation */\n | 'BUILD_READY'\n\n /**\n * Finished building the documentation and triggered a content reload.\n * This state is left toward UP_TO_DATE when the content loading has finished.\n */\n | 'BUILD_READY_RELOAD'\n\n /** No need for a sync. The content was already up-to-date. */\n | 'UP_TO_DATE'\n\n /** An error occurred */\n | 'ERROR';\n\ntype ReducerActions =\n | {\n type: 'sync';\n state: SyncStates;\n syncError?: Error;\n }\n | { type: 'contentLoading' }\n | {\n type: 'content';\n path?: string;\n content?: string;\n contentError?: Error;\n }\n | { type: 'buildLog'; log: string };\n\ntype ReducerState = {\n /**\n * The path of the current page\n */\n path: string;\n\n /**\n * The current sync state\n */\n activeSyncState: SyncStates;\n\n /**\n * If true, the content is downloading from the storage.\n */\n contentLoading: boolean;\n /**\n * The content that has been downloaded and should be displayed.\n */\n content?: string;\n\n contentError?: Error;\n syncError?: Error;\n\n /**\n * A list of log messages that were emitted by the build process.\n */\n buildLog: string[];\n};\n\nexport function reducer(\n oldState: ReducerState,\n action: ReducerActions,\n): ReducerState {\n const newState = { ...oldState };\n\n switch (action.type) {\n case 'sync':\n // reset the build log when a new check starts\n if (action.state === 'CHECKING') {\n newState.buildLog = [];\n }\n\n newState.activeSyncState = action.state;\n newState.syncError = action.syncError;\n break;\n\n case 'contentLoading':\n newState.contentLoading = true;\n\n // only reset errors but keep the old content until it is replaced by the 'content' action\n newState.contentError = undefined;\n break;\n\n case 'content':\n // only override the path if it is part of the action\n if (typeof action.path === 'string') {\n newState.path = action.path;\n }\n\n newState.contentLoading = false;\n newState.content = action.content;\n newState.contentError = action.contentError;\n break;\n\n case 'buildLog':\n newState.buildLog = newState.buildLog.concat(action.log);\n break;\n\n default:\n throw new Error();\n }\n\n // a content update loads fresh content so the build is updated to being up-to-date\n if (\n ['BUILD_READY', 'BUILD_READY_RELOAD'].includes(newState.activeSyncState) &&\n ['contentLoading', 'content'].includes(action.type)\n ) {\n newState.activeSyncState = 'UP_TO_DATE';\n newState.buildLog = [];\n }\n\n return newState;\n}\n/**\n * @public shared reader state\n */\nexport type ReaderState = {\n state: ContentStateTypes;\n path: string;\n contentReload: () => void;\n content?: string;\n contentErrorMessage?: string;\n syncErrorMessage?: string;\n buildLog: string[];\n};\n\nexport function useReaderState(\n kind: string,\n namespace: string,\n name: string,\n path: string,\n): ReaderState {\n const [state, dispatch] = useReducer(reducer, {\n activeSyncState: 'CHECKING',\n path,\n contentLoading: true,\n buildLog: [],\n });\n\n const techdocsStorageApi = useApi(techdocsStorageApiRef);\n\n // try to load the content. the function will fire events and we don't care for the return values\n const { retry: contentReload } = useAsyncRetry(async () => {\n dispatch({ type: 'contentLoading' });\n\n try {\n const entityDocs = await techdocsStorageApi.getEntityDocs(\n { kind, namespace, name },\n path,\n );\n\n // update content and path at the same time\n dispatch({ type: 'content', content: entityDocs, path });\n\n return entityDocs;\n } catch (e) {\n dispatch({ type: 'content', contentError: e, path });\n }\n\n return undefined;\n }, [techdocsStorageApi, kind, namespace, name, path]);\n\n // create a ref that holds the latest content. This provides a useAsync hook\n // with the latest content without restarting the useAsync hook.\n const contentRef = useRef<{ content?: string; reload: () => void }>({\n content: undefined,\n reload: () => {},\n });\n contentRef.current = { content: state.content, reload: contentReload };\n\n // try to derive the state. the function will fire events and we don't care for the return values\n useAsync(async () => {\n dispatch({ type: 'sync', state: 'CHECKING' });\n\n // should only switch to BUILDING if the request takes more than 1 seconds\n const buildingTimeout = setTimeout(() => {\n dispatch({ type: 'sync', state: 'BUILDING' });\n }, 1000);\n\n try {\n const result = await techdocsStorageApi.syncEntityDocs(\n {\n kind,\n namespace,\n name,\n },\n log => {\n dispatch({ type: 'buildLog', log });\n },\n );\n\n switch (result) {\n case 'updated':\n // if there was no content prior to building, retry the loading\n if (!contentRef.current.content) {\n contentRef.current.reload();\n dispatch({ type: 'sync', state: 'BUILD_READY_RELOAD' });\n } else {\n dispatch({ type: 'sync', state: 'BUILD_READY' });\n }\n break;\n case 'cached':\n dispatch({ type: 'sync', state: 'UP_TO_DATE' });\n break;\n\n default:\n dispatch({\n type: 'sync',\n state: 'ERROR',\n syncError: new Error('Unexpected return state'),\n });\n break;\n }\n } catch (e) {\n dispatch({ type: 'sync', state: 'ERROR', syncError: e });\n } finally {\n // Cancel the timer that sets the state \"BUILDING\"\n clearTimeout(buildingTimeout);\n }\n }, [kind, name, namespace, techdocsStorageApi, dispatch, contentRef]);\n\n const displayState = useMemo(\n () =>\n calculateDisplayState({\n activeSyncState: state.activeSyncState,\n contentLoading: state.contentLoading,\n content: state.content,\n }),\n [state.activeSyncState, state.content, state.contentLoading],\n );\n\n return useMemo(\n () => ({\n state: displayState,\n contentReload,\n path: state.path,\n content: state.content,\n contentErrorMessage: state.contentError?.toString(),\n syncErrorMessage: state.syncError?.toString(),\n buildLog: state.buildLog,\n }),\n [\n displayState,\n contentReload,\n state.path,\n state.content,\n state.contentError,\n state.syncError,\n state.buildLog,\n ],\n );\n}\n"],"names":[],"mappings":";;;;;;AAmDO,SAAS,qBAAsB,CAAA;AAAA,EACpC,cAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAGsB,EAAA;AAEpB,EAAA,IAAI,cAAgB,EAAA;AAClB,IAAO,OAAA,UAAA;AAAA;AAIT,EAAA,IAAI,oBAAoB,oBAAsB,EAAA;AAC5C,IAAO,OAAA,UAAA;AAAA;AAIT,EAAI,IAAA,CAAC,OAAW,IAAA,eAAA,KAAoB,UAAY,EAAA;AAC9C,IAAO,OAAA,UAAA;AAAA;AAIT,EAAI,IAAA,CAAC,OAAW,IAAA,eAAA,KAAoB,UAAY,EAAA;AAC9C,IAAO,OAAA,eAAA;AAAA;AAIT,EAAA,IAAI,CAAC,OAAS,EAAA;AACZ,IAAO,OAAA,mBAAA;AAAA;AAIT,EAAA,IAAI,oBAAoB,UAAY,EAAA;AAClC,IAAO,OAAA,0BAAA;AAAA;AAIT,EAAA,IAAI,oBAAoB,aAAe,EAAA;AACrC,IAAO,OAAA,qBAAA;AAAA;AAIT,EAAA,IAAI,oBAAoB,OAAS,EAAA;AAC/B,IAAO,OAAA,qBAAA;AAAA;AAIT,EAAO,OAAA,eAAA;AACT;AAwEgB,SAAA,OAAA,CACd,UACA,MACc,EAAA;AACd,EAAM,MAAA,QAAA,GAAW,EAAE,GAAG,QAAS,EAAA;AAE/B,EAAA,QAAQ,OAAO,IAAM;AAAA,IACnB,KAAK,MAAA;AAEH,MAAI,IAAA,MAAA,CAAO,UAAU,UAAY,EAAA;AAC/B,QAAA,QAAA,CAAS,WAAW,EAAC;AAAA;AAGvB,MAAA,QAAA,CAAS,kBAAkB,MAAO,CAAA,KAAA;AAClC,MAAA,QAAA,CAAS,YAAY,MAAO,CAAA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,CAAC,KAAM,CAAA,eAAA,EAAiB,KAAM,CAAA,OAAA,EAAS,MAAM,cAAc;AAAA,GAC7D;AAEA,EAAO,OAAA,OAAA;AAAA,IACL,OAAO;AAAA,MACL,KAAO,EAAA,YAAA;AAAA,MACP,aAAA;AAAA,MACA,MAAM,KAAM,CAAA,IAAA;AAAA,MACZ,SAAS,KAAM,CAAA,OAAA;AAAA,MACf,mBAAA,EAAqB,KAAM,CAAA,YAAA,EAAc,QAAS,EAAA;AAAA,MAClD,gBAAA,EAAkB,KAAM,CAAA,SAAA,EAAW,QAAS,EAAA;AAAA,MAC5C,UAAU,KAAM,CAAA;AAAA,KAClB,CAAA;AAAA,IACA;AAAA,MACE,YAAA;AAAA,MACA,aAAA;AAAA,MACA,KAAM,CAAA,IAAA;AAAA,MACN,KAAM,CAAA,OAAA;AAAA,MACN,KAAM,CAAA,YAAA;AAAA,MACN,KAAM,CAAA,SAAA;AAAA,MACN,KAAM,CAAA;AAAA;AACR,GACF;AACF;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import DOMPurify from 'dompurify';
|
|
2
|
-
import {
|
|
2
|
+
import { useMemo, useCallback } from 'react';
|
|
3
3
|
import { useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
4
4
|
import { removeUnsafeLinks } from './hooks/links.esm.js';
|
|
5
5
|
import { removeUnsafeIframes } from './hooks/iframes.esm.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs",
|
|
3
|
-
"version": "1.11.1
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "The Backstage plugin that renders technical documentation for your components",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -44,10 +44,19 @@
|
|
|
44
44
|
},
|
|
45
45
|
"main": "./dist/index.esm.js",
|
|
46
46
|
"types": "./dist/index.d.ts",
|
|
47
|
+
"typesVersions": {
|
|
48
|
+
"*": {
|
|
49
|
+
"index": [
|
|
50
|
+
"dist/index.d.ts"
|
|
51
|
+
],
|
|
52
|
+
"alpha": [
|
|
53
|
+
"dist/alpha.d.ts"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
47
57
|
"files": [
|
|
48
58
|
"dist",
|
|
49
|
-
"config.d.ts"
|
|
50
|
-
"alpha"
|
|
59
|
+
"config.d.ts"
|
|
51
60
|
],
|
|
52
61
|
"scripts": {
|
|
53
62
|
"build": "backstage-cli package build",
|
|
@@ -59,22 +68,22 @@
|
|
|
59
68
|
"test": "backstage-cli package test"
|
|
60
69
|
},
|
|
61
70
|
"dependencies": {
|
|
62
|
-
"@backstage/catalog-model": "1.7.
|
|
63
|
-
"@backstage/config": "1.
|
|
64
|
-
"@backstage/core-compat-api": "0.3.2
|
|
65
|
-
"@backstage/core-components": "0.16.0
|
|
66
|
-
"@backstage/core-plugin-api": "1.10.
|
|
67
|
-
"@backstage/errors": "1.2.
|
|
68
|
-
"@backstage/frontend-plugin-api": "0.9.1
|
|
69
|
-
"@backstage/integration": "1.15.
|
|
70
|
-
"@backstage/integration-react": "1.2.
|
|
71
|
-
"@backstage/plugin-auth-react": "0.1.8
|
|
72
|
-
"@backstage/plugin-catalog-react": "1.14.1
|
|
73
|
-
"@backstage/plugin-search-common": "1.2.
|
|
74
|
-
"@backstage/plugin-search-react": "1.8.2
|
|
75
|
-
"@backstage/plugin-techdocs-common": "0.1.0",
|
|
76
|
-
"@backstage/plugin-techdocs-react": "1.2.10
|
|
77
|
-
"@backstage/theme": "0.6.1
|
|
71
|
+
"@backstage/catalog-model": "^1.7.1",
|
|
72
|
+
"@backstage/config": "^1.3.0",
|
|
73
|
+
"@backstage/core-compat-api": "^0.3.2",
|
|
74
|
+
"@backstage/core-components": "^0.16.0",
|
|
75
|
+
"@backstage/core-plugin-api": "^1.10.1",
|
|
76
|
+
"@backstage/errors": "^1.2.5",
|
|
77
|
+
"@backstage/frontend-plugin-api": "^0.9.1",
|
|
78
|
+
"@backstage/integration": "^1.15.2",
|
|
79
|
+
"@backstage/integration-react": "^1.2.1",
|
|
80
|
+
"@backstage/plugin-auth-react": "^0.1.8",
|
|
81
|
+
"@backstage/plugin-catalog-react": "^1.14.1",
|
|
82
|
+
"@backstage/plugin-search-common": "^1.2.15",
|
|
83
|
+
"@backstage/plugin-search-react": "^1.8.2",
|
|
84
|
+
"@backstage/plugin-techdocs-common": "^0.1.0",
|
|
85
|
+
"@backstage/plugin-techdocs-react": "^1.2.10",
|
|
86
|
+
"@backstage/theme": "^0.6.1",
|
|
78
87
|
"@material-ui/core": "^4.12.2",
|
|
79
88
|
"@material-ui/icons": "^4.9.1",
|
|
80
89
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
@@ -88,11 +97,11 @@
|
|
|
88
97
|
"react-use": "^17.2.4"
|
|
89
98
|
},
|
|
90
99
|
"devDependencies": {
|
|
91
|
-
"@backstage/cli": "0.29.0
|
|
92
|
-
"@backstage/core-app-api": "1.15.
|
|
93
|
-
"@backstage/dev-utils": "1.1.3
|
|
94
|
-
"@backstage/plugin-techdocs-module-addons-contrib": "1.1.17
|
|
95
|
-
"@backstage/test-utils": "1.7.1
|
|
100
|
+
"@backstage/cli": "^0.29.0",
|
|
101
|
+
"@backstage/core-app-api": "^1.15.2",
|
|
102
|
+
"@backstage/dev-utils": "^1.1.3",
|
|
103
|
+
"@backstage/plugin-techdocs-module-addons-contrib": "^1.1.17",
|
|
104
|
+
"@backstage/test-utils": "^1.7.1",
|
|
96
105
|
"@testing-library/dom": "^10.0.0",
|
|
97
106
|
"@testing-library/jest-dom": "^6.0.0",
|
|
98
107
|
"@testing-library/react": "^16.0.0",
|