@backstage/plugin-techdocs-react 1.3.2-next.0 → 1.3.3-next.0
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 +16 -0
- package/dist/addons.esm.js.map +1 -1
- package/dist/alpha.d.ts +3 -4
- package/dist/alpha.esm.js.map +1 -1
- package/dist/api.esm.js.map +1 -1
- package/dist/component.esm.js +1 -1
- package/dist/component.esm.js.map +1 -1
- package/dist/context.esm.js.map +1 -1
- package/dist/helpers.esm.js.map +1 -1
- package/dist/hooks.esm.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types/{types.d-BooYUMWM.d.ts → types.d-DXgF2CAr.d.ts} +1 -1
- package/dist/types.esm.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @backstage/plugin-techdocs-react
|
|
2
2
|
|
|
3
|
+
## 1.3.3-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/frontend-plugin-api@0.11.1-next.0
|
|
9
|
+
- @backstage/core-components@0.17.6-next.0
|
|
10
|
+
|
|
11
|
+
## 1.3.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- @backstage/core-components@0.17.5
|
|
17
|
+
- @backstage/frontend-plugin-api@0.11.0
|
|
18
|
+
|
|
3
19
|
## 1.3.2-next.0
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/addons.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addons.esm.js","sources":["../src/addons.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 { PropsWithChildren, ComponentType, useCallback } from 'react';\nimport { useOutlet } from 'react-router-dom';\n\nimport {\n attachComponentData,\n createReactExtension,\n ElementCollection,\n Extension,\n useElementFilter,\n} from '@backstage/core-plugin-api';\n\nimport { TechDocsAddonLocations, TechDocsAddonOptions } from './types';\n\n/**\n * Key for each addon.\n * @public\n */\nexport const TECHDOCS_ADDONS_KEY = 'techdocs.addons.addon.v1';\n\n/**\n * Marks the `<TechDocsAddons>` registry component.\n * @public\n */\nexport const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';\n\n/**\n * TechDocs Addon registry.\n * @public\n */\nexport const TechDocsAddons: ComponentType<PropsWithChildren<{}>> = () => null;\n\nattachComponentData(TechDocsAddons, TECHDOCS_ADDONS_WRAPPER_KEY, true);\n\nexport const getDataKeyByName = (name: string) => {\n return `${TECHDOCS_ADDONS_KEY}.${name.toLocaleLowerCase('en-US')}`;\n};\n\n/**\n * Create a TechDocs addon overload signature without props.\n * @public\n */\nexport function createTechDocsAddonExtension(\n options: TechDocsAddonOptions,\n): Extension<() => JSX.Element | null>;\n\n/**\n * Create a TechDocs addon overload signature with props.\n * @public\n */\nexport function createTechDocsAddonExtension<TComponentProps>(\n options: TechDocsAddonOptions<TComponentProps>,\n): Extension<(props: TComponentProps) => JSX.Element | null>;\n\n/**\n * Create a TechDocs addon implementation.\n * @public\n */\nexport function createTechDocsAddonExtension<\n TComponentProps extends PropsWithChildren<{}>,\n>(\n options: TechDocsAddonOptions<TComponentProps>,\n): Extension<(props: TComponentProps) => JSX.Element | null> {\n const { name, component: TechDocsAddon } = options;\n return createReactExtension({\n name,\n component: {\n sync: (props: TComponentProps) => <TechDocsAddon {...props} />,\n },\n data: {\n [TECHDOCS_ADDONS_KEY]: options,\n [getDataKeyByName(name)]: true,\n },\n });\n}\n\nconst getTechDocsAddonByName = (\n collection: ElementCollection,\n key: string,\n): JSX.Element | undefined => {\n return collection.selectByComponentData({ key }).getElements()[0];\n};\n\nconst getAllTechDocsAddons = (collection: ElementCollection) => {\n return collection\n .selectByComponentData({\n key: TECHDOCS_ADDONS_WRAPPER_KEY,\n })\n .selectByComponentData({\n key: TECHDOCS_ADDONS_KEY,\n });\n};\n\nconst getAllTechDocsAddonsData = (collection: ElementCollection) => {\n return collection\n .selectByComponentData({\n key: TECHDOCS_ADDONS_WRAPPER_KEY,\n })\n .findComponentData<TechDocsAddonOptions>({\n key: TECHDOCS_ADDONS_KEY,\n });\n};\n\n/**\n * hook to use addons in components\n * @public\n */\nexport const useTechDocsAddons = () => {\n const node = useOutlet();\n const collection = useElementFilter(node, getAllTechDocsAddons);\n const options = useElementFilter(node, getAllTechDocsAddonsData);\n\n const findAddonByData = useCallback(\n (data: TechDocsAddonOptions | undefined) => {\n if (!collection || !data) return null;\n const nameKey = getDataKeyByName(data.name);\n return getTechDocsAddonByName(collection, nameKey) ?? null;\n },\n [collection],\n );\n\n const renderComponentByName = useCallback(\n (name: string) => {\n const data = options.find(option => option.name === name);\n return data ? findAddonByData(data) : null;\n },\n [options, findAddonByData],\n );\n\n const renderComponentsByLocation = useCallback(\n (location: keyof typeof TechDocsAddonLocations) => {\n const data = options.filter(option => option.location === location);\n return data.length ? data.map(findAddonByData) : null;\n },\n [options, findAddonByData],\n );\n\n return { renderComponentByName, renderComponentsByLocation };\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,
|
|
1
|
+
{"version":3,"file":"addons.esm.js","sources":["../src/addons.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 { PropsWithChildren, ComponentType, useCallback } from 'react';\nimport { useOutlet } from 'react-router-dom';\n\nimport {\n attachComponentData,\n createReactExtension,\n ElementCollection,\n Extension,\n useElementFilter,\n} from '@backstage/core-plugin-api';\n\nimport { TechDocsAddonLocations, TechDocsAddonOptions } from './types';\n\n/**\n * Key for each addon.\n * @public\n */\nexport const TECHDOCS_ADDONS_KEY = 'techdocs.addons.addon.v1';\n\n/**\n * Marks the `<TechDocsAddons>` registry component.\n * @public\n */\nexport const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';\n\n/**\n * TechDocs Addon registry.\n * @public\n */\nexport const TechDocsAddons: ComponentType<PropsWithChildren<{}>> = () => null;\n\nattachComponentData(TechDocsAddons, TECHDOCS_ADDONS_WRAPPER_KEY, true);\n\nexport const getDataKeyByName = (name: string) => {\n return `${TECHDOCS_ADDONS_KEY}.${name.toLocaleLowerCase('en-US')}`;\n};\n\n/**\n * Create a TechDocs addon overload signature without props.\n * @public\n */\nexport function createTechDocsAddonExtension(\n options: TechDocsAddonOptions,\n): Extension<() => JSX.Element | null>;\n\n/**\n * Create a TechDocs addon overload signature with props.\n * @public\n */\nexport function createTechDocsAddonExtension<TComponentProps>(\n options: TechDocsAddonOptions<TComponentProps>,\n): Extension<(props: TComponentProps) => JSX.Element | null>;\n\n/**\n * Create a TechDocs addon implementation.\n * @public\n */\nexport function createTechDocsAddonExtension<\n TComponentProps extends PropsWithChildren<{}>,\n>(\n options: TechDocsAddonOptions<TComponentProps>,\n): Extension<(props: TComponentProps) => JSX.Element | null> {\n const { name, component: TechDocsAddon } = options;\n return createReactExtension({\n name,\n component: {\n sync: (props: TComponentProps) => <TechDocsAddon {...props} />,\n },\n data: {\n [TECHDOCS_ADDONS_KEY]: options,\n [getDataKeyByName(name)]: true,\n },\n });\n}\n\nconst getTechDocsAddonByName = (\n collection: ElementCollection,\n key: string,\n): JSX.Element | undefined => {\n return collection.selectByComponentData({ key }).getElements()[0];\n};\n\nconst getAllTechDocsAddons = (collection: ElementCollection) => {\n return collection\n .selectByComponentData({\n key: TECHDOCS_ADDONS_WRAPPER_KEY,\n })\n .selectByComponentData({\n key: TECHDOCS_ADDONS_KEY,\n });\n};\n\nconst getAllTechDocsAddonsData = (collection: ElementCollection) => {\n return collection\n .selectByComponentData({\n key: TECHDOCS_ADDONS_WRAPPER_KEY,\n })\n .findComponentData<TechDocsAddonOptions>({\n key: TECHDOCS_ADDONS_KEY,\n });\n};\n\n/**\n * hook to use addons in components\n * @public\n */\nexport const useTechDocsAddons = () => {\n const node = useOutlet();\n const collection = useElementFilter(node, getAllTechDocsAddons);\n const options = useElementFilter(node, getAllTechDocsAddonsData);\n\n const findAddonByData = useCallback(\n (data: TechDocsAddonOptions | undefined) => {\n if (!collection || !data) return null;\n const nameKey = getDataKeyByName(data.name);\n return getTechDocsAddonByName(collection, nameKey) ?? null;\n },\n [collection],\n );\n\n const renderComponentByName = useCallback(\n (name: string) => {\n const data = options.find(option => option.name === name);\n return data ? findAddonByData(data) : null;\n },\n [options, findAddonByData],\n );\n\n const renderComponentsByLocation = useCallback(\n (location: keyof typeof TechDocsAddonLocations) => {\n const data = options.filter(option => option.location === location);\n return data.length ? data.map(findAddonByData) : null;\n },\n [options, findAddonByData],\n );\n\n return { renderComponentByName, renderComponentsByLocation };\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,mBAAA,GAAsB;AAM5B,MAAM,2BAAA,GAA8B;AAMpC,MAAM,iBAAuD,MAAM;AAE1E,mBAAA,CAAoB,cAAA,EAAgB,6BAA6B,IAAI,CAAA;AAE9D,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAiB;AAChD,EAAA,OAAO,GAAG,mBAAmB,CAAA,CAAA,EAAI,IAAA,CAAK,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AAM,eAAA,GAAkB,WAAA;AAAA,IACtB,CAAC,IAAA,KAA2C;AAC1C,MAAA,IAAI,CAAC,UAAA,IAAc,CAAC,IAAA,EAAM,OAAO,IAAA;AACjC,MAAA,MAAM,OAAA,GAAU,gBAAA,CAAiB,IAAA,CAAK,IAAI,CAAA;AAC1C,MAAA,OAAO,sBAAA,CAAuB,UAAA,EAAY,OAAO,CAAA,IAAK,IAAA;AAAA,IACxD,CAAA;AAAA,IACA,CAAC,UAAU;AAAA,GACb;AAEA,EAAA,MAAM,qBAAA,GAAwB,WAAA;AAAA,IAC5B,CAAC,IAAA,KAAiB;AAChB,MAAA,MAAM,OAAO,OAAA,CAAQ,IAAA,CAAK,CAAA,MAAA,KAAU,MAAA,CAAO,SAAS,IAAI,CAAA;AACxD,MAAA,OAAO,IAAA,GAAO,eAAA,CAAgB,IAAI,CAAA,GAAI,IAAA;AAAA,IACxC,CAAA;AAAA,IACA,CAAC,SAAS,eAAe;AAAA,GAC3B;AAEA,EAAA,MAAM,0BAAA,GAA6B,WAAA;AAAA,IACjC,CAAC,QAAA,KAAkD;AACjD,MAAA,MAAM,OAAO,OAAA,CAAQ,MAAA,CAAO,CAAA,MAAA,KAAU,MAAA,CAAO,aAAa,QAAQ,CAAA;AAClE,MAAA,OAAO,IAAA,CAAK,MAAA,GAAS,IAAA,CAAK,GAAA,CAAI,eAAe,CAAA,GAAI,IAAA;AAAA,IACnD,CAAA;AAAA,IACA,CAAC,SAAS,eAAe;AAAA,GAC3B;AAEA,EAAA,OAAO,EAAE,uBAAuB,0BAAA,EAA2B;AAC7D;;;;"}
|
package/dist/alpha.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
|
|
2
2
|
import { ComponentType } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
3
|
+
import { a as TechDocsAddonOptions } from './types/types.d-DXgF2CAr.js';
|
|
4
|
+
export { T as TechDocsAddonLocations } from './types/types.d-DXgF2CAr.js';
|
|
5
5
|
import '@backstage/catalog-model';
|
|
6
6
|
|
|
7
7
|
/** @alpha */
|
|
@@ -12,9 +12,8 @@ declare const techDocsAddonDataRef: _backstage_frontend_plugin_api.ConfigurableE
|
|
|
12
12
|
*/
|
|
13
13
|
declare const AddonBlueprint: _backstage_frontend_plugin_api.ExtensionBlueprint<{
|
|
14
14
|
kind: "addon";
|
|
15
|
-
name: undefined;
|
|
16
15
|
params: TechDocsAddonOptions;
|
|
17
|
-
output: _backstage_frontend_plugin_api.
|
|
16
|
+
output: _backstage_frontend_plugin_api.ExtensionDataRef<TechDocsAddonOptions, "techdocs.addon", {}>;
|
|
18
17
|
inputs: {};
|
|
19
18
|
config: {};
|
|
20
19
|
configInput: {};
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { createElement, ComponentType } from 'react';\n\nimport { TechDocsAddonOptions } from './types';\nimport {\n attachComponentData,\n getComponentData,\n} from '@backstage/core-plugin-api';\nimport { getDataKeyByName, TECHDOCS_ADDONS_KEY } from './addons';\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\n\n/** @alpha */\nexport type { TechDocsAddonOptions, TechDocsAddonLocations } from './types';\n\n/** @alpha */\nexport const techDocsAddonDataRef =\n createExtensionDataRef<TechDocsAddonOptions>().with({\n id: 'techdocs.addon',\n });\n\n/**\n * Creates an extension to add addons to the TechDocs standalone reader and entity pages.\n * @alpha\n */\nexport const AddonBlueprint = createExtensionBlueprint({\n kind: 'addon',\n attachTo: [\n { id: 'page:techdocs/reader', input: 'addons' },\n { id: 'entity-content:techdocs', input: 'addons' },\n ],\n output: [techDocsAddonDataRef],\n factory: (params: TechDocsAddonOptions) => [techDocsAddonDataRef(params)],\n dataRefs: {\n addon: techDocsAddonDataRef,\n },\n});\n\n/** @alpha */\nexport const attachTechDocsAddonComponentData = <P>(\n techDocsAddon: ComponentType<P>,\n data: TechDocsAddonOptions,\n) => {\n const element = createElement(techDocsAddon as ComponentType);\n\n const isDataAttached = getComponentData<TechDocsAddonOptions>(\n element,\n TECHDOCS_ADDONS_KEY,\n );\n if (!isDataAttached) {\n attachComponentData(techDocsAddon, TECHDOCS_ADDONS_KEY, data);\n }\n\n const dataKey = getDataKeyByName(data.name);\n const isDataKeyAttached = getComponentData<boolean>(element, dataKey);\n if (!isDataKeyAttached) {\n attachComponentData(techDocsAddon, dataKey, true);\n }\n};\n"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2025 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 { createElement, ComponentType } from 'react';\n\nimport { TechDocsAddonOptions } from './types';\nimport {\n attachComponentData,\n getComponentData,\n} from '@backstage/core-plugin-api';\nimport { getDataKeyByName, TECHDOCS_ADDONS_KEY } from './addons';\nimport {\n createExtensionBlueprint,\n createExtensionDataRef,\n} from '@backstage/frontend-plugin-api';\n\n/** @alpha */\nexport type { TechDocsAddonOptions, TechDocsAddonLocations } from './types';\n\n/** @alpha */\nexport const techDocsAddonDataRef =\n createExtensionDataRef<TechDocsAddonOptions>().with({\n id: 'techdocs.addon',\n });\n\n/**\n * Creates an extension to add addons to the TechDocs standalone reader and entity pages.\n * @alpha\n */\nexport const AddonBlueprint = createExtensionBlueprint({\n kind: 'addon',\n attachTo: [\n { id: 'page:techdocs/reader', input: 'addons' },\n { id: 'entity-content:techdocs', input: 'addons' },\n ],\n output: [techDocsAddonDataRef],\n factory: (params: TechDocsAddonOptions) => [techDocsAddonDataRef(params)],\n dataRefs: {\n addon: techDocsAddonDataRef,\n },\n});\n\n/** @alpha */\nexport const attachTechDocsAddonComponentData = <P>(\n techDocsAddon: ComponentType<P>,\n data: TechDocsAddonOptions,\n) => {\n const element = createElement(techDocsAddon as ComponentType);\n\n const isDataAttached = getComponentData<TechDocsAddonOptions>(\n element,\n TECHDOCS_ADDONS_KEY,\n );\n if (!isDataAttached) {\n attachComponentData(techDocsAddon, TECHDOCS_ADDONS_KEY, data);\n }\n\n const dataKey = getDataKeyByName(data.name);\n const isDataKeyAttached = getComponentData<boolean>(element, dataKey);\n if (!isDataKeyAttached) {\n attachComponentData(techDocsAddon, dataKey, true);\n }\n};\n"],"names":[],"mappings":";;;;;AAgCO,MAAM,oBAAA,GACX,sBAAA,EAA6C,CAAE,IAAA,CAAK;AAAA,EAClD,EAAA,EAAI;AACN,CAAC;AAMI,MAAM,iBAAiB,wBAAA,CAAyB;AAAA,EACrD,IAAA,EAAM,OAAA;AAAA,EACN,QAAA,EAAU;AAAA,IACR,EAAE,EAAA,EAAI,sBAAA,EAAwB,KAAA,EAAO,QAAA,EAAS;AAAA,IAC9C,EAAE,EAAA,EAAI,yBAAA,EAA2B,KAAA,EAAO,QAAA;AAAS,GACnD;AAAA,EACA,MAAA,EAAQ,CAAC,oBAAoB,CAAA;AAAA,EAC7B,SAAS,CAAC,MAAA,KAAiC,CAAC,oBAAA,CAAqB,MAAM,CAAC,CAAA;AAAA,EACxE,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAC;AAGM,MAAM,gCAAA,GAAmC,CAC9C,aAAA,EACA,IAAA,KACG;AACH,EAAA,MAAM,OAAA,GAAU,cAAc,aAA8B,CAAA;AAE5D,EAAA,MAAM,cAAA,GAAiB,gBAAA;AAAA,IACrB,OAAA;AAAA,IACA;AAAA,GACF;AACA,EAAA,IAAI,CAAC,cAAA,EAAgB;AACnB,IAAA,mBAAA,CAAoB,aAAA,EAAe,qBAAqB,IAAI,CAAA;AAAA,EAC9D;AAEA,EAAA,MAAM,OAAA,GAAU,gBAAA,CAAiB,IAAA,CAAK,IAAI,CAAA;AAC1C,EAAA,MAAM,iBAAA,GAAoB,gBAAA,CAA0B,OAAA,EAAS,OAAO,CAAA;AACpE,EAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,IAAA,mBAAA,CAAoB,aAAA,EAAe,SAAS,IAAI,CAAA;AAAA,EAClD;AACF;;;;"}
|
package/dist/api.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\n\n/**\n * API to talk to techdocs-backend.\n *\n * @public\n */\nexport interface TechDocsApi {\n getCookie(): Promise<{ expiresAt: string }>;\n getApiOrigin(): Promise<string>;\n getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;\n getEntityMetadata(\n entityId: CompoundEntityRef,\n ): Promise<TechDocsEntityMetadata>;\n}\n\n/**\n * Utility API reference for the {@link TechDocsApi}.\n *\n * @public\n */\nexport const techdocsApiRef = createApiRef<TechDocsApi>({\n id: 'plugin.techdocs.service',\n});\n\n/**\n * The outcome of a docs sync operation.\n *\n * @public\n */\nexport type SyncResult = 'cached' | 'updated';\n\n/**\n * API which talks to TechDocs storage to fetch files to render.\n *\n * @public\n */\nexport interface TechDocsStorageApi {\n getApiOrigin(): Promise<string>;\n getStorageUrl(): Promise<string>;\n getBuilder(): Promise<string>;\n getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;\n syncEntityDocs(\n entityId: CompoundEntityRef,\n logHandler?: (line: string) => void,\n ): Promise<SyncResult>;\n getBaseUrl(\n oldBaseUrl: string,\n entityId: CompoundEntityRef,\n path: string,\n ): Promise<string>;\n}\n\n/**\n * Utility API reference for the {@link TechDocsStorageApi}.\n *\n * @public\n */\nexport const techdocsStorageApiRef = createApiRef<TechDocsStorageApi>({\n id: 'plugin.techdocs.storageservice',\n});\n"],"names":[],"mappings":";;AAuCO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"api.esm.js","sources":["../src/api.ts"],"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 { CompoundEntityRef } from '@backstage/catalog-model';\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\n\n/**\n * API to talk to techdocs-backend.\n *\n * @public\n */\nexport interface TechDocsApi {\n getCookie(): Promise<{ expiresAt: string }>;\n getApiOrigin(): Promise<string>;\n getTechDocsMetadata(entityId: CompoundEntityRef): Promise<TechDocsMetadata>;\n getEntityMetadata(\n entityId: CompoundEntityRef,\n ): Promise<TechDocsEntityMetadata>;\n}\n\n/**\n * Utility API reference for the {@link TechDocsApi}.\n *\n * @public\n */\nexport const techdocsApiRef = createApiRef<TechDocsApi>({\n id: 'plugin.techdocs.service',\n});\n\n/**\n * The outcome of a docs sync operation.\n *\n * @public\n */\nexport type SyncResult = 'cached' | 'updated';\n\n/**\n * API which talks to TechDocs storage to fetch files to render.\n *\n * @public\n */\nexport interface TechDocsStorageApi {\n getApiOrigin(): Promise<string>;\n getStorageUrl(): Promise<string>;\n getBuilder(): Promise<string>;\n getEntityDocs(entityId: CompoundEntityRef, path: string): Promise<string>;\n syncEntityDocs(\n entityId: CompoundEntityRef,\n logHandler?: (line: string) => void,\n ): Promise<SyncResult>;\n getBaseUrl(\n oldBaseUrl: string,\n entityId: CompoundEntityRef,\n path: string,\n ): Promise<string>;\n}\n\n/**\n * Utility API reference for the {@link TechDocsStorageApi}.\n *\n * @public\n */\nexport const techdocsStorageApiRef = createApiRef<TechDocsStorageApi>({\n id: 'plugin.techdocs.storageservice',\n});\n"],"names":[],"mappings":";;AAuCO,MAAM,iBAAiB,YAAA,CAA0B;AAAA,EACtD,EAAA,EAAI;AACN,CAAC;AAmCM,MAAM,wBAAwB,YAAA,CAAiC;AAAA,EACpE,EAAA,EAAI;AACN,CAAC;;;;"}
|
package/dist/component.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useState,
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { create } from 'jss';
|
|
4
4
|
import StylesProvider from '@material-ui/styles/StylesProvider';
|
|
5
5
|
import jssPreset from '@material-ui/styles/jssPreset';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.esm.js","sources":["../src/component.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 { PropsWithChildren, useState, useEffect, useCallback } from 'react';\n\nimport { create } from 'jss';\nimport StylesProvider from '@material-ui/styles/StylesProvider';\nimport jssPreset from '@material-ui/styles/jssPreset';\n\n/**\n * Name for the event dispatched when ShadowRoot styles are loaded.\n * @public\n */\nexport const SHADOW_DOM_STYLE_LOAD_EVENT = 'TECH_DOCS_SHADOW_DOM_STYLE_LOAD';\n\n/**\n * Dispatch style load event after all styles are loaded.\n * @param element - the ShadowRoot tree.\n */\nconst useShadowDomStylesEvents = (element: Element | null) => {\n useEffect(() => {\n if (!element) {\n return () => {};\n }\n\n const styles = element.querySelectorAll<HTMLElement>(\n 'head > link[rel=\"stylesheet\"]',\n );\n\n let count = styles?.length ?? 0;\n const event = new CustomEvent(SHADOW_DOM_STYLE_LOAD_EVENT);\n\n if (!count) {\n element.dispatchEvent(event);\n return () => {};\n }\n\n const handleLoad = () => {\n if (--count === 0) {\n element.dispatchEvent(event);\n }\n };\n\n styles?.forEach(style => {\n style.addEventListener('load', handleLoad);\n });\n\n return () => {\n styles?.forEach(style => {\n style.removeEventListener('load', handleLoad);\n });\n };\n }, [element]);\n};\n\n/**\n * Returns the style's loading state.\n *\n * @example\n * Here's an example that updates the sidebar position only after styles are calculated:\n * ```jsx\n * import {\n * TechDocsShadowDom,\n * useShadowDomStylesLoading,\n * } from '@backstage/plugin-techdocs-react';\n *\n * export const TechDocsReaderPageContent = () => {\n * // ...\n * const dom = useTechDocsReaderDom(entity);\n * const isStyleLoading = useShadowDomStylesLoading(dom);\n *\n * const updateSidebarPosition = useCallback(() => {\n * //...\n * }, [dom]);\n *\n * useEffect(() => {\n * if (!isStyleLoading) {\n * updateSidebarPosition();\n * }\n * }, [isStyleLoading, updateSidebarPosition]);\n *\n * const handleDomAppend = useCallback(\n * (newShadowRoot: ShadowRoot) => {\n * setShadowRoot(newShadowRoot);\n * },\n * [setShadowRoot],\n * );\n *\n * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;\n * };\n * ```\n *\n * @param element - which is the ShadowRoot tree.\n * @returns a boolean value, true if styles are being loaded.\n * @public\n */\nexport const useShadowDomStylesLoading = (element: Element | null) => {\n const [loading, setLoading] = useState(false);\n\n useEffect(() => {\n if (!element) return () => {};\n\n setLoading(true);\n\n const style = (element as HTMLElement).style;\n\n style.setProperty('opacity', '0');\n\n const handleLoad = () => {\n setLoading(false);\n style.setProperty('opacity', '1');\n };\n\n element.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);\n\n return () => {\n element.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);\n };\n }, [element]);\n\n return loading;\n};\n\n/**\n * Props for {@link TechDocsShadowDom}.\n *\n * @remarks\n * If you want to use portals to render Material UI components in the Shadow DOM,\n * you must render these portals as children because this component wraps its children in a Material UI StylesProvider\n * to ensure that Material UI styles are applied.\n *\n * @public\n */\nexport type TechDocsShadowDomProps = PropsWithChildren<{\n /**\n * Element tree that is appended to ShadowRoot.\n */\n element: Element;\n /**\n * Callback called when the element tree is appended in ShadowRoot.\n */\n onAppend?: (shadowRoot: ShadowRoot) => void;\n}>;\n\n/**\n * Renders a tree of elements in a Shadow DOM.\n *\n * @remarks\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 * so if you want to know when Shadow DOM styles are computed, you can listen for the \"TECH_DOCS_SHADOW_DOM_STYLE_LOAD\" event dispatched by the element tree.\n *\n * @example\n * Here is an example using this component and also listening for styles loaded event:\n *```jsx\n * import {\n * TechDocsShadowDom,\n * SHADOW_DOM_STYLE_LOAD_EVENT,\n * } from '@backstage/plugin-techdocs-react';\n *\n * export const TechDocsReaderPageContent = ({ entity }: TechDocsReaderPageContentProps) => {\n * // ...\n * const dom = useTechDocsReaderDom(entity);\n *\n * useEffect(() => {\n * const updateSidebarPosition = () => {\n * // ...\n * };\n * dom?.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);\n * return () => {\n * dom?.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);\n * };\n * }, [dom]);\n *\n * const handleDomAppend = useCallback(\n * (newShadowRoot: ShadowRoot) => {\n * setShadowRoot(newShadowRoot);\n * },\n * [setShadowRoot],\n * );\n *\n * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;\n * };\n * ```\n *\n * @param props - see {@link TechDocsShadowDomProps}.\n * @public\n */\nexport const TechDocsShadowDom = (props: TechDocsShadowDomProps) => {\n const { element, onAppend, children } = props;\n\n const [jss, setJss] = useState(\n create({\n ...jssPreset(),\n insertionPoint: undefined,\n }),\n );\n\n useShadowDomStylesEvents(element);\n\n const ref = useCallback(\n (shadowHost: HTMLDivElement) => {\n if (!element || !shadowHost) return;\n\n setJss(\n create({\n ...jssPreset(),\n insertionPoint: element.querySelector('head') || undefined,\n }),\n );\n\n let shadowRoot = shadowHost.shadowRoot;\n\n if (!shadowRoot) {\n shadowRoot = shadowHost.attachShadow({ mode: 'open' });\n }\n\n shadowRoot.replaceChildren(element);\n\n if (typeof onAppend === 'function') {\n onAppend(shadowRoot);\n }\n },\n [element, onAppend],\n );\n\n return (\n <>\n {/* The sheetsManager={new Map()} is needed in order to deduplicate the injection of CSS in the page. */}\n <StylesProvider jss={jss} sheetsManager={new Map()}>\n <div ref={ref} data-testid=\"techdocs-native-shadowroot\" />\n {children}\n </StylesProvider>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;AA0BO,MAAM,
|
|
1
|
+
{"version":3,"file":"component.esm.js","sources":["../src/component.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 { PropsWithChildren, useState, useEffect, useCallback } from 'react';\n\nimport { create } from 'jss';\nimport StylesProvider from '@material-ui/styles/StylesProvider';\nimport jssPreset from '@material-ui/styles/jssPreset';\n\n/**\n * Name for the event dispatched when ShadowRoot styles are loaded.\n * @public\n */\nexport const SHADOW_DOM_STYLE_LOAD_EVENT = 'TECH_DOCS_SHADOW_DOM_STYLE_LOAD';\n\n/**\n * Dispatch style load event after all styles are loaded.\n * @param element - the ShadowRoot tree.\n */\nconst useShadowDomStylesEvents = (element: Element | null) => {\n useEffect(() => {\n if (!element) {\n return () => {};\n }\n\n const styles = element.querySelectorAll<HTMLElement>(\n 'head > link[rel=\"stylesheet\"]',\n );\n\n let count = styles?.length ?? 0;\n const event = new CustomEvent(SHADOW_DOM_STYLE_LOAD_EVENT);\n\n if (!count) {\n element.dispatchEvent(event);\n return () => {};\n }\n\n const handleLoad = () => {\n if (--count === 0) {\n element.dispatchEvent(event);\n }\n };\n\n styles?.forEach(style => {\n style.addEventListener('load', handleLoad);\n });\n\n return () => {\n styles?.forEach(style => {\n style.removeEventListener('load', handleLoad);\n });\n };\n }, [element]);\n};\n\n/**\n * Returns the style's loading state.\n *\n * @example\n * Here's an example that updates the sidebar position only after styles are calculated:\n * ```jsx\n * import {\n * TechDocsShadowDom,\n * useShadowDomStylesLoading,\n * } from '@backstage/plugin-techdocs-react';\n *\n * export const TechDocsReaderPageContent = () => {\n * // ...\n * const dom = useTechDocsReaderDom(entity);\n * const isStyleLoading = useShadowDomStylesLoading(dom);\n *\n * const updateSidebarPosition = useCallback(() => {\n * //...\n * }, [dom]);\n *\n * useEffect(() => {\n * if (!isStyleLoading) {\n * updateSidebarPosition();\n * }\n * }, [isStyleLoading, updateSidebarPosition]);\n *\n * const handleDomAppend = useCallback(\n * (newShadowRoot: ShadowRoot) => {\n * setShadowRoot(newShadowRoot);\n * },\n * [setShadowRoot],\n * );\n *\n * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;\n * };\n * ```\n *\n * @param element - which is the ShadowRoot tree.\n * @returns a boolean value, true if styles are being loaded.\n * @public\n */\nexport const useShadowDomStylesLoading = (element: Element | null) => {\n const [loading, setLoading] = useState(false);\n\n useEffect(() => {\n if (!element) return () => {};\n\n setLoading(true);\n\n const style = (element as HTMLElement).style;\n\n style.setProperty('opacity', '0');\n\n const handleLoad = () => {\n setLoading(false);\n style.setProperty('opacity', '1');\n };\n\n element.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);\n\n return () => {\n element.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);\n };\n }, [element]);\n\n return loading;\n};\n\n/**\n * Props for {@link TechDocsShadowDom}.\n *\n * @remarks\n * If you want to use portals to render Material UI components in the Shadow DOM,\n * you must render these portals as children because this component wraps its children in a Material UI StylesProvider\n * to ensure that Material UI styles are applied.\n *\n * @public\n */\nexport type TechDocsShadowDomProps = PropsWithChildren<{\n /**\n * Element tree that is appended to ShadowRoot.\n */\n element: Element;\n /**\n * Callback called when the element tree is appended in ShadowRoot.\n */\n onAppend?: (shadowRoot: ShadowRoot) => void;\n}>;\n\n/**\n * Renders a tree of elements in a Shadow DOM.\n *\n * @remarks\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 * so if you want to know when Shadow DOM styles are computed, you can listen for the \"TECH_DOCS_SHADOW_DOM_STYLE_LOAD\" event dispatched by the element tree.\n *\n * @example\n * Here is an example using this component and also listening for styles loaded event:\n *```jsx\n * import {\n * TechDocsShadowDom,\n * SHADOW_DOM_STYLE_LOAD_EVENT,\n * } from '@backstage/plugin-techdocs-react';\n *\n * export const TechDocsReaderPageContent = ({ entity }: TechDocsReaderPageContentProps) => {\n * // ...\n * const dom = useTechDocsReaderDom(entity);\n *\n * useEffect(() => {\n * const updateSidebarPosition = () => {\n * // ...\n * };\n * dom?.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);\n * return () => {\n * dom?.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);\n * };\n * }, [dom]);\n *\n * const handleDomAppend = useCallback(\n * (newShadowRoot: ShadowRoot) => {\n * setShadowRoot(newShadowRoot);\n * },\n * [setShadowRoot],\n * );\n *\n * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;\n * };\n * ```\n *\n * @param props - see {@link TechDocsShadowDomProps}.\n * @public\n */\nexport const TechDocsShadowDom = (props: TechDocsShadowDomProps) => {\n const { element, onAppend, children } = props;\n\n const [jss, setJss] = useState(\n create({\n ...jssPreset(),\n insertionPoint: undefined,\n }),\n );\n\n useShadowDomStylesEvents(element);\n\n const ref = useCallback(\n (shadowHost: HTMLDivElement) => {\n if (!element || !shadowHost) return;\n\n setJss(\n create({\n ...jssPreset(),\n insertionPoint: element.querySelector('head') || undefined,\n }),\n );\n\n let shadowRoot = shadowHost.shadowRoot;\n\n if (!shadowRoot) {\n shadowRoot = shadowHost.attachShadow({ mode: 'open' });\n }\n\n shadowRoot.replaceChildren(element);\n\n if (typeof onAppend === 'function') {\n onAppend(shadowRoot);\n }\n },\n [element, onAppend],\n );\n\n return (\n <>\n {/* The sheetsManager={new Map()} is needed in order to deduplicate the injection of CSS in the page. */}\n <StylesProvider jss={jss} sheetsManager={new Map()}>\n <div ref={ref} data-testid=\"techdocs-native-shadowroot\" />\n {children}\n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I,CAAC,UAAA,EAAY;AACf,QAAA,UAAA,GAAa,UAAA,CAAW,YAAA,CAAa,EAAE,IAAA,EAAM,QAAQ,CAAA;AAAA,MACvD;AAEA,MAAA,UAAA,CAAW,gBAAgB,OAAO,CAAA;AAElC,MAAA,IAAI,OAAO,aAAa,UAAA,EAAY;AAClC,QAAA,QAAA,CAAS,UAAU,CAAA;AAAA,MACrB;AAAA,IACF,CAAA;AAAA,IACA,CAAC,SAAS,QAAQ;AAAA,GACpB;AAEA,EAAA,uCAGI,QAAA,kBAAA,IAAA,CAAC,cAAA,EAAA,EAAe,KAAU,aAAA,kBAAe,IAAI,KAAI,EAC/C,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,aAAA,EAAY,4BAAA,EAA6B,CAAA;AAAA,IACvD;AAAA,GAAA,EACH,CAAA,EACF,CAAA;AAEJ;;;;"}
|
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 && !metadata.value && !metadata.loading) {\n metadata.retry();\n }\n }, [\n metadata.value,\n metadata.loading,\n shadowRoot,\n metadata.retry,\n metadata,\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,
|
|
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 && !metadata.value && !metadata.loading) {\n metadata.retry();\n }\n }, [\n metadata.value,\n metadata.loading,\n shadowRoot,\n metadata.retry,\n metadata,\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;AAAA,EACtB,QAAA,EAAU,EAAE,OAAA,EAAS,IAAA,EAAK;AAAA,EAC1B,cAAA,EAAgB,EAAE,OAAA,EAAS,IAAA,EAAK;AAAA,EAChC,WAAW,EAAE,IAAA,EAAM,IAAI,IAAA,EAAM,EAAA,EAAI,WAAW,EAAA;AAC9C,CAAA;AAEA,MAAM,yBAAA,GAA4B,uBAE/B,8BAA8B,CAAA;AAyB1B,MAAM,0BAAA,GAA6B,IAAA;AAAA,EACxC,CAAC,KAAA,KAA2C;AAC1C,IAAA,MAAM,EAAE,SAAA,EAAW,QAAA,EAAS,GAAI,KAAA;AAEhC,IAAA,MAAM,WAAA,GAAc,OAAO,cAAc,CAAA;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A;AAE3D,IAAA,uBACE,GAAA;AAAA,MAAC,gBAAA;AAAA,MAAA;AAAA,QACC,UAAA,EAAY,EAAE,SAAA,EAAW,kBAAA,CAAmB,SAAS,CAAA,EAAE;AAAA,QAEvD,QAAA,kBAAA,GAAA,CAAC,yBAAA,CAA0B,QAAA,EAA1B,EAAmC,KAAA,EAAO,cAAA,EACxC,QAAA,EAAA,QAAA,YAAoB,QAAA,GAAW,QAAA,CAAS,KAAK,CAAA,GAAI,QAAA,EACpD;AAAA;AAAA,KACF;AAAA,EAEJ,CAAA;AAAA,EACA,CAAC,WAAW,SAAA,KAAc;AACxB,IAAA,OAAO,kBAAA,CAAmB,SAAA,CAAU,SAAA,EAAW,SAAA,CAAU,SAAS,CAAA;AAAA,EACpE;AACF;AAMO,MAAM,wBAAwB,MAAM;AACzC,EAAA,MAAM,gBAAA,GAAmB,WAAW,yBAAyB,CAAA;AAE7D,EAAA,IAAI,qBAAqB,MAAA,EAAW;AAClC,IAAA,OAAO,8BAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,GAAU,gBAAA,CAAiB,SAAA,CAAU,CAAC,CAAA;AAC5C,EAAA,IAAI,YAAY,MAAA,EAAW;AACzB,IAAA,MAAM,IAAI,MAAM,iCAAiC,CAAA;AAAA,EACnD;AAEA,EAAA,OAAO,OAAA;AACT;;;;"}
|
package/dist/helpers.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"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 { Config } from '@backstage/config';\nimport {\n CompoundEntityRef,\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport {\n TECHDOCS_EXTERNAL_ANNOTATION,\n TECHDOCS_EXTERNAL_PATH_ANNOTATION,\n} from '@backstage/plugin-techdocs-common';\nimport { RouteFunc } from '@backstage/core-plugin-api';\n\n/**\n * Lower-case entity triplets by default, but allow override.\n *\n * @public\n */\nexport function toLowercaseEntityRefMaybe(\n entityRef: CompoundEntityRef,\n config: Config,\n): CompoundEntityRef {\n if (config.getOptionalBoolean('techdocs.legacyUseCaseSensitiveTripletPaths'))\n return entityRef;\n\n entityRef.kind = entityRef.kind.toLocaleLowerCase();\n entityRef.name = entityRef.name.toLocaleLowerCase();\n entityRef.namespace = entityRef.namespace.toLocaleLowerCase();\n\n return entityRef;\n}\n\n/**\n * Get the entity path annotation from the given entity and ensure it starts with a slash.\n *\n * @public\n */\nexport function getEntityRootTechDocsPath(entity: Entity): string {\n let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];\n if (!path) {\n return '';\n }\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n return path;\n}\n\n/**\n * Build the TechDocs URL for the given entity. This helper should be used anywhere there\n * is a link to an entities TechDocs.\n *\n * @public\n */\nexport const buildTechDocsURL = (\n entity: Entity,\n routeFunc:\n | RouteFunc<{\n namespace: string;\n kind: string;\n name: string;\n }>\n | undefined,\n) => {\n if (!routeFunc) {\n return undefined;\n }\n\n let { namespace, kind, name } = getCompoundEntityRef(entity);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n const techdocsRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n namespace = techdocsRef.namespace;\n kind = techdocsRef.kind;\n name = techdocsRef.name;\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n const url = routeFunc({\n namespace,\n kind,\n name,\n });\n\n // Add on the external entity path to the url if one exists. This allows deep linking into another\n // entities TechDocs.\n const path = getEntityRootTechDocsPath(entity);\n\n return `${url}${path}`;\n};\n"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"helpers.esm.js","sources":["../src/helpers.ts"],"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 { Config } from '@backstage/config';\nimport {\n CompoundEntityRef,\n Entity,\n getCompoundEntityRef,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport {\n TECHDOCS_EXTERNAL_ANNOTATION,\n TECHDOCS_EXTERNAL_PATH_ANNOTATION,\n} from '@backstage/plugin-techdocs-common';\nimport { RouteFunc } from '@backstage/core-plugin-api';\n\n/**\n * Lower-case entity triplets by default, but allow override.\n *\n * @public\n */\nexport function toLowercaseEntityRefMaybe(\n entityRef: CompoundEntityRef,\n config: Config,\n): CompoundEntityRef {\n if (config.getOptionalBoolean('techdocs.legacyUseCaseSensitiveTripletPaths'))\n return entityRef;\n\n entityRef.kind = entityRef.kind.toLocaleLowerCase();\n entityRef.name = entityRef.name.toLocaleLowerCase();\n entityRef.namespace = entityRef.namespace.toLocaleLowerCase();\n\n return entityRef;\n}\n\n/**\n * Get the entity path annotation from the given entity and ensure it starts with a slash.\n *\n * @public\n */\nexport function getEntityRootTechDocsPath(entity: Entity): string {\n let path = entity.metadata.annotations?.[TECHDOCS_EXTERNAL_PATH_ANNOTATION];\n if (!path) {\n return '';\n }\n if (!path.startsWith('/')) {\n path = `/${path}`;\n }\n return path;\n}\n\n/**\n * Build the TechDocs URL for the given entity. This helper should be used anywhere there\n * is a link to an entities TechDocs.\n *\n * @public\n */\nexport const buildTechDocsURL = (\n entity: Entity,\n routeFunc:\n | RouteFunc<{\n namespace: string;\n kind: string;\n name: string;\n }>\n | undefined,\n) => {\n if (!routeFunc) {\n return undefined;\n }\n\n let { namespace, kind, name } = getCompoundEntityRef(entity);\n\n if (entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION]) {\n try {\n const techdocsRef = parseEntityRef(\n entity.metadata.annotations?.[TECHDOCS_EXTERNAL_ANNOTATION],\n );\n namespace = techdocsRef.namespace;\n kind = techdocsRef.kind;\n name = techdocsRef.name;\n } catch {\n // not a fan of this but we don't care if the parseEntityRef fails\n }\n }\n\n const url = routeFunc({\n namespace,\n kind,\n name,\n });\n\n // Add on the external entity path to the url if one exists. This allows deep linking into another\n // entities TechDocs.\n const path = getEntityRootTechDocsPath(entity);\n\n return `${url}${path}`;\n};\n"],"names":[],"mappings":";;;AAkCO,SAAS,yBAAA,CACd,WACA,MAAA,EACmB;AACnB,EAAA,IAAI,MAAA,CAAO,mBAAmB,6CAA6C,CAAA;AACzE,IAAA,OAAO,SAAA;AAET,EAAA,SAAA,CAAU,IAAA,GAAO,SAAA,CAAU,IAAA,CAAK,iBAAA,EAAkB;AAClD,EAAA,SAAA,CAAU,IAAA,GAAO,SAAA,CAAU,IAAA,CAAK,iBAAA,EAAkB;AAClD,EAAA,SAAA,CAAU,SAAA,GAAY,SAAA,CAAU,SAAA,CAAU,iBAAA,EAAkB;AAE5D,EAAA,OAAO,SAAA;AACT;AAOO,SAAS,0BAA0B,MAAA,EAAwB;AAChE,EAAA,IAAI,IAAA,GAAO,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,iCAAiC,CAAA;AAC1E,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,EAAA;AAAA,EACT;AACA,EAAA,IAAI,CAAC,IAAA,CAAK,UAAA,CAAW,GAAG,CAAA,EAAG;AACzB,IAAA,IAAA,GAAO,IAAI,IAAI,CAAA,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,IAAA;AACT;AAQO,MAAM,gBAAA,GAAmB,CAC9B,MAAA,EACA,SAAA,KAOG;AACH,EAAA,IAAI,CAAC,SAAA,EAAW;AACd,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,IAAI,EAAE,SAAA,EAAW,IAAA,EAAM,IAAA,EAAK,GAAI,qBAAqB,MAAM,CAAA;AAE3D,EAAA,IAAI,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,4BAA4B,CAAA,EAAG;AAC/D,IAAA,IAAI;AACF,MAAA,MAAM,WAAA,GAAc,cAAA;AAAA,QAClB,MAAA,CAAO,QAAA,CAAS,WAAA,GAAc,4BAA4B;AAAA,OAC5D;AACA,MAAA,SAAA,GAAY,WAAA,CAAY,SAAA;AACxB,MAAA,IAAA,GAAO,WAAA,CAAY,IAAA;AACnB,MAAA,IAAA,GAAO,WAAA,CAAY,IAAA;AAAA,IACrB,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AAEA,EAAA,MAAM,MAAM,SAAA,CAAU;AAAA,IACpB,SAAA;AAAA,IACA,IAAA;AAAA,IACA;AAAA,GACD,CAAA;AAID,EAAA,MAAM,IAAA,GAAO,0BAA0B,MAAM,CAAA;AAE7C,EAAA,OAAO,CAAA,EAAG,GAAG,CAAA,EAAG,IAAI,CAAA,CAAA;AACtB;;;;"}
|
package/dist/hooks.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.esm.js","sources":["../src/hooks.ts"],"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 */\nimport { useEffect, useMemo, useState } from 'react';\nimport debounce from 'lodash/debounce';\nimport { useTechDocsReaderPage } from './context';\n\n/**\n * Hook for use within TechDocs addons that provides access to the underlying\n * shadow root of the current page, allowing the DOM within to be mutated.\n * @public\n */\nexport const useShadowRoot = () => {\n const { shadowRoot } = useTechDocsReaderPage();\n return shadowRoot;\n};\n\n/**\n * Convenience hook for use within TechDocs addons that provides access to\n * elements that match a given selector within the shadow root.\n *\n * @public\n */\nexport const useShadowRootElements = <\n TReturnedElement extends HTMLElement = HTMLElement,\n>(\n selectors: string[],\n): TReturnedElement[] => {\n const shadowRoot = useShadowRoot();\n const [root, setRootNode] = useState(shadowRoot?.firstChild);\n\n useEffect(() => {\n let observer: MutationObserver;\n if (shadowRoot) {\n observer = new MutationObserver(() => {\n setRootNode(shadowRoot?.firstChild);\n });\n observer.observe(shadowRoot, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n });\n }\n return () => observer?.disconnect();\n }, [shadowRoot]);\n\n if (!root || !(root instanceof HTMLElement)) return [];\n\n return selectors\n .map(selector => root.querySelectorAll<TReturnedElement>(selector))\n .filter(nodeList => nodeList.length)\n .map(nodeList => Array.from(nodeList))\n .flat();\n};\n\nconst isValidSelection = (newSelection: Selection) => {\n // Safari sets the selection rect to top zero\n return (\n newSelection.toString() &&\n newSelection.rangeCount &&\n newSelection.getRangeAt(0).getBoundingClientRect().top\n );\n};\n\n/**\n * Hook for retrieving a selection within the ShadowRoot.\n * @public\n */\nexport const useShadowRootSelection = (waitMillis: number = 0) => {\n const shadowRoot = useShadowRoot();\n const [selection, setSelection] = useState<Selection | null>(null);\n const handleSelectionChange = useMemo(\n () =>\n debounce(() => {\n const shadowDocument = shadowRoot as ShadowRoot &\n Pick<Document, 'getSelection'>;\n // Firefox and Safari don't implement getSelection for Shadow DOM\n const newSelection = shadowDocument.getSelection\n ? shadowDocument.getSelection()\n : document.getSelection();\n\n if (newSelection && isValidSelection(newSelection)) {\n setSelection(newSelection);\n } else {\n setSelection(null);\n }\n }, waitMillis),\n [shadowRoot, setSelection, waitMillis],\n );\n\n useEffect(() => {\n window.document.addEventListener('selectionchange', handleSelectionChange);\n return () => {\n handleSelectionChange.cancel();\n window.document.removeEventListener(\n 'selectionchange',\n handleSelectionChange,\n );\n };\n }, [handleSelectionChange]);\n\n return selection;\n};\n"],"names":[],"mappings":";;;;AAwBO,MAAM,gBAAgB,MAAM;AACjC,
|
|
1
|
+
{"version":3,"file":"hooks.esm.js","sources":["../src/hooks.ts"],"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 */\nimport { useEffect, useMemo, useState } from 'react';\nimport debounce from 'lodash/debounce';\nimport { useTechDocsReaderPage } from './context';\n\n/**\n * Hook for use within TechDocs addons that provides access to the underlying\n * shadow root of the current page, allowing the DOM within to be mutated.\n * @public\n */\nexport const useShadowRoot = () => {\n const { shadowRoot } = useTechDocsReaderPage();\n return shadowRoot;\n};\n\n/**\n * Convenience hook for use within TechDocs addons that provides access to\n * elements that match a given selector within the shadow root.\n *\n * @public\n */\nexport const useShadowRootElements = <\n TReturnedElement extends HTMLElement = HTMLElement,\n>(\n selectors: string[],\n): TReturnedElement[] => {\n const shadowRoot = useShadowRoot();\n const [root, setRootNode] = useState(shadowRoot?.firstChild);\n\n useEffect(() => {\n let observer: MutationObserver;\n if (shadowRoot) {\n observer = new MutationObserver(() => {\n setRootNode(shadowRoot?.firstChild);\n });\n observer.observe(shadowRoot, {\n attributes: true,\n characterData: true,\n childList: true,\n subtree: true,\n });\n }\n return () => observer?.disconnect();\n }, [shadowRoot]);\n\n if (!root || !(root instanceof HTMLElement)) return [];\n\n return selectors\n .map(selector => root.querySelectorAll<TReturnedElement>(selector))\n .filter(nodeList => nodeList.length)\n .map(nodeList => Array.from(nodeList))\n .flat();\n};\n\nconst isValidSelection = (newSelection: Selection) => {\n // Safari sets the selection rect to top zero\n return (\n newSelection.toString() &&\n newSelection.rangeCount &&\n newSelection.getRangeAt(0).getBoundingClientRect().top\n );\n};\n\n/**\n * Hook for retrieving a selection within the ShadowRoot.\n * @public\n */\nexport const useShadowRootSelection = (waitMillis: number = 0) => {\n const shadowRoot = useShadowRoot();\n const [selection, setSelection] = useState<Selection | null>(null);\n const handleSelectionChange = useMemo(\n () =>\n debounce(() => {\n const shadowDocument = shadowRoot as ShadowRoot &\n Pick<Document, 'getSelection'>;\n // Firefox and Safari don't implement getSelection for Shadow DOM\n const newSelection = shadowDocument.getSelection\n ? shadowDocument.getSelection()\n : document.getSelection();\n\n if (newSelection && isValidSelection(newSelection)) {\n setSelection(newSelection);\n } else {\n setSelection(null);\n }\n }, waitMillis),\n [shadowRoot, setSelection, waitMillis],\n );\n\n useEffect(() => {\n window.document.addEventListener('selectionchange', handleSelectionChange);\n return () => {\n handleSelectionChange.cancel();\n window.document.removeEventListener(\n 'selectionchange',\n handleSelectionChange,\n );\n };\n }, [handleSelectionChange]);\n\n return selection;\n};\n"],"names":[],"mappings":";;;;AAwBO,MAAM,gBAAgB,MAAM;AACjC,EAAA,MAAM,EAAE,UAAA,EAAW,GAAI,qBAAA,EAAsB;AAC7C,EAAA,OAAO,UAAA;AACT;AAQO,MAAM,qBAAA,GAAwB,CAGnC,SAAA,KACuB;AACvB,EAAA,MAAM,aAAa,aAAA,EAAc;AACjC,EAAA,MAAM,CAAC,IAAA,EAAM,WAAW,CAAA,GAAI,QAAA,CAAS,YAAY,UAAU,CAAA;AAE3D,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,QAAA;AACJ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Ae,YAAA,EAAa,GAC5B,SAAS,YAAA,EAAa;AAE1B,MAAA,IAAI,YAAA,IAAgB,gBAAA,CAAiB,YAAY,CAAA,EAAG;AAClD,QAAA,YAAA,CAAa,YAAY,CAAA;AAAA,MAC3B,CAAA,MAAO;AACL,QAAA,YAAA,CAAa,IAAI,CAAA;AAAA,MACnB;AAAA,IACF,GAAG,UAAU,CAAA;AAAA,IACf,CAAC,UAAA,EAAY,YAAA,EAAc,UAAU;AAAA,GACvC;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAA,CAAO,QAAA,CAAS,gBAAA,CAAiB,iBAAA,EAAmB,qBAAqB,CAAA;AACzE,IAAA,OAAO,MAAM;AACX,MAAA,qBAAA,CAAsB,MAAA,EAAO;AAC7B,MAAA,MAAA,CAAO,QAAA,CAAS,mBAAA;AAAA,QACd,iBAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,qBAAqB,CAAC,CAAA;AAE1B,EAAA,OAAO,SAAA;AACT;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, PropsWithChildren, Dispatch, SetStateAction, ReactNode } from 'react';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
4
|
import { Extension, RouteFunc } from '@backstage/core-plugin-api';
|
|
5
|
-
import { T as
|
|
5
|
+
import { T as TechDocsAddonLocations, a as TechDocsAddonOptions, b as TechDocsMetadata, c as TechDocsEntityMetadata } from './types/types.d-DXgF2CAr.js';
|
|
6
6
|
import { CompoundEntityRef, Entity } from '@backstage/catalog-model';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
8
8
|
import { AsyncState } from 'react-use/esm/useAsync';
|
|
@@ -65,4 +65,4 @@ type TechDocsAddonOptions<TAddonProps = {}> = {
|
|
|
65
65
|
component: ComponentType<TAddonProps>;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
export {
|
|
68
|
+
export { TechDocsAddonLocations as T, type TechDocsAddonOptions as a, type TechDocsMetadata as b, type TechDocsEntityMetadata as c };
|
package/dist/types.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"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 { ComponentType } from 'react';\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * Metadata for TechDocs page\n *\n * @public\n */\nexport type TechDocsMetadata = {\n site_name: string;\n site_description: string;\n};\n\n/**\n * Metadata for TechDocs Entity\n *\n * @public\n */\nexport type TechDocsEntityMetadata = Entity & {\n locationMetadata?: { type: string; target: string };\n};\n\n/**\n * Locations for which TechDocs addons may be declared and rendered.\n * @public\n */\nexport const TechDocsAddonLocations = Object.freeze({\n /**\n * These addons fill up the header from the right, on the same line as the\n * title.\n */\n Header: 'Header',\n\n /**\n * These addons appear below the header and above all content; tooling addons\n * can be inserted for convenience.\n */\n Subheader: 'Subheader',\n\n /**\n * These addons are items added to the settings menu list and are designed to make\n * the reader experience customizable, for example accessibility options\n */\n Settings: 'Settings',\n\n /**\n * These addons appear left of the content and above the navigation.\n */\n PrimarySidebar: 'PrimarySidebar',\n\n /**\n * These addons appear right of the content and above the table of contents.\n */\n SecondarySidebar: 'SecondarySidebar',\n\n /**\n * A virtual location which allows mutation of all content within the shadow\n * root by transforming DOM nodes. These addons should return null on render.\n */\n Content: 'Content',\n\n /**\n * todo(backstage/community): This is a proposed virtual location which would\n * help implement a common addon pattern in which many instances of a given\n * element in markdown would be dynamically replaced at render-time based on\n * attributes provided on that element, for example:\n *\n * ```md\n * ## For Fun\n * <TechDocsAddon>CatGif</TechDocsAddon>\n *\n * ## Component Metadata\n * <TechDocsAddon entityRef=\"default:component/some-component-name\">CatalogEntityCard</TechDocsAddon>\n *\n * ## System Metadata\n * <TechDocsAddon entityRef=\"default:system/some-system-name\">CatalogEntityCard</TechDocsAddon>\n * ```\n *\n * Could correspond to a TechDocs addon named `CatalogEntityCard` with\n * location `TechDocsAddonLocations.COMPONENT`, whose `component` would be\n * the react component that would be rendered in place of all instances of\n * the markdown illustrated above.\n *\n * The `@backstage/plugin-techdocs-react` package would need to be updated to, in\n * cases where such addons had been registered, find all instances of the\n * the `<TechDocsAddon>` tag whose `textContent` corresponded with the name of the\n * addon, then replace them with component instances of the addon component,\n * passing any attributes from the tag as props to the component.\n */\n // Component: 'Component',\n} as const);\n\n/**\n * Options for creating a TechDocs addon.\n * @public\n */\nexport type TechDocsAddonOptions<TAddonProps = {}> = {\n name: string;\n location: keyof typeof TechDocsAddonLocations;\n component: ComponentType<TAddonProps>;\n};\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.esm.js","sources":["../src/types.ts"],"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 { ComponentType } from 'react';\nimport { Entity } from '@backstage/catalog-model';\n\n/**\n * Metadata for TechDocs page\n *\n * @public\n */\nexport type TechDocsMetadata = {\n site_name: string;\n site_description: string;\n};\n\n/**\n * Metadata for TechDocs Entity\n *\n * @public\n */\nexport type TechDocsEntityMetadata = Entity & {\n locationMetadata?: { type: string; target: string };\n};\n\n/**\n * Locations for which TechDocs addons may be declared and rendered.\n * @public\n */\nexport const TechDocsAddonLocations = Object.freeze({\n /**\n * These addons fill up the header from the right, on the same line as the\n * title.\n */\n Header: 'Header',\n\n /**\n * These addons appear below the header and above all content; tooling addons\n * can be inserted for convenience.\n */\n Subheader: 'Subheader',\n\n /**\n * These addons are items added to the settings menu list and are designed to make\n * the reader experience customizable, for example accessibility options\n */\n Settings: 'Settings',\n\n /**\n * These addons appear left of the content and above the navigation.\n */\n PrimarySidebar: 'PrimarySidebar',\n\n /**\n * These addons appear right of the content and above the table of contents.\n */\n SecondarySidebar: 'SecondarySidebar',\n\n /**\n * A virtual location which allows mutation of all content within the shadow\n * root by transforming DOM nodes. These addons should return null on render.\n */\n Content: 'Content',\n\n /**\n * todo(backstage/community): This is a proposed virtual location which would\n * help implement a common addon pattern in which many instances of a given\n * element in markdown would be dynamically replaced at render-time based on\n * attributes provided on that element, for example:\n *\n * ```md\n * ## For Fun\n * <TechDocsAddon>CatGif</TechDocsAddon>\n *\n * ## Component Metadata\n * <TechDocsAddon entityRef=\"default:component/some-component-name\">CatalogEntityCard</TechDocsAddon>\n *\n * ## System Metadata\n * <TechDocsAddon entityRef=\"default:system/some-system-name\">CatalogEntityCard</TechDocsAddon>\n * ```\n *\n * Could correspond to a TechDocs addon named `CatalogEntityCard` with\n * location `TechDocsAddonLocations.COMPONENT`, whose `component` would be\n * the react component that would be rendered in place of all instances of\n * the markdown illustrated above.\n *\n * The `@backstage/plugin-techdocs-react` package would need to be updated to, in\n * cases where such addons had been registered, find all instances of the\n * the `<TechDocsAddon>` tag whose `textContent` corresponded with the name of the\n * addon, then replace them with component instances of the addon component,\n * passing any attributes from the tag as props to the component.\n */\n // Component: 'Component',\n} as const);\n\n/**\n * Options for creating a TechDocs addon.\n * @public\n */\nexport type TechDocsAddonOptions<TAddonProps = {}> = {\n name: string;\n location: keyof typeof TechDocsAddonLocations;\n component: ComponentType<TAddonProps>;\n};\n"],"names":[],"mappings":"AA0CO,MAAM,sBAAA,GAAyB,OAAO,MAAA,CAAO;AAAA;AAAA;AAAA;AAAA;AAAA,EAKlD,MAAA,EAAQ,QAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMR,SAAA,EAAW,WAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMX,QAAA,EAAU,UAAA;AAAA;AAAA;AAAA;AAAA,EAKV,cAAA,EAAgB,gBAAA;AAAA;AAAA;AAAA;AAAA,EAKhB,gBAAA,EAAkB,kBAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,OAAA,EAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BX,CAAU;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-techdocs-react",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3-next.0",
|
|
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.7.5",
|
|
70
70
|
"@backstage/config": "1.3.3",
|
|
71
|
-
"@backstage/core-components": "0.17.
|
|
71
|
+
"@backstage/core-components": "0.17.6-next.0",
|
|
72
72
|
"@backstage/core-plugin-api": "1.10.9",
|
|
73
|
-
"@backstage/frontend-plugin-api": "0.11.
|
|
73
|
+
"@backstage/frontend-plugin-api": "0.11.1-next.0",
|
|
74
74
|
"@backstage/plugin-techdocs-common": "0.1.1",
|
|
75
75
|
"@backstage/version-bridge": "1.0.11",
|
|
76
76
|
"@material-ui/core": "^4.12.2",
|
|
@@ -81,9 +81,9 @@
|
|
|
81
81
|
"react-use": "^17.2.4"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@backstage/cli": "0.
|
|
85
|
-
"@backstage/test-utils": "1.7.11
|
|
86
|
-
"@backstage/theme": "0.6.8
|
|
84
|
+
"@backstage/cli": "0.34.2-next.1",
|
|
85
|
+
"@backstage/test-utils": "1.7.11",
|
|
86
|
+
"@backstage/theme": "0.6.8",
|
|
87
87
|
"@testing-library/jest-dom": "^6.0.0",
|
|
88
88
|
"@testing-library/react": "^16.0.0",
|
|
89
89
|
"@types/react": "^18.0.0",
|