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, string|null, string|null, string|null, string|null,
|
97 | string|null, string|null, string|null, string|null, string|null,
|
98 | string|null, string|null, string|null, string|null, string|null,
|
99 | string|null, string|null, string|null, string|null, string|null,
|
100 | string|null, string|null, string|null, string|null, string|null,
|
101 | string|null, string|null, string|null, string|null, string|null,
|
102 | string|null, string|null, string|null, string|null, string|null,
|
103 | string|null, string|null, string|null, string|null, string|null,
|
104 | string|null, string|null, string|null, string|null, string|null,
|
105 | string|null, string|null, string|null, string|null, string|null,
|
106 | string|null, string|null, string|null, string|null, string|null,
|
107 | string|null, string|null, string|null, string|null, string|null,
|
108 | string|null, string|null, string|null, string|null, string|null,
|
109 | string|null, string|null, string|null, string|null, string|null ];
|
110 |
|
111 | /**
|
112 | * The agent's name
|
113 | */
|
114 | browser: string;
|
115 |
|
116 | /**
|
117 | * Release dates as seconds since epoch by version.
|
118 | */
|
119 | release_date: { [version: string]: number | undefined };
|
120 |
|
121 | /**
|
122 | * Exceptions to vendor prefix use.
|
123 | */
|
124 | prefix_exceptions?: { [version: string]: string | undefined } | undefined;
|
125 | }
|
126 |
|
127 | /**
|
128 | * Specifies a feature and its support status in all known agent versions.
|
129 | */
|
130 | export interface Feature {
|
131 | /**
|
132 | * Specification status of the feature.
|
133 | */
|
134 | status: FeatureStatus;
|
135 |
|
136 | /**
|
137 | * Descriptive title of the feature.
|
138 | */
|
139 | title: string;
|
140 |
|
141 | /**
|
142 | * Agent support matrix for this feature.
|
143 | */
|
144 | stats: StatsByAgentID;
|
145 | }
|
146 |
|
147 | /**
|
148 | * A space optimized version of Feature that can be unpacked using `feature(PackedFeature)`.
|
149 | */
|
150 | export interface PackedFeature {
|
151 | [encodedKey: string]: any;
|
152 | }
|
153 |
|
154 | /**
|
155 | * A space optimized version of Region that can be unpacked using `region(PackedFeature)`.
|
156 | */
|
157 | export interface PackedRegion {
|
158 | [encodedKey: string]: any;
|
159 | }
|