dumi 2.0.6 → 2.0.8

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/README.md CHANGED
@@ -1,18 +1,29 @@
1
1
  # dumi
2
2
 
3
- [![NPM version](https://img.shields.io/npm/v/dumi/next)](https://npmjs.org/package/dumi) [![NPM downloads](https://img.shields.io/npm/dm/dumi)](https://npmjs.org/package/dumi)
3
+ [![NPM version](https://img.shields.io/npm/v/dumi)](https://npmjs.org/package/dumi) [![NPM downloads](https://img.shields.io/npm/dm/dumi)](https://npmjs.org/package/dumi) [![GitHub CI](https://github.com/umijs/dumi/workflows/CI/badge.svg)](https://github.com/umijs/dumi)
4
4
 
5
- The development version for dumi 2, if you are looking for dumi 1, please switch to the [1.x branch](https://github.com/umijs/dumi/tree/1.x).
5
+ <img src="https://gw.alipayobjects.com/zos/bmw-prod/d3e3eb39-1cd7-4aa5-827c-877deced6b7e/lalxt4g3_w256_h256.png" width="120">
6
6
 
7
- ## Install
7
+ dumi is a static site generator for component library development.
8
+
9
+ ## Usage & Guide
10
+
11
+ To view more online examples and docs, please visit [dumi official site](https://d.umijs.org).
12
+
13
+ ## Development
8
14
 
9
15
  ```bash
10
16
  $ pnpm install
17
+ $ pnpm dev
18
+ $ pnpm docs:dev
11
19
  ```
12
20
 
13
- ```bash
14
- $ npm run dev
15
- $ npm run build
21
+ ## Badge
22
+
23
+ Using dumi? Add a README badge to show it off: [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue)](https://github.com/umijs/dumi)
24
+
25
+ ```
26
+ [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue)](https://github.com/umijs/dumi)
16
27
  ```
17
28
 
18
29
  ## LICENSE
@@ -18,5 +18,6 @@ declare class AtomAssetsParser {
18
18
  functions: Record<string, AtomFunctionAsset>;
19
19
  }>;
20
20
  watch(cb: AtomAssetsParser['cbs'][number]): void;
21
+ unwatch(cb: AtomAssetsParser['cbs'][number]): void;
21
22
  }
22
23
  export default AtomAssetsParser;
@@ -45,7 +45,7 @@ var AtomAssetsParser = class {
45
45
  async parse() {
46
46
  if (!this.resolverDeferrer || this.unresolvedFiles.length) {
47
47
  this.resolverDeferrer = (async () => {
48
- await this.parser.patch(this.unresolvedFiles);
48
+ await this.parser.patch(this.unresolvedFiles.splice(0));
49
49
  return new import_parser.SchemaResolver(await this.parser.parse());
50
50
  })();
51
51
  }
@@ -106,6 +106,9 @@ var AtomAssetsParser = class {
106
106
  });
107
107
  }
108
108
  }
109
+ unwatch(cb) {
110
+ this.cbs.splice(this.cbs.indexOf(cb), 1);
111
+ }
109
112
  };
110
113
  var atom_default = AtomAssetsParser;
111
114
  // Annotate the CommonJS export names for ESM import in node:
@@ -43,30 +43,49 @@ function addAtomMeta(atomId, data) {
43
43
  atomsMeta[atomId] = import_plugin_utils.lodash.pick(data, ["title", "keywords", "deprecated"]);
44
44
  }
45
45
  var assets_default = (api) => {
46
+ let compileDeferrer = new Promise((resolve) => {
47
+ api.register({
48
+ key: "onDevCompileDone",
49
+ stage: -Infinity,
50
+ fn: resolve
51
+ });
52
+ api.register({
53
+ key: "onCompileDone",
54
+ stage: -Infinity,
55
+ fn: resolve
56
+ });
57
+ });
46
58
  api.describe({
47
59
  config: {
48
60
  schema: (Joi) => Joi.object()
49
61
  },
50
- enableBy: ({ env }) => env === "production" && Boolean(api.args.assets)
62
+ enableBy: ({ env }) => env === "development" || Boolean(api.args.assets)
51
63
  });
52
- api.onBuildComplete(async () => {
53
- const { components } = api.service.atomParser ? await api.service.atomParser.parse() : { components: {} };
54
- const assets = await api.applyPlugins({
55
- key: "modifyAssetsMetadata",
56
- initialValue: {
57
- name: api.config.themeConfig.title || api.pkg.name,
58
- npmPackageName: api.pkg.name,
59
- version: api.pkg.version,
60
- description: api.pkg.description,
61
- logo: api.config.themeConfig.logo,
62
- homepage: api.pkg.homepage,
63
- repository: api.pkg.repository,
64
- assets: {
65
- atoms: Object.values(components).map((atom) => Object.assign(atom, atomsMeta[atom.id] || {})),
66
- examples: import_plugin_utils.lodash.uniqBy(examples, "id")
64
+ api.registerMethod({
65
+ name: "getAssetsMetadata",
66
+ async fn() {
67
+ await compileDeferrer;
68
+ const { components } = api.service.atomParser ? await api.service.atomParser.parse() : { components: {} };
69
+ return await api.applyPlugins({
70
+ key: "modifyAssetsMetadata",
71
+ initialValue: {
72
+ name: api.config.themeConfig.title || api.pkg.name,
73
+ npmPackageName: api.pkg.name,
74
+ version: api.pkg.version,
75
+ description: api.pkg.description,
76
+ logo: api.config.themeConfig.logo,
77
+ homepage: api.pkg.homepage,
78
+ repository: api.pkg.repository,
79
+ assets: {
80
+ atoms: Object.values(components).map((atom) => Object.assign(atom, atomsMeta[atom.id] || {})),
81
+ examples: import_plugin_utils.lodash.uniqBy(examples, "id")
82
+ }
67
83
  }
68
- }
69
- });
84
+ });
85
+ }
86
+ });
87
+ api.onBuildComplete(async () => {
88
+ const assets = await api.getAssetsMetadata();
70
89
  import_fs.default.writeFileSync(import_path.default.join(api.cwd, "assets.json"), JSON.stringify(assets, null, 2), "utf-8");
71
90
  });
72
91
  };
@@ -80,7 +80,10 @@ var derivative_default = (api) => {
80
80
  import_plugin_utils.logger.warn("Hash history is temporarily incompatible, it is recommended to use browser history for now.");
81
81
  }
82
82
  });
83
- safeExcludeInMFSU(api, [new RegExp("dumi/dist/client")]);
83
+ safeExcludeInMFSU(api, [
84
+ new RegExp("dumi/dist/client"),
85
+ new RegExp("compiled/_internal/searchWorker")
86
+ ]);
84
87
  api.modifyDefaultConfig((memo) => {
85
88
  if (api.userConfig.mfsu !== false) {
86
89
  if (import_fs.default.existsSync(import_path.default.join(api.cwd, "node_modules", ".pnpm")) || process.platform === "win32") {
package/dist/types.d.ts CHANGED
@@ -94,5 +94,9 @@ export declare type IApi = IUmiApi & {
94
94
  * modify assets metadata
95
95
  */
96
96
  modifyAssetsMetadata: IModify<AssetsPackage, null>;
97
+ /**
98
+ * get assets metadata
99
+ */
100
+ getAssetsMetadata?: () => Promise<AssetsPackage>;
97
101
  };
98
102
  export {};
package/dist/utils.js CHANGED
@@ -98,7 +98,8 @@ async function tryFatherBuildConfigs(cwd) {
98
98
  configs = getBuildConfig(svc.config, svc.pkg);
99
99
  } catch {
100
100
  }
101
- process.env.APP_ROOT = APP_ROOT;
101
+ if (APP_ROOT)
102
+ process.env.APP_ROOT = APP_ROOT;
102
103
  return configs;
103
104
  }
104
105
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -43,6 +43,13 @@
43
43
  &-aside {
44
44
  display: flex;
45
45
  align-items: center;
46
+
47
+ @media @mobile {
48
+ margin: 8px 16px;
49
+ padding-top: 24px;
50
+ justify-content: center;
51
+ border-top: 1px solid @c-border-light;
52
+ }
46
53
  }
47
54
 
48
55
  @media @mobile {
@@ -69,7 +76,7 @@
69
76
  &-menu-btn {
70
77
  position: absolute;
71
78
  top: 50%;
72
- right: 24px;
79
+ inset-inline-end: 24px;
73
80
  padding: 0;
74
81
  border: 0;
75
82
  background: transparent;
@@ -1,7 +1,7 @@
1
1
  @import '../LangSwitch/index.less';
2
2
 
3
3
  .@{prefix}-lang-switch {
4
- + & {
4
+ & + & {
5
5
  margin-inline-start: 20px;
6
6
  }
7
7
  }
@@ -19,7 +19,8 @@ import "./index.less";
19
19
 
20
20
  var Toc = function Toc() {
21
21
  var _useLocation = useLocation(),
22
- pathname = _useLocation.pathname;
22
+ pathname = _useLocation.pathname,
23
+ search = _useLocation.search;
23
24
 
24
25
  var meta = useRouteMeta();
25
26
 
@@ -50,7 +51,7 @@ var Toc = function Toc() {
50
51
  });
51
52
  setSectionRefs(refs);
52
53
  }
53
- }, [pathname, loading]);
54
+ }, [pathname, search, loading]);
54
55
  return sectionRefs.length ? /*#__PURE__*/React.createElement(ScrollSpy, {
55
56
  sectionRefs: sectionRefs
56
57
  }, function (_ref3) {