dumi 2.4.19-beta.0 → 2.4.20
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/features/routes.js
CHANGED
|
@@ -140,14 +140,14 @@ var routes_default = (api) => {
|
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
142
|
Object.entries(pages).forEach(([, route]) => {
|
|
143
|
-
const { base
|
|
144
|
-
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(
|
|
143
|
+
const { base } = api.config.conventionRoutes;
|
|
144
|
+
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(base, route.file));
|
|
145
145
|
routes[route.id] = route;
|
|
146
146
|
});
|
|
147
147
|
docDirs.map(normalizeDocDir).forEach(({ type, dir }) => {
|
|
148
|
-
const
|
|
148
|
+
const base = import_path.default.join(api.cwd, dir);
|
|
149
149
|
const dirRoutes = (0, import_core.getConventionRoutes)({
|
|
150
|
-
base
|
|
150
|
+
base,
|
|
151
151
|
exclude: [/.*(?<!md)$/, /(\/|^)(\.|_)/]
|
|
152
152
|
});
|
|
153
153
|
Object.entries(dirRoutes).forEach(([key, route]) => {
|
|
@@ -157,15 +157,15 @@ var routes_default = (api) => {
|
|
|
157
157
|
route.path = `${pluralType}/${route.path}`.replace(/\/+$/, "/");
|
|
158
158
|
route.absPath = `/${route.path}`;
|
|
159
159
|
}
|
|
160
|
-
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(
|
|
160
|
+
route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(base, route.file));
|
|
161
161
|
routes[route.id] = route;
|
|
162
162
|
});
|
|
163
163
|
});
|
|
164
164
|
atomDirs.forEach(({ type, subType = "", dir }) => {
|
|
165
|
-
const
|
|
165
|
+
const base = import_path.default.join(api.cwd, dir);
|
|
166
166
|
const atomFiles = import_plugin_utils.glob.sync(
|
|
167
167
|
"{*,*/index,*/index.*,*/README,*/README.*}.md",
|
|
168
|
-
{ cwd:
|
|
168
|
+
{ cwd: base }
|
|
169
169
|
);
|
|
170
170
|
atomFiles.forEach((file) => {
|
|
171
171
|
const routeFile = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), subType, file));
|
|
@@ -176,7 +176,7 @@ var routes_default = (api) => {
|
|
|
176
176
|
path: routePath,
|
|
177
177
|
absPath: `/${routePath}`,
|
|
178
178
|
parentId: docLayoutId,
|
|
179
|
-
file: (0, import_plugin_utils.winPath)(import_path.default.resolve(
|
|
179
|
+
file: (0, import_plugin_utils.winPath)(import_path.default.resolve(base, file)),
|
|
180
180
|
meta: { _atom_route: true }
|
|
181
181
|
};
|
|
182
182
|
});
|
|
@@ -205,11 +205,10 @@ var routes_default = (api) => {
|
|
|
205
205
|
file: require.resolve("../client/pages/404")
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
|
-
const base = api.config.base;
|
|
209
208
|
routes["demo-render"] = {
|
|
210
209
|
id: "demo-render",
|
|
211
210
|
path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
212
|
-
absPath:
|
|
211
|
+
absPath: `/${import_constants.SP_ROUTE_PREFIX}demos/:id`,
|
|
213
212
|
parentId: demoLayoutId,
|
|
214
213
|
file: require.resolve("../client/pages/Demo")
|
|
215
214
|
};
|
|
@@ -47,7 +47,7 @@ function rehypeSlug() {
|
|
|
47
47
|
const slugger = new import_github_slugger.default();
|
|
48
48
|
vFile.data.toc = [];
|
|
49
49
|
visit(tree, "element", (node) => {
|
|
50
|
-
var _a, _b;
|
|
50
|
+
var _a, _b, _c;
|
|
51
51
|
if (HEADING_TAGS.includes(node.tagName)) {
|
|
52
52
|
const title = toString({
|
|
53
53
|
type: "element",
|
|
@@ -58,12 +58,16 @@ function rehypeSlug() {
|
|
|
58
58
|
)
|
|
59
59
|
}).trim();
|
|
60
60
|
const depth = Number(node.tagName.slice(1));
|
|
61
|
-
|
|
62
|
-
node.properties.id =
|
|
63
|
-
vFile.data.toc.push({
|
|
64
|
-
|
|
61
|
+
node.properties ?? (node.properties = {});
|
|
62
|
+
(_a = node.properties).id ?? (_a.id = slugger.slug(title));
|
|
63
|
+
vFile.data.toc.push({
|
|
64
|
+
id: node.properties.id,
|
|
65
|
+
depth,
|
|
66
|
+
title
|
|
67
|
+
});
|
|
68
|
+
} else if ([import_rehypeDemo.DUMI_DEMO_TAG, import_rehypeDemo.DUMI_DEMO_GRID_TAG].includes(node.tagName) && ((_b = node.data) == null ? void 0 : _b[import_rehypeDemo.DEMO_PROP_VALUE_KEY])) {
|
|
65
69
|
const demos = [].concat(
|
|
66
|
-
(
|
|
70
|
+
(_c = node.data) == null ? void 0 : _c[import_rehypeDemo.DEMO_PROP_VALUE_KEY]
|
|
67
71
|
);
|
|
68
72
|
demos.forEach(({ demo, previewerProps }) => {
|
|
69
73
|
var _a2, _b2;
|
package/package.json
CHANGED
|
@@ -95,8 +95,14 @@ var HANDLERS = {
|
|
|
95
95
|
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Token, null, '{'), props, /*#__PURE__*/React.createElement(Token, null, '}'));
|
|
96
96
|
},
|
|
97
97
|
array: function array(prop) {
|
|
98
|
+
var _this2 = this;
|
|
98
99
|
var arrayType = /*#__PURE__*/React.createElement("span", null, "any");
|
|
99
100
|
if (prop.items) {
|
|
101
|
+
if (Array.isArray(prop.items)) return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Token, null, '['), prop.items.map(function (item, i) {
|
|
102
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
103
|
+
key: "".concat(i)
|
|
104
|
+
}, i > 0 && ', ', _this2.toNode(item));
|
|
105
|
+
}), /*#__PURE__*/React.createElement(Token, null, ']'));
|
|
100
106
|
var className = this.getValidClassName(prop.items);
|
|
101
107
|
arrayType = className !== null && className !== void 0 ? className : this.toNode(prop.items);
|
|
102
108
|
}
|
|
@@ -108,7 +114,7 @@ var HANDLERS = {
|
|
|
108
114
|
},
|
|
109
115
|
// FIXME: extract real type
|
|
110
116
|
function: function _function(_ref4) {
|
|
111
|
-
var
|
|
117
|
+
var _this3 = this;
|
|
112
118
|
var signature = _ref4.signature;
|
|
113
119
|
// handle Function type without signature
|
|
114
120
|
if (!signature) return /*#__PURE__*/React.createElement("span", null, "Function");
|
|
@@ -119,8 +125,8 @@ var HANDLERS = {
|
|
|
119
125
|
}, signature.isAsync ? /*#__PURE__*/React.createElement(Token, null, "async") : '', /*#__PURE__*/React.createElement(Token, null, '('), signature.arguments.map(function (arg, ai) {
|
|
120
126
|
return /*#__PURE__*/React.createElement("span", {
|
|
121
127
|
key: "".concat(si).concat(ai)
|
|
122
|
-
}, /*#__PURE__*/React.createElement("span", null, arg.key), arg.hasQuestionToken && /*#__PURE__*/React.createElement(Token, null, "?"), /*#__PURE__*/React.createElement(Token, null, ":"),
|
|
123
|
-
}), /*#__PURE__*/React.createElement(Token, null, ')'), /*#__PURE__*/React.createElement(Token, null, "=>"),
|
|
128
|
+
}, /*#__PURE__*/React.createElement("span", null, arg.key), arg.hasQuestionToken && /*#__PURE__*/React.createElement(Token, null, "?"), /*#__PURE__*/React.createElement(Token, null, ":"), _this3.toNode(!!arg.schema ? arg.schema : fixArg(arg)), ai < signature.arguments.length - 1 && /*#__PURE__*/React.createElement(Token, null, ","));
|
|
129
|
+
}), /*#__PURE__*/React.createElement(Token, null, ')'), /*#__PURE__*/React.createElement(Token, null, "=>"), _this3.toNode(signature.returnType), si < signatures.length - 1 && /*#__PURE__*/React.createElement(Token, null, "|"));
|
|
124
130
|
});
|
|
125
131
|
},
|
|
126
132
|
// FIXME: extract real type
|
|
@@ -139,20 +145,20 @@ var HANDLERS = {
|
|
|
139
145
|
}));
|
|
140
146
|
},
|
|
141
147
|
oneOf: function oneOf(prop) {
|
|
142
|
-
var
|
|
148
|
+
var _this4 = this;
|
|
143
149
|
return prop.oneOf.map(function (v, i) {
|
|
144
150
|
return /*#__PURE__*/React.createElement("span", {
|
|
145
151
|
key: i
|
|
146
|
-
},
|
|
152
|
+
}, _this4.getValidClassName(v) || _this4.toNode(v), i < prop.oneOf.length - 1 && /*#__PURE__*/React.createElement(Token, null, "|"));
|
|
147
153
|
});
|
|
148
154
|
},
|
|
149
155
|
reference: function reference(prop) {
|
|
150
|
-
var
|
|
156
|
+
var _this5 = this;
|
|
151
157
|
var typeParameters = prop.typeParameters || [];
|
|
152
158
|
var params = typeParameters.map(function (param, i) {
|
|
153
159
|
return /*#__PURE__*/React.createElement("span", {
|
|
154
160
|
key: i
|
|
155
|
-
},
|
|
161
|
+
}, _this5.toNode(param), i < typeParameters.length - 1 && /*#__PURE__*/React.createElement(Token, null, ","));
|
|
156
162
|
});
|
|
157
163
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
|
|
158
164
|
className: "dumi-default-api-link",
|
|
@@ -91,7 +91,9 @@ var SourceCode = function SourceCode(props) {
|
|
|
91
91
|
});
|
|
92
92
|
return /*#__PURE__*/React.createElement("div", {
|
|
93
93
|
className: "dumi-default-source-code"
|
|
94
|
-
}, /*#__PURE__*/React.createElement(
|
|
94
|
+
}, Boolean(lang) && /*#__PURE__*/React.createElement("span", {
|
|
95
|
+
className: "dumi-default-source-code-language"
|
|
96
|
+
}, lang), /*#__PURE__*/React.createElement(CopyToClipboard, {
|
|
95
97
|
text: text,
|
|
96
98
|
onCopy: function onCopy() {
|
|
97
99
|
setIsCopied(true);
|
|
@@ -158,6 +158,24 @@
|
|
|
158
158
|
visibility: hidden;
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
&-language {
|
|
162
|
+
position: absolute;
|
|
163
|
+
top: 2px;
|
|
164
|
+
right: 8px;
|
|
165
|
+
z-index: 2;
|
|
166
|
+
font-size: 12px;
|
|
167
|
+
font-weight: 500;
|
|
168
|
+
user-select: none;
|
|
169
|
+
user-select: none;
|
|
170
|
+
color: @c-text-note;
|
|
171
|
+
transition: color 0.4s, opacity 0.4s;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
&:hover &-language {
|
|
175
|
+
opacity: 0;
|
|
176
|
+
visibility: hidden;
|
|
177
|
+
}
|
|
178
|
+
|
|
161
179
|
@{dark-selector} & {
|
|
162
180
|
@bg-color: shade(@c-site-bg-dark, 50%);
|
|
163
181
|
|