-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathextra.d.ts
More file actions
134 lines (119 loc) · 3.44 KB
/
extra.d.ts
File metadata and controls
134 lines (119 loc) · 3.44 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
// AllowSharedBufferSource wasn't introduced until TypeScript 5.2.
// But it also didn't include SharedArrayBuffer in the union.
// This broke in ES2024 when ArrayBuffer gained some properties that SharedArrayBuffer didn't.
// So, we use our own definition for AllowSharedBufferSource.
type GPUAllowSharedBufferSource =
| BufferSource
| SharedArrayBuffer;
// Stronger typing for getContext()
interface HTMLCanvasElement {
getContext(
contextId:
| "webgpu"
): GPUCanvasContext | null;
}
interface OffscreenCanvas {
getContext(
contextId:
| "webgpu"
): GPUCanvasContext | null;
}
// Defined as an empty interface here to prevent errors when using these types in a worker.
interface HTMLVideoElement {}
// Strict types defined to help developers catch a common class of errors.
// This interface defines depth as an undefined, which will cause a type check failure if someone
// attempts to set depth rather than depthOrArrayLayers on a GPUExtent3D (an easy mistake to make.)
type GPUOrigin2DStrict =
| Iterable<GPUIntegerCoordinate>
| GPUOrigin2DDictStrict;
interface GPUOrigin2DDictStrict
extends GPUOrigin2DDict {
/** @deprecated Does not exist for GPUOrigin2D. */
z?: undefined;
}
type GPUExtent3DStrict =
| Iterable<GPUIntegerCoordinate>
| GPUExtent3DDictStrict;
interface GPUExtent3DDictStrict
extends GPUExtent3DDict {
/** @deprecated The correct name is `depthOrArrayLayers`. */
depth?: undefined;
}
// Stronger typing for event listeners.
/** @internal */
interface __GPUDeviceEventMap {
uncapturederror: GPUUncapturedErrorEvent;
}
// Extensions to the generated definition below.
interface GPUDevice {
addEventListener<
K extends keyof __GPUDeviceEventMap
>(
type: K,
listener: (
this: GPUDevice,
ev: __GPUDeviceEventMap[K]
) => any,
options?:
| boolean
| AddEventListenerOptions
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?:
| boolean
| AddEventListenerOptions
): void;
removeEventListener<
K extends keyof __GPUDeviceEventMap
>(
type: K,
listener: (
this: GPUDevice,
ev: __GPUDeviceEventMap[K]
) => any,
options?:
| boolean
| EventListenerOptions
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?:
| boolean
| EventListenerOptions
): void;
}
interface GPUCanvasConfigurationOut
extends Required<
Omit<
GPUCanvasConfiguration,
"toneMapping"
>
> {
/** {@inheritDoc GPUCanvasConfiguration.viewFormats} */
viewFormats: GPUTextureFormat[];
/**
* {@inheritDoc GPUCanvasConfiguration.toneMapping}
*/
toneMapping?: GPUCanvasToneMapping;
}
/** @deprecated Use {@link GPUTexelCopyBufferLayout} */
type GPUImageDataLayout =
GPUTexelCopyBufferLayout;
/** @deprecated Use {@link GPUTexelCopyBufferInfo} */
type GPUImageCopyBuffer =
GPUTexelCopyBufferInfo;
/** @deprecated Use {@link GPUTexelCopyTextureInfo} */
type GPUImageCopyTexture =
GPUTexelCopyTextureInfo;
/** @deprecated Use {@link GPUCopyExternalImageDestInfo} */
type GPUImageCopyTextureTagged =
GPUCopyExternalImageDestInfo;
/** @deprecated Use {@link GPUCopyExternalImageSourceInfo} */
type GPUImageCopyExternalImage =
GPUCopyExternalImageSourceInfo;
/** @deprecated Use {@link GPUCopyExternalImageSource} */
type GPUImageCopyExternalImageSource =
GPUCopyExternalImageSource;