1 | import { Disposable } from '../common';
|
2 | import { Emitter, Event } from '../common/event';
|
3 | export declare type ContextKeyValue = null | undefined | boolean | number | string | Array<null | undefined | boolean | number | string> | Record<string, null | undefined | boolean | number | string>;
|
4 | export interface ContextKey<T extends ContextKeyValue = ContextKeyValue> {
|
5 | set(value: T | undefined): void;
|
6 | reset(): void;
|
7 | get(): T | undefined;
|
8 | }
|
9 | export declare namespace ContextKey {
|
10 | const None: ContextKey<any>;
|
11 | }
|
12 | export interface ContextKeyChangeEvent {
|
13 | affects(keys: {
|
14 | has(key: string): boolean;
|
15 | }): boolean;
|
16 | }
|
17 | export declare const ContextKeyService: unique symbol;
|
18 | export interface ContextMatcher extends Disposable {
|
19 | |
20 |
|
21 |
|
22 | match(expression: string, context?: HTMLElement): boolean;
|
23 | }
|
24 | export interface ContextKeyService extends ContextMatcher {
|
25 | readonly onDidChange: Event<ContextKeyChangeEvent>;
|
26 | createKey<T extends ContextKeyValue>(key: string, defaultValue: T | undefined): ContextKey<T>;
|
27 | |
28 |
|
29 |
|
30 | parseKeys(expression: string): Set<string> | undefined;
|
31 | |
32 |
|
33 |
|
34 |
|
35 | with<T>(values: Record<string, unknown>, callback: () => T): T;
|
36 | /**
|
37 | * Creates a child service with a separate context scoped to the HTML element passed in.
|
38 | * Useful for e.g. setting the {view} context value for particular widgets.
|
39 | */
|
40 | createScoped(target: HTMLElement): ScopedValueStore;
|
41 | /**
|
42 | * @param overlay values to be used in the new {@link ContextKeyService}. These values will be static.
|
43 | * Creates a child service with a separate context and a set of fixed values to override parent values.
|
44 | */
|
45 | createOverlay(overlay: Iterable<[string, unknown]>): ContextMatcher;
|
46 | /**
|
47 | * Set or modify a value in the service's context.
|
48 | */
|
49 | setContext(key: string, value: unknown): void;
|
50 | }
|
51 | export declare type ScopedValueStore = Omit<ContextKeyService, 'onDidChange' | 'match' | 'parseKeys' | 'with' | 'createOverlay'>;
|
52 | export declare class ContextKeyServiceDummyImpl implements ContextKeyService {
|
53 | protected readonly onDidChangeEmitter: Emitter<ContextKeyChangeEvent>;
|
54 | readonly onDidChange: Event<ContextKeyChangeEvent>;
|
55 | protected fireDidChange(event: ContextKeyChangeEvent): void;
|
56 | createKey<T extends ContextKeyValue>(key: string, defaultValue: T | undefined): ContextKey<T>;
|
57 | /**
|
58 | * It should be implemented by an extension, e.g. by the monaco extension.
|
59 | */
|
60 | match(expression: string, context?: HTMLElement): boolean;
|
61 | /**
|
62 | * It should be implemented by an extension, e.g. by the monaco extension.
|
63 | */
|
64 | parseKeys(expression: string): Set<string> | undefined;
|
65 | /**
|
66 | * Details should be implemented by an extension, e.g. by the monaco extension.
|
67 | * Callback must be synchronous.
|
68 | */
|
69 | with<T>(values: Record<string, unknown>, callback: () => T): T;
|
70 | /**
|
71 | * Details should implemented by an extension, e.g. by the monaco extension.
|
72 | */
|
73 | createScoped(target: HTMLElement): ContextKeyService;
|
74 | /**
|
75 | * Details should be implemented by an extension, e.g. the monaco extension.
|
76 | */
|
77 | createOverlay(overlay: Iterable<[string, unknown]>): ContextMatcher;
|
78 | /**
|
79 | * Details should be implemented by an extension, e.g. by the monaco extension.
|
80 | */
|
81 | setContext(key: string, value: unknown): void;
|
82 | dispose(): void;
|
83 | }
|
84 | //# sourceMappingURL=context-key-service.d.ts.map |
\ | No newline at end of file |