|
|
@ -5,7 +5,6 @@ import JSZip from 'jszip' |
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import { Plugin } from '@remixproject/engine' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
import * as packageJson from '../../../../../package.json' |
|
|
|
import {Registry} from '@remix-project/remix-lib' |
|
|
|
import {Registry} from '@remix-project/remix-lib' |
|
|
|
import { EventEmitter } from 'events' |
|
|
|
|
|
|
|
import { fileChangedToastMsg, recursivePasteToastMsg, storageFullMessage } from '@remix-ui/helper' |
|
|
|
import { fileChangedToastMsg, recursivePasteToastMsg, storageFullMessage } from '@remix-ui/helper' |
|
|
|
import helper from '../../lib/helper.js' |
|
|
|
import helper from '../../lib/helper.js' |
|
|
|
import { RemixAppManager } from '../../remixAppManager' |
|
|
|
import { RemixAppManager } from '../../remixAppManager' |
|
|
@ -42,7 +41,6 @@ const createError = (err) => { |
|
|
|
class FileManager extends Plugin { |
|
|
|
class FileManager extends Plugin { |
|
|
|
mode: string |
|
|
|
mode: string |
|
|
|
openedFiles: any |
|
|
|
openedFiles: any |
|
|
|
events: EventEmitter |
|
|
|
|
|
|
|
editor: any |
|
|
|
editor: any |
|
|
|
_components: any |
|
|
|
_components: any |
|
|
|
appManager: RemixAppManager |
|
|
|
appManager: RemixAppManager |
|
|
@ -56,7 +54,6 @@ class FileManager extends Plugin { |
|
|
|
super(profile) |
|
|
|
super(profile) |
|
|
|
this.mode = 'browser' |
|
|
|
this.mode = 'browser' |
|
|
|
this.openedFiles = {} // list all opened files
|
|
|
|
this.openedFiles = {} // list all opened files
|
|
|
|
this.events = new EventEmitter() |
|
|
|
|
|
|
|
this.editor = editor |
|
|
|
this.editor = editor |
|
|
|
this._components = {} |
|
|
|
this._components = {} |
|
|
|
this._components.registry = Registry.getInstance() |
|
|
|
this._components.registry = Registry.getInstance() |
|
|
@ -565,7 +562,6 @@ class FileManager extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('fileRenamed', oldName, newName, isFolder) |
|
|
|
this.emit('fileRenamed', oldName, newName, isFolder) |
|
|
|
this.events.emit('fileRenamed', oldName, newName, isFolder) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
currentFileProvider() { |
|
|
|
currentFileProvider() { |
|
|
@ -583,7 +579,6 @@ class FileManager extends Plugin { |
|
|
|
async closeAllFiles() { |
|
|
|
async closeAllFiles() { |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('filesAllClosed') |
|
|
|
this.emit('filesAllClosed') |
|
|
|
this.events.emit('filesAllClosed') |
|
|
|
|
|
|
|
for (const file in this.openedFiles) { |
|
|
|
for (const file in this.openedFiles) { |
|
|
|
await this.closeFile(file) |
|
|
|
await this.closeFile(file) |
|
|
|
} |
|
|
|
} |
|
|
@ -595,11 +590,9 @@ class FileManager extends Plugin { |
|
|
|
this._deps.config.set('currentFile', '') |
|
|
|
this._deps.config.set('currentFile', '') |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('noFileSelected') |
|
|
|
this.emit('noFileSelected') |
|
|
|
this.events.emit('noFileSelected') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('fileClosed', name) |
|
|
|
this.emit('fileClosed', name) |
|
|
|
this.events.emit('fileClosed', name) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
currentPath() { |
|
|
|
currentPath() { |
|
|
@ -703,22 +696,21 @@ class FileManager extends Plugin { |
|
|
|
delete this.openedFiles[path] |
|
|
|
delete this.openedFiles[path] |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('fileRemoved', path) |
|
|
|
this.emit('fileRemoved', path) |
|
|
|
this.events.emit('fileRemoved', path) |
|
|
|
if (path === this._deps.config.get('currentFile')) { |
|
|
|
this.openFile(this._deps.config.get('currentFile')) |
|
|
|
this.openFile(this._deps.config.get('currentFile')) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async unselectCurrentFile() { |
|
|
|
async unselectCurrentFile() { |
|
|
|
await this.saveCurrentFile() |
|
|
|
await this.saveCurrentFile() |
|
|
|
this._deps.config.set('currentFile', '') |
|
|
|
this._deps.config.set('currentFile', '') |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('noFileSelected') |
|
|
|
this.emit('noFileSelected') |
|
|
|
this.events.emit('noFileSelected') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async openFile(file?: string) { |
|
|
|
async openFile(file?: string) { |
|
|
|
if (!file) { |
|
|
|
if (!file) { |
|
|
|
this.emit('noFileSelected') |
|
|
|
this.emit('noFileSelected') |
|
|
|
this.events.emit('noFileSelected') |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
file = this.normalize(file) |
|
|
|
file = this.normalize(file) |
|
|
|
const resolved = this.getPathFromUrl(file) |
|
|
|
const resolved = this.getPathFromUrl(file) |
|
|
@ -752,7 +744,6 @@ class FileManager extends Plugin { |
|
|
|
} |
|
|
|
} |
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
// TODO: Only keep `this.emit` (issue#2210)
|
|
|
|
this.emit('currentFileChanged', file) |
|
|
|
this.emit('currentFileChanged', file) |
|
|
|
this.events.emit('currentFileChanged', file) |
|
|
|
|
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|