@nota/nativescript-webview-ext
Version:
Extended WebView for NativeScript which adds 'x-local' scheme for local-files. events between WebView and native-layer, javascript execution, injecting CSS and JS-files.
93 lines (92 loc) • 5.4 kB
TypeScript
/// <reference path="types/ios/NotaWebViewExt.d.ts" />
import "@nativescript/core";
import { WebViewExtBase } from "./webview-ext-common";
export * from "./webview-ext-common";
export declare class WebViewExt extends WebViewExtBase {
ios: WKWebView;
static supportXLocalScheme: boolean;
protected wkWebViewConfiguration: WKWebViewConfiguration;
protected wkNavigationDelegate: WKNavigationDelegateNotaImpl;
protected wkUIDelegate: WKUIDelegateNotaImpl;
protected wkCustomUrlSchemeHandler: CustomUrlSchemeHandler | void;
protected wkUserContentController: WKUserContentController;
protected wkUserScriptInjectWebViewBridge?: WKUserScript;
protected wkUserScriptViewPortCode: Promise<WKUserScript | null> | null;
protected wkNamedUserScripts: {
resourceName: string;
wkUserScript: WKUserScript;
}[];
readonly supportXLocalScheme: boolean;
viewPortSize: {
initialScale: number;
};
private limitsNavigationsToAppBoundDomains;
createNativeView(): WKWebView;
initNativeView(): void;
disposeNativeView(): void;
protected injectWebViewBridge(): Promise<void>;
protected injectViewPortMeta(): Promise<void>;
executeJavaScript<T>(scriptCode: string, stringifyResult?: boolean): Promise<T>;
onLoaded(): void;
onUnloaded(): void;
stopLoading(): void;
_loadUrl(src: string): void;
_loadData(content: string): void;
get canGoBack(): boolean;
get canGoForward(): boolean;
goBack(): void;
goForward(): void;
reload(): void;
_webAlert(message: string, callback: () => void): boolean;
_webConfirm(message: string, callback: (response: boolean | null) => void): boolean;
_webPrompt(message: string, defaultText: string, callback: (response: string | null) => void): boolean;
registerLocalResource(resourceName: string, path: string): void;
unregisterLocalResource(resourceName: string): void;
getRegisteredLocalResource(resourceName: string): string | undefined;
getTitle(): Promise<string>;
autoLoadStyleSheetFile(resourceName: string, path: string, insertBefore?: boolean): Promise<void>;
removeAutoLoadStyleSheetFile(resourceName: string): void;
autoLoadJavaScriptFile(resourceName: string, path: string): Promise<void>;
removeAutoLoadJavaScriptFile(resourceName: string): void;
protected loadWKUserScripts(autoInjectJSBridge?: boolean): void;
protected removeNamedWKUserScript(resourceName: string): void;
protected resetViewPortCode(): Promise<void>;
protected registerLocalResourceForNative(resourceName: string, filepath: string): void;
protected unregisterLocalResourceForNative(resourceName: string): void;
protected getRegisteredLocalResourceFromNative(resourceName: string): string | undefined;
protected makeWKUserScriptPromise(scriptCodePromise: Promise<string | null>): Promise<WKUserScript | null>;
protected addUserScriptFromPromise(userScriptPromise: Promise<WKUserScript | null>): Promise<void>;
protected addUserScript(userScript: WKUserScript | null): void;
protected addNamedWKUserScript(resourceName: string, scriptCode: string): void;
protected createWkUserScript(source: string): WKUserScript;
}
export declare class WKNavigationDelegateNotaImpl extends NSObject implements WKNavigationDelegate {
static ObjCProtocols: {
prototype: WKNavigationDelegate;
}[];
static initWithOwner(owner: WeakRef<WebViewExt>): WKNavigationDelegateNotaImpl;
private owner;
webViewDecidePolicyForNavigationActionDecisionHandler(webView: WKWebView, navigationAction: WKNavigationAction, decisionHandler: (policy: WKNavigationActionPolicy) => void): void;
webViewDidStartProvisionalNavigation(webView: WKWebView, navigation: WKNavigation): void;
webViewDidFinishNavigation(webView: WKWebView, navigation: WKNavigation): void;
webViewDidFailNavigationWithError(webView: WKWebView, navigation: WKNavigation, error: NSError): void;
webViewDidFailProvisionalNavigationWithError(webView: WKWebView, navigation: WKNavigation, error: NSError): void;
}
export declare class WKScriptMessageHandlerNotaImpl extends NSObject implements WKScriptMessageHandler {
static ObjCProtocols: {
prototype: WKScriptMessageHandler;
}[];
private owner;
static initWithOwner(owner: WeakRef<WebViewExtBase>): WKScriptMessageHandlerNotaImpl;
userContentControllerDidReceiveScriptMessage(userContentController: WKUserContentController, webViewMessage: WKScriptMessage): void;
}
export declare class WKUIDelegateNotaImpl extends NSObject implements WKUIDelegate {
static ObjCProtocols: {
prototype: WKUIDelegate;
}[];
owner: WeakRef<WebViewExt>;
static initWithOwner(owner: WeakRef<WebViewExt>): WKUIDelegateNotaImpl;
webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler(webView: WKWebView, message: string, frame: WKFrameInfo, completionHandler: () => void): void;
webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler(webView: WKWebView, message: string, frame: WKFrameInfo, completionHandler: (confirmed: boolean) => void): void;
webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler(webView: WKWebView, message: string, defaultText: string, frame: WKFrameInfo, completionHandler: (response: string) => void): void;
}