@rsdoctor/core 1.6.1 → 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 -3
- package/dist/build-utils/build/module-graph/index.js +0 -3
- 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 +7 -5
- 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/build/utils/plugin.js +1 -2
- 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/constants.d.ts +1 -1
- package/dist/inner-plugins/constants.js +1 -1
- 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 +4 -20
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.ts +6 -8
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.js +12 -77
- package/dist/inner-plugins/plugins/errors.d.ts +3 -3
- package/dist/inner-plugins/plugins/errors.js +6 -6
- package/dist/inner-plugins/plugins/index.d.ts +0 -1
- package/dist/inner-plugins/plugins/index.js +0 -1
- package/dist/inner-plugins/plugins/loader.d.ts +1 -1
- package/dist/inner-plugins/plugins/loader.js +8 -20
- package/dist/inner-plugins/plugins/plugins.d.ts +1 -1
- package/dist/inner-plugins/plugins/plugins.js +3 -3
- package/dist/inner-plugins/plugins/progress.d.ts +3 -3
- package/dist/inner-plugins/plugins/progress.js +16 -18
- package/dist/inner-plugins/plugins/resolver.d.ts +2 -3
- 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 +6 -6
- 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 +3 -4
- package/dist/inner-plugins/utils/config.js +4 -17
- package/dist/inner-plugins/utils/loader.d.ts +4 -7
- package/dist/inner-plugins/utils/loader.js +10 -36
- package/dist/inner-plugins/utils/normalize-config.d.ts +4 -7
- 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} +4 -1
- 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 +3 -3
- 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 +3 -18
- 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 +3 -3
- 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 +2 -2
- package/dist/rules/rules/side-effects-only-imports/index.d.ts +1 -1
- package/dist/rules/rules/side-effects-only-imports/index.js +2 -2
- 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/dist/types/rules.d.ts +4 -4
- package/package.json +123 -55
- package/static/openChrome.applescript +95 -0
- package/dist/build-utils/build/chunks/assetsModules.cjs +0 -46
- package/dist/build-utils/build/chunks/assetsModules.d.cts +0 -17
- package/dist/build-utils/build/chunks/chunkTransform.cjs +0 -43
- 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 -76
- package/dist/build-utils/build/chunks/index.d.cts +0 -3
- package/dist/build-utils/build/chunks/rspack/transform.cjs +0 -84
- package/dist/build-utils/build/chunks/rspack/transform.d.cts +0 -13
- package/dist/build-utils/build/index.cjs +0 -56
- package/dist/build-utils/build/index.d.cts +0 -5
- package/dist/build-utils/build/loader/index.cjs +0 -69
- package/dist/build-utils/build/loader/index.d.cts +0 -2
- package/dist/build-utils/build/loader/probeLoader.cjs +0 -93
- package/dist/build-utils/build/loader/probeLoader.d.cts +0 -4
- package/dist/build-utils/build/loader/probeLoaderPlugin.cjs +0 -69
- package/dist/build-utils/build/loader/probeLoaderPlugin.d.cts +0 -5
- package/dist/build-utils/build/module-graph/index.cjs +0 -83
- package/dist/build-utils/build/module-graph/index.d.cts +0 -4
- package/dist/build-utils/build/module-graph/parser.cjs +0 -50
- package/dist/build-utils/build/module-graph/parser.d.cts +0 -2
- package/dist/build-utils/build/module-graph/rspack/transform.cjs +0 -155
- package/dist/build-utils/build/module-graph/rspack/transform.d.cts +0 -26
- package/dist/build-utils/build/module-graph/transform.cjs +0 -44
- package/dist/build-utils/build/module-graph/transform.d.cts +0 -4
- package/dist/build-utils/build/module-graph/transform.d.ts +0 -4
- package/dist/build-utils/build/module-graph/transform.js +0 -7
- package/dist/build-utils/build/module-graph/treeShaking.cjs +0 -110
- package/dist/build-utils/build/module-graph/treeShaking.d.cts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.d.ts +0 -2
- package/dist/build-utils/build/module-graph/treeShaking.js +0 -73
- package/dist/build-utils/build/module-graph/utils.cjs +0 -99
- package/dist/build-utils/build/module-graph/utils.d.cts +0 -3
- package/dist/build-utils/build/module-graph/webpack/transform.cjs +0 -174
- package/dist/build-utils/build/module-graph/webpack/transform.d.cts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.d.ts +0 -16
- package/dist/build-utils/build/module-graph/webpack/transform.js +0 -124
- package/dist/build-utils/build/utils/index.cjs +0 -76
- package/dist/build-utils/build/utils/index.d.cts +0 -3
- package/dist/build-utils/build/utils/loader.cjs +0 -358
- package/dist/build-utils/build/utils/loader.d.cts +0 -20
- package/dist/build-utils/build/utils/parseBundle.cjs +0 -287
- package/dist/build-utils/build/utils/parseBundle.d.cts +0 -12
- package/dist/build-utils/build/utils/plugin.cjs +0 -65
- package/dist/build-utils/build/utils/plugin.d.cts +0 -5
- package/dist/build-utils/index.cjs +0 -40
- package/dist/build-utils/index.d.cts +0 -1
- package/dist/index.cjs +0 -85
- package/dist/index.d.cts +0 -3
- package/dist/inner-plugins/constants.cjs +0 -68
- package/dist/inner-plugins/index.cjs +0 -69
- package/dist/inner-plugins/index.d.cts +0 -2
- package/dist/inner-plugins/loaders/proxy.cjs +0 -108
- package/dist/inner-plugins/loaders/proxy.d.cts +0 -7
- package/dist/inner-plugins/plugins/base.cjs +0 -57
- package/dist/inner-plugins/plugins/base.d.cts +0 -12
- package/dist/inner-plugins/plugins/bundle.cjs +0 -116
- package/dist/inner-plugins/plugins/bundle.d.cts +0 -15
- package/dist/inner-plugins/plugins/bundleTagPlugin.cjs +0 -88
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.cts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.d.ts +0 -6
- package/dist/inner-plugins/plugins/bundleTagPlugin.js +0 -51
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.cjs +0 -182
- package/dist/inner-plugins/plugins/ensureModulesChunkGraph.d.cts +0 -36
- package/dist/inner-plugins/plugins/errors.cjs +0 -102
- package/dist/inner-plugins/plugins/errors.d.cts +0 -11
- package/dist/inner-plugins/plugins/index.cjs +0 -132
- package/dist/inner-plugins/plugins/index.d.cts +0 -11
- package/dist/inner-plugins/plugins/loader.cjs +0 -169
- package/dist/inner-plugins/plugins/loader.d.cts +0 -10
- package/dist/inner-plugins/plugins/plugins.cjs +0 -77
- package/dist/inner-plugins/plugins/plugins.d.cts +0 -8
- package/dist/inner-plugins/plugins/progress.cjs +0 -74
- package/dist/inner-plugins/plugins/progress.d.cts +0 -8
- package/dist/inner-plugins/plugins/resolver.cjs +0 -94
- package/dist/inner-plugins/plugins/resolver.d.cts +0 -13
- package/dist/inner-plugins/plugins/rspack.cjs +0 -122
- package/dist/inner-plugins/plugins/rspack.d.cts +0 -4
- package/dist/inner-plugins/plugins/rules.cjs +0 -101
- package/dist/inner-plugins/plugins/rules.d.cts +0 -8
- package/dist/inner-plugins/plugins/sourcemapTool.cjs +0 -279
- package/dist/inner-plugins/plugins/sourcemapTool.d.cts +0 -52
- package/dist/inner-plugins/plugins/summary.cjs +0 -129
- package/dist/inner-plugins/plugins/summary.d.cts +0 -14
- package/dist/inner-plugins/utils/circleDetect.cjs +0 -53
- package/dist/inner-plugins/utils/circleDetect.d.cts +0 -4
- package/dist/inner-plugins/utils/config.cjs +0 -207
- package/dist/inner-plugins/utils/config.d.cts +0 -5
- package/dist/inner-plugins/utils/index.cjs +0 -110
- package/dist/inner-plugins/utils/index.d.cts +0 -9
- package/dist/inner-plugins/utils/loader.cjs +0 -222
- package/dist/inner-plugins/utils/loader.d.cts +0 -13
- package/dist/inner-plugins/utils/normalize-config.cjs +0 -126
- package/dist/inner-plugins/utils/normalize-config.d.cts +0 -40
- package/dist/inner-plugins/utils/plugin-common.cjs +0 -147
- package/dist/inner-plugins/utils/plugin-common.d.cts +0 -11
- package/dist/inner-plugins/utils/plugin.cjs +0 -110
- package/dist/inner-plugins/utils/plugin.d.cts +0 -4
- package/dist/inner-plugins/utils/sdk.cjs +0 -59
- package/dist/inner-plugins/utils/sdk.d.cts +0 -8
- package/dist/rslib-runtime.js +0 -19
- package/dist/rules/index.cjs +0 -85
- package/dist/rules/index.d.cts +0 -3
- package/dist/rules/linter.cjs +0 -76
- package/dist/rules/linter.d.cts +0 -9
- package/dist/rules/rule.cjs +0 -141
- package/dist/rules/rule.d.cts +0 -27
- package/dist/rules/rules/cjs-require/index.cjs +0 -87
- 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 -78
- 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 -44
- package/dist/rules/rules/cross-chunks-package/utils.d.cts +0 -1
- package/dist/rules/rules/default-import-check/index.cjs +0 -120
- 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 -101
- package/dist/rules/rules/default-import-check/utils.d.cts +0 -10
- package/dist/rules/rules/duplicate-package/index.cjs +0 -76
- package/dist/rules/rules/duplicate-package/index.d.cts +0 -4
- package/dist/rules/rules/duplicate-package/types.cjs +0 -64
- package/dist/rules/rules/duplicate-package/types.d.cts +0 -24
- package/dist/rules/rules/duplicate-package/utils.cjs +0 -88
- package/dist/rules/rules/duplicate-package/utils.d.cts +0 -3
- package/dist/rules/rules/ecma-version-check/index.cjs +0 -100
- 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 -43
- package/dist/rules/rules/ecma-version-check/utils.d.cts +0 -2
- package/dist/rules/rules/esm-resolved-to-cjs/index.cjs +0 -256
- 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 -59
- package/dist/rules/rules/index.d.cts +0 -2
- package/dist/rules/rules/loader-performance-optimization/index.cjs +0 -123
- 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 -47
- package/dist/rules/rules/loader-performance-optimization/utils.d.cts +0 -1
- package/dist/rules/rules/module-mixed-chunks/index.cjs +0 -89
- 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 -118
- 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 -50
- 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 -83
- 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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
const normalizeAPIKey = (key)=>{
|
|
3
|
+
if (key && 'object' == typeof key && 'name' in key) return key.name;
|
|
4
|
+
return key;
|
|
5
|
+
};
|
|
6
|
+
class Router {
|
|
7
|
+
static get(pathname) {
|
|
8
|
+
return (target, propertyKey, descriptor)=>{
|
|
9
|
+
const routes = Router.routes.get;
|
|
10
|
+
const constructor = target.constructor;
|
|
11
|
+
if (!routes.has(constructor)) routes.set(constructor, []);
|
|
12
|
+
routes.get(constructor).push([
|
|
13
|
+
normalizeAPIKey(propertyKey),
|
|
14
|
+
pathname
|
|
15
|
+
]);
|
|
16
|
+
return descriptor;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static post(pathname) {
|
|
20
|
+
return (target, propertyKey, descriptor)=>{
|
|
21
|
+
const routes = Router.routes.post;
|
|
22
|
+
const constructor = target.constructor;
|
|
23
|
+
if (!routes.has(constructor)) routes.set(constructor, []);
|
|
24
|
+
routes.get(constructor).push([
|
|
25
|
+
normalizeAPIKey(propertyKey),
|
|
26
|
+
pathname
|
|
27
|
+
]);
|
|
28
|
+
return descriptor;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async setup() {
|
|
32
|
+
const { apis, sdk, server } = this.options;
|
|
33
|
+
apis.forEach((API)=>{
|
|
34
|
+
const obj = new API(sdk, server);
|
|
35
|
+
Router.routes.get.get(API)?.forEach(([key, pathname])=>{
|
|
36
|
+
server.get(pathname, this.wrapAPIFunction(obj, key));
|
|
37
|
+
});
|
|
38
|
+
Router.routes.post.get(API)?.forEach(([key, pathname])=>{
|
|
39
|
+
server.post(pathname, this.wrapAPIFunction(obj, key));
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
wrapAPIFunction(api, key) {
|
|
44
|
+
const { sdk, server } = this.options;
|
|
45
|
+
return async (req, res)=>{
|
|
46
|
+
const ctx = {
|
|
47
|
+
req,
|
|
48
|
+
res,
|
|
49
|
+
sdk,
|
|
50
|
+
server
|
|
51
|
+
};
|
|
52
|
+
const trap = new Proxy(api, {
|
|
53
|
+
get (target, key, receiver) {
|
|
54
|
+
switch(key){
|
|
55
|
+
case 'ctx':
|
|
56
|
+
return ctx;
|
|
57
|
+
default:
|
|
58
|
+
return Reflect.get(target, key, receiver);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
set (target, key, value, receiver) {
|
|
62
|
+
return Reflect.set(target, key, value, receiver);
|
|
63
|
+
},
|
|
64
|
+
defineProperty (target, p, attrs) {
|
|
65
|
+
return Reflect.defineProperty(target, p, attrs);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const fn = api[key];
|
|
69
|
+
const result = await fn.call(trap, trap);
|
|
70
|
+
if ('string' == typeof result) return Buffer.from(result, 'utf-8');
|
|
71
|
+
if (result && 'object' == typeof result) return Buffer.from(JSON.stringify(result), 'utf-8');
|
|
72
|
+
return result;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
constructor(options){
|
|
76
|
+
this.options = options;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
Router.routes = {
|
|
80
|
+
get: new Map(),
|
|
81
|
+
post: new Map()
|
|
82
|
+
};
|
|
83
|
+
export { Router };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const DEFAULT_ALLOWED_CORS_ORIGINS: RegExp;
|
|
2
|
+
export declare function isAllowedRequestOrigin(origin: string | string[] | undefined): boolean;
|
|
3
|
+
export declare function isAllowedRequestHost(host: string | string[] | undefined): boolean;
|
|
4
|
+
export declare function isAllowedCorsRequest(origin: string | string[] | undefined, host: string | string[] | undefined): boolean;
|
|
5
|
+
export declare function isAllowedOpenInEditorToken(token: string | null, expectedToken: string): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { isIP } from "node:net";
|
|
3
|
+
import { timingSafeEqual } from "node:crypto";
|
|
4
|
+
const DEFAULT_ALLOWED_CORS_ORIGINS = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
|
5
|
+
const LOCAL_HOSTNAMES = /^(?:localhost|[^:]+\.localhost)$/;
|
|
6
|
+
function isAllowedRequestOrigin(origin) {
|
|
7
|
+
if (void 0 === origin) return true;
|
|
8
|
+
return 'string' == typeof origin && DEFAULT_ALLOWED_CORS_ORIGINS.test(origin);
|
|
9
|
+
}
|
|
10
|
+
function getHostnameFromOrigin(origin) {
|
|
11
|
+
try {
|
|
12
|
+
const hostname = new URL(origin).hostname.toLowerCase();
|
|
13
|
+
return hostname.startsWith('[') && hostname.endsWith(']') ? hostname.slice(1, -1) : hostname;
|
|
14
|
+
} catch {
|
|
15
|
+
return '';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function isIpAddress(hostname) {
|
|
19
|
+
return 0 !== isIP(hostname);
|
|
20
|
+
}
|
|
21
|
+
function getHostnameFromHost(host) {
|
|
22
|
+
if (host.startsWith('[')) {
|
|
23
|
+
const endIndex = host.indexOf(']');
|
|
24
|
+
return -1 === endIndex ? '' : host.slice(1, endIndex);
|
|
25
|
+
}
|
|
26
|
+
return host.split(':')[0];
|
|
27
|
+
}
|
|
28
|
+
function isAllowedRequestHost(host) {
|
|
29
|
+
if ('string' != typeof host) return false;
|
|
30
|
+
const hostname = getHostnameFromHost(host).toLowerCase();
|
|
31
|
+
return LOCAL_HOSTNAMES.test(hostname) || isIpAddress(hostname);
|
|
32
|
+
}
|
|
33
|
+
function isAllowedCorsRequest(origin, host) {
|
|
34
|
+
if (void 0 === origin) return true;
|
|
35
|
+
if ('string' != typeof origin || 'string' != typeof host || !isAllowedRequestOrigin(origin)) return false;
|
|
36
|
+
const originHostname = getHostnameFromOrigin(origin);
|
|
37
|
+
const hostHostname = getHostnameFromHost(host).toLowerCase();
|
|
38
|
+
if (originHostname.endsWith('.localhost')) return originHostname === hostHostname;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
function isAllowedOpenInEditorToken(token, expectedToken) {
|
|
42
|
+
if ('string' != typeof token || !expectedToken) return false;
|
|
43
|
+
const tokenBuffer = Buffer.from(token);
|
|
44
|
+
const expectedTokenBuffer = Buffer.from(expectedToken);
|
|
45
|
+
return tokenBuffer.length === expectedTokenBuffer.length && timingSafeEqual(tokenBuffer, expectedTokenBuffer);
|
|
46
|
+
}
|
|
47
|
+
export { DEFAULT_ALLOWED_CORS_ORIGINS, isAllowedCorsRequest, isAllowedOpenInEditorToken, isAllowedRequestHost, isAllowedRequestOrigin };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Data } from '../../../common/index.js';
|
|
2
|
+
import { Manifest, SDK } from '@rsdoctor/shared/types';
|
|
3
|
+
interface SocketAPILoaderOptions {
|
|
4
|
+
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
5
|
+
}
|
|
6
|
+
export declare class SocketAPILoader implements Manifest.ManifestDataLoader {
|
|
7
|
+
protected options: SocketAPILoaderOptions;
|
|
8
|
+
protected dataLoader: Data.APIDataLoader;
|
|
9
|
+
constructor(options: SocketAPILoaderOptions);
|
|
10
|
+
loadManifest(): Promise<Manifest.RsdoctorManifestWithShardingFiles>;
|
|
11
|
+
loadData<T extends Manifest.RsdoctorManifestMappingKeys>(key: T): Promise<Manifest.InferManifestDataValue<T>>;
|
|
12
|
+
loadData(key: string): Promise<void>;
|
|
13
|
+
get loadAPIData(): <T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>) => Promise<SDK.ServerAPI.InferResponseType<T>>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { Data } from "../../../common/index.js";
|
|
3
|
+
class SocketAPILoader {
|
|
4
|
+
async loadManifest() {
|
|
5
|
+
return this.options.sdk.getManifestData();
|
|
6
|
+
}
|
|
7
|
+
async loadData(key) {
|
|
8
|
+
const data = this.options.sdk.getStoreData();
|
|
9
|
+
const sep = '.';
|
|
10
|
+
let res = data[key];
|
|
11
|
+
if (key.includes(sep)) res = key.split(sep).reduce((t, k)=>t[k], data);
|
|
12
|
+
return res;
|
|
13
|
+
}
|
|
14
|
+
get loadAPIData() {
|
|
15
|
+
return this.dataLoader.loadAPI;
|
|
16
|
+
}
|
|
17
|
+
constructor(options){
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.dataLoader = new Data.APIDataLoader(this);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { SocketAPILoader };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Common, SDK } from '@rsdoctor/shared/types';
|
|
2
|
+
import type { Server } from 'http';
|
|
3
|
+
import WebSocket, { WebSocketServer } from 'ws';
|
|
4
|
+
import { SocketAPILoader } from './api.js';
|
|
5
|
+
interface SocketOptions {
|
|
6
|
+
sdk: SDK.RsdoctorBuilderSDKInstance;
|
|
7
|
+
server: Server;
|
|
8
|
+
port: number;
|
|
9
|
+
token: string;
|
|
10
|
+
}
|
|
11
|
+
type Subscription = {
|
|
12
|
+
api: SDK.ServerAPI.API;
|
|
13
|
+
body: Common.PlainObject | null;
|
|
14
|
+
};
|
|
15
|
+
type SubscriptionRecord = Subscription & {
|
|
16
|
+
count: number;
|
|
17
|
+
};
|
|
18
|
+
type ClientMessage = {
|
|
19
|
+
type?: string;
|
|
20
|
+
id?: string;
|
|
21
|
+
api?: SDK.ServerAPI.API;
|
|
22
|
+
body?: Common.PlainObject | null;
|
|
23
|
+
};
|
|
24
|
+
export declare class Socket {
|
|
25
|
+
protected options: SocketOptions;
|
|
26
|
+
protected server?: WebSocketServer;
|
|
27
|
+
protected clients: Set<WebSocket>;
|
|
28
|
+
protected loader: SocketAPILoader;
|
|
29
|
+
protected map: Map<string, SubscriptionRecord>;
|
|
30
|
+
protected clientSubscriptions: Map<WebSocket, Set<string>>;
|
|
31
|
+
constructor(options: SocketOptions);
|
|
32
|
+
bootstrap(): void;
|
|
33
|
+
attachClient(client: WebSocket): void;
|
|
34
|
+
handleClientMessage(raw: string, client?: WebSocket): Promise<void>;
|
|
35
|
+
protected handleAPIRequestMessage(message: ClientMessage, client?: WebSocket): Promise<void>;
|
|
36
|
+
getSubscriptions(): Subscription[];
|
|
37
|
+
protected saveRequestToMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
38
|
+
protected removeRequestFromMap<T extends SDK.ServerAPI.API>(api: T, body?: SDK.ServerAPI.InferRequestBodyType<T, null> | null, client?: WebSocket): void;
|
|
39
|
+
protected removeClientSubscriptions(client: WebSocket): void;
|
|
40
|
+
protected removeSubscriptionKey(key: string): void;
|
|
41
|
+
protected getSubscriptionKey(api: SDK.ServerAPI.API, body: Common.PlainObject | null): string;
|
|
42
|
+
protected getAPIResponse<T extends SDK.ServerAPI.API>(api: T, body: SDK.ServerAPI.InferRequestBodyType<T>): Promise<SDK.ServerAPI.SocketResponseType<SDK.ServerAPI.API>>;
|
|
43
|
+
protected timer: NodeJS.Immediate | undefined;
|
|
44
|
+
broadcast(): Promise<void>;
|
|
45
|
+
sendAPIData<T extends SDK.ServerAPI.API | SDK.ServerAPI.APIExtends>(api: T, payload: SDK.ServerAPI.SocketResponseType<T>): void;
|
|
46
|
+
dispose(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { SDK } from "@rsdoctor/shared/types";
|
|
3
|
+
import ws, { WebSocketServer } from "ws";
|
|
4
|
+
import { SocketAPILoader } from "./api.js";
|
|
5
|
+
import { isAllowedRequestHost } from "../security.js";
|
|
6
|
+
function isAllowedSocketToken(url, token) {
|
|
7
|
+
if (!url) return false;
|
|
8
|
+
return new URL(url, 'http://localhost').searchParams.get('token') === token;
|
|
9
|
+
}
|
|
10
|
+
class Socket {
|
|
11
|
+
bootstrap() {
|
|
12
|
+
this.server = new WebSocketServer({
|
|
13
|
+
server: this.options.server,
|
|
14
|
+
verifyClient: ({ req })=>{
|
|
15
|
+
const host = req.headers.host || req.headers[':authority'];
|
|
16
|
+
return isAllowedRequestHost(host) && isAllowedSocketToken(req.url, this.options.token);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
this.server.on('connection', (client)=>{
|
|
20
|
+
this.attachClient(client);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
attachClient(client) {
|
|
24
|
+
this.clients.add(client);
|
|
25
|
+
if ('function' == typeof client.on) {
|
|
26
|
+
client.on('message', (message)=>{
|
|
27
|
+
this.handleClientMessage(message.toString(), client);
|
|
28
|
+
});
|
|
29
|
+
client.on('close', ()=>{
|
|
30
|
+
this.clients.delete(client);
|
|
31
|
+
this.removeClientSubscriptions(client);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async handleClientMessage(raw, client) {
|
|
36
|
+
let message;
|
|
37
|
+
try {
|
|
38
|
+
message = JSON.parse(raw);
|
|
39
|
+
} catch {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!message.api || !Object.values(SDK.ServerAPI.API).includes(message.api)) return;
|
|
43
|
+
if ('request' === message.type) return void await this.handleAPIRequestMessage(message, client);
|
|
44
|
+
if ('subscribe' === message.type) return void this.saveRequestToMap(message.api, message.body ?? null, client);
|
|
45
|
+
if ('unsubscribe' === message.type) this.removeRequestFromMap(message.api, message.body ?? null, client);
|
|
46
|
+
}
|
|
47
|
+
async handleAPIRequestMessage(message, client) {
|
|
48
|
+
if (!message.id || !client || client.readyState !== ws.OPEN) return;
|
|
49
|
+
try {
|
|
50
|
+
const response = await this.getAPIResponse(message.api, message.body);
|
|
51
|
+
client.send(JSON.stringify({
|
|
52
|
+
type: 'response',
|
|
53
|
+
id: message.id,
|
|
54
|
+
payload: response.res
|
|
55
|
+
}));
|
|
56
|
+
} catch (err) {
|
|
57
|
+
client.send(JSON.stringify({
|
|
58
|
+
type: 'response',
|
|
59
|
+
id: message.id,
|
|
60
|
+
error: err instanceof Error ? err.message : String(err)
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
getSubscriptions() {
|
|
65
|
+
return [
|
|
66
|
+
...this.map.values()
|
|
67
|
+
].map(({ api, body })=>({
|
|
68
|
+
api,
|
|
69
|
+
body
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
saveRequestToMap(api, body = null, client) {
|
|
73
|
+
const key = this.getSubscriptionKey(api, body);
|
|
74
|
+
if (client) {
|
|
75
|
+
if (!this.clientSubscriptions.has(client)) this.clientSubscriptions.set(client, new Set());
|
|
76
|
+
const subscriptions = this.clientSubscriptions.get(client);
|
|
77
|
+
if (subscriptions.has(key)) return;
|
|
78
|
+
subscriptions.add(key);
|
|
79
|
+
}
|
|
80
|
+
const record = this.map.get(key);
|
|
81
|
+
if (record) {
|
|
82
|
+
record.count += 1;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.map.set(key, {
|
|
86
|
+
api,
|
|
87
|
+
body,
|
|
88
|
+
count: 1
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
removeRequestFromMap(api, body = null, client) {
|
|
92
|
+
const key = this.getSubscriptionKey(api, body);
|
|
93
|
+
if (client) {
|
|
94
|
+
const subscriptions = this.clientSubscriptions.get(client);
|
|
95
|
+
if (!subscriptions?.has(key)) return;
|
|
96
|
+
subscriptions.delete(key);
|
|
97
|
+
if (0 === subscriptions.size) this.clientSubscriptions.delete(client);
|
|
98
|
+
}
|
|
99
|
+
this.removeSubscriptionKey(key);
|
|
100
|
+
}
|
|
101
|
+
removeClientSubscriptions(client) {
|
|
102
|
+
const subscriptions = this.clientSubscriptions.get(client);
|
|
103
|
+
if (!subscriptions) return;
|
|
104
|
+
subscriptions.forEach((key)=>this.removeSubscriptionKey(key));
|
|
105
|
+
this.clientSubscriptions.delete(client);
|
|
106
|
+
}
|
|
107
|
+
removeSubscriptionKey(key) {
|
|
108
|
+
const record = this.map.get(key);
|
|
109
|
+
if (!record) return;
|
|
110
|
+
record.count -= 1;
|
|
111
|
+
if (record.count <= 0) this.map.delete(key);
|
|
112
|
+
}
|
|
113
|
+
getSubscriptionKey(api, body) {
|
|
114
|
+
return `${api}:${JSON.stringify(body ?? null)}`;
|
|
115
|
+
}
|
|
116
|
+
async getAPIResponse(api, body) {
|
|
117
|
+
const data = await this.loader.loadAPIData(api, body);
|
|
118
|
+
const response = {
|
|
119
|
+
req: {
|
|
120
|
+
api,
|
|
121
|
+
body
|
|
122
|
+
},
|
|
123
|
+
res: data
|
|
124
|
+
};
|
|
125
|
+
return response;
|
|
126
|
+
}
|
|
127
|
+
async broadcast() {
|
|
128
|
+
clearImmediate(this.timer);
|
|
129
|
+
this.timer = setImmediate(async ()=>{
|
|
130
|
+
const promises = [];
|
|
131
|
+
this.map.forEach(({ api, body })=>{
|
|
132
|
+
promises.push((async ()=>{
|
|
133
|
+
const res = await this.getAPIResponse(api, body);
|
|
134
|
+
this.sendAPIData(api, res);
|
|
135
|
+
})());
|
|
136
|
+
});
|
|
137
|
+
await Promise.all(promises);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
sendAPIData(api, payload) {
|
|
141
|
+
const message = JSON.stringify({
|
|
142
|
+
api,
|
|
143
|
+
payload
|
|
144
|
+
});
|
|
145
|
+
this.clients.forEach((client)=>{
|
|
146
|
+
if (client.readyState === ws.OPEN) client.send(message);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
dispose() {
|
|
150
|
+
this.clients.forEach((client)=>{
|
|
151
|
+
client.close();
|
|
152
|
+
});
|
|
153
|
+
this.clients.clear();
|
|
154
|
+
this.server?.close();
|
|
155
|
+
}
|
|
156
|
+
constructor(options){
|
|
157
|
+
this.options = options;
|
|
158
|
+
this.clients = new Set();
|
|
159
|
+
this.map = new Map();
|
|
160
|
+
this.clientSubscriptions = new Map();
|
|
161
|
+
this.loader = new SocketAPILoader({
|
|
162
|
+
sdk: options.sdk
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
export { Socket };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SDK } from '@rsdoctor/shared/types';
|
|
2
|
+
export declare function getDataByPagination<T>(data: T[], pagination: SDK.ServerAPI.PaginationRequest): {
|
|
3
|
+
data: T[];
|
|
4
|
+
pagination: SDK.ServerAPI.PaginationResponse;
|
|
5
|
+
};
|
|
6
|
+
export declare function getLocalIpAddress(): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import os from "os";
|
|
3
|
+
function getDataByPagination(data, pagination) {
|
|
4
|
+
const { page = 1, pageSize = 1000 } = pagination;
|
|
5
|
+
return {
|
|
6
|
+
data: data.slice((page - 1) * pageSize, page * pageSize),
|
|
7
|
+
pagination: {
|
|
8
|
+
page,
|
|
9
|
+
pageSize,
|
|
10
|
+
hasNextPage: page <= 0 ? false : page * pageSize < data.length
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function getLocalIpAddress() {
|
|
15
|
+
const interfaces = os.networkInterfaces();
|
|
16
|
+
for (const iface of Object.values(interfaces))for (const alias of iface)if ('IPv4' === alias.family && !alias.internal) return alias.address;
|
|
17
|
+
return '127.0.0.1';
|
|
18
|
+
}
|
|
19
|
+
export { getDataByPagination, getLocalIpAddress };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findRoot(startDir?: string): string | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
function findRoot(startDir = process.cwd()) {
|
|
5
|
+
let dir = startDir;
|
|
6
|
+
let firstPkgDir = null;
|
|
7
|
+
while(dir !== path.parse(dir).root){
|
|
8
|
+
if (fs.existsSync(path.join(dir, 'pnpm-workspace.yaml'))) return dir;
|
|
9
|
+
if (fs.existsSync(path.join(dir, 'yarn.lock'))) return dir;
|
|
10
|
+
if (fs.existsSync(path.join(dir, 'lerna.json'))) return dir;
|
|
11
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
12
|
+
if (fs.existsSync(pkgPath)) {
|
|
13
|
+
if (!firstPkgDir) firstPkgDir = dir;
|
|
14
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
15
|
+
if (pkg.workspaces) return dir;
|
|
16
|
+
}
|
|
17
|
+
dir = path.dirname(dir);
|
|
18
|
+
}
|
|
19
|
+
if (firstPkgDir) return firstPkgDir;
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
export { findRoot };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CLOUD_DIR: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import { exec } from "node:child_process";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { logger } from "../../logger.js";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
const execAsync = promisify(exec);
|
|
7
|
+
const supportedChromiumBrowsers = [
|
|
8
|
+
'Google Chrome Canary',
|
|
9
|
+
'Google Chrome Dev',
|
|
10
|
+
'Google Chrome Beta',
|
|
11
|
+
'Google Chrome',
|
|
12
|
+
'Microsoft Edge',
|
|
13
|
+
'Brave Browser',
|
|
14
|
+
'Vivaldi',
|
|
15
|
+
'Chromium'
|
|
16
|
+
];
|
|
17
|
+
const getTargetBrowser = async ()=>{
|
|
18
|
+
let targetBrowser = process.env.BROWSER;
|
|
19
|
+
if (!targetBrowser || !supportedChromiumBrowsers.includes(targetBrowser)) {
|
|
20
|
+
const { stdout: ps } = await execAsync('ps cax');
|
|
21
|
+
targetBrowser = supportedChromiumBrowsers.find((b)=>ps.includes(b));
|
|
22
|
+
}
|
|
23
|
+
return targetBrowser;
|
|
24
|
+
};
|
|
25
|
+
const openWithDefaultBrowser = async (url)=>{
|
|
26
|
+
try {
|
|
27
|
+
const { default: open } = await import("open");
|
|
28
|
+
await open(url);
|
|
29
|
+
return true;
|
|
30
|
+
} catch (err) {
|
|
31
|
+
logger.error('Failed to open Rsdoctor URL.');
|
|
32
|
+
logger.error(err);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
async function openBrowser(url, needEncodeURI = true) {
|
|
37
|
+
const shouldTryOpenChromeWithAppleScript = 'darwin' === process.platform;
|
|
38
|
+
if (shouldTryOpenChromeWithAppleScript) try {
|
|
39
|
+
const targetBrowser = await getTargetBrowser();
|
|
40
|
+
if (targetBrowser) {
|
|
41
|
+
await execAsync(`osascript openChrome.applescript "${needEncodeURI ? encodeURI(url) : url}" "${targetBrowser}"`, {
|
|
42
|
+
cwd: join(__dirname, '../static')
|
|
43
|
+
});
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
logger.debug('Failed to find the target browser.');
|
|
47
|
+
} catch (err) {
|
|
48
|
+
logger.debug("Failed to open Rsdoctor URL with apple script.");
|
|
49
|
+
logger.debug(err);
|
|
50
|
+
}
|
|
51
|
+
return openWithDefaultBrowser(url);
|
|
52
|
+
}
|
|
53
|
+
export { openBrowser };
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sdk/index.js';
|
package/dist/sdk.js
ADDED
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/loader.d.ts
CHANGED
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { Linter, Linter as LinterType, Plugin, SDK } from '@rsdoctor/shared/types';
|
|
2
|
+
export interface RsdoctorMultiplePluginOptions<Rules extends LinterType.ExtendRuleData[] = LinterType.ExtendRuleData[]> extends Omit<Plugin.RsdoctorRspackPluginOptions<Rules>, 'sdkInstance'>, Pick<{
|
|
3
|
+
stage?: number;
|
|
4
|
+
}, 'stage'> {
|
|
4
5
|
/**
|
|
5
6
|
* name of builder
|
|
6
7
|
*/
|
|
@@ -24,28 +25,6 @@ export interface RsdoctorPluginInstance<T extends Plugin.BaseCompiler, Rules ext
|
|
|
24
25
|
modulesGraph: SDK.ModuleGraphInstance;
|
|
25
26
|
ensureModulesChunksGraphApplied(compiler: T): void;
|
|
26
27
|
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
moduleGraph?: boolean;
|
|
31
|
-
chunkGraph?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export interface RsdoctorRspackPluginExperiments {
|
|
34
|
-
/**
|
|
35
|
-
* Whether to enable the native plugin to improve the performance.
|
|
36
|
-
* @default true
|
|
37
|
-
*/
|
|
38
|
-
enableNativePlugin?: boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface RsdoctorRspackPluginExperimentsNormalized {
|
|
41
|
-
enableNativePlugin?: NativePluginConfig;
|
|
42
|
-
}
|
|
43
|
-
export interface RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> extends Plugin.RsdoctorWebpackPluginOptions<Rules> {
|
|
44
|
-
/**
|
|
45
|
-
* The experiments of the Rsdoctor Rspack plugin.
|
|
46
|
-
*/
|
|
47
|
-
experiments?: RsdoctorRspackPluginExperiments;
|
|
48
|
-
}
|
|
49
|
-
export type RsdoctorRspackPluginOptionsNormalized<Rules extends Linter.ExtendRuleData[]> = Plugin.RsdoctorPluginOptionsNormalized<Rules> & {
|
|
50
|
-
experiments?: RsdoctorRspackPluginExperimentsNormalized;
|
|
51
|
-
};
|
|
28
|
+
export type RsdoctorRspackPluginInstance<Rules extends LinterType.ExtendRuleData[] = []> = RsdoctorPluginInstance<Plugin.BaseCompilerType<'rspack'>, Rules>;
|
|
29
|
+
export type RsdoctorRspackPluginOptions<Rules extends LinterType.ExtendRuleData[]> = Plugin.RsdoctorRspackPluginOptions<Rules>;
|
|
30
|
+
export type RsdoctorRspackPluginOptionsNormalized<Rules extends Linter.ExtendRuleData[]> = Plugin.RsdoctorPluginOptionsNormalized<Rules>;
|
package/dist/types/rules.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { RuleSetRule } from '
|
|
2
|
-
export
|
|
1
|
+
import type { RuleSetRule } from '@rspack/core';
|
|
2
|
+
export type Rule = RuleSetRule & {
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* The legacy `loaders` field used by rule normalizers.
|
|
5
5
|
*/
|
|
6
6
|
loaders: RuleSetRule['use'];
|
|
7
|
-
}
|
|
7
|
+
};
|