dumi 2.3.1 → 2.3.3
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/assetParsers/block.js +2 -1
- package/dist/features/meta.js +2 -1
- package/dist/features/theme/index.js +3 -1
- package/dist/loaders/markdown/transformer/index.js +2 -4
- package/dist/templates/ContextWrapper.ts.tpl +1 -1
- package/dist/templates/meta/runtime.ts.tpl +1 -1
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +11 -0
- package/package.json +1 -1
- package/theme-default/slots/Toc/index.js +14 -1
|
@@ -83,7 +83,8 @@ async function parseBlockAsset(opts) {
|
|
|
83
83
|
type: "NPM",
|
|
84
84
|
value: pkg.version
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
if (opts.techStack.runtimeOpts)
|
|
87
|
+
result.resolveMap[args.path] = args.path;
|
|
87
88
|
}
|
|
88
89
|
return { path: args.path, external: true };
|
|
89
90
|
}
|
package/dist/features/meta.js
CHANGED
|
@@ -98,7 +98,8 @@ var meta_default = (api) => {
|
|
|
98
98
|
path: "dumi/meta/runtime.ts",
|
|
99
99
|
tplPath: require.resolve("../templates/meta/runtime.ts.tpl"),
|
|
100
100
|
context: {
|
|
101
|
-
deepmerge: (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("deepmerge/package")))
|
|
101
|
+
deepmerge: (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("deepmerge/package"))),
|
|
102
|
+
rc_util: (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("rc-util/package")))
|
|
102
103
|
}
|
|
103
104
|
});
|
|
104
105
|
api.writeTmpFile({
|
|
@@ -33,6 +33,7 @@ __export(theme_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(theme_exports);
|
|
35
35
|
var import_constants = require("../../constants");
|
|
36
|
+
var import_utils = require("../../utils");
|
|
36
37
|
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
37
38
|
var import_child_process = require("child_process");
|
|
38
39
|
var import_fs = __toESM(require("fs"));
|
|
@@ -87,7 +88,7 @@ function checkMinor2ByPkg(pkg) {
|
|
|
87
88
|
if ((_a = pkg.name) == null ? void 0 : _a.startsWith("@examples/"))
|
|
88
89
|
return true;
|
|
89
90
|
const ver = ((_b = pkg.peerDependencies) == null ? void 0 : _b.dumi) || ((_c = pkg.devDependencies) == null ? void 0 : _c.dumi) || "^2.0.0";
|
|
90
|
-
return
|
|
91
|
+
return (0, import_utils.isVersionInRange)(ver, import_constants.VERSION_2_LEVEL_NAV);
|
|
91
92
|
}
|
|
92
93
|
var theme_default = (api) => {
|
|
93
94
|
const defaultThemeData = (0, import_loader.default)(DEFAULT_THEME_PATH);
|
|
@@ -318,6 +319,7 @@ export default DumiLoading;
|
|
|
318
319
|
api.config.themeConfig
|
|
319
320
|
)
|
|
320
321
|
),
|
|
322
|
+
rc_util: (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("rc-util/package"))),
|
|
321
323
|
_2_level_nav_available: api.appData._2LevelNavAvailable
|
|
322
324
|
}
|
|
323
325
|
});
|
|
@@ -33,8 +33,8 @@ __export(transformer_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(transformer_exports);
|
|
35
35
|
var import_constants = require("../../../constants");
|
|
36
|
+
var import_utils = require("../../../utils");
|
|
36
37
|
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
37
|
-
var import_plugin_utils = require("umi/plugin-utils");
|
|
38
38
|
var import_rehypeDemo = __toESM(require("./rehypeDemo"));
|
|
39
39
|
var import_rehypeDesc = __toESM(require("./rehypeDesc"));
|
|
40
40
|
var import_rehypeEnhancedTag = __toESM(require("./rehypeEnhancedTag"));
|
|
@@ -56,9 +56,7 @@ function keepSoftBreak(pkg) {
|
|
|
56
56
|
if (((_a = pkg == null ? void 0 : pkg.name) == null ? void 0 : _a.startsWith("@examples/")) || (pkg == null ? void 0 : pkg.name) === "dumi")
|
|
57
57
|
return false;
|
|
58
58
|
const ver = ((_b = pkg == null ? void 0 : pkg.devDependencies) == null ? void 0 : _b.dumi) ?? ((_c = pkg == null ? void 0 : pkg.dependencies) == null ? void 0 : _c.dumi) ?? "^2.0.0";
|
|
59
|
-
return !
|
|
60
|
-
includePrerelease: true
|
|
61
|
-
});
|
|
59
|
+
return !(0, import_utils.isVersionInRange)(ver, import_constants.VERSION_2_DEPRECATE_SOFT_BREAKS);
|
|
62
60
|
}
|
|
63
61
|
async function applyUnifiedPlugin(opts) {
|
|
64
62
|
const [plugin, options] = Array.isArray(opts.plugin) ? opts.plugin : [opts.plugin];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef } from 'react';
|
|
2
2
|
import { useOutlet, history } from 'dumi';
|
|
3
|
-
import { warning } from '
|
|
3
|
+
import { warning } from '{{{rc_util}}}';
|
|
4
4
|
import { SiteContext, type ISiteContext } from '{{{contextPath}}}';
|
|
5
5
|
import { components } from '../meta/atoms';
|
|
6
6
|
import { locales } from '../locales/config';
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Range, RangeOptions } from '@umijs/utils/compiled/semver';
|
|
1
2
|
import Cache from 'file-system-cache';
|
|
2
3
|
/**
|
|
3
4
|
* get route path from file-system path
|
|
@@ -47,4 +48,8 @@ export declare function generateMetaChunkName(path: string, cwd: string, locales
|
|
|
47
48
|
* generate hash for string
|
|
48
49
|
*/
|
|
49
50
|
export declare function getContentHash(content: string, length?: number): string;
|
|
51
|
+
/**
|
|
52
|
+
* check if version is in range
|
|
53
|
+
*/
|
|
54
|
+
export declare function isVersionInRange(version: string, range: string | Range, options?: RangeOptions): boolean;
|
|
50
55
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -38,6 +38,7 @@ __export(utils_exports, {
|
|
|
38
38
|
getFileIdFromFsPath: () => getFileIdFromFsPath,
|
|
39
39
|
getFileRangeLines: () => getFileRangeLines,
|
|
40
40
|
getProjectRoot: () => getProjectRoot,
|
|
41
|
+
isVersionInRange: () => isVersionInRange,
|
|
41
42
|
parseCodeFrontmatter: () => parseCodeFrontmatter,
|
|
42
43
|
tryFatherBuildConfigs: () => tryFatherBuildConfigs
|
|
43
44
|
});
|
|
@@ -159,6 +160,15 @@ function generateMetaChunkName(path2, cwd, locales = []) {
|
|
|
159
160
|
function getContentHash(content2, length = 8) {
|
|
160
161
|
return (0, import_crypto.createHash)("md5").update(content2).digest("hex").slice(0, length);
|
|
161
162
|
}
|
|
163
|
+
function isVersionInRange(version, range, options = { includePrerelease: true }) {
|
|
164
|
+
if (import_plugin_utils.semver.valid(version)) {
|
|
165
|
+
return import_plugin_utils.semver.satisfies(version, range, options);
|
|
166
|
+
}
|
|
167
|
+
if (import_plugin_utils.semver.validRange(version)) {
|
|
168
|
+
return import_plugin_utils.semver.subset(version, range, options);
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
162
172
|
// Annotate the CommonJS export names for ESM import in node:
|
|
163
173
|
0 && (module.exports = {
|
|
164
174
|
_setFSCacheDir,
|
|
@@ -170,6 +180,7 @@ function getContentHash(content2, length = 8) {
|
|
|
170
180
|
getFileIdFromFsPath,
|
|
171
181
|
getFileRangeLines,
|
|
172
182
|
getProjectRoot,
|
|
183
|
+
isVersionInRange,
|
|
173
184
|
parseCodeFrontmatter,
|
|
174
185
|
tryFatherBuildConfigs
|
|
175
186
|
});
|
package/package.json
CHANGED
|
@@ -23,6 +23,10 @@ var Toc = function Toc() {
|
|
|
23
23
|
_useState2 = _slicedToArray(_useState, 2),
|
|
24
24
|
sectionRefs = _useState2[0],
|
|
25
25
|
setSectionRefs = _useState2[1];
|
|
26
|
+
var _useState3 = useState(0),
|
|
27
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
28
|
+
headerHeight = _useState4[0],
|
|
29
|
+
setHeaderHeight = _useState4[1];
|
|
26
30
|
var memoToc = React.useMemo(function () {
|
|
27
31
|
var toc = meta.toc;
|
|
28
32
|
if (tabMeta) {
|
|
@@ -47,8 +51,17 @@ var Toc = function Toc() {
|
|
|
47
51
|
setSectionRefs(refs);
|
|
48
52
|
}
|
|
49
53
|
}, [pathname, search, loading, memoToc]);
|
|
54
|
+
useEffect(function () {
|
|
55
|
+
if (sectionRefs.length > 0) {
|
|
56
|
+
// find the header height, and set it to scrollspy offset
|
|
57
|
+
// because the header is sticky, so we need to set the offset to avoid the active item is hidden by the header
|
|
58
|
+
var header = document.querySelector('.dumi-default-header');
|
|
59
|
+
setHeaderHeight(header ? header.clientHeight : 0);
|
|
60
|
+
}
|
|
61
|
+
}, [sectionRefs]);
|
|
50
62
|
return sectionRefs.length ? /*#__PURE__*/React.createElement(ScrollSpy, {
|
|
51
|
-
sectionRefs: sectionRefs
|
|
63
|
+
sectionRefs: sectionRefs,
|
|
64
|
+
offset: -headerHeight
|
|
52
65
|
}, function (_ref3) {
|
|
53
66
|
var currentElementIndexInViewport = _ref3.currentElementIndexInViewport;
|
|
54
67
|
// for keep prev item active when no item in viewport
|