@modern-js/app-tools 2.15.0 → 2.16.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.
- package/CHANGELOG.md +45 -0
- package/dist/cjs/analyze/constants.js +37 -61
- package/dist/cjs/analyze/generateCode.js +102 -127
- package/dist/cjs/analyze/getBundleEntry.js +33 -66
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +61 -117
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +61 -115
- package/dist/cjs/analyze/getClientRoutes/index.js +15 -28
- package/dist/cjs/analyze/getClientRoutes/utils.js +24 -48
- package/dist/cjs/analyze/getFileSystemEntry.js +39 -79
- package/dist/cjs/analyze/getHtmlTemplate.js +88 -98
- package/dist/cjs/analyze/getServerRoutes.js +67 -110
- package/dist/cjs/analyze/index.js +265 -257
- package/dist/cjs/analyze/isDefaultExportFunction.js +66 -44
- package/dist/cjs/analyze/makeLegalIdentifier.js +7 -25
- package/dist/cjs/analyze/nestedRoutes.js +99 -104
- package/dist/cjs/analyze/templates.js +49 -110
- package/dist/cjs/analyze/utils.js +98 -102
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +58 -100
- package/dist/cjs/builder/builder-rspack/index.js +14 -30
- package/dist/cjs/builder/builder-webpack/adapterModern.js +33 -50
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +16 -32
- package/dist/cjs/builder/builder-webpack/index.js +65 -46
- package/dist/cjs/builder/generator/createBuilderOptions.js +10 -26
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +11 -27
- package/dist/cjs/builder/generator/getBuilderTargets.js +13 -29
- package/dist/cjs/builder/generator/index.js +61 -55
- package/dist/cjs/builder/index.js +53 -43
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +13 -36
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +90 -90
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +108 -111
- package/dist/cjs/builder/shared/builderPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +30 -30
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +32 -38
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +86 -116
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +20 -19
- package/dist/cjs/builder/shared/createCopyInfo.js +16 -42
- package/dist/cjs/builder/shared/index.js +20 -19
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +8 -24
- package/dist/cjs/builder/shared/types.js +4 -15
- package/dist/cjs/commands/build.js +23 -40
- package/dist/cjs/commands/deploy.js +7 -25
- package/dist/cjs/commands/dev.js +38 -57
- package/dist/cjs/commands/index.js +20 -19
- package/dist/cjs/commands/inspect.js +10 -30
- package/dist/cjs/commands/serve.js +28 -66
- package/dist/cjs/config/default.js +34 -34
- package/dist/cjs/config/index.js +20 -19
- package/dist/cjs/config/initialize/index.js +11 -29
- package/dist/cjs/config/initialize/inits.js +103 -82
- package/dist/cjs/config/legacy/createHtmlConfig.js +8 -40
- package/dist/cjs/config/legacy/createOutputConfig.js +8 -51
- package/dist/cjs/config/legacy/createSourceConfig.js +8 -38
- package/dist/cjs/config/legacy/createToolsConfig.js +8 -43
- package/dist/cjs/config/legacy/index.js +22 -46
- package/dist/cjs/defineConfig.js +16 -31
- package/dist/cjs/exports/server.js +7 -25
- package/dist/cjs/hooks.js +33 -51
- package/dist/cjs/index.js +185 -166
- package/dist/cjs/initialize/index.js +84 -100
- package/dist/cjs/locale/en.js +13 -27
- package/dist/cjs/locale/index.js +18 -28
- package/dist/cjs/locale/zh.js +13 -27
- package/dist/cjs/schema/Schema.js +27 -31
- package/dist/cjs/schema/index.js +141 -71
- package/dist/cjs/schema/legacy.js +273 -96
- package/dist/cjs/types/config/deploy.js +4 -15
- package/dist/cjs/types/config/dev.js +4 -15
- package/dist/cjs/types/config/experiments.js +4 -15
- package/dist/cjs/types/config/html.js +4 -15
- package/dist/cjs/types/config/index.js +18 -17
- package/dist/cjs/types/config/output.js +4 -15
- package/dist/cjs/types/config/performance.js +4 -15
- package/dist/cjs/types/config/security.js +4 -15
- package/dist/cjs/types/config/source.js +4 -15
- package/dist/cjs/types/config/tools.js +4 -15
- package/dist/cjs/types/hooks.js +4 -15
- package/dist/cjs/types/index.js +20 -19
- package/dist/cjs/types/legacyConfig/deploy.js +4 -15
- package/dist/cjs/types/legacyConfig/dev.js +4 -15
- package/dist/cjs/types/legacyConfig/index.js +4 -15
- package/dist/cjs/types/legacyConfig/output.js +4 -15
- package/dist/cjs/types/legacyConfig/source.js +4 -15
- package/dist/cjs/types/legacyConfig/tools.js +4 -15
- package/dist/cjs/types/utils.js +4 -15
- package/dist/cjs/utils/config.js +74 -79
- package/dist/cjs/utils/createServer.js +16 -42
- package/dist/cjs/utils/env.js +7 -25
- package/dist/cjs/utils/generateWatchFiles.js +31 -52
- package/dist/cjs/utils/getSelectedEntries.js +13 -35
- package/dist/cjs/utils/getServerInternalPlugins.js +8 -29
- package/dist/cjs/utils/printInstructions.js +10 -28
- package/dist/cjs/utils/restart.js +13 -31
- package/dist/cjs/utils/routes.js +18 -39
- package/dist/cjs/utils/types.js +4 -15
- package/dist/esm/analyze/constants.js +40 -41
- package/dist/esm/analyze/generateCode.js +477 -455
- package/dist/esm/analyze/getBundleEntry.js +53 -54
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +201 -202
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +199 -200
- package/dist/esm/analyze/getClientRoutes/index.js +2 -3
- package/dist/esm/analyze/getClientRoutes/utils.js +15 -15
- package/dist/esm/analyze/getFileSystemEntry.js +86 -87
- package/dist/esm/analyze/getHtmlTemplate.js +289 -278
- package/dist/esm/analyze/getServerRoutes.js +203 -190
- package/dist/esm/analyze/index.js +679 -651
- package/dist/esm/analyze/isDefaultExportFunction.js +38 -39
- package/dist/esm/analyze/makeLegalIdentifier.js +8 -9
- package/dist/esm/analyze/nestedRoutes.js +400 -392
- package/dist/esm/analyze/templates.js +536 -509
- package/dist/esm/analyze/utils.js +357 -336
- package/dist/esm/builder/builder-rspack/adapterCopy.js +347 -330
- package/dist/esm/builder/builder-rspack/index.js +8 -9
- package/dist/esm/builder/builder-webpack/adapterModern.js +51 -43
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +31 -32
- package/dist/esm/builder/builder-webpack/index.js +266 -249
- package/dist/esm/builder/generator/createBuilderOptions.js +37 -38
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +62 -63
- package/dist/esm/builder/generator/getBuilderTargets.js +13 -14
- package/dist/esm/builder/generator/index.js +203 -196
- package/dist/esm/builder/index.js +183 -176
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +90 -91
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +300 -291
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +337 -329
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +108 -97
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +66 -64
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +364 -337
- package/dist/esm/builder/shared/createCopyInfo.js +9 -10
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +2 -3
- package/dist/esm/builder/shared/types.js +1 -1
- package/dist/esm/commands/build.js +279 -272
- package/dist/esm/commands/deploy.js +150 -144
- package/dist/esm/commands/dev.js +296 -289
- package/dist/esm/commands/inspect.js +144 -138
- package/dist/esm/commands/serve.js +241 -235
- package/dist/esm/config/default.js +202 -203
- package/dist/esm/config/initialize/index.js +7 -8
- package/dist/esm/config/initialize/inits.js +189 -181
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -18
- package/dist/esm/config/legacy/createOutputConfig.js +41 -42
- package/dist/esm/config/legacy/createSourceConfig.js +38 -39
- package/dist/esm/config/legacy/createToolsConfig.js +24 -25
- package/dist/esm/config/legacy/index.js +31 -32
- package/dist/esm/defineConfig.js +52 -53
- package/dist/esm/exports/server.js +1 -2
- package/dist/esm/hooks.js +26 -27
- package/dist/esm/index.js +685 -671
- package/dist/esm/initialize/index.js +276 -269
- package/dist/esm/locale/en.js +36 -37
- package/dist/esm/locale/index.js +2 -2
- package/dist/esm/locale/zh.js +36 -37
- package/dist/esm/schema/Schema.js +255 -244
- package/dist/esm/schema/index.js +165 -165
- package/dist/esm/schema/legacy.js +316 -317
- package/dist/esm/types/config/deploy.js +1 -1
- package/dist/esm/types/config/dev.js +1 -1
- package/dist/esm/types/config/experiments.js +1 -1
- package/dist/esm/types/config/html.js +1 -1
- package/dist/esm/types/config/output.js +1 -1
- package/dist/esm/types/config/performance.js +1 -1
- package/dist/esm/types/config/security.js +1 -1
- package/dist/esm/types/config/source.js +1 -1
- package/dist/esm/types/config/tools.js +1 -1
- package/dist/esm/types/hooks.js +1 -1
- package/dist/esm/types/legacyConfig/deploy.js +1 -1
- package/dist/esm/types/legacyConfig/dev.js +1 -1
- package/dist/esm/types/legacyConfig/index.js +1 -1
- package/dist/esm/types/legacyConfig/output.js +1 -1
- package/dist/esm/types/legacyConfig/source.js +1 -1
- package/dist/esm/types/legacyConfig/tools.js +1 -1
- package/dist/esm/types/utils.js +1 -1
- package/dist/esm/utils/config.js +285 -278
- package/dist/esm/utils/createServer.js +242 -234
- package/dist/esm/utils/env.js +11 -12
- package/dist/esm/utils/generateWatchFiles.js +205 -190
- package/dist/esm/utils/getSelectedEntries.js +180 -173
- package/dist/esm/utils/getServerInternalPlugins.js +197 -191
- package/dist/esm/utils/printInstructions.js +147 -141
- package/dist/esm/utils/restart.js +179 -173
- package/dist/esm/utils/routes.js +146 -139
- package/dist/esm/utils/types.js +1 -1
- package/dist/esm-node/analyze/constants.js +31 -46
- package/dist/esm-node/analyze/generateCode.js +28 -94
- package/dist/esm-node/analyze/getBundleEntry.js +8 -27
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +24 -65
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +24 -63
- package/dist/esm-node/analyze/getClientRoutes/index.js +2 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +5 -19
- package/dist/esm-node/analyze/getFileSystemEntry.js +10 -37
- package/dist/esm-node/analyze/getHtmlTemplate.js +29 -59
- package/dist/esm-node/analyze/getServerRoutes.js +43 -75
- package/dist/esm-node/analyze/index.js +208 -230
- package/dist/esm-node/analyze/isDefaultExportFunction.js +7 -5
- package/dist/esm-node/analyze/makeLegalIdentifier.js +1 -4
- package/dist/esm-node/analyze/nestedRoutes.js +23 -43
- package/dist/esm-node/analyze/templates.js +22 -69
- package/dist/esm-node/analyze/utils.js +66 -60
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +40 -62
- package/dist/esm-node/builder/builder-rspack/index.js +4 -5
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +24 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +3 -10
- package/dist/esm-node/builder/builder-webpack/index.js +13 -11
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -5
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +5 -6
- package/dist/esm-node/builder/generator/getBuilderTargets.js +5 -11
- package/dist/esm-node/builder/generator/index.js +7 -16
- package/dist/esm-node/builder/index.js +2 -7
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +2 -6
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +34 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +54 -74
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +23 -8
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +25 -16
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +66 -76
- package/dist/esm-node/builder/shared/createCopyInfo.js +2 -8
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +1 -4
- package/dist/esm-node/builder/shared/types.js +1 -0
- package/dist/esm-node/commands/build.js +7 -9
- package/dist/esm-node/commands/deploy.js +1 -4
- package/dist/esm-node/commands/dev.js +19 -27
- package/dist/esm-node/commands/inspect.js +3 -8
- package/dist/esm-node/commands/serve.js +7 -25
- package/dist/esm-node/config/default.js +20 -11
- package/dist/esm-node/config/initialize/index.js +1 -4
- package/dist/esm-node/config/initialize/inits.js +48 -54
- package/dist/esm-node/config/legacy/createHtmlConfig.js +2 -19
- package/dist/esm-node/config/legacy/createOutputConfig.js +2 -30
- package/dist/esm-node/config/legacy/createSourceConfig.js +2 -17
- package/dist/esm-node/config/legacy/createToolsConfig.js +2 -22
- package/dist/esm-node/config/legacy/index.js +3 -18
- package/dist/esm-node/defineConfig.js +7 -13
- package/dist/esm-node/exports/server.js +1 -4
- package/dist/esm-node/hooks.js +2 -9
- package/dist/esm-node/index.js +95 -120
- package/dist/esm-node/initialize/index.js +74 -87
- package/dist/esm-node/locale/en.js +7 -6
- package/dist/esm-node/locale/index.js +5 -5
- package/dist/esm-node/locale/zh.js +7 -6
- package/dist/esm-node/schema/Schema.js +19 -8
- package/dist/esm-node/schema/index.js +121 -36
- package/dist/esm-node/schema/legacy.js +262 -72
- package/dist/esm-node/types/config/deploy.js +1 -0
- package/dist/esm-node/types/config/dev.js +1 -0
- package/dist/esm-node/types/config/experiments.js +1 -0
- package/dist/esm-node/types/config/html.js +1 -0
- package/dist/esm-node/types/config/output.js +1 -0
- package/dist/esm-node/types/config/performance.js +1 -0
- package/dist/esm-node/types/config/security.js +1 -0
- package/dist/esm-node/types/config/source.js +1 -0
- package/dist/esm-node/types/config/tools.js +1 -0
- package/dist/esm-node/types/hooks.js +1 -0
- package/dist/esm-node/types/legacyConfig/deploy.js +1 -0
- package/dist/esm-node/types/legacyConfig/dev.js +1 -0
- package/dist/esm-node/types/legacyConfig/index.js +1 -0
- package/dist/esm-node/types/legacyConfig/output.js +1 -0
- package/dist/esm-node/types/legacyConfig/source.js +1 -0
- package/dist/esm-node/types/legacyConfig/tools.js +1 -0
- package/dist/esm-node/types/utils.js +1 -0
- package/dist/esm-node/utils/config.js +16 -47
- package/dist/esm-node/utils/createServer.js +5 -12
- package/dist/esm-node/utils/env.js +1 -4
- package/dist/esm-node/utils/generateWatchFiles.js +13 -20
- package/dist/esm-node/utils/getSelectedEntries.js +2 -9
- package/dist/esm-node/utils/getServerInternalPlugins.js +2 -8
- package/dist/esm-node/utils/printInstructions.js +1 -4
- package/dist/esm-node/utils/restart.js +2 -11
- package/dist/esm-node/utils/routes.js +4 -4
- package/dist/esm-node/utils/types.js +1 -0
- package/dist/types/index.d.ts +2 -2
- package/package.json +29 -25
package/dist/esm/locale/zh.js
CHANGED
|
@@ -1,39 +1,38 @@
|
|
|
1
|
-
var ZH_LOCALE = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
export var ZH_LOCALE = {
|
|
2
|
+
command: {
|
|
3
|
+
shared: {
|
|
4
|
+
analyze: "分析构建产物体积,查看各个模块打包后的大小",
|
|
5
|
+
config: "指定配置文件路径,可以为相对路径或绝对路径"
|
|
6
|
+
},
|
|
7
|
+
dev: {
|
|
8
|
+
describe: "启动开发服务器",
|
|
9
|
+
entry: "指定入口,编译特定的页面",
|
|
10
|
+
apiOnly: "仅启动 API 接口服务",
|
|
11
|
+
webOnly: "仅启动 Web 服务",
|
|
12
|
+
selectEntry: "请选择需要构建的入口",
|
|
13
|
+
requireEntry: "请至少选择一个入口"
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
describe: "构建生产环境产物"
|
|
17
|
+
},
|
|
18
|
+
serve: {
|
|
19
|
+
describe: "启动生产环境服务"
|
|
20
|
+
},
|
|
21
|
+
deploy: {
|
|
22
|
+
describe: "部署应用"
|
|
23
|
+
},
|
|
24
|
+
new: {
|
|
25
|
+
describe: "Web App 项目中执行生成器",
|
|
26
|
+
debug: "开启 Debug 模式,打印调试日志信息",
|
|
27
|
+
config: "生成器运行默认配置(JSON 字符串)",
|
|
28
|
+
distTag: "生成器使用特殊的 npm Tag 版本",
|
|
29
|
+
registry: "生成器运行过程中定制 npm Registry",
|
|
30
|
+
lang: "设置 new 命令执行语言(zh 或者 en)"
|
|
31
|
+
},
|
|
32
|
+
inspect: {
|
|
33
|
+
env: "查看指定环境下的配置",
|
|
34
|
+
output: "指定在 dist 目录下输出的路径",
|
|
35
|
+
verbose: "在结果中展示函数的完整内容"
|
|
37
36
|
}
|
|
37
|
+
}
|
|
38
38
|
};
|
|
39
|
-
export { ZH_LOCALE };
|
|
@@ -1,273 +1,284 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_with_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return arr;
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
function _classCallCheck(instance, Constructor) {
|
|
16
|
-
if (!(instance instanceof Constructor)) {
|
|
17
|
-
throw new TypeError("Cannot call a class as a function");
|
|
18
|
-
}
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
|
+
if (self === void 0) {
|
|
14
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
+
}
|
|
16
|
+
return self;
|
|
19
17
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
try {
|
|
25
|
-
Date.prototype.toString.call(Reflect.construct(Date, [], function() {}));
|
|
26
|
-
return true;
|
|
27
|
-
} catch (e) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
18
|
+
function _class_call_check(instance, Constructor) {
|
|
19
|
+
if (!(instance instanceof Constructor)) {
|
|
20
|
+
throw new TypeError("Cannot call a class as a function");
|
|
21
|
+
}
|
|
30
22
|
}
|
|
31
23
|
function _construct(Parent, args, Class) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
24
|
+
if (_is_native_reflect_construct()) {
|
|
25
|
+
_construct = Reflect.construct;
|
|
26
|
+
} else {
|
|
27
|
+
_construct = function construct(Parent2, args2, Class2) {
|
|
28
|
+
var a = [
|
|
29
|
+
null
|
|
30
|
+
];
|
|
31
|
+
a.push.apply(a, args2);
|
|
32
|
+
var Constructor = Function.bind.apply(Parent2, a);
|
|
33
|
+
var instance = new Constructor();
|
|
34
|
+
if (Class2)
|
|
35
|
+
_set_prototype_of(instance, Class2.prototype);
|
|
36
|
+
return instance;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return _construct.apply(null, arguments);
|
|
47
40
|
}
|
|
48
41
|
function _defineProperties(target, props) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
for (var i = 0; i < props.length; i++) {
|
|
43
|
+
var descriptor = props[i];
|
|
44
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
45
|
+
descriptor.configurable = true;
|
|
46
|
+
if ("value" in descriptor)
|
|
47
|
+
descriptor.writable = true;
|
|
48
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
49
|
+
}
|
|
56
50
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
52
|
+
if (protoProps)
|
|
53
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps)
|
|
55
|
+
_defineProperties(Constructor, staticProps);
|
|
56
|
+
return Constructor;
|
|
61
57
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
function _define_property(obj, key, value) {
|
|
59
|
+
if (key in obj) {
|
|
60
|
+
Object.defineProperty(obj, key, {
|
|
61
|
+
value,
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
obj[key] = value;
|
|
68
|
+
}
|
|
69
|
+
return obj;
|
|
74
70
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
function _get_prototype_of(o) {
|
|
72
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
73
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
74
|
+
};
|
|
75
|
+
return _get_prototype_of(o);
|
|
80
76
|
}
|
|
81
77
|
function _inherits(subClass, superClass) {
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
79
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
80
|
+
}
|
|
81
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
82
|
+
constructor: {
|
|
83
|
+
value: subClass,
|
|
84
|
+
writable: true,
|
|
85
|
+
configurable: true
|
|
84
86
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
writable: true,
|
|
89
|
-
configurable: true
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
87
|
+
});
|
|
88
|
+
if (superClass)
|
|
89
|
+
_set_prototype_of(subClass, superClass);
|
|
93
90
|
}
|
|
94
|
-
function
|
|
95
|
-
|
|
91
|
+
function _is_native_function(fn) {
|
|
92
|
+
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
96
93
|
}
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
94
|
+
function _iterable_to_array_limit(arr, i) {
|
|
95
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
96
|
+
if (_i == null)
|
|
97
|
+
return;
|
|
98
|
+
var _arr = [];
|
|
99
|
+
var _n = true;
|
|
100
|
+
var _d = false;
|
|
101
|
+
var _s, _e;
|
|
102
|
+
try {
|
|
103
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
104
|
+
_arr.push(_s.value);
|
|
105
|
+
if (i && _arr.length === i)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
} catch (err) {
|
|
109
|
+
_d = true;
|
|
110
|
+
_e = err;
|
|
111
|
+
} finally {
|
|
104
112
|
try {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_d = true;
|
|
111
|
-
_e = err;
|
|
112
|
-
} finally{
|
|
113
|
-
try {
|
|
114
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
115
|
-
} finally{
|
|
116
|
-
if (_d) throw _e;
|
|
117
|
-
}
|
|
113
|
+
if (!_n && _i["return"] != null)
|
|
114
|
+
_i["return"]();
|
|
115
|
+
} finally {
|
|
116
|
+
if (_d)
|
|
117
|
+
throw _e;
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
}
|
|
120
|
+
return _arr;
|
|
120
121
|
}
|
|
121
|
-
function
|
|
122
|
-
|
|
122
|
+
function _non_iterable_rest() {
|
|
123
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
function _possible_constructor_return(self, call) {
|
|
126
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
127
|
+
return call;
|
|
128
|
+
}
|
|
129
|
+
return _assert_this_initialized(self);
|
|
129
130
|
}
|
|
130
|
-
function
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
function _set_prototype_of(o, p) {
|
|
132
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
133
|
+
o2.__proto__ = p2;
|
|
134
|
+
return o2;
|
|
135
|
+
};
|
|
136
|
+
return _set_prototype_of(o, p);
|
|
136
137
|
}
|
|
137
|
-
function
|
|
138
|
-
|
|
138
|
+
function _sliced_to_array(arr, i) {
|
|
139
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
139
140
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
};
|
|
144
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
145
|
-
if (!o) return;
|
|
146
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
147
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
148
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
149
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
150
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
141
|
+
function _type_of(obj) {
|
|
142
|
+
"@swc/helpers - typeof";
|
|
143
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
151
144
|
}
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
|
|
165
|
-
}
|
|
166
|
-
Wrapper.prototype = Object.create(Class.prototype, {
|
|
167
|
-
constructor: {
|
|
168
|
-
value: Wrapper,
|
|
169
|
-
enumerable: false,
|
|
170
|
-
writable: true,
|
|
171
|
-
configurable: true
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
return _setPrototypeOf(Wrapper, Class);
|
|
175
|
-
};
|
|
176
|
-
return _wrapNativeSuper(Class);
|
|
145
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
146
|
+
if (!o)
|
|
147
|
+
return;
|
|
148
|
+
if (typeof o === "string")
|
|
149
|
+
return _array_like_to_array(o, minLen);
|
|
150
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
151
|
+
if (n === "Object" && o.constructor)
|
|
152
|
+
n = o.constructor.name;
|
|
153
|
+
if (n === "Map" || n === "Set")
|
|
154
|
+
return Array.from(n);
|
|
155
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
156
|
+
return _array_like_to_array(o, minLen);
|
|
177
157
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
158
|
+
function _wrap_native_super(Class) {
|
|
159
|
+
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
|
|
160
|
+
_wrap_native_super = function wrapNativeSuper(Class2) {
|
|
161
|
+
if (Class2 === null || !_is_native_function(Class2))
|
|
162
|
+
return Class2;
|
|
163
|
+
if (typeof Class2 !== "function") {
|
|
164
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
165
|
+
}
|
|
166
|
+
if (typeof _cache !== "undefined") {
|
|
167
|
+
if (_cache.has(Class2))
|
|
168
|
+
return _cache.get(Class2);
|
|
169
|
+
_cache.set(Class2, Wrapper);
|
|
170
|
+
}
|
|
171
|
+
function Wrapper() {
|
|
172
|
+
return _construct(Class2, arguments, _get_prototype_of(this).constructor);
|
|
187
173
|
}
|
|
174
|
+
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
175
|
+
constructor: {
|
|
176
|
+
value: Wrapper,
|
|
177
|
+
enumerable: false,
|
|
178
|
+
writable: true,
|
|
179
|
+
configurable: true
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
return _set_prototype_of(Wrapper, Class2);
|
|
183
|
+
};
|
|
184
|
+
return _wrap_native_super(Class);
|
|
188
185
|
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
return
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
186
|
+
function _is_native_reflect_construct() {
|
|
187
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
188
|
+
return false;
|
|
189
|
+
if (Reflect.construct.sham)
|
|
190
|
+
return false;
|
|
191
|
+
if (typeof Proxy === "function")
|
|
192
|
+
return true;
|
|
193
|
+
try {
|
|
194
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
195
|
+
}));
|
|
196
|
+
return true;
|
|
197
|
+
} catch (e) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
201
200
|
}
|
|
202
|
-
|
|
203
|
-
var
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
_this = _super.call(this);
|
|
212
|
-
_defineProperty(_assertThisInitialized(_this), "schema", void 0);
|
|
213
|
-
_this.schema = baseSchema;
|
|
214
|
-
return _this;
|
|
201
|
+
function _create_super(Derived) {
|
|
202
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
203
|
+
return function _createSuperInternal() {
|
|
204
|
+
var Super = _get_prototype_of(Derived), result;
|
|
205
|
+
if (hasNativeReflectConstruct) {
|
|
206
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
207
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
208
|
+
} else {
|
|
209
|
+
result = Super.apply(this, arguments);
|
|
215
210
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
key: "delete",
|
|
254
|
-
value: function _delete(key) {
|
|
255
|
-
return delete this.schema[key];
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
key: "generate",
|
|
260
|
-
value: function generate() {
|
|
261
|
-
return Object.entries(this.schema).map(function(param) {
|
|
262
|
-
var _param = _slicedToArray(param, 2), target = _param[0], schema = _param[1];
|
|
263
|
-
return {
|
|
264
|
-
target: target,
|
|
265
|
-
schema: schema
|
|
266
|
-
};
|
|
267
|
-
});
|
|
268
|
-
}
|
|
211
|
+
return _possible_constructor_return(this, result);
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
import { merge } from "@modern-js/utils/lodash";
|
|
215
|
+
export var Schema = /* @__PURE__ */ function(Map1) {
|
|
216
|
+
"use strict";
|
|
217
|
+
_inherits(Schema2, Map1);
|
|
218
|
+
var _super = _create_super(Schema2);
|
|
219
|
+
function Schema2() {
|
|
220
|
+
var baseSchema = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
221
|
+
_class_call_check(this, Schema2);
|
|
222
|
+
var _this;
|
|
223
|
+
_this = _super.call(this);
|
|
224
|
+
_define_property(_assert_this_initialized(_this), "schema", void 0);
|
|
225
|
+
_this.schema = baseSchema;
|
|
226
|
+
return _this;
|
|
227
|
+
}
|
|
228
|
+
_create_class(Schema2, [
|
|
229
|
+
{
|
|
230
|
+
key: "setSchema",
|
|
231
|
+
value: function setSchema(key, object) {
|
|
232
|
+
var _this = this;
|
|
233
|
+
Object.entries(object).forEach(function(param) {
|
|
234
|
+
var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
|
|
235
|
+
var target = "".concat(key, ".").concat(k);
|
|
236
|
+
_this.set(target, v);
|
|
237
|
+
});
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
key: "set",
|
|
243
|
+
value: function set(key, value) {
|
|
244
|
+
if (this.has(key)) {
|
|
245
|
+
merge(this.schema[key], value);
|
|
246
|
+
} else {
|
|
247
|
+
this.schema[key] = value;
|
|
269
248
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
249
|
+
return this;
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
key: "has",
|
|
254
|
+
value: function has(key) {
|
|
255
|
+
return key in this.schema;
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
key: "get",
|
|
260
|
+
value: function get(key) {
|
|
261
|
+
return this.schema[key];
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: "delete",
|
|
266
|
+
value: function _delete(key) {
|
|
267
|
+
return delete this.schema[key];
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
key: "generate",
|
|
272
|
+
value: function generate() {
|
|
273
|
+
return Object.entries(this.schema).map(function(param) {
|
|
274
|
+
var _param = _sliced_to_array(param, 2), target = _param[0], schema = _param[1];
|
|
275
|
+
return {
|
|
276
|
+
target,
|
|
277
|
+
schema
|
|
278
|
+
};
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
]);
|
|
283
|
+
return Schema2;
|
|
284
|
+
}(_wrap_native_super(Map));
|