Eugene Pankov 4 лет назад
Родитель
Сommit
ff18926bf9

+ 1 - 4
scripts/build-modules.js

@@ -1,5 +1,4 @@
 #!/usr/bin/env node
-const sh = require('shelljs')
 const vars = require('./vars')
 const log = require('npmlog')
 const webpack = require('webpack')
@@ -8,9 +7,7 @@ const { promisify } = require('util')
 const configs = [
     '../app/webpack.main.config.js',
     '../app/webpack.config.js',
-    '../web/webpack.config.js',
-    '../tabby-web-demo/webpack.config.js',
-    ...vars.builtinPlugins.map(x => `../${x}/webpack.config.js`),
+    ...vars.allPackages.map(x => `../${x}/webpack.config.js`),
 ]
 
 ;(async () => {

+ 1 - 1
scripts/publish-plugins.js

@@ -3,7 +3,7 @@ const sh = require('shelljs')
 const vars = require('./vars')
 const log = require('npmlog')
 
-;[...vars.builtinPlugins, 'web', 'tabby-web-demo'].forEach(plugin => {
+vars.builtinPlugins.forEach(plugin => {
     log.info('bump', plugin)
     sh.cd(plugin)
     sh.exec('npm --no-git-tag-version version ' + vars.version)

+ 7 - 0
scripts/vars.js

@@ -26,6 +26,13 @@ exports.builtinPlugins = [
     'tabby-serial',
     'tabby-telnet',
 ]
+
+exports.allPackages = [
+    ...exports.builtinPlugins,
+    'web',
+    'tabby-web-demo',
+]
+
 exports.bundledModules = [
     '@angular',
     '@ng-bootstrap',

+ 1 - 1
tabby-community-color-schemes/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-community-color-schemes",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Community color schemes for Tabby",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-core/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-core",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Tabby core",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 0
tabby-core/src/services/profiles.service.ts

@@ -74,6 +74,7 @@ export class ProfilesService {
     }
 
     selectorOptionForProfile <T> (profile: Profile): SelectorOption<T> {
+        profile = this.getConfigProxyForProfile(profile)
         return {
             icon: profile.icon,
             name: profile.group ? `${profile.group} / ${profile.name}` : profile.name,

+ 1 - 1
tabby-electron/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-electron",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Electron-specific bindings",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-local/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-local",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Tabby's local shell plugin",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-plugin-manager/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-plugin-manager",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Tabby's plugin manager",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-serial/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-serial",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Serial connections for Tabby",
   "keywords": [
     "tabby-builtin-plugin"

+ 8 - 0
tabby-serial/src/api.ts

@@ -4,6 +4,7 @@ import { LogService, NotificationsService, Profile } from 'tabby-core'
 import { Subject, Observable } from 'rxjs'
 import { Injector, NgZone } from '@angular/core'
 import { BaseSession, LoginScriptsOptions, StreamProcessingOptions, TerminalStreamProcessor } from 'tabby-terminal'
+import { SerialService } from './services/serial.service'
 
 export interface SerialProfile extends Profile {
     options: SerialProfileOptions
@@ -38,9 +39,12 @@ export class SerialSession extends BaseSession {
     private streamProcessor: TerminalStreamProcessor
     private zone: NgZone
     private notifications: NotificationsService
+    private serialService: SerialService
 
     constructor (injector: Injector, public profile: SerialProfile) {
         super(injector.get(LogService).create(`serial-${profile.options.port}`))
+        this.serialService = injector.get(SerialService)
+
         this.zone = injector.get(NgZone)
         this.notifications = injector.get(NotificationsService)
 
@@ -57,6 +61,10 @@ export class SerialSession extends BaseSession {
     }
 
     async start (): Promise<void> {
+        if (!this.profile.options.port) {
+            this.profile.options.port = (await this.serialService.listPorts())[0].name
+        }
+
         this.serial = new SerialPort(this.profile.options.port, {
             autoOpen: false,
             baudRate: parseInt(this.profile.options.baudrate as any),

+ 1 - 1
tabby-serial/src/components/serialProfileSettings.component.pug

@@ -3,7 +3,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
         a(ngbNavLink) General
         ng-template(ngbNavContent)
             .row
-                .col-6
+                .col-6(ng:if='hostApp.platform !== Platform.Web')
                     .form-group
                         label Device
                         input.form-control(

+ 3 - 1
tabby-serial/src/components/serialProfileSettings.component.ts

@@ -1,7 +1,7 @@
 /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
 import { Component } from '@angular/core'
 import { debounceTime, distinctUntilChanged, map } from 'rxjs'
-import { ProfileSettingsComponent } from 'tabby-core'
+import { HostAppService, Platform, ProfileSettingsComponent } from 'tabby-core'
 import { SerialPortInfo, BAUD_RATES, SerialProfile } from '../api'
 import { SerialService } from '../services/serial.service'
 
@@ -12,9 +12,11 @@ import { SerialService } from '../services/serial.service'
 export class SerialProfileSettingsComponent implements ProfileSettingsComponent {
     profile: SerialProfile
     foundPorts: SerialPortInfo[]
+    Platform = Platform
 
     constructor (
         private serial: SerialService,
+        public hostApp: HostAppService,
     ) { }
 
     portsAutocomplete = text$ => text$.pipe(map(() => {

+ 1 - 1
tabby-serial/src/components/serialTab.component.pug

@@ -8,7 +8,7 @@
 
     .mr-auto
 
-    button.btn.btn-sm.btn-link.mr-3((click)='changeBaudRate()', *ngIf='session && session.open')
+    button.btn.btn-sm.btn-link.mr-3((click)='changeBaudRate()', *ngIf='session && session.open && hostApp.platform !== Platform.Web')
         span Change baud rate
 
     button.btn.btn-sm.btn-link((click)='reconnect()', *ngIf='!session || !session.open')

+ 2 - 1
tabby-serial/src/components/serialTab.component.ts

@@ -2,7 +2,7 @@
 import colors from 'ansi-colors'
 import { Component, Injector } from '@angular/core'
 import { first } from 'rxjs'
-import { SelectorService } from 'tabby-core'
+import { Platform, SelectorService } from 'tabby-core'
 import { BaseTerminalTabComponent } from 'tabby-terminal'
 import { SerialSession, BAUD_RATES, SerialProfile } from '../api'
 
@@ -17,6 +17,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
     profile?: SerialProfile
     session: SerialSession|null = null
     serialPort: any
+    Platform = Platform
 
     // eslint-disable-next-line @typescript-eslint/no-useless-constructor
     constructor (

+ 24 - 24
tabby-serial/src/profiles.ts

@@ -1,8 +1,9 @@
 import slugify from 'slugify'
+import SerialPort from 'serialport'
+import WSABinding from 'serialport-binding-webserialapi'
 import deepClone from 'clone-deep'
 import { Injectable } from '@angular/core'
-import { ProfileProvider, NewTabParameters, SelectorService } from 'tabby-core'
-import { InputMode, NewlineMode } from 'tabby-terminal'
+import { ProfileProvider, NewTabParameters, SelectorService, HostAppService, Platform } from 'tabby-core'
 import { SerialProfileSettingsComponent } from './components/serialProfileSettings.component'
 import { SerialTabComponent } from './components/serialTab.component'
 import { SerialService } from './services/serial.service'
@@ -35,44 +36,43 @@ export class SerialProfilesService extends ProfileProvider {
     constructor (
         private selector: SelectorService,
         private serial: SerialService,
-    ) { super() }
+        private hostApp: HostAppService,
+    ) {
+        super()
+        if (hostApp.platform === Platform.Web) {
+            SerialPort.Binding = WSABinding
+        }
+    }
 
     async getBuiltinProfiles (): Promise<SerialProfile[]> {
+        if (this.hostApp.platform === Platform.Web) {
+            return [
+                {
+                    id: `serial:web`,
+                    type: 'serial',
+                    name: 'Serial connection',
+                    icon: 'fas fa-microchip',
+                    isBuiltin: true,
+                } as SerialProfile,
+            ]
+        }
+
         return [
             {
                 id: `serial:template`,
                 type: 'serial',
                 name: 'Serial connection',
                 icon: 'fas fa-microchip',
-                options: {
-                    port: '',
-                    databits: 8,
-                    parity: 'none',
-                    rtscts: false,
-                    stopbits: 1,
-                    xany: false,
-                    xoff: false,
-                    xon: false,
-                    inputMode: 'local-echo' as InputMode,
-                    outputMode: null,
-                    inputNewlines: null,
-                    outputNewlines: 'crlf' as NewlineMode,
-                },
                 isBuiltin: true,
                 isTemplate: true,
-            },
+            } as SerialProfile,
             ...(await this.serial.listPorts()).map(p => ({
                 id: `serial:port-${slugify(p.name).replace('.', '-')}`,
                 type: 'serial',
                 name: p.description ? `Serial: ${p.description}` : 'Serial',
                 icon: 'fas fa-microchip',
                 isBuiltin: true,
-                options: {
-                    port: p.name,
-                    inputMode: 'local-echo' as InputMode,
-                    outputNewlines: 'crlf' as NewlineMode,
-                },
-            })),
+            } as SerialProfile)),
         ]
     }
 

+ 34 - 0
tabby-serial/yarn.lock

@@ -2,6 +2,20 @@
 # yarn lockfile v1
 
 
+"@serialport/binding-abstract@^9.0.2":
+  version "9.0.7"
+  resolved "https://registry.yarnpkg.com/@serialport/binding-abstract/-/binding-abstract-9.0.7.tgz#d2c7ecea0f100bdf20187bfc0d34ba90f5504e1e"
+  integrity sha512-g1ncCMIG9rMsxo/28ObYmXZcHThlvtZygsCANmyMUuFS7SwXY4+PhcEnt2+ZcMkEDNRiOklT+ngtIVx5GGpt/A==
+  dependencies:
+    debug "^4.3.1"
+
+"@serialport/stream@^9.0.2":
+  version "9.0.7"
+  resolved "https://registry.yarnpkg.com/@serialport/stream/-/stream-9.0.7.tgz#0bf023eb0233a714fcc5a86de09e381e466d9882"
+  integrity sha512-c/h7HPAeFiryD9iTGlaSvPqHFHSZ0NMQHxC4rcmKS2Vu3qJuEtkBdTLABwsMp7iWEiSnI4KC3s7bHapaXP06FQ==
+  dependencies:
+    debug "^4.3.1"
+
 "@types/[email protected]":
   version "14.14.14"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae"
@@ -11,3 +25,23 @@ ansi-colors@^4.1.1:
   version "4.1.1"
   resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
   integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
+
+debug@^4.3.1:
+  version "4.3.2"
+  resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
+  integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
+  dependencies:
+    ms "2.1.2"
+
[email protected]:
+  version "2.1.2"
+  resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
+  integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
+
+serialport-binding-webserialapi@^1.0.3:
+  version "1.0.3"
+  resolved "https://registry.yarnpkg.com/serialport-binding-webserialapi/-/serialport-binding-webserialapi-1.0.3.tgz#cf4348c075da2de8f6cf9936c0b95645f3ae657b"
+  integrity sha512-TS7dsvetVoTeiWlzpsT/akjtljiYPO56FoJWSFyJSoO/E8icYJ2neQ7CW5NW/sHZDnMqAxULyAny47UFhWz9oQ==
+  dependencies:
+    "@serialport/binding-abstract" "^9.0.2"
+    "@serialport/stream" "^9.0.2"

+ 1 - 1
tabby-settings/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-settings",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Tabby terminal settings page",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-ssh/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-ssh",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "SSH connections for Tabby",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-telnet/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-telnet",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Telnet/socket connections for Tabby",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-terminal/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-terminal",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Tabby's terminal emulation core",
   "keywords": [
     "tabby-builtin-plugin"

+ 1 - 1
tabby-web-demo/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-web-demo",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "main": "dist/index.js",
   "typings": "dist/index.d.ts",
   "scripts": {

+ 1 - 1
tabby-web/package.json

@@ -1,6 +1,6 @@
 {
   "name": "tabby-web",
-  "version": "1.0.147-nightly.1",
+  "version": "1.0.147-nightly.2",
   "description": "Web-specific bindings",
   "keywords": [
     "tabby-builtin-plugin"

+ 3 - 0
web/entry.preload.ts

@@ -102,6 +102,9 @@ Object.assign(window, {
         stderr: {},
         resourcesPath: 'resources',
         version: '14.0.0',
+        versions: {
+            modules: 0,
+        },
         nextTick: (f, ...args) => setTimeout(() => f(...args)),
         cwd: () => '/',
     },

+ 2 - 1
web/package.json

@@ -10,10 +10,11 @@
         "events": "^3.3.0",
         "patch-package": "^6.4.7",
         "path-browserify": "^1.0.1",
+        "readline-browserify": "^0.0.4",
         "stream-browserify": "^3.0.0"
     },
     "resolutions": {
         "**/util": "^0.12.0"
     },
-    "version": "1.0.147-nightly.1"
+    "version": "1.0.147-nightly.2"
 }

+ 6 - 4
web/polyfills.ts

@@ -58,10 +58,6 @@ Tabby.registerMock('fs', {
     appendFile: () => null,
     constants: {},
 })
-Tabby.registerMock('readline', {
-    cursorTo: () => null,
-    clearLine: stream => stream.write('\r'),
-})
 Tabby.registerMock('any-promise', Promise)
 Tabby.registerMock('tls', {})
 Tabby.registerMock('module', {
@@ -124,6 +120,7 @@ Tabby.registerMock('util', require('util/'))
 Tabby.registerMock('keytar', {
     getPassword: () => null,
 })
+Tabby.registerMock('@serialport/bindings', {})
 
 Tabby.registerModule('net', {
     Socket: SocketProxy,
@@ -143,6 +140,11 @@ Tabby.registerModule('assert', Object.assign(
 ))
 Tabby.registerModule('constants', require('constants-browserify'))
 Tabby.registerModule('stream', require('stream-browserify'))
+Tabby.registerModule('readline', {
+    ...require('readline-browserify'),
+    cursorTo: () => null,
+    clearLine: stream => stream.write('\r'),
+})
 
 Tabby.registerModule('@angular/core', angularCoreModule)
 Tabby.registerModule('@angular/compiler', angularCompilerModule)

+ 5 - 0
web/yarn.lock

@@ -800,6 +800,11 @@ readable-stream@^3.5.0, readable-stream@^3.6.0:
     string_decoder "^1.1.1"
     util-deprecate "^1.0.1"
 
+readline-browserify@^0.0.4:
+  version "0.0.4"
+  resolved "https://registry.yarnpkg.com/readline-browserify/-/readline-browserify-0.0.4.tgz#d4367efe1e74881ea9deb836f69a608b885ffc7c"
+  integrity sha1-1DZ+/h50iB6p3rg29ppgi4hf/Hw=
+
 rimraf@^2.6.3:
   version "2.7.1"
   resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"

+ 1 - 1
webpack.plugin.config.js

@@ -98,6 +98,7 @@ module.exports = options => {
         },
         externals: [
             '@electron/remote',
+            '@serialport/bindings',
             'any-promise',
             'child_process',
             'electron-promise-ipc',
@@ -112,7 +113,6 @@ module.exports = options => {
             'os',
             'path',
             'readline',
-            'serialport',
             'socksv5',
             'stream',
             'windows-native-registry',