@remcostoeten/use-shortcut 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +120 -40
- package/dist/constants.d.ts +36 -0
- package/dist/constants.js +1 -0
- package/dist/constants.mjs +1 -0
- package/dist/formatter.d.ts +30 -0
- package/dist/formatter.js +1 -0
- package/dist/formatter.mjs +1 -0
- package/dist/index.d.ts +5 -468
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/parser.d.ts +47 -0
- package/dist/parser.js +1 -0
- package/dist/parser.mjs +1 -0
- package/dist/react.d.ts +79 -0
- package/dist/react.js +1 -0
- package/dist/react.mjs +1 -0
- package/dist/types-yQWKtHDh.d.ts +320 -0
- package/package.json +46 -5
- package/dist/cli/index.mjs +0 -469
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/** Lowercase letter keys a-z */
|
|
2
|
+
type AlphaKey = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
3
|
+
/** Number keys 0-9 */
|
|
4
|
+
type NumericKey = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9";
|
|
5
|
+
/** Function keys F1-F12 */
|
|
6
|
+
type FunctionKey = "f1" | "f2" | "f3" | "f4" | "f5" | "f6" | "f7" | "f8" | "f9" | "f10" | "f11" | "f12";
|
|
7
|
+
/** Arrow and navigation keys */
|
|
8
|
+
type NavigationKey = "up" | "down" | "left" | "right" | "arrowup" | "arrowdown" | "arrowleft" | "arrowright" | "home" | "end" | "pageup" | "pagedown";
|
|
9
|
+
/** Special action keys like Enter, Escape, Tab */
|
|
10
|
+
type SpecialKey = "enter" | "return" | "escape" | "esc" | "space" | "tab" | "backspace" | "delete" | "del" | "insert";
|
|
11
|
+
/** Symbol and punctuation keys */
|
|
12
|
+
type SymbolKey = "minus" | "plus" | "equal" | "equals" | "bracketleft" | "bracketright" | "backslash" | "slash" | "/" | "comma" | "period" | "semicolon" | "quote" | "backtick";
|
|
13
|
+
/**
|
|
14
|
+
* All valid action keys that can be used with `.key()`
|
|
15
|
+
* @example $.mod.key("s") // "s" is an ActionKey
|
|
16
|
+
*/
|
|
17
|
+
type ActionKey = AlphaKey | NumericKey | FunctionKey | NavigationKey | SpecialKey | SymbolKey;
|
|
18
|
+
/** Modifier key names used in the chainable API */
|
|
19
|
+
type ModifierName = "ctrl" | "shift" | "alt" | "cmd" | "mod";
|
|
20
|
+
/** Internal modifier state flags */
|
|
21
|
+
type ModifierFlags = {
|
|
22
|
+
ctrl: boolean;
|
|
23
|
+
shift: boolean;
|
|
24
|
+
alt: boolean;
|
|
25
|
+
cmd: boolean;
|
|
26
|
+
};
|
|
27
|
+
/** Modifier key state from a keyboard event */
|
|
28
|
+
type ModifierState = {
|
|
29
|
+
meta: boolean;
|
|
30
|
+
ctrl: boolean;
|
|
31
|
+
alt: boolean;
|
|
32
|
+
shift: boolean;
|
|
33
|
+
};
|
|
34
|
+
/** Result of parsing a shortcut string */
|
|
35
|
+
type ParsedShortcut = {
|
|
36
|
+
modifiers: ModifierState;
|
|
37
|
+
key: string;
|
|
38
|
+
original: string;
|
|
39
|
+
};
|
|
40
|
+
type EmptyModifiers = {};
|
|
41
|
+
/**
|
|
42
|
+
* Handler function called when a shortcut is triggered
|
|
43
|
+
* @param event - The keyboard event that triggered the shortcut
|
|
44
|
+
*/
|
|
45
|
+
type ShortcutHandler = (event: KeyboardEvent) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Custom predicate for excluding shortcuts in certain conditions
|
|
48
|
+
* @param event - The keyboard event to evaluate
|
|
49
|
+
* @returns `true` to skip the shortcut, `false` to allow it
|
|
50
|
+
*/
|
|
51
|
+
type ExceptPredicate = (event: KeyboardEvent) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Built-in exception presets for common scenarios
|
|
54
|
+
* - "input" - Skip when focused on input, textarea, or select
|
|
55
|
+
* - "editable" - Skip when focused on contentEditable elements
|
|
56
|
+
* - "typing" - Skip in any text input context (combines input + editable)
|
|
57
|
+
* - "modal" - Skip when a modal/dialog is open (checks [data-modal] or [role="dialog"])
|
|
58
|
+
* - "disabled" - Skip when focused element is disabled
|
|
59
|
+
*/
|
|
60
|
+
type ExceptPreset = "input" | "editable" | "typing" | "modal" | "disabled";
|
|
61
|
+
/** Scope selector used to enable/disable subsets of shortcuts at runtime. */
|
|
62
|
+
type ShortcutScope = string | string[];
|
|
63
|
+
/** Conflict metadata emitted when two registered shortcuts overlap. */
|
|
64
|
+
type ShortcutConflict = {
|
|
65
|
+
combo: string;
|
|
66
|
+
existingCombo: string;
|
|
67
|
+
reason: "exact" | "sequence-prefix";
|
|
68
|
+
};
|
|
69
|
+
/** High-level match status for one shortcut attempt against the current keyboard input. */
|
|
70
|
+
type ShortcutAttemptStatus = "matched" | "partial" | "wrong-order" | "mismatch";
|
|
71
|
+
/** Token-level verdict for modifiers and keys inside debug attempt payloads. */
|
|
72
|
+
type ShortcutDebugTokenStatus = "match" | "wrong-order" | "mismatch";
|
|
73
|
+
/** Debug metadata for one expected token in a shortcut step. */
|
|
74
|
+
type ShortcutDebugToken = {
|
|
75
|
+
token: string;
|
|
76
|
+
kind: "modifier" | "key";
|
|
77
|
+
status: ShortcutDebugTokenStatus;
|
|
78
|
+
};
|
|
79
|
+
/** Debug metadata for one step in a combo or multi-step shortcut sequence. */
|
|
80
|
+
type ShortcutDebugStep = {
|
|
81
|
+
index: number;
|
|
82
|
+
expected: string;
|
|
83
|
+
actual?: string;
|
|
84
|
+
status: "match" | "partial" | "pending" | "wrong-order" | "mismatch";
|
|
85
|
+
tokens: ShortcutDebugToken[];
|
|
86
|
+
};
|
|
87
|
+
/** Normalized view of the keyboard input that triggered debug processing. */
|
|
88
|
+
type ShortcutDebugInput = {
|
|
89
|
+
key: string;
|
|
90
|
+
code: string;
|
|
91
|
+
location: number;
|
|
92
|
+
repeat: boolean;
|
|
93
|
+
keyCode?: number;
|
|
94
|
+
which?: number;
|
|
95
|
+
combo: string;
|
|
96
|
+
modifiers: ModifierState;
|
|
97
|
+
};
|
|
98
|
+
/** Per-shortcut debug payload describing how one registered shortcut was evaluated. */
|
|
99
|
+
type ShortcutAttemptDebugEvent = {
|
|
100
|
+
combo: string;
|
|
101
|
+
display: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
status: ShortcutAttemptStatus;
|
|
104
|
+
matched: boolean;
|
|
105
|
+
progress: number;
|
|
106
|
+
expectedSteps: string[];
|
|
107
|
+
actualSteps: string[];
|
|
108
|
+
stepIndex: number;
|
|
109
|
+
input: ShortcutDebugInput;
|
|
110
|
+
steps: ShortcutDebugStep[];
|
|
111
|
+
};
|
|
112
|
+
/** Global debug payload emitted for every processed keyboard event. */
|
|
113
|
+
type ShortcutDebugEvent = {
|
|
114
|
+
input: ShortcutDebugInput;
|
|
115
|
+
attempts: ShortcutAttemptDebugEvent[];
|
|
116
|
+
};
|
|
117
|
+
/** Runtime debug configuration for console/debug-stream metadata. */
|
|
118
|
+
type ShortcutDebugOptions = {
|
|
119
|
+
/** Log shortcut attempts to the console (default: true) */
|
|
120
|
+
console?: boolean;
|
|
121
|
+
/** Include `KeyboardEvent.code` in console output */
|
|
122
|
+
includeCode?: boolean;
|
|
123
|
+
/** Include `KeyboardEvent.location` in console output */
|
|
124
|
+
includeLocation?: boolean;
|
|
125
|
+
/** Include deprecated numeric key metadata in console output when available */
|
|
126
|
+
includeKeyCode?: boolean;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Options for shortcut handler registration
|
|
130
|
+
*/
|
|
131
|
+
type HandlerOptions = {
|
|
132
|
+
/** Prevent the browser's default action (default: `true`) */
|
|
133
|
+
preventDefault?: boolean;
|
|
134
|
+
/** Stop event propagation */
|
|
135
|
+
stopPropagation?: boolean;
|
|
136
|
+
/** Delay handler execution in milliseconds */
|
|
137
|
+
delay?: number;
|
|
138
|
+
/** Description for documentation/debugging */
|
|
139
|
+
description?: string;
|
|
140
|
+
/** Disable this specific shortcut */
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
/** Conditions to skip the shortcut */
|
|
143
|
+
except?: ExceptPreset | ExceptPreset[] | ExceptPredicate;
|
|
144
|
+
/** Required named scopes that must be active */
|
|
145
|
+
scopes?: ShortcutScope;
|
|
146
|
+
/** Timeout in ms for multi-step sequences */
|
|
147
|
+
sequenceTimeout?: number;
|
|
148
|
+
/** Higher priority handlers run first (default: 0) */
|
|
149
|
+
priority?: number;
|
|
150
|
+
/** Stop evaluating other handlers for this combo when matched */
|
|
151
|
+
stopOnMatch?: boolean;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Result object returned when registering a shortcut
|
|
155
|
+
* Provides control over the shortcut and display information
|
|
156
|
+
*/
|
|
157
|
+
type ShortcutResult = {
|
|
158
|
+
/** Remove the keyboard listener */
|
|
159
|
+
unbind: () => void;
|
|
160
|
+
/** Platform-aware display string (e.g., "⌘S" on Mac, "Ctrl+S" on Windows) */
|
|
161
|
+
display: string;
|
|
162
|
+
/** Normalized combo string (e.g., "cmd+s" or "g d") */
|
|
163
|
+
combo: string;
|
|
164
|
+
/** Programmatically trigger the shortcut handler */
|
|
165
|
+
trigger: () => void;
|
|
166
|
+
/** Whether the shortcut is currently enabled */
|
|
167
|
+
isEnabled: boolean;
|
|
168
|
+
/** Enable the shortcut (after being disabled) */
|
|
169
|
+
enable: () => void;
|
|
170
|
+
/** Temporarily disable the shortcut */
|
|
171
|
+
disable: () => void;
|
|
172
|
+
/** Subscribe to shortcut attempt events (useful for visual feedback) */
|
|
173
|
+
onAttempt?: (callback: (matched: boolean, event: KeyboardEvent, details?: ShortcutAttemptDebugEvent) => void) => () => void;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Chainable modifier builder with type-safe exhaustion
|
|
177
|
+
* Each modifier can only be used once in a chain
|
|
178
|
+
*/
|
|
179
|
+
type ModifierChain<Used extends Partial<ModifierFlags>> = {
|
|
180
|
+
ctrl: Used["ctrl"] extends true ? never : ModifierChain<Used & {
|
|
181
|
+
ctrl: true;
|
|
182
|
+
}>;
|
|
183
|
+
shift: Used["shift"] extends true ? never : ModifierChain<Used & {
|
|
184
|
+
shift: true;
|
|
185
|
+
}>;
|
|
186
|
+
alt: Used["alt"] extends true ? never : ModifierChain<Used & {
|
|
187
|
+
alt: true;
|
|
188
|
+
}>;
|
|
189
|
+
cmd: Used["cmd"] extends true ? never : ModifierChain<Used & {
|
|
190
|
+
cmd: true;
|
|
191
|
+
}>;
|
|
192
|
+
mod: Used["cmd"] extends true ? never : ModifierChain<Used & {
|
|
193
|
+
cmd: true;
|
|
194
|
+
}>;
|
|
195
|
+
key: <K extends ActionKey>(key: K) => KeyChain<K>;
|
|
196
|
+
in: (scopes: ShortcutScope) => ModifierChain<Used>;
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Chain state after calling `.key()` - ready to attach a handler
|
|
200
|
+
*/
|
|
201
|
+
type KeyChain<Key extends string> = {
|
|
202
|
+
/** Attach a handler to this shortcut */
|
|
203
|
+
on: (handler: ShortcutHandler, options?: HandlerOptions) => ShortcutResult;
|
|
204
|
+
/** Attach a handler with inline options */
|
|
205
|
+
handle: (options: HandlerOptions & {
|
|
206
|
+
handler: ShortcutHandler;
|
|
207
|
+
}) => ShortcutResult;
|
|
208
|
+
/** Bind a combo string mid-chain */
|
|
209
|
+
bind: (combo: string | string[]) => KeyChain<any>;
|
|
210
|
+
/** Add exception conditions before attaching handler */
|
|
211
|
+
except: (condition: ExceptPreset | ExceptPreset[] | ExceptPredicate) => KeyChainWithExcept<Key>;
|
|
212
|
+
/** Add required named scopes */
|
|
213
|
+
in: (scopes: ShortcutScope) => KeyChain<Key>;
|
|
214
|
+
/** Add the next step in a sequence */
|
|
215
|
+
then: <K extends ActionKey | string>(key: K) => KeyChain<`${Key} ${K}`>;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Chain state after calling `.except()` - ready to attach handler
|
|
219
|
+
*/
|
|
220
|
+
type KeyChainWithExcept<Key extends string> = {
|
|
221
|
+
on: (handler: ShortcutHandler, options?: Omit<HandlerOptions, "except">) => ShortcutResult;
|
|
222
|
+
/** Bind a combo string mid-chain */
|
|
223
|
+
bind: (combo: string | string[]) => KeyChainWithExcept<Key>;
|
|
224
|
+
in: (scopes: ShortcutScope) => KeyChainWithExcept<Key>;
|
|
225
|
+
then: <K extends ActionKey | string>(key: K) => KeyChainWithExcept<`${Key} ${K}`>;
|
|
226
|
+
};
|
|
227
|
+
/** Options for `ShortcutBuilder.record()` and low-level recording flows. */
|
|
228
|
+
type ShortcutRecordingOptions = {
|
|
229
|
+
target?: HTMLElement | Window | null;
|
|
230
|
+
eventType?: "keydown" | "keyup";
|
|
231
|
+
timeoutMs?: number;
|
|
232
|
+
};
|
|
233
|
+
/**
|
|
234
|
+
* The main shortcut builder interface returned by `useShortcut()`
|
|
235
|
+
*/
|
|
236
|
+
type ShortcutBuilder = ModifierChain<EmptyModifiers> & {
|
|
237
|
+
ctrl: ModifierChain<{
|
|
238
|
+
ctrl: true;
|
|
239
|
+
}>;
|
|
240
|
+
shift: ModifierChain<{
|
|
241
|
+
shift: true;
|
|
242
|
+
}>;
|
|
243
|
+
alt: ModifierChain<{
|
|
244
|
+
alt: true;
|
|
245
|
+
}>;
|
|
246
|
+
cmd: ModifierChain<{
|
|
247
|
+
cmd: true;
|
|
248
|
+
}>;
|
|
249
|
+
mod: ModifierChain<{
|
|
250
|
+
cmd: true;
|
|
251
|
+
}>;
|
|
252
|
+
key: <K extends ActionKey>(key: K) => KeyChain<K>;
|
|
253
|
+
/** Bind a pre-defined combo string */
|
|
254
|
+
bind: (combo: string | string[]) => KeyChain<any>;
|
|
255
|
+
/** Set required scopes for upcoming chain calls */
|
|
256
|
+
in: (scopes: ShortcutScope) => ShortcutBuilder;
|
|
257
|
+
/** Update active scopes at runtime */
|
|
258
|
+
setScopes: (scopes: ShortcutScope) => void;
|
|
259
|
+
/** Enable one scope */
|
|
260
|
+
enableScope: (scope: string) => void;
|
|
261
|
+
/** Disable one scope */
|
|
262
|
+
disableScope: (scope: string) => void;
|
|
263
|
+
/** Return currently active scopes */
|
|
264
|
+
getScopes: () => string[];
|
|
265
|
+
/** Check if a scope is active */
|
|
266
|
+
isScopeActive: (scope: string) => boolean;
|
|
267
|
+
/** Subscribe to every keyboard input evaluated by this shortcut registry */
|
|
268
|
+
onDebug: (callback: (event: ShortcutDebugEvent) => void) => () => void;
|
|
269
|
+
/** Record the next key combo */
|
|
270
|
+
record: (options?: ShortcutRecordingOptions) => Promise<string>;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* Options for the `useShortcut` hook
|
|
274
|
+
*/
|
|
275
|
+
type UseShortcutOptions = {
|
|
276
|
+
/** Enable debug logging to console or configure structured debug output */
|
|
277
|
+
debug?: boolean | ShortcutDebugOptions;
|
|
278
|
+
/** Global delay for all handlers in milliseconds */
|
|
279
|
+
delay?: number;
|
|
280
|
+
/** Skip shortcuts when focused on input elements (default: `true`) */
|
|
281
|
+
ignoreInputs?: boolean;
|
|
282
|
+
/** Target element for keyboard listeners (default: `window`) */
|
|
283
|
+
target?: HTMLElement | Window | null;
|
|
284
|
+
/** Keyboard event type to listen for (default: "keydown") */
|
|
285
|
+
eventType?: "keydown" | "keyup";
|
|
286
|
+
/** Globally disable all shortcuts from this hook */
|
|
287
|
+
disabled?: boolean;
|
|
288
|
+
/** Active named scopes. Shortcuts with scopes only run when at least one matches. */
|
|
289
|
+
activeScopes?: ShortcutScope;
|
|
290
|
+
/** Global timeout in ms for sequence completion */
|
|
291
|
+
sequenceTimeout?: number;
|
|
292
|
+
/** Warn when conflicting shortcuts are registered (default: true) */
|
|
293
|
+
conflictWarnings?: boolean;
|
|
294
|
+
/** Custom conflict callback */
|
|
295
|
+
onConflict?: (conflict: ShortcutConflict) => void;
|
|
296
|
+
/** Global event filter; return false to skip all shortcuts for the event */
|
|
297
|
+
eventFilter?: (event: KeyboardEvent) => boolean;
|
|
298
|
+
};
|
|
299
|
+
/** Single shortcut-map entry used by `registerShortcutMap` and `useShortcutMap`. */
|
|
300
|
+
type ShortcutMapEntry = {
|
|
301
|
+
keys: string | string[];
|
|
302
|
+
handler: ShortcutHandler;
|
|
303
|
+
options?: HandlerOptions;
|
|
304
|
+
};
|
|
305
|
+
/** Bulk registration shape mapping action ids to key+handler definitions. */
|
|
306
|
+
type ShortcutMap = Record<string, ShortcutMapEntry>;
|
|
307
|
+
/** Return type for map registrations, keyed by the same ids as the source map. */
|
|
308
|
+
type ShortcutMapResult<T extends ShortcutMap = ShortcutMap> = {
|
|
309
|
+
[K in keyof T]: ShortcutResult;
|
|
310
|
+
};
|
|
311
|
+
/** Imperative grouping controller for binding/unbinding many shortcut registrations together. */
|
|
312
|
+
type ShortcutGroup = {
|
|
313
|
+
add: (...results: ShortcutResult[]) => void;
|
|
314
|
+
addMany: (results: ShortcutResult[] | Record<string, ShortcutResult>) => void;
|
|
315
|
+
unbindAll: () => void;
|
|
316
|
+
clear: () => void;
|
|
317
|
+
getResults: () => ShortcutResult[];
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
export type { ActionKey as A, ExceptPredicate as E, FunctionKey as F, HandlerOptions as H, KeyChain as K, ModifierChain as M, NavigationKey as N, ParsedShortcut as P, ShortcutAttemptDebugEvent as S, UseShortcutOptions as U, AlphaKey as a, ExceptPreset as b, ModifierFlags as c, ModifierName as d, ModifierState as e, NumericKey as f, ShortcutAttemptStatus as g, ShortcutBuilder as h, ShortcutConflict as i, ShortcutDebugEvent as j, ShortcutDebugInput as k, ShortcutDebugOptions as l, ShortcutDebugStep as m, ShortcutDebugToken as n, ShortcutDebugTokenStatus as o, ShortcutGroup as p, ShortcutHandler as q, ShortcutMap as r, ShortcutMapEntry as s, ShortcutMapResult as t, ShortcutRecordingOptions as u, ShortcutResult as v, ShortcutScope as w, SpecialKey as x, SymbolKey as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remcostoeten/use-shortcut",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.3.0",
|
|
4
|
+
"description": "Tiny, chainable React keyboard shortcuts with sequences, scopes, and typed debug hooks.",
|
|
5
5
|
"author": "Remco Stoeten",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/remcostoeten/use-shortcut#readme",
|
|
@@ -23,9 +23,6 @@
|
|
|
23
23
|
"chainable"
|
|
24
24
|
],
|
|
25
25
|
"sideEffects": false,
|
|
26
|
-
"bin": {
|
|
27
|
-
"use-shortcut": "dist/cli/index.mjs"
|
|
28
|
-
},
|
|
29
26
|
"main": "./dist/index.js",
|
|
30
27
|
"module": "./dist/index.mjs",
|
|
31
28
|
"types": "./dist/index.d.ts",
|
|
@@ -39,6 +36,46 @@
|
|
|
39
36
|
"types": "./dist/index.d.ts",
|
|
40
37
|
"default": "./dist/index.js"
|
|
41
38
|
}
|
|
39
|
+
},
|
|
40
|
+
"./react": {
|
|
41
|
+
"import": {
|
|
42
|
+
"types": "./dist/react.d.ts",
|
|
43
|
+
"default": "./dist/react.mjs"
|
|
44
|
+
},
|
|
45
|
+
"require": {
|
|
46
|
+
"types": "./dist/react.d.ts",
|
|
47
|
+
"default": "./dist/react.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./parser": {
|
|
51
|
+
"import": {
|
|
52
|
+
"types": "./dist/parser.d.ts",
|
|
53
|
+
"default": "./dist/parser.mjs"
|
|
54
|
+
},
|
|
55
|
+
"require": {
|
|
56
|
+
"types": "./dist/parser.d.ts",
|
|
57
|
+
"default": "./dist/parser.js"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"./formatter": {
|
|
61
|
+
"import": {
|
|
62
|
+
"types": "./dist/formatter.d.ts",
|
|
63
|
+
"default": "./dist/formatter.mjs"
|
|
64
|
+
},
|
|
65
|
+
"require": {
|
|
66
|
+
"types": "./dist/formatter.d.ts",
|
|
67
|
+
"default": "./dist/formatter.js"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./constants": {
|
|
71
|
+
"import": {
|
|
72
|
+
"types": "./dist/constants.d.ts",
|
|
73
|
+
"default": "./dist/constants.mjs"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./dist/constants.d.ts",
|
|
77
|
+
"default": "./dist/constants.js"
|
|
78
|
+
}
|
|
42
79
|
}
|
|
43
80
|
},
|
|
44
81
|
"files": [
|
|
@@ -56,9 +93,13 @@
|
|
|
56
93
|
"build": "tsup && node scripts/prune-dist.mjs",
|
|
57
94
|
"dev": "tsup --watch",
|
|
58
95
|
"test": "vitest run --environment jsdom",
|
|
96
|
+
"test:watch": "vitest --environment jsdom",
|
|
97
|
+
"test:entrypoints": "vitest run --environment jsdom src/__tests__/entrypoints.test.ts",
|
|
98
|
+
"test:features": "vitest run --environment jsdom src/__tests__/features.test.ts",
|
|
59
99
|
"typecheck": "tsc --noEmit",
|
|
60
100
|
"docs:api": "node scripts/generate-api-reference.mjs",
|
|
61
101
|
"docs:check": "bun run docs:api && node scripts/docs-check.mjs",
|
|
102
|
+
"verify": "bun run typecheck && bun run test && bun run build && bun run docs:check",
|
|
62
103
|
"clean": "rm -rf dist",
|
|
63
104
|
"prepublishOnly": "npm run build"
|
|
64
105
|
},
|