scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
155 lines • 3.83 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 pasteboard_exports = {};
__export(pasteboard_exports, {
MockPasteboard: () => MockPasteboard
});
module.exports = __toCommonJS(pasteboard_exports);
var import_scriptable_abstract = require("scriptable-abstract");
class MockPasteboard extends import_scriptable_abstract.AbsPasteboard {
/**
* @inheritdoc
* Inherited from ScriptableVariable, just adding type casting
*/
static get instance() {
return super.instance;
}
/**
* @implements Scriptable.Pasteboard.copy
* Copies text to the pasteboard
*/
copy(text) {
this.setText(text);
}
/**
* @implements Scriptable.Pasteboard.paste
* Gets text from the pasteboard
*/
paste() {
return this.getText();
}
/**
* @implements Scriptable.Pasteboard.copyString
* Copies string to the pasteboard
*/
copyString(text) {
this.setText(text);
}
/**
* @implements Scriptable.Pasteboard.pasteString
* Gets string from the pasteboard
*/
pasteString() {
return this.getText();
}
/**
* @implements Scriptable.Pasteboard.copyImage
* Copies image to the pasteboard
*/
copyImage(image) {
this.setItems([{ image }]);
}
/**
* @implements Scriptable.Pasteboard.pasteImage
* Gets image from the pasteboard
*/
pasteImage() {
const images = this.getImages();
if (images.length === 0) {
throw new Error("No image on pasteboard");
}
return images[0];
}
/**
* @additional
* Additional helper method for getting text
*/
getText() {
return this.state.text;
}
/**
* @additional
* Additional helper method for setting text
*/
setText(text) {
this.setState({
text,
items: [{ text }]
});
}
/**
* @additional
* Additional helper method for getting all items
*/
getItems() {
return [...this.state.items];
}
/**
* @additional
* Additional helper method for setting items
*/
setItems(items) {
this.setState({
text: items[0]?.text ?? this.state.text,
items: [...items]
});
}
/**
* @additional
* Additional helper method for checking URLs
*/
hasURLs() {
return this.state.items.some((item) => item.url !== void 0);
}
/**
* @additional
* Additional helper method for getting URLs
*/
getURLs() {
return this.state.items.map((item) => item.url).filter((url) => url !== void 0);
}
/**
* @additional
* Additional helper method for checking images
*/
hasImages() {
return this.state.items.some((item) => item.image !== void 0);
}
/**
* @additional
* Additional helper method for getting images
*/
getImages() {
return this.state.items.map((item) => item.image).filter((image) => image !== void 0);
}
/**
* @additional
* Additional helper method for clearing pasteboard
*/
clear() {
this.setState({
text: "",
items: []
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
MockPasteboard
});
//# sourceMappingURL=pasteboard.js.map