mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-01-20 21:41:32 +01:00
feat: create proper classes and export for extension use
This commit is contained in:
parent
770f3e5da3
commit
b96d1e79a0
@ -3,25 +3,42 @@ import { renderExtensionTemplateAsync } from './extensions.js';
|
|||||||
import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from './popup.js';
|
import { POPUP_RESULT, POPUP_TYPE, callGenericPopup } from './popup.js';
|
||||||
import { isValidUrl } from './utils.js';
|
import { isValidUrl } from './utils.js';
|
||||||
|
|
||||||
/**
|
export class Scraper {
|
||||||
* @typedef {Object} Scraper
|
constructor(id, name, description, iconClass, iconAvailable) {
|
||||||
* @property {string} id
|
this.id = id;
|
||||||
* @property {string} name
|
this.name = name;
|
||||||
* @property {string} description
|
this.description = description;
|
||||||
* @property {string} iconClass
|
this.iconClass = iconClass;
|
||||||
* @property {boolean} iconAvailable
|
this.iconAvailable = iconAvailable;
|
||||||
* @property {() => Promise<boolean>} isAvailable
|
}
|
||||||
* @property {() => Promise<File[]>} scrape
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} ScraperInfo
|
* Check if the scraper is available.
|
||||||
* @property {string} id
|
* @returns {Promise<boolean>}
|
||||||
* @property {string} name
|
*/
|
||||||
* @property {string} description
|
async isAvailable() {
|
||||||
* @property {string} iconClass
|
// Implement in subclass
|
||||||
* @property {boolean} iconAvailable
|
return false;
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a text file from a string.
|
||||||
|
* @returns {Promise<File[]>} File attachments scraped from the text
|
||||||
|
*/
|
||||||
|
async scrape() {
|
||||||
|
// Implement in subclass
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ScraperInfo {
|
||||||
|
constructor(id, name, description, iconClass) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
this.iconClass = iconClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class ScraperManager {
|
export class ScraperManager {
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user