Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
fe33ef72
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fe33ef72
编写于
8月 04, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip: url service
上级
dccf029e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
118 addition
and
42 deletion
+118
-42
src/vs/base/parts/ipc/common/ipc.electron.ts
src/vs/base/parts/ipc/common/ipc.electron.ts
+11
-23
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+19
-14
src/vs/platform/url/common/url.ts
src/vs/platform/url/common/url.ts
+2
-1
src/vs/platform/url/common/urlIpc.ts
src/vs/platform/url/common/urlIpc.ts
+32
-1
src/vs/platform/url/electron-main/urlService.ts
src/vs/platform/url/electron-main/urlService.ts
+36
-0
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+12
-2
src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension.ts
...tensions/electron-browser/extensionsWorkbenchExtension.ts
+6
-1
未找到文件。
src/vs/base/parts/ipc/common/ipc.electron.ts
浏览文件 @
fe33ef72
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
IDisposable
,
toDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IMessagePassingProtocol
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Server
as
IPCServer
,
Client
as
IPCClient
,
IServer
,
IClient
,
IChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
...
...
@@ -12,24 +11,26 @@ const Hello = 'ipc:hello';
const
Goodbye
=
'
ipc:goodbye
'
;
const
Message
=
'
ipc:message
'
;
export
interface
IPC
extends
NodeJS
.
EventEmitt
er
{
export
interface
Send
er
{
send
(
channel
:
string
,
...
args
:
any
[]):
void
;
}
export
interface
IPC
extends
Sender
,
NodeJS
.
EventEmitter
{}
class
Protocol
implements
IMessagePassingProtocol
{
private
listener
:
IDisposable
;
constructor
(
private
ipc
:
IPC
)
{}
constructor
(
private
sender
:
Sender
,
private
receiver
:
NodeJS
.
EventEmitter
)
{}
send
(
message
:
any
):
void
{
this
.
ipc
.
send
(
Message
,
message
);
this
.
sender
.
send
(
Message
,
message
);
}
onMessage
(
callback
:
(
message
:
any
)
=>
void
):
void
{
const
cb
=
(
_
,
m
)
=>
callback
(
m
);
this
.
ipc
.
on
(
Message
,
cb
);
this
.
listener
=
toDisposable
(()
=>
this
.
ipc
.
removeListener
(
Message
,
cb
));
this
.
receiver
.
on
(
Message
,
cb
);
this
.
listener
=
toDisposable
(()
=>
this
.
receiver
.
removeListener
(
Message
,
cb
));
}
dispose
():
void
{
...
...
@@ -41,11 +42,11 @@ export class Server implements IServer, IDisposable {
private
channels
:
{
[
name
:
string
]:
IChannel
};
constructor
(
ipc
:
IPC
)
{
constructor
(
ipc
:
NodeJS
.
EventEmitter
)
{
this
.
channels
=
Object
.
create
(
null
);
ipc
.
on
(
Hello
,
({
sender
})
=>
{
const
protocol
=
new
Protocol
(
sender
);
const
protocol
=
new
Protocol
(
sender
,
ipc
);
const
ipcServer
=
new
IPCServer
(
protocol
);
Object
.
keys
(
this
.
channels
)
...
...
@@ -55,8 +56,6 @@ export class Server implements IServer, IDisposable {
ipcServer
.
dispose
();
protocol
.
dispose
();
});
sender
.
send
(
Hello
);
});
}
...
...
@@ -75,7 +74,8 @@ export class Client implements IClient, IDisposable {
private
ipcClient
:
IPCClient
;
constructor
(
private
ipc
:
IPC
)
{
this
.
protocol
=
new
Protocol
(
ipc
);
ipc
.
send
(
Hello
);
this
.
protocol
=
new
Protocol
(
ipc
,
ipc
);
this
.
ipcClient
=
new
IPCClient
(
this
.
protocol
);
}
...
...
@@ -87,16 +87,4 @@ export class Client implements IClient, IDisposable {
this
.
ipc
.
send
(
Goodbye
);
this
.
protocol
=
dispose
(
this
.
protocol
);
}
}
export
function
connect
(
ipc
:
IPC
):
TPromise
<
Client
>
{
return
new
TPromise
<
Client
>
((
c
,
e
)
=>
{
ipc
.
once
(
Hello
,
()
=>
{
ipc
.
removeListener
(
'
error
'
,
e
);
c
(
new
Client
(
ipc
));
});
ipc
.
once
(
'
error
'
,
e
);
ipc
.
send
(
Hello
);
});
}
\ No newline at end of file
src/vs/code/electron-main/main.ts
浏览文件 @
fe33ef72
...
...
@@ -16,6 +16,7 @@ import { ILifecycleService, LifecycleService } from 'vs/code/electron-main/lifec
import
{
VSCodeMenu
}
from
'
vs/code/electron-main/menus
'
;
import
{
ISettingsService
,
SettingsManager
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
,
UpdateManager
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
Server
as
ElectronIPCServer
}
from
'
vs/base/parts/ipc/common/ipc.electron
'
;
import
{
Server
,
serve
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
AskpassChannel
}
from
'
vs/workbench/parts/git/common/gitIpc
'
;
...
...
@@ -31,6 +32,8 @@ import { ILogService, MainLogService } from 'vs/code/electron-main/log';
import
{
IStorageService
,
StorageService
}
from
'
vs/code/electron-main/storage
'
;
import
*
as
cp
from
'
child_process
'
;
import
{
generateUuid
}
from
'
vs/base/common/uuid
'
;
import
{
URLChannel
}
from
'
vs/platform/url/common/urlIpc
'
;
import
{
URLService
}
from
'
vs/platform/url/electron-main/urlService
'
;
function
quit
(
accessor
:
ServicesAccessor
,
error
?:
Error
);
function
quit
(
accessor
:
ServicesAccessor
,
message
?:
string
);
...
...
@@ -52,7 +55,7 @@ function quit(accessor: ServicesAccessor, arg?: any) {
process
.
exit
(
exitCode
);
// in main, process.exit === app.exit
}
function
main
(
accessor
:
ServicesAccessor
,
i
pcServer
:
Server
,
userEnv
:
IProcessEnvironment
):
void
{
function
main
(
accessor
:
ServicesAccessor
,
mainI
pcServer
:
Server
,
userEnv
:
IProcessEnvironment
):
void
{
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
logService
=
accessor
.
get
(
ILogService
);
const
envService
=
accessor
.
get
(
IEnvironmentService
);
...
...
@@ -93,14 +96,22 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
// noop
}
// Register IPC services
// Register
Main
IPC services
const
launchService
=
instantiationService
.
createInstance
(
LaunchService
);
const
launchChannel
=
new
LaunchChannel
(
launchService
);
i
pcServer
.
registerChannel
(
'
launch
'
,
launchChannel
);
mainI
pcServer
.
registerChannel
(
'
launch
'
,
launchChannel
);
const
askpassService
=
new
GitAskpassService
();
const
askpassChannel
=
new
AskpassChannel
(
askpassService
);
ipcServer
.
registerChannel
(
'
askpass
'
,
askpassChannel
);
mainIpcServer
.
registerChannel
(
'
askpass
'
,
askpassChannel
);
// Create Electron IPC Server
const
electronIpcServer
=
new
ElectronIPCServer
(
ipc
);
// Register Electron IPC services
const
urlService
=
instantiationService
.
createInstance
(
URLService
);
const
urlChannel
=
new
URLChannel
(
urlService
);
electronIpcServer
.
registerChannel
(
'
url
'
,
urlChannel
);
// Used by sub processes to communicate back to the main instance
process
.
env
[
'
VSCODE_PID
'
]
=
''
+
process
.
pid
;
...
...
@@ -125,9 +136,9 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
global
.
programStart
=
envService
.
cliArgs
.
programStart
;
function
dispose
()
{
if
(
i
pcServer
)
{
i
pcServer
.
dispose
();
i
pcServer
=
null
;
if
(
mainI
pcServer
)
{
mainI
pcServer
.
dispose
();
mainI
pcServer
=
null
;
}
sharedProcess
.
dispose
();
...
...
@@ -144,12 +155,6 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
dispose
();
});
app
.
setAsDefaultProtocolClient
(
'
vscode
'
);
app
.
on
(
'
open-url
'
,
url
=>
{
console
.
log
(
url
);
});
// Dispose on vscode:exit
ipc
.
on
(
'
vscode:exit
'
,
(
event
,
code
:
number
)
=>
{
logService
.
log
(
'
IPC#vscode:exit
'
,
code
);
...
...
@@ -356,6 +361,6 @@ getUserEnvironment()
return
instantiationService
.
invokeFunction
(
a
=>
a
.
get
(
IEnvironmentService
).
createPaths
())
.
then
(()
=>
instantiationService
.
invokeFunction
(
setupIPC
))
.
then
(
ipcServer
=>
instantiationService
.
invokeFunction
(
main
,
i
pcServer
,
userEnv
));
.
then
(
mainIpcServer
=>
instantiationService
.
invokeFunction
(
main
,
mainI
pcServer
,
userEnv
));
})
.
done
(
null
,
err
=>
instantiationService
.
invokeFunction
(
quit
,
err
));
\ No newline at end of file
src/vs/platform/url/common/url.ts
浏览文件 @
fe33ef72
...
...
@@ -12,5 +12,6 @@ export const ID = 'urlService';
export
const
IURLService
=
createDecorator
<
IURLService
>
(
ID
);
export
interface
IURLService
{
onOpenUrl
:
Event
<
string
>
;
_serviceBrand
:
any
;
onOpenURL
:
Event
<
string
>
;
}
src/vs/platform/url/common/urlIpc.ts
浏览文件 @
fe33ef72
...
...
@@ -3,4 +3,35 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
\ No newline at end of file
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IChannel
,
eventToCall
,
eventFromCall
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IURLService
}
from
'
./url
'
;
import
Event
from
'
vs/base/common/event
'
;
export
interface
IURLChannel
extends
IChannel
{
call
(
command
:
'
event:onOpenURL
'
):
TPromise
<
void
>
;
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
;
}
export
class
URLChannel
implements
IURLChannel
{
constructor
(
private
service
:
IURLService
)
{
}
call
(
command
:
string
,
arg
:
any
):
TPromise
<
any
>
{
switch
(
command
)
{
case
'
event:onOpenURL
'
:
return
eventToCall
(
this
.
service
.
onOpenURL
);
}
}
}
export
class
URLChannelClient
implements
IURLService
{
_serviceBrand
:
any
;
constructor
(
private
channel
:
IChannel
)
{
}
private
_onOpenURL
=
eventFromCall
<
string
>
(
this
.
channel
,
'
event:onOpenURL
'
);
get
onOpenURL
():
Event
<
string
>
{
return
this
.
_onOpenURL
;
}
}
\ No newline at end of file
src/vs/platform/url/
node
/urlService.ts
→
src/vs/platform/url/
electron-main
/urlService.ts
浏览文件 @
fe33ef72
...
...
@@ -6,14 +6,31 @@
'
use strict
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
app
}
from
'
electron
'
;
export
class
URLService
implements
IURLService
{
export
class
URLService
implements
IURLService
,
IDisposable
{
private
_onOpenUrl
=
new
Emitter
<
string
>
();
onOpenUrl
:
Event
<
string
>
=
this
.
_onOpenUrl
.
event
;
_serviceBrand
:
any
;
private
_onOpenURL
=
new
Emitter
<
string
>
();
onOpenURL
:
Event
<
string
>
=
this
.
_onOpenURL
.
event
;
private
disposables
:
IDisposable
[]
=
[];
constructor
()
{
const
handler
=
(
e
:
Electron
.
Event
,
url
:
string
)
=>
{
e
.
preventDefault
();
this
.
_onOpenURL
.
fire
(
url
);
};
app
.
on
(
'
open-url
'
,
handler
);
this
.
disposables
.
push
(
toDisposable
(()
=>
app
.
removeListener
(
'
open-url
'
,
handler
)));
// app.setAsDefaultProtocolClient('vscode');
}
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
\ No newline at end of file
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
fe33ef72
...
...
@@ -70,9 +70,13 @@ import {CrashReporter} from 'vs/workbench/electron-browser/crashReporter';
import
{
IThemeService
}
from
'
vs/workbench/services/themes/common/themeService
'
;
import
{
ThemeService
}
from
'
vs/workbench/services/themes/electron-browser/themeService
'
;
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
connect
as
connectNet
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
Client
as
ElectronIPCClient
}
from
'
vs/base/parts/ipc/common/ipc.electron
'
;
import
{
ipcRenderer
}
from
'
electron
'
;
import
{
IExtensionManagementChannel
,
ExtensionManagementChannelClient
}
from
'
vs/platform/extensionManagement/common/extensionManagementIpc
'
;
import
{
IExtensionManagementService
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
URLChannelClient
}
from
'
vs/platform/url/common/urlIpc
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
import
{
ReloadWindowAction
}
from
'
vs/workbench/electron-browser/actions
'
;
// self registering services
...
...
@@ -202,7 +206,7 @@ export class WorkbenchShell {
}
private
initServiceCollection
():
[
InstantiationService
,
ServiceCollection
]
{
const
sharedProcess
=
connect
(
process
.
env
[
'
VSCODE_SHARED_IPC_HOOK
'
]);
const
sharedProcess
=
connect
Net
(
process
.
env
[
'
VSCODE_SHARED_IPC_HOOK
'
]);
sharedProcess
.
done
(
service
=>
{
service
.
onClose
(()
=>
{
this
.
messageService
.
show
(
Severity
.
Error
,
{
...
...
@@ -212,6 +216,8 @@ export class WorkbenchShell {
});
},
errors
.
onUnexpectedError
);
const
mainProcessClient
=
new
ElectronIPCClient
(
ipcRenderer
);
const
serviceCollection
=
new
ServiceCollection
();
serviceCollection
.
set
(
IEventService
,
this
.
eventService
);
serviceCollection
.
set
(
IWorkspaceContextService
,
this
.
contextService
);
...
...
@@ -314,6 +320,10 @@ export class WorkbenchShell {
const
extensionManagementChannelClient
=
instantiationService
.
createInstance
(
ExtensionManagementChannelClient
,
extensionManagementChannel
);
serviceCollection
.
set
(
IExtensionManagementService
,
extensionManagementChannelClient
);
const
urlChannel
=
mainProcessClient
.
getChannel
(
'
url
'
);
const
urlChannelClient
=
instantiationService
.
createInstance
(
URLChannelClient
,
urlChannel
);
serviceCollection
.
set
(
IURLService
,
urlChannelClient
);
return
[
instantiationService
,
serviceCollection
];
}
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension.ts
浏览文件 @
fe33ef72
...
...
@@ -17,6 +17,7 @@ import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common
import
{
IActivityService
,
ProgressBadge
,
NumberBadge
}
from
'
vs/workbench/services/activity/common/activityService
'
;
import
{
ReloadWindowAction
}
from
'
vs/workbench/electron-browser/actions
'
;
import
{
ipcRenderer
as
ipc
}
from
'
electron
'
;
import
{
IURLService
}
from
'
vs/platform/url/common/url
'
;
interface
IInstallExtensionsRequest
{
extensionsToInstall
:
string
[];
...
...
@@ -31,7 +32,8 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
@
IMessageService
private
messageService
:
IMessageService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IExtensionTipsService
extenstionTips
:
IExtensionTipsService
,
// this is to eagerly start the service
@
IExtensionGalleryService
galleryService
:
IExtensionGalleryService
@
IExtensionGalleryService
galleryService
:
IExtensionGalleryService
,
@
IURLService
urlService
:
IURLService
)
{
this
.
registerListeners
();
...
...
@@ -40,6 +42,9 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
if
(
options
.
extensionsToInstall
&&
options
.
extensionsToInstall
.
length
)
{
this
.
install
(
options
.
extensionsToInstall
).
done
(
null
,
onUnexpectedError
);
}
urlService
.
onOpenURL
(
url
=>
console
.
log
(
url
));
//actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallExtensionAction, InstallExtensionAction.ID, InstallExtensionAction.LABEL), 'Extensions: Install Extension', ExtensionsLabel);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录