@shopify/ui-extensions-server-kit 5.2.0 → 5.3.0

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 (169) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/ExtensionServerClient/ExtensionServerClient.cjs.js +1 -1
  3. package/dist/ExtensionServerClient/ExtensionServerClient.d.ts +1 -0
  4. package/dist/ExtensionServerClient/ExtensionServerClient.es.js +1 -1
  5. package/dist/ExtensionServerClient/ExtensionServerClient.test.d.ts +8 -0
  6. package/dist/ExtensionServerClient/server-types.d.ts +42 -0
  7. package/dist/context/constants.cjs.js +1 -1
  8. package/dist/context/constants.d.ts +0 -1
  9. package/dist/context/constants.es.js +0 -1
  10. package/dist/context/types.d.ts +1 -0
  11. package/dist/hooks/index.d.ts +0 -2
  12. package/dist/i18n.cjs.js +1 -1
  13. package/dist/i18n.d.ts +1 -20
  14. package/dist/i18n.es.js +0 -1
  15. package/dist/index.cjs.js +1 -1
  16. package/dist/index.es.js +40 -48
  17. package/dist/testing/extensions.cjs.js +1 -1
  18. package/dist/testing/extensions.es.js +2 -2
  19. package/dist/types.cjs.js +1 -1
  20. package/dist/types.d.ts +10 -4
  21. package/dist/types.es.js +2 -2
  22. package/dist/utilities/index.d.ts +0 -1
  23. package/node_modules/@shopify/ui-extensions-test-utils/dist/index.d.ts +3 -0
  24. package/node_modules/@shopify/ui-extensions-test-utils/dist/render.d.ts +2 -0
  25. package/node_modules/@shopify/ui-extensions-test-utils/dist/renderHook.d.ts +17 -0
  26. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.d.ts +9 -0
  27. package/node_modules/@shopify/ui-extensions-test-utils/dist/withProviders.js +1 -0
  28. package/node_modules/@shopify/ui-extensions-test-utils/package.json +2 -3
  29. package/package.json +7 -6
  30. package/project.json +0 -2
  31. package/src/ExtensionServerClient/ExtensionServerClient.test.ts +837 -330
  32. package/src/ExtensionServerClient/ExtensionServerClient.ts +10 -8
  33. package/src/ExtensionServerClient/server-types.ts +55 -0
  34. package/src/ExtensionServerClient/types.ts +2 -0
  35. package/src/context/ExtensionServerProvider.test.tsx +202 -39
  36. package/src/context/ExtensionServerProvider.tsx +1 -0
  37. package/src/context/constants.ts +3 -2
  38. package/src/context/types.ts +1 -0
  39. package/src/hooks/index.ts +0 -2
  40. package/src/i18n.ts +3 -3
  41. package/src/state/reducers/extensionServerReducer.test.ts +2 -2
  42. package/src/testing/extensions.ts +2 -2
  43. package/src/types.ts +10 -4
  44. package/src/utilities/index.ts +0 -1
  45. package/src/utilities/replaceUpdated.ts +1 -0
  46. package/src/utilities/set.ts +1 -0
  47. package/dist/hooks/useExtensionClient.cjs.js +0 -1
  48. package/dist/hooks/useExtensionClient.d.ts +0 -1
  49. package/dist/hooks/useExtensionClient.es.js +0 -8
  50. package/dist/hooks/useExtensionServerEvent.cjs.js +0 -1
  51. package/dist/hooks/useExtensionServerEvent.d.ts +0 -1
  52. package/dist/hooks/useExtensionServerEvent.es.js +0 -9
  53. package/dist/utilities/groupByKey.cjs.js +0 -1
  54. package/dist/utilities/groupByKey.d.ts +0 -3
  55. package/dist/utilities/groupByKey.es.js +0 -6
  56. package/node_modules/@types/node/LICENSE +0 -21
  57. package/node_modules/@types/node/README.md +0 -15
  58. package/node_modules/@types/node/assert/strict.d.ts +0 -8
  59. package/node_modules/@types/node/assert.d.ts +0 -985
  60. package/node_modules/@types/node/async_hooks.d.ts +0 -522
  61. package/node_modules/@types/node/buffer.d.ts +0 -2321
  62. package/node_modules/@types/node/child_process.d.ts +0 -1544
  63. package/node_modules/@types/node/cluster.d.ts +0 -432
  64. package/node_modules/@types/node/console.d.ts +0 -412
  65. package/node_modules/@types/node/constants.d.ts +0 -19
  66. package/node_modules/@types/node/crypto.d.ts +0 -4451
  67. package/node_modules/@types/node/dgram.d.ts +0 -586
  68. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -192
  69. package/node_modules/@types/node/dns/promises.d.ts +0 -381
  70. package/node_modules/@types/node/dns.d.ts +0 -809
  71. package/node_modules/@types/node/dom-events.d.ts +0 -122
  72. package/node_modules/@types/node/domain.d.ts +0 -170
  73. package/node_modules/@types/node/events.d.ts +0 -803
  74. package/node_modules/@types/node/fs/promises.d.ts +0 -1205
  75. package/node_modules/@types/node/fs.d.ts +0 -4211
  76. package/node_modules/@types/node/globals.d.ts +0 -377
  77. package/node_modules/@types/node/globals.global.d.ts +0 -1
  78. package/node_modules/@types/node/http.d.ts +0 -1801
  79. package/node_modules/@types/node/http2.d.ts +0 -2386
  80. package/node_modules/@types/node/https.d.ts +0 -544
  81. package/node_modules/@types/node/index.d.ts +0 -88
  82. package/node_modules/@types/node/inspector.d.ts +0 -2739
  83. package/node_modules/@types/node/module.d.ts +0 -298
  84. package/node_modules/@types/node/net.d.ts +0 -913
  85. package/node_modules/@types/node/os.d.ts +0 -473
  86. package/node_modules/@types/node/package.json +0 -235
  87. package/node_modules/@types/node/path.d.ts +0 -191
  88. package/node_modules/@types/node/perf_hooks.d.ts +0 -626
  89. package/node_modules/@types/node/process.d.ts +0 -1531
  90. package/node_modules/@types/node/punycode.d.ts +0 -117
  91. package/node_modules/@types/node/querystring.d.ts +0 -141
  92. package/node_modules/@types/node/readline/promises.d.ts +0 -143
  93. package/node_modules/@types/node/readline.d.ts +0 -666
  94. package/node_modules/@types/node/repl.d.ts +0 -430
  95. package/node_modules/@types/node/stream/consumers.d.ts +0 -12
  96. package/node_modules/@types/node/stream/promises.d.ts +0 -83
  97. package/node_modules/@types/node/stream/web.d.ts +0 -336
  98. package/node_modules/@types/node/stream.d.ts +0 -1731
  99. package/node_modules/@types/node/string_decoder.d.ts +0 -67
  100. package/node_modules/@types/node/test.d.ts +0 -1113
  101. package/node_modules/@types/node/timers/promises.d.ts +0 -93
  102. package/node_modules/@types/node/timers.d.ts +0 -126
  103. package/node_modules/@types/node/tls.d.ts +0 -1203
  104. package/node_modules/@types/node/trace_events.d.ts +0 -171
  105. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  106. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -985
  107. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -522
  108. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2321
  109. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1544
  110. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  111. package/node_modules/@types/node/ts4.8/console.d.ts +0 -412
  112. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  113. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4450
  114. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -586
  115. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -192
  116. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -381
  117. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  118. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  119. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  120. package/node_modules/@types/node/ts4.8/events.d.ts +0 -754
  121. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1205
  122. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4211
  123. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -377
  124. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  125. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1801
  126. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2386
  127. package/node_modules/@types/node/ts4.8/https.d.ts +0 -544
  128. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  129. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2739
  130. package/node_modules/@types/node/ts4.8/module.d.ts +0 -298
  131. package/node_modules/@types/node/ts4.8/net.d.ts +0 -913
  132. package/node_modules/@types/node/ts4.8/os.d.ts +0 -473
  133. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  134. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -626
  135. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1531
  136. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  137. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  138. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -143
  139. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -666
  140. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  141. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  142. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  143. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -336
  144. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1731
  145. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  146. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1113
  147. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  148. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -126
  149. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1203
  150. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -171
  151. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -206
  152. package/node_modules/@types/node/ts4.8/url.d.ts +0 -937
  153. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2075
  154. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -541
  155. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -667
  156. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -158
  157. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -692
  158. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  159. package/node_modules/@types/node/tty.d.ts +0 -206
  160. package/node_modules/@types/node/url.d.ts +0 -937
  161. package/node_modules/@types/node/util.d.ts +0 -2075
  162. package/node_modules/@types/node/v8.d.ts +0 -541
  163. package/node_modules/@types/node/vm.d.ts +0 -667
  164. package/node_modules/@types/node/wasi.d.ts +0 -158
  165. package/node_modules/@types/node/worker_threads.d.ts +0 -692
  166. package/node_modules/@types/node/zlib.d.ts +0 -517
  167. package/src/hooks/useExtensionClient.ts +0 -6
  168. package/src/hooks/useExtensionServerEvent.ts +0 -11
  169. package/src/utilities/groupByKey.ts +0 -3
@@ -1,541 +0,0 @@
1
- /**
2
- * The `v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
3
- *
4
- * ```js
5
- * const v8 = require('v8');
6
- * ```
7
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js)
8
- */
9
- declare module "v8" {
10
- import { Readable } from "node:stream";
11
- interface HeapSpaceInfo {
12
- space_name: string;
13
- space_size: number;
14
- space_used_size: number;
15
- space_available_size: number;
16
- physical_space_size: number;
17
- }
18
- // ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
19
- type DoesZapCodeSpaceFlag = 0 | 1;
20
- interface HeapInfo {
21
- total_heap_size: number;
22
- total_heap_size_executable: number;
23
- total_physical_size: number;
24
- total_available_size: number;
25
- used_heap_size: number;
26
- heap_size_limit: number;
27
- malloced_memory: number;
28
- peak_malloced_memory: number;
29
- does_zap_garbage: DoesZapCodeSpaceFlag;
30
- number_of_native_contexts: number;
31
- number_of_detached_contexts: number;
32
- }
33
- interface HeapCodeStatistics {
34
- code_and_metadata_size: number;
35
- bytecode_and_metadata_size: number;
36
- external_script_source_size: number;
37
- }
38
- /**
39
- * Returns an integer representing a version tag derived from the V8 version,
40
- * command-line flags, and detected CPU features. This is useful for determining
41
- * whether a `vm.Script` `cachedData` buffer is compatible with this instance
42
- * of V8.
43
- *
44
- * ```js
45
- * console.log(v8.cachedDataVersionTag()); // 3947234607
46
- * // The value returned by v8.cachedDataVersionTag() is derived from the V8
47
- * // version, command-line flags, and detected CPU features. Test that the value
48
- * // does indeed update when flags are toggled.
49
- * v8.setFlagsFromString('--allow_natives_syntax');
50
- * console.log(v8.cachedDataVersionTag()); // 183726201
51
- * ```
52
- * @since v8.0.0
53
- */
54
- function cachedDataVersionTag(): number;
55
- /**
56
- * Returns an object with the following properties:
57
- *
58
- * `does_zap_garbage` is a 0/1 boolean, which signifies whether the`--zap_code_space` option is enabled or not. This makes V8 overwrite heap
59
- * garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
60
- * because it continuously touches all heap pages and that makes them less likely
61
- * to get swapped out by the operating system.
62
- *
63
- * `number_of_native_contexts` The value of native\_context is the number of the
64
- * top-level contexts currently active. Increase of this number over time indicates
65
- * a memory leak.
66
- *
67
- * `number_of_detached_contexts` The value of detached\_context is the number
68
- * of contexts that were detached and not yet garbage collected. This number
69
- * being non-zero indicates a potential memory leak.
70
- *
71
- * ```js
72
- * {
73
- * total_heap_size: 7326976,
74
- * total_heap_size_executable: 4194304,
75
- * total_physical_size: 7326976,
76
- * total_available_size: 1152656,
77
- * used_heap_size: 3476208,
78
- * heap_size_limit: 1535115264,
79
- * malloced_memory: 16384,
80
- * peak_malloced_memory: 1127496,
81
- * does_zap_garbage: 0,
82
- * number_of_native_contexts: 1,
83
- * number_of_detached_contexts: 0
84
- * }
85
- * ```
86
- * @since v1.0.0
87
- */
88
- function getHeapStatistics(): HeapInfo;
89
- /**
90
- * Returns statistics about the V8 heap spaces, i.e. the segments which make up
91
- * the V8 heap. Neither the ordering of heap spaces, nor the availability of a
92
- * heap space can be guaranteed as the statistics are provided via the
93
- * V8[`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
94
- * next.
95
- *
96
- * The value returned is an array of objects containing the following properties:
97
- *
98
- * ```json
99
- * [
100
- * {
101
- * "space_name": "new_space",
102
- * "space_size": 2063872,
103
- * "space_used_size": 951112,
104
- * "space_available_size": 80824,
105
- * "physical_space_size": 2063872
106
- * },
107
- * {
108
- * "space_name": "old_space",
109
- * "space_size": 3090560,
110
- * "space_used_size": 2493792,
111
- * "space_available_size": 0,
112
- * "physical_space_size": 3090560
113
- * },
114
- * {
115
- * "space_name": "code_space",
116
- * "space_size": 1260160,
117
- * "space_used_size": 644256,
118
- * "space_available_size": 960,
119
- * "physical_space_size": 1260160
120
- * },
121
- * {
122
- * "space_name": "map_space",
123
- * "space_size": 1094160,
124
- * "space_used_size": 201608,
125
- * "space_available_size": 0,
126
- * "physical_space_size": 1094160
127
- * },
128
- * {
129
- * "space_name": "large_object_space",
130
- * "space_size": 0,
131
- * "space_used_size": 0,
132
- * "space_available_size": 1490980608,
133
- * "physical_space_size": 0
134
- * }
135
- * ]
136
- * ```
137
- * @since v6.0.0
138
- */
139
- function getHeapSpaceStatistics(): HeapSpaceInfo[];
140
- /**
141
- * The `v8.setFlagsFromString()` method can be used to programmatically set
142
- * V8 command-line flags. This method should be used with care. Changing settings
143
- * after the VM has started may result in unpredictable behavior, including
144
- * crashes and data loss; or it may simply do nothing.
145
- *
146
- * The V8 options available for a version of Node.js may be determined by running`node --v8-options`.
147
- *
148
- * Usage:
149
- *
150
- * ```js
151
- * // Print GC events to stdout for one minute.
152
- * const v8 = require('v8');
153
- * v8.setFlagsFromString('--trace_gc');
154
- * setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
155
- * ```
156
- * @since v1.0.0
157
- */
158
- function setFlagsFromString(flags: string): void;
159
- /**
160
- * Generates a snapshot of the current V8 heap and returns a Readable
161
- * Stream that may be used to read the JSON serialized representation.
162
- * This JSON stream format is intended to be used with tools such as
163
- * Chrome DevTools. The JSON schema is undocumented and specific to the
164
- * V8 engine. Therefore, the schema may change from one version of V8 to the next.
165
- *
166
- * Creating a heap snapshot requires memory about twice the size of the heap at
167
- * the time the snapshot is created. This results in the risk of OOM killers
168
- * terminating the process.
169
- *
170
- * Generating a snapshot is a synchronous operation which blocks the event loop
171
- * for a duration depending on the heap size.
172
- *
173
- * ```js
174
- * // Print heap snapshot to the console
175
- * const v8 = require('v8');
176
- * const stream = v8.getHeapSnapshot();
177
- * stream.pipe(process.stdout);
178
- * ```
179
- * @since v11.13.0
180
- * @return A Readable Stream containing the V8 heap snapshot
181
- */
182
- function getHeapSnapshot(): Readable;
183
- /**
184
- * Generates a snapshot of the current V8 heap and writes it to a JSON
185
- * file. This file is intended to be used with tools such as Chrome
186
- * DevTools. The JSON schema is undocumented and specific to the V8
187
- * engine, and may change from one version of V8 to the next.
188
- *
189
- * A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
190
- * not contain any information about the workers, and vice versa.
191
- *
192
- * Creating a heap snapshot requires memory about twice the size of the heap at
193
- * the time the snapshot is created. This results in the risk of OOM killers
194
- * terminating the process.
195
- *
196
- * Generating a snapshot is a synchronous operation which blocks the event loop
197
- * for a duration depending on the heap size.
198
- *
199
- * ```js
200
- * const { writeHeapSnapshot } = require('v8');
201
- * const {
202
- * Worker,
203
- * isMainThread,
204
- * parentPort
205
- * } = require('worker_threads');
206
- *
207
- * if (isMainThread) {
208
- * const worker = new Worker(__filename);
209
- *
210
- * worker.once('message', (filename) => {
211
- * console.log(`worker heapdump: ${filename}`);
212
- * // Now get a heapdump for the main thread.
213
- * console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
214
- * });
215
- *
216
- * // Tell the worker to create a heapdump.
217
- * worker.postMessage('heapdump');
218
- * } else {
219
- * parentPort.once('message', (message) => {
220
- * if (message === 'heapdump') {
221
- * // Generate a heapdump for the worker
222
- * // and return the filename to the parent.
223
- * parentPort.postMessage(writeHeapSnapshot());
224
- * }
225
- * });
226
- * }
227
- * ```
228
- * @since v11.13.0
229
- * @param filename The file path where the V8 heap snapshot is to be saved. If not specified, a file name with the pattern `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
230
- * generated, where `{pid}` will be the PID of the Node.js process, `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from the main Node.js thread or the id of a
231
- * worker thread.
232
- * @return The filename where the snapshot was saved.
233
- */
234
- function writeHeapSnapshot(filename?: string): string;
235
- /**
236
- * Returns an object with the following properties:
237
- *
238
- * ```js
239
- * {
240
- * code_and_metadata_size: 212208,
241
- * bytecode_and_metadata_size: 161368,
242
- * external_script_source_size: 1410794
243
- * }
244
- * ```
245
- * @since v12.8.0
246
- */
247
- function getHeapCodeStatistics(): HeapCodeStatistics;
248
- /**
249
- * @since v8.0.0
250
- */
251
- class Serializer {
252
- /**
253
- * Writes out a header, which includes the serialization format version.
254
- */
255
- writeHeader(): void;
256
- /**
257
- * Serializes a JavaScript value and adds the serialized representation to the
258
- * internal buffer.
259
- *
260
- * This throws an error if `value` cannot be serialized.
261
- */
262
- writeValue(val: any): boolean;
263
- /**
264
- * Returns the stored internal buffer. This serializer should not be used once
265
- * the buffer is released. Calling this method results in undefined behavior
266
- * if a previous write has failed.
267
- */
268
- releaseBuffer(): Buffer;
269
- /**
270
- * Marks an `ArrayBuffer` as having its contents transferred out of band.
271
- * Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
272
- * @param id A 32-bit unsigned integer.
273
- * @param arrayBuffer An `ArrayBuffer` instance.
274
- */
275
- transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
276
- /**
277
- * Write a raw 32-bit unsigned integer.
278
- * For use inside of a custom `serializer._writeHostObject()`.
279
- */
280
- writeUint32(value: number): void;
281
- /**
282
- * Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
283
- * For use inside of a custom `serializer._writeHostObject()`.
284
- */
285
- writeUint64(hi: number, lo: number): void;
286
- /**
287
- * Write a JS `number` value.
288
- * For use inside of a custom `serializer._writeHostObject()`.
289
- */
290
- writeDouble(value: number): void;
291
- /**
292
- * Write raw bytes into the serializer’s internal buffer. The deserializer
293
- * will require a way to compute the length of the buffer.
294
- * For use inside of a custom `serializer._writeHostObject()`.
295
- */
296
- writeRawBytes(buffer: NodeJS.TypedArray): void;
297
- }
298
- /**
299
- * A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
300
- * stores the part of their underlying `ArrayBuffer`s that they are referring to.
301
- * @since v8.0.0
302
- */
303
- class DefaultSerializer extends Serializer {}
304
- /**
305
- * @since v8.0.0
306
- */
307
- class Deserializer {
308
- constructor(data: NodeJS.TypedArray);
309
- /**
310
- * Reads and validates a header (including the format version).
311
- * May, for example, reject an invalid or unsupported wire format. In that case,
312
- * an `Error` is thrown.
313
- */
314
- readHeader(): boolean;
315
- /**
316
- * Deserializes a JavaScript value from the buffer and returns it.
317
- */
318
- readValue(): any;
319
- /**
320
- * Marks an `ArrayBuffer` as having its contents transferred out of band.
321
- * Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
322
- * `SharedArrayBuffer`s).
323
- * @param id A 32-bit unsigned integer.
324
- * @param arrayBuffer An `ArrayBuffer` instance.
325
- */
326
- transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
327
- /**
328
- * Reads the underlying wire format version. Likely mostly to be useful to
329
- * legacy code reading old wire format versions. May not be called before`.readHeader()`.
330
- */
331
- getWireFormatVersion(): number;
332
- /**
333
- * Read a raw 32-bit unsigned integer and return it.
334
- * For use inside of a custom `deserializer._readHostObject()`.
335
- */
336
- readUint32(): number;
337
- /**
338
- * Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]`with two 32-bit unsigned integer entries.
339
- * For use inside of a custom `deserializer._readHostObject()`.
340
- */
341
- readUint64(): [number, number];
342
- /**
343
- * Read a JS `number` value.
344
- * For use inside of a custom `deserializer._readHostObject()`.
345
- */
346
- readDouble(): number;
347
- /**
348
- * Read raw bytes from the deserializer’s internal buffer. The `length` parameter
349
- * must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
350
- * For use inside of a custom `deserializer._readHostObject()`.
351
- */
352
- readRawBytes(length: number): Buffer;
353
- }
354
- /**
355
- * A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
356
- * @since v8.0.0
357
- */
358
- class DefaultDeserializer extends Deserializer {}
359
- /**
360
- * Uses a `DefaultSerializer` to serialize `value` into a buffer.
361
- *
362
- * `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
363
- * serialize a huge object which requires buffer
364
- * larger than `buffer.constants.MAX_LENGTH`.
365
- * @since v8.0.0
366
- */
367
- function serialize(value: any): Buffer;
368
- /**
369
- * Uses a `DefaultDeserializer` with default options to read a JS value
370
- * from a buffer.
371
- * @since v8.0.0
372
- * @param buffer A buffer returned by {@link serialize}.
373
- */
374
- function deserialize(buffer: NodeJS.TypedArray): any;
375
- /**
376
- * The `v8.takeCoverage()` method allows the user to write the coverage started by `NODE_V8_COVERAGE` to disk on demand. This method can be invoked multiple
377
- * times during the lifetime of the process. Each time the execution counter will
378
- * be reset and a new coverage report will be written to the directory specified
379
- * by `NODE_V8_COVERAGE`.
380
- *
381
- * When the process is about to exit, one last coverage will still be written to
382
- * disk unless {@link stopCoverage} is invoked before the process exits.
383
- * @since v15.1.0, v14.18.0, v12.22.0
384
- */
385
- function takeCoverage(): void;
386
- /**
387
- * The `v8.stopCoverage()` method allows the user to stop the coverage collection
388
- * started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
389
- * records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
390
- * @since v15.1.0, v14.18.0, v12.22.0
391
- */
392
- function stopCoverage(): void;
393
-
394
- /**
395
- * This API collects GC data in current thread.
396
- */
397
- class GCProfiler {
398
- /**
399
- * Start collecting GC data.
400
- */
401
- start(): void;
402
- /**
403
- * Stop collecting GC data and return a object.
404
- */
405
- stop(): GCProfilerResult;
406
- }
407
- interface GCProfilerResult {
408
- version: number;
409
- startTime: number;
410
- endTime: number;
411
- statistics: Array<{
412
- gcType: string;
413
- cost: number;
414
- beforeGC: {
415
- heapStatistics: HeapStatistics;
416
- heapSpaceStatistics: HeapSpaceStatistics[];
417
- };
418
- afterGC: {
419
- heapStatistics: HeapStatistics;
420
- heapSpaceStatistics: HeapSpaceStatistics[];
421
- };
422
- }>;
423
- }
424
- interface HeapStatistics {
425
- totalHeapSize: number;
426
- totalHeapSizeExecutable: number;
427
- totalPhysicalSize: number;
428
- totalAvailableSize: number;
429
- totalGlobalHandlesSize: number;
430
- usedGlobalHandlesSize: number;
431
- usedHeapSize: number;
432
- heapSizeLimit: number;
433
- mallocedMemory: number;
434
- externalMemory: number;
435
- peakMallocedMemory: number;
436
- }
437
- interface HeapSpaceStatistics {
438
- spaceName: string;
439
- spaceSize: number;
440
- spaceUsedSize: number;
441
- spaceAvailableSize: number;
442
- physicalSpaceSize: number;
443
- }
444
- /**
445
- * Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
446
- * happen if a promise is created without ever getting a continuation.
447
- * @since v17.1.0, v16.14.0
448
- * @param promise The promise being created.
449
- * @param parent The promise continued from, if applicable.
450
- */
451
- interface Init {
452
- (promise: Promise<unknown>, parent: Promise<unknown>): void;
453
- }
454
- /**
455
- * Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
456
- *
457
- * The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
458
- * The before callback may be called many times in the case where many continuations have been made from the same promise.
459
- * @since v17.1.0, v16.14.0
460
- */
461
- interface Before {
462
- (promise: Promise<unknown>): void;
463
- }
464
- /**
465
- * Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
466
- * @since v17.1.0, v16.14.0
467
- */
468
- interface After {
469
- (promise: Promise<unknown>): void;
470
- }
471
- /**
472
- * Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
473
- * {@link Promise.reject()}.
474
- * @since v17.1.0, v16.14.0
475
- */
476
- interface Settled {
477
- (promise: Promise<unknown>): void;
478
- }
479
- /**
480
- * Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
481
- * around an await, and when the promise resolves or rejects.
482
- *
483
- * Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
484
- * `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
485
- * @since v17.1.0, v16.14.0
486
- */
487
- interface HookCallbacks {
488
- init?: Init;
489
- before?: Before;
490
- after?: After;
491
- settled?: Settled;
492
- }
493
- interface PromiseHooks {
494
- /**
495
- * The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
496
- * @since v17.1.0, v16.14.0
497
- * @param init The {@link Init | `init` callback} to call when a promise is created.
498
- * @return Call to stop the hook.
499
- */
500
- onInit: (init: Init) => Function;
501
- /**
502
- * The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
503
- * @since v17.1.0, v16.14.0
504
- * @param settled The {@link Settled | `settled` callback} to call when a promise is created.
505
- * @return Call to stop the hook.
506
- */
507
- onSettled: (settled: Settled) => Function;
508
- /**
509
- * The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
510
- * @since v17.1.0, v16.14.0
511
- * @param before The {@link Before | `before` callback} to call before a promise continuation executes.
512
- * @return Call to stop the hook.
513
- */
514
- onBefore: (before: Before) => Function;
515
- /**
516
- * The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
517
- * @since v17.1.0, v16.14.0
518
- * @param after The {@link After | `after` callback} to call after a promise continuation executes.
519
- * @return Call to stop the hook.
520
- */
521
- onAfter: (after: After) => Function;
522
- /**
523
- * Registers functions to be called for different lifetime events of each promise.
524
- * The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
525
- * All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
526
- * The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
527
- * @since v17.1.0, v16.14.0
528
- * @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
529
- * @return Used for disabling hooks
530
- */
531
- createHook: (callbacks: HookCallbacks) => Function;
532
- }
533
- /**
534
- * The `promiseHooks` interface can be used to track promise lifecycle events.
535
- * @since v17.1.0, v16.14.0
536
- */
537
- const promiseHooks: PromiseHooks;
538
- }
539
- declare module "node:v8" {
540
- export * from "v8";
541
- }