dumi 2.0.7 → 2.0.9
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 +1 -1
- package/dist/assetParsers/atom.d.ts +1 -0
- package/dist/assetParsers/atom.js +4 -1
- package/dist/features/assets.js +37 -18
- package/dist/features/theme/index.js +5 -4
- package/dist/loaders/markdown/transformer/rehypeDemo.js +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/utils.js +2 -1
- package/package.json +1 -1
- package/theme-default/slots/Toc/index.js +3 -2
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
|
|
7
|
+
dumi is a static site generator for component library development.
|
|
8
8
|
|
|
9
9
|
## Usage & Guide
|
|
10
10
|
|
|
@@ -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:
|
package/dist/features/assets.js
CHANGED
|
@@ -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: "onBuildComplete",
|
|
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 === "
|
|
62
|
+
enableBy: ({ env }) => env === "development" || Boolean(api.args.assets)
|
|
51
63
|
});
|
|
52
|
-
api.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
};
|
|
@@ -164,12 +164,13 @@ export default function DumiContextWrapper() {
|
|
|
164
164
|
|
|
165
165
|
useEffect(() => {
|
|
166
166
|
return history.listen((next) => {
|
|
167
|
-
// mark loading when route change, page component will set false when loaded
|
|
168
|
-
setLoading(true);
|
|
169
|
-
|
|
170
|
-
// scroll to top when route changed
|
|
171
167
|
if (next.location.pathname !== prev.current) {
|
|
172
168
|
prev.current = next.location.pathname;
|
|
169
|
+
|
|
170
|
+
// mark loading when route change, page component will set false when loaded
|
|
171
|
+
setLoading(true);
|
|
172
|
+
|
|
173
|
+
// scroll to top when route changed
|
|
173
174
|
document.documentElement.scrollTo(0, 0);
|
|
174
175
|
}
|
|
175
176
|
});
|
|
@@ -141,7 +141,7 @@ function rehypeDemo(opts) {
|
|
|
141
141
|
if (codeType === "external") {
|
|
142
142
|
const chunkName = [vFile.data.frontmatter.atomId, "demos"].filter(Boolean).join("__");
|
|
143
143
|
parseOpts.fileAbsPath = codeNode.properties.src;
|
|
144
|
-
parseOpts.id = getCodeId(opts.cwd, opts.fileAbsPath, import_path.default.parse(parseOpts.fileAbsPath).name, vFile.data.frontmatter.atomId);
|
|
144
|
+
parseOpts.id = getCodeId(opts.cwd, opts.fileAbsPath, import_path.default.parse(parseOpts.fileAbsPath.replace(/\/index\.(j|t)sx?$/, "")).name, vFile.data.frontmatter.atomId);
|
|
145
145
|
component = `React.lazy(() => import( /* webpackChunkName: "${chunkName}" */ '${(0, import_plugin_utils.winPath)(parseOpts.fileAbsPath)}?techStack=${techStack.name}'))`;
|
|
146
146
|
if (codeValue)
|
|
147
147
|
codeNode.properties.title = codeValue;
|
package/dist/types.d.ts
CHANGED
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
|
-
|
|
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
|
@@ -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) {
|