Eugene Pankov 4 rokov pred
rodič
commit
75a0aadce4

+ 14 - 0
tabby-ssh/src/algorithms.ts

@@ -0,0 +1,14 @@
+import { ALGORITHM_BLACKLIST, SSHAlgorithmType } from './api'
+import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
+
+export const supportedAlgorithms: Record<string, string> = {}
+
+for (const k of Object.values(SSHAlgorithmType)) {
+    const supportedAlg = {
+        [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX',
+        [SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY',
+        [SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER',
+        [SSHAlgorithmType.HMAC]: 'SUPPORTED_MAC',
+    }[k]
+    supportedAlgorithms[k] = ALGORITHMS[supportedAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)).sort()
+}

+ 3 - 6
tabby-ssh/src/components/sshProfileSettings.component.ts

@@ -6,7 +6,7 @@ import { ConfigService, FileProvidersService, Platform, HostAppService, PromptMo
 import { LoginScriptsSettingsComponent } from 'tabby-terminal'
 import { PasswordStorageService } from '../services/passwordStorage.service'
 import { ForwardedPortConfig, SSHAlgorithmType, SSHProfile } from '../api'
-import { SSHProfilesService } from '../profiles'
+import { supportedAlgorithms } from '../algorithms'
 
 /** @hidden */
 @Component({
@@ -18,7 +18,7 @@ export class SSHProfileSettingsComponent {
     hasSavedPassword: boolean
     useProxyCommand: boolean
 
-    supportedAlgorithms: Record<string, string> = {}
+    supportedAlgorithms = supportedAlgorithms
     algorithms: Record<string, Record<string, boolean>> = {}
     jumpHosts: SSHProfile[]
     @ViewChild('loginScriptsSettings') loginScriptsSettings: LoginScriptsSettingsComponent|null
@@ -29,10 +29,7 @@ export class SSHProfileSettingsComponent {
         private passwordStorage: PasswordStorageService,
         private ngbModal: NgbModal,
         private fileProviders: FileProvidersService,
-        sshProfilesService: SSHProfilesService,
-    ) {
-        this.supportedAlgorithms = sshProfilesService.supportedAlgorithms
-    }
+    ) { }
 
     async ngOnInit () {
         this.jumpHosts = this.config.store.profiles.filter(x => x.type === 'ssh' && x !== this.profile)

+ 1 - 10
tabby-ssh/src/profiles.ts

@@ -4,9 +4,9 @@ import { SSHProfileSettingsComponent } from './components/sshProfileSettings.com
 import { SSHTabComponent } from './components/sshTab.component'
 import { PasswordStorageService } from './services/passwordStorage.service'
 import { ALGORITHM_BLACKLIST, SSHAlgorithmType, SSHProfile } from './api'
-
 import * as ALGORITHMS from 'ssh2/lib/protocol/constants'
 
+
 @Injectable({ providedIn: 'root' })
 export class SSHProfilesService extends ProfileProvider<SSHProfile> {
     id = 'ssh'
@@ -41,26 +41,17 @@ export class SSHProfilesService extends ProfileProvider<SSHProfile> {
         },
     }
 
-    supportedAlgorithms: Record<string, string> = {}
-
     constructor (
         private passwordStorage: PasswordStorageService
     ) {
         super()
         for (const k of Object.values(SSHAlgorithmType)) {
-            const supportedAlg = {
-                [SSHAlgorithmType.KEX]: 'SUPPORTED_KEX',
-                [SSHAlgorithmType.HOSTKEY]: 'SUPPORTED_SERVER_HOST_KEY',
-                [SSHAlgorithmType.CIPHER]: 'SUPPORTED_CIPHER',
-                [SSHAlgorithmType.HMAC]: 'SUPPORTED_MAC',
-            }[k]
             const defaultAlg = {
                 [SSHAlgorithmType.KEX]: 'DEFAULT_KEX',
                 [SSHAlgorithmType.HOSTKEY]: 'DEFAULT_SERVER_HOST_KEY',
                 [SSHAlgorithmType.CIPHER]: 'DEFAULT_CIPHER',
                 [SSHAlgorithmType.HMAC]: 'DEFAULT_MAC',
             }[k]
-            this.supportedAlgorithms[k] = ALGORITHMS[supportedAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x)).sort()
             this.configDefaults.options.algorithms[k] = ALGORITHMS[defaultAlg].filter(x => !ALGORITHM_BLACKLIST.includes(x))
             this.configDefaults.options.algorithms[k].sort()
         }

+ 1 - 1
tabby-web-demo/src/index.ts

@@ -7,7 +7,7 @@ import TabbyCorePlugin, { ProfileProvider, AppService } from 'tabby-core'
 import TabbyTerminalModule from 'tabby-terminal'
 
 import { DemoTerminalTabComponent } from './components/terminalTab.component'
-import { DemoProfilesService } from 'profiles'
+import { DemoProfilesService } from './profiles'
 
 /** @hidden */
 @NgModule({

+ 3 - 3
tabby-web-demo/src/session.ts

@@ -2,7 +2,7 @@
 import { Injector, NgZone } from '@angular/core'
 import * as path from 'path'
 import { BaseSession } from 'tabby-terminal'
-import { Logger } from '../../tabby-core/typings'
+import { Logger } from 'tabby-core'
 
 const currentScript: any = document.currentScript
 
@@ -32,7 +32,7 @@ export class Session extends BaseSession {
                     Session.v86Loaded = true
                 }
                 script.src = `${this.dataPath}/v86_all.js`
-                document.querySelector('head').appendChild(script)
+                document.querySelector('head')?.appendChild(script)
             })
         }
 
@@ -94,7 +94,7 @@ export class Session extends BaseSession {
         return false
     }
 
-    getWorkingDirectory (): Promise<string | null> {
+    async getWorkingDirectory (): Promise<string | null> {
         return null
     }
 }

+ 4 - 22
tabby-web-demo/tsconfig.json

@@ -1,25 +1,7 @@
 {
+  "extends": "../tsconfig.json",
+  "exclude": ["node_modules", "dist", "typings"],
   "compilerOptions": {
-    "baseUrl": "src",
-    "module": "commonjs",
-    "target": "es2016",
-    "esModuleInterop": true,
-    "noImplicitAny": false,
-    "removeComments": false,
-    "emitDecoratorMetadata": true,
-    "experimentalDecorators": true,
-    "sourceMap": true,
-    "noUnusedParameters": true,
-    "noImplicitReturns": true,
-    "noFallthroughCasesInSwitch": true,
-    "noUnusedLocals": true,
-    "declaration": true,
-    "declarationDir": "dist",
-    "lib": [
-      "dom",
-      "es2015",
-      "es7"
-    ]
-  },
-  "exclude": ["node_modules", "dist"]
+    "baseUrl": "src"
+  }
 }

+ 5 - 42
tabby-web-demo/webpack.config.js

@@ -1,42 +1,5 @@
-const path = require('path')
-
-module.exports = {
-    target: 'node',
-    entry: 'src/index.ts',
-    devtool: 'source-map',
-    context: __dirname,
-    mode: 'development',
-    output: {
-        path: path.resolve(__dirname, 'dist'),
-        filename: 'index.js',
-        pathinfo: true,
-        libraryTarget: 'umd',
-        devtoolModuleFilenameTemplate: 'webpack-tabby-demo:///[resource-path]',
-    },
-    resolve: {
-        modules: ['.', 'src', 'node_modules'].map(x => path.join(__dirname, x)),
-        extensions: ['.ts', '.js'],
-    },
-    module: {
-        rules: [
-            {
-                test: /\.ts$/,
-                loader: 'ts-loader',
-                options: {
-                    configFile: path.resolve(__dirname, 'tsconfig.json'),
-                },
-            },
-            { test: /\.pug$/, use: ['apply-loader', 'pug-loader'] },
-            { test: /\.svg/, use: ['svg-inline-loader'] },
-        ],
-    },
-    externals: [
-        'fs',
-        'ngx-toastr',
-        'path',
-        /^rxjs/,
-        /^@angular/,
-        /^@ng-bootstrap/,
-        /^tabby-/,
-    ],
-}
+const config = require('../webpack.plugin.config')
+module.exports = config({
+    name: 'web-demo',
+    dirname: __dirname,
+})