scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
97 lines • 2.49 kB
JavaScript
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 url_scheme_exports = {};
__export(url_scheme_exports, {
MockURLScheme: () => MockURLScheme
});
module.exports = __toCommonJS(url_scheme_exports);
var import_scriptable_abstract = require("scriptable-abstract");
const DEFAULT_STATE = {
schemes: /* @__PURE__ */ new Set(),
lastOpenedURL: null
};
class MockURLScheme extends import_scriptable_abstract.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
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MockURLScheme
});
//# sourceMappingURL=url-scheme.js.map