Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b1457fa4
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,发现更多精彩内容 >>
未验证
提交
b1457fa4
编写于
6月 01, 2021
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove NotebookCellOutputItem#metadata
上级
6a02e833
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
44 deletion
+33
-44
extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts
.../vscode-api-tests/src/singlefolder-tests/notebook.test.ts
+12
-10
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+7
-16
src/vs/workbench/api/common/extHostTypeConverters.ts
src/vs/workbench/api/common/extHostTypeConverters.ts
+1
-2
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+12
-13
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
...ntrib/notebook/browser/view/renderers/backLayerWebView.ts
+1
-1
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+0
-1
src/vs/workbench/test/browser/api/extHostTypeConverter.test.ts
...s/workbench/test/browser/api/extHostTypeConverter.test.ts
+0
-1
未找到文件。
extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts
浏览文件 @
b1457fa4
...
...
@@ -61,13 +61,13 @@ class Kernel {
task
.
executionOrder
=
1
;
if
(
cell
.
notebook
.
uri
.
path
.
endsWith
(
'
customRenderer.vsctestnb
'
))
{
await
task
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
test
'
,
'
text/custom
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
test
'
,
'
text/custom
'
)
])]);
return
;
}
await
task
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
my output
'
,
'
text/plain
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
my output
'
,
'
text/plain
'
)
])]);
task
.
end
({
success
:
true
});
}
...
...
@@ -130,9 +130,12 @@ suite('Notebook API tests', function () {
kind
:
vscode
.
NotebookCellKind
.
Code
,
outputs
:
[
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
Hello World
'
,
'
text/plain
'
,
{
testOutputItemMetadata
:
true
}
)
vscode
.
NotebookCellOutputItem
.
text
(
'
Hello World
'
,
'
text/plain
'
)
],
{
testOutputMetadata
:
true
})
{
testOutputMetadata
:
true
,
[
'
text/plain
'
]:
{
testOutputItemMetadata
:
true
}
})
],
executionSummary
:
{
executionOrder
:
5
,
success
:
true
},
metadata
:
new
vscode
.
NotebookCellMetadata
().
with
({
custom
:
{
testCellMetadata
:
456
}
})
...
...
@@ -183,7 +186,7 @@ suite('Notebook API tests', function () {
const
task
=
this
.
controller
.
createNotebookCellExecution
(
cell
);
task
.
start
();
await
task
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
my second output
'
,
'
text/plain
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
my second output
'
,
'
text/plain
'
)
])]);
task
.
end
({
success
:
true
});
}
...
...
@@ -474,12 +477,11 @@ suite('Notebook API tests', function () {
const
secondCell
=
vscode
.
window
.
activeNotebookEditor
!
.
document
.
cellAt
(
1
);
assert
.
strictEqual
(
secondCell
!
.
outputs
.
length
,
1
);
assert
.
deepStrictEqual
(
secondCell
!
.
outputs
[
0
].
metadata
,
{
testOutputMetadata
:
true
});
assert
.
deepStrictEqual
(
secondCell
!
.
outputs
[
0
].
metadata
,
{
testOutputMetadata
:
true
,
[
'
text/plain
'
]:
{
testOutputItemMetadata
:
true
}
});
assert
.
strictEqual
((
<
any
>
secondCell
!
.
outputs
[
0
]).
outputs
.
length
,
1
);
//todo@jrieken will FAIL once the backwards compatibility is gone
assert
.
strictEqual
(
secondCell
!
.
outputs
[
0
].
items
.
length
,
1
);
assert
.
strictEqual
(
secondCell
!
.
outputs
[
0
].
items
[
0
].
mime
,
'
text/plain
'
);
assert
.
strictEqual
(
new
TextDecoder
().
decode
(
secondCell
!
.
outputs
[
0
].
items
[
0
].
data
),
'
Hello World
'
);
assert
.
deepStrictEqual
(
secondCell
!
.
outputs
[
0
].
items
[
0
].
metadata
,
{
testOutputItemMetadata
:
true
});
assert
.
strictEqual
(
secondCell
!
.
executionSummary
?.
executionOrder
,
5
);
assert
.
strictEqual
(
secondCell
!
.
executionSummary
?.
success
,
true
);
...
...
@@ -777,7 +779,7 @@ suite('Notebook API tests', function () {
task
.
start
();
task
.
token
.
onCancellationRequested
(
async
()
=>
{
await
task
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
Canceled
'
,
'
text/plain
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
Canceled
'
,
'
text/plain
'
)
])]);
task
.
end
({});
});
...
...
@@ -822,7 +824,7 @@ suite('Notebook API tests', function () {
async
interrupt
()
{
await
this
.
_task
!
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
Interrupted
'
,
'
text/plain
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
Interrupted
'
,
'
text/plain
'
)
])]);
this
.
_task
!
.
end
({});
}
...
...
@@ -1182,7 +1184,7 @@ suite('Notebook API tests', function () {
const
task
=
this
.
controller
.
createNotebookCellExecution
(
cell
);
task
.
start
();
await
task
.
replaceOutput
([
new
vscode
.
NotebookCellOutput
([
vscode
.
NotebookCellOutputItem
.
text
(
'
Some output
'
,
'
text/plain
'
,
undefined
)
vscode
.
NotebookCellOutputItem
.
text
(
'
Some output
'
,
'
text/plain
'
)
])]);
assert
.
strictEqual
(
cell
.
notebook
.
cellAt
(
0
).
outputs
.
length
,
1
);
assert
.
deepStrictEqual
(
new
TextDecoder
().
decode
(
cell
.
notebook
.
cellAt
(
0
).
outputs
[
0
].
items
[
0
].
data
),
'
Some output
'
);
...
...
src/vs/vscode.d.ts
浏览文件 @
b1457fa4
...
...
@@ -11578,10 +11578,9 @@ declare module 'vscode' {
*
* @param value A string.
* @param mime Optional MIME type, defaults to `text/plain`.
* @param metadata Optional metadata.
* @returns A new output item object.
*/
static
text
(
value
:
string
,
mime
?:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
;
static
text
(
value
:
string
,
mime
?:
string
):
NotebookCellOutputItem
;
/**
* Factory function to create a `NotebookCellOutputItem` from
...
...
@@ -11593,40 +11592,36 @@ declare module 'vscode' {
*
* @param value A JSON-stringifyable value.
* @param mime Optional MIME type, defaults to `application/json`
* @param metadata Optional metadata.
* @returns A new output item object.
*/
static
json
(
value
:
any
,
mime
?:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
;
static
json
(
value
:
any
,
mime
?:
string
):
NotebookCellOutputItem
;
/**
* Factory function to create a `NotebookCellOutputItem` that uses
* uses the `application/vnd.code.notebook.stdout` mime type.
*
* @param value A string.
* @param metadata Optional metadata.
* @returns A new output item object.
*/
static
stdout
(
value
:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
;
static
stdout
(
value
:
string
):
NotebookCellOutputItem
;
/**
* Factory function to create a `NotebookCellOutputItem` that uses
* uses the `application/vnd.code.notebook.stderr` mime type.
*
* @param value A string.
* @param metadata Optional metadata.
* @returns A new output item object.
*/
static
stderr
(
value
:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
;
static
stderr
(
value
:
string
):
NotebookCellOutputItem
;
/**
* Factory function to create a `NotebookCellOutputItem` that uses
* uses the `application/vnd.code.notebook.error` mime type.
*
* @param value An error object.
* @param metadata Optional metadata.
* @returns A new output item object.
*/
static
error
(
value
:
Error
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
;
static
error
(
value
:
Error
):
NotebookCellOutputItem
;
/**
* The mime type which determines how the {@link NotebookCellOutputItem.value `value`}-property
...
...
@@ -11642,17 +11637,13 @@ declare module 'vscode' {
*/
data
:
Uint8Array
;
//todo@API remove in favour of NotebookCellOutput#metadata
metadata
?:
{
[
key
:
string
]:
any
};
/**
* Create a new notbook cell output item.
*
* @param data The value of the output item.
* @param mime The mime type of the output item.
* @param metadata Optional metadata for this output item.
*/
constructor
(
data
:
Uint8Array
,
mime
:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
);
constructor
(
data
:
Uint8Array
,
mime
:
string
);
}
/**
...
...
@@ -11685,7 +11676,7 @@ declare module 'vscode' {
items
:
NotebookCellOutputItem
[];
/**
* Arbitrary metadata for this cell output. .
* Arbitrary metadata for this cell output.
Can be anything but must be JSON-stringifyable
.
*/
metadata
?:
{
[
key
:
string
]:
any
};
...
...
src/vs/workbench/api/common/extHostTypeConverters.ts
浏览文件 @
b1457fa4
...
...
@@ -1535,14 +1535,13 @@ export namespace NotebookCellData {
export
namespace
NotebookCellOutputItem
{
export
function
from
(
item
:
types
.
NotebookCellOutputItem
):
notebooks
.
IOutputItemDto
{
return
{
metadata
:
item
.
metadata
,
mime
:
item
.
mime
,
valueBytes
:
Array
.
from
(
item
.
data
),
//todo@jrieken this HACKY and SLOW... hoist VSBuffer instead
};
}
export
function
to
(
item
:
notebooks
.
IOutputItemDto
):
types
.
NotebookCellOutputItem
{
return
new
types
.
NotebookCellOutputItem
(
new
Uint8Array
(
item
.
valueBytes
),
item
.
mime
,
item
.
metadata
);
return
new
types
.
NotebookCellOutputItem
(
new
Uint8Array
(
item
.
valueBytes
),
item
.
mime
);
}
}
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
b1457fa4
...
...
@@ -3116,43 +3116,42 @@ export class NotebookCellOutputItem {
&&
(
<
vscode
.
NotebookCellOutputItem
>
obj
).
data
instanceof
Uint8Array
;
}
static
error
(
err
:
Error
|
{
name
:
string
,
message
?:
string
,
stack
?:
string
}
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
static
error
(
err
:
Error
|
{
name
:
string
,
message
?:
string
,
stack
?:
string
}):
NotebookCellOutputItem
{
const
obj
=
{
name
:
err
.
name
,
message
:
err
.
message
,
stack
:
err
.
stack
};
return
NotebookCellOutputItem
.
json
(
obj
,
'
application/vnd.code.notebook.error
'
,
metadata
);
return
NotebookCellOutputItem
.
json
(
obj
,
'
application/vnd.code.notebook.error
'
);
}
static
stdout
(
value
:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
return
NotebookCellOutputItem
.
text
(
value
,
'
application/vnd.code.notebook.stdout
'
,
metadata
);
static
stdout
(
value
:
string
):
NotebookCellOutputItem
{
return
NotebookCellOutputItem
.
text
(
value
,
'
application/vnd.code.notebook.stdout
'
);
}
static
stderr
(
value
:
string
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
return
NotebookCellOutputItem
.
text
(
value
,
'
application/vnd.code.notebook.stderr
'
,
metadata
);
static
stderr
(
value
:
string
):
NotebookCellOutputItem
{
return
NotebookCellOutputItem
.
text
(
value
,
'
application/vnd.code.notebook.stderr
'
);
}
static
bytes
(
value
:
Uint8Array
,
mime
:
string
=
'
application/octet-stream
'
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
return
new
NotebookCellOutputItem
(
value
,
mime
,
metadata
);
static
bytes
(
value
:
Uint8Array
,
mime
:
string
=
'
application/octet-stream
'
):
NotebookCellOutputItem
{
return
new
NotebookCellOutputItem
(
value
,
mime
);
}
static
#
encoder
=
new
TextEncoder
();
static
text
(
value
:
string
,
mime
:
string
=
'
text/plain
'
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
static
text
(
value
:
string
,
mime
:
string
=
'
text/plain
'
):
NotebookCellOutputItem
{
const
bytes
=
NotebookCellOutputItem
.
#
encoder
.
encode
(
String
(
value
));
return
new
NotebookCellOutputItem
(
bytes
,
mime
,
metadata
);
return
new
NotebookCellOutputItem
(
bytes
,
mime
);
}
static
json
(
value
:
any
,
mime
:
string
=
'
application/json
'
,
metadata
?:
{
[
key
:
string
]:
any
}
):
NotebookCellOutputItem
{
static
json
(
value
:
any
,
mime
:
string
=
'
application/json
'
):
NotebookCellOutputItem
{
const
rawStr
=
JSON
.
stringify
(
value
,
undefined
,
'
\t
'
);
return
NotebookCellOutputItem
.
text
(
rawStr
,
mime
,
metadata
);
return
NotebookCellOutputItem
.
text
(
rawStr
,
mime
);
}
constructor
(
public
data
:
Uint8Array
,
public
mime
:
string
,
public
metadata
?:
{
[
key
:
string
]:
any
}
)
{
const
mimeNormalized
=
normalizeMimeType
(
mime
,
true
);
if
(
!
mimeNormalized
)
{
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts
浏览文件 @
b1457fa4
...
...
@@ -1523,7 +1523,7 @@ var requirejs = (function() {
outputId
:
output
.
outputId
,
mimeType
:
content
.
mimeType
,
valueBytes
:
new
Uint8Array
(
outputDto
?.
valueBytes
??
[]),
metadata
:
output
Dto
?
.
metadata
,
metadata
:
output
.
metadata
,
metadata2
:
output
.
metadata
},
};
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
b1457fa4
...
...
@@ -174,7 +174,6 @@ export interface IOrderedMimeType {
export
interface
IOutputItemDto
{
readonly
mime
:
string
;
readonly
valueBytes
:
number
[];
readonly
metadata
?:
Record
<
string
,
unknown
>
;
}
export
interface
IOutputDto
{
...
...
src/vs/workbench/test/browser/api/extHostTypeConverter.test.ts
浏览文件 @
b1457fa4
...
...
@@ -96,7 +96,6 @@ suite('ExtHostTypeConverter', function () {
const
item2
=
NotebookCellOutputItem
.
to
(
dto
);
assert
.
strictEqual
(
item2
.
mime
,
item
.
mime
);
assert
.
strictEqual
(
item2
.
metadata
,
item
.
metadata
);
assert
.
deepStrictEqual
(
item2
.
data
,
item
.
data
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录