@modern-js/app-tools 2.8.1-alpha.2 → 2.9.0

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 (272) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/cjs/analyze/templates.js +1 -2
  3. package/dist/esm/analyze/templates.js +2 -2
  4. package/dist/esm-node/analyze/templates.js +1 -2
  5. package/package.json +24 -24
  6. package/dist/js/modern/analyze/constants.js +0 -56
  7. package/dist/js/modern/analyze/generateCode.js +0 -247
  8. package/dist/js/modern/analyze/getBundleEntry.js +0 -71
  9. package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
  10. package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
  11. package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
  12. package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
  13. package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
  14. package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
  15. package/dist/js/modern/analyze/getServerRoutes.js +0 -178
  16. package/dist/js/modern/analyze/index.js +0 -333
  17. package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
  18. package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
  19. package/dist/js/modern/analyze/nestedRoutes.js +0 -186
  20. package/dist/js/modern/analyze/templates.js +0 -328
  21. package/dist/js/modern/analyze/utils.js +0 -141
  22. package/dist/js/modern/builder/builder-rspack/index.js +0 -8
  23. package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
  24. package/dist/js/modern/builder/builder-webpack/index.js +0 -93
  25. package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -116
  26. package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
  27. package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
  28. package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
  29. package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -21
  30. package/dist/js/modern/builder/generator/index.js +0 -53
  31. package/dist/js/modern/builder/index.js +0 -39
  32. package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +0 -219
  33. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
  34. package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
  35. package/dist/js/modern/builder/shared/createCopyPattern.js +0 -46
  36. package/dist/js/modern/builder/shared/index.js +0 -3
  37. package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +0 -7
  38. package/dist/js/modern/builder/shared/types.js +0 -0
  39. package/dist/js/modern/commands/build.js +0 -91
  40. package/dist/js/modern/commands/deploy.js +0 -28
  41. package/dist/js/modern/commands/dev.js +0 -109
  42. package/dist/js/modern/commands/index.js +0 -3
  43. package/dist/js/modern/commands/inspect.js +0 -38
  44. package/dist/js/modern/commands/serve.js +0 -54
  45. package/dist/js/modern/config/default.js +0 -175
  46. package/dist/js/modern/config/index.js +0 -3
  47. package/dist/js/modern/config/initialize/index.js +0 -12
  48. package/dist/js/modern/config/initialize/inits.js +0 -154
  49. package/dist/js/modern/config/legacy/createHtmlConfig.js +0 -35
  50. package/dist/js/modern/config/legacy/createOutputConfig.js +0 -68
  51. package/dist/js/modern/config/legacy/createSourceConfig.js +0 -39
  52. package/dist/js/modern/config/legacy/createToolsConfig.js +0 -42
  53. package/dist/js/modern/config/legacy/index.js +0 -51
  54. package/dist/js/modern/defineConfig.js +0 -27
  55. package/dist/js/modern/exports/server.js +0 -4
  56. package/dist/js/modern/hooks.js +0 -35
  57. package/dist/js/modern/index.js +0 -221
  58. package/dist/js/modern/initialize/index.js +0 -132
  59. package/dist/js/modern/locale/en.js +0 -36
  60. package/dist/js/modern/locale/index.js +0 -9
  61. package/dist/js/modern/locale/zh.js +0 -36
  62. package/dist/js/modern/schema/Schema.js +0 -40
  63. package/dist/js/modern/schema/index.js +0 -88
  64. package/dist/js/modern/schema/legacy.js +0 -148
  65. package/dist/js/modern/types/config/deploy.js +0 -0
  66. package/dist/js/modern/types/config/dev.js +0 -0
  67. package/dist/js/modern/types/config/experiments.js +0 -0
  68. package/dist/js/modern/types/config/html.js +0 -0
  69. package/dist/js/modern/types/config/index.js +0 -1
  70. package/dist/js/modern/types/config/output.js +0 -0
  71. package/dist/js/modern/types/config/performance.js +0 -0
  72. package/dist/js/modern/types/config/security.js +0 -0
  73. package/dist/js/modern/types/config/source.js +0 -0
  74. package/dist/js/modern/types/config/tools.js +0 -0
  75. package/dist/js/modern/types/hooks.js +0 -0
  76. package/dist/js/modern/types/index.js +0 -3
  77. package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
  78. package/dist/js/modern/types/legacyConfig/dev.js +0 -0
  79. package/dist/js/modern/types/legacyConfig/index.js +0 -0
  80. package/dist/js/modern/types/legacyConfig/output.js +0 -0
  81. package/dist/js/modern/types/legacyConfig/source.js +0 -0
  82. package/dist/js/modern/types/legacyConfig/tools.js +0 -0
  83. package/dist/js/modern/types/utils.js +0 -0
  84. package/dist/js/modern/utils/config.js +0 -128
  85. package/dist/js/modern/utils/createServer.js +0 -75
  86. package/dist/js/modern/utils/env.js +0 -15
  87. package/dist/js/modern/utils/generateWatchFiles.js +0 -55
  88. package/dist/js/modern/utils/getSelectedEntries.js +0 -58
  89. package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
  90. package/dist/js/modern/utils/language.js +0 -8
  91. package/dist/js/modern/utils/printInstructions.js +0 -31
  92. package/dist/js/modern/utils/restart.js +0 -44
  93. package/dist/js/modern/utils/routes.js +0 -30
  94. package/dist/js/modern/utils/types.js +0 -0
  95. package/dist/js/node/analyze/constants.js +0 -100
  96. package/dist/js/node/analyze/generateCode.js +0 -271
  97. package/dist/js/node/analyze/getBundleEntry.js +0 -95
  98. package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
  99. package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
  100. package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
  101. package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
  102. package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
  103. package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
  104. package/dist/js/node/analyze/getServerRoutes.js +0 -196
  105. package/dist/js/node/analyze/index.js +0 -340
  106. package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
  107. package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
  108. package/dist/js/node/analyze/nestedRoutes.js +0 -213
  109. package/dist/js/node/analyze/templates.js +0 -359
  110. package/dist/js/node/analyze/utils.js +0 -172
  111. package/dist/js/node/builder/builder-rspack/index.js +0 -31
  112. package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  113. package/dist/js/node/builder/builder-webpack/index.js +0 -118
  114. package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -140
  115. package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
  116. package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
  117. package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
  118. package/dist/js/node/builder/generator/getBuilderTargets.js +0 -39
  119. package/dist/js/node/builder/generator/index.js +0 -82
  120. package/dist/js/node/builder/index.js +0 -68
  121. package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +0 -245
  122. package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -50
  123. package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -57
  124. package/dist/js/node/builder/shared/createCopyPattern.js +0 -75
  125. package/dist/js/node/builder/shared/index.js +0 -19
  126. package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +0 -28
  127. package/dist/js/node/builder/shared/types.js +0 -15
  128. package/dist/js/node/commands/build.js +0 -112
  129. package/dist/js/node/commands/deploy.js +0 -51
  130. package/dist/js/node/commands/dev.js +0 -126
  131. package/dist/js/node/commands/index.js +0 -19
  132. package/dist/js/node/commands/inspect.js +0 -61
  133. package/dist/js/node/commands/serve.js +0 -83
  134. package/dist/js/node/config/default.js +0 -197
  135. package/dist/js/node/config/index.js +0 -19
  136. package/dist/js/node/config/initialize/index.js +0 -35
  137. package/dist/js/node/config/initialize/inits.js +0 -177
  138. package/dist/js/node/config/legacy/createHtmlConfig.js +0 -58
  139. package/dist/js/node/config/legacy/createOutputConfig.js +0 -91
  140. package/dist/js/node/config/legacy/createSourceConfig.js +0 -62
  141. package/dist/js/node/config/legacy/createToolsConfig.js +0 -65
  142. package/dist/js/node/config/legacy/index.js +0 -75
  143. package/dist/js/node/defineConfig.js +0 -49
  144. package/dist/js/node/exports/server.js +0 -27
  145. package/dist/js/node/hooks.js +0 -54
  146. package/dist/js/node/index.js +0 -245
  147. package/dist/js/node/initialize/index.js +0 -141
  148. package/dist/js/node/locale/en.js +0 -59
  149. package/dist/js/node/locale/index.js +0 -33
  150. package/dist/js/node/locale/zh.js +0 -59
  151. package/dist/js/node/schema/Schema.js +0 -63
  152. package/dist/js/node/schema/index.js +0 -118
  153. package/dist/js/node/schema/legacy.js +0 -169
  154. package/dist/js/node/types/config/deploy.js +0 -15
  155. package/dist/js/node/types/config/dev.js +0 -15
  156. package/dist/js/node/types/config/experiments.js +0 -15
  157. package/dist/js/node/types/config/html.js +0 -15
  158. package/dist/js/node/types/config/index.js +0 -17
  159. package/dist/js/node/types/config/output.js +0 -15
  160. package/dist/js/node/types/config/performance.js +0 -15
  161. package/dist/js/node/types/config/security.js +0 -15
  162. package/dist/js/node/types/config/source.js +0 -15
  163. package/dist/js/node/types/config/tools.js +0 -15
  164. package/dist/js/node/types/hooks.js +0 -15
  165. package/dist/js/node/types/index.js +0 -19
  166. package/dist/js/node/types/legacyConfig/deploy.js +0 -15
  167. package/dist/js/node/types/legacyConfig/dev.js +0 -15
  168. package/dist/js/node/types/legacyConfig/index.js +0 -15
  169. package/dist/js/node/types/legacyConfig/output.js +0 -15
  170. package/dist/js/node/types/legacyConfig/source.js +0 -15
  171. package/dist/js/node/types/legacyConfig/tools.js +0 -15
  172. package/dist/js/node/types/utils.js +0 -15
  173. package/dist/js/node/utils/config.js +0 -153
  174. package/dist/js/node/utils/createServer.js +0 -106
  175. package/dist/js/node/utils/env.js +0 -38
  176. package/dist/js/node/utils/generateWatchFiles.js +0 -85
  177. package/dist/js/node/utils/getSelectedEntries.js +0 -81
  178. package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
  179. package/dist/js/node/utils/language.js +0 -31
  180. package/dist/js/node/utils/printInstructions.js +0 -54
  181. package/dist/js/node/utils/restart.js +0 -67
  182. package/dist/js/node/utils/routes.js +0 -59
  183. package/dist/js/node/utils/types.js +0 -15
  184. package/dist/js/treeshaking/analyze/constants.js +0 -42
  185. package/dist/js/treeshaking/analyze/generateCode.js +0 -485
  186. package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
  187. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
  188. package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
  189. package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
  190. package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
  191. package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
  192. package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
  193. package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -224
  194. package/dist/js/treeshaking/analyze/index.js +0 -702
  195. package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
  196. package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
  197. package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -409
  198. package/dist/js/treeshaking/analyze/templates.js +0 -465
  199. package/dist/js/treeshaking/analyze/utils.js +0 -374
  200. package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
  201. package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
  202. package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
  203. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -346
  204. package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
  205. package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
  206. package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
  207. package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -16
  208. package/dist/js/treeshaking/builder/generator/index.js +0 -199
  209. package/dist/js/treeshaking/builder/index.js +0 -175
  210. package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +0 -300
  211. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -110
  212. package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -72
  213. package/dist/js/treeshaking/builder/shared/createCopyPattern.js +0 -40
  214. package/dist/js/treeshaking/builder/shared/index.js +0 -3
  215. package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +0 -5
  216. package/dist/js/treeshaking/builder/shared/types.js +0 -1
  217. package/dist/js/treeshaking/commands/build.js +0 -291
  218. package/dist/js/treeshaking/commands/deploy.js +0 -154
  219. package/dist/js/treeshaking/commands/dev.js +0 -301
  220. package/dist/js/treeshaking/commands/index.js +0 -3
  221. package/dist/js/treeshaking/commands/inspect.js +0 -149
  222. package/dist/js/treeshaking/commands/serve.js +0 -199
  223. package/dist/js/treeshaking/config/default.js +0 -210
  224. package/dist/js/treeshaking/config/index.js +0 -3
  225. package/dist/js/treeshaking/config/initialize/index.js +0 -10
  226. package/dist/js/treeshaking/config/initialize/inits.js +0 -211
  227. package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
  228. package/dist/js/treeshaking/config/legacy/createOutputConfig.js +0 -41
  229. package/dist/js/treeshaking/config/legacy/createSourceConfig.js +0 -42
  230. package/dist/js/treeshaking/config/legacy/createToolsConfig.js +0 -23
  231. package/dist/js/treeshaking/config/legacy/index.js +0 -38
  232. package/dist/js/treeshaking/defineConfig.js +0 -61
  233. package/dist/js/treeshaking/exports/server.js +0 -2
  234. package/dist/js/treeshaking/hooks.js +0 -29
  235. package/dist/js/treeshaking/index.js +0 -713
  236. package/dist/js/treeshaking/initialize/index.js +0 -284
  237. package/dist/js/treeshaking/locale/en.js +0 -38
  238. package/dist/js/treeshaking/locale/index.js +0 -9
  239. package/dist/js/treeshaking/locale/zh.js +0 -38
  240. package/dist/js/treeshaking/schema/Schema.js +0 -273
  241. package/dist/js/treeshaking/schema/index.js +0 -181
  242. package/dist/js/treeshaking/schema/legacy.js +0 -337
  243. package/dist/js/treeshaking/types/config/deploy.js +0 -1
  244. package/dist/js/treeshaking/types/config/dev.js +0 -1
  245. package/dist/js/treeshaking/types/config/experiments.js +0 -1
  246. package/dist/js/treeshaking/types/config/html.js +0 -1
  247. package/dist/js/treeshaking/types/config/index.js +0 -1
  248. package/dist/js/treeshaking/types/config/output.js +0 -1
  249. package/dist/js/treeshaking/types/config/performance.js +0 -1
  250. package/dist/js/treeshaking/types/config/security.js +0 -1
  251. package/dist/js/treeshaking/types/config/source.js +0 -1
  252. package/dist/js/treeshaking/types/config/tools.js +0 -1
  253. package/dist/js/treeshaking/types/hooks.js +0 -1
  254. package/dist/js/treeshaking/types/index.js +0 -3
  255. package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
  256. package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
  257. package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
  258. package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
  259. package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
  260. package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
  261. package/dist/js/treeshaking/types/utils.js +0 -1
  262. package/dist/js/treeshaking/utils/config.js +0 -302
  263. package/dist/js/treeshaking/utils/createServer.js +0 -258
  264. package/dist/js/treeshaking/utils/env.js +0 -13
  265. package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
  266. package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
  267. package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
  268. package/dist/js/treeshaking/utils/language.js +0 -6
  269. package/dist/js/treeshaking/utils/printInstructions.js +0 -152
  270. package/dist/js/treeshaking/utils/restart.js +0 -187
  271. package/dist/js/treeshaking/utils/routes.js +0 -153
  272. package/dist/js/treeshaking/utils/types.js +0 -1
@@ -1,54 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var hooks_exports = {};
19
- __export(hooks_exports, {
20
- hooks: () => hooks
21
- });
22
- module.exports = __toCommonJS(hooks_exports);
23
- var import_plugin = require("@modern-js/plugin");
24
- const hooks = {
25
- modifyEntryExport: (0, import_plugin.createAsyncWaterfall)(),
26
- modifyEntryImports: (0, import_plugin.createAsyncWaterfall)(),
27
- modifyEntryRuntimePlugins: (0, import_plugin.createAsyncWaterfall)(),
28
- modifyEntryRenderFunction: (0, import_plugin.createAsyncWaterfall)(),
29
- modifyAsyncEntry: (0, import_plugin.createAsyncWaterfall)(),
30
- modifyFileSystemRoutes: (0, import_plugin.createAsyncWaterfall)(),
31
- modifyServerRoutes: (0, import_plugin.createAsyncWaterfall)(),
32
- htmlPartials: (0, import_plugin.createAsyncWaterfall)(),
33
- beforeGenerateRoutes: (0, import_plugin.createAsyncWaterfall)(),
34
- addDefineTypes: (0, import_plugin.createAsyncWaterfall)(),
35
- collectServerPlugins: (0, import_plugin.createAsyncWaterfall)(),
36
- beforeDev: (0, import_plugin.createAsyncWorkflow)(),
37
- afterDev: (0, import_plugin.createAsyncWorkflow)(),
38
- beforeCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
39
- afterCreateCompiler: (0, import_plugin.createAsyncWorkflow)(),
40
- beforePrintInstructions: (0, import_plugin.createAsyncWaterfall)(),
41
- beforeBuild: (0, import_plugin.createAsyncWorkflow)(),
42
- afterBuild: (0, import_plugin.createAsyncWorkflow)(),
43
- beforeDeploy: (0, import_plugin.createAsyncWorkflow)(),
44
- afterDeploy: (0, import_plugin.createAsyncWorkflow)(),
45
- beforeRestart: (0, import_plugin.createAsyncWorkflow)(),
46
- registerDev: (0, import_plugin.createParallelWorkflow)(),
47
- beforeDevTask: (0, import_plugin.createParallelWorkflow)(),
48
- registerBuildPlatform: (0, import_plugin.createParallelWorkflow)(),
49
- beforeBuildPlatform: (0, import_plugin.createParallelWorkflow)()
50
- };
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- hooks
54
- });
@@ -1,245 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
- var __export = (target, all) => {
25
- for (var name in all)
26
- __defProp(target, name, { get: all[name], enumerable: true });
27
- };
28
- var __copyProps = (to, from, except, desc) => {
29
- if (from && typeof from === "object" || typeof from === "function") {
30
- for (let key of __getOwnPropNames(from))
31
- if (!__hasOwnProp.call(to, key) && key !== except)
32
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
- }
34
- return to;
35
- };
36
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
37
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
39
- mod
40
- ));
41
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
42
- var __async = (__this, __arguments, generator) => {
43
- return new Promise((resolve, reject) => {
44
- var fulfilled = (value) => {
45
- try {
46
- step(generator.next(value));
47
- } catch (e) {
48
- reject(e);
49
- }
50
- };
51
- var rejected = (value) => {
52
- try {
53
- step(generator.throw(value));
54
- } catch (e) {
55
- reject(e);
56
- }
57
- };
58
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
59
- step((generator = generator.apply(__this, __arguments)).next());
60
- });
61
- };
62
- var src_exports = {};
63
- __export(src_exports, {
64
- buildCommand: () => buildCommand,
65
- default: () => src_default,
66
- devCommand: () => devCommand
67
- });
68
- module.exports = __toCommonJS(src_exports);
69
- var import_path = __toESM(require("path"));
70
- var import_plugin_lint = __toESM(require("@modern-js/plugin-lint"));
71
- var import_utils = require("@modern-js/utils");
72
- var import_lodash = require("@modern-js/utils/lodash");
73
- var import_analyze = __toESM(require("./analyze"));
74
- var import_initialize = __toESM(require("./initialize"));
75
- var import_hooks = require("./hooks");
76
- var import_locale = require("./locale");
77
- var import_language = require("./utils/language");
78
- var import_restart = require("./utils/restart");
79
- var import_generateWatchFiles = require("./utils/generateWatchFiles");
80
- __reExport(src_exports, require("./defineConfig"), module.exports);
81
- __reExport(src_exports, require("./types"), module.exports);
82
- const upgradeModel = import_utils.Import.lazy(
83
- "@modern-js/upgrade",
84
- require
85
- );
86
- const devCommand = (program, api) => __async(void 0, null, function* () {
87
- const runner = api.useHookRunners();
88
- const devToolMetas = yield runner.registerDev();
89
- const devProgram = program.command("dev").alias("start").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.dev.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("-e --entry [entry...]", import_locale.i18n.t(import_locale.localeKeys.command.dev.entry)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).action((options) => __async(void 0, null, function* () {
90
- const { dev } = yield Promise.resolve().then(() => __toESM(require("./commands/dev")));
91
- yield dev(api, options);
92
- }));
93
- for (const meta of devToolMetas) {
94
- if (!meta.subCommands) {
95
- continue;
96
- }
97
- for (const subCmd of meta.subCommands) {
98
- devProgram.command(subCmd).action((..._0) => __async(void 0, [..._0], function* (options = {}) {
99
- const { appDirectory } = api.useAppContext();
100
- const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
101
- yield runner.beforeDevTask(meta);
102
- yield meta.action(options, {
103
- isTsProject: isTypescript(appDirectory)
104
- });
105
- }));
106
- }
107
- }
108
- });
109
- const buildCommand = (program, api) => __async(void 0, null, function* () {
110
- const runner = api.useHookRunners();
111
- const platformBuilders = yield runner.registerBuildPlatform();
112
- const buildProgram = program.command("build").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.build.describe)).option("-c --config <config>", import_locale.i18n.t(import_locale.localeKeys.command.shared.config)).option("--analyze", import_locale.i18n.t(import_locale.localeKeys.command.shared.analyze)).action((options) => __async(void 0, null, function* () {
113
- const { build } = yield Promise.resolve().then(() => __toESM(require("./commands/build")));
114
- yield build(api, options);
115
- }));
116
- for (const platformBuilder of platformBuilders) {
117
- const platforms = (0, import_lodash.castArray)(platformBuilder.platform);
118
- for (const platform of platforms) {
119
- buildProgram.command(platform).action(() => __async(void 0, null, function* () {
120
- const { appDirectory } = api.useAppContext();
121
- const { isTypescript } = yield Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
122
- yield runner.beforeBuildPlatform(platformBuilders);
123
- yield platformBuilder.build(platform, {
124
- isTsProject: isTypescript(appDirectory)
125
- });
126
- }));
127
- }
128
- }
129
- });
130
- var src_default = (options = {
131
- bundler: "webpack"
132
- }) => ({
133
- name: "@modern-js/app-tools",
134
- post: [
135
- "@modern-js/plugin-initialize",
136
- "@modern-js/plugin-analyze",
137
- "@modern-js/plugin-ssr",
138
- "@modern-js/plugin-document",
139
- "@modern-js/plugin-state",
140
- "@modern-js/plugin-router",
141
- "@modern-js/plugin-router-v5",
142
- "@modern-js/plugin-polyfill"
143
- ],
144
- registerHook: import_hooks.hooks,
145
- usePlugins: [
146
- (0, import_initialize.default)({
147
- bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
148
- }),
149
- (0, import_analyze.default)({
150
- bundler: (options == null ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
151
- }),
152
- (0, import_plugin_lint.default)()
153
- ],
154
- setup: (api) => {
155
- const locale = (0, import_language.getLocaleLanguage)();
156
- import_locale.i18n.changeLanguage({ locale });
157
- return {
158
- commands(_0) {
159
- return __async(this, arguments, function* ({ program }) {
160
- yield devCommand(program, api);
161
- yield buildCommand(program, api);
162
- program.command("serve").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.serve.describe)).option("--api-only", import_locale.i18n.t(import_locale.localeKeys.command.dev.apiOnly)).option(
163
- "-c --config <config>",
164
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
165
- ).action(() => __async(this, null, function* () {
166
- const { start } = yield Promise.resolve().then(() => __toESM(require("./commands/serve")));
167
- yield start(api);
168
- }));
169
- program.command("deploy").usage("[options]").option(
170
- "-c --config <config>",
171
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
172
- ).description(import_locale.i18n.t(import_locale.localeKeys.command.deploy.describe)).action((options2) => __async(this, null, function* () {
173
- const { build } = yield Promise.resolve().then(() => __toESM(require("./commands/build")));
174
- yield build(api);
175
- const { deploy } = yield Promise.resolve().then(() => __toESM(require("./commands/deploy")));
176
- yield deploy(api, options2);
177
- process.exit(0);
178
- }));
179
- program.command("new").usage("[options]").description(import_locale.i18n.t(import_locale.localeKeys.command.new.describe)).option("--lang <lang>", import_locale.i18n.t(import_locale.localeKeys.command.new.lang)).option("-d, --debug", import_locale.i18n.t(import_locale.localeKeys.command.new.debug), false).option(
180
- "-c, --config <config>",
181
- import_locale.i18n.t(import_locale.localeKeys.command.new.config)
182
- ).option("--dist-tag <tag>", import_locale.i18n.t(import_locale.localeKeys.command.new.distTag)).option("--registry", import_locale.i18n.t(import_locale.localeKeys.command.new.registry)).action((options2) => __async(this, null, function* () {
183
- const { MWANewAction } = yield Promise.resolve().then(() => __toESM(require("@modern-js/new-action")));
184
- yield MWANewAction(__spreadProps(__spreadValues({}, options2), { locale: options2.lang || locale }));
185
- }));
186
- program.command("inspect").description("inspect internal webpack config").option(
187
- `--env <env>`,
188
- import_locale.i18n.t(import_locale.localeKeys.command.inspect.env),
189
- "development"
190
- ).option(
191
- "--output <output>",
192
- import_locale.i18n.t(import_locale.localeKeys.command.inspect.output),
193
- "/"
194
- ).option("--verbose", import_locale.i18n.t(import_locale.localeKeys.command.inspect.verbose)).option(
195
- "-c --config <config>",
196
- import_locale.i18n.t(import_locale.localeKeys.command.shared.config)
197
- ).action((options2) => __async(this, null, function* () {
198
- const { inspect } = yield Promise.resolve().then(() => __toESM(require("./commands/inspect")));
199
- inspect(api, options2);
200
- }));
201
- upgradeModel.defineCommand(program.command("upgrade"));
202
- });
203
- },
204
- prepare() {
205
- return __async(this, null, function* () {
206
- const command = (0, import_utils.getCommand)();
207
- if (command === "dev" || command === "start" || command === "build") {
208
- const appContext = api.useAppContext();
209
- yield (0, import_utils.emptyDir)(appContext.distDirectory);
210
- }
211
- });
212
- },
213
- watchFiles() {
214
- return __async(this, null, function* () {
215
- const appContext = api.useAppContext();
216
- const config = api.useResolvedConfigContext();
217
- return (0, import_generateWatchFiles.generateWatchFiles)(appContext, config.source.configDir);
218
- });
219
- },
220
- fileChange(e) {
221
- return __async(this, null, function* () {
222
- const { filename, eventType } = e;
223
- const appContext = api.useAppContext();
224
- const { appDirectory, srcDirectory } = appContext;
225
- const absolutePath = import_path.default.resolve(appDirectory, filename);
226
- if (!absolutePath.includes(srcDirectory) && (eventType === "change" || eventType === "unlink")) {
227
- const { closeServer } = yield Promise.resolve().then(() => __toESM(require("./utils/createServer")));
228
- yield closeServer();
229
- yield (0, import_restart.restart)(api.useHookRunners(), filename);
230
- }
231
- });
232
- },
233
- beforeRestart() {
234
- return __async(this, null, function* () {
235
- (0, import_utils.cleanRequireCache)([require.resolve("./analyze")]);
236
- });
237
- }
238
- };
239
- }
240
- });
241
- // Annotate the CommonJS export names for ESM import in node:
242
- 0 && (module.exports = {
243
- buildCommand,
244
- devCommand
245
- });
@@ -1,141 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __export = (target, all) => {
23
- for (var name in all)
24
- __defProp(target, name, { get: all[name], enumerable: true });
25
- };
26
- var __copyProps = (to, from, except, desc) => {
27
- if (from && typeof from === "object" || typeof from === "function") {
28
- for (let key of __getOwnPropNames(from))
29
- if (!__hasOwnProp.call(to, key) && key !== except)
30
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
- }
32
- return to;
33
- };
34
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var __async = (__this, __arguments, generator) => {
36
- return new Promise((resolve, reject) => {
37
- var fulfilled = (value) => {
38
- try {
39
- step(generator.next(value));
40
- } catch (e) {
41
- reject(e);
42
- }
43
- };
44
- var rejected = (value) => {
45
- try {
46
- step(generator.throw(value));
47
- } catch (e) {
48
- reject(e);
49
- }
50
- };
51
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
52
- step((generator = generator.apply(__this, __arguments)).next());
53
- });
54
- };
55
- var initialize_exports = {};
56
- __export(initialize_exports, {
57
- default: () => initialize_default
58
- });
59
- module.exports = __toCommonJS(initialize_exports);
60
- var import_utils = require("@modern-js/utils");
61
- var import_schema = require("../schema");
62
- var import_config = require("../config");
63
- var initialize_default = ({
64
- bundler
65
- }) => ({
66
- name: "@modern-js/plugin-initialize",
67
- setup(api) {
68
- const config = () => {
69
- const appContext = api.useAppContext();
70
- const userConfig = api.useConfigContext();
71
- return (0, import_config.checkIsLegacyConfig)(userConfig) ? (0, import_config.createLegacyDefaultConfig)(appContext) : (0, import_config.createDefaultConfig)(appContext, bundler);
72
- };
73
- const validateSchema = () => {
74
- const userConfig = api.useConfigContext();
75
- const schemas = (0, import_config.checkIsLegacyConfig)(userConfig) ? import_schema.legacySchema : import_schema.schema;
76
- return schemas.generate();
77
- };
78
- return {
79
- config,
80
- validateSchema,
81
- resolvedConfig(_0) {
82
- return __async(this, arguments, function* ({ resolved }) {
83
- var _a2;
84
- let appContext = api.useAppContext();
85
- const userConfig = api.useConfigContext();
86
- const port = yield getServerPort(resolved);
87
- appContext = __spreadProps(__spreadValues({}, appContext), {
88
- port,
89
- distDirectory: (0, import_utils.ensureAbsolutePath)(
90
- appContext.distDirectory,
91
- ((_a2 = resolved.output.distPath) == null ? void 0 : _a2.root) || "dist"
92
- )
93
- });
94
- api.setAppContext(appContext);
95
- const normalizedConfig = (0, import_config.checkIsLegacyConfig)(resolved) ? (0, import_config.transformNormalizedConfig)(resolved) : resolved;
96
- resolved._raw = userConfig;
97
- resolved.server = __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
98
- port
99
- });
100
- resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
101
- stabilizeConfig(resolved, normalizedConfig, [
102
- "source",
103
- "bff",
104
- "dev",
105
- "html",
106
- "output",
107
- "tools",
108
- "testing",
109
- "plugins",
110
- "builderPlugins",
111
- "runtime",
112
- "runtimeByEntries",
113
- "deploy",
114
- "performance"
115
- ]);
116
- if (bundler === "webpack") {
117
- resolved.security = normalizedConfig.security || {};
118
- resolved.experiments = normalizedConfig.experiments;
119
- }
120
- return { resolved };
121
- });
122
- }
123
- };
124
- }
125
- });
126
- function stabilizeConfig(resolve, config, keys) {
127
- keys.forEach((key) => {
128
- resolve[key] = config[key] || {};
129
- });
130
- }
131
- function getServerPort(config) {
132
- return __async(this, null, function* () {
133
- const prodPort = config.server.port || 8080;
134
- if ((0, import_utils.isDev)() && (0, import_utils.isDevCommand)()) {
135
- return (0, import_utils.getPort)(config.dev.port || prodPort);
136
- }
137
- return prodPort;
138
- });
139
- }
140
- // Annotate the CommonJS export names for ESM import in node:
141
- 0 && (module.exports = {});
@@ -1,59 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var en_exports = {};
19
- __export(en_exports, {
20
- EN_LOCALE: () => EN_LOCALE
21
- });
22
- module.exports = __toCommonJS(en_exports);
23
- const EN_LOCALE = {
24
- command: {
25
- shared: {
26
- analyze: "analyze bundle size",
27
- config: "specify config file"
28
- },
29
- dev: {
30
- describe: "start dev server",
31
- entry: "compiler by entry",
32
- apiOnly: "start api server only",
33
- selectEntry: "Please select the entry that needs to be built",
34
- requireEntry: "You must choose at least one entry"
35
- },
36
- build: {
37
- describe: "build application"
38
- },
39
- serve: { describe: "start server" },
40
- deploy: { describe: "deploy application" },
41
- new: {
42
- describe: "generator runner for MWA project",
43
- debug: "using debug mode to log something",
44
- config: "set default generator config(json string)",
45
- distTag: `use specified tag version for it's generator`,
46
- registry: "set npm registry url to run npm command",
47
- lang: "set new command language(en or zh)"
48
- },
49
- inspect: {
50
- env: "specify env mode",
51
- output: "specify inspect content output path",
52
- verbose: "show full function definitions in output"
53
- }
54
- }
55
- };
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- EN_LOCALE
59
- });
@@ -1,33 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var locale_exports = {};
19
- __export(locale_exports, {
20
- i18n: () => i18n,
21
- localeKeys: () => localeKeys
22
- });
23
- module.exports = __toCommonJS(locale_exports);
24
- var import_plugin_i18n = require("@modern-js/plugin-i18n");
25
- var import_zh = require("./zh");
26
- var import_en = require("./en");
27
- const i18n = new import_plugin_i18n.I18n();
28
- const localeKeys = i18n.init("zh", { zh: import_zh.ZH_LOCALE, en: import_en.EN_LOCALE });
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- i18n,
32
- localeKeys
33
- });
@@ -1,59 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var zh_exports = {};
19
- __export(zh_exports, {
20
- ZH_LOCALE: () => ZH_LOCALE
21
- });
22
- module.exports = __toCommonJS(zh_exports);
23
- const ZH_LOCALE = {
24
- command: {
25
- shared: {
26
- analyze: "分析构建产物体积,查看各个模块打包后的大小",
27
- config: "指定配置文件路径,可以为相对路径或绝对路径"
28
- },
29
- dev: {
30
- describe: "本地开发命令",
31
- entry: "指定入口,编译特定的页面",
32
- apiOnly: "仅启动 API 接口服务",
33
- selectEntry: "请选择需要构建的入口",
34
- requireEntry: "请至少选择一个入口"
35
- },
36
- build: {
37
- describe: "构建应用命令"
38
- },
39
- serve: { describe: "应用启动命令" },
40
- deploy: { describe: "部署应用命令" },
41
- new: {
42
- describe: "Web App 项目中执行生成器",
43
- debug: "开启 Debug 模式,打印调试日志信息",
44
- config: "生成器运行默认配置(JSON 字符串)",
45
- distTag: "生成器使用特殊的 npm Tag 版本",
46
- registry: "生成器运行过程中定制 npm Registry",
47
- lang: "设置 new 命令执行语言(zh 或者 en)"
48
- },
49
- inspect: {
50
- env: "查看指定环境下的配置",
51
- output: "指定在 dist 目录下输出的路径",
52
- verbose: "在结果中展示函数的完整内容"
53
- }
54
- }
55
- };
56
- // Annotate the CommonJS export names for ESM import in node:
57
- 0 && (module.exports = {
58
- ZH_LOCALE
59
- });
@@ -1,63 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var Schema_exports = {};
19
- __export(Schema_exports, {
20
- Schema: () => Schema
21
- });
22
- module.exports = __toCommonJS(Schema_exports);
23
- var import_lodash = require("@modern-js/utils/lodash");
24
- class Schema extends Map {
25
- constructor(baseSchema = {}) {
26
- super();
27
- this.schema = baseSchema;
28
- }
29
- setSchema(key, object) {
30
- Object.entries(object).forEach(([k, v]) => {
31
- const target = `${key}.${k}`;
32
- this.set(target, v);
33
- });
34
- return this;
35
- }
36
- set(key, value) {
37
- if (this.has(key)) {
38
- (0, import_lodash.merge)(this.schema[key], value);
39
- } else {
40
- this.schema[key] = value;
41
- }
42
- return this;
43
- }
44
- has(key) {
45
- return key in this.schema;
46
- }
47
- get(key) {
48
- return this.schema[key];
49
- }
50
- delete(key) {
51
- return delete this.schema[key];
52
- }
53
- generate() {
54
- return Object.entries(this.schema).map(([target, schema]) => ({
55
- target,
56
- schema
57
- }));
58
- }
59
- }
60
- // Annotate the CommonJS export names for ESM import in node:
61
- 0 && (module.exports = {
62
- Schema
63
- });