@backstage/plugin-techdocs-react 0.0.0-nightly-20260707031921 → 0.0.0-nightly-20260710031816
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 +5 -4
- package/dist/context.esm.js +12 -6
- package/dist/context.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-nightly-
|
|
3
|
+
## 0.0.0-nightly-20260710031816
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 0b02d4c: Fixed the TechDocs reader requesting the documentation metadata in a tight loop when the request fails permanently (for example when the metadata returns a 404). The reader now stops after a failed request, which previously flooded the backend with requests and caused the page to flicker.
|
|
7
8
|
- Updated dependencies
|
|
8
|
-
- @backstage/frontend-plugin-api@0.0.0-nightly-
|
|
9
|
-
- @backstage/core-components@0.0.0-nightly-
|
|
10
|
-
- @backstage/core-plugin-api@0.0.0-nightly-
|
|
9
|
+
- @backstage/frontend-plugin-api@0.0.0-nightly-20260710031816
|
|
10
|
+
- @backstage/core-components@0.0.0-nightly-20260710031816
|
|
11
|
+
- @backstage/core-plugin-api@0.0.0-nightly-20260710031816
|
|
11
12
|
- @backstage/catalog-model@1.9.0
|
|
12
13
|
- @backstage/config@1.3.8
|
|
13
14
|
- @backstage/version-bridge@1.0.12
|
package/dist/context.esm.js
CHANGED
|
@@ -43,16 +43,22 @@ const TechDocsReaderPageProvider = memo(
|
|
|
43
43
|
const [shadowRoot, setShadowRoot] = useState(
|
|
44
44
|
defaultTechDocsReaderPageValue.shadowRoot
|
|
45
45
|
);
|
|
46
|
+
const {
|
|
47
|
+
value: metadataValue,
|
|
48
|
+
loading: metadataLoading,
|
|
49
|
+
error: metadataError,
|
|
50
|
+
retry: retryMetadata
|
|
51
|
+
} = metadata;
|
|
46
52
|
useEffect(() => {
|
|
47
|
-
if (shadowRoot && !
|
|
48
|
-
|
|
53
|
+
if (shadowRoot && !metadataValue && !metadataLoading && !metadataError) {
|
|
54
|
+
retryMetadata();
|
|
49
55
|
}
|
|
50
56
|
}, [
|
|
51
|
-
metadata.value,
|
|
52
|
-
metadata.loading,
|
|
53
57
|
shadowRoot,
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
metadataValue,
|
|
59
|
+
metadataLoading,
|
|
60
|
+
metadataError,
|
|
61
|
+
retryMetadata
|
|
56
62
|
]);
|
|
57
63
|
const value = {
|
|
58
64
|
metadata,
|
package/dist/context.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.esm.js","sources":["../src/context.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 {\n Dispatch,\n SetStateAction,\n useContext,\n useState,\n memo,\n ReactNode,\n useEffect,\n} from 'react';\nimport useAsync, { AsyncState } from 'react-use/esm/useAsync';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\nimport {\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\n\nimport {\n AnalyticsContext,\n configApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\n\nimport { techdocsApiRef } from './api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\n\nimport { toLowercaseEntityRefMaybe } from './helpers';\n\nconst areEntityRefsEqual = (\n prevEntityRef: CompoundEntityRef,\n nextEntityRef: CompoundEntityRef,\n) => {\n return (\n stringifyEntityRef(prevEntityRef) === stringifyEntityRef(nextEntityRef)\n );\n};\n\n/**\n * @public type for the value of the TechDocsReaderPageContext\n */\nexport type TechDocsReaderPageValue = {\n metadata: AsyncState<TechDocsMetadata>;\n entityRef: CompoundEntityRef;\n entityMetadata: AsyncState<TechDocsEntityMetadata>;\n shadowRoot?: ShadowRoot;\n setShadowRoot: Dispatch<SetStateAction<ShadowRoot | undefined>>;\n title: string;\n setTitle: Dispatch<SetStateAction<string>>;\n subtitle: string;\n setSubtitle: Dispatch<SetStateAction<string>>;\n /**\n * @deprecated property can be passed down directly to the `TechDocsReaderPageContent` instead.\n */\n onReady?: () => void;\n};\n\nconst defaultTechDocsReaderPageValue: TechDocsReaderPageValue = {\n title: '',\n subtitle: '',\n setTitle: () => {},\n setSubtitle: () => {},\n setShadowRoot: () => {},\n metadata: { loading: true },\n entityMetadata: { loading: true },\n entityRef: { kind: '', name: '', namespace: '' },\n};\n\nconst TechDocsReaderPageContext = createVersionedContext<{\n 1: TechDocsReaderPageValue;\n}>('techdocs-reader-page-context');\n\n/**\n * render function for {@link TechDocsReaderPageProvider}\n *\n * @public\n */\nexport type TechDocsReaderPageProviderRenderFunction = (\n value: TechDocsReaderPageValue,\n) => JSX.Element;\n\n/**\n * Props for {@link TechDocsReaderPageProvider}\n *\n * @public\n */\nexport type TechDocsReaderPageProviderProps = {\n entityRef: CompoundEntityRef;\n children: TechDocsReaderPageProviderRenderFunction | ReactNode;\n};\n\n/**\n * A context to store the reader page state\n * @public\n */\nexport const TechDocsReaderPageProvider = memo(\n (props: TechDocsReaderPageProviderProps) => {\n const { entityRef, children } = props;\n\n const techdocsApi = useApi(techdocsApiRef);\n const config = useApi(configApiRef);\n\n const entityMetadata = useAsync(async () => {\n return techdocsApi.getEntityMetadata(entityRef);\n }, [entityRef]);\n\n const metadata = useAsyncRetry(async () => {\n return techdocsApi.getTechDocsMetadata(entityRef);\n }, [entityRef]);\n\n const [title, setTitle] = useState(defaultTechDocsReaderPageValue.title);\n const [subtitle, setSubtitle] = useState(\n defaultTechDocsReaderPageValue.subtitle,\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | undefined>(\n defaultTechDocsReaderPageValue.shadowRoot,\n );\n\n useEffect(() => {\n if (shadowRoot && !
|
|
1
|
+
{"version":3,"file":"context.esm.js","sources":["../src/context.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 {\n Dispatch,\n SetStateAction,\n useContext,\n useState,\n memo,\n ReactNode,\n useEffect,\n} from 'react';\nimport useAsync, { AsyncState } from 'react-use/esm/useAsync';\nimport useAsyncRetry from 'react-use/esm/useAsyncRetry';\n\nimport {\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\n\nimport {\n AnalyticsContext,\n configApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\n\nimport { techdocsApiRef } from './api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\n\nimport { toLowercaseEntityRefMaybe } from './helpers';\n\nconst areEntityRefsEqual = (\n prevEntityRef: CompoundEntityRef,\n nextEntityRef: CompoundEntityRef,\n) => {\n return (\n stringifyEntityRef(prevEntityRef) === stringifyEntityRef(nextEntityRef)\n );\n};\n\n/**\n * @public type for the value of the TechDocsReaderPageContext\n */\nexport type TechDocsReaderPageValue = {\n metadata: AsyncState<TechDocsMetadata>;\n entityRef: CompoundEntityRef;\n entityMetadata: AsyncState<TechDocsEntityMetadata>;\n shadowRoot?: ShadowRoot;\n setShadowRoot: Dispatch<SetStateAction<ShadowRoot | undefined>>;\n title: string;\n setTitle: Dispatch<SetStateAction<string>>;\n subtitle: string;\n setSubtitle: Dispatch<SetStateAction<string>>;\n /**\n * @deprecated property can be passed down directly to the `TechDocsReaderPageContent` instead.\n */\n onReady?: () => void;\n};\n\nconst defaultTechDocsReaderPageValue: TechDocsReaderPageValue = {\n title: '',\n subtitle: '',\n setTitle: () => {},\n setSubtitle: () => {},\n setShadowRoot: () => {},\n metadata: { loading: true },\n entityMetadata: { loading: true },\n entityRef: { kind: '', name: '', namespace: '' },\n};\n\nconst TechDocsReaderPageContext = createVersionedContext<{\n 1: TechDocsReaderPageValue;\n}>('techdocs-reader-page-context');\n\n/**\n * render function for {@link TechDocsReaderPageProvider}\n *\n * @public\n */\nexport type TechDocsReaderPageProviderRenderFunction = (\n value: TechDocsReaderPageValue,\n) => JSX.Element;\n\n/**\n * Props for {@link TechDocsReaderPageProvider}\n *\n * @public\n */\nexport type TechDocsReaderPageProviderProps = {\n entityRef: CompoundEntityRef;\n children: TechDocsReaderPageProviderRenderFunction | ReactNode;\n};\n\n/**\n * A context to store the reader page state\n * @public\n */\nexport const TechDocsReaderPageProvider = memo(\n (props: TechDocsReaderPageProviderProps) => {\n const { entityRef, children } = props;\n\n const techdocsApi = useApi(techdocsApiRef);\n const config = useApi(configApiRef);\n\n const entityMetadata = useAsync(async () => {\n return techdocsApi.getEntityMetadata(entityRef);\n }, [entityRef]);\n\n const metadata = useAsyncRetry(async () => {\n return techdocsApi.getTechDocsMetadata(entityRef);\n }, [entityRef]);\n\n const [title, setTitle] = useState(defaultTechDocsReaderPageValue.title);\n const [subtitle, setSubtitle] = useState(\n defaultTechDocsReaderPageValue.subtitle,\n );\n const [shadowRoot, setShadowRoot] = useState<ShadowRoot | undefined>(\n defaultTechDocsReaderPageValue.shadowRoot,\n );\n\n const {\n value: metadataValue,\n loading: metadataLoading,\n error: metadataError,\n retry: retryMetadata,\n } = metadata;\n\n useEffect(() => {\n // Retry once the shadow root is attached, but only while the request has\n // not yet produced a value or failed. Checking the error state is what\n // stops a permanently failing request (e.g. a 404) from retrying forever.\n if (shadowRoot && !metadataValue && !metadataLoading && !metadataError) {\n retryMetadata();\n }\n }, [\n shadowRoot,\n metadataValue,\n metadataLoading,\n metadataError,\n retryMetadata,\n ]);\n\n const value: TechDocsReaderPageValue = {\n metadata,\n entityRef: toLowercaseEntityRefMaybe(entityRef, config),\n entityMetadata,\n shadowRoot,\n setShadowRoot,\n title,\n setTitle,\n subtitle,\n setSubtitle,\n };\n const versionedValue = createVersionedValueMap({ 1: value });\n\n return (\n <AnalyticsContext\n attributes={{ entityRef: stringifyEntityRef(entityRef) }}\n >\n <TechDocsReaderPageContext.Provider value={versionedValue}>\n {children instanceof Function ? children(value) : children}\n </TechDocsReaderPageContext.Provider>\n </AnalyticsContext>\n );\n },\n (prevProps, nextProps) => {\n return areEntityRefsEqual(prevProps.entityRef, nextProps.entityRef);\n },\n);\n\n/**\n * Hook used to get access to shared state between reader page components.\n * @public\n */\nexport const useTechDocsReaderPage = () => {\n const versionedContext = useContext(TechDocsReaderPageContext);\n\n if (versionedContext === undefined) {\n return defaultTechDocsReaderPageValue;\n }\n\n const context = versionedContext.atVersion(1);\n if (context === undefined) {\n throw new Error('No context found for version 1.');\n }\n\n return context;\n};\n"],"names":[],"mappings":";;;;;;;;;;AAgDA,MAAM,kBAAA,GAAqB,CACzB,aAAA,EACA,aAAA,KACG;AACH,EAAA,OACE,kBAAA,CAAmB,aAAa,CAAA,KAAM,kBAAA,CAAmB,aAAa,CAAA;AAE1E,CAAA;AAqBA,MAAM,8BAAA,GAA0D;AAAA,EAC9D,KAAA,EAAO,EAAA;AAAA,EACP,QAAA,EAAU,EAAA;AAAA,EACV,UAAU,MAAM;AAAA,EAAC,CAAA;AAAA,EACjB,aAAa,MAAM;AAAA,EAAC,CAAA;AAAA,EACpB,eAAe,MAAM;AAAA,EAAC,CAAA;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AAA;AAC5C,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA,MAAM,IAAI,MAAM,iCAAiC,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-react",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20260710031816",
|
|
4
4
|
"description": "Shared frontend utilities for TechDocs and Addons",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@backstage/catalog-model": "1.9.0",
|
|
70
70
|
"@backstage/config": "1.3.8",
|
|
71
|
-
"@backstage/core-components": "0.0.0-nightly-
|
|
72
|
-
"@backstage/core-plugin-api": "0.0.0-nightly-
|
|
73
|
-
"@backstage/frontend-plugin-api": "0.0.0-nightly-
|
|
71
|
+
"@backstage/core-components": "0.0.0-nightly-20260710031816",
|
|
72
|
+
"@backstage/core-plugin-api": "0.0.0-nightly-20260710031816",
|
|
73
|
+
"@backstage/frontend-plugin-api": "0.0.0-nightly-20260710031816",
|
|
74
74
|
"@backstage/plugin-techdocs-common": "0.1.1",
|
|
75
75
|
"@backstage/version-bridge": "1.0.12",
|
|
76
76
|
"@material-ui/core": "^4.12.2",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"react-use": "^17.2.4"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@backstage/cli": "0.0.0-nightly-
|
|
84
|
-
"@backstage/test-utils": "0.0.0-nightly-
|
|
83
|
+
"@backstage/cli": "0.0.0-nightly-20260710031816",
|
|
84
|
+
"@backstage/test-utils": "0.0.0-nightly-20260710031816",
|
|
85
85
|
"@backstage/theme": "0.7.3",
|
|
86
86
|
"@testing-library/jest-dom": "^6.0.0",
|
|
87
87
|
"@testing-library/react": "^16.0.0",
|