diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 00000000..b448406b --- /dev/null +++ b/babel.config.js @@ -0,0 +1,9 @@ +module.exports = (api) => { + api.cache(false); // set cache as true/false + + return { + presets: ["@babel/preset-env"], + // optional if you want to use local .babelrc files + babelrcRoots: [".", "injector", "preload", "renderer"], + }; +}; \ No newline at end of file diff --git a/package.json b/package.json index ff9434e5..bb2a0bde 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,9 @@ "translations": "node -r dotenv/config scripts/translations.js" }, "devDependencies": { + "@babel/core": "^7.16.12", + "@babel/preset-env": "^7.16.11", + "@babel/register": "^7.16.9", "asar": "^3.2.0", "dotenv": "^16.0.3", "eslint": "^8.23.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8338201c..1ab14866 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ importers: .: specifiers: + '@babel/core': ^7.16.12 + '@babel/preset-env': ^7.16.11 + '@babel/register': ^7.16.9 asar: ^3.2.0 dotenv: ^16.0.3 eslint: ^8.23.0 @@ -13,6 +16,9 @@ importers: webpack: ^5.74.0 webpack-cli: ^4.10.0 devDependencies: + '@babel/core': 7.18.6 + '@babel/preset-env': 7.18.6_@babel+core@7.18.6 + '@babel/register': 7.18.6_@babel+core@7.18.6 asar: 3.2.0 dotenv: 16.0.3 eslint: 8.23.0 @@ -119,7 +125,7 @@ packages: resolution: {integrity: sha512-shck+7VLlY72a2w9c3zYWuE1pwOKEiQHV7GTUbSnhyl5eu3i04t30tBY82ZRWrDfo3gkakCFtevExnxbkf2a3A==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 '@jridgewell/gen-mapping': 0.3.2 jsesc: 2.5.2 dev: true @@ -128,7 +134,7 @@ packages: resolution: {integrity: sha512-duORpUiYrEpzKIop6iNbjnwKLAKnJ47csTyRACyEmWj0QdUrm5aqNJGHSSEQSUAvNW0ojX0dOmK9dZduvkfeXA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-builder-binary-assignment-operator-visitor/7.18.6: @@ -136,7 +142,7 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/helper-explode-assignable-expression': 7.18.6 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-compilation-targets/7.18.6_@babel+core@7.18.6: @@ -148,7 +154,7 @@ packages: '@babel/compat-data': 7.18.8 '@babel/core': 7.18.6 '@babel/helper-validator-option': 7.18.6 - browserslist: 4.21.1 + browserslist: 4.21.5 semver: 6.3.0 dev: true @@ -181,16 +187,14 @@ packages: regexpu-core: 5.1.0 dev: true - /@babel/helper-define-polyfill-provider/0.3.1_@babel+core@7.18.6: - resolution: {integrity: sha512-J9hGMpJQmtWmj46B3kBHmL38UhJGhYX7eqkcq+2gsstyYt341HmPeWspihX43yVRA0mS+8GGk2Gckc7bY/HCmA==} + /@babel/helper-define-polyfill-provider/0.3.3_@babel+core@7.18.6: + resolution: {integrity: sha512-z5aQKU4IzbqCC1XH0nAqfsFLMVSo22SBKUc0BxGrLkolTdPTructy0ToNnlO2zA4j9Q/7pjMZf0DSY+DSTYzww==} peerDependencies: '@babel/core': ^7.4.0-0 dependencies: '@babel/core': 7.18.6 '@babel/helper-compilation-targets': 7.18.6_@babel+core@7.18.6 - '@babel/helper-module-imports': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 - '@babel/traverse': 7.18.8 + '@babel/helper-plugin-utils': 7.21.5 debug: 4.3.4 lodash.debounce: 4.0.8 resolve: 1.22.1 @@ -208,7 +212,7 @@ packages: resolution: {integrity: sha512-eyAYAsQmB80jNfg4baAtLeWAQHfHFiR483rzFK+BhETlGZaQC9bsfrugfXDCbRHLQbIA7U5NxhhOxN7p/dWIcg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-function-name/7.18.6: @@ -216,21 +220,21 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.18.6 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-hoist-variables/7.18.6: resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-member-expression-to-functions/7.18.6: resolution: {integrity: sha512-CeHxqwwipekotzPDUuJOfIMtcIHBuc7WAzLmTYWctVigqS5RktNMQ5bEwQSuGewzYnCtTWa3BARXeiLxDTv+Ng==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-module-imports/7.18.6: @@ -240,18 +244,25 @@ packages: '@babel/types': 7.18.8 dev: true + /@babel/helper-module-imports/7.21.4: + resolution: {integrity: sha512-orajc5T2PsRYUN3ZryCEFeMDYwyw09c/pZeaQEZPH0MpKzSvn3e0uXsDBu3k03VI+9DBiRo+l22BfKTpKwa/Wg==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/types': 7.21.5 + dev: true + /@babel/helper-module-transforms/7.18.8: resolution: {integrity: sha512-che3jvZwIcZxrwh63VfnFTUzcAM9v/lznYkkRxIBGMPt1SudOKHAEec0SIRCfiuIzTcF7VGj/CaTT6gY4eWxvA==} engines: {node: '>=6.9.0'} dependencies: '@babel/helper-environment-visitor': 7.18.6 - '@babel/helper-module-imports': 7.18.6 + '@babel/helper-module-imports': 7.21.4 '@babel/helper-simple-access': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 '@babel/template': 7.18.6 '@babel/traverse': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -260,7 +271,7 @@ packages: resolution: {integrity: sha512-HP59oD9/fEHQkdcbgFCnbmgH5vIQTJbxh2yf+CdM89/glUNnuzr87Q8GIjGEnOktTROemO0Pe0iPAYbqZuOUiA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-plugin-utils/7.18.6: @@ -268,6 +279,11 @@ packages: engines: {node: '>=6.9.0'} dev: true + /@babel/helper-plugin-utils/7.21.5: + resolution: {integrity: sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==} + engines: {node: '>=6.9.0'} + dev: true + /@babel/helper-remap-async-to-generator/7.18.6_@babel+core@7.18.6: resolution: {integrity: sha512-z5wbmV55TveUPZlCLZvxWHtrjuJd+8inFhk7DG0WW87/oJuGDcjDiu7HIvGcpf5464L6xKCg3vNkmlVVz9hwyQ==} engines: {node: '>=6.9.0'} @@ -278,7 +294,7 @@ packages: '@babel/helper-annotate-as-pure': 7.18.6 '@babel/helper-environment-visitor': 7.18.6 '@babel/helper-wrap-function': 7.18.6 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -291,7 +307,7 @@ packages: '@babel/helper-member-expression-to-functions': 7.18.6 '@babel/helper-optimise-call-expression': 7.18.6 '@babel/traverse': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -300,25 +316,30 @@ packages: resolution: {integrity: sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-skip-transparent-expression-wrappers/7.18.6: resolution: {integrity: sha512-4KoLhwGS9vGethZpAhYnMejWkX64wsnHPDwvOsKWU6Fg4+AlK2Jz3TyjQLMEPvz+1zemi/WBdkYxCD0bAfIkiw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/helper-split-export-declaration/7.18.6: resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true - /@babel/helper-validator-identifier/7.18.6: - resolution: {integrity: sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==} + /@babel/helper-string-parser/7.21.5: + resolution: {integrity: sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==} + engines: {node: '>=6.9.0'} + dev: true + + /@babel/helper-validator-identifier/7.19.1: + resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} dev: true @@ -334,7 +355,7 @@ packages: '@babel/helper-function-name': 7.18.6 '@babel/template': 7.18.6 '@babel/traverse': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -345,7 +366,7 @@ packages: dependencies: '@babel/template': 7.18.6 '@babel/traverse': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -354,7 +375,7 @@ packages: resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 chalk: 2.4.2 js-tokens: 4.0.0 dev: true @@ -364,7 +385,7 @@ packages: engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/7.18.6_@babel+core@7.18.6: @@ -374,7 +395,7 @@ packages: '@babel/core': ^7.0.0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/7.18.6_@babel+core@7.18.6: @@ -384,7 +405,7 @@ packages: '@babel/core': ^7.13.0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-skip-transparent-expression-wrappers': 7.18.6 '@babel/plugin-proposal-optional-chaining': 7.18.6_@babel+core@7.18.6 dev: true @@ -397,7 +418,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-environment-visitor': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-remap-async-to-generator': 7.18.6_@babel+core@7.18.6 '@babel/plugin-syntax-async-generators': 7.8.4_@babel+core@7.18.6 transitivePeerDependencies: @@ -412,7 +433,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-class-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -425,7 +446,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-class-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-class-static-block': 7.14.5_@babel+core@7.18.6 transitivePeerDependencies: - supports-color @@ -438,7 +459,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-dynamic-import': 7.8.3_@babel+core@7.18.6 dev: true @@ -449,7 +470,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-export-namespace-from': 7.8.3_@babel+core@7.18.6 dev: true @@ -460,7 +481,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-json-strings': 7.8.3_@babel+core@7.18.6 dev: true @@ -471,7 +492,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-logical-assignment-operators': 7.10.4_@babel+core@7.18.6 dev: true @@ -482,7 +503,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3_@babel+core@7.18.6 dev: true @@ -493,7 +514,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-numeric-separator': 7.10.4_@babel+core@7.18.6 dev: true @@ -506,7 +527,7 @@ packages: '@babel/compat-data': 7.18.8 '@babel/core': 7.18.6 '@babel/helper-compilation-targets': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-object-rest-spread': 7.8.3_@babel+core@7.18.6 '@babel/plugin-transform-parameters': 7.18.8_@babel+core@7.18.6 dev: true @@ -518,7 +539,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-optional-catch-binding': 7.8.3_@babel+core@7.18.6 dev: true @@ -529,7 +550,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-skip-transparent-expression-wrappers': 7.18.6 '@babel/plugin-syntax-optional-chaining': 7.8.3_@babel+core@7.18.6 dev: true @@ -542,7 +563,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-class-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -556,7 +577,7 @@ packages: '@babel/core': 7.18.6 '@babel/helper-annotate-as-pure': 7.18.6 '@babel/helper-create-class-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-syntax-private-property-in-object': 7.14.5_@babel+core@7.18.6 transitivePeerDependencies: - supports-color @@ -570,7 +591,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-regexp-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-async-generators/7.8.4_@babel+core@7.18.6: @@ -579,7 +600,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-class-properties/7.12.13_@babel+core@7.18.6: @@ -588,7 +609,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-class-static-block/7.14.5_@babel+core@7.18.6: @@ -598,7 +619,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-dynamic-import/7.8.3_@babel+core@7.18.6: @@ -607,7 +628,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-export-namespace-from/7.8.3_@babel+core@7.18.6: @@ -616,7 +637,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-import-assertions/7.18.6_@babel+core@7.18.6: @@ -626,7 +647,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-json-strings/7.8.3_@babel+core@7.18.6: @@ -635,7 +656,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-jsx/7.18.6_@babel+core@7.18.6: @@ -654,7 +675,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-nullish-coalescing-operator/7.8.3_@babel+core@7.18.6: @@ -663,7 +684,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-numeric-separator/7.10.4_@babel+core@7.18.6: @@ -672,7 +693,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-object-rest-spread/7.8.3_@babel+core@7.18.6: @@ -681,7 +702,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-optional-catch-binding/7.8.3_@babel+core@7.18.6: @@ -690,7 +711,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-optional-chaining/7.8.3_@babel+core@7.18.6: @@ -699,7 +720,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-private-property-in-object/7.14.5_@babel+core@7.18.6: @@ -709,7 +730,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-syntax-top-level-await/7.14.5_@babel+core@7.18.6: @@ -719,7 +740,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-arrow-functions/7.18.6_@babel+core@7.18.6: @@ -729,7 +750,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-async-to-generator/7.18.6_@babel+core@7.18.6: @@ -739,8 +760,8 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-module-imports': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-module-imports': 7.21.4 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-remap-async-to-generator': 7.18.6_@babel+core@7.18.6 transitivePeerDependencies: - supports-color @@ -753,7 +774,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-block-scoping/7.18.6_@babel+core@7.18.6: @@ -763,7 +784,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-classes/7.18.8_@babel+core@7.18.6: @@ -777,7 +798,7 @@ packages: '@babel/helper-environment-visitor': 7.18.6 '@babel/helper-function-name': 7.18.6 '@babel/helper-optimise-call-expression': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-replace-supers': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 globals: 11.12.0 @@ -792,7 +813,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-destructuring/7.18.6_@babel+core@7.18.6: @@ -802,7 +823,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-dotall-regex/7.18.6_@babel+core@7.18.6: @@ -813,7 +834,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-regexp-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-duplicate-keys/7.18.6_@babel+core@7.18.6: @@ -823,7 +844,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-exponentiation-operator/7.18.6_@babel+core@7.18.6: @@ -834,7 +855,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-builder-binary-assignment-operator-visitor': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-for-of/7.18.8_@babel+core@7.18.6: @@ -844,7 +865,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-function-name/7.18.6_@babel+core@7.18.6: @@ -856,7 +877,7 @@ packages: '@babel/core': 7.18.6 '@babel/helper-compilation-targets': 7.18.6_@babel+core@7.18.6 '@babel/helper-function-name': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-literals/7.18.6_@babel+core@7.18.6: @@ -866,7 +887,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-member-expression-literals/7.18.6_@babel+core@7.18.6: @@ -876,7 +897,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-modules-amd/7.18.6_@babel+core@7.18.6: @@ -887,7 +908,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-module-transforms': 7.18.8 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 babel-plugin-dynamic-import-node: 2.3.3 transitivePeerDependencies: - supports-color @@ -901,7 +922,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-module-transforms': 7.18.8 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-simple-access': 7.18.6 babel-plugin-dynamic-import-node: 2.3.3 transitivePeerDependencies: @@ -917,8 +938,8 @@ packages: '@babel/core': 7.18.6 '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-module-transforms': 7.18.8 - '@babel/helper-plugin-utils': 7.18.6 - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 + '@babel/helper-validator-identifier': 7.19.1 babel-plugin-dynamic-import-node: 2.3.3 transitivePeerDependencies: - supports-color @@ -932,7 +953,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-module-transforms': 7.18.8 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 transitivePeerDependencies: - supports-color dev: true @@ -945,7 +966,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-regexp-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-new-target/7.18.6_@babel+core@7.18.6: @@ -955,7 +976,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-object-super/7.18.6_@babel+core@7.18.6: @@ -965,7 +986,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-replace-supers': 7.18.6 transitivePeerDependencies: - supports-color @@ -978,7 +999,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-property-literals/7.18.6_@babel+core@7.18.6: @@ -988,7 +1009,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-react-display-name/7.18.6_@babel+core@7.18.6: @@ -1043,7 +1064,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 regenerator-transform: 0.15.0 dev: true @@ -1054,7 +1075,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-shorthand-properties/7.18.6_@babel+core@7.18.6: @@ -1064,7 +1085,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-spread/7.18.6_@babel+core@7.18.6: @@ -1074,7 +1095,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/helper-skip-transparent-expression-wrappers': 7.18.6 dev: true @@ -1085,7 +1106,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-template-literals/7.18.6_@babel+core@7.18.6: @@ -1095,7 +1116,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-typeof-symbol/7.18.6_@babel+core@7.18.6: @@ -1105,7 +1126,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-unicode-escapes/7.18.6_@babel+core@7.18.6: @@ -1115,7 +1136,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/plugin-transform-unicode-regex/7.18.6_@babel+core@7.18.6: @@ -1126,7 +1147,7 @@ packages: dependencies: '@babel/core': 7.18.6 '@babel/helper-create-regexp-features-plugin': 7.18.6_@babel+core@7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 dev: true /@babel/preset-env/7.18.6_@babel+core@7.18.6: @@ -1221,10 +1242,10 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-plugin-utils': 7.18.6 + '@babel/helper-plugin-utils': 7.21.5 '@babel/plugin-proposal-unicode-property-regex': 7.18.6_@babel+core@7.18.6 '@babel/plugin-transform-dotall-regex': 7.18.6_@babel+core@7.18.6 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 esutils: 2.0.3 dev: true @@ -1261,7 +1282,7 @@ packages: resolution: {integrity: sha512-t9wi7/AW6XtKahAe20Yw0/mMljKq0B1r2fPdvaAdV/KPDZewFXdaaa6K7lxmZBZ8FBNpCiAT6iHPmd6QO9bKfQ==} engines: {node: '>=6.9.0'} dependencies: - regenerator-runtime: 0.13.9 + regenerator-runtime: 0.13.11 dev: true /@babel/template/7.18.6: @@ -1270,7 +1291,7 @@ packages: dependencies: '@babel/code-frame': 7.18.6 '@babel/parser': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 dev: true /@babel/traverse/7.18.8: @@ -1284,7 +1305,7 @@ packages: '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 '@babel/parser': 7.18.8 - '@babel/types': 7.18.8 + '@babel/types': 7.21.5 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: @@ -1295,7 +1316,16 @@ packages: resolution: {integrity: sha512-qwpdsmraq0aJ3osLJRApsc2ouSJCdnMeZwB0DhbtHAtRpZNZCdlbRnHIgcRKzdE1g0iOGg644fzjOBcdOz9cPw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 + to-fast-properties: 2.0.0 + dev: true + + /@babel/types/7.21.5: + resolution: {integrity: sha512-m4AfNvVF2mVC/F7fDEdH2El3HzUg9It/XsCxZiOTTA3m3qYfcSVSbTfM6Q9xG+hYDniZssYhlXKKUMD5m8tF4Q==} + engines: {node: '>=6.9.0'} + dependencies: + '@babel/helper-string-parser': 7.21.5 + '@babel/helper-validator-identifier': 7.19.1 to-fast-properties: 2.0.0 dev: true @@ -1651,6 +1681,12 @@ packages: hasBin: true dev: true + /acorn/8.8.2: + resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /ajv-keywords/3.5.2_ajv@6.12.6: resolution: {integrity: sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==} peerDependencies: @@ -1818,7 +1854,7 @@ packages: dependencies: '@babel/compat-data': 7.18.8 '@babel/core': 7.18.6 - '@babel/helper-define-polyfill-provider': 0.3.1_@babel+core@7.18.6 + '@babel/helper-define-polyfill-provider': 0.3.3_@babel+core@7.18.6 semver: 6.3.0 transitivePeerDependencies: - supports-color @@ -1830,8 +1866,8 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-define-polyfill-provider': 0.3.1_@babel+core@7.18.6 - core-js-compat: 3.23.4 + '@babel/helper-define-polyfill-provider': 0.3.3_@babel+core@7.18.6 + core-js-compat: 3.30.2 transitivePeerDependencies: - supports-color dev: true @@ -1842,7 +1878,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.18.6 - '@babel/helper-define-polyfill-provider': 0.3.1_@babel+core@7.18.6 + '@babel/helper-define-polyfill-provider': 0.3.3_@babel+core@7.18.6 transitivePeerDependencies: - supports-color dev: true @@ -1904,10 +1940,21 @@ packages: engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001359 - electron-to-chromium: 1.4.185 - node-releases: 2.0.5 - update-browserslist-db: 1.0.4_browserslist@4.21.1 + caniuse-lite: 1.0.30001487 + electron-to-chromium: 1.4.396 + node-releases: 2.0.10 + update-browserslist-db: 1.0.11_browserslist@4.21.1 + dev: true + + /browserslist/4.21.5: + resolution: {integrity: sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + dependencies: + caniuse-lite: 1.0.30001487 + electron-to-chromium: 1.4.396 + node-releases: 2.0.10 + update-browserslist-db: 1.0.11_browserslist@4.21.5 dev: true /buffer-from/1.1.2: @@ -1949,6 +1996,10 @@ packages: resolution: {integrity: sha512-Xln/BAsPzEuiVLgJ2/45IaqD9jShtk3Y33anKb4+yLwQzws3+v6odKfpgES/cDEaZMLzSChpIGdbOYtH9MyuHw==} dev: true + /caniuse-lite/1.0.30001487: + resolution: {integrity: sha512-83564Z3yWGqXsh2vaH/mhXfEM0wX+NlBCm1jYHOb97TrTWJEmPTccZgeLTPBUUb0PNVo+oomb7wkimZBIERClA==} + dev: true + /chalk/2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -2083,10 +2134,16 @@ packages: /core-js-compat/3.23.4: resolution: {integrity: sha512-RkSRPe+JYEoflcsuxJWaiMPhnZoFS51FcIxm53k4KzhISCBTmaGlto9dTIrYuk0hnJc3G6pKufAKepHnBq6B6Q==} dependencies: - browserslist: 4.21.1 + browserslist: 4.21.5 semver: 7.0.0 dev: true + /core-js-compat/3.30.2: + resolution: {integrity: sha512-nriW1nuJjUgvkEjIot1Spwakz52V9YkYHZAQG6A1eCgC8AA1p0zngrQEP9R0+V6hji5XilWKG1Bd0YRppmGimA==} + dependencies: + browserslist: 4.21.5 + dev: true + /cosmiconfig/7.0.1: resolution: {integrity: sha512-a1YWNUV2HwGimB7dU2s1wUMurNKjpx60HxBB6xUM8Re+2s1g1IIfJvFR0/iCF+XHdE0GMTKTuLR32UQff4TEyQ==} engines: {node: '>=10'} @@ -2245,6 +2302,10 @@ packages: resolution: {integrity: sha512-9kV/isoOGpKkBt04yYNaSWIBn3187Q5VZRtoReq8oz5NY/A4XmU6cAoqgQlDp7kKJCZMRjWZ8nsQyxfpFHvfyw==} dev: true + /electron-to-chromium/1.4.396: + resolution: {integrity: sha512-pqKTdqp/c5vsrc0xUPYXTDBo9ixZuGY8es4ZOjjd6HD6bFYbu5QA09VoW3fkY4LF1T0zYk86lN6bZnNlBuOpdQ==} + dev: true + /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -3453,6 +3514,10 @@ packages: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} dev: true + /node-releases/2.0.10: + resolution: {integrity: sha512-5GFldHPXVG/YZmFzJvKK2zDSzPKhEp0+ZR5SVaoSag9fsL5YgHbUHDfnG5494ISANDcK4KwPXAx2xqVEydmd7w==} + dev: true + /node-releases/2.0.5: resolution: {integrity: sha512-U9h1NLROZTq9uE1SNffn6WuPDg8icmi3ns4rEl/oTfIle4iLjTliCzgTsbaIFMq/Xn078/lfY/BL0GWZ+psK4Q==} dev: true @@ -3988,8 +4053,8 @@ packages: resolution: {integrity: sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==} dev: true - /regenerator-runtime/0.13.9: - resolution: {integrity: sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==} + /regenerator-runtime/0.13.11: + resolution: {integrity: sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==} dev: true /regenerator-transform/0.15.0: @@ -4481,7 +4546,7 @@ packages: hasBin: true dependencies: '@jridgewell/source-map': 0.3.2 - acorn: 8.8.0 + acorn: 8.8.2 commander: 2.20.3 source-map-support: 0.5.21 dev: true @@ -4575,6 +4640,28 @@ packages: engines: {node: '>= 10.0.0'} dev: true + /update-browserslist-db/1.0.11_browserslist@4.21.1: + resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + dependencies: + browserslist: 4.21.1 + escalade: 3.1.1 + picocolors: 1.0.0 + dev: true + + /update-browserslist-db/1.0.11_browserslist@4.21.5: + resolution: {integrity: sha512-dCwEFf0/oT85M1fHBg4F0jtLwJrutGoHSQXCh7u4o2t1drG+c0a9Flnqww6XUKSfQMPpJBRjU8d4RXB09qtvaA==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + dependencies: + browserslist: 4.21.5 + escalade: 3.1.1 + picocolors: 1.0.0 + dev: true + /update-browserslist-db/1.0.4_browserslist@4.21.0: resolution: {integrity: sha512-jnmO2BEGUjsMOe/Fg9u0oczOe/ppIDZPebzccl1yDWGLFP16Pa1/RM5wEoKYPG2zstNcDuAStejyxsOuKINdGA==} hasBin: true @@ -4586,17 +4673,6 @@ packages: picocolors: 1.0.0 dev: true - /update-browserslist-db/1.0.4_browserslist@4.21.1: - resolution: {integrity: sha512-jnmO2BEGUjsMOe/Fg9u0oczOe/ppIDZPebzccl1yDWGLFP16Pa1/RM5wEoKYPG2zstNcDuAStejyxsOuKINdGA==} - hasBin: true - peerDependencies: - browserslist: '>= 4.21.0' - dependencies: - browserslist: 4.21.1 - escalade: 3.1.1 - picocolors: 1.0.0 - dev: true - /uri-js/4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: diff --git a/preload/src/api/fetch.js b/preload/src/api/fetch.js new file mode 100644 index 00000000..6eced311 --- /dev/null +++ b/preload/src/api/fetch.js @@ -0,0 +1,147 @@ +import * as https from "https"; +import * as http from "http"; + +const MAX_DEFAULT_REDIRECTS = 20; +const redirectCodes = new Set([301, 302, 307, 308]); + +/** + * @typedef {Object} FetchOptions + * @property {"GET" | "PUT" | "POST" | "DELETE"} [method] - Request method. + * @property {Record} [headers] - Request headers. + * @property {"manual" | "follow"} [redirect] - Whether to follow redirects. + * @property {number} [maxRedirects] - Maximum amount of redirects to be followed. + * @property {AbortSignal} [signal] - Signal to abruptly cancel the request + * @property {Uint8Array | string} [body] - Defines a request body. Data must be serializable. + */ + +/** + * @param {string} url + * @param {FetchOptions} options + */ +export function nativeFetch(url, options) { + let state = "PENDING"; + const data = {content: [], headers: null, statusCode: null, url: url, statusText: "", redirected: false}; + const listeners = new Set(); + const errors = new Set(); + + /** * @param {URL} url */ + const execute = (url, options, redirectCount = 0) => { + const Module = url.protocol === "http:" ? http : https; + + const req = Module.request(url.href, { + headers: options.headers ?? {}, + method: options.method ?? "GET", + timeout: options.timeout ?? 3000 + }, res => { + if (redirectCodes.has(res.statusCode) && res.headers.location && options.redirect !== "manual") { + redirectCount++; + + if (redirectCount >= (options.maxRedirects ?? MAX_DEFAULT_REDIRECTS)) { + state = "ABORTED"; + const error = new Error(`Maximum amount of redirects reached (${options.maxRedirects ?? MAX_DEFAULT_REDIRECTS})`); + errors.forEach(e => e(error)); + + return; + } + + let final; + try { + final = new URL(res.headers.location); + } + catch (error) { + state = "ABORTED"; + errors.forEach(e => e(error)); + return; + } + + for (const [key, value] of new URL(url).searchParams.entries()) { + final.searchParams.set(key, value); + } + + return execute(final, options, redirectCount); + } + + res.on("data", chunk => data.content.push(chunk)); + res.on("end", () => { + data.content = Buffer.concat(data.content); + data.headers = res.headers; + data.statusCode = res.statusCode; + data.url = url.toString(); + data.statusText = res.statusMessage; + data.redirected = redirectCount > 0; + state = "DONE"; + + listeners.forEach(listener => listener()); + }); + res.on("error", error => { + state = "ABORTED"; + errors.forEach(e => e(error)); + }); + }); + + req.on("timeout", () => { + const error = new Error("Request timed out"); + req.destroy(error); + }); + + req.on("error", error => { + state = "ABORTED"; + errors.forEach(e => e(error)); + }); + + if (options.body) { + try {req.write(options.body);} + catch (error) { + state = "ABORTED"; + errors.forEach(e => e(error)); + } + finally { + req.end(); + } + } + else { + req.end(); + } + + if (options.signal) { + options.signal.addEventListener("abort", () => { + req.end(); + state = "ABORTED"; + }); + } + }; + + /** + * Obviously parsing a URL may throw an error, but this is + * actually intended here. The caller should handle this + * gracefully. + * + * Reasoning: at this point the caller does not have a + * reference to the object below so they have no way of + * listening to the error through onError. + */ + const parsed = new URL(url); + if (parsed.protocol !== "http:" && parsed.protocol !== "https:") { + throw new Error(`Unsupported protocol: ${parsed.protocol}`); + } + execute(parsed, options); + + return { + onComplete(listener) { + listeners.add(listener); + }, + onError(listener) { + errors.add(listener); + }, + readData() { + switch (state) { + case "PENDING": + throw new Error("Cannot read data before request is done!"); + case "ABORTED": + throw new Error("Request was aborted."); + case "DONE": + return data; + } + } + }; +} diff --git a/preload/src/api/https.js b/preload/src/api/https.js index dae2ac0f..e2e6ae0a 100644 --- a/preload/src/api/https.js +++ b/preload/src/api/https.js @@ -1,6 +1,6 @@ import * as https from "https"; -const methods = ["get", "put", "post", "delete"]; +const methods = ["get", "put", "post", "delete", "head"]; const redirectCodes = new Set([301, 302, 307, 308]); const headersToClone = ["statusCode", "statusMessage", "url", "headers", "method", "aborted", "complete", "rawHeaders", "end"]; @@ -34,7 +34,15 @@ const makeRequest = (url, options, callback, setReq) => { req.end(); }); }); - req.end(); + + if (options.formData) { + // Make sure to close the socket. + try {req.write(options.formData);} + finally {req.end();} + } else { + req.end(); + } + }; const request = function (url, options, callback) { diff --git a/preload/src/api/index.js b/preload/src/api/index.js index 2d097c76..7907775f 100644 --- a/preload/src/api/index.js +++ b/preload/src/api/index.js @@ -3,6 +3,7 @@ export {default as https} from "./https"; export * as electron from "./electron"; export * as crypto from "./crypto"; export * as vm from "./vm"; +export * from "./fetch"; // We can expose that without any issues. export * as path from "path"; diff --git a/renderer/.babelrc b/renderer/.babelrc deleted file mode 100644 index e016ad43..00000000 --- a/renderer/.babelrc +++ /dev/null @@ -1,23 +0,0 @@ -{ - "presets": [ - "@babel/react", - ["@babel/env", - { - "targets": { - "node": "14.16.0", - "chrome": "91" - } - }] - ], - "plugins": [[ - "module-resolver", - { - "alias": { - "builtins": "./src/builtins/builtins.js", - "data": "./src/data/data.js", - "modules": "./src/modules/modules.js", - "common": "../common" - } - } - ]] -} \ No newline at end of file diff --git a/renderer/.babelrc.js b/renderer/.babelrc.js new file mode 100644 index 00000000..54157904 --- /dev/null +++ b/renderer/.babelrc.js @@ -0,0 +1,31 @@ +const path = require("path"); + +module.exports = { + presets: [ + "@babel/react", + ["@babel/env", + { + targets: { + node: "14.16.0", + chrome: "91" + } + }] + ], + plugins: [[ + "module-resolver", + { + alias: { + "@assets": path.join(__dirname, "..", "assets"), + "@common": path.join(__dirname, "..", "common"), + + "@builtins": path.join(__dirname, "src", "builtins"), + "@data": path.join(__dirname, "src", "data"), + "@modules": path.join(__dirname, "src", "modules"), + "@polyfill": path.join(__dirname, "src", "polyfill"), + "@structs": path.join(__dirname, "src", "structs"), + "@styles": path.join(__dirname, "src", "styles"), + "@ui": path.join(__dirname, "src", "ui"), + } + } + ]] +} \ No newline at end of file diff --git a/renderer/jsconfig.json b/renderer/jsconfig.json index 27b51680..4671b46e 100644 --- a/renderer/jsconfig.json +++ b/renderer/jsconfig.json @@ -4,10 +4,15 @@ "allowSyntheticDefaultImports": false, "baseUrl": "./", "paths": { - "modules": ["./src/modules/modules.js"], - "builtins": ["./src/builtins/builtins.js"], - "data": ["./src/data/data.js"], - "common": ["../common"] + "@assets/*": ["../assets/*"], + "@common/*": ["../common/*"], + "@builtins/*": ["./src/builtins/*"], + "@data/*": ["./src/data/*"], + "@modules/*": ["./src/modules/*"], + "@polyfill/*": ["./src/polyfill/*"], + "@structs/*": ["./src/structs/*"], + "@styles/*": ["./src/styles/*"], + "@ui/*": ["./src/ui/*"] } }, "exclude": ["node_modules"] diff --git a/renderer/src/builtins/customcss.js b/renderer/src/builtins/customcss.js index 6f830f1c..9b9307c1 100644 --- a/renderer/src/builtins/customcss.js +++ b/renderer/src/builtins/customcss.js @@ -1,12 +1,23 @@ -import Builtin from "../structs/builtin"; -import {Settings, DataStore, React, WebpackModules, Events, DOMManager, Strings, DiscordModules} from "modules"; -import CSSEditor from "../ui/customcss/csseditor"; -import FloatingWindows from "../ui/floatingwindows"; -import SettingsTitle from "../ui/settings/title"; -import Utilities from "../modules/utilities"; +import fs from "fs"; +import electron from "electron"; + +import Builtin from "@structs/builtin"; + +import Settings from "@modules/settingsmanager"; +import DataStore from "@modules/datastore"; +import React from "@modules/react"; +import WebpackModules from "@modules/webpackmodules"; +import Events from "@modules/emitter"; +import DOMManager from "@modules/dommanager"; +import Strings from "@modules/strings"; +import DiscordModules from "@modules/discordmodules"; +import Utilities from "@modules/utilities"; + +import CSSEditor from "@ui/customcss/csseditor"; +import FloatingWindows from "@ui/floatingwindows"; +import SettingsTitle from "@ui/settings/title"; + -const fs = require("fs"); -const electron = require("electron"); const UserSettings = WebpackModules.getByProps("updateAccount"); const Dispatcher = DiscordModules.Dispatcher; diff --git a/renderer/src/builtins/developer/debugger.js b/renderer/src/builtins/developer/debugger.js index fffebbe4..00d5cd40 100644 --- a/renderer/src/builtins/developer/debugger.js +++ b/renderer/src/builtins/developer/debugger.js @@ -1,4 +1,4 @@ -import Builtin from "../../structs/builtin"; +import Builtin from "@structs/builtin"; export default new class DeveloperMode extends Builtin { get name() {return "Debugger";} diff --git a/renderer/src/builtins/developer/debuglogs.js b/renderer/src/builtins/developer/debuglogs.js index d10a58bb..b1b0ea0f 100644 --- a/renderer/src/builtins/developer/debuglogs.js +++ b/renderer/src/builtins/developer/debuglogs.js @@ -1,7 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -import Builtin from "../../structs/builtin"; -import DataStore from "../../modules/datastore"; +import fs from "fs"; +import path from "path"; + +import Builtin from "@structs/builtin"; +import DataStore from "@modules/datastore"; const timestamp = () => new Date().toISOString().replace("T", " ").replace("Z", ""); diff --git a/renderer/src/builtins/developer/devtools.js b/renderer/src/builtins/developer/devtools.js index 0835efbb..a573117c 100644 --- a/renderer/src/builtins/developer/devtools.js +++ b/renderer/src/builtins/developer/devtools.js @@ -1,5 +1,6 @@ -import Builtin from "../../structs/builtin"; -import IPC from "../../modules/ipc"; +import Builtin from "@structs/builtin"; + +import IPC from "@modules/ipc"; export default new class DevToolsListener extends Builtin { get name() {return "DevTools";} diff --git a/renderer/src/builtins/developer/devtoolswarning.js b/renderer/src/builtins/developer/devtoolswarning.js index a97903f5..e2b9db4d 100644 --- a/renderer/src/builtins/developer/devtoolswarning.js +++ b/renderer/src/builtins/developer/devtoolswarning.js @@ -1,6 +1,6 @@ -import Builtin from "../../structs/builtin"; -import WebpackModules from "../../modules/webpackmodules"; -// import IPC from "../../modules/ipc"; +import Builtin from "@structs/builtin"; + +import WebpackModules from "@modules/webpackmodules"; export default new class StopDevToolsWarning extends Builtin { get name() {return "StopDevToolsWarning";} diff --git a/renderer/src/builtins/developer/inspectelement.js b/renderer/src/builtins/developer/inspectelement.js index 50d6a4ae..09742ebe 100644 --- a/renderer/src/builtins/developer/inspectelement.js +++ b/renderer/src/builtins/developer/inspectelement.js @@ -1,5 +1,6 @@ -import Builtin from "../../structs/builtin"; -import IPC from "../../modules/ipc"; +import Builtin from "@structs/builtin"; + +import IPC from "@modules/ipc"; export default new class InspectElement extends Builtin { get name() {return "InspectElementHotkey";} diff --git a/renderer/src/builtins/developer/reactdevtools.js b/renderer/src/builtins/developer/reactdevtools.js index 418360a6..4b4722c3 100644 --- a/renderer/src/builtins/developer/reactdevtools.js +++ b/renderer/src/builtins/developer/reactdevtools.js @@ -1,6 +1,10 @@ -import Builtin from "../../structs/builtin"; -import Modals from "../../ui/modals"; -import {Strings, IPC} from "modules"; +import Builtin from "@structs/builtin"; + +import Strings from "@modules/strings"; +import IPC from "@modules/ipc"; + +import Modals from "@ui/modals"; + export default new class ReactDevTools extends Builtin { get name() {return "ReactDevTools";} diff --git a/renderer/src/builtins/general/mediakeys.js b/renderer/src/builtins/general/mediakeys.js index e2fe1a86..78922e93 100644 --- a/renderer/src/builtins/general/mediakeys.js +++ b/renderer/src/builtins/general/mediakeys.js @@ -1,6 +1,10 @@ -import Builtin from "../../structs/builtin"; -import Modals from "../../ui/modals"; -import {Strings, IPC} from "modules"; +import Builtin from "@structs/builtin"; + +import Strings from "@modules/strings"; +import IPC from "@modules/ipc"; + +import Modals from "@ui/modals"; + export default new class MediaKeys extends Builtin { get name() {return "DisableMediaKeys";} diff --git a/renderer/src/builtins/general/voicedisconnect.js b/renderer/src/builtins/general/voicedisconnect.js index bacd3eff..f59b877a 100644 --- a/renderer/src/builtins/general/voicedisconnect.js +++ b/renderer/src/builtins/general/voicedisconnect.js @@ -1,5 +1,6 @@ -import Builtin from "../../structs/builtin"; -import {DiscordModules} from "modules"; +import Builtin from "@structs/builtin"; + +import DiscordModules from "@modules/discordmodules"; export default new class VoiceDisconnect extends Builtin { get name() {return "VoiceDisconnect";} diff --git a/renderer/src/builtins/window/removeminimumsize.js b/renderer/src/builtins/window/removeminimumsize.js index a0b6a1f5..6f8effd7 100644 --- a/renderer/src/builtins/window/removeminimumsize.js +++ b/renderer/src/builtins/window/removeminimumsize.js @@ -1,6 +1,7 @@ -import Builtin from "../../structs/builtin"; -import IPC from "../../modules/ipc"; -import DataStore from "../../modules/datastore"; +import Builtin from "@structs/builtin"; + +import IPC from "@modules/ipc"; +import DataStore from "@modules/datastore"; const DISCORD_MIN_HEIGHT = 500; const DISCORD_MIN_WIDTH = 940; diff --git a/renderer/src/builtins/window/transparency.js b/renderer/src/builtins/window/transparency.js index 0b9ee3a5..31525073 100644 --- a/renderer/src/builtins/window/transparency.js +++ b/renderer/src/builtins/window/transparency.js @@ -1,6 +1,10 @@ -import Builtin from "../../structs/builtin"; -import Modals from "../../ui/modals"; -import {Strings, IPC} from "modules"; +import Builtin from "@structs/builtin"; + +import Strings from "@modules/strings"; +import IPC from "@modules/ipc"; + +import Modals from "@ui/modals"; + export default new class WindowTransparency extends Builtin { get name() {return "WindowTransparency";} diff --git a/renderer/src/data/data.js b/renderer/src/data/data.js deleted file mode 100644 index 00775b05..00000000 --- a/renderer/src/data/data.js +++ /dev/null @@ -1,3 +0,0 @@ -export {default as Config} from "./config"; -export {default as SettingsConfig} from "./settings"; -export {default as Changelog} from "./changelog"; \ No newline at end of file diff --git a/renderer/src/index.js b/renderer/src/index.js index 674b2d6d..346a98cd 100644 --- a/renderer/src/index.js +++ b/renderer/src/index.js @@ -1,8 +1,8 @@ import require from "./polyfill"; // eslint-disable-line no-unused-vars import secure from "./secure"; import LoadingIcon from "./loadingicon"; -import BetterDiscord from "./modules/core"; -import BdApi from "./modules/api/index"; +import BetterDiscord from "@modules/core"; +import BdApi from "@modules/api/index"; // Perform some setup secure(); diff --git a/renderer/src/modules/addonmanager.js b/renderer/src/modules/addonmanager.js index 2c6cbb0d..365445b2 100644 --- a/renderer/src/modules/addonmanager.js +++ b/renderer/src/modules/addonmanager.js @@ -1,19 +1,22 @@ -import Logger from "common/logger"; +import path from "path"; +import fs from "fs"; +import {shell} from "electron"; + +import Logger from "@common/logger"; + +import AddonError from "@structs/addonerror"; + import Settings from "./settingsmanager"; import Events from "./emitter"; import DataStore from "./datastore"; -import AddonError from "../structs/addonerror"; -import Toasts from "../ui/toasts"; -import DiscordModules from "./discordmodules"; +import React from "./react"; import Strings from "./strings"; -import AddonEditor from "../ui/misc/addoneditor"; -import FloatingWindows from "../ui/floatingwindows"; -const React = DiscordModules.React; +import AddonEditor from "@ui/misc/addoneditor"; +import FloatingWindows from "@ui/floatingwindows"; +import Toasts from "@ui/toasts"; + -const path = require("path"); -const fs = require("fs"); -const shell = require("electron").shell; const openItem = shell.openItem || shell.openPath; const splitRegex = /[^\S\r\n]*?\r?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/; diff --git a/renderer/src/modules/api/contextmenu.js b/renderer/src/modules/api/contextmenu.js index da08e734..2af01498 100644 --- a/renderer/src/modules/api/contextmenu.js +++ b/renderer/src/modules/api/contextmenu.js @@ -1,7 +1,8 @@ -import WebpackModules from "../webpackmodules"; -import Patcher from "../patcher"; -import Logger from "common/logger"; -import {React} from "../modules"; +import WebpackModules from "@modules/webpackmodules"; +import Patcher from "@modules/patcher"; +import Logger from "@common/logger"; +import React from "@modules/react"; + let startupComplete = false; diff --git a/renderer/src/modules/api/data.js b/renderer/src/modules/api/data.js index 7bed623e..f31b08c4 100644 --- a/renderer/src/modules/api/data.js +++ b/renderer/src/modules/api/data.js @@ -1,4 +1,5 @@ -import DataStore from "../datastore"; +import DataStore from "@modules/datastore"; + /** * `Data` is a simple utility class for the management of plugin data. An instance is available on {@link BdApi}. diff --git a/renderer/src/modules/api/dom.js b/renderer/src/modules/api/dom.js index e08cdefa..ae058d27 100644 --- a/renderer/src/modules/api/dom.js +++ b/renderer/src/modules/api/dom.js @@ -1,4 +1,5 @@ -import DOMManager from "../dommanager"; +import DOMManager from "@modules/dommanager"; + /** * `DOM` is a simple utility class for dom manipulation. An instance is available on {@link BdApi}. diff --git a/renderer/src/modules/api/fetch.js b/renderer/src/modules/api/fetch.js new file mode 100644 index 00000000..7fb23463 --- /dev/null +++ b/renderer/src/modules/api/fetch.js @@ -0,0 +1,92 @@ +import Remote from "../../polyfill/remote"; + +const methods = new Set(["GET", "PUT", "POST", "DELETE"]); + +class FetchResponse extends Response { + constructor(options) { + super(options.content, { + headers: new Headers(options.headers), + method: options.method ?? "GET", + body: options.content, + ...options + }); + + this._options = options; + } + + get url() {return this._options.url;} + get redirected() {return this._options.redirected;} +} + +const convertSignal = signal => { + const listeners = new Set(); + + signal.addEventListener("abort", () => { + listeners.forEach(l => l()); + }); + + return { + addEventListener(_, listener) { + listeners.add(listener); + } + }; +}; + +/** + * @typedef {Object} FetchOptions + * @property {"GET" | "PUT" | "POST" | "DELETE"} [method] - Request method. + * @property {Record} [headers] - Request headers. + * @property {"manual" | "follow"} [redirect] - Whether to follow redirects. + * @property {number} [maxRedirects] - Maximum amount of redirects to be followed. + * @property {AbortSignal} [signal] - Signal to abruptly cancel the request + * @property {Uint8Array | string} [body] - Defines a request body. Data must be serializable. + */ + +/** + * @param {string} url + * @param {FetchOptions} options + * @returns {Promise} + */ +export default function fetch(url, options = {}) { + return new Promise((resolve, reject) => { + const data = {}; + + if (typeof options.headers === "object") { + data.headers = options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers; + } + + if (typeof options.body === "string" || options.body instanceof Uint8Array) data.body = options.body; + if (typeof options.method === "string" && methods.has(options.method)) data.method = options.method; + if (options.signal instanceof AbortSignal) data.signal = convertSignal(options.signal); + + let ctx; + try { + ctx = Remote.nativeFetch(url, data); + } + catch (error) { + return reject(error); + } + + ctx.onError(error => { + reject(error); + }); + + ctx.onComplete(() => { + try { + const data = ctx.readData(); + + const req = new FetchResponse({ + method: options.method ?? "GET", + status: data.statusCode, + ...options, + ...data + }); + + resolve(req); + } + catch (error) { + reject(error); + } + }); + }); +} diff --git a/renderer/src/modules/api/index.js b/renderer/src/modules/api/index.js index a7f5f2d7..37cb7fc3 100644 --- a/renderer/src/modules/api/index.js +++ b/renderer/src/modules/api/index.js @@ -1,6 +1,8 @@ -import PluginManager from "../pluginmanager"; -import ThemeManager from "../thememanager"; -import Logger from "common/logger"; +import Logger from "@common/logger"; + +import PluginManager from "@modules/pluginmanager"; +import ThemeManager from "@modules/thememanager"; +import DiscordModules from "@modules/discordmodules"; import AddonAPI from "./addonapi"; import Data from "./data"; @@ -12,7 +14,7 @@ import Utils from "./utils"; import Webpack from "./webpack"; import * as Legacy from "./legacy"; import ContextMenu from "./contextmenu"; -import {DiscordModules} from "modules"; +import fetch from "./fetch"; const bounded = new Map(); const PluginAPI = new AddonAPI(PluginManager); @@ -57,6 +59,7 @@ export default class BdApi { Components = { get Tooltip() {return DiscordModules.Tooltip;} } + Net = {fetch}; } // Add legacy functions @@ -126,6 +129,9 @@ BdApi.Components = { get Tooltip() {return DiscordModules.Tooltip;} }; +BdApi.Net = {fetch}; + Object.freeze(BdApi); +Object.freeze(BdApi.Net); Object.freeze(BdApi.prototype); Object.freeze(BdApi.Components); diff --git a/renderer/src/modules/api/legacy.js b/renderer/src/modules/api/legacy.js index 2b6cd45a..3d222eec 100644 --- a/renderer/src/modules/api/legacy.js +++ b/renderer/src/modules/api/legacy.js @@ -1,15 +1,18 @@ -import {Config} from "data"; -import WebpackModules from "../webpackmodules"; -import DiscordModules from "../discordmodules"; -import DataStore from "../datastore"; -import DOMManager from "../dommanager"; -import Toasts from "../../ui/toasts"; -import Notices from "../../ui/notices"; -import Modals from "../../ui/modals"; -import Settings from "../settingsmanager"; -import Logger from "common/logger"; -import Patcher from "../patcher"; -import ipc from "../ipc"; +import Logger from "@common/logger"; + +import Config from "@data/config"; + +import WebpackModules from "@modules/webpackmodules"; +import DiscordModules from "@modules/discordmodules"; +import DataStore from "@modules/datastore"; +import DOMManager from "@modules/dommanager"; +import Settings from "@modules/settingsmanager"; +import Patcher from "@modules/patcher"; +import ipc from "@modules/ipc"; + +import Toasts from "@ui/toasts"; +import Notices from "@ui/notices"; +import Modals from "@ui/modals"; /** * The React module being used inside Discord. diff --git a/renderer/src/modules/api/patcher.js b/renderer/src/modules/api/patcher.js index 008e4dcd..0cb49a96 100644 --- a/renderer/src/modules/api/patcher.js +++ b/renderer/src/modules/api/patcher.js @@ -1,5 +1,7 @@ -import Logger from "common/logger"; -import {default as MainPatcher} from "../patcher"; +import Logger from "@common/logger"; + +import {default as MainPatcher} from "@modules/patcher"; + /** * `Patcher` is a utility class for modifying existing functions. Instance is accessible through the {@link BdApi}. diff --git a/renderer/src/modules/api/reactutils.js b/renderer/src/modules/api/reactutils.js index 1046373c..d58ab402 100644 --- a/renderer/src/modules/api/reactutils.js +++ b/renderer/src/modules/api/reactutils.js @@ -1,4 +1,5 @@ -import DiscordModules from "../discordmodules"; +import DiscordModules from "@modules//discordmodules"; + /** * `ReactUtils` is a utility class for interacting with React internals. Instance is accessible through the {@link BdApi}. diff --git a/renderer/src/modules/api/ui.js b/renderer/src/modules/api/ui.js index 3d7cb17d..15332691 100644 --- a/renderer/src/modules/api/ui.js +++ b/renderer/src/modules/api/ui.js @@ -1,8 +1,10 @@ -import Modals from "../../ui/modals"; -import Toasts from "../../ui/toasts"; -import Notices from "../../ui/notices"; -import Tooltip from "../../ui/tooltip"; -import ipc from "../ipc"; +import ipc from "@modules/ipc"; + +import Modals from "@ui/modals"; +import Toasts from "@ui/toasts"; +import Notices from "@ui/notices"; +import Tooltip from "@ui/tooltip"; + /** * `UI` is a utility class for creating user interfaces. Instance is accessible through the {@link BdApi}. diff --git a/renderer/src/modules/api/utils.js b/renderer/src/modules/api/utils.js index 49041f2d..74fd7aa8 100644 --- a/renderer/src/modules/api/utils.js +++ b/renderer/src/modules/api/utils.js @@ -1,4 +1,5 @@ -import Utilities from "../utilities"; +import Utilities from "@modules/utilities"; + /** * `Utils` is a utility containing commonly reused functions. Instance is accessible through the {@link BdApi}. diff --git a/renderer/src/modules/api/webpack.js b/renderer/src/modules/api/webpack.js index e0f0df6a..c6f27887 100644 --- a/renderer/src/modules/api/webpack.js +++ b/renderer/src/modules/api/webpack.js @@ -1,5 +1,7 @@ -import Logger from "common/logger"; -import WebpackModules, {Filters} from "../webpackmodules"; +import Logger from "@common/logger"; + +import WebpackModules, {Filters} from "@modules/webpackmodules"; + const getOptions = (args, defaultOptions = {}) => { if (args.length > 1 && diff --git a/renderer/src/modules/core.js b/renderer/src/modules/core.js index 94dde01c..2125c72f 100644 --- a/renderer/src/modules/core.js +++ b/renderer/src/modules/core.js @@ -1,21 +1,29 @@ -import LocaleManager from "./localemanager"; +import Logger from "@common/logger"; -import Logger from "common/logger"; -import {Config, Changelog} from "data"; +import Config from "@data/config"; +import Changelog from "@data/changelog"; + +import * as Builtins from "@builtins/builtins"; + +import LoadingIcon from "../loadingicon"; + +import LocaleManager from "./localemanager"; import DOMManager from "./dommanager"; import PluginManager from "./pluginmanager"; import ThemeManager from "./thememanager"; import Settings from "./settingsmanager"; -import * as Builtins from "builtins"; -import Modals from "../ui/modals"; -import FloatingWindows from "../ui/floatingwindows"; import DataStore from "./datastore"; import DiscordModules from "./discordmodules"; -import LoadingIcon from "../loadingicon"; -import Styles from "../styles/index.css"; + import Editor from "./editor"; import Updater from "./updater"; +import Styles from "@styles/index.css"; + +import Modals from "@ui/modals"; +import FloatingWindows from "@ui/floatingwindows"; + + export default new class Core { async startup() { if (this.hasStarted) return; diff --git a/renderer/src/modules/datastore.js b/renderer/src/modules/datastore.js index 40d357d1..6b255dc7 100644 --- a/renderer/src/modules/datastore.js +++ b/renderer/src/modules/datastore.js @@ -1,7 +1,11 @@ -import {Config} from "data"; -import Logger from "common/logger"; -const fs = require("fs"); -const path = require("path"); +import fs from "fs"; +import path from "path"; + +import Logger from "@common/logger"; + +import Config from "@data/config"; + + const releaseChannel = window?.DiscordNative?.app?.getReleaseChannel?.() ?? "stable"; // Schema diff --git a/renderer/src/modules/discordclasses.js b/renderer/src/modules/discordclasses.js index b8136036..ed73c0a2 100644 --- a/renderer/src/modules/discordclasses.js +++ b/renderer/src/modules/discordclasses.js @@ -1,7 +1,9 @@ +import ClassName from "@structs/classname"; + import Utilities from "./utilities"; -import ClassName from "../structs/classname"; import WebpackModules from "./webpackmodules"; + const combineClasses = function (...props) { return Object.assign({}, ...props.map(prop => WebpackModules.getByProps(...prop))); }; diff --git a/renderer/src/modules/discordmodules.js b/renderer/src/modules/discordmodules.js index 2e46f8e5..8eea820f 100644 --- a/renderer/src/modules/discordmodules.js +++ b/renderer/src/modules/discordmodules.js @@ -8,6 +8,7 @@ import Utilities from "./utilities"; import WebpackModules, {Filters} from "./webpackmodules"; + export default Utilities.memoizeObject({ get React() {return WebpackModules.getByProps("createElement", "cloneElement");}, get ReactDOM() {return WebpackModules.getByProps("render", "findDOMNode");}, diff --git a/renderer/src/modules/editor.js b/renderer/src/modules/editor.js index 02a26980..f58c2235 100644 --- a/renderer/src/modules/editor.js +++ b/renderer/src/modules/editor.js @@ -1,4 +1,5 @@ -import Logger from "../../../common/logger"; +import Logger from "@common/logger"; + import DOMManager from "./dommanager"; export default new class Editor { diff --git a/renderer/src/modules/emitter.js b/renderer/src/modules/emitter.js index 7fac5f00..b538f439 100644 --- a/renderer/src/modules/emitter.js +++ b/renderer/src/modules/emitter.js @@ -1,4 +1,4 @@ -const EventEmitter = require("events"); +import EventEmitter from "events"; export default new class BDEvents extends EventEmitter { constructor() { diff --git a/renderer/src/modules/ipc.js b/renderer/src/modules/ipc.js index 705157d3..df89c3db 100644 --- a/renderer/src/modules/ipc.js +++ b/renderer/src/modules/ipc.js @@ -1,8 +1,9 @@ import {ipcRenderer as ipc} from "electron"; +import * as IPCEvents from "@common/constants/ipcevents"; + import Events from "./emitter"; -import * as IPCEvents from "common/constants/ipcevents"; export default new class IPCRenderer { diff --git a/renderer/src/modules/localemanager.js b/renderer/src/modules/localemanager.js index 77439b5f..442e0cae 100644 --- a/renderer/src/modules/localemanager.js +++ b/renderer/src/modules/localemanager.js @@ -1,4 +1,5 @@ -import * as Locales from "../../../assets/locales"; +import * as Locales from "@assets/locales/index"; + import DiscordModules from "./discordmodules"; import Utilities from "./utilities"; import Events from "./emitter"; diff --git a/renderer/src/modules/modules.js b/renderer/src/modules/modules.js deleted file mode 100644 index b1377797..00000000 --- a/renderer/src/modules/modules.js +++ /dev/null @@ -1,18 +0,0 @@ -export {default as WebpackModules} from "./webpackmodules"; - -import DiscordModules from "./discordmodules"; -export const React = DiscordModules.React; -export const ReactDOM = DiscordModules.ReactDOM; -export {DiscordModules}; - -export {default as Utilities} from "./utilities"; -export {default as DataStore} from "./datastore"; -export {default as Events} from "./emitter"; -export {default as Settings} from "./settingsmanager"; -export {default as DOMManager} from "./dommanager"; -export {default as Patcher} from "./patcher"; -export {default as LocaleManager} from "./localemanager"; -export {default as Strings} from "./strings"; -export {default as IPC} from "./ipc"; -export {default as Logger} from "common/logger"; -export {default as DiscordClasses} from "./discordclasses"; \ No newline at end of file diff --git a/renderer/src/modules/patcher.js b/renderer/src/modules/patcher.js index 3564c469..274ea2fd 100644 --- a/renderer/src/modules/patcher.js +++ b/renderer/src/modules/patcher.js @@ -3,10 +3,12 @@ * instead of the original function. Can also alter arguments and return values. */ - import Logger from "common/logger"; + import Logger from "@common/logger"; + import DiscordModules from "./discordmodules"; import WebpackModules from "./webpackmodules"; + export default class Patcher { static get patches() {return this._patches || (this._patches = []);} diff --git a/renderer/src/modules/pluginmanager.js b/renderer/src/modules/pluginmanager.js index c315fd0c..28c2a77f 100644 --- a/renderer/src/modules/pluginmanager.js +++ b/renderer/src/modules/pluginmanager.js @@ -1,17 +1,21 @@ -import {Config} from "data"; -import Logger from "common/logger"; +import path from "path"; +import vm from "vm"; + +import Logger from "@common/logger"; + +import Config from "@data/config"; + +import AddonError from "@structs/addonerror"; + import AddonManager from "./addonmanager"; -import AddonError from "../structs/addonerror"; import Settings from "./settingsmanager"; import Strings from "./strings"; import Events from "./emitter"; -import Toasts from "../ui/toasts"; -import Modals from "../ui/modals"; -import SettingsRenderer from "../ui/settings"; +import Toasts from "@ui/toasts"; +import Modals from "@ui/modals"; +import SettingsRenderer from "@ui/settings"; -const path = require("path"); -const vm = require("vm"); const normalizeExports = name => ` if (module.exports.default) { diff --git a/renderer/src/modules/react.js b/renderer/src/modules/react.js new file mode 100644 index 00000000..b5720fbd --- /dev/null +++ b/renderer/src/modules/react.js @@ -0,0 +1,3 @@ +import DiscordModules from "./discordmodules"; +export default DiscordModules.React; +export const ReactDOM = DiscordModules.ReactDOM; \ No newline at end of file diff --git a/renderer/src/modules/reactdom.js b/renderer/src/modules/reactdom.js new file mode 100644 index 00000000..19d4e76c --- /dev/null +++ b/renderer/src/modules/reactdom.js @@ -0,0 +1,2 @@ +import DiscordModules from "./discordmodules"; +export default DiscordModules.ReactDOM; \ No newline at end of file diff --git a/renderer/src/modules/settingsmanager.js b/renderer/src/modules/settingsmanager.js index c41652ef..63717a68 100644 --- a/renderer/src/modules/settingsmanager.js +++ b/renderer/src/modules/settingsmanager.js @@ -1,10 +1,13 @@ -import {SettingsConfig} from "data"; -import Logger from "common/logger"; +import Logger from "@common/logger"; + +import SettingsConfig from "@data/settings"; + import DataStore from "./datastore"; import Events from "./emitter"; import DiscordModules from "./discordmodules"; import Strings from "./strings"; + export default new class SettingsManager { constructor() { diff --git a/renderer/src/modules/strings.js b/renderer/src/modules/strings.js index bb02f984..7978c454 100644 --- a/renderer/src/modules/strings.js +++ b/renderer/src/modules/strings.js @@ -1,5 +1,7 @@ +import FormattableString from "@structs/string"; + import LocaleManager from "./localemanager"; -import FormattableString from "../structs/string"; + export default new Proxy(LocaleManager.strings, { get: function(strings, category) { diff --git a/renderer/src/modules/thememanager.js b/renderer/src/modules/thememanager.js index dccfb3ab..008ed669 100644 --- a/renderer/src/modules/thememanager.js +++ b/renderer/src/modules/thememanager.js @@ -1,15 +1,18 @@ -import {Config} from "data"; +import path from "path"; + +import Config from "@data/config"; + +import AddonError from "@structs/addonerror"; + import AddonManager from "./addonmanager"; -import AddonError from "../structs/addonerror"; import Settings from "./settingsmanager"; import DOMManager from "./dommanager"; import Strings from "./strings"; -import Toasts from "../ui/toasts"; -import Modals from "../ui/modals"; -import SettingsRenderer from "../ui/settings"; +import Toasts from "@ui/toasts"; +import Modals from "@ui/modals"; +import SettingsRenderer from "@ui/settings"; -const path = require("path"); export default new class ThemeManager extends AddonManager { get name() {return "ThemeManager";} diff --git a/renderer/src/modules/updater.js b/renderer/src/modules/updater.js index b5e3b12b..acecf287 100644 --- a/renderer/src/modules/updater.js +++ b/renderer/src/modules/updater.js @@ -1,28 +1,27 @@ import request from "request"; import fileSystem from "fs"; -import {Config} from "data"; import path from "path"; -import Logger from "common/logger"; +import Logger from "@common/logger"; + +import Config from "@data/config"; + +import {comparator as semverComparator, regex as semverRegex} from "@structs/semver"; import Events from "./emitter"; import IPC from "./ipc"; import Strings from "./strings"; import DataStore from "./datastore"; +import React from "./react"; import Settings from "./settingsmanager"; import PluginManager from "./pluginmanager"; import ThemeManager from "./thememanager"; import WebpackModules from "./webpackmodules"; -import Toasts from "../ui/toasts"; -import Notices from "../ui/notices"; -import Modals from "../ui/modals"; -import UpdaterPanel from "../ui/updater"; -import DiscordModules from "./discordmodules"; - -import {comparator as semverComparator, regex as semverRegex} from "../structs/semver"; - -const React = DiscordModules.React; +import Toasts from "@ui/toasts"; +import Notices from "@ui/notices"; +import Modals from "@ui/modals"; +import UpdaterPanel from "@ui/updater"; const UserSettingsWindow = WebpackModules.getByProps("updateAccount"); diff --git a/renderer/src/modules/utilities.js b/renderer/src/modules/utilities.js index 8d17b90e..b1de98ba 100644 --- a/renderer/src/modules/utilities.js +++ b/renderer/src/modules/utilities.js @@ -1,4 +1,5 @@ -import Logger from "common/logger"; +import Logger from "@common/logger"; + export default class Utilities { /** diff --git a/renderer/src/modules/webpackmodules.js b/renderer/src/modules/webpackmodules.js index 5bcd0bc7..dc1fdea4 100644 --- a/renderer/src/modules/webpackmodules.js +++ b/renderer/src/modules/webpackmodules.js @@ -3,7 +3,7 @@ * @module WebpackModules * @version 0.0.2 */ -import Logger from "../../../common/logger"; +import Logger from "@common/logger"; /** * Checks if a given module matches a set of parameters. diff --git a/renderer/src/polyfill/buffer.js b/renderer/src/polyfill/buffer.js index a1b299c0..4dce364d 100644 --- a/renderer/src/polyfill/buffer.js +++ b/renderer/src/polyfill/buffer.js @@ -1,4 +1,4 @@ -import WebpackModules from "../modules/webpackmodules"; +import WebpackModules from "@modules/webpackmodules"; Object.defineProperty(window, "Buffer", { get() {return Buffer.getBuffer().Buffer;}, diff --git a/renderer/src/polyfill/crypto.js b/renderer/src/polyfill/crypto.js index fb053392..5db1e39e 100644 --- a/renderer/src/polyfill/crypto.js +++ b/renderer/src/polyfill/crypto.js @@ -1,5 +1,6 @@ import Remote from "./remote"; + export default { ...Remote.crypto, // Wrap it in Buffer diff --git a/renderer/src/polyfill/fs.js b/renderer/src/polyfill/fs.js index b2510c39..4db835ca 100644 --- a/renderer/src/polyfill/fs.js +++ b/renderer/src/polyfill/fs.js @@ -1,6 +1,6 @@ - import Remote from "./remote"; + export const readFileSync = function (path, options = "utf8") { return Remote.filesystem.readFile(path, options); }; @@ -179,6 +179,8 @@ export default { rmSync, rmdir, rmdirSync, + stat, + statSync, unlink, unlinkSync, watch, diff --git a/renderer/src/polyfill/https.js b/renderer/src/polyfill/https.js index 9ef7e353..8a28d58d 100644 --- a/renderer/src/polyfill/https.js +++ b/renderer/src/polyfill/https.js @@ -1,6 +1,8 @@ -import EventEmitter from "common/events"; +import EventEmitter from "@common/events"; + import Remote from "./remote"; + export function get(url, options = {}, callback) { if (typeof(options) === "function") { callback = options; diff --git a/renderer/src/polyfill/index.js b/renderer/src/polyfill/index.js index 72434088..6e772ee4 100644 --- a/renderer/src/polyfill/index.js +++ b/renderer/src/polyfill/index.js @@ -1,12 +1,20 @@ +import EventEmitter from "@common/events"; + import Module from "./module"; -import * as vm from "./vm"; -import * as fs from "./fs"; +import vm from "./vm"; +import fs from "./fs"; import request from "./request"; -import EventEmitter from "common/events"; -import * as https from "./https"; +import https from "./https"; import Buffer from "./buffer"; import crypto from "./crypto"; import Remote from "./remote"; +import Logger from "common/logger"; + +const deprecated = new Map([ + ["request", "Use BdApi.Net.fetch instead."], + ["https", "Use BdApi.Net.fetch instead."], +]); + const originalFs = Object.assign({}, fs); originalFs.writeFileSync = (path, data, options) => fs.writeFileSync(path, data, Object.assign({}, options, {originalFs: true})); @@ -14,6 +22,10 @@ originalFs.writeFile = (path, data, options) => fs.writeFile(path, data, Object. export const createRequire = function (path) { return mod => { + if (deprecated.has(mod)) { + Logger.warn("Remote~Require", `The "${mod}" module is marked as deprecated. ${deprecated.get(mod)}`); + } + switch (mod) { case "request": return request; case "https": return https; @@ -42,4 +54,4 @@ require.resolve = (path) => { } }; -export default require; \ No newline at end of file +export default require; diff --git a/renderer/src/polyfill/module.js b/renderer/src/polyfill/module.js index 9bf8a6fa..8ceae297 100644 --- a/renderer/src/polyfill/module.js +++ b/renderer/src/polyfill/module.js @@ -1,8 +1,10 @@ -import Logger from "common/logger"; +import Logger from "@common/logger"; + import {compileFunction} from "./vm"; import Remote from "./remote"; import fs from "./fs"; + const path = Remote.path; export const RequireExtensions = { diff --git a/renderer/src/polyfill/request.js b/renderer/src/polyfill/request.js index a37d2264..9d9bb2ee 100644 --- a/renderer/src/polyfill/request.js +++ b/renderer/src/polyfill/request.js @@ -1,5 +1,6 @@ import Remote from "./remote"; + const methods = ["get", "put", "post", "delete", "head"]; const aliases = {del: "delete"}; diff --git a/renderer/src/polyfill/vm.js b/renderer/src/polyfill/vm.js index bc89f797..66b065eb 100644 --- a/renderer/src/polyfill/vm.js +++ b/renderer/src/polyfill/vm.js @@ -1,9 +1,12 @@ import Remote from "./remote"; + export const compileFunction = function(code, params = [], options = {}) { const returned = Remote.vm.compileFunction(code, params, options); if (typeof(returned) === "function") return returned; const syntaxError = new SyntaxError(returned.message); syntaxError.stack = returned.stack; throw syntaxError; -}; \ No newline at end of file +}; + +export default {compileFunction}; \ No newline at end of file diff --git a/renderer/src/structs/builtin.js b/renderer/src/structs/builtin.js index f3c6358c..21d2421d 100644 --- a/renderer/src/structs/builtin.js +++ b/renderer/src/structs/builtin.js @@ -1,7 +1,9 @@ -import Logger from "common/logger"; -import Events from "../modules/emitter"; -import Settings from "../modules/settingsmanager"; -import Patcher from "../modules/patcher"; +import Logger from "@common/logger"; + +import Events from "@modules/emitter"; +import Settings from "@modules/settingsmanager"; +import Patcher from "@modules/patcher"; + export default class BuiltinModule { diff --git a/renderer/src/structs/markdown.js b/renderer/src/structs/markdown.js index fc6464ba..6db0309d 100644 --- a/renderer/src/structs/markdown.js +++ b/renderer/src/structs/markdown.js @@ -1,4 +1,6 @@ -import {DiscordModules, Utilities} from "modules"; +import DiscordModules from "@modules/discordmodules"; +import Utilities from "@modules/utilities"; + export default class SimpleMarkdownExt { static parseToReact(str) { diff --git a/renderer/src/structs/string.js b/renderer/src/structs/string.js index 8a7735ab..9ea2188b 100644 --- a/renderer/src/structs/string.js +++ b/renderer/src/structs/string.js @@ -1,4 +1,5 @@ -import Utilities from "../modules/utilities"; +import Utilities from "@modules/utilities"; + const LINK = /\[(.+?)]/; diff --git a/renderer/src/ui/addonerrormodal.jsx b/renderer/src/ui/addonerrormodal.jsx index 5ac9bfaa..6164dace 100644 --- a/renderer/src/ui/addonerrormodal.jsx +++ b/renderer/src/ui/addonerrormodal.jsx @@ -1,14 +1,19 @@ -import {React, Strings, WebpackModules, DiscordClasses} from "modules"; -import Extension from "./icons/extension"; -import ThemeIcon from "./icons/theme"; -import Divider from "./divider"; +import React from "@modules/react"; +import Strings from "@modules/strings"; +import DiscordClasses from "@modules/discordclasses"; +import WebpackModules from "@modules/webpackmodules"; +import Extension from "@ui/icons/extension"; +import ThemeIcon from "@ui/icons/theme"; + +import Divider from "@ui/divider"; const Parser = Object(WebpackModules.getByProps("defaultRules", "parse")).defaultRules; const {useState, useCallback, useMemo} = React; const joinClassNames = (...classNames) => classNames.filter(e => e).join(" "); + function AddonError({err, index}) { const [expanded, setExpanded] = useState(false); const toggle = useCallback(() => setExpanded(!expanded), [expanded]); diff --git a/renderer/src/ui/blankslates/emptyimage.jsx b/renderer/src/ui/blankslates/emptyimage.jsx index 7fd77004..d88cd6c6 100644 --- a/renderer/src/ui/blankslates/emptyimage.jsx +++ b/renderer/src/ui/blankslates/emptyimage.jsx @@ -1,5 +1,8 @@ -import {React, DiscordClasses} from "modules"; -import SimpleMarkdown from "../../structs/markdown"; +import SimpleMarkdown from "@structs/markdown"; + +import React from "@modules/react"; +import DiscordClasses from "@modules/discordclasses"; + export default function EmptyImage(props) { return
diff --git a/renderer/src/ui/blankslates/noresults.jsx b/renderer/src/ui/blankslates/noresults.jsx index 943f7102..7f9ac924 100644 --- a/renderer/src/ui/blankslates/noresults.jsx +++ b/renderer/src/ui/blankslates/noresults.jsx @@ -1,5 +1,8 @@ -import {React, DiscordModules} from "modules"; -import MagnifyingGlass from "../icons/magnifyingglass"; +import React from "@modules/react"; +import DiscordModules from "@modules/discordmodules"; + +import MagnifyingGlass from "@ui/icons/magnifyingglass"; + export default function NoResults(props) { return
diff --git a/renderer/src/ui/customcss/checkbox.jsx b/renderer/src/ui/customcss/checkbox.jsx index 390f00f4..a17e7cc6 100644 --- a/renderer/src/ui/customcss/checkbox.jsx +++ b/renderer/src/ui/customcss/checkbox.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/customcss/csseditor.jsx b/renderer/src/ui/customcss/csseditor.jsx index 3c7bd776..3ba43a8b 100644 --- a/renderer/src/ui/customcss/csseditor.jsx +++ b/renderer/src/ui/customcss/csseditor.jsx @@ -1,10 +1,14 @@ -import {React, Settings, Events, Strings} from "modules"; +import React from "@modules/react"; +import Strings from "@modules/strings"; +import Events from "@modules/emitter"; +import Settings from "@modules/settingsmanager"; import Editor from "./editor"; -import Refresh from "../icons/reload"; -import Save from "../icons/save"; -import Edit from "../icons/edit"; -import Detach from "../icons/detach"; + +import Refresh from "@ui/icons/reload"; +import Save from "@ui/icons/save"; +import Edit from "@ui/icons/edit"; +import Detach from "@ui/icons/detach"; const {useState, useCallback, useEffect, forwardRef, useImperativeHandle, useRef} = React; diff --git a/renderer/src/ui/customcss/editor.jsx b/renderer/src/ui/customcss/editor.jsx index bc79399a..ffceeb8b 100644 --- a/renderer/src/ui/customcss/editor.jsx +++ b/renderer/src/ui/customcss/editor.jsx @@ -1,4 +1,6 @@ -import {React, DiscordModules, Settings} from "modules"; +import React from "@modules/react"; +import DiscordModules from "@modules/discordmodules"; +import Settings from "@modules/settingsmanager"; import Checkbox from "./checkbox"; diff --git a/renderer/src/ui/divider.jsx b/renderer/src/ui/divider.jsx index 7f9b2fbd..605ed252 100644 --- a/renderer/src/ui/divider.jsx +++ b/renderer/src/ui/divider.jsx @@ -1,3 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; + export default ({className}) =>
; \ No newline at end of file diff --git a/renderer/src/ui/errorboundary.jsx b/renderer/src/ui/errorboundary.jsx index af27c9da..f60e746d 100644 --- a/renderer/src/ui/errorboundary.jsx +++ b/renderer/src/ui/errorboundary.jsx @@ -1,5 +1,7 @@ -import Logger from "common/logger"; -import {React, IPC} from "modules"; +import Logger from "@common/logger"; +import React from "@modules/react"; +import IPC from "@modules/ipc"; + export default class ErrorBoundary extends React.Component { constructor(props) { diff --git a/renderer/src/ui/floating/container.jsx b/renderer/src/ui/floating/container.jsx index 50008ad3..2722f380 100644 --- a/renderer/src/ui/floating/container.jsx +++ b/renderer/src/ui/floating/container.jsx @@ -1,4 +1,5 @@ -import {React, Events} from "modules"; +import React from "@modules/react"; +import Events from "@modules/emitter"; import FloatingWindow from "./window"; diff --git a/renderer/src/ui/floating/window.jsx b/renderer/src/ui/floating/window.jsx index 220b9844..88816fba 100644 --- a/renderer/src/ui/floating/window.jsx +++ b/renderer/src/ui/floating/window.jsx @@ -1,9 +1,12 @@ -import {React, Strings} from "modules"; +import React from "@modules/react"; +import Strings from "@modules/strings"; -import Screen from "../../structs/screen"; -import CloseButton from "../icons/close"; -import MaximizeIcon from "../icons/fullscreen"; -import Modals from "../modals"; +import Screen from "@structs/screen"; + +import CloseButton from "@ui/icons/close"; +import MaximizeIcon from "@ui/icons/fullscreen"; + +import Modals from "@ui/modals"; const {useState, useCallback, useEffect, useRef} = React; diff --git a/renderer/src/ui/floatingwindows.js b/renderer/src/ui/floatingwindows.js index c6d1d1cd..7ccd18a6 100644 --- a/renderer/src/ui/floatingwindows.js +++ b/renderer/src/ui/floatingwindows.js @@ -1,8 +1,13 @@ -import {WebpackModules, React, ReactDOM, DOMManager, Events} from "modules"; +import React from "@modules/react"; +import ReactDOM from "@modules/reactdom"; +import Events from "@modules/emitter"; +import DOMManager from "@modules/dommanager"; +import WebpackModules from "@modules/webpackmodules"; + import FloatingWindowContainer from "./floating/container"; -/* eslint-disable new-cap */ +/* eslint-disable new-cap */ const AppLayerProvider = WebpackModules.getByDisplayName("AppLayerProvider"); let hasInitialized = false; diff --git a/renderer/src/ui/icons/bdlogo.jsx b/renderer/src/ui/icons/bdlogo.jsx index d6dc74d1..112fec76 100644 --- a/renderer/src/ui/icons/bdlogo.jsx +++ b/renderer/src/ui/icons/bdlogo.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function BDLogo(props) { return diff --git a/renderer/src/ui/icons/check.jsx b/renderer/src/ui/icons/check.jsx index d994ea89..97900b22 100644 --- a/renderer/src/ui/icons/check.jsx +++ b/renderer/src/ui/icons/check.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Checkmark(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/close.jsx b/renderer/src/ui/icons/close.jsx index 55a45c0a..964b11a8 100644 --- a/renderer/src/ui/icons/close.jsx +++ b/renderer/src/ui/icons/close.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Close(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/cog.jsx b/renderer/src/ui/icons/cog.jsx index 9a929bf5..25dacd26 100644 --- a/renderer/src/ui/icons/cog.jsx +++ b/renderer/src/ui/icons/cog.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Cog(props) { const size = props.size || "20px"; diff --git a/renderer/src/ui/icons/delete.jsx b/renderer/src/ui/icons/delete.jsx index 92f4d79d..c1e712d0 100644 --- a/renderer/src/ui/icons/delete.jsx +++ b/renderer/src/ui/icons/delete.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Delete(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/detach.jsx b/renderer/src/ui/icons/detach.jsx index 8e5ade9f..42107a7c 100644 --- a/renderer/src/ui/icons/detach.jsx +++ b/renderer/src/ui/icons/detach.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Detach(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/dollarsign.jsx b/renderer/src/ui/icons/dollarsign.jsx index 5634e440..e1907ac4 100644 --- a/renderer/src/ui/icons/dollarsign.jsx +++ b/renderer/src/ui/icons/dollarsign.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function DollarSign(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/downarrow.jsx b/renderer/src/ui/icons/downarrow.jsx index 96d40694..d559aef1 100644 --- a/renderer/src/ui/icons/downarrow.jsx +++ b/renderer/src/ui/icons/downarrow.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function DownArrow(props) { const size = props.size || "16px"; diff --git a/renderer/src/ui/icons/edit.jsx b/renderer/src/ui/icons/edit.jsx index e7cf3109..33112063 100644 --- a/renderer/src/ui/icons/edit.jsx +++ b/renderer/src/ui/icons/edit.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Edit(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/error.jsx b/renderer/src/ui/icons/error.jsx index 5c6a7e5f..904e4606 100644 --- a/renderer/src/ui/icons/error.jsx +++ b/renderer/src/ui/icons/error.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Error(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/extension.jsx b/renderer/src/ui/icons/extension.jsx index d908cd2c..e0e01ce4 100644 --- a/renderer/src/ui/icons/extension.jsx +++ b/renderer/src/ui/icons/extension.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Extension(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/favorite.jsx b/renderer/src/ui/icons/favorite.jsx index 929bb316..4d35b6a7 100644 --- a/renderer/src/ui/icons/favorite.jsx +++ b/renderer/src/ui/icons/favorite.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Favorite(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/fullscreen.jsx b/renderer/src/ui/icons/fullscreen.jsx index 41ee8d71..61b858ff 100644 --- a/renderer/src/ui/icons/fullscreen.jsx +++ b/renderer/src/ui/icons/fullscreen.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function FullScreen(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/github.jsx b/renderer/src/ui/icons/github.jsx index 851bc2cd..6c4b3f24 100644 --- a/renderer/src/ui/icons/github.jsx +++ b/renderer/src/ui/icons/github.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function GitHub(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/globe.jsx b/renderer/src/ui/icons/globe.jsx index b89a3d53..9d0f4881 100644 --- a/renderer/src/ui/icons/globe.jsx +++ b/renderer/src/ui/icons/globe.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Globe(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/grid.jsx b/renderer/src/ui/icons/grid.jsx index 1e926576..feba09ab 100644 --- a/renderer/src/ui/icons/grid.jsx +++ b/renderer/src/ui/icons/grid.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Grid(props) { const size = props.size || "20px"; diff --git a/renderer/src/ui/icons/history.jsx b/renderer/src/ui/icons/history.jsx index 92999de0..d9951a77 100644 --- a/renderer/src/ui/icons/history.jsx +++ b/renderer/src/ui/icons/history.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function History(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/keyboard.jsx b/renderer/src/ui/icons/keyboard.jsx index 52161f60..53e2f2f4 100644 --- a/renderer/src/ui/icons/keyboard.jsx +++ b/renderer/src/ui/icons/keyboard.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Keyboard(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/list.jsx b/renderer/src/ui/icons/list.jsx index b6011e1a..6a7f5e16 100644 --- a/renderer/src/ui/icons/list.jsx +++ b/renderer/src/ui/icons/list.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function List(props) { const size = props.size || "20px"; diff --git a/renderer/src/ui/icons/magnifyingglass.jsx b/renderer/src/ui/icons/magnifyingglass.jsx index 1d838d50..a2a45ece 100644 --- a/renderer/src/ui/icons/magnifyingglass.jsx +++ b/renderer/src/ui/icons/magnifyingglass.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function MagnifyingGlass(props) { const size = props.size || "160px"; diff --git a/renderer/src/ui/icons/next.jsx b/renderer/src/ui/icons/next.jsx index c2e01393..149c9502 100644 --- a/renderer/src/ui/icons/next.jsx +++ b/renderer/src/ui/icons/next.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function ArrowRight(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/patreon.jsx b/renderer/src/ui/icons/patreon.jsx index 573d8c2a..7e323ccc 100644 --- a/renderer/src/ui/icons/patreon.jsx +++ b/renderer/src/ui/icons/patreon.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Patreon(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/previous.jsx b/renderer/src/ui/icons/previous.jsx index 36407172..6592ba16 100644 --- a/renderer/src/ui/icons/previous.jsx +++ b/renderer/src/ui/icons/previous.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function ArrowLeft(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/radio.jsx b/renderer/src/ui/icons/radio.jsx index b08f2445..63688619 100644 --- a/renderer/src/ui/icons/radio.jsx +++ b/renderer/src/ui/icons/radio.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Radio(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/reload.jsx b/renderer/src/ui/icons/reload.jsx index 4ff81a98..8100984f 100644 --- a/renderer/src/ui/icons/reload.jsx +++ b/renderer/src/ui/icons/reload.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function ReloadIcon(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/save.jsx b/renderer/src/ui/icons/save.jsx index 5a02f66c..73ca9c22 100644 --- a/renderer/src/ui/icons/save.jsx +++ b/renderer/src/ui/icons/save.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Save(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/search.jsx b/renderer/src/ui/icons/search.jsx index 3a936e90..5cc3c044 100644 --- a/renderer/src/ui/icons/search.jsx +++ b/renderer/src/ui/icons/search.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Search(props) { const size = props.size || "16px"; diff --git a/renderer/src/ui/icons/support.jsx b/renderer/src/ui/icons/support.jsx index 732c6409..29ea5ef3 100644 --- a/renderer/src/ui/icons/support.jsx +++ b/renderer/src/ui/icons/support.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Support(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/icons/theme.jsx b/renderer/src/ui/icons/theme.jsx index cccae69b..3c642dbc 100644 --- a/renderer/src/ui/icons/theme.jsx +++ b/renderer/src/ui/icons/theme.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Theme(props) { const size = props.size || "24px"; diff --git a/renderer/src/ui/icons/twitch.jsx b/renderer/src/ui/icons/twitch.jsx index 04a313d4..2800b4e3 100644 --- a/renderer/src/ui/icons/twitch.jsx +++ b/renderer/src/ui/icons/twitch.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; export default function Twitch(props) { const size = props.size || "18px"; diff --git a/renderer/src/ui/misc/addoneditor.jsx b/renderer/src/ui/misc/addoneditor.jsx index 43a1048a..cf06adf9 100644 --- a/renderer/src/ui/misc/addoneditor.jsx +++ b/renderer/src/ui/misc/addoneditor.jsx @@ -1,8 +1,10 @@ -import {React, Strings} from "modules"; +import React from "@modules/react"; +import Strings from "@modules/strings"; -import Editor from "../customcss/editor"; -import Save from "../icons/save"; -import Edit from "../icons/edit"; +import Editor from "@ui/customcss/editor"; + +import Save from "@ui/icons/save"; +import Edit from "@ui/icons/edit"; const {useState, useCallback, forwardRef, useImperativeHandle, useRef} = React; diff --git a/renderer/src/ui/modals.js b/renderer/src/ui/modals.js index da72056d..3e775eed 100644 --- a/renderer/src/ui/modals.js +++ b/renderer/src/ui/modals.js @@ -1,7 +1,17 @@ -import {Config} from "data"; -import Logger from "common/logger"; -import {WebpackModules, React, ReactDOM, Settings, Strings, DOMManager, DiscordModules, DiscordClasses} from "modules"; -import FormattableString from "../structs/string"; +import Config from "@data/config"; + +import FormattableString from "@structs/string"; + +import Logger from "@common/logger"; +import React from "@modules/react"; +import ReactDOM from "@modules/reactdom"; +import Strings from "@modules/strings"; +import Settings from "@modules/settingsmanager"; +import DiscordModules from "@modules/discordmodules"; +import WebpackModules from "@modules/webpackmodules"; +import DiscordClasses from "@modules/discordclasses"; +import DOMManager from "@modules/dommanager"; + import AddonErrorModal from "./addonerrormodal"; import ErrorBoundary from "./errorboundary"; diff --git a/renderer/src/ui/notices.js b/renderer/src/ui/notices.js index f41a5025..c57249b1 100644 --- a/renderer/src/ui/notices.js +++ b/renderer/src/ui/notices.js @@ -1,4 +1,6 @@ -import {WebpackModules, DOMManager} from "modules"; +import WebpackModules from "@modules/webpackmodules"; +import DOMManager from "@modules/dommanager"; + export default class Notices { static get baseClass() {return this.__baseClass ??= WebpackModules.getByProps("container", "base")?.base;} diff --git a/renderer/src/ui/settings.js b/renderer/src/ui/settings.js index 977f31dc..c54d3c07 100644 --- a/renderer/src/ui/settings.js +++ b/renderer/src/ui/settings.js @@ -1,10 +1,15 @@ -import {React, WebpackModules, Patcher, Utilities, Settings, Events, DataStore} from "modules"; +import React from "@modules/react"; +import Utilities from "@modules/utilities"; +import Events from "@modules/emitter"; +import Settings from "@modules/settingsmanager"; +import DataStore from "@modules/datastore"; +import WebpackModules, {Filters} from "@modules/webpackmodules"; +import Patcher from "@modules/patcher"; import AddonList from "./settings/addonlist"; import SettingsGroup from "./settings/group"; import SettingsTitle from "./settings/title"; import Header from "./settings/sidebarheader"; -import {Filters} from "../modules/webpackmodules"; export default new class SettingsRenderer { diff --git a/renderer/src/ui/settings/addoncard.jsx b/renderer/src/ui/settings/addoncard.jsx index 927877cc..ba6d7436 100644 --- a/renderer/src/ui/settings/addoncard.jsx +++ b/renderer/src/ui/settings/addoncard.jsx @@ -1,21 +1,29 @@ -import Logger from "common/logger"; -import {React, Strings, WebpackModules, DiscordModules} from "modules"; -import SimpleMarkdown from "../../structs/markdown"; -import EditIcon from "../icons/edit"; -import DeleteIcon from "../icons/delete"; -import CogIcon from "../icons/cog"; +import Logger from "@common/logger"; + +import SimpleMarkdown from "@structs/markdown"; + +import React from "@modules/react"; +import Strings from "@modules/strings"; +import WebpackModules from "@modules/webpackmodules"; +import DiscordModules from "@modules/discordmodules"; + + import Switch from "./components/switch"; -import GitHubIcon from "../icons/github"; -import MoneyIcon from "../icons/dollarsign"; -import WebIcon from "../icons/globe"; -import PatreonIcon from "../icons/patreon"; -import SupportIcon from "../icons/support"; -import ExtIcon from "../icons/extension"; -import ErrorIcon from "../icons/error"; -import ThemeIcon from "../icons/theme"; -import Modals from "../modals"; -import Toasts from "../toasts"; +import Modals from "@ui/modals"; +import Toasts from "@ui/toasts"; + +import EditIcon from "@ui/icons/edit"; +import DeleteIcon from "@ui/icons/delete"; +import CogIcon from "@ui/icons/cog"; +import GitHubIcon from "@ui/icons/github"; +import MoneyIcon from "@ui/icons/dollarsign"; +import WebIcon from "@ui/icons/globe"; +import PatreonIcon from "@ui/icons/patreon"; +import SupportIcon from "@ui/icons/support"; +import ExtIcon from "@ui/icons/extension"; +import ErrorIcon from "@ui/icons/error"; +import ThemeIcon from "@ui/icons/theme"; const {useState, useCallback, useMemo} = React; diff --git a/renderer/src/ui/settings/addonlist.jsx b/renderer/src/ui/settings/addonlist.jsx index 2b7b9084..8e61f093 100644 --- a/renderer/src/ui/settings/addonlist.jsx +++ b/renderer/src/ui/settings/addonlist.jsx @@ -1,19 +1,26 @@ -import {React, Strings, Events, DataStore, DiscordModules} from "modules"; +import React from "@modules/react"; +import Strings from "@modules/strings"; +import Events from "@modules/emitter"; +import DataStore from "@modules/datastore"; +import DiscordModules from "@modules/discordmodules"; -import Modals from "../modals"; import SettingsTitle from "./title"; import AddonCard from "./addoncard"; import Dropdown from "./components/dropdown"; import Search from "./components/search"; -import ErrorBoundary from "../errorboundary"; -import ListIcon from "../icons/list"; -import GridIcon from "../icons/grid"; -import NoResults from "../blankslates/noresults"; -import EmptyImage from "../blankslates/emptyimage"; +import Modals from "@ui/modals"; +import ErrorBoundary from "@ui/errorboundary"; + +import ListIcon from "@ui/icons/list"; +import GridIcon from "@ui/icons/grid"; + +import NoResults from "@ui/blankslates/noresults"; +import EmptyImage from "@ui/blankslates/emptyimage"; const {useState, useCallback, useEffect, useReducer, useMemo} = React; + const SORT_OPTIONS = [ {label: Strings.Addons.name, value: "name"}, {label: Strings.Addons.author, value: "author"}, diff --git a/renderer/src/ui/settings/components/color.jsx b/renderer/src/ui/settings/components/color.jsx index 86040ca5..924d4ca5 100644 --- a/renderer/src/ui/settings/components/color.jsx +++ b/renderer/src/ui/settings/components/color.jsx @@ -1,4 +1,5 @@ -import {DiscordModules, React} from "modules"; +import React from "@modules/react"; +import DiscordModules from "@modules/discordmodules"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/dropdown.jsx b/renderer/src/ui/settings/components/dropdown.jsx index d4d52946..34ebad58 100644 --- a/renderer/src/ui/settings/components/dropdown.jsx +++ b/renderer/src/ui/settings/components/dropdown.jsx @@ -1,5 +1,6 @@ -import {React} from "modules"; -import Arrow from "../../icons/downarrow"; +import React from "@modules/react"; + +import Arrow from "@ui/icons/downarrow"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/item.jsx b/renderer/src/ui/settings/components/item.jsx index 0fdb40e0..4fd21243 100644 --- a/renderer/src/ui/settings/components/item.jsx +++ b/renderer/src/ui/settings/components/item.jsx @@ -1,4 +1,5 @@ -import {React} from "modules"; +import React from "@modules/react"; + export default function SettingItem({id, name, note, inline, children}) { return
diff --git a/renderer/src/ui/settings/components/keybind.jsx b/renderer/src/ui/settings/components/keybind.jsx index 6db46c86..992cf1cb 100644 --- a/renderer/src/ui/settings/components/keybind.jsx +++ b/renderer/src/ui/settings/components/keybind.jsx @@ -1,7 +1,7 @@ -import {React} from "modules"; +import React from "@modules/react"; -import Keyboard from "../../icons/keyboard"; -import Close from "../../icons/close"; +import Keyboard from "@ui/icons/keyboard"; +import Close from "@ui/icons/close"; const {useState, useCallback, useEffect} = React; diff --git a/renderer/src/ui/settings/components/number.jsx b/renderer/src/ui/settings/components/number.jsx index f6e31db0..01180e8e 100644 --- a/renderer/src/ui/settings/components/number.jsx +++ b/renderer/src/ui/settings/components/number.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/radio.jsx b/renderer/src/ui/settings/components/radio.jsx index 02d5da89..ea293de0 100644 --- a/renderer/src/ui/settings/components/radio.jsx +++ b/renderer/src/ui/settings/components/radio.jsx @@ -1,6 +1,6 @@ -import {React} from "modules"; +import React from "@modules/react"; -import RadioIcon from "../../icons/radio"; +import RadioIcon from "@ui/icons/radio"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/search.jsx b/renderer/src/ui/settings/components/search.jsx index 77ac05d0..1bd481c8 100644 --- a/renderer/src/ui/settings/components/search.jsx +++ b/renderer/src/ui/settings/components/search.jsx @@ -1,5 +1,5 @@ -import {React} from "modules"; -import SearchIcon from "../../icons/search"; +import React from "@modules/react"; +import SearchIcon from "@ui/icons/search"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/slider.jsx b/renderer/src/ui/settings/components/slider.jsx index 75f833ac..3483d535 100644 --- a/renderer/src/ui/settings/components/slider.jsx +++ b/renderer/src/ui/settings/components/slider.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/switch.jsx b/renderer/src/ui/settings/components/switch.jsx index a0fdf278..d72099a0 100644 --- a/renderer/src/ui/settings/components/switch.jsx +++ b/renderer/src/ui/settings/components/switch.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/components/textbox.jsx b/renderer/src/ui/settings/components/textbox.jsx index 3997ea6e..60bf97ad 100644 --- a/renderer/src/ui/settings/components/textbox.jsx +++ b/renderer/src/ui/settings/components/textbox.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useState, useCallback} = React; diff --git a/renderer/src/ui/settings/drawer.jsx b/renderer/src/ui/settings/drawer.jsx index 97425c5e..957df5d1 100644 --- a/renderer/src/ui/settings/drawer.jsx +++ b/renderer/src/ui/settings/drawer.jsx @@ -1,6 +1,8 @@ -import {React} from "modules"; +import React from "@modules/react"; + import Title from "./title"; -import Divider from "../divider"; + +import Divider from "@ui/divider"; const {useState, useCallback, useRef} = React; diff --git a/renderer/src/ui/settings/group.jsx b/renderer/src/ui/settings/group.jsx index 0b98e8f8..aba72f62 100644 --- a/renderer/src/ui/settings/group.jsx +++ b/renderer/src/ui/settings/group.jsx @@ -1,4 +1,5 @@ -import {React} from "modules"; +import React from "@modules/react"; + import Drawer from "./drawer"; import Switch from "./components/switch"; import Dropdown from "./components/dropdown"; diff --git a/renderer/src/ui/settings/sidebarheader.jsx b/renderer/src/ui/settings/sidebarheader.jsx index ad99ade4..0bb6ab71 100644 --- a/renderer/src/ui/settings/sidebarheader.jsx +++ b/renderer/src/ui/settings/sidebarheader.jsx @@ -1,7 +1,11 @@ -import {Changelog} from "data"; -import {DiscordModules, React} from "modules"; -import HistoryIcon from "../icons/history"; -import Modals from "../modals"; +import Changelog from "@data/changelog"; + +import React from "@modules/react"; +import DiscordModules from "@modules/discordmodules"; + +import HistoryIcon from "@ui/icons/history"; + +import Modals from "@ui/modals"; export default function SettingsTitle() { diff --git a/renderer/src/ui/settings/title.jsx b/renderer/src/ui/settings/title.jsx index cd81f6d7..e42dba86 100644 --- a/renderer/src/ui/settings/title.jsx +++ b/renderer/src/ui/settings/title.jsx @@ -1,4 +1,4 @@ -import {React} from "modules"; +import React from "@modules/react"; const {useCallback} = React; diff --git a/renderer/src/ui/toasts.js b/renderer/src/ui/toasts.js index 121c45ec..7e1190bb 100644 --- a/renderer/src/ui/toasts.js +++ b/renderer/src/ui/toasts.js @@ -1,5 +1,9 @@ -import Logger from "common/logger"; -import {WebpackModules, Settings, DOMManager} from "modules"; +import Logger from "@common/logger"; + +import Settings from "@modules/settingsmanager"; +import WebpackModules from "@modules/webpackmodules"; +import DOMManager from "@modules/dommanager"; + export default class Toasts { diff --git a/renderer/src/ui/tooltip.js b/renderer/src/ui/tooltip.js index ef5dac4f..ad956a78 100644 --- a/renderer/src/ui/tooltip.js +++ b/renderer/src/ui/tooltip.js @@ -1,5 +1,5 @@ -import Logger from "common/logger"; -import {DOMManager} from "modules"; +import Logger from "@common/logger"; +import DOMManager from "@modules/dommanager"; const toPx = function(value) { diff --git a/renderer/src/ui/updater.jsx b/renderer/src/ui/updater.jsx index 79f88b91..b274b738 100644 --- a/renderer/src/ui/updater.jsx +++ b/renderer/src/ui/updater.jsx @@ -1,11 +1,15 @@ -import {Config} from "data"; -import {React, Events, Strings} from "modules"; +import Config from "@data/config"; + +import React from "@modules/react"; +import Strings from "@modules/strings"; +import Events from "@modules/emitter"; + import Drawer from "./settings/drawer"; import SettingItem from "./settings/components/item"; import SettingsTitle from "./settings/title"; import Toasts from "./toasts"; -import Checkmark from "./icons/check"; +import Checkmark from "@ui/icons/check"; const {useState, useCallback, useEffect} = React; diff --git a/tests/renderer/utilities.js b/tests/renderer/utilities.js index ca49d237..9985ef01 100644 --- a/tests/renderer/utilities.js +++ b/tests/renderer/utilities.js @@ -2,27 +2,6 @@ import assert from "assert"; import Utilities from "../../renderer/src/modules/utilities"; describe("Utilities", function() { - - describe("suppressErrors", function() { - it("Prevent error propagation", function() { - const thrower = () => {throw new Error("Error");}; - const wrapped = Utilities.suppressErrors(thrower); - assert.doesNotThrow(wrapped); - }); - it("Allows arguments through", function() { - const thrower = (foo) => { - assert.equal(foo, "bar"); - }; - const wrapped = Utilities.suppressErrors(thrower); - wrapped("bar"); - }); - it("Retains the return value", function() { - const thrower = () => {return "bar";}; - const wrapped = Utilities.suppressErrors(thrower); - const foo = wrapped(); - assert.equal(foo, "bar"); - }); - }); describe("formatString", function() { it("Should handle direct replacement", function() { @@ -54,30 +33,6 @@ describe("Utilities", function() { }); }); - describe("getNestedProp", function() { - const testObj = {test: {deep: {go: "far"}, other: [0, 1, {test2: "foo"}]}}; - it("Gets a shallow property", function() { - const result = Utilities.getNestedProp(testObj, "test"); - assert.deepEqual(result, testObj.test); - }); - it("Gets a deep property", function() { - const result = Utilities.getNestedProp(testObj, "test.deep.go"); - assert.deepEqual(result, testObj.test.deep.go); - }); - it("Gets a property through index", function() { - const result = Utilities.getNestedProp(testObj, "test.other.2.test2"); - assert.deepEqual(result, testObj.test.other[2].test2); - }); - it("Returns null when the a prop is not found", function() { - const result = Utilities.getNestedProp(testObj, "test.foo"); - assert.equal(result, null); - }); - it("Returns null when several layers are not found", function() { - const result = Utilities.getNestedProp(testObj, "test.deep.far.doit.cmon"); - assert.equal(result, null); - }); - }); - describe("findInTree", function() { const testObj = {test: {deep: {go: "far"}, other: [0, 1, {test2: "foo"}]}}; it("Gets a shallow property using a string", function() { @@ -123,36 +78,4 @@ describe("Utilities", function() { assert.deepEqual(result, walkingObj.otherTest); }); }); - - describe("findInReactTree", function() { - const originalFindInTree = Utilities.findInTree; - - it("Passes the original object", function() { - const myObj = {props: "foo"}; - Utilities.findInTree = function(obj) { assert.deepEqual(obj, myObj); return Reflect.apply(originalFindInTree, Utilities, arguments); }; - const result = Utilities.findInReactTree(myObj, "props"); - assert.equal(result, "foo"); - }); - it("Passes the original filter", function() { - const myObj = {props: "foo"}; - const myFilter = "props"; - Utilities.findInTree = function(obj, filter) { assert.deepEqual(filter, myFilter); return Reflect.apply(originalFindInTree, Utilities, arguments); }; - const result = Utilities.findInReactTree(myObj, myFilter); - assert.equal(result, "foo"); - - const myFilter2 = o => o == "foo"; - Utilities.findInTree = function(obj, filter) { assert.deepEqual(filter, myFilter2); return Reflect.apply(originalFindInTree, Utilities, arguments); }; - const result2 = Utilities.findInReactTree(myObj, myFilter2); - assert.equal(result2, "foo"); - }); - it("Includes the react walkables", function() { - Utilities.findInTree = function(obj, filter, {walkable}) { - const shouldWalk = ["props", "children", "return", "stateNode"]; - assert.ok(shouldWalk.every(k => walkable.includes(k))); - }; - Utilities.findInReactTree({}, "foobar"); - }); - - Utilities.findInTree = originalFindInTree; - }); }); \ No newline at end of file