Skip to content

Commit b26bffb

Browse files
committed
Add minimal Performance
1 parent acb3283 commit b26bffb

File tree

4 files changed

+198
-0
lines changed

4 files changed

+198
-0
lines changed

src/DOM.res

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ open WebLocks
2929
open CSSFontLoading
3030
open IndexedDB
3131
open WebCrypto
32+
open Performance
3233

3334
type shadowRootMode =
3435
| @as("closed") Closed

src/Performance.js

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Performance.res

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
@@warning("-30")
2+
3+
open Prelude
4+
open Event
5+
6+
/**
7+
[See EventCounts on MDN](https://developer.mozilla.org/docs/Web/API/EventCounts)
8+
*/
9+
type eventCounts = {}
10+
11+
/**
12+
Provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API.
13+
[See Performance on MDN](https://developer.mozilla.org/docs/Web/API/Performance)
14+
*/
15+
type performance = {
16+
...eventTarget,
17+
/**
18+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/timeOrigin)
19+
*/
20+
timeOrigin: float,
21+
/**
22+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/eventCounts)
23+
*/
24+
eventCounts: eventCounts,
25+
}
26+
27+
/**
28+
Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
29+
[See PerformanceEntry on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
30+
*/
31+
type performanceEntry = {
32+
/**
33+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name)
34+
*/
35+
name: string,
36+
/**
37+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType)
38+
*/
39+
entryType: string,
40+
/**
41+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime)
42+
*/
43+
startTime: float,
44+
/**
45+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration)
46+
*/
47+
duration: float,
48+
}
49+
50+
/**
51+
PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.
52+
[See PerformanceMark on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
53+
*/
54+
type performanceMark = {
55+
...performanceEntry,
56+
/**
57+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail)
58+
*/
59+
detail: any,
60+
}
61+
62+
/**
63+
PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.
64+
[See PerformanceMeasure on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
65+
*/
66+
type performanceMeasure = {
67+
...performanceEntry,
68+
/**
69+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail)
70+
*/
71+
detail: any,
72+
}
73+
74+
type performanceEntryList = any
75+
76+
type performanceMarkOptions = {
77+
mutable detail: any,
78+
mutable startTime: float,
79+
}
80+
81+
module Performance = {
82+
/**
83+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/now)
84+
*/
85+
@send
86+
external now: performance => float = "now"
87+
88+
/**
89+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
90+
*/
91+
@send
92+
external toJSON: performance => Dict.t<string> = "toJSON"
93+
94+
/**
95+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntries)
96+
*/
97+
@send
98+
external getEntries: performance => performanceEntryList = "getEntries"
99+
100+
/**
101+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType)
102+
*/
103+
@send
104+
external getEntriesByType: (performance, string) => performanceEntryList = "getEntriesByType"
105+
106+
/**
107+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName)
108+
*/
109+
@send
110+
external getEntriesByName: (performance, string, string) => performanceEntryList =
111+
"getEntriesByName"
112+
113+
/**
114+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings)
115+
*/
116+
@send
117+
external clearResourceTimings: performance => unit = "clearResourceTimings"
118+
119+
/**
120+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize)
121+
*/
122+
@send
123+
external setResourceTimingBufferSize: (performance, int) => unit = "setResourceTimingBufferSize"
124+
125+
/**
126+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/mark)
127+
*/
128+
@send
129+
external mark: (performance, string, performanceMarkOptions) => performanceMark = "mark"
130+
131+
/**
132+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks)
133+
*/
134+
@send
135+
external clearMarks: (performance, string) => unit = "clearMarks"
136+
137+
/**
138+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/measure)
139+
*/
140+
@send
141+
external measure: (performance, string, unknown, string) => performanceMeasure = "measure"
142+
143+
/**
144+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures)
145+
*/
146+
@send
147+
external clearMeasures: (performance, string) => unit = "clearMeasures"
148+
}
149+
150+
module PerformanceEntry = {
151+
/**
152+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON)
153+
*/
154+
@send
155+
external toJSON: performanceEntry => Dict.t<string> = "toJSON"
156+
}
157+
158+
module PerformanceMark = {
159+
/**
160+
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
161+
*/
162+
@new
163+
external make: (string, performanceMarkOptions) => performanceMark = "PerformanceMark"
164+
}

tools/TypeScript-DOM-lib-generator/src/build/emitter.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,6 +1816,23 @@ export async function emitRescriptBindings(
18161816
],
18171817
opens: ["Prelude"],
18181818
},
1819+
// https://developer.mozilla.org/en-US/docs/Web/API/Performance_API
1820+
{
1821+
name: "Performance",
1822+
entries: [
1823+
individualInterfaces([
1824+
"EventCounts",
1825+
"Performance",
1826+
"PerformanceEntry",
1827+
"PerformanceMark",
1828+
"PerformanceMeasure",
1829+
]),
1830+
byHand("PerformanceEntryList", emitAny("PerformanceEntryList")),
1831+
dictionaries(["PerformanceMarkOptions"]),
1832+
// ...callbacks(["PerformanceObserverCallback"]),
1833+
],
1834+
opens: ["Prelude", "Event"],
1835+
},
18191836
// https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
18201837
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API
18211838
{
@@ -2047,6 +2064,7 @@ export async function emitRescriptBindings(
20472064
"CSSFontLoading",
20482065
"IndexedDB",
20492066
"WebCrypto",
2067+
"Performance",
20502068
],
20512069
},
20522070
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API

0 commit comments

Comments
 (0)