dumi 2.0.0-beta.1 → 2.0.0-beta.2

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.
@@ -37,11 +37,11 @@ export var useNavData = function useNavData() {
37
37
  groups = _ref2[1];
38
38
 
39
39
  var meta = Object.values(routes).reduce(function (ret, route) {
40
- var _frontmatter$nav$orde;
40
+ var _route$meta, _frontmatter$nav$orde;
41
41
 
42
42
  // find routes which within the nav path
43
43
  if (route.path.startsWith(link.slice(1))) {
44
- switch (_typeof(route.meta.frontmatter.nav)) {
44
+ switch (_typeof((_route$meta = route.meta) === null || _route$meta === void 0 ? void 0 : _route$meta.frontmatter.nav)) {
45
45
  case 'object':
46
46
  ret.title = route.meta.frontmatter.nav.title || ret.title;
47
47
  ret.order = (_frontmatter$nav$orde = route.meta.frontmatter.nav.order) !== null && _frontmatter$nav$orde !== void 0 ? _frontmatter$nav$orde : ret.order;
@@ -1,8 +1,9 @@
1
+ import type { ISidebarGroup } from './types';
1
2
  /**
2
3
  * hook for get sidebar data for all nav
3
4
  */
4
- export declare const useFullSidebarData: () => any;
5
+ export declare const useFullSidebarData: () => Record<string, ISidebarGroup[]>;
5
6
  /**
6
7
  * hook for get sidebar data for current nav
7
8
  */
8
- export declare const useSidebarData: () => any;
9
+ export declare const useSidebarData: () => ISidebarGroup[];
@@ -4,7 +4,7 @@
4
4
  "paths": {
5
5
  "@/*": ["src/*"],
6
6
  "@@/*": ["src/.umi/*"],
7
- "dumi": ["src"],
7
+ "dumi": ["."],
8
8
  "dumi/theme": ["src/client/theme-api"],
9
9
  "dumi/theme/*": ["src/client/theme-default/*"]
10
10
  },
@@ -1,6 +1,8 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
4
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
7
  var __export = (target, all) => {
6
8
  for (var name in all)
@@ -14,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
14
16
  }
15
17
  return to;
16
18
  };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
17
20
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
21
 
19
22
  // src/features/locales.ts
@@ -22,6 +25,8 @@ __export(locales_exports, {
22
25
  default: () => locales_default
23
26
  });
24
27
  module.exports = __toCommonJS(locales_exports);
28
+ var import_path = __toESM(require("path"));
29
+ var import_plugin_utils = require("umi/plugin-utils");
25
30
  var locales_default = (api) => {
26
31
  var _a;
27
32
  api.describe({
@@ -71,7 +76,7 @@ export const messages = ${JSON.stringify(api.service.themeData.locales, null, 2)
71
76
  content: `
72
77
  import { history } from 'dumi';
73
78
  import React, { useState, type ReactNode } from 'react';
74
- import { RawIntlProvider, createIntl, createIntlCache } from 'react-intl';
79
+ import { RawIntlProvider, createIntl, createIntlCache } from '${(0, import_plugin_utils.winPath)(import_path.default.dirname(require.resolve("react-intl/package")))}';
75
80
  import { locales, messages } from './config';
76
81
 
77
82
  const cache = createIntlCache();
@@ -47,11 +47,12 @@ var routes_default = (api) => {
47
47
  ...((_b = (_a = api.userConfig.resolve) == null ? void 0 : _a.entityDirs) == null ? void 0 : _b.map(({ dir }) => dir)) || ["docs"],
48
48
  ...((_c = api.userConfig.resolve) == null ? void 0 : _c.docDirs) || []
49
49
  ].map((dir) => import_path.default.join(api.cwd, dir, "**/*.md"));
50
+ const pagesDir = import_path.default.join(api.cwd, ".dumi/pages");
50
51
  api.describe({ key: "dumi:routes" });
51
52
  api.addTmpGenerateWatcherPaths(() => extraWatchPaths);
52
53
  api.modifyConfig((memo) => {
53
54
  memo.conventionRoutes = {
54
- base: import_path.default.join(__dirname, "dumi-disable-default-routes")
55
+ base: pagesDir
55
56
  };
56
57
  return memo;
57
58
  });
@@ -67,9 +68,12 @@ var routes_default = (api) => {
67
68
  return memo;
68
69
  });
69
70
  api.modifyRoutes((oRoutes) => {
71
+ const pages = {};
70
72
  const routes = Object.values(oRoutes).reduce((ret, route) => {
71
73
  if (route.isLayout) {
72
74
  ret[route.id] = route;
75
+ } else {
76
+ pages[route.id] = route;
73
77
  }
74
78
  return ret;
75
79
  }, {});
@@ -101,6 +105,11 @@ var routes_default = (api) => {
101
105
  isLayout: true
102
106
  };
103
107
  }
108
+ Object.entries(pages).forEach(([, route]) => {
109
+ route.parentId = docLayoutId;
110
+ route.file = import_path.default.resolve(pagesDir, route.file);
111
+ routes[route.id] = route;
112
+ });
104
113
  docDirs.forEach((dir) => {
105
114
  const base = import_path.default.join(api.cwd, dir);
106
115
  const dirRoutes = (0, import_core.getConventionRoutes)({
@@ -131,13 +140,15 @@ var routes_default = (api) => {
131
140
  localizeUmiRoute(routes[routeId], api.config.locales);
132
141
  });
133
142
  });
134
- routes["404"] = {
135
- id: "404",
136
- path: "*",
137
- absPath: "/*",
138
- parentId: docLayoutId,
139
- file: require.resolve("../client/pages/404")
140
- };
143
+ if (Object.values(pages).every((route) => route.path !== "*")) {
144
+ routes["404"] = {
145
+ id: "404",
146
+ path: "*",
147
+ absPath: "/*",
148
+ parentId: docLayoutId,
149
+ file: require.resolve("../client/pages/404")
150
+ };
151
+ }
141
152
  routes["demo-render"] = {
142
153
  id: "demo-render",
143
154
  path: `${import_constants.SP_ROUTE_PREFIX}demos/:id`,
package/dist/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import type { IDumiUserConfig } from "./types";
2
2
  declare let unistUtilVisit: typeof import('unist-util-visit');
3
3
  export * from 'umi';
4
- export * from './client/theme-api';
5
- export { IApi } from "./types";
6
- export type { Root as HastRoot } from 'hast';
7
- export type { Plugin as UnifiedPlugin, Transformer as UnifiedTransformer, } from 'unified';
8
4
  export { unistUtilVisit };
9
5
  export declare const defineConfig: (config: IDumiUserConfig) => IDumiUserConfig;
package/dist/index.js CHANGED
@@ -28,7 +28,6 @@ __export(src_exports, {
28
28
  });
29
29
  module.exports = __toCommonJS(src_exports);
30
30
  __reExport(src_exports, require("umi"), module.exports);
31
- __reExport(src_exports, require("./client/theme-api"), module.exports);
32
31
  var unistUtilVisit;
33
32
  (async () => {
34
33
  unistUtilVisit = await import("unist-util-visit");
package/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export { Root as HastRoot } from 'hast';
2
+ export * from 'umi';
3
+ export {
4
+ Plugin as UnifiedPlugin,
5
+ Transformer as UnifiedTransformer,
6
+ } from 'unified';
7
+ export * from './dist';
8
+ // override umi exported defineConfig
9
+ export { defineConfig } from './dist';
10
+ export * from './dist/client/theme-api';
11
+ export { IApi } from './dist/types';
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
8
+ "types": "index.d.ts",
9
9
  "bin": "./bin/dumi.js",
10
10
  "files": [
11
11
  "bin",
12
12
  "dist",
13
13
  "compiled",
14
14
  "theme-default",
15
- "theme.d.ts"
15
+ "theme.d.ts",
16
+ "index.d.ts"
16
17
  ],
17
18
  "scripts": {
18
19
  "build": "father build",
@@ -1,25 +0,0 @@
1
- import { SchemaParser, SchemaResolver } from 'dumi-afx-deps/compiled/parser';
2
- import type { webpack } from 'umi';
3
- declare class AtomParserWatchWebpackPlugin {
4
- resolveDir: string;
5
- onWatchRun: (files: string[]) => void;
6
- constructor(opts: {
7
- resolveDir: string;
8
- onWatchRun: typeof AtomParserWatchWebpackPlugin.prototype.onWatchRun;
9
- });
10
- apply(compiler: webpack.Compiler): void;
11
- }
12
- declare class AtomAssetsParser {
13
- parser: SchemaParser;
14
- resolver: Promise<SchemaResolver> | undefined;
15
- resolveDir: string;
16
- unresolvedFiles: string[];
17
- constructor(opts: {
18
- entryFile: string;
19
- resolveDir: string;
20
- });
21
- parse(): Promise<SchemaResolver>;
22
- patchUnresolvedFiles(files: string[]): void;
23
- getWebpackWatchPlugin(): AtomParserWatchWebpackPlugin;
24
- }
25
- export default AtomAssetsParser;
@@ -1,74 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/assetParsers/atom.ts
23
- var atom_exports = {};
24
- __export(atom_exports, {
25
- default: () => atom_default
26
- });
27
- module.exports = __toCommonJS(atom_exports);
28
- var import_parser = require("dumi-afx-deps/compiled/parser");
29
- var import_path = __toESM(require("path"));
30
- var import_plugin_utils = require("umi/plugin-utils");
31
- var AtomParserWatchWebpackPlugin = class {
32
- constructor(opts) {
33
- this.resolveDir = opts.resolveDir;
34
- this.onWatchRun = opts.onWatchRun;
35
- }
36
- apply(compiler) {
37
- compiler.hooks.watchRun.tap(this.constructor.name, (compilation) => {
38
- const files = Array.from(compilation.watchFileSystem.watcher.fileWatchers.keys());
39
- this.onWatchRun(files.map((file) => (0, import_plugin_utils.winPath)(import_path.default.relative(this.resolveDir, file))).filter((file) => /\.(j|t)sx?$/.test(file) && !file.startsWith("../") && !file.includes(".umi")));
40
- });
41
- }
42
- };
43
- var AtomAssetsParser = class {
44
- constructor(opts) {
45
- this.unresolvedFiles = [];
46
- this.resolveDir = opts.resolveDir;
47
- this.parser = new import_parser.SchemaParser({
48
- entryPath: opts.entryFile,
49
- basePath: opts.resolveDir,
50
- unPkgHost: "https://unpkg.com"
51
- });
52
- }
53
- async parse() {
54
- if (!this.resolver || this.unresolvedFiles.length) {
55
- this.resolver = (async () => {
56
- await this.parser.patch(this.unresolvedFiles);
57
- return new import_parser.SchemaResolver(await this.parser.parse());
58
- })();
59
- }
60
- return this.resolver;
61
- }
62
- patchUnresolvedFiles(files) {
63
- this.unresolvedFiles.push(...files);
64
- }
65
- getWebpackWatchPlugin() {
66
- return new AtomParserWatchWebpackPlugin({
67
- resolveDir: this.resolveDir,
68
- onWatchRun: (files) => this.parser.patch(files)
69
- });
70
- }
71
- };
72
- var atom_default = AtomAssetsParser;
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {});