Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myhjmzy
code-server
提交
7072bf1e
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,发现更多精彩内容 >>
未验证
提交
7072bf1e
编写于
7月 02, 2019
作者:
A
Asher
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use new URI transformer everywhere
上级
4e0a6d29
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
40 addition
and
25 deletion
+40
-25
channel.ts
channel.ts
+28
-16
connection.ts
connection.ts
+2
-1
server.ts
server.ts
+8
-6
uriTransformer.js
uriTransformer.js
+2
-2
未找到文件。
channel.ts
浏览文件 @
7072bf1e
import
*
as
path
from
"
path
"
;
import
{
getPathFromAmdModule
}
from
"
vs/base/common/amd
"
;
import
{
VSBuffer
}
from
"
vs/base/common/buffer
"
;
import
{
Emitter
,
Event
}
from
"
vs/base/common/event
"
;
import
{
IDisposable
}
from
"
vs/base/common/lifecycle
"
;
import
{
Schemas
}
from
"
vs/base/common/network
"
;
import
{
OS
}
from
"
vs/base/common/platform
"
;
import
{
URI
,
UriComponents
}
from
"
vs/base/common/uri
"
;
import
{
URITransformer
,
IRawURITransformer
,
transformOutgoingURIs
}
from
"
vs/base/common/uriIpc
"
;
import
{
IServerChannel
}
from
"
vs/base/parts/ipc/common/ipc
"
;
import
{
IDiagnosticInfo
}
from
"
vs/platform/diagnostics/common/diagnosticsService
"
;
import
{
IEnvironmentService
}
from
"
vs/platform/environment/common/environment
"
;
...
...
@@ -47,7 +48,7 @@ export class FileProviderChannel implements IServerChannel {
this
.
provider
=
new
DiskFileSystemProvider
(
this
.
logService
);
}
public
listen
(
_
:
unknown
,
event
:
string
,
args
?:
any
):
Event
<
any
>
{
public
listen
(
context
:
any
,
event
:
string
,
args
?:
any
):
Event
<
any
>
{
switch
(
event
)
{
// This is where the actual file changes are sent. The watch method just
// adds things that will fire here. That means we have to split up
...
...
@@ -61,10 +62,11 @@ export class FileProviderChannel implements IServerChannel {
onFirstListenerAdd
:
()
=>
{
const
provider
=
new
Watcher
(
this
.
logService
);
this
.
watchers
.
set
(
session
,
provider
);
const
transformer
=
getUriTransformer
(
context
.
remoteAuthority
);
provider
.
onDidChangeFile
((
events
)
=>
{
emitter
.
fire
(
events
.
map
((
event
)
=>
({
...
event
,
resource
:
event
.
resource
.
with
({
scheme
:
Schemas
.
vscodeRemote
}
),
resource
:
transformer
.
transformOutgoing
(
event
.
resource
),
})));
});
provider
.
onDidErrorOccur
((
event
)
=>
emitter
.
fire
(
event
));
...
...
@@ -157,13 +159,17 @@ export class FileProviderChannel implements IServerChannel {
export
class
ExtensionEnvironmentChannel
implements
IServerChannel
{
public
constructor
(
private
readonly
environment
:
IEnvironmentService
)
{}
public
listen
(
_
context
:
any
,
event
:
string
):
Event
<
any
>
{
public
listen
(
_
:
unknown
,
event
:
string
):
Event
<
any
>
{
throw
new
Error
(
`Invalid listen "
${
event
}
"`
);
}
public
call
(
_
:
unknown
,
command
:
string
,
_args
?:
any
):
Promise
<
any
>
{
public
async
call
(
context
:
any
,
command
:
string
,
_args
?:
any
):
Promise
<
any
>
{
switch
(
command
)
{
case
"
getEnvironmentData
"
:
return
this
.
getEnvironmentData
();
case
"
getEnvironmentData
"
:
return
transformOutgoingURIs
(
await
this
.
getEnvironmentData
(),
getUriTransformer
(
context
.
remoteAuthority
),
);
case
"
getDiagnosticInfo
"
:
return
this
.
getDiagnosticInfo
();
case
"
disableTelemetry
"
:
return
this
.
disableTelemetry
();
}
...
...
@@ -171,18 +177,16 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
}
private
async
getEnvironmentData
():
Promise
<
IRemoteAgentEnvironment
>
{
// TODO: this `with` stuff feels a bit jank.
// Maybe it should already come in like this instead.
return
{
pid
:
process
.
pid
,
appRoot
:
URI
.
file
(
this
.
environment
.
appRoot
)
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
appSettingsHome
:
this
.
environment
.
appSettingsHome
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
settingsPath
:
this
.
environment
.
machineSettingsHome
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
logsPath
:
URI
.
file
(
this
.
environment
.
logsPath
)
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
extensionsPath
:
URI
.
file
(
this
.
environment
.
extensionsPath
)
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
extensionHostLogsPath
:
URI
.
file
(
path
.
join
(
this
.
environment
.
logsPath
,
"
extension-host
"
))
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
// TODO
globalStorageHome
:
URI
.
file
(
this
.
environment
.
globalStorageHome
)
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
userHome
:
URI
.
file
(
this
.
environment
.
userHome
)
.
with
({
scheme
:
Schemas
.
vscodeRemote
})
,
appRoot
:
URI
.
file
(
this
.
environment
.
appRoot
),
appSettingsHome
:
this
.
environment
.
appSettingsHome
,
settingsPath
:
this
.
environment
.
machineSettingsHome
,
logsPath
:
URI
.
file
(
this
.
environment
.
logsPath
),
extensionsPath
:
URI
.
file
(
this
.
environment
.
extensionsPath
),
extensionHostLogsPath
:
URI
.
file
(
path
.
join
(
this
.
environment
.
logsPath
,
"
extension-host
"
)),
// TODO
globalStorageHome
:
URI
.
file
(
this
.
environment
.
globalStorageHome
),
userHome
:
URI
.
file
(
this
.
environment
.
userHome
),
extensions
:
[],
// TODO
os
:
OS
,
};
...
...
@@ -196,3 +200,11 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
throw
new
Error
(
"
not implemented
"
);
}
}
export
const
uriTransformerPath
=
getPathFromAmdModule
(
require
,
"
vs/server/uriTransformer
"
);
export
const
getUriTransformer
=
(
remoteAuthority
:
string
):
URITransformer
=>
{
const
rawURITransformerFactory
=
<
any
>
require
.
__$__nodeRequire
(
uriTransformerPath
);
const
rawURITransformer
=
<
IRawURITransformer
>
rawURITransformerFactory
(
remoteAuthority
);
return
new
URITransformer
(
rawURITransformer
);
};
connection.ts
浏览文件 @
7072bf1e
...
...
@@ -6,6 +6,7 @@ import { Emitter } from "vs/base/common/event";
import
{
ISocket
}
from
"
vs/base/parts/ipc/common/ipc.net
"
;
import
{
NodeSocket
,
WebSocketNodeSocket
}
from
"
vs/base/parts/ipc/node/ipc.net
"
;
import
{
ILogService
}
from
"
vs/platform/log/common/log
"
;
import
{
uriTransformerPath
}
from
"
vs/server/channel
"
;
import
{
IExtHostReadyMessage
,
IExtHostSocketMessage
}
from
"
vs/workbench/services/extensions/common/extensionHostProtocol
"
;
import
{
Protocol
}
from
"
vs/server/protocol
"
;
...
...
@@ -125,7 +126,7 @@ export class ExtensionHostConnection extends Connection {
getPathFromAmdModule
(
require
,
"
bootstrap-fork
"
),
[
"
--type=extensionHost
"
,
`--uriTransformerPath=
${
getPathFromAmdModule
(
require
,
"
vs/server/transformer
"
)
}
`
`--uriTransformerPath=
${
uriTransformerPath
}
`
],
{
env
:
{
...
...
server.ts
浏览文件 @
7072bf1e
...
...
@@ -7,9 +7,8 @@ import * as url from "url";
import
{
Emitter
}
from
"
vs/base/common/event
"
;
import
{
getMediaMime
}
from
"
vs/base/common/mime
"
;
import
{
Schemas
}
from
"
vs/base/common/network
"
;
import
{
extname
}
from
"
vs/base/common/path
"
;
import
{
URI
}
from
"
vs/base/common/uri
"
;
import
{
U
riComponents
,
U
RI
}
from
"
vs/base/common/uri
"
;
import
{
IPCServer
,
ClientConnectionEvent
}
from
"
vs/base/parts/ipc/common/ipc
"
;
import
{
validatePaths
}
from
"
vs/code/node/paths
"
;
import
{
parseMainProcessArgv
}
from
"
vs/platform/environment/node/argvHelper
"
;
...
...
@@ -26,7 +25,7 @@ import { RemoteExtensionLogFileName } from "vs/workbench/services/remote/common/
import
{
IWorkbenchConstructionOptions
}
from
"
vs/workbench/workbench.web.api
"
;
import
{
Connection
,
ManagementConnection
,
ExtensionHostConnection
}
from
"
vs/server/connection
"
;
import
{
ExtensionEnvironmentChannel
,
FileProviderChannel
}
from
"
vs/server/channel
"
;
import
{
ExtensionEnvironmentChannel
,
FileProviderChannel
,
getUriTransformer
}
from
"
vs/server/channel
"
;
import
{
Protocol
}
from
"
vs/server/protocol
"
;
export
enum
HttpCode
{
...
...
@@ -37,7 +36,7 @@ export enum HttpCode {
export
interface
Options
{
WORKBENCH_WEB_CONGIGURATION
:
IWorkbenchConstructionOptions
;
REMOTE_USER_DATA_URI
:
URI
;
REMOTE_USER_DATA_URI
:
U
riComponents
|
U
RI
;
PRODUCT_CONFIGURATION
:
IProductConfiguration
|
null
;
CONNECTION_AUTH_TOKEN
:
string
;
}
...
...
@@ -149,11 +148,14 @@ export class Server {
let
html
=
await
util
.
promisify
(
fs
.
readFile
)(
htmlPath
,
"
utf8
"
);
const
remoteAuthority
=
request
.
headers
.
host
as
string
;
const
transformer
=
getUriTransformer
(
remoteAuthority
);
const
options
:
Options
=
{
WORKBENCH_WEB_CONGIGURATION
:
{
remoteAuthority
:
request
.
headers
.
host
as
string
,
remoteAuthority
,
},
REMOTE_USER_DATA_URI
:
t
his
.
environmentService
.
webUserDataHome
.
with
({
scheme
:
Schemas
.
vscodeRemote
}
),
REMOTE_USER_DATA_URI
:
t
ransformer
.
transformOutgoing
(
this
.
environmentService
.
webUserDataHome
),
PRODUCT_CONFIGURATION
:
null
,
CONNECTION_AUTH_TOKEN
:
""
,
};
...
...
t
ransformer.js
→
uriT
ransformer.js
浏览文件 @
7072bf1e
...
...
@@ -5,14 +5,14 @@ module.exports = (remoteAuthority) => {
transformIncoming
:
(
uri
)
=>
{
switch
(
uri
.
scheme
)
{
case
"
vscode-remote
"
:
return
{
scheme
:
"
file
"
,
path
:
uri
.
path
};
case
"
file
"
:
return
{
scheme
:
"
vscode-local
"
,
path
:
uri
.
path
};
case
"
file
"
:
return
{
scheme
:
"
vscode-local
"
,
path
:
uri
.
path
};
default
:
return
uri
;
}
},
transformOutgoing
:
(
uri
)
=>
{
switch
(
uri
.
scheme
)
{
case
"
vscode-local
"
:
return
{
scheme
:
"
file
"
,
path
:
uri
.
path
};
case
"
file
"
:
return
{
scheme
:
"
vscode-remote
"
,
authority
:
remoteAuthority
,
path
:
uri
.
path
};
case
"
file
"
:
return
{
scheme
:
"
vscode-remote
"
,
authority
:
remoteAuthority
,
path
:
uri
.
path
};
default
:
return
uri
;
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录