@docusaurus/theme-common 2.0.0-beta.15d451942 → 2.0.0-beta.16

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 (211) hide show
  1. package/lib/components/Collapsible/index.d.ts +36 -0
  2. package/lib/components/Collapsible/index.d.ts.map +1 -0
  3. package/lib/components/Collapsible/index.js +144 -0
  4. package/lib/components/Collapsible/index.js.map +1 -0
  5. package/lib/components/Details/index.d.ts +12 -0
  6. package/lib/components/Details/index.d.ts.map +1 -0
  7. package/lib/components/Details/index.js +66 -0
  8. package/lib/components/Details/index.js.map +1 -0
  9. package/lib/components/Details/styles.module.css +58 -0
  10. package/lib/{utils/useChangeRoute.d.ts → hooks/styles.css} +4 -1
  11. package/lib/hooks/useHideableNavbar.d.ts +13 -0
  12. package/lib/hooks/useHideableNavbar.d.ts.map +1 -0
  13. package/lib/hooks/useHideableNavbar.js +59 -0
  14. package/lib/hooks/useHideableNavbar.js.map +1 -0
  15. package/lib/hooks/useKeyboardNavigation.d.ts +10 -0
  16. package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -0
  17. package/lib/hooks/useKeyboardNavigation.js +31 -0
  18. package/lib/hooks/useKeyboardNavigation.js.map +1 -0
  19. package/{src/utils/docsUtils.ts → lib/hooks/useLockBodyScroll.d.ts} +2 -5
  20. package/lib/hooks/useLockBodyScroll.d.ts.map +1 -0
  21. package/lib/hooks/useLockBodyScroll.js +16 -0
  22. package/lib/hooks/useLockBodyScroll.js.map +1 -0
  23. package/lib/hooks/usePrismTheme.d.ts +9 -0
  24. package/lib/hooks/usePrismTheme.d.ts.map +1 -0
  25. package/lib/hooks/usePrismTheme.js +18 -0
  26. package/lib/hooks/usePrismTheme.js.map +1 -0
  27. package/lib/hooks/useSearchPage.d.ts +14 -0
  28. package/lib/hooks/useSearchPage.d.ts.map +1 -0
  29. package/lib/hooks/useSearchPage.js +43 -0
  30. package/lib/hooks/useSearchPage.js.map +1 -0
  31. package/lib/hooks/useWindowSize.d.ts +15 -0
  32. package/lib/hooks/useWindowSize.d.ts.map +1 -0
  33. package/lib/hooks/useWindowSize.js +56 -0
  34. package/lib/hooks/useWindowSize.js.map +1 -0
  35. package/lib/index.d.ts +35 -4
  36. package/lib/index.d.ts.map +1 -0
  37. package/lib/index.js +29 -3
  38. package/lib/index.js.map +1 -0
  39. package/lib/utils/ThemeClassNames.d.ts +40 -12
  40. package/lib/utils/ThemeClassNames.d.ts.map +1 -0
  41. package/lib/utils/ThemeClassNames.js +41 -3
  42. package/lib/utils/ThemeClassNames.js.map +1 -0
  43. package/lib/utils/announcementBarUtils.d.ts +18 -0
  44. package/lib/utils/announcementBarUtils.d.ts.map +1 -0
  45. package/lib/utils/announcementBarUtils.js +71 -0
  46. package/lib/utils/announcementBarUtils.js.map +1 -0
  47. package/lib/utils/codeBlockUtils.d.ts +10 -0
  48. package/lib/utils/codeBlockUtils.d.ts.map +1 -0
  49. package/lib/utils/codeBlockUtils.js +125 -2
  50. package/lib/utils/codeBlockUtils.js.map +1 -0
  51. package/lib/utils/colorModeUtils.d.ts +18 -0
  52. package/lib/utils/colorModeUtils.d.ts.map +1 -0
  53. package/lib/utils/colorModeUtils.js +106 -0
  54. package/lib/utils/colorModeUtils.js.map +1 -0
  55. package/lib/utils/docSidebarItemsExpandedState.d.ts +17 -0
  56. package/lib/utils/docSidebarItemsExpandedState.d.ts.map +1 -0
  57. package/lib/utils/docSidebarItemsExpandedState.js +22 -0
  58. package/lib/utils/docSidebarItemsExpandedState.js.map +1 -0
  59. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts +3 -2
  60. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -0
  61. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +8 -11
  62. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -0
  63. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts +2 -1
  64. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.d.ts.map +1 -0
  65. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js +2 -3
  66. package/lib/utils/docsPreferredVersion/DocsPreferredVersionStorage.js.map +1 -0
  67. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts +12 -3
  68. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.d.ts.map +1 -0
  69. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js +3 -3
  70. package/lib/utils/docsPreferredVersion/useDocsPreferredVersion.js.map +1 -0
  71. package/lib/utils/docsUtils.d.ts +26 -0
  72. package/lib/utils/docsUtils.d.ts.map +1 -0
  73. package/lib/utils/docsUtils.js +136 -1
  74. package/lib/utils/docsUtils.js.map +1 -0
  75. package/lib/utils/generalUtils.d.ts +7 -0
  76. package/lib/utils/generalUtils.d.ts.map +1 -0
  77. package/lib/utils/generalUtils.js +3 -2
  78. package/lib/utils/generalUtils.js.map +1 -0
  79. package/lib/utils/historyUtils.d.ts +23 -0
  80. package/lib/utils/historyUtils.d.ts.map +1 -0
  81. package/lib/utils/historyUtils.js +41 -0
  82. package/lib/utils/historyUtils.js.map +1 -0
  83. package/lib/utils/jsUtils.d.ts +23 -0
  84. package/lib/utils/jsUtils.d.ts.map +1 -0
  85. package/lib/utils/jsUtils.js +29 -0
  86. package/lib/utils/jsUtils.js.map +1 -0
  87. package/lib/utils/mobileSecondaryMenu.d.ts +21 -0
  88. package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -0
  89. package/lib/utils/mobileSecondaryMenu.js +50 -0
  90. package/lib/utils/mobileSecondaryMenu.js.map +1 -0
  91. package/lib/utils/pathUtils.d.ts +1 -0
  92. package/lib/utils/pathUtils.d.ts.map +1 -0
  93. package/lib/utils/pathUtils.js +6 -2
  94. package/lib/utils/pathUtils.js.map +1 -0
  95. package/lib/utils/reactUtils.d.ts +28 -0
  96. package/lib/utils/reactUtils.d.ts.map +1 -0
  97. package/lib/utils/reactUtils.js +36 -0
  98. package/lib/utils/reactUtils.js.map +1 -0
  99. package/lib/utils/regexpUtils.d.ts +11 -0
  100. package/lib/utils/regexpUtils.d.ts.map +1 -0
  101. package/lib/utils/regexpUtils.js +17 -0
  102. package/lib/utils/regexpUtils.js.map +1 -0
  103. package/lib/utils/routesUtils.d.ts +11 -0
  104. package/lib/utils/routesUtils.d.ts.map +1 -0
  105. package/lib/utils/routesUtils.js +33 -0
  106. package/lib/utils/routesUtils.js.map +1 -0
  107. package/lib/utils/scrollUtils.d.ts +53 -0
  108. package/lib/utils/scrollUtils.d.ts.map +1 -0
  109. package/lib/utils/scrollUtils.js +136 -0
  110. package/lib/utils/scrollUtils.js.map +1 -0
  111. package/lib/utils/searchUtils.d.ts +1 -0
  112. package/lib/utils/searchUtils.d.ts.map +1 -0
  113. package/lib/utils/searchUtils.js +1 -0
  114. package/lib/utils/searchUtils.js.map +1 -0
  115. package/lib/utils/storageUtils.d.ts +5 -0
  116. package/lib/utils/storageUtils.d.ts.map +1 -0
  117. package/lib/utils/storageUtils.js +41 -16
  118. package/lib/utils/storageUtils.js.map +1 -0
  119. package/lib/utils/tabGroupChoiceUtils.d.ts +19 -0
  120. package/lib/utils/tabGroupChoiceUtils.d.ts.map +1 -0
  121. package/lib/utils/tabGroupChoiceUtils.js +54 -0
  122. package/lib/utils/tabGroupChoiceUtils.js.map +1 -0
  123. package/lib/utils/tagsUtils.d.ts +19 -0
  124. package/lib/utils/tagsUtils.d.ts.map +1 -0
  125. package/lib/utils/tagsUtils.js +34 -0
  126. package/lib/utils/tagsUtils.js.map +1 -0
  127. package/lib/utils/tocUtils.d.ts +20 -0
  128. package/lib/utils/tocUtils.d.ts.map +1 -0
  129. package/lib/utils/tocUtils.js +73 -0
  130. package/lib/utils/tocUtils.js.map +1 -0
  131. package/lib/utils/useAlternatePageUtils.d.ts +1 -0
  132. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -0
  133. package/lib/utils/useAlternatePageUtils.js +3 -1
  134. package/lib/utils/useAlternatePageUtils.js.map +1 -0
  135. package/lib/utils/useContextualSearchFilters.d.ts +12 -0
  136. package/lib/utils/useContextualSearchFilters.d.ts.map +1 -0
  137. package/lib/utils/useContextualSearchFilters.js +37 -0
  138. package/lib/utils/useContextualSearchFilters.js.map +1 -0
  139. package/lib/utils/useLocalPathname.d.ts +8 -0
  140. package/lib/utils/useLocalPathname.d.ts.map +1 -0
  141. package/lib/utils/useLocalPathname.js +17 -0
  142. package/lib/utils/useLocalPathname.js.map +1 -0
  143. package/lib/utils/useLocationChange.d.ts +15 -0
  144. package/lib/utils/useLocationChange.d.ts.map +1 -0
  145. package/lib/utils/useLocationChange.js +27 -0
  146. package/lib/utils/useLocationChange.js.map +1 -0
  147. package/lib/utils/usePluralForm.d.ts +1 -0
  148. package/lib/utils/usePluralForm.d.ts.map +1 -0
  149. package/lib/utils/usePluralForm.js +29 -25
  150. package/lib/utils/usePluralForm.js.map +1 -0
  151. package/lib/utils/usePrevious.d.ts +8 -0
  152. package/lib/utils/usePrevious.d.ts.map +1 -0
  153. package/lib/utils/usePrevious.js +16 -0
  154. package/lib/utils/usePrevious.js.map +1 -0
  155. package/lib/utils/useTOCHighlight.d.ts +14 -0
  156. package/lib/utils/useTOCHighlight.d.ts.map +1 -0
  157. package/lib/utils/useTOCHighlight.js +128 -0
  158. package/lib/utils/useTOCHighlight.js.map +1 -0
  159. package/lib/utils/useThemeConfig.d.ts +36 -11
  160. package/lib/utils/useThemeConfig.d.ts.map +1 -0
  161. package/lib/utils/useThemeConfig.js +1 -0
  162. package/lib/utils/useThemeConfig.js.map +1 -0
  163. package/package.json +19 -13
  164. package/src/components/Collapsible/index.tsx +247 -0
  165. package/src/components/Details/index.tsx +102 -0
  166. package/src/components/Details/styles.module.css +58 -0
  167. package/src/hooks/styles.css +10 -0
  168. package/src/hooks/useHideableNavbar.ts +77 -0
  169. package/src/hooks/useKeyboardNavigation.ts +37 -0
  170. package/src/hooks/useLockBodyScroll.ts +18 -0
  171. package/src/hooks/usePrismTheme.ts +20 -0
  172. package/src/hooks/useSearchPage.ts +66 -0
  173. package/src/hooks/useWindowSize.ts +70 -0
  174. package/src/index.ts +102 -4
  175. package/src/types.d.ts +0 -2
  176. package/src/utils/ThemeClassNames.ts +46 -4
  177. package/src/utils/announcementBarUtils.tsx +121 -0
  178. package/src/utils/codeBlockUtils.ts +153 -2
  179. package/src/utils/colorModeUtils.tsx +156 -0
  180. package/src/utils/docSidebarItemsExpandedState.tsx +41 -0
  181. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +16 -14
  182. package/src/utils/docsPreferredVersion/DocsPreferredVersionStorage.ts +3 -4
  183. package/src/utils/docsPreferredVersion/useDocsPreferredVersion.ts +18 -14
  184. package/src/utils/docsUtils.tsx +230 -0
  185. package/src/utils/generalUtils.ts +3 -2
  186. package/src/utils/historyUtils.ts +51 -0
  187. package/src/utils/jsUtils.ts +36 -0
  188. package/src/utils/mobileSecondaryMenu.tsx +115 -0
  189. package/src/utils/pathUtils.ts +6 -4
  190. package/src/utils/reactUtils.tsx +43 -0
  191. package/src/utils/regexpUtils.ts +23 -0
  192. package/src/utils/routesUtils.ts +39 -0
  193. package/src/utils/scrollUtils.tsx +237 -0
  194. package/src/utils/storageUtils.ts +40 -15
  195. package/src/utils/tabGroupChoiceUtils.tsx +90 -0
  196. package/src/utils/tagsUtils.ts +48 -0
  197. package/src/utils/tocUtils.ts +108 -0
  198. package/src/utils/useAlternatePageUtils.ts +13 -4
  199. package/src/utils/useContextualSearchFilters.ts +53 -0
  200. package/src/utils/useLocalPathname.ts +20 -0
  201. package/src/utils/useLocationChange.ts +39 -0
  202. package/src/utils/usePluralForm.ts +35 -28
  203. package/src/utils/usePrevious.ts +19 -0
  204. package/src/utils/useTOCHighlight.ts +183 -0
  205. package/src/utils/useThemeConfig.ts +38 -11
  206. package/lib/.tsbuildinfo +0 -4159
  207. package/lib/utils/useChangeRoute.js +0 -18
  208. package/src/utils/__tests__/codeBlockUtils.test.ts +0 -54
  209. package/src/utils/__tests__/pathUtils.test.ts +0 -32
  210. package/src/utils/useChangeRoute.ts +0 -21
  211. package/tsconfig.json +0 -10
@@ -6,23 +6,21 @@
6
6
  */
7
7
  const StorageTypes = ['localStorage', 'sessionStorage', 'none'];
8
8
  const DefaultStorageType = 'localStorage';
9
- // Will return null browser storage is unavailable (like running Docusaurus in iframe)
10
- // See https://github.com/facebook/docusaurus/pull/4501
9
+ // Will return null browser storage is unavailable (like running Docusaurus in
10
+ // iframe) See https://github.com/facebook/docusaurus/pull/4501
11
11
  function getBrowserStorage(storageType = DefaultStorageType) {
12
12
  if (typeof window === 'undefined') {
13
- throw new Error('Browser storage is not available on NodeJS / Docusaurus SSR process');
13
+ throw new Error('Browser storage is not available on Node.js/Docusaurus SSR process.');
14
14
  }
15
15
  if (storageType === 'none') {
16
16
  return null;
17
17
  }
18
- else {
19
- try {
20
- return window[storageType];
21
- }
22
- catch (e) {
23
- logOnceBrowserStorageNotAvailableWarning(e);
24
- return null;
25
- }
18
+ try {
19
+ return window[storageType];
20
+ }
21
+ catch (err) {
22
+ logOnceBrowserStorageNotAvailableWarning(err);
23
+ return null;
26
24
  }
27
25
  }
28
26
  /**
@@ -33,7 +31,7 @@ let hasLoggedBrowserStorageNotAvailableWarning = false;
33
31
  function logOnceBrowserStorageNotAvailableWarning(error) {
34
32
  if (!hasLoggedBrowserStorageNotAvailableWarning) {
35
33
  console.warn(`Docusaurus browser storage is not available.
36
- Possible reasons: running Docusaurus in an Iframe, in an Incognito browser session, or using too strict browser privacy settings.`, error);
34
+ Possible reasons: running Docusaurus in an iframe, in an incognito browser session, or using too strict browser privacy settings.`, error);
37
35
  hasLoggedBrowserStorageNotAvailableWarning = true;
38
36
  }
39
37
  }
@@ -45,7 +43,7 @@ const NoopStorageSlot = {
45
43
  // Fail-fast, as storage APIs should not be used during the SSR process
46
44
  function createServerStorageSlot(key) {
47
45
  function throwError() {
48
- throw new Error(`Illegal storage API usage for storage key=${key}.
46
+ throw new Error(`Illegal storage API usage for storage key "${key}".
49
47
  Docusaurus storage APIs are not supposed to be called on the server-rendering process.
50
48
  Please only call storage APIs in effects and event handlers.`);
51
49
  }
@@ -57,6 +55,10 @@ Please only call storage APIs in effects and event handlers.`);
57
55
  }
58
56
  /**
59
57
  * Creates an object for accessing a particular key in localStorage.
58
+ * The API is fail-safe, and usage of browser storage should be considered
59
+ * unreliable. Local storage might simply be unavailable (iframe + browser
60
+ * security) or operations might fail individually. Please assume that using
61
+ * this API can be a NO-OP. See also https://github.com/facebook/docusaurus/issues/6036
60
62
  */
61
63
  export const createStorageSlot = (key, options) => {
62
64
  if (typeof window === 'undefined') {
@@ -67,9 +69,31 @@ export const createStorageSlot = (key, options) => {
67
69
  return NoopStorageSlot;
68
70
  }
69
71
  return {
70
- get: () => browserStorage.getItem(key),
71
- set: (value) => browserStorage.setItem(key, value),
72
- del: () => browserStorage.removeItem(key),
72
+ get: () => {
73
+ try {
74
+ return browserStorage.getItem(key);
75
+ }
76
+ catch (err) {
77
+ console.error(`Docusaurus storage error, can't get key=${key}`, err);
78
+ return null;
79
+ }
80
+ },
81
+ set: (value) => {
82
+ try {
83
+ browserStorage.setItem(key, value);
84
+ }
85
+ catch (err) {
86
+ console.error(`Docusaurus storage error, can't set ${key}=${value}`, err);
87
+ }
88
+ },
89
+ del: () => {
90
+ try {
91
+ browserStorage.removeItem(key);
92
+ }
93
+ catch (err) {
94
+ console.error(`Docusaurus storage error, can't delete key=${key}`, err);
95
+ }
96
+ },
73
97
  };
74
98
  };
75
99
  /**
@@ -90,3 +114,4 @@ export function listStorageKeys(storageType = DefaultStorageType) {
90
114
  }
91
115
  return keys;
92
116
  }
117
+ //# 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,MAA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AAI,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
+ import { type ReactNode } from 'react';
8
+ declare type TabGroupChoiceContextValue = {
9
+ readonly tabGroupChoices: {
10
+ readonly [groupId: string]: string;
11
+ };
12
+ readonly setTabGroupChoices: (groupId: string, newChoice: string) => void;
13
+ };
14
+ export declare function TabGroupChoiceProvider({ children, }: {
15
+ children: ReactNode;
16
+ }): JSX.Element;
17
+ export declare function useTabGroupChoice(): TabGroupChoiceContextValue;
18
+ export {};
19
+ //# sourceMappingURL=tabGroupChoiceUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabGroupChoiceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/tabGroupChoiceUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAOZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,aAAK,0BAA0B,GAAG;IAChC,QAAQ,CAAC,eAAe,EAAE;QAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAC;IAC/D,QAAQ,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3E,CAAC;AAsCF,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAcd;AAED,wBAAgB,iBAAiB,IAAI,0BAA0B,CAQ9D"}
@@ -0,0 +1,54 @@
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, { useState, useCallback, useEffect, createContext, useMemo, useContext, } from 'react';
8
+ import { createStorageSlot, listStorageKeys } from './storageUtils';
9
+ const TAB_CHOICE_PREFIX = 'docusaurus.tab.';
10
+ const TabGroupChoiceContext = createContext(undefined);
11
+ function useTabGroupChoiceContextValue() {
12
+ const [tabGroupChoices, setChoices] = useState({});
13
+ const setChoiceSyncWithLocalStorage = useCallback((groupId, newChoice) => {
14
+ createStorageSlot(`${TAB_CHOICE_PREFIX}${groupId}`).set(newChoice);
15
+ }, []);
16
+ useEffect(() => {
17
+ try {
18
+ const localStorageChoices = {};
19
+ listStorageKeys().forEach((storageKey) => {
20
+ if (storageKey.startsWith(TAB_CHOICE_PREFIX)) {
21
+ const groupId = storageKey.substring(TAB_CHOICE_PREFIX.length);
22
+ localStorageChoices[groupId] = createStorageSlot(storageKey).get();
23
+ }
24
+ });
25
+ setChoices(localStorageChoices);
26
+ }
27
+ catch (err) {
28
+ console.error(err);
29
+ }
30
+ }, []);
31
+ return {
32
+ tabGroupChoices,
33
+ setTabGroupChoices: (groupId, newChoice) => {
34
+ setChoices((oldChoices) => ({ ...oldChoices, [groupId]: newChoice }));
35
+ setChoiceSyncWithLocalStorage(groupId, newChoice);
36
+ },
37
+ };
38
+ }
39
+ export function TabGroupChoiceProvider({ children, }) {
40
+ const { tabGroupChoices, setTabGroupChoices } = useTabGroupChoiceContextValue();
41
+ const contextValue = useMemo(() => ({
42
+ tabGroupChoices,
43
+ setTabGroupChoices,
44
+ }), [tabGroupChoices, setTabGroupChoices]);
45
+ return (React.createElement(TabGroupChoiceContext.Provider, { value: contextValue }, children));
46
+ }
47
+ export function useTabGroupChoice() {
48
+ const context = useContext(TabGroupChoiceContext);
49
+ if (context == null) {
50
+ throw new Error('"useUserPreferencesContext" is used outside of "Layout" component.');
51
+ }
52
+ return context;
53
+ }
54
+ //# sourceMappingURL=tabGroupChoiceUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabGroupChoiceUtils.js","sourceRoot":"","sources":["../../src/utils/tabGroupChoiceUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EACR,WAAW,EACX,SAAS,EACT,aAAa,EACb,OAAO,EACP,UAAU,GAEX,MAAM,OAAO,CAAC;AACf,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAElE,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAO5C,MAAM,qBAAqB,GAAG,aAAa,CAEzC,SAAS,CAAC,CAAC;AAEb,SAAS,6BAA6B;IACpC,MAAM,CAAC,eAAe,EAAE,UAAU,CAAC,GAAG,QAAQ,CAE3C,EAAE,CAAC,CAAC;IACP,MAAM,6BAA6B,GAAG,WAAW,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE;QACvE,iBAAiB,CAAC,GAAG,iBAAiB,GAAG,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACrE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI;YACF,MAAM,mBAAmB,GAA2B,EAAE,CAAC;YACvD,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;gBACvC,IAAI,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;oBAC5C,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC/D,mBAAmB,CAAC,OAAO,CAAC,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC,GAAG,EAAG,CAAC;iBACrE;YACH,CAAC,CAAC,CAAC;YACH,UAAU,CAAC,mBAAmB,CAAC,CAAC;SACjC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;SACpB;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,eAAe;QACf,kBAAkB,EAAE,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE;YACzD,UAAU,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,UAAU,EAAE,CAAC,OAAO,CAAC,EAAE,SAAS,EAAC,CAAC,CAAC,CAAC;YACpE,6BAA6B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,EACrC,QAAQ,GAGT;IACC,MAAM,EAAC,eAAe,EAAE,kBAAkB,EAAC,GAAG,6BAA6B,EAAE,CAAC;IAC9E,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,CAAC;QACL,eAAe;QACf,kBAAkB;KACnB,CAAC,EACF,CAAC,eAAe,EAAE,kBAAkB,CAAC,CACtC,CAAC;IACF,OAAO,CACL,oBAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,IAChD,QAAQ,CACsB,CAClC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,qBAAqB,CAAC,CAAC;IAClD,IAAI,OAAO,IAAI,IAAI,EAAE;QACnB,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,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
+ //# sourceMappingURL=tagsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tagsUtils.js","sourceRoot":"","sources":["../../src/utils/tagsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAC;AAEhD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAW,EAAE,CACjD,SAAS,CAAC;IACR,EAAE,EAAE,0BAA0B;IAC9B,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,gCAAgC;CAC9C,CAAC,CAAC;AAML,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAA6B;IAE7B,mBAAmB;IACnB,MAAM,MAAM,GAAmC,EAAE,CAAC;IAClD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;;QAClC,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAA,MAAM,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QACpB,eAAe;SACd,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SAC9D,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE;QAC5B,4BAA4B;QAC5B,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAChD,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,20 @@
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 type { TOCItem } from '@docusaurus/types';
8
+ export declare type TOCTreeNode = {
9
+ readonly value: string;
10
+ readonly id: string;
11
+ readonly level: number;
12
+ readonly children: readonly TOCTreeNode[];
13
+ };
14
+ export declare function useTreeifiedTOC(toc: TOCItem[]): readonly TOCTreeNode[];
15
+ export declare function useFilteredAndTreeifiedTOC({ toc, minHeadingLevel, maxHeadingLevel, }: {
16
+ toc: readonly TOCItem[];
17
+ minHeadingLevel: number;
18
+ maxHeadingLevel: number;
19
+ }): readonly TOCTreeNode[];
20
+ //# 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,KAAK,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAE/C,oBAAY,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C,CAAC;AAuCF,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,SAAS,WAAW,EAAE,CAEtE;AAiCD,wBAAgB,0BAA0B,CAAC,EACzC,GAAG,EACH,eAAe,EACf,eAAe,GAChB,EAAE;IACD,GAAG,EAAE,SAAS,OAAO,EAAE,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,SAAS,WAAW,EAAE,CAUzB"}
@@ -0,0 +1,73 @@
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
+ function treeifyTOC(flatTOC) {
9
+ const headings = flatTOC.map((heading) => ({
10
+ ...heading,
11
+ parentIndex: -1,
12
+ children: [],
13
+ }));
14
+ // Keep track of which previous index would be the current heading's direct
15
+ // parent. Each entry <i> is the last index of the `headings` array at heading
16
+ // level <i>. We will modify these indices as we iterate through all headings.
17
+ // e.g. if an ### H3 was last seen at index 2, then prevIndexForLevel[3] === 2
18
+ // indices 0 and 1 will remain unused.
19
+ const prevIndexForLevel = Array(7).fill(-1);
20
+ headings.forEach((curr, currIndex) => {
21
+ // take the last seen index for each ancestor level. the highest
22
+ // index will be the direct ancestor of the current heading.
23
+ const ancestorLevelIndexes = prevIndexForLevel.slice(2, curr.level);
24
+ curr.parentIndex = Math.max(...ancestorLevelIndexes);
25
+ // mark that curr.level was last seen at the current index
26
+ prevIndexForLevel[curr.level] = currIndex;
27
+ });
28
+ const rootNodes = [];
29
+ // For a given parentIndex, add each Node into that parent's `children` array
30
+ headings.forEach((heading) => {
31
+ const { parentIndex, ...rest } = heading;
32
+ if (parentIndex >= 0) {
33
+ headings[parentIndex].children.push(rest);
34
+ }
35
+ else {
36
+ rootNodes.push(rest);
37
+ }
38
+ });
39
+ return rootNodes;
40
+ }
41
+ export function useTreeifiedTOC(toc) {
42
+ return useMemo(() => treeifyTOC(toc), [toc]);
43
+ }
44
+ function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
45
+ function isValid(item) {
46
+ return item.level >= minHeadingLevel && item.level <= maxHeadingLevel;
47
+ }
48
+ return toc.flatMap((item) => {
49
+ const filteredChildren = filterTOC({
50
+ toc: item.children,
51
+ minHeadingLevel,
52
+ maxHeadingLevel,
53
+ });
54
+ if (isValid(item)) {
55
+ return [
56
+ {
57
+ ...item,
58
+ children: filteredChildren,
59
+ },
60
+ ];
61
+ }
62
+ return filteredChildren;
63
+ });
64
+ }
65
+ export function useFilteredAndTreeifiedTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
66
+ return useMemo(() =>
67
+ // Note: we have to filter the TOC after it has been treeified. This is
68
+ // mostly to ensure that weird TOC structures preserve their semantics.
69
+ // For example, an h3-h2-h4 sequence should not be treeified as an h3 > h4
70
+ // hierarchy with min=3, max=4, but should rather be [h3, h4]
71
+ filterTOC({ toc: treeifyTOC(toc), minHeadingLevel, maxHeadingLevel }), [toc, minHeadingLevel, maxHeadingLevel]);
72
+ }
73
+ //# 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;AAU9B,SAAS,UAAU,CAAC,OAA2B;IAC7C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACzC,GAAG,OAAO;QACV,WAAW,EAAE,CAAC,CAAC;QACf,QAAQ,EAAE,EAAmB;KAC9B,CAAC,CAAC,CAAC;IAEJ,2EAA2E;IAC3E,8EAA8E;IAC9E,8EAA8E;IAC9E,8EAA8E;IAC9E,sCAAsC;IACtC,MAAM,iBAAiB,GAAG,KA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AC,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;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,EACzC,GAAG,EACH,eAAe,EACf,eAAe,GAKhB;IACC,OAAO,OAAO,CACZ,GAAG,EAAE;IACH,uEAAuE;IACvE,uEAAuE;IACvE,0EAA0E;IAC1E,6DAA6D;IAC7D,SAAS,CAAC,EAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,eAAe,EAAE,eAAe,EAAC,CAAC,EACrE,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,CAqCA"}
@@ -21,9 +21,11 @@ export function useAlternatePageUtils() {
21
21
  ? `${baseUrlUnlocalized}`
22
22
  : `${baseUrlUnlocalized}${locale}/`;
23
23
  }
24
- // TODO support correct alternate url when localized site is deployed on another domain
24
+ // TODO support correct alternate url when localized site is deployed on
25
+ // another domain
25
26
  function createUrl({ locale, fullyQualified, }) {
26
27
  return `${fullyQualified ? url : ''}${getLocalizedBaseUrl(locale)}${pathnameSuffix}`;
27
28
  }
28
29
  return { createUrl };
29
30
  }
31
+ //# 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,wEAAwE;IACxE,iBAAiB;IACjB,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;AAUH,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 '@docusaurus/plugin-content-docs/client';
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
12
+ // Algolia/DocSearch. Maybe users want to use their 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.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContextualSearchFilters.js","sourceRoot":"","sources":["../../src/utils/useContextualSearchFilters.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,yBAAyB,GAC1B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAC,iCAAiC,EAAC,MAAM,gDAAgD,CAAC;AACjG,OAAO,EAAC,mBAAmB,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACtE,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAOpE,uEAAuE;AACvE,8EAA8E;AAC9E,MAAM,UAAU,0BAA0B;IACxC,MAAM,EAAC,IAAI,EAAC,GAAG,oBAAoB,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,sBAAsB,GAAG,yBAAyB,EAAE,CAAC;IAC3D,MAAM,8BAA8B,GAAG,iCAAiC,EAAE,CAAC;IAE3E,SAAS,gBAAgB,CAAC,QAAgB;;QACxC,MAAM,aAAa,GACjB,CAAA,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,YAAY,0CAAE,QAAQ,MAAK,QAAQ;YACzD,CAAC,CAAC,sBAAsB,CAAC,aAAa;YACtC,CAAC,CAAC,SAAS,CAAC;QAEhB,MAAM,gBAAgB,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;QAElE,MAAM,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAE,CAAC;QAE5E,MAAM,OAAO,GAAG,MAAA,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,gBAAgB,mCAAI,aAAa,CAAC;QAEnE,OAAO,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,IAAI,GAAG;QACX,kBAAkB;QAClB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;KAClD,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,aAAa;QAC1B,IAAI;KACL,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
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 function useLocalPathname(): string;
8
+ //# sourceMappingURL=useLocalPathname.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalPathname.d.ts","sourceRoot":"","sources":["../../src/utils/useLocalPathname.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,wBAAgB,gBAAgB,IAAI,MAAM,CAMzC"}
@@ -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
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
8
+ import { useLocation } from '@docusaurus/router';
9
+ // Get the pathname of current route, without the optional site baseUrl
10
+ // - /docs/myDoc => /docs/myDoc
11
+ // - /baseUrl/docs/myDoc => /docs/myDoc
12
+ export function useLocalPathname() {
13
+ const { siteConfig: { baseUrl }, } = useDocusaurusContext();
14
+ const { pathname } = useLocation();
15
+ return pathname.replace(baseUrl, '/');
16
+ }
17
+ //# sourceMappingURL=useLocalPathname.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalPathname.js","sourceRoot":"","sources":["../../src/utils/useLocalPathname.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,uEAAuE;AACvE,+BAA+B;AAC/B,uCAAuC;AACvC,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EACJ,UAAU,EAAE,EAAC,OAAO,EAAC,GACtB,GAAG,oBAAoB,EAAE,CAAC;IAC3B,MAAM,EAAC,QAAQ,EAAC,GAAG,WAAW,EAAE,CAAC;IACjC,OAAO,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC"}
@@ -0,0 +1,15 @@
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 type { Location } from 'history';
8
+ declare type LocationChangeEvent = {
9
+ location: Location;
10
+ previousLocation: Location | undefined;
11
+ };
12
+ declare type OnLocationChange = (locationChangeEvent: LocationChangeEvent) => void;
13
+ export declare function useLocationChange(onLocationChange: OnLocationChange): void;
14
+ export {};
15
+ //# sourceMappingURL=useLocationChange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocationChange.d.ts","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAItC,aAAK,mBAAmB,GAAG;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,gBAAgB,EAAE,QAAQ,GAAG,SAAS,CAAC;CACxC,CAAC;AAEF,aAAK,gBAAgB,GAAG,CAAC,mBAAmB,EAAE,mBAAmB,KAAK,IAAI,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAkB1E"}
@@ -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 { useEffect } from 'react';
8
+ import { useLocation } from '@docusaurus/router';
9
+ import { usePrevious } from './usePrevious';
10
+ import { useDynamicCallback } from './reactUtils';
11
+ export function useLocationChange(onLocationChange) {
12
+ const location = useLocation();
13
+ const previousLocation = usePrevious(location);
14
+ const onLocationChangeDynamic = useDynamicCallback(onLocationChange);
15
+ useEffect(() => {
16
+ if (!previousLocation) {
17
+ return;
18
+ }
19
+ if (location !== previousLocation) {
20
+ onLocationChangeDynamic({
21
+ location,
22
+ previousLocation,
23
+ });
24
+ }
25
+ }, [onLocationChangeDynamic, location, previousLocation]);
26
+ }
27
+ //# sourceMappingURL=useLocationChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocationChange.js","sourceRoot":"","sources":["../../src/utils/useLocationChange.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAShD,MAAM,UAAU,iBAAiB,CAAC,gBAAkC;IAClE,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,gBAAgB,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE/C,MAAM,uBAAuB,GAAG,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAErE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,gBAAgB,EAAE;YACrB,OAAO;SACR;QAED,IAAI,QAAQ,KAAK,gBAAgB,EAAE;YACjC,uBAAuB,CAAC;gBACtB,QAAQ;gBACR,gBAAgB;aACjB,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,uBAAuB,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -7,3 +7,4 @@
7
7
  export declare function usePluralForm(): {
8
8
  selectMessage: (count: number, pluralMessages: string) => string;
9
9
  };
10
+ //# sourceMappingURL=usePluralForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePluralForm.d.ts","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA8GH,wBAAgB,aAAa,IAAI;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE,CAMA"}
@@ -34,27 +34,33 @@ function createLocalePluralForms(locale) {
34
34
  select: (count) => pluralRules.select(count),
35
35
  };
36
36
  }
37
- // Poor man's PluralSelector implementation, using an english fallback.
38
- // We want a lightweight, future-proof and good-enough solution.
39
- // We don't want a perfect and heavy solution.
40
- //
41
- // Docusaurus classic theme has only 2 deeply nested labels requiring complex plural rules
42
- // We don't want to use Intl + PluralRules polyfills + full ICU syntax (react-intl) just for that.
43
- //
44
- // Notes:
45
- // - 2021: 92+% Browsers support Intl.PluralRules, and support will increase in the future
46
- // - NodeJS >= 13 has full ICU support by default
47
- // - In case of "mismatch" between SSR and Browser ICU support, React keeps working!
37
+ /**
38
+ * Poor man's PluralSelector implementation, using an english fallback. We want
39
+ * a lightweight, future-proof and good-enough solution. We don't want a perfect
40
+ * and heavy solution.
41
+ *
42
+ * Docusaurus classic theme has only 2 deeply nested labels requiring complex
43
+ * plural rules. We don't want to use Intl + PluralRules polyfills + full ICU
44
+ * syntax (react-intl) just for that.
45
+ *
46
+ * Notes:
47
+ * - 2021: 92+% Browsers support Intl.PluralRules, and support will increase in
48
+ * the future
49
+ * - NodeJS >= 13 has full ICU support by default
50
+ * - In case of "mismatch" between SSR and Browser ICU support, React keeps
51
+ * working!
52
+ */
48
53
  function useLocalePluralForms() {
49
54
  const { i18n: { currentLocale }, } = useDocusaurusContext();
50
55
  return useMemo(() => {
51
- // @ts-expect-error checking Intl.PluralRules in case browser doesn't have it (e.g Safari 12-)
56
+ // @ts-expect-error checking Intl.PluralRules in case browser doesn't
57
+ // have it (e.g Safari 12-)
52
58
  if (Intl.PluralRules) {
53
59
  try {
54
60
  return createLocalePluralForms(currentLocale);
55
61
  }
56
- catch (e) {
57
- console.error(`Failed to use Intl.PluralRules for locale=${currentLocale}.
62
+ catch {
63
+ console.error(`Failed to use Intl.PluralRules for locale "${currentLocale}".
58
64
  Docusaurus will fallback to a default/fallback (English) Intl.PluralRules implementation.
59
65
  `);
60
66
  return EnglishPluralForms;
@@ -74,21 +80,19 @@ function selectPluralMessage(pluralMessages, count, localePluralForms) {
74
80
  if (parts.length === 1) {
75
81
  return parts[0];
76
82
  }
77
- else {
78
- if (parts.length > localePluralForms.pluralForms.length) {
79
- console.error(`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length} plural forms: ${pluralMessages} `);
80
- }
81
- const pluralForm = localePluralForms.select(count);
82
- const pluralFormIndex = localePluralForms.pluralForms.indexOf(pluralForm);
83
- // In case of not enough plural form messages, we take the last one (other) instead of returning undefined
84
- return parts[Math.min(pluralFormIndex, parts.length - 1)];
83
+ if (parts.length > localePluralForms.pluralForms.length) {
84
+ console.error(`For locale=${localePluralForms.locale}, a maximum of ${localePluralForms.pluralForms.length} plural forms are expected (${localePluralForms.pluralForms}), but the message contains ${parts.length} plural forms: ${pluralMessages} `);
85
85
  }
86
+ const pluralForm = localePluralForms.select(count);
87
+ const pluralFormIndex = localePluralForms.pluralForms.indexOf(pluralForm);
88
+ // In case of not enough plural form messages, we take the last one (other)
89
+ // instead of returning undefined
90
+ return parts[Math.min(pluralFormIndex, parts.length - 1)];
86
91
  }
87
92
  export function usePluralForm() {
88
93
  const localePluralForm = useLocalePluralForms();
89
94
  return {
90
- selectMessage: (count, pluralMessages) => {
91
- return selectPluralMessage(pluralMessages, count, localePluralForm);
92
- },
95
+ selectMessage: (count, pluralMessages) => selectPluralMessage(pluralMessages, count, localePluralForm),
93
96
  };
94
97
  }
98
+ //# sourceMappingURL=usePluralForm.js.map