* fix: ensure the typescript definitions only export correct value types In typescript there are two main types of "types" you can export, value types (class, const) and definition types (type, interface). The typescript compiler will let anything declared via const or class be used as a value. Unfortunately we were exporting a bunch of things (see the diff) as class/const when they weren't actually exported values. This lead to typescript being happy but the runtime throwing errors (not something we want). This change passes "exported-in" context through our docs, to the parser and then to the definitions generator to ensure we only mark things as exported in the ts defs that we actually export. Fixes #22167 * chore: update typescript-defs * chore: update typescript-defs * chore: fix bad typescript in IPC test * docs: test rendering of new syntax * chore: update per feedback, use same syntax but with 'this is not exportedd' line
1.7 KiB
MessagePortMain
MessagePortMain
is the main-process-side equivalent of the DOM
MessagePort
object. It behaves similarly to the DOM version, with the
exception that it uses the Node.js EventEmitter
event system, instead of the
DOM EventTarget
system. This means you should use port.on('message', ...)
to listen for events, instead of port.onmessage = ...
or
port.addEventListener('message', ...)
See the Channel Messaging API documentation for more information on using channel messaging.
MessagePortMain
is an [EventEmitter][event-emitter].
Class: MessagePortMain
Port interface for channel messaging in the main process.
Process: Main
This class is not exported from the 'electron'
module. It is only available as a return value of other methods in the Electron API.
Instance Methods
port.postMessage(message, [transfer])
message
anytransfer
MessagePortMain[] (optional)
Sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
port.start()
Starts the sending of messages queued on the port. Messages will be queued until this method is called.
port.close()
Disconnects the port, so it is no longer active.
Instance Events
Event: 'message'
Returns:
messageEvent
Objectdata
anyports
MessagePortMain[]
Emitted when a MessagePortMain object receives a message.
Event: 'close'
Emitted when the remote end of a MessagePortMain object becomes disconnected.