rdesktop2
filip mertens 1 year ago
parent 673258ef87
commit d2eea4eea2
  1. 56
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 10
      apps/remix-ide/src/app/files/electronProvider.ts
  3. 2
      apps/remix-ide/src/app/files/fileManager.ts
  4. 31
      apps/remix-ide/src/app/files/fileProvider.ts
  5. 1
      apps/remix-ide/src/app/panels/terminal.js
  6. 1
      apps/remix-ide/src/app/tabs/theme-module.js
  7. 1
      apps/remix-ide/src/remixAppManager.js

@ -10,10 +10,11 @@ import {
} from 'file-saver'
import http from 'isomorphic-git/http/web'
const JSZip = require('jszip')
const path = require('path')
const FormData = require('form-data')
const axios = require('axios')
import JSZip from 'jszip'
import path from 'path'
import FormData from 'form-data'
import axios from 'axios'
import isElectron from 'is-electron'
const profile = {
name: 'dGitProvider',
@ -25,6 +26,12 @@ const profile = {
kind: 'file-system'
}
class DGitProvider extends Plugin {
ipfsconfig: { host: string; port: number; protocol: string; ipfsurl: string }
globalIPFSConfig: { host: string; port: number; protocol: string; ipfsurl: string }
remixIPFS: { host: string; port: number; protocol: string; ipfsurl: string }
ipfsSources: any[]
ipfs: any
filesToSend: any[]
constructor() {
super(profile)
this.ipfsconfig = {
@ -48,9 +55,6 @@ class DGitProvider extends Plugin {
this.ipfsSources = [this.remixIPFS, this.globalIPFSConfig, this.ipfsconfig]
}
async onActivation() {
}
async getGitConfig() {
if (isElectron()) {
@ -84,7 +88,7 @@ class DGitProvider extends Plugin {
}
}
async init(input) {
async init(input?) {
if (isElectron()) {
await this.call('isogit', 'init', {
defaultBranch: (input && input.branch) || 'main'
@ -346,7 +350,7 @@ class DGitProvider extends Plugin {
})
}
async checkIpfsConfig(config) {
async checkIpfsConfig(config?) {
this.ipfs = IpfsHttpClient(config || this.ipfsconfig)
try {
await this.ipfs.config.getAll()
@ -395,7 +399,7 @@ class DGitProvider extends Plugin {
} else {
const permission = await this.askUserPermission('clone', 'Import multiple files into your workspaces.')
if (!permission) return false
if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.')
if (parseFloat(this.calculateLocalStorage()) > 10000) throw new Error('The local storage of the browser is full.')
if (!workspaceExists) await this.call('filePanel', 'createWorkspace', workspaceName || `workspace_${Date.now()}`, true)
const cmd = {
url: input.url,
@ -427,19 +431,19 @@ class DGitProvider extends Plugin {
name: input.name,
email: input.email
},
input
input,
}
if (isElectron()) {
return await this.call('isogit', 'push', cmd)
} else {
cmd = {
const cmd2 = {
...cmd,
...await this.parseInput(input),
}
return await git.push({
...await this.getGitConfig(),
...cmd
...cmd2
})
}
@ -454,20 +458,20 @@ class DGitProvider extends Plugin {
email: input.email
},
remote: input.remote,
input
input,
}
let result
if (isElectron()) {
result = await this.call('isogit', 'pull', cmd)
}
else {
cmd = {
const cmd2 = {
...cmd,
...await this.parseInput(input),
}
result = await git.pull({
...await this.getGitConfig(),
...cmd
...cmd2
})
}
setTimeout(async () => {
@ -491,13 +495,13 @@ class DGitProvider extends Plugin {
if (isElectron()) {
result = await this.call('isogit', 'fetch', cmd)
} else {
cmd = {
const cmd2 = {
...cmd,
...await this.parseInput(input),
}
result = await git.fetch({
...await this.getGitConfig(),
...cmd
...cmd2
})
}
setTimeout(async () => {
@ -579,15 +583,15 @@ class DGitProvider extends Plugin {
.post(url, data, {
maxBodyLength: 'Infinity',
headers: {
'Content-Type': `multipart/form-data; boundary=${data._boundary}`,
'Content-Type': `multipart/form-data; boundary=${(data as any)._boundary}`,
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
}).catch((e) => {
} as any).catch((e) => {
console.log(e)
})
// also commit to remix IPFS for availability after pinning to Pinata
return await this.export(this.remixIPFS) || result.data.IpfsHash
return await this.export(this.remixIPFS) || (result as any).data.IpfsHash
} catch (error) {
throw new Error(error)
}
@ -603,10 +607,10 @@ class DGitProvider extends Plugin {
pinata_api_key: pinataApiKey,
pinata_secret_api_key: pinataSecretApiKey
}
}).catch((e) => {
} as any).catch((e) => {
console.log('Pinata unreachable')
})
return result.data
return (result as any).data
} catch (error) {
throw new Error(error)
}
@ -658,8 +662,8 @@ class DGitProvider extends Plugin {
}
calculateLocalStorage() {
var _lsTotal = 0
var _xLen; var _x
let _lsTotal = 0
let _xLen; let _x
for (_x in localStorage) {
// eslint-disable-next-line no-prototype-builtins
if (!localStorage.hasOwnProperty(_x)) {
@ -674,7 +678,7 @@ class DGitProvider extends Plugin {
async import(cmd) {
const permission = await this.askUserPermission('import', 'Import multiple files into your workspaces.')
if (!permission) return false
if (this.calculateLocalStorage() > 10000) throw new Error('The local storage of the browser is full.')
if (parseFloat(this.calculateLocalStorage()) > 10000) throw new Error('The local storage of the browser is full.')
const cid = cmd.cid
await this.call('filePanel', 'createWorkspace', `workspace_${Date.now()}`, true)
const workspace = await this.call('filePanel', 'getCurrentWorkspace')

@ -1,4 +1,5 @@
const FileProvider = require('./fileProvider')
import { FileProvider } from "./fileProvider"
declare global {
interface Window {
@ -7,6 +8,7 @@ declare global {
}
export class ElectronProvider extends FileProvider {
_appManager: any
constructor(appManager) {
super('')
this._appManager = appManager
@ -48,7 +50,7 @@ export class ElectronProvider extends FileProvider {
const files = await window.remixFileSystem.readdir(path)
const ret = {}
if (files) {
for (let element of files) {
for (const element of files) {
path = path.replace(/^\/|\/$/g, '') // remove first and last slash
const file = element.file.replace(/^\/|\/$/g, '') // remove first and last slash
const absPath = (path === '/' ? '' : path) + '/' + file
@ -68,12 +70,14 @@ export class ElectronProvider extends FileProvider {
* Removes the folder recursively
* @param {*} path is the folder to be removed
*/
async remove(path) {
async remove(path: string) {
console.log('remove', path)
try {
await window.remixFileSystem.rmdir(path)
return true
} catch (error) {
console.log(error)
return false
}
}

@ -9,7 +9,7 @@ import { fileChangedToastMsg, recursivePasteToastMsg, storageFullMessage } from
import helper from '../../lib/helper.js'
import { RemixAppManager } from '../../remixAppManager'
const isElectron = require('is-electron')
import isElectron from 'is-electron'
/*
attach to files event (removed renamed)

@ -1,12 +1,17 @@
'use strict'
import { CompilerImports } from '@remix-project/core-plugin'
const EventManager = require('events')
const remixLib = require('@remix-project/remix-lib')
const pathModule = require('path')
const Storage = remixLib.Storage
import EventManager from 'events'
import { Storage } from '@remix-project/remix-lib'
import pathModule from 'path'
export class FileProvider {
event: any
type: any
providerExternalsStorage: any
externalFolders: string[]
reverseKey: string
constructor (name) {
this.event = new EventManager()
this.type = name
@ -79,7 +84,7 @@ export class FileProvider {
async _exists (path) {
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
var unprefixedpath = this.removePrefix(path)
const unprefixedpath = this.removePrefix(path)
return path === this.type ? true : await window.remixFileSystem.exists(unprefixedpath)
}
@ -90,7 +95,7 @@ export class FileProvider {
async get (path, cb) {
cb = cb || function () { /* do nothing. */ }
path = this.getPathFromUrl(path) || path // ensure we actually use the normalized path from here
var unprefixedpath = this.removePrefix(path)
const unprefixedpath = this.removePrefix(path)
try {
const content = await window.remixFileSystem.readFile(unprefixedpath, 'utf8')
if (cb) cb(null, content)
@ -103,13 +108,13 @@ export class FileProvider {
async set (path, content, cb) {
cb = cb || function () { /* do nothing. */ }
var unprefixedpath = this.removePrefix(path)
const unprefixedpath = this.removePrefix(path)
const exists = await window.remixFileSystem.exists(unprefixedpath)
if (exists && await window.remixFileSystem.readFile(unprefixedpath, 'utf8') === content) {
if (cb) cb()
return null
}
await this.createDir(path.substr(0, path.lastIndexOf('/')))
await this.createDir(path.substr(0, path.lastIndexOf('/')), null)
try {
await window.remixFileSystem.writeFile(unprefixedpath, content, 'utf8')
} catch (e) {
@ -152,7 +157,7 @@ export class FileProvider {
// this will not add a folder as readonly but keep the original url to be able to restore it later
async addExternal (path, content, url) {
if (url) this.addNormalizedName(path, url)
return await this.set(path, content)
return await this.set(path, content, null)
}
isReadOnly (path) {
@ -175,7 +180,7 @@ export class FileProvider {
* Removes the folder recursively
* @param {*} path is the folder to be removed
*/
async remove (path) {
async remove (path: string) {
path = this.removePrefix(path)
if (await window.remixFileSystem.exists(path)) {
const stat = await window.remixFileSystem.stat(path)
@ -226,7 +231,7 @@ export class FileProvider {
visitFolder({ path })
if (items.length !== 0) {
for (const item of items) {
const file = {}
const file: any = {}
const curPath = `${path}${path.endsWith('/') ? '' : '/'}${item}`
if ((await window.remixFileSystem.stat(curPath)).isDirectory()) {
file.children = await this._copyFolderToJsonInternal(curPath, visitFile, visitFolder)
@ -267,8 +272,8 @@ export class FileProvider {
}
async rename (oldPath, newPath, isFolder) {
var unprefixedoldPath = this.removePrefix(oldPath)
var unprefixednewPath = this.removePrefix(newPath)
const unprefixedoldPath = this.removePrefix(oldPath)
const unprefixednewPath = this.removePrefix(newPath)
if (await this._exists(unprefixedoldPath)) {
await window.remixFileSystem.rename(unprefixedoldPath, unprefixednewPath)
this.event.emit('fileRenamed',

@ -6,6 +6,7 @@ import * as packageJson from '../../../../../package.json'
import Registry from '../state/registry'
import { PluginViewWrapper } from '@remix-ui/helper'
import vm from 'vm'
import isElectron from 'is-electron'
const EventManager = require('../../lib/events')
import { CompilerImports } from '@remix-project/core-plugin' // eslint-disable-line

@ -3,6 +3,7 @@ import { EventEmitter } from 'events'
import { QueryParams } from '@remix-project/remix-lib'
import * as packageJson from '../../../../../package.json'
import Registry from '../state/registry'
const isElectron = require('is-electron')
const _paq = window._paq = window._paq || []
const themes = [

@ -2,6 +2,7 @@ import { PluginManager } from '@remixproject/engine'
import { EventEmitter } from 'events'
import { QueryParams } from '@remix-project/remix-lib'
import { IframePlugin } from '@remixproject/engine-web'
const isElectron = require('is-electron')
const _paq = window._paq = window._paq || []
// requiredModule removes the plugin from the plugin manager list on UI

Loading…
Cancel
Save