@rsdoctor/core 2.0.0-alpha.0 → 2.0.0-alpha.1
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/build-utils/build/chunks/assetsModules.d.ts +1 -1
- package/dist/build-utils/build/chunks/assetsModules.js +1 -1
- package/dist/build-utils/build/chunks/index.d.ts +0 -1
- package/dist/build-utils/build/chunks/index.js +0 -1
- package/dist/build-utils/build/chunks/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/chunks/rspack/transform.js +1 -1
- package/dist/build-utils/build/envinfo.d.ts +13 -0
- package/dist/build-utils/build/envinfo.js +60 -0
- package/dist/build-utils/build/file/cache.d.ts +5 -0
- package/dist/build-utils/build/file/cache.js +24 -0
- package/dist/build-utils/build/file/index.d.ts +3 -0
- package/dist/build-utils/build/file/index.js +5 -0
- package/dist/build-utils/build/file/sharding.d.ts +21 -0
- package/dist/build-utils/build/file/sharding.js +38 -0
- package/dist/build-utils/build/index.d.ts +5 -0
- package/dist/build-utils/build/index.js +11 -6
- package/dist/build-utils/build/json.d.ts +3 -0
- package/dist/build-utils/build/json.js +67 -0
- package/dist/build-utils/build/loader/probeLoader.d.ts +2 -2
- package/dist/build-utils/build/loader/probeLoader.js +4 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.ts +1 -1
- package/dist/build-utils/build/loader/probeLoaderPlugin.js +1 -1
- package/dist/build-utils/build/module-graph/index.d.ts +0 -1
- package/dist/build-utils/build/module-graph/index.js +0 -1
- package/dist/build-utils/build/module-graph/parser.d.ts +1 -1
- package/dist/build-utils/build/module-graph/parser.js +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.d.ts +1 -1
- package/dist/build-utils/build/module-graph/rspack/transform.js +6 -4
- package/dist/build-utils/build/module-graph/utils.d.ts +1 -1
- package/dist/build-utils/build/module-graph/utils.js +5 -4
- package/dist/build-utils/build/process.d.ts +2 -0
- package/dist/build-utils/build/process.js +18 -0
- package/dist/build-utils/build/server.d.ts +15 -0
- package/dist/build-utils/build/server.js +107 -0
- package/dist/build-utils/build/utils/loader.d.ts +2 -2
- package/dist/build-utils/build/utils/loader.js +10 -19
- package/dist/build-utils/build/utils/parseBundle.d.ts +1 -1
- package/dist/build-utils/build/utils/parseBundle.js +6 -8
- package/dist/build-utils/build/utils/plugin.d.ts +1 -1
- package/dist/build-utils/index.d.ts +10 -0
- package/dist/build-utils/index.js +12 -2
- package/dist/collection.d.ts +1 -0
- package/dist/collection.js +2 -0
- package/dist/common/file.d.ts +2 -0
- package/dist/common/file.js +8 -0
- package/dist/common/global-config.d.ts +21 -0
- package/dist/common/global-config.js +33 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +6 -0
- package/dist/common-browser.d.ts +1 -0
- package/dist/common-browser.js +2 -0
- package/dist/error/error.d.ts +35 -0
- package/dist/error/error.js +143 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +3 -0
- package/dist/error/transform.d.ts +3 -0
- package/dist/error/transform.js +138 -0
- package/dist/error/utils.d.ts +4 -0
- package/dist/error/utils.js +23 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/graph/index.js +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/inner-plugins/loaders/proxy.d.ts +4 -4
- package/dist/inner-plugins/plugins/base.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.d.ts +1 -1
- package/dist/inner-plugins/plugins/bundle.js +3 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +3 -3
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +11 -39
- package/dist/inner-plugins/plugins/errors.d.ts +2 -2
- package/dist/inner-plugins/plugins/errors.js +3 -3
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/loader.js +7 -19
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.js +2 -2
- package/dist/inner-plugins/plugins/progress.d.ts +2 -2
- package/dist/inner-plugins/plugins/progress.js +2 -2
- package/dist/inner-plugins/plugins/resolver.d.ts +1 -1
- package/dist/inner-plugins/plugins/resolver.js +2 -2
- package/dist/inner-plugins/plugins/rspack.d.ts +8 -3
- package/dist/inner-plugins/plugins/rspack.js +18 -4
- package/dist/inner-plugins/plugins/rules.d.ts +1 -1
- package/dist/inner-plugins/plugins/rules.js +3 -3
- package/dist/inner-plugins/plugins/sourcemapTool.d.ts +2 -2
- package/dist/inner-plugins/plugins/sourcemapTool.js +2 -2
- package/dist/inner-plugins/plugins/summary.d.ts +1 -1
- package/dist/inner-plugins/plugins/summary.js +3 -3
- package/dist/inner-plugins/utils/config.d.ts +2 -3
- package/dist/inner-plugins/utils/config.js +16 -17
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/loader.js +8 -34
- 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/openBrowser.js +55 -0
- package/dist/inner-plugins/utils/plugin-common.js +4 -4
- package/dist/inner-plugins/utils/plugin.d.ts +1 -1
- package/dist/inner-plugins/utils/plugin.js +1 -1
- package/dist/inner-plugins/utils/sdk.d.ts +2 -3
- package/dist/inner-plugins/utils/sdk.js +2 -2
- package/dist/logger.d.ts +9 -0
- package/dist/logger.js +51 -0
- package/dist/{inner-plugins/constants.d.cts → rspack-plugin/constants.d.ts} +3 -0
- package/dist/rspack-plugin/constants.js +23 -0
- package/dist/rspack-plugin/index.d.ts +2 -0
- package/dist/rspack-plugin/index.js +3 -0
- package/dist/rspack-plugin/multiple.d.ts +8 -0
- package/dist/rspack-plugin/multiple.js +39 -0
- package/dist/rspack-plugin/plugin.d.ts +25 -0
- package/dist/rspack-plugin/plugin.js +133 -0
- package/dist/rule-utils/document/document.d.ts +16 -0
- package/dist/rule-utils/document/document.js +46 -0
- package/dist/rule-utils/document/index.d.ts +3 -0
- package/dist/rule-utils/document/index.js +4 -0
- package/dist/rule-utils/document/server.d.ts +4 -0
- package/dist/rule-utils/document/server.js +13 -0
- package/dist/rule-utils/document/types.d.ts +31 -0
- package/dist/rule-utils/index.d.ts +2 -0
- package/dist/rule-utils/index.js +3 -0
- package/dist/rule-utils/parser/asserts.d.ts +81 -0
- package/dist/rule-utils/parser/asserts.js +105 -0
- package/dist/rule-utils/parser/index.d.ts +4 -0
- package/dist/rule-utils/parser/index.js +5 -0
- package/dist/rule-utils/parser/parser.d.ts +118 -0
- package/dist/rule-utils/parser/parser.js +24 -0
- package/dist/rule-utils/parser/types.d.ts +30 -0
- package/dist/rule-utils/parser/types.js +8 -0
- package/dist/rule-utils/parser/utils.d.ts +30 -0
- package/dist/rule-utils/parser/utils.js +106 -0
- package/dist/rules/linter.d.ts +1 -1
- package/dist/rules/linter.js +1 -1
- package/dist/rules/rule.d.ts +2 -2
- package/dist/rules/rule.js +2 -2
- package/dist/rules/rules/cjs-require/index.d.ts +1 -1
- package/dist/rules/rules/cjs-require/index.js +1 -1
- package/dist/rules/rules/cross-chunks-package/index.d.ts +1 -1
- package/dist/rules/rules/cross-chunks-package/index.js +2 -2
- package/dist/rules/rules/default-import-check/index.d.ts +1 -1
- package/dist/rules/rules/default-import-check/index.js +2 -2
- package/dist/rules/rules/default-import-check/utils.d.ts +2 -2
- package/dist/rules/rules/default-import-check/utils.js +2 -2
- package/dist/rules/rules/duplicate-package/index.d.ts +3 -3
- package/dist/rules/rules/duplicate-package/index.js +3 -3
- package/dist/rules/rules/duplicate-package/utils.d.ts +1 -1
- package/dist/rules/rules/ecma-version-check/index.d.ts +3 -2
- package/dist/rules/rules/ecma-version-check/index.js +1 -1
- package/dist/rules/rules/ecma-version-check/types.d.ts +1 -2
- 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/esm-resolved-to-cjs/index.js +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/index.js +2 -2
- 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/module-mixed-chunks/index.js +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +1 -1
- package/dist/rules/utils.d.ts +1 -1
- package/dist/rules/utils.js +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +3 -0
- package/dist/sdk/multiple/controller.d.ts +12 -0
- package/dist/sdk/multiple/controller.js +42 -0
- package/dist/sdk/multiple/index.d.ts +2 -0
- package/dist/sdk/multiple/index.js +3 -0
- package/dist/sdk/multiple/primary.d.ts +32 -0
- package/dist/sdk/multiple/primary.js +64 -0
- package/dist/sdk/multiple/server.d.ts +7 -0
- package/dist/sdk/multiple/server.js +14 -0
- package/dist/sdk/sdk/core.d.ts +33 -0
- package/dist/sdk/sdk/core.js +163 -0
- package/dist/sdk/sdk/index.d.ts +52 -0
- package/dist/sdk/sdk/index.js +435 -0
- package/dist/sdk/sdk/types.d.ts +26 -0
- package/dist/sdk/sdk/types.js +1 -0
- package/dist/sdk/server/apis/alerts.d.ts +5 -0
- package/dist/sdk/server/apis/alerts.js +30 -0
- package/dist/sdk/server/apis/base.d.ts +11 -0
- package/dist/sdk/server/apis/base.js +22 -0
- package/dist/sdk/server/apis/bundle-diff.d.ts +6 -0
- package/dist/sdk/server/apis/bundle-diff.js +51 -0
- package/dist/sdk/server/apis/data.d.ts +6 -0
- package/dist/sdk/server/apis/data.js +44 -0
- package/dist/sdk/server/apis/fs.d.ts +5 -0
- package/dist/sdk/server/apis/fs.js +28 -0
- package/dist/sdk/server/apis/graph.d.ts +12 -0
- package/dist/sdk/server/apis/graph.js +116 -0
- package/dist/sdk/server/apis/index.d.ts +10 -0
- package/dist/sdk/server/apis/index.js +11 -0
- package/dist/sdk/server/apis/loader.d.ts +15 -0
- package/dist/sdk/server/apis/loader.js +120 -0
- package/dist/sdk/server/apis/plugin.d.ts +6 -0
- package/dist/sdk/server/apis/plugin.js +39 -0
- package/dist/sdk/server/apis/project.d.ts +8 -0
- package/dist/sdk/server/apis/project.js +59 -0
- package/dist/sdk/server/apis/renderer.d.ts +6 -0
- package/dist/sdk/server/apis/renderer.js +33 -0
- package/dist/sdk/server/apis/resolver.d.ts +6 -0
- package/dist/sdk/server/apis/resolver.js +38 -0
- package/dist/sdk/server/client.d.ts +3 -0
- package/dist/sdk/server/client.js +8 -0
- package/dist/sdk/server/fakeServer.d.ts +9 -0
- package/dist/sdk/server/fakeServer.js +12 -0
- package/dist/sdk/server/index.d.ts +44 -0
- package/dist/sdk/server/index.js +292 -0
- package/dist/sdk/server/json-body.d.ts +6 -0
- package/dist/sdk/server/json-body.js +150 -0
- package/dist/sdk/server/router.d.ts +24 -0
- package/dist/sdk/server/router.js +83 -0
- package/dist/sdk/server/security.d.ts +5 -0
- package/dist/sdk/server/security.js +47 -0
- package/dist/sdk/server/socket/api.d.ts +15 -0
- package/dist/sdk/server/socket/api.js +22 -0
- package/dist/sdk/server/socket/index.d.ts +48 -0
- package/dist/sdk/server/socket/index.js +166 -0
- package/dist/sdk/server/utils.d.ts +6 -0
- package/dist/sdk/server/utils.js +19 -0
- package/dist/sdk/utils/base.d.ts +1 -0
- package/dist/sdk/utils/base.js +22 -0
- package/dist/sdk/utils/constant.d.ts +1 -0
- package/dist/sdk/utils/constant.js +4 -0
- package/dist/sdk/utils/index.d.ts +3 -0
- package/dist/sdk/utils/index.js +4 -0
- package/dist/sdk/utils/openBrowser.d.ts +4 -0
- package/dist/sdk/utils/openBrowser.js +53 -0
- package/dist/sdk/utils/upload.d.ts +2 -0
- package/dist/sdk/utils/upload.js +6 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +2 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/loader.d.ts +1 -1
- package/dist/types/plugin.d.ts +7 -28
- package/package.json +127 -58
- 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/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/rspack/transform.cjs +0 -80
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/index.cjs +0 -52
- package/dist/build-utils/build/index.d.cts +0 -5
- 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/probeLoader.cjs +0 -89
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- 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/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/parser.cjs +0 -46
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- 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/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/utils/index.cjs +0 -72
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- 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/parseBundle.cjs +0 -283
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- 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/index.cjs +0 -36
- package/dist/build-utils/index.d.cts +0 -1
- 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/index.cjs +0 -65
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/loaders/proxy.cjs +0 -104
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/plugins/base.cjs +0 -53
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/bundle.cjs +0 -96
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -141
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -34
- package/dist/inner-plugins/plugins/errors.cjs +0 -98
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/index.cjs +0 -121
- package/dist/inner-plugins/plugins/index.d.cts +0 -10
- package/dist/inner-plugins/plugins/loader.cjs +0 -165
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/plugins.cjs +0 -73
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.cjs +0 -68
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/resolver.cjs +0 -90
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -12
- package/dist/inner-plugins/plugins/rspack.cjs +0 -118
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rules.cjs +0 -97
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -275
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/summary.cjs +0 -125
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -49
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/config.cjs +0 -191
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/index.cjs +0 -106
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/loader.cjs +0 -218
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- 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/plugin-common.cjs +0 -143
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin.cjs +0 -106
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/sdk.cjs +0 -55
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/rslib-runtime.js +0 -19
- package/dist/rules/index.cjs +0 -81
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/linter.cjs +0 -72
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/rule.cjs +0 -137
- package/dist/rules/rule.d.cts +0 -27
- 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/types.cjs +0 -18
- package/dist/rules/rules/cjs-require/types.d.cts +0 -7
- 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/types.cjs +0 -18
- package/dist/rules/rules/cross-chunks-package/types.d.cts +0 -3
- 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/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/types.cjs +0 -18
- package/dist/rules/rules/default-import-check/types.d.cts +0 -4
- 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/duplicate-package/index.cjs +0 -72
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- 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/utils.cjs +0 -84
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- 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/types.cjs +0 -18
- package/dist/rules/rules/ecma-version-check/types.d.cts +0 -3
- 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/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/types.cjs +0 -18
- package/dist/rules/rules/esm-resolved-to-cjs/types.d.cts +0 -8
- package/dist/rules/rules/index.cjs +0 -55
- package/dist/rules/rules/index.d.cts +0 -2
- 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/types.cjs +0 -18
- package/dist/rules/rules/loader-performance-optimization/types.d.cts +0 -22
- 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/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/types.cjs +0 -18
- package/dist/rules/rules/module-mixed-chunks/types.d.cts +0 -3
- 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/types.cjs +0 -18
- package/dist/rules/rules/side-effects-only-imports/types.d.cts +0 -9
- package/dist/rules/utils.cjs +0 -46
- package/dist/rules/utils.d.cts +0 -3
- 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/index.cjs +0 -79
- package/dist/types/index.d.cts +0 -4
- package/dist/types/loader.cjs +0 -18
- package/dist/types/loader.d.cts +0 -19
- package/dist/types/plugin.cjs +0 -18
- package/dist/types/plugin.d.cts +0 -51
- package/dist/types/rules.cjs +0 -18
- package/dist/types/rules.d.cts +0 -7
- /package/dist/{types/chunks.js → rule-utils/document/types.js} +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SDK } from '@rsdoctor/types';
|
|
1
|
+
import { SDK } from '@rsdoctor/shared/types';
|
|
3
2
|
declare global {
|
|
4
3
|
var __rsdoctor_sdks__: SDK.RsdoctorBuilderSDKInstance[] | undefined;
|
|
5
4
|
var __rsdoctor_sdk__: SDK.RsdoctorBuilderSDKInstance | undefined;
|
|
6
5
|
}
|
|
7
6
|
export declare function setSDK(t: SDK.RsdoctorBuilderSDKInstance): void;
|
|
8
|
-
export declare function getSDK(builderName?: string):
|
|
7
|
+
export declare function getSDK(builderName?: string): SDK.RsdoctorBuilderSDKInstance | undefined;
|
|
@@ -10,8 +10,8 @@ function getSDK(builderName) {
|
|
|
10
10
|
let sdk = globalThis['__rsdoctor_sdk__'];
|
|
11
11
|
if (sdk && sdk.name !== builderName) sdk = builderName ? sdks.find((s)=>s.name === builderName) || sdk : sdk;
|
|
12
12
|
if (sdk && builderName && 'parent' in sdk) {
|
|
13
|
-
const
|
|
14
|
-
const slaveSDK =
|
|
13
|
+
const parent = sdk.parent;
|
|
14
|
+
const slaveSDK = parent?.slaves.find((_sdk)=>_sdk.name === builderName);
|
|
15
15
|
return slaveSDK || sdk;
|
|
16
16
|
}
|
|
17
17
|
return sdk;
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import c from 'picocolors';
|
|
2
|
+
/**
|
|
3
|
+
* log debug message
|
|
4
|
+
*/
|
|
5
|
+
export declare function debug(getMsg: () => string, prefix?: string): void;
|
|
6
|
+
declare const rsdoctorLogger: import("rslog").Logger;
|
|
7
|
+
declare function time(label: string): void;
|
|
8
|
+
declare function timeEnd(label: string): void;
|
|
9
|
+
export { time, timeEnd, c as chalk, rsdoctorLogger as logger };
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import picocolors from "picocolors";
|
|
3
|
+
import { createLogger, logger } from "rslog";
|
|
4
|
+
import { Constants } from "@rsdoctor/shared/types";
|
|
5
|
+
function debug(getMsg, prefix = '') {
|
|
6
|
+
if (!process.env.DEBUG) return;
|
|
7
|
+
logger.level = 'verbose';
|
|
8
|
+
logger.debug(`${prefix} ${getMsg()}`);
|
|
9
|
+
}
|
|
10
|
+
const rsdoctorLogger = createLogger();
|
|
11
|
+
rsdoctorLogger.override({
|
|
12
|
+
log: (message)=>{
|
|
13
|
+
console.log(`${picocolors.green('[RSDOCTOR LOG]')} ${message}`);
|
|
14
|
+
},
|
|
15
|
+
info: (message)=>{
|
|
16
|
+
console.log(`${picocolors.yellow('[RSDOCTOR INFO]')} ${message}`);
|
|
17
|
+
},
|
|
18
|
+
warn: (message)=>{
|
|
19
|
+
console.warn(`${picocolors.yellow('[RSDOCTOR WARN]')} ${message}`);
|
|
20
|
+
},
|
|
21
|
+
start: (message)=>{
|
|
22
|
+
console.log(`${picocolors.green('[RSDOCTOR START]')} ${message}`);
|
|
23
|
+
},
|
|
24
|
+
ready: (message)=>{
|
|
25
|
+
console.log(`${picocolors.green('[RSDOCTOR READY]')} ${message}`);
|
|
26
|
+
},
|
|
27
|
+
error: (message)=>{
|
|
28
|
+
console.error(`${picocolors.red('[RSDOCTOR ERROR]')} ${message}`);
|
|
29
|
+
},
|
|
30
|
+
success: (message)=>{
|
|
31
|
+
console.error(`${picocolors.green('[RSDOCTOR SUCCESS]')} ${message}`);
|
|
32
|
+
},
|
|
33
|
+
debug: (message)=>{
|
|
34
|
+
if (process.env.DEBUG) console.log(`${picocolors.blue('[RSDOCTOR DEBUG]')} ${message}`);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const _timers = new Map();
|
|
38
|
+
function time(label) {
|
|
39
|
+
if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
|
|
40
|
+
if (_timers.has(label)) return;
|
|
41
|
+
_timers.set(label, Date.now());
|
|
42
|
+
}
|
|
43
|
+
function timeEnd(label) {
|
|
44
|
+
if (process.env.DEBUG !== Constants.RsdoctorProcessEnvDebugKey) return;
|
|
45
|
+
const start = _timers.get(label);
|
|
46
|
+
if (null == start) return void logger.debug(`Timer '${label}' does not exist.`);
|
|
47
|
+
const duration = Date.now() - start;
|
|
48
|
+
logger.debug(`Timer '${label}' ended: ${duration}ms`);
|
|
49
|
+
_timers.delete(label);
|
|
50
|
+
}
|
|
51
|
+
export { debug, picocolors as chalk, rsdoctorLogger as logger, time, timeEnd };
|
|
@@ -4,3 +4,6 @@ export declare const pluginTapPostOptions: Tap;
|
|
|
4
4
|
export declare const pluginTapPreOptions: Tap;
|
|
5
5
|
export declare const internalPluginTapPreOptions: (namespace: string) => Tap;
|
|
6
6
|
export declare const internalPluginTapPostOptions: (namespace: string) => Tap;
|
|
7
|
+
export declare const pkg: {
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const constants_require = createRequire(import.meta.url);
|
|
4
|
+
const packageJson = constants_require('../../package.json');
|
|
5
|
+
const pluginTapName = 'RsdoctorRspackPlugin';
|
|
6
|
+
const pluginTapPostOptions = {
|
|
7
|
+
name: pluginTapName,
|
|
8
|
+
stage: 999
|
|
9
|
+
};
|
|
10
|
+
const pluginTapPreOptions = {
|
|
11
|
+
name: pluginTapName,
|
|
12
|
+
stage: -999
|
|
13
|
+
};
|
|
14
|
+
const internalPluginTapPreOptions = (namespace)=>({
|
|
15
|
+
name: `${pluginTapName}:${namespace}`,
|
|
16
|
+
stage: -998
|
|
17
|
+
});
|
|
18
|
+
const internalPluginTapPostOptions = (namespace)=>({
|
|
19
|
+
name: `${pluginTapName}:${namespace}`,
|
|
20
|
+
stage: 1000
|
|
21
|
+
});
|
|
22
|
+
const pkg = packageJson;
|
|
23
|
+
export { internalPluginTapPostOptions, internalPluginTapPreOptions, pkg, pluginTapName, pluginTapPostOptions, pluginTapPreOptions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { RsdoctorMultiplePluginOptions } from '../types/index.js';
|
|
2
|
+
import { type Linter, type Plugin } from '@rsdoctor/shared/types';
|
|
3
|
+
import { RsdoctorRspackPlugin } from './plugin.js';
|
|
4
|
+
export declare class RsdoctorRspackMultiplePlugin<Rules extends Linter.ExtendRuleData[]> extends RsdoctorRspackPlugin<Rules> {
|
|
5
|
+
private controller;
|
|
6
|
+
constructor(options?: RsdoctorMultiplePluginOptions<Rules>);
|
|
7
|
+
apply(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { RsdoctorSDKController } from "../sdk.js";
|
|
3
|
+
import { SDK } from "@rsdoctor/shared/types";
|
|
4
|
+
import { normalizeUserConfig } from "../inner-plugins/index.js";
|
|
5
|
+
import { RsdoctorRspackPlugin } from "./plugin.js";
|
|
6
|
+
let globalController;
|
|
7
|
+
class RsdoctorRspackMultiplePlugin extends RsdoctorRspackPlugin {
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
if ('dependencies' in compiler.options) this.sdk.dependencies = compiler.options.dependencies;
|
|
10
|
+
super.apply(compiler);
|
|
11
|
+
}
|
|
12
|
+
constructor(options = {}){
|
|
13
|
+
const controller = (()=>{
|
|
14
|
+
if (globalController) return globalController;
|
|
15
|
+
const controller = new RsdoctorSDKController();
|
|
16
|
+
globalController = controller;
|
|
17
|
+
return controller;
|
|
18
|
+
})();
|
|
19
|
+
const normallizedOptions = normalizeUserConfig(options);
|
|
20
|
+
const instance = controller.createSlave({
|
|
21
|
+
name: options.name || 'Builder',
|
|
22
|
+
stage: options.stage,
|
|
23
|
+
extraConfig: {
|
|
24
|
+
innerClientPath: normallizedOptions.innerClientPath,
|
|
25
|
+
printLog: normallizedOptions.printLog,
|
|
26
|
+
server: normallizedOptions.server,
|
|
27
|
+
mode: normallizedOptions.output.mode ? normallizedOptions.output.mode : void 0,
|
|
28
|
+
brief: normallizedOptions.output.mode === SDK.IMode[SDK.IMode.brief] ? normallizedOptions.output.options || void 0 : void 0
|
|
29
|
+
},
|
|
30
|
+
type: normallizedOptions.output.reportCodeType
|
|
31
|
+
});
|
|
32
|
+
super({
|
|
33
|
+
...options,
|
|
34
|
+
sdkInstance: instance
|
|
35
|
+
});
|
|
36
|
+
this.controller = controller;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export { RsdoctorRspackMultiplePlugin };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RsdoctorRspackPluginInstance, RsdoctorRspackPluginOptions, RsdoctorRspackPluginOptionsNormalized } from '../types/index.js';
|
|
2
|
+
import { RsdoctorPrimarySDK } from '../sdk/index.js';
|
|
3
|
+
import { Linter, Plugin, SDK } from '@rsdoctor/shared/types';
|
|
4
|
+
export declare class RsdoctorRspackPlugin<Rules extends Linter.ExtendRuleData[]> implements RsdoctorRspackPluginInstance<Rules> {
|
|
5
|
+
readonly name = "RsdoctorRspackPlugin";
|
|
6
|
+
readonly sdk: SDK.RsdoctorBuilderSDKInstance | RsdoctorPrimarySDK;
|
|
7
|
+
readonly isRsdoctorPlugin: boolean;
|
|
8
|
+
_bootstrapTask: Promise<unknown>;
|
|
9
|
+
protected browserIsOpened: boolean;
|
|
10
|
+
modulesGraph: SDK.ModuleGraphInstance;
|
|
11
|
+
options: RsdoctorRspackPluginOptionsNormalized<Rules>;
|
|
12
|
+
outsideInstance: boolean;
|
|
13
|
+
constructor(options?: RsdoctorRspackPluginOptions<Rules>);
|
|
14
|
+
apply(compiler: unknown): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* @description Generate ModuleGraph and ChunkGraph from the Rspack native plugin.
|
|
17
|
+
* @param {Compiler} compiler
|
|
18
|
+
* @return {*}
|
|
19
|
+
* @memberof RsdoctorRspackPlugin
|
|
20
|
+
*/
|
|
21
|
+
ensureModulesChunksGraphApplied(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
22
|
+
afterPlugins: (compiler: Plugin.BaseCompilerType<'rspack'>) => void;
|
|
23
|
+
done: (compiler: Plugin.BaseCompilerType<'rspack'>) => Promise<void>;
|
|
24
|
+
getRspackConfig(compiler: Plugin.BaseCompilerType<'rspack'>): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { Loader } from "../build-utils/index.js";
|
|
3
|
+
import { InternalBundlePlugin, InternalErrorReporterPlugin, InternalLoaderPlugin, InternalPluginsPlugin, InternalResolverPlugin, InternalRulesPlugin, InternalSummaryPlugin, ensureModulesChunksGraphFn, handleBriefModeReport, normalizeRspackUserOptions, processCompilerConfig, setSDK } from "../inner-plugins/index.js";
|
|
4
|
+
import { RsdoctorSDK, findRoot } from "../sdk.js";
|
|
5
|
+
import { Constants, Manifest, SDK } from "@rsdoctor/shared/types";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { pkg, pluginTapName, pluginTapPostOptions } from "./constants.js";
|
|
8
|
+
import { ModuleGraph } from "../graph/index.js";
|
|
9
|
+
import { Loader as index_js_Loader } from "../common/index.js";
|
|
10
|
+
import { logger, time, timeEnd } from "../logger.js";
|
|
11
|
+
import { getRspackNativePlugin } from "../inner-plugins/plugins/rspack.js";
|
|
12
|
+
let hasGreeted = false;
|
|
13
|
+
class RsdoctorRspackPlugin {
|
|
14
|
+
apply(compiler) {
|
|
15
|
+
time('RsdoctorRspackPlugin.apply');
|
|
16
|
+
try {
|
|
17
|
+
if (!hasGreeted && !compiler.isChild()) {
|
|
18
|
+
hasGreeted = true;
|
|
19
|
+
logger.greet(`
|
|
20
|
+
\nRsdoctor v${pkg.version}\n`);
|
|
21
|
+
}
|
|
22
|
+
if (!this._bootstrapTask) this._bootstrapTask = this.sdk.bootstrap();
|
|
23
|
+
if (compiler.options.name) this.sdk.setName(compiler.options.name);
|
|
24
|
+
setSDK(this.sdk);
|
|
25
|
+
compiler.hooks.afterPlugins.tap(pluginTapPostOptions, this.afterPlugins.bind(this, compiler));
|
|
26
|
+
compiler.hooks.done.tapPromise({
|
|
27
|
+
...pluginTapPostOptions,
|
|
28
|
+
stage: pluginTapPostOptions.stage + 100
|
|
29
|
+
}, this.done.bind(this, compiler));
|
|
30
|
+
new InternalSummaryPlugin(this).apply(compiler);
|
|
31
|
+
if (this.options.features.loader) {
|
|
32
|
+
new Loader.ProbeLoaderPlugin().apply(compiler);
|
|
33
|
+
this.sdk.addClientRoutes([
|
|
34
|
+
Manifest.RsdoctorManifestClientRoutes.Loaders
|
|
35
|
+
]);
|
|
36
|
+
if (!index_js_Loader.isVue(compiler)) new InternalLoaderPlugin(this).apply(compiler);
|
|
37
|
+
}
|
|
38
|
+
if (this.options.features.plugins) new InternalPluginsPlugin(this).apply(compiler);
|
|
39
|
+
if (this.options.features.bundle) new InternalBundlePlugin(this).apply(compiler);
|
|
40
|
+
if (this.options.features.resolver) new InternalResolverPlugin(this).apply(compiler);
|
|
41
|
+
new InternalRulesPlugin(this).apply(compiler);
|
|
42
|
+
new InternalErrorReporterPlugin(this).apply(compiler);
|
|
43
|
+
const RsdoctorRspackNativePlugin = getRspackNativePlugin(compiler);
|
|
44
|
+
logger.debug('[RspackNativePlugin] Enabled');
|
|
45
|
+
new RsdoctorRspackNativePlugin({
|
|
46
|
+
moduleGraphFeatures: true,
|
|
47
|
+
chunkGraphFeatures: true,
|
|
48
|
+
sourceMapFeatures: {
|
|
49
|
+
cheap: false,
|
|
50
|
+
module: false
|
|
51
|
+
}
|
|
52
|
+
}).apply(compiler);
|
|
53
|
+
} finally{
|
|
54
|
+
timeEnd('RsdoctorRspackPlugin.apply');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
ensureModulesChunksGraphApplied(compiler) {
|
|
58
|
+
ensureModulesChunksGraphFn(compiler, this);
|
|
59
|
+
}
|
|
60
|
+
getRspackConfig(compiler) {
|
|
61
|
+
time('RsdoctorRspackPlugin.getRspackConfig');
|
|
62
|
+
try {
|
|
63
|
+
if (compiler.isChild()) return;
|
|
64
|
+
const configuration = processCompilerConfig(compiler.options);
|
|
65
|
+
const rspackVersion = compiler.webpack?.rspackVersion || compiler.webpack?.version;
|
|
66
|
+
this.sdk.reportConfiguration({
|
|
67
|
+
name: 'rspack',
|
|
68
|
+
version: rspackVersion || 'unknown',
|
|
69
|
+
config: configuration,
|
|
70
|
+
root: findRoot() || ''
|
|
71
|
+
});
|
|
72
|
+
} finally{
|
|
73
|
+
timeEnd('RsdoctorRspackPlugin.getRspackConfig');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
constructor(options){
|
|
77
|
+
this.name = pluginTapName;
|
|
78
|
+
this.browserIsOpened = false;
|
|
79
|
+
this.afterPlugins = (compiler)=>{
|
|
80
|
+
time('RsdoctorRspackPlugin.afterPlugins');
|
|
81
|
+
try {
|
|
82
|
+
this.getRspackConfig(compiler);
|
|
83
|
+
} finally{
|
|
84
|
+
timeEnd('RsdoctorRspackPlugin.afterPlugins');
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
this.done = async (compiler)=>{
|
|
88
|
+
time('RsdoctorRspackPlugin.done');
|
|
89
|
+
try {
|
|
90
|
+
logger.debug('[RsdoctorRspackPlugin] bootstrap(start) in done()');
|
|
91
|
+
await this.sdk.bootstrap();
|
|
92
|
+
logger.debug('[RsdoctorRspackPlugin] bootstrap(end) in done()');
|
|
93
|
+
this.sdk.addClientRoutes([
|
|
94
|
+
Manifest.RsdoctorManifestClientRoutes.Overall
|
|
95
|
+
]);
|
|
96
|
+
if (this.outsideInstance && 'parent' in this.sdk) this.sdk.parent.master.setOutputDir(path.resolve(this.options.output.reportDir || compiler.outputPath, this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? '' : `./${Constants.RsdoctorOutputFolder}`));
|
|
97
|
+
this.sdk.setOutputDir(path.resolve(this.options.output.reportDir || compiler.outputPath, this.options.output.mode === SDK.IMode[SDK.IMode.brief] ? '' : `./${Constants.RsdoctorOutputFolder}`));
|
|
98
|
+
await this.sdk.writeStore();
|
|
99
|
+
if (!this.options.disableClientServer) if (this.options.output.mode === SDK.IMode[SDK.IMode.brief]) await handleBriefModeReport(this.sdk, this.options, this.options.disableClientServer);
|
|
100
|
+
else await this.sdk.server.openClientPage('homepage');
|
|
101
|
+
if (this.options.disableClientServer || this.options.output.mode === SDK.IMode[SDK.IMode.brief] && Array.isArray(this.options.output.options?.type) && 1 === this.options.output.options.type.length && 'json' === this.options.output.options.type[0]) await this.sdk.dispose();
|
|
102
|
+
} finally{
|
|
103
|
+
timeEnd('RsdoctorRspackPlugin.done');
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
this.options = normalizeRspackUserOptions(Object.assign(options || {}, {
|
|
107
|
+
supports: {
|
|
108
|
+
...options?.supports
|
|
109
|
+
}
|
|
110
|
+
}));
|
|
111
|
+
const { port, server, output, innerClientPath, printLog, sdkInstance } = this.options;
|
|
112
|
+
this.sdk = this.options.sdkInstance ?? new RsdoctorSDK({
|
|
113
|
+
port,
|
|
114
|
+
name: pluginTapName,
|
|
115
|
+
root: process.cwd(),
|
|
116
|
+
type: output.reportCodeType,
|
|
117
|
+
config: {
|
|
118
|
+
innerClientPath,
|
|
119
|
+
printLog,
|
|
120
|
+
server,
|
|
121
|
+
mode: output.mode ? output.mode : void 0,
|
|
122
|
+
brief: output.mode === SDK.IMode[SDK.IMode.brief] ? output.options || void 0 : void 0,
|
|
123
|
+
features: {
|
|
124
|
+
treeShaking: this.options.features.treeShaking
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
this.outsideInstance = Boolean(sdkInstance);
|
|
129
|
+
this.modulesGraph = new ModuleGraph();
|
|
130
|
+
this.isRsdoctorPlugin = true;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export { RsdoctorRspackPlugin };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Range, OffsetRange, Position, DocumentEditData } from './types.js';
|
|
2
|
+
/** Document Catalogue */
|
|
3
|
+
export declare class Document {
|
|
4
|
+
/** Actual document content. */
|
|
5
|
+
private _text;
|
|
6
|
+
/** Get the displacement of the file position in the text. */
|
|
7
|
+
positionAt: (offset: number) => Position | undefined;
|
|
8
|
+
/** Get the position of the displacement point in the file. */
|
|
9
|
+
offsetAt: (position: Position) => number | undefined;
|
|
10
|
+
constructor(content: string);
|
|
11
|
+
/** Generate location search */
|
|
12
|
+
private createFinder;
|
|
13
|
+
getText(range?: Range | OffsetRange): string;
|
|
14
|
+
/** Edit document data */
|
|
15
|
+
edit(data: DocumentEditData): string | undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { Lodash } from "../../common/index.js";
|
|
3
|
+
import { LinesAndColumns } from "lines-and-columns";
|
|
4
|
+
class Document {
|
|
5
|
+
createFinder() {
|
|
6
|
+
const find = new LinesAndColumns(this._text);
|
|
7
|
+
this.positionAt = (offset)=>{
|
|
8
|
+
if (offset >= this._text.length) offset = this._text.length - 1;
|
|
9
|
+
if (offset < 0) offset = 0;
|
|
10
|
+
const result = find.locationForIndex(offset);
|
|
11
|
+
if (!result) return;
|
|
12
|
+
return {
|
|
13
|
+
line: result.line + 1,
|
|
14
|
+
column: result.column
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
this.offsetAt = (position)=>find.indexForLocation({
|
|
18
|
+
line: position.line - 1,
|
|
19
|
+
column: position.column
|
|
20
|
+
}) ?? void 0;
|
|
21
|
+
}
|
|
22
|
+
getText(range) {
|
|
23
|
+
if (!range) return this._text;
|
|
24
|
+
const start = 'number' == typeof range.start ? range.start : this.offsetAt(range.start);
|
|
25
|
+
const end = 'number' == typeof range.end ? range.end : this.offsetAt(range.end);
|
|
26
|
+
if (Lodash.isUndefined(start)) throw new Error(`Location ${JSON.stringify(start)} is illegal`);
|
|
27
|
+
if (Lodash.isUndefined(end)) throw new Error(`Location ${JSON.stringify(end)} is illegal`);
|
|
28
|
+
return this._text.slice(start, end);
|
|
29
|
+
}
|
|
30
|
+
edit(data) {
|
|
31
|
+
let { _text: content } = this;
|
|
32
|
+
const startOffset = Lodash.isNumber(data.start) ? data.start : this.offsetAt(data.start);
|
|
33
|
+
const endOffset = Lodash.isNumber(data.end) ? data.end : this.offsetAt(data.end);
|
|
34
|
+
if (Lodash.isUndefined(startOffset) || Lodash.isUndefined(endOffset)) return;
|
|
35
|
+
const startTxt = content.substring(0, startOffset);
|
|
36
|
+
const endTxt = content.substring(endOffset, content.length);
|
|
37
|
+
content = startTxt + data.newText + endTxt;
|
|
38
|
+
return content;
|
|
39
|
+
}
|
|
40
|
+
constructor(content){
|
|
41
|
+
this._text = '';
|
|
42
|
+
this._text = content;
|
|
43
|
+
this.createFinder();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export { Document };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { Document } from "./document.js";
|
|
3
|
+
const store = new Map();
|
|
4
|
+
function getDocument(content) {
|
|
5
|
+
if (store.has(content)) return store.get(content);
|
|
6
|
+
const doc = new Document(content);
|
|
7
|
+
store.set(content, doc);
|
|
8
|
+
return doc;
|
|
9
|
+
}
|
|
10
|
+
function clearDocument() {
|
|
11
|
+
store.clear();
|
|
12
|
+
}
|
|
13
|
+
export { clearDocument, getDocument };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Location
|
|
3
|
+
* - line starting point is 1
|
|
4
|
+
* - column starting point is 0
|
|
5
|
+
*/
|
|
6
|
+
export interface Position {
|
|
7
|
+
line: number;
|
|
8
|
+
column: number;
|
|
9
|
+
}
|
|
10
|
+
/** Location range */
|
|
11
|
+
export interface Range {
|
|
12
|
+
start: Position;
|
|
13
|
+
end: Position;
|
|
14
|
+
}
|
|
15
|
+
/** Offset range */
|
|
16
|
+
export interface OffsetRange {
|
|
17
|
+
start: number;
|
|
18
|
+
end: number;
|
|
19
|
+
}
|
|
20
|
+
/** Text repair data */
|
|
21
|
+
export interface DocumentEditData {
|
|
22
|
+
/** Modify the starting position of string in the original text */
|
|
23
|
+
start: number | Position;
|
|
24
|
+
/** Modify string in the key position of the original text */
|
|
25
|
+
end: number | Position;
|
|
26
|
+
/**
|
|
27
|
+
* Replaced new text
|
|
28
|
+
* - If empty, delete the original text
|
|
29
|
+
*/
|
|
30
|
+
newText?: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Node } from './types.js';
|
|
2
|
+
export declare const asserts: {
|
|
3
|
+
readonly isProgram: (node: unknown) => node is Node.Program;
|
|
4
|
+
readonly isEmptyStatement: (node: unknown) => node is Node.EmptyStatement;
|
|
5
|
+
readonly isBlockStatement: (node: unknown) => node is Node.BlockStatement;
|
|
6
|
+
readonly isStaticBlock: (node: unknown) => node is Node.StaticBlock;
|
|
7
|
+
readonly isExpressionStatement: (node: unknown) => node is Node.ExpressionStatement;
|
|
8
|
+
readonly isIfStatement: (node: unknown) => node is Node.IfStatement;
|
|
9
|
+
readonly isLabeledStatement: (node: unknown) => node is Node.LabeledStatement;
|
|
10
|
+
readonly isBreakStatement: (node: unknown) => node is Node.BreakStatement;
|
|
11
|
+
readonly isContinueStatement: (node: unknown) => node is Node.ContinueStatement;
|
|
12
|
+
readonly isWithStatement: (node: unknown) => node is Node.WithStatement;
|
|
13
|
+
readonly isSwitchStatement: (node: unknown) => node is Node.SwitchStatement;
|
|
14
|
+
readonly isReturnStatement: (node: unknown) => node is Node.ReturnStatement;
|
|
15
|
+
readonly isThrowStatement: (node: unknown) => node is Node.ThrowStatement;
|
|
16
|
+
readonly isTryStatement: (node: unknown) => node is Node.TryStatement;
|
|
17
|
+
readonly isWhileStatement: (node: unknown) => node is Node.WhileStatement;
|
|
18
|
+
readonly isDoWhileStatement: (node: unknown) => node is Node.DoWhileStatement;
|
|
19
|
+
readonly isForStatement: (node: unknown) => node is Node.ForStatement;
|
|
20
|
+
readonly isForInStatement: (node: unknown) => node is Node.ForInStatement;
|
|
21
|
+
readonly isForOfStatement: (node: unknown) => node is Node.ForOfStatement;
|
|
22
|
+
readonly isDebuggerStatement: (node: unknown) => node is Node.DebuggerStatement;
|
|
23
|
+
readonly isFunctionDeclaration: (node: unknown) => node is Node.FunctionDeclaration;
|
|
24
|
+
readonly isVariableDeclaration: (node: unknown) => node is Node.VariableDeclaration;
|
|
25
|
+
readonly isVariableDeclarator: (node: unknown) => node is Node.VariableDeclarator;
|
|
26
|
+
readonly isChainExpression: (node: unknown) => node is Node.ChainExpression;
|
|
27
|
+
readonly isThisExpression: (node: unknown) => node is Node.ThisExpression;
|
|
28
|
+
readonly isArrayExpression: (node: unknown) => node is Node.ArrayExpression;
|
|
29
|
+
readonly isObjectExpression: (node: unknown) => node is Node.ObjectExpression;
|
|
30
|
+
readonly isPrivateIdentifier: (node: unknown) => node is Node.PrivateIdentifier;
|
|
31
|
+
readonly isProperty: (node: unknown) => node is Node.Property;
|
|
32
|
+
readonly isPropertyDefinition: (node: unknown) => node is Node.PropertyDefinition;
|
|
33
|
+
readonly isFunctionExpression: (node: unknown) => node is Node.FunctionExpression;
|
|
34
|
+
readonly isSequenceExpression: (node: unknown) => node is Node.SequenceExpression;
|
|
35
|
+
readonly isUnaryExpression: (node: unknown) => node is Node.UnaryExpression;
|
|
36
|
+
readonly isBinaryExpression: (node: unknown) => node is Node.BinaryExpression;
|
|
37
|
+
readonly isAssignmentExpression: (node: unknown) => node is Node.AssignmentExpression;
|
|
38
|
+
readonly isUpdateExpression: (node: unknown) => node is Node.UpdateExpression;
|
|
39
|
+
readonly isLogicalExpression: (node: unknown) => node is Node.LogicalExpression;
|
|
40
|
+
readonly isConditionalExpression: (node: unknown) => node is Node.ConditionalExpression;
|
|
41
|
+
readonly isNewExpression: (node: unknown) => node is Node.NewExpression;
|
|
42
|
+
readonly isSwitchCase: (node: unknown) => node is Node.SwitchCase;
|
|
43
|
+
readonly isCatchClause: (node: unknown) => node is Node.CatchClause;
|
|
44
|
+
readonly isIdentifier: (node: unknown) => node is Node.Identifier;
|
|
45
|
+
readonly isLiteral: (node: unknown) => node is Node.Literal;
|
|
46
|
+
readonly isSuper: (node: unknown) => node is Node.Super;
|
|
47
|
+
readonly isSpreadElement: (node: unknown) => node is Node.SpreadElement;
|
|
48
|
+
readonly isArrowFunctionExpression: (node: unknown) => node is Node.ArrowFunctionExpression;
|
|
49
|
+
readonly isYieldExpression: (node: unknown) => node is Node.YieldExpression;
|
|
50
|
+
readonly isTemplateLiteral: (node: unknown) => node is Node.TemplateLiteral;
|
|
51
|
+
readonly isTaggedTemplateExpression: (node: unknown) => node is Node.TaggedTemplateExpression;
|
|
52
|
+
readonly isTemplateElement: (node: unknown) => node is Node.TemplateElement;
|
|
53
|
+
readonly isObjectPattern: (node: unknown) => node is Node.ObjectPattern;
|
|
54
|
+
readonly isArrayPattern: (node: unknown) => node is Node.ArrayPattern;
|
|
55
|
+
readonly isRestElement: (node: unknown) => node is Node.RestElement;
|
|
56
|
+
readonly isAssignmentPattern: (node: unknown) => node is Node.AssignmentPattern;
|
|
57
|
+
readonly isClassBody: (node: unknown) => node is Node.ClassBody;
|
|
58
|
+
readonly isClassDeclaration: (node: unknown) => node is Node.ClassDeclaration;
|
|
59
|
+
readonly isClassExpression: (node: unknown) => node is Node.ClassExpression;
|
|
60
|
+
readonly isMetaProperty: (node: unknown) => node is Node.MetaProperty;
|
|
61
|
+
readonly isImportDeclaration: (node: unknown) => node is Node.ImportDeclaration;
|
|
62
|
+
readonly isImportSpecifier: (node: unknown) => node is Node.ImportSpecifier;
|
|
63
|
+
readonly isImportExpression: (node: unknown) => node is Node.ImportExpression;
|
|
64
|
+
readonly isImportDefaultSpecifier: (node: unknown) => node is Node.ImportDefaultSpecifier;
|
|
65
|
+
readonly isImportNamespaceSpecifier: (node: unknown) => node is Node.ImportNamespaceSpecifier;
|
|
66
|
+
readonly isExportNamedDeclaration: (node: unknown) => node is Node.ExportNamedDeclaration;
|
|
67
|
+
readonly isExportSpecifier: (node: unknown) => node is Node.ExportSpecifier;
|
|
68
|
+
readonly isExportDefaultDeclaration: (node: unknown) => node is Node.ExportDefaultDeclaration;
|
|
69
|
+
readonly isExportAllDeclaration: (node: unknown) => node is Node.ExportAllDeclaration;
|
|
70
|
+
readonly isAwaitExpression: (node: unknown) => node is Node.AwaitExpression;
|
|
71
|
+
readonly isMethodDefinition: (node: unknown) => node is Node.MethodDefinition;
|
|
72
|
+
readonly isMemberExpression: (node: unknown) => node is Node.MemberExpression;
|
|
73
|
+
readonly isComment: (node: unknown) => node is Node.Comment;
|
|
74
|
+
readonly isDirective: (node: unknown) => node is Node.Directive;
|
|
75
|
+
readonly isSimpleCallExpression: (node: unknown) => node is Node.SimpleCallExpression;
|
|
76
|
+
readonly isAssignmentProperty: (node: unknown) => node is Node.AssignmentProperty;
|
|
77
|
+
readonly isSimpleLiteral: (node: unknown) => node is Node.SimpleLiteral;
|
|
78
|
+
readonly isRegExpLiteral: (node: unknown) => node is Node.RegExpLiteral;
|
|
79
|
+
readonly isBigIntLiteral: (node: unknown) => node is Node.BigIntLiteral;
|
|
80
|
+
readonly isExportStatement: (node: unknown) => node is Node.ExportStatement;
|
|
81
|
+
};
|