@fylib/config 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './manager';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './manager';
@@ -0,0 +1,13 @@
1
+ import { AppConfig, ThemeConfig, LoggingConfig } from './types';
2
+ export declare class ConfigManager {
3
+ private currentConfig;
4
+ private listeners;
5
+ constructor();
6
+ getConfig(): AppConfig;
7
+ updateConfig(newConfig: Partial<AppConfig>): void;
8
+ updateThemeConfig(themeConfig: Partial<ThemeConfig>): void;
9
+ updateLoggingConfig(loggingConfig: Partial<LoggingConfig>): void;
10
+ subscribe(listener: (config: AppConfig) => void): () => void;
11
+ private notifyListeners;
12
+ }
13
+ export declare const configManager: ConfigManager;
@@ -0,0 +1,59 @@
1
+ import { defaultConfig } from './types';
2
+ import { logger } from '@fylib/logger';
3
+ export class ConfigManager {
4
+ constructor() {
5
+ this.currentConfig = { ...defaultConfig };
6
+ this.listeners = [];
7
+ // Sincroniza configuração de log inicial
8
+ if (this.currentConfig.logging) {
9
+ logger.setConfig(this.currentConfig.logging);
10
+ }
11
+ // Expõe o manager globalmente para plugins de outros pacotes (ex: ThemeEngine)
12
+ globalThis.configManager = this;
13
+ }
14
+ getConfig() {
15
+ return this.currentConfig;
16
+ }
17
+ updateConfig(newConfig) {
18
+ // Verifica se houve mudança real para evitar logs repetitivos
19
+ const themeChanged = newConfig.theme && JSON.stringify(newConfig.theme) !== JSON.stringify(this.currentConfig.theme);
20
+ const loggingChanged = newConfig.logging && JSON.stringify(newConfig.logging) !== JSON.stringify(this.currentConfig.logging);
21
+ // Merge profundo para preservar sub-objetos como theme, sse, etc.
22
+ this.currentConfig = {
23
+ ...this.currentConfig,
24
+ ...newConfig,
25
+ theme: newConfig.theme ? { ...this.currentConfig.theme, ...newConfig.theme } : this.currentConfig.theme,
26
+ logging: newConfig.logging ? { ...this.currentConfig.logging, ...newConfig.logging } : this.currentConfig.logging
27
+ };
28
+ // Sincroniza configuração de log se presente e mudou
29
+ if (this.currentConfig.logging && loggingChanged) {
30
+ logger.setConfig(this.currentConfig.logging);
31
+ }
32
+ if (themeChanged || loggingChanged) {
33
+ logger.info('Config', 'Configuration updated', {
34
+ theme: this.currentConfig.theme?.theme,
35
+ animations: this.currentConfig.theme?.animationsEnabled
36
+ });
37
+ }
38
+ this.notifyListeners();
39
+ }
40
+ updateThemeConfig(themeConfig) {
41
+ this.updateConfig({ theme: themeConfig });
42
+ }
43
+ updateLoggingConfig(loggingConfig) {
44
+ this.updateConfig({ logging: loggingConfig });
45
+ }
46
+ subscribe(listener) {
47
+ this.listeners.push(listener);
48
+ logger.debug('Config', 'New listener subscribed');
49
+ listener(this.currentConfig);
50
+ return () => {
51
+ this.listeners = this.listeners.filter(l => l !== listener);
52
+ logger.debug('Config', 'Listener unsubscribed');
53
+ };
54
+ }
55
+ notifyListeners() {
56
+ this.listeners.forEach(l => l(this.currentConfig));
57
+ }
58
+ }
59
+ export const configManager = new ConfigManager();
@@ -0,0 +1,108 @@
1
+ import { DesignTokens, SSEConfig } from '@fylib/core';
2
+ import { CryptoConfig } from '@fylib/crypto';
3
+ import { ButtonClickAnimationName, ButtonHoverAnimationName, ButtonStateAnimationName, InputFocusAnimationName, InputStateAnimationName, LayoutAnimationName, SidebarAnimationName, CardAnimationName, TableAnimationName, ChartAnimationName } from '@fylib/animation';
4
+ export type ThemeName = 'default' | 'finey-workbench-1' | 'finey-workbench-2' | 'finey-workbench-3' | 'windows-xp' | 'windows-7' | 'christmas' | 'finey-nexus-1' | 'finey-hub-1' | 'finey-puffy-1';
5
+ export type IconSet = 'ph' | 'fa' | 'mdi';
6
+ export type ComponentSelector = 'fy-button' | 'fy-input' | 'fy-select' | 'fy-layout' | 'fy-slot' | 'fy-slot:sidebar' | 'fy-slot:header' | 'fy-card' | 'fy-table' | 'fy-modal' | 'fy-accordion' | 'fy-chart' | 'fy-toast' | 'fy-notification-menu';
7
+ export type UIEventKey = 'fy-button.click' | 'fy-input.focus' | 'fy-select.focus' | 'fy-layout.enter' | 'fy-slot:sidebar.open' | 'fy-slot:sidebar.close' | 'fy-card.enter' | 'fy-card.submit' | 'fy-table.enter' | 'fy-table.rowClick' | 'fy-chart.enter' | 'fy-chart.dataClick' | 'fy-toast.open' | 'fy-notification-menu.open' | 'fy-notification-menu.clearAll';
8
+ export type EffectName = 'confetti' | 'hearts' | 'snow' | 'bubbles' | 'aurora' | 'matrix' | 'particles' | 'stars' | 'window-open' | 'sidebar-slide-in' | 'sidebar-slide-out' | 'window-macos-sheet-open' | 'window-macos-sheet-close';
9
+ export type WallpaperName = 'auto' | 'hearts' | 'geometric' | 'pine-trees' | 'cyber-grid' | 'dots' | 'grass' | 'aero-waves' | 'mesh-gradient';
10
+ export type DeepPartial<T> = {
11
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
12
+ };
13
+ export interface ButtonEventsMap {
14
+ hover?: ButtonHoverAnimationName;
15
+ click?: ButtonClickAnimationName;
16
+ success?: ButtonStateAnimationName;
17
+ error?: ButtonStateAnimationName;
18
+ }
19
+ export interface InputEventsMap {
20
+ focus?: InputFocusAnimationName;
21
+ success?: InputStateAnimationName;
22
+ error?: InputStateAnimationName;
23
+ }
24
+ export interface LayoutEventsMap {
25
+ enter?: LayoutAnimationName;
26
+ }
27
+ export interface SidebarEventsMap {
28
+ open?: SidebarAnimationName;
29
+ close?: SidebarAnimationName;
30
+ }
31
+ export interface CardEventsMap {
32
+ enter?: CardAnimationName;
33
+ }
34
+ export interface TableEventsMap {
35
+ enter?: TableAnimationName;
36
+ rowEnter?: TableAnimationName;
37
+ }
38
+ export interface SelectEventsMap {
39
+ focus?: InputFocusAnimationName;
40
+ success?: InputStateAnimationName;
41
+ error?: InputStateAnimationName;
42
+ }
43
+ export interface ChartEventsMap {
44
+ enter?: ChartAnimationName;
45
+ update?: ChartAnimationName;
46
+ }
47
+ export type ComponentAnimationsOverrides = {
48
+ 'fy-button'?: Partial<ButtonEventsMap>;
49
+ 'fy-input'?: Partial<InputEventsMap>;
50
+ 'fy-select'?: Partial<SelectEventsMap>;
51
+ 'fy-layout'?: Partial<LayoutEventsMap>;
52
+ 'fy-slot:sidebar'?: Partial<SidebarEventsMap>;
53
+ 'fy-slot:header'?: Partial<SidebarEventsMap>;
54
+ 'fy-card'?: Partial<CardEventsMap>;
55
+ 'fy-table'?: Partial<TableEventsMap>;
56
+ 'fy-chart'?: Partial<ChartEventsMap>;
57
+ } & {
58
+ [selector: string]: {
59
+ [event: string]: string | undefined;
60
+ } | undefined;
61
+ };
62
+ export interface HttpConfig {
63
+ baseUrl?: string;
64
+ timeout?: number;
65
+ retries?: number;
66
+ retryDelay?: number;
67
+ headers?: Record<string, string>;
68
+ cryptoEnabled?: boolean;
69
+ autoNotify?: boolean;
70
+ }
71
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
72
+ export interface LoggingConfig {
73
+ enabled: boolean;
74
+ level: LogLevel;
75
+ console?: {
76
+ enabled: boolean;
77
+ };
78
+ localFiles?: {
79
+ enabled: boolean;
80
+ path: string;
81
+ filenamePattern?: string;
82
+ };
83
+ remote?: {
84
+ enabled: boolean;
85
+ endpoint: string;
86
+ };
87
+ }
88
+ export interface ThemeConfig {
89
+ theme: ThemeName;
90
+ animationsEnabled: boolean;
91
+ themeEffectsEnabled?: boolean;
92
+ wallpaperEnabled?: boolean;
93
+ disableAnimationsForComponents?: ComponentSelector[];
94
+ tokenOverrides?: DeepPartial<DesignTokens>;
95
+ componentAnimationsOverrides?: ComponentAnimationsOverrides;
96
+ effectsEnabled?: boolean;
97
+ disableEffectsForComponents?: ComponentSelector[];
98
+ effectTriggers?: Partial<Record<UIEventKey, EffectName>>;
99
+ }
100
+ export interface AppConfig {
101
+ theme?: ThemeConfig;
102
+ sse?: SSEConfig;
103
+ crypto?: CryptoConfig;
104
+ http?: HttpConfig;
105
+ logging?: Partial<LoggingConfig>;
106
+ }
107
+ export declare const defaultThemeConfig: ThemeConfig;
108
+ export declare const defaultConfig: AppConfig;
package/dist/types.js ADDED
@@ -0,0 +1,25 @@
1
+ export const defaultThemeConfig = {
2
+ theme: 'default',
3
+ animationsEnabled: true,
4
+ effectsEnabled: true,
5
+ themeEffectsEnabled: false,
6
+ wallpaperEnabled: false
7
+ };
8
+ export const defaultConfig = {
9
+ theme: defaultThemeConfig,
10
+ logging: {
11
+ enabled: false,
12
+ level: 'info',
13
+ console: {
14
+ enabled: false
15
+ },
16
+ localFiles: {
17
+ enabled: false,
18
+ path: 'fylogs'
19
+ },
20
+ remote: {
21
+ enabled: false,
22
+ endpoint: 'https://logs.example.com'
23
+ }
24
+ }
25
+ };
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@fylib/config",
3
+ "version": "0.1.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "files": ["dist"],
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc -p tsconfig.json",
12
+ "test": "vitest run --passWithNoTests"
13
+ },
14
+ "dependencies": {
15
+ "@fylib/core": "workspace:*",
16
+ "@fylib/crypto": "workspace:*",
17
+ "@fylib/animation": "workspace:*",
18
+ "@fylib/logger": "workspace:*"
19
+ },
20
+ "devDependencies": {
21
+ "typescript": "catalog:",
22
+ "@types/node": "catalog:"
23
+ }
24
+ }