dumi 2.2.4 → 2.2.6
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/compiled/crates/swc_plugin_react_demo.wasm +0 -0
- package/dist/client/theme-api/types.d.ts +1 -1
- package/dist/client/theme-api/useTabMeta.js +1 -1
- package/dist/features/routes.js +8 -10
- package/dist/features/theme/index.js +1 -1
- package/package.json +43 -44
- package/theme-default/builtins/SourceCode/index.js +13 -2
- package/theme-default/builtins/Tree/index.d.ts +2 -1
- package/theme-default/slots/SearchBar/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:}};})();
|
|
Binary file
|
|
@@ -175,7 +175,7 @@ export type INavItems = (INavItem & {
|
|
|
175
175
|
children?: INavItem[];
|
|
176
176
|
})[];
|
|
177
177
|
export type INav = INavItems | Record<string, INavItems>;
|
|
178
|
-
type IUserNavItem = Pick<INavItem, 'title' | 'link'>;
|
|
178
|
+
type IUserNavItem = Pick<INavItem, 'title' | 'link' | 'activePath'>;
|
|
179
179
|
export type IUserNavMode = 'override' | 'append' | 'prepend';
|
|
180
180
|
export type IUserNavItems = (IUserNavItem & {
|
|
181
181
|
children?: IUserNavItem[];
|
|
@@ -17,7 +17,7 @@ export var useTabQueryState = function useTabQueryState() {
|
|
|
17
17
|
if (val) params.set(TAB_QUERY_KEY, val);else params.delete(TAB_QUERY_KEY);
|
|
18
18
|
history.push({
|
|
19
19
|
pathname: pathname,
|
|
20
|
-
search: params.toString()
|
|
20
|
+
search: "?".concat(params.toString())
|
|
21
21
|
});
|
|
22
22
|
}, [params]);
|
|
23
23
|
return [params.get(TAB_QUERY_KEY), setTabQueryState];
|
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
|
}
|
|
@@ -296,7 +296,7 @@ const entryExports = {
|
|
|
296
296
|
|
|
297
297
|
export default function DumiContextWrapper() {
|
|
298
298
|
const outlet = useOutlet();
|
|
299
|
-
const [loading, setLoading] = useState(
|
|
299
|
+
const [loading, setLoading] = useState(false);
|
|
300
300
|
const prev = useRef(history.location.pathname);
|
|
301
301
|
|
|
302
302
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -78,37 +78,36 @@
|
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@ant-design/icons-svg": "^4.2.1",
|
|
80
80
|
"@makotot/ghostui": "^2.0.0",
|
|
81
|
-
"@stackblitz/sdk": "^1.
|
|
82
|
-
"@swc/core": "1.3.
|
|
83
|
-
"@types/hast": "^2.3.
|
|
84
|
-
"@types/mdast": "^3.0.
|
|
85
|
-
"@types/nprogress": "^0.2.0",
|
|
81
|
+
"@stackblitz/sdk": "^1.9.0",
|
|
82
|
+
"@swc/core": "1.3.72",
|
|
83
|
+
"@types/hast": "^2.3.5",
|
|
84
|
+
"@types/mdast": "^3.0.12",
|
|
86
85
|
"@umijs/bundler-utils": "^4.0.73",
|
|
87
86
|
"@umijs/core": "^4.0.73",
|
|
88
87
|
"animated-scroll-to": "^2.3.0",
|
|
89
88
|
"classnames": "2.3.2",
|
|
90
89
|
"codesandbox": "^2.2.3",
|
|
91
90
|
"copy-to-clipboard": "^3.3.3",
|
|
92
|
-
"deepmerge": "^4.
|
|
91
|
+
"deepmerge": "^4.3.1",
|
|
93
92
|
"dumi-afx-deps": "^1.0.0-alpha.19",
|
|
94
93
|
"dumi-assets-types": "2.0.0-alpha.0",
|
|
95
|
-
"enhanced-resolve": "^5.
|
|
96
|
-
"estree-util-to-js": "^1.
|
|
97
|
-
"estree-util-visit": "^1.2.
|
|
98
|
-
"file-system-cache": "^2.
|
|
99
|
-
"github-slugger": "^1.
|
|
100
|
-
"hast-util-is-element": "^2.1.
|
|
101
|
-
"hast-util-raw": "^
|
|
102
|
-
"hast-util-to-estree": "^2.
|
|
94
|
+
"enhanced-resolve": "^5.15.0",
|
|
95
|
+
"estree-util-to-js": "^1.2.0",
|
|
96
|
+
"estree-util-visit": "^1.2.1",
|
|
97
|
+
"file-system-cache": "^2.4.3",
|
|
98
|
+
"github-slugger": "^1.5.0",
|
|
99
|
+
"hast-util-is-element": "^2.1.3",
|
|
100
|
+
"hast-util-raw": "^8.0.0",
|
|
101
|
+
"hast-util-to-estree": "^2.3.3",
|
|
103
102
|
"hast-util-to-string": "^2.0.0",
|
|
104
|
-
"heti": "^0.9.
|
|
103
|
+
"heti": "^0.9.4",
|
|
105
104
|
"hosted-git-info": "^6.1.1",
|
|
106
|
-
"html-to-text": "^
|
|
107
|
-
"html2sketch": "^1.0.
|
|
105
|
+
"html-to-text": "^9.0.5",
|
|
106
|
+
"html2sketch": "^1.0.2",
|
|
108
107
|
"js-yaml": "^4.1.0",
|
|
109
108
|
"lodash.throttle": "^4.1.1",
|
|
110
109
|
"mdast-util-find-and-replace": "^2.2.2",
|
|
111
|
-
"mdast-util-to-string": "^3.
|
|
110
|
+
"mdast-util-to-string": "^3.2.0",
|
|
112
111
|
"nprogress": "^0.2.0",
|
|
113
112
|
"pluralize": "^8.0.0",
|
|
114
113
|
"prism-react-renderer": "^1.3.5",
|
|
@@ -116,58 +115,58 @@
|
|
|
116
115
|
"prismjs": "^1.29.0",
|
|
117
116
|
"raw-loader": "^4.0.2",
|
|
118
117
|
"rc-motion": "^2.7.3",
|
|
119
|
-
"rc-tabs": "^12.
|
|
120
|
-
"rc-tree": "^5.7.
|
|
118
|
+
"rc-tabs": "^12.10.0",
|
|
119
|
+
"rc-tree": "^5.7.9",
|
|
121
120
|
"react-copy-to-clipboard": "^5.1.0",
|
|
122
|
-
"react-error-boundary": "^
|
|
123
|
-
"react-intl": "^6.
|
|
121
|
+
"react-error-boundary": "^4.0.10",
|
|
122
|
+
"react-intl": "^6.4.4",
|
|
124
123
|
"rehype-autolink-headings": "^6.1.1",
|
|
125
124
|
"rehype-remove-comments": "^5.0.0",
|
|
126
125
|
"rehype-stringify": "^9.0.3",
|
|
127
126
|
"remark-directive": "^2.0.1",
|
|
128
127
|
"remark-frontmatter": "^4.0.1",
|
|
129
128
|
"remark-gfm": "^3.0.1",
|
|
130
|
-
"remark-parse": "^10.0.
|
|
129
|
+
"remark-parse": "^10.0.2",
|
|
131
130
|
"remark-rehype": "^10.1.0",
|
|
132
|
-
"sass": "^1.
|
|
131
|
+
"sass": "^1.64.1",
|
|
133
132
|
"sitemap": "^7.1.1",
|
|
134
133
|
"umi": "^4.0.73",
|
|
135
134
|
"unified": "^10.1.2",
|
|
136
|
-
"unist-util-visit": "^4.1.
|
|
137
|
-
"unist-util-visit-parents": "^5.1.
|
|
138
|
-
"url": "^0.11.
|
|
135
|
+
"unist-util-visit": "^4.1.2",
|
|
136
|
+
"unist-util-visit-parents": "^5.1.3",
|
|
137
|
+
"url": "^0.11.1",
|
|
139
138
|
"v8-compile-cache": "2.3.0",
|
|
140
|
-
"vfile": "^5.3.
|
|
139
|
+
"vfile": "^5.3.7"
|
|
141
140
|
},
|
|
142
141
|
"devDependencies": {
|
|
143
|
-
"@commitlint/cli": "^17.
|
|
144
|
-
"@commitlint/config-conventional": "^17.
|
|
142
|
+
"@commitlint/cli": "^17.6.7",
|
|
143
|
+
"@commitlint/config-conventional": "^17.6.7",
|
|
145
144
|
"@types/github-slugger": "^1.3.0",
|
|
146
145
|
"@types/highlight-words-core": "^1.2.1",
|
|
147
146
|
"@types/hosted-git-info": "^3.0.2",
|
|
148
147
|
"@types/js-yaml": "^4.0.5",
|
|
149
148
|
"@types/lodash.throttle": "^4.1.7",
|
|
150
|
-
"@types/node": "^18.
|
|
151
|
-
"@types/pluralize": "^0.0.
|
|
152
|
-
"@types/react": "^18.
|
|
149
|
+
"@types/node": "^18.17.1",
|
|
150
|
+
"@types/pluralize": "^0.0.30",
|
|
151
|
+
"@types/react": "^18.2.17",
|
|
153
152
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
154
153
|
"@umijs/lint": "^4.0.73",
|
|
155
154
|
"@umijs/plugins": "4.0.32",
|
|
156
155
|
"dumi-theme-mobile": "workspace:*",
|
|
157
|
-
"eslint": "^8.
|
|
158
|
-
"fast-glob": "^3.
|
|
156
|
+
"eslint": "^8.46.0",
|
|
157
|
+
"fast-glob": "^3.3.1",
|
|
159
158
|
"father": "^4.3.0",
|
|
160
159
|
"highlight-words-core": "^1.2.2",
|
|
161
|
-
"husky": "^8.0.
|
|
162
|
-
"lint-staged": "^13.
|
|
163
|
-
"prettier": "^2.
|
|
164
|
-
"prettier-plugin-organize-imports": "^3.
|
|
165
|
-
"prettier-plugin-packagejson": "^2.
|
|
160
|
+
"husky": "^8.0.3",
|
|
161
|
+
"lint-staged": "^13.2.3",
|
|
162
|
+
"prettier": "^2.8.8",
|
|
163
|
+
"prettier-plugin-organize-imports": "^3.2.3",
|
|
164
|
+
"prettier-plugin-packagejson": "^2.4.5",
|
|
166
165
|
"react": "^18.2.0",
|
|
167
|
-
"stylelint": "^15.10.
|
|
168
|
-
"ts-node": "^10.
|
|
166
|
+
"stylelint": "^15.10.2",
|
|
167
|
+
"ts-node": "^10.9.1",
|
|
169
168
|
"typescript": "~5.0.4",
|
|
170
|
-
"vitest": "^0.
|
|
169
|
+
"vitest": "^0.33.0"
|
|
171
170
|
},
|
|
172
171
|
"peerDependencies": {
|
|
173
172
|
"react": ">=16.8",
|
|
@@ -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);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentProps } from 'react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import './index.less';
|
|
3
|
-
declare const _default: (props: ComponentProps<'div'>) => JSX.Element;
|
|
4
|
+
declare const _default: (props: ComponentProps<'div'>) => React.JSX.Element;
|
|
4
5
|
export default _default;
|
|
@@ -10,7 +10,7 @@ import { ReactComponent as IconArrowUp } from '@ant-design/icons-svg/inline-svg/
|
|
|
10
10
|
import { ReactComponent as IconSearch } from '@ant-design/icons-svg/inline-svg/outlined/search.svg';
|
|
11
11
|
import { useSiteSearch } from 'dumi';
|
|
12
12
|
import React, { useEffect, useRef, useState } from 'react';
|
|
13
|
-
import SearchResult from
|
|
13
|
+
import SearchResult from 'dumi/theme/slots/SearchResult';
|
|
14
14
|
import "./index.less";
|
|
15
15
|
import { Input } from "./Input";
|
|
16
16
|
import { Mask } from "./Mask";
|