@smilodon/core 1.9.3 → 1.10.1

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 (55) hide show
  1. package/README.md +140 -377
  2. package/dist/index.cjs +4030 -297
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +4014 -298
  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 +4030 -297
  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 +172 -8
  13. package/dist/types/src/components/native-select.d.ts +1 -1
  14. package/dist/types/src/components/select-option.d.ts +2 -2
  15. package/dist/types/src/config/global-config.d.ts +7 -5
  16. package/dist/types/src/data-loading/public-config.d.ts +3 -0
  17. package/dist/types/src/data-loading/public-types.d.ts +171 -0
  18. package/dist/types/src/data-loading/request-coordinator.d.ts +236 -0
  19. package/dist/types/src/engine/accessibility.d.ts +109 -0
  20. package/dist/types/src/engine/contracts.d.ts +4 -0
  21. package/dist/types/src/engine/index.d.ts +9 -0
  22. package/dist/types/src/engine/item-adapter.d.ts +23 -0
  23. package/dist/types/src/engine/item-registry.d.ts +31 -0
  24. package/dist/types/src/engine/select-effects.d.ts +20 -0
  25. package/dist/types/src/engine/select-events.d.ts +55 -0
  26. package/dist/types/src/engine/select-machine.d.ts +9 -0
  27. package/dist/types/src/engine/select-state.d.ts +17 -0
  28. package/dist/types/src/engine/selection-policy.d.ts +33 -0
  29. package/dist/types/src/engine/selectors.d.ts +10 -0
  30. package/dist/types/src/engine/virtualization.d.ts +56 -0
  31. package/dist/types/src/index.d.ts +6 -0
  32. package/dist/types/src/native-types.d.ts +5 -0
  33. package/dist/types/src/platform/web/accessibility-effects.d.ts +19 -0
  34. package/dist/types/src/platform/web/index.d.ts +2 -0
  35. package/dist/types/src/platform/web/select-effect-runner.d.ts +15 -0
  36. package/dist/types/src/platform/web/select-engine-bridge.d.ts +10 -0
  37. package/dist/types/src/renderers/contracts.d.ts +1 -1
  38. package/dist/types/src/types/limitation.d.ts +6 -0
  39. package/dist/types/src/types.d.ts +2 -6
  40. package/dist/types/src/utils/custom-option-pool.d.ts +1 -1
  41. package/dist/types/src/utils/virtualizer.d.ts +48 -1
  42. package/package.json +7 -4
  43. package/dist/types/src/themes/importer.d.ts +0 -112
  44. package/dist/types/tests/capabilities-tracking.spec.d.ts +0 -1
  45. package/dist/types/tests/csp.spec.d.ts +0 -5
  46. package/dist/types/tests/enhanced-option-renderer.spec.d.ts +0 -1
  47. package/dist/types/tests/interaction.spec.d.ts +0 -1
  48. package/dist/types/tests/lifecycle.spec.d.ts +0 -1
  49. package/dist/types/tests/memory-lifecycle.spec.d.ts +0 -1
  50. package/dist/types/tests/setup.d.ts +0 -6
  51. package/dist/types/tests/shadow-dom.spec.d.ts +0 -5
  52. package/dist/types/tests/smoke.spec.d.ts +0 -1
  53. package/dist/types/tests/stress.spec.d.ts +0 -5
  54. package/dist/types/tests/styling-contract.spec.d.ts +0 -1
  55. package/dist/types/tests/virtualizer.spec.d.ts +0 -1
@@ -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
+ }
@@ -1,4 +1,4 @@
1
- import type { RendererHelpers } from '../types';
1
+ import type { RendererHelpers } from '../types.js';
2
2
  export type OptionTemplate = (item: unknown, index: number) => string;
3
3
  export type OptionRenderer = (item: unknown, index: number, helpers: RendererHelpers) => HTMLElement;
4
4
  export declare const createRendererHelpers: (onSelect: (item: unknown, index: number) => void) => RendererHelpers;
@@ -0,0 +1,6 @@
1
+ export type KnownLimitationId = 'variableItemHeight' | 'builtInFetchPaginationApi' | 'virtualizationOverheadSmallLists' | 'runtimeModeSwitching' | 'legacyBrowserSupport' | 'webkitArchLinux';
2
+ export type LimitationControlMode = 'default' | 'suppress' | 'strict';
3
+ export interface LimitationPolicy {
4
+ mode: LimitationControlMode;
5
+ note?: string;
6
+ }
@@ -1,3 +1,5 @@
1
+ import type { KnownLimitationId, LimitationControlMode, LimitationPolicy } from './types/limitation.js';
2
+ export type { KnownLimitationId, LimitationControlMode, LimitationPolicy } from './types/limitation.js';
1
3
  export type Placement = 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end';
2
4
  export type Strategy = 'fixed' | 'absolute';
3
5
  export interface GroupedItem {
@@ -64,12 +66,6 @@ export interface ClearEventDetail {
64
66
  clearedSelection: boolean;
65
67
  clearedSearch: boolean;
66
68
  }
67
- export type KnownLimitationId = 'variableItemHeight' | 'builtInFetchPaginationApi' | 'virtualizationOverheadSmallLists' | 'runtimeModeSwitching' | 'legacyBrowserSupport' | 'webkitArchLinux';
68
- export type LimitationControlMode = 'default' | 'suppress' | 'strict';
69
- export interface LimitationPolicy {
70
- mode: LimitationControlMode;
71
- note?: string;
72
- }
73
69
  export type LimitationPolicyMap = Partial<Record<KnownLimitationId, LimitationPolicy>>;
74
70
  export interface LimitationState {
75
71
  id: KnownLimitationId;
@@ -4,7 +4,7 @@
4
4
  * Manages lifecycle and recycling of custom option components for optimal performance.
5
5
  * Uses object pooling pattern to minimize allocation/deallocation overhead.
6
6
  */
7
- import type { CustomOptionContract, CustomOptionContext, CustomOptionFactory } from '../types/custom-option';
7
+ import type { CustomOptionContract, CustomOptionContext, CustomOptionFactory } from '../types/custom-option.js';
8
8
  /**
9
9
  * Manages a pool of reusable custom option component instances
10
10
  */
@@ -6,30 +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;
19
40
  private destroyed;
20
41
  private recycleRafId;
42
+ private intendedScrollTop;
43
+ private currentWindow;
21
44
  constructor(container: HTMLElement, itemsLength: number, itemGetter: ItemGetter, options: VirtualizerOptions);
22
45
  computeWindow(scrollTop: number, viewportHeight: number): {
23
46
  startIndex: number;
24
47
  endIndex: number;
25
48
  windowSize: number;
26
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;
27
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;
28
71
  acquireNode(index: number): HTMLElement;
29
72
  releaseNode(index: number): void;
30
73
  releaseExcess(activeIndices: Set<number>): void;
31
74
  render(startIndex: number, endIndex: number, updateNode: (node: HTMLElement, item: unknown, index: number) => void): void;
32
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;
33
78
  /**
34
79
  * Get pool statistics (if telemetry enabled)
35
80
  */
@@ -51,5 +96,7 @@ export declare class Virtualizer {
51
96
  * Cleanup resources
52
97
  */
53
98
  destroy(): void;
99
+ private updateAverageHeight;
100
+ private createFenwickTree;
54
101
  }
55
102
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smilodon/core",
3
- "version": "1.9.3",
3
+ "version": "1.10.1",
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",
@@ -12,6 +12,9 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./native-types": {
16
+ "types": "./dist/types/src/native-types.d.ts"
17
+ },
15
18
  "./package.json": "./package.json"
16
19
  },
17
20
  "files": [
@@ -19,7 +22,7 @@
19
22
  "README.md"
20
23
  ],
21
24
  "scripts": {
22
- "build": "rollup -c && tsc --emitDeclarationOnly --outDir dist/types",
25
+ "build": "rollup -c && tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",
23
26
  "dev": "rollup -c --watch",
24
27
  "test": "vitest run",
25
28
  "test:watch": "vitest",
@@ -56,12 +59,12 @@
56
59
  },
57
60
  "devDependencies": {
58
61
  "@rollup/plugin-node-resolve": "^15.2.3",
59
- "@rollup/plugin-terser": "^0.4.4",
62
+ "@rollup/plugin-terser": "^1.0.2",
60
63
  "@rollup/plugin-typescript": "^11.1.6",
61
64
  "jsdom": "^24.0.0",
62
65
  "rollup": "^4.9.0",
63
66
  "typescript": "^5.6.2",
64
- "vitest": "^1.6.0"
67
+ "vitest": "4.1.12"
65
68
  },
66
69
  "sideEffects": [
67
70
  "./src/components/enhanced-select.ts",
@@ -1,112 +0,0 @@
1
- /**
2
- * Design Token Importer
3
- * Convert design tokens from Figma, Adobe XD, and other design tools to CSS variables
4
- *
5
- * Supports:
6
- * - Figma Variables API
7
- * - Adobe XD Design Tokens
8
- * - Design Tokens Format (W3C Community Group spec)
9
- * - Style Dictionary format
10
- *
11
- * Usage:
12
- * import { importTokens, applyTokens } from '@smilodon/core/themes/importer';
13
- *
14
- * const tokens = await importTokens('figma', figmaData);
15
- * applyTokens(selectElement, tokens);
16
- */
17
- /**
18
- * Design token types
19
- */
20
- export interface DesignToken {
21
- $type?: string;
22
- $value: string | number | DesignToken;
23
- $description?: string;
24
- }
25
- export interface DesignTokens {
26
- [key: string]: DesignToken | DesignTokens;
27
- }
28
- export interface CSSVariable {
29
- name: string;
30
- value: string;
31
- category?: string;
32
- description?: string;
33
- }
34
- /**
35
- * Import design tokens from various sources
36
- */
37
- export declare function importTokens(source: 'figma' | 'adobe-xd' | 'tokens-studio' | 'style-dictionary' | 'json', data: any): Promise<Map<string, CSSVariable>>;
38
- /**
39
- * Import Figma Variables API format
40
- *
41
- * Example Figma export:
42
- * {
43
- * "colors": {
44
- * "primary": { "$type": "color", "$value": "#007aff" },
45
- * "background": { "$type": "color", "$value": "#ffffff" }
46
- * },
47
- * "spacing": {
48
- * "sm": { "$type": "dimension", "$value": "8px" }
49
- * }
50
- * }
51
- */
52
- export declare function importFigmaTokens(data: any): Map<string, CSSVariable>;
53
- /**
54
- * Import Adobe XD design tokens
55
- *
56
- * Example Adobe XD export:
57
- * {
58
- * "colors": [
59
- * { "name": "Primary Blue", "value": "#007aff" }
60
- * ],
61
- * "textStyles": [
62
- * { "name": "Body", "fontSize": 16, "fontFamily": "SF Pro" }
63
- * ]
64
- * }
65
- */
66
- export declare function importAdobeXDTokens(data: any): Map<string, CSSVariable>;
67
- /**
68
- * Import Tokens Studio (Figma plugin) format
69
- */
70
- export declare function importTokensStudioTokens(data: any): Map<string, CSSVariable>;
71
- /**
72
- * Import Style Dictionary format
73
- *
74
- * Example:
75
- * {
76
- * "color": {
77
- * "primary": { "value": "#007aff" }
78
- * }
79
- * }
80
- */
81
- export declare function importStyleDictionaryTokens(data: any): Map<string, CSSVariable>;
82
- /**
83
- * Import generic JSON token format
84
- */
85
- export declare function importGenericTokens(data: any): Map<string, CSSVariable>;
86
- /**
87
- * Apply CSS variables to an element
88
- */
89
- export declare function applyTokens(element: HTMLElement, tokens: Map<string, CSSVariable>, options?: {
90
- prefix?: string;
91
- scope?: 'element' | 'root';
92
- }): void;
93
- /**
94
- * Generate CSS stylesheet from tokens
95
- */
96
- export declare function generateCSS(tokens: Map<string, CSSVariable>, options?: {
97
- selector?: string;
98
- groupByCategory?: boolean;
99
- includeComments?: boolean;
100
- }): string;
101
- /**
102
- * Export tokens to various formats
103
- */
104
- export declare function exportTokens(tokens: Map<string, CSSVariable>, format: 'css' | 'json' | 'scss' | 'js' | 'ts'): string;
105
- /**
106
- * CLI tool for token conversion
107
- *
108
- * Usage:
109
- * npx @smilodon/tokens import figma tokens.json --output theme.css
110
- * npx @smilodon/tokens import adobe-xd design.json --output vars.css
111
- */
112
- export declare function cli(args: string[]): Promise<void>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * CSP (Content Security Policy) compliance test suite.
3
- * Verifies the library works in CSP-restricted environments.
4
- */
5
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Test setup - runs before all tests
3
- */
4
- import '../src/components/native-select';
5
- import '../src/components/enhanced-select';
6
- import '../src/components/select-option';
@@ -1,5 +0,0 @@
1
- /**
2
- * Shadow DOM security and isolation tests.
3
- * Tests closed shadow roots, nested embeddings, and isolation boundaries.
4
- */
5
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,5 +0,0 @@
1
- /**
2
- * Stress tests for extreme scale performance validation.
3
- * Tests 1M+ items, heavy transforms, worker offloading.
4
- */
5
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};