mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 18:38:01 +00:00
pass the web connector via an angular provider
This commit is contained in:
@@ -64,8 +64,7 @@
|
|||||||
"**/graceful-fs": "^4.2.4"
|
"**/graceful-fs": "^4.2.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:typings && webpack --color --config app/webpack.main.config.js && webpack --color --config app/webpack.config.js && webpack --color --config terminus-core/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-terminal/webpack.config.js && webpack --color --config terminus-local/webpack.config.js && webpack --color --config terminus-plugin-manager/webpack.config.js && webpack --color --config terminus-community-color-schemes/webpack.config.js && webpack --color --config terminus-ssh/webpack.config.js && webpack --color --config terminus-serial/webpack.config.js && webpack --color --config terminus-electron/webpack.config.js && webpack --color --config terminus-web/webpack.config.js",
|
"build": "npm run build:typings && webpack --color --config app/webpack.main.config.js && webpack --color --config app/webpack.config.js && webpack --color --config terminus-core/webpack.config.js && webpack --color --config terminus-settings/webpack.config.js && webpack --color --config terminus-terminal/webpack.config.js && webpack --color --config terminus-local/webpack.config.js && webpack --color --config terminus-plugin-manager/webpack.config.js && webpack --color --config terminus-community-color-schemes/webpack.config.js && webpack --color --config terminus-ssh/webpack.config.js && webpack --color --config terminus-serial/webpack.config.js && webpack --color --config terminus-electron/webpack.config.js && webpack --color --config terminus-web/webpack.config.js && webpack --color --config web/webpack.config.js",
|
||||||
"build:web": "webpack --color --config web/webpack.config.js",
|
|
||||||
"build:typings": "node scripts/build-typings.js",
|
"build:typings": "node scripts/build-typings.js",
|
||||||
"watch": "cross-env TERMINUS_DEV=1 webpack --progress --color --watch",
|
"watch": "cross-env TERMINUS_DEV=1 webpack --progress --color --watch",
|
||||||
"start": "cross-env TERMINUS_DEV=1 electron app --debug --inspect",
|
"start": "cross-env TERMINUS_DEV=1 electron app --debug --inspect",
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import '@vaadin/vaadin-context-menu/vaadin-context-menu.js'
|
import '@vaadin/vaadin-context-menu/vaadin-context-menu.js'
|
||||||
import copyToClipboard from 'copy-text-to-clipboard'
|
import copyToClipboard from 'copy-text-to-clipboard'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { PlatformService, ClipboardContent, MenuItemOptions, MessageBoxOptions, MessageBoxResult, FileUpload, FileUploadOptions, FileDownload, HTMLFileUpload } from 'terminus-core'
|
import { PlatformService, ClipboardContent, MenuItemOptions, MessageBoxOptions, MessageBoxResult, FileUpload, FileUploadOptions, FileDownload, HTMLFileUpload } from 'terminus-core'
|
||||||
|
|
||||||
@@ -16,14 +16,13 @@ export class WebPlatformService extends PlatformService {
|
|||||||
private menu: ContextMenuElement
|
private menu: ContextMenuElement
|
||||||
private contextMenuHandlers = new Map<ContextMenuItem, () => void>()
|
private contextMenuHandlers = new Map<ContextMenuItem, () => void>()
|
||||||
private fileSelector: HTMLInputElement
|
private fileSelector: HTMLInputElement
|
||||||
private connector: any
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
|
@Inject('WEB_CONNECTOR') private connector: any,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
this.connector = window['__connector__']
|
|
||||||
|
|
||||||
this.menu = window.document.createElement('vaadin-context-menu')
|
this.menu = window.document.createElement('vaadin-context-menu')
|
||||||
this.menu.addEventListener('item-selected', e => {
|
this.menu.addEventListener('item-selected', e => {
|
||||||
this.contextMenuHandlers.get(e.detail.value)?.()
|
this.contextMenuHandlers.get(e.detail.value)?.()
|
||||||
|
17
web/entry.ts
17
web/entry.ts
@@ -15,19 +15,25 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|||||||
import { getRootModule } from '../app/src/app.module'
|
import { getRootModule } from '../app/src/app.module'
|
||||||
import { BootstrapData, BOOTSTRAP_DATA } from '../terminus-core/src/api/mainProcess'
|
import { BootstrapData, BOOTSTRAP_DATA } from '../terminus-core/src/api/mainProcess'
|
||||||
|
|
||||||
|
interface BootstrapOptions {
|
||||||
|
packageModules: any[]
|
||||||
|
bootstrapData: BootstrapData
|
||||||
|
debugMode: boolean
|
||||||
|
connector: any
|
||||||
|
}
|
||||||
|
|
||||||
window['bootstrapTerminus'] = async function bootstrap (packageModules: any[], bootstrapData: BootstrapData, debugMode = false): Promise<NgModuleRef<any>> {
|
window['bootstrapTerminus'] = async function bootstrap (options: BootstrapOptions): Promise<NgModuleRef<any>> {
|
||||||
window.parent.postMessage('request-connector', '*')
|
window.parent.postMessage('request-connector', '*')
|
||||||
|
|
||||||
const pluginModules = []
|
const pluginModules = []
|
||||||
for (const packageModule of packageModules) {
|
for (const packageModule of options.packageModules) {
|
||||||
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
const pluginModule = packageModule.default.forRoot ? packageModule.default.forRoot() : packageModule.default
|
||||||
pluginModule.pluginName = packageModule.pluginName
|
pluginModule.pluginName = packageModule.pluginName
|
||||||
pluginModule.bootstrap = packageModule.bootstrap
|
pluginModule.bootstrap = packageModule.bootstrap
|
||||||
pluginModules.push(pluginModule)
|
pluginModules.push(pluginModule)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!debugMode) {
|
if (!options.debugMode) {
|
||||||
enableProdMode()
|
enableProdMode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,9 +41,10 @@ window['bootstrapTerminus'] = async function bootstrap (packageModules: any[], b
|
|||||||
window['rootModule'] = module
|
window['rootModule'] = module
|
||||||
|
|
||||||
const moduleRef = await platformBrowserDynamic([
|
const moduleRef = await platformBrowserDynamic([
|
||||||
{ provide: BOOTSTRAP_DATA, useValue: bootstrapData },
|
{ provide: BOOTSTRAP_DATA, useValue: options.bootstrapData },
|
||||||
|
{ provide: 'WEB_CONNECTOR', useValue: options.connector },
|
||||||
]).bootstrapModule(module)
|
]).bootstrapModule(module)
|
||||||
if (debugMode) {
|
if (options.debugMode) {
|
||||||
const applicationRef = moduleRef.injector.get(ApplicationRef)
|
const applicationRef = moduleRef.injector.get(ApplicationRef)
|
||||||
const componentRef = applicationRef.components[0]
|
const componentRef = applicationRef.components[0]
|
||||||
enableDebugTools(componentRef)
|
enableDebugTools(componentRef)
|
||||||
|
@@ -12,4 +12,5 @@ module.exports = [
|
|||||||
require('./terminus-ssh/webpack.config.js'),
|
require('./terminus-ssh/webpack.config.js'),
|
||||||
require('./terminus-serial/webpack.config.js'),
|
require('./terminus-serial/webpack.config.js'),
|
||||||
require('./terminus-web/webpack.config.js'),
|
require('./terminus-web/webpack.config.js'),
|
||||||
|
require('./web/webpack.config.js'),
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user