dumi 2.4.7 → 2.4.8-beta.1

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.
@@ -174,7 +174,7 @@ export interface ISidebarGroup {
174
174
  children: ISidebarItem[];
175
175
  [key: string]: any;
176
176
  }
177
- export type SocialTypes = 'github' | 'weibo' | 'twitter' | 'gitlab' | 'facebook' | 'zhihu' | 'yuque' | 'linkedin';
177
+ export type SocialTypes = 'github' | 'weibo' | 'twitter' | 'x' | 'gitlab' | 'facebook' | 'zhihu' | 'yuque' | 'linkedin';
178
178
  export type INavItems = (INavItem & {
179
179
  children?: INavItem[];
180
180
  })[];
@@ -104,9 +104,6 @@ var compile_default = (api) => {
104
104
  if (!babelInUmi)
105
105
  return memo;
106
106
  const loaderPath = require.resolve("../../loaders/markdown");
107
- memo.resolve.byDependency.set("commonjs", {
108
- conditionNames: ["require", "node", "import"]
109
- });
110
107
  const loaderBaseOpts = {
111
108
  techStacks,
112
109
  cwd: api.cwd,
@@ -49,6 +49,9 @@ function getDemoSourceFiles(demos = []) {
49
49
  return ret;
50
50
  }, []);
51
51
  }
52
+ function isRelativePath(path2) {
53
+ return path2.startsWith("./") || path2.startsWith("../");
54
+ }
52
55
  function emitDefault(opts, ret) {
53
56
  const { frontmatter, demos } = ret.meta;
54
57
  const isTabContent = (0, import_tabs.isTabRouteFile)(this.resourcePath);
@@ -89,9 +92,45 @@ export default DumiMarkdownContent;`;
89
92
  }
90
93
  function emitDemo(opts, ret) {
91
94
  const { demos } = ret.meta;
95
+ const shareDepsMap = {};
96
+ const demoDepsMap = {};
97
+ demos == null ? void 0 : demos.forEach((demo) => {
98
+ var _a;
99
+ if ("resolveMap" in demo && "asset" in demo) {
100
+ const entryFileName = Object.keys(demo.asset.dependencies)[0];
101
+ demoDepsMap[_a = demo.id] ?? (demoDepsMap[_a] = {});
102
+ Object.keys(demo.resolveMap).forEach((key, index) => {
103
+ const specifier = `${demo.id.replace(/-/g, "_")}_deps_${index}`;
104
+ if (key !== entryFileName && !isRelativePath(key)) {
105
+ if (shareDepsMap[key]) {
106
+ demoDepsMap[demo.id][key] = shareDepsMap[key];
107
+ } else {
108
+ demoDepsMap[demo.id][key] = specifier;
109
+ shareDepsMap[key] = specifier;
110
+ }
111
+ } else if (isRelativePath(key)) {
112
+ demoDepsMap[demo.id][demo.resolveMap[key]] = specifier;
113
+ }
114
+ });
115
+ }
116
+ });
117
+ const dedupedDemosDeps = Object.entries(demoDepsMap).reduce((acc, [, deps]) => {
118
+ return acc.concat(
119
+ Object.entries(deps).map(([key, specifier]) => {
120
+ const existingIndex = acc.findIndex((obj) => obj.key === key);
121
+ if (existingIndex === -1) {
122
+ return { key, specifier };
123
+ }
124
+ return void 0;
125
+ }).filter((item) => item !== void 0)
126
+ );
127
+ }, []);
92
128
  return import_plugin_utils.Mustache.render(
93
129
  `import React from 'react';
94
- import '${(0, import_plugin_utils.winPath)(this.getDependencies()[0])}?watch=parent';
130
+ import '${(0, import_plugin_utils.winPath)(this.getDependencies()[0])}?watch=parent';
131
+ {{#dedupedDemosDeps}}
132
+ import * as {{{specifier}}} from '{{{key}}}';
133
+ {{/dedupedDemosDeps}}
95
134
  export const demos = {
96
135
  {{#demos}}
97
136
  '{{{id}}}': {
@@ -106,6 +145,7 @@ export const demos = {
106
145
  };`,
107
146
  {
108
147
  demos,
148
+ dedupedDemosDeps,
109
149
  renderAsset: function renderAsset() {
110
150
  if (!("asset" in this))
111
151
  return "null";
@@ -127,14 +167,10 @@ export const demos = {
127
167
  renderContext: function renderContext() {
128
168
  if (!("resolveMap" in this) || !("asset" in this))
129
169
  return "undefined";
130
- const entryFileName = Object.keys(this.asset.dependencies)[0];
131
- const context = Object.entries(this.resolveMap).reduce(
132
- (acc, [key, path2]) => ({
170
+ const context = Object.entries(demoDepsMap[this.id]).reduce(
171
+ (acc, [key, specifier]) => ({
133
172
  ...acc,
134
- // omit entry file
135
- ...key !== entryFileName ? {
136
- [key]: `{{{require('${path2}')}}}`
137
- } : {}
173
+ ...{ [key]: `{{{${specifier}}}}` }
138
174
  }),
139
175
  {}
140
176
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.4.7",
3
+ "version": "2.4.8-beta.1",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -59,7 +59,7 @@
59
59
  ]
60
60
  },
61
61
  "dependencies": {
62
- "@ant-design/icons-svg": "^4.2.1",
62
+ "@ant-design/icons-svg": "^4.4.2",
63
63
  "@makotot/ghostui": "^2.0.0",
64
64
  "@stackblitz/sdk": "^1.9.0",
65
65
  "@swc/core": "1.4.2",
@@ -6,6 +6,7 @@
6
6
  "header.social.github": "GitHub",
7
7
  "header.social.weibo": "Weibo",
8
8
  "header.social.twitter": "Twitter",
9
+ "header.social.x": "X",
9
10
  "header.social.gitlab": "GitLab",
10
11
  "header.social.facebook": "Facebook",
11
12
  "header.social.zhihu": "Zhihu",
@@ -6,6 +6,7 @@
6
6
  "header.social.github": "GitHub",
7
7
  "header.social.weibo": "微博",
8
8
  "header.social.twitter": "Twitter",
9
+ "header.social.x": "X",
9
10
  "header.social.gitlab": "GitLab",
10
11
  "header.social.facebook": "Facebook",
11
12
  "header.social.zhihu": "知乎",
@@ -2,8 +2,8 @@ import { ReactComponent as IconFacebook } from '@ant-design/icons-svg/inline-svg
2
2
  import { ReactComponent as IconGitHub } from '@ant-design/icons-svg/inline-svg/outlined/github.svg';
3
3
  import { ReactComponent as IconGitlab } from '@ant-design/icons-svg/inline-svg/outlined/gitlab.svg';
4
4
  import { ReactComponent as IconLinkedin } from '@ant-design/icons-svg/inline-svg/outlined/linkedin.svg';
5
- import { ReactComponent as IconTwitter } from '@ant-design/icons-svg/inline-svg/outlined/twitter.svg';
6
5
  import { ReactComponent as IconWeiBo } from '@ant-design/icons-svg/inline-svg/outlined/weibo.svg';
6
+ import { ReactComponent as IconX } from '@ant-design/icons-svg/inline-svg/outlined/x.svg';
7
7
  import { ReactComponent as IconYuque } from '@ant-design/icons-svg/inline-svg/outlined/yuque.svg';
8
8
  import { ReactComponent as IconZhihu } from '@ant-design/icons-svg/inline-svg/outlined/zhihu.svg';
9
9
  import React, { useMemo } from 'react';
@@ -12,7 +12,8 @@ import "./index.less";
12
12
  var presetIconMap = {
13
13
  github: IconGitHub,
14
14
  weibo: IconWeiBo,
15
- twitter: IconTwitter,
15
+ twitter: IconX,
16
+ x: IconX,
16
17
  gitlab: IconGitlab,
17
18
  facebook: IconFacebook,
18
19
  zhihu: IconZhihu,
@@ -81,7 +81,8 @@ var SourceCodeEditor = function SourceCodeEditor(props) {
81
81
  },
82
82
  autoComplete: "off",
83
83
  autoCorrect: "off",
84
- autoSave: "off"
84
+ autoSave: "off",
85
+ spellCheck: "false"
85
86
  }),
86
87
  extra: style && props.extra
87
88
  }), code));