dumi 2.0.7 → 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
@@ -4,7 +4,7 @@
4
4
 
5
5
  <img src="https://gw.alipayobjects.com/zos/bmw-prod/d3e3eb39-1cd7-4aa5-827c-877deced6b7e/lalxt4g3_w256_h256.png" width="120">
6
6
 
7
- dumi is an static site generator for component library development.
7
+ dumi is a static site generator for component library development.
8
8
 
9
9
  ## Usage & Guide
10
10
 
@@ -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
  };
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.7",
3
+ "version": "2.0.8",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -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) {