@docusaurus/theme-common 2.0.0-beta.15 → 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.
- package/lib/components/Collapsible/index.d.ts.map +1 -1
- package/lib/components/Collapsible/index.js +9 -5
- package/lib/components/Collapsible/index.js.map +1 -1
- package/lib/components/Details/index.d.ts +1 -2
- package/lib/components/Details/index.d.ts.map +1 -1
- package/lib/components/Details/index.js +5 -4
- package/lib/components/Details/index.js.map +1 -1
- package/lib/hooks/useKeyboardNavigation.d.ts +1 -0
- package/lib/hooks/useKeyboardNavigation.d.ts.map +1 -1
- package/lib/hooks/useKeyboardNavigation.js +1 -1
- package/lib/hooks/useKeyboardNavigation.js.map +1 -1
- package/lib/hooks/useWindowSize.d.ts.map +1 -1
- package/lib/hooks/useWindowSize.js +4 -2
- package/lib/hooks/useWindowSize.js.map +1 -1
- package/lib/index.d.ts +4 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/index.js.map +1 -1
- package/lib/utils/ThemeClassNames.d.ts +1 -0
- package/lib/utils/ThemeClassNames.d.ts.map +1 -1
- package/lib/utils/ThemeClassNames.js +3 -1
- package/lib/utils/ThemeClassNames.js.map +1 -1
- package/lib/utils/codeBlockUtils.d.ts.map +1 -1
- package/lib/utils/codeBlockUtils.js +5 -4
- package/lib/utils/codeBlockUtils.js.map +1 -1
- package/lib/utils/colorModeUtils.d.ts.map +1 -1
- package/lib/utils/colorModeUtils.js +38 -16
- package/lib/utils/colorModeUtils.js.map +1 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -1
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +3 -7
- package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -1
- package/lib/utils/docsUtils.d.ts +6 -1
- package/lib/utils/docsUtils.d.ts.map +1 -1
- package/lib/utils/docsUtils.js +38 -10
- package/lib/utils/docsUtils.js.map +1 -1
- package/lib/utils/historyUtils.d.ts +12 -1
- package/lib/utils/historyUtils.d.ts.map +1 -1
- package/lib/utils/historyUtils.js +9 -8
- package/lib/utils/historyUtils.js.map +1 -1
- package/lib/utils/jsUtils.d.ts +5 -2
- package/lib/utils/jsUtils.d.ts.map +1 -1
- package/lib/utils/jsUtils.js +5 -2
- package/lib/utils/jsUtils.js.map +1 -1
- package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -1
- package/lib/utils/mobileSecondaryMenu.js.map +1 -1
- package/lib/utils/pathUtils.d.ts.map +1 -1
- package/lib/utils/pathUtils.js +7 -2
- package/lib/utils/pathUtils.js.map +1 -1
- package/lib/utils/reactUtils.d.ts +18 -0
- package/lib/utils/reactUtils.d.ts.map +1 -1
- package/lib/utils/reactUtils.js +20 -11
- package/lib/utils/reactUtils.js.map +1 -1
- package/lib/utils/regexpUtils.d.ts +1 -1
- package/lib/utils/regexpUtils.js +1 -1
- package/lib/utils/routesUtils.d.ts +11 -0
- package/lib/utils/routesUtils.d.ts.map +1 -0
- package/lib/utils/routesUtils.js +33 -0
- package/lib/utils/routesUtils.js.map +1 -0
- package/lib/utils/storageUtils.d.ts +4 -4
- package/lib/utils/storageUtils.d.ts.map +1 -1
- package/lib/utils/storageUtils.js +18 -20
- package/lib/utils/storageUtils.js.map +1 -1
- package/lib/utils/tocUtils.d.ts +9 -5
- package/lib/utils/tocUtils.d.ts.map +1 -1
- package/lib/utils/tocUtils.js +45 -7
- package/lib/utils/tocUtils.js.map +1 -1
- package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
- package/lib/utils/useAlternatePageUtils.js +2 -1
- package/lib/utils/useAlternatePageUtils.js.map +1 -1
- package/lib/utils/useContextualSearchFilters.js +2 -2
- package/lib/utils/useContextualSearchFilters.js.map +1 -1
- package/lib/utils/useLocationChange.d.ts +1 -1
- package/lib/utils/useLocationChange.d.ts.map +1 -1
- package/lib/utils/useLocationChange.js +3 -0
- package/lib/utils/useLocationChange.js.map +1 -1
- package/lib/utils/usePluralForm.d.ts.map +1 -1
- package/lib/utils/usePluralForm.js +26 -21
- package/lib/utils/usePluralForm.js.map +1 -1
- package/lib/utils/useTOCHighlight.d.ts +1 -2
- package/lib/utils/useTOCHighlight.d.ts.map +1 -1
- package/lib/utils/useTOCHighlight.js +22 -20
- package/lib/utils/useTOCHighlight.js.map +1 -1
- package/package.json +11 -11
- package/src/components/Collapsible/index.tsx +14 -9
- package/src/components/Details/index.tsx +7 -4
- package/src/hooks/useKeyboardNavigation.ts +2 -2
- package/src/hooks/useWindowSize.ts +4 -2
- package/src/index.ts +12 -2
- package/src/utils/ThemeClassNames.ts +3 -1
- package/src/utils/codeBlockUtils.ts +5 -4
- package/src/utils/colorModeUtils.tsx +39 -18
- package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +3 -5
- package/src/utils/docsUtils.tsx +56 -11
- package/src/utils/historyUtils.ts +10 -9
- package/src/utils/jsUtils.ts +5 -2
- package/src/utils/mobileSecondaryMenu.tsx +6 -5
- package/src/utils/pathUtils.ts +5 -2
- package/src/utils/reactUtils.tsx +20 -11
- package/src/utils/regexpUtils.ts +1 -1
- package/src/utils/routesUtils.ts +39 -0
- package/src/utils/storageUtils.ts +21 -19
- package/src/utils/tocUtils.ts +66 -13
- package/src/utils/useAlternatePageUtils.ts +4 -3
- package/src/utils/useContextualSearchFilters.ts +2 -2
- package/src/utils/useLocationChange.ts +5 -1
- package/src/utils/usePluralForm.ts +29 -23
- package/src/utils/useTOCHighlight.ts +24 -21
package/lib/utils/docsUtils.js
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import React, { createContext, useContext } from 'react';
|
|
8
|
-
import { useAllDocsData } from '@docusaurus/plugin-content-docs/client';
|
|
8
|
+
import { useActivePlugin, useAllDocsData, } from '@docusaurus/plugin-content-docs/client';
|
|
9
9
|
import { isSamePath } from './pathUtils';
|
|
10
10
|
import { useLocation } from '@docusaurus/router';
|
|
11
11
|
// TODO not ideal, see also "useDocs"
|
|
12
12
|
export const isDocsPluginEnabled = !!useAllDocsData;
|
|
13
|
-
// Using a Symbol because null is a valid context value (a doc
|
|
13
|
+
// Using a Symbol because null is a valid context value (a doc with no sidebar)
|
|
14
14
|
// Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
|
|
15
15
|
const EmptyContextValue = Symbol('EmptyContext');
|
|
16
16
|
const DocsVersionContext = createContext(EmptyContextValue);
|
|
@@ -49,17 +49,14 @@ export function useDocsSidebar() {
|
|
|
49
49
|
// Use the components props and the sidebar in context
|
|
50
50
|
// to get back the related sidebar category that we want to render
|
|
51
51
|
export function findSidebarCategory(sidebar, predicate) {
|
|
52
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
53
52
|
for (const item of sidebar) {
|
|
54
53
|
if (item.type === 'category') {
|
|
55
54
|
if (predicate(item)) {
|
|
56
55
|
return item;
|
|
57
56
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return subItem;
|
|
62
|
-
}
|
|
57
|
+
const subItem = findSidebarCategory(item.items, predicate);
|
|
58
|
+
if (subItem) {
|
|
59
|
+
return subItem;
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
62
|
}
|
|
@@ -70,17 +67,19 @@ export function findFirstCategoryLink(item) {
|
|
|
70
67
|
if (item.href) {
|
|
71
68
|
return item.href;
|
|
72
69
|
}
|
|
73
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
74
70
|
for (const subItem of item.items) {
|
|
75
71
|
if (subItem.type === 'link') {
|
|
76
72
|
return subItem.href;
|
|
77
73
|
}
|
|
78
|
-
if (subItem.type === 'category') {
|
|
74
|
+
else if (subItem.type === 'category') {
|
|
79
75
|
const categoryLink = findFirstCategoryLink(subItem);
|
|
80
76
|
if (categoryLink) {
|
|
81
77
|
return categoryLink;
|
|
82
78
|
}
|
|
83
79
|
}
|
|
80
|
+
else if (subItem.type === 'html') {
|
|
81
|
+
// skip
|
|
82
|
+
}
|
|
84
83
|
else {
|
|
85
84
|
throw new Error(`Unexpected category item type for ${JSON.stringify(subItem)}`);
|
|
86
85
|
}
|
|
@@ -113,4 +112,33 @@ export function isActiveSidebarItem(item, activePath) {
|
|
|
113
112
|
}
|
|
114
113
|
return false;
|
|
115
114
|
}
|
|
115
|
+
export function getBreadcrumbs({ sidebar, pathname, }) {
|
|
116
|
+
const breadcrumbs = [];
|
|
117
|
+
function extract(items) {
|
|
118
|
+
for (const item of items) {
|
|
119
|
+
if (item.type === 'category' &&
|
|
120
|
+
(isSamePath(item.href, pathname) || extract(item.items))) {
|
|
121
|
+
breadcrumbs.push(item);
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
else if (item.type === 'link' && isSamePath(item.href, pathname)) {
|
|
125
|
+
breadcrumbs.push(item);
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
extract(sidebar);
|
|
132
|
+
return breadcrumbs.reverse();
|
|
133
|
+
}
|
|
134
|
+
export function useSidebarBreadcrumbs() {
|
|
135
|
+
var _a;
|
|
136
|
+
const sidebar = useDocsSidebar();
|
|
137
|
+
const { pathname } = useLocation();
|
|
138
|
+
const breadcrumbsOption = (_a = useActivePlugin()) === null || _a === void 0 ? void 0 : _a.pluginData.breadcrumbs;
|
|
139
|
+
if (breadcrumbsOption === false || !sidebar) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
return getBreadcrumbs({ sidebar, pathname });
|
|
143
|
+
}
|
|
116
144
|
//# sourceMappingURL=docsUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docsUtils.js","sourceRoot":"","sources":["../../src/utils/docsUtils.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EAAC,aAAa,EAAkB,UAAU,EAAC,MAAM,O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iB,KAAK,KAAK,IAAI,CAAC,OAAO,EAAE;QAC3C,OAAO,IAAI,CAAC;KACb;IAED,OAAO,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,EAAC,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -4,9 +4,20 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
import type { Location, Action } from '
|
|
7
|
+
import type { Location, Action } from 'history';
|
|
8
8
|
declare type HistoryBlockHandler = (location: Location, action: Action) => void | false;
|
|
9
|
+
/**
|
|
10
|
+
* Permits to register a handler that will be called on history actions (pop,
|
|
11
|
+
* push, replace) If the handler returns false, the navigation transition will
|
|
12
|
+
* be blocked/cancelled
|
|
13
|
+
*/
|
|
9
14
|
export declare function useHistoryActionHandler(handler: HistoryBlockHandler): void;
|
|
15
|
+
/**
|
|
16
|
+
* Permits to register a handler that will be called on history pop navigation
|
|
17
|
+
* (backward/forward) If the handler returns false, the backward/forward
|
|
18
|
+
* transition will be blocked. Unfortunately there's no good way to detect the
|
|
19
|
+
* "direction" (backward/forward) of the POP event.
|
|
20
|
+
*/
|
|
10
21
|
export declare function useHistoryPopHandler(handler: HistoryBlockHandler): void;
|
|
11
22
|
export {};
|
|
12
23
|
//# sourceMappingURL=historyUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"historyUtils.d.ts","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAC,QAAQ,EAAE,MAAM,EAAC,MAAM,SAAS,CAAC;AAE9C,aAAK,mBAAmB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,KAAK,CAAC;AAEhF;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAe1E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CASvE"}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { useEffect, useRef } from 'react';
|
|
8
8
|
import { useHistory } from '@docusaurus/router';
|
|
9
|
-
|
|
10
|
-
Permits to register a handler that will be called on history actions (pop,
|
|
11
|
-
If the handler returns false, the navigation transition will
|
|
9
|
+
/**
|
|
10
|
+
* Permits to register a handler that will be called on history actions (pop,
|
|
11
|
+
* push, replace) If the handler returns false, the navigation transition will
|
|
12
|
+
* be blocked/cancelled
|
|
12
13
|
*/
|
|
13
14
|
export function useHistoryActionHandler(handler) {
|
|
14
15
|
const { block } = useHistory();
|
|
@@ -21,11 +22,11 @@ export function useHistoryActionHandler(handler) {
|
|
|
21
22
|
// See https://github.com/remix-run/history/blob/main/docs/blocking-transitions.md
|
|
22
23
|
block((location, action) => lastHandlerRef.current(location, action)), [block, lastHandlerRef]);
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
Permits to register a handler that will be called on history pop navigation
|
|
26
|
-
If the handler returns false, the backward/forward
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Permits to register a handler that will be called on history pop navigation
|
|
27
|
+
* (backward/forward) If the handler returns false, the backward/forward
|
|
28
|
+
* transition will be blocked. Unfortunately there's no good way to detect the
|
|
29
|
+
* "direction" (backward/forward) of the POP event.
|
|
29
30
|
*/
|
|
30
31
|
export function useHistoryPopHandler(handler) {
|
|
31
32
|
useHistoryActionHandler((location, action) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAK9C
|
|
1
|
+
{"version":3,"file":"historyUtils.js","sourceRoot":"","sources":["../../src/utils/historyUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxC,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAK9C;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAA4B;IAClE,MAAM,EAAC,KAAK,EAAC,GAAG,UAAU,EAAE,CAAC;IAE7B,mEAAmE;IACnE,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,cAAc,CAAC,OAAO,GAAG,OAAO,CAAC;IACnC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,SAAS,CACP,GAAG,EAAE;IACH,kFAAkF;IAClF,KAAK,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,EACvE,CAAC,KAAK,EAAE,cAAc,CAAC,CACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA4B;IAC/D,uBAAuB,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE;QAC3C,IAAI,MAAM,KAAK,KAAK,EAAE;YACpB,uDAAuD;YACvD,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAClC;QACD,uCAAuC;QACvC,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/lib/utils/jsUtils.d.ts
CHANGED
|
@@ -7,8 +7,11 @@
|
|
|
7
7
|
/**
|
|
8
8
|
* Gets the duplicate values in an array.
|
|
9
9
|
* @param arr The array.
|
|
10
|
-
* @param comparator Compares two values and returns `true` if they are equal
|
|
11
|
-
*
|
|
10
|
+
* @param comparator Compares two values and returns `true` if they are equal
|
|
11
|
+
* (duplicated).
|
|
12
|
+
* @returns Value of the elements `v` that have a preceding element `u` where
|
|
13
|
+
* `comparator(u, v) === true`. Values within the returned array are not
|
|
14
|
+
* guaranteed to be unique.
|
|
12
15
|
*/
|
|
13
16
|
export declare function duplicates<T>(arr: readonly T[], comparator?: (a: T, b: T) => boolean): T[];
|
|
14
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH
|
|
1
|
+
{"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,SAAS,CAAC,EAAE,EACjB,UAAU,GAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAA2B,GACtD,CAAC,EAAE,CAIL;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAGrC"}
|
package/lib/utils/jsUtils.js
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* Gets the duplicate values in an array.
|
|
10
10
|
* @param arr The array.
|
|
11
|
-
* @param comparator Compares two values and returns `true` if they are equal
|
|
12
|
-
*
|
|
11
|
+
* @param comparator Compares two values and returns `true` if they are equal
|
|
12
|
+
* (duplicated).
|
|
13
|
+
* @returns Value of the elements `v` that have a preceding element `u` where
|
|
14
|
+
* `comparator(u, v) === true`. Values within the returned array are not
|
|
15
|
+
* guaranteed to be unique.
|
|
13
16
|
*/
|
|
14
17
|
export function duplicates(arr, comparator = (a, b) => a === b) {
|
|
15
18
|
return arr.filter((v, vIndex) => arr.findIndex((u) => comparator(u, v)) !== vIndex);
|
package/lib/utils/jsUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsUtils.js","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yCAAyC;AAEzC
|
|
1
|
+
{"version":3,"file":"jsUtils.js","sourceRoot":"","sources":["../../src/utils/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yCAAyC;AAEzC;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,GAAiB,EACjB,aAAsC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC;IAEvD,OAAO,GAAG,CAAC,MAAM,CACf,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,MAAM,CACjE,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAI,GAAQ;IAC9B,oHAAoH;IACpH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobileSecondaryMenu.d.ts","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAEZ,KAAK,SAAS,EAId,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mobileSecondaryMenu.d.ts","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAc,EAEZ,KAAK,SAAS,EAId,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AAaf,aAAK,UAAU,GAAG;IAChB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF,oBAAY,4BAA4B,CAAC,KAAK,IAAI,aAAa,CAC7D,KAAK,GAAG,UAAU,CACnB,CAAC;AAeF,wBAAgB,2BAA2B,CAAC,EAC1C,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAId;AAYD,wBAAgB,8BAA8B,IAAI,CAChD,UAAU,EAAE,UAAU,KACnB,SAAS,GAAG,SAAS,CASzB;AAYD,wBAAgB,yBAAyB,CACvC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,EACA,SAAS,EACT,KAAK,GACN,EAAE;IACD,SAAS,EAAE,4BAA4B,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC;IAC5D,KAAK,EAAE,KAAK,CAAC;CACd,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAcrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobileSecondaryMenu.js","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EAER,UAAU,EACV,aAAa,EACb,SAAS,EAET,OAAO,GACR,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"mobileSecondaryMenu.js","sourceRoot":"","sources":["../../src/utils/mobileSecondaryMenu.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,EACZ,QAAQ,EAER,UAAU,EACV,aAAa,EACb,SAAS,EAET,OAAO,GACR,MAAM,OAAO,CAAC;AA0Bf,SAAS,eAAe;I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Aa,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACb,8DAA8D;QAC9D,QAAQ,CAAC,EAAC,SAAS,EAAE,KAAK,EAAE,aAAa,EAAC,CAAC,CAAC;IAC9C,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC;IAEzC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAElD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1 +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,
|
|
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,OAOF,CAAC"}
|
package/lib/utils/pathUtils.js
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
// Compare the 2 paths, ignoring trailing
|
|
7
|
+
// Compare the 2 paths, case insensitive and ignoring trailing slash
|
|
8
8
|
export const isSamePath = (path1, path2) => {
|
|
9
|
-
const normalize = (pathname) =>
|
|
9
|
+
const normalize = (pathname) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return (_a = (!pathname || (pathname === null || pathname === void 0 ? void 0 : pathname.endsWith('/'))
|
|
12
|
+
? pathname
|
|
13
|
+
: `${pathname}/`)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
14
|
+
};
|
|
10
15
|
return normalize(path1) === normalize(path2);
|
|
11
16
|
};
|
|
12
17
|
//# sourceMappingURL=pathUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,
|
|
1
|
+
{"version":3,"file":"pathUtils.js","sourceRoot":"","sources":["../../src/utils/pathUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,KAAyB,EACzB,KAAyB,EAChB,EAAE;IACX,MAAM,SAAS,GAAG,CAAC,QAA4B,EAAE,EAAE;;QACjD,OAAA,MAAA,CAAC,CAAC,QAAQ,KAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,CAAC,GAAG,CAAC,CAAA;YACnC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,GAAG,QAAQ,GAAG,CACjB,0CAAE,WAAW,EAAE,CAAA;KAAA,CAAC;IACnB,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC"}
|
|
@@ -5,6 +5,24 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { useEffect } from 'react';
|
|
8
|
+
/**
|
|
9
|
+
* This hook is like useLayoutEffect, but without the SSR warning
|
|
10
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...)
|
|
11
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
12
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
13
|
+
* render (before `useEffect`)
|
|
14
|
+
*/
|
|
8
15
|
export declare const useIsomorphicLayoutEffect: typeof useEffect;
|
|
16
|
+
/**
|
|
17
|
+
* Permits to transform an unstable callback (like an arrow function provided as
|
|
18
|
+
* props) to a "stable" callback that is safe to use in a useEffect dependency
|
|
19
|
+
* array. Useful to avoid React stale closure problems + avoid useless effect
|
|
20
|
+
* re-executions
|
|
21
|
+
*
|
|
22
|
+
* Workaround until the React team recommends a good solution, see
|
|
23
|
+
* https://github.com/facebook/react/issues/16956
|
|
24
|
+
* This generally works but has some potential drawbacks, such as
|
|
25
|
+
* https://github.com/facebook/react/issues/16956#issuecomment-536636418
|
|
26
|
+
*/
|
|
9
27
|
export declare function useDynamicCallback<T extends (...args: never[]) => unknown>(callback: T): T;
|
|
10
28
|
//# sourceMappingURL=reactUtils.d.ts.map
|
|
@@ -1 +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;
|
|
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;AAEtE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,kBACuB,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,EACxE,QAAQ,EAAE,CAAC,GACV,CAAC,CAUH"}
|
package/lib/utils/reactUtils.js
CHANGED
|
@@ -5,23 +5,32 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
/**
|
|
9
|
+
* This hook is like useLayoutEffect, but without the SSR warning
|
|
10
|
+
* It seems hacky but it's used in many React libs (Redux, Formik...)
|
|
11
|
+
* Also mentioned here: https://github.com/facebook/react/issues/16956
|
|
12
|
+
* It is useful when you need to update a ref as soon as possible after a React
|
|
13
|
+
* render (before `useEffect`)
|
|
14
|
+
*/
|
|
12
15
|
export const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Permits to transform an unstable callback (like an arrow function provided as
|
|
18
|
+
* props) to a "stable" callback that is safe to use in a useEffect dependency
|
|
19
|
+
* array. Useful to avoid React stale closure problems + avoid useless effect
|
|
20
|
+
* re-executions
|
|
21
|
+
*
|
|
22
|
+
* Workaround until the React team recommends a good solution, see
|
|
23
|
+
* https://github.com/facebook/react/issues/16956
|
|
24
|
+
* This generally works but has some potential drawbacks, such as
|
|
25
|
+
* https://github.com/facebook/react/issues/16956#issuecomment-536636418
|
|
26
|
+
*/
|
|
19
27
|
export function useDynamicCallback(callback) {
|
|
20
28
|
const ref = useRef(callback);
|
|
21
29
|
useIsomorphicLayoutEffect(() => {
|
|
22
30
|
ref.current = callback;
|
|
23
31
|
}, [callback]);
|
|
24
|
-
// @ts-expect-error:
|
|
32
|
+
// @ts-expect-error: TS is right that this callback may be a supertype of T,
|
|
33
|
+
// but good enough for our use
|
|
25
34
|
return useCallback((...args) => ref.current(...args), []);
|
|
26
35
|
}
|
|
27
36
|
//# sourceMappingURL=reactUtils.js.map
|
|
@@ -1 +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
|
|
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;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,yBAAyB,GACpC,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9D;;;;;;;;;;GAUG;AACH,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,4EAA4E;IAC5E,8BAA8B;IAC9B,OAAO,WAAW,CAAI,CAAC,GAAG,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Converts an optional string into a Regex case insensitive and global
|
|
9
9
|
*/
|
|
10
10
|
export declare function isRegexpStringMatch(regexAsString?: string, valueToTest?: string): boolean;
|
|
11
11
|
//# sourceMappingURL=regexpUtils.d.ts.map
|
package/lib/utils/regexpUtils.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Converts an optional string into a Regex case insensitive and global
|
|
9
9
|
*/
|
|
10
10
|
export function isRegexpStringMatch(regexAsString, valueToTest) {
|
|
11
11
|
if (typeof regexAsString === 'undefined' ||
|
|
@@ -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
|
+
/// <reference types="@docusaurus/module-type-aliases" />
|
|
8
|
+
import { type Route } from '@generated/routes';
|
|
9
|
+
export declare function findHomePageRoute(routes?: Route[]): Route | undefined;
|
|
10
|
+
export declare function useHomePageRoute(): Route | undefined;
|
|
11
|
+
//# sourceMappingURL=routesUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesUtils.d.ts","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;AAEH,OAAwB,EAAC,KAAK,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAa9D,wBAAgB,iBAAiB,CAC/B,MAAM,GAAE,KAAK,EAAoB,GAChC,KAAK,GAAG,SAAS,CAYnB;AAED,wBAAgB,gBAAgB,IAAI,KAAK,GAAG,SAAS,CAEpD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 GeneratedRoutes from '@generated/routes';
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
function isHomePageRoute(route) {
|
|
10
|
+
return route.path === '/' && route.exact === true;
|
|
11
|
+
}
|
|
12
|
+
function isHomeParentRoute(route) {
|
|
13
|
+
return route.path === '/' && route.exact === false;
|
|
14
|
+
}
|
|
15
|
+
// Note that all sites don't always have a homepage in practice
|
|
16
|
+
// See https://github.com/facebook/docusaurus/pull/6517#issuecomment-1048709116
|
|
17
|
+
export function findHomePageRoute(routes = GeneratedRoutes) {
|
|
18
|
+
if (routes.length === 0) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const homePage = routes.find(isHomePageRoute);
|
|
22
|
+
if (homePage) {
|
|
23
|
+
return homePage;
|
|
24
|
+
}
|
|
25
|
+
const indexSubRoutes = routes
|
|
26
|
+
.filter(isHomeParentRoute)
|
|
27
|
+
.flatMap((route) => { var _a; return (_a = route.routes) !== null && _a !== void 0 ? _a : []; });
|
|
28
|
+
return findHomePageRoute(indexSubRoutes);
|
|
29
|
+
}
|
|
30
|
+
export function useHomePageRoute() {
|
|
31
|
+
return useMemo(() => findHomePageRoute(), []);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=routesUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routesUtils.js","sourceRoot":"","sources":["../../src/utils/routesUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,eAA6B,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAE9B,SAAS,eAAe,CAAC,KAAY;IACnC,OAAO,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC;AACpD,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY;IACrC,OAAO,KAAK,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK,CAAC;AACrD,CAAC;AAED,+DAA+D;AAC/D,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB,CAC/B,SAAkB,eAAe;IAEjC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9C,IAAI,QAAQ,EAAE;QACZ,OAAO,QAAQ,CAAC;KACjB;IACD,MAAM,cAAc,GAAG,MAAM;SAC1B,MAAM,CAAC,iBAAiB,CAAC;SACzB,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,WAAC,OAAA,MAAA,KAAK,CAAC,MAAM,mCAAI,EAAE,CAAA,EAAA,CAAC,CAAC;IAC1C,OAAO,iBAAiB,CAAC,cAAc,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -13,10 +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
|
|
17
|
-
* Local storage might simply be unavailable (iframe + browser
|
|
18
|
-
*
|
|
19
|
-
* See also https://github.com/facebook/docusaurus/issues/6036
|
|
16
|
+
* The API is fail-safe, and usage of browser storage should be considered
|
|
17
|
+
* unreliable. Local storage might simply be unavailable (iframe + browser
|
|
18
|
+
* security) or operations might fail individually. Please assume that using
|
|
19
|
+
* this API can be a NO-OP. See also https://github.com/facebook/docusaurus/issues/6036
|
|
20
20
|
*/
|
|
21
21
|
export declare const createStorageSlot: (key: string, options?: {
|
|
22
22
|
persistence?: "localStorage" | "none" | "sessionStorage" | undefined;
|
|
@@ -1 +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;
|
|
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;AA0CtD,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,WAmCF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,WAAW,GAAE,WAAgC,GAC5C,MAAM,EAAE,CAcV"}
|
|
@@ -6,8 +6,8 @@
|
|
|
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
|
|
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
13
|
throw new Error('Browser storage is not available on Node.js/Docusaurus SSR process.');
|
|
@@ -15,14 +15,12 @@ function getBrowserStorage(storageType = DefaultStorageType) {
|
|
|
15
15
|
if (storageType === 'none') {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
/**
|
|
@@ -57,10 +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.
|
|
60
|
-
* The API is fail-safe, and usage of browser storage should be considered
|
|
61
|
-
* Local storage might simply be unavailable (iframe + browser
|
|
62
|
-
*
|
|
63
|
-
* See also https://github.com/facebook/docusaurus/issues/6036
|
|
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
|
|
64
62
|
*/
|
|
65
63
|
export const createStorageSlot = (key, options) => {
|
|
66
64
|
if (typeof window === 'undefined') {
|
|
@@ -75,8 +73,8 @@ export const createStorageSlot = (key, options) => {
|
|
|
75
73
|
try {
|
|
76
74
|
return browserStorage.getItem(key);
|
|
77
75
|
}
|
|
78
|
-
catch (
|
|
79
|
-
console.error(`Docusaurus storage error, can't get key=${key}`,
|
|
76
|
+
catch (err) {
|
|
77
|
+
console.error(`Docusaurus storage error, can't get key=${key}`, err);
|
|
80
78
|
return null;
|
|
81
79
|
}
|
|
82
80
|
},
|
|
@@ -84,16 +82,16 @@ export const createStorageSlot = (key, options) => {
|
|
|
84
82
|
try {
|
|
85
83
|
browserStorage.setItem(key, value);
|
|
86
84
|
}
|
|
87
|
-
catch (
|
|
88
|
-
console.error(`Docusaurus storage error, can't set ${key}=${value}`,
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error(`Docusaurus storage error, can't set ${key}=${value}`, err);
|
|
89
87
|
}
|
|
90
88
|
},
|
|
91
89
|
del: () => {
|
|
92
90
|
try {
|
|
93
91
|
browserStorage.removeItem(key);
|
|
94
92
|
}
|
|
95
|
-
catch (
|
|
96
|
-
console.error(`Docusaurus storage error, can't delete key=${key}`,
|
|
93
|
+
catch (err) {
|
|
94
|
+
console.error(`Docusaurus storage error, can't delete key=${key}`, err);
|
|
97
95
|
}
|
|
98
96
|
},
|
|
99
97
|
};
|
|
@@ -1 +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,
|
|
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,8EAA8E;AAC9E,+DAA+D;AAC/D,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;IACD,IAAI;QACF,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;KAC5B;IAAC,OAAO,GAAG,EAAE;QACZ,wCAAwC,CAAC,GAAY,CAAC,CAAC;QACvD,OAAO,IAAI,CAAC;KACb;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,CAAC;QACF,0CAA0C,GAAG,IAAI,CAAC;KACnD;AACH,CAAC;AASD,MAAM,eAAe,GAAgB;IACnC,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI;IACf,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC;IACb,GAAG,EAAE,GAAG,EAAE,GAAE,CAA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AAC,KAAK,CAAC,8CAA8C,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC;aACzE;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"}
|
package/lib/utils/tocUtils.d.ts
CHANGED
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import type { TOCItem } from '@docusaurus/types';
|
|
8
|
-
declare type
|
|
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, }: {
|
|
9
16
|
toc: readonly TOCItem[];
|
|
10
17
|
minHeadingLevel: number;
|
|
11
18
|
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 {};
|
|
19
|
+
}): readonly TOCTreeNode[];
|
|
16
20
|
//# sourceMappingURL=tocUtils.d.ts.map
|
|
@@ -1 +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,
|
|
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"}
|