dumi 2.4.6-beta.1 → 2.4.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/crates/swc_plugin_react_demo.wasm +0 -0
- package/dist/client/theme-api/index.d.ts +1 -1
- package/dist/client/theme-api/index.js +1 -1
- package/dist/client/theme-api/useLiveDemo.js +1 -1
- package/dist/client/theme-api/useRouteMeta.d.ts +12 -0
- package/dist/client/theme-api/useRouteMeta.js +12 -4
- package/dist/features/compile/index.js +3 -0
- package/dist/loaders/markdown/index.js +2 -8
- package/dist/templates/meta/exports.ts.tpl +1 -1
- package/package.json +2 -2
- package/theme-default/slots/SourceCodeEditor/index.js +7 -2
- package/theme-default/slots/Toc/index.js +1 -1
|
Binary file
|
|
@@ -12,7 +12,7 @@ export { useLiveDemo } from './useLiveDemo';
|
|
|
12
12
|
export { useLocale } from './useLocale';
|
|
13
13
|
export { useNavData } from './useNavData';
|
|
14
14
|
export { usePrefersColor } from './usePrefersColor';
|
|
15
|
-
export { useRouteMeta } from './useRouteMeta';
|
|
15
|
+
export { useMatchedRoute, useRouteMeta } from './useRouteMeta';
|
|
16
16
|
export { useFullSidebarData, useSidebarData } from './useSidebarData';
|
|
17
17
|
export { useSiteSearch } from './useSiteSearch';
|
|
18
18
|
export { useTabMeta } from './useTabMeta';
|
|
@@ -11,7 +11,7 @@ export { useLiveDemo } from "./useLiveDemo";
|
|
|
11
11
|
export { useLocale } from "./useLocale";
|
|
12
12
|
export { useNavData } from "./useNavData";
|
|
13
13
|
export { usePrefersColor } from "./usePrefersColor";
|
|
14
|
-
export { useRouteMeta } from "./useRouteMeta";
|
|
14
|
+
export { useMatchedRoute, useRouteMeta } from "./useRouteMeta";
|
|
15
15
|
export { useFullSidebarData, useSidebarData } from "./useSidebarData";
|
|
16
16
|
export { useSiteSearch } from "./useSiteSearch";
|
|
17
17
|
export { useTabMeta } from "./useTabMeta";
|
|
@@ -110,7 +110,7 @@ export var useLiveDemo = function useLiveDemo(id, opts) {
|
|
|
110
110
|
_context.prev = 12;
|
|
111
111
|
_context.next = 15;
|
|
112
112
|
return renderOpts.compile(entryFileCode, {
|
|
113
|
-
filename:
|
|
113
|
+
filename: entryFileName
|
|
114
114
|
});
|
|
115
115
|
case 15:
|
|
116
116
|
entryFileCode = _context.sent;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { IRouteMeta } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* hook for get matched route
|
|
4
|
+
* @internal internal use. Do not use in your production code.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useMatchedRoute: () => {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
parentId?: string | undefined;
|
|
10
|
+
meta?: IRouteMeta | undefined;
|
|
11
|
+
id: string;
|
|
12
|
+
redirect?: string | undefined;
|
|
13
|
+
};
|
|
2
14
|
/**
|
|
3
15
|
* hook for get matched route meta
|
|
4
16
|
*/
|
|
@@ -73,9 +73,10 @@ function getCachedRouteMeta(route) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* hook for get matched route
|
|
76
|
+
* hook for get matched route
|
|
77
|
+
* @internal internal use. Do not use in your production code.
|
|
77
78
|
*/
|
|
78
|
-
export var
|
|
79
|
+
export var useMatchedRoute = function useMatchedRoute() {
|
|
79
80
|
var _useRouteData = useRouteData(),
|
|
80
81
|
route = _useRouteData.route;
|
|
81
82
|
var _useLocation = useLocation(),
|
|
@@ -99,9 +100,16 @@ export var useRouteMeta = function useRouteMeta() {
|
|
|
99
100
|
_useState2 = _slicedToArray(_useState, 2),
|
|
100
101
|
matchedRoute = _useState2[0],
|
|
101
102
|
setMatchedRoute = _useState2[1];
|
|
102
|
-
var meta = getCachedRouteMeta(matchedRoute);
|
|
103
103
|
useIsomorphicLayoutEffect(function () {
|
|
104
104
|
setMatchedRoute(getter);
|
|
105
105
|
}, [clientRoutes.length, pathname]);
|
|
106
|
-
return
|
|
106
|
+
return matchedRoute;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* hook for get matched route meta
|
|
111
|
+
*/
|
|
112
|
+
export var useRouteMeta = function useRouteMeta() {
|
|
113
|
+
var route = useMatchedRoute();
|
|
114
|
+
return getCachedRouteMeta(route);
|
|
107
115
|
};
|
|
@@ -104,6 +104,9 @@ var compile_default = (api) => {
|
|
|
104
104
|
if (!babelInUmi)
|
|
105
105
|
return memo;
|
|
106
106
|
const loaderPath = require.resolve("../../loaders/markdown");
|
|
107
|
+
memo.resolve.byDependency.set("commonjs", {
|
|
108
|
+
conditionNames: ["require", "node", "import"]
|
|
109
|
+
});
|
|
107
110
|
const loaderBaseOpts = {
|
|
108
111
|
techStacks,
|
|
109
112
|
cwd: api.cwd,
|
|
@@ -34,7 +34,6 @@ __export(markdown_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(markdown_exports);
|
|
35
35
|
var import_tabs = require("../../features/tabs");
|
|
36
36
|
var import_utils = require("../../utils");
|
|
37
|
-
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
38
37
|
var import_fs = __toESM(require("fs"));
|
|
39
38
|
var import_path = __toESM(require("path"));
|
|
40
39
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
@@ -50,11 +49,6 @@ function getDemoSourceFiles(demos = []) {
|
|
|
50
49
|
return ret;
|
|
51
50
|
}, []);
|
|
52
51
|
}
|
|
53
|
-
var resolver = import_enhanced_resolve.default.create.sync({
|
|
54
|
-
mainFields: ["browser", "module", "main"],
|
|
55
|
-
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
|
|
56
|
-
conditionNames: ["import", "default", "browser"]
|
|
57
|
-
});
|
|
58
52
|
function emitDefault(opts, ret) {
|
|
59
53
|
const { frontmatter, demos } = ret.meta;
|
|
60
54
|
const isTabContent = (0, import_tabs.isTabRouteFile)(this.resourcePath);
|
|
@@ -135,11 +129,11 @@ export const demos = {
|
|
|
135
129
|
return "undefined";
|
|
136
130
|
const entryFileName = Object.keys(this.asset.dependencies)[0];
|
|
137
131
|
const context = Object.entries(this.resolveMap).reduce(
|
|
138
|
-
(acc, [key,
|
|
132
|
+
(acc, [key, path2]) => ({
|
|
139
133
|
...acc,
|
|
140
134
|
// omit entry file
|
|
141
135
|
...key !== entryFileName ? {
|
|
142
|
-
[key]: `{{{require('${
|
|
136
|
+
[key]: `{{{require('${path2}')}}}`
|
|
143
137
|
} : {}
|
|
144
138
|
}),
|
|
145
139
|
{}
|
|
@@ -75,6 +75,7 @@ export function useDemo(id: string): IDemoData | undefined {
|
|
|
75
75
|
demoIdMap[id]?.().then(({ demos }) => {
|
|
76
76
|
// expand context for omit ext
|
|
77
77
|
expandDemoContext(demos[id].context);
|
|
78
|
+
|
|
78
79
|
return demos[id];
|
|
79
80
|
}),
|
|
80
81
|
);
|
|
@@ -139,7 +140,6 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
|
|
|
139
140
|
): T extends { syncOnly: true }
|
|
140
141
|
? IRouteMeta | undefined
|
|
141
142
|
: Promise<IRouteMeta> | undefined {
|
|
142
|
-
|
|
143
143
|
if (filesMeta[id]) {
|
|
144
144
|
const { frontmatter, toc, textGetter, tabs } = filesMeta[id];
|
|
145
145
|
const routeMeta: IRouteMeta = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.7",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"enhanced-resolve": "^5.15.0",
|
|
79
79
|
"estree-util-to-js": "^1.2.0",
|
|
80
80
|
"estree-util-visit": "^1.2.1",
|
|
81
|
-
"file-system-cache": "
|
|
81
|
+
"file-system-cache": "2.4.4",
|
|
82
82
|
"github-slugger": "^1.5.0",
|
|
83
83
|
"hast-util-is-element": "^2.1.3",
|
|
84
84
|
"hast-util-raw": "^8.0.0",
|
|
@@ -27,14 +27,19 @@ var SourceCodeEditor = function SourceCodeEditor(props) {
|
|
|
27
27
|
var _elm$current;
|
|
28
28
|
var pre = (_elm$current = elm.current) === null || _elm$current === void 0 ? void 0 : _elm$current.querySelector('pre');
|
|
29
29
|
if (pre) {
|
|
30
|
+
var lineCell = pre.querySelector('.line-cell');
|
|
30
31
|
var preStyle = window.getComputedStyle(pre);
|
|
31
|
-
|
|
32
|
+
var styles = {
|
|
32
33
|
fontSize: preStyle.fontSize,
|
|
33
34
|
fontFamily: preStyle.fontFamily,
|
|
34
35
|
lineHeight: preStyle.lineHeight,
|
|
35
36
|
padding: preStyle.padding,
|
|
36
37
|
margin: preStyle.margin
|
|
37
|
-
}
|
|
38
|
+
};
|
|
39
|
+
if (lineCell) {
|
|
40
|
+
styles.paddingLeft = lineCell.offsetLeft;
|
|
41
|
+
}
|
|
42
|
+
setStyle(styles);
|
|
38
43
|
} else {
|
|
39
44
|
console.warn('[dumi] pre element not found in SourceCode component, the SourceCodeEditor will be disabled, you can report an issue to dumi repository.');
|
|
40
45
|
}
|
|
@@ -5,7 +5,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
5
5
|
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; }
|
|
6
6
|
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; } }
|
|
7
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
-
import { Scrollspy as ScrollSpy } from '@makotot/ghostui';
|
|
8
|
+
import { Scrollspy as ScrollSpy } from '@makotot/ghostui/src/Scrollspy';
|
|
9
9
|
import { history, Link, useLocation, useRouteMeta, useSiteData, useTabMeta } from 'dumi';
|
|
10
10
|
import React, { useEffect, useRef, useState } from 'react';
|
|
11
11
|
import "./index.less";
|