dumi 2.1.15 → 2.1.17

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.
Files changed (32) hide show
  1. package/dist/assetParsers/atom.d.ts +1 -0
  2. package/dist/assetParsers/atom.js +2 -1
  3. package/dist/client/pages/404.js +1 -1
  4. package/dist/client/theme-api/DumiDemo.js +2 -2
  5. package/dist/client/theme-api/DumiPage.js +1 -1
  6. package/dist/constants.d.ts +0 -1
  7. package/dist/constants.js +0 -13
  8. package/dist/features/autoAlias.js +26 -19
  9. package/dist/features/derivative.js +15 -19
  10. package/dist/features/exportStatic.js +41 -30
  11. package/dist/features/locales.js +9 -0
  12. package/dist/features/parser.js +4 -2
  13. package/dist/features/routes.js +1 -2
  14. package/dist/loaders/markdown/transformer/index.js +3 -0
  15. package/dist/loaders/markdown/transformer/rehypeEnhancedTag.js +9 -1
  16. package/dist/loaders/markdown/transformer/rehypeHighlightLine.d.ts +4 -0
  17. package/dist/loaders/markdown/transformer/rehypeHighlightLine.js +60 -0
  18. package/package.json +5 -5
  19. package/theme-default/builtins/Previewer/index.js +1 -1
  20. package/theme-default/builtins/Previewer/index.less +1 -1
  21. package/theme-default/builtins/SourceCode/index.d.ts +4 -2
  22. package/theme-default/builtins/SourceCode/index.js +16 -10
  23. package/theme-default/builtins/SourceCode/index.less +12 -0
  24. package/theme-default/layouts/DocLayout/index.js +7 -7
  25. package/theme-default/slots/Header/index.js +6 -6
  26. package/theme-default/slots/Hero/index.js +1 -1
  27. package/theme-default/slots/Logo/index.less +1 -1
  28. package/theme-default/slots/Navbar/index.js +1 -1
  29. package/theme-default/slots/Navbar/index.less +1 -1
  30. package/theme-default/slots/PreviewerActions/index.js +2 -2
  31. package/theme-default/slots/Sidebar/index.js +1 -1
  32. package/theme-default/slots/Sidebar/index.less +2 -2
@@ -15,6 +15,7 @@ declare class AtomAssetsParser {
15
15
  resolveFilter?: AtomAssetsParser['resolveFilter'];
16
16
  unpkgHost?: string;
17
17
  watch?: boolean;
18
+ parseOptions?: object;
18
19
  });
19
20
  parse(): Promise<{
20
21
  components: Record<string, AtomComponentAsset>;
@@ -44,7 +44,8 @@ var AtomAssetsParser = class {
44
44
  entryPath: absEntryFile,
45
45
  basePath: (0, import_utils.getProjectRoot)(opts.resolveDir),
46
46
  unPkgHost: opts.unpkgHost ?? "https://unpkg.com",
47
- mode: "worker"
47
+ mode: "worker",
48
+ parseOptions: opts.parseOptions
48
49
  });
49
50
  }
50
51
  async parse() {
@@ -1,2 +1,2 @@
1
1
  // allow customize 404 via theme slots
2
- export { default } from "dumi/theme/slots/NotFound";
2
+ export { default } from 'dumi/theme/slots/NotFound';
@@ -2,8 +2,8 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
 
3
3
  import { SP_ROUTE_PREFIX } from "../../constants";
4
4
  import { useAppData, useSiteData } from 'dumi';
5
- import Container from "dumi/theme/builtins/Container";
6
- import Previewer from "dumi/theme/builtins/Previewer";
5
+ import Container from 'dumi/theme/builtins/Container';
6
+ import Previewer from 'dumi/theme/builtins/Previewer';
7
7
  import React, { createElement } from 'react';
8
8
  import { ErrorBoundary } from 'react-error-boundary';
9
9
 
@@ -11,7 +11,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import { useRouteMeta, useSiteData } from 'dumi';
14
- import ContentTabs from "dumi/theme/slots/ContentTabs";
14
+ import ContentTabs from 'dumi/theme/slots/ContentTabs';
15
15
  import React, { useEffect, useState } from 'react';
16
16
  import { useTabQueryState } from "./useTabMeta";
17
17
  export var DumiPage = function DumiPage(props) {
@@ -14,5 +14,4 @@ export declare const PICKED_PKG_FIELDS: {
14
14
  author: string;
15
15
  authors: string;
16
16
  };
17
- export declare const CLIENT_DEPS: string[];
18
17
  export declare const USELESS_TMP_FILES: string[];
package/dist/constants.js CHANGED
@@ -19,7 +19,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/constants.ts
20
20
  var constants_exports = {};
21
21
  __export(constants_exports, {
22
- CLIENT_DEPS: () => CLIENT_DEPS,
23
22
  LOCAL_DUMI_DIR: () => LOCAL_DUMI_DIR,
24
23
  LOCAL_PAGES_DIR: () => LOCAL_PAGES_DIR,
25
24
  LOCAL_THEME_DIR: () => LOCAL_THEME_DIR,
@@ -47,21 +46,9 @@ var PICKED_PKG_FIELDS = {
47
46
  author: "",
48
47
  authors: ""
49
48
  };
50
- var CLIENT_DEPS = [
51
- "@ant-design/icons-svg",
52
- "@makotot/ghostui",
53
- "deepmerge",
54
- "lodash.throttle",
55
- "prism-react-renderer",
56
- "prismjs",
57
- "rc-tabs",
58
- "react-copy-to-clipboard",
59
- "react-intl"
60
- ];
61
49
  var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
62
50
  // Annotate the CommonJS export names for ESM import in node:
63
51
  0 && (module.exports = {
64
- CLIENT_DEPS,
65
52
  LOCAL_DUMI_DIR,
66
53
  LOCAL_PAGES_DIR,
67
54
  LOCAL_THEME_DIR,
@@ -29,34 +29,41 @@ var import_utils = require("../utils");
29
29
  var import_fs = __toESM(require("fs"));
30
30
  var import_path = __toESM(require("path"));
31
31
  var autoAlias_default = (api) => {
32
+ let entryDir;
32
33
  api.describe({
33
34
  key: "autoAlias",
34
35
  config: {
35
36
  schema: (Joi) => Joi.bool()
36
37
  },
37
- enableBy: ({ userConfig }) => userConfig.autoAlias !== false
38
+ enableBy: () => !!api.pkg.name
38
39
  });
39
- api.modifyConfig(async (memo) => {
40
- var _a, _b, _c;
41
- let entryDir = "";
42
- if ((_a = memo.resolve) == null ? void 0 : _a.entryFile) {
43
- entryDir = import_path.default.resolve(api.cwd, memo.resolve.entryFile);
40
+ api.modifyAppData(async (memo) => {
41
+ var _a;
42
+ if ((_a = api.config.resolve) == null ? void 0 : _a.entryFile) {
43
+ entryDir = import_path.default.resolve(api.cwd, api.config.resolve.entryFile);
44
44
  } else if (import_fs.default.existsSync(import_path.default.join(api.cwd, "src"))) {
45
45
  entryDir = import_path.default.join(api.cwd, "src");
46
46
  }
47
- if (entryDir && api.pkg.name) {
48
- const fatherConfigs = await (0, import_utils.tryFatherBuildConfigs)(api.cwd);
49
- fatherConfigs.sort((a, b) => {
50
- var _a2, _b2;
51
- const aLevel = (((_a2 = a.output) == null ? void 0 : _a2.path) || a.output).split("/").length;
52
- const bLevel = (((_b2 = b.output) == null ? void 0 : _b2.path) || b.output).split("/").length;
53
- return bLevel - aLevel;
54
- });
55
- fatherConfigs.forEach((item) => {
56
- var _a2, _b2, _c2;
57
- (_b2 = memo.alias)[_c2 = `${api.pkg.name}/${((_a2 = item.output) == null ? void 0 : _a2.path) || item.output}`] ?? (_b2[_c2] = import_path.default.join(api.cwd, item.entry || item.input));
58
- });
59
- (_b = memo.alias)[_c = api.pkg.name] ?? (_b[_c] = entryDir);
47
+ memo.fatherConfigs = await (0, import_utils.tryFatherBuildConfigs)(api.cwd);
48
+ return memo;
49
+ });
50
+ api.chainWebpack((memo) => {
51
+ const fatherConfigs = api.appData.fatherConfigs;
52
+ fatherConfigs.sort((a, b) => {
53
+ var _a, _b;
54
+ const aLevel = (((_a = a.output) == null ? void 0 : _a.path) || a.output).split("/").length;
55
+ const bLevel = (((_b = b.output) == null ? void 0 : _b.path) || b.output).split("/").length;
56
+ return bLevel - aLevel;
57
+ });
58
+ fatherConfigs.forEach((item) => {
59
+ var _a;
60
+ const key = `${api.pkg.name}/${((_a = item.output) == null ? void 0 : _a.path) || item.output}`;
61
+ if (!memo.resolve.alias.has(key)) {
62
+ memo.resolve.alias.set(key, import_path.default.join(api.cwd, item.entry || item.input));
63
+ }
64
+ });
65
+ if (entryDir && !memo.resolve.alias.has(api.pkg.name)) {
66
+ memo.resolve.alias.set(api.pkg.name, entryDir);
60
67
  }
61
68
  return memo;
62
69
  });
@@ -31,11 +31,16 @@ var import_assert = __toESM(require("assert"));
31
31
  var import_fs = __toESM(require("fs"));
32
32
  var import_path = __toESM(require("path"));
33
33
  var import_plugin_utils = require("umi/plugin-utils");
34
+ function isMFSUAvailable(api) {
35
+ return process.platform !== "win32" && api.userConfig.mfsu !== false;
36
+ }
34
37
  function safeExcludeInMFSU(api, excludes) {
35
- if (api.userConfig.mfsu !== false) {
36
- api.modifyDefaultConfig((memo) => {
38
+ if (isMFSUAvailable(api)) {
39
+ api.modifyConfig((memo) => {
37
40
  if (memo.mfsu === false)
38
41
  return memo;
42
+ else if (memo.mfsu === true)
43
+ memo.mfsu = {};
39
44
  memo.mfsu ?? (memo.mfsu = {});
40
45
  memo.mfsu.exclude = (0, import_plugin_utils.deepmerge)(memo.mfsu.exclude || [], excludes);
41
46
  memo.extraBabelIncludes ?? (memo.extraBabelIncludes = []);
@@ -87,20 +92,14 @@ var derivative_default = (api) => {
87
92
  new RegExp("compiled/_internal/searchWorker")
88
93
  ]);
89
94
  api.modifyDefaultConfig((memo) => {
90
- if (api.userConfig.mfsu !== false) {
91
- if (import_fs.default.existsSync(import_path.default.join(api.cwd, "node_modules", ".pnpm")) || process.platform === "win32") {
92
- memo.mfsu = false;
93
- } else {
94
- memo.mfsu.strategy = "normal";
95
- memo.mfsu.shared = {
96
- react: { singleton: true },
97
- "react-dom": { singleton: true }
98
- };
99
- import_constants.CLIENT_DEPS.forEach((pkg) => {
100
- memo.alias ?? (memo.alias = {});
101
- memo.alias[pkg] = (0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve(`${pkg}/package.json`)));
102
- });
103
- }
95
+ if (!isMFSUAvailable(api)) {
96
+ memo.mfsu = false;
97
+ } else {
98
+ memo.mfsu.strategy = "normal";
99
+ memo.mfsu.shared = {
100
+ react: { singleton: true },
101
+ "react-dom": { singleton: true }
102
+ };
104
103
  }
105
104
  if (api.userConfig.conventionRoutes !== false) {
106
105
  memo.conventionRoutes = {
@@ -117,9 +116,6 @@ var derivative_default = (api) => {
117
116
  });
118
117
  api.modifyConfig((memo) => {
119
118
  var _a;
120
- if (api.userConfig.mfsu === true) {
121
- memo.mfsu = {};
122
- }
123
119
  if ((_a = api.userConfig.alias) == null ? void 0 : _a["@"]) {
124
120
  memo.alias["@"] = api.userConfig.alias["@"];
125
121
  } else {
@@ -23,46 +23,57 @@ __export(exportStatic_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(exportStatic_exports);
25
25
  var import_constants = require("../constants");
26
- var import_plugin_utils = require("umi/plugin-utils");
27
26
  var import_assets = require("./assets");
27
+ var NO_PRERENDER_ROUTES = [
28
+ "demo-render"
29
+ ];
28
30
  var exportStatic_default = (api) => {
29
- const prevExtraRoutePaths = [];
30
- api.describe({ key: "dumi:exportStatic" });
31
- api.register({
32
- key: "modifyDefaultConfig",
31
+ api.describe({
32
+ key: "dumi:exportStatic",
33
+ enableBy: ({ env }) => env === "production" && api.isPluginEnable("exportStatic")
34
+ });
35
+ api.modifyRoutes({
33
36
  stage: Infinity,
34
37
  fn(memo) {
35
- if (memo.exportStatic && memo.exportStatic.extraRoutePaths) {
36
- prevExtraRoutePaths.push(memo.exportStatic.extraRoutePaths);
37
- }
38
+ NO_PRERENDER_ROUTES.forEach((id) => {
39
+ if (memo[id])
40
+ memo[id].prerender = false;
41
+ });
42
+ return memo;
38
43
  }
39
44
  });
40
- api.register({
41
- key: "modifyConfig",
42
- stage: Infinity,
45
+ api.modifyExportHTMLFiles({
46
+ before: "exportStatic",
43
47
  fn(memo) {
44
- var _a;
45
- if (memo.exportStatic !== false) {
46
- if ((_a = memo.exportStatic) == null ? void 0 : _a.extraRoutePaths) {
47
- prevExtraRoutePaths.push(memo.exportStatic.extraRoutePaths);
48
- }
49
- memo.exportStatic ?? (memo.exportStatic = {});
50
- memo.exportStatic.extraRoutePaths = async () => {
51
- const examples = (0, import_assets.getExampleAssets)();
52
- const userExtraPaths = [];
53
- const isSupportDisablePrerender = import_plugin_utils.semver.gte(api.appData.umi.version, "4.0.48");
54
- for (const prev of prevExtraRoutePaths) {
55
- userExtraPaths.push(...typeof prev === "function" ? await prev() : prev);
56
- }
57
- return userExtraPaths.concat(examples.map(({ id }) => {
58
- const demoPath = `/${import_constants.SP_ROUTE_PREFIX}demos/${id}`;
59
- return isSupportDisablePrerender ? { path: demoPath, prerender: false } : demoPath;
60
- }));
61
- };
62
- }
48
+ const routePrefix = `${import_constants.SP_ROUTE_PREFIX}demos`;
49
+ const examples = (0, import_assets.getExampleAssets)();
50
+ api.appData.exportHtmlData.push(...examples.map(({ id }) => ({
51
+ route: { path: `/${routePrefix}/${id}` },
52
+ file: `${routePrefix}/${id}/index.html`,
53
+ prerender: false
54
+ })));
63
55
  return memo;
64
56
  }
65
57
  });
58
+ api.onGenerateFiles(() => {
59
+ api.writeTmpFile({
60
+ path: "dumi/exportStaticRuntimePlugin.ts",
61
+ content: `
62
+ export function modifyClientRenderOpts(memo: any) {
63
+ const { history, hydrate } = memo;
64
+
65
+ return {
66
+ ...memo,
67
+ hydrate: hydrate && !history.location.pathname.startsWith('/${import_constants.SP_ROUTE_PREFIX}demos'),
68
+ };
69
+ }
70
+ `.trim(),
71
+ noPluginDir: true
72
+ });
73
+ });
74
+ api.addRuntimePlugin(() => {
75
+ return [`@@/dumi/exportStaticRuntimePlugin.ts`];
76
+ });
66
77
  };
67
78
  // Annotate the CommonJS export names for ESM import in node:
68
79
  0 && (module.exports = {});
@@ -50,6 +50,15 @@ var locales_default = (api) => {
50
50
  }
51
51
  }
52
52
  });
53
+ api.onCheck(() => {
54
+ if (api.config.locales) {
55
+ api.config.locales.slice(1).forEach((locale) => {
56
+ if ("base" in locale && locale.base === "/") {
57
+ assert(false, `Only the first locale item is allowed to set base: '/', you can move ${locale.id} to the front as default locale. See more: See https://d.umijs.org/config#locales`);
58
+ }
59
+ });
60
+ }
61
+ });
53
62
  api.register({
54
63
  key: "modifyConfig",
55
64
  stage: Infinity,
@@ -42,7 +42,8 @@ var parser_default = (api) => {
42
42
  config: {
43
43
  schema: (Joi) => Joi.object({
44
44
  unpkgHost: Joi.string().uri().optional(),
45
- resolveFilter: Joi.function().optional()
45
+ resolveFilter: Joi.function().optional(),
46
+ parseOptions: Joi.object().optional()
46
47
  })
47
48
  }
48
49
  });
@@ -59,7 +60,8 @@ var parser_default = (api) => {
59
60
  entryFile: api.config.resolve.entryFile,
60
61
  resolveDir: api.cwd,
61
62
  unpkgHost: api.config.apiParser.unpkgHost,
62
- resolveFilter: api.config.apiParser.resolveFilter
63
+ resolveFilter: api.config.apiParser.resolveFilter,
64
+ parseOptions: api.config.apiParser.parseOptions
63
65
  });
64
66
  });
65
67
  api.onDevCompileDone(({ isFirstCompile }) => {
@@ -181,8 +181,7 @@ var routes_default = (api) => {
181
181
  path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
182
182
  absPath: `/${import_constants.SP_ROUTE_PREFIX}demos/:id`,
183
183
  parentId: demoLayoutId,
184
- file: (0, import_utils.getClientDistFile)("dist/client/pages/Demo", api.cwd),
185
- prerender: false
184
+ file: (0, import_utils.getClientDistFile)("dist/client/pages/Demo", api.cwd)
186
185
  };
187
186
  return routes;
188
187
  });
@@ -29,6 +29,7 @@ var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
29
29
  var import_rehypeDemo = __toESM(require("./rehypeDemo"));
30
30
  var import_rehypeDesc = __toESM(require("./rehypeDesc"));
31
31
  var import_rehypeEnhancedTag = __toESM(require("./rehypeEnhancedTag"));
32
+ var import_rehypeHighlightLine = __toESM(require("./rehypeHighlightLine"));
32
33
  var import_rehypeImg = __toESM(require("./rehypeImg"));
33
34
  var import_rehypeIsolation = __toESM(require("./rehypeIsolation"));
34
35
  var import_rehypeJsxify = __toESM(require("./rehypeJsxify"));
@@ -73,6 +74,8 @@ var transformer_default = async (raw, opts) => {
73
74
  }));
74
75
  processor.use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default, {
75
76
  fileAbsPath: opts.fileAbsPath
77
+ }).use(import_rehypeHighlightLine.default, {
78
+ resolve: opts.resolve
76
79
  }).use(rehypeRemoveComments, { removeConditional: true }).use(import_rehypeStrip.default).use(import_rehypeImg.default).use(import_rehypeDemo.default, {
77
80
  techStacks: opts.techStacks,
78
81
  cwd: opts.cwd,
@@ -36,14 +36,22 @@ var toString;
36
36
  function rehypeEnhancedTag() {
37
37
  return async (tree) => {
38
38
  visit(tree, "element", (node, i, parent) => {
39
- var _a, _b, _c;
39
+ var _a, _b, _c, _d;
40
40
  if (node.tagName === "pre" && isElement((_a = node.children) == null ? void 0 : _a[0]) && node.children[0].tagName === "code") {
41
41
  const className = ((_b = node.children[0].properties) == null ? void 0 : _b.className) || [];
42
42
  const lang = (_c = className.join("").match(/language-(\w+)(?:$| )/)) == null ? void 0 : _c[1];
43
+ const highlightLines = (_d = node.children[0].data) == null ? void 0 : _d.highlightLines;
43
44
  parent.children.splice(i, 1, {
44
45
  type: "element",
45
46
  tagName: "SourceCode",
46
47
  properties: { lang },
48
+ JSXAttributes: [
49
+ {
50
+ type: "JSXAttribute",
51
+ name: "highlightLines",
52
+ value: JSON.stringify(highlightLines)
53
+ }
54
+ ],
47
55
  children: [
48
56
  {
49
57
  type: "text",
@@ -0,0 +1,4 @@
1
+ import type { Root } from 'hast';
2
+ import type { Transformer } from 'unified';
3
+ declare function rehypeHighlightLine(): Transformer<Root>;
4
+ export default rehypeHighlightLine;
@@ -0,0 +1,60 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/loaders/markdown/transformer/rehypeHighlightLine.ts
23
+ var rehypeHighlightLine_exports = {};
24
+ __export(rehypeHighlightLine_exports, {
25
+ default: () => rehypeHighlightLine_default
26
+ });
27
+ module.exports = __toCommonJS(rehypeHighlightLine_exports);
28
+ var visit;
29
+ var isElement;
30
+ var RE = /{((?:\d+(?:-\d+)?,?)+)}/;
31
+ (async () => {
32
+ ({ visit } = await import("unist-util-visit"));
33
+ ({ isElement } = await import("hast-util-is-element"));
34
+ })();
35
+ var attrsToLines = (attrs) => {
36
+ const result = [];
37
+ attrs.split(",").map((v) => v.split("-").map((v2) => parseInt(v2, 10))).forEach(([start, end = start]) => {
38
+ for (let i = start; i <= end; i++) {
39
+ result.push(i);
40
+ }
41
+ });
42
+ return result;
43
+ };
44
+ function rehypeHighlightLine() {
45
+ return async (tree) => {
46
+ visit(tree, "element", (node) => {
47
+ var _a, _b;
48
+ if (isElement(node, "code") && typeof ((_a = node.data) == null ? void 0 : _a.meta) === "string") {
49
+ const lines = (_b = node.data.meta.match(RE)) == null ? void 0 : _b[1];
50
+ if (lines) {
51
+ node.data.meta = node.data.meta.replace(lines, "").trim();
52
+ node.data.highlightLines = attrsToLines(lines);
53
+ }
54
+ }
55
+ });
56
+ };
57
+ }
58
+ var rehypeHighlightLine_default = rehypeHighlightLine;
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.1.15",
3
+ "version": "2.1.17",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -80,8 +80,8 @@
80
80
  "@swc/core": "^1.2.224",
81
81
  "@types/hast": "^2.3.4",
82
82
  "@types/mdast": "^3.0.10",
83
- "@umijs/bundler-utils": "^4.0.55",
84
- "@umijs/core": "^4.0.55",
83
+ "@umijs/bundler-utils": "^4.0.59",
84
+ "@umijs/core": "^4.0.59",
85
85
  "animated-scroll-to": "^2.3.0",
86
86
  "classnames": "2.3.2",
87
87
  "codesandbox": "^2.2.3",
@@ -122,7 +122,7 @@
122
122
  "remark-rehype": "^10.1.0",
123
123
  "sass": "^1.55.0",
124
124
  "sitemap": "^7.1.1",
125
- "umi": "^4.0.55",
125
+ "umi": "^4.0.59",
126
126
  "unified": "^10.1.2",
127
127
  "unist-util-visit": "^4.1.0",
128
128
  "unist-util-visit-parents": "^5.1.1",
@@ -141,7 +141,7 @@
141
141
  "@types/pluralize": "^0.0.29",
142
142
  "@types/react": "^18.0.16",
143
143
  "@types/react-copy-to-clipboard": "^5.0.4",
144
- "@umijs/lint": "^4.0.55",
144
+ "@umijs/lint": "^4.0.59",
145
145
  "@umijs/plugins": "4.0.32",
146
146
  "dumi-theme-mobile": "workspace:*",
147
147
  "eslint": "^8.20.0",
@@ -2,7 +2,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2
2
 
3
3
  import classnames from 'classnames';
4
4
  import { useLocation } from 'dumi';
5
- import PreviewerActions from "dumi/theme/slots/PreviewerActions";
5
+ import PreviewerActions from 'dumi/theme/slots/PreviewerActions';
6
6
  import React from 'react';
7
7
  import "./index.less";
8
8
 
@@ -107,7 +107,7 @@
107
107
  display: inline-block;
108
108
  font-size: 14px;
109
109
  line-height: 1;
110
- font-weight: 500;
110
+ font-weight: bold;
111
111
  background: linear-gradient(
112
112
  to top,
113
113
  rgba(255, 255, 255, 100%),
@@ -2,8 +2,10 @@ import { type Language } from 'prism-react-renderer';
2
2
  import 'prism-themes/themes/prism-one-light.css';
3
3
  import { type FC } from 'react';
4
4
  import './index.less';
5
- declare const SourceCode: FC<{
5
+ interface SourceCodeProps {
6
6
  children: string;
7
7
  lang: Language;
8
- }>;
8
+ highlightLines?: number[];
9
+ }
10
+ declare const SourceCode: FC<SourceCodeProps>;
9
11
  export default SourceCode;
@@ -14,6 +14,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
 
15
15
  import { ReactComponent as IconCheck } from '@ant-design/icons-svg/inline-svg/outlined/check.svg';
16
16
  import { ReactComponent as IconCopy } from '@ant-design/icons-svg/inline-svg/outlined/copy.svg';
17
+ import classNames from 'classnames';
17
18
  import Highlight, { defaultProps } from 'prism-react-renderer';
18
19
  import 'prism-themes/themes/prism-one-light.css';
19
20
  import React, { useRef, useState } from 'react';
@@ -28,9 +29,11 @@ var SIMILAR_DSL = {
28
29
  axml: 'markup'
29
30
  };
30
31
 
31
- var SourceCode = function SourceCode(_ref) {
32
- var children = _ref.children,
33
- lang = _ref.lang;
32
+ var SourceCode = function SourceCode(props) {
33
+ var children = props.children,
34
+ lang = props.lang,
35
+ _props$highlightLines = props.highlightLines,
36
+ highlightLines = _props$highlightLines === void 0 ? [] : _props$highlightLines;
34
37
  var timer = useRef();
35
38
 
36
39
  var _useState = useState(false),
@@ -57,12 +60,12 @@ var SourceCode = function SourceCode(_ref) {
57
60
  code: children.trim(),
58
61
  language: SIMILAR_DSL[lang] || lang,
59
62
  theme: undefined
60
- }), function (_ref2) {
61
- var className = _ref2.className,
62
- style = _ref2.style,
63
- tokens = _ref2.tokens,
64
- getLineProps = _ref2.getLineProps,
65
- getTokenProps = _ref2.getTokenProps;
63
+ }), function (_ref) {
64
+ var className = _ref.className,
65
+ style = _ref.style,
66
+ tokens = _ref.tokens,
67
+ getLineProps = _ref.getLineProps,
68
+ getTokenProps = _ref.getTokenProps;
66
69
  return /*#__PURE__*/React.createElement("pre", {
67
70
  className: className,
68
71
  style: style
@@ -71,7 +74,10 @@ var SourceCode = function SourceCode(_ref) {
71
74
  key: String(i)
72
75
  }, getLineProps({
73
76
  line: line,
74
- key: i
77
+ key: i,
78
+ className: classNames({
79
+ highlighted: highlightLines.includes(i + 1)
80
+ })
75
81
  })), line.map(function (token, key) {
76
82
  return /*#__PURE__*/React.createElement("span", _extends({
77
83
  key: String(i)
@@ -38,6 +38,14 @@
38
38
  &::after {
39
39
  content: none;
40
40
  }
41
+
42
+ // highlight line
43
+ & > .highlighted {
44
+ background-color: shade(@bg-color, 5%);
45
+ width: calc(100% + 48px);
46
+ margin-inline-start: -24px;
47
+ padding-inline-start: 24px;
48
+ }
41
49
  }
42
50
 
43
51
  &-copy {
@@ -92,5 +100,9 @@
92
100
  &-copy {
93
101
  background-color: fadeout(@bg-color, 80%);
94
102
  }
103
+
104
+ & > pre.prism-code > .highlighted {
105
+ background-color: tint(@bg-color, 10%);
106
+ }
95
107
  }
96
108
  }
@@ -13,13 +13,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { ReactComponent as IconSidebar } from '@ant-design/icons-svg/inline-svg/outlined/align-left.svg';
14
14
  import animateScrollTo from 'animated-scroll-to';
15
15
  import { Helmet, useIntl, useLocation, useOutlet, useRouteMeta, useSidebarData, useSiteData } from 'dumi';
16
- import Content from "dumi/theme/slots/Content";
17
- import Features from "dumi/theme/slots/Features";
18
- import Footer from "dumi/theme/slots/Footer";
19
- import Header from "dumi/theme/slots/Header";
20
- import Hero from "dumi/theme/slots/Hero";
21
- import Sidebar from "dumi/theme/slots/Sidebar";
22
- import Toc from "dumi/theme/slots/Toc";
16
+ import Content from 'dumi/theme/slots/Content';
17
+ import Features from 'dumi/theme/slots/Features';
18
+ import Footer from 'dumi/theme/slots/Footer';
19
+ import Header from 'dumi/theme/slots/Header';
20
+ import Hero from 'dumi/theme/slots/Hero';
21
+ import Sidebar from 'dumi/theme/slots/Sidebar';
22
+ import Toc from 'dumi/theme/slots/Toc';
23
23
  import React, { useEffect, useState } from 'react';
24
24
  import "./index.less";
25
25
 
@@ -14,12 +14,12 @@ import HeaderExtra from "../HeadeExtra";
14
14
  import { ReactComponent as IconClose } from '@ant-design/icons-svg/inline-svg/outlined/close.svg';
15
15
  import { ReactComponent as IconMenu } from '@ant-design/icons-svg/inline-svg/outlined/menu.svg';
16
16
  import { useRouteMeta, useSiteData } from 'dumi';
17
- import ColorSwitch from "dumi/theme/slots/ColorSwitch";
18
- import LangSwitch from "dumi/theme/slots/LangSwitch";
19
- import Logo from "dumi/theme/slots/Logo";
20
- import Navbar from "dumi/theme/slots/Navbar";
21
- import RtlSwitch from "dumi/theme/slots/RtlSwitch";
22
- import SearchBar from "dumi/theme/slots/SearchBar";
17
+ import ColorSwitch from 'dumi/theme/slots/ColorSwitch';
18
+ import LangSwitch from 'dumi/theme/slots/LangSwitch';
19
+ import Logo from 'dumi/theme/slots/Logo';
20
+ import Navbar from 'dumi/theme/slots/Navbar';
21
+ import RtlSwitch from 'dumi/theme/slots/RtlSwitch';
22
+ import SearchBar from 'dumi/theme/slots/SearchBar';
23
23
  import React, { useMemo, useState } from 'react';
24
24
  import SocialIcon from "../SocialIcon";
25
25
  import "./index.less";
@@ -1,5 +1,5 @@
1
1
  import { Link, useRouteMeta } from 'dumi';
2
- import HeroTitle from "dumi/theme/slots/HeroTitle";
2
+ import HeroTitle from 'dumi/theme/slots/HeroTitle';
3
3
  import React from 'react';
4
4
  import "./index.less";
5
5
 
@@ -6,7 +6,7 @@
6
6
  color: @c-text;
7
7
  font-size: 22px;
8
8
  line-height: 1;
9
- font-weight: 500;
9
+ font-weight: bold;
10
10
  text-decoration: none;
11
11
 
12
12
  @{dark-selector} & {
@@ -1,7 +1,7 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
3
  import { Link, useLocation, useNavData } from 'dumi';
4
- import NavbarExtra from "dumi/theme/slots/NavbarExtra";
4
+ import NavbarExtra from 'dumi/theme/slots/NavbarExtra';
5
5
  import React from 'react';
6
6
  import "./index.less";
7
7
 
@@ -40,7 +40,7 @@
40
40
 
41
41
  &.active {
42
42
  color: @c-text;
43
- font-weight: 500;
43
+ font-weight: bold;
44
44
 
45
45
  @{dark-selector} & {
46
46
  color: @c-text-dark;
@@ -14,8 +14,8 @@ import { ReactComponent as IconCodeSandbox } from '@ant-design/icons-svg/inline-
14
14
 
15
15
  import { ReactComponent as IconStackBlitz } from '@ant-design/icons-svg/inline-svg/outlined/thunderbolt.svg';
16
16
  import { openCodeSandbox, openStackBlitz, useIntl } from 'dumi';
17
- import SourceCode from "dumi/theme/builtins/SourceCode";
18
- import PreviewerActionsExtra from "dumi/theme/slots/PreviewerActionsExtra";
17
+ import SourceCode from 'dumi/theme/builtins/SourceCode';
18
+ import PreviewerActionsExtra from 'dumi/theme/slots/PreviewerActionsExtra';
19
19
  import Tabs from 'rc-tabs';
20
20
  import React, { useState } from 'react';
21
21
  import "./index.less";
@@ -1,5 +1,5 @@
1
1
  import { NavLink, useLocation, useRouteMeta, useSidebarData } from 'dumi';
2
- import Toc from "dumi/theme/slots/Toc";
2
+ import Toc from 'dumi/theme/slots/Toc';
3
3
  import React from 'react';
4
4
  import "./index.less";
5
5
 
@@ -46,7 +46,7 @@
46
46
  margin: 8px 0;
47
47
  color: @c-text;
48
48
  font-size: 14px;
49
- font-weight: 500;
49
+ font-weight: bold;
50
50
  white-space: nowrap;
51
51
  overflow: hidden;
52
52
  text-overflow: ellipsis;
@@ -86,7 +86,7 @@
86
86
 
87
87
  &.active {
88
88
  color: @c-primary;
89
- font-weight: 500;
89
+ font-weight: bold;
90
90
 
91
91
  @{dark-selector} & {
92
92
  color: @c-primary-dark;