@docusaurus/theme-common 0.0.0-4521 → 0.0.0-4526

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 (73) hide show
  1. package/lib/components/Collapsible/index.d.ts.map +1 -1
  2. package/lib/components/Collapsible/index.js +9 -5
  3. package/lib/components/Collapsible/index.js.map +1 -1
  4. package/lib/components/Details/index.js +1 -1
  5. package/lib/components/Details/index.js.map +1 -1
  6. package/lib/hooks/useWindowSize.d.ts.map +1 -1
  7. package/lib/hooks/useWindowSize.js +4 -2
  8. package/lib/hooks/useWindowSize.js.map +1 -1
  9. package/lib/utils/ThemeClassNames.d.ts.map +1 -1
  10. package/lib/utils/ThemeClassNames.js +2 -1
  11. package/lib/utils/ThemeClassNames.js.map +1 -1
  12. package/lib/utils/codeBlockUtils.d.ts.map +1 -1
  13. package/lib/utils/codeBlockUtils.js +5 -4
  14. package/lib/utils/codeBlockUtils.js.map +1 -1
  15. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.d.ts.map +1 -1
  16. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js +3 -7
  17. package/lib/utils/docsPreferredVersion/DocsPreferredVersionProvider.js.map +1 -1
  18. package/lib/utils/docsUtils.d.ts.map +1 -1
  19. package/lib/utils/docsUtils.js +4 -6
  20. package/lib/utils/docsUtils.js.map +1 -1
  21. package/lib/utils/historyUtils.d.ts +11 -0
  22. package/lib/utils/historyUtils.d.ts.map +1 -1
  23. package/lib/utils/historyUtils.js +9 -8
  24. package/lib/utils/historyUtils.js.map +1 -1
  25. package/lib/utils/jsUtils.d.ts +5 -2
  26. package/lib/utils/jsUtils.d.ts.map +1 -1
  27. package/lib/utils/jsUtils.js +5 -2
  28. package/lib/utils/jsUtils.js.map +1 -1
  29. package/lib/utils/mobileSecondaryMenu.d.ts.map +1 -1
  30. package/lib/utils/mobileSecondaryMenu.js.map +1 -1
  31. package/lib/utils/reactUtils.d.ts +18 -0
  32. package/lib/utils/reactUtils.d.ts.map +1 -1
  33. package/lib/utils/reactUtils.js +20 -11
  34. package/lib/utils/reactUtils.js.map +1 -1
  35. package/lib/utils/regexpUtils.d.ts +1 -1
  36. package/lib/utils/regexpUtils.js +1 -1
  37. package/lib/utils/storageUtils.d.ts +4 -4
  38. package/lib/utils/storageUtils.d.ts.map +1 -1
  39. package/lib/utils/storageUtils.js +12 -14
  40. package/lib/utils/storageUtils.js.map +1 -1
  41. package/lib/utils/tocUtils.d.ts.map +1 -1
  42. package/lib/utils/tocUtils.js +1 -3
  43. package/lib/utils/tocUtils.js.map +1 -1
  44. package/lib/utils/useAlternatePageUtils.d.ts.map +1 -1
  45. package/lib/utils/useAlternatePageUtils.js +2 -1
  46. package/lib/utils/useAlternatePageUtils.js.map +1 -1
  47. package/lib/utils/useContextualSearchFilters.js +2 -2
  48. package/lib/utils/useContextualSearchFilters.js.map +1 -1
  49. package/lib/utils/usePluralForm.d.ts.map +1 -1
  50. package/lib/utils/usePluralForm.js +25 -20
  51. package/lib/utils/usePluralForm.js.map +1 -1
  52. package/lib/utils/useTOCHighlight.d.ts.map +1 -1
  53. package/lib/utils/useTOCHighlight.js +20 -17
  54. package/lib/utils/useTOCHighlight.js.map +1 -1
  55. package/package.json +8 -8
  56. package/src/components/Collapsible/index.tsx +14 -9
  57. package/src/components/Details/index.tsx +1 -1
  58. package/src/hooks/useWindowSize.ts +4 -2
  59. package/src/utils/ThemeClassNames.ts +2 -1
  60. package/src/utils/codeBlockUtils.ts +5 -4
  61. package/src/utils/docsPreferredVersion/DocsPreferredVersionProvider.tsx +3 -5
  62. package/src/utils/docsUtils.tsx +5 -6
  63. package/src/utils/historyUtils.ts +9 -8
  64. package/src/utils/jsUtils.ts +5 -2
  65. package/src/utils/mobileSecondaryMenu.tsx +6 -5
  66. package/src/utils/reactUtils.tsx +20 -11
  67. package/src/utils/regexpUtils.ts +1 -1
  68. package/src/utils/storageUtils.ts +12 -13
  69. package/src/utils/tocUtils.ts +1 -2
  70. package/src/utils/useAlternatePageUtils.ts +4 -3
  71. package/src/utils/useContextualSearchFilters.ts +2 -2
  72. package/src/utils/usePluralForm.ts +28 -22
  73. package/src/utils/useTOCHighlight.ts +20 -17
@@ -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 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
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
- 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 (e) {
22
+ logOnceBrowserStorageNotAvailableWarning(e);
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 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
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') {
@@ -1 +1 @@
1
- {"version":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AO,EAAE,CAKrC"}
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,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,CAqB5B;AAGD,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,eAAe,EACf,eAAe,GAChB,EAAE,cAAc,GAAG,SAAS,OAAO,EAAE,CAKrC"}
@@ -23,9 +23,7 @@ export function filterTOC({ toc, minHeadingLevel, maxHeadingLevel, }) {
23
23
  },
24
24
  ];
25
25
  }
26
- else {
27
- return filteredChildren;
28
- }
26
+ return filteredChildren;
29
27
  });
30
28
  }
31
29
  // Memoize potentially expensive filtering logic
@@ -1 +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;Q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,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"}
@@ -1 +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"}
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,7 +21,8 @@ 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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useAlternatePageUtils.js","sourceRoot":"","sources":["../../src/utils/useAlternatePageUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AACpE,OAA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AqB;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"}
@@ -8,8 +8,8 @@ import { useAllDocsData, useActivePluginAndVersion, } from '@docusaurus/plugin-c
8
8
  import { useDocsPreferredVersionByPluginId } from './docsPreferredVersion/useDocsPreferredVersion';
9
9
  import { docVersionSearchTag, DEFAULT_SEARCH_TAG } from './searchUtils';
10
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
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
13
  export function useContextualSearchFilters() {
14
14
  const { i18n } = useDocusaurusContext();
15
15
  const allDocsData = useAllDocsData();
@@ -1 +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,yFAAyF;AACzF,8DAA8D;AAC9D,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,CA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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"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePluralForm.d.ts","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwGH,wBAAgB,aAAa,IAAI;IAC/B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,KAAK,MAAM,CAAC;CAClE,CAMA"}
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,21 +34,27 @@ 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);
@@ -74,15 +80,14 @@ 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();
@@ -1 +1 @@
1
- {"version":3,"file":"usePluralForm.js","sourceRoot":"","sources":["../../src/utils/usePluralForm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAC9B,OAAO,oBAAoB,MAAM,kCAAkC,CAAC;AAEpE,6DAA6D;AAC7D,mEAAmE;AACnE,qEAAqE;AACrE,MAAM,kBAAkB,GAA0B;IAChD,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,OAAO;CACR,CAAC;AACF,SAAS,eAAe,CACtB,WAAkC;IAElC,OAAO,kBAAkB,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACrE,CAAC;AAQD,4CAA4C;AAC5C,MAAM,kBAAkB,GAAsB;IAC5C,MAAM,EAAE,IAAI;IACZ,WAAW,EAAE,eAAe,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC9C,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;CACnD,CAAC;AAEF,SAAS,uBAAuB,CAAC,MAAc;IAC7C,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACjD,OAAO;QACL,MAAM;QACN,WAAW,EAAE,eAAe,CAC1B,WAAW,CAAC,eAAe,EAAE,CAAC,gBAAgB,CAC/C;QACD,MAAM,EAAE,CAA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ts","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgHH,oBAAY,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,iBAAS,eAAe,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAwDrE;AAED,eAAe,eAAe,CAAC"}
@@ -10,7 +10,8 @@ import { useThemeConfig } from './useThemeConfig';
10
10
  TODO make the hardcoded theme-classic classnames configurable
11
11
  (or add them to ThemeClassNames?)
12
12
  */
13
- // If the anchor has no height and is just a "marker" in the dom; we'll use the parent (normally the link text) rect boundaries instead
13
+ // If the anchor has no height and is just a "marker" in the dom; we'll use the
14
+ // parent (normally the link text) rect boundaries instead
14
15
  function getVisibleBoundingClientRect(element) {
15
16
  const rect = element.getBoundingClientRect();
16
17
  const hasNoHeight = rect.top === rect.bottom;
@@ -19,8 +20,10 @@ function getVisibleBoundingClientRect(element) {
19
20
  }
20
21
  return rect;
21
22
  }
22
- // Considering we divide viewport into 2 zones of each 50vh
23
- // This returns true if an element is in the first zone (ie, appear in viewport, near the top)
23
+ /**
24
+ * Considering we divide viewport into 2 zones of each 50vh, this returns true
25
+ * if an element is in the first zone (ie, appear in viewport, near the top)
26
+ */
24
27
  function isInViewportTopHalf(boundingRect) {
25
28
  return boundingRect.top > 0 && boundingRect.bottom < window.innerHeight / 2;
26
29
  }
@@ -33,32 +36,32 @@ function getAnchors({ minHeadingLevel, maxHeadingLevel, }) {
33
36
  }
34
37
  function getActiveAnchor(anchors, { anchorTopOffset, }) {
35
38
  var _a;
36
- // Naming is hard
37
- // The "nextVisibleAnchor" is the first anchor that appear under the viewport top boundary
38
- // Note: it does not mean this anchor is visible yet, but if user continues scrolling down, it will be the first to become visible
39
+ // Naming is hard: The "nextVisibleAnchor" is the first anchor that appear
40
+ // under the viewport top boundary. It does not mean this anchor is visible
41
+ // yet, but if user continues scrolling down, it will be the first to become
42
+ // visible
39
43
  const nextVisibleAnchor = anchors.find((anchor) => {
40
44
  const boundingRect = getVisibleBoundingClientRect(anchor);
41
45
  return boundingRect.top >= anchorTopOffset;
42
46
  });
43
47
  if (nextVisibleAnchor) {
44
48
  const boundingRect = getVisibleBoundingClientRect(nextVisibleAnchor);
45
- // If anchor is in the top half of the viewport: it is the one we consider "active"
46
- // (unless it's too close to the top and and soon to be scrolled outside viewport)
49
+ // If anchor is in the top half of the viewport: it is the one we consider
50
+ // "active" (unless it's too close to the top and and soon to be scrolled
51
+ // outside viewport)
47
52
  if (isInViewportTopHalf(boundingRect)) {
48
53
  return nextVisibleAnchor;
49
54
  }
50
- // If anchor is in the bottom half of the viewport, or under the viewport, we consider the active anchor is the previous one
51
- // This is because the main text appearing in the user screen mostly belong to the previous anchor
52
- else {
53
- // Returns null for the first anchor, see https://github.com/facebook/docusaurus/issues/5318
54
- return (_a = anchors[anchors.indexOf(nextVisibleAnchor) - 1]) !== null && _a !== void 0 ? _a : null;
55
- }
55
+ // If anchor is in the bottom half of the viewport, or under the viewport,
56
+ // we consider the active anchor is the previous one. This is because the
57
+ // main text appearing in the user screen mostly belong to the previous
58
+ // anchor. Returns null for the first anchor, see
59
+ // https://github.com/facebook/docusaurus/issues/5318
60
+ return (_a = anchors[anchors.indexOf(nextVisibleAnchor) - 1]) !== null && _a !== void 0 ? _a : null;
56
61
  }
57
62
  // no anchor under viewport top? (ie we are at the bottom of the page)
58
63
  // => highlight the last anchor found
59
- else {
60
- return anchors[anchors.length - 1];
61
- }
64
+ return anchors[anchors.length - 1];
62
65
  }
63
66
  function getLinkAnchorValue(link) {
64
67
  return decodeURIComponent(link.href.substring(link.href.indexOf('#') + 1));
@@ -1 +1 @@
1
- {"version":3,"file":"useTOCHighlight.js","sourceRoot":"","sources":["../../src/utils/useTOCHighlight.ts"],"names":[],"mappings":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,EAAE,gBAAgB,CAAC,CAAC;QACtD,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAEtD,gBAAgB,EAAE,CAAC;QAEnB,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACzD,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;QAC3D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,eAAe,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/theme-common",
3
- "version": "0.0.0-4521",
3
+ "version": "0.0.0-4526",
4
4
  "description": "Common code for Docusaurus themes.",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,18 +18,18 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/plugin-content-blog": "0.0.0-4521",
22
- "@docusaurus/plugin-content-docs": "0.0.0-4521",
23
- "@docusaurus/plugin-content-pages": "0.0.0-4521",
21
+ "@docusaurus/plugin-content-blog": "0.0.0-4526",
22
+ "@docusaurus/plugin-content-docs": "0.0.0-4526",
23
+ "@docusaurus/plugin-content-pages": "0.0.0-4526",
24
24
  "clsx": "^1.1.1",
25
25
  "parse-numeric-range": "^1.3.0",
26
26
  "tslib": "^2.3.1",
27
27
  "utility-types": "^3.10.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@docusaurus/core": "0.0.0-4521",
31
- "@docusaurus/module-type-aliases": "0.0.0-4521",
32
- "@docusaurus/types": "0.0.0-4521",
30
+ "@docusaurus/core": "0.0.0-4526",
31
+ "@docusaurus/module-type-aliases": "0.0.0-4526",
32
+ "@docusaurus/types": "0.0.0-4526",
33
33
  "@testing-library/react-hooks": "^7.0.2",
34
34
  "fs-extra": "^10.0.0",
35
35
  "lodash": "^4.17.20"
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": ">=14"
45
45
  },
46
- "gitHead": "10eacaa44e87420d300c367fc5e1538c21485767"
46
+ "gitHead": "3086e9e823783e306698097d959007f44de275b1"
47
47
  }
@@ -67,7 +67,8 @@ function applyCollapsedStyle(el: HTMLElement, collapsed: boolean) {
67
67
  }
68
68
 
69
69
  /*
70
- Lex111: Dynamic transition duration is used in Material design, this technique is good for a large number of items.
70
+ Lex111: Dynamic transition duration is used in Material design, this technique
71
+ is good for a large number of items.
71
72
  https://material.io/archive/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
72
73
  https://github.com/mui-org/material-ui/blob/e724d98eba018e55e1a684236a2037e24bcf050c/packages/material-ui/src/styles/createTransitions.js#L40-L43
73
74
  */
@@ -151,7 +152,8 @@ type CollapsibleElementType = React.ElementType<
151
152
  Pick<React.HTMLAttributes<unknown>, 'className' | 'onTransitionEnd' | 'style'>
152
153
  >;
153
154
 
154
- // Prevent hydration layout shift before animations are handled imperatively with JS
155
+ // Prevent hydration layout shift before animations are handled imperatively
156
+ // with JS
155
157
  function getSSRStyle(collapsed: boolean) {
156
158
  if (ExecutionEnvironment.canUseDOM) {
157
159
  return undefined;
@@ -167,8 +169,9 @@ type CollapsibleBaseProps = {
167
169
  onCollapseTransitionEnd?: (collapsed: boolean) => void;
168
170
  className?: string;
169
171
 
170
- // This is mostly useful for details/summary component where ssrStyle is not needed (as details are hidden natively)
171
- // and can mess-up with the default native behavior of the browser when JS fails to load or is disabled
172
+ // This is mostly useful for details/summary component where ssrStyle is not
173
+ // needed (as details are hidden natively) and can mess up with the default
174
+ // native behavior of the browser when JS fails to load or is disabled
172
175
  disableSSRStyle?: boolean;
173
176
  };
174
177
 
@@ -189,7 +192,8 @@ function CollapsibleBase({
189
192
 
190
193
  return (
191
194
  <As
192
- // @ts-expect-error: the "too complicated type" is produced from "CollapsibleElementType" being a huge union
195
+ // @ts-expect-error: the "too complicated type" is produced from
196
+ // "CollapsibleElementType" being a huge union
193
197
  ref={collapsibleRef}
194
198
  style={disableSSRStyle ? undefined : getSSRStyle(collapsed)}
195
199
  onTransitionEnd={(e: React.TransitionEvent) => {
@@ -215,7 +219,7 @@ function CollapsibleLazy({collapsed, ...props}: CollapsibleBaseProps) {
215
219
  }
216
220
  }, [collapsed]);
217
221
 
218
- // lazyCollapsed updated in effect so that the first expansion transition can work
222
+ // lazyCollapsed updated in effect so that first expansion transition can work
219
223
  const [lazyCollapsed, setLazyCollapsed] = useState(collapsed);
220
224
  useLayoutEffect(() => {
221
225
  if (mounted) {
@@ -229,9 +233,10 @@ function CollapsibleLazy({collapsed, ...props}: CollapsibleBaseProps) {
229
233
  }
230
234
 
231
235
  type CollapsibleProps = CollapsibleBaseProps & {
232
- // Lazy allows to delay the rendering when collapsed => it will render children only after hydration, on first expansion
233
- // Required prop: it forces to think if content should be server-rendered or not!
234
- // This has perf impact on the SSR output and html file sizes
236
+ // Lazy allows to delay the rendering when collapsed => it will render
237
+ // children only after hydration, on first expansion
238
+ // Required prop: it forces to think if content should be server-rendered
239
+ // or not! This has perf impact on the SSR output and html file sizes
235
240
  // See https://github.com/facebook/docusaurus/issues/4753
236
241
  lazy: boolean;
237
242
  };
@@ -41,7 +41,7 @@ function Details({summary, children, ...props}: DetailsProps): JSX.Element {
41
41
  const {collapsed, setCollapsed} = useCollapsible({
42
42
  initialState: !props.open,
43
43
  });
44
- // We use a separate prop because it must be set only after animation completes
44
+ // Use a separate prop because it must be set only after animation completes
45
45
  // Otherwise close anim won't work
46
46
  const [open, setOpen] = useState(props.open);
47
47
 
@@ -15,7 +15,8 @@ const windowSizes = {
15
15
 
16
16
  // This "ssr" value is very important to handle hydration FOUC / layout shifts
17
17
  // You have to handle server-rendering explicitly on the call-site
18
- // On the server, you may need to render BOTH the mobile/desktop elements (and hide one of them with mediaquery)
18
+ // On the server, you may need to render BOTH the mobile/desktop elements (and
19
+ // hide one of them with mediaquery)
19
20
  // We don't return "undefined" on purpose, to make it more explicit
20
21
  ssr: 'ssr',
21
22
  } as const;
@@ -33,7 +34,8 @@ function getWindowSize() {
33
34
  : windowSizes.mobile;
34
35
  }
35
36
 
36
- // Simulate the SSR window size in dev, so that potential hydration FOUC/layout shift problems can be seen in dev too!
37
+ // Simulate the SSR window size in dev, so that potential hydration FOUC/layout
38
+ // shift problems can be seen in dev too!
37
39
  const DevSimulateSSR = process.env.NODE_ENV === 'development' && true;
38
40
 
39
41
  // This hook returns an enum value on purpose!
@@ -7,7 +7,8 @@
7
7
 
8
8
  // These class names are used to style page layouts in Docusaurus
9
9
  // Those are meant to be targeted by user-provided custom CSS selectors
10
- // /!\ Please do not modify the classnames! This is a breaking change, and annoying for users!
10
+ // Please do not modify the classnames! This is a breaking change, and annoying
11
+ // for users!
11
12
  export const ThemeClassNames = {
12
13
  page: {
13
14
  blogListPage: 'blog-list-page',
@@ -7,8 +7,8 @@
7
7
 
8
8
  import rangeParser from 'parse-numeric-range';
9
9
 
10
- const codeBlockTitleRegex = /title=(["'])(.*?)\1/;
11
- const highlightLinesRangeRegex = /{([\d,-]+)}/;
10
+ const codeBlockTitleRegex = /title=(?<quote>["'])(?<title>.*?)\1/;
11
+ const highlightLinesRangeRegex = /{(?<range>[\d,-]+)}/;
12
12
 
13
13
  const commentTypes = ['js', 'jsBlock', 'jsx', 'python', 'html'] as const;
14
14
  type CommentType = typeof commentTypes[number];
@@ -89,7 +89,7 @@ const magicCommentDirectiveRegex = (lang: string) => {
89
89
  };
90
90
 
91
91
  export function parseCodeBlockTitle(metastring?: string): string {
92
- return metastring?.match(codeBlockTitleRegex)?.[2] ?? '';
92
+ return metastring?.match(codeBlockTitleRegex)?.groups!.title ?? '';
93
93
  }
94
94
 
95
95
  export function parseLanguage(className: string): string | undefined {
@@ -114,7 +114,8 @@ export function parseLines(
114
114
  let code = content.replace(/\n$/, '');
115
115
  // Highlighted lines specified in props: don't parse the content
116
116
  if (metastring && highlightLinesRangeRegex.test(metastring)) {
117
- const highlightLinesRange = metastring.match(highlightLinesRangeRegex)![1];
117
+ const highlightLinesRange = metastring.match(highlightLinesRangeRegex)!
118
+ .groups!.range;
118
119
  const highlightLines = rangeParser(highlightLinesRange)
119
120
  .filter((n) => n > 0)
120
121
  .map((n) => n - 1);
@@ -76,10 +76,9 @@ function readStorageState({
76
76
  );
77
77
  if (versionExists) {
78
78
  return {preferredVersionName: preferredVersionNameUnsafe};
79
- } else {
80
- DocsPreferredVersionStorage.clear(pluginId, versionPersistence);
81
- return {preferredVersionName: null};
82
79
  }
80
+ DocsPreferredVersionStorage.clear(pluginId, versionPersistence);
81
+ return {preferredVersionName: null};
83
82
  }
84
83
 
85
84
  const initialState: DocsPreferredVersionState = {};
@@ -144,9 +143,8 @@ export function DocsPreferredVersionContextProvider({
144
143
  {children}
145
144
  </DocsPreferredVersionContextProviderUnsafe>
146
145
  );
147
- } else {
148
- return children;
149
146
  }
147
+ return children;
150
148
  }
151
149
 
152
150
  function DocsPreferredVersionContextProviderUnsafe({
@@ -20,7 +20,7 @@ import {useLocation} from '@docusaurus/router';
20
20
  // TODO not ideal, see also "useDocs"
21
21
  export const isDocsPluginEnabled: boolean = !!useAllDocsData;
22
22
 
23
- // Using a Symbol because null is a valid context value (a doc can have no sidebar)
23
+ // Using a Symbol because null is a valid context value (a doc with no sidebar)
24
24
  // Inspired by https://github.com/jamiebuilds/unstated-next/blob/master/src/unstated-next.tsx
25
25
  const EmptyContextValue: unique symbol = Symbol('EmptyContext');
26
26
 
@@ -101,11 +101,10 @@ export function findSidebarCategory(
101
101
  if (item.type === 'category') {
102
102
  if (predicate(item)) {
103
103
  return item;
104
- } else {
105
- const subItem = findSidebarCategory(item.items, predicate);
106
- if (subItem) {
107
- return subItem;
108
- }
104
+ }
105
+ const subItem = findSidebarCategory(item.items, predicate);
106
+ if (subItem) {
107
+ return subItem;
109
108
  }
110
109
  }
111
110
  }
@@ -11,9 +11,10 @@ import type {Location, Action} from '@docusaurus/history';
11
11
 
12
12
  type HistoryBlockHandler = (location: Location, action: Action) => void | false;
13
13
 
14
- /*
15
- Permits to register a handler that will be called on history actions (pop,push,replace)
16
- If the handler returns false, the navigation transition will be blocked/cancelled
14
+ /**
15
+ * Permits to register a handler that will be called on history actions (pop,
16
+ * push, replace) If the handler returns false, the navigation transition will
17
+ * be blocked/cancelled
17
18
  */
18
19
  export function useHistoryActionHandler(handler: HistoryBlockHandler): void {
19
20
  const {block} = useHistory();
@@ -32,11 +33,11 @@ export function useHistoryActionHandler(handler: HistoryBlockHandler): void {
32
33
  );
33
34
  }
34
35
 
35
- /*
36
- Permits to register a handler that will be called on history pop navigation (backward/forward)
37
- If the handler returns false, the backward/forward transition will be blocked
38
-
39
- Unfortunately there's no good way to detect the "direction" (backward/forward) of the POP event.
36
+ /**
37
+ * Permits to register a handler that will be called on history pop navigation
38
+ * (backward/forward) If the handler returns false, the backward/forward
39
+ * transition will be blocked. Unfortunately there's no good way to detect the
40
+ * "direction" (backward/forward) of the POP event.
40
41
  */
41
42
  export function useHistoryPopHandler(handler: HistoryBlockHandler): void {
42
43
  useHistoryActionHandler((location, action) => {
@@ -10,8 +10,11 @@
10
10
  /**
11
11
  * Gets the duplicate values in an array.
12
12
  * @param arr The array.
13
- * @param comparator Compares two values and returns `true` if they are equal (duplicated).
14
- * @returns Value of the elements `v` that have a preceding element `u` where `comparator(u, v) === true`. Values within the returned array are not guaranteed to be unique.
13
+ * @param comparator Compares two values and returns `true` if they are equal
14
+ * (duplicated).
15
+ * @returns Value of the elements `v` that have a preceding element `u` where
16
+ * `comparator(u, v) === true`. Values within the returned array are not
17
+ * guaranteed to be unique.
15
18
  */
16
19
  export function duplicates<T>(
17
20
  arr: readonly T[],
@@ -16,12 +16,13 @@ import React, {
16
16
  } from 'react';
17
17
 
18
18
  /*
19
- The idea behind all this is that a specific component must be able to fill a placeholder in the generic layout
20
- The doc page should be able to fill the secondary menu of the main mobile navbar.
21
- This permits to reduce coupling between the main layout and the specific page.
19
+ The idea behind all this is that a specific component must be able to fill a
20
+ placeholder in the generic layout. The doc page should be able to fill the
21
+ secondary menu of the main mobile navbar. This permits to reduce coupling
22
+ between the main layout and the specific page.
22
23
 
23
- This kind of feature is often called portal/teleport/gateway... various unmaintained React libs exist
24
- Most up-to-date one: https://github.com/gregberge/react-teleporter
24
+ This kind of feature is often called portal/teleport/gateway... various
25
+ unmaintained React libs exist. Most up-to-date one: https://github.com/gregberge/react-teleporter
25
26
  Not sure any of those is safe regarding concurrent mode.
26
27
  */
27
28