@smilodon/core 1.9.2 → 1.10.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.
Files changed (52) hide show
  1. package/README.md +10 -6
  2. package/dist/index.cjs +2488 -436
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +2473 -437
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.map +1 -1
  8. package/dist/index.umd.js +2488 -436
  9. package/dist/index.umd.js.map +1 -1
  10. package/dist/index.umd.min.js +1 -1
  11. package/dist/index.umd.min.js.map +1 -1
  12. package/dist/types/src/components/enhanced-select.d.ts +114 -1
  13. package/dist/types/src/components/native-select.d.ts +2 -1
  14. package/dist/types/src/config/global-config.d.ts +2 -2
  15. package/dist/types/src/engine/accessibility.d.ts +109 -0
  16. package/dist/types/src/engine/contracts.d.ts +4 -0
  17. package/dist/types/src/engine/index.d.ts +9 -0
  18. package/dist/types/src/engine/item-adapter.d.ts +23 -0
  19. package/dist/types/src/engine/item-registry.d.ts +31 -0
  20. package/dist/types/src/engine/select-effects.d.ts +20 -0
  21. package/dist/types/src/engine/select-events.d.ts +55 -0
  22. package/dist/types/src/engine/select-machine.d.ts +9 -0
  23. package/dist/types/src/engine/select-state.d.ts +17 -0
  24. package/dist/types/src/engine/selection-policy.d.ts +33 -0
  25. package/dist/types/src/engine/selectors.d.ts +10 -0
  26. package/dist/types/src/engine/virtualization.d.ts +56 -0
  27. package/dist/types/src/index.d.ts +4 -0
  28. package/dist/types/src/platform/web/accessibility-effects.d.ts +19 -0
  29. package/dist/types/src/platform/web/index.d.ts +2 -0
  30. package/dist/types/src/platform/web/select-effect-runner.d.ts +15 -0
  31. package/dist/types/src/platform/web/select-engine-bridge.d.ts +10 -0
  32. package/dist/types/src/utils/custom-option-pool.d.ts +3 -4
  33. package/dist/types/src/utils/data-source.d.ts +7 -2
  34. package/dist/types/src/utils/dom-pool.d.ts +1 -0
  35. package/dist/types/src/utils/telemetry.d.ts +2 -2
  36. package/dist/types/src/utils/virtualizer.d.ts +50 -1
  37. package/dist/types/tests/accessibility-contract.spec.d.ts +1 -0
  38. package/dist/types/tests/enhanced-select-accessibility-integration.spec.d.ts +1 -0
  39. package/dist/types/tests/enhanced-select-active-authority.spec.d.ts +1 -0
  40. package/dist/types/tests/enhanced-select-active-parity.spec.d.ts +1 -0
  41. package/dist/types/tests/enhanced-select-authority.spec.d.ts +1 -0
  42. package/dist/types/tests/enhanced-select-compatibility-projection.spec.d.ts +1 -0
  43. package/dist/types/tests/enhanced-select-selection-parity.spec.d.ts +1 -0
  44. package/dist/types/tests/enhanced-select-virtualization-integration.spec.d.ts +1 -0
  45. package/dist/types/tests/item-adapter.spec.d.ts +1 -0
  46. package/dist/types/tests/item-registry.spec.d.ts +1 -0
  47. package/dist/types/tests/memory-lifecycle.spec.d.ts +1 -0
  48. package/dist/types/tests/select-accessibility.spec.d.ts +1 -0
  49. package/dist/types/tests/select-selection.spec.d.ts +1 -0
  50. package/dist/types/tests/virtualization-contract.spec.d.ts +1 -0
  51. package/dist/types/tests/web-accessibility-effects.spec.d.ts +1 -0
  52. package/package.json +3 -3
@@ -0,0 +1,2 @@
1
+ export * from './select-engine-bridge.js';
2
+ export * from './select-effect-runner.js';
@@ -0,0 +1,15 @@
1
+ import type { SelectEffect } from '../../engine/select-effects.js';
2
+ export interface WebSelectContext {
3
+ focusTrigger?: () => void;
4
+ syncAria?: () => void;
5
+ onPopupOpened?: () => void;
6
+ onPopupClosed?: (reason: Extract<SelectEffect, {
7
+ type: 'POPUP_CLOSED';
8
+ }>['reason']) => void;
9
+ }
10
+ export interface SelectEffectRunner {
11
+ run(effects: readonly SelectEffect[], context: WebSelectContext): void;
12
+ }
13
+ export declare class DefaultSelectEffectRunner implements SelectEffectRunner {
14
+ run(effects: readonly SelectEffect[], context: WebSelectContext): void;
15
+ }
@@ -0,0 +1,10 @@
1
+ import type { SelectKey } from '../../engine/contracts.js';
2
+ import type { SelectEffect } from '../../engine/select-effects.js';
3
+ import type { SelectEvent } from '../../engine/select-events.js';
4
+ import type { SelectState } from '../../engine/select-state.js';
5
+ export declare class SelectEngineBridge<K extends SelectKey = SelectKey> {
6
+ private _state;
7
+ constructor(initialState?: SelectState<K>);
8
+ get state(): SelectState<K>;
9
+ dispatch(event: SelectEvent<K>): SelectEffect<K>[];
10
+ }
@@ -71,8 +71,7 @@ export declare class CustomOptionPool {
71
71
  * Find an available component in the pool
72
72
  */
73
73
  private _findAvailableComponent;
74
- /**
75
- * Generate a unique key for a factory function
76
- */
77
- private _getFactoryKey;
74
+ private _addToPool;
75
+ private _evictAvailableComponent;
76
+ private _getTotalPooled;
78
77
  }
@@ -12,10 +12,14 @@ export interface FetchResult<T> {
12
12
  }
13
13
  export declare class TTLCache<T> {
14
14
  private defaultTTL;
15
+ private maxEntries;
15
16
  private store;
16
- constructor(defaultTTL?: number);
17
+ constructor(defaultTTL?: number, maxEntries?: number);
17
18
  get(key: string): T[] | null;
18
19
  set(key: string, items: T[], ttl?: number): void;
20
+ clear(): void;
21
+ private pruneExpired;
22
+ private pruneToMaxEntries;
19
23
  }
20
24
  export declare class LocalSource<T = unknown> {
21
25
  private items;
@@ -32,6 +36,7 @@ export declare class RemoteSource<T = unknown> {
32
36
  private key;
33
37
  fetchPage(query: string, page: number): Promise<FetchResult<T>>;
34
38
  refresh(query: string, page: number): Promise<void>;
35
- getPage(page: number): T[] | null;
39
+ getPage(page: number, query?: string): T[] | null;
40
+ destroy(): void;
36
41
  }
37
42
  export declare function debounce<T extends (...args: any[]) => void>(fn: T, ms: number): (...args: Parameters<T>) => void;
@@ -43,6 +43,7 @@ export declare class DOMPool {
43
43
  * Complexity: O(n)
44
44
  */
45
45
  private evictLRU;
46
+ private removePoolNode;
46
47
  /**
47
48
  * Default reset: clear content, remove inline styles, remove attributes
48
49
  */
@@ -31,8 +31,8 @@ export declare class PerformanceTelemetry {
31
31
  private rafId;
32
32
  private measuring;
33
33
  private observer;
34
- private workTimes;
35
- constructor();
34
+ private workTotal;
35
+ private workCount;
36
36
  /**
37
37
  * Setup PerformanceObserver for long tasks
38
38
  */
@@ -6,28 +6,75 @@ export interface VirtualizerOptions {
6
6
  measurementThreshold?: number;
7
7
  enableTelemetry?: boolean;
8
8
  }
9
+ export interface VirtualizerScrollResult {
10
+ /** Clamped target index in the current item set. */
11
+ index: number;
12
+ /** Prefix-sum offset for the target item. */
13
+ offset: number;
14
+ /** Intended container scrollTop; the caller owns applying it to the DOM. */
15
+ scrollTop: number;
16
+ }
17
+ export interface VirtualizerWindow {
18
+ startIndex: number;
19
+ endIndex: number;
20
+ windowSize: number;
21
+ }
22
+ export interface VirtualizerWindowUpdate {
23
+ window: VirtualizerWindow;
24
+ changed: boolean;
25
+ scrollTop: number;
26
+ viewportHeight: number;
27
+ }
9
28
  export declare class Virtualizer {
10
29
  private container;
11
30
  private itemsLength;
12
31
  private options;
32
+ private readonly estimatedItemHeight;
13
33
  measuredHeights: Map<number, number>;
34
+ private measuredHeightTotal;
14
35
  averageHeight: number;
15
36
  private pool;
16
37
  private itemGetter;
17
- private fenwick?;
38
+ private fenwick;
18
39
  private activeNodes;
40
+ private destroyed;
41
+ private recycleRafId;
42
+ private intendedScrollTop;
43
+ private currentWindow;
19
44
  constructor(container: HTMLElement, itemsLength: number, itemGetter: ItemGetter, options: VirtualizerOptions);
20
45
  computeWindow(scrollTop: number, viewportHeight: number): {
21
46
  startIndex: number;
22
47
  endIndex: number;
23
48
  windowSize: number;
24
49
  };
50
+ /** Computes and records a scroll-derived window without installing listeners. */
51
+ updateWindow(scrollTop: number, viewportHeight: number): VirtualizerWindowUpdate | null;
52
+ /** Returns a copy of the last recorded window, or null before the first update. */
53
+ getCurrentWindow(): VirtualizerWindow | null;
54
+ /** Finds the item containing an offset, advancing past exact item boundaries. */
55
+ private indexAtOffset;
25
56
  cumulativeOffset(index: number): number;
57
+ /**
58
+ * Calculates and records the intended scroll position for an item without
59
+ * mutating the container. The caller may apply the returned scrollTop.
60
+ * Returns null after destruction or when there are no items to target.
61
+ */
62
+ scrollToIndex(index: number): VirtualizerScrollResult | null;
63
+ /**
64
+ * Resolves a stable key against the caller's current data identity, then
65
+ * delegates to scrollToIndex(). Invalid or out-of-range resolutions are
66
+ * rejected rather than clamped to a different item's position.
67
+ */
68
+ scrollToKey<TKey>(key: TKey, resolveIndex: (key: TKey) => number | null | undefined): VirtualizerScrollResult | null;
69
+ /** Returns the last scroll position requested through scrollToIndex(). */
70
+ getIntendedScrollTop(): number;
26
71
  acquireNode(index: number): HTMLElement;
27
72
  releaseNode(index: number): void;
28
73
  releaseExcess(activeIndices: Set<number>): void;
29
74
  render(startIndex: number, endIndex: number, updateNode: (node: HTMLElement, item: unknown, index: number) => void): void;
30
75
  measureOnAppear(node: HTMLElement, index: number): void;
76
+ /** Records a validated measured height and updates the virtual offset index. */
77
+ measureItem(index: number, height: number): boolean;
31
78
  /**
32
79
  * Get pool statistics (if telemetry enabled)
33
80
  */
@@ -49,5 +96,7 @@ export declare class Virtualizer {
49
96
  * Cleanup resources
50
97
  */
51
98
  destroy(): void;
99
+ private updateAverageHeight;
100
+ private createFenwickTree;
52
101
  }
53
102
  export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smilodon/core",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "High-performance native select component with extreme-scale virtualization - React, Vue, Svelte, Vanilla JS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -58,10 +58,10 @@
58
58
  "@rollup/plugin-node-resolve": "^15.2.3",
59
59
  "@rollup/plugin-terser": "^0.4.4",
60
60
  "@rollup/plugin-typescript": "^11.1.6",
61
+ "jsdom": "^24.0.0",
61
62
  "rollup": "^4.9.0",
62
63
  "typescript": "^5.6.2",
63
- "vitest": "^1.6.0",
64
- "jsdom": "^24.0.0"
64
+ "vitest": "^1.6.0"
65
65
  },
66
66
  "sideEffects": [
67
67
  "./src/components/enhanced-select.ts",