@forcecalendar/core 2.1.69 → 2.2.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.
- package/core/calendar/Calendar.js +5 -5
- package/core/conflicts/ConflictDetector.js +5 -5
- package/core/events/Event.js +17 -17
- package/core/events/EventStore.js +16 -16
- package/core/events/RecurrenceEngine.js +123 -29
- package/core/ics/ICSHandler.js +5 -3
- package/core/index.js +5 -1
- package/core/state/StateManager.js +3 -3
- package/core/timezone/TimezoneManager.js +91 -53
- package/core/types.js +17 -14
- package/package.json +40 -20
- package/types/calendar/Calendar.d.ts +287 -0
- package/types/calendar/DateUtils.d.ts +298 -0
- package/types/conflicts/ConflictDetector.d.ts +103 -0
- package/types/events/Event.d.ts +329 -0
- package/types/events/EventStore.d.ts +341 -0
- package/types/events/RRuleParser.d.ts +60 -0
- package/types/events/RecurrenceEngine.d.ts +128 -0
- package/types/events/RecurrenceEngineV2.d.ts +140 -0
- package/types/ics/ICSHandler.d.ts +111 -0
- package/types/ics/ICSParser.d.ts +111 -0
- package/types/index.d.ts +22 -0
- package/types/integration/EnhancedCalendar.d.ts +76 -0
- package/types/performance/AdaptiveMemoryManager.d.ts +104 -0
- package/types/performance/LRUCache.d.ts +59 -0
- package/types/performance/PerformanceOptimizer.d.ts +134 -0
- package/types/search/EventSearch.d.ts +91 -0
- package/types/search/SearchWorkerManager.d.ts +116 -0
- package/types/state/StateManager.d.ts +200 -0
- package/types/timezone/TimezoneDatabase.d.ts +993 -0
- package/types/timezone/TimezoneManager.d.ts +134 -0
- package/types/types.d.ts +1225 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AdaptiveMemoryManager - Dynamically manages cache sizes based on memory pressure
|
|
3
|
+
* Monitors memory usage and adjusts cache capacity to prevent memory issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class AdaptiveMemoryManager {
|
|
6
|
+
config: {
|
|
7
|
+
checkInterval: number;
|
|
8
|
+
memoryThreshold: number;
|
|
9
|
+
criticalThreshold: number;
|
|
10
|
+
minCacheSize: number;
|
|
11
|
+
maxCacheSize: number;
|
|
12
|
+
adaptiveScaling: boolean;
|
|
13
|
+
};
|
|
14
|
+
caches: Map<any, any>;
|
|
15
|
+
stats: {
|
|
16
|
+
adjustments: number;
|
|
17
|
+
emergencyClears: number;
|
|
18
|
+
lastMemoryUsage: number;
|
|
19
|
+
lastCheckTime: null;
|
|
20
|
+
cacheResizes: never[];
|
|
21
|
+
};
|
|
22
|
+
monitoringInterval: number | null;
|
|
23
|
+
constructor(config?: {});
|
|
24
|
+
/**
|
|
25
|
+
* Register a cache for management
|
|
26
|
+
* @param {string} name - Cache identifier
|
|
27
|
+
* @param {Object} cache - Cache instance with size/clear methods
|
|
28
|
+
* @param {Object} [options] - Cache-specific options
|
|
29
|
+
*/
|
|
30
|
+
registerCache(name: string, cache: Object, options?: Object): void;
|
|
31
|
+
/**
|
|
32
|
+
* Unregister a cache
|
|
33
|
+
* @param {string} name - Cache identifier
|
|
34
|
+
*/
|
|
35
|
+
unregisterCache(name: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Start memory monitoring
|
|
38
|
+
*/
|
|
39
|
+
startMonitoring(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Stop memory monitoring
|
|
42
|
+
*/
|
|
43
|
+
stopMonitoring(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Check memory pressure and adjust caches
|
|
46
|
+
*/
|
|
47
|
+
checkMemoryPressure(): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Get current memory usage percentage
|
|
50
|
+
* @returns {Promise<number>} Memory usage as percentage (0-1)
|
|
51
|
+
*/
|
|
52
|
+
getMemoryUsage(): Promise<number>;
|
|
53
|
+
/**
|
|
54
|
+
* Estimate memory usage based on cache sizes
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
private estimateMemoryUsage;
|
|
58
|
+
/**
|
|
59
|
+
* Reduce cache sizes based on memory pressure
|
|
60
|
+
* @param {number} memoryUsage - Current memory usage percentage
|
|
61
|
+
*/
|
|
62
|
+
reduceCacheSizes(memoryUsage: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Increase cache sizes when memory is available
|
|
65
|
+
*/
|
|
66
|
+
increaseCacheSizes(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Resize a cache
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private resizeCache;
|
|
72
|
+
/**
|
|
73
|
+
* Evict excess items from cache
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
private evictExcessItems;
|
|
77
|
+
/**
|
|
78
|
+
* Emergency clear all caches
|
|
79
|
+
*/
|
|
80
|
+
emergencyClear(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Update cache access time
|
|
83
|
+
* @param {string} name - Cache name
|
|
84
|
+
*/
|
|
85
|
+
touchCache(name: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get memory management statistics
|
|
88
|
+
* @returns {Object} Statistics object
|
|
89
|
+
*/
|
|
90
|
+
getStats(): Object;
|
|
91
|
+
/**
|
|
92
|
+
* Manual trigger for memory pressure check
|
|
93
|
+
*/
|
|
94
|
+
checkNow(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Set memory thresholds
|
|
97
|
+
* @param {Object} thresholds - New threshold values
|
|
98
|
+
*/
|
|
99
|
+
setThresholds(thresholds: Object): void;
|
|
100
|
+
/**
|
|
101
|
+
* Destroy manager and clean up
|
|
102
|
+
*/
|
|
103
|
+
destroy(): void;
|
|
104
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LRU (Least Recently Used) Cache implementation
|
|
3
|
+
* Provides O(1) get and put operations
|
|
4
|
+
*/
|
|
5
|
+
export declare class LRUCache {
|
|
6
|
+
capacity: number;
|
|
7
|
+
cache: Map<any, any>;
|
|
8
|
+
hits: number;
|
|
9
|
+
misses: number;
|
|
10
|
+
evictions: number;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new LRU Cache
|
|
13
|
+
* @param {number} capacity - Maximum number of items in cache
|
|
14
|
+
*/
|
|
15
|
+
constructor(capacity?: number);
|
|
16
|
+
/**
|
|
17
|
+
* Get a value from the cache
|
|
18
|
+
* @param {string} key - Cache key
|
|
19
|
+
* @returns {*} Cached value or undefined
|
|
20
|
+
*/
|
|
21
|
+
get(key: string): any;
|
|
22
|
+
/**
|
|
23
|
+
* Put a value in the cache
|
|
24
|
+
* @param {string} key - Cache key
|
|
25
|
+
* @param {*} value - Value to cache
|
|
26
|
+
*/
|
|
27
|
+
put(key: string, value: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Check if key exists in cache
|
|
30
|
+
* @param {string} key - Cache key
|
|
31
|
+
* @returns {boolean} True if key exists
|
|
32
|
+
*/
|
|
33
|
+
has(key: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Remove a key from the cache
|
|
36
|
+
* @param {string} key - Cache key
|
|
37
|
+
* @returns {boolean} True if key was removed
|
|
38
|
+
*/
|
|
39
|
+
delete(key: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all cached items
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get cache statistics
|
|
46
|
+
* @returns {Object} Cache stats
|
|
47
|
+
*/
|
|
48
|
+
getStats(): Object;
|
|
49
|
+
/**
|
|
50
|
+
* Get all keys in order (least to most recently used)
|
|
51
|
+
* @returns {string[]} Array of keys
|
|
52
|
+
*/
|
|
53
|
+
keys(): string[];
|
|
54
|
+
/**
|
|
55
|
+
* Get cache size
|
|
56
|
+
* @returns {number} Number of items in cache
|
|
57
|
+
*/
|
|
58
|
+
get size(): number;
|
|
59
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PerformanceOptimizer - Optimizes calendar operations for large datasets
|
|
3
|
+
* Includes caching, lazy loading, and batch processing with adaptive memory management
|
|
4
|
+
*/
|
|
5
|
+
import { LRUCache } from './LRUCache.js';
|
|
6
|
+
import { AdaptiveMemoryManager } from './AdaptiveMemoryManager.js';
|
|
7
|
+
export declare class PerformanceOptimizer {
|
|
8
|
+
config: {
|
|
9
|
+
enableCache: boolean;
|
|
10
|
+
cacheCapacity: number;
|
|
11
|
+
maxIndexDays: number;
|
|
12
|
+
batchSize: number;
|
|
13
|
+
enableMetrics: boolean;
|
|
14
|
+
cleanupInterval: number;
|
|
15
|
+
maxIndexAge: number;
|
|
16
|
+
enableAdaptiveMemory: boolean;
|
|
17
|
+
};
|
|
18
|
+
eventCache: LRUCache;
|
|
19
|
+
queryCache: LRUCache;
|
|
20
|
+
dateRangeCache: LRUCache;
|
|
21
|
+
memoryManager: AdaptiveMemoryManager | undefined;
|
|
22
|
+
lazyIndexes: Map<any, any>;
|
|
23
|
+
pendingIndexes: Map<any, any>;
|
|
24
|
+
batchQueue: any[];
|
|
25
|
+
batchTimer: number | null;
|
|
26
|
+
batchCallbacks: any[];
|
|
27
|
+
metrics: {
|
|
28
|
+
operations: {};
|
|
29
|
+
averageTimes: {};
|
|
30
|
+
slowQueries: never[];
|
|
31
|
+
};
|
|
32
|
+
cleanupTimer: number | null;
|
|
33
|
+
constructor(config?: {});
|
|
34
|
+
/**
|
|
35
|
+
* Measure operation performance
|
|
36
|
+
* @param {string} operation - Operation name
|
|
37
|
+
* @param {Function} fn - Function to measure
|
|
38
|
+
* @returns {*} Function result
|
|
39
|
+
*/
|
|
40
|
+
measure(operation: string, fn: Function): any;
|
|
41
|
+
/**
|
|
42
|
+
* Measure async operation performance
|
|
43
|
+
* @param {string} operation - Operation name
|
|
44
|
+
* @param {Function} fn - Async function to measure
|
|
45
|
+
* @returns {Promise<*>} Function result
|
|
46
|
+
*/
|
|
47
|
+
measureAsync(operation: string, fn: Function): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Record performance metric
|
|
50
|
+
* @private
|
|
51
|
+
*/
|
|
52
|
+
private recordMetric;
|
|
53
|
+
/**
|
|
54
|
+
* Get performance metrics
|
|
55
|
+
* @returns {Object} Performance metrics
|
|
56
|
+
*/
|
|
57
|
+
getMetrics(): Object;
|
|
58
|
+
/**
|
|
59
|
+
* Check if event should use lazy indexing
|
|
60
|
+
* @param {import('../events/Event.js').Event} event - Event to check
|
|
61
|
+
* @returns {boolean} True if should use lazy indexing
|
|
62
|
+
*/
|
|
63
|
+
shouldUseLazyIndexing(event: import('../events/Event.js').Event): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Create lazy index markers for large events
|
|
66
|
+
* @param {import('../events/Event.js').Event} event - Event to index
|
|
67
|
+
* @returns {Object} Index boundaries
|
|
68
|
+
*/
|
|
69
|
+
createLazyIndexMarkers(event: import('../events/Event.js').Event): Object;
|
|
70
|
+
/**
|
|
71
|
+
* Expand lazy index for a specific date range
|
|
72
|
+
* @param {string} eventId - Event ID
|
|
73
|
+
* @param {Date} rangeStart - Start of range to index
|
|
74
|
+
* @param {Date} rangeEnd - End of range to index
|
|
75
|
+
* @returns {Promise<Set<string>>} Indexed date strings
|
|
76
|
+
*/
|
|
77
|
+
expandLazyIndex(eventId: string, rangeStart: Date, rangeEnd: Date): Promise<Set<string>>;
|
|
78
|
+
/**
|
|
79
|
+
* Get month key for date
|
|
80
|
+
* @private
|
|
81
|
+
*/
|
|
82
|
+
private getMonthKey;
|
|
83
|
+
/**
|
|
84
|
+
* Cache event with TTL
|
|
85
|
+
* @param {string} key - Cache key
|
|
86
|
+
* @param {*} value - Value to cache
|
|
87
|
+
* @param {string} cacheType - Type of cache to use
|
|
88
|
+
*/
|
|
89
|
+
cache(key: string, value: any, cacheType?: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Get from cache
|
|
92
|
+
* @param {string} key - Cache key
|
|
93
|
+
* @param {string} cacheType - Type of cache
|
|
94
|
+
* @returns {*} Cached value or undefined
|
|
95
|
+
*/
|
|
96
|
+
getFromCache(key: string, cacheType?: string): any;
|
|
97
|
+
/**
|
|
98
|
+
* Invalidate caches for an event
|
|
99
|
+
* @param {string} eventId - Event ID
|
|
100
|
+
*/
|
|
101
|
+
invalidateEventCaches(eventId: string): void;
|
|
102
|
+
/**
|
|
103
|
+
* Batch operation for efficiency
|
|
104
|
+
* @param {Function} operation - Operation to batch
|
|
105
|
+
* @returns {Promise} Batch result
|
|
106
|
+
*/
|
|
107
|
+
batch(operation: Function): Promise<any>;
|
|
108
|
+
/**
|
|
109
|
+
* Process batched operations
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private processBatch;
|
|
113
|
+
/**
|
|
114
|
+
* Start cleanup timer for old indexes
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private startCleanupTimer;
|
|
118
|
+
/**
|
|
119
|
+
* Clean up old indexes
|
|
120
|
+
* @private
|
|
121
|
+
*/
|
|
122
|
+
private cleanupOldIndexes;
|
|
123
|
+
/**
|
|
124
|
+
* Optimize query by checking cache first
|
|
125
|
+
* @param {string} queryKey - Unique query identifier
|
|
126
|
+
* @param {Function} queryFn - Function to execute if not cached
|
|
127
|
+
* @returns {*} Query result
|
|
128
|
+
*/
|
|
129
|
+
optimizeQuery(queryKey: string, queryFn: Function): any;
|
|
130
|
+
/**
|
|
131
|
+
* Destroy optimizer and clean up resources
|
|
132
|
+
*/
|
|
133
|
+
destroy(): void;
|
|
134
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event Search Engine
|
|
3
|
+
* Full-text search and filtering for calendar events
|
|
4
|
+
*/
|
|
5
|
+
export declare class EventSearch {
|
|
6
|
+
eventStore: any;
|
|
7
|
+
searchIndex: Map<any, any>;
|
|
8
|
+
indexFields: string[];
|
|
9
|
+
_indexDirty: boolean;
|
|
10
|
+
_unsubscribe: any;
|
|
11
|
+
constructor(eventStore: any);
|
|
12
|
+
/**
|
|
13
|
+
* Destroy the search engine and unsubscribe from store changes
|
|
14
|
+
*/
|
|
15
|
+
destroy(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Search events by query string
|
|
18
|
+
* @param {string} query - Search query
|
|
19
|
+
* @param {Object} options - Search options
|
|
20
|
+
* @returns {Array} Matching events
|
|
21
|
+
*/
|
|
22
|
+
search(query: string, options?: Object): any[];
|
|
23
|
+
/**
|
|
24
|
+
* Filter events by criteria
|
|
25
|
+
* @param {Object} filters - Filter criteria
|
|
26
|
+
* @returns {Array} Filtered events
|
|
27
|
+
*/
|
|
28
|
+
filter(filters: Object): any[];
|
|
29
|
+
/**
|
|
30
|
+
* Advanced search combining text search and filters
|
|
31
|
+
* @param {string} query - Search query
|
|
32
|
+
* @param {Object} filters - Filter criteria
|
|
33
|
+
* @param {Object} options - Search options
|
|
34
|
+
* @returns {Array} Matching events
|
|
35
|
+
*/
|
|
36
|
+
advancedSearch(query: string, filters?: Object, options?: Object): any[];
|
|
37
|
+
/**
|
|
38
|
+
* Get search suggestions/autocomplete
|
|
39
|
+
* @param {string} partial - Partial search term
|
|
40
|
+
* @param {Object} options - Suggestion options
|
|
41
|
+
* @returns {Array} Suggested terms
|
|
42
|
+
*/
|
|
43
|
+
getSuggestions(partial: string, options?: Object): any[];
|
|
44
|
+
/**
|
|
45
|
+
* Get unique values for a field (for filter dropdowns)
|
|
46
|
+
* @param {string} field - Field name
|
|
47
|
+
* @returns {Array} Unique values
|
|
48
|
+
*/
|
|
49
|
+
getUniqueValues(field: string): any[];
|
|
50
|
+
/**
|
|
51
|
+
* Group events by a field
|
|
52
|
+
* @param {string} field - Field to group by
|
|
53
|
+
* @param {Object} options - Grouping options
|
|
54
|
+
* @returns {Object} Grouped events
|
|
55
|
+
*/
|
|
56
|
+
groupBy(field: string, options?: Object): Object;
|
|
57
|
+
/**
|
|
58
|
+
* Calculate match score for an event
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
private calculateMatchScore;
|
|
62
|
+
/**
|
|
63
|
+
* Get match details for highlighting
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
private getMatchDetails;
|
|
67
|
+
/**
|
|
68
|
+
* Tokenize search query
|
|
69
|
+
* @private
|
|
70
|
+
*/
|
|
71
|
+
private tokenize;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate Levenshtein distance for fuzzy matching
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
private levenshteinDistance;
|
|
77
|
+
/**
|
|
78
|
+
* Sort search results
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
private sortResults;
|
|
82
|
+
/**
|
|
83
|
+
* Ensure the search index is up to date
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
private _ensureIndex;
|
|
87
|
+
/**
|
|
88
|
+
* Rebuild search index
|
|
89
|
+
*/
|
|
90
|
+
rebuildIndex(): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchWorkerManager - Offloads search indexing to Web Workers
|
|
3
|
+
* Provides scalable search for large event datasets
|
|
4
|
+
*/
|
|
5
|
+
export declare class SearchWorkerManager {
|
|
6
|
+
eventStore: any;
|
|
7
|
+
workerSupported: boolean;
|
|
8
|
+
worker: Worker | null;
|
|
9
|
+
indexReady: boolean;
|
|
10
|
+
indexMode: string;
|
|
11
|
+
workerExpectedCount: number;
|
|
12
|
+
pendingSearches: any[];
|
|
13
|
+
fallbackIndex: InvertedIndex | null;
|
|
14
|
+
config: {
|
|
15
|
+
chunkSize: number;
|
|
16
|
+
maxWorkers: number;
|
|
17
|
+
indexThreshold: number;
|
|
18
|
+
cacheSize: number;
|
|
19
|
+
searchTimeout: number;
|
|
20
|
+
};
|
|
21
|
+
searchCache: Map<any, any>;
|
|
22
|
+
cacheOrder: any[];
|
|
23
|
+
constructor(eventStore: any);
|
|
24
|
+
/**
|
|
25
|
+
* Initialize the search worker
|
|
26
|
+
*/
|
|
27
|
+
initializeWorker(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Ensure a fallback index exists.
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
private ensureFallbackIndex;
|
|
33
|
+
/**
|
|
34
|
+
* Setup worker message handlers
|
|
35
|
+
*/
|
|
36
|
+
setupWorkerHandlers(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Index all events
|
|
39
|
+
*/
|
|
40
|
+
indexEvents(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Search with caching and worker support
|
|
43
|
+
*/
|
|
44
|
+
search(query: any, options?: {}): Promise<any>;
|
|
45
|
+
/**
|
|
46
|
+
* Search using worker
|
|
47
|
+
*/
|
|
48
|
+
workerSearch(query: any, options: any): Promise<any>;
|
|
49
|
+
/**
|
|
50
|
+
* Direct search without worker
|
|
51
|
+
*/
|
|
52
|
+
directSearch(query: any, options: any): {
|
|
53
|
+
event: any;
|
|
54
|
+
score: number;
|
|
55
|
+
}[];
|
|
56
|
+
/**
|
|
57
|
+
* Handle search results from worker
|
|
58
|
+
*/
|
|
59
|
+
handleSearchResults(data: any): void;
|
|
60
|
+
/**
|
|
61
|
+
* Process any pending searches
|
|
62
|
+
*/
|
|
63
|
+
processPendingSearches(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Cache search results with LRU eviction
|
|
66
|
+
*/
|
|
67
|
+
cacheResults(key: any, results: any): void;
|
|
68
|
+
/**
|
|
69
|
+
* Clear index and cache
|
|
70
|
+
*/
|
|
71
|
+
clear(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Destroy worker and clean up
|
|
74
|
+
*/
|
|
75
|
+
destroy(): void;
|
|
76
|
+
/**
|
|
77
|
+
* Reject all pending worker searches.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
private rejectPendingSearches;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* InvertedIndex - Efficient inverted index for text search
|
|
84
|
+
* Used as fallback when Web Workers not available
|
|
85
|
+
*/
|
|
86
|
+
export declare class InvertedIndex {
|
|
87
|
+
index: Map<any, any>;
|
|
88
|
+
events: Map<any, any>;
|
|
89
|
+
fieldBoosts: {
|
|
90
|
+
title: number;
|
|
91
|
+
description: number;
|
|
92
|
+
location: number;
|
|
93
|
+
category: number;
|
|
94
|
+
categories: number;
|
|
95
|
+
};
|
|
96
|
+
constructor();
|
|
97
|
+
/**
|
|
98
|
+
* Build inverted index from events
|
|
99
|
+
*/
|
|
100
|
+
buildIndex(events: any): void;
|
|
101
|
+
/**
|
|
102
|
+
* Tokenize text into searchable terms
|
|
103
|
+
*/
|
|
104
|
+
tokenize(text: any): any;
|
|
105
|
+
/**
|
|
106
|
+
* Search the index
|
|
107
|
+
*/
|
|
108
|
+
search(query: any, options?: {}): {
|
|
109
|
+
event: any;
|
|
110
|
+
score: any;
|
|
111
|
+
}[];
|
|
112
|
+
/**
|
|
113
|
+
* Clear the index
|
|
114
|
+
*/
|
|
115
|
+
clear(): void;
|
|
116
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StateManager - Central state management for the calendar
|
|
3
|
+
* Implements an immutable state pattern with change notifications
|
|
4
|
+
*/
|
|
5
|
+
export declare class StateManager {
|
|
6
|
+
state: {
|
|
7
|
+
view: string;
|
|
8
|
+
currentDate: Date;
|
|
9
|
+
selectedEventId: string | null;
|
|
10
|
+
selectedDate: Date | null;
|
|
11
|
+
hoveredEventId: string | null;
|
|
12
|
+
hoveredDate: Date | null;
|
|
13
|
+
weekStartsOn: number;
|
|
14
|
+
showWeekNumbers: boolean;
|
|
15
|
+
showWeekends: boolean;
|
|
16
|
+
fixedWeekCount: boolean;
|
|
17
|
+
timeZone: string;
|
|
18
|
+
locale: string;
|
|
19
|
+
hourFormat: string;
|
|
20
|
+
businessHours: {
|
|
21
|
+
start: string;
|
|
22
|
+
end: string;
|
|
23
|
+
};
|
|
24
|
+
filters: import("../types.js").FilterState;
|
|
25
|
+
isDragging: boolean;
|
|
26
|
+
isResizing: boolean;
|
|
27
|
+
isCreating: boolean;
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
loadingMessage: string;
|
|
30
|
+
error: string | null;
|
|
31
|
+
metadata: {};
|
|
32
|
+
};
|
|
33
|
+
listeners: Map<any, any>;
|
|
34
|
+
globalListeners: Set<any>;
|
|
35
|
+
history: any[];
|
|
36
|
+
historyIndex: number;
|
|
37
|
+
maxHistorySize: number;
|
|
38
|
+
/**
|
|
39
|
+
* Create a new StateManager instance
|
|
40
|
+
* @param {Partial<import('../types.js').CalendarState>} [initialState={}] - Initial state values
|
|
41
|
+
*/
|
|
42
|
+
constructor(initialState?: Partial<import('../types.js').CalendarState>);
|
|
43
|
+
/**
|
|
44
|
+
* Get the current state
|
|
45
|
+
* @returns {import('../types.js').CalendarState} Current state (frozen)
|
|
46
|
+
*/
|
|
47
|
+
getState(): import('../types.js').CalendarState;
|
|
48
|
+
/**
|
|
49
|
+
* Get a specific state value
|
|
50
|
+
* @param {keyof import('../types.js').CalendarState} key - The state key
|
|
51
|
+
* @returns {any} The state value
|
|
52
|
+
*/
|
|
53
|
+
get(key: keyof import('../types.js').CalendarState): any;
|
|
54
|
+
/**
|
|
55
|
+
* Update state with partial updates
|
|
56
|
+
* @param {Object|Function} updates - Object with updates or updater function
|
|
57
|
+
*/
|
|
58
|
+
setState(updates: Object | Function): void;
|
|
59
|
+
/**
|
|
60
|
+
* Set the current view
|
|
61
|
+
* @param {string} view - The view type
|
|
62
|
+
*/
|
|
63
|
+
setView(view: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Set the current date
|
|
66
|
+
* @param {Date} date - The date to set
|
|
67
|
+
*/
|
|
68
|
+
setCurrentDate(date: Date): void;
|
|
69
|
+
/**
|
|
70
|
+
* Navigate to the next period (month/week/day based on view)
|
|
71
|
+
*/
|
|
72
|
+
navigateNext(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Navigate to the previous period
|
|
75
|
+
*/
|
|
76
|
+
navigatePrevious(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Navigate to today
|
|
79
|
+
*/
|
|
80
|
+
navigateToday(): void;
|
|
81
|
+
/**
|
|
82
|
+
* Select an event
|
|
83
|
+
* @param {string} eventId - The event ID to select
|
|
84
|
+
*/
|
|
85
|
+
selectEvent(eventId: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Clear event selection
|
|
88
|
+
*/
|
|
89
|
+
clearEventSelection(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Select a date
|
|
92
|
+
* @param {Date} date - The date to select
|
|
93
|
+
*/
|
|
94
|
+
selectDate(date: Date): void;
|
|
95
|
+
/**
|
|
96
|
+
* Clear date selection
|
|
97
|
+
*/
|
|
98
|
+
clearDateSelection(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Set loading state
|
|
101
|
+
* @param {boolean} isLoading - Loading state
|
|
102
|
+
* @param {string} message - Optional loading message
|
|
103
|
+
*/
|
|
104
|
+
setLoading(isLoading: boolean, message?: string): void;
|
|
105
|
+
/**
|
|
106
|
+
* Set error state
|
|
107
|
+
* @param {Error|string|null} error - The error
|
|
108
|
+
*/
|
|
109
|
+
setError(error: Error | string | null): void;
|
|
110
|
+
/**
|
|
111
|
+
* Update filters
|
|
112
|
+
* @param {Object} filters - Filter updates
|
|
113
|
+
*/
|
|
114
|
+
updateFilters(filters: Object): void;
|
|
115
|
+
/**
|
|
116
|
+
* Subscribe to all state changes
|
|
117
|
+
* @param {Function} callback - Callback function
|
|
118
|
+
* @returns {Function} Unsubscribe function
|
|
119
|
+
*/
|
|
120
|
+
subscribe(callback: Function): Function;
|
|
121
|
+
/**
|
|
122
|
+
* Subscribe to specific state key changes
|
|
123
|
+
* @param {string|string[]} keys - State key(s) to watch
|
|
124
|
+
* @param {Function} callback - Callback function
|
|
125
|
+
* @returns {Function} Unsubscribe function
|
|
126
|
+
*/
|
|
127
|
+
watch(keys: string | string[], callback: Function): Function;
|
|
128
|
+
/**
|
|
129
|
+
* Check if undo is available
|
|
130
|
+
* @returns {boolean} True if undo is available
|
|
131
|
+
*/
|
|
132
|
+
canUndo(): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Check if redo is available
|
|
135
|
+
* @returns {boolean} True if redo is available
|
|
136
|
+
*/
|
|
137
|
+
canRedo(): boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Get the number of undo operations available
|
|
140
|
+
* @returns {number} Number of undo operations
|
|
141
|
+
*/
|
|
142
|
+
getUndoCount(): number;
|
|
143
|
+
/**
|
|
144
|
+
* Get the number of redo operations available
|
|
145
|
+
* @returns {number} Number of redo operations
|
|
146
|
+
*/
|
|
147
|
+
getRedoCount(): number;
|
|
148
|
+
/**
|
|
149
|
+
* Undo the last state change
|
|
150
|
+
* @returns {boolean} True if undo was performed
|
|
151
|
+
*/
|
|
152
|
+
undo(): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Redo the next state change
|
|
155
|
+
* @returns {boolean} True if redo was performed
|
|
156
|
+
*/
|
|
157
|
+
redo(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Reset state to initial values
|
|
160
|
+
*/
|
|
161
|
+
reset(): void;
|
|
162
|
+
/**
|
|
163
|
+
* Recursively sanitize an object to prevent prototype pollution
|
|
164
|
+
* Removes dangerous keys (__proto__, constructor, prototype) at all levels
|
|
165
|
+
* @param {*} obj - Object to sanitize
|
|
166
|
+
* @param {number} depth - Current recursion depth
|
|
167
|
+
* @returns {*} Sanitized object
|
|
168
|
+
* @private
|
|
169
|
+
*/
|
|
170
|
+
private static _deepSanitize;
|
|
171
|
+
/**
|
|
172
|
+
* Check if state has changed
|
|
173
|
+
* @private
|
|
174
|
+
*/
|
|
175
|
+
private _hasChanged;
|
|
176
|
+
/**
|
|
177
|
+
* Deep equality check optimized for state comparison
|
|
178
|
+
* @private
|
|
179
|
+
* @param {*} a - First value
|
|
180
|
+
* @param {*} b - Second value
|
|
181
|
+
* @param {Set} seen - Track circular references
|
|
182
|
+
* @returns {boolean} True if values are deeply equal
|
|
183
|
+
*/
|
|
184
|
+
private _deepEqual;
|
|
185
|
+
/**
|
|
186
|
+
* Add state to history
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
private _addToHistory;
|
|
190
|
+
/**
|
|
191
|
+
* Deep clone a value for history storage
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
private _deepClone;
|
|
195
|
+
/**
|
|
196
|
+
* Notify listeners of state changes
|
|
197
|
+
* @private
|
|
198
|
+
*/
|
|
199
|
+
private _notifyListeners;
|
|
200
|
+
}
|