impact-nova 1.5.7 → 1.5.8
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/components/layout/dashboard-layout.d.ts +24 -39
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/percent-progress-cell-editor.d.ts +16 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/editors/percent-progress-cell-editor.js +135 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/index.d.ts +14 -1
- package/dist/components/ui/ag-grid-react/cell-renderers/index.js +41 -35
- package/dist/components/ui/ag-grid-react/cell-renderers/percent-progress-display-renderer.d.ts +31 -0
- package/dist/components/ui/ag-grid-react/cell-renderers/percent-progress-display-renderer.js +63 -0
- package/dist/components/ui/command-palette/command-palette-context.d.ts +4 -2
- package/dist/components/ui/command-palette/command-palette-context.js +76 -77
- package/dist/components/ui/command-palette/index.d.ts +3 -3
- package/dist/components/ui/command-palette/index.js +43 -40
- package/dist/components/ui/command-palette/shortcut-registry.d.ts +15 -2
- package/dist/components/ui/command-palette/shortcut-registry.js +61 -35
- package/dist/components/ui/command-palette/utils.d.ts +15 -0
- package/dist/components/ui/command-palette/utils.js +105 -70
- package/dist/icons/assets/command-pallet.svg.js +5 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +146 -144
- package/dist/impact-nova.css +1 -1
- package/dist/index.js +100 -97
- package/package.json +1 -1
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { ShortcutRegistry as
|
|
4
|
-
import { matchesKeybinding as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { ShortcutRegistry as N } from "./shortcut-registry.js";
|
|
4
|
+
import { matchesKeybinding as R } from "./utils.js";
|
|
5
|
+
const w = t.createContext(null);
|
|
6
6
|
function T({
|
|
7
7
|
children: o,
|
|
8
|
-
openKeybinding:
|
|
8
|
+
openKeybinding: c = { key: "k", meta: !0 },
|
|
9
|
+
storage: h
|
|
9
10
|
}) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
e
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (N(r, u)) {
|
|
19
|
-
r.preventDefault(), r.stopPropagation(), i((w) => !w);
|
|
11
|
+
const [e] = t.useState(() => new N(h)), [r, i] = t.useState(!1), [u, S] = t.useState(0);
|
|
12
|
+
t.useEffect(() => e.subscribe(() => {
|
|
13
|
+
S((s) => s + 1);
|
|
14
|
+
}), [e]), t.useEffect(() => {
|
|
15
|
+
const n = (s) => {
|
|
16
|
+
const a = s.target, I = a.closest?.("[data-command-palette]"), x = a.tagName === "INPUT" || a.tagName === "TEXTAREA" || a.tagName === "SELECT" || a.isContentEditable;
|
|
17
|
+
if (R(s, c)) {
|
|
18
|
+
s.preventDefault(), s.stopPropagation(), i((v) => !v);
|
|
20
19
|
return;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
r || x && !I && !(s.metaKey || s.ctrlKey) || e.handleKeyEvent(s);
|
|
23
22
|
};
|
|
24
|
-
return window.addEventListener("keydown",
|
|
25
|
-
}, [
|
|
26
|
-
const m =
|
|
27
|
-
(
|
|
28
|
-
[]
|
|
29
|
-
),
|
|
30
|
-
(
|
|
31
|
-
[]
|
|
32
|
-
),
|
|
33
|
-
(
|
|
34
|
-
[]
|
|
35
|
-
),
|
|
36
|
-
(
|
|
37
|
-
[]
|
|
38
|
-
),
|
|
39
|
-
() =>
|
|
40
|
-
[]
|
|
41
|
-
),
|
|
42
|
-
() =>
|
|
43
|
-
[]
|
|
44
|
-
),
|
|
45
|
-
(
|
|
46
|
-
[]
|
|
47
|
-
),
|
|
48
|
-
() =>
|
|
49
|
-
[]
|
|
50
|
-
),
|
|
51
|
-
(
|
|
52
|
-
[]
|
|
53
|
-
),
|
|
54
|
-
(
|
|
55
|
-
[]
|
|
56
|
-
),
|
|
57
|
-
(
|
|
58
|
-
[]
|
|
59
|
-
),
|
|
60
|
-
() =>
|
|
61
|
-
[]
|
|
62
|
-
),
|
|
63
|
-
registry:
|
|
64
|
-
open:
|
|
23
|
+
return window.addEventListener("keydown", n, !0), () => window.removeEventListener("keydown", n, !0);
|
|
24
|
+
}, [e, r, c]);
|
|
25
|
+
const m = t.useCallback(
|
|
26
|
+
(n) => e.register(n),
|
|
27
|
+
[e]
|
|
28
|
+
), l = t.useCallback(
|
|
29
|
+
(n) => e.unregister(n),
|
|
30
|
+
[e]
|
|
31
|
+
), d = t.useCallback(
|
|
32
|
+
(n, s) => e.updateKeybinding(n, s),
|
|
33
|
+
[e]
|
|
34
|
+
), C = t.useCallback(
|
|
35
|
+
(n) => e.resetKeybinding(n),
|
|
36
|
+
[e]
|
|
37
|
+
), g = t.useCallback(
|
|
38
|
+
() => e.getPaletteCommands(),
|
|
39
|
+
[e]
|
|
40
|
+
), p = t.useCallback(
|
|
41
|
+
() => e.getSettingsCommands(),
|
|
42
|
+
[e]
|
|
43
|
+
), b = t.useCallback(
|
|
44
|
+
(n) => e.getEffectiveKeybinding(n),
|
|
45
|
+
[e]
|
|
46
|
+
), f = t.useCallback(
|
|
47
|
+
() => e.getRecentCommandIds(),
|
|
48
|
+
[e]
|
|
49
|
+
), y = t.useCallback(
|
|
50
|
+
(n) => e.pushScope(n),
|
|
51
|
+
[e]
|
|
52
|
+
), P = t.useCallback(
|
|
53
|
+
(n) => e.popScope(n),
|
|
54
|
+
[e]
|
|
55
|
+
), k = t.useCallback(
|
|
56
|
+
(n) => e.setActiveInstance(n),
|
|
57
|
+
[e]
|
|
58
|
+
), E = t.useCallback(
|
|
59
|
+
() => e.getActiveInstance(),
|
|
60
|
+
[e]
|
|
61
|
+
), K = t.useMemo(() => ({
|
|
62
|
+
registry: e,
|
|
63
|
+
open: r,
|
|
65
64
|
setOpen: i,
|
|
66
65
|
registerCommand: m,
|
|
67
|
-
unregisterCommand:
|
|
68
|
-
updateKeybinding:
|
|
69
|
-
resetKeybinding:
|
|
70
|
-
getPaletteCommands:
|
|
71
|
-
getSettingsCommands:
|
|
72
|
-
getEffectiveKeybinding:
|
|
73
|
-
getRecentCommandIds:
|
|
74
|
-
pushScope:
|
|
75
|
-
popScope:
|
|
76
|
-
setActiveInstance:
|
|
77
|
-
getActiveInstance:
|
|
78
|
-
version:
|
|
66
|
+
unregisterCommand: l,
|
|
67
|
+
updateKeybinding: d,
|
|
68
|
+
resetKeybinding: C,
|
|
69
|
+
getPaletteCommands: g,
|
|
70
|
+
getSettingsCommands: p,
|
|
71
|
+
getEffectiveKeybinding: b,
|
|
72
|
+
getRecentCommandIds: f,
|
|
73
|
+
pushScope: y,
|
|
74
|
+
popScope: P,
|
|
75
|
+
setActiveInstance: k,
|
|
76
|
+
getActiveInstance: E,
|
|
77
|
+
version: u
|
|
79
78
|
}), [
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
e,
|
|
80
|
+
r,
|
|
81
|
+
u,
|
|
83
82
|
m,
|
|
83
|
+
l,
|
|
84
84
|
d,
|
|
85
85
|
C,
|
|
86
86
|
g,
|
|
@@ -90,14 +90,13 @@ function T({
|
|
|
90
90
|
y,
|
|
91
91
|
P,
|
|
92
92
|
k,
|
|
93
|
-
E
|
|
94
|
-
v
|
|
93
|
+
E
|
|
95
94
|
]);
|
|
96
|
-
return /* @__PURE__ */
|
|
95
|
+
return /* @__PURE__ */ A(w.Provider, { value: K, children: o });
|
|
97
96
|
}
|
|
98
97
|
T.displayName = "CommandPaletteProvider";
|
|
99
98
|
function V() {
|
|
100
|
-
const o =
|
|
99
|
+
const o = t.useContext(w);
|
|
101
100
|
if (!o)
|
|
102
101
|
throw new Error(
|
|
103
102
|
"useCommandPalette must be used within a <CommandPaletteProvider>. Wrap your application root with <CommandPaletteProvider>."
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Command Palette & Keyboard Shortcuts — Public API
|
|
3
3
|
*/
|
|
4
|
-
export type { ShortcutScope, KeyBinding, CommandDefinition, FuzzyResult, SerializedOverride, BrowserShortcutInfo, } from './utils';
|
|
5
|
-
export { isMac, getKeySymbol, keybindingToSymbols, keybindingToString, matchesKeybinding, parseKeybinding, keybindingsEqual, keybindingFromEvent, isReservedShortcut, getBrowserShortcutInfo, BROWSER_SHORTCUTS, fuzzyScore, fuzzyFilter, scopePriority, } from './utils';
|
|
6
|
-
export { ShortcutRegistry } from './shortcut-registry';
|
|
4
|
+
export type { ShortcutScope, KeyBinding, CommandDefinition, FuzzyResult, SerializedOverride, BrowserShortcutInfo, ShortcutStorageAdapter, } from './utils';
|
|
5
|
+
export { isMac, getKeySymbol, keybindingToSymbols, keybindingToString, matchesKeybinding, parseKeybinding, keybindingsEqual, keybindingFromEvent, isReservedShortcut, getBrowserShortcutInfo, BROWSER_SHORTCUTS, fuzzyScore, fuzzyFilter, scopePriority, serialiseOverrides, deserialiseOverrides, } from './utils';
|
|
6
|
+
export { ShortcutRegistry, LocalStorageAdapter } from './shortcut-registry';
|
|
7
7
|
export type { RegistryChangeEvent, RegistryListener, ConflictInfo } from './shortcut-registry';
|
|
8
8
|
export { CommandPaletteProvider, useCommandPalette, } from './command-palette-context';
|
|
9
9
|
export type { CommandPaletteContextValue, CommandPaletteProviderProps } from './command-palette-context';
|
|
@@ -1,44 +1,47 @@
|
|
|
1
|
-
import { BROWSER_SHORTCUTS as o,
|
|
2
|
-
import { ShortcutRegistry as
|
|
3
|
-
import { CommandPaletteProvider as
|
|
4
|
-
import { useShortcut as
|
|
5
|
-
import { useGlobalShortcut as
|
|
6
|
-
import { useBrowserShortcuts as
|
|
7
|
-
import { ShortcutScopeProvider as
|
|
8
|
-
import { CommandPalette as
|
|
9
|
-
import { Kbd as
|
|
10
|
-
import { ShortcutSettings as
|
|
1
|
+
import { BROWSER_SHORTCUTS as o, deserialiseOverrides as r, fuzzyFilter as m, fuzzyScore as a, getBrowserShortcutInfo as i, getKeySymbol as n, isMac as d, isReservedShortcut as s, keybindingFromEvent as l, keybindingToString as S, keybindingToSymbols as p, keybindingsEqual as u, matchesKeybinding as c, parseKeybinding as y, scopePriority as P, serialiseOverrides as f } from "./utils.js";
|
|
2
|
+
import { LocalStorageAdapter as C, ShortcutRegistry as b } from "./shortcut-registry.js";
|
|
3
|
+
import { CommandPaletteProvider as x, useCommandPalette as v } from "./command-palette-context.js";
|
|
4
|
+
import { useShortcut as k } from "./use-shortcut.js";
|
|
5
|
+
import { useGlobalShortcut as E } from "./use-global-shortcut.js";
|
|
6
|
+
import { useBrowserShortcuts as O } from "./use-browser-shortcuts.js";
|
|
7
|
+
import { ShortcutScopeProvider as B } from "./shortcut-scope-provider.js";
|
|
8
|
+
import { CommandPalette as I, CommandPaletteEmpty as w, CommandPaletteFooter as G, CommandPaletteGroup as L, CommandPaletteInput as q, CommandPaletteItem as A, CommandPaletteList as H, CommandPaletteSeparator as M, CommandPaletteShortcut as U } from "./command-palette.js";
|
|
9
|
+
import { Kbd as _ } from "./kbd.js";
|
|
10
|
+
import { ShortcutSettings as D } from "./shortcut-settings.js";
|
|
11
11
|
export {
|
|
12
12
|
o as BROWSER_SHORTCUTS,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
I as CommandPalette,
|
|
14
|
+
w as CommandPaletteEmpty,
|
|
15
|
+
G as CommandPaletteFooter,
|
|
16
|
+
L as CommandPaletteGroup,
|
|
17
|
+
q as CommandPaletteInput,
|
|
18
|
+
A as CommandPaletteItem,
|
|
19
|
+
H as CommandPaletteList,
|
|
20
|
+
x as CommandPaletteProvider,
|
|
21
|
+
M as CommandPaletteSeparator,
|
|
22
|
+
U as CommandPaletteShortcut,
|
|
23
|
+
_ as Kbd,
|
|
24
|
+
C as LocalStorageAdapter,
|
|
25
|
+
b as ShortcutRegistry,
|
|
26
|
+
B as ShortcutScopeProvider,
|
|
27
|
+
D as ShortcutSettings,
|
|
28
|
+
r as deserialiseOverrides,
|
|
29
|
+
m as fuzzyFilter,
|
|
30
|
+
a as fuzzyScore,
|
|
31
|
+
i as getBrowserShortcutInfo,
|
|
30
32
|
n as getKeySymbol,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
d as isMac,
|
|
34
|
+
s as isReservedShortcut,
|
|
35
|
+
l as keybindingFromEvent,
|
|
36
|
+
S as keybindingToString,
|
|
37
|
+
p as keybindingToSymbols,
|
|
38
|
+
u as keybindingsEqual,
|
|
39
|
+
c as matchesKeybinding,
|
|
40
|
+
y as parseKeybinding,
|
|
41
|
+
P as scopePriority,
|
|
42
|
+
f as serialiseOverrides,
|
|
43
|
+
O as useBrowserShortcuts,
|
|
44
|
+
v as useCommandPalette,
|
|
45
|
+
E as useGlobalShortcut,
|
|
46
|
+
k as useShortcut
|
|
44
47
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommandDefinition, KeyBinding, ShortcutScope } from './utils';
|
|
1
|
+
import { CommandDefinition, KeyBinding, ShortcutScope, ShortcutStorageAdapter } from './utils';
|
|
2
2
|
export type RegistryChangeEvent = {
|
|
3
3
|
type: 'register' | 'unregister' | 'update-keybinding' | 'reset-keybinding' | 'scope-change';
|
|
4
4
|
commandId?: string;
|
|
@@ -9,6 +9,18 @@ export interface ConflictInfo {
|
|
|
9
9
|
conflictingLabel: string;
|
|
10
10
|
scope: ShortcutScope;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Default localStorage-based storage adapter.
|
|
14
|
+
* Maintains backward compatibility with existing localStorage implementation.
|
|
15
|
+
*/
|
|
16
|
+
export declare class LocalStorageAdapter implements ShortcutStorageAdapter {
|
|
17
|
+
private static readonly STORAGE_KEY;
|
|
18
|
+
private static readonly RECENT_COMMANDS_KEY;
|
|
19
|
+
getOverrides(): Map<string, KeyBinding> | null;
|
|
20
|
+
saveOverrides(overrides: Map<string, KeyBinding>): void;
|
|
21
|
+
getRecentCommands(): string[] | null;
|
|
22
|
+
saveRecentCommands(ids: string[]): void;
|
|
23
|
+
}
|
|
12
24
|
export declare class ShortcutRegistry {
|
|
13
25
|
private commands;
|
|
14
26
|
private overrides;
|
|
@@ -16,7 +28,8 @@ export declare class ShortcutRegistry {
|
|
|
16
28
|
private listeners;
|
|
17
29
|
private activeScopes;
|
|
18
30
|
private activeInstance;
|
|
19
|
-
|
|
31
|
+
private storage;
|
|
32
|
+
constructor(storage?: ShortcutStorageAdapter);
|
|
20
33
|
setActiveInstance(instance: string | null): void;
|
|
21
34
|
getActiveInstance(): string | null;
|
|
22
35
|
/**
|
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
1
|
+
import { deserialiseOverrides as h, serialiseOverrides as u, isReservedShortcut as f, keybindingsEqual as m, matchesKeybinding as g, scopePriority as o } from "./utils.js";
|
|
2
|
+
const v = 10;
|
|
3
|
+
class c {
|
|
4
|
+
static STORAGE_KEY = "impact-nova-shortcuts";
|
|
5
|
+
static RECENT_COMMANDS_KEY = "impact-nova-recent-commands";
|
|
6
|
+
getOverrides() {
|
|
7
|
+
if (typeof localStorage > "u") return null;
|
|
8
|
+
try {
|
|
9
|
+
const e = localStorage.getItem(c.STORAGE_KEY);
|
|
10
|
+
return e ? h(e) : null;
|
|
11
|
+
} catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
saveOverrides(e) {
|
|
16
|
+
if (!(typeof localStorage > "u"))
|
|
17
|
+
try {
|
|
18
|
+
localStorage.setItem(c.STORAGE_KEY, u(e));
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
getRecentCommands() {
|
|
23
|
+
if (typeof localStorage > "u") return null;
|
|
24
|
+
try {
|
|
25
|
+
const e = localStorage.getItem(c.RECENT_COMMANDS_KEY);
|
|
26
|
+
if (e) {
|
|
27
|
+
const t = JSON.parse(e);
|
|
28
|
+
return Array.isArray(t) ? t : null;
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
saveRecentCommands(e) {
|
|
36
|
+
if (!(typeof localStorage > "u"))
|
|
37
|
+
try {
|
|
38
|
+
localStorage.setItem(c.RECENT_COMMANDS_KEY, JSON.stringify(e));
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
3
43
|
class C {
|
|
4
44
|
commands = /* @__PURE__ */ new Map();
|
|
5
45
|
overrides = /* @__PURE__ */ new Map();
|
|
@@ -7,8 +47,9 @@ class C {
|
|
|
7
47
|
listeners = /* @__PURE__ */ new Set();
|
|
8
48
|
activeScopes = /* @__PURE__ */ new Set();
|
|
9
49
|
activeInstance = null;
|
|
10
|
-
|
|
11
|
-
|
|
50
|
+
storage;
|
|
51
|
+
constructor(e) {
|
|
52
|
+
this.storage = e ?? new c(), this.activeScopes.add("global"), this.loadOverrides(), this.loadRecentCommands();
|
|
12
53
|
}
|
|
13
54
|
// ─── Instance Management ────────────────────────────────────────────────
|
|
14
55
|
setActiveInstance(e) {
|
|
@@ -58,8 +99,8 @@ class C {
|
|
|
58
99
|
findConflict(e, t, s) {
|
|
59
100
|
for (const [n, r] of this.commands) {
|
|
60
101
|
if (n === e || r.scope !== s) continue;
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
102
|
+
const a = this.getEffectiveKeybinding(n);
|
|
103
|
+
if (a && m(a, t))
|
|
63
104
|
return {
|
|
64
105
|
conflictingCommandId: n,
|
|
65
106
|
conflictingLabel: r.label,
|
|
@@ -99,7 +140,7 @@ class C {
|
|
|
99
140
|
*/
|
|
100
141
|
getPaletteCommands() {
|
|
101
142
|
const t = this.getRegisteredInstances().length > 1;
|
|
102
|
-
return this.getAllCommands().filter((s) => !(s.hidden || s.when && !s.when() || s.instance && t && this.activeInstance && s.instance !== this.activeInstance));
|
|
143
|
+
return this.getAllCommands().filter((s) => !(s.hidden || s.when && !s.when() || !this.activeScopes.has(s.scope) || s.instance && t && this.activeInstance && s.instance !== this.activeInstance));
|
|
103
144
|
}
|
|
104
145
|
/**
|
|
105
146
|
* Get commands for the settings panel (all registered, including hidden).
|
|
@@ -116,13 +157,13 @@ class C {
|
|
|
116
157
|
*/
|
|
117
158
|
handleKeyEvent(e) {
|
|
118
159
|
const t = this.activeScopes.has("modal"), n = this.getRegisteredInstances().length > 1;
|
|
119
|
-
let r = null,
|
|
160
|
+
let r = null, a = -1;
|
|
120
161
|
for (const i of this.commands.values()) {
|
|
121
162
|
if (i.passive) continue;
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
const
|
|
125
|
-
|
|
163
|
+
const d = this.getEffectiveKeybinding(i.id);
|
|
164
|
+
if (d && !(t && i.scope !== "modal") && !(i.instance && n && i.instance !== this.activeInstance) && !(i.when && !i.when()) && g(e, d)) {
|
|
165
|
+
const l = o(i.scope);
|
|
166
|
+
l > a && (r = i, a = l);
|
|
126
167
|
}
|
|
127
168
|
}
|
|
128
169
|
return r ? (e.preventDefault(), e.stopPropagation(), r.handler(), this.addRecentCommand(r.id), !0) : !1;
|
|
@@ -135,7 +176,7 @@ class C {
|
|
|
135
176
|
this.recentCommandIds = [
|
|
136
177
|
e,
|
|
137
178
|
...this.recentCommandIds.filter((t) => t !== e)
|
|
138
|
-
].slice(0,
|
|
179
|
+
].slice(0, v), this.saveRecentCommands();
|
|
139
180
|
}
|
|
140
181
|
// ─── Event System ─────────────────────────────────────────────────────
|
|
141
182
|
subscribe(e) {
|
|
@@ -148,36 +189,21 @@ class C {
|
|
|
148
189
|
}
|
|
149
190
|
// ─── Persistence ──────────────────────────────────────────────────────
|
|
150
191
|
loadOverrides() {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const e = localStorage.getItem(l);
|
|
154
|
-
e && (this.overrides = g(e));
|
|
155
|
-
} catch {
|
|
156
|
-
}
|
|
192
|
+
const e = this.storage.getOverrides();
|
|
193
|
+
e && (this.overrides = e);
|
|
157
194
|
}
|
|
158
195
|
saveOverrides() {
|
|
159
|
-
|
|
160
|
-
try {
|
|
161
|
-
localStorage.setItem(l, v(this.overrides));
|
|
162
|
-
} catch {
|
|
163
|
-
}
|
|
196
|
+
this.storage.saveOverrides(this.overrides);
|
|
164
197
|
}
|
|
165
198
|
loadRecentCommands() {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const e = localStorage.getItem(h);
|
|
169
|
-
e && (this.recentCommandIds = JSON.parse(e));
|
|
170
|
-
} catch {
|
|
171
|
-
}
|
|
199
|
+
const e = this.storage.getRecentCommands();
|
|
200
|
+
e && (this.recentCommandIds = e);
|
|
172
201
|
}
|
|
173
202
|
saveRecentCommands() {
|
|
174
|
-
|
|
175
|
-
try {
|
|
176
|
-
localStorage.setItem(h, JSON.stringify(this.recentCommandIds));
|
|
177
|
-
} catch {
|
|
178
|
-
}
|
|
203
|
+
this.storage.saveRecentCommands(this.recentCommandIds);
|
|
179
204
|
}
|
|
180
205
|
}
|
|
181
206
|
export {
|
|
207
|
+
c as LocalStorageAdapter,
|
|
182
208
|
C as ShortcutRegistry
|
|
183
209
|
};
|
|
@@ -39,6 +39,21 @@ export interface CommandDefinition {
|
|
|
39
39
|
*/
|
|
40
40
|
instance?: string;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Storage adapter for shortcut overrides and recent commands.
|
|
44
|
+
* Allows consumers to provide their own persistence implementation
|
|
45
|
+
* (e.g., IndexedDB, backend API) instead of hardcoded localStorage.
|
|
46
|
+
*/
|
|
47
|
+
export interface ShortcutStorageAdapter {
|
|
48
|
+
/** Load user-defined keybinding overrides */
|
|
49
|
+
getOverrides(): Map<string, KeyBinding> | null;
|
|
50
|
+
/** Save user-defined keybinding overrides */
|
|
51
|
+
saveOverrides(overrides: Map<string, KeyBinding>): void;
|
|
52
|
+
/** Load recent command IDs (most recent first) */
|
|
53
|
+
getRecentCommands(): string[] | null;
|
|
54
|
+
/** Save recent command IDs */
|
|
55
|
+
saveRecentCommands(ids: string[]): void;
|
|
56
|
+
}
|
|
42
57
|
export declare function isMac(): boolean;
|
|
43
58
|
/**
|
|
44
59
|
* Get the display symbol for a modifier or special key.
|