dumi 2.0.0-alpha.4 → 2.0.0-beta.0

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/bin/dumi.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('v8-compile-cache');
3
+ // disable for TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
4
+ // require('v8-compile-cache');
4
5
  require('../dist/cli');
@@ -26,6 +26,7 @@ var import_plugin_utils = require("umi/plugin-utils");
26
26
  var meta_default = (api) => {
27
27
  const mdRouteFiles = [];
28
28
  api.modifyRoutes((routes) => {
29
+ mdRouteFiles.length = 0;
29
30
  Object.values(routes).forEach((route) => {
30
31
  if (route.file.endsWith(".md")) {
31
32
  mdRouteFiles.push({
@@ -42,7 +42,13 @@ function localizeUmiRoute(route, locales) {
42
42
  }
43
43
  }
44
44
  var routes_default = (api) => {
45
+ var _a, _b, _c;
46
+ const extraWatchPaths = [
47
+ ...((_b = (_a = api.userConfig.resolve) == null ? void 0 : _a.entityDirs) == null ? void 0 : _b.map(({ dir }) => dir)) || ["docs"],
48
+ ...((_c = api.userConfig.resolve) == null ? void 0 : _c.docDirs) || []
49
+ ].map((dir) => import_path.default.join(api.cwd, dir, "**/*.md"));
45
50
  api.describe({ key: "dumi:routes" });
51
+ api.addTmpGenerateWatcherPaths(() => extraWatchPaths);
46
52
  api.modifyConfig((memo) => {
47
53
  memo.conventionRoutes = {
48
54
  base: import_path.default.join(__dirname, "dumi-disable-default-routes")
@@ -53,8 +59,8 @@ var routes_default = (api) => {
53
59
  if (api.userConfig.resolve) {
54
60
  const keys = ["docDirs", "entityDirs"];
55
61
  keys.forEach((key) => {
56
- var _a;
57
- if (((_a = api.userConfig.resolve[key]) == null ? void 0 : _a.length) === 0)
62
+ var _a2;
63
+ if (((_a2 = api.userConfig.resolve[key]) == null ? void 0 : _a2.length) === 0)
58
64
  memo.resolve[key] = [];
59
65
  });
60
66
  }
@@ -27,6 +27,7 @@ __export(transformer_exports, {
27
27
  module.exports = __toCommonJS(transformer_exports);
28
28
  var import_rehypeDemo = __toESM(require("./rehypeDemo"));
29
29
  var import_rehypeEmbed = __toESM(require("./rehypeEmbed"));
30
+ var import_rehypeEnhancedTag = __toESM(require("./rehypeEnhancedTag"));
30
31
  var import_rehypeIsolation = __toESM(require("./rehypeIsolation"));
31
32
  var import_rehypeJsxify = __toESM(require("./rehypeJsxify"));
32
33
  var import_rehypeRaw = __toESM(require("./rehypeRaw"));
@@ -61,7 +62,7 @@ var transformer_default = async (raw, opts) => {
61
62
  cwd: opts.cwd,
62
63
  fileAbsPath: opts.fileAbsPath,
63
64
  codeBlockMode: opts.codeBlockMode
64
- }).use(import_rehypeSlug.default, opts).use(rehypeAutolinkHeadings).use(import_rehypeIsolation.default);
65
+ }).use(import_rehypeSlug.default, opts).use(rehypeAutolinkHeadings).use(import_rehypeIsolation.default).use(import_rehypeEnhancedTag.default);
65
66
  (_b = opts.extraRehypePlugins) == null ? void 0 : _b.forEach((plugin) => applyUnifiedPlugin({
66
67
  plugin,
67
68
  processor,
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'hast';
2
+ import type { Transformer } from 'unified';
3
+ export default function rehypeEnhancedTag(): Transformer<Root>;
@@ -0,0 +1,54 @@
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/rehypeEnhancedTag.ts
23
+ var rehypeEnhancedTag_exports = {};
24
+ __export(rehypeEnhancedTag_exports, {
25
+ default: () => rehypeEnhancedTag
26
+ });
27
+ module.exports = __toCommonJS(rehypeEnhancedTag_exports);
28
+ var visit;
29
+ var isElement;
30
+ var toString;
31
+ (async () => {
32
+ ({ visit } = await import("unist-util-visit"));
33
+ ({ isElement } = await import("hast-util-is-element"));
34
+ ({ toString } = await import("hast-util-to-string"));
35
+ })();
36
+ function rehypeEnhancedTag() {
37
+ return async (tree) => {
38
+ visit(tree, "element", (node, i, parent) => {
39
+ var _a, _b, _c;
40
+ if (node.tagName === "pre" && isElement((_a = node.children) == null ? void 0 : _a[0]) && node.children[0].tagName === "code") {
41
+ const className = ((_b = node.children[0].properties) == null ? void 0 : _b.className) || [];
42
+ const lang = (_c = className.join("").match(/language-(\w+)(?:$| )/)) == null ? void 0 : _c[1];
43
+ parent.children.splice(i, 1, {
44
+ type: "element",
45
+ tagName: "SourceCode",
46
+ properties: { lang },
47
+ children: [{ type: "text", value: toString(node.children[0]) }]
48
+ });
49
+ }
50
+ });
51
+ };
52
+ }
53
+ // Annotate the CommonJS export names for ESM import in node:
54
+ 0 && (module.exports = {});
@@ -32,19 +32,25 @@ var visit;
32
32
  function isDemoNode(node) {
33
33
  return ["DumiDemo", "DumiDemoGrid"].includes(node.tagName);
34
34
  }
35
+ function isReactComponent(node) {
36
+ return /^[A-Z].+/.test(node.tagName);
37
+ }
35
38
  function rehypeIsolation() {
36
39
  return (tree) => {
37
40
  visit(tree, "root", (node) => {
38
41
  node.children = node.children.reduce((nextChildren, current) => {
42
+ var _a, _b;
39
43
  let prevSibling = nextChildren[nextChildren.length - 1];
40
44
  if (isDemoNode(current)) {
41
45
  nextChildren.push(current);
46
+ } else if (current.tagName === "p" && ((_a = current.children) == null ? void 0 : _a.length) === 1 && isReactComponent(current.children[0]) || isReactComponent(current)) {
47
+ nextChildren.push(current.tagName === "p" ? (_b = current.children) == null ? void 0 : _b[0] : current);
42
48
  } else {
43
- if (!prevSibling || isDemoNode(prevSibling)) {
49
+ if (!prevSibling || isDemoNode(prevSibling) || isReactComponent(prevSibling)) {
44
50
  prevSibling = {
45
51
  type: "element",
46
52
  tagName: "div",
47
- properties: { className: "markdown" },
53
+ properties: { className: ["markdown"] },
48
54
  children: []
49
55
  };
50
56
  nextChildren.push(prevSibling);
@@ -63,7 +63,6 @@ var ReactTechStack = class {
63
63
  },
64
64
  module: {
65
65
  type: "commonjs",
66
- importInterop: "none",
67
66
  strictMode: false
68
67
  },
69
68
  plugin: (m) => new ReactDemoVisitor().visitProgram(m)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-alpha.4",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -17,8 +17,11 @@
17
17
  "scripts": {
18
18
  "build": "father build",
19
19
  "build:deps": "father prebundle",
20
+ "custom-install": "pnpm i",
20
21
  "dev": "father dev",
21
- "postinstall": "umi setup",
22
+ "docs:build": "node ./bin/dumi.js build",
23
+ "docs:dev": "node ./bin/dumi.js dev",
24
+ "postinstall": "npm run build && node ./bin/dumi.js setup",
22
25
  "lint": "npm run lint:es && npm run lint:css",
23
26
  "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
24
27
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
@@ -1,3 +1,4 @@
1
1
  // override .heti root-selector
2
2
  $root-selector: '.markdown';
3
+ $line-length: 100%;
3
4
  @import 'heti/lib/heti.scss';
@@ -15,6 +15,14 @@
15
15
  background: darken(@c-site-bg, 2%);
16
16
  border-radius: 2px;
17
17
  }
18
+
19
+ // pre tag
20
+ pre {
21
+ font-size: 14px;
22
+ padding-left: 24px;
23
+ padding-right: 24px;
24
+ background-color: tint(@c-site-bg, 50%);
25
+ }
18
26
  }
19
27
 
20
28
  .@{prefix}-content {
@@ -23,12 +23,15 @@ var SearchBar = function SearchBar() {
23
23
  };
24
24
  }, []);
25
25
  return /*#__PURE__*/React.createElement("div", {
26
- className: "dumi-default-search-bar"
26
+ className: "dumi-default-search-bar",
27
+ "data-dumi-tooltip": "\u6682\u4E0D\u53EF\u7528",
28
+ "data-dumi-tooltip-bottom": true
27
29
  }, /*#__PURE__*/React.createElement(IconSearch, null), /*#__PURE__*/React.createElement("input", {
28
30
  placeholder: intl.formatMessage({
29
31
  id: 'header.search.placeholder'
30
32
  }),
31
- ref: input
33
+ ref: input,
34
+ disabled: true
32
35
  }), /*#__PURE__*/React.createElement("span", {
33
36
  className: "dumi-default-search-shortcut"
34
37
  }, symbol, " K"));
@@ -2,6 +2,7 @@
2
2
 
3
3
  .@{prefix}-search-bar {
4
4
  position: relative;
5
+ cursor: not-allowed;
5
6
 
6
7
  &:not(:last-child) {
7
8
  margin-right: 28px;
@@ -29,6 +30,7 @@
29
30
  outline: none;
30
31
  transition: all 0.3s;
31
32
  background-color: transparent;
33
+ pointer-events: none;
32
34
 
33
35
  &:focus {
34
36
  border-color: fade(@c-primary, 50%);
@@ -13,8 +13,11 @@ var Toc = function Toc() {
13
13
 
14
14
  return /*#__PURE__*/React.createElement("ul", {
15
15
  className: "dumi-default-toc"
16
- }, toc.map(function (item) {
17
- var link = "#".concat(item.id);
16
+ }, toc.filter(function (_ref) {
17
+ var depth = _ref.depth;
18
+ return depth > 1 && depth < 4;
19
+ }).map(function (item) {
20
+ var link = "#".concat(encodeURIComponent(item.id));
18
21
  return /*#__PURE__*/React.createElement("li", {
19
22
  key: item.id,
20
23
  "data-depth": item.depth
@@ -10,22 +10,28 @@
10
10
  display: none;
11
11
  }
12
12
 
13
- > li > a {
14
- display: block;
15
- margin: 6px 0;
16
- padding: 2px 12px;
17
- color: @c-text-secondary;
18
- font-size: 13px;
19
- line-height: 1;
20
- text-decoration: none;
21
- white-space: nowrap;
22
- overflow: hidden;
23
- text-overflow: ellipsis;
13
+ > li {
14
+ > a {
15
+ display: block;
16
+ margin: 6px 0;
17
+ padding: 3px 12px;
18
+ color: @c-text-secondary;
19
+ font-size: 13px;
20
+ line-height: 1;
21
+ text-decoration: none;
22
+ white-space: nowrap;
23
+ overflow: hidden;
24
+ text-overflow: ellipsis;
24
25
 
25
- &.active {
26
- margin-left: -1px;
27
- color: @c-text;
28
- border-left: 1px solid @c-primary;
26
+ &.active {
27
+ margin-left: -1px;
28
+ color: @c-text;
29
+ border-left: 1px solid @c-primary;
30
+ }
31
+ }
32
+
33
+ &[data-depth='3'] > a {
34
+ padding-left: 20px;
29
35
  }
30
36
  }
31
37
  }
@@ -43,4 +43,22 @@
43
43
  opacity: 0;
44
44
  }
45
45
  }
46
+
47
+ &[data-dumi-tooltip-bottom] {
48
+ &::before,
49
+ &::after {
50
+ bottom: auto;
51
+ top: 100%;
52
+ }
53
+
54
+ &::before {
55
+ margin-top: 8px;
56
+ margin-bottom: 0;
57
+ }
58
+
59
+ &::after {
60
+ border-top-color: transparent;
61
+ border-bottom-color: #000;
62
+ }
63
+ }
46
64
  }