Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
e770920b
C
code-server
项目概览
myhjmzy
/
code-server
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
code-server
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e770920b
编写于
2月 05, 2019
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove block padding (blank lines)
Also made a rule for it.
上级
dc08df55
变更
43
隐藏空白更改
内联
并排
Showing
43 changed file
with
108 addition
and
189 deletion
+108
-189
packages/disposable/src/disposable.ts
packages/disposable/src/disposable.ts
+0
-2
packages/events/src/events.ts
packages/events/src/events.ts
+1
-3
packages/ide/src/client.ts
packages/ide/src/client.ts
+0
-2
packages/ide/src/fill/client.ts
packages/ide/src/fill/client.ts
+0
-2
packages/ide/src/fill/clipboard.ts
packages/ide/src/fill/clipboard.ts
+1
-3
packages/ide/src/fill/dialog.ts
packages/ide/src/fill/dialog.ts
+0
-8
packages/ide/src/fill/electron.ts
packages/ide/src/fill/electron.ts
+0
-22
packages/ide/src/fill/notification.ts
packages/ide/src/fill/notification.ts
+1
-46
packages/ide/src/fill/os.ts
packages/ide/src/fill/os.ts
+1
-2
packages/ide/src/fill/uri.ts
packages/ide/src/fill/uri.ts
+0
-4
packages/ide/src/retry.ts
packages/ide/src/retry.ts
+0
-2
packages/ide/src/upload.ts
packages/ide/src/upload.ts
+0
-2
packages/logger/src/logger.ts
packages/logger/src/logger.ts
+0
-12
packages/protocol/src/browser/client.ts
packages/protocol/src/browser/client.ts
+0
-2
packages/protocol/src/browser/command.ts
packages/protocol/src/browser/command.ts
+0
-4
packages/protocol/src/browser/modules/child_process.ts
packages/protocol/src/browser/modules/child_process.ts
+0
-2
packages/protocol/src/browser/modules/fs.ts
packages/protocol/src/browser/modules/fs.ts
+0
-8
packages/protocol/src/browser/modules/net.ts
packages/protocol/src/browser/modules/net.ts
+0
-2
packages/protocol/src/node/evaluate.ts
packages/protocol/src/node/evaluate.ts
+1
-1
packages/protocol/src/node/server.ts
packages/protocol/src/node/server.ts
+0
-2
packages/protocol/test/evaluate.test.ts
packages/protocol/test/evaluate.test.ts
+5
-5
packages/requirefs/src/requirefs.ts
packages/requirefs/src/requirefs.ts
+0
-2
packages/requirefs/src/tarReader.ts
packages/requirefs/src/tarReader.ts
+0
-6
packages/server/src/cli.ts
packages/server/src/cli.ts
+2
-4
packages/server/src/fill.ts
packages/server/src/fill.ts
+2
-2
packages/server/src/ipc.ts
packages/server/src/ipc.ts
+1
-3
packages/server/src/server.ts
packages/server/src/server.ts
+1
-1
packages/server/src/vscode/sharedProcess.ts
packages/server/src/vscode/sharedProcess.ts
+1
-2
packages/vscode/src/client.ts
packages/vscode/src/client.ts
+0
-2
packages/vscode/src/fill/codeEditor.ts
packages/vscode/src/fill/codeEditor.ts
+0
-2
packages/vscode/src/fill/environmentService.ts
packages/vscode/src/fill/environmentService.ts
+0
-2
packages/vscode/src/fill/iconv-lite.ts
packages/vscode/src/fill/iconv-lite.ts
+0
-1
packages/vscode/src/fill/mouseEvent.ts
packages/vscode/src/fill/mouseEvent.ts
+0
-2
packages/vscode/src/fill/native-keymap.ts
packages/vscode/src/fill/native-keymap.ts
+0
-2
packages/vscode/src/fill/native-watchdog.ts
packages/vscode/src/fill/native-watchdog.ts
+0
-2
packages/vscode/src/fill/node-pty.ts
packages/vscode/src/fill/node-pty.ts
+0
-4
packages/vscode/src/fill/paste.ts
packages/vscode/src/fill/paste.ts
+0
-6
packages/vscode/src/fill/spdlog.ts
packages/vscode/src/fill/spdlog.ts
+0
-2
packages/vscode/src/fill/stdioElectron.ts
packages/vscode/src/fill/stdioElectron.ts
+0
-2
packages/vscode/src/fill/storageDatabase.ts
packages/vscode/src/fill/storageDatabase.ts
+0
-4
packages/vscode/src/fill/windowsService.ts
packages/vscode/src/fill/windowsService.ts
+0
-2
rules/src/noBlockPaddingRule.ts
rules/src/noBlockPaddingRule.ts
+89
-0
tslint.json
tslint.json
+2
-0
未找到文件。
packages/disposable/src/disposable.ts
浏览文件 @
e770920b
export
interface
IDisposable
{
dispose
():
void
;
}
packages/events/src/events.ts
浏览文件 @
e770920b
...
...
@@ -8,7 +8,6 @@ export interface Event<T> {
* Emitter typecasts for a single event type
*/
export
class
Emitter
<
T
>
{
private
listeners
:
Array
<
(
e
:
T
)
=>
void
>
|
undefined
;
public
constructor
()
{
...
...
@@ -56,5 +55,4 @@ export class Emitter<T> {
public
get
hasListeners
():
boolean
{
return
!!
this
.
listeners
&&
this
.
listeners
.
length
>
0
;
}
}
\ No newline at end of file
}
packages/ide/src/client.ts
浏览文件 @
e770920b
...
...
@@ -17,7 +17,6 @@ import { IURIFactory } from "./fill/uri";
* It also provides task management to help asynchronously load and time code.
*/
export
abstract
class
Client
{
public
readonly
retry
=
retry
;
public
readonly
clipboard
=
clipboard
;
public
readonly
uriFactory
:
IURIFactory
;
...
...
@@ -191,5 +190,4 @@ export abstract class Client {
* Create URI factory.
*/
protected
abstract
createUriFactory
():
IURIFactory
;
}
packages/ide/src/fill/client.ts
浏览文件 @
e770920b
...
...
@@ -8,7 +8,6 @@ import { retry } from "../retry";
* messages during connection.
*/
class
Connection
implements
ReadWriteConnection
{
private
activeSocket
:
WebSocket
|
undefined
;
private
readonly
messageEmitter
:
Emitter
<
Uint8Array
>
=
new
Emitter
();
private
readonly
closeEmitter
:
Emitter
<
void
>
=
new
Emitter
();
...
...
@@ -143,7 +142,6 @@ class Connection implements ReadWriteConnection {
this
.
activeSocket
.
close
();
}
}
}
// Global instance so all fills can use the same client.
...
...
packages/ide/src/fill/clipboard.ts
浏览文件 @
e770920b
...
...
@@ -2,10 +2,9 @@ import { IDisposable } from "@coder/disposable";
import
{
Emitter
}
from
"
@coder/events
"
;
/**
*
Native clipboard
.
*
Wrapper around the native clipboard with some fallbacks
.
*/
export
class
Clipboard
{
private
readonly
enableEmitter
:
Emitter
<
boolean
>
=
new
Emitter
();
private
_isEnabled
:
boolean
=
false
;
...
...
@@ -149,7 +148,6 @@ export class Clipboard {
return
Promise
.
resolve
();
}
}
// Global clipboard instance since it's used in the Electron fill.
...
...
packages/ide/src/fill/dialog.ts
浏览文件 @
e770920b
...
...
@@ -3,9 +3,6 @@ import { Emitter } from "@coder/events";
import
"
./dialog.scss
"
;
/**
* Dialog options.
*/
export
interface
IDialogOptions
{
message
?:
string
;
detail
?:
string
;
...
...
@@ -24,16 +21,12 @@ export interface IDialogAction {
key
?:
IKey
;
}
/**
* Pressed keys.
*/
export
enum
IKey
{
Enter
=
"
Enter
"
,
Escape
=
"
Escape
"
,
}
export
class
Dialog
{
private
options
:
IDialogOptions
;
private
overlay
:
HTMLElement
;
private
cachedActiveElement
:
HTMLElement
|
undefined
;
...
...
@@ -190,5 +183,4 @@ export class Dialog {
});
}
}
}
packages/ide/src/fill/electron.ts
浏览文件 @
e770920b
...
...
@@ -84,7 +84,6 @@ const newCreateElement = <K extends keyof HTMLElementTagNameMap>(tagName: K): HT
document
.
createElement
=
newCreateElement
;
class
Clipboard
{
public
has
():
boolean
{
return
false
;
}
...
...
@@ -92,21 +91,17 @@ class Clipboard {
public
writeText
(
value
:
string
):
Promise
<
void
>
{
return
clipboard
.
writeText
(
value
);
}
}
class
Shell
{
public
async
moveItemToTrash
(
path
:
string
):
Promise
<
void
>
{
await
promisify
(
exec
)(
`trash-put --trash-dir
${
escapePath
(
"
~/.Trash
"
)}
${
escapePath
(
path
)}
`
,
);
}
}
class
App
extends
EventEmitter
{
public
isAccessibilitySupportEnabled
():
boolean
{
return
false
;
}
...
...
@@ -114,11 +109,9 @@ class App extends EventEmitter {
public
setAsDefaultProtocolClient
():
void
{
throw
new
Error
(
"
not implemented
"
);
}
}
class
Dialog
{
public
showSaveDialog
(
_
:
void
,
options
:
Electron
.
SaveDialogOptions
,
callback
:
(
filename
:
string
|
undefined
)
=>
void
):
void
{
const
defaultPath
=
options
.
defaultPath
||
"
/untitled
"
;
const
fileIndex
=
defaultPath
.
lastIndexOf
(
"
/
"
);
...
...
@@ -203,11 +196,9 @@ class Dialog {
});
dialog
.
show
();
}
}
class
WebFrame
{
public
getZoomFactor
():
number
{
return
1
;
}
...
...
@@ -219,19 +210,15 @@ class WebFrame {
public
setZoomLevel
():
void
{
// Nothing.
}
}
class
Screen
{
public
getAllDisplays
():
[]
{
return
[];
}
}
class
WebRequest
extends
EventEmitter
{
public
onBeforeRequest
():
void
{
throw
new
Error
(
"
not implemented
"
);
}
...
...
@@ -243,28 +230,22 @@ class WebRequest extends EventEmitter {
public
onHeadersReceived
():
void
{
throw
new
Error
(
"
not implemented
"
);
}
}
class
Session
extends
EventEmitter
{
public
webRequest
=
new
WebRequest
();
public
resolveProxy
(
url
:
string
,
callback
:
(
proxy
:
string
)
=>
void
):
void
{
// TODO: not sure what this actually does.
callback
(
url
);
}
}
class
WebContents
extends
EventEmitter
{
public
session
=
new
Session
();
}
class
BrowserWindow
extends
EventEmitter
{
public
webContents
=
new
WebContents
();
private
representedFilename
:
string
=
""
;
...
...
@@ -323,7 +304,6 @@ class BrowserWindow extends EventEmitter {
public
setTitle
(
value
:
string
):
void
{
document
.
title
=
value
;
}
}
/**
...
...
@@ -331,7 +311,6 @@ class BrowserWindow extends EventEmitter {
* example returns a boolean while we need a promise.
*/
class
ElectronFill
{
public
readonly
shell
=
new
Shell
();
public
readonly
clipboard
=
new
Clipboard
();
public
readonly
app
=
new
App
();
...
...
@@ -382,7 +361,6 @@ class ElectronFill {
};
}
// tslint:enable no-any
}
module
.
exports
=
new
ElectronFill
();
packages/ide/src/fill/notification.ts
浏览文件 @
e770920b
import
{
logger
,
field
}
from
"
@coder/logger
"
;
/**
* Handle for a notification that allows it to be closed and updated.
*/
export
interface
INotificationHandle
{
/**
* Closes the notification.
*/
close
():
void
;
/**
* Update the message.
*/
updateMessage
(
message
:
string
):
void
;
/**
* Update the buttons.
*/
updateButtons
(
buttons
:
INotificationButton
[]):
void
;
}
/**
* Notification severity.
*/
export
enum
Severity
{
Ignore
=
0
,
Info
=
1
,
...
...
@@ -32,9 +13,6 @@ export enum Severity {
Error
=
3
,
}
/**
* Notification button.
*/
export
interface
INotificationButton
{
label
:
string
;
run
():
void
;
...
...
@@ -44,48 +22,28 @@ export interface INotificationButton {
* Optional notification service.
*/
export
interface
INotificationService
{
/**
* Display an error message.
*/
error
(
error
:
Error
):
void
;
/**
* Show a notification.
*/
prompt
(
severity
:
Severity
,
message
:
string
,
buttons
:
INotificationButton
[],
onCancel
:
()
=>
void
):
INotificationHandle
;
}
/**
* Updatable progress.
*/
export
interface
IProgress
{
/**
* Report progress
. Progress is
the completed percentage from 0 to 100.
* Report progress
, which should be
the completed percentage from 0 to 100.
*/
report
(
progress
:
number
):
void
;
}
/**
* Option progress reporting service.
*/
export
interface
IProgressService
{
/**
* Start a new progress bar that resolves & disappears when the task finishes.
*/
start
<
T
>
(
title
:
string
,
task
:
(
progress
:
IProgress
)
=>
Promise
<
T
>
,
onCancel
:
()
=>
void
):
Promise
<
T
>
;
}
/**
* Temporary notification service.
*/
export
class
NotificationService
implements
INotificationService
{
public
error
(
error
:
Error
):
void
{
logger
.
error
(
error
.
message
,
field
(
"
error
"
,
error
));
}
...
...
@@ -93,14 +51,12 @@ export class NotificationService implements INotificationService {
public
prompt
(
_severity
:
Severity
,
message
:
string
,
_buttons
:
INotificationButton
[],
_onCancel
:
()
=>
void
):
INotificationHandle
{
throw
new
Error
(
`cannot prompt using the console:
${
message
}
`
);
}
}
/**
* Temporary progress service.
*/
export
class
ProgressService
implements
IProgressService
{
public
start
<
T
>
(
title
:
string
,
task
:
(
progress
:
IProgress
)
=>
Promise
<
T
>
):
Promise
<
T
>
{
logger
.
info
(
title
);
...
...
@@ -110,5 +66,4 @@ export class ProgressService implements IProgressService {
},
});
}
}
packages/ide/src/fill/os.ts
浏览文件 @
e770920b
...
...
@@ -2,7 +2,6 @@ import { InitData } from "@coder/protocol";
import
{
client
}
from
"
./client
"
;
class
OS
{
private
_homedir
:
string
|
undefined
;
private
_tmpdir
:
string
|
undefined
;
...
...
@@ -40,9 +39,9 @@ class OS {
if
(
navigator
.
appVersion
.
indexOf
(
"
Mac
"
)
!=
-
1
)
{
return
"
darwin
"
;
}
return
"
linux
"
;
}
}
export
=
new
OS
();
packages/ide/src/fill/uri.ts
浏览文件 @
e770920b
export
interface
IURI
{
readonly
path
:
string
;
readonly
fsPath
:
string
;
readonly
scheme
:
string
;
}
export
interface
IURIFactory
{
/**
* Convert the object to an instance of a real URI.
*/
create
<
T
extends
IURI
>
(
uri
:
IURI
):
T
;
file
(
path
:
string
):
IURI
;
parse
(
raw
:
string
):
IURI
;
}
packages/ide/src/retry.ts
浏览文件 @
e770920b
...
...
@@ -21,7 +21,6 @@ interface IRetryItem {
* to the user explaining what is happening with an option to immediately retry.
*/
export
class
Retry
{
private
items
:
Map
<
string
,
IRetryItem
>
;
// Times are in seconds.
...
...
@@ -284,7 +283,6 @@ export class Retry {
item
.
timeout
=
undefined
;
item
.
end
=
undefined
;
}
}
// Global instance so we can block other retries when retrying the main
...
...
packages/ide/src/upload.ts
浏览文件 @
e770920b
...
...
@@ -32,7 +32,6 @@ interface IEntry {
* Handles file uploads.
*/
export
class
Upload
{
private
readonly
maxParallelUploads
=
100
;
private
readonly
readSize
=
32000
;
// ~32kb max while reading in the file.
private
readonly
packetSize
=
32000
;
// ~32kb max when writing.
...
...
@@ -353,7 +352,6 @@ export class Upload {
});
}
}
}
// Global instance.
...
...
packages/logger/src/logger.ts
浏览文件 @
e770920b
...
...
@@ -12,7 +12,6 @@ export enum Level {
* A field to log.
*/
export
class
Field
<
T
>
{
public
constructor
(
public
readonly
identifier
:
string
,
public
readonly
value
:
T
,
...
...
@@ -27,19 +26,16 @@ export class Field<T> {
value
:
this
.
value
,
};
}
}
/**
* Represents the time something takes.
*/
export
class
Time
{
public
constructor
(
public
readonly
expected
:
number
,
public
readonly
ms
:
number
,
)
{
}
}
// tslint:disable-next-line no-any
...
...
@@ -117,7 +113,6 @@ const hashStringToColor = (str: string): string => {
* currently built items and appends to that.
*/
export
abstract
class
Formatter
{
protected
format
:
string
=
""
;
protected
args
:
string
[]
=
[];
...
...
@@ -159,14 +154,12 @@ export abstract class Formatter {
return
"
%s
"
;
}
}
}
/**
* Browser formatter.
*/
export
class
BrowserFormatter
extends
Formatter
{
public
tag
(
name
:
string
,
color
:
string
):
void
{
this
.
format
+=
`%c
${
name
}
`
;
this
.
args
.
push
(
...
...
@@ -207,14 +200,12 @@ export class BrowserFormatter extends Formatter {
// tslint:disable-next-line no-console
console
.
groupEnd
();
}
}
/**
* Server (Node) formatter.
*/
export
class
ServerFormatter
extends
Formatter
{
public
tag
(
name
:
string
,
color
:
string
):
void
{
const
[
r
,
g
,
b
]
=
hexToRgb
(
color
);
while
(
name
.
length
<
5
)
{
...
...
@@ -250,14 +241,12 @@ export class ServerFormatter extends Formatter {
this
.
args
.
push
(
JSON
.
stringify
(
obj
));
console
.
log
(...
this
.
flush
());
// tslint:disable-line no-console
}
}
/**
* Class for logging.
*/
export
class
Logger
{
public
level
=
Level
.
Info
;
private
readonly
nameColor
?:
string
;
...
...
@@ -429,7 +418,6 @@ export class Logger {
}
// tslint:enable no-console
}
}
export
const
logger
=
new
Logger
(
...
...
packages/protocol/src/browser/client.ts
浏览文件 @
e770920b
...
...
@@ -9,7 +9,6 @@ import { EventEmitter } from "events";
* Client accepts an arbitrary connection intended to communicate with the Server.
*/
export
class
Client
{
public
Socket
:
typeof
ServerSocket
;
private
evalId
:
number
=
0
;
...
...
@@ -453,5 +452,4 @@ export class Client {
}
this
.
connections
.
set
(
id
,
socket
);
}
}
packages/protocol/src/browser/command.ts
浏览文件 @
e770920b
...
...
@@ -170,7 +170,6 @@ export interface Socket {
}
export
class
ServerSocket
extends
events
.
EventEmitter
implements
Socket
{
public
writable
:
boolean
=
true
;
public
readable
:
boolean
=
true
;
...
...
@@ -276,7 +275,6 @@ export class ServerSocket extends events.EventEmitter implements Socket {
public
setDefaultEncoding
(
encoding
:
string
):
this
{
throw
new
Error
(
"
Method not implemented.
"
);
}
}
export
interface
Server
{
...
...
@@ -307,7 +305,6 @@ export interface Server {
}
export
class
ServerListener
extends
events
.
EventEmitter
implements
Server
{
private
_listening
:
boolean
=
false
;
public
constructor
(
...
...
@@ -358,7 +355,6 @@ export class ServerListener extends events.EventEmitter implements Server {
return
this
;
}
}
export
interface
ActiveEval
{
...
...
packages/protocol/src/browser/modules/child_process.ts
浏览文件 @
e770920b
...
...
@@ -3,7 +3,6 @@ import { Client } from "../client";
import
{
useBuffer
}
from
"
../../common/util
"
;
export
class
CP
{
public
constructor
(
private
readonly
client
:
Client
,
)
{
}
...
...
@@ -75,5 +74,4 @@ export class CP {
Array
.
isArray
(
args
)
||
!
args
?
options
:
args
,
);
}
}
packages/protocol/src/browser/modules/fs.ts
浏览文件 @
e770920b
...
...
@@ -19,7 +19,6 @@ declare var _Buffer: typeof Buffer;
* _this somehow which the __awaiter helper uses.
*/
export
class
FS
{
public
constructor
(
private
readonly
client
:
Client
,
)
{
}
...
...
@@ -686,11 +685,9 @@ export class FS {
return
watcher
;
}
}
class
Watcher
extends
EventEmitter
implements
fs
.
FSWatcher
{
public
constructor
(
private
readonly
process
:
ChildProcess
)
{
super
();
}
...
...
@@ -698,7 +695,6 @@ class Watcher extends EventEmitter implements fs.FSWatcher {
public
close
():
void
{
this
.
process
.
kill
();
}
}
interface
IStats
{
...
...
@@ -730,7 +726,6 @@ interface IStats {
}
class
Stats
implements
fs
.
Stats
{
public
readonly
atime
:
Date
;
public
readonly
mtime
:
Date
;
public
readonly
ctime
:
Date
;
...
...
@@ -768,7 +763,6 @@ class Stats implements fs.Stats {
public
toObject
():
object
{
return
JSON
.
parse
(
JSON
.
stringify
(
this
));
}
}
/**
...
...
@@ -776,7 +770,6 @@ class Stats implements fs.Stats {
* Assumes that messages are split by newlines.
*/
export
class
NewlineInputBuffer
{
private
callback
:
(
msg
:
string
)
=>
void
;
private
buffer
:
string
|
undefined
;
...
...
@@ -804,5 +797,4 @@ export class NewlineInputBuffer {
this
.
callback
(
lines
[
i
]);
}
}
}
packages/protocol/src/browser/modules/net.ts
浏览文件 @
e770920b
...
...
@@ -7,7 +7,6 @@ type NodeNet = typeof net;
* Implementation of net for the browser.
*/
export
class
Net
implements
NodeNet
{
public
constructor
(
private
readonly
client
:
Client
,
)
{}
...
...
@@ -51,5 +50,4 @@ export class Net implements NodeNet {
):
net
.
Server
{
return
this
.
client
.
createServer
()
as
net
.
Server
;
}
}
packages/protocol/src/node/evaluate.ts
浏览文件 @
e770920b
import
*
as
vm
from
"
vm
"
;
import
{
NewEvalMessage
,
TypedValue
,
EvalFailedMessage
,
EvalDoneMessage
,
ServerMessage
,
EvalEventMessage
,
ClientMessage
}
from
"
../proto
"
;
import
{
NewEvalMessage
,
TypedValue
,
EvalFailedMessage
,
EvalDoneMessage
,
ServerMessage
,
EvalEventMessage
}
from
"
../proto
"
;
import
{
SendableConnection
}
from
"
../common/connection
"
;
import
{
EventEmitter
}
from
"
events
"
;
...
...
packages/protocol/src/node/server.ts
浏览文件 @
e770920b
...
...
@@ -20,7 +20,6 @@ export interface ServerOptions {
}
export
class
Server
{
private
readonly
sessions
:
Map
<
number
,
Process
>
=
new
Map
();
private
readonly
connections
:
Map
<
number
,
net
.
Socket
>
=
new
Map
();
private
readonly
servers
:
Map
<
number
,
net
.
Server
>
=
new
Map
();
...
...
@@ -250,5 +249,4 @@ export class Server {
private
getSession
(
id
:
number
):
Process
|
undefined
{
return
this
.
sessions
.
get
(
id
);
}
}
packages/protocol/test/evaluate.test.ts
浏览文件 @
e770920b
...
...
@@ -7,7 +7,7 @@ describe("Evaluate", () => {
const
value
=
await
client
.
evaluate
(
function
()
{
return
"
hi
"
;
});
expect
(
value
).
toEqual
(
"
hi
"
);
},
100
);
...
...
@@ -24,7 +24,7 @@ describe("Evaluate", () => {
const
value
=
await
client
.
evaluate
((
arg
)
=>
{
return
arg
.
bananas
*
2
;
},
{
bananas
:
1
});
expect
(
value
).
toEqual
(
2
);
},
100
);
...
...
@@ -32,14 +32,14 @@ describe("Evaluate", () => {
const
value
=
await
client
.
evaluate
(()
=>
{
return
{
alpha
:
"
beta
"
};
});
expect
(
value
.
alpha
).
toEqual
(
"
beta
"
);
},
100
);
it
(
"
should require
"
,
async
()
=>
{
const
value
=
await
client
.
evaluate
(()
=>
{
const
fs
=
require
(
"
fs
"
)
as
typeof
import
(
"
fs
"
);
return
Object
.
keys
(
fs
).
filter
((
f
)
=>
f
===
"
readFileSync
"
);
});
...
...
@@ -69,4 +69,4 @@ describe("Evaluate", () => {
runner
.
on
(
"
2
"
,
()
=>
runner
.
emit
(
"
3
"
));
runner
.
on
(
"
close
"
,
()
=>
done
());
});
});
\ No newline at end of file
});
packages/requirefs/src/requirefs.ts
浏览文件 @
e770920b
...
...
@@ -13,7 +13,6 @@ export interface IFileReader {
* RequireFS allows users to require from a file system.
*/
export
class
RequireFS
{
private
readonly
reader
:
IFileReader
;
private
readonly
customModules
:
Map
<
string
,
{
exports
:
object
}
>
;
private
readonly
requireCache
:
Map
<
string
,
{
exports
:
object
}
>
;
...
...
@@ -126,7 +125,6 @@ export class RequireFS {
return
stripPrefix
(
resolvedPath
);
}
}
export
const
fromTar
=
(
content
:
Uint8Array
):
RequireFS
=>
{
...
...
packages/requirefs/src/tarReader.ts
浏览文件 @
e770920b
...
...
@@ -5,7 +5,6 @@ const textDecoder = new (typeof TextDecoder === "undefined" ? require("text-enco
* Tar represents a tar archive.
*/
export
class
Tar
{
/**
* Return a tar object from a Uint8Array.
*/
...
...
@@ -42,14 +41,12 @@ export class Tar {
public
get
files
():
ReadonlyMap
<
string
,
TarFile
>
{
return
this
.
_files
;
}
}
/**
* Represents a tar files location within a reader
*/
export
class
TarFile
{
/**
* Locate a tar file from a reader.
*/
...
...
@@ -186,14 +183,12 @@ export class TarFile {
public
read
():
Uint8Array
{
return
this
.
reader
.
jump
(
this
.
data
.
offset
).
read
(
this
.
data
.
size
);
}
}
/**
* Reads within a Uint8Array.
*/
export
class
Reader
{
private
array
:
Uint8Array
;
private
_offset
:
number
;
private
lastClamp
:
number
;
...
...
@@ -281,5 +276,4 @@ export class Reader {
return
data
;
}
}
packages/server/src/cli.ts
浏览文件 @
e770920b
...
...
@@ -8,11 +8,10 @@ import * as WebSocket from "ws";
import
{
createApp
}
from
"
./server
"
;
import
{
requireModule
}
from
"
./vscode/bootstrapFork
"
;
import
{
SharedProcess
,
SharedProcessState
}
from
"
./vscode/sharedProcess
"
;
import
{
setup
as
setupNativeModules
}
from
'
./modules
'
;
import
{
fillFs
}
from
'
./fill
'
;
import
{
setup
as
setupNativeModules
}
from
"
./modules
"
;
import
{
fillFs
}
from
"
./fill
"
;
export
class
Entry
extends
Command
{
public
static
description
=
"
Start your own self-hosted browser-accessible VS Code
"
;
public
static
flags
=
{
cert
:
flags
.
string
(),
...
...
@@ -167,7 +166,6 @@ export class Entry extends Command {
logger
.
info
(
`http://localhost:
${
flags
.
port
}
/`
);
logger
.
info
(
"
"
);
}
}
Entry
.
run
(
undefined
,
{
...
...
packages/server/src/fill.ts
浏览文件 @
e770920b
...
...
@@ -3,7 +3,7 @@ import * as util from "util";
const
oldAccess
=
fs
.
access
;
const
existsWithinBinary
=
(
path
:
fs
.
PathLike
):
Promise
<
boolean
>
=>
{
return
new
Promise
<
boolean
>
((
resolve
)
=>
{
return
new
Promise
<
boolean
>
((
resolve
)
:
void
=>
{
if
(
typeof
path
===
"
number
"
)
{
if
(
path
<
0
)
{
return
resolve
(
true
);
...
...
@@ -18,7 +18,7 @@ const existsWithinBinary = (path: fs.PathLike): Promise<boolean> => {
});
};
export
const
fillFs
=
()
=>
{
export
const
fillFs
=
()
:
void
=>
{
/**
* Refer to https://github.com/nexe/nexe/blob/master/src/fs/patch.ts
* For impls
...
...
packages/server/src/ipc.ts
浏览文件 @
e770920b
...
...
@@ -7,7 +7,6 @@ export interface IpcMessage {
}
export
class
StdioIpcHandler
extends
EventEmitter
{
private
isListening
:
boolean
=
false
;
public
constructor
(
...
...
@@ -66,5 +65,4 @@ export class StdioIpcHandler extends EventEmitter {
process
.
stdin
.
on
(
"
data
"
,
onData
);
}
}
}
\ No newline at end of file
}
packages/server/src/server.ts
浏览文件 @
e770920b
import
{
logger
}
from
"
@coder/logger
"
;
import
{
ReadWriteConnection
}
from
"
@coder/protocol
"
;
import
{
Server
,
ServerOptions
}
from
"
@coder/protocol/src/node/server
"
;
import
{
NewSessionMessage
}
from
'
@coder/protocol/src/proto
'
;
import
{
NewSessionMessage
}
from
"
@coder/protocol/src/proto
"
;
import
{
ChildProcess
}
from
"
child_process
"
;
import
*
as
express
from
"
express
"
;
//@ts-ignore
...
...
packages/server/src/vscode/sharedProcess.ts
浏览文件 @
e770920b
...
...
@@ -6,7 +6,7 @@ import { forkModule } from "./bootstrapFork";
import
{
StdioIpcHandler
}
from
"
../ipc
"
;
import
{
ParsedArgs
}
from
"
vs/platform/environment/common/environment
"
;
import
{
LogLevel
}
from
"
vs/platform/log/common/log
"
;
import
{
Emitter
,
Event
}
from
'
@coder/events/src
'
;
import
{
Emitter
,
Event
}
from
"
@coder/events/src
"
;
export
enum
SharedProcessState
{
Stopped
,
...
...
@@ -22,7 +22,6 @@ export type SharedProcessEvent = {
};
export
class
SharedProcess
{
public
readonly
socketPath
:
string
=
path
.
join
(
os
.
tmpdir
(),
`.vscode-remote
${
Math
.
random
().
toString
()}
`
);
private
_state
:
SharedProcessState
=
SharedProcessState
.
Stopped
;
private
activeProcess
:
ChildProcess
|
undefined
;
...
...
packages/vscode/src/client.ts
浏览文件 @
e770920b
...
...
@@ -26,7 +26,6 @@ import { ServiceCollection } from "vs/platform/instantiation/common/serviceColle
import
{
RawContextKey
,
IContextKeyService
}
from
"
vs/platform/contextkey/common/contextkey
"
;
export
class
Client
extends
IDEClient
{
private
readonly
windowId
=
parseInt
(
new
Date
().
toISOString
().
replace
(
/
[
-:.TZ
]
/g
,
""
),
10
);
private
_serviceCollection
:
ServiceCollection
|
undefined
;
private
_clipboardContextKey
:
RawContextKey
<
boolean
>
|
undefined
;
...
...
@@ -192,7 +191,6 @@ export class Client extends IDEClient {
this
.
clipboard
.
initialize
();
},
this
.
initData
,
pathSets
);
}
}
export
const
client
=
new
Client
();
packages/vscode/src/fill/codeEditor.ts
浏览文件 @
e770920b
...
...
@@ -6,7 +6,6 @@ import { IDecorationRenderOptions } from "vs/editor/common/editorCommon";
* This converts icon paths for decorations to the correct URL.
*/
abstract
class
CodeEditorServiceImpl
extends
editor
.
CodeEditorServiceImpl
{
public
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
):
void
{
super
.
registerDecorationType
(
key
,
options
?
{
...
options
,
...
...
@@ -18,7 +17,6 @@ abstract class CodeEditorServiceImpl extends editor.CodeEditorServiceImpl {
}
:
options
.
gutterIconPath
,
}
:
{},
parentTypeKey
);
}
}
const
target
=
editor
as
typeof
editor
;
...
...
packages/vscode/src/fill/environmentService.ts
浏览文件 @
e770920b
...
...
@@ -2,11 +2,9 @@ import * as paths from "./paths";
import
*
as
environment
from
"
vs/platform/environment/node/environmentService
"
;
export
class
EnvironmentService
extends
environment
.
EnvironmentService
{
public
get
sharedIPCHandle
():
string
{
return
paths
.
_paths
.
socketPath
||
super
.
sharedIPCHandle
;
}
}
const
target
=
environment
as
typeof
environment
;
...
...
packages/vscode/src/fill/iconv-lite.ts
浏览文件 @
e770920b
...
...
@@ -2,7 +2,6 @@ import * as iconv from "../../node_modules/iconv-lite";
import
{
Transform
,
TransformCallback
}
from
"
stream
"
;
class
IconvLiteDecoderStream
extends
Transform
{
// tslint:disable-next-line no-any
private
conv
:
any
;
private
encoding
:
string
;
...
...
packages/vscode/src/fill/mouseEvent.ts
浏览文件 @
e770920b
...
...
@@ -4,7 +4,6 @@ import * as mouse from "vs/base/browser/mouseEvent";
* Fix the wheel event for Firefox.
*/
class
StandardWheelEvent
extends
mouse
.
StandardWheelEvent
{
public
constructor
(
event
:
mouse
.
IMouseWheelEvent
|
null
)
{
super
(
event
,
...
...
@@ -12,7 +11,6 @@ class StandardWheelEvent extends mouse.StandardWheelEvent {
(
-
(
event
as
any
as
MouseWheelEvent
).
deltaY
||
0
)
/
3
,
// tslint:disable-line no-any
);
}
}
const
target
=
mouse
as
typeof
mouse
;
...
...
packages/vscode/src/fill/native-keymap.ts
浏览文件 @
e770920b
class
NativeKeymap
{
public
getCurrentKeyboardLayout
():
null
{
return
null
;
}
...
...
@@ -7,7 +6,6 @@ class NativeKeymap {
public
getKeyMap
():
undefined
[]
{
return
[];
}
}
export
=
new
NativeKeymap
();
packages/vscode/src/fill/native-watchdog.ts
浏览文件 @
e770920b
class
Watchdog
{
public
start
():
void
{
// No action required.
}
}
export
=
new
Watchdog
();
packages/vscode/src/fill/node-pty.ts
浏览文件 @
e770920b
...
...
@@ -9,7 +9,6 @@ type nodePtyType = typeof nodePty;
* Implementation of nodePty for the browser.
*/
class
Pty
implements
nodePty
.
IPty
{
private
readonly
emitter
:
EventEmitter
;
private
readonly
cp
:
ChildProcess
;
...
...
@@ -54,15 +53,12 @@ class Pty implements nodePty.IPty {
public
kill
(
signal
?:
string
):
void
{
this
.
emitter
.
emit
(
"
kill
"
,
signal
);
}
}
const
ptyType
:
nodePtyType
=
{
spawn
:
(
file
:
string
,
args
:
string
[]
|
string
,
options
:
nodePty
.
IPtyForkOptions
):
nodePty
.
IPty
=>
{
return
new
Pty
(
file
,
args
,
options
);
},
};
module
.
exports
=
ptyType
;
packages/vscode/src/fill/paste.ts
浏览文件 @
e770920b
...
...
@@ -13,7 +13,6 @@ const getLabel = (key: string, enabled: boolean): string => {
};
export
class
PasteAction
extends
Action
{
private
static
readonly
KEY
=
"
paste
"
;
public
constructor
()
{
...
...
@@ -30,11 +29,9 @@ export class PasteAction extends Action {
this
.
enabled
=
enabled
;
});
}
}
class
TerminalPasteAction
extends
Action
{
private
static
readonly
KEY
=
"
workbench.action.terminal.paste
"
;
public
static
readonly
ID
=
TERMINAL_COMMAND_ID
.
PASTE
;
...
...
@@ -61,11 +58,9 @@ class TerminalPasteAction extends Action {
return
Promise
.
resolve
();
}
}
class
TerminalInstance
extends
instance
.
TerminalInstance
{
public
async
paste
():
Promise
<
void
>
{
this
.
focus
();
if
(
clipboard
.
isEnabled
)
{
...
...
@@ -75,7 +70,6 @@ class TerminalInstance extends instance.TerminalInstance {
document
.
execCommand
(
"
paste
"
);
}
}
}
const
actionsTarget
=
actions
as
typeof
actions
;
...
...
packages/vscode/src/fill/spdlog.ts
浏览文件 @
e770920b
...
...
@@ -9,7 +9,6 @@ import { escapePath } from "@coder/protocol";
// use that for the logging. Or maybe create an instance when the server starts,
// and just always use that one (make it part of the protocol).
export
class
RotatingLogger
implements
NodeRotatingLogger
{
private
format
=
true
;
private
buffer
=
""
;
private
flushPromise
:
Promise
<
void
>
|
undefined
;
...
...
@@ -178,7 +177,6 @@ export class RotatingLogger implements NodeRotatingLogger {
await
this
.
rotate
();
}
}
}
export
const
setAsyncMode
=
():
void
=>
{
...
...
packages/vscode/src/fill/stdioElectron.ts
浏览文件 @
e770920b
...
...
@@ -4,7 +4,6 @@ import { IpcRenderer } from "electron";
export
*
from
"
@coder/ide/src/fill/electron
"
;
class
StdioIpcRenderer
extends
StdioIpcHandler
implements
IpcRenderer
{
public
sendTo
(
windowId
:
number
,
channel
:
string
,
...
args
:
any
[]):
void
{
throw
new
Error
(
"
Method not implemented.
"
);
}
...
...
@@ -16,7 +15,6 @@ class StdioIpcRenderer extends StdioIpcHandler implements IpcRenderer {
public
eventNames
():
string
[]
{
return
super
.
eventNames
()
as
string
[];
}
}
export
const
ipcRenderer
=
new
StdioIpcRenderer
();
packages/vscode/src/fill/storageDatabase.ts
浏览文件 @
e770920b
...
...
@@ -9,7 +9,6 @@ import * as paths from "./paths";
import
{
logger
,
field
}
from
"
@coder/logger
"
;
class
StorageDatabase
implements
workspaceStorage
.
IStorageDatabase
{
public
readonly
onDidChangeItemsExternal
=
Event
.
None
;
private
items
=
new
Map
<
string
,
string
>
();
private
fetched
:
boolean
=
false
;
...
...
@@ -78,11 +77,9 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
return
promisify
(
writeFile
)(
this
.
path
,
JSON
.
stringify
(
json
));
}
}
class
GlobalStorageDatabase
extends
StorageDatabase
implements
IDisposable
{
public
constructor
()
{
super
(
path
.
join
(
paths
.
getAppDataPath
(),
"
globalStorage
"
,
"
state.vscdb
"
));
}
...
...
@@ -90,7 +87,6 @@ class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
public
dispose
():
void
{
// Nothing to do.
}
}
const
workspaceTarget
=
workspaceStorage
as
typeof
workspaceStorage
;
...
...
packages/vscode/src/fill/windowsService.ts
浏览文件 @
e770920b
...
...
@@ -14,7 +14,6 @@ import { client } from "../client";
* the client. This setup means we can only control the current window.
*/
class
WindowsService
implements
IWindowsService
{
// tslint:disable-next-line no-any
public
_serviceBrand
:
any
;
...
...
@@ -278,7 +277,6 @@ class WindowsService implements IWindowsService {
private
getWindowById
(
_windowId
:
number
):
electron
.
BrowserWindow
{
return
this
.
window
;
}
}
const
target
=
windowsIpc
as
typeof
windowsIpc
;
...
...
rules/src/noBlockPaddingRule.ts
0 → 100644
浏览文件 @
e770920b
import
*
as
ts
from
"
typescript
"
;
import
*
as
Lint
from
"
tslint
"
;
/**
* Rule for disallowing blank lines around the content of blocks.
*/
export
class
Rule
extends
Lint
.
Rules
.
AbstractRule
{
public
static
BEFORE_FAILURE_STRING
=
"
Blocks must not start with blank lines
"
;
public
static
AFTER_FAILURE_STRING
=
"
Blocks must not end with blank lines
"
;
/**
* Apply the rule.
*/
public
apply
(
sourceFile
:
ts
.
SourceFile
):
Lint
.
RuleFailure
[]
{
return
this
.
applyWithWalker
(
new
NoBlockPaddingWalker
(
sourceFile
,
this
.
getOptions
()));
}
}
/**
* Walker for checking block padding.
*/
class
NoBlockPaddingWalker
extends
Lint
.
RuleWalker
{
/**
* Apply this rule to interfaces.
*/
public
visitInterfaceDeclaration
(
node
:
ts
.
InterfaceDeclaration
):
void
{
this
.
visitBlockNode
(
node
);
super
.
visitInterfaceDeclaration
(
node
);
}
/**
* Apply this rule to classes.
*/
public
visitClassDeclaration
(
node
:
ts
.
ClassDeclaration
):
void
{
this
.
visitBlockNode
(
node
);
super
.
visitClassDeclaration
(
node
);
}
/**
* Add failures to blank lines surrounding a block's content.
*/
private
visitBlockNode
(
node
:
ts
.
ClassDeclaration
|
ts
.
InterfaceDeclaration
):
void
{
const
sourceFile
=
node
.
getSourceFile
();
const
children
=
node
.
getChildren
();
const
openBraceIndex
=
children
.
findIndex
((
n
)
=>
n
.
kind
===
ts
.
SyntaxKind
.
OpenBraceToken
);
if
(
openBraceIndex
!==
-
1
)
{
const
nextToken
=
children
[
openBraceIndex
+
1
];
if
(
nextToken
)
{
const
startLine
=
this
.
getStartIncludingComments
(
sourceFile
,
nextToken
);
const
openBraceToken
=
children
[
openBraceIndex
];
if
(
ts
.
getLineAndCharacterOfPosition
(
sourceFile
,
openBraceToken
.
getEnd
()).
line
+
1
<
startLine
)
{
this
.
addFailureAt
(
openBraceToken
.
getEnd
(),
openBraceToken
.
getEnd
(),
Rule
.
BEFORE_FAILURE_STRING
);
}
}
}
const
closeBraceIndex
=
children
.
findIndex
((
n
)
=>
n
.
kind
===
ts
.
SyntaxKind
.
CloseBraceToken
);
if
(
closeBraceIndex
>=
2
)
{
const
previousToken
=
children
[
closeBraceIndex
-
1
];
if
(
previousToken
)
{
let
endLine
=
ts
.
getLineAndCharacterOfPosition
(
sourceFile
,
previousToken
.
getEnd
()).
line
;
const
closeBraceToken
=
children
[
closeBraceIndex
];
if
(
this
.
getStartIncludingComments
(
sourceFile
,
closeBraceToken
)
>
endLine
+
1
)
{
this
.
addFailureAt
(
closeBraceToken
.
getStart
(),
closeBraceToken
.
getStart
(),
Rule
.
AFTER_FAILURE_STRING
);
}
}
}
}
/**
* getStart() doesn't account for comments while this does.
*/
private
getStartIncludingComments
(
sourceFile
:
ts
.
SourceFile
,
node
:
ts
.
Node
):
number
{
// This gets the line the node starts on without counting comments.
let
startLine
=
ts
.
getLineAndCharacterOfPosition
(
sourceFile
,
node
.
getStart
()).
line
;
// Adjust the start line for the comments.
const
comments
=
ts
.
getLeadingCommentRanges
(
sourceFile
.
text
,
node
.
pos
)
||
[];
comments
.
forEach
((
c
)
=>
{
const
commentStartLine
=
ts
.
getLineAndCharacterOfPosition
(
sourceFile
,
c
.
pos
).
line
;
if
(
commentStartLine
<
startLine
)
{
startLine
=
commentStartLine
;
}
});
return
startLine
;
}
}
tslint.json
浏览文件 @
e770920b
...
...
@@ -3,12 +3,14 @@
"rules"
:
{
"only-arrow-functions"
:
true
,
"curly-statement-newlines"
:
true
,
"no-block-padding"
:
true
,
"adjacent-overload-signatures"
:
true
,
"align"
:
true
,
"await-promise"
:
[
true
,
"Thenable"
],
"class-name"
:
true
,
"eofline"
:
true
,
"import-spacing"
:
true
,
"indent"
:
[
true
,
"tabs"
],
"no-angle-bracket-type-assertion"
:
false
,
"no-bitwise"
:
false
,
"no-any"
:
true
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录