dumi 2.0.0-rc.3 → 2.0.0-rc.4

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.
@@ -43,7 +43,7 @@ async function parseBlockAsset(opts) {
43
43
  sources: {},
44
44
  frontmatter: null
45
45
  };
46
- await (0, import_esbuild.build)({
46
+ const deferrer = (0, import_esbuild.build)({
47
47
  write: false,
48
48
  bundle: true,
49
49
  logLevel: "silent",
@@ -116,6 +116,10 @@ async function parseBlockAsset(opts) {
116
116
  }
117
117
  ]
118
118
  });
119
+ try {
120
+ await deferrer;
121
+ } catch {
122
+ }
119
123
  return result;
120
124
  }
121
125
  var block_default = parseBlockAsset;
@@ -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,7 +2,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
2
2
 
3
3
  import { SP_ROUTE_PREFIX } from "../../constants";
4
4
  import { useSiteData } from 'dumi';
5
- import Previewer from 'dumi/theme/builtins/Previewer';
5
+ import Previewer from "dumi/theme/builtins/Previewer";
6
6
  import React, { createElement } from 'react';
7
7
  export var DumiDemo = function DumiDemo(props) {
8
8
  var _useSiteData = useSiteData(),
@@ -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 { useLocation, 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) {
@@ -27,6 +27,7 @@ __export(derivative_exports, {
27
27
  });
28
28
  module.exports = __toCommonJS(derivative_exports);
29
29
  var import_constants = require("../constants");
30
+ var import_bundler_utils = require("@umijs/bundler-utils");
30
31
  var import_assert = __toESM(require("assert"));
31
32
  var import_fs = __toESM(require("fs"));
32
33
  var import_path = __toESM(require("path"));
@@ -50,7 +51,20 @@ function getFilesByGlob(globExp, dir) {
50
51
  var derivative_default = (api) => {
51
52
  const dumiAbsDir = import_path.default.join(api.cwd, import_constants.LOCAL_DUMI_DIR);
52
53
  const strategies = {
53
- appJS: getFilesByGlob.bind(null, "app.{js,jsx,ts,tsx}", dumiAbsDir),
54
+ async appJS() {
55
+ const [appJS] = getFilesByGlob("app.{js,jsx,ts,tsx}", dumiAbsDir);
56
+ if (appJS) {
57
+ const [, exports] = await (0, import_bundler_utils.parseModule)({
58
+ path: appJS,
59
+ content: import_fs.default.readFileSync(appJS, "utf-8")
60
+ });
61
+ return {
62
+ path: appJS,
63
+ exports
64
+ };
65
+ }
66
+ return null;
67
+ },
54
68
  globalCSS: getFilesByGlob.bind(null, "global.{css,less,scss,sass}", dumiAbsDir),
55
69
  globalJS: getFilesByGlob.bind(null, "global.{js,jsx,ts,tsx}", dumiAbsDir),
56
70
  overridesCSS: getFilesByGlob.bind(null, "overrides.{css,less,scss,sass}", dumiAbsDir)
@@ -89,19 +103,20 @@ var derivative_default = (api) => {
89
103
  memo.exportStatic || (memo.exportStatic = {});
90
104
  return memo;
91
105
  });
92
- api.modifyAppData((memo) => {
93
- Object.entries(strategies).forEach(([key, fn]) => {
94
- memo[key] = fn();
95
- });
106
+ api.modifyAppData(async (memo) => {
107
+ for (const [key, strategy] of Object.entries(strategies)) {
108
+ memo[key] = await strategy();
109
+ }
96
110
  return memo;
97
111
  });
98
- api.onGenerateFiles(() => {
99
- Object.entries(strategies).forEach(([key, fn]) => {
100
- api.appData[key] = fn();
101
- });
102
- });
103
- api.addRuntimePlugin(() => {
104
- return strategies.appJS().slice(0, 1);
112
+ api.register({
113
+ key: "onGenerateFiles",
114
+ stage: -Infinity,
115
+ async fn() {
116
+ for (const [key, strategy] of Object.entries(strategies)) {
117
+ api.appData[key] = await strategy();
118
+ }
119
+ }
105
120
  });
106
121
  api.registerPlugins([require.resolve("@umijs/plugins/dist/analytics")]);
107
122
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-rc.3",
3
+ "version": "2.0.0-rc.4",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "lint": "npm run lint:es && npm run lint:css",
26
26
  "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
27
27
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
28
- "prepare": "npm run build && node ./bin/dumi.js setup && npm run docs:sync",
28
+ "prepare": "husky install && npm run build && node ./bin/dumi.js setup && npm run docs:sync",
29
29
  "prepublishOnly": "npm run build",
30
30
  "test": "vitest"
31
31
  },
@@ -57,9 +57,9 @@
57
57
  "@swc/core": "^1.2.224",
58
58
  "@types/hast": "^2.3.4",
59
59
  "@types/mdast": "^3.0.10",
60
- "@umijs/bundler-utils": "^4.0.29",
61
- "@umijs/core": "^4.0.29",
62
- "@umijs/plugins": "^4.0.29",
60
+ "@umijs/bundler-utils": "^4.0.30",
61
+ "@umijs/core": "^4.0.30",
62
+ "@umijs/plugins": "^4.0.30",
63
63
  "codesandbox": "^2.2.3",
64
64
  "deepmerge": "^4.2.2",
65
65
  "dumi-afx-deps": "^1.0.0-alpha.1",
@@ -96,7 +96,7 @@
96
96
  "remark-parse": "^10.0.1",
97
97
  "remark-rehype": "^10.1.0",
98
98
  "sass": "^1.55.0",
99
- "umi": "^4.0.29",
99
+ "umi": "^4.0.30",
100
100
  "unified": "^10.1.2",
101
101
  "unist-util-visit": "^4.1.0",
102
102
  "unist-util-visit-parents": "^5.1.1",
@@ -116,7 +116,7 @@
116
116
  "@types/react": "^18.0.16",
117
117
  "@types/react-copy-to-clipboard": "^5.0.4",
118
118
  "@types/react-helmet": "^6.1.5",
119
- "@umijs/lint": "^4.0.29",
119
+ "@umijs/lint": "^4.0.30",
120
120
  "eslint": "^8.20.0",
121
121
  "father": "^4.1.0",
122
122
  "husky": "^8.0.1",
@@ -1,7 +1,7 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
2
 
3
3
  import { useLocation } from 'dumi';
4
- import PreviewerActions from 'dumi/theme/slots/PreviewerActions';
4
+ import PreviewerActions from "dumi/theme/slots/PreviewerActions";
5
5
  import React from 'react';
6
6
  import "./index.less";
7
7
 
@@ -12,13 +12,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
13
13
  import { ReactComponent as IconSidebar } from '@ant-design/icons-svg/inline-svg/outlined/align-left.svg';
14
14
  import { useIntl, useOutlet, useRouteMeta, useSidebarData } from 'dumi';
15
- import Content from 'dumi/theme/slots/Content';
16
- import Features from 'dumi/theme/slots/Features';
17
- import Footer from 'dumi/theme/slots/Footer';
18
- import Header from 'dumi/theme/slots/Header';
19
- import Hero from 'dumi/theme/slots/Hero';
20
- import Sidebar from 'dumi/theme/slots/Sidebar';
21
- import Toc from 'dumi/theme/slots/Toc';
15
+ import Content from "dumi/theme/slots/Content";
16
+ import Features from "dumi/theme/slots/Features";
17
+ import Footer from "dumi/theme/slots/Footer";
18
+ import Header from "dumi/theme/slots/Header";
19
+ import Hero from "dumi/theme/slots/Hero";
20
+ import Sidebar from "dumi/theme/slots/Sidebar";
21
+ import Toc from "dumi/theme/slots/Toc";
22
22
  import React, { useState } from 'react';
23
23
  import Helmet from 'react-helmet';
24
24
  import "./index.less";
@@ -9,9 +9,19 @@
9
9
  padding: 0 @s-content-padding;
10
10
  border-bottom: 1px solid @c-border-light;
11
11
 
12
+ @media @mobile {
13
+ margin: -24px -24px 24px;
14
+ padding: 0 24px;
15
+ height: 42px;
16
+ }
17
+
12
18
  [data-no-sidebar] & {
13
19
  margin: 0 0 @s-content-padding;
14
20
  padding: 0;
21
+
22
+ @media @mobile {
23
+ margin-bottom: 24px;
24
+ }
15
25
  }
16
26
 
17
27
  > li {
@@ -34,6 +44,10 @@
34
44
 
35
45
  &:not(last-child) {
36
46
  margin-right: 42px;
47
+
48
+ @media @mobile {
49
+ margin-right: 20px;
50
+ }
37
51
  }
38
52
 
39
53
  &[data-active] {
@@ -13,10 +13,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { ReactComponent as IconClose } from '@ant-design/icons-svg/inline-svg/outlined/close.svg';
14
14
  import { ReactComponent as IconMenu } from '@ant-design/icons-svg/inline-svg/outlined/menu.svg';
15
15
  import { useRouteMeta } from 'dumi';
16
- import LangSwitch from 'dumi/theme/slots/LangSwitch';
17
- import Logo from 'dumi/theme/slots/Logo';
18
- import Navbar from 'dumi/theme/slots/Navbar';
19
- import SearchBar from 'dumi/theme/slots/SearchBar';
16
+ import LangSwitch from "dumi/theme/slots/LangSwitch";
17
+ import Logo from "dumi/theme/slots/Logo";
18
+ import Navbar from "dumi/theme/slots/Navbar";
19
+ import SearchBar from "dumi/theme/slots/SearchBar";
20
20
  import React, { useState } from 'react';
21
21
  import "./index.less";
22
22
 
@@ -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
 
@@ -15,7 +15,11 @@ var Navbar = function Navbar() {
15
15
  }, nav.map(function (item) {
16
16
  return /*#__PURE__*/React.createElement("li", {
17
17
  key: item.link
18
- }, /*#__PURE__*/React.createElement(Link, _extends({
18
+ }, /^(\w+:)\/\/|^(mailto|tel):/.test(item.link) ? /*#__PURE__*/React.createElement("a", {
19
+ href: item.link,
20
+ target: "_blank",
21
+ rel: "noreferrer"
22
+ }, item.title) : /*#__PURE__*/React.createElement(Link, _extends({
19
23
  to: item.link
20
24
  }, pathname.startsWith(item.activePath || item.link) ? {
21
25
  className: 'active'
@@ -13,8 +13,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { ReactComponent as IconCodeSandbox } from '@ant-design/icons-svg/inline-svg/outlined/code-sandbox.svg'; // import { ReactComponent as IconCodePen } from '@ant-design/icons-svg/inline-svg/outlined/codepen.svg';
14
14
 
15
15
  import { openCodeSandbox, useIntl } from 'dumi';
16
- import SourceCode from 'dumi/theme/builtins/SourceCode';
17
- import PreviewerActionsExtra from 'dumi/theme/slots/PreviewerActionsExtra';
16
+ import SourceCode from "dumi/theme/builtins/SourceCode";
17
+ import PreviewerActionsExtra from "dumi/theme/slots/PreviewerActionsExtra";
18
18
  import Tabs from 'rc-tabs';
19
19
  import React, { useState } from 'react';
20
20
  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