dumi 2.2.10 → 2.2.12

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.
@@ -111,7 +111,9 @@ export default DumiMarkdownContent;`;
111
111
  }
112
112
  function getDepsCacheKey(deps = []) {
113
113
  return JSON.stringify(
114
- deps.map((file) => `${file}:${import_fs.default.statSync(file).mtimeMs}`)
114
+ deps.map(
115
+ (file) => `${file}:${(0, import_utils.getContentHash)(import_fs.default.readFileSync(file, "utf-8"))}`
116
+ )
115
117
  );
116
118
  }
117
119
  var deferrer = {};
@@ -122,7 +124,7 @@ function mdLoader(content) {
122
124
  const cache = (0, import_utils.getCache)("md-loader");
123
125
  const baseCacheKey = [
124
126
  this.resourcePath,
125
- import_fs.default.statSync(this.resourcePath).mtimeMs,
127
+ (0, import_utils.getContentHash)(content),
126
128
  JSON.stringify(import_plugin_utils.lodash.omit(opts, ["mode", "builtins", "onResolveDemos"]))
127
129
  ].join(":");
128
130
  const cacheKey = [
@@ -58,14 +58,14 @@ function keepSoftBreak(pkg) {
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
59
  return !import_plugin_utils.semver.subset(ver, import_constants.VERSION_2_DEPRECATE_SOFT_BREAKS);
60
60
  }
61
- function applyUnifiedPlugin(opts) {
61
+ async function applyUnifiedPlugin(opts) {
62
62
  const [plugin, options] = Array.isArray(opts.plugin) ? opts.plugin : [opts.plugin];
63
- const mod = typeof plugin === "function" ? plugin : require(require.resolve(plugin, { paths: [opts.cwd] }));
63
+ let mod = typeof plugin === "function" ? plugin : await import(plugin);
64
64
  const fn = mod.default || mod;
65
65
  opts.processor.use(fn, options);
66
66
  }
67
67
  var transformer_default = async (raw, opts) => {
68
- var _a, _b, _c;
68
+ var _a;
69
69
  let fileLocaleLessPath = opts.fileAbsPath;
70
70
  const { unified } = await import("unified");
71
71
  const { default: remarkParse } = await import("remark-parse");
@@ -94,13 +94,13 @@ var transformer_default = async (raw, opts) => {
94
94
  if (keepSoftBreak(opts.pkg)) {
95
95
  processor.use(import_remarkBreaks.default, { fileAbsPath: opts.fileAbsPath });
96
96
  }
97
- (_b = opts.extraRemarkPlugins) == null ? void 0 : _b.forEach(
98
- (plugin) => applyUnifiedPlugin({
97
+ for (const plugin of opts.extraRemarkPlugins ?? []) {
98
+ await applyUnifiedPlugin({
99
99
  plugin,
100
100
  processor,
101
101
  cwd: opts.cwd
102
- })
103
- );
102
+ });
103
+ }
104
104
  processor.use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default, {
105
105
  fileAbsPath: opts.fileAbsPath
106
106
  }).use(import_rehypeHighlightLine.default).use(rehypeRemoveComments, { removeConditional: true }).use(import_rehypeStrip.default).use(import_rehypeImg.default).use(import_rehypeDemo.default, {
@@ -115,13 +115,14 @@ var transformer_default = async (raw, opts) => {
115
115
  fileAbsPath: opts.fileAbsPath,
116
116
  routes: opts.routes
117
117
  }).use(rehypeAutolinkHeadings).use(import_rehypeIsolation.default).use(import_rehypeEnhancedTag.default).use(import_rehypeDesc.default).use(import_rehypeText.default);
118
- (_c = opts.extraRehypePlugins) == null ? void 0 : _c.forEach(
119
- (plugin) => applyUnifiedPlugin({
118
+ for (const plugin of opts.extraRehypePlugins ?? []) {
119
+ await applyUnifiedPlugin({
120
120
  plugin,
121
121
  processor,
122
122
  cwd: opts.cwd
123
- })
124
- );
123
+ });
124
+ }
125
+ processor.data("fileAbsPath", opts.fileAbsPath);
125
126
  const result = await processor.use(import_rehypeJsxify.default).process(raw);
126
127
  return {
127
128
  content: String(result.value),
@@ -22,7 +22,7 @@ __export(cli_exports, {
22
22
  run: () => run
23
23
  });
24
24
  module.exports = __toCommonJS(cli_exports);
25
- var import_node = require("umi/dist/cli/node");
25
+ var import_node = require("@umijs/utils/dist/node");
26
26
  var import_plugin_utils = require("umi/plugin-utils");
27
27
  var import_constants = require("./constants");
28
28
  var import_dev = require("./dev");
@@ -30,7 +30,7 @@ var import_printHelp = require("./printHelp");
30
30
  var import_service = require("./service");
31
31
  (0, import_node.catchUnhandledRejection)();
32
32
  async function run(opts) {
33
- (0, import_node.checkVersion)();
33
+ (0, import_node.checkVersion)(import_constants.MIN_NODE_VERSION);
34
34
  (0, import_node.setNodeTitle)(import_constants.FRAMEWORK_NAME);
35
35
  (0, import_plugin_utils.setNoDeprecation)();
36
36
  const args = (0, import_plugin_utils.yParser)(process.argv.slice(2), {
@@ -1,5 +1,5 @@
1
1
  // src/service/forkedDev.ts
2
- var import_node = require("umi/dist/cli/node");
2
+ var import_node = require("@umijs/utils/dist/node");
3
3
  var import_plugin_utils = require("umi/plugin-utils");
4
4
  var import_constants = require("./constants");
5
5
  var import_service = require("./service");
package/dist/utils.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare function parseCodeFrontmatter(raw: string): {
25
25
  * get file-system cache for specific namespace
26
26
  */
27
27
  declare const caches: Record<string, ReturnType<typeof Cache>>;
28
- export declare function getCache(ns: string): typeof caches['0'];
28
+ export declare function getCache(ns: string): (typeof caches)['0'];
29
29
  /**
30
30
  * try to get father config
31
31
  */
@@ -34,4 +34,8 @@ export declare function tryFatherBuildConfigs(cwd: string): Promise<any[]>;
34
34
  * get root dir for monorepo project
35
35
  */
36
36
  export declare function getProjectRoot(cwd: string): string;
37
+ /**
38
+ * generate hash for string
39
+ */
40
+ export declare function getContentHash(content: string, length?: number): string;
37
41
  export {};
package/dist/utils.js CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
32
  getCache: () => getCache,
33
+ getContentHash: () => getContentHash,
33
34
  getFileContentByRegExp: () => getFileContentByRegExp,
34
35
  getFileIdFromFsPath: () => getFileIdFromFsPath,
35
36
  getFileRangeLines: () => getFileRangeLines,
@@ -38,6 +39,7 @@ __export(utils_exports, {
38
39
  tryFatherBuildConfigs: () => tryFatherBuildConfigs
39
40
  });
40
41
  module.exports = __toCommonJS(utils_exports);
42
+ var import_crypto = require("crypto");
41
43
  var import_file_system_cache = __toESM(require("file-system-cache"));
42
44
  var import_fs = __toESM(require("fs"));
43
45
  var import_js_yaml = __toESM(require("js-yaml"));
@@ -126,9 +128,13 @@ function getProjectRoot(cwd) {
126
128
  }
127
129
  return (0, import_plugin_utils.winPath)(cwd);
128
130
  }
131
+ function getContentHash(content2, length = 8) {
132
+ return (0, import_crypto.createHash)("md5").update(content2).digest("hex").slice(0, length);
133
+ }
129
134
  // Annotate the CommonJS export names for ESM import in node:
130
135
  0 && (module.exports = {
131
136
  getCache,
137
+ getContentHash,
132
138
  getFileContentByRegExp,
133
139
  getFileIdFromFsPath,
134
140
  getFileRangeLines,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.2.10",
3
+ "version": "2.2.12",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -82,8 +82,9 @@
82
82
  "@swc/core": "1.3.72",
83
83
  "@types/hast": "^2.3.5",
84
84
  "@types/mdast": "^3.0.12",
85
- "@umijs/bundler-utils": "^4.0.73",
86
- "@umijs/core": "^4.0.73",
85
+ "@umijs/bundler-utils": "^4.0.83",
86
+ "@umijs/core": "^4.0.83",
87
+ "@umijs/utils": "^4.0.83",
87
88
  "animated-scroll-to": "^2.3.0",
88
89
  "classnames": "2.3.2",
89
90
  "codesandbox": "^2.2.3",
@@ -130,7 +131,7 @@
130
131
  "remark-rehype": "^10.1.0",
131
132
  "sass": "^1.64.1",
132
133
  "sitemap": "^7.1.1",
133
- "umi": "^4.0.73",
134
+ "umi": "^4.0.83",
134
135
  "unified": "^10.1.2",
135
136
  "unist-util-visit": "^4.1.2",
136
137
  "unist-util-visit-parents": "^5.1.3",
@@ -150,7 +151,7 @@
150
151
  "@types/pluralize": "^0.0.30",
151
152
  "@types/react": "^18.2.17",
152
153
  "@types/react-copy-to-clipboard": "^5.0.4",
153
- "@umijs/lint": "^4.0.73",
154
+ "@umijs/lint": "^4.0.83",
154
155
  "@umijs/plugins": "4.0.32",
155
156
  "dumi-theme-mobile": "workspace:*",
156
157
  "eslint": "^8.46.0",
@@ -113,6 +113,7 @@
113
113
  box-shadow: 0 4px 16px rgba(0, 0, 0, 10%);
114
114
  border-radius: 6px;
115
115
  transition: all 0.2s ease-in-out;
116
+ z-index: 1;
116
117
 
117
118
  @{dark-selector} & {
118
119
  background-color: lighten(@c-site-bg-dark, 6%);
@@ -126,6 +127,7 @@
126
127
  font-size: 15px;
127
128
  line-height: 1.6;
128
129
  text-align: left;
130
+ white-space: nowrap;
129
131
 
130
132
  @media @mobile {
131
133
  display: inline;