Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
675e5da7
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,体验更适合开发者的 AI 搜索 >>
提交
675e5da7
编写于
1月 13, 2021
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared process - expose methods for message channel API
上级
936e7776
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
96 addition
and
19 deletion
+96
-19
src/vs/base/parts/sandbox/common/electronTypes.ts
src/vs/base/parts/sandbox/common/electronTypes.ts
+4
-4
src/vs/base/parts/sandbox/electron-browser/preload.js
src/vs/base/parts/sandbox/electron-browser/preload.js
+11
-0
src/vs/base/parts/sandbox/electron-sandbox/electronTypes.ts
src/vs/base/parts/sandbox/electron-sandbox/electronTypes.ts
+81
-15
未找到文件。
src/vs/base/parts/sandbox/common/electronTypes.ts
浏览文件 @
675e5da7
...
...
@@ -7,7 +7,7 @@
// #######################################################################
// ### ###
// ### electron.d.ts types we need in a common layer for reuse ###
// ### (copied from Electron
9.x)
###
// ### (copied from Electron
11.x)
###
// ### ###
// #######################################################################
...
...
@@ -212,7 +212,7 @@ export interface SaveDialogReturnValue {
export
interface
FileFilter
{
// Docs: http://electronjs.org/docs/api/structures/file-filter
// Docs: http
s
://electronjs.org/docs/api/structures/file-filter
extensions
:
string
[];
name
:
string
;
...
...
@@ -220,7 +220,7 @@ export interface FileFilter {
export
interface
InputEvent
{
// Docs: http://electronjs.org/docs/api/structures/input-event
// Docs: http
s
://electronjs.org/docs/api/structures/input-event
/**
* An array of modifiers of the event, can be `shift`, `control`, `ctrl`, `alt`,
...
...
@@ -232,7 +232,7 @@ export interface InputEvent {
export
interface
MouseInputEvent
extends
InputEvent
{
// Docs: http://electronjs.org/docs/api/structures/mouse-input-event
// Docs: http
s
://electronjs.org/docs/api/structures/mouse-input-event
/**
* The button pressed, can be `left`, `middle`, `right`.
...
...
src/vs/base/parts/sandbox/electron-browser/preload.js
浏览文件 @
675e5da7
...
...
@@ -35,6 +35,17 @@
}
},
/**
* @param {string} channel
* @param {any} message
* @param {MessagePort[]} transfer
*/
postMessage
(
channel
,
message
,
transfer
)
{
if
(
validateIPC
(
channel
))
{
ipcRenderer
.
postMessage
(
channel
,
message
,
transfer
);
}
},
/**
* @param {string} channel
* @param {any[]} args
...
...
src/vs/base/parts/sandbox/electron-sandbox/electronTypes.ts
浏览文件 @
675e5da7
...
...
@@ -7,35 +7,54 @@
// #######################################################################
// ### ###
// ### electron.d.ts types we expose from electron-sandbox ###
// ### (copied from Electron
9.x)
###
// ### (copied from Electron
11.x)
###
// ### ###
// #######################################################################
export
interface
IpcRendererEvent
extends
Event
{
// Docs: https://electronjs.org/docs/api/structures/ipc-renderer-event
/**
* A list of MessagePorts that were transferred with this message
*/
ports
:
MessagePort
[];
/**
* The `IpcRenderer` instance that emitted the event originally
*/
sender
:
IpcRenderer
;
/**
* The `webContents.id` that sent the message, you can call
* `event.sender.sendTo(event.senderId, ...)` to reply to the message, see
* ipcRenderer.sendTo for more information. This only applies to messages sent from
* a different renderer. Messages sent directly from the main process set
* `event.senderId` to `0`.
*/
senderId
:
number
;
}
export
interface
IpcRenderer
{
/**
* Listens to `channel`, when a new message arrives `listener` would be called with
* `listener(event, args...)`.
*/
on
(
channel
:
string
,
listener
:
(
event
:
unknown
,
...
args
:
any
[])
=>
void
):
void
;
on
(
channel
:
string
,
listener
:
(
event
:
IpcRendererEvent
,
...
args
:
any
[])
=>
void
):
this
;
/**
* Adds a one time `listener` function for the event. This `listener` is invoked
* only the next time a message is sent to `channel`, after which it is removed.
*/
once
(
channel
:
string
,
listener
:
(
event
:
unknown
,
...
args
:
any
[])
=>
void
):
void
;
once
(
channel
:
string
,
listener
:
(
event
:
IpcRendererEvent
,
...
args
:
any
[])
=>
void
):
this
;
/**
* Removes the specified `listener` from the listener array for the specified
* `channel`.
*/
removeListener
(
channel
:
string
,
listener
:
(
event
:
unknown
,
...
args
:
any
[])
=>
void
):
void
;
removeListener
(
channel
:
string
,
listener
:
(...
args
:
any
[])
=>
void
):
this
;
/**
* Send an asynchronous message to the main process via `channel`, along with
* arguments. Arguments will be serialized with the Structured Clone Algorithm,
* just like `postMessage`, so prototype chains will not be included. Sending
* Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception.
* just like `window.postMessage`, so prototype chains will not be included.
* Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an
* exception.
*
* > **NOTE**: Sending non-standard JavaScript types such as DOM objects or special
* Electron objects is deprecated, and will begin throwing an exception starting
...
...
@@ -43,8 +62,51 @@ export interface IpcRenderer {
*
* The main process handles it by listening for `channel` with the `ipcMain`
* module.
*
* If you need to transfer a `MessagePort` to the main process, use
* `ipcRenderer.postMessage`.
*
* If you want to receive a single response from the main process, like the result
* of a method call, consider using `ipcRenderer.invoke`.
*/
send
(
channel
:
string
,
...
args
:
any
[]):
void
;
/**
* Resolves with the response from the main process.
*
* Send a message to the main process via `channel` and expect a result
* asynchronously. Arguments will be serialized with the Structured Clone
* Algorithm, just like `window.postMessage`, so prototype chains will not be
* included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw
* an exception.
*
* > **NOTE**: Sending non-standard JavaScript types such as DOM objects or special
* Electron objects is deprecated, and will begin throwing an exception starting
* with Electron 9.
*
* The main process should listen for `channel` with `ipcMain.handle()`.
*
* For example:
*
* If you need to transfer a `MessagePort` to the main process, use
* `ipcRenderer.postMessage`.
*
* If you do not need a response to the message, consider using `ipcRenderer.send`.
*/
invoke
(
channel
:
string
,
...
args
:
any
[]):
Promise
<
any
>
;
/**
* Send a message to the main process, optionally transferring ownership of zero or
* more `MessagePort` objects.
*
* The transferred `MessagePort` objects will be available in the main process as
* `MessagePortMain` objects by accessing the `ports` property of the emitted
* event.
*
* For example:
*
* For more information on using `MessagePort` and `MessageChannel`, see the MDN
* documentation.
*/
postMessage
(
channel
:
string
,
message
:
any
,
transfer
?:
MessagePort
[]):
void
;
}
export
interface
WebFrame
{
...
...
@@ -70,16 +132,23 @@ export interface CrashReporter {
* with crashes that occur in other renderer processes or in the main process.
*
* **Note:** Parameters have limits on the length of the keys and values. Key names
* must be no longer than 39 bytes, and values must be no longer than
127
bytes.
* must be no longer than 39 bytes, and values must be no longer than
20320
bytes.
* Keys with names longer than the maximum will be silently ignored. Key values
* longer than the maximum length will be truncated.
*
* **Note:** On linux values that are longer than 127 bytes will be chunked into
* multiple keys, each 127 bytes in length. E.g. `addExtraParameter('foo',
* 'a'.repeat(130))` will result in two chunked keys `foo__1` and `foo__2`, the
* first will contain the first 127 bytes and the second will contain the remaining
* 3 bytes. On your crash reporting backend you should stitch together keys in
* this format.
*/
addExtraParameter
(
key
:
string
,
value
:
string
):
void
;
}
export
interface
ProcessMemoryInfo
{
// Docs: http://electronjs.org/docs/api/structures/process-memory-info
// Docs: http
s
://electronjs.org/docs/api/structures/process-memory-info
/**
* The amount of memory not shared by other processes, such as JS heap or HTML
...
...
@@ -133,10 +202,7 @@ export interface CrashReporterStartOptions {
rateLimit
?:
boolean
;
/**
* If true, crash reports will be compressed and uploaded with `Content-Encoding:
* gzip`. Not all collection servers support compressed payloads. Default is
* `false`.
*
* @platform darwin,win32
* gzip`. Default is `false`.
*/
compress
?:
boolean
;
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录