@docusaurus/theme-common 2.0.0-beta.12faed89d → 2.0.0-beta.14

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.
Files changed (156) hide show
  1. package/lib/{utils/useCollapsible.d.ts → components/Collapsible/index.d.ts} +10 -3
  2. package/lib/components/Collapsible/index.d.ts.map +1 -0
  3. package/lib/{utils/useCollapsible.js → components/Collapsible/index.js} +37 -14
  4. package/lib/components/Collapsible/index.js.map +1 -0
  5. package/lib/components/Details/index.d.ts +13 -0
  6. package/lib/components/Details/index.d.ts.map +1 -0
  7. package/lib/components/Details/index.js +65 -0
  8. package/lib/components/Details/index.js.map +1 -0
  9. package/lib/components/Details/styles.module.css +58 -0
  10. package/lib/index.d.ts +20 -5
  11. package/lib/index.d.ts.map +1 -0
  12. package/lib/index.js +15 -3
  13. package/lib/index.js.map +1 -0
  14. package/lib/utils/ThemeClassNames.d.ts +38 -12
  15. package/lib/utils/ThemeClassNames.d.ts.map +1 -0
  16. package/lib/utils/ThemeClassNames.js +38 -3
  17. package/lib/utils/ThemeClassNames.js.map +1 -0
  18. package/lib/utils/announcementBarUtils.d.ts +4 -3
  19. package/lib/utils/announcementBarUtils.d.ts.map +1 -0
  20. package/lib/utils/announcementBarUtils.js +15 -18
  21. package/lib/utils/announcementBarUtils.js.map +1 -0
  22. package/lib/utils/codeBlockUtils.d.ts +11 -0
  23. package/lib/utils/codeBlockUtils.d.ts.map +1 -0
  24. package/lib/utils/codeBlockUtils.js +120 -0
  25. package/lib/utils/codeBlockUtils.js.map +1 -0
  26. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +3 -2
  27. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -0
  28. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +3 -2
  29. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -0
  30. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +1 -0
  31. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +1 -0
  32. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +2 -3
  33. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +1 -0
  34. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +12 -3
  35. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +1 -0
  36. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +2 -2
  37. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +1 -0
  38. package/lib/utils/docsUtils.d.ts +21 -0
  39. package/lib/utils/docsUtils.d.ts.map +1 -0
  40. package/lib/utils/docsUtils.js +107 -0
  41. package/lib/utils/docsUtils.js.map +1 -0
  42. package/lib/utils/generalUtils.d.ts +7 -0
  43. package/lib/utils/generalUtils.d.ts.map +1 -0
  44. package/lib/utils/generalUtils.js +3 -2
  45. package/lib/utils/generalUtils.js.map +1 -0
  46. package/lib/utils/historyUtils.d.ts +12 -0
  47. package/lib/utils/historyUtils.d.ts.map +1 -0
  48. package/lib/utils/historyUtils.js +40 -0
  49. package/lib/utils/historyUtils.js.map +1 -0
  50. package/lib/utils/jsUtils.d.ts +20 -0
  51. package/lib/utils/jsUtils.d.ts.map +1 -0
  52. package/lib/utils/jsUtils.js +26 -0
  53. package/lib/utils/jsUtils.js.map +1 -0
  54. package/lib/utils/mobileSecondaryMenu.d.ts +3 -2
  55. package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -0
  56. package/lib/utils/mobileSecondaryMenu.js +4 -4
  57. package/lib/utils/mobileSecondaryMenu.js.map +1 -0
  58. package/lib/utils/pathUtils.d.ts +1 -0
  59. package/lib/utils/pathUtils.d.ts.map +1 -0
  60. package/lib/utils/pathUtils.js +2 -3
  61. package/lib/utils/pathUtils.js.map +1 -0
  62. package/lib/utils/reactUtils.d.ts +10 -0
  63. package/lib/utils/reactUtils.d.ts.map +1 -0
  64. package/lib/utils/reactUtils.js +27 -0
  65. package/lib/utils/reactUtils.js.map +1 -0
  66. package/lib/utils/regexpUtils.d.ts +11 -0
  67. package/lib/utils/regexpUtils.d.ts.map +1 -0
  68. package/lib/utils/regexpUtils.js +17 -0
  69. package/lib/utils/regexpUtils.js.map +1 -0
  70. package/lib/utils/scrollUtils.d.ts +53 -0
  71. package/lib/utils/scrollUtils.d.ts.map +1 -0
  72. package/lib/utils/scrollUtils.js +136 -0
  73. package/lib/utils/scrollUtils.js.map +1 -0
  74. package/lib/utils/searchUtils.d.ts +1 -0
  75. package/lib/utils/searchUtils.d.ts.map +1 -0
  76. package/lib/utils/searchUtils.js +1 -0
  77. package/lib/utils/searchUtils.js.map +1 -0
  78. package/lib/utils/storageUtils.d.ts +5 -0
  79. package/lib/utils/storageUtils.d.ts.map +1 -0
  80. package/lib/utils/storageUtils.js +30 -3
  81. package/lib/utils/storageUtils.js.map +1 -0
  82. package/lib/utils/tagsUtils.d.ts +19 -0
  83. package/lib/utils/tagsUtils.d.ts.map +1 -0
  84. package/lib/utils/tagsUtils.js +34 -0
  85. package/lib/utils/tagsUtils.js.map +1 -0
  86. package/lib/utils/tocUtils.d.ts +16 -0
  87. package/lib/utils/tocUtils.d.ts.map +1 -0
  88. package/lib/utils/tocUtils.js +35 -0
  89. package/lib/utils/tocUtils.js.map +1 -0
  90. package/lib/utils/useAlternatePageUtils.d.ts +1 -0
  91. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
  92. package/lib/utils/useAlternatePageUtils.js +1 -0
  93. package/lib/utils/useAlternatePageUtils.js.map +1 -0
  94. package/lib/utils/useContextualSearchFilters.d.ts +12 -0
  95. package/lib/utils/useContextualSearchFilters.d.ts.map +1 -0
  96. package/lib/utils/useContextualSearchFilters.js +37 -0
  97. package/lib/utils/useContextualSearchFilters.js.map +1 -0
  98. package/{src/utils/docsUtils.ts → lib/utils/useLocalPathname.d.ts} +2 -5
  99. package/lib/utils/useLocalPathname.d.ts.map +1 -0
  100. package/lib/utils/useLocalPathname.js +17 -0
  101. package/lib/utils/useLocalPathname.js.map +1 -0
  102. package/lib/utils/useLocationChange.d.ts +1 -0
  103. package/lib/utils/useLocationChange.d.ts.map +1 -0
  104. package/lib/utils/useLocationChange.js +10 -11
  105. package/lib/utils/useLocationChange.js.map +1 -0
  106. package/lib/utils/usePluralForm.d.ts +1 -0
  107. package/lib/utils/usePluralForm.d.ts.map +1 -0
  108. package/lib/utils/usePluralForm.js +2 -3
  109. package/lib/utils/usePluralForm.js.map +1 -0
  110. package/lib/utils/usePrevious.d.ts +1 -0
  111. package/lib/utils/usePrevious.d.ts.map +1 -0
  112. package/lib/utils/usePrevious.js +4 -2
  113. package/lib/utils/usePrevious.js.map +1 -0
  114. package/lib/utils/useTOCHighlight.d.ts +15 -0
  115. package/lib/utils/useTOCHighlight.d.ts.map +1 -0
  116. package/lib/utils/useTOCHighlight.js +125 -0
  117. package/lib/utils/useTOCHighlight.js.map +1 -0
  118. package/lib/utils/useThemeConfig.d.ts +32 -9
  119. package/lib/utils/useThemeConfig.d.ts.map +1 -0
  120. package/lib/utils/useThemeConfig.js +1 -0
  121. package/lib/utils/useThemeConfig.js.map +1 -0
  122. package/package.json +18 -12
  123. package/src/{utils/useCollapsible.tsx → components/Collapsible/index.tsx} +70 -25
  124. package/src/components/Details/index.tsx +94 -0
  125. package/src/components/Details/styles.module.css +58 -0
  126. package/src/index.ts +56 -5
  127. package/src/types.d.ts +0 -2
  128. package/src/utils/ThemeClassNames.ts +43 -4
  129. package/src/utils/announcementBarUtils.tsx +20 -15
  130. package/src/utils/codeBlockUtils.ts +151 -0
  131. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +7 -6
  132. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +2 -3
  133. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +14 -14
  134. package/src/utils/docsUtils.tsx +185 -0
  135. package/src/utils/generalUtils.ts +3 -2
  136. package/src/utils/historyUtils.ts +50 -0
  137. package/src/utils/jsUtils.ts +33 -0
  138. package/src/utils/mobileSecondaryMenu.tsx +9 -6
  139. package/src/utils/pathUtils.ts +2 -3
  140. package/src/utils/reactUtils.tsx +34 -0
  141. package/src/utils/regexpUtils.ts +23 -0
  142. package/src/utils/scrollUtils.tsx +237 -0
  143. package/src/utils/storageUtils.ts +27 -4
  144. package/src/utils/tagsUtils.ts +48 -0
  145. package/src/utils/tocUtils.ts +55 -0
  146. package/src/utils/useContextualSearchFilters.ts +50 -0
  147. package/src/utils/useLocalPathname.ts +20 -0
  148. package/src/utils/useLocationChange.ts +10 -12
  149. package/src/utils/usePluralForm.ts +2 -3
  150. package/src/utils/usePrevious.ts +3 -2
  151. package/src/utils/useTOCHighlight.ts +179 -0
  152. package/src/utils/useThemeConfig.ts +34 -9
  153. package/lib/.tsbuildinfo +0 -1
  154. package/src/utils/__tests__/codeBlockUtils.test.ts +0 -54
  155. package/src/utils/__tests__/pathUtils.test.ts +0 -32
  156. package/tsconfig.json +0 -10
@@ -5,3 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  export declare const isSamePath: (path1: string | undefined, path2: string | undefined) => boolean;
8
+ //# sourceMappingURL=pathUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.d.ts","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,UAAU,UACd,MAAM,GAAG,SAAS,SAClB,MAAM,GAAG,SAAS,KACxB,OAIF,CAAC"}
@@ -6,8 +6,7 @@
6
6
  */
7
7
  // Compare the 2 paths, ignoring trailing /
8
8
  export const isSamePath = (path1, path2) => {
9
- const normalize = (pathname) => {
10
- return !pathname || (pathname === null || pathname === void 0 ? void 0 : pathname.endsWith('/')) ? pathname : `${pathname}/`;
11
- };
9
+ const normalize = (pathname) => !pathname || (pathname === null || pathname === void 0 ? void 0 : pathname.endsWith('/')) ? pathname : `${pathname}/`;
12
10
  return normalize(path1) === normalize(path2);
13
11
  };
12
+ //# sourceMappingURL=pathUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,2CAA2C;AAC3C,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAyB,EACzB,KAAyB,EAChB,EAAE;IACX,MAAM,SAAS,GAAG,CAAC,QAA4B,EAAE,EAAE,CACjD,CAAC,QAAQ,KAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC;IACnE,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useEffect } from 'react';
8
+ export declare const useIsomorphicLayoutEffect: typeof useEffect;
9
+ export declare function useDynamicCallback<T extends (...args: never[]) => unknown>(callback: T): T;
10
+ //# sourceMappingURL=reactUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactUtils.d.ts","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAc,SAAS,EAA0B,MAAM,OAAO,CAAC;AAMtE,eAAO,MAAM,yBAAyB,kBACuB,CAAC;AAQ9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxE,QAAQ,EAAE,CAAC,GACV,CAAC,CASH"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
8
+ // This hook is like useLayoutEffect, but without the SSR warning
9
+ // It seems hacky but it's used in many React libs (Redux, Formik...)
10
+ // Also mentioned here: https://github.com/facebook/react/issues/16956
11
+ // It is useful when you need to update a ref as soon as possible after a React render (before useEffect)
12
+ export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
13
+ // Permits to transform an unstable callback (like an arrow function provided as props)
14
+ // to a "stable" callback that is safe to use in a useEffect dependency array
15
+ // Useful to avoid React stale closure problems + avoid useless effect re-executions
16
+ //
17
+ // Workaround until the React team recommends a good solution, see https://github.com/facebook/react/issues/16956
18
+ // This generally works has some potential drawbacks, such as https://github.com/facebook/react/issues/16956#issuecomment-536636418
19
+ export function useDynamicCallback(callback) {
20
+ const ref = useRef(callback);
21
+ useIsomorphicLayoutEffect(() => {
22
+ ref.current = callback;
23
+ }, [callback]);
24
+ // @ts-expect-error: TODO, not sure how to fix this TS error
25
+ return useCallback((...args) => ref.current(...args), []);
26
+ }
27
+ //# sourceMappingURL=reactUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactUtils.js","sourceRoot":"","sources":["../../src/utils/reactUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtE,iEAAiE;AACjE,qEAAqE;AACrE,sEAAsE;AACtE,yGAAyG;AACzG,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9D,uFAAuF;AACvF,6EAA6E;AAC7E,oFAAoF;AACpF,EAAE;AACF,iHAAiH;AACjH,mIAAmI;AACnI,MAAM,UAAU,kBAAkB,CAChC,QAAW;IAEX,MAAM,GAAG,GAAG,MAAM,CAAI,QAAQ,CAAC,CAAC;IAEhC,yBAAyB,CAAC,GAAG,EAAE;QAC7B,GAAG,CAAC,OAAO,GAAG,QAAQ,CAAC;IACzB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,4DAA4D;IAC5D,OAAO,WAAW,CAAI,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * Utility to convert an optional string into a Regex case sensitive and global
9
+ */
10
+ export declare function isRegexpStringMatch(regexAsString?: string, valueToTest?: string): boolean;
11
+ //# sourceMappingURL=regexpUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexpUtils.d.ts","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,CAAC,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAST"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * Utility to convert an optional string into a Regex case sensitive and global
9
+ */
10
+ export function isRegexpStringMatch(regexAsString, valueToTest) {
11
+ if (typeof regexAsString === 'undefined' ||
12
+ typeof valueToTest === 'undefined') {
13
+ return false;
14
+ }
15
+ return new RegExp(regexAsString, 'gi').test(valueToTest);
16
+ }
17
+ //# sourceMappingURL=regexpUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexpUtils.js","sourceRoot":"","sources":["../../src/utils/regexpUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,aAAsB,EACtB,WAAoB;IAEpB,IACE,OAAO,aAAa,KAAK,WAAW;QACpC,OAAO,WAAW,KAAK,WAAW,EAClC;QACA,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC3D,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { ReactNode } from 'react';
8
+ /**
9
+ * We need a way to update the scroll position while ignoring scroll events
10
+ * without affecting Navbar/BackToTop visibility
11
+ *
12
+ * This API permits to temporarily disable/ignore scroll events
13
+ * Motivated by https://github.com/facebook/docusaurus/pull/5618
14
+ */
15
+ declare type ScrollController = {
16
+ /**
17
+ * A boolean ref tracking whether scroll events are enabled
18
+ */
19
+ scrollEventsEnabledRef: React.MutableRefObject<boolean>;
20
+ /**
21
+ * Enables scroll events in `useScrollPosition`
22
+ */
23
+ enableScrollEvents: () => void;
24
+ /**
25
+ * Disables scroll events in `useScrollPosition`
26
+ */
27
+ disableScrollEvents: () => void;
28
+ };
29
+ export declare function ScrollControllerProvider({ children, }: {
30
+ children: ReactNode;
31
+ }): JSX.Element;
32
+ export declare function useScrollController(): ScrollController;
33
+ declare type ScrollPosition = {
34
+ scrollX: number;
35
+ scrollY: number;
36
+ };
37
+ export declare function useScrollPosition(effect: (position: ScrollPosition, lastPosition: ScrollPosition | null) => void, deps?: unknown[]): void;
38
+ declare type UseScrollPositionBlockerReturn = {
39
+ blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
40
+ };
41
+ /**
42
+ * This hook permits to "block" the scroll position of a dom element
43
+ * The idea is that we should be able to update DOM content above this element
44
+ * but the screen position of this element should not change
45
+ *
46
+ * Feature motivated by the Tabs groups:
47
+ * clicking on a tab may affect tabs of the same group upper in the tree
48
+ * Yet to avoid a bad UX, the clicked tab must remain under the user mouse!
49
+ * See GIF here: https://github.com/facebook/docusaurus/pull/5618
50
+ */
51
+ export declare function useScrollPositionBlocker(): UseScrollPositionBlockerReturn;
52
+ export {};
53
+ //# sourceMappingURL=scrollUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollUtils.d.ts","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAEZ,SAAS,EAOV,MAAM,OAAO,CAAC;AAIf;;;;;;GAMG;AACH,aAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,sBAAsB,EAAE,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxD;;OAEG;IACH,kBAAkB,EAAE,MAAM,IAAI,CAAC;IAC/B;;OAEG;IACH,mBAAmB,EAAE,MAAM,IAAI,CAAC;CACjC,CAAC;AAuBF,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAMd;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAQtD;AAUD,aAAK,cAAc,GAAG;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAAC;AAEzD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,CACN,QAAQ,EAAE,cAAc,EACxB,YAAY,EAAE,cAAc,GAAG,IAAI,KAChC,IAAI,EACT,IAAI,GAAE,OAAO,EAAO,GACnB,IAAI,CAkCN;AA+CD,aAAK,8BAA8B,GAAG;IACpC,yCAAyC,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC;CACtE,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,IAAI,8BAA8B,CAwCzE"}
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React, { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
8
+ import { useDynamicCallback } from './reactUtils';
9
+ import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
10
+ function useScrollControllerContextValue() {
11
+ const scrollEventsEnabledRef = useRef(true);
12
+ return useMemo(() => ({
13
+ scrollEventsEnabledRef,
14
+ enableScrollEvents: () => {
15
+ scrollEventsEnabledRef.current = true;
16
+ },
17
+ disableScrollEvents: () => {
18
+ scrollEventsEnabledRef.current = false;
19
+ },
20
+ }), []);
21
+ }
22
+ const ScrollMonitorContext = createContext(undefined);
23
+ export function ScrollControllerProvider({ children, }) {
24
+ return (React.createElement(ScrollMonitorContext.Provider, { value: useScrollControllerContextValue() }, children));
25
+ }
26
+ export function useScrollController() {
27
+ const context = useContext(ScrollMonitorContext);
28
+ if (context == null) {
29
+ throw new Error('"useScrollController" is used but no context provider was found in the React tree.');
30
+ }
31
+ return context;
32
+ }
33
+ const getScrollPosition = () => ExecutionEnvironment.canUseDOM
34
+ ? {
35
+ scrollX: window.pageXOffset,
36
+ scrollY: window.pageYOffset,
37
+ }
38
+ : null;
39
+ export function useScrollPosition(effect, deps = []) {
40
+ const { scrollEventsEnabledRef } = useScrollController();
41
+ const lastPositionRef = useRef(getScrollPosition());
42
+ const dynamicEffect = useDynamicCallback(effect);
43
+ useEffect(() => {
44
+ const handleScroll = () => {
45
+ if (!scrollEventsEnabledRef.current) {
46
+ return;
47
+ }
48
+ const currentPosition = getScrollPosition();
49
+ if (dynamicEffect) {
50
+ dynamicEffect(currentPosition, lastPositionRef.current);
51
+ }
52
+ lastPositionRef.current = currentPosition;
53
+ };
54
+ const opts = {
55
+ passive: true,
56
+ };
57
+ handleScroll();
58
+ window.addEventListener('scroll', handleScroll, opts);
59
+ return () => window.removeEventListener('scroll', handleScroll, opts);
60
+ }, [
61
+ dynamicEffect,
62
+ scrollEventsEnabledRef,
63
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
+ ...deps,
65
+ ]);
66
+ }
67
+ function useScrollPositionSaver() {
68
+ const lastElementRef = useRef({
69
+ elem: null,
70
+ top: 0,
71
+ });
72
+ const save = useCallback((elem) => {
73
+ lastElementRef.current = {
74
+ elem,
75
+ top: elem.getBoundingClientRect().top,
76
+ };
77
+ }, []);
78
+ const restore = useCallback(() => {
79
+ const { current: { elem, top }, } = lastElementRef;
80
+ if (!elem) {
81
+ return { restored: false };
82
+ }
83
+ const newTop = elem.getBoundingClientRect().top;
84
+ const heightDiff = newTop - top;
85
+ if (heightDiff) {
86
+ window.scrollBy({ left: 0, top: heightDiff });
87
+ }
88
+ lastElementRef.current = { elem: null, top: 0 };
89
+ return { restored: heightDiff !== 0 };
90
+ }, []);
91
+ return useMemo(() => ({ save, restore }), [restore, save]);
92
+ }
93
+ /**
94
+ * This hook permits to "block" the scroll position of a dom element
95
+ * The idea is that we should be able to update DOM content above this element
96
+ * but the screen position of this element should not change
97
+ *
98
+ * Feature motivated by the Tabs groups:
99
+ * clicking on a tab may affect tabs of the same group upper in the tree
100
+ * Yet to avoid a bad UX, the clicked tab must remain under the user mouse!
101
+ * See GIF here: https://github.com/facebook/docusaurus/pull/5618
102
+ */
103
+ export function useScrollPositionBlocker() {
104
+ const scrollController = useScrollController();
105
+ const scrollPositionSaver = useScrollPositionSaver();
106
+ const nextLayoutEffectCallbackRef = useRef(undefined);
107
+ const blockElementScrollPositionUntilNextRender = useCallback((el) => {
108
+ scrollPositionSaver.save(el);
109
+ scrollController.disableScrollEvents();
110
+ nextLayoutEffectCallbackRef.current = () => {
111
+ const { restored } = scrollPositionSaver.restore();
112
+ nextLayoutEffectCallbackRef.current = undefined;
113
+ // Restoring the former scroll position will trigger a scroll event
114
+ // We need to wait for next scroll event to happen
115
+ // before enabling again the scrollController events
116
+ if (restored) {
117
+ const handleScrollRestoreEvent = () => {
118
+ scrollController.enableScrollEvents();
119
+ window.removeEventListener('scroll', handleScrollRestoreEvent);
120
+ };
121
+ window.addEventListener('scroll', handleScrollRestoreEvent);
122
+ }
123
+ else {
124
+ scrollController.enableScrollEvents();
125
+ }
126
+ };
127
+ }, [scrollController, scrollPositionSaver]);
128
+ useLayoutEffect(() => {
129
+ var _a;
130
+ (_a = nextLayoutEffectCallbackRef.current) === null || _a === void 0 ? void 0 : _a.call(nextLayoutEffectCallbackRef);
131
+ });
132
+ return {
133
+ blockElementScrollPositionUntilNextRender,
134
+ };
135
+ }
136
+ //# sourceMappingURL=scrollUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollUtils.js","sourceRoot":"","sources":["../../src/utils/scrollUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAwBpE,SAAS,+BAA+B;IACtC,MAAM,sBAAsB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAE5C,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,sBAAsB;QACtB,kBAAkB,EAAE,GAAG,EAAE;YACvB,sBAAsB,CAAC,OAAO,GAAG,IAAI,CAAC;QACxC,CAAC;QACD,mBAAmB,EAAE,GAAG,EAAE;YACxB,sBAAsB,CAAC,OAAO,GAAG,KAAK,CAAC;QACzC,CAAC;KACF,CAAC,EACF,EAAE,CACH,CAAC;A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A2B,CAAC,OAAO,+CAAnC,2BAA2B,CAAY,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,yCAAyC;KAC1C,CAAC;AACJ,CAAC"}
@@ -6,3 +6,4 @@
6
6
  */
7
7
  export declare const DEFAULT_SEARCH_TAG = "default";
8
8
  export declare function docVersionSearchTag(pluginId: string, versionName: string): string;
9
+ //# sourceMappingURL=searchUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchUtils.d.ts","sourceRoot":"","sources":["../../src/utils/searchUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAE5C,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,MAAM,CAER"}
@@ -8,3 +8,4 @@ export const DEFAULT_SEARCH_TAG = 'default';
8
8
  export function docVersionSearchTag(pluginId, versionName) {
9
9
  return `docs-${pluginId}-${versionName}`;
10
10
  }
11
+ //# sourceMappingURL=searchUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchUtils.js","sourceRoot":"","sources":["../../src/utils/searchUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,WAAmB;IAEnB,OAAO,QAAQ,QAAQ,IAAI,WAAW,EAAE,CAAC;AAC3C,CAAC"}
@@ -13,6 +13,10 @@ export interface StorageSlot {
13
13
  }
14
14
  /**
15
15
  * Creates an object for accessing a particular key in localStorage.
16
+ * The API is fail-safe, and usage of browser storage should be considered unreliable
17
+ * Local storage might simply be unavailable (iframe + browser security) or operations might fail individually
18
+ * Please assume that using this API can be a NO-OP
19
+ * See also https://github.com/facebook/docusaurus/issues/6036
16
20
  */
17
21
  export declare const createStorageSlot: (key: string, options?: {
18
22
  persistence?: "localStorage" | "none" | "sessionStorage" | undefined;
@@ -23,3 +27,4 @@ export declare const createStorageSlot: (key: string, options?: {
23
27
  */
24
28
  export declare function listStorageKeys(storageType?: StorageType): string[];
25
29
  export {};
30
+ //# sourceMappingURL=storageUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,QAAA,MAAM,YAAY,qDAAsD,CAAC;AAEzE,oBAAY,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AA2CtD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACzB,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB;AAuBD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,QACvB,MAAM;;kBAEV,WAgCF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,WAAW,GAAE,WAAgC,GAC5C,MAAM,EAAE,CAcV"}
@@ -57,6 +57,10 @@ Please only call storage APIs in effects and event handlers.`);
57
57
  }
58
58
  /**
59
59
  * Creates an object for accessing a particular key in localStorage.
60
+ * The API is fail-safe, and usage of browser storage should be considered unreliable
61
+ * Local storage might simply be unavailable (iframe + browser security) or operations might fail individually
62
+ * Please assume that using this API can be a NO-OP
63
+ * See also https://github.com/facebook/docusaurus/issues/6036
60
64
  */
61
65
  export const createStorageSlot = (key, options) => {
62
66
  if (typeof window === 'undefined') {
@@ -67,9 +71,31 @@ export const createStorageSlot = (key, options) => {
67
71
  return NoopStorageSlot;
68
72
  }
69
73
  return {
70
- get: () => browserStorage.getItem(key),
71
- set: (value) => browserStorage.setItem(key, value),
72
- del: () => browserStorage.removeItem(key),
74
+ get: () => {
75
+ try {
76
+ return browserStorage.getItem(key);
77
+ }
78
+ catch (e) {
79
+ console.error(`Docusaurus storage error, can't get key=${key}`, e);
80
+ return null;
81
+ }
82
+ },
83
+ set: (value) => {
84
+ try {
85
+ browserStorage.setItem(key, value);
86
+ }
87
+ catch (e) {
88
+ console.error(`Docusaurus storage error, can't set ${key}=${value}`, e);
89
+ }
90
+ },
91
+ del: () => {
92
+ try {
93
+ browserStorage.removeItem(key);
94
+ }
95
+ catch (e) {
96
+ console.error(`Docusaurus storage error, can't delete key=${key}`, e);
97
+ }
98
+ },
73
99
  };
74
100
  };
75
101
  /**
@@ -90,3 +116,4 @@ export function listStorageKeys(storageType = DefaultStorageType) {
90
116
  }
91
117
  return keys;
92
118
  }
119
+ //# sourceMappingURL=storageUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storageUtils.js","sourceRoot":"","sources":["../../src/utils/storageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,YAAY,GAAG,CAAC,cAAc,EAAE,gBAAgB,EAAE,MAAM,CAAU,CAAC;AAIzE,MAAM,kBAAkB,GAAgB,cAAc,CAAC;AAEvD,sFAAsF;AACtF,uDAAuD;AACvD,SAAS,iBAAiB,CACxB,cAA2B,kBAAkB;IAE7C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;KACH;IACD,IAAI,WAAW,KAAK,MAAM,EAAE;QAC1B,OAAO,IAAI,CAAC;KACb;SAAM;QACL,IAAI;YACF,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;SAC5B;QAAC,OAAO,CAAC,EAAE;YACV,wCAAwC,CAAC,CAAU,CAAC,CAAC;YACrD,OAAO,IAAI,CAAC;SACb;KACF;AACH,CAAC;AAED;;;GAGG;AACH,IAAI,0CAA0C,GAAG,KAAK,CAAC;AACvD,SAAS,wCAAwC,CAAC,KAAY;IAC5D,IAAI,CAAC,0CAA0C,EAAE;QAC/C,OAAO,CAAC,IAAI,CACV;kIAC4H,EAC5H,KAAK,CACN,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C,GAAG,IAAI,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;aACzE;QACH,CAAC;QACD,GAAG,EAAE,GAAG,EAAE;YACR,IAAI;gBACF,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aAChC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,8CAA8C,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;aACvE;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,eAAe,CAC7B,cAA2B,kBAAkB;IAE7C,MAAM,cAAc,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACtD,IAAI,CAAC,cAAc,EAAE;QACnB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACjD,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,GAAG,KAAK,IAAI,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAChB;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export declare const translateTagsPageTitle: () => string;
8
+ declare type TagsListItem = Readonly<{
9
+ name: string;
10
+ permalink: string;
11
+ count: number;
12
+ }>;
13
+ export declare type TagLetterEntry = Readonly<{
14
+ letter: string;
15
+ tags: TagsListItem[];
16
+ }>;
17
+ export declare function listTagsByLetters(tags: readonly TagsListItem[]): TagLetterEntry[];
18
+ export {};
19
+ //# sourceMappingURL=tagsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/tagsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,eAAO,MAAM,sBAAsB,QAAO,MAKtC,CAAC;AAEL,aAAK,YAAY,GAAG,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC;AAE/E,oBAAY,cAAc,GAAG,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,YAAY,EAAE,CAAA;CAAC,CAAC,CAAC;AAM9E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,YAAY,EAAE,GAC5B,cAAc,EAAE,CAqBlB"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { translate } from '@docusaurus/Translate';
8
+ export const translateTagsPageTitle = () => translate({
9
+ id: 'theme.tags.tagsPageTitle',
10
+ message: 'Tags',
11
+ description: 'The title of the tag list page',
12
+ });
13
+ function getTagLetter(tag) {
14
+ return tag[0].toUpperCase();
15
+ }
16
+ export function listTagsByLetters(tags) {
17
+ // Group by letters
18
+ const groups = {};
19
+ Object.values(tags).forEach((tag) => {
20
+ var _a;
21
+ const letter = getTagLetter(tag.name);
22
+ groups[letter] = (_a = groups[letter]) !== null && _a !== void 0 ? _a : [];
23
+ groups[letter].push(tag);
24
+ });
25
+ return (Object.entries(groups)
26
+ // Sort letters
27
+ .sort(([letter1], [letter2]) => letter1.localeCompare(letter2))
28
+ .map(([letter, letterTags]) => {
29
+ // Sort tags inside a letter
30
+ const sortedTags = letterTags.sort((tag1, tag2) => tag1.name.localeCompare(tag2.name));
31
+ return { letter, tags: sortedTags };
32
+ }));
33
+ }
34
+ //# sourceMappingUR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IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CACnC,CAAC;QACF,OAAO,EAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAC,CAAC;IACpC,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { TOCItem } from '@docusaurus/types';
8
+ declare type FilterTOCParam = {
9
+ toc: readonly TOCItem[];
10
+ minHeadingLevel: number;
11
+ maxHeadingLevel: number;
12
+ };
13
+ export declare function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }: FilterTOCParam): TOCItem[];
14
+ export declare function useTOCFilter({ toc, minHeadingLevel, maxHeadingLevel, }: FilterTOCParam): readonly TOCItem[];
15
+ export {};
16
+ //# sourceMappingURL=tocUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tocUtils.d.ts","sourceRoot":"","sources":["../../src/utils/tocUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE1C,aAAK,cAAc,GAAG;IACpB,GAAG,EAAE,SAAS,OAAO,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,GAAG,EACH,eAAe,EACf,eAAe,GAChB,EAAE,cAAc,GAAG,OAAO,EAAE,CAsB5B;AAGD,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,eAAe,EACf,eAAe,GAChB,EAAE,cAAc,GAAG,SAAS,OAAO,EAAE,CAKrC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useMemo } from 'react';
8
+ export function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
9
+ function isValid(item) {
10
+ return item.level >= minHeadingLevel && item.level <= maxHeadingLevel;
11
+ }
12
+ return toc.flatMap((item) => {
13
+ const filteredChildren = filterTOC({
14
+ toc: item.children,
15
+ minHeadingLevel,
16
+ maxHeadingLevel,
17
+ });
18
+ if (isValid(item)) {
19
+ return [
20
+ {
21
+ ...item,
22
+ children: filteredChildren,
23
+ },
24
+ ];
25
+ }
26
+ else {
27
+ return filteredChildren;
28
+ }
29
+ });
30
+ }
31
+ // Memoize potentially expensive filtering logic
32
+ export function useTOCFilter({ toc, minHeadingLevel, maxHeadingLevel, }) {
33
+ return useMemo(() => filterTOC({ toc, minHeadingLevel, maxHeadingLevel }), [toc, minHeadingLevel, maxHeadingLevel]);
34
+ }
35
+ //# sourceMappingURL=tocUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tocUtils.js","sourceRoot":"","sources":["../../src/utils/tocUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAS9B,MAAM,UAAU,SAAS,CAAC,EACxB,GAAG,EACH,eAAe,EACf,eAAe,GACA;IACf,SAAS,OAAO,CAAC,IAAa;QAC5B,OAAO,IAAI,CAAC,KAAK,IAAI,eAAe,IAAI,IAAI,CAAC,KAAK,IAAI,eAAe,CAAC;IACxE,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC1B,MAAM,gBAAgB,GAAG,SAAS,CAAC;YACjC,GAAG,EAAE,IAAI,CAAC,QAAQ;YAClB,eAAe;YACf,eAAe;SAChB,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,OAAO;gBACL;oBACE,GAAG,IAAI;oBACP,QAAQ,EAAE,gBAAgB;iBAC3B;aACF,CAAC;SACH;aAAM;YACL,OAAO,gBAAgB,CAAC;SACzB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,YAAY,CAAC,EAC3B,GAAG,EACH,eAAe,EACf,eAAe,GACA;IACf,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,SAAS,CAAC,EAAC,GAAG,EAAE,eAAe,EAAE,eAAe,EAAC,CAAC,EACxD,CAAC,GAAG,EAAE,eAAe,EAAE,eAAe,CAAC,CACxC,CAAC;AACJ,CAAC"}
@@ -10,3 +10,4 @@ export declare function useAlternatePageUtils(): {
10
10
  fullyQualified: boolean;
11
11
  }) => string;
12
12
  };
13
+ //# sourceMappingURL=useAlternatePageUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlternatePageUtils.d.ts","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,qBAAqB,IAAI;IACvC,SAAS,EAAE,CAAC,EACV,MAAM,EACN,cAAc,GACf,EAAE;QACD,MAAM,EAAE,MAAM,CAAC;QACf,cAAc,EAAE,OAAO,CAAC;KACzB,KAAK,MAAM,CAAC;CACd,CAoCA"}
@@ -27,3 +27,4 @@ export function useAlternatePageUtils() {
27
27
  }
28
28
  return { createUrl };
29
29
  }
30
+ //# sourceMappingURL=useAlternatePageUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAlternatePageUtils.js","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,kEAAkE;AAClE,kDAAkD;AAClD,qFAAqF;AACrF,MAAM,UAAU,qBAAqB;IASnC,MAAM,EACJ,UAAU,EAAE,EAAC,OAAO,EAAE,GAAG,EAAC,EAC1B,IAAI,EAAE,EAAC,aAAa,EAAE,aAAa,EAAC,GACrC,GAAG,oBAAoB,EAAE,CAAC;IAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,WAAW,EAAE,CAAC;IAEjC,MAAM,kBAAkB,GACtB,aAAa,KAAK,aAAa;QAC7B,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,aAAa,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjD,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAErD,SAAS,mBAAmB,CAAC,MAAc;QACzC,OAAO,MAAM,KAAK,aAAa;YAC7B,CAAC,CAAC,GAAG,kBAAkB,EAAE;YACzB,CAAC,CAAC,GAAG,kBAAkB,GAAG,MAAM,GAAG,CAAC;IACxC,CAAC;IAED,uFAAuF;IACvF,SAAS,SAAS,CAAC,EACjB,MAAM,EACN,cAAc,GAMf;QACC,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,mBAAmB,CACvD,MAAM,CACP,GAAG,cAAc,EAAE,CAAC;IACvB,CAAC;IAED,OAAO,EAAC,SAAS,EAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export declare type useContextualSearchFiltersReturns = {
8
+ locale: string;
9
+ tags: string[];
10
+ };
11
+ export declare function useContextualSearchFilters(): useContextualSearchFiltersReturns;
12
+ //# sourceMappingURL=useContextualSearchFilters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextualSearchFilters.d.ts","sourceRoot":"","sources":["../../src/utils/useContextualSearchFilters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,oBAAY,iCAAiC,GAAG;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAIF,wBAAgB,0BAA0B,IAAI,iCAAiC,CA8B9E"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { useAllDocsData, useActivePluginAndVersion } from '@theme/hooks/useDocs';
8
+ import { useDocsPreferredVersionByPluginId } from './docsPreferredVersion/useDocsPreferredVersion';
9
+ import { docVersionSearchTag, DEFAULT_SEARCH_TAG } from './searchUtils';
10
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
11
+ // We may want to support multiple search engines, don't couple that to Algolia/DocSearch
12
+ // Maybe users will want to use its own search engine solution
13
+ export function useContextualSearchFilters() {
14
+ const { i18n } = useDocusaurusContext();
15
+ const allDocsData = useAllDocsData();
16
+ const activePluginAndVersion = useActivePluginAndVersion();
17
+ const docsPreferredVersionByPluginId = useDocsPreferredVersionByPluginId();
18
+ function getDocPluginTags(pluginId) {
19
+ var _a, _b;
20
+ const activeVersion = ((_a = activePluginAndVersion === null || activePluginAndVersion === void 0 ? void 0 : activePluginAndVersion.activePlugin) === null || _a === void 0 ? void 0 : _a.pluginId) === pluginId
21
+ ? activePluginAndVersion.activeVersion
22
+ : undefined;
23
+ const preferredVersion = docsPreferredVersionByPluginId[pluginId];
24
+ const latestVersion = allDocsData[pluginId].versions.find((v) => v.isLast);
25
+ const version = (_b = activeVersion !== null && activeVersion !== void 0 ? activeVersion : preferredVersion) !== null && _b !== void 0 ? _b : latestVersion;
26
+ return docVersionSearchTag(pluginId, version.name);
27
+ }
28
+ const tags = [
29
+ DEFAULT_SEARCH_TAG,
30
+ ...Object.keys(allDocsData).map(getDocPluginTags),
31
+ ];
32
+ return {
33
+ locale: i18n.currentLocale,
34
+ tags,
35
+ };
36
+ }
37
+ //# sourceMappingURL=useContextualSearchFilters.js.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