dumi 2.2.5 → 2.2.7
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/compiled/_internal/searchWorker.min.js +1 -1
- package/dist/client/theme-api/useNavData.js +2 -1
- package/dist/client/theme-api/useSidebarData.d.ts +2 -1
- package/dist/client/theme-api/useSidebarData.js +1 -1
- package/dist/features/routes.js +8 -10
- package/package.json +1 -1
- package/theme-default/builtins/API/index.js +2 -0
- package/theme-default/builtins/SourceCode/index.js +13 -2
- package/theme-default/layouts/DocLayout/index.js +1 -1
- package/theme-default/slots/ColorSwitch/index.less +5 -4
- package/theme-default/slots/Toc/index.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var P=Object.create;var I=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,B=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var O=(e,t,i)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,M=(e,t)=>{for(var i in t||(t={}))E.call(t,i)&&O(e,i,t[i]);if(R)for(var i of R(t))L.call(t,i)&&O(e,i,t[i]);return e};var F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var N=(e,t,i,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of D(t))!E.call(e,a)&&a!==i&&I(e,a,{get:()=>t[a],enumerable:!(h=z(t,a))||h.enumerable});return e};var W=(e,t,i)=>(i=e!=null?P(B(e)):{},N(t||!e||!e.__esModule?I(i,"default",{value:e,enumerable:!0}):i,e));var j=F((K,w)=>{w.exports=function(e){var t={};function i(h){if(t[h])return t[h].exports;var a=t[h]={exports:{},id:h,loaded:!1};return e[h].call(a.exports,a,a.exports,i),a.loaded=!0,a.exports}return i.m=e,i.c=t,i.p="",i(0)}([function(e,t,i){e.exports=i(1)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var h=i(2);Object.defineProperty(t,"combineChunks",{enumerable:!0,get:function(){return h.combineChunks}}),Object.defineProperty(t,"fillInChunks",{enumerable:!0,get:function(){return h.fillInChunks}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return h.findAll}}),Object.defineProperty(t,"findChunks",{enumerable:!0,get:function(){return h.findChunks}})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=t.findAll=function(s){var n=s.autoEscape,
|
|
1
|
+
"use strict";(()=>{var P=Object.create;var I=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,B=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var O=(e,t,i)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,M=(e,t)=>{for(var i in t||(t={}))E.call(t,i)&&O(e,i,t[i]);if(R)for(var i of R(t))L.call(t,i)&&O(e,i,t[i]);return e};var F=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var N=(e,t,i,h)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of D(t))!E.call(e,a)&&a!==i&&I(e,a,{get:()=>t[a],enumerable:!(h=z(t,a))||h.enumerable});return e};var W=(e,t,i)=>(i=e!=null?P(B(e)):{},N(t||!e||!e.__esModule?I(i,"default",{value:e,enumerable:!0}):i,e));var j=F((K,w)=>{w.exports=function(e){var t={};function i(h){if(t[h])return t[h].exports;var a=t[h]={exports:{},id:h,loaded:!1};return e[h].call(a.exports,a,a.exports,i),a.loaded=!0,a.exports}return i.m=e,i.c=t,i.p="",i(0)}([function(e,t,i){e.exports=i(1)},function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var h=i(2);Object.defineProperty(t,"combineChunks",{enumerable:!0,get:function(){return h.combineChunks}}),Object.defineProperty(t,"fillInChunks",{enumerable:!0,get:function(){return h.fillInChunks}}),Object.defineProperty(t,"findAll",{enumerable:!0,get:function(){return h.findAll}}),Object.defineProperty(t,"findChunks",{enumerable:!0,get:function(){return h.findChunks}})},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=t.findAll=function(s){var n=s.autoEscape,g=s.caseSensitive,f=g===void 0?!1:g,p=s.findChunks,u=p===void 0?a:p,c=s.sanitize,v=s.searchWords,T=s.textToHighlight;return l({chunksToHighlight:h({chunks:u({autoEscape:n,caseSensitive:f,sanitize:c,searchWords:v,textToHighlight:T})}),totalLength:T?T.length:0})},h=t.combineChunks=function(s){var n=s.chunks;return n=n.sort(function(g,f){return g.start-f.start}).reduce(function(g,f){if(g.length===0)return[f];var p=g.pop();if(f.start<=p.end){var u=Math.max(p.end,f.end);g.push({highlight:!1,start:p.start,end:u})}else g.push(p,f);return g},[]),n},a=function(s){var n=s.autoEscape,g=s.caseSensitive,f=s.sanitize,p=f===void 0?d:f,u=s.searchWords,c=s.textToHighlight;return c=p(c),u.filter(function(v){return v}).reduce(function(v,T){T=p(T),n&&(T=r(T));for(var m=new RegExp(T,g?"g":"gi"),x=void 0;x=m.exec(c);){var S=x.index,$=m.lastIndex;$>S&&v.push({highlight:!1,start:S,end:$}),x.index===m.lastIndex&&m.lastIndex++}return v},[])};t.findChunks=a;var l=t.fillInChunks=function(s){var n=s.chunksToHighlight,g=s.totalLength,f=[],p=function(v,T,m){T-v>0&&f.push({start:v,end:T,highlight:m})};if(n.length===0)p(0,g,!1);else{var u=0;n.forEach(function(c){p(u,c.start,!1),p(c.start,c.end,!0),u=c.end}),p(u,g,!1)}return f};function d(o){return o}function r(o){return o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}}])});var C=W(j());var H="tab";function k(e,t,i,h,a){let l=a!==void 0;return h.reduce((r,o)=>(o.tocIndex===a&&(r[o.paraId]=(r[o.paraId]||"").concat(o.value)),r),[]).filter(Boolean).length||l?{rawTitle:e,title:t,link:i,paragraphs:h.reduce((r,o)=>{var s,n;return o.tocIndex===a&&((n=r[s=o.paraId])!=null||(r[s]=""),r[o.paraId]+=o.value),r},[]).filter(Boolean)}:null}function y(e){return[e.title,e.subtitle].filter(Boolean).join(" ")}function _(e,t,i){let h=[],a=Object.values(t).reduce((l,d)=>{var r,o;return d.asset&&((o=l[r=d.routeId])!=null||(l[r]=[]),l[d.routeId].push(d)),l},{});return Object.values(e).forEach(l=>{var d;if("meta"in l&&!("isLayout"in l)){let r=l.meta,o=l.path.replace(/^([^/])/,"/$1")||"/",s=i.find(u=>o===u.link||o.startsWith(`${u.activePath}/`)),n=(a[l.id]||[]).map(u=>{var c;return(c=u.asset)==null?void 0:c.id}),g=k("",y(r.frontmatter),o,r.texts),f=r.toc.reduce((u,c,v)=>{if(!n.includes(c.id)&&c.depth>=1){let T=y(r.frontmatter);c.depth!==1&&(T=`${T} - ${c.title}`),u.push(k(c.title,T,`${o}#${c.id}`,r.texts,v))}return u},[]),p=(r.tabs||[]).reduce((u,{key:c,meta:v})=>{let T=k("",`${y(r.frontmatter)} - ${v.frontmatter.title}`,`${o}?${H}=${c}`,v.texts);return T&&u.push(T),u.push(...v.toc.map((m,x)=>k(m.title,`${y(r.frontmatter)} - ${v.frontmatter.title} - ${m.title}`,`${o}?${H}=${c}#${m.id}`,v.texts,x))),u},[]);h.push({navTitle:s==null?void 0:s.title,navOrder:s?i.indexOf(s):1/0,title:y(r.frontmatter),link:o,sections:[...g?[g]:[],...f,...p],demos:((d=a[l.id])==null?void 0:d.map(u=>({link:`${o}#${u.asset.id}`,rawTitle:u.asset.title||"",title:u.asset.title||y(r.frontmatter),description:u.asset.description||"",keywords:u.asset.keywords||[]})))||[]})}}),h}function b(e="",t,i=1){let h=(0,C.findAll)({textToHighlight:e,searchWords:t,autoEscape:!0}),a={};return[h.map(({start:l,end:d,highlight:r},o)=>{let s={text:e.slice(l,d)};return o===0&&!r&&h.length>1&&s.text.length>20&&(s.text=`...${s.text.slice(-20)}`),r&&(s.highlighted=!0,a[t.find(n=>s.text.includes(n))]=i),s}),a]}function Y(e,t){let i=t.split(" "),h=new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\s+/g,"|"),"i"),a={};return e.forEach(l=>{var o,s;let d=l.title,r=[];if(l.sections.forEach(n=>{for(let g of n.paragraphs)if(h.test(g)){let[f,p]=b(n.title,i,10),[u,c]=b(g,i);r.push({type:"content",link:n.link,priority:Object.values(M(M({},c),p)).reduce((v,T)=>v+T,0),highlightTitleTexts:f,highlightTexts:u,pageTitle:d});return}if(h.test(n.rawTitle)&&!h.test(l.title)){let[g,f]=b(n.title,i,10);r.push({type:"title",link:n.link,priority:Object.values(f).reduce((p,u)=>p+u,0),highlightTitleTexts:g,highlightTexts:b(n.paragraphs[0]||"",i)[0],pageTitle:d})}}),l.demos.forEach(n=>{if(h.test(n.rawTitle)||h.test(n.description)){let[g,f]=b(n.title,i,10),[p,u]=b(n.description,i);r.push({type:"demo",link:n.link,priority:Object.values(M(M({},u),f)).reduce((c,v)=>c+v,0),highlightTitleTexts:g,highlightTexts:p,pageTitle:d})}}),h.test(l.title)){let[n,g]=b(l.title,i,100);r.push({type:"page",link:l.link,priority:Object.values(g).reduce((f,p)=>f+p,0),highlightTitleTexts:n,highlightTexts:b(((o=l.sections[0])==null?void 0:o.paragraphs[0])||"",i)[0],pageTitle:d})}if(r.length){let n=l.navTitle||"$ROOT";(s=a[n])!=null||(a[n]={title:l.navTitle,priority:l.navOrder*1e3,hints:[]}),a[n].hints.push(...r)}}),Object.values(a).forEach(({hints:l})=>{l.sort((d,r)=>r.priority-d.priority)}),Object.values(a).sort((l,d)=>d.priority-l.priority)}var A;self.onmessage=({data:e})=>{switch(e.action){case"generate-metadata":A=_(e.args.routes,e.args.demos,e.args.nav);break;case"get-search-result":self.postMessage(Y(A,e.args.keywords));break;default:}};})();
|
|
@@ -16,6 +16,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
16
16
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
17
|
import { useFullSidebarData, useLocale, useSiteData } from 'dumi';
|
|
18
18
|
import { useState } from 'react';
|
|
19
|
+
import { getLocaleClearPath } from "./useSidebarData";
|
|
19
20
|
import { getLocaleNav, pickRouteSortMeta, useLocaleDocRoutes, useRouteDataComparer } from "./utils";
|
|
20
21
|
function genNavItem(meta, groups, activePath, link) {
|
|
21
22
|
return _objectSpread({
|
|
@@ -69,7 +70,7 @@ export var useNavData = function useNavData() {
|
|
|
69
70
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
70
71
|
link = _ref6[0],
|
|
71
72
|
groups = _ref6[1];
|
|
72
|
-
var _ref7 = link.match(/^(\/[^/]+)([^]+)?$/),
|
|
73
|
+
var _ref7 = "/".concat(getLocaleClearPath(link.replace(/^\//, ''), locale)).match(/^(\/[^/]+)([^]+)?$/),
|
|
73
74
|
_ref8 = _slicedToArray(_ref7, 3),
|
|
74
75
|
parentPath = _ref8[1],
|
|
75
76
|
restPath = _ref8[2];
|
|
@@ -19,7 +19,7 @@ import { useLocale, useLocation, useRouteMeta, useSiteData } from 'dumi';
|
|
|
19
19
|
import { useState } from 'react';
|
|
20
20
|
import { pickRouteSortMeta, useLocaleDocRoutes, useRouteDataComparer } from "./utils";
|
|
21
21
|
var DEFAULT_GROUP_STUB_TITLE = '$default-group-title';
|
|
22
|
-
var getLocaleClearPath = function getLocaleClearPath(routePath, locale) {
|
|
22
|
+
export var getLocaleClearPath = function getLocaleClearPath(routePath, locale) {
|
|
23
23
|
return 'base' in locale ? routePath.replace(locale.base.slice(1), '').replace(/^\//, '') : routePath;
|
|
24
24
|
};
|
|
25
25
|
|
package/dist/features/routes.js
CHANGED
|
@@ -88,21 +88,19 @@ function getAliasLayoutFile({
|
|
|
88
88
|
return `${alias}/${specifier}`;
|
|
89
89
|
}
|
|
90
90
|
var routes_default = (api) => {
|
|
91
|
-
var _a, _b, _c;
|
|
92
|
-
const extraWatchPaths = [
|
|
93
|
-
...((_a = api.userConfig.resolve) == null ? void 0 : _a.atomDirs) || [],
|
|
94
|
-
...((_c = (_b = api.userConfig.resolve) == null ? void 0 : _b.docDirs) == null ? void 0 : _c.map(normalizeDocDir)) || [
|
|
95
|
-
{ dir: "docs" }
|
|
96
|
-
]
|
|
97
|
-
].map(({ dir }) => import_path.default.join(api.cwd, dir, "**/*.md"));
|
|
98
91
|
api.describe({ key: "dumi:routes" });
|
|
99
|
-
api.addTmpGenerateWatcherPaths(
|
|
92
|
+
api.addTmpGenerateWatcherPaths(
|
|
93
|
+
() => [
|
|
94
|
+
...api.config.resolve.atomDirs,
|
|
95
|
+
...api.config.resolve.docDirs.map(normalizeDocDir)
|
|
96
|
+
].map(({ dir }) => import_path.default.join(api.cwd, dir, "**/*.md"))
|
|
97
|
+
);
|
|
100
98
|
api.modifyDefaultConfig((memo) => {
|
|
101
99
|
if (api.userConfig.resolve) {
|
|
102
100
|
const keys = ["docDirs", "atomDirs"];
|
|
103
101
|
keys.forEach((key) => {
|
|
104
|
-
var
|
|
105
|
-
if (((
|
|
102
|
+
var _a;
|
|
103
|
+
if (((_a = api.userConfig.resolve[key]) == null ? void 0 : _a.length) === 0)
|
|
106
104
|
memo.resolve[key] = [];
|
|
107
105
|
});
|
|
108
106
|
}
|
package/package.json
CHANGED
|
@@ -69,6 +69,8 @@ var HANDLERS = {
|
|
|
69
69
|
function: function _function(_ref3) {
|
|
70
70
|
var _this2 = this;
|
|
71
71
|
var signature = _ref3.signature;
|
|
72
|
+
// handle Function type without signature
|
|
73
|
+
if (!signature) return 'Function';
|
|
72
74
|
var signatures = 'oneOf' in signature ? signature.oneOf : [signature];
|
|
73
75
|
return signatures.map(function (signature) {
|
|
74
76
|
return "".concat(signature.isAsync ? 'async ' : '', "(").concat(signature.arguments.map(function (arg) {
|
|
@@ -11,7 +11,7 @@ import classNames from 'classnames';
|
|
|
11
11
|
import { useSiteData } from 'dumi';
|
|
12
12
|
import Highlight, { defaultProps } from 'prism-react-renderer';
|
|
13
13
|
import 'prism-themes/themes/prism-one-light.css';
|
|
14
|
-
import React, { useRef, useState } from 'react';
|
|
14
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
15
15
|
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
16
16
|
import "./index.less";
|
|
17
17
|
|
|
@@ -33,12 +33,23 @@ var SourceCode = function SourceCode(props) {
|
|
|
33
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
34
34
|
isCopied = _useState2[0],
|
|
35
35
|
setIsCopied = _useState2[1];
|
|
36
|
+
var _useState3 = useState(children),
|
|
37
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
38
|
+
text = _useState4[0],
|
|
39
|
+
setText = _useState4[1];
|
|
36
40
|
var _useSiteData = useSiteData(),
|
|
37
41
|
themeConfig = _useSiteData.themeConfig;
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
var isShell = /shellscript|shell|bash|sh|zsh/.test(lang);
|
|
44
|
+
if (isShell) {
|
|
45
|
+
var _text = children.replace(/^(\$|>)\s/gm, '');
|
|
46
|
+
setText(_text);
|
|
47
|
+
}
|
|
48
|
+
}, [lang, children]);
|
|
38
49
|
return /*#__PURE__*/React.createElement("div", {
|
|
39
50
|
className: "dumi-default-source-code"
|
|
40
51
|
}, /*#__PURE__*/React.createElement(CopyToClipboard, {
|
|
41
|
-
text:
|
|
52
|
+
text: text,
|
|
42
53
|
onCopy: function onCopy() {
|
|
43
54
|
setIsCopied(true);
|
|
44
55
|
clearTimeout(timer.current);
|
|
@@ -4,11 +4,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import ContentFooter from "../../slots/ContentFooter";
|
|
8
7
|
import { ReactComponent as IconSidebar } from '@ant-design/icons-svg/inline-svg/outlined/align-left.svg';
|
|
9
8
|
import animateScrollTo from 'animated-scroll-to';
|
|
10
9
|
import { Helmet, useIntl, useLocation, useOutlet, useRouteMeta, useSidebarData, useSiteData } from 'dumi';
|
|
11
10
|
import Content from 'dumi/theme/slots/Content';
|
|
11
|
+
import ContentFooter from 'dumi/theme/slots/ContentFooter';
|
|
12
12
|
import Features from 'dumi/theme/slots/Features';
|
|
13
13
|
import Footer from 'dumi/theme/slots/Footer';
|
|
14
14
|
import Header from 'dumi/theme/slots/Header';
|
|
@@ -46,7 +46,7 @@ var Toc = function Toc() {
|
|
|
46
46
|
});
|
|
47
47
|
setSectionRefs(refs);
|
|
48
48
|
}
|
|
49
|
-
}, [pathname, search, loading]);
|
|
49
|
+
}, [pathname, search, loading, memoToc]);
|
|
50
50
|
return sectionRefs.length ? /*#__PURE__*/React.createElement(ScrollSpy, {
|
|
51
51
|
sectionRefs: sectionRefs
|
|
52
52
|
}, function (_ref3) {
|