@zengrid/core 1.0.1 → 1.0.4
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/dist/index.cjs.js +43 -55
- package/dist/index.esm.js +2 -14
- package/dist/package.json +5 -5
- package/dist/src/a11y/aria-manager.d.ts.map +1 -1
- package/dist/src/a11y/focus-manager.d.ts.map +1 -1
- package/dist/src/a11y/index.d.ts.map +1 -1
- package/dist/src/data/data-accessor/array-accessor.d.ts.map +1 -1
- package/dist/src/data/data-accessor/column-store-accessor.d.ts.map +1 -1
- package/dist/src/data/data-accessor/data-accessor.interface.d.ts.map +1 -1
- package/dist/src/data/data-accessor/index.d.ts.map +1 -1
- package/dist/src/data/data-accessor/sparse-matrix-accessor.d.ts.map +1 -1
- package/dist/src/data/data-manager.d.ts.map +1 -1
- package/dist/src/data/data-source.interface.d.ts.map +1 -1
- package/dist/src/data/grid-data-model.d.ts +2 -2
- package/dist/src/data/grid-data-model.d.ts.map +1 -1
- package/dist/src/data/index-map/index-map.d.ts.map +1 -1
- package/dist/src/data/index-map/index-map.interface.d.ts.map +1 -1
- package/dist/src/data/index-map/index.d.ts.map +1 -1
- package/dist/src/data/index.d.ts.map +1 -1
- package/dist/src/editing/cell-editor.interface.d.ts.map +1 -1
- package/dist/src/editing/date-editor.d.ts.map +1 -1
- package/dist/src/editing/editor-manager.d.ts.map +1 -1
- package/dist/src/editing/index.d.ts.map +1 -1
- package/dist/src/editing/number-editor.d.ts.map +1 -1
- package/dist/src/editing/select-editor.d.ts.map +1 -1
- package/dist/src/editing/text-editor.d.ts.map +1 -1
- package/dist/src/events/event-emitter.d.ts.map +1 -1
- package/dist/src/events/grid-events.d.ts.map +1 -1
- package/dist/src/events/index.d.ts.map +1 -1
- package/dist/src/features/autofill/autofill-manager.d.ts +1 -1
- package/dist/src/features/autofill/autofill-manager.d.ts.map +1 -1
- package/dist/src/features/autofill/index.d.ts.map +1 -1
- package/dist/src/features/column-resize/auto-fit-calculator.d.ts.map +1 -1
- package/dist/src/features/column-resize/column-resize-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/column-resize-manager.interface.d.ts.map +1 -1
- package/dist/src/features/column-resize/index.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-constraint-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-handle-renderer.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-preview.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-state-manager.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-strategies.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-test-helper.d.ts.map +1 -1
- package/dist/src/features/column-resize/resize-zone-detector.d.ts.map +1 -1
- package/dist/src/features/copy-paste/clipboard-manager.d.ts.map +1 -1
- package/dist/src/features/copy-paste/index.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/adapter.interface.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/graphql-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/index.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/rest-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/sql-adapter.d.ts.map +1 -1
- package/dist/src/features/filtering/adapters/types.d.ts.map +1 -1
- package/dist/src/features/filtering/column-filter.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-autocomplete.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-cache.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-compiler.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-export-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-index-manager.d.ts +1 -1
- package/dist/src/features/filtering/filter-index-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-manager.d.ts +1 -1
- package/dist/src/features/filtering/filter-manager.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-optimizer.d.ts.map +1 -1
- package/dist/src/features/filtering/filter-query-parser.d.ts.map +1 -1
- package/dist/src/features/filtering/index.d.ts.map +1 -1
- package/dist/src/features/filtering/range-filter-optimizer.d.ts.map +1 -1
- package/dist/src/features/filtering/substring-filter.d.ts.map +1 -1
- package/dist/src/features/filtering/types.d.ts.map +1 -1
- package/dist/src/features/formulas/formula-calculator.d.ts.map +1 -1
- package/dist/src/features/formulas/index.d.ts.map +1 -1
- package/dist/src/features/hit-testing/index.d.ts.map +1 -1
- package/dist/src/features/hit-testing/spatial-hit-tester.d.ts +1 -1
- package/dist/src/features/hit-testing/spatial-hit-tester.d.ts.map +1 -1
- package/dist/src/features/loading/index.d.ts.map +1 -1
- package/dist/src/features/loading/loading-indicator.d.ts.map +1 -1
- package/dist/src/features/pagination/index.d.ts.map +1 -1
- package/dist/src/features/pagination/paginator.d.ts.map +1 -1
- package/dist/src/features/selection/index.d.ts.map +1 -1
- package/dist/src/features/selection/selection-manager.d.ts.map +1 -1
- package/dist/src/features/sorting/index.d.ts.map +1 -1
- package/dist/src/features/sorting/row-sorter.interface.d.ts.map +1 -1
- package/dist/src/features/sorting/single-column-sorter.d.ts.map +1 -1
- package/dist/src/features/sorting/sort-manager.d.ts.map +1 -1
- package/dist/src/features/undo-redo/index.d.ts.map +1 -1
- package/dist/src/features/undo-redo/undo-redo-manager.d.ts.map +1 -1
- package/dist/src/grid.d.ts.map +1 -1
- package/dist/src/i18n/index.d.ts.map +1 -1
- package/dist/src/i18n/locale-manager.d.ts.map +1 -1
- package/dist/src/i18n/rtl-support.d.ts.map +1 -1
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keyboard/index.d.ts.map +1 -1
- package/dist/src/keyboard/keyboard-navigator.d.ts.map +1 -1
- package/dist/src/rendering/cache/index.d.ts.map +1 -1
- package/dist/src/rendering/cache/renderer-cache.d.ts.map +1 -1
- package/dist/src/rendering/cache/renderer-cache.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/cell-pool.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/cell-pool.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-pool/index.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/cell-positioner.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/cell-positioner.interface.d.ts.map +1 -1
- package/dist/src/rendering/cell-positioner/index.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/height-provider.interface.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/index.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/uniform-height-provider.d.ts.map +1 -1
- package/dist/src/rendering/height-provider/variable-height-provider.d.ts.map +1 -1
- package/dist/src/rendering/renderers/advanced-cell-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/image-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/index.d.ts.map +1 -1
- package/dist/src/rendering/renderers/number-renderer.d.ts.map +1 -1
- package/dist/src/rendering/renderers/renderer-registry.d.ts.map +1 -1
- package/dist/src/rendering/renderers/renderer.interface.d.ts.map +1 -1
- package/dist/src/rendering/renderers/text-renderer.d.ts.map +1 -1
- package/dist/src/rendering/spatial-hit-tester.d.ts +1 -1
- package/dist/src/rendering/spatial-hit-tester.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/index.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/virtual-scroller.d.ts.map +1 -1
- package/dist/src/rendering/virtual-scroller/virtual-scroller.interface.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/index.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/uniform-width-provider.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/variable-width-provider.d.ts.map +1 -1
- package/dist/src/rendering/width-provider/width-provider.interface.d.ts.map +1 -1
- package/dist/src/selection/hit-tester.d.ts.map +1 -1
- package/dist/src/selection/hit-tester.interface.d.ts.map +1 -1
- package/dist/src/selection/index.d.ts.map +1 -1
- package/dist/src/selection/range-utils.d.ts.map +1 -1
- package/dist/src/selection/range-utils.interface.d.ts.map +1 -1
- package/dist/src/shared/algorithms/filter/bloom-filter.d.ts +120 -0
- package/dist/src/shared/algorithms/filter/bloom-filter.d.ts.map +1 -0
- package/dist/src/shared/algorithms/filter/index.d.ts +7 -0
- package/dist/src/shared/algorithms/filter/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/bfs.d.ts +71 -0
- package/dist/src/shared/algorithms/graph/bfs.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/dfs.d.ts +62 -0
- package/dist/src/shared/algorithms/graph/dfs.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/graph.interface.d.ts +63 -0
- package/dist/src/shared/algorithms/graph/graph.interface.d.ts.map +1 -0
- package/dist/src/shared/algorithms/graph/index.d.ts +9 -0
- package/dist/src/shared/algorithms/graph/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/index.d.ts +11 -0
- package/dist/src/shared/algorithms/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/pattern/index.d.ts +8 -0
- package/dist/src/shared/algorithms/pattern/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/pattern/sequence-detector.d.ts +62 -0
- package/dist/src/shared/algorithms/pattern/sequence-detector.d.ts.map +1 -0
- package/dist/src/shared/algorithms/search/binary-search.d.ts +86 -0
- package/dist/src/shared/algorithms/search/binary-search.d.ts.map +1 -0
- package/dist/src/shared/algorithms/search/index.d.ts +6 -0
- package/dist/src/shared/algorithms/search/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/comparators.d.ts +126 -0
- package/dist/src/shared/algorithms/sorting/comparators.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/index.d.ts +9 -0
- package/dist/src/shared/algorithms/sorting/index.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/sorting.interface.d.ts +38 -0
- package/dist/src/shared/algorithms/sorting/sorting.interface.d.ts.map +1 -0
- package/dist/src/shared/algorithms/sorting/timsort.d.ts +55 -0
- package/dist/src/shared/algorithms/sorting/timsort.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/column-store.d.ts +52 -0
- package/dist/src/shared/data-structures/column-store/column-store.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/column-store.interface.d.ts +155 -0
- package/dist/src/shared/data-structures/column-store/column-store.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/column-store/index.d.ts +6 -0
- package/dist/src/shared/data-structures/column-store/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.d.ts +61 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.interface.d.ts +80 -0
- package/dist/src/shared/data-structures/command-stack/command-stack.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/command-stack/index.d.ts +3 -0
- package/dist/src/shared/data-structures/command-stack/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.d.ts +147 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.interface.d.ts +161 -0
- package/dist/src/shared/data-structures/dependency-graph/dependency-graph.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/dependency-graph/index.d.ts +8 -0
- package/dist/src/shared/data-structures/dependency-graph/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.d.ts +84 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.interface.d.ts +185 -0
- package/dist/src/shared/data-structures/disjoint-set/disjoint-set.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/disjoint-set/index.d.ts +7 -0
- package/dist/src/shared/data-structures/disjoint-set/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index-map.d.ts +150 -0
- package/dist/src/shared/data-structures/index-map/index-map.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index-map.interface.d.ts +186 -0
- package/dist/src/shared/data-structures/index-map/index-map.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index-map/index.d.ts +6 -0
- package/dist/src/shared/data-structures/index-map/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/index.d.ts +36 -0
- package/dist/src/shared/data-structures/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/index.d.ts +7 -0
- package/dist/src/shared/data-structures/interval-tree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.d.ts +141 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.interface.d.ts +212 -0
- package/dist/src/shared/data-structures/interval-tree/interval-tree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/index.d.ts +3 -0
- package/dist/src/shared/data-structures/lru-cache/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.d.ts +134 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.d.ts.map +1 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.interface.d.ts +173 -0
- package/dist/src/shared/data-structures/lru-cache/lru-cache.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/index.d.ts +6 -0
- package/dist/src/shared/data-structures/prefix-sum-array/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.d.ts +63 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.d.ts.map +1 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts +80 -0
- package/dist/src/shared/data-structures/prefix-sum-array/prefix-sum-array.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/index.d.ts +8 -0
- package/dist/src/shared/data-structures/rtree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/rtree.d.ts +81 -0
- package/dist/src/shared/data-structures/rtree/rtree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/rtree/rtree.interface.d.ts +143 -0
- package/dist/src/shared/data-structures/rtree/rtree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/index.d.ts +4 -0
- package/dist/src/shared/data-structures/segment-tree/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.d.ts +134 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.d.ts.map +1 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.interface.d.ts +202 -0
- package/dist/src/shared/data-structures/segment-tree/segment-tree.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/index.d.ts +4 -0
- package/dist/src/shared/data-structures/skip-list/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.d.ts +137 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.d.ts.map +1 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.interface.d.ts +223 -0
- package/dist/src/shared/data-structures/skip-list/skip-list.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/index.d.ts +6 -0
- package/dist/src/shared/data-structures/sparse-matrix/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.d.ts +44 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.d.ts.map +1 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.interface.d.ts +105 -0
- package/dist/src/shared/data-structures/sparse-matrix/sparse-matrix.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/index.d.ts +3 -0
- package/dist/src/shared/data-structures/suffix-array/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.d.ts +102 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.d.ts.map +1 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.interface.d.ts +117 -0
- package/dist/src/shared/data-structures/suffix-array/suffix-array.interface.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/index.d.ts +8 -0
- package/dist/src/shared/data-structures/trie/index.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/trie.d.ts +205 -0
- package/dist/src/shared/data-structures/trie/trie.d.ts.map +1 -0
- package/dist/src/shared/data-structures/trie/trie.interface.d.ts +117 -0
- package/dist/src/shared/data-structures/trie/trie.interface.d.ts.map +1 -0
- package/dist/src/shared/index.d.ts +47 -0
- package/dist/src/shared/index.d.ts.map +1 -0
- package/dist/src/shared/patterns/coordinator.d.ts +90 -0
- package/dist/src/shared/patterns/coordinator.d.ts.map +1 -0
- package/dist/src/shared/patterns/event-emitter.d.ts +106 -0
- package/dist/src/shared/patterns/event-emitter.d.ts.map +1 -0
- package/dist/src/shared/patterns/factory.d.ts +120 -0
- package/dist/src/shared/patterns/factory.d.ts.map +1 -0
- package/dist/src/shared/patterns/index.d.ts +21 -0
- package/dist/src/shared/patterns/index.d.ts.map +1 -0
- package/dist/src/shared/patterns/mediator.d.ts +116 -0
- package/dist/src/shared/patterns/mediator.d.ts.map +1 -0
- package/dist/src/shared/patterns/object-pool.d.ts +178 -0
- package/dist/src/shared/patterns/object-pool.d.ts.map +1 -0
- package/dist/src/shared/patterns/observer.d.ts +89 -0
- package/dist/src/shared/patterns/observer.d.ts.map +1 -0
- package/dist/src/shared/patterns/operation-mode.d.ts +75 -0
- package/dist/src/shared/patterns/operation-mode.d.ts.map +1 -0
- package/dist/src/shared/patterns/state-machine.d.ts +122 -0
- package/dist/src/shared/patterns/state-machine.d.ts.map +1 -0
- package/dist/src/shared/types/common.d.ts +56 -0
- package/dist/src/shared/types/common.d.ts.map +1 -0
- package/dist/src/shared/types/index.d.ts +5 -0
- package/dist/src/shared/types/index.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +7 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -0
- package/dist/src/shared/utils/timing.d.ts +104 -0
- package/dist/src/shared/utils/timing.d.ts.map +1 -0
- package/dist/src/shared/utils/timing.interface.d.ts +96 -0
- package/dist/src/shared/utils/timing.interface.d.ts.map +1 -0
- package/dist/src/touch/index.d.ts.map +1 -1
- package/dist/src/touch/touch-handler.d.ts.map +1 -1
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +47 -47
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { ITrie, TrieOptions, TrieSearchResult } from './trie.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Trie (Prefix Tree) Data Structure
|
|
4
|
+
*
|
|
5
|
+
* A tree-based data structure for efficient prefix-based searches.
|
|
6
|
+
*
|
|
7
|
+
* **Time Complexity:**
|
|
8
|
+
* - Insert: O(m) where m = word length
|
|
9
|
+
* - Search: O(m)
|
|
10
|
+
* - Autocomplete: O(m + n) where n = number of suggestions
|
|
11
|
+
* - Delete: O(m)
|
|
12
|
+
*
|
|
13
|
+
* **Space Complexity:** O(ALPHABET_SIZE * m * n) where n = number of words
|
|
14
|
+
*
|
|
15
|
+
* **Use Cases:**
|
|
16
|
+
* - Column filter autocomplete: type "ap" → suggests "apple", "application"
|
|
17
|
+
* - Search suggestions: real-time filtering as user types
|
|
18
|
+
* - Dictionary lookups: spell checking
|
|
19
|
+
* - IP routing tables
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const trie = new Trie();
|
|
24
|
+
* trie.insert('apple');
|
|
25
|
+
* trie.insert('application');
|
|
26
|
+
* trie.insert('app');
|
|
27
|
+
*
|
|
28
|
+
* trie.search('apple'); // true
|
|
29
|
+
* trie.search('appl'); // false
|
|
30
|
+
* trie.startsWith('app'); // true
|
|
31
|
+
* trie.autocomplete('app'); // ['app', 'apple', 'application']
|
|
32
|
+
*
|
|
33
|
+
* const result = trie.find('app');
|
|
34
|
+
* // {
|
|
35
|
+
* // term: 'app',
|
|
36
|
+
* // isComplete: true,
|
|
37
|
+
* // suggestions: ['app', 'apple', 'application'],
|
|
38
|
+
* // count: 3
|
|
39
|
+
* // }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example Grid Integration
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Column filter with autocomplete
|
|
45
|
+
* class FilterManager {
|
|
46
|
+
* private valueTrie = new Trie();
|
|
47
|
+
*
|
|
48
|
+
* indexColumn(col: number): void {
|
|
49
|
+
* const values = this.grid.getColumnValues(col);
|
|
50
|
+
* values.forEach(v => this.valueTrie.insert(String(v)));
|
|
51
|
+
* }
|
|
52
|
+
*
|
|
53
|
+
* getSuggestions(prefix: string): string[] {
|
|
54
|
+
* return this.valueTrie.autocomplete(prefix, 10);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class Trie implements ITrie {
|
|
60
|
+
private root;
|
|
61
|
+
private options;
|
|
62
|
+
private wordCount;
|
|
63
|
+
constructor(options?: TrieOptions);
|
|
64
|
+
/**
|
|
65
|
+
* Insert a word into the trie
|
|
66
|
+
*
|
|
67
|
+
* @param word - Word to insert
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* trie.insert('hello');
|
|
72
|
+
* trie.insert('world');
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
insert(word: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Search for an exact word in the trie
|
|
78
|
+
*
|
|
79
|
+
* @param word - Word to search for
|
|
80
|
+
* @returns true if word exists, false otherwise
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* trie.insert('apple');
|
|
85
|
+
* trie.search('apple'); // true
|
|
86
|
+
* trie.search('app'); // false (not a complete word)
|
|
87
|
+
* trie.search('apples'); // false
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
search(word: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Check if any word starts with the given prefix
|
|
93
|
+
*
|
|
94
|
+
* @param prefix - Prefix to check
|
|
95
|
+
* @returns true if prefix exists, false otherwise
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* trie.insert('apple');
|
|
100
|
+
* trie.startsWith('app'); // true
|
|
101
|
+
* trie.startsWith('ban'); // false
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
startsWith(prefix: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Get autocomplete suggestions for a prefix
|
|
107
|
+
*
|
|
108
|
+
* @param prefix - Prefix to search for
|
|
109
|
+
* @param maxResults - Maximum number of results (default: from options)
|
|
110
|
+
* @returns Array of suggestions
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* trie.insert('apple');
|
|
115
|
+
* trie.insert('application');
|
|
116
|
+
* trie.insert('app');
|
|
117
|
+
*
|
|
118
|
+
* trie.autocomplete('app'); // ['app', 'apple', 'application']
|
|
119
|
+
* trie.autocomplete('app', 2); // ['app', 'apple']
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
autocomplete(prefix: string, maxResults?: number): string[];
|
|
123
|
+
/**
|
|
124
|
+
* Get detailed search result with metadata
|
|
125
|
+
*
|
|
126
|
+
* @param term - Search term
|
|
127
|
+
* @returns Search result with suggestions and metadata
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const result = trie.find('app');
|
|
132
|
+
* // {
|
|
133
|
+
* // term: 'app',
|
|
134
|
+
* // isComplete: true,
|
|
135
|
+
* // suggestions: ['app', 'apple', 'application'],
|
|
136
|
+
* // count: 3
|
|
137
|
+
* // }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
find(term: string): TrieSearchResult;
|
|
141
|
+
/**
|
|
142
|
+
* Delete a word from the trie
|
|
143
|
+
*
|
|
144
|
+
* @param word - Word to delete
|
|
145
|
+
* @returns true if word was deleted, false if word didn't exist
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```typescript
|
|
149
|
+
* trie.insert('apple');
|
|
150
|
+
* trie.delete('apple'); // true
|
|
151
|
+
* trie.delete('banana'); // false (doesn't exist)
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
delete(word: string): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Clear all words from the trie
|
|
157
|
+
*/
|
|
158
|
+
clear(): void;
|
|
159
|
+
/**
|
|
160
|
+
* Get all words in the trie
|
|
161
|
+
*
|
|
162
|
+
* @returns Array of all words
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* trie.insert('apple');
|
|
167
|
+
* trie.insert('banana');
|
|
168
|
+
* trie.getAllWords(); // ['apple', 'banana']
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
getAllWords(): string[];
|
|
172
|
+
/**
|
|
173
|
+
* Get the number of unique words in the trie
|
|
174
|
+
*
|
|
175
|
+
* @returns Number of words
|
|
176
|
+
*/
|
|
177
|
+
size(): number;
|
|
178
|
+
/**
|
|
179
|
+
* Check if the trie is empty
|
|
180
|
+
*
|
|
181
|
+
* @returns true if empty, false otherwise
|
|
182
|
+
*/
|
|
183
|
+
isEmpty(): boolean;
|
|
184
|
+
/**
|
|
185
|
+
* Normalize a string based on case sensitivity option
|
|
186
|
+
*/
|
|
187
|
+
private normalize;
|
|
188
|
+
/**
|
|
189
|
+
* Restore original case from prefix to suggestion
|
|
190
|
+
*/
|
|
191
|
+
private restoreCase;
|
|
192
|
+
/**
|
|
193
|
+
* Find a node in the trie by traversing the path
|
|
194
|
+
*/
|
|
195
|
+
private findNode;
|
|
196
|
+
/**
|
|
197
|
+
* Collect all words from a node using DFS
|
|
198
|
+
*/
|
|
199
|
+
private collectWords;
|
|
200
|
+
/**
|
|
201
|
+
* Recursively delete a word from the trie
|
|
202
|
+
*/
|
|
203
|
+
private deleteRecursive;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=trie.d.ts.map
|
|
@@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BpB;;OAEG;IACH,OAAO,CAAC,eAAe;CAwCxB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trie (Prefix Tree) Interface
|
|
3
|
+
*
|
|
4
|
+
* Used for:
|
|
5
|
+
* - Autocomplete in column filters
|
|
6
|
+
* - Search suggestions
|
|
7
|
+
* - Dictionary lookups
|
|
8
|
+
* - Prefix-based searches
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Trie search result
|
|
12
|
+
*/
|
|
13
|
+
export interface TrieSearchResult {
|
|
14
|
+
/**
|
|
15
|
+
* The search term
|
|
16
|
+
*/
|
|
17
|
+
term: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the term exists as a complete word
|
|
20
|
+
*/
|
|
21
|
+
isComplete: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* All words with this prefix
|
|
24
|
+
*/
|
|
25
|
+
suggestions: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Number of words with this prefix
|
|
28
|
+
*/
|
|
29
|
+
count: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Trie node interface
|
|
33
|
+
*/
|
|
34
|
+
export interface ITrieNode {
|
|
35
|
+
/**
|
|
36
|
+
* Character at this node
|
|
37
|
+
*/
|
|
38
|
+
char: string;
|
|
39
|
+
/**
|
|
40
|
+
* Is this the end of a word?
|
|
41
|
+
*/
|
|
42
|
+
isEndOfWord: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Child nodes
|
|
45
|
+
*/
|
|
46
|
+
children: Map<string, ITrieNode>;
|
|
47
|
+
/**
|
|
48
|
+
* Number of words passing through this node
|
|
49
|
+
*/
|
|
50
|
+
wordCount: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Trie options
|
|
54
|
+
*/
|
|
55
|
+
export interface TrieOptions {
|
|
56
|
+
/**
|
|
57
|
+
* Case-sensitive search
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
caseSensitive?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Maximum suggestions to return
|
|
63
|
+
* @default 10
|
|
64
|
+
*/
|
|
65
|
+
maxSuggestions?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Allow partial matches
|
|
68
|
+
* @default true
|
|
69
|
+
*/
|
|
70
|
+
allowPartial?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Trie data structure interface
|
|
74
|
+
*/
|
|
75
|
+
export interface ITrie {
|
|
76
|
+
/**
|
|
77
|
+
* Insert a word into the trie
|
|
78
|
+
*/
|
|
79
|
+
insert(word: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Search for a word in the trie
|
|
82
|
+
*/
|
|
83
|
+
search(word: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Check if any word starts with the given prefix
|
|
86
|
+
*/
|
|
87
|
+
startsWith(prefix: string): boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Get all words with the given prefix (autocomplete)
|
|
90
|
+
*/
|
|
91
|
+
autocomplete(prefix: string, maxResults?: number): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Get detailed search result
|
|
94
|
+
*/
|
|
95
|
+
find(term: string): TrieSearchResult;
|
|
96
|
+
/**
|
|
97
|
+
* Delete a word from the trie
|
|
98
|
+
*/
|
|
99
|
+
delete(word: string): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Clear all words from the trie
|
|
102
|
+
*/
|
|
103
|
+
clear(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Get all words in the trie
|
|
106
|
+
*/
|
|
107
|
+
getAllWords(): string[];
|
|
108
|
+
/**
|
|
109
|
+
* Get the number of words in the trie
|
|
110
|
+
*/
|
|
111
|
+
size(): number;
|
|
112
|
+
/**
|
|
113
|
+
* Check if the trie is empty
|
|
114
|
+
*/
|
|
115
|
+
isEmpty(): boolean;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=trie.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trie.interface.d.ts","sourceRoot":"","sources":["../../../../../src/shared/data-structures/trie/trie.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IAEtB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE3B;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;IAEpC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE5D;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAAC;IAErC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAE9B;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;IAEd;;OAEG;IACH,WAAW,IAAI,MAAM,EAAE,CAAC;IAExB;;OAEG;IACH,IAAI,IAAI,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,IAAI,OAAO,CAAC;CACpB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZenGrid Shared Package
|
|
3
|
+
* Reusable algorithms and data structures
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { SparseMatrix } from './data-structures/sparse-matrix';
|
|
8
|
+
export type { ReadonlySparseMatrix, ISparseMatrix, SparseMatrixOptions, } from './data-structures/sparse-matrix';
|
|
9
|
+
export { PrefixSumArray } from './data-structures/prefix-sum-array';
|
|
10
|
+
export type { IPrefixSumArray, PrefixSumArrayOptions, } from './data-structures/prefix-sum-array';
|
|
11
|
+
export { ColumnStore } from './data-structures/column-store';
|
|
12
|
+
export type { IColumnStore, ColumnStoreOptions, ColumnDefinition, ColumnType, AggregateOperation, AggregationResult, } from './data-structures/column-store';
|
|
13
|
+
export { LRUCache } from './data-structures/lru-cache';
|
|
14
|
+
export type { ILRUCache, LRUCacheOptions, CacheEntry, CacheStats, } from './data-structures/lru-cache';
|
|
15
|
+
export { CommandStack } from './data-structures/command-stack';
|
|
16
|
+
export type { ICommandStack, ICommand, ICommandStackOptions, } from './data-structures/command-stack';
|
|
17
|
+
export { SegmentTree } from './data-structures/segment-tree';
|
|
18
|
+
export type { ISegmentTree, SegmentTreeOptions, AggregateFunction, AggregationType, } from './data-structures/segment-tree';
|
|
19
|
+
export { Aggregations, SegmentTreeUtils } from './data-structures/segment-tree';
|
|
20
|
+
export { SkipList } from './data-structures/skip-list';
|
|
21
|
+
export type { ISkipList, SkipListNode, SkipListOptions, RangeResult as SkipListRangeResult, SkipListStats, } from './data-structures/skip-list';
|
|
22
|
+
export { defaultComparator as skipListDefaultComparator, SkipListUtils } from './data-structures/skip-list';
|
|
23
|
+
export { DisjointSet } from './data-structures/disjoint-set';
|
|
24
|
+
export type { IDisjointSet, DisjointSetOptions, DisjointSetStats, } from './data-structures/disjoint-set';
|
|
25
|
+
export { DisjointSetUtils } from './data-structures/disjoint-set';
|
|
26
|
+
export { IndexMap } from './data-structures/index-map';
|
|
27
|
+
export type { IIndexMap, IndexMapEntry, IndexMapOptions, } from './data-structures/index-map';
|
|
28
|
+
export { IntervalTree } from './data-structures/interval-tree';
|
|
29
|
+
export type { IIntervalTree, Interval, IntervalData, IntervalTreeOptions, } from './data-structures/interval-tree';
|
|
30
|
+
export { IntervalUtils } from './data-structures/interval-tree';
|
|
31
|
+
export { RTree } from './data-structures/rtree';
|
|
32
|
+
export type { IRTree, RTreeData, RTreeOptions, RTreeSearchResult, RTreeStats, } from './data-structures/rtree';
|
|
33
|
+
export { Trie } from './data-structures/trie';
|
|
34
|
+
export type { ITrie, ITrieNode, TrieOptions, TrieSearchResult, } from './data-structures/trie';
|
|
35
|
+
export { DependencyGraph } from './data-structures/dependency-graph';
|
|
36
|
+
export type { IDependencyGraph, NodeId, Dependency, DependencyGraphOptions, TopologicalSortResult, GraphStats, } from './data-structures/dependency-graph';
|
|
37
|
+
export { SuffixArray } from './data-structures/suffix-array';
|
|
38
|
+
export type { ISuffixArray, SuffixArrayOptions, SuffixSearchResult, SuffixArrayStats, } from './data-structures/suffix-array';
|
|
39
|
+
export { binarySearch, binarySearchLeft, binarySearchRight, } from './algorithms/search';
|
|
40
|
+
export type { BinarySearchOptions, BinarySearchResult, } from './algorithms/search';
|
|
41
|
+
export type { Comparator, Predicate, EqualityFn, HashFn, Range, Rectangle, Point, BoundingBox, } from './types';
|
|
42
|
+
export { debounce, throttle, createRAFBatchScheduler, delay, timeout, } from './utils/timing';
|
|
43
|
+
export type { DebounceOptions, DebouncedFunction, ThrottleOptions, ThrottledFunction, RAFBatchScheduler, } from './utils/timing.interface';
|
|
44
|
+
export { EventEmitter, Subject, StateMachine, BaseCoordinator, Factory, SingletonFactory, Mediator, MediatedComponent, EventMediator, ObjectPool, KeyedObjectPool, resolveOperationMode, OperationModeManager, } from './patterns';
|
|
45
|
+
export type { IEventEmitter, IObserver, ISubject, IStateMachine, StateMachineOptions, TransitionHandler, ICoordinator, IFactory, IMediator, IObjectPool, ObjectPoolOptions, ObjectPoolStats, OperationMode, ResolvedOperationMode, OperationModeConfig, } from './patterns';
|
|
46
|
+
export declare const VERSION = "0.1.0";
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,YAAY,EACV,eAAe,EACf,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,YAAY,EACV,SAAS,EACT,eAAe,EACf,UAAU,EACV,UAAU,GACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,YAAY,EACV,aAAa,EACb,QAAQ,EACR,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,YAAY,EACV,YAAY,EACZ,kBAA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|
4
|
+
* Base class for coordinators that manage lifecycle and integration
|
|
5
|
+
* of components within a larger system.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* class SortCoordinator extends BaseCoordinator {
|
|
10
|
+
* constructor(
|
|
11
|
+
* private grid: Grid,
|
|
12
|
+
* private sortManager: SortManager
|
|
13
|
+
* ) {
|
|
14
|
+
* super();
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* protected onInitialize(): void {
|
|
18
|
+
* // Setup event listeners
|
|
19
|
+
* this.sortManager.on('sort:change', this.handleSortChange);
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* protected onCleanup(): void {
|
|
23
|
+
* // Remove event listeners
|
|
24
|
+
* this.sortManager.off('sort:change', this.handleSortChange);
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* private handleSortChange = () => {
|
|
28
|
+
* this.grid.refresh();
|
|
29
|
+
* };
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* const coordinator = new SortCoordinator(grid, sortManager);
|
|
33
|
+
* coordinator.initialize(); // Setup
|
|
34
|
+
* // ... use ...
|
|
35
|
+
* coordinator.cleanup(); // Teardown
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export interface ICoordinator {
|
|
39
|
+
/** Initialize the coordinator */
|
|
40
|
+
initialize(): void;
|
|
41
|
+
/** Cleanup and tear down the coordinator */
|
|
42
|
+
cleanup(): void;
|
|
43
|
+
/** Check if the coordinator is initialized */
|
|
44
|
+
readonly isInitialized: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Base coordinator implementation
|
|
48
|
+
*
|
|
49
|
+
* Provides lifecycle management with initialization and cleanup hooks.
|
|
50
|
+
*/
|
|
51
|
+
export declare abstract class BaseCoordinator implements ICoordinator {
|
|
52
|
+
private _initialized;
|
|
53
|
+
/**
|
|
54
|
+
* Initialize the coordinator
|
|
55
|
+
*
|
|
56
|
+
* This can be called multiple times safely - it will only
|
|
57
|
+
* initialize once until cleanup() is called.
|
|
58
|
+
*/
|
|
59
|
+
initialize(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Cleanup the coordinator
|
|
62
|
+
*
|
|
63
|
+
* This can be called multiple times safely - cleanup will only
|
|
64
|
+
* occur if the coordinator is initialized.
|
|
65
|
+
*/
|
|
66
|
+
cleanup(): void;
|
|
67
|
+
/**
|
|
68
|
+
* Check if the coordinator is initialized
|
|
69
|
+
*/
|
|
70
|
+
get isInitialized(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Hook called during initialization
|
|
73
|
+
*
|
|
74
|
+
* Subclasses should override this to perform their setup.
|
|
75
|
+
*/
|
|
76
|
+
protected abstract onInitialize(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Hook called during cleanup
|
|
79
|
+
*
|
|
80
|
+
* Subclasses should override this to perform their teardown.
|
|
81
|
+
*/
|
|
82
|
+
protected abstract onCleanup(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Assert that the coordinator is initialized
|
|
85
|
+
*
|
|
86
|
+
* Throws an error if not initialized.
|
|
87
|
+
*/
|
|
88
|
+
protected assertInitialized(): void;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../../src/shared/patterns/coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,MAAM,WAAW,YAAY;IAC3B,iCAAiC;IACjC,UAAU,IAAI,IAAI,CAAC;IAEnB,4CAA4C;IAC5C,OAAO,IAAI,IAAI,CAAC;IAEhB,8CAA8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,8BAAsB,eAAgB,YAAW,YAAY;IAC3D,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;;OAKG;IACH,UAAU,IAAI,IAAI;IAoBlB;;;;;OAKG;IACH,OAAO,IAAI,IAAI;IAiBf;;OAEG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAED;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,IAAI,IAAI;IAEvC;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,SAAS,IAAI,IAAI;IAEpC;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,IAAI,IAAI;CAOpC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe event emitter pattern
|
|
3
|
+
*
|
|
4
|
+
* Provides a strongly-typed pub/sub system for events.
|
|
5
|
+
* Supports both synchronous and asynchronous event handlers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* interface MyEvents {
|
|
10
|
+
* 'user:login': { userId: string; timestamp: number };
|
|
11
|
+
* 'user:logout': { userId: string };
|
|
12
|
+
* 'data:update': { id: number; data: any };
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* const emitter = new EventEmitter<MyEvents>();
|
|
16
|
+
*
|
|
17
|
+
* // Subscribe
|
|
18
|
+
* emitter.on('user:login', (event) => {
|
|
19
|
+
* console.log(`User ${event.userId} logged in at ${event.timestamp}`);
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Emit
|
|
23
|
+
* emitter.emit('user:login', {
|
|
24
|
+
* userId: '123',
|
|
25
|
+
* timestamp: Date.now(),
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Unsubscribe
|
|
29
|
+
* emitter.off('user:login', handler);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export interface IEventEmitter<TEvents extends Record<string, any>> {
|
|
33
|
+
on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): () => void;
|
|
34
|
+
once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): () => void;
|
|
35
|
+
off<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): void;
|
|
36
|
+
emit<K extends keyof TEvents>(event: K, data: TEvents[K]): void;
|
|
37
|
+
removeAllListeners<K extends keyof TEvents>(event?: K): void;
|
|
38
|
+
listenerCount<K extends keyof TEvents>(event: K): number;
|
|
39
|
+
eventNames(): Array<keyof TEvents>;
|
|
40
|
+
setMaxListeners(n: number): void;
|
|
41
|
+
getMaxListeners(): number;
|
|
42
|
+
}
|
|
43
|
+
export declare class EventEmitter<TEvents extends Record<string, any>> implements IEventEmitter<TEvents> {
|
|
44
|
+
private listeners;
|
|
45
|
+
private onceListeners;
|
|
46
|
+
private maxListeners;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribe to an event
|
|
49
|
+
* @param event - Event name
|
|
50
|
+
* @param handler - Event handler function
|
|
51
|
+
* @returns Unsubscribe function
|
|
52
|
+
*/
|
|
53
|
+
on<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): () => void;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to an event (fires only once)
|
|
56
|
+
* @param event - Event name
|
|
57
|
+
* @param handler - Event handler function
|
|
58
|
+
* @returns Unsubscribe function
|
|
59
|
+
*/
|
|
60
|
+
once<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Unsubscribe from an event
|
|
63
|
+
* @param event - Event name
|
|
64
|
+
* @param handler - Event handler function to remove
|
|
65
|
+
*/
|
|
66
|
+
off<K extends keyof TEvents>(event: K, handler: (data: TEvents[K]) => void): void;
|
|
67
|
+
/**
|
|
68
|
+
* Remove a once listener
|
|
69
|
+
* @param event - Event name
|
|
70
|
+
* @param handler - Event handler function to remove
|
|
71
|
+
*/
|
|
72
|
+
private offOnce;
|
|
73
|
+
/**
|
|
74
|
+
* Emit an event
|
|
75
|
+
* @param event - Event name
|
|
76
|
+
* @param data - Event data
|
|
77
|
+
*/
|
|
78
|
+
emit<K extends keyof TEvents>(event: K, data: TEvents[K]): void;
|
|
79
|
+
/**
|
|
80
|
+
* Remove all listeners for an event (or all events if no event specified)
|
|
81
|
+
* @param event - Optional event name
|
|
82
|
+
*/
|
|
83
|
+
removeAllListeners<K extends keyof TEvents>(event?: K): void;
|
|
84
|
+
/**
|
|
85
|
+
* Get the number of listeners for an event
|
|
86
|
+
* @param event - Event name
|
|
87
|
+
* @returns Number of listeners
|
|
88
|
+
*/
|
|
89
|
+
listenerCount<K extends keyof TEvents>(event: K): number;
|
|
90
|
+
/**
|
|
91
|
+
* Get all event names that have listeners
|
|
92
|
+
* @returns Array of event names
|
|
93
|
+
*/
|
|
94
|
+
eventNames(): Array<keyof TEvents>;
|
|
95
|
+
/**
|
|
96
|
+
* Set the maximum number of listeners per event
|
|
97
|
+
* @param n - Maximum number of listeners
|
|
98
|
+
*/
|
|
99
|
+
setMaxListeners(n: number): void;
|
|
100
|
+
/**
|
|
101
|
+
* Get the maximum number of listeners per event
|
|
102
|
+
* @returns Maximum number of listeners
|
|
103
|
+
*/
|
|
104
|
+
getMaxListeners(): number;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=event-emitter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-emitter.d.ts","sourceRoot":"","sources":["../../../../src/shared/patterns/event-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,aAAa,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAChE,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACvF,IAAI,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,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