@backstage/plugin-techdocs-react 0.1.1-next.2 → 1.0.1-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # @backstage/plugin-techdocs-react
2
2
 
3
+ ## 1.0.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/core-components@0.9.5-next.1
9
+ - @backstage/core-plugin-api@1.0.3-next.0
10
+ - @backstage/catalog-model@1.0.3-next.0
11
+
12
+ ## 1.0.1-next.0
13
+
14
+ ### Patch Changes
15
+
16
+ - 3b45ad701f: Creates a `TechDocsShadowDom` component that takes a tree of elements and an `onAppend` handler:
17
+
18
+ - Calls the `onAppend` handler when appending the element tree to the shadow root;
19
+ - Also dispatches an event when styles are loaded to let transformers know that the computed styles are ready to be consumed.
20
+
21
+ - Updated dependencies
22
+ - @backstage/core-components@0.9.5-next.0
23
+
24
+ ## 1.0.0
25
+
26
+ ### Major Changes
27
+
28
+ - 0ad901569f: The TechDocs Addon framework is now generally available.
29
+
30
+ ### Patch Changes
31
+
32
+ - 52419be116: Create a new addon location called "Settings", it is designed for addons that allow users to customize the reading experience in documentation pages.
33
+
34
+ Usage example:
35
+
36
+ ```tsx
37
+ const TextSize = techdocsModuleAddonsContribPlugin.provide(
38
+ createTechDocsAddonExtension({
39
+ name: 'TextSize',
40
+ location: TechDocsAddonLocations.Settings,
41
+ component: TextSizeAddon,
42
+ }),
43
+ );
44
+ ```
45
+
46
+ - c25e880e36: Added overload signatures for `createTechDocsAddonExtension` to handle TechDocs addons without props.
47
+ - 52fddad92d: The `TechDocsStorageApi` and its associated ref are now exported by `@backstage/plugin-techdocs-react`. The API interface, ref, and types are now deprecated in `@backstage/plugin-techdocs` and will be removed in a future release.
48
+ - 075a9a067b: Updated the return type of `createTechDocsAddonExtension` to better reflect the fact that passing children to Addon components is not a valid use-case.
49
+ - Updated dependencies
50
+ - @backstage/core-components@0.9.4
51
+ - @backstage/core-plugin-api@1.0.2
52
+ - @backstage/catalog-model@1.0.2
53
+
3
54
  ## 0.1.1-next.2
4
55
 
5
56
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-techdocs-react",
3
- "version": "0.1.1-next.2",
3
+ "version": "1.0.1-next.1",
4
4
  "main": "../dist/index.esm.js",
5
5
  "types": "../dist/index.alpha.d.ts"
6
6
  }
@@ -11,20 +11,28 @@ import { CompoundEntityRef } from '@backstage/catalog-model';
11
11
  import { Dispatch } from 'react';
12
12
  import { Entity } from '@backstage/catalog-model';
13
13
  import { Extension } from '@backstage/core-plugin-api';
14
+ import { PropsWithChildren } from 'react';
14
15
  import { default as React_2 } from 'react';
15
16
  import { ReactNode } from 'react';
16
17
  import { SetStateAction } from 'react';
17
18
 
18
19
  /**
19
- * Create a TechDocs addon.
20
- * @alpha
20
+ * Create a TechDocs addon overload signature without props.
21
+ * @public
22
+ */
23
+ export declare function createTechDocsAddonExtension(options: TechDocsAddonOptions): Extension<() => JSX.Element | null>;
24
+
25
+ /**
26
+ * Create a TechDocs addon overload signature with props.
27
+ * @public
21
28
  */
22
29
  export declare function createTechDocsAddonExtension<TComponentProps>(options: TechDocsAddonOptions<TComponentProps>): Extension<(props: TComponentProps) => JSX.Element | null>;
23
30
 
24
31
  /**
25
- * @alpha
32
+ * Name for the event dispatched when ShadowRoot styles are loaded.
33
+ * @public
26
34
  */
27
- export declare const defaultTechDocsReaderPageValue: TechDocsReaderPageValue;
35
+ export declare const SHADOW_DOM_STYLE_LOAD_EVENT = "TECH_DOCS_SHADOW_DOM_STYLE_LOAD";
28
36
 
29
37
  /**
30
38
  * The outcome of a docs sync operation.
@@ -35,13 +43,13 @@ export declare type SyncResult = 'cached' | 'updated';
35
43
 
36
44
  /**
37
45
  * Marks the <TechDocsAddons> registry component.
38
- * @alpha
46
+ * @public
39
47
  */
40
48
  export declare const TECHDOCS_ADDONS_WRAPPER_KEY = "techdocs.addons.wrapper.v1";
41
49
 
42
50
  /**
43
51
  * Locations for which TechDocs addons may be declared and rendered.
44
- * @alpha
52
+ * @public
45
53
  */
46
54
  export declare const TechDocsAddonLocations: Readonly<{
47
55
  /**
@@ -76,7 +84,7 @@ export declare const TechDocsAddonLocations: Readonly<{
76
84
 
77
85
  /**
78
86
  * Options for creating a TechDocs addon.
79
- * @alpha
87
+ * @public
80
88
  */
81
89
  export declare type TechDocsAddonOptions<TAddonProps = {}> = {
82
90
  name: string;
@@ -86,7 +94,7 @@ export declare type TechDocsAddonOptions<TAddonProps = {}> = {
86
94
 
87
95
  /**
88
96
  * TechDocs Addon registry.
89
- * @alpha
97
+ * @public
90
98
  */
91
99
  export declare const TechDocsAddons: React_2.ComponentType;
92
100
 
@@ -172,6 +180,72 @@ export declare type TechDocsReaderPageValue = {
172
180
  onReady?: () => void;
173
181
  };
174
182
 
183
+ /**
184
+ * Renders a tree of elements in a Shadow DOM.
185
+ *
186
+ * @remarks
187
+ * Centers the styles loaded event to avoid having multiple locations setting the opacity style in Shadow DOM causing the screen to flash multiple times,
188
+ * 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.
189
+ *
190
+ * @example
191
+ * Here is an example using this component and also listening for styles loaded event:
192
+ *```jsx
193
+ * import {
194
+ * TechDocsShadowDom,
195
+ * SHADOW_DOM_STYLE_LOAD_EVENT,
196
+ * } from '@backstage/plugin-techdocs-react';
197
+ *
198
+ * export const TechDocsReaderPageContent = ({ entity }: TechDocsReaderPageContentProps) => {
199
+ * // ...
200
+ * const dom = useTechDocsReaderDom(entity);
201
+ *
202
+ * useEffect(() => {
203
+ * const updateSidebarPosition = () => {
204
+ * // ...
205
+ * };
206
+ * dom?.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
207
+ * return () => {
208
+ * dom?.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
209
+ * };
210
+ * }, [dom]);
211
+ *
212
+ * const handleDomAppend = useCallback(
213
+ * (newShadowRoot: ShadowRoot) => {
214
+ * setShadowRoot(newShadowRoot);
215
+ * },
216
+ * [setShadowRoot],
217
+ * );
218
+ *
219
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
220
+ * };
221
+ * ```
222
+ *
223
+ * @param props - see {@link TechDocsShadowDomProps}.
224
+ * @public
225
+ */
226
+ export declare const TechDocsShadowDom: ({ element, onAppend, children, }: TechDocsShadowDomProps) => JSX.Element;
227
+
228
+ /**
229
+ * Props for {@link TechDocsShadowDom}.
230
+ *
231
+ * @remarks
232
+ * If you want to use portals to render Material UI components in the Shadow DOM,
233
+ * you must render these portals as children because this component wraps its children in a Material UI StylesProvider
234
+ * to ensure that Material UI styles are applied.
235
+ *
236
+ * @public
237
+ */
238
+ export declare type TechDocsShadowDomProps = PropsWithChildren<{
239
+ /**
240
+ * Element tree that is appended to ShadowRoot.
241
+ */
242
+ element: Element;
243
+ /**
244
+ * Callback called when the element tree is appended in ShadowRoot.
245
+ */
246
+ onAppend?: (shadowRoot: ShadowRoot) => void;
247
+ }>;
248
+
175
249
  /**
176
250
  * API which talks to TechDocs storage to fetch files to render.
177
251
  *
@@ -193,10 +267,53 @@ export declare interface TechDocsStorageApi {
193
267
  */
194
268
  export declare const techdocsStorageApiRef: ApiRef<TechDocsStorageApi>;
195
269
 
270
+ /**
271
+ * Returns the style's loading state.
272
+ *
273
+ * @example
274
+ * Here's an example that updates the sidebar position only after styles are calculated:
275
+ * ```jsx
276
+ * import {
277
+ * TechDocsShadowDom,
278
+ * useShadowDomStylesLoading,
279
+ * } from '@backstage/plugin-techdocs-react';
280
+ *
281
+ * export const TechDocsReaderPageContent = () => {
282
+ * // ...
283
+ * const dom = useTechDocsReaderDom(entity);
284
+ * const isStyleLoading = useShadowDomStylesLoading(dom);
285
+ *
286
+ * const updateSidebarPosition = useCallback(() => {
287
+ * //...
288
+ * }, [dom]);
289
+ *
290
+ * useEffect(() => {
291
+ * if (!isStyleLoading) {
292
+ * updateSidebarPosition();
293
+ * }
294
+ * }, [isStyleLoading, updateSidebarPosition]);
295
+ *
296
+ * const handleDomAppend = useCallback(
297
+ * (newShadowRoot: ShadowRoot) => {
298
+ * setShadowRoot(newShadowRoot);
299
+ * },
300
+ * [setShadowRoot],
301
+ * );
302
+ *
303
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
304
+ * };
305
+ * ```
306
+ *
307
+ * @param element - which is the ShadowRoot tree.
308
+ * @returns a boolean value, true if styles are being loaded.
309
+ * @public
310
+ */
311
+ export declare const useShadowDomStylesLoading: (element: Element | null) => boolean;
312
+
196
313
  /**
197
314
  * Hook for use within TechDocs addons that provides access to the underlying
198
315
  * shadow root of the current page, allowing the DOM within to be mutated.
199
- * @alpha
316
+ * @public
200
317
  */
201
318
  export declare const useShadowRoot: () => ShadowRoot | undefined;
202
319
 
@@ -204,19 +321,19 @@ export declare const useShadowRoot: () => ShadowRoot | undefined;
204
321
  * Convenience hook for use within TechDocs addons that provides access to
205
322
  * elements that match a given selector within the shadow root.
206
323
  *
207
- * @alpha
324
+ * @public
208
325
  */
209
326
  export declare const useShadowRootElements: <TReturnedElement extends HTMLElement = HTMLElement>(selectors: string[]) => TReturnedElement[];
210
327
 
211
328
  /**
212
329
  * Hook for retreiving a selection within the ShadowRoot.
213
- * @alpha
330
+ * @public
214
331
  */
215
332
  export declare const useShadowRootSelection: (wait?: number) => Selection | null;
216
333
 
217
334
  /**
218
335
  * hook to use addons in components
219
- * @alpha
336
+ * @public
220
337
  */
221
338
  export declare const useTechDocsAddons: () => {
222
339
  renderComponentByName: (name: string) => JSX.Element | null;
@@ -225,7 +342,7 @@ export declare const useTechDocsAddons: () => {
225
342
 
226
343
  /**
227
344
  * Hook used to get access to shared state between reader page components.
228
- * @alpha
345
+ * @public
229
346
  */
230
347
  export declare const useTechDocsReaderPage: () => TechDocsReaderPageValue;
231
348
 
@@ -11,13 +11,28 @@ import { CompoundEntityRef } from '@backstage/catalog-model';
11
11
  import { Dispatch } from 'react';
12
12
  import { Entity } from '@backstage/catalog-model';
13
13
  import { Extension } from '@backstage/core-plugin-api';
14
+ import { PropsWithChildren } from 'react';
14
15
  import { default as React_2 } from 'react';
15
16
  import { ReactNode } from 'react';
16
17
  import { SetStateAction } from 'react';
17
18
 
18
- /* Excluded from this release type: createTechDocsAddonExtension */
19
+ /**
20
+ * Create a TechDocs addon overload signature without props.
21
+ * @public
22
+ */
23
+ export declare function createTechDocsAddonExtension(options: TechDocsAddonOptions): Extension<() => JSX.Element | null>;
19
24
 
20
- /* Excluded from this release type: defaultTechDocsReaderPageValue */
25
+ /**
26
+ * Create a TechDocs addon overload signature with props.
27
+ * @public
28
+ */
29
+ export declare function createTechDocsAddonExtension<TComponentProps>(options: TechDocsAddonOptions<TComponentProps>): Extension<(props: TComponentProps) => JSX.Element | null>;
30
+
31
+ /**
32
+ * Name for the event dispatched when ShadowRoot styles are loaded.
33
+ * @public
34
+ */
35
+ export declare const SHADOW_DOM_STYLE_LOAD_EVENT = "TECH_DOCS_SHADOW_DOM_STYLE_LOAD";
21
36
 
22
37
  /**
23
38
  * The outcome of a docs sync operation.
@@ -26,13 +41,62 @@ import { SetStateAction } from 'react';
26
41
  */
27
42
  export declare type SyncResult = 'cached' | 'updated';
28
43
 
29
- /* Excluded from this release type: TECHDOCS_ADDONS_WRAPPER_KEY */
44
+ /**
45
+ * Marks the <TechDocsAddons> registry component.
46
+ * @public
47
+ */
48
+ export declare const TECHDOCS_ADDONS_WRAPPER_KEY = "techdocs.addons.wrapper.v1";
30
49
 
31
- /* Excluded from this release type: TechDocsAddonLocations */
50
+ /**
51
+ * Locations for which TechDocs addons may be declared and rendered.
52
+ * @public
53
+ */
54
+ export declare const TechDocsAddonLocations: Readonly<{
55
+ /**
56
+ * These addons fill up the header from the right, on the same line as the
57
+ * title.
58
+ */
59
+ readonly Header: "Header";
60
+ /**
61
+ * These addons appear below the header and above all content; tooling addons
62
+ * can be inserted for convenience.
63
+ */
64
+ readonly Subheader: "Subheader";
65
+ /**
66
+ * These addons are items added to the settings menu list and are designed to make
67
+ * the reader experience customizable, for example accessibility options
68
+ */
69
+ readonly Settings: "Settings";
70
+ /**
71
+ * These addons appear left of the content and above the navigation.
72
+ */
73
+ readonly PrimarySidebar: "PrimarySidebar";
74
+ /**
75
+ * These addons appear right of the content and above the table of contents.
76
+ */
77
+ readonly SecondarySidebar: "SecondarySidebar";
78
+ /**
79
+ * A virtual location which allows mutation of all content within the shadow
80
+ * root by transforming DOM nodes. These addons should return null on render.
81
+ */
82
+ readonly Content: "Content";
83
+ }>;
32
84
 
33
- /* Excluded from this release type: TechDocsAddonOptions */
85
+ /**
86
+ * Options for creating a TechDocs addon.
87
+ * @public
88
+ */
89
+ export declare type TechDocsAddonOptions<TAddonProps = {}> = {
90
+ name: string;
91
+ location: keyof typeof TechDocsAddonLocations;
92
+ component: ComponentType<TAddonProps>;
93
+ };
34
94
 
35
- /* Excluded from this release type: TechDocsAddons */
95
+ /**
96
+ * TechDocs Addon registry.
97
+ * @public
98
+ */
99
+ export declare const TechDocsAddons: React_2.ComponentType;
36
100
 
37
101
  /**
38
102
  * API to talk to techdocs-backend.
@@ -116,6 +180,72 @@ export declare type TechDocsReaderPageValue = {
116
180
  onReady?: () => void;
117
181
  };
118
182
 
183
+ /**
184
+ * Renders a tree of elements in a Shadow DOM.
185
+ *
186
+ * @remarks
187
+ * Centers the styles loaded event to avoid having multiple locations setting the opacity style in Shadow DOM causing the screen to flash multiple times,
188
+ * 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.
189
+ *
190
+ * @example
191
+ * Here is an example using this component and also listening for styles loaded event:
192
+ *```jsx
193
+ * import {
194
+ * TechDocsShadowDom,
195
+ * SHADOW_DOM_STYLE_LOAD_EVENT,
196
+ * } from '@backstage/plugin-techdocs-react';
197
+ *
198
+ * export const TechDocsReaderPageContent = ({ entity }: TechDocsReaderPageContentProps) => {
199
+ * // ...
200
+ * const dom = useTechDocsReaderDom(entity);
201
+ *
202
+ * useEffect(() => {
203
+ * const updateSidebarPosition = () => {
204
+ * // ...
205
+ * };
206
+ * dom?.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
207
+ * return () => {
208
+ * dom?.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
209
+ * };
210
+ * }, [dom]);
211
+ *
212
+ * const handleDomAppend = useCallback(
213
+ * (newShadowRoot: ShadowRoot) => {
214
+ * setShadowRoot(newShadowRoot);
215
+ * },
216
+ * [setShadowRoot],
217
+ * );
218
+ *
219
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
220
+ * };
221
+ * ```
222
+ *
223
+ * @param props - see {@link TechDocsShadowDomProps}.
224
+ * @public
225
+ */
226
+ export declare const TechDocsShadowDom: ({ element, onAppend, children, }: TechDocsShadowDomProps) => JSX.Element;
227
+
228
+ /**
229
+ * Props for {@link TechDocsShadowDom}.
230
+ *
231
+ * @remarks
232
+ * If you want to use portals to render Material UI components in the Shadow DOM,
233
+ * you must render these portals as children because this component wraps its children in a Material UI StylesProvider
234
+ * to ensure that Material UI styles are applied.
235
+ *
236
+ * @public
237
+ */
238
+ export declare type TechDocsShadowDomProps = PropsWithChildren<{
239
+ /**
240
+ * Element tree that is appended to ShadowRoot.
241
+ */
242
+ element: Element;
243
+ /**
244
+ * Callback called when the element tree is appended in ShadowRoot.
245
+ */
246
+ onAppend?: (shadowRoot: ShadowRoot) => void;
247
+ }>;
248
+
119
249
  /**
120
250
  * API which talks to TechDocs storage to fetch files to render.
121
251
  *
@@ -137,14 +267,83 @@ export declare interface TechDocsStorageApi {
137
267
  */
138
268
  export declare const techdocsStorageApiRef: ApiRef<TechDocsStorageApi>;
139
269
 
140
- /* Excluded from this release type: useShadowRoot */
270
+ /**
271
+ * Returns the style's loading state.
272
+ *
273
+ * @example
274
+ * Here's an example that updates the sidebar position only after styles are calculated:
275
+ * ```jsx
276
+ * import {
277
+ * TechDocsShadowDom,
278
+ * useShadowDomStylesLoading,
279
+ * } from '@backstage/plugin-techdocs-react';
280
+ *
281
+ * export const TechDocsReaderPageContent = () => {
282
+ * // ...
283
+ * const dom = useTechDocsReaderDom(entity);
284
+ * const isStyleLoading = useShadowDomStylesLoading(dom);
285
+ *
286
+ * const updateSidebarPosition = useCallback(() => {
287
+ * //...
288
+ * }, [dom]);
289
+ *
290
+ * useEffect(() => {
291
+ * if (!isStyleLoading) {
292
+ * updateSidebarPosition();
293
+ * }
294
+ * }, [isStyleLoading, updateSidebarPosition]);
295
+ *
296
+ * const handleDomAppend = useCallback(
297
+ * (newShadowRoot: ShadowRoot) => {
298
+ * setShadowRoot(newShadowRoot);
299
+ * },
300
+ * [setShadowRoot],
301
+ * );
302
+ *
303
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
304
+ * };
305
+ * ```
306
+ *
307
+ * @param element - which is the ShadowRoot tree.
308
+ * @returns a boolean value, true if styles are being loaded.
309
+ * @public
310
+ */
311
+ export declare const useShadowDomStylesLoading: (element: Element | null) => boolean;
312
+
313
+ /**
314
+ * Hook for use within TechDocs addons that provides access to the underlying
315
+ * shadow root of the current page, allowing the DOM within to be mutated.
316
+ * @public
317
+ */
318
+ export declare const useShadowRoot: () => ShadowRoot | undefined;
141
319
 
142
- /* Excluded from this release type: useShadowRootElements */
320
+ /**
321
+ * Convenience hook for use within TechDocs addons that provides access to
322
+ * elements that match a given selector within the shadow root.
323
+ *
324
+ * @public
325
+ */
326
+ export declare const useShadowRootElements: <TReturnedElement extends HTMLElement = HTMLElement>(selectors: string[]) => TReturnedElement[];
143
327
 
144
- /* Excluded from this release type: useShadowRootSelection */
328
+ /**
329
+ * Hook for retreiving a selection within the ShadowRoot.
330
+ * @public
331
+ */
332
+ export declare const useShadowRootSelection: (wait?: number) => Selection | null;
145
333
 
146
- /* Excluded from this release type: useTechDocsAddons */
334
+ /**
335
+ * hook to use addons in components
336
+ * @public
337
+ */
338
+ export declare const useTechDocsAddons: () => {
339
+ renderComponentByName: (name: string) => JSX.Element | null;
340
+ renderComponentsByLocation: (location: keyof typeof TechDocsAddonLocations) => (JSX.Element | null)[] | null;
341
+ };
147
342
 
148
- /* Excluded from this release type: useTechDocsReaderPage */
343
+ /**
344
+ * Hook used to get access to shared state between reader page components.
345
+ * @public
346
+ */
347
+ export declare const useTechDocsReaderPage: () => TechDocsReaderPageValue;
149
348
 
150
349
  export { }
package/dist/index.d.ts CHANGED
@@ -11,13 +11,28 @@ import { CompoundEntityRef } from '@backstage/catalog-model';
11
11
  import { Dispatch } from 'react';
12
12
  import { Entity } from '@backstage/catalog-model';
13
13
  import { Extension } from '@backstage/core-plugin-api';
14
+ import { PropsWithChildren } from 'react';
14
15
  import { default as React_2 } from 'react';
15
16
  import { ReactNode } from 'react';
16
17
  import { SetStateAction } from 'react';
17
18
 
18
- /* Excluded from this release type: createTechDocsAddonExtension */
19
+ /**
20
+ * Create a TechDocs addon overload signature without props.
21
+ * @public
22
+ */
23
+ export declare function createTechDocsAddonExtension(options: TechDocsAddonOptions): Extension<() => JSX.Element | null>;
19
24
 
20
- /* Excluded from this release type: defaultTechDocsReaderPageValue */
25
+ /**
26
+ * Create a TechDocs addon overload signature with props.
27
+ * @public
28
+ */
29
+ export declare function createTechDocsAddonExtension<TComponentProps>(options: TechDocsAddonOptions<TComponentProps>): Extension<(props: TComponentProps) => JSX.Element | null>;
30
+
31
+ /**
32
+ * Name for the event dispatched when ShadowRoot styles are loaded.
33
+ * @public
34
+ */
35
+ export declare const SHADOW_DOM_STYLE_LOAD_EVENT = "TECH_DOCS_SHADOW_DOM_STYLE_LOAD";
21
36
 
22
37
  /**
23
38
  * The outcome of a docs sync operation.
@@ -26,13 +41,62 @@ import { SetStateAction } from 'react';
26
41
  */
27
42
  export declare type SyncResult = 'cached' | 'updated';
28
43
 
29
- /* Excluded from this release type: TECHDOCS_ADDONS_WRAPPER_KEY */
44
+ /**
45
+ * Marks the <TechDocsAddons> registry component.
46
+ * @public
47
+ */
48
+ export declare const TECHDOCS_ADDONS_WRAPPER_KEY = "techdocs.addons.wrapper.v1";
30
49
 
31
- /* Excluded from this release type: TechDocsAddonLocations */
50
+ /**
51
+ * Locations for which TechDocs addons may be declared and rendered.
52
+ * @public
53
+ */
54
+ export declare const TechDocsAddonLocations: Readonly<{
55
+ /**
56
+ * These addons fill up the header from the right, on the same line as the
57
+ * title.
58
+ */
59
+ readonly Header: "Header";
60
+ /**
61
+ * These addons appear below the header and above all content; tooling addons
62
+ * can be inserted for convenience.
63
+ */
64
+ readonly Subheader: "Subheader";
65
+ /**
66
+ * These addons are items added to the settings menu list and are designed to make
67
+ * the reader experience customizable, for example accessibility options
68
+ */
69
+ readonly Settings: "Settings";
70
+ /**
71
+ * These addons appear left of the content and above the navigation.
72
+ */
73
+ readonly PrimarySidebar: "PrimarySidebar";
74
+ /**
75
+ * These addons appear right of the content and above the table of contents.
76
+ */
77
+ readonly SecondarySidebar: "SecondarySidebar";
78
+ /**
79
+ * A virtual location which allows mutation of all content within the shadow
80
+ * root by transforming DOM nodes. These addons should return null on render.
81
+ */
82
+ readonly Content: "Content";
83
+ }>;
32
84
 
33
- /* Excluded from this release type: TechDocsAddonOptions */
85
+ /**
86
+ * Options for creating a TechDocs addon.
87
+ * @public
88
+ */
89
+ export declare type TechDocsAddonOptions<TAddonProps = {}> = {
90
+ name: string;
91
+ location: keyof typeof TechDocsAddonLocations;
92
+ component: ComponentType<TAddonProps>;
93
+ };
34
94
 
35
- /* Excluded from this release type: TechDocsAddons */
95
+ /**
96
+ * TechDocs Addon registry.
97
+ * @public
98
+ */
99
+ export declare const TechDocsAddons: React_2.ComponentType;
36
100
 
37
101
  /**
38
102
  * API to talk to techdocs-backend.
@@ -116,6 +180,72 @@ export declare type TechDocsReaderPageValue = {
116
180
  onReady?: () => void;
117
181
  };
118
182
 
183
+ /**
184
+ * Renders a tree of elements in a Shadow DOM.
185
+ *
186
+ * @remarks
187
+ * Centers the styles loaded event to avoid having multiple locations setting the opacity style in Shadow DOM causing the screen to flash multiple times,
188
+ * 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.
189
+ *
190
+ * @example
191
+ * Here is an example using this component and also listening for styles loaded event:
192
+ *```jsx
193
+ * import {
194
+ * TechDocsShadowDom,
195
+ * SHADOW_DOM_STYLE_LOAD_EVENT,
196
+ * } from '@backstage/plugin-techdocs-react';
197
+ *
198
+ * export const TechDocsReaderPageContent = ({ entity }: TechDocsReaderPageContentProps) => {
199
+ * // ...
200
+ * const dom = useTechDocsReaderDom(entity);
201
+ *
202
+ * useEffect(() => {
203
+ * const updateSidebarPosition = () => {
204
+ * // ...
205
+ * };
206
+ * dom?.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
207
+ * return () => {
208
+ * dom?.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, updateSidebarPosition);
209
+ * };
210
+ * }, [dom]);
211
+ *
212
+ * const handleDomAppend = useCallback(
213
+ * (newShadowRoot: ShadowRoot) => {
214
+ * setShadowRoot(newShadowRoot);
215
+ * },
216
+ * [setShadowRoot],
217
+ * );
218
+ *
219
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
220
+ * };
221
+ * ```
222
+ *
223
+ * @param props - see {@link TechDocsShadowDomProps}.
224
+ * @public
225
+ */
226
+ export declare const TechDocsShadowDom: ({ element, onAppend, children, }: TechDocsShadowDomProps) => JSX.Element;
227
+
228
+ /**
229
+ * Props for {@link TechDocsShadowDom}.
230
+ *
231
+ * @remarks
232
+ * If you want to use portals to render Material UI components in the Shadow DOM,
233
+ * you must render these portals as children because this component wraps its children in a Material UI StylesProvider
234
+ * to ensure that Material UI styles are applied.
235
+ *
236
+ * @public
237
+ */
238
+ export declare type TechDocsShadowDomProps = PropsWithChildren<{
239
+ /**
240
+ * Element tree that is appended to ShadowRoot.
241
+ */
242
+ element: Element;
243
+ /**
244
+ * Callback called when the element tree is appended in ShadowRoot.
245
+ */
246
+ onAppend?: (shadowRoot: ShadowRoot) => void;
247
+ }>;
248
+
119
249
  /**
120
250
  * API which talks to TechDocs storage to fetch files to render.
121
251
  *
@@ -137,14 +267,83 @@ export declare interface TechDocsStorageApi {
137
267
  */
138
268
  export declare const techdocsStorageApiRef: ApiRef<TechDocsStorageApi>;
139
269
 
140
- /* Excluded from this release type: useShadowRoot */
270
+ /**
271
+ * Returns the style's loading state.
272
+ *
273
+ * @example
274
+ * Here's an example that updates the sidebar position only after styles are calculated:
275
+ * ```jsx
276
+ * import {
277
+ * TechDocsShadowDom,
278
+ * useShadowDomStylesLoading,
279
+ * } from '@backstage/plugin-techdocs-react';
280
+ *
281
+ * export const TechDocsReaderPageContent = () => {
282
+ * // ...
283
+ * const dom = useTechDocsReaderDom(entity);
284
+ * const isStyleLoading = useShadowDomStylesLoading(dom);
285
+ *
286
+ * const updateSidebarPosition = useCallback(() => {
287
+ * //...
288
+ * }, [dom]);
289
+ *
290
+ * useEffect(() => {
291
+ * if (!isStyleLoading) {
292
+ * updateSidebarPosition();
293
+ * }
294
+ * }, [isStyleLoading, updateSidebarPosition]);
295
+ *
296
+ * const handleDomAppend = useCallback(
297
+ * (newShadowRoot: ShadowRoot) => {
298
+ * setShadowRoot(newShadowRoot);
299
+ * },
300
+ * [setShadowRoot],
301
+ * );
302
+ *
303
+ * return <TechDocsShadowDom element={dom} onAppend={handleDomAppend} />;
304
+ * };
305
+ * ```
306
+ *
307
+ * @param element - which is the ShadowRoot tree.
308
+ * @returns a boolean value, true if styles are being loaded.
309
+ * @public
310
+ */
311
+ export declare const useShadowDomStylesLoading: (element: Element | null) => boolean;
312
+
313
+ /**
314
+ * Hook for use within TechDocs addons that provides access to the underlying
315
+ * shadow root of the current page, allowing the DOM within to be mutated.
316
+ * @public
317
+ */
318
+ export declare const useShadowRoot: () => ShadowRoot | undefined;
141
319
 
142
- /* Excluded from this release type: useShadowRootElements */
320
+ /**
321
+ * Convenience hook for use within TechDocs addons that provides access to
322
+ * elements that match a given selector within the shadow root.
323
+ *
324
+ * @public
325
+ */
326
+ export declare const useShadowRootElements: <TReturnedElement extends HTMLElement = HTMLElement>(selectors: string[]) => TReturnedElement[];
143
327
 
144
- /* Excluded from this release type: useShadowRootSelection */
328
+ /**
329
+ * Hook for retreiving a selection within the ShadowRoot.
330
+ * @public
331
+ */
332
+ export declare const useShadowRootSelection: (wait?: number) => Selection | null;
145
333
 
146
- /* Excluded from this release type: useTechDocsAddons */
334
+ /**
335
+ * hook to use addons in components
336
+ * @public
337
+ */
338
+ export declare const useTechDocsAddons: () => {
339
+ renderComponentByName: (name: string) => JSX.Element | null;
340
+ renderComponentsByLocation: (location: keyof typeof TechDocsAddonLocations) => (JSX.Element | null)[] | null;
341
+ };
147
342
 
148
- /* Excluded from this release type: useTechDocsReaderPage */
343
+ /**
344
+ * Hook used to get access to shared state between reader page components.
345
+ * @public
346
+ */
347
+ export declare const useTechDocsReaderPage: () => TechDocsReaderPageValue;
149
348
 
150
349
  export { }
package/dist/index.esm.js CHANGED
@@ -1,9 +1,12 @@
1
- import React, { useCallback, memo, useState, useContext, useMemo, useEffect } from 'react';
1
+ import React, { useCallback, memo, useState, useContext, useEffect, useMemo } from 'react';
2
2
  import { useOutlet } from 'react-router-dom';
3
3
  import { attachComponentData, createReactExtension, useElementFilter, createApiRef, useApi } from '@backstage/core-plugin-api';
4
4
  import useAsync from 'react-use/lib/useAsync';
5
5
  import { stringifyEntityRef } from '@backstage/catalog-model';
6
6
  import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
7
+ import { create } from 'jss';
8
+ import { jssPreset, StylesProvider } from '@material-ui/styles';
9
+ import { Progress } from '@backstage/core-components';
7
10
  import debounce from 'lodash/debounce';
8
11
 
9
12
  const TECHDOCS_ADDONS_KEY = "techdocs.addons.addon.v1";
@@ -132,6 +135,102 @@ const useTechDocsReaderPage = () => {
132
135
  return context;
133
136
  };
134
137
 
138
+ const TechDocsAddonLocations = Object.freeze({
139
+ Header: "Header",
140
+ Subheader: "Subheader",
141
+ Settings: "Settings",
142
+ PrimarySidebar: "PrimarySidebar",
143
+ SecondarySidebar: "SecondarySidebar",
144
+ Content: "Content"
145
+ });
146
+
147
+ const SHADOW_DOM_STYLE_LOAD_EVENT = "TECH_DOCS_SHADOW_DOM_STYLE_LOAD";
148
+ const useShadowDomStylesEvents = (element) => {
149
+ useEffect(() => {
150
+ var _a;
151
+ if (!element) {
152
+ return () => {
153
+ };
154
+ }
155
+ const styles = element.querySelectorAll('head > link[rel="stylesheet"]');
156
+ let count = (_a = styles == null ? void 0 : styles.length) != null ? _a : 0;
157
+ const event = new CustomEvent(SHADOW_DOM_STYLE_LOAD_EVENT);
158
+ if (!count) {
159
+ element.dispatchEvent(event);
160
+ return () => {
161
+ };
162
+ }
163
+ const handleLoad = () => {
164
+ if (--count === 0) {
165
+ element.dispatchEvent(event);
166
+ }
167
+ };
168
+ styles == null ? void 0 : styles.forEach((style) => {
169
+ style.addEventListener("load", handleLoad);
170
+ });
171
+ return () => {
172
+ styles == null ? void 0 : styles.forEach((style) => {
173
+ style.removeEventListener("load", handleLoad);
174
+ });
175
+ };
176
+ }, [element]);
177
+ };
178
+ const useShadowDomStylesLoading = (element) => {
179
+ const [loading, setLoading] = useState(false);
180
+ useEffect(() => {
181
+ if (!element)
182
+ return () => {
183
+ };
184
+ setLoading(true);
185
+ const style = element.style;
186
+ style.setProperty("opacity", "0");
187
+ const handleLoad = () => {
188
+ setLoading(false);
189
+ style.setProperty("opacity", "1");
190
+ };
191
+ element.addEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);
192
+ return () => {
193
+ element.removeEventListener(SHADOW_DOM_STYLE_LOAD_EVENT, handleLoad);
194
+ };
195
+ }, [element]);
196
+ return loading;
197
+ };
198
+ const TechDocsShadowDom = ({
199
+ element,
200
+ onAppend,
201
+ children
202
+ }) => {
203
+ const [jss, setJss] = useState(create({
204
+ ...jssPreset(),
205
+ insertionPoint: void 0
206
+ }));
207
+ useShadowDomStylesEvents(element);
208
+ const loading = useShadowDomStylesLoading(element);
209
+ const ref = useCallback((shadowHost) => {
210
+ if (!element || !shadowHost)
211
+ return;
212
+ setJss(create({
213
+ ...jssPreset(),
214
+ insertionPoint: element.querySelector("head") || void 0
215
+ }));
216
+ let shadowRoot = shadowHost.shadowRoot;
217
+ if (!shadowRoot) {
218
+ shadowRoot = shadowHost.attachShadow({ mode: "open" });
219
+ }
220
+ shadowRoot.replaceChildren(element);
221
+ if (typeof onAppend === "function") {
222
+ onAppend(shadowRoot);
223
+ }
224
+ }, [element, onAppend]);
225
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, loading && /* @__PURE__ */ React.createElement(Progress, null), /* @__PURE__ */ React.createElement(StylesProvider, {
226
+ jss,
227
+ sheetsManager: /* @__PURE__ */ new Map()
228
+ }, /* @__PURE__ */ React.createElement("div", {
229
+ ref,
230
+ "data-testid": "techdocs-native-shadowroot"
231
+ }), children));
232
+ };
233
+
135
234
  const useShadowRoot = () => {
136
235
  const { shadowRoot } = useTechDocsReaderPage();
137
236
  return shadowRoot;
@@ -164,14 +263,5 @@ const useShadowRootSelection = (wait = 0) => {
164
263
  return selection;
165
264
  };
166
265
 
167
- const TechDocsAddonLocations = Object.freeze({
168
- Header: "Header",
169
- Subheader: "Subheader",
170
- Settings: "Settings",
171
- PrimarySidebar: "PrimarySidebar",
172
- SecondarySidebar: "SecondarySidebar",
173
- Content: "Content"
174
- });
175
-
176
- export { TECHDOCS_ADDONS_WRAPPER_KEY, TechDocsAddonLocations, TechDocsAddons, TechDocsReaderPageProvider, createTechDocsAddonExtension, defaultTechDocsReaderPageValue, techdocsApiRef, techdocsStorageApiRef, useShadowRoot, useShadowRootElements, useShadowRootSelection, useTechDocsAddons, useTechDocsReaderPage };
266
+ export { SHADOW_DOM_STYLE_LOAD_EVENT, TECHDOCS_ADDONS_WRAPPER_KEY, TechDocsAddonLocations, TechDocsAddons, TechDocsReaderPageProvider, TechDocsShadowDom, createTechDocsAddonExtension, techdocsApiRef, techdocsStorageApiRef, useShadowDomStylesLoading, useShadowRoot, useShadowRootElements, useShadowRootSelection, useTechDocsAddons, useTechDocsReaderPage };
177
267
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/addons.tsx","../src/api.ts","../src/context.tsx","../src/hooks.ts","../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 React, { 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\nexport const TECHDOCS_ADDONS_KEY = 'techdocs.addons.addon.v1';\n\n/**\n * Marks the <TechDocsAddons> registry component.\n * @alpha\n */\nexport const TECHDOCS_ADDONS_WRAPPER_KEY = 'techdocs.addons.wrapper.v1';\n\n/**\n * TechDocs Addon registry.\n * @alpha\n */\nexport const TechDocsAddons: React.ComponentType = () => null;\n\nattachComponentData(TechDocsAddons, TECHDOCS_ADDONS_WRAPPER_KEY, true);\n\nconst getDataKeyByName = (name: string) => {\n return `${TECHDOCS_ADDONS_KEY}.${name.toLocaleLowerCase('en-US')}`;\n};\n\n/**\n * Create a TechDocs addon.\n * @alpha\n */\nexport function createTechDocsAddonExtension<TComponentProps>(\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 * @alpha\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","/*\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 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","/*\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, {\n Dispatch,\n SetStateAction,\n useContext,\n useState,\n memo,\n ReactNode,\n} from 'react';\nimport useAsync, { AsyncState } from 'react-use/lib/useAsync';\n\nimport {\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { techdocsApiRef } from './api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\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\n/**\n * @alpha\n */\nexport const 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 ({ entityRef, children }: TechDocsReaderPageProviderProps) => {\n const techdocsApi = useApi(techdocsApiRef);\n\n const metadata = useAsync(async () => {\n return techdocsApi.getTechDocsMetadata(entityRef);\n }, [entityRef]);\n\n const entityMetadata = useAsync(async () => {\n return techdocsApi.getEntityMetadata(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 value = {\n metadata,\n entityRef,\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 <TechDocsReaderPageContext.Provider value={versionedValue}>\n {children instanceof Function ? children(value) : children}\n </TechDocsReaderPageContext.Provider>\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 * @alpha\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","/*\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 { useState, useEffect, useMemo } 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 * @alpha\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 * @alpha\n */\nexport const useShadowRootElements = <\n TReturnedElement extends HTMLElement = HTMLElement,\n>(\n selectors: string[],\n): TReturnedElement[] => {\n const shadowRoot = useShadowRoot();\n if (!shadowRoot) return [];\n return selectors\n .map(selector => shadowRoot?.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 retreiving a selection within the ShadowRoot.\n * @alpha\n */\nexport const useShadowRootSelection = (wait: 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 }, wait),\n [shadowRoot, setSelection, wait],\n );\n\n useEffect(() => {\n window.document.addEventListener('selectionchange', handleSelectionChange);\n return () =>\n window.document.removeEventListener(\n 'selectionchange',\n handleSelectionChange,\n );\n }, [handleSelectionChange]);\n\n return selection;\n};\n","/*\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 * @alpha\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 * @alpha\n */\nexport type TechDocsAddonOptions<TAddonProps = {}> = {\n name: string;\n location: keyof typeof TechDocsAddonLocations;\n component: ComponentType<TAddonProps>;\n};\n"],"names":[],"mappings":";;;;;;;;AAOO,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAClD,MAAC,2BAA2B,GAAG,6BAA6B;AAC5D,MAAC,cAAc,GAAG,MAAM,KAAK;AACzC,mBAAmB,CAAC,cAAc,EAAE,2BAA2B,EAAE,IAAI,CAAC,CAAC;AACvE,MAAM,gBAAgB,GAAG,CAAC,IAAI,KAAK;AACnC,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AACK,SAAS,4BAA4B,CAAC,OAAO,EAAE;AACtD,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;AACrD,EAAE,OAAO,oBAAoB,CAAC;AAC9B,IAAI,IAAI;AACR,IAAI,SAAS,EAAE;AACf,MAAM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c,CAAC,YAAY,EAAE,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;AAC/G,IAAI,IAAI,YAAY,IAAI,gBAAgB,CAAC,YAAY,CAAC,EAAE;AACxD,MAAM,YAAY,CAAC,YAAY,CAAC,CAAC;AACjC,KAAK,MAAM;AACX,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;AACzB,KAAK;AACL,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9C,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;AAC/E,IAAI,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;AAC/F,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9B,EAAE,OAAO,SAAS,CAAC;AACnB;;ACjCY,MAAC,sBAAsB,GAAG,MAAM,CAAC,MAAM,CAAC;AACpD,EAAE,MAAM,EAAE,QAAQ;AAClB,EAAE,SAAS,EAAE,WAAW;AACxB,EAAE,QAAQ,EAAE,UAAU;AACtB,EAAE,cAAc,EAAE,gBAAgB;AAClC,EAAE,gBAAgB,EAAE,kBAAkB;AACtC,EAAE,OAAO,EAAE,SAAS;AACpB,CAAC;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/addons.tsx","../src/api.ts","../src/context.tsx","../src/types.ts","../src/component.tsx","../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 */\n\nimport React, { 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\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: React.ComponentType = () => null;\n\nattachComponentData(TechDocsAddons, TECHDOCS_ADDONS_WRAPPER_KEY, true);\n\nconst 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<TComponentProps>(\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","/*\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 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","/*\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, {\n Dispatch,\n SetStateAction,\n useContext,\n useState,\n memo,\n ReactNode,\n} from 'react';\nimport useAsync, { AsyncState } from 'react-use/lib/useAsync';\n\nimport {\n CompoundEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport {\n createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\n\nimport { useApi } from '@backstage/core-plugin-api';\n\nimport { techdocsApiRef } from './api';\nimport { TechDocsEntityMetadata, TechDocsMetadata } from './types';\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 ({ entityRef, children }: TechDocsReaderPageProviderProps) => {\n const techdocsApi = useApi(techdocsApiRef);\n\n const metadata = useAsync(async () => {\n return techdocsApi.getTechDocsMetadata(entityRef);\n }, [entityRef]);\n\n const entityMetadata = useAsync(async () => {\n return techdocsApi.getEntityMetadata(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 value = {\n metadata,\n entityRef,\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 <TechDocsReaderPageContext.Provider value={versionedValue}>\n {children instanceof Function ? children(value) : children}\n </TechDocsReaderPageContext.Provider>\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","/*\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","/*\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, {\n PropsWithChildren,\n useState,\n useEffect,\n useCallback,\n} from 'react';\n\nimport { create } from 'jss';\nimport { StylesProvider, jssPreset } from '@material-ui/styles';\n\nimport { Progress } from '@backstage/core-components';\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 = ({\n element,\n onAppend,\n children,\n}: TechDocsShadowDomProps) => {\n const [jss, setJss] = useState(\n create({\n ...jssPreset(),\n insertionPoint: undefined,\n }),\n );\n\n useShadowDomStylesEvents(element);\n const loading = useShadowDomStylesLoading(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 {loading && <Progress />}\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","/*\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 { useState, useEffect, useMemo } 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 if (!shadowRoot) return [];\n return selectors\n .map(selector => shadowRoot?.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 retreiving a selection within the ShadowRoot.\n * @public\n */\nexport const useShadowRootSelection = (wait: 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 }, wait),\n [shadowRoot, setSelection, wait],\n );\n\n useEffect(() => {\n window.document.addEventListener('selectionchange', handleSelectionChange);\n return () =>\n window.document.removeEventListener(\n 'selectionchange',\n handleSelectionChange,\n );\n }, [handleSelectionChange]);\n\n return selection;\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAOO,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAClD,MAAC,2BAA2B,GAAG,6BAA6B;AAC5D,MAAC,cAAc,GAAG,MAAM,KAAK;AACzC,mBAAmB,CAAC,cAAc,EAAE,2BAA2B,EAAE,IAAI,CAAC,CAAC;AACvE,MAAM,gBAAgB,GAAG,CAAC,IAAI,KAAK;AACnC,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACrE,CAAC,CAAC;AACK,SAAS,4BAA4B,CAAC,OAAO,EAAE;AACtD,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;AACrD,EAAE,OAAO,oBAAoB,CAAC;AAC9B,IAAI,IAAI;AACR,IAAI,SAAS,EAAE;AACf,MAAM,IAAI,EAAE,CAAC,KAAK,qBAAqB,KAAK,CAAC,aAAa,CAAC,aAAa,EAAE;AAC1E,QAAQ,GAAG,KAAK;AAChB,OAAO,CAAC;AACR,KAAK;AACL,IAAI,IAAI,EAAE;AACV,MAAM,CAAC,mBAAmB,GAAG,OAAO;AACpC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI;AACpC,KAAK;AACL,GAAG,CAAC,CAAC;AACL,CAAC;AACD,MAAM,sBAAsB,GAAG,CAAC,UAAU,EAAE,GAAG,KAAK;AACpD,EAAE,OAAO,UAAU,CAAC,qBAAqB,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Y,CAAC,CAAC;AACjC,KAAK,MAAM;AACX,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;AACzB,KAAK;AACL,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;AAC9C,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;AAC/E,IAAI,OAAO,MAAM,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,CAAC;AAC/F,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC9B,EAAE,OAAO,SAAS,CAAC;AACnB;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-techdocs-react",
3
3
  "description": "Shared frontend utilities for TechDocs and Addons",
4
- "version": "0.1.1-next.2",
4
+ "version": "1.0.1-next.1",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -35,9 +35,9 @@
35
35
  "start": "backstage-cli package start"
36
36
  },
37
37
  "dependencies": {
38
- "@backstage/catalog-model": "^1.0.2-next.0",
39
- "@backstage/core-components": "^0.9.4-next.1",
40
- "@backstage/core-plugin-api": "^1.0.2-next.1",
38
+ "@backstage/catalog-model": "^1.0.3-next.0",
39
+ "@backstage/core-components": "^0.9.5-next.1",
40
+ "@backstage/core-plugin-api": "^1.0.3-next.0",
41
41
  "@backstage/version-bridge": "^1.0.1",
42
42
  "@material-ui/core": "^4.12.2",
43
43
  "@material-ui/lab": "4.0.0-alpha.57",
@@ -53,8 +53,9 @@
53
53
  "react": "^16.13.1 || ^17.0.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@backstage/test-utils": "^1.1.0-next.2",
56
+ "@backstage/test-utils": "^1.1.1-next.0",
57
57
  "@backstage/theme": "^0.2.15",
58
+ "@testing-library/jest-dom": "^5.10.1",
58
59
  "@testing-library/react": "^12.1.3",
59
60
  "@testing-library/react-hooks": "^8.0.0"
60
61
  },
@@ -62,5 +63,5 @@
62
63
  "alpha",
63
64
  "dist"
64
65
  ],
65
- "gitHead": "cfbf5762d7d91eee18999306b21d63840400ee29"
66
+ "gitHead": "e15c24ddb5d14034629ced8a5a5d8f12b8f1a7dd"
66
67
  }