1 | import { Emitter, Event } from '../../common/event';
|
2 | import { ILogger } from '../../common/logger';
|
3 | import { Deferred } from '../../common/promise-util';
|
4 | import { NativeKeyboardLayout, KeyboardLayoutProvider, KeyboardLayoutChangeNotifier, KeyValidator, KeyValidationInput } from '../../common/keyboard/keyboard-layout-provider';
|
5 | import { LocalStorageService } from '../storage-service';
|
6 | export declare type KeyboardLayoutSource = 'navigator.keyboard' | 'user-choice' | 'pressed-keys';
|
7 | export declare class BrowserKeyboardLayoutProvider implements KeyboardLayoutProvider, KeyboardLayoutChangeNotifier, KeyValidator {
|
8 | protected readonly logger: ILogger;
|
9 | protected readonly storageService: LocalStorageService;
|
10 | protected readonly initialized: Deferred<void>;
|
11 | protected readonly nativeLayoutChanged: Emitter<NativeKeyboardLayout>;
|
12 | get onDidChangeNativeLayout(): Event<NativeKeyboardLayout>;
|
13 | protected readonly tester: KeyboardTester;
|
14 | protected source: KeyboardLayoutSource;
|
15 | protected currentLayout: KeyboardLayoutData;
|
16 | get allLayoutData(): KeyboardLayoutData[];
|
17 | get currentLayoutData(): KeyboardLayoutData;
|
18 | get currentLayoutSource(): KeyboardLayoutSource;
|
19 | protected initialize(): Promise<void>;
|
20 | getNativeLayout(): Promise<NativeKeyboardLayout>;
|
21 | |
22 |
|
23 |
|
24 | setLayoutData(layout: KeyboardLayoutData | 'autodetect'): Promise<KeyboardLayoutData>;
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | validateKey(keyCode: KeyValidationInput): void;
|
32 | protected setCurrent(layout: KeyboardLayoutData, source: KeyboardLayoutSource): void;
|
33 | protected autodetect(): Promise<[KeyboardLayoutData, KeyboardLayoutSource]>;
|
34 | |
35 |
|
36 |
|
37 | protected testLayoutMap(layoutMap: KeyboardLayoutMap): void;
|
38 | |
39 |
|
40 |
|
41 |
|
42 | protected selectLayout(): KeyboardLayoutData;
|
43 | protected saveState(): Promise<void>;
|
44 | protected loadState(): Promise<void>;
|
45 | }
|
46 | export interface KeyboardLayoutData {
|
47 | name: string;
|
48 | hardware: 'pc' | 'mac';
|
49 | language: string;
|
50 | raw: NativeKeyboardLayout;
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 | export declare const DEFAULT_LAYOUT_DATA: KeyboardLayoutData;
|
57 | export interface LayoutProviderState {
|
58 | tester?: KeyboardTesterState;
|
59 | source?: KeyboardLayoutSource;
|
60 | currentLayout?: string;
|
61 | }
|
62 | export interface KeyboardTesterState {
|
63 | scores?: {
|
64 | [id: string]: number;
|
65 | };
|
66 | topScore?: number;
|
67 | testedInputs?: {
|
68 | [key: string]: string;
|
69 | };
|
70 | }
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | export declare class KeyboardTester {
|
77 | readonly candidates: KeyboardLayoutData[];
|
78 | readonly scores: number[];
|
79 | topScore: number;
|
80 | private readonly testedInputs;
|
81 | get inputCount(): number;
|
82 | constructor(candidates: KeyboardLayoutData[]);
|
83 | reset(): void;
|
84 | updateScores(input: KeyValidationInput): boolean;
|
85 | protected testCandidate(candidate: KeyboardLayoutData, input: KeyValidationInput, property: 'value' | 'withShift' | 'withAltGr' | 'withShiftAltGr'): number;
|
86 | getState(): KeyboardTesterState;
|
87 | setState(state: KeyboardTesterState): void;
|
88 | }
|
89 | declare type KeyboardLayoutMap = Map<string, string>;
|
90 | export {};
|
91 |
|
\ | No newline at end of file |