import { CanWebViewGoBack, CanWebViewGoForward, HasNativeView, Convert2AbsFullPath } from "../interface";
import { webview } from '@kit.ArkWeb';

export const canWebViewGoBack : CanWebViewGoBack = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getHarmonyController() as webview.WebviewController | null;
  return view == null ? false : view.accessBackward();
}

export const canWebViewGoForward : CanWebViewGoForward = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getHarmonyController() as webview.WebviewController | null;
  return view == null ? false : view.accessForward();
}

export const hasNativeView : HasNativeView = function (elementId : string) : boolean {
  const view = uni.getElementById(elementId)?.getHarmonyController() as webview.WebviewController | null;
  return view != null;
}

export const convert2AbsFullPath: Convert2AbsFullPath = function (path: string): string {
  return UTSHarmony.convert2AbsFullPath(path)
}
