// Create our TAC namespace var TAC = TAC || {}; /** * @typedef {Object} TAC.CFG * @property {string} tagFile - Tag filename * @property {{ global: boolean, txt2img: boolean, img2img: boolean, negativePrompts: boolean, thirdParty: boolean, modelList: string, modelListMode: "Blacklist"|"Whitelist" }} activeIn - Settings for which parts of the UI the tag completion is active in. * @property {boolean} slidingPopup - Move completion popup together with text cursor * @property {number} maxResults - Maximum results * @property {boolean} showAllResults - Show all results * @property {number} resultStepLength - How many results to load at once * @property {number} delayTime - Time in ms to wait before triggering completion again * @property {boolean} useWildcards - Search for wildcards * @property {boolean} sortWildcardResults - Sort wildcard file contents alphabetically * @property {boolean} useEmbeddings - Search for embeddings * @property {boolean} includeEmbeddingsInNormalResults - Include embeddings in normal tag results * @property {boolean} useHypernetworks - Search for hypernetworks * @property {boolean} useLoras - Search for Loras * @property {boolean} useLycos - Search for LyCORIS/LoHa * @property {boolean} useLoraPrefixForLycos - Use the '_,<|>_<|>,=_=,>_<,3_3,6_9,>_o,@_@,^_^,o_o,u_u,x_x,|_|,||_||", escapeParentheses: true, appendComma: true, appendSpace: true, alwaysSpaceAtEnd: true, wildcardCompletionMode: "To next folder level", modelKeywordCompletion: "Never", modelKeywordLocation: "Start of prompt", wcWrap: "__", // to support custom wrapper chars set by dp_parser // Alias settings alias: { searchByAlias: true, onlyShowAlias: false, }, // Translation settings translation: { translationFile: "None", oldFormat: false, searchByTranslation: true, liveTranslation: false, }, // Extra file settings extra: { extraFile: "extra-quality-tags.csv", addMode: "Insert before", }, // Chant file settings chantFile: "demo-chants.json", // Settings not from tac but still used by the script extraNetworksDefaultMultiplier: 1.0, extraNetworksSeparator: ", ", // Custom mapping settings keymap: { MoveUp: "ArrowUp", MoveDown: "ArrowDown", JumpUp: "PageUp", JumpDown: "PageDown", JumpToStart: "Home", JumpToEnd: "End", ChooseSelected: "Enter", ChooseFirstOrSelected: "Tab", Close: "Escape", }, colorMap: { filename: { category: ["light", "dark"] }, }, }; TAC.Globals = new (function () { // Core components this.tagBasePath = ""; this.modelKeywordPath = ""; this.selfTrigger = false; // Tag completion data loaded from files this.allTags = []; this.translations = new Map(); this.extras = []; // Same for tag-likes this.wildcardFiles = []; this.wildcardExtFiles = []; this.yamlWildcards = []; this.umiWildcards = []; this.embeddings = []; this.hypernetworks = []; this.loras = []; this.lycos = []; this.modelKeywordDict = new Map(); this.chants = []; this.styleNames = []; // Selected model info for black/whitelisting this.currentModelHash = ""; this.currentModelName = ""; // Current results this.results = []; this.resultCount = 0; // Relevant for parsing this.previousTags = []; this.tagword = ""; this.originalTagword = ""; this.hideBlocked = false; // Tag selection for keyboard navigation this.selectedTag = null; this.oldSelectedTag = null; this.resultCountBeforeNormalTags = 0; // Lora keyword undo/redo history this.textBeforeKeywordInsertion = ""; this.textAfterKeywordInsertion = ""; this.lastEditWasKeywordInsertion = false; this.keywordInsertionUndone = false; // UMI this.umiPreviousTags = []; })(); /// Extendability system: /// Provides "queues" for other files of the script (or really any js) /// to add functions to be called at certain points in the script. /// Similar to a callback system, but primitive. TAC.Ext = new (function () { // Queues this.QUEUE_AFTER_INSERT = []; this.QUEUE_AFTER_SETUP = []; this.QUEUE_FILE_LOAD = []; this.QUEUE_AFTER_CONFIG_CHANGE = []; this.QUEUE_SANITIZE = []; // List of parsers to try this.PARSERS = []; })();