From 2ef3e6135a09aceae6540f36e100cc7c019e90eb Mon Sep 17 00:00:00 2001 From: yuhaoge Date: Fri, 30 Dec 2022 14:18:14 +0800 Subject: [PATCH] add new web sdk Signed-off-by: yuhaoge --- api/@internal/component/ets/web.d.ts | 40 +++++++++++++++++++++ api/@ohos.web.webview.d.ts | 52 ++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index 27d6f5157d..9efc51b6ba 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -159,6 +159,30 @@ declare enum CacheMode { Only, } +/** + * Enum type supplied to {@link darkMode} for setting the web dark mode. + * @since 9 + */ +declare enum WebDarkMode { + /** + * Disable the web dark mode. + * @since 9 + */ + Off, + + /** + * Enable the web dark mode. + * @since 9 + */ + On, + + /** + * Make web dark mode follow the system. + * @since 9 + */ + Auto, +} + /** * Define the handler to exit the full screen mode, related to the {@link onFullScreenEnter} event. * @since 9 @@ -1737,6 +1761,22 @@ declare class WebAttribute extends CommonMethod { */ cacheMode(cacheMode: CacheMode): WebAttribute; + /** + * Sets the dark mode of Web. + * @param mode The dark mode, which can be {@link WebDarkMode}. + * + * @since 9 + */ + darkMode(mode: WebDarkMode): WebAttribute; + + /** + * Sets whether to enable forced dark algorithm when the web is in dark mode + * @param access {@code true} means enable the force dark algorithm; {@code false} otherwise. + * + * @since 9 + */ + forceDarkAccess(access: boolean): WebAttribute; + /** * Sets whether the Web should save the table data. * @param tableData {@code true} means the Web can save the table data; {@code false} otherwise. diff --git a/api/@ohos.web.webview.d.ts b/api/@ohos.web.webview.d.ts index ef8ec55156..9cb06d6e31 100644 --- a/api/@ohos.web.webview.d.ts +++ b/api/@ohos.web.webview.d.ts @@ -16,6 +16,7 @@ /// import {AsyncCallback} from "./basic"; +import {Callback} from "./basic"; import {Resource} from 'GlobalResource'; import image from "./@ohos.multimedia.image"; @@ -119,6 +120,34 @@ declare namespace webview { extra: string; } + /** + * Defines the configuration of web custom scheme, related to {@link customizeSchemes} method. + * @since 9 + */ + interface WebCustomScheme { + + /** + * Name of the custom scheme. + * + * @since 9 + */ + schemeName: string; + + /** + * Whether Cross-Origin Resource Sharing is supported. + * + * @since 9 + */ + isSupportCORS: boolean; + + /** + * Whether fetch request is supported. + * + * @since 9 + */ + isSupportFetch: boolean; + } + /** * Provides basic information of web storage. * @name WebStorageOrigin @@ -131,6 +160,18 @@ declare namespace webview { quota: number; } + /** + * Subscribe to a callback of a specified type of web event once. + * + * @param type Types of web event. + * @param callback Indicate callback used to receive the web event. + * + * @throws { BusinessError } 401 - Invalid input parameter. + * + * @since 9 + */ + function once(type: string, callback: Callback): void; + /** * Provides methods for managing web storage. * @name WebStorage @@ -1144,6 +1185,17 @@ declare namespace webview { * @since 9 */ restoreWebState(state: Uint8Array) : void; + + /** + * Set whether the Web custom scheme supports cross domain and fetch requests. + * + * @param { Array } schemes - Configuration of web custom scheme. + * + * @throws { BusinessError } 401 - Invalid input parameter. + * + * @since 9 + */ + static customizeSchemes(schemes: Array): void; } } -- Gitee