@umijs/preset-umi 4.6.66 → 4.6.68

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.
Files changed (148) hide show
  1. package/dist/commands/build.d.ts +1 -1
  2. package/dist/commands/config/config.d.ts +1 -1
  3. package/dist/commands/config/list.d.ts +1 -1
  4. package/dist/commands/config/remove.js +2 -1
  5. package/dist/commands/config/set.js +2 -1
  6. package/dist/commands/deadcode.d.ts +1 -1
  7. package/dist/commands/deadcode.js +2 -1
  8. package/dist/commands/dev/createRouteMiddleware.js +2 -1
  9. package/dist/commands/dev/depBuildWorker/depBuildWorker.js +3 -3
  10. package/dist/commands/dev/depBuildWorker/depBuilder.d.ts +1 -1
  11. package/dist/commands/dev/depBuildWorker/depBuilder.js +6 -5
  12. package/dist/commands/dev/depBuildWorker/dev-config.d.ts +1 -1
  13. package/dist/commands/dev/depBuildWorker/getConfig.js +2 -2
  14. package/dist/commands/dev/depBuildWorker/workerPreset.d.ts +2 -2
  15. package/dist/commands/dev/dev.d.ts +1 -1
  16. package/dist/commands/dev/dev.js +2 -1
  17. package/dist/commands/generators/api.d.ts +1 -1
  18. package/dist/commands/generators/component.d.ts +1 -1
  19. package/dist/commands/generators/component.js +0 -2
  20. package/dist/commands/generators/cypress.d.ts +1 -1
  21. package/dist/commands/generators/dva.d.ts +1 -1
  22. package/dist/commands/generators/jest.d.ts +1 -1
  23. package/dist/commands/generators/mock.d.ts +1 -1
  24. package/dist/commands/generators/page.d.ts +1 -1
  25. package/dist/commands/generators/page.js +9 -8
  26. package/dist/commands/generators/precommit.d.ts +1 -1
  27. package/dist/commands/generators/prettier.d.ts +1 -1
  28. package/dist/commands/generators/tailwindcss.d.ts +1 -1
  29. package/dist/commands/generators/tsconfig.d.ts +1 -1
  30. package/dist/commands/generators/utils.js +0 -2
  31. package/dist/commands/help.d.ts +1 -1
  32. package/dist/commands/lint.d.ts +1 -1
  33. package/dist/commands/mfsu/mfsu.d.ts +1 -1
  34. package/dist/commands/mfsu/util.js +0 -2
  35. package/dist/commands/plugin.d.ts +1 -1
  36. package/dist/commands/preview.d.ts +1 -1
  37. package/dist/commands/setup.d.ts +1 -1
  38. package/dist/commands/verify-commit.d.ts +1 -1
  39. package/dist/commands/version.d.ts +1 -1
  40. package/dist/constants.d.ts +1 -0
  41. package/dist/constants.js +3 -0
  42. package/dist/features/404/404.d.ts +2 -2
  43. package/dist/features/__sample.d.ts +1 -1
  44. package/dist/features/aiDev/aiDev.d.ts +1 -1
  45. package/dist/features/aiDev/aiDev.js +2 -1
  46. package/dist/features/apiRoute/apiRoute.d.ts +1 -1
  47. package/dist/features/apiRoute/apiRoute.js +2 -1
  48. package/dist/features/apiRoute/dev-server/esbuild.js +2 -1
  49. package/dist/features/apiRoute/request.d.ts +0 -2
  50. package/dist/features/apiRoute/request.js +6 -5
  51. package/dist/features/apiRoute/response.d.ts +0 -1
  52. package/dist/features/apiRoute/response.js +0 -1
  53. package/dist/features/apiRoute/utils.js +18 -9
  54. package/dist/features/appData/appData.d.ts +1 -1
  55. package/dist/features/appData/appData.js +2 -2
  56. package/dist/features/appData/umiInfo.d.ts +1 -1
  57. package/dist/features/bundler/bundler.d.ts +1 -1
  58. package/dist/features/check/babel722.d.ts +1 -1
  59. package/dist/features/check/check.d.ts +1 -1
  60. package/dist/features/classPropertiesLoose/classPropertiesLoose.d.ts +1 -1
  61. package/dist/features/clickToComponent/clickToComponent.d.ts +1 -1
  62. package/dist/features/clientLoader/clientLoader.d.ts +1 -1
  63. package/dist/features/codeSplitting/codeSplitting.d.ts +1 -1
  64. package/dist/features/codeSplitting/codeSplitting.js +4 -2
  65. package/dist/features/configPlugins/configPlugins.d.ts +1 -1
  66. package/dist/features/crossorigin/crossorigin.d.ts +1 -1
  67. package/dist/features/depsOnDemand/depsOnDemand.d.ts +1 -1
  68. package/dist/features/devTool/devTool.d.ts +1 -1
  69. package/dist/features/esbuildHelperChecker/esbuildHelperChecker.d.ts +1 -1
  70. package/dist/features/esbuildHelperChecker/esbuildHelperChecker.js +10 -5
  71. package/dist/features/esmi/Service.js +5 -5
  72. package/dist/features/esmi/esmi.d.ts +1 -1
  73. package/dist/features/exportStatic/exportStatic.d.ts +1 -1
  74. package/dist/features/favicons/favicons.d.ts +1 -1
  75. package/dist/features/favicons/favicons.js +4 -2
  76. package/dist/features/helmet/helmet.d.ts +2 -2
  77. package/dist/features/icons/icons.d.ts +1 -1
  78. package/dist/features/icons/svgr.js +4 -2
  79. package/dist/features/legacy/legacy.d.ts +1 -1
  80. package/dist/features/legacy/legacy.js +6 -6
  81. package/dist/features/lowImport/lowImport.d.ts +1 -1
  82. package/dist/features/mako/mako.d.ts +1 -1
  83. package/dist/features/mock/createMockMiddleware.js +2 -1
  84. package/dist/features/monorepo/redirect.d.ts +1 -1
  85. package/dist/features/monorepo/redirect.js +4 -2
  86. package/dist/features/mpa/mpa.d.ts +1 -1
  87. package/dist/features/mpa/mpa.js +10 -5
  88. package/dist/features/okam/okam.d.ts +1 -1
  89. package/dist/features/overrides/overrides.d.ts +1 -1
  90. package/dist/features/overrides/overrides.js +2 -1
  91. package/dist/features/overrides/transform.js +4 -2
  92. package/dist/features/phantomDependency/phantomDependency.d.ts +1 -1
  93. package/dist/features/phantomDependency/phantomDependency.js +30 -15
  94. package/dist/features/polyfill/polyfill.d.ts +1 -1
  95. package/dist/features/polyfill/publicPathPolyfill.d.ts +1 -1
  96. package/dist/features/prepare/esbuildPlugins/esbuildAliasPlugin.js +8 -4
  97. package/dist/features/prepare/prepare.d.ts +1 -1
  98. package/dist/features/prepare/prepare.js +2 -1
  99. package/dist/features/reactCompiler/forget.d.ts +1 -1
  100. package/dist/features/reactCompiler/reactCompiler.d.ts +1 -1
  101. package/dist/features/reactCompiler/reactCompiler.js +4 -7
  102. package/dist/features/routePrefetch/routePrefetch.d.ts +1 -1
  103. package/dist/features/routePreloadOnLoad/routePreloadOnLoad.d.ts +1 -1
  104. package/dist/features/routePreloadOnLoad/routePreloadOnLoad.js +4 -2
  105. package/dist/features/routeProps/routeProps.d.ts +1 -1
  106. package/dist/features/ssr/builder/css-loader.js +2 -2
  107. package/dist/features/ssr/mako/mako.d.ts +1 -0
  108. package/dist/features/ssr/mako/mako.js +2 -2
  109. package/dist/features/ssr/ssr.d.ts +1 -1
  110. package/dist/features/ssr/ssr.js +4 -3
  111. package/dist/features/ssr/utils.js +4 -2
  112. package/dist/features/ssr/utoopack/utoopack.js +3 -3
  113. package/dist/features/ssr/webpack/webpack.js +2 -2
  114. package/dist/features/stagewise/stagewise.d.ts +1 -1
  115. package/dist/features/swc/swc.d.ts +1 -1
  116. package/dist/features/terminal/terminal.d.ts +1 -1
  117. package/dist/features/test/test.d.ts +1 -1
  118. package/dist/features/tmpFiles/configTypes.d.ts +1 -1
  119. package/dist/features/tmpFiles/getModuleExports.js +2 -2
  120. package/dist/features/tmpFiles/routes.js +7 -6
  121. package/dist/features/tmpFiles/tmpFiles.d.ts +1 -1
  122. package/dist/features/tmpFiles/tmpFiles.js +15 -15
  123. package/dist/features/transform/CodeFrameError.js +0 -1
  124. package/dist/features/transform/transform.d.ts +1 -1
  125. package/dist/features/ui/ui.d.ts +1 -1
  126. package/dist/features/ui/ui.js +2 -1
  127. package/dist/features/utoopack/utoopack.d.ts +1 -1
  128. package/dist/features/vite/vite.d.ts +1 -1
  129. package/dist/features/webpack/webpack.d.ts +1 -1
  130. package/dist/index.d.ts +2 -2
  131. package/dist/libs/folderCache/AutoUpdateFolderCache.js +3 -9
  132. package/dist/libs/folderCache/AutoUpdateSourceCodeCache.d.ts +2 -2
  133. package/dist/libs/folderCache/AutoUpdateSourceCodeCache.js +2 -5
  134. package/dist/libs/folderCache/FolderWatch.js +2 -5
  135. package/dist/libs/folderCache/LazySourceCodeCache.d.ts +2 -2
  136. package/dist/libs/folderCache/LazySourceCodeCache.js +6 -10
  137. package/dist/libs/folderCache/constant.d.ts +28 -28
  138. package/dist/libs/folderCache/types.d.ts +5 -5
  139. package/dist/libs/scan.d.ts +1 -1
  140. package/dist/libs/scan.js +4 -2
  141. package/dist/registerMethods.d.ts +1 -1
  142. package/dist/types.d.ts +12 -13
  143. package/dist/utils/extractEntryAssets.d.ts +1 -1
  144. package/dist/utils/routeExportExtractor.d.ts +1 -1
  145. package/dist/utils/routeExportExtractor.js +2 -1
  146. package/dist/utils/serializeAppData.js +2 -1
  147. package/package.json +15 -15
  148. package/templates/defineApp.tpl +1 -0
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,2 +1,2 @@
1
- import type { IConfig } from '@umijs/bundler-webpack/dist/types';
1
+ import type { IConfig } from '@umijs/bundler-webpack';
2
2
  export declare function list(config: IConfig, name?: string): void;
@@ -26,7 +26,8 @@ var import_ast = require("@umijs/ast");
26
26
  var import_fs = require("fs");
27
27
  function remove(mainConfigFile, name) {
28
28
  const ast = (0, import_ast.getASTByFilePath)(mainConfigFile);
29
- if (!ast) return;
29
+ if (!ast)
30
+ return;
30
31
  const generateCode = (0, import_ast.generate)((0, import_ast.removeConfigByName)(ast, name));
31
32
  const prettier = require("@umijs/utils/compiled/prettier");
32
33
  const printStr = prettier.format(generateCode, {
@@ -35,7 +35,8 @@ function set(api, name, value) {
35
35
  api.appData.mainConfigFile = absPath;
36
36
  }
37
37
  const ast = (0, import_ast.getASTByFilePath)(mainConfigFile);
38
- if (!ast) return;
38
+ if (!ast)
39
+ return;
39
40
  const generateCode = (0, import_ast.generate)((0, import_ast.setConfigByName)(ast, name, value));
40
41
  const prettier = require("@umijs/utils/compiled/prettier");
41
42
  const printStr = prettier.format(generateCode, {
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -205,7 +205,8 @@ var deadcode_default = (api) => {
205
205
  const recordJsonPath = (0, import_utils.winPath)(
206
206
  (0, import_path.join)(cwd, typeof out === "string" ? out : recordJson)
207
207
  );
208
- if (gitInfo) import_utils.logger.wait("generating file...");
208
+ if (gitInfo)
209
+ import_utils.logger.wait("generating file...");
209
210
  await outputUnusedFiles(unusedFiles, recordJsonPath, {
210
211
  gitInfo,
211
212
  cwd
@@ -44,7 +44,8 @@ function createRouteMiddleware(opts) {
44
44
  hasErrors: () => false
45
45
  };
46
46
  }
47
- if (webpackStats) return Promise.resolve(webpackStats);
47
+ if (webpackStats)
48
+ return Promise.resolve(webpackStats);
48
49
  return new Promise((resolve) => {
49
50
  onStats = (stats) => {
50
51
  resolve(stats);
@@ -24,7 +24,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  // src/commands/dev/depBuildWorker/depBuildWorker.ts
25
25
  var import_bundler_webpack = require("@umijs/bundler-webpack");
26
26
  var import_constants = require("@umijs/bundler-webpack/dist/constants");
27
- var import_types = require("@umijs/bundler-webpack/dist/types");
28
27
  var import_mfsu = require("@umijs/mfsu");
29
28
  var import_utils = require("@umijs/utils");
30
29
  var import_path = require("path");
@@ -71,7 +70,7 @@ async function start() {
71
70
  const depConfig = await (0, import_bundler_webpack.getConfig)({
72
71
  cwd: opts.cwd,
73
72
  rootDir: opts.rootDir,
74
- env: import_types.Env.development,
73
+ env: import_bundler_webpack.Env.development,
75
74
  entry: opts.entry,
76
75
  userConfig: opts.config,
77
76
  disableCopy: true,
@@ -114,7 +113,8 @@ start().catch((e) => {
114
113
  import_utils.logger.error("[MFSU][eager] build worker start failed", e);
115
114
  });
116
115
  function makeArray(a) {
117
- if (Array.isArray(a)) return a;
116
+ if (Array.isArray(a))
117
+ return a;
118
118
  return [a];
119
119
  }
120
120
  function setupWorkerEnv() {
@@ -1,6 +1,6 @@
1
1
  import webpack from '@umijs/bundler-webpack/compiled/webpack';
2
2
  import { Dep } from '@umijs/mfsu/dist/dep/dep';
3
- declare type IOpts = {
3
+ type IOpts = {
4
4
  depConfig: webpack.Configuration;
5
5
  cwd: string;
6
6
  tmpBase: string;
@@ -45,10 +45,9 @@ var import_path = require("path");
45
45
  var import_worker_threads = require("worker_threads");
46
46
  var MF_ENTRY = "mf_index.js";
47
47
  var DepBuilderInWorker = class {
48
- completeFns = [];
49
- isBuilding = false;
50
- opts;
51
48
  constructor(opts) {
49
+ this.completeFns = [];
50
+ this.isBuilding = false;
52
51
  this.opts = opts;
53
52
  }
54
53
  async buildWithWebpack(opts) {
@@ -155,8 +154,10 @@ var DepBuilderInWorker = class {
155
154
  depConfig.output.path = this.opts.tmpBase;
156
155
  depConfig.output.publicPath = "auto";
157
156
  depConfig.devtool = false;
158
- if ((_a = depConfig.output) == null ? void 0 : _a.library) delete depConfig.output.library;
159
- if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget) delete depConfig.output.libraryTarget;
157
+ if ((_a = depConfig.output) == null ? void 0 : _a.library)
158
+ delete depConfig.output.library;
159
+ if ((_b = depConfig.output) == null ? void 0 : _b.libraryTarget)
160
+ delete depConfig.output.libraryTarget;
160
161
  depConfig.optimization || (depConfig.optimization = {});
161
162
  depConfig.optimization.splitChunks = {
162
163
  chunks: (chunk) => {
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -32,9 +32,9 @@ __export(getConfig_exports, {
32
32
  getDevConfig: () => getDevConfig
33
33
  });
34
34
  module.exports = __toCommonJS(getConfig_exports);
35
- var import_service = require("umi/dist/service/service");
35
+ var { Service } = require("umi");
36
36
  async function getDevConfig() {
37
- const service = new import_service.Service({
37
+ const service = new Service({
38
38
  presets: [require.resolve("./workerPreset")]
39
39
  });
40
40
  const opts = await service.run({
@@ -1,4 +1,4 @@
1
- declare const _default: () => {
1
+ export default _default;
2
+ declare function _default(): {
2
3
  plugins: string[];
3
4
  };
4
- export default _default;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -216,7 +216,8 @@ PORT=8888 umi dev
216
216
  const isPublicAvailable = (0, import_fs.existsSync)(publicDir) && (0, import_fs.readdirSync)(publicDir).length;
217
217
  let restarted = false;
218
218
  const restartServer = () => {
219
- if (restarted) return;
219
+ if (restarted)
220
+ return;
220
221
  restarted = true;
221
222
  import_utils.logger.event(`public dir changed, restart server...`);
222
223
  api.restartServer();
@@ -1,6 +1,6 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
4
4
  export declare function generateApiResKV(apiName: string): {
5
5
  key: string;
6
6
  value: string;
@@ -1,7 +1,7 @@
1
1
  import { IApi } from '../../types';
2
2
  import { type IArgsComponent } from './utils';
3
- declare const _default: (api: IApi) => void;
4
3
  export default _default;
4
+ declare function _default(api: IApi): void;
5
5
  export declare class ComponentGenerator {
6
6
  readonly opts: {
7
7
  componentName: string;
@@ -74,8 +74,6 @@ var ComponentGenerator = class {
74
74
  this.name = name;
75
75
  this.dir = dir;
76
76
  }
77
- name;
78
- dir;
79
77
  async run() {
80
78
  const { appRoot, args } = this.opts;
81
79
  const capitalizeName = import_utils.lodash.upperFirst(this.name);
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,8 +1,8 @@
1
1
  import { prompts } from '@umijs/utils';
2
2
  import { IApi } from '../../types';
3
3
  import { type IArgsPage } from './utils';
4
- declare const _default: (api: IApi) => void;
5
4
  export default _default;
5
+ declare function _default(api: IApi): void;
6
6
  export declare class PageGenerator {
7
7
  readonly options: {
8
8
  args: IArgsPage;
@@ -59,6 +59,13 @@ var USER_TEMPLATE_PAGE_DIR = "templates/page";
59
59
  var PageGenerator = class {
60
60
  constructor(options) {
61
61
  this.options = options;
62
+ this.isDirMode = false;
63
+ this.dir = "";
64
+ this.name = "";
65
+ this.importSource = "";
66
+ this.needEnsureDirMode = false;
67
+ this.prompts = import_utils2.promptsExitWhenCancel;
68
+ this.paths = [];
62
69
  this.isDirMode = !!options.args.dir;
63
70
  this.importSource = options.importSource || "umi";
64
71
  const [_, ...inputPaths] = options.args._;
@@ -68,13 +75,6 @@ var PageGenerator = class {
68
75
  this.needEnsureDirMode = true;
69
76
  }
70
77
  }
71
- isDirMode = false;
72
- dir = "";
73
- name = "";
74
- importSource = "";
75
- needEnsureDirMode = false;
76
- prompts = import_utils2.promptsExitWhenCancel;
77
- paths = [];
78
78
  async run() {
79
79
  if (this.paths.length === 0) {
80
80
  await this.runInteractiveMode();
@@ -129,7 +129,8 @@ var PageGenerator = class {
129
129
  this.isDirMode = false;
130
130
  }
131
131
  async ensureDirMode() {
132
- if (!this.needEnsureDirMode) return;
132
+ if (!this.needEnsureDirMode)
133
+ return;
133
134
  const response = await this.prompts({
134
135
  type: "select",
135
136
  name: "mode",
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -60,8 +60,6 @@ var GeneratorHelper = class {
60
60
  this.needInstallUmiPlugin = needInstall;
61
61
  this.needConfigUmiPlugin = needConfigPlugins;
62
62
  }
63
- needConfigUmiPlugin;
64
- needInstallUmiPlugin;
65
63
  setUmirc(key, val) {
66
64
  (0, import_set.set)(this.api, key, val);
67
65
  }
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -49,8 +49,6 @@ var MFSUUtilBase = class {
49
49
  this.mfsuCacheBase = ((_b = (_a = api.config) == null ? void 0 : _a.mfsu) == null ? void 0 : _b.cacheDirectoryPath) || (0, import_path.join)(cacheBase, "mfsu");
50
50
  this.cliName = this.api.appData.umi.cliName;
51
51
  }
52
- mfsuCacheBase;
53
- cliName;
54
52
  async prepare() {
55
53
  var _a, _b, _c, _d;
56
54
  const api = this.api;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,4 +1,5 @@
1
1
  export declare const DEFAULT_PORT = "8000";
2
2
  export declare const DEFAULT_HOST = "0.0.0.0";
3
3
  export declare const CACHE_DIR_NAME = ".cache";
4
+ export declare const RUNTIME_TYPE_FILE_NAME = "runtimeConfig.d.ts";
4
5
  export declare const TEMPLATES_DIR: string;
package/dist/constants.js CHANGED
@@ -22,6 +22,7 @@ __export(constants_exports, {
22
22
  CACHE_DIR_NAME: () => CACHE_DIR_NAME,
23
23
  DEFAULT_HOST: () => DEFAULT_HOST,
24
24
  DEFAULT_PORT: () => DEFAULT_PORT,
25
+ RUNTIME_TYPE_FILE_NAME: () => RUNTIME_TYPE_FILE_NAME,
25
26
  TEMPLATES_DIR: () => TEMPLATES_DIR
26
27
  });
27
28
  module.exports = __toCommonJS(constants_exports);
@@ -29,11 +30,13 @@ var import_path = require("path");
29
30
  var DEFAULT_PORT = "8000";
30
31
  var DEFAULT_HOST = "0.0.0.0";
31
32
  var CACHE_DIR_NAME = ".cache";
33
+ var RUNTIME_TYPE_FILE_NAME = "runtimeConfig.d.ts";
32
34
  var TEMPLATES_DIR = (0, import_path.join)(__dirname, "../templates");
33
35
  // Annotate the CommonJS export names for ESM import in node:
34
36
  0 && (module.exports = {
35
37
  CACHE_DIR_NAME,
36
38
  DEFAULT_HOST,
37
39
  DEFAULT_PORT,
40
+ RUNTIME_TYPE_FILE_NAME,
38
41
  TEMPLATES_DIR
39
42
  });
@@ -1,5 +1,5 @@
1
1
  import { IApi, IRoute } from '../../types';
2
- declare type Routes = Record<string, IRoute>;
2
+ type Routes = Record<string, IRoute>;
3
3
  export declare function patchRoutes(routes: Routes): Routes;
4
- declare const _default: (api: IApi) => void;
5
4
  export default _default;
5
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -54,7 +54,8 @@ var aiDev_default = (api) => {
54
54
  if (api.config.mako || api.config.utoopack) {
55
55
  return;
56
56
  }
57
- if (!process.env.UMI_AI_COMMAND || !process.env.UMI_AI_PACKAGE) return;
57
+ if (!process.env.UMI_AI_COMMAND || !process.env.UMI_AI_PACKAGE)
58
+ return;
58
59
  try {
59
60
  const aiCommand = process.env.UMI_AI_COMMAND;
60
61
  const aiPackage = process.env.UMI_AI_PACKAGE;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -66,7 +66,8 @@ var apiRoute_default = (api) => {
66
66
  },
67
67
  enableBy: () => {
68
68
  const hasApiRoutes = import_fs.default.existsSync((0, import_path.join)(api.paths.absSrcPath, "api"));
69
- if (!hasApiRoutes) return false;
69
+ if (!hasApiRoutes)
70
+ return false;
70
71
  const config = api.userConfig.apiRoute;
71
72
  if (!config) {
72
73
  return false;
@@ -55,7 +55,8 @@ async function esbuild_default(api, apiRoutes) {
55
55
  (0, import_utils2.esbuildIgnorePathPrefixPlugin)(),
56
56
  (0, import_watchRebuild.esbuildWatchRebuildPlugin)({
57
57
  onRebuild(error) {
58
- if (error) import_utils.logger.error("Compile api routes failed: ", error);
58
+ if (error)
59
+ import_utils.logger.error("Compile api routes failed: ", error);
59
60
  Object.keys(require.cache).forEach((modulePath) => {
60
61
  if (modulePath.startsWith((0, import_path.join)(api.paths.cwd, import_constants.OUTPUT_PATH)))
61
62
  delete require.cache[modulePath];
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import type { IncomingMessage } from 'http';
4
2
  import type { IRoute } from '../../types';
5
3
  declare class UmiApiRequest {
@@ -26,17 +26,17 @@ __export(request_exports, {
26
26
  module.exports = __toCommonJS(request_exports);
27
27
  var import_utils = require("./utils");
28
28
  var UmiApiRequest = class {
29
- _req;
30
- _params = {};
31
29
  constructor(req, apiRoutes) {
30
+ this._params = {};
31
+ this._body = null;
32
32
  this._req = req;
33
33
  const m = (0, import_utils.matchApiRoute)(apiRoutes, this.pathName || "");
34
- if (m) this._params = m.params;
34
+ if (m)
35
+ this._params = m.params;
35
36
  }
36
37
  get params() {
37
38
  return this._params;
38
39
  }
39
- _body = null;
40
40
  get body() {
41
41
  return this._body;
42
42
  }
@@ -128,7 +128,8 @@ function parseMultipart(body, boundary) {
128
128
  );
129
129
  const meta = Buffer.from(hexMeta, "hex").toString("utf-8");
130
130
  const name = (_a = meta.split('name="')[1]) == null ? void 0 : _a.split('"')[0];
131
- if (!name) return acc;
131
+ if (!name)
132
+ return acc;
132
133
  const fileName = (_b = meta.split('filename="')[1]) == null ? void 0 : _b.split('"')[0];
133
134
  if (fileName) {
134
135
  const fileBufferBeforeTrim = Buffer.from(hexValue, "hex");
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ServerResponse } from 'http';
3
2
  declare class UmiApiResponse {
4
3
  private _res;
@@ -23,7 +23,6 @@ __export(response_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(response_exports);
25
25
  var UmiApiResponse = class {
26
- _res;
27
26
  constructor(res) {
28
27
  this._res = res;
29
28
  }
@@ -34,30 +34,39 @@ function esbuildIgnorePathPrefixPlugin() {
34
34
  };
35
35
  }
36
36
  function matchApiRoute(apiRoutes, path) {
37
- if (path.startsWith("/")) path = path.substring(1);
38
- if (path.startsWith("api/")) path = path.substring(4);
37
+ if (path.startsWith("/"))
38
+ path = path.substring(1);
39
+ if (path.startsWith("api/"))
40
+ path = path.substring(4);
39
41
  const pathSegments = path.split("/").filter((p) => p !== "");
40
42
  if (pathSegments.length === 0 || pathSegments.length === 1 && pathSegments[0] === "api") {
41
43
  const route2 = apiRoutes.find((r) => r.path === "/");
42
- if (route2) return { route: route2, params: {} };
43
- else return void 0;
44
+ if (route2)
45
+ return { route: route2, params: {} };
46
+ else
47
+ return void 0;
44
48
  }
45
49
  const params = {};
46
50
  const route = apiRoutes.find((route2) => {
47
51
  const routePathSegments = route2.path.split("/").filter((p) => p !== "");
48
- if (routePathSegments.length !== pathSegments.length) return false;
52
+ if (routePathSegments.length !== pathSegments.length)
53
+ return false;
49
54
  for (let i = 0; i < routePathSegments.length; i++) {
50
55
  const routePathSegment = routePathSegments[i];
51
56
  if (routePathSegment.match(/^\[.*]$/)) {
52
57
  params[routePathSegment.substring(1, routePathSegment.length - 1)] = pathSegments[i];
53
- if (i == routePathSegments.length - 1) return true;
58
+ if (i == routePathSegments.length - 1)
59
+ return true;
54
60
  continue;
55
61
  }
56
- if (routePathSegment !== pathSegments[i]) return false;
57
- if (i == routePathSegments.length - 1) return true;
62
+ if (routePathSegment !== pathSegments[i])
63
+ return false;
64
+ if (i == routePathSegments.length - 1)
65
+ return true;
58
66
  }
59
67
  });
60
- if (route) return { route, params };
68
+ if (route)
69
+ return { route, params };
61
70
  }
62
71
  // Annotate the CommonJS export names for ESM import in node:
63
72
  0 && (module.exports = {
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -160,13 +160,13 @@ var appData_default = (api) => {
160
160
  async function getAppJsInfo() {
161
161
  for (const path of (0, import_watch.expandJSPaths)((0, import_path.join)(api.paths.absSrcPath, "app"))) {
162
162
  if ((0, import_fs.existsSync)(path)) {
163
- const [_, exports2] = await bundlerUtils.parseModule({
163
+ const [_, exports] = await bundlerUtils.parseModule({
164
164
  path,
165
165
  content: (0, import_fs.readFileSync)(path, "utf-8")
166
166
  });
167
167
  return {
168
168
  path,
169
- exports: exports2
169
+ exports
170
170
  };
171
171
  }
172
172
  }
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;
@@ -1,3 +1,3 @@
1
1
  import type { IApi } from '../../types';
2
- declare const _default: (api: IApi) => void;
3
2
  export default _default;
3
+ declare function _default(api: IApi): void;