Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b7b21844
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,发现更多精彩内容 >>
提交
b7b21844
编写于
10月 29, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
api - fold app uri creation into asExternalUri (fix #82884)
上级
d1866531
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
82 addition
and
47 deletion
+82
-47
extensions/vscode-api-tests/src/singlefolder-tests/env.test.ts
...sions/vscode-api-tests/src/singlefolder-tests/env.test.ts
+24
-3
src/vs/platform/product/common/product.ts
src/vs/platform/product/common/product.ts
+2
-1
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+36
-7
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-27
src/vs/workbench/api/browser/mainThreadUrls.ts
src/vs/workbench/api/browser/mainThreadUrls.ts
+5
-1
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+5
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-1
src/vs/workbench/api/common/extHostUrls.ts
src/vs/workbench/api/common/extHostUrls.ts
+6
-2
src/vs/workbench/browser/web.main.ts
src/vs/workbench/browser/web.main.ts
+1
-4
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/env.test.ts
浏览文件 @
b7b21844
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
*
as
assert
from
'
assert
'
;
import
{
env
,
extensions
,
ExtensionKind
,
UIKind
}
from
'
vscode
'
;
import
{
env
,
extensions
,
ExtensionKind
,
UIKind
,
Uri
}
from
'
vscode
'
;
suite
(
'
env-namespace
'
,
()
=>
{
suite
(
'
env-namespace
'
,
()
=>
{
...
@@ -45,8 +45,29 @@ suite('env-namespace', () => {
...
@@ -45,8 +45,29 @@ suite('env-namespace', () => {
}
}
});
});
test
(
'
env.uiKind
'
,
function
()
{
test
(
'
env.uiKind
'
,
async
function
()
{
const
uri
=
Uri
.
parse
(
`
${
env
.
uriScheme
}
:://vscode.vscode-api-tests/path?key=value&other=false`
);
const
result
=
await
env
.
asExternalUri
(
uri
);
const
kind
=
env
.
uiKind
;
const
kind
=
env
.
uiKind
;
assert
.
equal
(
kind
,
UIKind
.
Desktop
);
if
(
result
.
scheme
===
'
http
'
||
result
.
scheme
===
'
https
'
)
{
assert
.
equal
(
kind
,
UIKind
.
Web
);
}
else
{
assert
.
equal
(
kind
,
UIKind
.
Desktop
);
}
});
test
(
'
env.asExternalUri - with env.uriScheme
'
,
async
function
()
{
const
uri
=
Uri
.
parse
(
`
${
env
.
uriScheme
}
:://vscode.vscode-api-tests/path?key=value&other=false`
);
const
result
=
await
env
.
asExternalUri
(
uri
);
assert
.
ok
(
result
);
if
(
env
.
uiKind
===
UIKind
.
Desktop
)
{
assert
.
equal
(
uri
.
scheme
,
result
.
scheme
);
assert
.
equal
(
uri
.
authority
,
result
.
authority
);
assert
.
equal
(
uri
.
path
,
result
.
path
);
}
else
{
assert
.
ok
(
result
.
scheme
===
'
http
'
||
result
.
scheme
===
'
https
'
);
}
});
});
});
});
src/vs/platform/product/common/product.ts
浏览文件 @
b7b21844
...
@@ -23,7 +23,8 @@ if (isWeb) {
...
@@ -23,7 +23,8 @@ if (isWeb) {
assign
(
product
,
{
assign
(
product
,
{
version
:
'
1.39.0-dev
'
,
version
:
'
1.39.0-dev
'
,
nameLong
:
'
Visual Studio Code Web Dev
'
,
nameLong
:
'
Visual Studio Code Web Dev
'
,
nameShort
:
'
VSCode Web Dev
'
nameShort
:
'
VSCode Web Dev
'
,
urlProtocol
:
'
code-oss
'
});
});
}
}
}
}
...
...
src/vs/vscode.d.ts
浏览文件 @
b7b21844
...
@@ -6433,22 +6433,51 @@ declare module 'vscode' {
...
@@ -6433,22 +6433,51 @@ declare module 'vscode' {
export
function
openExternal
(
target
:
Uri
):
Thenable
<
boolean
>
;
export
function
openExternal
(
target
:
Uri
):
Thenable
<
boolean
>
;
/**
/**
* Resolves a uri to form that is accessible externally. Currently only supports `https:`, `http:` and
* `vscode.env.uriScheme` uris.
*
* #### `http:` or `https:` scheme
*
* Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
* Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
* uri to the same resource on the client machine.
* uri to the same resource on the client machine.
*
*
* This is a no-op if the extension is running on the client machine. Currently only supports
* This is a no-op if the extension is running on the client machine.
* `https:` and `http:` uris.
*
*
* If the extension is running remotely, this function automatically establishes a port forwarding tunnel
* If the extension is running remotely, this function automatically establishes a port forwarding tunnel
* from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
* from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
* the port fowarding tunnel is managed by VS Code and the tunnel can be closed by the user.
* the port fowarding tunnel is managed by VS Code and the tunnel can be closed by the user.
*
*
* Extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
* *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
* a system or user action — for example, in remote cases, a user may close a port forwardng tunnel
*
* that was opened by `asExternalUri`.
* #### `vscode.env.uriScheme`
*
* Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered [UriHandler](#UriHandler)
* to trigger.
*
* Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
* Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
* argument to the server to authenticate to.
*
* *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
* will appear in the uri that is passed to the [UriHandler](#UriHandler).
*
* **Example** of an authentication flow:
* ```typescript
* vscode.window.registerUriHandler({
* handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
* if (uri.path === '/did-authenticate') {
* console.log(uri.toString());
* }
* }
* });
*
* const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${env.uriScheme}:://my.extension/did-authenticate`));
* await vscode.env.openExternal(callableUri);
* ```
*
*
* *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri`
* *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
* on them.
* a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
* `asExternalUri`.
*
*
* @return A uri that can be used on the client machine.
* @return A uri that can be used on the client machine.
*/
*/
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
b7b21844
...
@@ -855,33 +855,7 @@ declare module 'vscode' {
...
@@ -855,33 +855,7 @@ declare module 'vscode' {
export
namespace
env
{
export
namespace
env
{
/**
/**
* Creates a Uri that - if opened in a browser - will result in a
* @deprecated use `vscode.env.asExternalUri` instead.
* registered [UriHandler](#UriHandler) to fire. The handler's
* Uri will be configured with the path, query and fragment of
* [AppUriOptions](#AppUriOptions) if provided, otherwise it will be empty.
*
* Extensions should not make any assumptions about the resulting
* Uri and should not alter it in anyway. Rather, extensions can e.g.
* use this Uri in an authentication flow, by adding the Uri as
* callback query argument to the server to authenticate to.
*
* Note: If the server decides to add additional query parameters to the Uri
* (e.g. a token or secret), it will appear in the Uri that is passed
* to the [UriHandler](#UriHandler).
*
* **Example** of an authentication flow:
* ```typescript
* vscode.window.registerUriHandler({
* handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
* if (uri.path === '/did-authenticate') {
* console.log(uri.toString());
* }
* }
* });
*
* const callableUri = await vscode.env.createAppUri({ payload: { path: '/did-authenticate' } });
* await vscode.env.openExternal(callableUri);
* ```
*/
*/
export
function
createAppUri
(
options
?:
AppUriOptions
):
Thenable
<
Uri
>
;
export
function
createAppUri
(
options
?:
AppUriOptions
):
Thenable
<
Uri
>
;
}
}
...
...
src/vs/workbench/api/browser/mainThreadUrls.ts
浏览文件 @
b7b21844
...
@@ -68,7 +68,11 @@ export class MainThreadUrls implements MainThreadUrlsShape {
...
@@ -68,7 +68,11 @@ export class MainThreadUrls implements MainThreadUrlsShape {
return
Promise
.
resolve
(
undefined
);
return
Promise
.
resolve
(
undefined
);
}
}
async
$createAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
{
payload
?:
Partial
<
UriComponents
>
}):
Promise
<
URI
>
{
async
$createAppUri
(
uri
:
UriComponents
):
Promise
<
URI
>
{
return
this
.
urlService
.
create
(
uri
);
}
async
$proposedCreateAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
{
payload
?:
Partial
<
UriComponents
>
}):
Promise
<
URI
>
{
const
payload
:
Partial
<
UriComponents
>
=
options
&&
options
.
payload
?
options
.
payload
:
Object
.
create
(
null
);
const
payload
:
Partial
<
UriComponents
>
=
options
&&
options
.
payload
?
options
.
payload
:
Object
.
create
(
null
);
// we define the authority to be the extension ID to ensure
// we define the authority to be the extension ID to ensure
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
b7b21844
...
@@ -228,7 +228,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
...
@@ -228,7 +228,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
get
uriScheme
()
{
return
initData
.
environment
.
appUriScheme
;
},
get
uriScheme
()
{
return
initData
.
environment
.
appUriScheme
;
},
createAppUri
(
options
?)
{
createAppUri
(
options
?)
{
checkProposedApiEnabled
(
extension
);
checkProposedApiEnabled
(
extension
);
return
extHostUrls
.
c
reateAppUri
(
extension
.
identifier
,
options
);
return
extHostUrls
.
proposedC
reateAppUri
(
extension
.
identifier
,
options
);
},
},
get
logLevel
()
{
get
logLevel
()
{
checkProposedApiEnabled
(
extension
);
checkProposedApiEnabled
(
extension
);
...
@@ -248,6 +248,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
...
@@ -248,6 +248,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
return
extHostWindow
.
openUri
(
uri
,
{
allowTunneling
:
!!
initData
.
remote
.
isRemote
});
return
extHostWindow
.
openUri
(
uri
,
{
allowTunneling
:
!!
initData
.
remote
.
isRemote
});
},
},
asExternalUri
(
uri
:
URI
)
{
asExternalUri
(
uri
:
URI
)
{
if
(
uri
.
scheme
===
initData
.
environment
.
appUriScheme
)
{
return
extHostUrls
.
createAppUri
(
uri
);
}
return
extHostWindow
.
asExternalUri
(
uri
,
{
allowTunneling
:
!!
initData
.
remote
.
isRemote
});
return
extHostWindow
.
asExternalUri
(
uri
,
{
allowTunneling
:
!!
initData
.
remote
.
isRemote
});
},
},
get
remoteName
()
{
get
remoteName
()
{
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
b7b21844
...
@@ -594,7 +594,8 @@ export interface ExtHostWebviewsShape {
...
@@ -594,7 +594,8 @@ export interface ExtHostWebviewsShape {
export
interface
MainThreadUrlsShape
extends
IDisposable
{
export
interface
MainThreadUrlsShape
extends
IDisposable
{
$registerUriHandler
(
handle
:
number
,
extensionId
:
ExtensionIdentifier
):
Promise
<
void
>
;
$registerUriHandler
(
handle
:
number
,
extensionId
:
ExtensionIdentifier
):
Promise
<
void
>
;
$unregisterUriHandler
(
handle
:
number
):
Promise
<
void
>
;
$unregisterUriHandler
(
handle
:
number
):
Promise
<
void
>
;
$createAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
{
payload
?:
Partial
<
UriComponents
>
}):
Promise
<
UriComponents
>
;
$createAppUri
(
uri
:
UriComponents
):
Promise
<
UriComponents
>
;
$proposedCreateAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
{
payload
?:
Partial
<
UriComponents
>
}):
Promise
<
UriComponents
>
;
}
}
export
interface
ExtHostUrlsShape
{
export
interface
ExtHostUrlsShape
{
...
...
src/vs/workbench/api/common/extHostUrls.ts
浏览文件 @
b7b21844
...
@@ -56,7 +56,11 @@ export class ExtHostUrls implements ExtHostUrlsShape {
...
@@ -56,7 +56,11 @@ export class ExtHostUrls implements ExtHostUrlsShape {
return
Promise
.
resolve
(
undefined
);
return
Promise
.
resolve
(
undefined
);
}
}
async
createAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
vscode
.
AppUriOptions
):
Promise
<
vscode
.
Uri
>
{
async
createAppUri
(
uri
:
URI
):
Promise
<
vscode
.
Uri
>
{
return
URI
.
revive
(
await
this
.
_proxy
.
$createAppUri
(
extensionId
,
options
));
return
URI
.
revive
(
await
this
.
_proxy
.
$createAppUri
(
uri
));
}
async
proposedCreateAppUri
(
extensionId
:
ExtensionIdentifier
,
options
?:
vscode
.
AppUriOptions
):
Promise
<
vscode
.
Uri
>
{
return
URI
.
revive
(
await
this
.
_proxy
.
$proposedCreateAppUri
(
extensionId
,
options
));
}
}
}
}
src/vs/workbench/browser/web.main.ts
浏览文件 @
b7b21844
...
@@ -162,10 +162,7 @@ class BrowserMain extends Disposable {
...
@@ -162,10 +162,7 @@ class BrowserMain extends Disposable {
// Product
// Product
const
productService
=
{
const
productService
=
{
_serviceBrand
:
undefined
,
_serviceBrand
:
undefined
,
...{
...
product
...
product
,
// dev or built time config
...{
urlProtocol
:
''
}
// web related overrides from us
}
};
};
serviceCollection
.
set
(
IProductService
,
productService
);
serviceCollection
.
set
(
IProductService
,
productService
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录