1 | // Type definitions for caniuse-lite 1.0
|
2 | // Project: https://github.com/ben-eb/caniuse-lite#readme
|
3 | // Definitions by: Michael Utech <https://github.com/mutech>
|
4 | // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 | // TypeScript Version: 2.2
|
6 |
|
7 | /**
|
8 | * Information about user agents (browsers, platforms) indexed by their ID.
|
9 | */
|
10 | export const agents: AgentsByID;
|
11 |
|
12 | /**
|
13 | * Features index by their ID. The feature ID is a human readable identifier. The
|
14 | * associated value is a packed version of information about the feature that
|
15 | * can be unpacked using the function `feature(packed)`
|
16 | */
|
17 | export const features: { [featureID: string]: PackedFeature };
|
18 |
|
19 | /**
|
20 | * @param packedFeature a packed feature obtained from `features[key]` for some valid key.
|
21 | * @return the unpacked information as `Feature`.
|
22 | */
|
23 | export function feature(packedFeature: PackedFeature): Feature;
|
24 |
|
25 | /**
|
26 | * @param packedRegion a packed version of regional usage data by agent OD.
|
27 | * @return the unpacked usage data indexed by agent ID and then version.
|
28 | */
|
29 | export function region(packedRegion: PackedRegion): { [agentID: string]: UsageByVersion };
|
30 |
|
31 | /**
|
32 | * Agents indexed by their ID. .
|
33 | */
|
34 | export type AgentsByID = Readonly<{ [id: string]: Readonly<Agent> | undefined }>;
|
35 |
|
36 | /**
|
37 | * Feature support status by version indexed by agent ID.
|
38 | */
|
39 | export type StatsByAgentID = Readonly<{ [agentID: string]: SupportStatusByVersion }>;
|
40 |
|
41 | /**
|
42 | * Feature support status indexed by an agent's versions.
|
43 | */
|
44 | export type SupportStatusByVersion = Readonly<{ [version: string]: SupportStatus }>;
|
45 |
|
46 | /**
|
47 | * Usage (percentage/market share) indexed by an agent's versions.
|
48 | */
|
49 | export type UsageByVersion = Readonly<{ [version: string]: number | undefined }>;
|
50 |
|
51 | /**
|
52 | * The standardization status of a feature:
|
53 | * * ls - WHATWG living standard
|
54 | * * rec - W3C recommendation
|
55 | * * pr - W3C proposed recommendation
|
56 | * * cr - W3C candidate recommendation
|
57 | * * wd - W3C working draft
|
58 | * * other - Non-W3C, but reputable
|
59 | * * unoff - Unofficial
|
60 | */
|
61 | export type FeatureStatus = "ls" | "rec" | "pr" | "cr" | "wd" | "other" | "unoff" | string;
|
62 |
|
63 | /**
|
64 | * Encoded support status:
|
65 | * * `n` - not supported
|
66 | * * `p` - not supported, polyfill available
|
67 | * * `u` - unknown
|
68 | * * `a x` - partially supported, vendor prefix
|
69 | * * `a` - partially supported
|
70 | * * `y x` - fully supported, vendor prefix
|
71 | * * `y` - fully supported
|
72 | *
|
73 | * The support status can additionally have one or more footnote references as `#<n>`, f.e.
|
74 | * `a x #1 #3`.
|
75 | */
|
76 | export type SupportStatus = "n" | "p" | "u" | "a x" | "a" | "y x" | "y" | string;
|
77 |
|
78 | /**
|
79 | * Provides information about the Agent.
|
80 | */
|
81 | export interface Agent {
|
82 | /**
|
83 | * Global agent usage by version
|
84 | */
|
85 | usage_global: UsageByVersion;
|
86 |
|
87 | /**
|
88 | * The agents vendor prefix
|
89 | */
|
90 | prefix: string;
|
91 |
|
92 | /**
|
93 | * Version matrix. See [caniuse](https://caniuse.com)
|
94 | */
|
95 | versions: [ // Tuple of 70 version slots:
|
96 | string | null,
|
97 | string | null,
|
98 | string | null,
|
99 | string | null,
|
100 | string | null,
|
101 | string | null,
|
102 | string | null,
|
103 | string | null,
|
104 | string | null,
|
105 | string | null,
|
106 | string | null,
|
107 | string | null,
|
108 | string | null,
|
109 | string | null,
|
110 | string | null,
|
111 | string | null,
|
112 | string | null,
|
113 | string | null,
|
114 | string | null,
|
115 | string | null,
|
116 | string | null,
|
117 | string | null,
|
118 | string | null,
|
119 | string | null,
|
120 | string | null,
|
121 | string | null,
|
122 | string | null,
|
123 | string | null,
|
124 | string | null,
|
125 | string | null,
|
126 | string | null,
|
127 | string | null,
|
128 | string | null,
|
129 | string | null,
|
130 | string | null,
|
131 | string | null,
|
132 | string | null,
|
133 | string | null,
|
134 | string | null,
|
135 | string | null,
|
136 | string | null,
|
137 | string | null,
|
138 | string | null,
|
139 | string | null,
|
140 | string | null,
|
141 | string | null,
|
142 | string | null,
|
143 | string | null,
|
144 | string | null,
|
145 | string | null,
|
146 | string | null,
|
147 | string | null,
|
148 | string | null,
|
149 | string | null,
|
150 | string | null,
|
151 | string | null,
|
152 | string | null,
|
153 | string | null,
|
154 | string | null,
|
155 | string | null,
|
156 | string | null,
|
157 | string | null,
|
158 | string | null,
|
159 | string | null,
|
160 | string | null,
|
161 | string | null,
|
162 | string | null,
|
163 | string | null,
|
164 | string | null,
|
165 | string | null,
|
166 | ];
|
167 |
|
168 | /**
|
169 | * The agent's name
|
170 | */
|
171 | browser: string;
|
172 |
|
173 | /**
|
174 | * Release dates as seconds since epoch by version.
|
175 | */
|
176 | release_date: { [version: string]: number | undefined };
|
177 |
|
178 | /**
|
179 | * Exceptions to vendor prefix use.
|
180 | */
|
181 | prefix_exceptions?: { [version: string]: string | undefined } | undefined;
|
182 | }
|
183 |
|
184 | /**
|
185 | * Specifies a feature and its support status in all known agent versions.
|
186 | */
|
187 | export interface Feature {
|
188 | /**
|
189 | * Specification status of the feature.
|
190 | */
|
191 | status: FeatureStatus;
|
192 |
|
193 | /**
|
194 | * Descriptive title of the feature.
|
195 | */
|
196 | title: string;
|
197 |
|
198 | /**
|
199 | * Agent support matrix for this feature.
|
200 | */
|
201 | stats: StatsByAgentID;
|
202 | }
|
203 |
|
204 | /**
|
205 | * A space optimized version of Feature that can be unpacked using `feature(PackedFeature)`.
|
206 | */
|
207 | export interface PackedFeature {
|
208 | [encodedKey: string]: any;
|
209 | }
|
210 |
|
211 | /**
|
212 | * A space optimized version of Region that can be unpacked using `region(PackedFeature)`.
|
213 | */
|
214 | export interface PackedRegion {
|
215 | [encodedKey: string]: any;
|
216 | }
|