@edv4h/usketch-core 2.4.13 → 2.6.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.
@@ -1,4 +1,5 @@
1
- import type { ActionRegistry, BoardStore, CommandRegistry, EventBus, ExternalContentRegistry, HudRegistry, LayerManager, LodPolicy, RenderMode, SelectionForeground, SelectionForegroundRegistry, ServiceRegistry, ShapeRegistry, ShortcutRegistry, ToolRegistry, TransientRegistry, UiRegistry, UsketchPlugin } from "@edv4h/usketch-shared";
1
+ import { type ActionRegistry, type BoardHeightApi, type BoardStore, type CommandRegistry, type EventBus, type ExternalContentRegistry, type HudRegistry, type LayerManager, type LodPolicy, type RenderMode, type SelectionForeground, type SelectionForegroundRegistry, type SelectionHandleRegistry, type ServiceRegistry, type ShapeRegistry, type ShortcutRegistry, type ToolRegistry, type TransientRegistry, type UiRegistry, type UsketchPlugin } from "@edv4h/usketch-shared";
2
+ import { type CreateKeymapOptions, type KeymapInternal } from "./keymap.js";
2
3
  import { type LodControllerInternal } from "./lod/index.js";
3
4
  export interface AppInstance {
4
5
  store: BoardStore;
@@ -7,12 +8,16 @@ export interface AppInstance {
7
8
  shapes: ShapeRegistry;
8
9
  commands: CommandRegistry;
9
10
  shortcuts: ShortcutRegistry;
11
+ /** Every key binding (shortcuts, tool keys, held keys) + overlap detection. */
12
+ keymap: KeymapInternal;
10
13
  events: EventBus;
11
14
  transient: TransientRegistry;
12
15
  lod: LodControllerInternal;
13
16
  ui: UiRegistry;
14
17
  /** Exposed so canvas-engine can subscribe to the active entry. */
15
18
  selectionForeground: SelectionForegroundRegistry;
19
+ /** Handles plugins add to the selection UI (same object as `ui.selectionHandles`). */
20
+ selectionHandles: SelectionHandleRegistry;
16
21
  /** Exposed so canvas-engine can dispatch drop/paste content. */
17
22
  externalContent: ExternalContentRegistry;
18
23
  /** Enumerable declarative plugin operations (control HUD / command palette). */
@@ -21,6 +26,8 @@ export interface AppInstance {
21
26
  hud: HudRegistry;
22
27
  /** String-keyed slot for plugin-provided services (IoC). */
23
28
  services: ServiceRegistry;
29
+ /** The board's height (ground + solid providers); the plugins' `ctx.height`. */
30
+ height: BoardHeightApi;
24
31
  plugins: readonly UsketchPlugin[];
25
32
  destroy(): void;
26
33
  }
@@ -43,6 +50,15 @@ export interface CreateAppOptions {
43
50
  * to override.
44
51
  */
45
52
  selectionForeground?: Pick<SelectionForeground, "render"> & Partial<Pick<SelectionForeground, "priority" | "order" | "fixed">>;
53
+ /**
54
+ * Key bindings: host defaults by binding id (`keys`), the viewer's saved rebindings
55
+ * (`overrides`), who gets a shared key (`conflictPolicy`, default `"first"`; can be
56
+ * switched later with `app.keymap.setConflictPolicy`), and whether to `console.warn`
57
+ * the overlapping keys once the plugins are set up (`warnConflicts`, default false).
58
+ */
59
+ keymap?: CreateKeymapOptions & {
60
+ warnConflicts?: boolean;
61
+ };
46
62
  }
47
63
  export declare function createApp(options: CreateAppOptions): Promise<AppInstance>;
48
64
  //# sourceMappingURL=create-app.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,cAAc,EACd,UAAU,EACV,eAAe,EACf,QAAQ,EACR,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,SAAS,EAIT,UAAU,EACV,mBAAmB,EACnB,2BAA2B,EAC3B,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAKN,KAAK,qBAAqB,EAC1B,MAAM,gBAAgB,CAAC;AAYxB,MAAM,WAAW,WAAW;IAC3B,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IAC1B,SAAS,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,GAAG,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,SAAS,CAAC;QACnB,WAAW,CAAC,EAAE,UAAU,CAAC;KACzB,CAAC;IACF;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GACxD,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IACpE;;;;;OAKG;IACH,MAAM,CAAC,EAAE,mBAAmB,GAAG;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3D;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CA0N/E"}
@@ -1,34 +1,55 @@
1
+ import { boardHeight, createShapeSolids, shapeSolidsService, } from "@edv4h/usketch-shared";
1
2
  import { createActionRegistry } from "./action-registry.js";
2
3
  import { createCommandRegistry } from "./command-registry.js";
3
4
  import { createEventBus } from "./event-bus.js";
4
5
  import { createExternalContentRegistry } from "./external-content-registry.js";
5
6
  import { createHudRegistry } from "./hud-registry.js";
7
+ import { createKeymap, describeConflicts, scopeKeymap, } from "./keymap.js";
6
8
  import { createLayerManager } from "./layer-manager.js";
7
9
  import { createCompositeLodPolicy, createLodController, createShapeCountLodPolicy, createZoomLodPolicy, } from "./lod/index.js";
8
10
  import { createPluginRegistry } from "./plugin-registry.js";
9
11
  import { createSelectionForegroundRegistry } from "./selection-foreground-registry.js";
12
+ import { createSelectionHandleRegistry } from "./selection-handle-registry.js";
10
13
  import { createServiceRegistry } from "./service-registry.js";
11
14
  import { createShapeRegistry } from "./shape-registry.js";
12
15
  import { createShortcutRegistry } from "./shortcut-registry.js";
13
16
  import { createToolRegistry } from "./tool-registry.js";
17
+ import { createToolShortcutBridge } from "./tool-shortcut-bridge.js";
14
18
  import { createTransientRegistry } from "./transient-registry.js";
15
19
  /** Internal id used when `CreateAppOptions.selectionForeground` is provided. */
16
20
  const APP_SELECTION_FOREGROUND_ID = "__app:selectionForeground";
17
21
  export async function createApp(options) {
18
22
  const { store, plugins } = options;
19
23
  const layers = createLayerManager();
20
- const tools = createToolRegistry();
21
24
  const shapes = createShapeRegistry();
22
25
  const commands = createCommandRegistry();
23
- const shortcuts = createShortcutRegistry();
26
+ const keymap = createKeymap(options.keymap);
27
+ const shortcutIds = new Set();
28
+ const shortcuts = createShortcutRegistry(keymap, {}, shortcutIds);
29
+ const baseTools = createToolRegistry();
30
+ const toolBindings = new Map();
31
+ const tools = createToolShortcutBridge(baseTools, keymap, store, {}, toolBindings);
24
32
  const events = createEventBus();
25
33
  const transient = createTransientRegistry();
26
34
  const actions = createActionRegistry();
27
35
  const hud = createHudRegistry();
28
36
  const services = createServiceRegistry();
37
+ const height = boardHeight(services);
38
+ // The solids 3D shapes make (`view3d.collision`): a solid provider on the board's height.
39
+ const shapeSolids = createShapeSolids({
40
+ shapes: () => store.getShapes(),
41
+ typeView3d: (type) => shapes.getView3d?.(type) ?? shapes.get(type)?.view3d,
42
+ groundAt: (x, y) => height.groundAt(x, y),
43
+ view3dAmount: () => store.getView3d?.().amount ?? 0,
44
+ });
45
+ const unregisterShapeSolids = height.register(shapeSolids.provider);
46
+ const unprovideShapeSolids = shapeSolidsService.provide(services, shapeSolids);
47
+ const offShapeView3d = shapes.subscribeView3d?.(() => shapeSolids.invalidate());
29
48
  const selectionForeground = createSelectionForegroundRegistry();
49
+ const selectionHandles = createSelectionHandleRegistry();
30
50
  const ui = {
31
51
  registerSelectionForeground: (entry) => selectionForeground.register(entry),
52
+ selectionHandles,
32
53
  };
33
54
  const externalContent = createExternalContentRegistry(() => ({
34
55
  store,
@@ -58,6 +79,7 @@ export async function createApp(options) {
58
79
  shapes,
59
80
  commands,
60
81
  shortcuts,
82
+ keymap: scopeKeymap(keymap, {}),
61
83
  events,
62
84
  transient,
63
85
  lod,
@@ -67,6 +89,7 @@ export async function createApp(options) {
67
89
  hud,
68
90
  plugins: pluginInfo,
69
91
  services,
92
+ height,
70
93
  };
71
94
  // Bridge store mutations to EventBus
72
95
  const unsubMutation = store.onMutation((event) => {
@@ -79,7 +102,7 @@ export async function createApp(options) {
79
102
  // plugins don't leak state.
80
103
  const teardowns = [];
81
104
  try {
82
- for (const plugin of plugins) {
105
+ for (const [index, plugin] of plugins.entries()) {
83
106
  pluginRegistry.register(plugin);
84
107
  // Per-plugin scoped context: `actions`/`hud` registrations (including any
85
108
  // made later from callbacks) are auto-attributed to this plugin's id.
@@ -101,7 +124,17 @@ export async function createApp(options) {
101
124
  getPanels: hud.getPanels,
102
125
  subscribe: hud.subscribe,
103
126
  };
104
- const scopedCtx = { ...ctx, actions: scopedActions, hud: scopedHud };
127
+ // Key bindings (incl. `shortcuts.register` and tool `shortcut`s) are attributed to
128
+ // the plugin and ranked by its position in `plugins` (earlier wins ties).
129
+ const keyOwner = { pluginId: plugin.id, index };
130
+ const scopedCtx = {
131
+ ...ctx,
132
+ actions: scopedActions,
133
+ hud: scopedHud,
134
+ keymap: scopeKeymap(keymap, keyOwner),
135
+ shortcuts: createShortcutRegistry(keymap, keyOwner, shortcutIds),
136
+ tools: createToolShortcutBridge(baseTools, keymap, store, keyOwner, toolBindings),
137
+ };
105
138
  const teardown = await plugin.setup(scopedCtx);
106
139
  if (typeof teardown === "function") {
107
140
  teardowns.push(teardown);
@@ -129,6 +162,14 @@ export async function createApp(options) {
129
162
  label: "Redo",
130
163
  category: "history",
131
164
  });
165
+ if (options.keymap?.warnConflicts) {
166
+ const conflicts = keymap.getConflicts();
167
+ if (conflicts.length > 0) {
168
+ const policy = keymap.getConflictPolicy();
169
+ const single = policy === "first" || policy === "last";
170
+ console.warn(`[usketch] ${conflicts.length} key(s) are bound by more than one operation (conflict policy: ${typeof policy === "function" ? "custom" : policy}${single ? ", ▶ = gets the key when all act" : ""}):\n${describeConflicts(conflicts, single)}`);
171
+ }
172
+ }
132
173
  // App-level selection foreground option is registered AFTER plugin setup
133
174
  // so it wins on ties against a plugin that registered priority 100.
134
175
  if (options.selectionForeground) {
@@ -149,15 +190,18 @@ export async function createApp(options) {
149
190
  shapes,
150
191
  commands,
151
192
  shortcuts,
193
+ keymap,
152
194
  events,
153
195
  transient,
154
196
  lod,
155
197
  ui,
156
198
  selectionForeground,
199
+ selectionHandles,
157
200
  externalContent,
158
201
  actions,
159
202
  hud,
160
203
  services,
204
+ height,
161
205
  plugins: pluginRegistry.getAll(),
162
206
  destroy() {
163
207
  if (destroyed)
@@ -178,6 +222,9 @@ export async function createApp(options) {
178
222
  }
179
223
  lod.destroy();
180
224
  unsubMutation();
225
+ offShapeView3d?.();
226
+ unprovideShapeSolids();
227
+ unregisterShapeSolids();
181
228
  },
182
229
  };
183
230
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-app.js","sourceRoot":"","sources":["../src/create-app.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EACN,wBAAwB,EACxB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAA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MAAM,EAAE;QAChC,OAAO;YACN,IAAI,SAAS;gBAAE,OAAO;YACtB,SAAS,GAAG,IAAI,CAAC;YACjB,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC;gBACjD,IAAI,CAAC;oBACJ,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;oBAC1B,IAAI,MAAM,IAAI,OAAQ,MAA2B,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;wBACvE,MAA2B,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;4BAC5C,OAAO,CAAC,KAAK,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAC;wBAClE,CAAC,CAAC,CAAC;oBACJ,CAAC;gBACF,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;gBACzD,CAAC;YACF,CAAC;YACD,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,aAAa,EAAE,CAAC;YAChB,cAAc,EAAE,EAAE,CAAC;YACnB,oBAAoB,EAAE,CAAC;YACvB,qBAAqB,EAAE,CAAC;QACzB,CAAC;KACD,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -5,11 +5,15 @@ export type { AppInstance, CreateAppOptions } from "./create-app.js";
5
5
  export { createApp } from "./create-app.js";
6
6
  export { createEventBus } from "./event-bus.js";
7
7
  export { createExternalContentRegistry } from "./external-content-registry.js";
8
+ export { type ComboOptions, type CreateKeymapOptions, codeToKey, createKeymap, describeConflicts, eventToCombo, eventToCombos, type KeymapInternal, type KeymapOwner, type ModKeyMode, normalizeCombo, scopeKeymap, } from "./keymap.js";
9
+ export { bindKeymapStorage, type KeymapOverrides, type KeymapStorage, type LocalStorageKeymapStorageOptions, localStorageKeymapStorage, parseKeymapOverrides, } from "./keymap-storage.js";
10
+ export { type AssignKeyOptions, type AssignKeyResult, assignKey, bindingsUsingKey, comboFromKeyEvent, DEFAULT_RESERVED_COMBOS, type FormatComboOptions, type FormatKeyCodeOptions, formatBindingKey, formatCombo, formatKeyCode, isReservedCombo, type ReservedComboOptions, unassignKey, } from "./keymap-ui.js";
8
11
  export { createLayerManager } from "./layer-manager.js";
9
12
  export type { CreateLodControllerOptions, LodControllerInternal } from "./lod/index.js";
10
13
  export { createCompositeLodPolicy, createFpsLodPolicy, createLodController, createShapeCountLodPolicy, createZoomLodPolicy, } from "./lod/index.js";
11
14
  export { createPluginRegistry } from "./plugin-registry.js";
12
15
  export { createSelectionForegroundRegistry } from "./selection-foreground-registry.js";
16
+ export { createSelectionHandleRegistry } from "./selection-handle-registry.js";
13
17
  export { createServiceRegistry } from "./service-registry.js";
14
18
  export { createShapeRegistry } from "./shape-registry.js";
15
19
  export { createShortcutRegistry } from "./shortcut-registry.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAO5D,eAAO,MAAM,oBAAoB,EAAE,MAAM,cAAyC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,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,gBAAgB,EAChB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,eAAe,EACf,KAAK,oBAAoB,EACzB,WAAW,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACxF,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -8,10 +8,14 @@ export { createCommandRegistry } from "./command-registry.js";
8
8
  export { createApp } from "./create-app.js";
9
9
  export { createEventBus } from "./event-bus.js";
10
10
  export { createExternalContentRegistry } from "./external-content-registry.js";
11
+ export { codeToKey, createKeymap, describeConflicts, eventToCombo, eventToCombos, normalizeCombo, scopeKeymap, } from "./keymap.js";
12
+ export { bindKeymapStorage, localStorageKeymapStorage, parseKeymapOverrides, } from "./keymap-storage.js";
13
+ export { assignKey, bindingsUsingKey, comboFromKeyEvent, DEFAULT_RESERVED_COMBOS, formatBindingKey, formatCombo, formatKeyCode, isReservedCombo, unassignKey, } from "./keymap-ui.js";
11
14
  export { createLayerManager } from "./layer-manager.js";
12
15
  export { createCompositeLodPolicy, createFpsLodPolicy, createLodController, createShapeCountLodPolicy, createZoomLodPolicy, } from "./lod/index.js";
13
16
  export { createPluginRegistry } from "./plugin-registry.js";
14
17
  export { createSelectionForegroundRegistry } from "./selection-foreground-registry.js";
18
+ export { createSelectionHandleRegistry } from "./selection-handle-registry.js";
15
19
  export { createServiceRegistry } from "./service-registry.js";
16
20
  export { createShapeRegistry } from "./shape-registry.js";
17
21
  export { createShortcutRegistry } from "./shortcut-registry.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAExF,kFAAkF;AAClF,gFAAgF;AAChF,8EAA8E;AAC9E,kEAAkE;AAClE,MAAM,CAAC,MAAM,oBAAoB,GAAyB,wBAAwB,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EACN,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iCAAiC,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;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CAAC;AACvF,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Keymap } from "@edv4h/usketch-shared";
2
+ export type KeymapOverrides = Readonly<Record<string, readonly string[] | null>>;
3
+ /** A place to keep the viewer's rebindings ({@link Keymap.getOverrides}). */
4
+ export interface KeymapStorage {
5
+ /** The saved rebindings, or undefined when nothing is saved (or it can't be read). */
6
+ load(): KeymapOverrides | undefined;
7
+ save(overrides: KeymapOverrides): void;
8
+ /** Optional: call back when the saved value changes elsewhere (another tab). */
9
+ subscribe?(listener: () => void): () => void;
10
+ }
11
+ /**
12
+ * Rebindings from untrusted input (a JSON blob, a settings API): keeps entries whose
13
+ * value is `null` or an array of strings and drops the rest. Undefined when `value`
14
+ * isn't an object.
15
+ */
16
+ export declare function parseKeymapOverrides(value: unknown): KeymapOverrides | undefined;
17
+ /**
18
+ * Load the saved rebindings into `keymap` (over any made before binding), save whenever the viewer changes them, and
19
+ * reload when the storage reports a change from elsewhere. Saves only when the
20
+ * rebindings actually changed (registrations also notify the keymap). Returns a
21
+ * function that stops syncing.
22
+ */
23
+ export declare function bindKeymapStorage(keymap: Keymap, storage: KeymapStorage): () => void;
24
+ export interface LocalStorageKeymapStorageOptions {
25
+ /** Default `"usketch:keymap"`. */
26
+ key?: string;
27
+ /** Default `globalThis.localStorage`. */
28
+ storage?: Storage;
29
+ }
30
+ /**
31
+ * A {@link KeymapStorage} on `localStorage` (per viewer and browser), following other
32
+ * tabs through the `storage` event. Read / write failures (private mode, quota) are
33
+ * ignored.
34
+ */
35
+ export declare function localStorageKeymapStorage(options?: LocalStorageKeymapStorageOptions): KeymapStorage;
36
+ //# sourceMappingURL=keymap-storage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap-storage.d.ts","sourceRoot":"","sources":["../src/keymap-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AAEjF,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC7B,sFAAsF;IACtF,IAAI,IAAI,eAAe,GAAG,SAAS,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,gFAAgF;IAChF,SAAS,CAAC,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAQhF;AAQD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,IAAI,CAqDpF;AAED,MAAM,WAAW,gCAAgC;IAChD,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,GAAE,gCAAqC,GAC5C,aAAa,CAqCf"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Rebindings from untrusted input (a JSON blob, a settings API): keeps entries whose
3
+ * value is `null` or an array of strings and drops the rest. Undefined when `value`
4
+ * isn't an object.
5
+ */
6
+ export function parseKeymapOverrides(value) {
7
+ if (typeof value !== "object" || value === null || Array.isArray(value))
8
+ return undefined;
9
+ const out = {};
10
+ for (const [id, keys] of Object.entries(value)) {
11
+ if (keys === null)
12
+ out[id] = null;
13
+ else if (Array.isArray(keys) && keys.every((k) => typeof k === "string"))
14
+ out[id] = [...keys];
15
+ }
16
+ return out;
17
+ }
18
+ const serialize = (overrides) => {
19
+ const sorted = {};
20
+ for (const id of Object.keys(overrides).sort())
21
+ sorted[id] = overrides[id] ?? null;
22
+ return JSON.stringify(sorted);
23
+ };
24
+ /**
25
+ * Load the saved rebindings into `keymap` (over any made before binding), save whenever the viewer changes them, and
26
+ * reload when the storage reports a change from elsewhere. Saves only when the
27
+ * rebindings actually changed (registrations also notify the keymap). Returns a
28
+ * function that stops syncing.
29
+ */
30
+ export function bindKeymapStorage(keymap, storage) {
31
+ let last = serialize(keymap.getOverrides());
32
+ let applying = false;
33
+ // On start, the saved rebindings go over any made before (e.g. ones a plugin carried
34
+ // over from older storage of its own), and the result is saved if it differs. A later
35
+ // change to "nothing saved" (another tab reset everything) means no rebindings.
36
+ const apply = (initial) => {
37
+ const stored = storage.load();
38
+ if (initial) {
39
+ const current = keymap.getOverrides();
40
+ const merged = stored ? { ...current, ...stored } : current;
41
+ const text = serialize(merged);
42
+ if (text !== serialize(current)) {
43
+ applying = true;
44
+ try {
45
+ keymap.setOverrides(merged);
46
+ }
47
+ finally {
48
+ applying = false;
49
+ }
50
+ }
51
+ last = text;
52
+ if (text !== serialize(stored ?? {}))
53
+ storage.save(merged);
54
+ return;
55
+ }
56
+ const loaded = stored ?? {};
57
+ const text = serialize(loaded);
58
+ if (text === last)
59
+ return;
60
+ applying = true;
61
+ try {
62
+ keymap.setOverrides(loaded);
63
+ }
64
+ finally {
65
+ applying = false;
66
+ }
67
+ last = text;
68
+ };
69
+ apply(true);
70
+ const offKeymap = keymap.subscribe(() => {
71
+ if (applying)
72
+ return;
73
+ const current = keymap.getOverrides();
74
+ const text = serialize(current);
75
+ if (text === last)
76
+ return;
77
+ last = text;
78
+ storage.save(current);
79
+ });
80
+ const offStorage = storage.subscribe?.(() => apply(false));
81
+ return () => {
82
+ offKeymap();
83
+ offStorage?.();
84
+ };
85
+ }
86
+ /**
87
+ * A {@link KeymapStorage} on `localStorage` (per viewer and browser), following other
88
+ * tabs through the `storage` event. Read / write failures (private mode, quota) are
89
+ * ignored.
90
+ */
91
+ export function localStorageKeymapStorage(options = {}) {
92
+ const key = options.key ?? "usketch:keymap";
93
+ const area = () => {
94
+ try {
95
+ return options.storage ?? globalThis.localStorage;
96
+ }
97
+ catch {
98
+ return undefined;
99
+ }
100
+ };
101
+ return {
102
+ load() {
103
+ try {
104
+ const raw = area()?.getItem(key);
105
+ return raw ? parseKeymapOverrides(JSON.parse(raw)) : undefined;
106
+ }
107
+ catch {
108
+ return undefined;
109
+ }
110
+ },
111
+ save(overrides) {
112
+ try {
113
+ const target = area();
114
+ if (!target)
115
+ return;
116
+ if (Object.keys(overrides).length === 0)
117
+ target.removeItem(key);
118
+ else
119
+ target.setItem(key, JSON.stringify(overrides));
120
+ }
121
+ catch {
122
+ // Not persisted; the in-memory keymap still has the change.
123
+ }
124
+ },
125
+ subscribe(listener) {
126
+ if (typeof window === "undefined")
127
+ return () => { };
128
+ const onStorage = (event) => {
129
+ if (event.key === key || event.key === null)
130
+ listener();
131
+ };
132
+ window.addEventListener("storage", onStorage);
133
+ return () => window.removeEventListener("storage", onStorage);
134
+ },
135
+ };
136
+ }
137
+ //# sourceMappingURL=keymap-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap-storage.js","sourceRoot":"","sources":["../src/keymap-storage.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC1F,MAAM,GAAG,GAA6C,EAAE,CAAC;IACzD,KAAK,MAAM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C;gBACR,4DAA4D;YAC7D,CAAC;QACF,CAAC;QACD,SAAS,CAAC,QAAQ;YACjB,IAAI,OAAO,MAAM,KAAK,WAAW;gBAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;YACnD,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAQ,EAAE;gBAC/C,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,KAAK,IAAI;oBAAE,QAAQ,EAAE,CAAC;YACzD,CAAC,CAAC;YACF,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC9C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC/D,CAAC;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,72 @@
1
+ import type { KeyBinding, KeyBindingKind, Keymap } from "@edv4h/usketch-shared";
2
+ import { type ComboOptions } from "./keymap.js";
3
+ export interface FormatComboOptions {
4
+ /** Default: detected from `navigator`. */
5
+ isMac?: boolean;
6
+ }
7
+ /**
8
+ * A combo for display: `"Mod+Shift+Z"` → `⇧⌘Z` on macOS (Apple's ⌃⌥⇧⌘ order) and
9
+ * `Ctrl+Shift+Z` elsewhere. `Shift+/` is shown as `?`.
10
+ */
11
+ export declare function formatCombo(combo: string, options?: FormatComboOptions): string;
12
+ export interface FormatKeyCodeOptions extends FormatComboOptions {
13
+ /**
14
+ * Prefixes for the left / right copy of a modifier (`ShiftLeft` …), so two bindings
15
+ * on either side read apart. Default `{ left: "Left ", right: "Right " }`.
16
+ */
17
+ sides?: {
18
+ left: string;
19
+ right: string;
20
+ };
21
+ }
22
+ /**
23
+ * A held key (`KeyboardEvent.code`) for display: `"KeyW"` → `W`, `"ShiftLeft"` →
24
+ * `Left Shift` (`Left ⇧` on macOS).
25
+ */
26
+ export declare function formatKeyCode(code: string, options?: FormatKeyCodeOptions): string;
27
+ /** {@link formatCombo} or {@link formatKeyCode}, by the binding's kind. */
28
+ export declare function formatBindingKey(kind: KeyBindingKind, key: string, options?: FormatKeyCodeOptions): string;
29
+ /** Browser / OS shortcuts a page can't (or shouldn't) take over. */
30
+ export declare const DEFAULT_RESERVED_COMBOS: readonly string[];
31
+ export interface ReservedComboOptions {
32
+ /** Combos viewers may not bind (default {@link DEFAULT_RESERVED_COMBOS}). */
33
+ reserved?: readonly string[];
34
+ /** Whether a key without Mod / Ctrl / Meta / Alt / Shift may be bound (default true). */
35
+ allowBareKeys?: boolean;
36
+ }
37
+ /**
38
+ * Whether a viewer may not bind `combo` (a `"press"` combo): modifier-only or several
39
+ * keys at once, a bare key when `allowBareKeys` is false, or one of `reserved`.
40
+ */
41
+ export declare function isReservedCombo(combo: string, options?: ReservedComboOptions): boolean;
42
+ /**
43
+ * The combo to store when a viewer presses a key to rebind a `"press"` binding, in
44
+ * {@link normalizeCombo} form (platform-independent: the accelerator becomes `mod`).
45
+ * Shifted symbols / digits are read by physical key (`Shift+1`, not `Shift+!`).
46
+ * Returns null while only modifiers are down.
47
+ */
48
+ export declare function comboFromKeyEvent(event: KeyboardEvent, options?: ComboOptions): string | null;
49
+ /** Bindings (other than `exceptId`) that use `key`, as the keymap's overlap check sees it. */
50
+ export declare function bindingsUsingKey(keymap: Keymap, key: string, kind?: KeyBindingKind, exceptId?: string): KeyBinding[];
51
+ export interface AssignKeyOptions {
52
+ /** Replace the key at this position (default: add it after the others). */
53
+ slot?: number;
54
+ /**
55
+ * Take the key away from the other (customizable) bindings that use it, so it isn't
56
+ * shared (default false: keep the overlap and let the conflict policy decide).
57
+ */
58
+ steal?: boolean;
59
+ }
60
+ export interface AssignKeyResult {
61
+ /** False when the binding is unknown or not customizable (nothing changed). */
62
+ ok: boolean;
63
+ /** Ids the key was taken from (`steal`). */
64
+ stolenFrom: string[];
65
+ /** Ids that still share the key afterwards (not customizable, or `steal` off). */
66
+ sharedWith: string[];
67
+ }
68
+ /** Bind `key` to `id` for the viewer (see {@link AssignKeyOptions}). */
69
+ export declare function assignKey(keymap: Keymap, id: string, key: string, options?: AssignKeyOptions): AssignKeyResult;
70
+ /** Remove `key` from `id` for the viewer. Returns false when nothing changed. */
71
+ export declare function unassignKey(keymap: Keymap, id: string, key: string): boolean;
72
+ //# sourceMappingURL=keymap-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keymap-ui.d.ts","sourceRoot":"","sources":["../src/keymap-ui.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,KAAK,YAAY,EAA6B,MAAM,aAAa,CAAC;AA0C3E,MAAM,WAAW,kBAAkB;IAClC,0CAA0C;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,MAAM,CAwBnF;AAED,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC/D;;;OAGG;IACH,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACxC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,MAAM,CAOtF;AAED,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,oBAAyB,GAChC,MAAM,CAER;AAED,oEAAoE;AACpE,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAQpD,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7B,yFAAyF;IACzF,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;GAG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