UNPKG

scriptable-testlab

Version:

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

74 lines 1.43 kB
import { AbsURLScheme } from "scriptable-abstract"; const DEFAULT_STATE = { schemes: /* @__PURE__ */ new Set(), lastOpenedURL: null }; class MockURLScheme extends AbsURLScheme { static get instance() { return super.instance; } constructor() { super(DEFAULT_STATE); } /** * @inheritdoc */ async open(urlScheme) { this.setState({ lastOpenedURL: urlScheme }); } /** * @inheritdoc */ async fromURLString(urlString) { return urlString; } /** * @inheritdoc */ async forActionExtension() { return this.state.lastOpenedURL ?? ""; } /** * @inheritdoc */ async forNotification() { return this.state.lastOpenedURL ?? ""; } /** * @additional * Register a URL scheme for testing */ registerScheme(scheme) { this.setState((state) => ({ schemes: /* @__PURE__ */ new Set([...state.schemes, scheme]) })); } /** * @additional * Check if a URL scheme is registered */ isRegistered(scheme) { return this.state.schemes.has(scheme); } /** * @additional * Get the last opened URL */ getLastOpenedURL() { return this.state.lastOpenedURL; } /** * @additional * Clear all registered schemes and last opened URL */ clear() { this.setState({ schemes: /* @__PURE__ */ new Set(), lastOpenedURL: null }); } } export { MockURLScheme }; //# sourceMappingURL=url-scheme.js.map