dumi 2.2.15 → 2.2.17

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.
@@ -126,7 +126,7 @@ var ColorChanger = /*#__PURE__*/function () {
126
126
  }
127
127
  this.prefersColor = color;
128
128
  this.color = color === 'auto' ? this.isColorMode('dark') ? 'dark' : 'light' : color;
129
- document.documentElement.setAttribute(PREFERS_COLOR_ATTR, color);
129
+ document.documentElement.setAttribute(PREFERS_COLOR_ATTR, this.color);
130
130
  this.applyCallbacks();
131
131
  return color;
132
132
  }
@@ -17,3 +17,4 @@ export declare const PICKED_PKG_FIELDS: {
17
17
  export declare const USELESS_TMP_FILES: string[];
18
18
  export declare const VERSION_2_LEVEL_NAV = "^2.2.0";
19
19
  export declare const VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
20
+ export declare const FS_CACHE_DIR = "node_modules/.cache/dumi";
package/dist/constants.js CHANGED
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // src/constants.ts
20
20
  var constants_exports = {};
21
21
  __export(constants_exports, {
22
+ FS_CACHE_DIR: () => FS_CACHE_DIR,
22
23
  LOCAL_DUMI_DIR: () => LOCAL_DUMI_DIR,
23
24
  LOCAL_PAGES_DIR: () => LOCAL_PAGES_DIR,
24
25
  LOCAL_THEME_DIR: () => LOCAL_THEME_DIR,
@@ -51,8 +52,10 @@ var PICKED_PKG_FIELDS = {
51
52
  var USELESS_TMP_FILES = ["tsconfig.json", "typings.d.ts"];
52
53
  var VERSION_2_LEVEL_NAV = "^2.2.0";
53
54
  var VERSION_2_DEPRECATE_SOFT_BREAKS = "^2.2.0";
55
+ var FS_CACHE_DIR = "node_modules/.cache/dumi";
54
56
  // Annotate the CommonJS export names for ESM import in node:
55
57
  0 && (module.exports = {
58
+ FS_CACHE_DIR,
56
59
  LOCAL_DUMI_DIR,
57
60
  LOCAL_PAGES_DIR,
58
61
  LOCAL_THEME_DIR,
@@ -33,6 +33,8 @@ __export(compile_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(compile_exports);
35
35
  var import_react = __toESM(require("../../techStacks/react"));
36
+ var import_utils = require("../../utils");
37
+ var import_path = __toESM(require("path"));
36
38
  var import_assets = require("../assets");
37
39
  var compile_default = (api) => {
38
40
  api.describe({ key: "dumi:compile" });
@@ -41,14 +43,20 @@ var compile_default = (api) => {
41
43
  stage: Infinity,
42
44
  fn: () => new import_react.default()
43
45
  });
44
- api.modifyConfig((memo) => {
45
- if (memo.babelLoaderCustomize) {
46
- api.logger.warn(
47
- "Config `babelLoaderCustomize` will be override by dumi, please report issue if you need it."
48
- );
46
+ api.modifyConfig({
47
+ stage: Infinity,
48
+ fn: (memo) => {
49
+ if (memo.babelLoaderCustomize) {
50
+ api.logger.warn(
51
+ "Config `babelLoaderCustomize` will be override by dumi, please report issue if you need it."
52
+ );
53
+ }
54
+ memo.babelLoaderCustomize = require.resolve("./babelLoaderCustomize");
55
+ const cacheDirPath = api.userConfig.cacheDirectoryPath || memo.cacheDirectoryPath;
56
+ if (cacheDirPath)
57
+ (0, import_utils._setFSCacheDir)(import_path.default.join(cacheDirPath, "dumi"));
58
+ return memo;
49
59
  }
50
- memo.babelLoaderCustomize = require.resolve("./babelLoaderCustomize");
51
- return memo;
52
60
  });
53
61
  api.chainWebpack(async (memo) => {
54
62
  const babelInUmi = memo.module.rule("src").use("babel-loader").entries();
@@ -68,22 +76,24 @@ var compile_default = (api) => {
68
76
  locales: api.config.locales,
69
77
  pkg: api.pkg
70
78
  };
71
- memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/).oneOf("md-meta").resourceQuery(/meta$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-meta-loader").loader(loaderPath).options({
72
- ...loaderBaseOpts,
73
- mode: "meta",
74
- onResolveDemos(demos) {
75
- const assets = demos.reduce(
76
- (ret, demo) => {
79
+ memo.module.rule("dumi-md").type("javascript/auto").test(/\.md$/).oneOf("md-meta").resourceQuery(/meta$/).use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-meta-loader").loader(loaderPath).options(
80
+ api.isPluginEnable("assets") || api.isPluginEnable("exportStatic") ? {
81
+ ...loaderBaseOpts,
82
+ mode: "meta",
83
+ onResolveDemos(demos) {
84
+ const assets = demos.reduce((ret, demo) => {
77
85
  if ("asset" in demo)
78
86
  ret.push(demo.asset);
79
87
  return ret;
80
- },
81
- []
82
- );
83
- (0, import_assets.addExampleAssets)(assets);
84
- },
85
- onResolveAtomMeta: import_assets.addAtomMeta
86
- }).end().end().oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
88
+ }, []);
89
+ (0, import_assets.addExampleAssets)(assets);
90
+ },
91
+ onResolveAtomMeta: import_assets.addAtomMeta
92
+ } : {
93
+ ...loaderBaseOpts,
94
+ mode: "meta"
95
+ }
96
+ ).end().end().oneOf("md").use("babel-loader").loader(babelInUmi.loader).options(babelInUmi.options).end().use("md-loader").loader(loaderPath).options({
87
97
  ...loaderBaseOpts,
88
98
  builtins: api.service.themeData.builtins
89
99
  });
@@ -43,9 +43,9 @@ function filterIgnoredProps(props) {
43
43
  } else if (prop.type === "object" && "properties" in prop) {
44
44
  prop.properties = filterIgnoredProps(prop.properties);
45
45
  } else if (prop.oneOf) {
46
- prop.oneOf = prop.oneOf.map((item) => filterIgnoredProps({ _: item })._);
46
+ prop.oneOf = prop.oneOf.filter(Boolean).map((item) => filterIgnoredProps({ _: item })._);
47
47
  } else if (prop.allOf) {
48
- prop.allOf = prop.allOf.map((item) => filterIgnoredProps({ _: item })._);
48
+ prop.allOf = prop.allOf.filter(Boolean).map((item) => filterIgnoredProps({ _: item })._);
49
49
  } else if ("hidden" in prop) {
50
50
  isHidden = true;
51
51
  }
@@ -72,11 +72,12 @@ function getPkgThemePath(api) {
72
72
  })
73
73
  );
74
74
  }
75
- function getModuleExports(modulePath) {
76
- return (0, import_bundler_utils.parseModuleSync)({
75
+ async function getModuleExports(modulePath) {
76
+ const [_, exports] = await (0, import_bundler_utils.parseModule)({
77
77
  path: modulePath,
78
78
  content: import_fs.default.readFileSync(modulePath, "utf-8")
79
- })[1];
79
+ });
80
+ return exports || [];
80
81
  }
81
82
  function checkMinor2ByPkg(pkg) {
82
83
  var _a, _b, _c;
@@ -251,14 +252,14 @@ export default DumiLoading;
251
252
  });
252
253
  }
253
254
  });
254
- api.onGenerateFiles(() => {
255
+ api.onGenerateFiles(async () => {
255
256
  var _a, _b, _c, _d, _e;
256
- themeMapKeys.forEach((key) => {
257
- Object.values(originalThemeData[key] || {}).forEach((item) => {
257
+ const pAll = themeMapKeys.flatMap(
258
+ (key) => Object.values(originalThemeData[key] || {}).map(async (item) => {
258
259
  if (item.source === "dumi")
259
260
  return;
260
- let contents = [];
261
- const exports = getModuleExports(item.source);
261
+ const exports = await getModuleExports(item.source);
262
+ const contents = [];
262
263
  if (exports.includes("default")) {
263
264
  contents.push(`export { default } from '${item.source}';`);
264
265
  }
@@ -270,10 +271,11 @@ export default DumiLoading;
270
271
  path: `dumi/theme/${key}/${item.specifier}.ts`,
271
272
  content: contents.join("\n")
272
273
  });
273
- });
274
- });
274
+ })
275
+ );
276
+ await Promise.all(pAll);
275
277
  const entryFile = api.config.resolve.entryFile && [import_path.default.resolve(api.cwd, api.config.resolve.entryFile)].find(import_fs.default.existsSync);
276
- const entryExports = entryFile ? getModuleExports(entryFile) : [];
278
+ const entryExports = entryFile ? await getModuleExports(entryFile) : [];
277
279
  const hasDefaultExport = entryExports.includes("default");
278
280
  const hasNamedExport = entryExports.some((exp) => exp !== "default");
279
281
  api.writeTmpFile({
@@ -121,6 +121,9 @@ var depsMapping = {};
121
121
  function mdLoader(content) {
122
122
  const opts = this.getOptions();
123
123
  const cb = this.async();
124
+ if (process.env.NODE_ENV === "production" && ["onResolveDemos", "onResolveAtomMeta"].some((k) => k in opts)) {
125
+ this.cacheable(false);
126
+ }
124
127
  const cache = (0, import_utils.getCache)("md-loader");
125
128
  const baseCacheKey = [
126
129
  this.resourcePath,
package/dist/utils.d.ts CHANGED
@@ -21,10 +21,8 @@ export declare function parseCodeFrontmatter(raw: string): {
21
21
  code: string;
22
22
  frontmatter: Record<string, any> | null;
23
23
  };
24
- /**
25
- * get file-system cache for specific namespace
26
- */
27
24
  declare const caches: Record<string, ReturnType<typeof Cache>>;
25
+ export declare function _setFSCacheDir(dir: string): void;
28
26
  export declare function getCache(ns: string): (typeof caches)['0'];
29
27
  /**
30
28
  * try to get father config
package/dist/utils.js CHANGED
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/utils.ts
30
30
  var utils_exports = {};
31
31
  __export(utils_exports, {
32
+ _setFSCacheDir: () => _setFSCacheDir,
32
33
  getCache: () => getCache,
33
34
  getContentHash: () => getContentHash,
34
35
  getFileContentByRegExp: () => getFileContentByRegExp,
@@ -45,6 +46,7 @@ var import_fs = __toESM(require("fs"));
45
46
  var import_js_yaml = __toESM(require("js-yaml"));
46
47
  var import_path = __toESM(require("path"));
47
48
  var import_plugin_utils = require("umi/plugin-utils");
49
+ var import_constants = require("./constants");
48
50
  function getFileIdFromFsPath(fsPath) {
49
51
  return import_plugin_utils.lodash.kebabCase((0, import_plugin_utils.winPath)(fsPath).replace(/((\/|^)index)?\.\w+$/g, ""));
50
52
  }
@@ -78,8 +80,11 @@ function parseCodeFrontmatter(raw) {
78
80
  }
79
81
  return { code: frontmatter ? code : raw, frontmatter };
80
82
  }
83
+ var cacheDir = import_constants.FS_CACHE_DIR;
81
84
  var caches = {};
82
- var CACHE_PATH = "node_modules/.cache/dumi";
85
+ function _setFSCacheDir(dir) {
86
+ cacheDir = dir;
87
+ }
83
88
  function getCache(ns) {
84
89
  if (process.env.DUMI_CACHE === "none") {
85
90
  return { set() {
@@ -88,7 +93,7 @@ function getCache(ns) {
88
93
  }, getSync() {
89
94
  } };
90
95
  }
91
- return caches[ns] ?? (caches[ns] = (0, import_file_system_cache.default)({ basePath: import_path.default.join(CACHE_PATH, ns) }));
96
+ return caches[ns] ?? (caches[ns] = (0, import_file_system_cache.default)({ basePath: import_path.default.resolve(cacheDir, ns) }));
92
97
  }
93
98
  async function tryFatherBuildConfigs(cwd) {
94
99
  let configs = [];
@@ -133,6 +138,7 @@ function getContentHash(content2, length = 8) {
133
138
  }
134
139
  // Annotate the CommonJS export names for ESM import in node:
135
140
  0 && (module.exports = {
141
+ _setFSCacheDir,
136
142
  getCache,
137
143
  getContentHash,
138
144
  getFileContentByRegExp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.2.15",
3
+ "version": "2.2.17",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",
@@ -56,7 +56,10 @@
56
56
  background-color: @c-site-bg-dark;
57
57
  box-shadow: 0 0 0 3px fade(@c-primary-dark, 10%);
58
58
  }
59
+ }
59
60
 
61
+ &:focus,
62
+ &:not(:placeholder-shown) {
60
63
  ~ .@{prefix}-search-shortcut {
61
64
  opacity: 0;
62
65
  }