UNPKG

scriptable-testlab

Version:

A lightweight, efficient tool designed to manage and update scripts for Scriptable.

94 lines 2.79 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var webview_exports = {}; __export(webview_exports, { MockWebView: () => MockWebView }); module.exports = __toCommonJS(webview_exports); var import_scriptable_abstract = require("scriptable-abstract"); const DEFAULT_STATE = { shouldAllowRequest: () => true }; class MockWebView extends import_scriptable_abstract.AbsWebView { constructor() { super(DEFAULT_STATE); } /** * Loads HTML and renders it. */ static async loadHTML(html, baseURL, _preferredSize, fullscreen) { const webView = new MockWebView(); await webView.loadHTML(html, baseURL); await webView.present(fullscreen); } /** * Loads a file and renders it. */ static async loadFile(fileURL, _preferredSize, fullscreen) { const webView = new MockWebView(); await webView.loadFile(fileURL); await webView.present(fullscreen); } /** * Loads URL in web view and presents the web view. */ static async loadURL(url, _preferredSize, fullscreen) { const webView = new MockWebView(); await webView.loadURL(url); await webView.present(fullscreen); } get shouldAllowRequest() { return this.state.shouldAllowRequest; } set shouldAllowRequest(value) { this.setState({ shouldAllowRequest: value }); } async loadURL(url) { this.setState({ url }); } async loadHTML(html, baseURL) { this.setState({ html, baseURL }); } async loadRequest(request) { if (this.state.shouldAllowRequest(request)) { this.setState({ url: request.url }); } } async loadFile(path) { this.setState({ url: `file://${path}` }); } async evaluateJavaScript(_javaScript, _useCallback) { return null; } async getHTML() { return this.state.html ?? ""; } async getURL() { return this.state.url ?? ""; } present(_fullscreen) { return Promise.resolve(); } async waitForLoad() { } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MockWebView }); //# sourceMappingURL=webview.js.map