scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
83 lines • 2.61 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
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 __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var safari_exports = {};
__export(safari_exports, {
MockSafari: () => MockSafari
});
module.exports = __toCommonJS(safari_exports);
var import_scriptable_abstract = require("scriptable-abstract");
const DEFAULT_STATE = {
currentURL: null,
inBackground: false,
openMethod: null,
fullscreen: false
};
const _MockSafari = class _MockSafari extends import_scriptable_abstract.AbsSafari {
static get instance() {
return super.instance;
}
constructor() {
super(DEFAULT_STATE);
}
/**
* Validates if the given URL is valid and has an acceptable scheme
*/
validateURL(url) {
try {
const parsedURL = new URL(url);
if (!_MockSafari.VALID_SCHEMES.includes(parsedURL.protocol)) {
throw new Error(`Invalid URL scheme: ${parsedURL.protocol}`);
}
} catch (error) {
throw new Error(`Invalid URL: ${error.message}`);
}
}
/**
* @inheritdoc
*/
open(url) {
this.validateURL(url);
this.setState({
currentURL: url,
inBackground: false,
openMethod: "browser",
fullscreen: false
});
}
/**
* @inheritdoc
*/
async openInApp(url, fullscreen = false) {
this.validateURL(url);
this.setState({
currentURL: url,
inBackground: false,
openMethod: "app",
fullscreen
});
}
};
__publicField(_MockSafari, "VALID_SCHEMES", ["http:", "https:"]);
let MockSafari = _MockSafari;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MockSafari
});
//# sourceMappingURL=safari.js.map