UNPKG

5.39 kBTypeScriptView Raw
1/**
2 * Information about user agents (browsers, platforms) indexed by their ID.
3 */
4export const agents: AgentsByID;
5
6/**
7 * Features index by their ID. The feature ID is a human readable identifier. The
8 * associated value is a packed version of information about the feature that
9 * can be unpacked using the function `feature(packed)`
10 */
11export const features: { [featureID: string]: PackedFeature };
12
13/**
14 * @param packedFeature a packed feature obtained from `features[key]` for some valid key.
15 * @return the unpacked information as `Feature`.
16 */
17export function feature(packedFeature: PackedFeature): Feature;
18
19/**
20 * @param packedRegion a packed version of regional usage data by agent OD.
21 * @return the unpacked usage data indexed by agent ID and then version.
22 */
23export function region(packedRegion: PackedRegion): { [agentID: string]: UsageByVersion };
24
25/**
26 * Agents indexed by their ID. .
27 */
28export type AgentsByID = Readonly<{ [id: string]: Readonly<Agent> | undefined }>;
29
30/**
31 * Feature support status by version indexed by agent ID.
32 */
33export type StatsByAgentID = Readonly<{ [agentID: string]: SupportStatusByVersion }>;
34
35/**
36 * Feature support status indexed by an agent's versions.
37 */
38export type SupportStatusByVersion = Readonly<{ [version: string]: SupportStatus }>;
39
40/**
41 * Usage (percentage/market share) indexed by an agent's versions.
42 */
43export type UsageByVersion = Readonly<{ [version: string]: number | undefined }>;
44
45/**
46 * The standardization status of a feature:
47 * * ls - WHATWG living standard
48 * * rec - W3C recommendation
49 * * pr - W3C proposed recommendation
50 * * cr - W3C candidate recommendation
51 * * wd - W3C working draft
52 * * other - Non-W3C, but reputable
53 * * unoff - Unofficial
54 */
55export type FeatureStatus = "ls" | "rec" | "pr" | "cr" | "wd" | "other" | "unoff" | string;
56
57/**
58 * Encoded support status:
59 * * `n` - not supported
60 * * `p` - not supported, polyfill available
61 * * `u` - unknown
62 * * `a x` - partially supported, vendor prefix
63 * * `a` - partially supported
64 * * `y x` - fully supported, vendor prefix
65 * * `y` - fully supported
66 *
67 * The support status can additionally have one or more footnote references as `#<n>`, f.e.
68 * `a x #1 #3`.
69 */
70export type SupportStatus = "n" | "p" | "u" | "a x" | "a" | "y x" | "y" | string;
71
72/**
73 * Provides information about the Agent.
74 */
75export interface Agent {
76 /**
77 * Global agent usage by version
78 */
79 usage_global: UsageByVersion;
80
81 /**
82 * The agents vendor prefix
83 */
84 prefix: string;
85
86 /**
87 * Version matrix. See [caniuse](https://caniuse.com)
88 */
89 versions: [ // Tuple of 70 version slots:
90 string | null,
91 string | null,
92 string | null,
93 string | null,
94 string | null,
95 string | null,
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 ];
161
162 /**
163 * The agent's name
164 */
165 browser: string;
166
167 /**
168 * Release dates as seconds since epoch by version.
169 */
170 release_date: { [version: string]: number | undefined };
171
172 /**
173 * Exceptions to vendor prefix use.
174 */
175 prefix_exceptions?: { [version: string]: string | undefined } | undefined;
176}
177
178/**
179 * Specifies a feature and its support status in all known agent versions.
180 */
181export interface Feature {
182 /**
183 * Specification status of the feature.
184 */
185 status: FeatureStatus;
186
187 /**
188 * Descriptive title of the feature.
189 */
190 title: string;
191
192 /**
193 * Agent support matrix for this feature.
194 */
195 stats: StatsByAgentID;
196
197 /**
198 * Whether the feature appears on caniuse.com.
199 */
200 shown: boolean;
201}
202
203/**
204 * A space optimized version of Feature that can be unpacked using `feature(PackedFeature)`.
205 */
206export interface PackedFeature {
207 [encodedKey: string]: any;
208}
209
210/**
211 * A space optimized version of Region that can be unpacked using `region(PackedFeature)`.
212 */
213export interface PackedRegion {
214 [encodedKey: string]: any;
215}