@aligent/cdk-prerender-proxy 0.2.4 → 0.2.5-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/lib/handlers/cache-control.ts +7 -20
  2. package/lib/handlers/error-response.ts +8 -51
  3. package/lib/handlers/node_modules/.package-lock.json +32 -3
  4. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.d.ts +6 -0
  5. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/index.js +14 -0
  6. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.d.ts +3 -0
  7. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/cache-control.js +24 -0
  8. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.d.ts +3 -0
  9. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/error-response.js +50 -0
  10. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.d.ts +3 -0
  11. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender-check.js +28 -0
  12. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.d.ts +3 -0
  13. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/prerender.js +49 -0
  14. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.d.ts +3 -0
  15. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/lib/redirect.js +33 -0
  16. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/package.json +27 -0
  17. package/lib/handlers/node_modules/@aligent/cdk-lambda-at-edge-handlers/tsconfig.json +3 -0
  18. package/lib/handlers/node_modules/@middy/core/LICENSE +21 -0
  19. package/lib/handlers/node_modules/@middy/core/README.md +65 -0
  20. package/lib/handlers/node_modules/@middy/core/index.cjs +207 -0
  21. package/lib/handlers/node_modules/@middy/core/index.d.ts +91 -0
  22. package/lib/handlers/node_modules/@middy/core/index.js +199 -0
  23. package/lib/handlers/node_modules/@middy/core/package.json +65 -0
  24. package/lib/handlers/node_modules/@types/node/README.md +4 -4
  25. package/lib/handlers/node_modules/@types/node/assert/strict.d.ts +5 -1
  26. package/lib/handlers/node_modules/@types/node/assert.d.ts +904 -67
  27. package/lib/handlers/node_modules/@types/node/async_hooks.d.ts +371 -96
  28. package/lib/handlers/node_modules/@types/node/buffer.d.ts +2199 -25
  29. package/lib/handlers/node_modules/@types/node/child_process.d.ts +1151 -308
  30. package/lib/handlers/node_modules/@types/node/cluster.d.ts +356 -208
  31. package/lib/handlers/node_modules/@types/node/console.d.ts +324 -45
  32. package/lib/handlers/node_modules/@types/node/constants.d.ts +8 -3
  33. package/lib/handlers/node_modules/@types/node/crypto.d.ts +3230 -846
  34. package/lib/handlers/node_modules/@types/node/dgram.d.ts +478 -74
  35. package/lib/handlers/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
  36. package/lib/handlers/node_modules/@types/node/dns/promises.d.ts +308 -35
  37. package/lib/handlers/node_modules/@types/node/dns.d.ts +444 -107
  38. package/lib/handlers/node_modules/@types/node/dom-events.d.ts +126 -0
  39. package/lib/handlers/node_modules/@types/node/domain.d.ts +162 -16
  40. package/lib/handlers/node_modules/@types/node/events.d.ts +624 -39
  41. package/lib/handlers/node_modules/@types/node/fs/promises.d.ts +911 -365
  42. package/lib/handlers/node_modules/@types/node/fs.d.ts +2611 -978
  43. package/lib/handlers/node_modules/@types/node/globals.d.ts +66 -421
  44. package/lib/handlers/node_modules/@types/node/globals.global.d.ts +1 -1
  45. package/lib/handlers/node_modules/@types/node/http.d.ts +1416 -199
  46. package/lib/handlers/node_modules/@types/node/http2.d.ts +1688 -530
  47. package/lib/handlers/node_modules/@types/node/https.d.ts +532 -26
  48. package/lib/handlers/node_modules/@types/node/index.d.ts +92 -16
  49. package/lib/handlers/node_modules/@types/node/inspector.d.ts +511 -811
  50. package/lib/handlers/node_modules/@types/node/module.d.ts +75 -13
  51. package/lib/handlers/node_modules/@types/node/net.d.ts +710 -167
  52. package/lib/handlers/node_modules/@types/node/os.d.ts +252 -25
  53. package/lib/handlers/node_modules/@types/node/package.json +30 -25
  54. package/lib/handlers/node_modules/@types/node/path.d.ts +59 -31
  55. package/lib/handlers/node_modules/@types/node/perf_hooks.d.ts +420 -105
  56. package/lib/handlers/node_modules/@types/node/process.d.ts +1249 -228
  57. package/lib/handlers/node_modules/@types/node/punycode.d.ts +67 -25
  58. package/lib/handlers/node_modules/@types/node/querystring.d.ts +113 -10
  59. package/lib/handlers/node_modules/@types/node/readline/promises.d.ts +143 -0
  60. package/lib/handlers/node_modules/@types/node/readline.d.ts +570 -109
  61. package/lib/handlers/node_modules/@types/node/repl.d.ts +154 -125
  62. package/lib/handlers/node_modules/@types/node/stream/consumers.d.ts +12 -0
  63. package/lib/handlers/node_modules/@types/node/stream/promises.d.ts +18 -43
  64. package/lib/handlers/node_modules/@types/node/stream/web.d.ts +330 -0
  65. package/lib/handlers/node_modules/@types/node/stream.d.ts +1117 -248
  66. package/lib/handlers/node_modules/@types/node/string_decoder.d.ts +60 -0
  67. package/lib/handlers/node_modules/@types/node/test.d.ts +446 -0
  68. package/lib/handlers/node_modules/@types/node/timers/promises.d.ts +81 -9
  69. package/lib/handlers/node_modules/@types/node/timers.d.ts +84 -17
  70. package/lib/handlers/node_modules/@types/node/tls.d.ts +510 -275
  71. package/lib/handlers/node_modules/@types/node/trace_events.d.ts +120 -10
  72. package/lib/handlers/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  73. package/lib/handlers/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
  74. package/lib/handlers/node_modules/@types/node/ts4.8/async_hooks.d.ts +501 -0
  75. package/lib/handlers/node_modules/@types/node/ts4.8/buffer.d.ts +2259 -0
  76. package/lib/handlers/node_modules/@types/node/ts4.8/child_process.d.ts +1369 -0
  77. package/lib/handlers/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
  78. package/lib/handlers/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  79. package/lib/handlers/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  80. package/lib/handlers/node_modules/@types/node/ts4.8/crypto.d.ts +3964 -0
  81. package/lib/handlers/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
  82. package/lib/handlers/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +153 -0
  83. package/lib/handlers/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
  84. package/lib/handlers/node_modules/@types/node/ts4.8/dns.d.ts +659 -0
  85. package/lib/handlers/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
  86. package/lib/handlers/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  87. package/lib/handlers/node_modules/@types/node/ts4.8/events.d.ts +678 -0
  88. package/lib/handlers/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
  89. package/lib/handlers/node_modules/@types/node/ts4.8/fs.d.ts +3872 -0
  90. package/lib/handlers/node_modules/@types/node/ts4.8/globals.d.ts +294 -0
  91. package/lib/handlers/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  92. package/lib/handlers/node_modules/@types/node/ts4.8/http.d.ts +1651 -0
  93. package/lib/handlers/node_modules/@types/node/ts4.8/http2.d.ts +2134 -0
  94. package/lib/handlers/node_modules/@types/node/ts4.8/https.d.ts +542 -0
  95. package/lib/handlers/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  96. package/lib/handlers/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
  97. package/lib/handlers/node_modules/@types/node/ts4.8/module.d.ts +114 -0
  98. package/lib/handlers/node_modules/@types/node/ts4.8/net.d.ts +869 -0
  99. package/lib/handlers/node_modules/@types/node/ts4.8/os.d.ts +466 -0
  100. package/lib/handlers/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  101. package/lib/handlers/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
  102. package/lib/handlers/node_modules/@types/node/ts4.8/process.d.ts +1482 -0
  103. package/lib/handlers/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  104. package/lib/handlers/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
  105. package/lib/handlers/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
  106. package/lib/handlers/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
  107. package/lib/handlers/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
  108. package/lib/handlers/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  109. package/lib/handlers/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
  110. package/lib/handlers/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
  111. package/lib/handlers/node_modules/@types/node/ts4.8/stream.d.ts +1340 -0
  112. package/lib/handlers/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  113. package/lib/handlers/node_modules/@types/node/ts4.8/test.d.ts +446 -0
  114. package/lib/handlers/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  115. package/lib/handlers/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
  116. package/lib/handlers/node_modules/@types/node/ts4.8/tls.d.ts +1028 -0
  117. package/lib/handlers/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
  118. package/lib/handlers/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
  119. package/lib/handlers/node_modules/@types/node/ts4.8/url.d.ts +897 -0
  120. package/lib/handlers/node_modules/@types/node/ts4.8/util.d.ts +1926 -0
  121. package/lib/handlers/node_modules/@types/node/ts4.8/v8.d.ts +396 -0
  122. package/lib/handlers/node_modules/@types/node/ts4.8/vm.d.ts +509 -0
  123. package/lib/handlers/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  124. package/lib/handlers/node_modules/@types/node/ts4.8/worker_threads.d.ts +689 -0
  125. package/lib/handlers/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  126. package/lib/handlers/node_modules/@types/node/tty.d.ts +163 -23
  127. package/lib/handlers/node_modules/@types/node/url.d.ts +825 -44
  128. package/lib/handlers/node_modules/@types/node/util.d.ts +1842 -72
  129. package/lib/handlers/node_modules/@types/node/v8.d.ts +276 -78
  130. package/lib/handlers/node_modules/@types/node/vm.d.ts +410 -53
  131. package/lib/handlers/node_modules/@types/node/wasi.d.ts +102 -30
  132. package/lib/handlers/node_modules/@types/node/worker_threads.d.ts +559 -152
  133. package/lib/handlers/node_modules/@types/node/zlib.d.ts +234 -78
  134. package/lib/handlers/node_modules/esbuild/README.md +3 -0
  135. package/lib/handlers/node_modules/esbuild/bin/esbuild +0 -0
  136. package/lib/handlers/node_modules/esbuild/install.js +256 -0
  137. package/lib/handlers/node_modules/esbuild/lib/main.d.ts +397 -0
  138. package/lib/handlers/node_modules/esbuild/lib/main.js +1939 -0
  139. package/lib/handlers/node_modules/esbuild/package.json +15 -0
  140. package/lib/handlers/package-lock.json +62 -6
  141. package/lib/handlers/package.json +6 -1
  142. package/lib/handlers/prerender-check.ts +8 -27
  143. package/lib/handlers/prerender.ts +8 -43
  144. package/package.json +1 -1
  145. package/lib/handlers/node_modules/@types/node/base.d.ts +0 -19
  146. package/lib/handlers/node_modules/@types/node/diagnostic_channel.d.ts +0 -34
  147. package/lib/handlers/node_modules/@types/node/ts3.6/assert.d.ts +0 -98
  148. package/lib/handlers/node_modules/@types/node/ts3.6/base.d.ts +0 -68
  149. package/lib/handlers/node_modules/@types/node/ts3.6/index.d.ts +0 -7
  150. package/lib/handlers/node_modules/@types/node/util/types.d.ts +0 -53
@@ -1,99 +1,197 @@
1
+ /**
2
+ * This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
3
+ * Node.js-specific performance measurements.
4
+ *
5
+ * Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
6
+ *
7
+ * * [High Resolution Time](https://www.w3.org/TR/hr-time-2)
8
+ * * [Performance Timeline](https://w3c.github.io/performance-timeline/)
9
+ * * [User Timing](https://www.w3.org/TR/user-timing/)
10
+ *
11
+ * ```js
12
+ * const { PerformanceObserver, performance } = require('perf_hooks');
13
+ *
14
+ * const obs = new PerformanceObserver((items) => {
15
+ * console.log(items.getEntries()[0].duration);
16
+ * performance.clearMarks();
17
+ * });
18
+ * obs.observe({ type: 'measure' });
19
+ * performance.measure('Start to Now');
20
+ *
21
+ * performance.mark('A');
22
+ * doSomeLongRunningProcess(() => {
23
+ * performance.measure('A to Now', 'A');
24
+ *
25
+ * performance.mark('B');
26
+ * performance.measure('A to B', 'A', 'B');
27
+ * });
28
+ * ```
29
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/perf_hooks.js)
30
+ */
1
31
  declare module 'perf_hooks' {
2
- import { AsyncResource } from 'async_hooks';
3
-
32
+ import { AsyncResource } from 'node:async_hooks';
4
33
  type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
5
-
34
+ interface NodeGCPerformanceDetail {
35
+ /**
36
+ * When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
37
+ * the type of garbage collection operation that occurred.
38
+ * See perf_hooks.constants for valid values.
39
+ */
40
+ readonly kind?: number | undefined;
41
+ /**
42
+ * When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
43
+ * property contains additional information about garbage collection operation.
44
+ * See perf_hooks.constants for valid values.
45
+ */
46
+ readonly flags?: number | undefined;
47
+ }
48
+ /**
49
+ * @since v8.5.0
50
+ */
6
51
  class PerformanceEntry {
7
52
  protected constructor();
8
53
  /**
9
- * The total number of milliseconds elapsed for this entry.
10
- * This value will not be meaningful for all Performance Entry types.
54
+ * The total number of milliseconds elapsed for this entry. This value will not
55
+ * be meaningful for all Performance Entry types.
56
+ * @since v8.5.0
11
57
  */
12
58
  readonly duration: number;
13
-
14
59
  /**
15
60
  * The name of the performance entry.
61
+ * @since v8.5.0
16
62
  */
17
63
  readonly name: string;
18
-
19
64
  /**
20
- * The high resolution millisecond timestamp marking the starting time of the Performance Entry.
65
+ * The high resolution millisecond timestamp marking the starting time of the
66
+ * Performance Entry.
67
+ * @since v8.5.0
21
68
  */
22
69
  readonly startTime: number;
23
-
24
70
  /**
25
- * The type of the performance entry.
26
- * Currently it may be one of: 'node', 'mark', 'measure', 'gc', or 'function'.
71
+ * The type of the performance entry. It may be one of:
72
+ *
73
+ * * `'node'` (Node.js only)
74
+ * * `'mark'` (available on the Web)
75
+ * * `'measure'` (available on the Web)
76
+ * * `'gc'` (Node.js only)
77
+ * * `'function'` (Node.js only)
78
+ * * `'http2'` (Node.js only)
79
+ * * `'http'` (Node.js only)
80
+ * @since v8.5.0
27
81
  */
28
82
  readonly entryType: EntryType;
29
-
30
83
  /**
31
- * When `performanceEntry.entryType` is equal to 'gc', `the performance.kind` property identifies
32
- * the type of garbage collection operation that occurred.
33
- * See perf_hooks.constants for valid values.
34
- */
35
- readonly kind?: number;
36
-
37
- /**
38
- * When `performanceEntry.entryType` is equal to 'gc', the `performance.flags`
39
- * property contains additional information about garbage collection operation.
40
- * See perf_hooks.constants for valid values.
84
+ * Additional detail specific to the `entryType`.
85
+ * @since v16.0.0
41
86
  */
42
- readonly flags?: number;
87
+ readonly detail?: NodeGCPerformanceDetail | unknown | undefined; // TODO: Narrow this based on entry type.
88
+ toJSON(): any;
43
89
  }
44
-
90
+ class PerformanceMark extends PerformanceEntry {
91
+ readonly duration: 0;
92
+ readonly entryType: 'mark';
93
+ }
94
+ class PerformanceMeasure extends PerformanceEntry {
95
+ readonly entryType: 'measure';
96
+ }
97
+ /**
98
+ * _This property is an extension by Node.js. It is not available in Web browsers._
99
+ *
100
+ * Provides timing details for Node.js itself. The constructor of this class
101
+ * is not exposed to users.
102
+ * @since v8.5.0
103
+ */
45
104
  class PerformanceNodeTiming extends PerformanceEntry {
46
105
  /**
47
- * The high resolution millisecond timestamp at which the Node.js process completed bootstrap.
106
+ * The high resolution millisecond timestamp at which the Node.js process
107
+ * completed bootstrapping. If bootstrapping has not yet finished, the property
108
+ * has the value of -1.
109
+ * @since v8.5.0
48
110
  */
49
111
  readonly bootstrapComplete: number;
50
-
51
112
  /**
52
- * The high resolution millisecond timestamp at which the Node.js process completed bootstrapping.
53
- * If bootstrapping has not yet finished, the property has the value of -1.
113
+ * The high resolution millisecond timestamp at which the Node.js environment was
114
+ * initialized.
115
+ * @since v8.5.0
54
116
  */
55
117
  readonly environment: number;
56
-
57
118
  /**
58
- * The high resolution millisecond timestamp at which the Node.js environment was initialized.
119
+ * The high resolution millisecond timestamp of the amount of time the event loop
120
+ * has been idle within the event loop's event provider (e.g. `epoll_wait`). This
121
+ * does not take CPU usage into consideration. If the event loop has not yet
122
+ * started (e.g., in the first tick of the main script), the property has the
123
+ * value of 0.
124
+ * @since v14.10.0, v12.19.0
59
125
  */
60
126
  readonly idleTime: number;
61
-
62
127
  /**
63
- * The high resolution millisecond timestamp of the amount of time the event loop has been idle
64
- * within the event loop's event provider (e.g. `epoll_wait`). This does not take CPU usage
65
- * into consideration. If the event loop has not yet started (e.g., in the first tick of the main script),
66
- * the property has the value of 0.
128
+ * The high resolution millisecond timestamp at which the Node.js event loop
129
+ * exited. If the event loop has not yet exited, the property has the value of -1\.
130
+ * It can only have a value of not -1 in a handler of the `'exit'` event.
131
+ * @since v8.5.0
67
132
  */
68
133
  readonly loopExit: number;
69
-
70
134
  /**
71
- * The high resolution millisecond timestamp at which the Node.js event loop started.
72
- * If the event loop has not yet started (e.g., in the first tick of the main script), the property has the value of -1.
135
+ * The high resolution millisecond timestamp at which the Node.js event loop
136
+ * started. If the event loop has not yet started (e.g., in the first tick of the
137
+ * main script), the property has the value of -1.
138
+ * @since v8.5.0
73
139
  */
74
140
  readonly loopStart: number;
75
-
76
141
  /**
77
- * The high resolution millisecond timestamp at which the V8 platform was initialized.
142
+ * The high resolution millisecond timestamp at which the V8 platform was
143
+ * initialized.
144
+ * @since v8.5.0
78
145
  */
79
146
  readonly v8Start: number;
80
147
  }
81
-
82
148
  interface EventLoopUtilization {
83
149
  idle: number;
84
150
  active: number;
85
151
  utilization: number;
86
152
  }
87
-
88
153
  /**
89
154
  * @param util1 The result of a previous call to eventLoopUtilization()
90
155
  * @param util2 The result of a previous call to eventLoopUtilization() prior to util1
91
156
  */
92
- type EventLoopUtilityFunction = (
93
- util1?: EventLoopUtilization,
94
- util2?: EventLoopUtilization,
95
- ) => EventLoopUtilization;
96
-
157
+ type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: EventLoopUtilization) => EventLoopUtilization;
158
+ interface MarkOptions {
159
+ /**
160
+ * Additional optional detail to include with the mark.
161
+ */
162
+ detail?: unknown | undefined;
163
+ /**
164
+ * An optional timestamp to be used as the mark time.
165
+ * @default `performance.now()`.
166
+ */
167
+ startTime?: number | undefined;
168
+ }
169
+ interface MeasureOptions {
170
+ /**
171
+ * Additional optional detail to include with the mark.
172
+ */
173
+ detail?: unknown | undefined;
174
+ /**
175
+ * Duration between start and end times.
176
+ */
177
+ duration?: number | undefined;
178
+ /**
179
+ * Timestamp to be used as the end time, or a string identifying a previously recorded mark.
180
+ */
181
+ end?: number | string | undefined;
182
+ /**
183
+ * Timestamp to be used as the start time, or a string identifying a previously recorded mark.
184
+ */
185
+ start?: number | string | undefined;
186
+ }
187
+ interface TimerifyOptions {
188
+ /**
189
+ * A histogram object created using
190
+ * `perf_hooks.createHistogram()` that will record runtime durations in
191
+ * nanoseconds.
192
+ */
193
+ histogram?: RecordableHistogram | undefined;
194
+ }
97
195
  interface Performance {
98
196
  /**
99
197
  * If name is not provided, removes all PerformanceMark objects from the Performance Timeline.
@@ -101,16 +199,44 @@ declare module 'perf_hooks' {
101
199
  * @param name
102
200
  */
103
201
  clearMarks(name?: string): void;
104
-
202
+ /**
203
+ * If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline.
204
+ * If name is provided, removes only the named measure.
205
+ * @param name
206
+ * @since v16.7.0
207
+ */
208
+ clearMeasures(name?: string): void;
209
+ /**
210
+ * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`.
211
+ * If you are only interested in performance entries of certain types or that have certain names, see
212
+ * `performance.getEntriesByType()` and `performance.getEntriesByName()`.
213
+ * @since v16.7.0
214
+ */
215
+ getEntries(): PerformanceEntry[];
216
+ /**
217
+ * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`
218
+ * whose `performanceEntry.name` is equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to `type`.
219
+ * @param name
220
+ * @param type
221
+ * @since v16.7.0
222
+ */
223
+ getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
224
+ /**
225
+ * Returns a list of `PerformanceEntry` objects in chronological order with respect to `performanceEntry.startTime`
226
+ * whose `performanceEntry.entryType` is equal to `type`.
227
+ * @param type
228
+ * @since v16.7.0
229
+ */
230
+ getEntriesByType(type: EntryType): PerformanceEntry[];
105
231
  /**
106
232
  * Creates a new PerformanceMark entry in the Performance Timeline.
107
233
  * A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark',
108
234
  * and whose performanceEntry.duration is always 0.
109
235
  * Performance marks are used to mark specific significant moments in the Performance Timeline.
110
236
  * @param name
237
+ * @return The PerformanceMark entry that was created
111
238
  */
112
- mark(name?: string): void;
113
-
239
+ mark(name?: string, options?: MarkOptions): PerformanceMark;
114
240
  /**
115
241
  * Creates a new PerformanceMeasure entry in the Performance Timeline.
116
242
  * A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure',
@@ -125,31 +251,28 @@ declare module 'perf_hooks' {
125
251
  * @param name
126
252
  * @param startMark
127
253
  * @param endMark
254
+ * @return The PerformanceMeasure entry that was created
128
255
  */
129
- measure(name: string, startMark?: string, endMark?: string): void;
130
-
256
+ measure(name: string, startMark?: string, endMark?: string): PerformanceMeasure;
257
+ measure(name: string, options: MeasureOptions): PerformanceMeasure;
131
258
  /**
132
259
  * An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
133
260
  */
134
261
  readonly nodeTiming: PerformanceNodeTiming;
135
-
136
262
  /**
137
263
  * @return the current high resolution millisecond timestamp
138
264
  */
139
265
  now(): number;
140
-
141
266
  /**
142
267
  * The timeOrigin specifies the high resolution millisecond timestamp from which all performance metric durations are measured.
143
268
  */
144
269
  readonly timeOrigin: number;
145
-
146
270
  /**
147
271
  * Wraps a function within a new function that measures the running time of the wrapped function.
148
272
  * A PerformanceObserver must be subscribed to the 'function' event type in order for the timing details to be accessed.
149
273
  * @param fn
150
274
  */
151
- timerify<T extends (...optionalParams: any[]) => any>(fn: T): T;
152
-
275
+ timerify<T extends (...params: any[]) => any>(fn: T, options?: TimerifyOptions): T;
153
276
  /**
154
277
  * eventLoopUtilization is similar to CPU utilization except that it is calculated using high precision wall-clock time.
155
278
  * It represents the percentage of time the event loop has spent outside the event loop's event provider (e.g. epoll_wait).
@@ -157,51 +280,183 @@ declare module 'perf_hooks' {
157
280
  */
158
281
  eventLoopUtilization: EventLoopUtilityFunction;
159
282
  }
160
-
161
283
  interface PerformanceObserverEntryList {
162
284
  /**
163
- * @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime.
285
+ * Returns a list of `PerformanceEntry` objects in chronological order
286
+ * with respect to `performanceEntry.startTime`.
287
+ *
288
+ * ```js
289
+ * const {
290
+ * performance,
291
+ * PerformanceObserver
292
+ * } = require('perf_hooks');
293
+ *
294
+ * const obs = new PerformanceObserver((perfObserverList, observer) => {
295
+ * console.log(perfObserverList.getEntries());
296
+ *
297
+ * * [
298
+ * * PerformanceEntry {
299
+ * * name: 'test',
300
+ * * entryType: 'mark',
301
+ * * startTime: 81.465639,
302
+ * * duration: 0
303
+ * * },
304
+ * * PerformanceEntry {
305
+ * * name: 'meow',
306
+ * * entryType: 'mark',
307
+ * * startTime: 81.860064,
308
+ * * duration: 0
309
+ * * }
310
+ * * ]
311
+ *
312
+ *
313
+ * performance.clearMarks();
314
+ * performance.clearMeasures();
315
+ * observer.disconnect();
316
+ * });
317
+ * obs.observe({ type: 'mark' });
318
+ *
319
+ * performance.mark('test');
320
+ * performance.mark('meow');
321
+ * ```
322
+ * @since v8.5.0
164
323
  */
165
324
  getEntries(): PerformanceEntry[];
166
-
167
325
  /**
168
- * @return a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
169
- * whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.
326
+ * Returns a list of `PerformanceEntry` objects in chronological order
327
+ * with respect to `performanceEntry.startTime` whose `performanceEntry.name` is
328
+ * equal to `name`, and optionally, whose `performanceEntry.entryType` is equal to`type`.
329
+ *
330
+ * ```js
331
+ * const {
332
+ * performance,
333
+ * PerformanceObserver
334
+ * } = require('perf_hooks');
335
+ *
336
+ * const obs = new PerformanceObserver((perfObserverList, observer) => {
337
+ * console.log(perfObserverList.getEntriesByName('meow'));
338
+ *
339
+ * * [
340
+ * * PerformanceEntry {
341
+ * * name: 'meow',
342
+ * * entryType: 'mark',
343
+ * * startTime: 98.545991,
344
+ * * duration: 0
345
+ * * }
346
+ * * ]
347
+ *
348
+ * console.log(perfObserverList.getEntriesByName('nope')); // []
349
+ *
350
+ * console.log(perfObserverList.getEntriesByName('test', 'mark'));
351
+ *
352
+ * * [
353
+ * * PerformanceEntry {
354
+ * * name: 'test',
355
+ * * entryType: 'mark',
356
+ * * startTime: 63.518931,
357
+ * * duration: 0
358
+ * * }
359
+ * * ]
360
+ *
361
+ * console.log(perfObserverList.getEntriesByName('test', 'measure')); // []
362
+ *
363
+ * performance.clearMarks();
364
+ * performance.clearMeasures();
365
+ * observer.disconnect();
366
+ * });
367
+ * obs.observe({ entryTypes: ['mark', 'measure'] });
368
+ *
369
+ * performance.mark('test');
370
+ * performance.mark('meow');
371
+ * ```
372
+ * @since v8.5.0
170
373
  */
171
374
  getEntriesByName(name: string, type?: EntryType): PerformanceEntry[];
172
-
173
375
  /**
174
- * @return Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime
175
- * whose performanceEntry.entryType is equal to type.
376
+ * Returns a list of `PerformanceEntry` objects in chronological order
377
+ * with respect to `performanceEntry.startTime` whose `performanceEntry.entryType`is equal to `type`.
378
+ *
379
+ * ```js
380
+ * const {
381
+ * performance,
382
+ * PerformanceObserver
383
+ * } = require('perf_hooks');
384
+ *
385
+ * const obs = new PerformanceObserver((perfObserverList, observer) => {
386
+ * console.log(perfObserverList.getEntriesByType('mark'));
387
+ *
388
+ * * [
389
+ * * PerformanceEntry {
390
+ * * name: 'test',
391
+ * * entryType: 'mark',
392
+ * * startTime: 55.897834,
393
+ * * duration: 0
394
+ * * },
395
+ * * PerformanceEntry {
396
+ * * name: 'meow',
397
+ * * entryType: 'mark',
398
+ * * startTime: 56.350146,
399
+ * * duration: 0
400
+ * * }
401
+ * * ]
402
+ *
403
+ * performance.clearMarks();
404
+ * performance.clearMeasures();
405
+ * observer.disconnect();
406
+ * });
407
+ * obs.observe({ type: 'mark' });
408
+ *
409
+ * performance.mark('test');
410
+ * performance.mark('meow');
411
+ * ```
412
+ * @since v8.5.0
176
413
  */
177
414
  getEntriesByType(type: EntryType): PerformanceEntry[];
178
415
  }
179
-
180
416
  type PerformanceObserverCallback = (list: PerformanceObserverEntryList, observer: PerformanceObserver) => void;
181
-
182
417
  class PerformanceObserver extends AsyncResource {
183
418
  constructor(callback: PerformanceObserverCallback);
184
-
185
419
  /**
186
- * Disconnects the PerformanceObserver instance from all notifications.
420
+ * Disconnects the `PerformanceObserver` instance from all notifications.
421
+ * @since v8.5.0
187
422
  */
188
423
  disconnect(): void;
189
-
190
424
  /**
191
- * Subscribes the PerformanceObserver instance to notifications of new PerformanceEntry instances identified by options.entryTypes.
192
- * When options.buffered is false, the callback will be invoked once for every PerformanceEntry instance.
193
- * Property buffered defaults to false.
194
- * @param options
195
- */
196
- observe(options: { entryTypes: ReadonlyArray<EntryType>; buffered?: boolean }): void;
425
+ * Subscribes the `PerformanceObserver` instance to notifications of new `PerformanceEntry` instances identified either by `options.entryTypes`or `options.type`:
426
+ *
427
+ * ```js
428
+ * const {
429
+ * performance,
430
+ * PerformanceObserver
431
+ * } = require('perf_hooks');
432
+ *
433
+ * const obs = new PerformanceObserver((list, observer) => {
434
+ * // Called once asynchronously. `list` contains three items.
435
+ * });
436
+ * obs.observe({ type: 'mark' });
437
+ *
438
+ * for (let n = 0; n < 3; n++)
439
+ * performance.mark(`test${n}`);
440
+ * ```
441
+ * @since v8.5.0
442
+ */
443
+ observe(
444
+ options:
445
+ | {
446
+ entryTypes: ReadonlyArray<EntryType>;
447
+ buffered?: boolean | undefined;
448
+ }
449
+ | {
450
+ type: EntryType;
451
+ buffered?: boolean | undefined;
452
+ }
453
+ ): void;
197
454
  }
198
-
199
455
  namespace constants {
200
456
  const NODE_PERFORMANCE_GC_MAJOR: number;
201
457
  const NODE_PERFORMANCE_GC_MINOR: number;
202
458
  const NODE_PERFORMANCE_GC_INCREMENTAL: number;
203
459
  const NODE_PERFORMANCE_GC_WEAKCB: number;
204
-
205
460
  const NODE_PERFORMANCE_GC_FLAGS_NO: number;
206
461
  const NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED: number;
207
462
  const NODE_PERFORMANCE_GC_FLAGS_FORCED: number;
@@ -210,101 +465,161 @@ declare module 'perf_hooks' {
210
465
  const NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY: number;
211
466
  const NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE: number;
212
467
  }
213
-
214
468
  const performance: Performance;
215
-
216
469
  interface EventLoopMonitorOptions {
217
470
  /**
218
471
  * The sampling rate in milliseconds.
219
472
  * Must be greater than zero.
220
473
  * @default 10
221
474
  */
222
- resolution?: number;
475
+ resolution?: number | undefined;
223
476
  }
224
-
225
477
  interface Histogram {
226
478
  /**
227
- * A `Map` object detailing the accumulated percentile distribution.
479
+ * Returns a `Map` object detailing the accumulated percentile distribution.
480
+ * @since v11.10.0
228
481
  */
229
482
  readonly percentiles: Map<number, number>;
230
-
231
483
  /**
232
- * The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold.
484
+ * The number of times the event loop delay exceeded the maximum 1 hour event
485
+ * loop delay threshold.
486
+ * @since v11.10.0
233
487
  */
234
488
  readonly exceeds: number;
235
-
236
489
  /**
237
490
  * The minimum recorded event loop delay.
491
+ * @since v11.10.0
238
492
  */
239
493
  readonly min: number;
240
-
241
494
  /**
242
495
  * The maximum recorded event loop delay.
496
+ * @since v11.10.0
243
497
  */
244
498
  readonly max: number;
245
-
246
499
  /**
247
500
  * The mean of the recorded event loop delays.
501
+ * @since v11.10.0
248
502
  */
249
503
  readonly mean: number;
250
-
251
504
  /**
252
505
  * The standard deviation of the recorded event loop delays.
506
+ * @since v11.10.0
253
507
  */
254
508
  readonly stddev: number;
255
-
256
509
  /**
257
510
  * Resets the collected histogram data.
511
+ * @since v11.10.0
258
512
  */
259
513
  reset(): void;
260
-
261
514
  /**
262
515
  * Returns the value at the given percentile.
263
- * @param percentile A percentile value between 1 and 100.
516
+ * @since v11.10.0
517
+ * @param percentile A percentile value in the range (0, 100].
264
518
  */
265
519
  percentile(percentile: number): number;
266
520
  }
267
-
268
521
  interface IntervalHistogram extends Histogram {
269
522
  /**
270
- * Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started.
523
+ * Enables the update interval timer. Returns `true` if the timer was
524
+ * started, `false` if it was already started.
525
+ * @since v11.10.0
271
526
  */
272
527
  enable(): boolean;
273
528
  /**
274
- * Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped.
529
+ * Disables the update interval timer. Returns `true` if the timer was
530
+ * stopped, `false` if it was already stopped.
531
+ * @since v11.10.0
275
532
  */
276
533
  disable(): boolean;
277
534
  }
278
-
279
535
  interface RecordableHistogram extends Histogram {
536
+ /**
537
+ * @since v15.9.0, v14.18.0
538
+ * @param val The amount to record in the histogram.
539
+ */
280
540
  record(val: number | bigint): void;
281
-
282
541
  /**
283
- * Calculates the amount of time (in nanoseconds) that has passed since the previous call to recordDelta() and records that amount in the histogram.
542
+ * Calculates the amount of time (in nanoseconds) that has passed since the
543
+ * previous call to `recordDelta()` and records that amount in the histogram.
544
+ *
545
+ * ## Examples
546
+ * @since v15.9.0, v14.18.0
284
547
  */
285
548
  recordDelta(): void;
549
+ /**
550
+ * Adds the values from other to this histogram.
551
+ * @since v17.4.0, v16.14.0
552
+ * @param other Recordable Histogram to combine with
553
+ */
554
+ add(other: RecordableHistogram): void;
286
555
  }
287
-
556
+ /**
557
+ * _This property is an extension by Node.js. It is not available in Web browsers._
558
+ *
559
+ * Creates an `IntervalHistogram` object that samples and reports the event loop
560
+ * delay over time. The delays will be reported in nanoseconds.
561
+ *
562
+ * Using a timer to detect approximate event loop delay works because the
563
+ * execution of timers is tied specifically to the lifecycle of the libuv
564
+ * event loop. That is, a delay in the loop will cause a delay in the execution
565
+ * of the timer, and those delays are specifically what this API is intended to
566
+ * detect.
567
+ *
568
+ * ```js
569
+ * const { monitorEventLoopDelay } = require('perf_hooks');
570
+ * const h = monitorEventLoopDelay({ resolution: 20 });
571
+ * h.enable();
572
+ * // Do something.
573
+ * h.disable();
574
+ * console.log(h.min);
575
+ * console.log(h.max);
576
+ * console.log(h.mean);
577
+ * console.log(h.stddev);
578
+ * console.log(h.percentiles);
579
+ * console.log(h.percentile(50));
580
+ * console.log(h.percentile(99));
581
+ * ```
582
+ * @since v11.10.0
583
+ */
288
584
  function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
289
-
290
585
  interface CreateHistogramOptions {
291
586
  /**
292
587
  * The minimum recordable value. Must be an integer value greater than 0.
293
588
  * @default 1
294
589
  */
295
- min?: number | bigint;
296
-
590
+ min?: number | bigint | undefined;
297
591
  /**
298
592
  * The maximum recordable value. Must be an integer value greater than min.
299
593
  * @default Number.MAX_SAFE_INTEGER
300
594
  */
301
- max?: number | bigint;
595
+ max?: number | bigint | undefined;
302
596
  /**
303
597
  * The number of accuracy digits. Must be a number between 1 and 5.
304
598
  * @default 3
305
599
  */
306
- figures?: number;
600
+ figures?: number | undefined;
307
601
  }
308
-
602
+ /**
603
+ * Returns a `RecordableHistogram`.
604
+ * @since v15.9.0, v14.18.0
605
+ */
309
606
  function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
607
+
608
+ import { performance as _performance } from 'perf_hooks';
609
+ global {
610
+ /**
611
+ * `performance` is a global reference for `require('perf_hooks').performance`
612
+ * https://nodejs.org/api/globals.html#performance
613
+ * @since v16.0.0
614
+ */
615
+ var performance: typeof globalThis extends {
616
+ onmessage: any;
617
+ performance: infer T;
618
+ }
619
+ ? T
620
+ : typeof _performance;
621
+ }
622
+ }
623
+ declare module 'node:perf_hooks' {
624
+ export * from 'perf_hooks';
310
625
  }