@brillout/docpress 0.15.10-commit-ef0b9a0 → 0.15.10-commit-e9efbd3

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/dist/utils/cls.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { cls };
2
2
  function cls(className) {
3
- const classNames = Array.isArray(className) ? className : [className];
3
+ var classNames = Array.isArray(className) ? className : [className];
4
4
  return classNames.filter(Boolean).join(' ');
5
5
  }
@@ -4,7 +4,7 @@ export { determineSectionTitle };
4
4
  function determineSectionUrlHash(title) {
5
5
  title = title.toLowerCase();
6
6
  title = removeAccentsAndDiacritics(title);
7
- const urlHash = title
7
+ var urlHash = title
8
8
  // \u4E00-\u9FA5 are chinese characters, see https://github.com/brillout/docpress/pull/2
9
9
  .split(/[^a-z0-9\u4E00-\u9FA5]+/)
10
10
  .filter(Boolean)
@@ -20,11 +20,11 @@ function removeAccentsAndDiacritics(str) {
20
20
  return str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
21
21
  }
22
22
  function determineSectionTitle(urlWithHash) {
23
- assert(urlWithHash.includes('#'), { urlWithHash });
24
- const urlHash = urlWithHash.split('#')[1];
25
- const title = urlHash
23
+ assert(urlWithHash.includes('#'), { urlWithHash: urlWithHash });
24
+ var urlHash = urlWithHash.split('#')[1];
25
+ var title = urlHash
26
26
  .split('-')
27
- .map((word, i) => {
27
+ .map(function (word, i) {
28
28
  if (i === 0) {
29
29
  return capitalizeFirstLetter(word);
30
30
  }
@@ -1,8 +1,8 @@
1
1
  export { filter };
2
2
  // https://stackoverflow.com/questions/66341757/typescript-how-to-filter-the-object
3
3
  function filter(obj, predicate) {
4
- const result = {};
5
- Object.keys(obj).forEach((name) => {
4
+ var result = {};
5
+ Object.keys(obj).forEach(function (name) {
6
6
  if (predicate(obj[name], name)) {
7
7
  result[name] = obj[name];
8
8
  }
@@ -2,8 +2,8 @@ export function getGlobalObject(
2
2
  // We use the filename as key; each `getGlobalObject()` call should live inside a file with a unique filename.
3
3
  key, defaultValue) {
4
4
  // @ts-ignore
5
- const globalObjectsAll = (globalThis[projectKey] = globalThis[projectKey] || {});
6
- const globalObject = (globalObjectsAll[key] = globalObjectsAll[key] || defaultValue);
5
+ var globalObjectsAll = (globalThis[projectKey] = globalThis[projectKey] || {});
6
+ var globalObject = (globalObjectsAll[key] = globalObjectsAll[key] || defaultValue);
7
7
  return globalObject;
8
8
  }
9
- const projectKey = '_docpress';
9
+ var projectKey = '_docpress';
@@ -1,20 +1,21 @@
1
1
  export { useSelectedLanguage };
2
2
  import { useState, useEffect, useCallback } from 'react';
3
- const key = 'docpress:selectedLang';
4
- const defaultSsrLang = 'ts';
5
- const defaultClientLang = 'js';
3
+ var key = 'docpress:selectedLang';
4
+ var defaultSsrLang = 'ts';
5
+ var defaultClientLang = 'js';
6
6
  function useSelectedLanguage() {
7
- const [selectedLang, setSelectedLang] = useState(defaultSsrLang);
8
- const getValue = () => {
7
+ var _a = useState(defaultSsrLang), selectedLang = _a[0], setSelectedLang = _a[1];
8
+ var getValue = function () {
9
+ var _a;
9
10
  try {
10
- return localStorage.getItem(key) ?? defaultClientLang;
11
+ return (_a = localStorage.getItem(key)) !== null && _a !== void 0 ? _a : defaultClientLang;
11
12
  }
12
13
  catch (error) {
13
14
  console.warn('Error reading from localStorage:', error);
14
15
  return defaultClientLang;
15
16
  }
16
17
  };
17
- const setValue = useCallback((value) => {
18
+ var setValue = useCallback(function (value) {
18
19
  try {
19
20
  window.localStorage.setItem(key, value);
20
21
  setSelectedLang(value);
@@ -24,22 +25,22 @@ function useSelectedLanguage() {
24
25
  console.warn('Error setting localStorage:', error);
25
26
  }
26
27
  }, []);
27
- useEffect(() => {
28
+ useEffect(function () {
28
29
  // Initial load from localStorage
29
30
  setSelectedLang(getValue());
30
31
  // Update language in current tab
31
- const handleCustomEvent = () => {
32
+ var handleCustomEvent = function () {
32
33
  setSelectedLang(getValue());
33
34
  };
34
35
  // Update language if changed in another tab
35
- const handleNativeStorage = (event) => {
36
+ var handleNativeStorage = function (event) {
36
37
  if (event.key === key) {
37
38
  setSelectedLang(getValue());
38
39
  }
39
40
  };
40
41
  window.addEventListener('lang-storage', handleCustomEvent);
41
42
  window.addEventListener('storage', handleNativeStorage);
42
- return () => {
43
+ return function () {
43
44
  window.removeEventListener('lang-storage', handleCustomEvent);
44
45
  window.removeEventListener('storage', handleNativeStorage);
45
46
  };
@@ -6,16 +6,16 @@ import { detypePlugin } from './detypePlugin.js';
6
6
  import rehypePrettyCode from 'rehype-pretty-code';
7
7
  import remarkGfm from 'remark-gfm';
8
8
  import { transformerNotationDiff } from '@shikijs/transformers';
9
- const root = process.cwd();
10
- const prettyCode = [rehypePrettyCode, { theme: 'github-light', transformers: [transformerNotationDiff()] }];
11
- const rehypePlugins = [prettyCode];
12
- const remarkPlugins = [remarkGfm];
13
- const config = {
14
- root,
9
+ var root = process.cwd();
10
+ var prettyCode = [rehypePrettyCode, { theme: 'github-light', transformers: [transformerNotationDiff()] }];
11
+ var rehypePlugins = [prettyCode];
12
+ var remarkPlugins = [remarkGfm];
13
+ var config = {
14
+ root: root,
15
15
  plugins: [
16
16
  parsePageSections(),
17
17
  detypePlugin(),
18
- mdx({ rehypePlugins, remarkPlugins }),
18
+ mdx({ rehypePlugins: rehypePlugins, remarkPlugins: remarkPlugins }),
19
19
  // @vitejs/plugin-react-swc needs to be added *after* the mdx plugins
20
20
  react(),
21
21
  ],
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.15.10-commit-ef0b9a0",
3
+ "version": "0.15.10-commit-e9efbd3",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
7
- "detype": "^1.1.2",
8
7
  "@docsearch/css": "3.9.0",
9
8
  "@docsearch/react": "3.9.0",
10
9
  "@mdx-js/mdx": "3.0.1",
@@ -12,6 +11,7 @@
12
11
  "@mdx-js/rollup": "3.0.1",
13
12
  "@shikijs/transformers": "1.2.0",
14
13
  "@vitejs/plugin-react-swc": "^3.10.2",
14
+ "detype": "^1.1.2",
15
15
  "rehype-pretty-code": "0.13.0",
16
16
  "remark-gfm": "4.0.0",
17
17
  "shiki": "1.2.0",
package/tsconfig.json CHANGED
@@ -3,7 +3,6 @@
3
3
  "outDir": "./dist/",
4
4
  "jsx": "react",
5
5
  "module": "ES2020",
6
- "target": "ES2020",
7
6
  "moduleResolution": "Bundler",
8
7
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
9
8
  "types": ["vite/client"],