-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (32 loc) · 1.07 KB
/
index.js
File metadata and controls
40 lines (32 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { initDom } from "./src/dom.js";
import { initUI } from "./src/ui.js";
import { MODULE_NAME, defaultSettings } from "./settings.js";
// Import outbound so comfyInjectInterceptor gets registered on globalThis
import "./src/outbound.js";
/**
* Initializes ComfyInject settings.
* Merges defaults with any existing saved settings so new
* keys are always present after an update.
*/
function initSettings() {
const { extensionSettings, saveSettingsDebounced } = SillyTavern.getContext();
if (!extensionSettings[MODULE_NAME]) {
extensionSettings[MODULE_NAME] = {};
}
// Merge defaults into existing settings so new keys are always present
const saved = extensionSettings[MODULE_NAME];
for (const key of Object.keys(defaultSettings)) {
if (!(key in saved)) {
saved[key] = structuredClone(defaultSettings[key]);
}
}
saveSettingsDebounced();
}
// Entry point
(async () => {
console.log("[ComfyInject] Loading...");
initSettings();
await initUI();
initDom();
console.log("[ComfyInject] Ready!");
})();