Repository navigation
Expand file tree
/
Copy pathglobal.d.ts
More file actions
253 lines (207 loc) · 6.25 KB
/
Copy pathglobal.d.ts
File metadata and controls
253 lines (207 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/// <reference types="user-agent-data-types" />
declare module '*.css';
declare module '*.scss';
declare const APP_VERSION: string;
declare module 'virtual:git-info' {
export const APP_REVISION: string;
}
interface ImportMetaEnv {
readonly TG_APP_ENV: string;
readonly TG_APP_NAME?: string;
readonly TG_APP_TITLE: string;
readonly TG_PUBLIC_URL: string;
readonly TG_TELEGRAM_API_HASH?: string;
readonly TG_TELEGRAM_API_ID?: string;
readonly TG_TEST_SESSION?: string;
}
declare namespace React {
interface HTMLAttributes {
// Optimization for DOM nodes prepends and inserts
teactFastList?: boolean;
teactExperimentControlled?: boolean;
onFileHoverOpen?: (e: Event) => void;
}
interface LiHTMLAttributes<_T> {
type?: string;
}
// Teact features
// eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-wrapper-object-types
interface CSSProperties extends String {}
interface ClassAttributes<T> extends RefAttributes<T> {
ref?: ((instance: T | undefined) => void) | React.RefObject<T | undefined> | undefined; // Teact ref
}
interface Attributes {
// Optimization for DOM nodes reordering. Requires `teactFastList` for parent
teactOrderKey?: number;
}
interface VideoHTMLAttributes {
srcObject?: MediaStream;
defaultMuted?: boolean;
}
interface MouseEvent {
offsetX: number;
offsetY: number;
}
interface KeyboardEvent {
isComposing: boolean;
}
}
type AnyLiteral = Record<string, any>;
type AnyClass = new (...args: any[]) => any;
type AnyFunction = (...args: any[]) => any;
type AnyToVoidFunction = (...args: any[]) => void;
type BooleanToVoidFunction = (value: boolean) => void;
type NoneToVoidFunction = () => void;
type StringAutocomplete<T> = T | (string & {});
type Complete<T> = {
[P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : (T[P] | undefined);
};
type EmojiCategory = {
id: string;
name: string;
emojis: string[];
};
type Emoji = {
id: string;
names: string[];
native: string;
image: string;
skin?: number;
};
type EmojiWithSkins = Record<number, Emoji>;
type AllEmojis = Record<string, Emoji | EmojiWithSkins>;
// Declare supported formats as modules
declare module '*.png' {
const url: string;
export default url;
}
declare module '*.jpg' {
const url: string;
export default url;
}
declare module '*.webp' {
const url: string;
export default url;
}
declare module '*.svg' {
const url: string;
export default url;
}
declare module '*.tgs' {
const url: string;
export default url;
}
declare module '*.wasm' {
const url: string;
export default url;
}
declare module '*.wasm?url' {
const url: string;
export default url;
}
declare module '*.strings?raw' {
const content: string;
export default content;
}
declare module '*.wgsl?raw' {
const content: string;
export default content;
}
declare module '*.bin?url&no-inline' {
const url: string;
export default url;
}
declare module 'opus-recorder' {
export interface IOpusRecorder extends Omit<MediaRecorder, 'start' | 'ondataavailable'> {
// eslint-disable-next-line @typescript-eslint/no-misused-new
new(options: AnyLiteral): IOpusRecorder;
start(stream?: MediaStreamAudioSourceNode): Promise<void>;
sourceNode: MediaStreamAudioSourceNode;
ondataavailable: (typedArray: Uint8Array<ArrayBuffer>) => void;
}
const recorder: IOpusRecorder;
export default recorder;
}
interface TEncodedImage {
result: Uint8ClampedArray;
width: number;
height: number;
}
interface IWebpWorker extends Worker {
wasmReady?: boolean;
requests: Map<string, (value: PromiseLike<TEncodedImage>) => void>;
}
interface Document {
mozFullScreenElement: HTMLElement;
webkitFullscreenElement: HTMLElement;
mozCancelFullScreen?: () => Promise<void>;
webkitCancelFullScreen?: () => Promise<void>;
webkitExitFullscreen?: () => Promise<void>;
}
interface HTMLElement {
mozRequestFullScreen?: () => Promise<void>;
webkitEnterFullscreen?: () => Promise<void>;
webkitRequestFullscreen?: () => Promise<void>;
}
interface Navigator {
// PWA badging extensions https://w3c.github.io/badging/
setAppBadge?(count: number): Promise<void>;
}
type Undefined<T> = {
[K in keyof T]: undefined;
};
type OptionalCombine<A, B> = (A & B) | (A & Undefined<B>);
type CommonProperties<T, U> = {
[K in keyof T & keyof U]: T[K] & U[K];
};
// Fix to make Boolean() work as !!
// https://github.com/microsoft/TypeScript/issues/16655
type Falsy = false | 0 | '' | null | undefined;
interface BooleanConstructor {
new<T>(value: T | Falsy): value is T;
<T>(value: T | Falsy): value is T;
// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types
readonly prototype: Boolean;
}
interface Array<T> {
filter<S extends T>(predicate: BooleanConstructor, thisArg?: unknown): Exclude<S, Falsy>[];
}
interface ReadonlyArray<T> {
filter<S extends T>(predicate: BooleanConstructor, thisArg?: unknown): Exclude<S, Falsy>[];
}
// Missing type definitions for OPFS (Origin Private File System) API
// https://github.com/WICG/file-system-access/blob/main/AccessHandle.md#accesshandle-idl
interface FileSystemFileHandle extends FileSystemHandle {
readonly kind: 'file';
getFile(): Promise<File>;
createSyncAccessHandle(): Promise<FileSystemSyncAccessHandle>;
}
interface FileSystemSyncAccessHandle {
read: (buffer: BufferSource, options: FilesystemReadWriteOptions) => number;
write: (buffer: BufferSource, options: FilesystemReadWriteOptions) => number;
truncate: (size: number) => Promise<undefined>;
getSize: () => Promise<number>;
flush: () => Promise<undefined>;
close: () => Promise<undefined>;
}
type FilesystemReadWriteOptions = {
at: number;
};
// WebGPU parts missing from the DOM library of TypeScript
interface HTMLCanvasElement {
getContext(contextId: 'webgpu'): GPUCanvasContext | null;
}
declare const GPUBufferUsage: {
readonly COPY_DST: GPUBufferUsageFlags;
readonly VERTEX: GPUBufferUsageFlags;
readonly UNIFORM: GPUBufferUsageFlags;
};
declare const GPUShaderStage: {
readonly VERTEX: GPUShaderStageFlags;
readonly FRAGMENT: GPUShaderStageFlags;
};
declare const GPUTextureUsage: {
readonly COPY_SRC: GPUTextureUsageFlags;
readonly COPY_DST: GPUTextureUsageFlags;
readonly RENDER_ATTACHMENT: GPUTextureUsageFlags;
};