dumi 2.3.0-beta.1 → 2.3.0-beta.3

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.
@@ -86,7 +86,7 @@ function checkMinor2ByPkg(pkg) {
86
86
  if ((_a = pkg.name) == null ? void 0 : _a.startsWith("@examples/"))
87
87
  return true;
88
88
  const ver = ((_b = pkg.peerDependencies) == null ? void 0 : _b.dumi) || ((_c = pkg.devDependencies) == null ? void 0 : _c.dumi) || "^2.0.0";
89
- return import_plugin_utils.semver.subset(ver, import_constants.VERSION_2_LEVEL_NAV);
89
+ return import_plugin_utils.semver.subset(ver, import_constants.VERSION_2_LEVEL_NAV, { includePrerelease: true });
90
90
  }
91
91
  var theme_default = (api) => {
92
92
  const defaultThemeData = (0, import_loader.default)(DEFAULT_THEME_PATH);
@@ -98,10 +98,11 @@ export const demos = {
98
98
  let { asset } = this;
99
99
  const { resolveMap } = this;
100
100
  Object.keys(this.resolveMap).forEach((file) => {
101
- if (!asset.dependencies[file])
102
- return;
103
- asset = import_plugin_utils.lodash.cloneDeep(asset);
104
- asset.dependencies[file].value = `{{{require('-!${resolveMap[file]}?dumi-raw').default}}}`;
101
+ var _a;
102
+ if (((_a = asset.dependencies[file]) == null ? void 0 : _a.type) === "FILE") {
103
+ asset = import_plugin_utils.lodash.cloneDeep(asset);
104
+ asset.dependencies[file].value = `{{{require('-!${resolveMap[file]}?dumi-raw').default}}}`;
105
+ }
105
106
  });
106
107
  return JSON.stringify(asset, null, 2).replace(/"{{{|}}}"/g, "");
107
108
  },
@@ -56,7 +56,9 @@ function keepSoftBreak(pkg) {
56
56
  if (((_a = pkg == null ? void 0 : pkg.name) == null ? void 0 : _a.startsWith("@examples/")) || (pkg == null ? void 0 : pkg.name) === "dumi")
57
57
  return false;
58
58
  const ver = ((_b = pkg == null ? void 0 : pkg.devDependencies) == null ? void 0 : _b.dumi) ?? ((_c = pkg == null ? void 0 : pkg.dependencies) == null ? void 0 : _c.dumi) ?? "^2.0.0";
59
- return !import_plugin_utils.semver.subset(ver, import_constants.VERSION_2_DEPRECATE_SOFT_BREAKS);
59
+ return !import_plugin_utils.semver.subset(ver, import_constants.VERSION_2_DEPRECATE_SOFT_BREAKS, {
60
+ includePrerelease: true
61
+ });
60
62
  }
61
63
  async function applyUnifiedPlugin(opts) {
62
64
  const [plugin, options] = Array.isArray(opts.plugin) ? opts.plugin : [opts.plugin];
@@ -76,6 +78,7 @@ var transformer_default = async (raw, opts) => {
76
78
  const { default: rehypeAutolinkHeadings } = await import("rehype-autolink-headings");
77
79
  const { default: rehypeRemoveComments } = await import("rehype-remove-comments");
78
80
  const resolver = import_enhanced_resolve.default.create.sync({
81
+ mainFields: ["browser", "module", "main"],
79
82
  extensions: [".js", ".jsx", ".ts", ".tsx"],
80
83
  alias: opts.alias
81
84
  });
@@ -109,7 +109,7 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
109
109
  ? undefined | IRouteMeta
110
110
  : Promise<undefined | IRouteMeta> | undefined {
111
111
  if (filesMeta[id]) {
112
- const { frontmatter, toc, textGetter, tabs = [] } = filesMeta[id];
112
+ const { frontmatter, toc, textGetter, tabs } = filesMeta[id];
113
113
  const routeMeta: IRouteMeta = {
114
114
  frontmatter,
115
115
  toc: toc,
@@ -117,25 +117,30 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
117
117
  };
118
118
 
119
119
  if (opts?.syncOnly) {
120
- routeMeta.tabs = tabs.map((tabId) =>
121
- genTab(tabId, getRouteMetaById(tabId, opts)),
122
- );
120
+ if (tabs) {
121
+ routeMeta.tabs = tabs.map((tabId) =>
122
+ genTab(tabId, getRouteMetaById(tabId, opts)),
123
+ );
124
+ }
125
+
126
+ return routeMeta;
123
127
  } else {
124
128
  return new Promise(async (resolve) => {
125
129
  if (textGetter) {
126
130
  ({ texts: routeMeta.texts } = await textGetter());
127
131
  }
128
132
 
129
- routeMeta.tabs = await Promise.all(
130
- tabs.map(async (tabId) =>
131
- genTab(tabId, await getRouteMetaById(tabId, opts)),
132
- ),
133
- );
133
+ if (tabs) {
134
+ routeMeta.tabs = await Promise.all(
135
+ tabs.map(async (tabId) =>
136
+ genTab(tabId, await getRouteMetaById(tabId, opts)),
137
+ ),
138
+ );
139
+ }
140
+
134
141
  resolve(routeMeta);
135
142
  });
136
143
  }
137
-
138
- return routeMeta;
139
144
  }
140
145
  }
141
146
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.3.0-beta.1",
3
+ "version": "2.3.0-beta.3",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -41,6 +41,7 @@ var Previewer = function Previewer(props) {
41
41
  "data-compact": props.compact || undefined,
42
42
  "data-transform": props.transform || undefined,
43
43
  "data-iframe": props.iframe || undefined,
44
+ "data-error": Boolean(combineError) || undefined,
44
45
  ref: demoContainer
45
46
  }, props.iframe ? /*#__PURE__*/React.createElement("iframe", {
46
47
  style: ['string', 'number'].includes(_typeof(props.iframe)) ? {
@@ -1,6 +1,8 @@
1
1
  @import (reference) '../../styles/variables.less';
2
2
 
3
3
  .@{prefix}-previewer {
4
+ @error-bar-height: 30px;
5
+
4
6
  margin: 24px 0 32px;
5
7
  border: 1px solid @c-border-light;
6
8
  border-radius: 4px;
@@ -76,16 +78,26 @@
76
78
  &[data-compact] {
77
79
  padding: 0;
78
80
  }
81
+
82
+ // error status
83
+ &[data-error][data-compact] {
84
+ min-height: @error-bar-height;
85
+
86
+ + .@{prefix}-previewer-demo-error {
87
+ border-top-left-radius: 3px;
88
+ border-top-right-radius: 3px;
89
+ }
90
+ }
79
91
  }
80
92
 
81
93
  &-demo-error {
82
- @height: 30px;
83
94
  @color: darken(desaturate(@c-error, 20%), 1%);
84
95
 
85
- margin-top: -@height;
86
- height: @height;
96
+ position: relative;
97
+ margin-top: -@error-bar-height;
98
+ height: @error-bar-height;
87
99
  padding: 0 24px;
88
- line-height: @height;
100
+ line-height: @error-bar-height;
89
101
  color: @color;
90
102
  font-size: 13px;
91
103
  white-space: nowrap;