dumi 2.0.16 → 2.0.18
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/dist/assetParsers/atom.js +4 -2
- package/dist/features/compile/index.js +1 -1
- package/dist/features/derivative.js +21 -2
- package/dist/loaders/markdown/transformer/index.js +3 -1
- package/dist/loaders/markdown/transformer/rehypeRaw.d.ts +4 -1
- package/dist/loaders/markdown/transformer/rehypeRaw.js +6 -1
- package/dist/types.d.ts +5 -3
- package/package.json +1 -1
- package/theme-default/builtins/API/index.d.ts +1 -1
- package/theme-default/builtins/API/index.js +11 -8
|
@@ -113,13 +113,15 @@ var AtomAssetsParser = class {
|
|
|
113
113
|
"**/_*",
|
|
114
114
|
"**/_*/**",
|
|
115
115
|
"**/*.{md,less,scss,sass,styl,css}"
|
|
116
|
-
]
|
|
116
|
+
],
|
|
117
|
+
ignoreInitial: true
|
|
117
118
|
}).on("all", (ev, file) => {
|
|
118
119
|
if (["add", "change"].includes(ev) && /\.(j|t)sx?$/.test(file)) {
|
|
119
|
-
this.unresolvedFiles.push(file);
|
|
120
|
+
this.unresolvedFiles.push(import_path.default.join(this.resolveDir, file));
|
|
120
121
|
lazyParse();
|
|
121
122
|
}
|
|
122
123
|
});
|
|
124
|
+
lazyParse();
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
unwatch(cb) {
|
|
@@ -75,7 +75,7 @@ var compile_default = (api) => {
|
|
|
75
75
|
});
|
|
76
76
|
memo.module.rule("dumi-page").type("javascript/auto").test(/\.(j|t)sx?$/).resourceQuery(/meta$/).use("page-meta-loader").loader(require.resolve("../../loaders/page"));
|
|
77
77
|
memo.module.rule("dumi-demo").type("javascript/auto").test(/\..+$/).enforce("pre").resourceQuery(/techStack/).use("demo-loader").loader(require.resolve("../../loaders/demo")).options({ techStacks, cwd: api.cwd });
|
|
78
|
-
memo.module.rule("dumi-raw").post().resourceQuery(/dumi-raw/).use("raw-loader").loader(require.resolve("raw-loader")).end().use("pre-raw-loader").loader(require.resolve("../../loaders/pre-raw"));
|
|
78
|
+
memo.module.rule("dumi-raw").type("javascript/auto").post().resourceQuery(/dumi-raw/).use("raw-loader").loader(require.resolve("raw-loader")).end().use("pre-raw-loader").loader(require.resolve("../../loaders/pre-raw"));
|
|
79
79
|
if (api.env === "development" && memo.plugins.has("fastRefresh")) {
|
|
80
80
|
memo.plugin("fastRefresh").tap(([params]) => [
|
|
81
81
|
{
|
|
@@ -47,14 +47,27 @@ function safeExcludeInMFSU(api, excludes) {
|
|
|
47
47
|
var derivative_default = (api) => {
|
|
48
48
|
api.describe({ key: "dumi:derivative" });
|
|
49
49
|
api.onCheck(() => {
|
|
50
|
-
var _a, _b;
|
|
50
|
+
var _a, _b, _c, _d;
|
|
51
51
|
(0, import_assert.default)(!api.config.mpa, "MPA mode is not supported in dumi!");
|
|
52
52
|
(0, import_assert.default)(!api.config.vite, "Vite mode is not supported yet!");
|
|
53
53
|
(0, import_assert.default)(((_a = api.config.mfsu) == null ? void 0 : _a.strategy) !== "eager", "MFSU eager mode is not supported yet!");
|
|
54
|
+
(0, import_assert.default)(((_b = api.config.mfsu) == null ? void 0 : _b.esbuild) !== true, "MFSU esbuild bundler is not supported yet!");
|
|
54
55
|
(0, import_assert.default)(!api.config.ssr || api.config.ssr.builder === "webpack", "Only `webpack` builder is supported in SSR mode!");
|
|
55
|
-
|
|
56
|
+
(0, import_assert.default)(((_c = api.config.cssLoader) == null ? void 0 : _c.modules) === void 0, "CSS Modules is not supported! Because it is not suitable for UI library development, please use normal CSS, Less, etc. instead.");
|
|
57
|
+
if (((_d = api.userConfig.history) == null ? void 0 : _d.type) === "hash") {
|
|
56
58
|
import_plugin_utils.logger.warn("Hash history is temporarily incompatible, it is recommended to use browser history for now.");
|
|
57
59
|
}
|
|
60
|
+
try {
|
|
61
|
+
const tsconfig = require(import_path.default.join(api.cwd, "tsconfig.json"));
|
|
62
|
+
const expected = [".dumi/**/*", ".dumirc.ts"];
|
|
63
|
+
if (!expected.every((f) => {
|
|
64
|
+
var _a2;
|
|
65
|
+
return (_a2 = tsconfig.include) == null ? void 0 : _a2.includes(f);
|
|
66
|
+
})) {
|
|
67
|
+
import_plugin_utils.logger.warn("Please append `.dumi/**/*` & `.dumirc.ts` into `include` option of `tsconfig.json`, to make sure `defineConfig` works.");
|
|
68
|
+
}
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
58
71
|
});
|
|
59
72
|
safeExcludeInMFSU(api, [
|
|
60
73
|
new RegExp("dumi/dist/client"),
|
|
@@ -98,6 +111,10 @@ var derivative_default = (api) => {
|
|
|
98
111
|
}
|
|
99
112
|
return memo;
|
|
100
113
|
});
|
|
114
|
+
api.modifyBabelPresetOpts((memo) => {
|
|
115
|
+
delete memo.pluginAutoCSSModules;
|
|
116
|
+
return memo;
|
|
117
|
+
});
|
|
101
118
|
api.register({
|
|
102
119
|
key: "onGenerateFiles",
|
|
103
120
|
stage: Infinity,
|
|
@@ -105,6 +122,8 @@ var derivative_default = (api) => {
|
|
|
105
122
|
import_constants.USELESS_TMP_FILES.forEach((file) => {
|
|
106
123
|
import_plugin_utils.fsExtra.rmSync(import_path.default.join(api.paths.absTmpPath, file), { force: true });
|
|
107
124
|
});
|
|
125
|
+
const umiPath = import_path.default.join(api.paths.absTmpPath, "umi.ts");
|
|
126
|
+
import_plugin_utils.fsExtra.writeFileSync(umiPath, import_plugin_utils.fsExtra.readFileSync(umiPath, "utf-8").replace("'@/loading'", "'../loading'"));
|
|
108
127
|
}
|
|
109
128
|
});
|
|
110
129
|
api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
|
|
@@ -71,7 +71,9 @@ var transformer_default = async (raw, opts) => {
|
|
|
71
71
|
processor,
|
|
72
72
|
cwd: opts.cwd
|
|
73
73
|
}));
|
|
74
|
-
processor.use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default
|
|
74
|
+
processor.use(remarkRehype, { allowDangerousHtml: true }).use(import_rehypeRaw.default, {
|
|
75
|
+
fileAbsPath: opts.fileAbsPath
|
|
76
|
+
}).use(rehypeRemoveComments, { removeConditional: true }).use(import_rehypeStrip.default).use(import_rehypeImg.default).use(import_rehypeDemo.default, {
|
|
75
77
|
techStacks: opts.techStacks,
|
|
76
78
|
cwd: opts.cwd,
|
|
77
79
|
fileAbsPath: opts.fileAbsPath,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { Root } from 'hast';
|
|
2
2
|
import type { Transformer } from 'unified';
|
|
3
|
-
|
|
3
|
+
import type { IMdTransformerOptions } from '.';
|
|
4
|
+
declare type IRehypeRawOptions = Pick<IMdTransformerOptions, 'fileAbsPath'>;
|
|
5
|
+
export default function rehypeRaw(opts: IRehypeRawOptions): Transformer<Root>;
|
|
6
|
+
export {};
|
|
@@ -25,6 +25,7 @@ __export(rehypeRaw_exports, {
|
|
|
25
25
|
default: () => rehypeRaw
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(rehypeRaw_exports);
|
|
28
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
28
29
|
var raw;
|
|
29
30
|
var visit;
|
|
30
31
|
var COMPONENT_NAME_REGEX = /<[A-Z][a-zA-Z\d]*/g;
|
|
@@ -34,7 +35,7 @@ var CODE_META_STUB_ATTR = "$code-meta";
|
|
|
34
35
|
({ visit } = await import("unist-util-visit"));
|
|
35
36
|
({ raw } = await import("hast-util-raw"));
|
|
36
37
|
})();
|
|
37
|
-
function rehypeRaw() {
|
|
38
|
+
function rehypeRaw(opts) {
|
|
38
39
|
return (tree, vFile) => {
|
|
39
40
|
visit(tree, (node) => {
|
|
40
41
|
var _a;
|
|
@@ -47,6 +48,10 @@ function rehypeRaw() {
|
|
|
47
48
|
node.properties ?? (node.properties = {});
|
|
48
49
|
node.properties[CODE_META_STUB_ATTR] = node.data.meta;
|
|
49
50
|
}
|
|
51
|
+
if (node.type === "raw" && /<code[^>]*src=[^>]*\/>/.test(node.value)) {
|
|
52
|
+
import_plugin_utils.logger.warn(`<code /> is not supported, please use <code></code> instead.
|
|
53
|
+
File: ${opts.fileAbsPath}`);
|
|
54
|
+
}
|
|
50
55
|
});
|
|
51
56
|
const newTree = raw(tree, vFile);
|
|
52
57
|
visit(newTree, "element", (node) => {
|
package/dist/types.d.ts
CHANGED
|
@@ -7,8 +7,9 @@ import type { IModify } from '@umijs/core';
|
|
|
7
7
|
import type { AssetsPackage, ExampleBlockAsset } from 'dumi-assets-types';
|
|
8
8
|
import type { Element } from 'hast';
|
|
9
9
|
import type { IApi as IUmiApi } from 'umi';
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import { defineConfig as defineUmiConfig } from 'umi';
|
|
11
|
+
declare type IUmiConfig = Parameters<typeof defineUmiConfig>[0];
|
|
12
|
+
interface IDumiExtendsConfig {
|
|
12
13
|
resolve: {
|
|
13
14
|
docDirs: (string | {
|
|
14
15
|
type?: string;
|
|
@@ -37,7 +38,8 @@ export interface IDumiConfig extends IUmiConfig {
|
|
|
37
38
|
extraRemarkPlugins?: (string | Function | [string | Function, object])[];
|
|
38
39
|
extraRehypePlugins?: (string | Function | [string | Function, object])[];
|
|
39
40
|
}
|
|
40
|
-
export
|
|
41
|
+
export declare type IDumiConfig = IUmiConfig & IDumiExtendsConfig;
|
|
42
|
+
export interface IDumiUserConfig extends Partial<Omit<IDumiConfig, 'resolve' | 'locales'>>, IUmiConfig {
|
|
41
43
|
resolve?: Partial<IDumiConfig['resolve']>;
|
|
42
44
|
locales?: (IDumiConfig['locales'][0] | Omit<IDumiConfig['locales'][0], 'base'>)[];
|
|
43
45
|
}
|
package/package.json
CHANGED
|
@@ -10,20 +10,23 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import { useAtomAssets, useIntl } from 'dumi';
|
|
13
|
+
import { useAtomAssets, useIntl, useRouteMeta } from 'dumi';
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import Table from "../Table";
|
|
16
16
|
|
|
17
|
-
var API = function API(
|
|
17
|
+
var API = function API(props) {
|
|
18
18
|
var _definition$propsConf;
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _useRouteMeta = useRouteMeta(),
|
|
21
|
+
frontmatter = _useRouteMeta.frontmatter;
|
|
21
22
|
|
|
22
23
|
var _useAtomAssets = useAtomAssets(),
|
|
23
24
|
components = _useAtomAssets.components;
|
|
24
25
|
|
|
25
|
-
var
|
|
26
|
+
var id = props.id || frontmatter.atomId;
|
|
26
27
|
var intl = useIntl();
|
|
28
|
+
if (!id) throw new Error('`id` properties if required for API component!');
|
|
29
|
+
var definition = components === null || components === void 0 ? void 0 : components[id];
|
|
27
30
|
return /*#__PURE__*/React.createElement("div", {
|
|
28
31
|
className: "markdown"
|
|
29
32
|
}, /*#__PURE__*/React.createElement(Table, null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
@@ -34,12 +37,12 @@ var API = function API(_ref) {
|
|
|
34
37
|
id: 'api.component.type'
|
|
35
38
|
})), /*#__PURE__*/React.createElement("th", null, intl.formatMessage({
|
|
36
39
|
id: 'api.component.default'
|
|
37
|
-
})))), /*#__PURE__*/React.createElement("tbody", null, definition && (_definition$propsConf = definition.propsConfig) !== null && _definition$propsConf !== void 0 && _definition$propsConf.properties ? Object.entries(definition.propsConfig.properties).map(function (
|
|
40
|
+
})))), /*#__PURE__*/React.createElement("tbody", null, definition && (_definition$propsConf = definition.propsConfig) !== null && _definition$propsConf !== void 0 && _definition$propsConf.properties ? Object.entries(definition.propsConfig.properties).map(function (_ref) {
|
|
38
41
|
var _definition$propsConf2;
|
|
39
42
|
|
|
40
|
-
var
|
|
41
|
-
name =
|
|
42
|
-
prop =
|
|
43
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
44
|
+
name = _ref2[0],
|
|
45
|
+
prop = _ref2[1];
|
|
43
46
|
|
|
44
47
|
return /*#__PURE__*/React.createElement("tr", {
|
|
45
48
|
key: name
|