dumi 2.0.0-rc.5 → 2.0.0-rc.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.
@@ -0,0 +1 @@
1
+ (function(){var e={226:function(e){var n=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var __export=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:true})};var __copyProps=(e,o,i,c)=>{if(o&&typeof o==="object"||typeof o==="function"){for(let s of r(o))if(!a.call(e,s)&&s!==i)n(e,s,{get:()=>o[s],enumerable:!(c=t(o,s))||c.enumerable})}return e};var __toCommonJS=e=>__copyProps(n({},"__esModule",{value:true}),e);var o={};__export(o,{default:()=>analytics_default});e.exports=__toCommonJS(o);var analytics_default=e=>{const n=process.env.GA_KEY;const t=process.env.GA_V2_KEY;const enableBy=e=>e.config.analytics||n;e.describe({key:"analytics",config:{schema(e){return e.alternatives().try(e.object({baidu:e.string(),ga:e.string(),ga_v2:e.string()}),e.boolean().invalid(true))},onChange:e.ConfigChangeType.reload},enableBy:enableBy});const baiduTpl=e=>`\n (function() {\n var hm = document.createElement('script');\n hm.src = '//hm.baidu.com/hm.js?${e}';\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(hm, s);\n })();\n `;const gaTpl=e=>`\n (function(){\n if (!location.port) {\n (function (i, s, o, g, r, a, m) {\n i['GoogleAnalyticsObject'] = r;\n i[r] = i[r] || function () {\n (i[r].q = i[r].q || []).push(arguments)\n }, i[r].l = 1 * new Date();\n a = s.createElement(o),\n m = s.getElementsByTagName(o)[0];\n a.async = 1;\n a.src = g;\n m.parentNode.insertBefore(a, m)\n })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');\n ga('create', '${e}', 'auto');\n ga('send', 'pageview');\n }\n })();\n `;const gaV2Tpl=e=>`\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${e}');\n `.trim();e.addHTMLHeadScripts((()=>{const r=e.config.analytics||{};const{baidu:a,ga:o=n,ga_v2:i=t}=r;const c=[];if(a){c.push({content:"var _hmt = _hmt || [];"})}if(e.env!=="development"){if(a){c.push({content:baiduTpl(a)})}if(o){c.push({content:gaTpl(o)})}if(i){c.push({async:true,src:`//www.googletagmanager.com/gtag/js?id=${i}`},{content:gaV2Tpl(i)})}}return c.filter(Boolean)}))};0&&0}};var n={};function __nccwpck_require__(t){var r=n[t];if(r!==undefined){return r.exports}var a=n[t]={exports:{}};var o=true;try{e[t](a,a.exports,__nccwpck_require__);o=false}finally{if(o)delete n[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(226);module.exports=t})();
@@ -0,0 +1 @@
1
+ {"name":"@umijs/plugins","version":"4.0.30","authors":["chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"],"license":"MIT","_lastModified":"2022-11-13T07:05:33.094Z"}
@@ -118,7 +118,7 @@ var derivative_default = (api) => {
118
118
  }
119
119
  }
120
120
  });
121
- api.registerPlugins([require.resolve("@umijs/plugins/dist/analytics")]);
121
+ api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
122
122
  };
123
123
  // Annotate the CommonJS export names for ESM import in node:
124
124
  0 && (module.exports = {
@@ -47,7 +47,7 @@ function localizeUmiRoute(route, locales) {
47
47
  function flatRoute(route) {
48
48
  if (route.parentId !== "DocLayout") {
49
49
  route.parentId = "DocLayout";
50
- route.path = route.path === "*" ? route.path : route.absPath.slice(1);
50
+ route.path = route.path === "*" ? route.path.toLowerCase() : route.absPath.slice(1).toLowerCase();
51
51
  }
52
52
  }
53
53
  function getClientPageFile(file, cwd) {
@@ -148,7 +148,7 @@ var routes_default = (api) => {
148
148
  const base = import_path.default.join(api.cwd, dir);
149
149
  const atomFiles = import_plugin_utils.glob.sync("{*,*/index,*/index.*,*/README,*/README.*}.md", { cwd: base });
150
150
  atomFiles.forEach((file) => {
151
- const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
151
+ const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/").toLowerCase();
152
152
  const routeId = (0, import_utils.createRouteId)(file);
153
153
  routes[routeId] = {
154
154
  id: routeId,
@@ -176,6 +176,12 @@ var routes_default = (api) => {
176
176
  parentId: demoLayoutId,
177
177
  file: getClientPageFile("client/pages/Demo", api.cwd)
178
178
  };
179
+ Object.values(routes).forEach((route) => {
180
+ if (route.path !== encodeURI(route.path)) {
181
+ throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
182
+ at ${route.file}`);
183
+ }
184
+ });
179
185
  return routes;
180
186
  });
181
187
  api.addLayouts(() => {
@@ -110,6 +110,8 @@ var theme_default = (api) => {
110
110
  api.onGenerateFiles(() => {
111
111
  themeMapKeys.forEach((key) => {
112
112
  Object.values(originalThemeData[key] || {}).forEach((item) => {
113
+ if (item.source === "dumi")
114
+ return;
113
115
  let contents = [];
114
116
  const [, exports] = (0, import_bundler_utils.parseModuleSync)({
115
117
  path: item.source,
@@ -30,10 +30,12 @@ var import_plugin_utils = require("umi/plugin-utils");
30
30
  function getComponentMapFromDir(globExp, dir) {
31
31
  return import_plugin_utils.glob.sync(globExp, { cwd: dir }).reduce((ret, file) => {
32
32
  const specifier = import_path.default.basename(file.replace(/(\/index)?\.[a-z]+$/, ""));
33
- ret[specifier] = {
34
- specifier,
35
- source: (0, import_plugin_utils.winPath)(import_path.default.join(dir, file))
36
- };
33
+ if (/^[A-Z\d]/.test(specifier)) {
34
+ ret[specifier] = {
35
+ specifier,
36
+ source: (0, import_plugin_utils.winPath)(import_path.default.join(dir, file))
37
+ };
38
+ }
37
39
  return ret;
38
40
  }, {});
39
41
  }
@@ -37,6 +37,7 @@ var import_rehypeRaw = __toESM(require("./rehypeRaw"));
37
37
  var import_rehypeSlug = __toESM(require("./rehypeSlug"));
38
38
  var import_rehypeStrip = __toESM(require("./rehypeStrip"));
39
39
  var import_rehypeText = __toESM(require("./rehypeText"));
40
+ var import_remarkContainer = __toESM(require("./remarkContainer"));
40
41
  var import_remarkEmbed = __toESM(require("./remarkEmbed"));
41
42
  var import_remarkMeta = __toESM(require("./remarkMeta"));
42
43
  function applyUnifiedPlugin(opts) {
@@ -50,6 +51,7 @@ var transformer_default = async (raw, opts) => {
50
51
  const { unified } = await import("unified");
51
52
  const { default: remarkParse } = await import("remark-parse");
52
53
  const { default: remarkFrontmatter } = await import("remark-frontmatter");
54
+ const { default: remarkDirective } = await import("remark-directive");
53
55
  const { default: remarkBreaks } = await import("remark-breaks");
54
56
  const { default: remarkGfm } = await import("remark-gfm");
55
57
  const { default: remarkRehype } = await import("remark-rehype");
@@ -63,7 +65,7 @@ var transformer_default = async (raw, opts) => {
63
65
  cwd: opts.cwd,
64
66
  fileAbsPath: opts.fileAbsPath,
65
67
  resolve: opts.resolve
66
- }).use(remarkBreaks).use(remarkGfm);
68
+ }).use(remarkDirective).use(import_remarkContainer.default).use(remarkBreaks).use(remarkGfm);
67
69
  (_a = opts.extraRemarkPlugins) == null ? void 0 : _a.forEach((plugin) => applyUnifiedPlugin({
68
70
  plugin,
69
71
  processor,
@@ -42,7 +42,11 @@ function rehypeSlug() {
42
42
  visit(tree, "element", (node) => {
43
43
  var _a, _b;
44
44
  if (HEADING_TAGS.includes(node.tagName)) {
45
- const title = toString(node);
45
+ const title = toString({
46
+ type: "element",
47
+ tagName: node.tagName,
48
+ children: node.children.filter((child) => child.type !== "element" || child.tagName !== "Badge")
49
+ }).trim();
46
50
  const depth = Number(node.tagName.slice(1));
47
51
  const id = slugger.slug(title);
48
52
  node.properties.id = id;
@@ -0,0 +1,3 @@
1
+ import type { Root } from 'mdast';
2
+ import type { Transformer } from 'unified';
3
+ export default function remarkContainer(): Transformer<Root>;
@@ -0,0 +1,53 @@
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/remarkContainer.ts
23
+ var remarkContainer_exports = {};
24
+ __export(remarkContainer_exports, {
25
+ default: () => remarkContainer
26
+ });
27
+ module.exports = __toCommonJS(remarkContainer_exports);
28
+ var visit;
29
+ var SKIP;
30
+ var VALID_CONTAINER_TYPES = ["info", "warning", "success", "error"];
31
+ (async () => {
32
+ ({ visit, SKIP } = await import("unist-util-visit"));
33
+ })();
34
+ function remarkContainer() {
35
+ return (tree) => {
36
+ visit(tree, (node, i, parent) => {
37
+ if (node.type === "containerDirective" && VALID_CONTAINER_TYPES.includes(node.name)) {
38
+ const attrs = Object.entries(node.attributes || {}).reduce((ret, [name, value]) => `${ret} ${value ? `${name}="${value}"` : name}`, "");
39
+ parent.children.splice(i, 1, {
40
+ type: "html",
41
+ value: `<Container type="${node.name}"${attrs}>`,
42
+ position: node.position
43
+ }, ...(node.children || []).concat({
44
+ type: "html",
45
+ value: "</Container>"
46
+ }));
47
+ return SKIP;
48
+ }
49
+ });
50
+ };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-rc.5",
3
+ "version": "2.0.0-rc.7",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -59,7 +59,6 @@
59
59
  "@types/mdast": "^3.0.10",
60
60
  "@umijs/bundler-utils": "^4.0.30",
61
61
  "@umijs/core": "^4.0.30",
62
- "@umijs/plugins": "^4.0.30",
63
62
  "codesandbox": "^2.2.3",
64
63
  "deepmerge": "^4.2.2",
65
64
  "dumi-afx-deps": "^1.0.0-alpha.1",
@@ -91,6 +90,7 @@
91
90
  "rehype-remove-comments": "^5.0.0",
92
91
  "rehype-stringify": "^9.0.3",
93
92
  "remark-breaks": "^3.0.2",
93
+ "remark-directive": "^2.0.1",
94
94
  "remark-frontmatter": "^4.0.1",
95
95
  "remark-gfm": "^3.0.1",
96
96
  "remark-parse": "^10.0.1",
@@ -117,6 +117,7 @@
117
117
  "@types/react-copy-to-clipboard": "^5.0.4",
118
118
  "@types/react-helmet": "^6.1.5",
119
119
  "@umijs/lint": "^4.0.30",
120
+ "@umijs/plugins": "^4.0.30",
120
121
  "eslint": "^8.20.0",
121
122
  "father": "^4.1.0",
122
123
  "husky": "^8.0.1",
@@ -0,0 +1,7 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ import './index.less';
3
+ declare const Badge: FC<{
4
+ children: ReactNode;
5
+ type: 'info' | 'warning' | 'error' | 'success';
6
+ }>;
7
+ export default Badge;
@@ -0,0 +1,12 @@
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
+
3
+ import React from 'react';
4
+ import "./index.less";
5
+
6
+ var Badge = function Badge(props) {
7
+ return /*#__PURE__*/React.createElement("span", _extends({
8
+ className: "dumi-default-badge"
9
+ }, props));
10
+ };
11
+
12
+ export default Badge;
@@ -0,0 +1,33 @@
1
+ @import (reference) '../../styles/variables.less';
2
+
3
+ .@{prefix}-badge {
4
+ display: inline-block;
5
+ margin-left: 2px;
6
+ padding: 1px 8px;
7
+ font-size: 12px;
8
+ font-weight: 400;
9
+ line-height: 20px;
10
+ border-radius: 4px;
11
+ vertical-align: top;
12
+
13
+ &:not([type]),
14
+ &[type='info'] {
15
+ color: @c-primary;
16
+ background: lighten(@c-primary, 40%);
17
+ }
18
+
19
+ &[type='warning'] {
20
+ color: @c-warning;
21
+ background: lighten(@c-warning, 48%);
22
+ }
23
+
24
+ &[type='success'] {
25
+ color: @c-success;
26
+ background: lighten(@c-success, 54%);
27
+ }
28
+
29
+ &[type='error'] {
30
+ color: @c-error;
31
+ background: lighten(@c-error, 47%);
32
+ }
33
+ }
@@ -0,0 +1,8 @@
1
+ import { type FC, type ReactNode } from 'react';
2
+ import './index.less';
3
+ declare const Container: FC<{
4
+ type: string;
5
+ title?: string;
6
+ children: ReactNode;
7
+ }>;
8
+ export default Container;
@@ -0,0 +1,39 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ 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; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import { ReactComponent as IconSuccess } from '@ant-design/icons-svg/inline-svg/outlined/check-circle.svg';
14
+ import { ReactComponent as IconError } from '@ant-design/icons-svg/inline-svg/outlined/close-circle.svg';
15
+ import { ReactComponent as IconInfo } from '@ant-design/icons-svg/inline-svg/outlined/info-circle.svg';
16
+ import { ReactComponent as IconWarning } from '@ant-design/icons-svg/inline-svg/outlined/warning.svg';
17
+ import React, { useState } from 'react';
18
+ import "./index.less";
19
+ var ICONS = {
20
+ info: IconInfo,
21
+ warning: IconWarning,
22
+ success: IconSuccess,
23
+ error: IconError
24
+ };
25
+
26
+ var Container = function Container(props) {
27
+ var _useState = useState(function () {
28
+ return ICONS[props.type];
29
+ }),
30
+ _useState2 = _slicedToArray(_useState, 1),
31
+ Icon = _useState2[0];
32
+
33
+ return /*#__PURE__*/React.createElement("div", {
34
+ className: "dumi-default-container markdown",
35
+ "data-type": props.type
36
+ }, /*#__PURE__*/React.createElement(Icon, null), /*#__PURE__*/React.createElement("h4", null, props.title || props.type.toUpperCase()), props.children);
37
+ };
38
+
39
+ export default Container;
@@ -0,0 +1,70 @@
1
+ @import (reference) '../../styles/variables.less';
2
+
3
+ .@{prefix}-container {
4
+ margin: 24px 0 32px;
5
+ padding: 18px 16px 18px 44px;
6
+ border-radius: 4px;
7
+
8
+ > svg {
9
+ float: left;
10
+ fill: currentcolor;
11
+ margin-left: -26px;
12
+ width: 18px;
13
+ }
14
+
15
+ > h4 {
16
+ margin: 1px 0 0;
17
+ font-size: 15px;
18
+ line-height: 1;
19
+ }
20
+
21
+ > p {
22
+ margin: 8px 0 0;
23
+ font-size: 15px;
24
+ line-height: 1.2;
25
+ }
26
+
27
+ &[data-type='info'] {
28
+ @color: darken(desaturate(@c-primary, 45%), 10%);
29
+
30
+ color: @color;
31
+ background: lighten(@c-primary, 42%);
32
+
33
+ > p {
34
+ color: desaturate(@color, 20%);
35
+ }
36
+ }
37
+
38
+ &[data-type='warning'] {
39
+ @color: darken(desaturate(@c-warning, 20%), 2%);
40
+
41
+ color: @color;
42
+ background: lighten(@c-warning, 51%);
43
+
44
+ > p {
45
+ color: desaturate(@color, 24%);
46
+ }
47
+ }
48
+
49
+ &[data-type='success'] {
50
+ @color: darken(desaturate(@c-success, 5%), 1%);
51
+
52
+ color: @color;
53
+ background: lighten(@c-success, 59%);
54
+
55
+ > p {
56
+ color: desaturate(@color, 22%);
57
+ }
58
+ }
59
+
60
+ &[data-type='error'] {
61
+ @color: darken(desaturate(@c-error, 20%), 1%);
62
+
63
+ color: @color;
64
+ background: lighten(@c-error, 51%);
65
+
66
+ > p {
67
+ color: desaturate(@color, 25%);
68
+ }
69
+ }
70
+ }
@@ -9,7 +9,8 @@ var Sidebar = function Sidebar() {
9
9
 
10
10
  var meta = useRouteMeta();
11
11
  var sidebar = useSidebarData();
12
- return sidebar && /*#__PURE__*/React.createElement("div", {
12
+ if (!sidebar) return null;
13
+ return /*#__PURE__*/React.createElement("div", {
13
14
  className: "dumi-default-sidebar"
14
15
  }, sidebar.map(function (item, i) {
15
16
  return /*#__PURE__*/React.createElement("dl", {
@@ -7,13 +7,15 @@
7
7
  @s-header-height-m: 52px;
8
8
 
9
9
  @c-primary: #1677ff;
10
+ @c-warning: #d59200;
11
+ @c-success: #208a41;
12
+ @c-error: #ce1f31;
10
13
  @c-text: #30363f;
11
14
  @c-text-secondary: #4f5866;
12
15
  @c-text-note: #8a9099;
13
16
  @c-border: #d0d5d8;
14
17
  @c-border-light: #e4e9ec;
15
18
  @c-site-bg: #f7f9fb;
16
- @c-warning: #dd9600;
17
19
 
18
20
  @mobile: ~'only screen and (max-width: 767px)';
19
21
  @tablet: ~'only screen and (min-width: 768px) and (max-width: 1024px)';