-
Notifications
You must be signed in to change notification settings - Fork 30
/
chrome.d.ts
246 lines (179 loc) · 5.83 KB
/
chrome.d.ts
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
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface ChromeVersionsData {
head: string;
releases: Map<number, { revision: string, version: string }>;
}
export interface ProcessedAPIData {
headRevision: string;
definitionsRevision: string;
version: { revision: string, version: string } | null;
when: string;
feature: {
[feature: string]: FeatureSpec|FeatureSpec[],
};
api: {
[api: string]: NamespaceSpec,
};
}
// FIXME: This should have at least one value.
export type MinArray<T> = T[];
export type Channel = 'stable' | 'beta' | 'dev' | 'canary' | 'trunk';
export type Platform = 'chromeos' | 'lacros' | 'linux' | 'mac' | 'win';
export type Context = 'blessed_extension' | 'blessed_web_page' | 'content_script' | 'lock_screen_extension' | 'web_page' | 'webui' | 'webui_untrusted' | 'unblessed_extension';
export type ExtensionType = 'extension' | 'hosted_app' | 'legacy_packaged_app' | 'platform_app' | 'shared_module' | 'theme' | 'login_screen_extension';
export type All = 'all';
export type SessionType = 'regular' | 'kiosk' | 'kiosk.autolaunched';
export type Location = 'component' | 'external_component' | 'policy' | 'unpacked';
export interface FeatureSpec {
allowlist?: MinArray<string>;
blocklist?: MinArray<string>;
channel?: Channel;
command_line_switch?: string;
/**
* The default here is true, so it can only be set to false.
*/
component_extensions_auto_granted?: false;
contexts?: MinArray<Context>|All;
/**
* If this is part of a complex feature (many definitions) and that complex feature is being used
* as a parent, then use this specific definition as the parent.
*/
default_parent?: true;
dependencies?: string[];
disallow_for_service_workers?: boolean;
extension_types?: MinArray<ExtensionType>|All;
feature_flag?: string;
location?: Location;
internal?: true;
matches?: MinArray<string>;
max_manifest_version?: number;
min_manifest_version?: number;
noparent?: true;
platforms?: MinArray<Platform>;
session_types?: MinArray<SessionType>;
}
export type SpecGroup = {[name: string]: TypeSpec} | TypeSpec[] | undefined;
export interface SharedSpec {
description?: string;
deprecated?: string | null;
nodoc?: boolean | 'true';
jsexterns?: string | null;
platforms?: string[] | null;
properties?: {[name: string]: TypeSpec};
functions?: (TypeSpec & {type: 'function'})[];
events?: EventSpec[];
}
/**
* A primitive type understood by Chrome's extensions.
*
* Note that `void`, `undefined` and `never` don't appear in source, but are helpful for our code.
*/
export type PrimitiveType = 'void' | 'undefined' | 'never' | 'array' | 'any' | 'int64' | 'binary' | 'boolean' | 'integer' | 'double' | 'number' | 'string' | 'object' | 'function';
/**
* This is a raw type as found inside Chrome's JSON extension definitions.
*/
export interface TypeSpec extends SharedSpec {
id?: string;
name?: string;
optional?: boolean;
type?: PrimitiveType;
$ref?: string;
isInstanceOf?: string;
value?: number | string | [string] | [string, ...TypeSpec[]] | {};
minimum?: number;
maximum?: number;
additionalProperties?: TypeSpec;
serializableFunction?: boolean;
serialized_type?: PrimitiveType;
parameters?: TypeSpec[];
returns?: TypeSpec;
returns_async?: TypeSpec;
enum?: string[] | number[] | { name: string, description?: string }[];
choices?: TypeSpec[];
// for type='array'
items?: TypeSpec;
minItems?: number;
maxItems?: number;
// only for top-level namespace types
noinline_doc?: boolean | 'True';
// only for returns_async types
does_not_support_promises?: string;
// special to mark converted-from-event-to-property, not part of definition
_event?: boolean;
}
export interface NamedTypeSpec extends TypeSpec {
name: string;
}
/**
* This is the type of instances of the "event" array found directly as part of a namespace or type.
* Events are effectively functions plus options.
*/
export interface EventSpec extends TypeSpec {
name: string;
type?: 'function';
extraParameters?: TypeSpec[];
filters?: TypeSpec[];
options?: {
unmanaged?: boolean;
maxListeners?: number;
supportsFilters?: boolean;
supportsListeners?: boolean;
supportsRules?: boolean;
conditions?: string[];
actions?: string[];
supportsDom?: boolean;
supportsLazyListeners?: boolean;
};
}
/**
* This is the type of the namespace.
*/
export interface NamespaceSpec extends SharedSpec {
namespace: string;
types?: TypeSpec[];
// largely unused parts of namespace
manifest_keys?: {[name: string]: TypeSpec} | null;
documentation_options?: Object;
compiler_options?: Object;
internal?: boolean;
}
export type SpecCallback = (spec: TypeSpec, id: string) => void;
export type Tag = { name: string, value?: string };
export type VersionHistoryData = {
versions: {
name: string,
version: string,
}[],
};
/**
* Generated by 'render-symbols'. Symbol data for a specific release version.
*/
export type ReleaseSymbolsData = {[id: string]: { deprecated?: true }};
export type AllReleasesSymbolData = {
[id: string]: {
deprecated?: number,
low?: number,
high: number,
},
};
export interface HistoricSymbolsPayload {
revision: number,
low: number,
high: number,
generated: string,
symbols: AllReleasesSymbolData,
}