@backstage/plugin-techdocs 0.0.0-nightly-20241119023621 → 0.0.0-nightly-20241121023535
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 +40 -16
- package/dist/EntityPageDocs.esm.js +13 -2
- package/dist/EntityPageDocs.esm.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js +3 -2
- package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.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/search/components/TechDocsSearch.esm.js +9 -2
- package/dist/search/components/TechDocsSearch.esm.js.map +1 -1
- package/dist/search/hooks/useTechDocsLocation.esm.js +26 -0
- package/dist/search/hooks/useTechDocsLocation.esm.js.map +1 -0
- package/package.json +21 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20241121023535
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7d8777d: Added support for the Search bar in docs residing in the entity page tab, and not only the global "/docs" page.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/plugin-search-react@0.0.0-nightly-20241121023535
|
|
10
|
+
- @backstage/catalog-model@1.7.1
|
|
11
|
+
- @backstage/config@1.3.0
|
|
12
|
+
- @backstage/core-compat-api@0.3.2
|
|
13
|
+
- @backstage/core-components@0.16.0
|
|
14
|
+
- @backstage/core-plugin-api@1.10.1
|
|
15
|
+
- @backstage/errors@1.2.5
|
|
16
|
+
- @backstage/frontend-plugin-api@0.9.1
|
|
17
|
+
- @backstage/integration@1.15.2
|
|
18
|
+
- @backstage/integration-react@1.2.1
|
|
19
|
+
- @backstage/theme@0.6.1
|
|
20
|
+
- @backstage/plugin-auth-react@0.1.8
|
|
21
|
+
- @backstage/plugin-catalog-react@1.14.1
|
|
22
|
+
- @backstage/plugin-search-common@1.2.15
|
|
23
|
+
- @backstage/plugin-techdocs-common@0.1.0
|
|
24
|
+
- @backstage/plugin-techdocs-react@1.2.10
|
|
25
|
+
|
|
26
|
+
## 1.11.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
6
29
|
|
|
30
|
+
- 37a7810: Fixed an issue where `<TechDocsReaderPageContent />` would re-render infinitely under certain conditions.
|
|
7
31
|
- e937ae7: Fix an issue with index page of documentation site being re-rendered.
|
|
8
32
|
- 90246a9: Fix techdocs config schema for custom elements sanitizer
|
|
9
33
|
- 605bdc0: Avoid page re-rendering when clicking on anchor links in the same documentation page.
|
|
@@ -13,21 +37,21 @@
|
|
|
13
37
|
- 4a2f73a: Fix an issue that caused the current documentation page to be re-rendered when navigating to
|
|
14
38
|
another one.
|
|
15
39
|
- Updated dependencies
|
|
16
|
-
- @backstage/
|
|
17
|
-
- @backstage/
|
|
18
|
-
- @backstage/plugin-catalog-react@
|
|
19
|
-
- @backstage/
|
|
20
|
-
- @backstage/
|
|
21
|
-
- @backstage/
|
|
22
|
-
- @backstage/core-compat-api@0.
|
|
23
|
-
- @backstage/core-plugin-api@
|
|
24
|
-
- @backstage/errors@
|
|
25
|
-
- @backstage/frontend-plugin-api@0.
|
|
26
|
-
- @backstage/integration@
|
|
27
|
-
- @backstage/integration-react@
|
|
28
|
-
- @backstage/plugin-auth-react@0.
|
|
29
|
-
- @backstage/plugin-search-common@
|
|
30
|
-
- @backstage/plugin-search-react@
|
|
40
|
+
- @backstage/config@1.3.0
|
|
41
|
+
- @backstage/theme@0.6.1
|
|
42
|
+
- @backstage/plugin-catalog-react@1.14.1
|
|
43
|
+
- @backstage/core-components@0.16.0
|
|
44
|
+
- @backstage/plugin-techdocs-react@1.2.10
|
|
45
|
+
- @backstage/catalog-model@1.7.1
|
|
46
|
+
- @backstage/core-compat-api@0.3.2
|
|
47
|
+
- @backstage/core-plugin-api@1.10.1
|
|
48
|
+
- @backstage/errors@1.2.5
|
|
49
|
+
- @backstage/frontend-plugin-api@0.9.1
|
|
50
|
+
- @backstage/integration@1.15.2
|
|
51
|
+
- @backstage/integration-react@1.2.1
|
|
52
|
+
- @backstage/plugin-auth-react@0.1.8
|
|
53
|
+
- @backstage/plugin-search-common@1.2.15
|
|
54
|
+
- @backstage/plugin-search-react@1.8.2
|
|
31
55
|
- @backstage/plugin-techdocs-common@0.1.0
|
|
32
56
|
|
|
33
57
|
## 1.11.1-next.3
|
|
@@ -4,9 +4,14 @@ import React from 'react';
|
|
|
4
4
|
import { TechDocsReaderPage } from './plugin.esm.js';
|
|
5
5
|
import { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js';
|
|
6
6
|
import { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader/TechDocsReaderPageSubheader.esm.js';
|
|
7
|
+
import { useEntityPageTechDocsRedirect } from './search/hooks/useTechDocsLocation.esm.js';
|
|
7
8
|
|
|
8
|
-
const EntityPageDocs = ({
|
|
9
|
+
const EntityPageDocs = ({
|
|
10
|
+
entity,
|
|
11
|
+
withSearch = true
|
|
12
|
+
}) => {
|
|
9
13
|
let entityRef = getCompoundEntityRef(entity);
|
|
14
|
+
const searchResultUrlMapper = useEntityPageTechDocsRedirect(entityRef);
|
|
10
15
|
if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {
|
|
11
16
|
try {
|
|
12
17
|
entityRef = parseEntityRef(
|
|
@@ -15,7 +20,13 @@ const EntityPageDocs = ({ entity }) => {
|
|
|
15
20
|
} catch {
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
|
-
return /* @__PURE__ */ React.createElement(TechDocsReaderPage, { entityRef }, /* @__PURE__ */ React.createElement(TechDocsReaderPageSubheader, null), /* @__PURE__ */ React.createElement(
|
|
23
|
+
return /* @__PURE__ */ React.createElement(TechDocsReaderPage, { entityRef }, /* @__PURE__ */ React.createElement(TechDocsReaderPageSubheader, null), /* @__PURE__ */ React.createElement(
|
|
24
|
+
TechDocsReaderPageContent,
|
|
25
|
+
{
|
|
26
|
+
withSearch,
|
|
27
|
+
searchResultUrlMapper
|
|
28
|
+
}
|
|
29
|
+
));
|
|
19
30
|
};
|
|
20
31
|
|
|
21
32
|
export { EntityPageDocs };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityPageDocs.esm.js","sources":["../src/EntityPageDocs.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport { TECHDOCS_EXTERNAL_ANNOTATION } from '@backstage/plugin-techdocs-common';\n\nimport React from 'react';\nimport { TechDocsReaderPage } from './plugin';\nimport { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent';\nimport { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader';\n\ntype EntityPageDocsProps = {
|
|
1
|
+
{"version":3,"file":"EntityPageDocs.esm.js","sources":["../src/EntityPageDocs.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 {\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport { TECHDOCS_EXTERNAL_ANNOTATION } from '@backstage/plugin-techdocs-common';\n\nimport React from 'react';\nimport { TechDocsReaderPage } from './plugin';\nimport { TechDocsReaderPageContent } from './reader/components/TechDocsReaderPageContent';\nimport { TechDocsReaderPageSubheader } from './reader/components/TechDocsReaderPageSubheader';\nimport { useEntityPageTechDocsRedirect } from './search/hooks/useTechDocsLocation';\n\ntype EntityPageDocsProps = {\n entity: Entity;\n /**\n * Show or hide the content search bar, defaults to true.\n */\n withSearch?: boolean;\n};\n\nexport const EntityPageDocs = ({\n entity,\n withSearch = true,\n}: EntityPageDocsProps) => {\n let entityRef = getCompoundEntityRef(entity);\n\n const searchResultUrlMapper = useEntityPageTechDocsRedirect(entityRef);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n entityRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n return (\n <TechDocsReaderPage entityRef={entityRef}>\n <TechDocsReaderPageSubheader />\n <TechDocsReaderPageContent\n withSearch={withSearch}\n searchResultUrlMapper={searchResultUrlMapper}\n />\n </TechDocsReaderPage>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAqCO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,MAAA;AAAA,EACA,UAAa,GAAA;AACf,CAA2B,KAAA;AACzB,EAAI,IAAA,SAAA,GAAY,qBAAqB,MAAM,CAAA;AAE3C,EAAM,MAAA,qBAAA,GAAwB,8BAA8B,SAAS,CAAA;AAErE,EAAA,IAAI,MAAO,CAAA,QAAA,CAAS,WAAc,GAAA,4BAA4B,CAAG,EAAA;AAC/D,IAAI,IAAA;AACF,MAAY,SAAA,GAAA,cAAA;AAAA,QACV,MAAA,CAAO,QAAS,CAAA,WAAA,GAAc,4BAA4B;AAAA,OAC5D;AAAA,KACM,CAAA,MAAA;AAAA;AAER;AAGF,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,kBAAA,EAAA,EAAmB,SAClB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,iCAA4B,CAC7B,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,yBAAA;AAAA,IAAA;AAAA,MACC,UAAA;AAAA,MACA;AAAA;AAAA,GAEJ,CAAA;AAEJ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -263,6 +263,13 @@ type TechDocsReaderPageContentProps = {
|
|
|
263
263
|
* Show or hide the search bar, defaults to true.
|
|
264
264
|
*/
|
|
265
265
|
withSearch?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* If {@link TechDocsReaderPageContentProps.withSearch | withSearch} is true,
|
|
268
|
+
* this will redirect the search result urls, e.g. turn search results into
|
|
269
|
+
* links within the "Docs" tab of the entity page, instead of the global docs
|
|
270
|
+
* page.
|
|
271
|
+
*/
|
|
272
|
+
searchResultUrlMapper?: (url: string) => string;
|
|
266
273
|
/**
|
|
267
274
|
* Callback called when the content is rendered.
|
|
268
275
|
*/
|
|
@@ -298,6 +305,7 @@ type TechDocsSearchProps = {
|
|
|
298
305
|
entityId: CompoundEntityRef;
|
|
299
306
|
entityTitle?: string;
|
|
300
307
|
debounceTime?: number;
|
|
308
|
+
searchResultUrlMapper?: (url: string) => string;
|
|
301
309
|
};
|
|
302
310
|
/**
|
|
303
311
|
* Component used to render search bar on TechDocs page, scoped to
|
|
@@ -23,7 +23,7 @@ const useStyles = makeStyles({
|
|
|
23
23
|
});
|
|
24
24
|
const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
|
25
25
|
(props) => {
|
|
26
|
-
const { withSearch = true, onReady } = props;
|
|
26
|
+
const { withSearch = true, searchResultUrlMapper, onReady } = props;
|
|
27
27
|
const classes = useStyles();
|
|
28
28
|
const {
|
|
29
29
|
entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },
|
|
@@ -64,7 +64,8 @@ const TechDocsReaderPageContent = withTechDocsReaderProvider(
|
|
|
64
64
|
TechDocsSearch,
|
|
65
65
|
{
|
|
66
66
|
entityId: entityRef,
|
|
67
|
-
entityTitle: entityMetadata?.metadata?.title
|
|
67
|
+
entityTitle: entityMetadata?.metadata?.title,
|
|
68
|
+
searchResultUrlMapper
|
|
68
69
|
}
|
|
69
70
|
)), /* @__PURE__ */ React.createElement(Grid, { xs: 12, item: true }, (state === "CHECKING" || isStyleLoading) && /* @__PURE__ */ React.createElement(Progress, null), /* @__PURE__ */ React.createElement(TechDocsShadowDom, { element: dom, onAppend: handleAppend }, /* @__PURE__ */ React.createElement(TechDocsReaderPageContentAddons, null)))));
|
|
70
71
|
}
|
package/dist/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsReaderPageContent.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.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 React, { useCallback, useEffect } from 'react';\n\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles } from '@material-ui/core/styles';\n\nimport {\n TechDocsShadowDom,\n useShadowDomStylesLoading,\n useShadowRootElements,\n useTechDocsReaderPage,\n} from '@backstage/plugin-techdocs-react';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { Content, ErrorPage, Progress } from '@backstage/core-components';\n\nimport { TechDocsSearch } from '../../../search';\nimport { TechDocsStateIndicator } from '../TechDocsStateIndicator';\n\nimport { useTechDocsReaderDom } from './dom';\nimport {\n useTechDocsReader,\n withTechDocsReaderProvider,\n} from '../TechDocsReaderProvider';\nimport { TechDocsReaderPageContentAddons } from './TechDocsReaderPageContentAddons';\n\nconst useStyles = makeStyles({\n search: {\n width: '100%',\n '@media (min-width: 76.1875em)': {\n width: 'calc(100% - 34.4rem)',\n margin: '0 auto',\n },\n '@media print': {\n display: 'none',\n },\n },\n});\n\n/**\n * Props for {@link TechDocsReaderPageContent}\n * @public\n */\nexport type TechDocsReaderPageContentProps = {\n /**\n * @deprecated No need to pass down entityRef as property anymore. Consumes the entityName from `TechDocsReaderPageContext`. Use the {@link @backstage/plugin-techdocs-react#useTechDocsReaderPage} hook for custom reader page content.\n */\n entityRef?: CompoundEntityRef;\n /**\n * Show or hide the search bar, defaults to true.\n */\n withSearch?: boolean;\n /**\n * Callback called when the content is rendered.\n */\n onReady?: () => void;\n};\n\n/**\n * Renders the reader page content\n * @public\n */\nexport const TechDocsReaderPageContent = withTechDocsReaderProvider(\n (props: TechDocsReaderPageContentProps) => {\n const { withSearch = true, onReady } = props;\n const classes = useStyles();\n\n const {\n entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },\n entityRef,\n setShadowRoot,\n } = useTechDocsReaderPage();\n const { state } = useTechDocsReader();\n const dom = useTechDocsReaderDom(entityRef);\n const path = window.location.pathname;\n const hash = window.location.hash;\n const isStyleLoading = useShadowDomStylesLoading(dom);\n const [hashElement] = useShadowRootElements([`[id=\"${hash.slice(1)}\"]`]);\n\n useEffect(() => {\n if (isStyleLoading) return;\n\n if (hash) {\n if (hashElement) {\n hashElement.scrollIntoView();\n }\n } else {\n document?.querySelector('header')?.scrollIntoView();\n }\n }, [path, hash, hashElement, isStyleLoading]);\n\n const handleAppend = useCallback(\n (newShadowRoot: ShadowRoot) => {\n setShadowRoot(newShadowRoot);\n if (onReady instanceof Function) {\n onReady();\n }\n },\n [setShadowRoot, onReady],\n );\n\n // No entity metadata = 404. Don't render content at all.\n if (entityMetadataLoading === false && !entityMetadata)\n return <ErrorPage status=\"404\" statusMessage=\"PAGE NOT FOUND\" />;\n\n // Do not return content until dom is ready; instead, render a state\n // indicator, which handles progress and content errors on our behalf.\n if (!dom) {\n return (\n <Content>\n <Grid container>\n <Grid xs={12} item>\n <TechDocsStateIndicator />\n </Grid>\n </Grid>\n </Content>\n );\n }\n\n return (\n <Content>\n <Grid container>\n <Grid xs={12} item>\n <TechDocsStateIndicator />\n </Grid>\n {withSearch && (\n <Grid className={classes.search} xs=\"auto\" item>\n <TechDocsSearch\n entityId={entityRef}\n entityTitle={entityMetadata?.metadata?.title}\n />\n </Grid>\n )}\n <Grid xs={12} item>\n {/* Centers the styles loaded event to avoid having multiple locations setting the opacity style in Shadow Dom causing the screen to flash multiple times */}\n {(state === 'CHECKING' || isStyleLoading) && <Progress />}\n\n <TechDocsShadowDom element={dom} onAppend={handleAppend}>\n <TechDocsReaderPageContentAddons />\n </TechDocsShadowDom>\n </Grid>\n </Grid>\n </Content>\n );\n },\n);\n\n/**\n * Props for {@link Reader}\n *\n * @public\n * @deprecated use `TechDocsReaderPageContentProps` instead.\n */\nexport type ReaderProps = TechDocsReaderPageContentProps;\n\n/**\n * Component responsible for rendering TechDocs documentation\n * @public\n * @deprecated use `TechDocsReaderPageContent` component instead.\n */\nexport const Reader = TechDocsReaderPageContent;\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,MAAA;AAAA,IACP,+BAAiC,EAAA;AAAA,MAC/B,KAAO,EAAA,sBAAA;AAAA,MACP,MAAQ,EAAA;AAAA,KACV;AAAA,IACA,cAAgB,EAAA;AAAA,MACd,OAAS,EAAA;AAAA;AACX;AAEJ,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"TechDocsReaderPageContent.esm.js","sources":["../../../../src/reader/components/TechDocsReaderPageContent/TechDocsReaderPageContent.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 React, { useCallback, useEffect } from 'react';\n\nimport Grid from '@material-ui/core/Grid';\nimport { makeStyles } from '@material-ui/core/styles';\n\nimport {\n TechDocsShadowDom,\n useShadowDomStylesLoading,\n useShadowRootElements,\n useTechDocsReaderPage,\n} from '@backstage/plugin-techdocs-react';\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { Content, ErrorPage, Progress } from '@backstage/core-components';\n\nimport { TechDocsSearch } from '../../../search';\nimport { TechDocsStateIndicator } from '../TechDocsStateIndicator';\n\nimport { useTechDocsReaderDom } from './dom';\nimport {\n useTechDocsReader,\n withTechDocsReaderProvider,\n} from '../TechDocsReaderProvider';\nimport { TechDocsReaderPageContentAddons } from './TechDocsReaderPageContentAddons';\n\nconst useStyles = makeStyles({\n search: {\n width: '100%',\n '@media (min-width: 76.1875em)': {\n width: 'calc(100% - 34.4rem)',\n margin: '0 auto',\n },\n '@media print': {\n display: 'none',\n },\n },\n});\n\n/**\n * Props for {@link TechDocsReaderPageContent}\n * @public\n */\nexport type TechDocsReaderPageContentProps = {\n /**\n * @deprecated No need to pass down entityRef as property anymore. Consumes the entityName from `TechDocsReaderPageContext`. Use the {@link @backstage/plugin-techdocs-react#useTechDocsReaderPage} hook for custom reader page content.\n */\n entityRef?: CompoundEntityRef;\n /**\n * Show or hide the search bar, defaults to true.\n */\n withSearch?: boolean;\n /**\n * If {@link TechDocsReaderPageContentProps.withSearch | withSearch} is true,\n * this will redirect the search result urls, e.g. turn search results into\n * links within the \"Docs\" tab of the entity page, instead of the global docs\n * page.\n */\n searchResultUrlMapper?: (url: string) => string;\n /**\n * Callback called when the content is rendered.\n */\n onReady?: () => void;\n};\n\n/**\n * Renders the reader page content\n * @public\n */\nexport const TechDocsReaderPageContent = withTechDocsReaderProvider(\n (props: TechDocsReaderPageContentProps) => {\n const { withSearch = true, searchResultUrlMapper, onReady } = props;\n const classes = useStyles();\n\n const {\n entityMetadata: { value: entityMetadata, loading: entityMetadataLoading },\n entityRef,\n setShadowRoot,\n } = useTechDocsReaderPage();\n const { state } = useTechDocsReader();\n const dom = useTechDocsReaderDom(entityRef);\n const path = window.location.pathname;\n const hash = window.location.hash;\n const isStyleLoading = useShadowDomStylesLoading(dom);\n const [hashElement] = useShadowRootElements([`[id=\"${hash.slice(1)}\"]`]);\n\n useEffect(() => {\n if (isStyleLoading) return;\n\n if (hash) {\n if (hashElement) {\n hashElement.scrollIntoView();\n }\n } else {\n document?.querySelector('header')?.scrollIntoView();\n }\n }, [path, hash, hashElement, isStyleLoading]);\n\n const handleAppend = useCallback(\n (newShadowRoot: ShadowRoot) => {\n setShadowRoot(newShadowRoot);\n if (onReady instanceof Function) {\n onReady();\n }\n },\n [setShadowRoot, onReady],\n );\n\n // No entity metadata = 404. Don't render content at all.\n if (entityMetadataLoading === false && !entityMetadata)\n return <ErrorPage status=\"404\" statusMessage=\"PAGE NOT FOUND\" />;\n\n // Do not return content until dom is ready; instead, render a state\n // indicator, which handles progress and content errors on our behalf.\n if (!dom) {\n return (\n <Content>\n <Grid container>\n <Grid xs={12} item>\n <TechDocsStateIndicator />\n </Grid>\n </Grid>\n </Content>\n );\n }\n\n return (\n <Content>\n <Grid container>\n <Grid xs={12} item>\n <TechDocsStateIndicator />\n </Grid>\n {withSearch && (\n <Grid className={classes.search} xs=\"auto\" item>\n <TechDocsSearch\n entityId={entityRef}\n entityTitle={entityMetadata?.metadata?.title}\n searchResultUrlMapper={searchResultUrlMapper}\n />\n </Grid>\n )}\n <Grid xs={12} item>\n {/* Centers the styles loaded event to avoid having multiple locations setting the opacity style in Shadow Dom causing the screen to flash multiple times */}\n {(state === 'CHECKING' || isStyleLoading) && <Progress />}\n\n <TechDocsShadowDom element={dom} onAppend={handleAppend}>\n <TechDocsReaderPageContentAddons />\n </TechDocsShadowDom>\n </Grid>\n </Grid>\n </Content>\n );\n },\n);\n\n/**\n * Props for {@link Reader}\n *\n * @public\n * @deprecated use `TechDocsReaderPageContentProps` instead.\n */\nexport type ReaderProps = TechDocsReaderPageContentProps;\n\n/**\n * Component responsible for rendering TechDocs documentation\n * @public\n * @deprecated use `TechDocsReaderPageContent` component instead.\n */\nexport const Reader = TechDocsReaderPageContent;\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,MAAM,YAAY,UAAW,CAAA;AAAA,EAC3B,MAAQ,EAAA;AAAA,IACN,KAAO,EAAA,MAAA;AAAA,IACP,+BAAiC,EAAA;AAAA,MAC/B,KAAO,EAAA,sBAAA;AAAA,MACP,MAAQ,EAAA;AAAA,KACV;AAAA,IACA,cAAgB,EAAA;AAAA,MACd,OAAS,EAAA;AAAA;AACX;AAEJ,CAAC,CAAA;AAgCM,MAAM,yBAA4B,GAAA,0BAAA;AAAA,EACvC,CAAC,KAA0C,KAAA;AACzC,IAAA,MAAM,EAAE,UAAA,GAAa,IAAM,EAAA,qBAAA,EAAuB,SAAY,GAAA,KAAA;AAC9D,IAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,IAAM,MAAA;AAAA,MACJ,cAAgB,EAAA,EAAE,KAAO,EAAA,cAAA,EAAgB,SAAS,qBAAsB,EAAA;AAAA,MACxE,SAAA;AAAA,MACA;AAAA,QACE,qBAAsB,EAAA;AAC1B,IAAM,MAAA,EAAE,KAAM,EAAA,GAAI,iBAAkB,EAAA;AACpC,IAAM,MAAA,GAAA,GAAM,qBAAqB,SAAS,CAAA;AAC1C,IAAM,MAAA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,kBAAA,KAAA,CAAA,aAAA,CAAC,sBAAuB,EAAA,IAAA,CAC1B,CACF,CACF,CAAA;AAAA;AAIJ,IACE,uBAAA,KAAA,CAAA,aAAA,CAAC,OACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,SAAA,EAAS,wBACZ,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,EAAI,EAAA,EAAA,EAAI,IAAI,EAAA,IAAA,EAAA,sCACf,sBAAuB,EAAA,IAAA,CAC1B,CACC,EAAA,UAAA,oBACE,KAAA,CAAA,aAAA,CAAA,IAAA,EAAA,EAAK,SAAW,EAAA,OAAA,CAAQ,MAAQ,EAAA,EAAA,EAAG,MAAO,EAAA,IAAA,EAAI,IAC7C,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,cAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,SAAA;AAAA,QACV,WAAA,EAAa,gBAAgB,QAAU,EAAA,KAAA;AAAA,QACvC;AAAA;AAAA,KAEJ,CAEF,kBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAI,IAAI,IAAI,EAAA,IAAA,EAAA,EAAA,CAEd,KAAU,KAAA,UAAA,IAAc,cAAmB,qBAAA,KAAA,CAAA,aAAA,CAAC,cAAS,CAEvD,kBAAA,KAAA,CAAA,aAAA,CAAC,iBAAkB,EAAA,EAAA,OAAA,EAAS,GAAK,EAAA,QAAA,EAAU,YACzC,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,+BAAgC,EAAA,IAAA,CACnC,CACF,CACF,CACF,CAAA;AAAA;AAGN;AAeO,MAAM,MAAS,GAAA;;;;"}
|
|
@@ -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"],"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;AA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AAA,QAAA,EAAU,UAAU,CAAC,CAAA;AAEpE,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,MACE,qBAAsB,CAAA;AAAA,MACpB,iBAAiB,KAAM,CAAA,eAAA;AAAA,MACvB,gBAAgB,KAAM,CAAA,cAAA;AAAA,MACtB,SAAS,KAAM,CAAA;AAAA,KAChB,CAAA;AAAA,IACH,CAAC,KAAM,CAAA,eAAA,EAAiB,KAAM,CAAA,OAAA,EAAS,MAAM,cAAc;AAAA,GAC7D;AAEA,EAAO,OAAA;AAAA,IACL,KAAO,EAAA,YAAA;AAAA,IACP,aAAA;AAAA,IACA,MAAM,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,EA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,OAAS,EAAA,SAAA,EAAW,GAAG,CAAA;AAAA,KACvD,SAAA;AAEA,MAAA,YAAA,CAAa,eAAe,CAAA;AAAA;AAC9B,GACF,EAAG,CAAC,IAAM,EAAA,IAAA,EAAM,WAAW,kBAAoB,EAAA,QAAA,EAAU,UAAU,CAAC,CAAA;AAEpE,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACnB,MACE,qBAAsB,CAAA;AAAA,MACpB,iBAAiB,KAAM,CAAA,eAAA;AAAA,MACvB,gBAAgB,KAAM,CAAA,cAAA;AAAA,MACtB,SAAS,KAAM,CAAA;AAAA,KAChB,CAAA;AAAA,IACH,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;;;;"}
|
|
@@ -7,7 +7,12 @@ const isTechDocsSearchResult = (option) => {
|
|
|
7
7
|
return option?.document;
|
|
8
8
|
};
|
|
9
9
|
const TechDocsSearchBar = (props) => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
entityId,
|
|
12
|
+
entityTitle,
|
|
13
|
+
debounceTime = 150,
|
|
14
|
+
searchResultUrlMapper
|
|
15
|
+
} = props;
|
|
11
16
|
const [open, setOpen] = useState(false);
|
|
12
17
|
const navigate = useNavigate();
|
|
13
18
|
const {
|
|
@@ -40,7 +45,9 @@ const TechDocsSearchBar = (props) => {
|
|
|
40
45
|
const handleSelection = (_, selection) => {
|
|
41
46
|
if (isTechDocsSearchResult(selection)) {
|
|
42
47
|
const { location } = selection.document;
|
|
43
|
-
navigate(
|
|
48
|
+
navigate(
|
|
49
|
+
searchResultUrlMapper ? searchResultUrlMapper(location) : location
|
|
50
|
+
);
|
|
44
51
|
}
|
|
45
52
|
};
|
|
46
53
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TechDocsSearch.esm.js","sources":["../../../src/search/components/TechDocsSearch.tsx"],"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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { ResultHighlight } from '@backstage/plugin-search-common';\nimport {\n SearchAutocomplete,\n SearchContextProvider,\n useSearch,\n} from '@backstage/plugin-search-react';\nimport React, { useEffect, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { TechDocsSearchResultListItem } from './TechDocsSearchResultListItem';\n\n/**\n * Props for {@link TechDocsSearch}\n *\n * @public\n */\nexport type TechDocsSearchProps = {\n entityId: CompoundEntityRef;\n entityTitle?: string;\n debounceTime?: number;\n};\n\ntype TechDocsDoc = {\n namespace: string;\n kind: string;\n name: string;\n path: string;\n location: string;\n title: string;\n};\n\ntype TechDocsSearchResult = {\n type: string;\n document: TechDocsDoc;\n highlight?: ResultHighlight;\n};\n\nconst isTechDocsSearchResult = (\n option: any,\n): option is TechDocsSearchResult => {\n return option?.document;\n};\n\nconst TechDocsSearchBar = (props: TechDocsSearchProps) => {\n const {
|
|
1
|
+
{"version":3,"file":"TechDocsSearch.esm.js","sources":["../../../src/search/components/TechDocsSearch.tsx"],"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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { ResultHighlight } from '@backstage/plugin-search-common';\nimport {\n SearchAutocomplete,\n SearchContextProvider,\n useSearch,\n} from '@backstage/plugin-search-react';\nimport React, { useEffect, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { TechDocsSearchResultListItem } from './TechDocsSearchResultListItem';\n\n/**\n * Props for {@link TechDocsSearch}\n *\n * @public\n */\nexport type TechDocsSearchProps = {\n entityId: CompoundEntityRef;\n entityTitle?: string;\n debounceTime?: number;\n searchResultUrlMapper?: (url: string) => string;\n};\n\ntype TechDocsDoc = {\n namespace: string;\n kind: string;\n name: string;\n path: string;\n location: string;\n title: string;\n};\n\ntype TechDocsSearchResult = {\n type: string;\n document: TechDocsDoc;\n highlight?: ResultHighlight;\n};\n\nconst isTechDocsSearchResult = (\n option: any,\n): option is TechDocsSearchResult => {\n return option?.document;\n};\n\nconst TechDocsSearchBar = (props: TechDocsSearchProps) => {\n const {\n entityId,\n entityTitle,\n debounceTime = 150,\n searchResultUrlMapper,\n } = props;\n const [open, setOpen] = useState(false);\n const navigate = useNavigate();\n const {\n setFilters,\n term,\n result: { loading, value: searchVal },\n } = useSearch();\n const [options, setOptions] = useState<any[]>([]);\n useEffect(() => {\n let mounted = true;\n\n if (mounted && searchVal) {\n // TODO: Change this into getting only subset of search results from the BE in the first place\n // once pagination is implemented for search engines\n // See: https://github.com/backstage/backstage/issues/6062\n const searchResults = searchVal.results.slice(0, 10);\n setOptions(searchResults);\n }\n return () => {\n mounted = false;\n };\n }, [loading, searchVal]);\n\n // Update the filter context when the entityId changes, e.g. when the search\n // bar continues to be rendered, navigating between different TechDocs sites.\n const { kind, name, namespace } = entityId;\n useEffect(() => {\n setFilters(prevFilters => {\n return {\n ...prevFilters,\n kind,\n namespace,\n name,\n };\n });\n }, [kind, namespace, name, setFilters]);\n\n const handleSelection = (\n _: any,\n selection: TechDocsSearchResult | string | null,\n ) => {\n if (isTechDocsSearchResult(selection)) {\n const { location } = selection.document;\n navigate(\n searchResultUrlMapper ? searchResultUrlMapper(location) : location,\n );\n }\n };\n\n return (\n <SearchAutocomplete\n data-testid=\"techdocs-search-bar\"\n size=\"small\"\n open={open && Boolean(term)}\n getOptionLabel={() => ''}\n filterOptions={x => {\n return x; // This is needed to get renderOption to be called after options change. Bug in material-ui?\n }}\n onClose={() => {\n setOpen(false);\n }}\n onOpen={() => {\n setOpen(true);\n }}\n onChange={handleSelection}\n blurOnSelect\n noOptionsText=\"No results found\"\n value={null}\n options={options}\n renderOption={({ document, highlight }) => (\n <TechDocsSearchResultListItem\n result={document}\n lineClamp={3}\n asListItem={false}\n asLink={false}\n title={document.title}\n highlight={highlight}\n />\n )}\n loading={loading}\n inputDebounceTime={debounceTime}\n inputPlaceholder={`Search ${entityTitle || entityId.name} docs`}\n freeSolo={false}\n />\n );\n};\n\n/**\n * Component used to render search bar on TechDocs page, scoped to\n *\n * @public\n */\nexport const TechDocsSearch = (props: TechDocsSearchProps) => {\n const initialState = {\n term: '',\n types: ['techdocs'],\n pageCursor: '',\n filters: props.entityId,\n };\n return (\n <SearchContextProvider initialState={initialState}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ACF;AAAA,MAEF,OAAA;AAAA,MACA,iBAAmB,EAAA,YAAA;AAAA,MACnB,gBAAkB,EAAA,CAAA,OAAA,EAAU,WAAe,IAAA,QAAA,CAAS,IAAI,CAAA,KAAA,CAAA;AAAA,MACxD,QAAU,EAAA;AAAA;AAAA,GACZ;AAEJ,CAAA;AAOa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAA,MAAM,YAAe,GAAA;AAAA,IACnB,IAAM,EAAA,EAAA;AAAA,IACN,KAAA,EAAO,CAAC,UAAU,CAAA;AAAA,IAClB,UAAY,EAAA,EAAA;AAAA,IACZ,SAAS,KAAM,CAAA;AAAA,GACjB;AACA,EAAA,2CACG,qBAAsB,EAAA,EAAA,YAAA,EAAA,sCACpB,iBAAmB,EAAA,EAAA,GAAG,OAAO,CAChC,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useRouteRef } from '@backstage/core-plugin-api';
|
|
3
|
+
import { rootDocsRouteRef, rootCatalogDocsRouteRef } from '../../routes.esm.js';
|
|
4
|
+
|
|
5
|
+
const trimStartSlash = (path) => path.replace(/^\/+/, "");
|
|
6
|
+
const trimEndSlash = (path) => path.replace(/\/+$/, "");
|
|
7
|
+
function useEntityPageTechDocsRedirect(entityRef) {
|
|
8
|
+
const { kind, name, namespace } = entityRef;
|
|
9
|
+
const routeDocsRoot = useRouteRef(rootDocsRouteRef);
|
|
10
|
+
const routeDocsCatalog = useRouteRef(rootCatalogDocsRouteRef);
|
|
11
|
+
const reRouteLocationToCatalog = useMemo(() => {
|
|
12
|
+
const rootDocsPath = trimEndSlash(routeDocsRoot({ kind, namespace, name }));
|
|
13
|
+
const catalogDocsPath = trimEndSlash(routeDocsCatalog());
|
|
14
|
+
return (url) => {
|
|
15
|
+
if (url.toLocaleLowerCase("en-US").startsWith(rootDocsPath.toLocaleLowerCase("en-US"))) {
|
|
16
|
+
const suffix = trimStartSlash(url.slice(rootDocsPath.length));
|
|
17
|
+
return suffix.length === 0 || suffix.startsWith("#") ? `${catalogDocsPath}${suffix}` : `${catalogDocsPath}/${suffix}`;
|
|
18
|
+
}
|
|
19
|
+
return url;
|
|
20
|
+
};
|
|
21
|
+
}, [routeDocsRoot, routeDocsCatalog, kind, name, namespace]);
|
|
22
|
+
return reRouteLocationToCatalog;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { useEntityPageTechDocsRedirect };
|
|
26
|
+
//# sourceMappingURL=useTechDocsLocation.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTechDocsLocation.esm.js","sources":["../../../src/search/hooks/useTechDocsLocation.ts"],"sourcesContent":["/*\n * Copyright 2024 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 */\nimport { useMemo } from 'react';\n\nimport { CompoundEntityRef } from '@backstage/catalog-model';\nimport { useRouteRef } from '@backstage/core-plugin-api';\n\nimport { rootCatalogDocsRouteRef, rootDocsRouteRef } from '../../routes';\n\nconst trimStartSlash = (path: string) => path.replace(/^\\/+/, '');\nconst trimEndSlash = (path: string) => path.replace(/\\/+$/, '');\n\n/**\n * Returns a function that takes a location to a Tech Docs entry, and returns a\n * new location, re-routed to the catalog page tab.\n *\n * @internal\n */\nexport function useEntityPageTechDocsRedirect(entityRef: CompoundEntityRef) {\n const { kind, name, namespace } = entityRef;\n\n const routeDocsRoot = useRouteRef(rootDocsRouteRef);\n const routeDocsCatalog = useRouteRef(rootCatalogDocsRouteRef);\n\n // Re-routes a /docs/:namespace/:kind/:name/* location into\n // /catalog/:namespace/:kind/:name/docs/*, while handling situations where\n // these defaults are changed.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const reRouteLocationToCatalog = useMemo(() => {\n const rootDocsPath = trimEndSlash(routeDocsRoot({ kind, namespace, name }));\n const catalogDocsPath = trimEndSlash(routeDocsCatalog());\n\n return (url: string): string => {\n if (\n url\n .toLocaleLowerCase('en-US')\n .startsWith(rootDocsPath.toLocaleLowerCase('en-US'))\n ) {\n const suffix = trimStartSlash(url.slice(rootDocsPath.length));\n return suffix.length === 0 || suffix.startsWith('#')\n ? `${catalogDocsPath}${suffix}`\n : `${catalogDocsPath}/${suffix}`;\n }\n return url;\n };\n }, [routeDocsRoot, routeDocsCatalog, kind, name, namespace]);\n\n return reRouteLocationToCatalog;\n}\n"],"names":[],"mappings":";;;;AAsBA,MAAM,iBAAiB,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAChE,MAAM,eAAe,CAAC,IAAA,KAAiB,IAAK,CAAA,OAAA,CAAQ,QAAQ,EAAE,CAAA;AAQvD,SAAS,8BAA8B,SAA8B,EAAA;AAC1E,EAAA,MAAM,EAAE,IAAA,EAAM,IAAM,EAAA,SAAA,EAAc,GAAA,SAAA;AAElC,EAAM,MAAA,aAAA,GAAgB,YAAY,gBAAgB,CAAA;AAClD,EAAM,MAAA,gBAAA,GAAmB,YAAY,uBAAuB,CAAA;AAM5D,EAAM,MAAA,wBAAA,GAA2B,QAAQ,MAAM;AAC7C,IAAM,MAAA,YAAA,GAAe,aAAa,aAAc,CAAA,EAAE,MAAM,SAAW,EAAA,IAAA,EAAM,CAAC,CAAA;AAC1E,IAAM,MAAA,eAAA,GAAkB,YAAa,CAAA,gBAAA,EAAkB,CAAA;AAEvD,IAAA,OAAO,CAAC,GAAwB,KAAA;AAC9B,MACE,IAAA,GAAA,CACG,kBAAkB,OAAO,CAAA,CACzB,WAAW,YAAa,CAAA,iBAAA,CAAkB,OAAO,CAAC,CACrD,EAAA;AACA,QAAA,MAAM,SAAS,cAAe,CAAA,GAAA,CAAI,KAAM,CAAA,YAAA,CAAa,MAAM,CAAC,CAAA;AAC5D,QAAA,OAAO,MAAO,CAAA,MAAA,KAAW,CAAK,IAAA,MAAA,CAAO,WAAW,GAAG,CAAA,GAC/C,CAAG,EAAA,eAAe,GAAG,MAAM,CAAA,CAAA,GAC3B,CAAG,EAAA,eAAe,IAAI,MAAM,CAAA,CAAA;AAAA;AAElC,MAAO,OAAA,GAAA;AAAA,KACT;AAAA,KACC,CAAC,aAAA,EAAe,kBAAkB,IAAM,EAAA,IAAA,EAAM,SAAS,CAAC,CAAA;AAE3D,EAAO,OAAA,wBAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20241121023535",
|
|
4
4
|
"description": "The Backstage plugin that renders technical documentation for your components",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "frontend-plugin",
|
|
@@ -68,22 +68,22 @@
|
|
|
68
68
|
"test": "backstage-cli package test"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@backstage/catalog-model": "
|
|
72
|
-
"@backstage/config": "
|
|
73
|
-
"@backstage/core-compat-api": "0.
|
|
74
|
-
"@backstage/core-components": "0.
|
|
75
|
-
"@backstage/core-plugin-api": "
|
|
76
|
-
"@backstage/errors": "
|
|
77
|
-
"@backstage/frontend-plugin-api": "0.
|
|
78
|
-
"@backstage/integration": "
|
|
79
|
-
"@backstage/integration-react": "
|
|
80
|
-
"@backstage/plugin-auth-react": "0.
|
|
81
|
-
"@backstage/plugin-catalog-react": "
|
|
82
|
-
"@backstage/plugin-search-common": "
|
|
83
|
-
"@backstage/plugin-search-react": "0.0.0-nightly-
|
|
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": "0.0.0-nightly-20241121023535",
|
|
84
84
|
"@backstage/plugin-techdocs-common": "0.1.0",
|
|
85
|
-
"@backstage/plugin-techdocs-react": "
|
|
86
|
-
"@backstage/theme": "0.
|
|
85
|
+
"@backstage/plugin-techdocs-react": "1.2.10",
|
|
86
|
+
"@backstage/theme": "0.6.1",
|
|
87
87
|
"@material-ui/core": "^4.12.2",
|
|
88
88
|
"@material-ui/icons": "^4.9.1",
|
|
89
89
|
"@material-ui/lab": "4.0.0-alpha.61",
|
|
@@ -97,11 +97,11 @@
|
|
|
97
97
|
"react-use": "^17.2.4"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
|
-
"@backstage/cli": "0.0.0-nightly-
|
|
101
|
-
"@backstage/core-app-api": "
|
|
102
|
-
"@backstage/dev-utils": "
|
|
103
|
-
"@backstage/plugin-techdocs-module-addons-contrib": "
|
|
104
|
-
"@backstage/test-utils": "
|
|
100
|
+
"@backstage/cli": "0.0.0-nightly-20241121023535",
|
|
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",
|
|
105
105
|
"@testing-library/dom": "^10.0.0",
|
|
106
106
|
"@testing-library/jest-dom": "^6.0.0",
|
|
107
107
|
"@testing-library/react": "^16.0.0",
|