Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9b507d2b
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9b507d2b
编写于
10月 24, 2020
作者:
S
Sandeep Somavarapu
提交者:
GitHub
10月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add apis to storage keys registry service to register extension storage keys
上级
b906da14
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
108 addition
and
16 deletion
+108
-16
src/vs/platform/userDataSync/common/storageKeys.ts
src/vs/platform/userDataSync/common/storageKeys.ts
+76
-4
src/vs/platform/userDataSync/common/userDataSyncIpc.ts
src/vs/platform/userDataSync/common/userDataSyncIpc.ts
+24
-12
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
+8
-0
未找到文件。
src/vs/platform/userDataSync/common/storageKeys.ts
浏览文件 @
9b507d2b
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtensionIdentifierWithVersion
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
interface
IStorageKey
{
export
interface
IStorageKey
{
...
@@ -14,6 +15,28 @@ export interface IStorageKey {
...
@@ -14,6 +15,28 @@ export interface IStorageKey {
}
}
export
interface
IExtensionIdWithVersion
{
id
:
string
;
version
:
string
;
}
export
namespace
ExtensionIdWithVersion
{
const
EXTENSION_ID_VERSION_REGEX
=
/^
([^
.
]
+
\.
.+
)
@
(\d
+
\.\d
+
\.\d
+
(
-.*
)?)
$/
;
export
function
toKey
(
extension
:
IExtensionIdWithVersion
):
string
{
return
`
${
extension
.
id
}
@
${
extension
.
version
}
`
;
}
export
function
fromKey
(
key
:
string
):
IExtensionIdWithVersion
|
undefined
{
const
matches
=
EXTENSION_ID_VERSION_REGEX
.
exec
(
key
);
if
(
matches
&&
matches
[
1
])
{
return
{
id
:
matches
[
1
],
version
:
matches
[
2
]
};
}
return
undefined
;
}
}
export
const
IStorageKeysSyncRegistryService
=
createDecorator
<
IStorageKeysSyncRegistryService
>
(
'
IStorageKeysSyncRegistryService
'
);
export
const
IStorageKeysSyncRegistryService
=
createDecorator
<
IStorageKeysSyncRegistryService
>
(
'
IStorageKeysSyncRegistryService
'
);
export
interface
IStorageKeysSyncRegistryService
{
export
interface
IStorageKeysSyncRegistryService
{
...
@@ -35,23 +58,68 @@ export interface IStorageKeysSyncRegistryService {
...
@@ -35,23 +58,68 @@ export interface IStorageKeysSyncRegistryService {
*/
*/
registerStorageKey
(
key
:
IStorageKey
):
void
;
registerStorageKey
(
key
:
IStorageKey
):
void
;
/**
* All registered extensions storage keys
*/
readonly
extensionsStorageKeys
:
ReadonlyArray
<
[
IExtensionIdentifierWithVersion
,
ReadonlyArray
<
string
>
]
>
;
/**
* Event that is triggered when extension storage keys are changed
*/
onDidChangeExtensionStorageKeys
:
Event
<
[
IExtensionIdWithVersion
,
ReadonlyArray
<
string
>
]
>
;
/**
* Register storage keys that has to be synchronized for the given extension.
*/
registerExtensionStorageKeys
(
extension
:
IExtensionIdWithVersion
,
keys
:
string
[]):
void
;
/**
* Returns storage keys of the given extension that has to be synchronized.
*/
getExtensioStorageKeys
(
extension
:
IExtensionIdWithVersion
):
ReadonlyArray
<
string
>
;
}
}
export
class
StorageKeysSyncRegistryService
extends
Disposable
implements
IStorageKeysSyncRegistryService
{
export
abstract
class
Abstract
StorageKeysSyncRegistryService
extends
Disposable
implements
IStorageKeysSyncRegistryService
{
_serviceBrand
:
any
;
declare
readonly
_serviceBrand
:
undefined
;
pr
ivate
readonly
_storageKeys
=
new
Map
<
string
,
IStorageKey
>
();
pr
otected
readonly
_storageKeys
=
new
Map
<
string
,
IStorageKey
>
();
get
storageKeys
():
ReadonlyArray
<
IStorageKey
>
{
return
[...
this
.
_storageKeys
.
values
()];
}
get
storageKeys
():
ReadonlyArray
<
IStorageKey
>
{
return
[...
this
.
_storageKeys
.
values
()];
}
pr
ivate
readonly
_onDidChangeStorageKeys
:
Emitter
<
ReadonlyArray
<
IStorageKey
>>
=
this
.
_register
(
new
Emitter
<
ReadonlyArray
<
IStorageKey
>>
());
pr
otected
readonly
_onDidChangeStorageKeys
:
Emitter
<
ReadonlyArray
<
IStorageKey
>>
=
this
.
_register
(
new
Emitter
<
ReadonlyArray
<
IStorageKey
>>
());
readonly
onDidChangeStorageKeys
=
this
.
_onDidChangeStorageKeys
.
event
;
readonly
onDidChangeStorageKeys
=
this
.
_onDidChangeStorageKeys
.
event
;
protected
readonly
_extensionsStorageKeys
=
new
Map
<
string
,
string
[]
>
();
get
extensionsStorageKeys
()
{
const
result
:
[
IExtensionIdWithVersion
,
ReadonlyArray
<
string
>
][]
=
[];
this
.
_extensionsStorageKeys
.
forEach
((
keys
,
extension
)
=>
result
.
push
([
ExtensionIdWithVersion
.
fromKey
(
extension
)
!
,
keys
]));
return
result
;
}
protected
readonly
_onDidChangeExtensionStorageKeys
=
this
.
_register
(
new
Emitter
<
[
IExtensionIdWithVersion
,
ReadonlyArray
<
string
>
]
>
());
readonly
onDidChangeExtensionStorageKeys
=
this
.
_onDidChangeExtensionStorageKeys
.
event
;
constructor
()
{
constructor
()
{
super
();
super
();
this
.
_register
(
toDisposable
(()
=>
this
.
_storageKeys
.
clear
()));
this
.
_register
(
toDisposable
(()
=>
this
.
_storageKeys
.
clear
()));
}
}
getExtensioStorageKeys
(
extension
:
IExtensionIdWithVersion
):
ReadonlyArray
<
string
>
{
return
this
.
_extensionsStorageKeys
.
get
(
ExtensionIdWithVersion
.
toKey
(
extension
))
||
[];
}
protected
updateExtensionStorageKeys
(
extension
:
IExtensionIdWithVersion
,
keys
:
string
[]):
void
{
this
.
_extensionsStorageKeys
.
set
(
ExtensionIdWithVersion
.
toKey
(
extension
),
keys
);
this
.
_onDidChangeExtensionStorageKeys
.
fire
([
extension
,
keys
]);
}
abstract
registerStorageKey
(
key
:
IStorageKey
):
void
;
abstract
registerExtensionStorageKeys
(
extension
:
IExtensionIdWithVersion
,
keys
:
string
[]):
void
;
}
export
class
StorageKeysSyncRegistryService
extends
AbstractStorageKeysSyncRegistryService
{
_serviceBrand
:
any
;
registerStorageKey
(
storageKey
:
IStorageKey
):
void
{
registerStorageKey
(
storageKey
:
IStorageKey
):
void
{
if
(
!
this
.
_storageKeys
.
has
(
storageKey
.
key
))
{
if
(
!
this
.
_storageKeys
.
has
(
storageKey
.
key
))
{
this
.
_storageKeys
.
set
(
storageKey
.
key
,
storageKey
);
this
.
_storageKeys
.
set
(
storageKey
.
key
,
storageKey
);
...
@@ -59,4 +127,8 @@ export class StorageKeysSyncRegistryService extends Disposable implements IStora
...
@@ -59,4 +127,8 @@ export class StorageKeysSyncRegistryService extends Disposable implements IStora
}
}
}
}
registerExtensionStorageKeys
(
extension
:
IExtensionIdWithVersion
,
keys
:
string
[]):
void
{
this
.
updateExtensionStorageKeys
(
extension
,
keys
);
}
}
}
src/vs/platform/userDataSync/common/userDataSyncIpc.ts
浏览文件 @
9b507d2b
...
@@ -4,16 +4,16 @@
...
@@ -4,16 +4,16 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
IServerChannel
,
IChannel
,
IPCServer
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
IServerChannel
,
IChannel
,
IPCServer
}
from
'
vs/base/parts/ipc/common/ipc
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
IUserDataSyncService
,
IUserDataSyncUtilService
,
IUserDataAutoSyncService
,
IManualSyncTask
,
IUserDataManifest
,
IUserDataSyncStoreManagementService
,
SyncStatus
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
IUserDataSyncService
,
IUserDataSyncUtilService
,
IUserDataAutoSyncService
,
IManualSyncTask
,
IUserDataManifest
,
IUserDataSyncStoreManagementService
,
SyncStatus
}
from
'
vs/platform/userDataSync/common/userDataSync
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
FormattingOptions
}
from
'
vs/base/common/jsonFormatter
'
;
import
{
FormattingOptions
}
from
'
vs/base/common/jsonFormatter
'
;
import
{
IStorageKeysSyncRegistryService
,
IStorageKey
}
from
'
vs/platform/userDataSync/common/storageKeys
'
;
import
{
IStorageKeysSyncRegistryService
,
IStorageKey
,
IExtensionIdWithVersion
,
AbstractStorageKeysSyncRegistryService
}
from
'
vs/platform/userDataSync/common/storageKeys
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IUserDataSyncMachinesService
}
from
'
vs/platform/userDataSync/common/userDataSyncMachines
'
;
import
{
IUserDataSyncMachinesService
}
from
'
vs/platform/userDataSync/common/userDataSyncMachines
'
;
import
{
IUserDataSyncAccountService
}
from
'
vs/platform/userDataSync/common/userDataSyncAccount
'
;
import
{
IUserDataSyncAccountService
}
from
'
vs/platform/userDataSync/common/userDataSyncAccount
'
;
import
{
IExtensionIdentifierWithVersion
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
export
class
UserDataSyncChannel
implements
IServerChannel
{
export
class
UserDataSyncChannel
implements
IServerChannel
{
...
@@ -175,6 +175,8 @@ export class UserDataSyncUtilServiceClient implements IUserDataSyncUtilService {
...
@@ -175,6 +175,8 @@ export class UserDataSyncUtilServiceClient implements IUserDataSyncUtilService {
}
}
type
StorageKeysSyncRegistryServiceInitData
=
{
storageKeys
:
ReadonlyArray
<
IStorageKey
>
,
extensionsStorageKeys
:
ReadonlyArray
<
[
IExtensionIdWithVersion
,
ReadonlyArray
<
string
>
]
>
};
export
class
StorageKeysSyncRegistryChannel
implements
IServerChannel
{
export
class
StorageKeysSyncRegistryChannel
implements
IServerChannel
{
constructor
(
private
readonly
service
:
IStorageKeysSyncRegistryService
)
{
}
constructor
(
private
readonly
service
:
IStorageKeysSyncRegistryService
)
{
}
...
@@ -188,39 +190,49 @@ export class StorageKeysSyncRegistryChannel implements IServerChannel {
...
@@ -188,39 +190,49 @@ export class StorageKeysSyncRegistryChannel implements IServerChannel {
call
(
context
:
any
,
command
:
string
,
args
?:
any
):
Promise
<
any
>
{
call
(
context
:
any
,
command
:
string
,
args
?:
any
):
Promise
<
any
>
{
switch
(
command
)
{
switch
(
command
)
{
case
'
_getInitialData
'
:
return
Promise
.
resolve
(
this
.
service
.
storageKeys
);
case
'
_getInitialData
'
:
return
Promise
.
resolve
<
StorageKeysSyncRegistryServiceInitData
>
({
storageKeys
:
this
.
service
.
storageKeys
,
extensionsStorageKeys
:
this
.
service
.
extensionsStorageKeys
}
);
case
'
registerStorageKey
'
:
return
Promise
.
resolve
(
this
.
service
.
registerStorageKey
(
args
[
0
]));
case
'
registerStorageKey
'
:
return
Promise
.
resolve
(
this
.
service
.
registerStorageKey
(
args
[
0
]));
}
}
throw
new
Error
(
'
Invalid call
'
);
throw
new
Error
(
'
Invalid call
'
);
}
}
}
}
export
class
StorageKeysSyncRegistryChannelClient
extends
Disposable
implements
I
StorageKeysSyncRegistryService
{
export
class
StorageKeysSyncRegistryChannelClient
extends
Abstract
StorageKeysSyncRegistryService
{
declare
readonly
_serviceBrand
:
undefined
;
declare
readonly
_serviceBrand
:
undefined
;
private
_storageKeys
:
ReadonlyArray
<
IStorageKey
>
=
[];
get
storageKeys
():
ReadonlyArray
<
IStorageKey
>
{
return
this
.
_storageKeys
;
}
private
readonly
_onDidChangeStorageKeys
:
Emitter
<
ReadonlyArray
<
IStorageKey
>>
=
this
.
_register
(
new
Emitter
<
ReadonlyArray
<
IStorageKey
>>
());
readonly
onDidChangeStorageKeys
=
this
.
_onDidChangeStorageKeys
.
event
;
constructor
(
private
readonly
channel
:
IChannel
)
{
constructor
(
private
readonly
channel
:
IChannel
)
{
super
();
super
();
this
.
channel
.
call
<
IStorageKey
[]
>
(
'
_getInitialData
'
).
then
(
storageKeys
=>
{
this
.
channel
.
call
<
StorageKeysSyncRegistryServiceInitData
>
(
'
_getInitialData
'
).
then
(({
storageKeys
,
extensionsStorageKeys
})
=>
{
this
.
updateStorageKeys
(
storageKeys
);
this
.
updateStorageKeys
(
storageKeys
);
this
.
updateExtensionsStorageKeys
(
extensionsStorageKeys
);
this
.
_register
(
this
.
channel
.
listen
<
ReadonlyArray
<
IStorageKey
>>
(
'
onDidChangeStorageKeys
'
)(
storageKeys
=>
this
.
updateStorageKeys
(
storageKeys
)));
this
.
_register
(
this
.
channel
.
listen
<
ReadonlyArray
<
IStorageKey
>>
(
'
onDidChangeStorageKeys
'
)(
storageKeys
=>
this
.
updateStorageKeys
(
storageKeys
)));
this
.
_register
(
this
.
channel
.
listen
<
[
IExtensionIdentifierWithVersion
,
string
[]]
>
(
'
onDidChangeExtensionStorageKeys
'
)(
e
=>
this
.
updateExtensionStorageKeys
(
e
[
0
],
e
[
1
])));
});
});
}
}
private
async
updateStorageKeys
(
storageKeys
:
ReadonlyArray
<
IStorageKey
>
):
Promise
<
void
>
{
private
async
updateStorageKeys
(
storageKeys
:
ReadonlyArray
<
IStorageKey
>
):
Promise
<
void
>
{
this
.
_storageKeys
=
storageKeys
;
this
.
_storageKeys
.
clear
();
for
(
const
storageKey
of
storageKeys
)
{
this
.
_storageKeys
.
set
(
storageKey
.
key
,
storageKey
);
}
this
.
_onDidChangeStorageKeys
.
fire
(
this
.
storageKeys
);
this
.
_onDidChangeStorageKeys
.
fire
(
this
.
storageKeys
);
}
}
private
async
updateExtensionsStorageKeys
(
extensionStorageKeys
:
ReadonlyArray
<
[
IExtensionIdentifierWithVersion
,
ReadonlyArray
<
string
>
]
>
):
Promise
<
void
>
{
for
(
const
[
extension
,
keys
]
of
extensionStorageKeys
)
{
this
.
updateExtensionStorageKeys
(
extension
,
[...
keys
]);
}
}
registerStorageKey
(
storageKey
:
IStorageKey
):
void
{
registerStorageKey
(
storageKey
:
IStorageKey
):
void
{
this
.
channel
.
call
(
'
registerStorageKey
'
,
[
storageKey
]);
this
.
channel
.
call
(
'
registerStorageKey
'
,
[
storageKey
]);
}
}
registerExtensionStorageKeys
(
extension
:
IExtensionIdentifierWithVersion
,
keys
:
string
[]):
void
{
this
.
channel
.
call
(
'
registerExtensionStorageKeys
'
,
[
extension
,
keys
]);
}
}
}
export
class
UserDataSyncMachinesServiceChannel
implements
IServerChannel
{
export
class
UserDataSyncMachinesServiceChannel
implements
IServerChannel
{
...
...
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
浏览文件 @
9b507d2b
...
@@ -726,6 +726,14 @@ class SimpleIStorageKeysSyncRegistryService implements IStorageKeysSyncRegistryS
...
@@ -726,6 +726,14 @@ class SimpleIStorageKeysSyncRegistryService implements IStorageKeysSyncRegistryS
storageKeys
=
[];
storageKeys
=
[];
registerStorageKey
():
void
{
}
registerStorageKey
():
void
{
}
onDidChangeExtensionStorageKeys
=
Event
.
None
;
extensionsStorageKeys
=
[];
getExtensioStorageKeys
():
[]
{
return
[];
}
registerExtensionStorageKeys
():
void
{
}
}
}
registerSingleton
(
IStorageKeysSyncRegistryService
,
SimpleIStorageKeysSyncRegistryService
);
registerSingleton
(
IStorageKeysSyncRegistryService
,
SimpleIStorageKeysSyncRegistryService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录