| 813 | }; | 813 | }; |
| 814 | } | 814 | } |
| 815 | | 815 | |
| | 816 | /** |
| | 817 | * Updates the world info settings. |
| | 818 | * @param {WorldInfoSettings} settings - Settings object |
| | 819 | * @param {string[]} [activeWorldInfo] - Optional array of active world info names |
| | 820 | */ |
| | 821 | export function updateWorldInfoSettings(settings, activeWorldInfo) { |
| | 822 | console.debug('[WI] Updating world info settings', settings, activeWorldInfo); |
| | 823 | |
| | 824 | /** @type {Record<keyof WorldInfoSettings, (value: any) => void>} */ |
| | 825 | const fields = { |
| | 826 | world_info_depth: (value) => world_info_depth = Number(value), |
| | 827 | world_info_min_activations: (value) => world_info_min_activations = Number(value), |
| | 828 | world_info_min_activations_depth_max: (value) => world_info_min_activations_depth_max = Number(value), |
| | 829 | world_info_budget: (value) => world_info_budget = Number(value), |
| | 830 | world_info_include_names: (value) => world_info_include_names = Boolean(value), |
| | 831 | world_info_recursive: (value) => world_info_recursive = Boolean(value), |
| | 832 | world_info_overflow_alert: (value) => world_info_overflow_alert = Boolean(value), |
| | 833 | world_info_case_sensitive: (value) => world_info_case_sensitive = Boolean(value), |
| | 834 | world_info_match_whole_words: (value) => world_info_match_whole_words = Boolean(value), |
| | 835 | world_info_character_strategy: (value) => world_info_character_strategy = Number(value), |
| | 836 | world_info_budget_cap: (value) => world_info_budget_cap = Number(value), |
| | 837 | world_info_use_group_scoring: (value) => world_info_use_group_scoring = Boolean(value), |
| | 838 | world_info_max_recursion_steps: (value) => world_info_max_recursion_steps = Number(value), |
| | 839 | // Unused |
| | 840 | world_info: (_value) => {}, |
| | 841 | }; |
| | 842 | |
| | 843 | for (const [key, setter] of Object.entries(fields)) { |
| | 844 | if (Object.hasOwn(settings, key)) { |
| | 845 | setter(settings[key]); |
| | 846 | } |
| | 847 | } |
| | 848 | |
| | 849 | if (Array.isArray(activeWorldInfo)) { |
| | 850 | delete settings.world_info; |
| | 851 | selected_world_info = activeWorldInfo; |
| | 852 | } |
| | 853 | |
| | 854 | saveSettingsDebounced(); |
| | 855 | } |
| | 856 | |
| 816 | export const world_info_position = { | 857 | export const world_info_position = { |
| 817 | before: 0, | 858 | before: 0, |
| 818 | after: 1, | 859 | after: 1, |