|
| 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 | +} |
0 commit comments