diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 4d435b3a6b24058c6b2da876682b3094c5339cbd..0742b47d2cdadc22b45a621a65d60ac687bb3971 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -157,6 +157,73 @@ declare enum CacheMode { Only, } +/** + * Define html5 web message port. + * @since 9 + */ +declare class WebMessagePort { + /** + * Constructor. + * @since 9 + */ + constructor(); + + /** + * Close port. + * @since 9 + */ + close(): void; + + /** + * Post a message to other port. + * @since 9 + */ + postMessageEvent(message: WebMessageEvent): void; + + /** + * Receive message from other port. + * @since 9 + */ + onMessageEvent(callback: (result: string) => void): void; +} + + +/** + * Define html5 web message, which include message and ports. + * @since 9 + */ +declare class WebMessageEvent { + /** + * Constructor. + * @since 9 + */ + constructor(); + + /** + * Get message. + * @since 9 + */ + getData(): string; + + /** + * Set message. + * @since 9 + */ + setData(data: string): void; + + /** + * Get ports. + * @since 9 + */ + getPorts(): Array; + + /** + * Set ports. + * @since 9 + */ + setPorts(ports: Array): void; +} + /** * Enum type supplied to {@link renderExitReason} when onRenderExited being called. * @since 9 @@ -968,6 +1035,21 @@ declare class WebCookie { */ runJavaScript(options: { script: string, callback?: (result: string) => void }); + /** + * Create web message ports + * + * @since 9 + */ + createWebMessagePorts(): Array; + + /** + * Post web message port to html5 + * @param options The options with a message event and a uri. + * + * @since 9 + */ + postMessage(options: { message: WebMessageEvent, uri: string}): void; + /** * Loads the data or URL. * @param options The options with the data or URL and other information.