@rsdoctor/core 2.0.0-alpha.0 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/26.js +26163 -0
- package/dist/630.js +1269 -0
- package/dist/630.js.LICENSE.txt +7 -0
- package/dist/build-utils/build/chunks/assetsModules.d.ts +8 -2
- package/dist/build-utils/build/chunks/index.d.ts +0 -1
- package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/envinfo.d.ts +13 -0
- package/dist/build-utils/build/file/cache.d.ts +5 -0
- package/dist/build-utils/build/file/index.d.ts +3 -0
- package/dist/build-utils/build/file/sharding.d.ts +21 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/json.d.ts +3 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +8 -3
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +0 -1
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/process.d.ts +2 -0
- package/dist/build-utils/build/server.d.ts +15 -0
- package/dist/build-utils/build/utils/loader.d.ts +2 -2
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/index.d.ts +10 -0
- package/dist/common/file.d.ts +2 -0
- package/dist/common/global-config.d.ts +21 -0
- package/dist/error/error.d.ts +35 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/transform.d.ts +3 -0
- package/dist/error/utils.d.ts +4 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +1725 -5
- package/dist/inner-plugins/constants.d.ts +1 -1
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
- package/dist/inner-plugins/plugins/base.d.ts +3 -3
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +3 -3
- package/dist/inner-plugins/plugins/errors.d.ts +2 -2
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/progress.d.ts +2 -2
- package/dist/inner-plugins/plugins/resolver.d.ts +1 -1
- package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
- package/dist/inner-plugins/plugins/rules.d.ts +1 -1
- package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
- package/dist/inner-plugins/plugins/summary.d.ts +1 -1
- package/dist/inner-plugins/utils/config.d.ts +2 -3
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/normalize-config.d.ts +1 -1
- package/dist/inner-plugins/utils/openBrowser.d.ts +1 -0
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +2 -3
- package/dist/logger.d.ts +9 -0
- package/dist/probe-loader.js +2 -0
- package/dist/proxy-loader.d.ts +1 -0
- package/dist/proxy-loader.js +48 -0
- package/dist/rslib-runtime.js +18 -9
- package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +4 -1
- package/dist/rspack-plugin/index.d.ts +2 -0
- package/dist/rspack-plugin/multiple.d.ts +8 -0
- package/dist/rspack-plugin/plugin.d.ts +25 -0
- package/dist/rule-utils/document/document.d.ts +16 -0
- package/dist/rule-utils/document/index.d.ts +3 -0
- package/dist/rule-utils/document/server.d.ts +4 -0
- package/dist/rule-utils/document/types.d.ts +31 -0
- package/dist/rule-utils/index.d.ts +2 -0
- package/dist/rule-utils/parser/asserts.d.ts +81 -0
- package/dist/rule-utils/parser/index.d.ts +4 -0
- package/dist/rule-utils/parser/parser.d.ts +118 -0
- package/dist/rule-utils/parser/types.d.ts +30 -0
- package/dist/rule-utils/parser/utils.d.ts +30 -0
- package/dist/rules/linter.d.ts +1 -1
- package/dist/rules/rule.d.ts +2 -2
- package/dist/rules/rules/cjs-require/index.d.ts +1 -1
- package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
- package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/htmlParserStub.d.ts +3 -0
- package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
- package/dist/rules/rules/ecma-version-check/types.d.ts +13 -3
- package/dist/rules/rules/ecma-version-check/utils.d.ts +1 -1
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.ts +1 -1
- package/dist/rules/rules/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/index.d.ts +1 -1
- package/dist/rules/rules/loader-performance-optimization/types.d.ts +1 -1
- package/dist/rules/rules/module-mixed-chunks/index.d.ts +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/utils.d.ts +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/multiple/controller.d.ts +12 -0
- package/dist/sdk/multiple/index.d.ts +2 -0
- package/dist/sdk/multiple/primary.d.ts +32 -0
- package/dist/sdk/multiple/server.d.ts +7 -0
- package/dist/sdk/sdk/core.d.ts +33 -0
- package/dist/sdk/sdk/index.d.ts +52 -0
- package/dist/sdk/sdk/types.d.ts +26 -0
- package/dist/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/sdk/server/apis/base.d.ts +11 -0
- package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/sdk/server/apis/data.d.ts +6 -0
- package/dist/sdk/server/apis/fs.d.ts +5 -0
- package/dist/sdk/server/apis/graph.d.ts +12 -0
- package/dist/sdk/server/apis/index.d.ts +10 -0
- package/dist/sdk/server/apis/loader.d.ts +15 -0
- package/dist/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/sdk/server/apis/project.d.ts +8 -0
- package/dist/sdk/server/apis/renderer.d.ts +6 -0
- package/dist/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/sdk/server/client.d.ts +3 -0
- package/dist/sdk/server/fakeServer.d.ts +9 -0
- package/dist/sdk/server/index.d.ts +44 -0
- package/dist/sdk/server/json-body.d.ts +6 -0
- package/dist/sdk/server/router.d.ts +24 -0
- package/dist/sdk/server/security.d.ts +5 -0
- package/dist/sdk/server/socket/api.d.ts +15 -0
- package/dist/sdk/server/socket/index.d.ts +48 -0
- package/dist/sdk/server/utils.d.ts +6 -0
- package/dist/sdk/utils/base.d.ts +1 -0
- package/dist/sdk/utils/constant.d.ts +1 -0
- package/dist/sdk/utils/date.d.ts +1 -0
- package/dist/sdk/utils/index.d.ts +3 -0
- package/dist/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/sdk/utils/upload.d.ts +2 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/loader.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -28
- package/package.json +56 -80
- package/static/openChrome.applescript +95 -0
- package/dist/build-utils/build/chunks/assetsModules.cjs +0 -42
- package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
- package/dist/build-utils/build/chunks/assetsModules.js +0 -9
- package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -39
- package/dist/build-utils/build/chunks/chunkTransform.d.cts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.d.ts +0 -4
- package/dist/build-utils/build/chunks/chunkTransform.js +0 -6
- package/dist/build-utils/build/chunks/index.cjs +0 -72
- package/dist/build-utils/build/chunks/index.d.cts +0 -3
- package/dist/build-utils/build/chunks/index.js +0 -4
- package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -80
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/chunks/rspack/transform.js +0 -44
- package/dist/build-utils/build/index.cjs +0 -52
- package/dist/build-utils/build/index.d.cts +0 -5
- package/dist/build-utils/build/index.js +0 -7
- package/dist/build-utils/build/loader/index.cjs +0 -65
- package/dist/build-utils/build/loader/index.d.cts +0 -2
- package/dist/build-utils/build/loader/index.js +0 -3
- package/dist/build-utils/build/loader/probeLoader.cjs +0 -89
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- package/dist/build-utils/build/loader/probeLoader.js +0 -44
- package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -65
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +0 -32
- package/dist/build-utils/build/module-graph/index.cjs +0 -65
- package/dist/build-utils/build/module-graph/index.d.cts +0 -2
- package/dist/build-utils/build/module-graph/index.js +0 -3
- package/dist/build-utils/build/module-graph/parser.cjs +0 -46
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- package/dist/build-utils/build/module-graph/parser.js +0 -13
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -151
- package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
- package/dist/build-utils/build/module-graph/rspack/transform.js +0 -109
- package/dist/build-utils/build/module-graph/transform.cjs +0 -39
- package/dist/build-utils/build/module-graph/transform.d.cts +0 -3
- package/dist/build-utils/build/module-graph/transform.d.ts +0 -3
- package/dist/build-utils/build/module-graph/transform.js +0 -6
- package/dist/build-utils/build/module-graph/utils.cjs +0 -95
- package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
- package/dist/build-utils/build/module-graph/utils.js +0 -59
- package/dist/build-utils/build/utils/index.cjs +0 -72
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- package/dist/build-utils/build/utils/index.js +0 -4
- package/dist/build-utils/build/utils/loader.cjs +0 -354
- package/dist/build-utils/build/utils/loader.d.cts +0 -20
- package/dist/build-utils/build/utils/loader.js +0 -276
- package/dist/build-utils/build/utils/parseBundle.cjs +0 -283
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- package/dist/build-utils/build/utils/parseBundle.js +0 -240
- package/dist/build-utils/build/utils/plugin.cjs +0 -60
- package/dist/build-utils/build/utils/plugin.d.cts +0 -5
- package/dist/build-utils/build/utils/plugin.js +0 -21
- package/dist/build-utils/index.cjs +0 -36
- package/dist/build-utils/index.d.cts +0 -1
- package/dist/build-utils/index.js +0 -3
- package/dist/index.cjs +0 -81
- package/dist/index.d.cts +0 -3
- package/dist/inner-plugins/constants.cjs +0 -64
- package/dist/inner-plugins/constants.js +0 -19
- package/dist/inner-plugins/index.cjs +0 -65
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/index.js +0 -3
- package/dist/inner-plugins/loaders/proxy.cjs +0 -104
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/loaders/proxy.js +0 -65
- package/dist/inner-plugins/plugins/base.cjs +0 -53
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/base.js +0 -20
- package/dist/inner-plugins/plugins/bundle.cjs +0 -96
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/bundle.js +0 -63
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -141
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -34
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +0 -102
- package/dist/inner-plugins/plugins/errors.cjs +0 -98
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/errors.js +0 -65
- package/dist/inner-plugins/plugins/index.cjs +0 -121
- package/dist/inner-plugins/plugins/index.d.cts +0 -10
- package/dist/inner-plugins/plugins/index.js +0 -11
- package/dist/inner-plugins/plugins/loader.cjs +0 -165
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/loader.js +0 -120
- package/dist/inner-plugins/plugins/plugins.cjs +0 -73
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/plugins.js +0 -40
- package/dist/inner-plugins/plugins/progress.cjs +0 -68
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.js +0 -35
- package/dist/inner-plugins/plugins/resolver.cjs +0 -90
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -12
- package/dist/inner-plugins/plugins/resolver.js +0 -57
- package/dist/inner-plugins/plugins/rspack.cjs +0 -118
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rspack.js +0 -85
- package/dist/inner-plugins/plugins/rules.cjs +0 -97
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/rules.js +0 -64
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -275
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/sourcemapTool.js +0 -230
- package/dist/inner-plugins/plugins/summary.cjs +0 -125
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/plugins/summary.js +0 -92
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -49
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/circleDetect.js +0 -16
- package/dist/inner-plugins/utils/config.cjs +0 -191
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/config.js +0 -142
- package/dist/inner-plugins/utils/index.cjs +0 -106
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/index.js +0 -8
- package/dist/inner-plugins/utils/loader.cjs +0 -218
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- package/dist/inner-plugins/utils/loader.js +0 -160
- package/dist/inner-plugins/utils/normalize-config.cjs +0 -122
- package/dist/inner-plugins/utils/normalize-config.d.cts +0 -37
- package/dist/inner-plugins/utils/normalize-config.js +0 -77
- package/dist/inner-plugins/utils/plugin-common.cjs +0 -143
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin-common.js +0 -94
- package/dist/inner-plugins/utils/plugin.cjs +0 -106
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/plugin.js +0 -70
- package/dist/inner-plugins/utils/sdk.cjs +0 -55
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/inner-plugins/utils/sdk.js +0 -19
- package/dist/rules/index.cjs +0 -81
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/index.js +0 -4
- package/dist/rules/linter.cjs +0 -72
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/linter.js +0 -36
- package/dist/rules/rule.cjs +0 -137
- package/dist/rules/rule.d.cts +0 -27
- package/dist/rules/rule.js +0 -101
- package/dist/rules/rules/cjs-require/index.cjs +0 -83
- package/dist/rules/rules/cjs-require/index.d.cts +0 -4
- package/dist/rules/rules/cjs-require/index.js +0 -50
- package/dist/rules/rules/cjs-require/types.cjs +0 -18
- package/dist/rules/rules/cjs-require/types.d.cts +0 -7
- package/dist/rules/rules/cjs-require/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/index.cjs +0 -74
- package/dist/rules/rules/cross-chunks-package/index.d.cts +0 -4
- package/dist/rules/rules/cross-chunks-package/index.js +0 -41
- package/dist/rules/rules/cross-chunks-package/types.cjs +0 -18
- package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
- package/dist/rules/rules/cross-chunks-package/types.js +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.cjs +0 -40
- package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
- package/dist/rules/rules/cross-chunks-package/utils.js +0 -7
- package/dist/rules/rules/default-import-check/index.cjs +0 -116
- package/dist/rules/rules/default-import-check/index.d.cts +0 -4
- package/dist/rules/rules/default-import-check/index.js +0 -83
- package/dist/rules/rules/default-import-check/types.cjs +0 -18
- package/dist/rules/rules/default-import-check/types.d.cts +0 -4
- package/dist/rules/rules/default-import-check/types.js +0 -1
- package/dist/rules/rules/default-import-check/utils.cjs +0 -97
- package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
- package/dist/rules/rules/default-import-check/utils.js +0 -52
- package/dist/rules/rules/duplicate-package/index.cjs +0 -72
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- package/dist/rules/rules/duplicate-package/index.js +0 -39
- package/dist/rules/rules/duplicate-package/types.cjs +0 -60
- package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
- package/dist/rules/rules/duplicate-package/types.js +0 -24
- package/dist/rules/rules/duplicate-package/utils.cjs +0 -84
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- package/dist/rules/rules/duplicate-package/utils.js +0 -38
- package/dist/rules/rules/ecma-version-check/index.cjs +0 -96
- package/dist/rules/rules/ecma-version-check/index.d.cts +0 -4
- package/dist/rules/rules/ecma-version-check/index.js +0 -53
- package/dist/rules/rules/ecma-version-check/types.cjs +0 -18
- package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/types.js +0 -1
- package/dist/rules/rules/ecma-version-check/utils.cjs +0 -39
- package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
- package/dist/rules/rules/ecma-version-check/utils.js +0 -6
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -237
- package/dist/rules/rules/esm-resolved-to-cjs/index.d.cts +0 -4
- package/dist/rules/rules/esm-resolved-to-cjs/index.js +0 -193
- package/dist/rules/rules/esm-resolved-to-cjs/types.cjs +0 -18
- package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
- package/dist/rules/rules/esm-resolved-to-cjs/types.js +0 -1
- package/dist/rules/rules/index.cjs +0 -55
- package/dist/rules/rules/index.d.cts +0 -2
- package/dist/rules/rules/index.js +0 -22
- package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -119
- package/dist/rules/rules/loader-performance-optimization/index.d.cts +0 -4
- package/dist/rules/rules/loader-performance-optimization/index.js +0 -86
- package/dist/rules/rules/loader-performance-optimization/types.cjs +0 -18
- package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
- package/dist/rules/rules/loader-performance-optimization/types.js +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.cjs +0 -43
- package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
- package/dist/rules/rules/loader-performance-optimization/utils.js +0 -10
- package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -85
- package/dist/rules/rules/module-mixed-chunks/index.d.cts +0 -4
- package/dist/rules/rules/module-mixed-chunks/index.js +0 -52
- package/dist/rules/rules/module-mixed-chunks/types.cjs +0 -18
- package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
- package/dist/rules/rules/module-mixed-chunks/types.js +0 -1
- package/dist/rules/rules/side-effects-only-imports/index.cjs +0 -114
- package/dist/rules/rules/side-effects-only-imports/index.d.cts +0 -4
- package/dist/rules/rules/side-effects-only-imports/index.js +0 -81
- package/dist/rules/rules/side-effects-only-imports/types.cjs +0 -18
- package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
- package/dist/rules/rules/side-effects-only-imports/types.js +0 -1
- package/dist/rules/utils.cjs +0 -46
- package/dist/rules/utils.d.cts +0 -3
- package/dist/rules/utils.js +0 -10
- package/dist/types/chunks.cjs +0 -18
- package/dist/types/chunks.d.cts +0 -6
- package/dist/types/chunks.d.ts +0 -6
- package/dist/types/chunks.js +0 -1
- package/dist/types/index.cjs +0 -79
- package/dist/types/index.d.cts +0 -4
- package/dist/types/index.js +0 -5
- package/dist/types/loader.cjs +0 -18
- package/dist/types/loader.d.cts +0 -19
- package/dist/types/loader.js +0 -1
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.d.cts +0 -51
- package/dist/types/plugin.js +0 -1
- package/dist/types/rules.cjs +0 -18
- package/dist/types/rules.d.cts +0 -7
- package/dist/types/rules.js +0 -1
package/dist/630.js
ADDED
|
@@ -0,0 +1,1269 @@
|
|
|
1
|
+
/*! LICENSE: 630.js.LICENSE.txt */
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
+
import { color, createLogger, logger as external_rslog_logger } from "rslog";
|
|
5
|
+
import { Constants } from "@rsdoctor/shared/types";
|
|
6
|
+
import { Readable, Transform } from "stream";
|
|
7
|
+
import path_0, { dirname, extname, join } from "path";
|
|
8
|
+
import { Loader, Lodash, Package } from "@rsdoctor/shared/common-browser";
|
|
9
|
+
import node_path from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import fs_extra from "fs-extra";
|
|
12
|
+
import { find as collection_find, mapValues, omit } from "@rsdoctor/shared/collection";
|
|
13
|
+
import fs from "fs";
|
|
14
|
+
import { LinesAndColumns } from "lines-and-columns";
|
|
15
|
+
import { Parser, parse } from "acorn";
|
|
16
|
+
import { importAttributes } from "acorn-import-attributes";
|
|
17
|
+
import * as __rspack_external_acorn_walk_1e4235a7 from "acorn-walk";
|
|
18
|
+
var Types, esm_Types, utils_namespaceObject = {};
|
|
19
|
+
__webpack_require__.r(utils_namespaceObject), __webpack_require__.d(utils_namespaceObject, {
|
|
20
|
+
canParse: ()=>canParse,
|
|
21
|
+
detectECMAVersion: ()=>detectECMAVersion,
|
|
22
|
+
getDefaultImports: ()=>getDefaultImports,
|
|
23
|
+
getIdentifierInDeclaration: ()=>getIdentifierInDeclaration,
|
|
24
|
+
getIdentifierInExport: ()=>getIdentifierInExport,
|
|
25
|
+
getIdentifierInImport: ()=>getIdentifierInImport,
|
|
26
|
+
getIdentifierInPattern: ()=>getIdentifierInPattern,
|
|
27
|
+
isES5: ()=>isES5,
|
|
28
|
+
isES6: ()=>isES6,
|
|
29
|
+
isSameSemantics: ()=>function isSameSemantics(node1, node2) {
|
|
30
|
+
if (node1.type !== node2.type) return !1;
|
|
31
|
+
switch(node1.type){
|
|
32
|
+
case 'CallExpression':
|
|
33
|
+
return node1.arguments.length === node2.arguments.length && !!node1.optional == !!node2.optional && isSameSemantics(node1.callee, node2.callee) && node1.arguments.every((node, i)=>isSameSemantics(node, node2.arguments[i]));
|
|
34
|
+
case 'MemberExpression':
|
|
35
|
+
return node1.computed === node2.computed && !!node1.optional == !!node2.optional && isSameSemantics(node1.object, node2.object) && isSameSemantics(node1.property, node2.property);
|
|
36
|
+
case 'Identifier':
|
|
37
|
+
return node1.name === node2.name;
|
|
38
|
+
case 'Literal':
|
|
39
|
+
if (asserts.isSimpleLiteral(node1) && asserts.isSimpleLiteral(node2)) return node1.value === node2.value;
|
|
40
|
+
return node1.raw === node2.raw;
|
|
41
|
+
case 'ObjectExpression':
|
|
42
|
+
return node1.properties.length === node2.properties.length && node1.properties.every((prop, i)=>isSameSemantics(prop, node2.properties[i]));
|
|
43
|
+
case 'Property':
|
|
44
|
+
return node1.computed === node2.computed && node1.kind === node2.kind && node1.method === node2.method && isSameSemantics(node1.key, node2.key) && isSameSemantics(node1.value, node2.value);
|
|
45
|
+
default:
|
|
46
|
+
throw Error(`Unknown node type: ${node1.type}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
let rsdoctorLogger = createLogger();
|
|
51
|
+
rsdoctorLogger.override({
|
|
52
|
+
log: (message)=>{
|
|
53
|
+
console.log(`${color.green('[RSDOCTOR LOG]')} ${message}`);
|
|
54
|
+
},
|
|
55
|
+
info: (message)=>{
|
|
56
|
+
console.log(`${color.yellow('[RSDOCTOR INFO]')} ${message}`);
|
|
57
|
+
},
|
|
58
|
+
warn: (message)=>{
|
|
59
|
+
console.warn(`${color.yellow('[RSDOCTOR WARN]')} ${message}`);
|
|
60
|
+
},
|
|
61
|
+
start: (message)=>{
|
|
62
|
+
console.log(`${color.green('[RSDOCTOR START]')} ${message}`);
|
|
63
|
+
},
|
|
64
|
+
ready: (message)=>{
|
|
65
|
+
console.log(`${color.green('[RSDOCTOR READY]')} ${message}`);
|
|
66
|
+
},
|
|
67
|
+
error: (message)=>{
|
|
68
|
+
console.error(`${color.red('[RSDOCTOR ERROR]')} ${message}`);
|
|
69
|
+
},
|
|
70
|
+
success: (message)=>{
|
|
71
|
+
console.error(`${color.green('[RSDOCTOR SUCCESS]')} ${message}`);
|
|
72
|
+
},
|
|
73
|
+
debug: (message)=>{
|
|
74
|
+
process.env.DEBUG && console.log(`${color.blue('[RSDOCTOR DEBUG]')} ${message}`);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
let _timers = new Map();
|
|
78
|
+
function logger_time(label) {
|
|
79
|
+
process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey || _timers.has(label) || _timers.set(label, Date.now());
|
|
80
|
+
}
|
|
81
|
+
function timeEnd(label) {
|
|
82
|
+
if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
|
|
83
|
+
let start = _timers.get(label);
|
|
84
|
+
if (null == start) return void external_rslog_logger.debug(`Timer '${label}' does not exist.`);
|
|
85
|
+
let duration = Date.now() - start;
|
|
86
|
+
external_rslog_logger.debug(`Timer '${label}' ended: ${duration}ms`), _timers.delete(label);
|
|
87
|
+
}
|
|
88
|
+
function _typeof(obj) {
|
|
89
|
+
return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
|
|
90
|
+
return typeof obj;
|
|
91
|
+
} : function(obj) {
|
|
92
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
93
|
+
})(obj);
|
|
94
|
+
}
|
|
95
|
+
function _defineProperty(obj, key, value) {
|
|
96
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
97
|
+
value: value,
|
|
98
|
+
enumerable: !0,
|
|
99
|
+
configurable: !0,
|
|
100
|
+
writable: !0
|
|
101
|
+
}) : obj[key] = value, obj;
|
|
102
|
+
}
|
|
103
|
+
function esm_getPrototypeOf(o) {
|
|
104
|
+
return (esm_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
|
|
105
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
106
|
+
})(o);
|
|
107
|
+
}
|
|
108
|
+
function esm_setPrototypeOf(o, p) {
|
|
109
|
+
return (esm_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
|
|
110
|
+
return o.__proto__ = p, o;
|
|
111
|
+
})(o, p);
|
|
112
|
+
}
|
|
113
|
+
function _assertThisInitialized(self) {
|
|
114
|
+
if (void 0 === self) throw ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
115
|
+
return self;
|
|
116
|
+
}
|
|
117
|
+
var rxEscapable = /[\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, meta = {
|
|
118
|
+
'\b': '\\b',
|
|
119
|
+
'\t': '\\t',
|
|
120
|
+
'\n': '\\n',
|
|
121
|
+
'\f': '\\f',
|
|
122
|
+
'\r': '\\r',
|
|
123
|
+
'"': '\\"',
|
|
124
|
+
'\\': '\\\\'
|
|
125
|
+
};
|
|
126
|
+
function getType(value) {
|
|
127
|
+
return value ? 'function' == typeof value.then ? esm_Types.Promise : 'function' == typeof value.read && 'function' == typeof value.pause && 'function' == typeof value.resume && 'function' == typeof value.pipe && 'function' == typeof value.once && 'function' == typeof value.removeListener ? value._readableState.objectMode ? esm_Types.ReadableObject : esm_Types.ReadableString : Array.isArray(value) ? esm_Types.Array : 'object' === _typeof(value) || value instanceof Object ? esm_Types.Object : esm_Types.Primitive : esm_Types.Primitive;
|
|
128
|
+
}
|
|
129
|
+
(Types = esm_Types || (esm_Types = {}))[Types.Array = 0] = "Array", Types[Types.Object = 1] = "Object", Types[Types.ReadableString = 2] = "ReadableString", Types[Types.ReadableObject = 3] = "ReadableObject", Types[Types.Primitive = 4] = "Primitive", Types[Types.Promise = 5] = "Promise";
|
|
130
|
+
var stackItemOpen = [];
|
|
131
|
+
stackItemOpen[esm_Types.Array] = '[', stackItemOpen[esm_Types.Object] = '{', stackItemOpen[esm_Types.ReadableString] = '"', stackItemOpen[esm_Types.ReadableObject] = '[';
|
|
132
|
+
var stackItemEnd = [];
|
|
133
|
+
stackItemEnd[esm_Types.Array] = ']', stackItemEnd[esm_Types.Object] = '}', stackItemEnd[esm_Types.ReadableString] = '"', stackItemEnd[esm_Types.ReadableObject] = ']';
|
|
134
|
+
var processFunctionLookupTable = [
|
|
135
|
+
'processArray',
|
|
136
|
+
'processObject',
|
|
137
|
+
'processReadableString',
|
|
138
|
+
'processReadableObject',
|
|
139
|
+
'processPrimitive',
|
|
140
|
+
'processPromise'
|
|
141
|
+
];
|
|
142
|
+
function escapeString(string) {
|
|
143
|
+
return string.replace(rxEscapable, function(a) {
|
|
144
|
+
var c = meta[a];
|
|
145
|
+
return 'string' == typeof c ? c : "\\u".concat(a.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function quoteString(string) {
|
|
149
|
+
return "\"".concat(escapeString(string), "\"");
|
|
150
|
+
}
|
|
151
|
+
function readAsPromised(stream, size) {
|
|
152
|
+
var value = stream.read(size);
|
|
153
|
+
return null === value ? new Promise(function(resolve, reject) {
|
|
154
|
+
var endListener = function() {
|
|
155
|
+
return resolve(null);
|
|
156
|
+
};
|
|
157
|
+
stream.once('end', endListener), stream.once('error', reject), stream.once('readable', function() {
|
|
158
|
+
stream.removeListener('end', endListener), stream.removeListener('error', reject), resolve(stream.read());
|
|
159
|
+
});
|
|
160
|
+
}) : Promise.resolve(value);
|
|
161
|
+
}
|
|
162
|
+
var esm_JsonStreamStringify = function(_Readable) {
|
|
163
|
+
if ("function" != typeof _Readable && null !== _Readable) throw TypeError("Super expression must either be null or a function");
|
|
164
|
+
JsonStreamStringify.prototype = Object.create(_Readable && _Readable.prototype, {
|
|
165
|
+
constructor: {
|
|
166
|
+
value: JsonStreamStringify,
|
|
167
|
+
writable: !0,
|
|
168
|
+
configurable: !0
|
|
169
|
+
}
|
|
170
|
+
}), Object.defineProperty(JsonStreamStringify, "prototype", {
|
|
171
|
+
writable: !1
|
|
172
|
+
}), _Readable && esm_setPrototypeOf(JsonStreamStringify, _Readable);
|
|
173
|
+
var hasNativeReflectConstruct, protoProps, _super = (hasNativeReflectConstruct = function() {
|
|
174
|
+
if ("u" < typeof Reflect || !Reflect.construct || Reflect.construct.sham) return !1;
|
|
175
|
+
if ("function" == typeof Proxy) return !0;
|
|
176
|
+
try {
|
|
177
|
+
return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {})), !0;
|
|
178
|
+
} catch (e) {
|
|
179
|
+
return !1;
|
|
180
|
+
}
|
|
181
|
+
}(), function() {
|
|
182
|
+
var result, Super = esm_getPrototypeOf(JsonStreamStringify);
|
|
183
|
+
result = hasNativeReflectConstruct ? Reflect.construct(Super, arguments, esm_getPrototypeOf(this).constructor) : Super.apply(this, arguments);
|
|
184
|
+
if (result && ("object" == typeof result || "function" == typeof result)) return result;
|
|
185
|
+
if (void 0 !== result) throw TypeError("Derived constructors may only return object or undefined");
|
|
186
|
+
return _assertThisInitialized(this);
|
|
187
|
+
});
|
|
188
|
+
function JsonStreamStringify(value, replacer, spaces) {
|
|
189
|
+
var _this, cycle = arguments.length > 3 && void 0 !== arguments[3] && arguments[3];
|
|
190
|
+
if (!(this instanceof JsonStreamStringify)) throw TypeError("Cannot call a class as a function");
|
|
191
|
+
_defineProperty(_assertThisInitialized(_this = _super.call(this, {
|
|
192
|
+
encoding: 'utf8'
|
|
193
|
+
})), "cycle", void 0), _defineProperty(_assertThisInitialized(_this), "visited", void 0), _defineProperty(_assertThisInitialized(_this), "stack", []), _defineProperty(_assertThisInitialized(_this), "replacerFunction", void 0), _defineProperty(_assertThisInitialized(_this), "replacerArray", void 0), _defineProperty(_assertThisInitialized(_this), "gap", void 0), _defineProperty(_assertThisInitialized(_this), "depth", 0), _defineProperty(_assertThisInitialized(_this), "error", void 0), _defineProperty(_assertThisInitialized(_this), "pushCalled", !1), _defineProperty(_assertThisInitialized(_this), "end", !1), _defineProperty(_assertThisInitialized(_this), "isReading", !1), _defineProperty(_assertThisInitialized(_this), "readMore", !1), _this.cycle = cycle;
|
|
194
|
+
var spaceType = _typeof(spaces);
|
|
195
|
+
return ('string' === spaceType || 'number' === spaceType) && (_this.gap = Number.isFinite(spaces) ? ' '.repeat(spaces) : spaces), Object.assign(_assertThisInitialized(_this), {
|
|
196
|
+
visited: cycle ? new WeakMap() : new WeakSet(),
|
|
197
|
+
replacerFunction: replacer instanceof Function && replacer,
|
|
198
|
+
replacerArray: Array.isArray(replacer) && replacer
|
|
199
|
+
}), replacer instanceof Function && (_this.replacerFunction = replacer), Array.isArray(replacer) && (_this.replacerArray = replacer), _this.addToStack(value), _this;
|
|
200
|
+
}
|
|
201
|
+
return protoProps = [
|
|
202
|
+
{
|
|
203
|
+
key: "cycler",
|
|
204
|
+
value: function(key, value) {
|
|
205
|
+
var existingPath = this.visited.get(value);
|
|
206
|
+
if (existingPath) return {
|
|
207
|
+
$ref: existingPath
|
|
208
|
+
};
|
|
209
|
+
var path = this.path();
|
|
210
|
+
return void 0 !== key && path.push(key), path = path.map(function(v) {
|
|
211
|
+
return "[".concat(Number.isInteger(v) ? v : quoteString(v), "]");
|
|
212
|
+
}), this.visited.set(value, path.length ? "$".concat(path.join('')) : '$'), value;
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: "addToStack",
|
|
217
|
+
value: function(value, key, index, parent) {
|
|
218
|
+
var _realValue$_readableS, _realValue$_readableS2, _this2 = this, realValue = value;
|
|
219
|
+
this.replacerFunction && (realValue = this.replacerFunction(key || index, realValue, this)), realValue && realValue.toJSON instanceof Function && (realValue = realValue.toJSON()), (realValue instanceof Function || 'symbol' === _typeof(value)) && (realValue = void 0), void 0 !== key && this.replacerArray && !this.replacerArray.includes(key) && (realValue = void 0);
|
|
220
|
+
var type = getType(realValue);
|
|
221
|
+
if ((parent && parent.type === esm_Types.Array || void 0 !== realValue) && type !== esm_Types.Promise && (parent && !parent.first && this._push(','), parent && (parent.first = !1)), void 0 !== realValue && type !== esm_Types.Promise && void 0 !== key && (this.gap ? this._push("\n".concat(this.gap.repeat(this.depth), "\"").concat(escapeString(key), "\": ")) : this._push("\"".concat(escapeString(key), "\":"))), type !== esm_Types.Primitive) if (this.cycle) type = getType(realValue = this.cycler(key || index, realValue));
|
|
222
|
+
else {
|
|
223
|
+
if (this.visited.has(realValue)) throw Object.assign(Error('Converting circular structure to JSON'), {
|
|
224
|
+
realValue: realValue,
|
|
225
|
+
key: key || index
|
|
226
|
+
});
|
|
227
|
+
this.visited.add(realValue);
|
|
228
|
+
}
|
|
229
|
+
!key && index > -1 && this.depth && this.gap && this._push("\n".concat(this.gap.repeat(this.depth)));
|
|
230
|
+
var open = stackItemOpen[type];
|
|
231
|
+
open && this._push(open);
|
|
232
|
+
var obj = {
|
|
233
|
+
key: key,
|
|
234
|
+
index: index,
|
|
235
|
+
type: type,
|
|
236
|
+
parent: parent,
|
|
237
|
+
value: realValue,
|
|
238
|
+
first: !0
|
|
239
|
+
};
|
|
240
|
+
return type === esm_Types.Object ? (this.depth += 1, obj.unread = Object.keys(realValue), obj.isEmpty = !obj.unread.length) : type === esm_Types.Array ? (this.depth += 1, obj.unread = realValue.length, obj.arrayLength = obj.unread, obj.isEmpty = !obj.unread) : (type === esm_Types.ReadableString || type === esm_Types.ReadableObject) && (this.depth += 1, realValue.readableEnded || null != (_realValue$_readableS = realValue._readableState) && _realValue$_readableS.endEmitted ? this.emit('error', Error('Readable Stream has ended before it was serialized. All stream data have been lost'), realValue, key || index) : (realValue.readableFlowing || null != (_realValue$_readableS2 = realValue._readableState) && _realValue$_readableS2.flowing) && (realValue.pause(), this.emit('error', Error('Readable Stream is in flowing mode, data may have been lost. Trying to pause stream.'), realValue, key || index)), obj.readCount = 0, realValue.once('end', function() {
|
|
241
|
+
obj.end = !0, _this2.__read();
|
|
242
|
+
}), realValue.once('error', function(err) {
|
|
243
|
+
_this2.error = !0, _this2.emit('error', err);
|
|
244
|
+
})), this.stack.unshift(obj), obj;
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
key: "removeFromStack",
|
|
249
|
+
value: function(item) {
|
|
250
|
+
var type = item.type, isObject = type === esm_Types.Object || type === esm_Types.Array || type === esm_Types.ReadableString || type === esm_Types.ReadableObject;
|
|
251
|
+
type !== esm_Types.Primitive && (this.cycle || this.visited.delete(item.value), isObject && (this.depth -= 1));
|
|
252
|
+
var end = stackItemEnd[type];
|
|
253
|
+
isObject && !item.isEmpty && this.gap && this._push("\n".concat(this.gap.repeat(this.depth))), end && this._push(end);
|
|
254
|
+
var stackIndex = this.stack.indexOf(item);
|
|
255
|
+
this.stack.splice(stackIndex, 1);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
key: "_push",
|
|
260
|
+
value: function(data) {
|
|
261
|
+
this.pushCalled = !0, this.push(data);
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
key: "processReadableObject",
|
|
266
|
+
value: function(current, size) {
|
|
267
|
+
var _this3 = this;
|
|
268
|
+
return current.end ? void this.removeFromStack(current) : readAsPromised(current.value, size).then(function(value) {
|
|
269
|
+
null !== value && (current.first || _this3._push(','), current.first = !1, _this3.addToStack(value, void 0, current.readCount), current.readCount += 1);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
key: "processObject",
|
|
275
|
+
value: function(current) {
|
|
276
|
+
if (!current.unread.length) return void this.removeFromStack(current);
|
|
277
|
+
var key = current.unread.shift(), value = current.value[key];
|
|
278
|
+
this.addToStack(value, key, void 0, current);
|
|
279
|
+
}
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
key: "processArray",
|
|
283
|
+
value: function(current) {
|
|
284
|
+
var key = current.unread;
|
|
285
|
+
if (!key) return void this.removeFromStack(current);
|
|
286
|
+
var index = current.arrayLength - key, value = current.value[index];
|
|
287
|
+
current.unread -= 1, this.addToStack(value, void 0, index, current);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
key: "processPrimitive",
|
|
292
|
+
value: function(current) {
|
|
293
|
+
if (void 0 !== current.value) {
|
|
294
|
+
var value, type = _typeof(current.value);
|
|
295
|
+
switch(type){
|
|
296
|
+
case 'string':
|
|
297
|
+
value = quoteString(current.value);
|
|
298
|
+
break;
|
|
299
|
+
case 'number':
|
|
300
|
+
value = Number.isFinite(current.value) ? String(current.value) : 'null';
|
|
301
|
+
break;
|
|
302
|
+
case 'bigint':
|
|
303
|
+
case 'boolean':
|
|
304
|
+
value = String(current.value);
|
|
305
|
+
break;
|
|
306
|
+
case 'object':
|
|
307
|
+
if (!current.value) {
|
|
308
|
+
value = 'null';
|
|
309
|
+
break;
|
|
310
|
+
}
|
|
311
|
+
default:
|
|
312
|
+
throw Object.assign(Error("Unknown type \"".concat(type, "\". Please file an issue!")), {
|
|
313
|
+
value: current.value
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
this._push(value);
|
|
317
|
+
} else this.stack[1] && (this.stack[1].type === esm_Types.Array || this.stack[1].type === esm_Types.ReadableObject) ? this._push('null') : current.addSeparatorAfterEnd = !1;
|
|
318
|
+
this.removeFromStack(current);
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
key: "processReadableString",
|
|
323
|
+
value: function(current, size) {
|
|
324
|
+
var _this4 = this;
|
|
325
|
+
return current.end ? void this.removeFromStack(current) : readAsPromised(current.value, size).then(function(value) {
|
|
326
|
+
value && _this4._push(escapeString(value.toString()));
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
key: "processPromise",
|
|
332
|
+
value: function(current) {
|
|
333
|
+
var _this5 = this;
|
|
334
|
+
return (function recursiveResolve(promise) {
|
|
335
|
+
return promise.then(function(res) {
|
|
336
|
+
return getType(res) === esm_Types.Promise ? recursiveResolve(res) : res;
|
|
337
|
+
});
|
|
338
|
+
})(current.value).then(function(value) {
|
|
339
|
+
_this5.removeFromStack(current), _this5.addToStack(value, current.key, current.index, current.parent);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
key: "processStackTopItem",
|
|
345
|
+
value: function(size) {
|
|
346
|
+
var out, _this6 = this, current = this.stack[0];
|
|
347
|
+
if (!current || this.error) return Promise.resolve();
|
|
348
|
+
try {
|
|
349
|
+
out = this[processFunctionLookupTable[current.type]](current, size);
|
|
350
|
+
} catch (err) {
|
|
351
|
+
return Promise.reject(err);
|
|
352
|
+
}
|
|
353
|
+
return Promise.resolve(out).then(function() {
|
|
354
|
+
0 === _this6.stack.length && (_this6.end = !0, _this6._push(null));
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
key: "__read",
|
|
360
|
+
value: function(size) {
|
|
361
|
+
var _this7 = this;
|
|
362
|
+
if (this.isReading || this.error) {
|
|
363
|
+
this.readMore = !0;
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
return this.isReading = !0, this.readMore = !1, this.processStackTopItem(size).then(function() {
|
|
367
|
+
_this7.end || _this7.error || !_this7.readMore && _this7.pushCalled ? _this7.isReading = !1 : setImmediate(function() {
|
|
368
|
+
_this7.isReading = !1, _this7.__read();
|
|
369
|
+
});
|
|
370
|
+
}).catch(function(err) {
|
|
371
|
+
_this7.error = !0, _this7.emit('error', err);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
key: "_read",
|
|
377
|
+
value: function(size) {
|
|
378
|
+
this.pushCalled = !1, this.__read(size);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
key: "path",
|
|
383
|
+
value: function() {
|
|
384
|
+
return this.stack.map(function(_ref) {
|
|
385
|
+
var key = _ref.key, index = _ref.index;
|
|
386
|
+
return key || index;
|
|
387
|
+
}).filter(function(v) {
|
|
388
|
+
return v || v > -1;
|
|
389
|
+
}).reverse();
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
], function(target, props) {
|
|
393
|
+
for(var i = 0; i < props.length; i++){
|
|
394
|
+
var descriptor = props[i];
|
|
395
|
+
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
|
|
396
|
+
}
|
|
397
|
+
}(JsonStreamStringify.prototype, protoProps), Object.defineProperty(JsonStreamStringify, "prototype", {
|
|
398
|
+
writable: !1
|
|
399
|
+
}), JsonStreamStringify;
|
|
400
|
+
}(Readable);
|
|
401
|
+
function stringify(json, replacer, space, cycle) {
|
|
402
|
+
let jsonList = [];
|
|
403
|
+
return json && 'object' == typeof json ? new Promise((resolve, reject)=>{
|
|
404
|
+
let stream = new esm_JsonStreamStringify(json, replacer, space, cycle), currentLength = 0, currentContent = '', batchProcessor = new Transform({
|
|
405
|
+
readableObjectMode: !0,
|
|
406
|
+
transform (chunk, _encoding, callback) {
|
|
407
|
+
chunk.toString().split('\\n').forEach((line)=>{
|
|
408
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
409
|
+
}), callback();
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
stream.pipe(batchProcessor).on('data', (line)=>{
|
|
413
|
+
currentLength + line.length > 419430400 && (jsonList.push(currentContent), currentContent = '', currentLength = 0), line.length && (currentContent += line, currentLength += line.length);
|
|
414
|
+
}).on('end', ()=>{
|
|
415
|
+
jsonList.length < 1 && jsonList.push(currentContent), resolve(jsonList);
|
|
416
|
+
}).on('error', (err)=>reject(err));
|
|
417
|
+
}) : Promise.resolve(JSON.stringify(json, replacer, space));
|
|
418
|
+
}
|
|
419
|
+
let readPackageJson = (file, readFile)=>{
|
|
420
|
+
let result, current = file;
|
|
421
|
+
for(; '/' !== current && !result;){
|
|
422
|
+
let parent = dirname(current);
|
|
423
|
+
if (parent === current) break;
|
|
424
|
+
current = parent, readFile && (result = readFile(join(current, 'package.json'))), readFile ? result?.name || (result = void 0) : result = Package.getPackageMetaFromModulePath(file);
|
|
425
|
+
}
|
|
426
|
+
if (result) return !readFile || result.name && result.version ? {
|
|
427
|
+
...result,
|
|
428
|
+
root: current
|
|
429
|
+
} : readPackageJson(dirname(current), readFile);
|
|
430
|
+
}, JEDEC = "jedec", BYTE = "byte", ARRAY = "array", OBJECT = "object", EXPONENT = "exponent", STRINGS_symbol = {
|
|
431
|
+
iec: {
|
|
432
|
+
bits: [
|
|
433
|
+
"bit",
|
|
434
|
+
"Kibit",
|
|
435
|
+
"Mibit",
|
|
436
|
+
"Gibit",
|
|
437
|
+
"Tibit",
|
|
438
|
+
"Pibit",
|
|
439
|
+
"Eibit",
|
|
440
|
+
"Zibit",
|
|
441
|
+
"Yibit"
|
|
442
|
+
],
|
|
443
|
+
bytes: [
|
|
444
|
+
"B",
|
|
445
|
+
"KiB",
|
|
446
|
+
"MiB",
|
|
447
|
+
"GiB",
|
|
448
|
+
"TiB",
|
|
449
|
+
"PiB",
|
|
450
|
+
"EiB",
|
|
451
|
+
"ZiB",
|
|
452
|
+
"YiB"
|
|
453
|
+
]
|
|
454
|
+
},
|
|
455
|
+
jedec: {
|
|
456
|
+
bits: [
|
|
457
|
+
"bit",
|
|
458
|
+
"Kbit",
|
|
459
|
+
"Mbit",
|
|
460
|
+
"Gbit",
|
|
461
|
+
"Tbit",
|
|
462
|
+
"Pbit",
|
|
463
|
+
"Ebit",
|
|
464
|
+
"Zbit",
|
|
465
|
+
"Ybit"
|
|
466
|
+
],
|
|
467
|
+
bytes: [
|
|
468
|
+
"B",
|
|
469
|
+
"KB",
|
|
470
|
+
"MB",
|
|
471
|
+
"GB",
|
|
472
|
+
"TB",
|
|
473
|
+
"PB",
|
|
474
|
+
"EB",
|
|
475
|
+
"ZB",
|
|
476
|
+
"YB"
|
|
477
|
+
]
|
|
478
|
+
}
|
|
479
|
+
}, STRINGS_fullform = {
|
|
480
|
+
iec: [
|
|
481
|
+
"",
|
|
482
|
+
"kibi",
|
|
483
|
+
"mebi",
|
|
484
|
+
"gibi",
|
|
485
|
+
"tebi",
|
|
486
|
+
"pebi",
|
|
487
|
+
"exbi",
|
|
488
|
+
"zebi",
|
|
489
|
+
"yobi"
|
|
490
|
+
],
|
|
491
|
+
jedec: [
|
|
492
|
+
"",
|
|
493
|
+
"kilo",
|
|
494
|
+
"mega",
|
|
495
|
+
"giga",
|
|
496
|
+
"tera",
|
|
497
|
+
"peta",
|
|
498
|
+
"exa",
|
|
499
|
+
"zetta",
|
|
500
|
+
"yotta"
|
|
501
|
+
]
|
|
502
|
+
}, BINARY_POWERS = [
|
|
503
|
+
1,
|
|
504
|
+
1024,
|
|
505
|
+
1048576,
|
|
506
|
+
1073741824,
|
|
507
|
+
1099511627776,
|
|
508
|
+
1125899906842624,
|
|
509
|
+
1152921504606846976,
|
|
510
|
+
1180591620717411303424,
|
|
511
|
+
1208925819614629174706176
|
|
512
|
+
], DECIMAL_POWERS = [
|
|
513
|
+
1,
|
|
514
|
+
1000,
|
|
515
|
+
1000000,
|
|
516
|
+
1000000000,
|
|
517
|
+
1000000000000,
|
|
518
|
+
1000000000000000,
|
|
519
|
+
1000000000000000000,
|
|
520
|
+
1000000000000000000000,
|
|
521
|
+
1000000000000000000000000
|
|
522
|
+
], LOG_2_1024 = Math.log(1024), LOG_10_1000 = Math.log(1000), STANDARD_CONFIGS = {
|
|
523
|
+
si: {
|
|
524
|
+
isDecimal: !0,
|
|
525
|
+
ceil: 1000,
|
|
526
|
+
actualStandard: JEDEC
|
|
527
|
+
},
|
|
528
|
+
iec: {
|
|
529
|
+
isDecimal: !1,
|
|
530
|
+
ceil: 1024,
|
|
531
|
+
actualStandard: "iec"
|
|
532
|
+
},
|
|
533
|
+
[JEDEC]: {
|
|
534
|
+
isDecimal: !1,
|
|
535
|
+
ceil: 1024,
|
|
536
|
+
actualStandard: JEDEC
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
function calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent = !0) {
|
|
540
|
+
let d, result = num / (d = isDecimal ? DECIMAL_POWERS[e] : BINARY_POWERS[e]);
|
|
541
|
+
return bits && (result *= 8, autoExponent && result >= ceil && e < 8 && (result /= ceil, e++)), {
|
|
542
|
+
result,
|
|
543
|
+
e
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
function filesize(arg, { bits = !1, pad = !1, base = -1, round = 2, locale = "", localeOptions = {}, separator = "", spacer = " ", symbols = {}, standard = "", output = "string", fullform = !1, fullforms = [], exponent = -1, roundingMethod = "round", precision = 0 } = {}) {
|
|
547
|
+
let p, r, symbolTable, numericValue, e = exponent, num, result = [], val = 0, u = "";
|
|
548
|
+
if ("bigint" == typeof arg) num = Number(arg);
|
|
549
|
+
else if (isNaN(num = Number(arg)) || !isFinite(num)) throw TypeError("Invalid number");
|
|
550
|
+
let { isDecimal, ceil, actualStandard } = STANDARD_CONFIGS[standard] ? STANDARD_CONFIGS[standard] : 2 === base ? {
|
|
551
|
+
isDecimal: !1,
|
|
552
|
+
ceil: 1024,
|
|
553
|
+
actualStandard: "iec"
|
|
554
|
+
} : {
|
|
555
|
+
isDecimal: !0,
|
|
556
|
+
ceil: 1000,
|
|
557
|
+
actualStandard: JEDEC
|
|
558
|
+
}, full = !0 === fullform, neg = num < 0, roundingFunc = Math[roundingMethod];
|
|
559
|
+
if ("function" != typeof roundingFunc) throw TypeError("Invalid rounding method");
|
|
560
|
+
if (neg && (num = -num), 0 === num) {
|
|
561
|
+
let value;
|
|
562
|
+
return (value = precision > 0 ? 0..toPrecision(precision) : pad && round > 0 ? 0..toFixed(round) : 0, output === EXPONENT) ? 0 : (symbol || (symbol = bits ? STRINGS_symbol[actualStandard].bits[0] : STRINGS_symbol[actualStandard].bytes[0]), symbols[symbol] && (symbol = symbols[symbol]), full && (fullforms[0] ? symbol = fullforms[0] : (symbol = STRINGS_fullform[actualStandard][0], bits ? symbol += "bit" : symbol += BYTE)), output === ARRAY) ? [
|
|
563
|
+
value,
|
|
564
|
+
symbol
|
|
565
|
+
] : output === OBJECT ? {
|
|
566
|
+
value,
|
|
567
|
+
symbol,
|
|
568
|
+
exponent: 0,
|
|
569
|
+
unit: symbol
|
|
570
|
+
} : value + spacer + symbol;
|
|
571
|
+
}
|
|
572
|
+
let { e: calculatedE, precision: precisionAdjusted } = (num1 = num, e1 = e, precision1 = precision, (-1 === e1 || isNaN(e1) ? (e1 = isDecimal ? Math.floor(Math.log(num1) / LOG_10_1000) : Math.floor(Math.log(num1) / LOG_2_1024)) < 0 && (e1 = 0) : e1 < 0 && (e1 = 0), e1 > 8) ? (precision1 > 0 && (precision1 += 8 - e1), {
|
|
573
|
+
e: 8,
|
|
574
|
+
precision: precision1
|
|
575
|
+
}) : {
|
|
576
|
+
e: e1,
|
|
577
|
+
precision: precision1
|
|
578
|
+
});
|
|
579
|
+
e = calculatedE;
|
|
580
|
+
let autoExponent = -1 === exponent || isNaN(exponent), { result: valueResult, e: valueExponent } = calculateOptimizedValue(num, e, isDecimal, bits, ceil, autoExponent);
|
|
581
|
+
val = valueResult, e = valueExponent;
|
|
582
|
+
let rounded = (val1 = val, (r = 1 === (p = (e2 = e) > 0 && round > 0 ? Math.pow(10, round) : 1) ? roundingFunc(val1) : roundingFunc(val1 * p) / p) === ceil && e2 < 8 && autoExponent && (r = 1, e2++), {
|
|
583
|
+
value: r,
|
|
584
|
+
e: e2
|
|
585
|
+
});
|
|
586
|
+
if (result[0] = rounded.value, e = rounded.e, precisionAdjusted > 0) {
|
|
587
|
+
let precisionResult = function(value, precision, e, num, isDecimal, bits, ceil, roundingFunc, round, exponent) {
|
|
588
|
+
"string" == typeof value && (value = parseFloat(value));
|
|
589
|
+
let result = value.toPrecision(precision), autoExponent = -1 === exponent || isNaN(exponent);
|
|
590
|
+
if (result.includes("e") && e < 8 && autoExponent) {
|
|
591
|
+
let p, { result: valueResult } = calculateOptimizedValue(num, ++e, isDecimal, bits, ceil);
|
|
592
|
+
result = (1 === (p = round > 0 ? Math.pow(10, round) : 1) ? roundingFunc(valueResult) : roundingFunc(valueResult * p) / p).toPrecision(precision);
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
value: result,
|
|
596
|
+
e
|
|
597
|
+
};
|
|
598
|
+
}(result[0], precisionAdjusted, e, num, isDecimal, bits, ceil, roundingFunc, round, exponent);
|
|
599
|
+
result[0] = precisionResult.value, e = precisionResult.e;
|
|
600
|
+
}
|
|
601
|
+
if (output === EXPONENT) return e;
|
|
602
|
+
e3 = e, symbolTable = STRINGS_symbol[actualStandard][bits ? "bits" : "bytes"], u = isDecimal && 1 === e3 ? bits ? "kbit" : "kB" : symbolTable[e3], result[1] = u;
|
|
603
|
+
var symbol, num1, e1, precision1, val1, e2, e3, e4, u1, e5 = e;
|
|
604
|
+
if (neg && (result[0] = -result[0]), symbols[result[1]] && (result[1] = symbols[result[1]]), numericValue = "string" == typeof result[0] ? parseFloat(result[0]) : result[0], result[0] = function(value, locale, localeOptions, separator, pad, round, roundingFunc) {
|
|
605
|
+
let result = value, localePad = pad && round > 0 ? {
|
|
606
|
+
minimumFractionDigits: round,
|
|
607
|
+
maximumFractionDigits: round
|
|
608
|
+
} : void 0;
|
|
609
|
+
if (!0 === locale) result = result.toLocaleString(void 0, localePad);
|
|
610
|
+
else if (locale.length > 0) result = result.toLocaleString(locale, {
|
|
611
|
+
...localeOptions,
|
|
612
|
+
...localePad
|
|
613
|
+
});
|
|
614
|
+
else if (separator.length > 0) {
|
|
615
|
+
if (pad && round > 0) {
|
|
616
|
+
let p = Math.pow(10, round);
|
|
617
|
+
result = roundingFunc(result * p) / p;
|
|
618
|
+
}
|
|
619
|
+
result = result.toString().replace(".", separator);
|
|
620
|
+
}
|
|
621
|
+
if (pad && round > 0 && !0 !== locale && 0 === locale.length) {
|
|
622
|
+
let resultStr = result.toString(), x = separator || ".", tmp = resultStr.split(x), s = tmp[1] || "";
|
|
623
|
+
result = `${tmp[0]}${x}${s.padEnd(round, "0")}`;
|
|
624
|
+
}
|
|
625
|
+
return result;
|
|
626
|
+
}(result[0], locale, localeOptions, separator, pad, round, roundingFunc), full) {
|
|
627
|
+
let unit;
|
|
628
|
+
unit = bits ? "bit" : BYTE, fullforms[e5] ? result[1] = fullforms[e5] : result[1] = STRINGS_fullform[actualStandard][e5] + unit + (1 === numericValue ? "" : "s");
|
|
629
|
+
}
|
|
630
|
+
return e4 = e, u1 = u, output === ARRAY ? result : output === OBJECT ? {
|
|
631
|
+
value: result[0],
|
|
632
|
+
symbol: result[1],
|
|
633
|
+
exponent: e4,
|
|
634
|
+
unit: u1
|
|
635
|
+
} : " " === spacer ? `${result[0]} ${result[1]}` : result.join(spacer);
|
|
636
|
+
}
|
|
637
|
+
let loader_filename = fileURLToPath(import.meta.url), loader_dirname = node_path.dirname(loader_filename), loader_require = createRequire(import.meta.url), PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
638
|
+
function parsePathQueryFragment(str) {
|
|
639
|
+
let match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
640
|
+
return {
|
|
641
|
+
path: match?.[1].replace(/\0(.)/g, '$1') || '',
|
|
642
|
+
query: match?.[2] ? match[2].replace(/\0(.)/g, '$1') : '',
|
|
643
|
+
fragment: match?.[3] || ''
|
|
644
|
+
};
|
|
645
|
+
}
|
|
646
|
+
function loadLoaderModule(loaderPath, cwd = process.cwd()) {
|
|
647
|
+
let cleanLoaderPath = parsePathQueryFragment(loaderPath).path, mod = loader_require(process.env.DOCTOR_TEST ? node_path.resolve(cwd, cleanLoaderPath) : loader_require.resolve(cleanLoaderPath, {
|
|
648
|
+
paths: [
|
|
649
|
+
cwd,
|
|
650
|
+
node_path.resolve(cwd, 'node_modules')
|
|
651
|
+
]
|
|
652
|
+
}));
|
|
653
|
+
return {
|
|
654
|
+
default: mod.__esModule && 'function' == typeof mod.default ? mod.default : 'function' == typeof mod ? mod : null,
|
|
655
|
+
pitch: mod.default?.pitch || mod.pitch,
|
|
656
|
+
raw: mod.default?.raw || mod.raw || !1
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
function extractLoaderName(loaderPath, cwd = '') {
|
|
660
|
+
let res = loaderPath.replace(cwd, '');
|
|
661
|
+
if (!node_path.isAbsolute(res)) return res;
|
|
662
|
+
let nms = '/node_modules/', idx = res.lastIndexOf(nms);
|
|
663
|
+
if (-1 !== idx) {
|
|
664
|
+
res = res.slice(idx + nms.length);
|
|
665
|
+
let ln = 'loader', lnIdx = res.lastIndexOf(ln);
|
|
666
|
+
lnIdx > -1 && (res = res.slice(0, lnIdx + ln.length));
|
|
667
|
+
}
|
|
668
|
+
return res;
|
|
669
|
+
}
|
|
670
|
+
function mapEachRules(rules, callback) {
|
|
671
|
+
return rules.filter(Boolean).map((rule)=>{
|
|
672
|
+
if ('string' == typeof rule) return callback({
|
|
673
|
+
loader: rule
|
|
674
|
+
});
|
|
675
|
+
if (rule.loader && 'string' == typeof rule.loader) return callback(rule);
|
|
676
|
+
if (Array.isArray(rule.loaders)) {
|
|
677
|
+
let { loaders, ...rest } = rule;
|
|
678
|
+
return {
|
|
679
|
+
...rest,
|
|
680
|
+
use: mapEachRules(loaders, callback)
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
if (rule.use && (!Array.isArray(rule.use) || 0 !== rule.use.length)) {
|
|
684
|
+
if ('string' == typeof rule.use) return {
|
|
685
|
+
...rule,
|
|
686
|
+
use: mapEachRules([
|
|
687
|
+
{
|
|
688
|
+
loader: rule.use,
|
|
689
|
+
options: rule.options
|
|
690
|
+
}
|
|
691
|
+
], callback)
|
|
692
|
+
};
|
|
693
|
+
if ('function' == typeof rule.use) {
|
|
694
|
+
let funcUse = rule.use;
|
|
695
|
+
return {
|
|
696
|
+
...rule,
|
|
697
|
+
use: (...args)=>mapEachRules(funcUse(...args), callback)
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
return Array.isArray(rule.use) ? {
|
|
701
|
+
...rule,
|
|
702
|
+
use: mapEachRules(rule.use, callback)
|
|
703
|
+
} : {
|
|
704
|
+
...rule,
|
|
705
|
+
use: mapEachRules([
|
|
706
|
+
rule.use
|
|
707
|
+
], callback)
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
return 'rules' in rule && Array.isArray(rule.rules) ? {
|
|
711
|
+
...rule,
|
|
712
|
+
rules: mapEachRules(rule.rules, callback)
|
|
713
|
+
} : Array.isArray(rule.oneOf) ? {
|
|
714
|
+
...rule,
|
|
715
|
+
oneOf: mapEachRules(rule.oneOf, callback)
|
|
716
|
+
} : rule;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function isESMLoader(r) {
|
|
720
|
+
let _loaderName = 'object' == typeof r && 'string' == typeof r?.loader ? r.loader : 'string' == typeof r ? r : '';
|
|
721
|
+
if (!_loaderName) return !1;
|
|
722
|
+
if (node_path.isAbsolute(_loaderName) || _loaderName.startsWith('./') || _loaderName.startsWith('../')) {
|
|
723
|
+
let packageJsonData = readPackageJson(_loaderName, (file)=>{
|
|
724
|
+
try {
|
|
725
|
+
return fs_extra.readJsonSync(file, {
|
|
726
|
+
encoding: 'utf8'
|
|
727
|
+
});
|
|
728
|
+
} catch (e) {
|
|
729
|
+
rsdoctorLogger.debug(`isESMLoader function error:${e}`);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
if (packageJsonData?.type === 'module' && !packageJsonData?.name.includes('@rsdoctor/')) return !0;
|
|
733
|
+
}
|
|
734
|
+
return !1;
|
|
735
|
+
}
|
|
736
|
+
function appendProbeLoaders(compiler, loaderConfig) {
|
|
737
|
+
let _options = 'object' == typeof loaderConfig ? 'string' == typeof loaderConfig.options ? {
|
|
738
|
+
options: loaderConfig.options
|
|
739
|
+
} : loaderConfig.options : {}, loaderPath = process.env.DOCTOR_TEST ? node_path.resolve(loader_dirname, '../loader/probeLoader.ts') : loader_require.resolve(node_path.join(loader_dirname, 'probe-loader')), loader = 'string' == typeof loaderConfig ? loaderConfig : 'object' == typeof loaderConfig && loaderConfig.loader, createProbeLoader = (type)=>({
|
|
740
|
+
loader: loaderPath,
|
|
741
|
+
options: {
|
|
742
|
+
..._options,
|
|
743
|
+
loader,
|
|
744
|
+
ident: void 0,
|
|
745
|
+
type,
|
|
746
|
+
builderName: compiler.options.name
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
return [
|
|
750
|
+
createProbeLoader('end'),
|
|
751
|
+
loaderConfig,
|
|
752
|
+
createProbeLoader('start')
|
|
753
|
+
];
|
|
754
|
+
}
|
|
755
|
+
function getLoaderNameMatch(r, loaderName, strict = !0) {
|
|
756
|
+
return strict ? 'object' == typeof r && 'string' == typeof r?.loader && r.loader === loaderName || 'string' == typeof r && r === loaderName : 'object' == typeof r && 'string' == typeof r?.loader && r.loader.includes(loaderName) || 'string' == typeof r && r.includes(loaderName);
|
|
757
|
+
}
|
|
758
|
+
function addProbeLoader2Rules(rules, compiler, fn) {
|
|
759
|
+
return rules.map((rule)=>{
|
|
760
|
+
if (!rule || 'string' == typeof rule) return rule;
|
|
761
|
+
if (fn(rule) && !rule.use) {
|
|
762
|
+
let loaderConfig = {
|
|
763
|
+
loader: rule.loader ?? '',
|
|
764
|
+
options: rule.options,
|
|
765
|
+
ident: 'ident' in rule && 'string' == typeof rule.ident ? rule.ident : void 0
|
|
766
|
+
};
|
|
767
|
+
return {
|
|
768
|
+
...rule,
|
|
769
|
+
use: appendProbeLoaders(compiler, loaderConfig),
|
|
770
|
+
loader: void 0,
|
|
771
|
+
options: void 0
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
return (rule.use && (Array.isArray(rule.use) ? rule.use = rule.use.flatMap((loaderConfig)=>('string' == typeof loaderConfig || 'object' == typeof loaderConfig && loaderConfig && 'loader' in loaderConfig) && fn(loaderConfig) ? appendProbeLoaders(compiler, loaderConfig) : [
|
|
775
|
+
loaderConfig
|
|
776
|
+
]) : 'object' != typeof rule.use || Array.isArray(rule.use) || 'function' == typeof rule.use ? 'string' == typeof rule.use && (rule.use = fn(rule.use) ? appendProbeLoaders(compiler, {
|
|
777
|
+
loader: rule.use
|
|
778
|
+
}) : [
|
|
779
|
+
{
|
|
780
|
+
loader: rule.use
|
|
781
|
+
}
|
|
782
|
+
]) : 'loader' in rule.use && (rule.use = fn(rule.use) ? appendProbeLoaders(compiler, rule.use) : [
|
|
783
|
+
rule.use
|
|
784
|
+
])), 'oneOf' in rule && rule.oneOf) ? {
|
|
785
|
+
...rule,
|
|
786
|
+
oneOf: addProbeLoader2Rules(rule.oneOf, compiler, fn)
|
|
787
|
+
} : 'rules' in rule && rule.rules ? {
|
|
788
|
+
...rule,
|
|
789
|
+
rules: addProbeLoader2Rules(rule.rules, compiler, fn)
|
|
790
|
+
} : rule;
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
function createLoaderContextTrap(final) {
|
|
794
|
+
let cb = this.callback, callback = (...args)=>(final(args[0], args[1] ?? null, args[2]), cb.call(this, ...args)), ac = this.async, async = (...args)=>{
|
|
795
|
+
let cb = ac(...args);
|
|
796
|
+
return (...args)=>(final(args[0], args[1] ?? null, args[2]), cb(...args));
|
|
797
|
+
};
|
|
798
|
+
return new Proxy(this, {
|
|
799
|
+
get (target, key, receiver) {
|
|
800
|
+
switch(key){
|
|
801
|
+
case 'async':
|
|
802
|
+
return async;
|
|
803
|
+
case 'callback':
|
|
804
|
+
return callback;
|
|
805
|
+
case 'query':
|
|
806
|
+
if (target.query) {
|
|
807
|
+
if ('string' == typeof target.query) return target.query.replace(RegExp(`"${Loader.LoaderInternalPropertyName}":{[^}]*},{0,1}`), '');
|
|
808
|
+
if ('object' == typeof target.query) {
|
|
809
|
+
let options = target.query[Loader.LoaderInternalPropertyName];
|
|
810
|
+
if (options.hasOptions) return omit(target.query, [
|
|
811
|
+
Loader.LoaderInternalPropertyName
|
|
812
|
+
]);
|
|
813
|
+
return parsePathQueryFragment(options?.loader).query;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
return Reflect.get(target, key, receiver);
|
|
817
|
+
case 'getOptions':
|
|
818
|
+
return 'function' == typeof target.getOptions ? ()=>omit(target.getOptions(), [
|
|
819
|
+
Loader.LoaderInternalPropertyName
|
|
820
|
+
]) : Reflect.get(target, key, receiver);
|
|
821
|
+
default:
|
|
822
|
+
return target[key];
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
set (target, key, value, receiver) {
|
|
826
|
+
switch(key){
|
|
827
|
+
case 'async':
|
|
828
|
+
return async = value, !0;
|
|
829
|
+
case 'callback':
|
|
830
|
+
return callback = value, !0;
|
|
831
|
+
default:
|
|
832
|
+
return Reflect.set(target, key, value, receiver);
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
defineProperty: (target, p, attrs)=>Reflect.defineProperty(target, p, attrs)
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
function parseQuery(query) {
|
|
839
|
+
return query.startsWith('?') && (query = query.slice(1)), Object.fromEntries(new URLSearchParams(query).entries());
|
|
840
|
+
}
|
|
841
|
+
function shouldInterceptPluginHook(hook) {
|
|
842
|
+
return (!hook || !hook._fakeHook) && (hook?.isUsed && 'function' == typeof hook.isUsed ? hook.isUsed() : !hook?._map || 0 !== hook._map.size);
|
|
843
|
+
}
|
|
844
|
+
function interceptCompilerHooks(compiler, interceptor) {
|
|
845
|
+
Object.keys(compiler.hooks).forEach((hook)=>{
|
|
846
|
+
let v = compiler.hooks[hook];
|
|
847
|
+
shouldInterceptPluginHook(v) && interceptor(hook, v, 'compiler');
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
function interceptCompilationHooks(compilation, interceptor) {
|
|
851
|
+
Object.keys(compilation.hooks).forEach((hook)=>{
|
|
852
|
+
if ('normalModuleLoader' === hook) return;
|
|
853
|
+
let v = compilation.hooks[hook];
|
|
854
|
+
shouldInterceptPluginHook(v) && interceptor(hook, v, 'compilation');
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
class Document {
|
|
858
|
+
constructor(content){
|
|
859
|
+
this._text = '', this._text = content, this.createFinder();
|
|
860
|
+
}
|
|
861
|
+
createFinder() {
|
|
862
|
+
let find = new LinesAndColumns(this._text);
|
|
863
|
+
this.positionAt = (offset)=>{
|
|
864
|
+
offset >= this._text.length && (offset = this._text.length - 1), offset < 0 && (offset = 0);
|
|
865
|
+
let result = find.locationForIndex(offset);
|
|
866
|
+
if (result) return {
|
|
867
|
+
line: result.line + 1,
|
|
868
|
+
column: result.column
|
|
869
|
+
};
|
|
870
|
+
}, this.offsetAt = (position)=>find.indexForLocation({
|
|
871
|
+
line: position.line - 1,
|
|
872
|
+
column: position.column
|
|
873
|
+
}) ?? void 0;
|
|
874
|
+
}
|
|
875
|
+
getText(range) {
|
|
876
|
+
if (!range) return this._text;
|
|
877
|
+
let start = 'number' == typeof range.start ? range.start : this.offsetAt(range.start), end = 'number' == typeof range.end ? range.end : this.offsetAt(range.end);
|
|
878
|
+
if (Lodash.isUndefined(start)) throw Error(`Location ${JSON.stringify(start)} is illegal`);
|
|
879
|
+
if (Lodash.isUndefined(end)) throw Error(`Location ${JSON.stringify(end)} is illegal`);
|
|
880
|
+
return this._text.slice(start, end);
|
|
881
|
+
}
|
|
882
|
+
edit(data) {
|
|
883
|
+
let { _text: content } = this, startOffset = Lodash.isNumber(data.start) ? data.start : this.offsetAt(data.start), endOffset = Lodash.isNumber(data.end) ? data.end : this.offsetAt(data.end);
|
|
884
|
+
if (Lodash.isUndefined(startOffset) || Lodash.isUndefined(endOffset)) return;
|
|
885
|
+
let startTxt = content.substring(0, startOffset), endTxt = content.substring(endOffset, content.length);
|
|
886
|
+
return startTxt + data.newText + endTxt;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
let store = new Map();
|
|
890
|
+
function getDocument(content) {
|
|
891
|
+
if (store.has(content)) return store.get(content);
|
|
892
|
+
let doc = new Document(content);
|
|
893
|
+
return store.set(content, doc), doc;
|
|
894
|
+
}
|
|
895
|
+
function isSyntaxNode(node) {
|
|
896
|
+
return Lodash.isObject(node) && 'type' in node;
|
|
897
|
+
}
|
|
898
|
+
function assertCreator(type) {
|
|
899
|
+
return (node)=>isSyntaxNode(node) && node.type === type;
|
|
900
|
+
}
|
|
901
|
+
let asserts = {
|
|
902
|
+
isProgram: assertCreator('Program'),
|
|
903
|
+
isEmptyStatement: assertCreator('EmptyStatement'),
|
|
904
|
+
isBlockStatement: assertCreator('BlockStatement'),
|
|
905
|
+
isStaticBlock: assertCreator('StaticBlock'),
|
|
906
|
+
isExpressionStatement: assertCreator('ExpressionStatement'),
|
|
907
|
+
isIfStatement: assertCreator('IfStatement'),
|
|
908
|
+
isLabeledStatement: assertCreator('LabeledStatement'),
|
|
909
|
+
isBreakStatement: assertCreator('BreakStatement'),
|
|
910
|
+
isContinueStatement: assertCreator('ContinueStatement'),
|
|
911
|
+
isWithStatement: assertCreator('WithStatement'),
|
|
912
|
+
isSwitchStatement: assertCreator('SwitchStatement'),
|
|
913
|
+
isReturnStatement: assertCreator('ReturnStatement'),
|
|
914
|
+
isThrowStatement: assertCreator('ThrowStatement'),
|
|
915
|
+
isTryStatement: assertCreator('TryStatement'),
|
|
916
|
+
isWhileStatement: assertCreator('WhileStatement'),
|
|
917
|
+
isDoWhileStatement: assertCreator('DoWhileStatement'),
|
|
918
|
+
isForStatement: assertCreator('ForStatement'),
|
|
919
|
+
isForInStatement: assertCreator('ForInStatement'),
|
|
920
|
+
isForOfStatement: assertCreator('ForOfStatement'),
|
|
921
|
+
isDebuggerStatement: assertCreator('DebuggerStatement'),
|
|
922
|
+
isFunctionDeclaration: assertCreator('FunctionDeclaration'),
|
|
923
|
+
isVariableDeclaration: assertCreator('VariableDeclaration'),
|
|
924
|
+
isVariableDeclarator: assertCreator('VariableDeclarator'),
|
|
925
|
+
isChainExpression: assertCreator('ChainExpression'),
|
|
926
|
+
isThisExpression: assertCreator('ThisExpression'),
|
|
927
|
+
isArrayExpression: assertCreator('ArrayExpression'),
|
|
928
|
+
isObjectExpression: assertCreator('ObjectExpression'),
|
|
929
|
+
isPrivateIdentifier: assertCreator('PrivateIdentifier'),
|
|
930
|
+
isProperty: assertCreator('Property'),
|
|
931
|
+
isPropertyDefinition: assertCreator('PropertyDefinition'),
|
|
932
|
+
isFunctionExpression: assertCreator('FunctionExpression'),
|
|
933
|
+
isSequenceExpression: assertCreator('SequenceExpression'),
|
|
934
|
+
isUnaryExpression: assertCreator('UnaryExpression'),
|
|
935
|
+
isBinaryExpression: assertCreator('BinaryExpression'),
|
|
936
|
+
isAssignmentExpression: assertCreator('AssignmentExpression'),
|
|
937
|
+
isUpdateExpression: assertCreator('UpdateExpression'),
|
|
938
|
+
isLogicalExpression: assertCreator('LogicalExpression'),
|
|
939
|
+
isConditionalExpression: assertCreator('ConditionalExpression'),
|
|
940
|
+
isNewExpression: assertCreator('NewExpression'),
|
|
941
|
+
isSwitchCase: assertCreator('SwitchCase'),
|
|
942
|
+
isCatchClause: assertCreator('CatchClause'),
|
|
943
|
+
isIdentifier: assertCreator('Identifier'),
|
|
944
|
+
isLiteral: assertCreator('Literal'),
|
|
945
|
+
isSuper: assertCreator('Super'),
|
|
946
|
+
isSpreadElement: assertCreator('SpreadElement'),
|
|
947
|
+
isArrowFunctionExpression: assertCreator('ArrowFunctionExpression'),
|
|
948
|
+
isYieldExpression: assertCreator('YieldExpression'),
|
|
949
|
+
isTemplateLiteral: assertCreator('TemplateLiteral'),
|
|
950
|
+
isTaggedTemplateExpression: assertCreator('TaggedTemplateExpression'),
|
|
951
|
+
isTemplateElement: assertCreator('TemplateElement'),
|
|
952
|
+
isObjectPattern: assertCreator('ObjectPattern'),
|
|
953
|
+
isArrayPattern: assertCreator('ArrayPattern'),
|
|
954
|
+
isRestElement: assertCreator('RestElement'),
|
|
955
|
+
isAssignmentPattern: assertCreator('AssignmentPattern'),
|
|
956
|
+
isClassBody: assertCreator('ClassBody'),
|
|
957
|
+
isClassDeclaration: assertCreator('ClassDeclaration'),
|
|
958
|
+
isClassExpression: assertCreator('ClassExpression'),
|
|
959
|
+
isMetaProperty: assertCreator('MetaProperty'),
|
|
960
|
+
isImportDeclaration: assertCreator('ImportDeclaration'),
|
|
961
|
+
isImportSpecifier: assertCreator('ImportSpecifier'),
|
|
962
|
+
isImportExpression: assertCreator('ImportExpression'),
|
|
963
|
+
isImportDefaultSpecifier: assertCreator('ImportDefaultSpecifier'),
|
|
964
|
+
isImportNamespaceSpecifier: assertCreator('ImportNamespaceSpecifier'),
|
|
965
|
+
isExportNamedDeclaration: assertCreator('ExportNamedDeclaration'),
|
|
966
|
+
isExportSpecifier: assertCreator('ExportSpecifier'),
|
|
967
|
+
isExportDefaultDeclaration: assertCreator('ExportDefaultDeclaration'),
|
|
968
|
+
isExportAllDeclaration: assertCreator('ExportAllDeclaration'),
|
|
969
|
+
isAwaitExpression: assertCreator('AwaitExpression'),
|
|
970
|
+
isMethodDefinition: assertCreator('MethodDefinition'),
|
|
971
|
+
isMemberExpression: assertCreator('MemberExpression'),
|
|
972
|
+
isComment: (node)=>isSyntaxNode(node) && ('Line' === node.type || 'Block' === node.type),
|
|
973
|
+
isDirective: (node)=>asserts.isExpressionStatement(node) && 'directive' in node,
|
|
974
|
+
isSimpleCallExpression: (node)=>isSyntaxNode(node) && 'CallExpression' === node.type,
|
|
975
|
+
isAssignmentProperty: (node)=>asserts.isProperty(node) && 'init' === node.kind,
|
|
976
|
+
isSimpleLiteral: (node)=>asserts.isLiteral(node) && !asserts.isRegExpLiteral(node) && !asserts.isBigIntLiteral(node),
|
|
977
|
+
isRegExpLiteral: (node)=>asserts.isLiteral(node) && 'regex' in node,
|
|
978
|
+
isBigIntLiteral: (node)=>asserts.isLiteral(node) && 'bigint' in node,
|
|
979
|
+
isExportStatement: (node)=>asserts.isExportAllDeclaration(node) || asserts.isExportDefaultDeclaration(node) || asserts.isExportNamedDeclaration(node)
|
|
980
|
+
};
|
|
981
|
+
function getDefaultImports(node) {
|
|
982
|
+
return node.body.filter((statement)=>{
|
|
983
|
+
if ('ImportDeclaration' !== statement.type) return !1;
|
|
984
|
+
let specifier = statement?.specifiers?.[0];
|
|
985
|
+
return specifier?.type === 'ImportDefaultSpecifier';
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
function getIdentifierInPattern(name, node) {
|
|
989
|
+
if (asserts.isIdentifier(node) && node.name === name) return node;
|
|
990
|
+
if (asserts.isObjectPattern(node)) for (let prop of node.properties){
|
|
991
|
+
if (asserts.isAssignmentProperty(prop)) return getIdentifierInPattern(name, prop.value);
|
|
992
|
+
if (asserts.isRestElement(prop)) return getIdentifierInPattern(name, prop);
|
|
993
|
+
}
|
|
994
|
+
if (asserts.isArrayPattern(node)) {
|
|
995
|
+
for (let el of node.elements)if (el) {
|
|
996
|
+
let result = getIdentifierInPattern(name, el);
|
|
997
|
+
if (result) return result;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return asserts.isRestElement(node) ? getIdentifierInPattern(name, node.argument) : asserts.isAssignmentPattern(node) ? getIdentifierInPattern(name, node.left) : void 0;
|
|
1001
|
+
}
|
|
1002
|
+
function getIdentifierInDeclaration(name, node) {
|
|
1003
|
+
var node1;
|
|
1004
|
+
return asserts.isFunctionDeclaration(node) || asserts.isClassDeclaration(node) ? (node1 = node, asserts.isIdentifier(node1.id) && node1.id.name === name ? node1.id : void 0) : asserts.isVariableDeclaration(node) ? node.declarations.find((item)=>getIdentifierInPattern(name, item.id))?.id : void 0;
|
|
1005
|
+
}
|
|
1006
|
+
function getIdentifierInImport(name, node) {
|
|
1007
|
+
if (asserts.isImportDeclaration(node)) {
|
|
1008
|
+
for (let specifier of node.specifiers ?? [])if (specifier.local.name === name) return specifier.local;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
function getIdentifierInExport(name, node) {
|
|
1012
|
+
if (asserts.isExportNamedDeclaration(node)) {
|
|
1013
|
+
if (node.declaration) return getIdentifierInDeclaration(name, node.declaration);
|
|
1014
|
+
for (let specifier of node.specifiers ?? [])if (specifier.exported.name === name) return specifier.exported;
|
|
1015
|
+
}
|
|
1016
|
+
if (asserts.isExportAllDeclaration(node) && node.exported && node.exported.name === name) return node.exported;
|
|
1017
|
+
}
|
|
1018
|
+
function canParse(code, ecmaVersion) {
|
|
1019
|
+
try {
|
|
1020
|
+
return parse(code, {
|
|
1021
|
+
ecmaVersion,
|
|
1022
|
+
sourceType: 'number' == typeof ecmaVersion && ecmaVersion <= 5 ? "script" : 'module'
|
|
1023
|
+
}), !0;
|
|
1024
|
+
} catch {
|
|
1025
|
+
return !1;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
function isES5(code) {
|
|
1029
|
+
return canParse(code, 5);
|
|
1030
|
+
}
|
|
1031
|
+
function isES6(code) {
|
|
1032
|
+
return canParse(code, 6);
|
|
1033
|
+
}
|
|
1034
|
+
function detectECMAVersion(code) {
|
|
1035
|
+
return isES6(code) ? isES5(code) ? "ES5" : "ES6" : "ES7+";
|
|
1036
|
+
}
|
|
1037
|
+
let acornParserInternal = Parser.extend(importAttributes), acornParserExport = Parser.extend(importAttributes), parser = {
|
|
1038
|
+
walk: __rspack_external_acorn_walk_1e4235a7,
|
|
1039
|
+
parse: (input, options)=>acornParserExport.parse(input, options),
|
|
1040
|
+
parseExpressionAt: (input, pos, options)=>acornParserExport.parseExpressionAt(input, pos, options),
|
|
1041
|
+
extend: (...args)=>acornParserExport = acornParserExport.extend(...args),
|
|
1042
|
+
asserts: asserts,
|
|
1043
|
+
utils: utils_namespaceObject,
|
|
1044
|
+
internal: {
|
|
1045
|
+
parse: (input, options)=>acornParserInternal.parse(input, options),
|
|
1046
|
+
parseExpressionAt: (input, pos, options)=>acornParserInternal.parseExpressionAt(input, pos, options)
|
|
1047
|
+
}
|
|
1048
|
+
}, parseBundle = (bundlePath, modulesData)=>{
|
|
1049
|
+
let modules;
|
|
1050
|
+
if (bundlePath.indexOf('.worker.') > 0) return {};
|
|
1051
|
+
let ext = extname(bundlePath);
|
|
1052
|
+
if (!Constants.JSExtensions.includes(ext)) return {};
|
|
1053
|
+
let content = fs.readFileSync(bundlePath, 'utf8'), tagCache = new Map(), hasBannerPlugin = (content = content.replace(/\/\/# sourceMappingURL=[^\n]*$/m, '')).indexOf('RSDOCTOR_START::') > 0;
|
|
1054
|
+
if (hasBannerPlugin && !tagCache.get(bundlePath)) {
|
|
1055
|
+
let tagMatchResult = function(raw, start, end) {
|
|
1056
|
+
try {
|
|
1057
|
+
let matchStart = raw.match(start), startFlagIndex = matchStart?.length ? raw.indexOf(matchStart[0], 0) : -1;
|
|
1058
|
+
if (-1 === startFlagIndex || !matchStart?.length) return {
|
|
1059
|
+
result: null,
|
|
1060
|
+
remain: 0
|
|
1061
|
+
};
|
|
1062
|
+
let startTagLength = matchStart[0].length, matchEnd = raw.match(end), endFlagIndex = matchEnd?.length ? raw.indexOf(matchEnd[0], startFlagIndex + startTagLength) : -1;
|
|
1063
|
+
if (-1 === endFlagIndex || !matchEnd?.length) return {
|
|
1064
|
+
result: null,
|
|
1065
|
+
remain: 0
|
|
1066
|
+
};
|
|
1067
|
+
let innerContent = raw.slice(startFlagIndex + startTagLength, endFlagIndex).trim();
|
|
1068
|
+
return innerContent.endsWith(',') && (innerContent = innerContent.slice(0, -1)), {
|
|
1069
|
+
result: innerContent,
|
|
1070
|
+
remain: matchEnd?.length ? endFlagIndex + matchEnd[0].length : endFlagIndex,
|
|
1071
|
+
loc: {
|
|
1072
|
+
start: startFlagIndex + startTagLength,
|
|
1073
|
+
end: endFlagIndex
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
} catch (e) {
|
|
1077
|
+
return rsdoctorLogger.debug(()=>e), {
|
|
1078
|
+
result: null,
|
|
1079
|
+
remain: 0
|
|
1080
|
+
};
|
|
1081
|
+
}
|
|
1082
|
+
}(content, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_START::(.*?)[;,]/, /([a-z|A-Z|_]+\.[a-z]+)\(\SRSDOCTOR_END::(.*?)\)/);
|
|
1083
|
+
content = tagMatchResult.result?.trim() || content, tagCache.set(bundlePath, tagMatchResult.loc), hasBannerPlugin = !0;
|
|
1084
|
+
} else if (hasBannerPlugin && tagCache.get(bundlePath)) {
|
|
1085
|
+
let loc = tagCache.get(bundlePath);
|
|
1086
|
+
content = content.slice(loc.start, loc.end), hasBannerPlugin = !0;
|
|
1087
|
+
}
|
|
1088
|
+
let ast = parser.internal.parse(content, {
|
|
1089
|
+
sourceType: "script",
|
|
1090
|
+
ecmaVersion: 'latest'
|
|
1091
|
+
}), walkState = {
|
|
1092
|
+
locations: null,
|
|
1093
|
+
expressionStatementDepth: 0
|
|
1094
|
+
};
|
|
1095
|
+
parser.walk.recursive(ast, walkState, {
|
|
1096
|
+
ExpressionStatement (node, state, c) {
|
|
1097
|
+
if (!state.locations) {
|
|
1098
|
+
state.expressionStatementDepth++;
|
|
1099
|
+
try {
|
|
1100
|
+
var node1, node2;
|
|
1101
|
+
if (1 === state.expressionStatementDepth && (node1 = node, 'ExpressionStatement' === node1.type && ('CallExpression' === node1.expression.type || 'UnaryExpression' === node1.expression.type && 'CallExpression' === node1.expression.argument.type))) {
|
|
1102
|
+
let fn = (node2 = node, 'UnaryExpression' === node2.expression.type ? node2.expression.argument : node2.expression);
|
|
1103
|
+
if (0 === fn.arguments.length && 0 === fn.callee.params.length) {
|
|
1104
|
+
let firstVariableDeclaration = fn.callee.body.body.find((node)=>'VariableDeclaration' === node.type);
|
|
1105
|
+
if (firstVariableDeclaration) {
|
|
1106
|
+
for (let declaration of firstVariableDeclaration.declarations)if (declaration.init && (state.locations = getModulesLocations(declaration.init), state.locations)) break;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
state.locations || c(node.expression, state);
|
|
1111
|
+
} catch (e) {
|
|
1112
|
+
rsdoctorLogger.debug(e);
|
|
1113
|
+
}
|
|
1114
|
+
state.expressionStatementDepth--;
|
|
1115
|
+
}
|
|
1116
|
+
},
|
|
1117
|
+
Program (node, state, _c) {
|
|
1118
|
+
if (!state.locations) {
|
|
1119
|
+
try {
|
|
1120
|
+
if (hasBannerPlugin) {
|
|
1121
|
+
let firstVariableDeclaration = node.body.find((node)=>'VariableDeclaration' === node.type && node.declarations?.[0]?.init?.type === 'ObjectExpression' && node.declarations?.[0]?.init?.properties?.length);
|
|
1122
|
+
if (firstVariableDeclaration) {
|
|
1123
|
+
for (let declaration of firstVariableDeclaration.declarations)if (declaration.init && (state.locations = getModulesLocations(declaration.init), state.locations)) break;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
state.locations || node.body.forEach((n)=>_c(n, state));
|
|
1127
|
+
} catch (e) {
|
|
1128
|
+
rsdoctorLogger.debug(e);
|
|
1129
|
+
}
|
|
1130
|
+
state.expressionStatementDepth--;
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
AssignmentExpression (node, state) {
|
|
1134
|
+
if (state.locations) return;
|
|
1135
|
+
let { left, right } = node;
|
|
1136
|
+
left?.object && 'exports' === left.object.name && left.property && 'modules' === left.property.name && isModulesHash(right) && (state.locations = getModulesLocations(right));
|
|
1137
|
+
},
|
|
1138
|
+
CallExpression (node, state, c) {
|
|
1139
|
+
var node1;
|
|
1140
|
+
if (state.locations) return;
|
|
1141
|
+
let args = node.arguments;
|
|
1142
|
+
if ('FunctionExpression' === node.callee.type && !node.callee.id && 1 === args.length && (isModulesHash(node1 = args[0]) || isModulesArray(node1))) {
|
|
1143
|
+
state.locations = getModulesLocations(args[0]);
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
if ('Identifier' === node.callee.type && mayBeAsyncChunkArguments(args) && isModulesList(args[1])) {
|
|
1147
|
+
state.locations = getModulesLocations(args[1]);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (function(node) {
|
|
1151
|
+
let { callee, arguments: args } = node;
|
|
1152
|
+
return 'MemberExpression' === callee.type && 'push' === callee.property.name && 'AssignmentExpression' === callee.object.type && 1 === args.length && 'ArrayExpression' === args[0].type && mayBeAsyncChunkArguments(args[0].elements) && isModulesList(args[0].elements[1]);
|
|
1153
|
+
}(node)) {
|
|
1154
|
+
state.locations = getModulesLocations(args[0].elements[1]);
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1157
|
+
if (function(node) {
|
|
1158
|
+
let { callee, type, arguments: args } = node;
|
|
1159
|
+
return 'CallExpression' === type && 'MemberExpression' === callee.type && 2 === args.length && isChunkIds(args[0]) && isModulesList(args[1]);
|
|
1160
|
+
}(node)) {
|
|
1161
|
+
state.locations = getModulesLocations(args[1]);
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
args.forEach((arg)=>c(arg, state));
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
let modulesObj = {};
|
|
1168
|
+
for(let module in modules = walkState.locations ? mapValues(walkState.locations, (loc)=>content.slice(loc.start, loc.end)) : {}){
|
|
1169
|
+
if (!module) return {};
|
|
1170
|
+
let moduleContent = modules[module], size = moduleContent && Buffer.byteLength(moduleContent);
|
|
1171
|
+
modulesObj[collection_find(modulesData, (item)=>item.renderId === module)?.identifier || ''] = {
|
|
1172
|
+
size,
|
|
1173
|
+
sizeConvert: filesize(size || 0),
|
|
1174
|
+
content: moduleContent
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
return {
|
|
1178
|
+
modules: modulesObj,
|
|
1179
|
+
src: content,
|
|
1180
|
+
runtimeSrc: function(content, modulesLocations) {
|
|
1181
|
+
let sortedLocations = Object.values(modulesLocations || {}).sort((a, b)=>a.start - b.start), result = '', lastIndex = 0;
|
|
1182
|
+
for (let { start, end } of sortedLocations)result += content.slice(lastIndex, start), lastIndex = end;
|
|
1183
|
+
return result + content.slice(lastIndex, content.length);
|
|
1184
|
+
}(content, walkState.locations)
|
|
1185
|
+
};
|
|
1186
|
+
};
|
|
1187
|
+
function isModulesList(node) {
|
|
1188
|
+
var node1, node2;
|
|
1189
|
+
return isModulesHash(node1 = node) || isModulesArray(node1) || 'CallExpression' === (node2 = node).type && 'MemberExpression' === node2.callee.type && 'CallExpression' === node2.callee.object.type && 'Identifier' === node2.callee.object.callee.type && 'Array' === node2.callee.object.callee.name && 1 === node2.callee.object.arguments.length && isNumericId(node2.callee.object.arguments[0]) && 'Identifier' === node2.callee.property.type && 'concat' === node2.callee.property.name && 1 === node2.arguments.length && isModulesArray(node2.arguments[0]);
|
|
1190
|
+
}
|
|
1191
|
+
function isModulesHash(node) {
|
|
1192
|
+
return 'ObjectExpression' === node.type && node.properties.map((node)=>node.value).every(isModuleWrapper);
|
|
1193
|
+
}
|
|
1194
|
+
function isModulesArray(node) {
|
|
1195
|
+
return 'ArrayExpression' === node.type && node.elements.every((elem)=>!elem || isModuleWrapper(elem));
|
|
1196
|
+
}
|
|
1197
|
+
function isModuleWrapper(node) {
|
|
1198
|
+
return ('FunctionExpression' === node.type || 'ArrowFunctionExpression' === node.type) && !node.id || isModuleId(node) || 'ArrayExpression' === node.type && node.elements.length > 1 && isModuleId(node.elements[0]);
|
|
1199
|
+
}
|
|
1200
|
+
function isModuleId(node) {
|
|
1201
|
+
return 'Literal' === node.type && (isNumericId(node) || 'string' == typeof node.value);
|
|
1202
|
+
}
|
|
1203
|
+
function isNumericId(node) {
|
|
1204
|
+
return 'Literal' === node.type && Number.isInteger(node.value) && node.value >= 0;
|
|
1205
|
+
}
|
|
1206
|
+
function isChunkIds(node) {
|
|
1207
|
+
return 'ArrayExpression' === node.type && node.elements.every(isModuleId);
|
|
1208
|
+
}
|
|
1209
|
+
function mayBeAsyncChunkArguments(args) {
|
|
1210
|
+
return args.length >= 2 && isChunkIds(args[0]);
|
|
1211
|
+
}
|
|
1212
|
+
function getModulesLocations(node) {
|
|
1213
|
+
if ('ObjectExpression' === node.type) return node.properties.reduce((result, moduleNode)=>(result[moduleNode.key.name || moduleNode.key.value] = getModuleLocation(moduleNode.value), result), {});
|
|
1214
|
+
let isOptimizedArray = 'CallExpression' === node.type;
|
|
1215
|
+
if ('ArrayExpression' === node.type || isOptimizedArray) {
|
|
1216
|
+
let minId = isOptimizedArray ? node.callee.object.arguments[0].value : 0;
|
|
1217
|
+
return (isOptimizedArray ? node.arguments[0].elements : node.elements).reduce((result, moduleNode, i)=>(moduleNode && (result[i + minId] = getModuleLocation(moduleNode)), result), {});
|
|
1218
|
+
}
|
|
1219
|
+
return {};
|
|
1220
|
+
}
|
|
1221
|
+
function getModuleLocation(node) {
|
|
1222
|
+
return {
|
|
1223
|
+
start: node.start,
|
|
1224
|
+
end: node.end
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
function setSDK(t) {
|
|
1228
|
+
globalThis.__rsdoctor_sdks__ || (globalThis.__rsdoctor_sdks__ = []), globalThis.__rsdoctor_sdks__.push(t), globalThis.__rsdoctor_sdk__ = t;
|
|
1229
|
+
}
|
|
1230
|
+
function getSDK(builderName) {
|
|
1231
|
+
let sdks = globalThis.__rsdoctor_sdks__ || [], sdk = globalThis.__rsdoctor_sdk__;
|
|
1232
|
+
if (sdk && sdk.name !== builderName && (sdk = builderName && sdks.find((s)=>s.name === builderName) || sdk), sdk && builderName && 'parent' in sdk) {
|
|
1233
|
+
let parent = sdk.parent;
|
|
1234
|
+
return parent?.slaves.find((_sdk)=>_sdk.name === builderName) || sdk;
|
|
1235
|
+
}
|
|
1236
|
+
return sdk;
|
|
1237
|
+
}
|
|
1238
|
+
export default function(...args) {
|
|
1239
|
+
let time = Date.now(), code = args[0], _options = this.getOptions(), sdk = getSDK(_options.builderName), loaderData = {
|
|
1240
|
+
resource: {
|
|
1241
|
+
path: this._module?.layer ? `${this.resourcePath}[${this._module.layer}]` : this.resourcePath,
|
|
1242
|
+
query: parseQuery(this.resourceQuery),
|
|
1243
|
+
queryRaw: this.resourceQuery,
|
|
1244
|
+
ext: path_0.extname(this.resourcePath).slice(1),
|
|
1245
|
+
...this._module?.layer ? {
|
|
1246
|
+
layer: this._module.layer
|
|
1247
|
+
} : {}
|
|
1248
|
+
},
|
|
1249
|
+
loaders: [
|
|
1250
|
+
{
|
|
1251
|
+
loader: _options.loader,
|
|
1252
|
+
loaderIndex: this.loaderIndex,
|
|
1253
|
+
path: _options.loader,
|
|
1254
|
+
input: 'start' === _options.type ? code : null,
|
|
1255
|
+
result: 'end' === _options.type ? code : null,
|
|
1256
|
+
startAt: 'start' === _options.type ? time : 0,
|
|
1257
|
+
endAt: 'end' === _options.type ? time : 0,
|
|
1258
|
+
options: omit(_options.options, 'type'),
|
|
1259
|
+
isPitch: !1,
|
|
1260
|
+
sync: !1,
|
|
1261
|
+
errors: [],
|
|
1262
|
+
pid: process.pid,
|
|
1263
|
+
ppid: process.ppid
|
|
1264
|
+
}
|
|
1265
|
+
]
|
|
1266
|
+
};
|
|
1267
|
+
sdk?.reportLoaderStartOrEnd(loaderData), this.callback(null, ...args);
|
|
1268
|
+
};
|
|
1269
|
+
export { addProbeLoader2Rules, color, createLoaderContextTrap, extractLoaderName, filesize, getDocument, getLoaderNameMatch, getSDK, interceptCompilationHooks, interceptCompilerHooks, isESMLoader, loadLoaderModule, logger_time, mapEachRules, parseBundle, parseQuery, parser, rsdoctorLogger as logger, setSDK, stringify, timeEnd };
|