refactor(core): extract core modules (state, persistence, config, events)
Extract core system modules from monolithic index.js into modular architecture: - src/core/state.js: All extension state variables with controlled setters - src/core/persistence.js: Settings and chat data persistence functions - src/core/config.js: Extension metadata and default configuration - src/core/events.js: SillyTavern event system wrapper Updated index.js to import and use new core modules. Removed ~220 lines of state/persistence code from index.js. Part of Epic 1: Foundation & Core Systems (Phase 1.1-1.2)
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Core Configuration Module
|
||||
* Extension metadata and configuration constants
|
||||
*/
|
||||
|
||||
export const extensionName = 'third-party/rpg-companion-sillytavern';
|
||||
|
||||
/**
|
||||
* Dynamically determine extension path based on current location
|
||||
* This supports both global (public/extensions) and user-specific (data/default-user/extensions) installations
|
||||
*/
|
||||
const currentScriptPath = import.meta.url;
|
||||
const isUserExtension = currentScriptPath.includes('/data/') || currentScriptPath.includes('\\data\\');
|
||||
export const extensionFolderPath = isUserExtension
|
||||
? `data/default-user/extensions/${extensionName}`
|
||||
: `scripts/extensions/${extensionName}`;
|
||||
|
||||
/**
|
||||
* Default extension settings
|
||||
*/
|
||||
export const defaultSettings = {
|
||||
enabled: true,
|
||||
autoUpdate: true,
|
||||
updateDepth: 4, // How many messages to include in the context
|
||||
generationMode: 'together', // 'separate' or 'together' - whether to generate with main response or separately
|
||||
showUserStats: true,
|
||||
showInfoBox: true,
|
||||
showCharacterThoughts: true,
|
||||
showThoughtsInChat: true, // Show thoughts overlay in chat
|
||||
enableHtmlPrompt: false, // Enable immersive HTML prompt injection
|
||||
enablePlotButtons: true, // Show plot progression buttons above chat input
|
||||
panelPosition: 'right', // 'left', 'right', or 'top'
|
||||
theme: 'default', // Theme: default, sci-fi, fantasy, cyberpunk, custom
|
||||
customColors: {
|
||||
bg: '#1a1a2e',
|
||||
accent: '#16213e',
|
||||
text: '#eaeaea',
|
||||
highlight: '#e94560'
|
||||
},
|
||||
statBarColorLow: '#cc3333', // Color for low stat values (red)
|
||||
statBarColorHigh: '#33cc66', // Color for high stat values (green)
|
||||
enableAnimations: true, // Enable smooth animations for stats and content updates
|
||||
mobileFabPosition: {
|
||||
top: 'calc(var(--topBarBlockSize) + 60px)',
|
||||
right: '12px'
|
||||
}, // Saved position for mobile FAB button
|
||||
userStats: {
|
||||
health: 100,
|
||||
satiety: 100,
|
||||
energy: 100,
|
||||
hygiene: 100,
|
||||
arousal: 0,
|
||||
mood: '😐',
|
||||
conditions: 'None',
|
||||
inventory: 'None'
|
||||
},
|
||||
classicStats: {
|
||||
str: 10,
|
||||
dex: 10,
|
||||
con: 10,
|
||||
int: 10,
|
||||
wis: 10,
|
||||
cha: 10
|
||||
},
|
||||
lastDiceRoll: null // Store last dice roll result
|
||||
};
|
||||
Reference in New Issue
Block a user