modern-cmdk 1.2.1 → 1.2.3
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/README.md +9 -5
- package/dist/codemod/cli.d.mts +1 -1
- package/dist/codemod/cli.mjs +14677 -61044
- package/dist/codemod/transforms/data-attrs.d.mts +4 -8
- package/dist/codemod/transforms/data-attrs.mjs +1 -2
- package/dist/codemod/transforms/forward-ref.d.mts +4 -8
- package/dist/codemod/transforms/forward-ref.mjs +1 -2
- package/dist/codemod/transforms/import-rewrite.d.mts +4 -8
- package/dist/codemod/transforms/import-rewrite.mjs +1 -2
- package/dist/codemod/transforms/should-filter.d.mts +3 -7
- package/dist/codemod/transforms/should-filter.mjs +1 -2
- package/dist/core/index.d.mts +149 -181
- package/dist/core/index.mjs +42 -47
- package/dist/react/index.d.mts +78 -217
- package/dist/react/index.mjs +141 -166
- package/package.json +8 -8
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { API, FileInfo } from "jscodeshift";
|
|
2
|
-
|
|
3
|
-
//#region src/codemod/transforms/data-attrs.d.ts
|
|
4
2
|
/**
|
|
5
|
-
* jscodeshift transform — renames cmdk data attributes in JSX and
|
|
6
|
-
* CSS selectors within string/template literals.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { transform as default };
|
|
3
|
+
* jscodeshift transform — renames cmdk data attributes in JSX and
|
|
4
|
+
* CSS selectors within string/template literals.
|
|
5
|
+
*/
|
|
6
|
+
export default function transform(fileInfo: FileInfo, api: API): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/codemod/transforms/data-attrs.ts
|
|
2
2
|
/** Mapping from old bare attribute names to new data-attribute names */
|
|
3
3
|
const ATTR_MAP = /* @__PURE__ */ new Map([
|
|
4
4
|
["cmdk-root", "data-command"],
|
|
@@ -62,5 +62,4 @@ function transform(fileInfo, api) {
|
|
|
62
62
|
});
|
|
63
63
|
return hasChanges ? root.toSource() : fileInfo.source;
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { transform as default };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { API, FileInfo } from "jscodeshift";
|
|
2
|
-
|
|
3
|
-
//#region src/codemod/transforms/forward-ref.d.ts
|
|
4
2
|
/**
|
|
5
|
-
* jscodeshift transform — removes forwardRef wrappers and merges the
|
|
6
|
-
* ref parameter into the props object as a regular prop.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { transform as default };
|
|
3
|
+
* jscodeshift transform — removes forwardRef wrappers and merges the
|
|
4
|
+
* ref parameter into the props object as a regular prop.
|
|
5
|
+
*/
|
|
6
|
+
export default function transform(fileInfo: FileInfo, api: API): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/codemod/transforms/forward-ref.ts
|
|
2
2
|
/**
|
|
3
3
|
* jscodeshift transform — removes forwardRef wrappers and merges the
|
|
4
4
|
* ref parameter into the props object as a regular prop.
|
|
@@ -47,5 +47,4 @@ function transform(fileInfo, api) {
|
|
|
47
47
|
}
|
|
48
48
|
return hasChanges ? root.toSource() : fileInfo.source;
|
|
49
49
|
}
|
|
50
|
-
//#endregion
|
|
51
50
|
export { transform as default };
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { API, FileInfo } from "jscodeshift";
|
|
2
|
-
|
|
3
|
-
//#region src/codemod/transforms/import-rewrite.d.ts
|
|
4
2
|
/**
|
|
5
|
-
* jscodeshift transform — rewrites all import/require/re-export paths
|
|
6
|
-
* from `cmdk` to `modern-cmdk/react`.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
//#endregion
|
|
10
|
-
export { transform as default };
|
|
3
|
+
* jscodeshift transform — rewrites all import/require/re-export paths
|
|
4
|
+
* from `cmdk` to `modern-cmdk/react`.
|
|
5
|
+
*/
|
|
6
|
+
export default function transform(fileInfo: FileInfo, api: API): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/codemod/transforms/import-rewrite.ts
|
|
2
2
|
const OLD_PACKAGE = "cmdk";
|
|
3
3
|
const NEW_PACKAGE = "modern-cmdk/react";
|
|
4
4
|
/**
|
|
@@ -39,5 +39,4 @@ function transform(fileInfo, api) {
|
|
|
39
39
|
});
|
|
40
40
|
return hasChanges ? root.toSource() : fileInfo.source;
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { transform as default };
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { API, FileInfo } from "jscodeshift";
|
|
2
|
-
|
|
3
|
-
//#region src/codemod/transforms/should-filter.d.ts
|
|
4
2
|
/**
|
|
5
|
-
* jscodeshift transform — migrates shouldFilter prop to filter.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { transform as default };
|
|
3
|
+
* jscodeshift transform — migrates shouldFilter prop to filter.
|
|
4
|
+
*/
|
|
5
|
+
export default function transform(fileInfo: FileInfo, api: API): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/codemod/transforms/should-filter.ts
|
|
2
2
|
/**
|
|
3
3
|
* jscodeshift transform — migrates shouldFilter prop to filter.
|
|
4
4
|
*/
|
|
@@ -15,5 +15,4 @@ function transform(fileInfo, api) {
|
|
|
15
15
|
});
|
|
16
16
|
return hasChanges ? root.toSource() : fileInfo.source;
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { transform as default };
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/search/types.d.ts
|
|
2
1
|
/** Result of scoring a single item against a query */
|
|
3
2
|
interface SearchResult {
|
|
4
3
|
readonly id: ItemId;
|
|
@@ -21,38 +20,36 @@ interface SearchEngine extends Disposable {
|
|
|
21
20
|
/** Dispose resources */
|
|
22
21
|
[Symbol.dispose](): void;
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/core/types.d.ts
|
|
26
23
|
/**
|
|
27
|
-
* Branded type for command item IDs.
|
|
28
|
-
* Prevents accidental mixing with plain strings at the type level.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const id = itemId('copy');
|
|
33
|
-
* // id has type ItemId, not string — catches type errors at compile time
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
24
|
+
* Branded type for command item IDs.
|
|
25
|
+
* Prevents accidental mixing with plain strings at the type level.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const id = itemId('copy');
|
|
30
|
+
* // id has type ItemId, not string — catches type errors at compile time
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
36
33
|
declare const __itemIdBrand: unique symbol;
|
|
37
34
|
type ItemId = string & {
|
|
38
35
|
readonly [__itemIdBrand]: never;
|
|
39
36
|
};
|
|
40
37
|
/**
|
|
41
|
-
* Branded type for group IDs.
|
|
42
|
-
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
43
|
-
*/
|
|
38
|
+
* Branded type for group IDs.
|
|
39
|
+
* Prevents accidental mixing with plain strings or ItemId at the type level.
|
|
40
|
+
*/
|
|
44
41
|
declare const __groupIdBrand: unique symbol;
|
|
45
42
|
type GroupId = string & {
|
|
46
43
|
readonly [__groupIdBrand]: never;
|
|
47
44
|
};
|
|
48
45
|
/** Create a branded {@link ItemId} from a plain string. Ensures well-formed Unicode. */
|
|
49
|
-
declare function itemId(id: string): ItemId;
|
|
46
|
+
export declare function itemId(id: string): ItemId;
|
|
50
47
|
/** Create a branded {@link GroupId} from a plain string. Ensures well-formed Unicode. */
|
|
51
|
-
declare function groupId(id: string): GroupId;
|
|
48
|
+
export declare function groupId(id: string): GroupId;
|
|
52
49
|
/**
|
|
53
|
-
* A registered command item in the palette.
|
|
54
|
-
* All fields are readonly — state machine creates new items on update.
|
|
55
|
-
*/
|
|
50
|
+
* A registered command item in the palette.
|
|
51
|
+
* All fields are readonly — state machine creates new items on update.
|
|
52
|
+
*/
|
|
56
53
|
interface CommandItem {
|
|
57
54
|
/** Unique identifier (branded type) */
|
|
58
55
|
readonly id: ItemId;
|
|
@@ -72,9 +69,9 @@ interface CommandItem {
|
|
|
72
69
|
readonly data?: Readonly<Record<string, unknown>> | undefined;
|
|
73
70
|
}
|
|
74
71
|
/**
|
|
75
|
-
* A command group for categorizing items.
|
|
76
|
-
* Groups are rendered with headings and sorted by priority.
|
|
77
|
-
*/
|
|
72
|
+
* A command group for categorizing items.
|
|
73
|
+
* Groups are rendered with headings and sorted by priority.
|
|
74
|
+
*/
|
|
78
75
|
interface CommandGroup {
|
|
79
76
|
/** Unique identifier (branded type) */
|
|
80
77
|
readonly id: GroupId;
|
|
@@ -84,10 +81,10 @@ interface CommandGroup {
|
|
|
84
81
|
readonly priority?: number | undefined;
|
|
85
82
|
}
|
|
86
83
|
/**
|
|
87
|
-
* Immutable state snapshot of the command palette.
|
|
88
|
-
* Consumed by React via `useSyncExternalStore` — each mutation
|
|
89
|
-
* produces a new object reference for efficient re-render detection.
|
|
90
|
-
*/
|
|
84
|
+
* Immutable state snapshot of the command palette.
|
|
85
|
+
* Consumed by React via `useSyncExternalStore` — each mutation
|
|
86
|
+
* produces a new object reference for efficient re-render detection.
|
|
87
|
+
*/
|
|
91
88
|
interface CommandState {
|
|
92
89
|
/** Current search query string */
|
|
93
90
|
readonly search: string;
|
|
@@ -181,7 +178,7 @@ interface FrecencyOptions {
|
|
|
181
178
|
readonly decayConfig?: FrecencyDecayConfig | undefined;
|
|
182
179
|
}
|
|
183
180
|
/** Default frecency decay configuration */
|
|
184
|
-
declare const DEFAULT_FRECENCY_DECAY: Required<FrecencyDecayConfig>;
|
|
181
|
+
export declare const DEFAULT_FRECENCY_DECAY: Required<FrecencyDecayConfig>;
|
|
185
182
|
/** Options for creating a command machine — const type param for narrowed option inference */
|
|
186
183
|
interface CommandMachineOptions {
|
|
187
184
|
/** Pre-registered items to populate on creation */
|
|
@@ -212,34 +209,32 @@ interface CommandMachineOptions {
|
|
|
212
209
|
readonly virtualizeThreshold?: number | undefined;
|
|
213
210
|
}
|
|
214
211
|
/** Default machine options */
|
|
215
|
-
declare const DEFAULT_MACHINE_OPTIONS: Partial<CommandMachineOptions>;
|
|
212
|
+
export declare const DEFAULT_MACHINE_OPTIONS: Partial<CommandMachineOptions>;
|
|
216
213
|
/** Initial state factory */
|
|
217
|
-
declare function createInitialState(options?: CommandMachineOptions): CommandState;
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/core/frecency/idb-storage.d.ts
|
|
214
|
+
export declare function createInitialState(options?: CommandMachineOptions): CommandState;
|
|
220
215
|
/**
|
|
221
|
-
* IndexedDB-backed frecency storage using idb-keyval 6.2.2.
|
|
222
|
-
*
|
|
223
|
-
* Persists frecency data across browser sessions. Implements both
|
|
224
|
-
* `Disposable` and `AsyncDisposable` for use with `using` and `await using`.
|
|
225
|
-
*
|
|
226
|
-
* idb-keyval is lazy-loaded on first method call — consumers who import
|
|
227
|
-
* the core module without using IDB frecency pay zero cost.
|
|
228
|
-
*
|
|
229
|
-
* @example
|
|
230
|
-
* ```ts
|
|
231
|
-
* await using storage = new IdbFrecencyStorage();
|
|
232
|
-
* const data = await storage.load('my-app');
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare class IdbFrecencyStorage implements FrecencyStorage, AsyncDisposable {
|
|
216
|
+
* IndexedDB-backed frecency storage using idb-keyval 6.2.2.
|
|
217
|
+
*
|
|
218
|
+
* Persists frecency data across browser sessions. Implements both
|
|
219
|
+
* `Disposable` and `AsyncDisposable` for use with `using` and `await using`.
|
|
220
|
+
*
|
|
221
|
+
* idb-keyval is lazy-loaded on first method call — consumers who import
|
|
222
|
+
* the core module without using IDB frecency pay zero cost.
|
|
223
|
+
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* await using storage = new IdbFrecencyStorage();
|
|
227
|
+
* const data = await storage.load('my-app');
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
export declare class IdbFrecencyStorage implements FrecencyStorage, AsyncDisposable {
|
|
236
231
|
#private;
|
|
237
232
|
/**
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
* Create an IDB-backed frecency storage.
|
|
234
|
+
*
|
|
235
|
+
* @param dbName — IndexedDB database name (default: 'modern-cmdk')
|
|
236
|
+
* @param storeName — IndexedDB object store name (default: 'frecency')
|
|
237
|
+
*/
|
|
243
238
|
constructor(dbName?: string, storeName?: string);
|
|
244
239
|
/** Load frecency data from IndexedDB for the given namespace */
|
|
245
240
|
load(namespace: string): Promise<FrecencyData>;
|
|
@@ -252,20 +247,18 @@ declare class IdbFrecencyStorage implements FrecencyStorage, AsyncDisposable {
|
|
|
252
247
|
/** Async dispose — marks as disposed, suitable for `await using` */
|
|
253
248
|
[Symbol.asyncDispose](): Promise<void>;
|
|
254
249
|
}
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/core/frecency/index.d.ts
|
|
257
250
|
/**
|
|
258
|
-
* Computes a frecency bonus for an item based on usage frequency and recency.
|
|
259
|
-
* Uses hour/day/week/month bucket boundaries with
|
|
260
|
-
* configurable exponential decay weights per time bucket.
|
|
261
|
-
*/
|
|
262
|
-
declare function computeFrecencyBonus(history: FrecencyRecord, now?: number, config?: FrecencyDecayConfig): number;
|
|
251
|
+
* Computes a frecency bonus for an item based on usage frequency and recency.
|
|
252
|
+
* Uses hour/day/week/month bucket boundaries with
|
|
253
|
+
* configurable exponential decay weights per time bucket.
|
|
254
|
+
*/
|
|
255
|
+
export declare function computeFrecencyBonus(history: FrecencyRecord, now?: number, config?: FrecencyDecayConfig): number;
|
|
263
256
|
/**
|
|
264
|
-
* Stateful frecency engine that tracks item selection history and provides
|
|
265
|
-
* ranking boosts for search results. Supports pluggable storage backends
|
|
266
|
-
* and automatic flush on dispose. Uses Date.now() for timestamps.
|
|
267
|
-
*/
|
|
268
|
-
declare class FrecencyEngine implements Disposable, AsyncDisposable {
|
|
257
|
+
* Stateful frecency engine that tracks item selection history and provides
|
|
258
|
+
* ranking boosts for search results. Supports pluggable storage backends
|
|
259
|
+
* and automatic flush on dispose. Uses Date.now() for timestamps.
|
|
260
|
+
*/
|
|
261
|
+
export declare class FrecencyEngine implements Disposable, AsyncDisposable {
|
|
269
262
|
#private;
|
|
270
263
|
constructor(options: FrecencyOptions);
|
|
271
264
|
/** Load frecency data from storage */
|
|
@@ -288,14 +281,12 @@ declare class FrecencyEngine implements Disposable, AsyncDisposable {
|
|
|
288
281
|
[Symbol.asyncDispose](): Promise<void>;
|
|
289
282
|
[Symbol.dispose](): void;
|
|
290
283
|
}
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region src/core/frecency/memory-storage.d.ts
|
|
293
284
|
/**
|
|
294
|
-
* In-memory implementation of FrecencyStorage using a Map.
|
|
295
|
-
* Data does not persist across page reloads. Suitable for ephemeral
|
|
296
|
-
* sessions or as the default when no persistent storage is configured.
|
|
297
|
-
*/
|
|
298
|
-
declare class MemoryFrecencyStorage implements FrecencyStorage {
|
|
285
|
+
* In-memory implementation of FrecencyStorage using a Map.
|
|
286
|
+
* Data does not persist across page reloads. Suitable for ephemeral
|
|
287
|
+
* sessions or as the default when no persistent storage is configured.
|
|
288
|
+
*/
|
|
289
|
+
export declare class MemoryFrecencyStorage implements FrecencyStorage {
|
|
299
290
|
#private;
|
|
300
291
|
load(namespace: string): FrecencyData;
|
|
301
292
|
save(namespace: string, data: FrecencyData): void;
|
|
@@ -305,12 +296,10 @@ declare class MemoryFrecencyStorage implements FrecencyStorage {
|
|
|
305
296
|
}>;
|
|
306
297
|
[Symbol.dispose](): void;
|
|
307
298
|
}
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/core/keyboard/parser.d.ts
|
|
310
299
|
/**
|
|
311
|
-
* Structured representation of a keyboard shortcut after parsing.
|
|
312
|
-
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
313
|
-
*/
|
|
300
|
+
* Structured representation of a keyboard shortcut after parsing.
|
|
301
|
+
* The `normalized` field provides a deterministic string for dedup and comparison.
|
|
302
|
+
*/
|
|
314
303
|
interface ParsedShortcut {
|
|
315
304
|
readonly key: string;
|
|
316
305
|
readonly meta: boolean;
|
|
@@ -321,43 +310,39 @@ interface ParsedShortcut {
|
|
|
321
310
|
readonly normalized: string;
|
|
322
311
|
}
|
|
323
312
|
/**
|
|
324
|
-
* Parse a shortcut string like "Mod+Shift+K" into a structured ParsedShortcut.
|
|
325
|
-
* Ensures valid Unicode input via ensureWellFormed helper.
|
|
326
|
-
*/
|
|
327
|
-
declare function parseShortcut(shortcut: string): ParsedShortcut;
|
|
313
|
+
* Parse a shortcut string like "Mod+Shift+K" into a structured ParsedShortcut.
|
|
314
|
+
* Ensures valid Unicode input via ensureWellFormed helper.
|
|
315
|
+
*/
|
|
316
|
+
export declare function parseShortcut(shortcut: string): ParsedShortcut;
|
|
328
317
|
/**
|
|
329
|
-
* Formats a ParsedShortcut for display using platform-appropriate symbols.
|
|
330
|
-
* On macOS: renders glyphs (⌘, ⇧, ⌥, ⌃). On other platforms: text labels joined by "+".
|
|
331
|
-
*/
|
|
332
|
-
declare function formatShortcut(parsed: ParsedShortcut): string;
|
|
333
|
-
//#endregion
|
|
334
|
-
//#region src/core/keyboard/matcher.d.ts
|
|
318
|
+
* Formats a ParsedShortcut for display using platform-appropriate symbols.
|
|
319
|
+
* On macOS: renders glyphs (⌘, ⇧, ⌥, ⌃). On other platforms: text labels joined by "+".
|
|
320
|
+
*/
|
|
321
|
+
export declare function formatShortcut(parsed: ParsedShortcut): string;
|
|
335
322
|
/**
|
|
336
|
-
* Tests whether a KeyboardEvent exactly matches a ParsedShortcut,
|
|
337
|
-
* comparing all four modifier keys (meta, ctrl, shift, alt) and the primary key.
|
|
338
|
-
*/
|
|
339
|
-
declare function matchesShortcut(event: KeyboardEvent, shortcut: ParsedShortcut): boolean;
|
|
323
|
+
* Tests whether a KeyboardEvent exactly matches a ParsedShortcut,
|
|
324
|
+
* comparing all four modifier keys (meta, ctrl, shift, alt) and the primary key.
|
|
325
|
+
*/
|
|
326
|
+
export declare function matchesShortcut(event: KeyboardEvent, shortcut: ParsedShortcut): boolean;
|
|
340
327
|
/** Match a KeyboardEvent against a list of shortcuts — Iterator Helpers .find() */
|
|
341
|
-
declare function findMatchingShortcut(event: KeyboardEvent, shortcuts: readonly ParsedShortcut[]): ParsedShortcut | null;
|
|
328
|
+
export declare function findMatchingShortcut(event: KeyboardEvent, shortcuts: readonly ParsedShortcut[]): ParsedShortcut | null;
|
|
342
329
|
/**
|
|
343
|
-
* Detects conflicting shortcut bindings by grouping on their normalized form
|
|
344
|
-
* via mapGroupBy helper. Returns only groups with two or more colliding shortcuts.
|
|
345
|
-
* mapGroupBy returns a Map directly — no Object.entries conversion needed.
|
|
346
|
-
*/
|
|
347
|
-
declare function detectConflicts(shortcuts: readonly ParsedShortcut[]): ReadonlyMap<string, readonly ParsedShortcut[]>;
|
|
348
|
-
//#endregion
|
|
349
|
-
//#region src/core/keyboard/index.d.ts
|
|
330
|
+
* Detects conflicting shortcut bindings by grouping on their normalized form
|
|
331
|
+
* via mapGroupBy helper. Returns only groups with two or more colliding shortcuts.
|
|
332
|
+
* mapGroupBy returns a Map directly — no Object.entries conversion needed.
|
|
333
|
+
*/
|
|
334
|
+
export declare function detectConflicts(shortcuts: readonly ParsedShortcut[]): ReadonlyMap<string, readonly ParsedShortcut[]>;
|
|
350
335
|
interface ShortcutBinding {
|
|
351
336
|
readonly shortcut: ParsedShortcut;
|
|
352
337
|
readonly itemId: ItemId;
|
|
353
338
|
readonly handler: () => void;
|
|
354
339
|
}
|
|
355
340
|
/**
|
|
356
|
-
* Manages keyboard shortcut bindings with global keydown listening.
|
|
357
|
-
* Supports `using` for automatic cleanup of both individual bindings and the
|
|
358
|
-
* global document listener. Detects conflicts via Map.groupBy (ES2026).
|
|
359
|
-
*/
|
|
360
|
-
declare class KeyboardShortcutRegistry implements Disposable {
|
|
341
|
+
* Manages keyboard shortcut bindings with global keydown listening.
|
|
342
|
+
* Supports `using` for automatic cleanup of both individual bindings and the
|
|
343
|
+
* global document listener. Detects conflicts via Map.groupBy (ES2026).
|
|
344
|
+
*/
|
|
345
|
+
export declare class KeyboardShortcutRegistry implements Disposable {
|
|
361
346
|
#private;
|
|
362
347
|
constructor(options?: {
|
|
363
348
|
enabled?: boolean;
|
|
@@ -376,14 +361,12 @@ declare class KeyboardShortcutRegistry implements Disposable {
|
|
|
376
361
|
getBindings(): ReadonlyMap<string, ShortcutBinding>;
|
|
377
362
|
[Symbol.dispose](): void;
|
|
378
363
|
}
|
|
379
|
-
//#endregion
|
|
380
|
-
//#region src/core/registry.d.ts
|
|
381
364
|
/**
|
|
382
|
-
* Manages registration and lookup of command items and groups.
|
|
383
|
-
* Uses set operation helpers (union/intersection/difference) for efficient ID operations.
|
|
384
|
-
* All registration methods return Disposable for automatic cleanup via `using`.
|
|
385
|
-
*/
|
|
386
|
-
declare class CommandRegistry implements Disposable {
|
|
365
|
+
* Manages registration and lookup of command items and groups.
|
|
366
|
+
* Uses set operation helpers (union/intersection/difference) for efficient ID operations.
|
|
367
|
+
* All registration methods return Disposable for automatic cleanup via `using`.
|
|
368
|
+
*/
|
|
369
|
+
export declare class CommandRegistry implements Disposable {
|
|
387
370
|
#private;
|
|
388
371
|
/** Register an item — returns Disposable for `using` auto-deregister */
|
|
389
372
|
registerItem(item: CommandItem): Disposable;
|
|
@@ -431,8 +414,6 @@ declare class CommandRegistry implements Disposable {
|
|
|
431
414
|
clear(): void;
|
|
432
415
|
[Symbol.dispose](): void;
|
|
433
416
|
}
|
|
434
|
-
//#endregion
|
|
435
|
-
//#region src/core/machine.d.ts
|
|
436
417
|
/** Command machine — explicit resource management via `using` */
|
|
437
418
|
interface CommandMachine extends Disposable {
|
|
438
419
|
getState(): CommandState;
|
|
@@ -450,52 +431,44 @@ interface CommandMachine extends Disposable {
|
|
|
450
431
|
[Symbol.dispose](): void;
|
|
451
432
|
}
|
|
452
433
|
/**
|
|
453
|
-
* Creates a headless command palette state machine with search, frecency,
|
|
454
|
-
* and keyboard shortcut support. Implements Disposable for `using` cleanup.
|
|
455
|
-
*
|
|
456
|
-
* @example
|
|
457
|
-
* ```ts
|
|
458
|
-
* using machine = createCommandMachine({ items, loop: true });
|
|
459
|
-
* machine.subscribe(() => console.log(machine.getState()));
|
|
460
|
-
* ```
|
|
461
|
-
*/
|
|
462
|
-
declare function createCommandMachine(options?: CommandMachineOptions): CommandMachine;
|
|
463
|
-
//#endregion
|
|
464
|
-
//#region src/core/search/default-scorer.d.ts
|
|
434
|
+
* Creates a headless command palette state machine with search, frecency,
|
|
435
|
+
* and keyboard shortcut support. Implements Disposable for `using` cleanup.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* using machine = createCommandMachine({ items, loop: true });
|
|
440
|
+
* machine.subscribe(() => console.log(machine.getState()));
|
|
441
|
+
* ```
|
|
442
|
+
*/
|
|
443
|
+
export declare function createCommandMachine(options?: CommandMachineOptions): CommandMachine;
|
|
465
444
|
/**
|
|
466
|
-
* Public API: scores a command item against a search query.
|
|
467
|
-
* Multi-strategy: exact → prefix → substring → word-boundary → fuzzy.
|
|
468
|
-
* Returns null if no match. For batch use, prefer the search engine
|
|
469
|
-
* which pre-caches lowercase and normalizes query once.
|
|
470
|
-
*/
|
|
471
|
-
declare function scoreItem(query: string, item: CommandItem): SearchResult | null;
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/core/search/fuzzy-scorer.d.ts
|
|
445
|
+
* Public API: scores a command item against a search query.
|
|
446
|
+
* Multi-strategy: exact → prefix → substring → word-boundary → fuzzy.
|
|
447
|
+
* Returns null if no match. For batch use, prefer the search engine
|
|
448
|
+
* which pre-caches lowercase and normalizes query once.
|
|
449
|
+
*/
|
|
450
|
+
export declare function scoreItem(query: string, item: CommandItem): SearchResult | null;
|
|
474
451
|
/**
|
|
475
|
-
* Async-safe fuzzy scorer — wraps scoring in Promise for error resilience.
|
|
476
|
-
* Falls back gracefully on error via synchronous-throw capture.
|
|
477
|
-
*/
|
|
478
|
-
declare function scoreItemAsync(query: string, item: CommandItem): Promise<SearchResult | null>;
|
|
452
|
+
* Async-safe fuzzy scorer — wraps scoring in Promise for error resilience.
|
|
453
|
+
* Falls back gracefully on error via synchronous-throw capture.
|
|
454
|
+
*/
|
|
455
|
+
export declare function scoreItemAsync(query: string, item: CommandItem): Promise<SearchResult | null>;
|
|
479
456
|
/**
|
|
480
|
-
* Batch score items synchronously inside a single Promise.
|
|
481
|
-
* Eliminates per-item microtask overhead from async generators — runs the
|
|
482
|
-
* entire scoring pipeline in one synchronous pass, wrapped for error safety.
|
|
483
|
-
*/
|
|
484
|
-
declare function batchScoreItems(query: string, items: readonly CommandItem[]): Promise<SearchResult[]>;
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region src/core/search/index.d.ts
|
|
457
|
+
* Batch score items synchronously inside a single Promise.
|
|
458
|
+
* Eliminates per-item microtask overhead from async generators — runs the
|
|
459
|
+
* entire scoring pipeline in one synchronous pass, wrapped for error safety.
|
|
460
|
+
*/
|
|
461
|
+
export declare function batchScoreItems(query: string, items: readonly CommandItem[]): Promise<SearchResult[]>;
|
|
487
462
|
interface SearchEngineOptions {
|
|
488
463
|
readonly scorer?: ScorerFn | undefined;
|
|
489
464
|
}
|
|
490
465
|
/**
|
|
491
|
-
* Creates a search engine with pluggable scorer and incremental filtering.
|
|
492
|
-
* When the query extends the previous one, only prior matches are re-scored.
|
|
493
|
-
* Pre-caches lowercase at index time — zero toLowerCase() calls during search.
|
|
494
|
-
* Uses Iterator Helpers (ES2026) for result pipelines and Set.difference for pruning.
|
|
495
|
-
*/
|
|
496
|
-
declare function createSearchEngine(options?: SearchEngineOptions): SearchEngine;
|
|
497
|
-
//#endregion
|
|
498
|
-
//#region src/core/telemetry.d.ts
|
|
466
|
+
* Creates a search engine with pluggable scorer and incremental filtering.
|
|
467
|
+
* When the query extends the previous one, only prior matches are re-scored.
|
|
468
|
+
* Pre-caches lowercase at index time — zero toLowerCase() calls during search.
|
|
469
|
+
* Uses Iterator Helpers (ES2026) for result pipelines and Set.difference for pruning.
|
|
470
|
+
*/
|
|
471
|
+
export declare function createSearchEngine(options?: SearchEngineOptions): SearchEngine;
|
|
499
472
|
interface CommandTelemetryHooks {
|
|
500
473
|
/** Called when the command palette opens */
|
|
501
474
|
readonly onPaletteOpen?: () => void;
|
|
@@ -513,29 +486,27 @@ interface TelemetryMiddleware {
|
|
|
513
486
|
readonly onSelect: (itemId: ItemId, query: string, position: number) => void;
|
|
514
487
|
}
|
|
515
488
|
/**
|
|
516
|
-
* Creates a telemetry middleware that measures command palette interactions.
|
|
517
|
-
* Uses Date.now() for millisecond-precision timestamps
|
|
518
|
-
* and subtraction for duration computation.
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* ```ts
|
|
522
|
-
* const telemetry = createTelemetryMiddleware({
|
|
523
|
-
* onPaletteOpen: () => analytics.track('palette_opened'),
|
|
524
|
-
* onItemSelected: (id, query, pos) => analytics.track('item_selected', { id, query, position: pos }),
|
|
525
|
-
* });
|
|
526
|
-
* ```
|
|
527
|
-
*/
|
|
528
|
-
declare function createTelemetryMiddleware(hooks: CommandTelemetryHooks): TelemetryMiddleware;
|
|
529
|
-
//#endregion
|
|
530
|
-
//#region src/core/utils/event-emitter.d.ts
|
|
489
|
+
* Creates a telemetry middleware that measures command palette interactions.
|
|
490
|
+
* Uses Date.now() for millisecond-precision timestamps
|
|
491
|
+
* and subtraction for duration computation.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* ```ts
|
|
495
|
+
* const telemetry = createTelemetryMiddleware({
|
|
496
|
+
* onPaletteOpen: () => analytics.track('palette_opened'),
|
|
497
|
+
* onItemSelected: (id, query, pos) => analytics.track('item_selected', { id, query, position: pos }),
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
export declare function createTelemetryMiddleware(hooks: CommandTelemetryHooks): TelemetryMiddleware;
|
|
531
502
|
type EventMap = {
|
|
532
503
|
[key: string]: unknown;
|
|
533
504
|
};
|
|
534
505
|
/**
|
|
535
|
-
* Type-safe event emitter with strong references and Disposable subscriptions.
|
|
536
|
-
* Returns Disposable from `on()` for automatic unsubscription via `using`.
|
|
537
|
-
*/
|
|
538
|
-
declare class TypedEmitter<T extends EventMap> implements Disposable {
|
|
506
|
+
* Type-safe event emitter with strong references and Disposable subscriptions.
|
|
507
|
+
* Returns Disposable from `on()` for automatic unsubscription via `using`.
|
|
508
|
+
*/
|
|
509
|
+
export declare class TypedEmitter<T extends EventMap> implements Disposable {
|
|
539
510
|
#private;
|
|
540
511
|
/** Subscribe to an event. Returns a Disposable that removes the listener when disposed. */
|
|
541
512
|
on<K extends keyof T>(event: K, listener: (data: T[K]) => void): Disposable;
|
|
@@ -549,21 +520,18 @@ declare class TypedEmitter<T extends EventMap> implements Disposable {
|
|
|
549
520
|
removeAll(): void;
|
|
550
521
|
[Symbol.dispose](): void;
|
|
551
522
|
}
|
|
552
|
-
//#endregion
|
|
553
|
-
//#region src/core/utils/scheduler.d.ts
|
|
554
523
|
/**
|
|
555
|
-
* Batched update scheduler that coalesces state updates into a single tick.
|
|
556
|
-
* Uses requestAnimationFrame in browsers, queueMicrotask in Node.js/tests.
|
|
557
|
-
*/
|
|
524
|
+
* Batched update scheduler that coalesces state updates into a single tick.
|
|
525
|
+
* Uses requestAnimationFrame in browsers, queueMicrotask in Node.js/tests.
|
|
526
|
+
*/
|
|
558
527
|
interface Scheduler extends Disposable {
|
|
559
528
|
schedule(update: () => void): void;
|
|
560
529
|
flush(): void;
|
|
561
530
|
[Symbol.dispose](): void;
|
|
562
531
|
}
|
|
563
532
|
/**
|
|
564
|
-
* Creates a batched update scheduler. Coalesces rapid state updates into a single
|
|
565
|
-
* execution pass using rAF (browser) or queueMicrotask (Node.js).
|
|
566
|
-
*/
|
|
567
|
-
declare function createScheduler(): Scheduler;
|
|
568
|
-
|
|
569
|
-
export { type CommandEvent, type CommandGroup, type CommandItem, type CommandMachine, type CommandMachineOptions, CommandRegistry, type CommandState, type CommandTelemetryHooks, DEFAULT_FRECENCY_DECAY, DEFAULT_MACHINE_OPTIONS, type FrecencyData, type FrecencyDecayConfig, FrecencyEngine, type FrecencyOptions, type FrecencyRecord, type FrecencyStorage, type GroupId, IdbFrecencyStorage, type ItemId, KeyboardShortcutRegistry, MemoryFrecencyStorage, type ParsedShortcut, type Scheduler, type ScorerFn, type SearchEngine, type SearchResult, type TelemetryMiddleware, TypedEmitter, batchScoreItems, computeFrecencyBonus, createCommandMachine, createInitialState, createScheduler, createSearchEngine, createTelemetryMiddleware, detectConflicts, findMatchingShortcut, formatShortcut, groupId, itemId, matchesShortcut, parseShortcut, scoreItem, scoreItemAsync };
|
|
533
|
+
* Creates a batched update scheduler. Coalesces rapid state updates into a single
|
|
534
|
+
* execution pass using rAF (browser) or queueMicrotask (Node.js).
|
|
535
|
+
*/
|
|
536
|
+
export declare function createScheduler(): Scheduler;
|
|
537
|
+
export type { CommandEvent, CommandGroup, CommandItem, CommandMachine, CommandMachineOptions, CommandState, CommandTelemetryHooks, FrecencyData, FrecencyDecayConfig, FrecencyOptions, FrecencyRecord, FrecencyStorage, GroupId, ItemId, ParsedShortcut, Scheduler, ScorerFn, SearchEngine, SearchResult, TelemetryMiddleware };
|