alicezetion 1.9.7 → 1.9.8
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/typescript/5.4/node_modules/.package-lock.json +137 -0
- package/.cache/typescript/5.4/node_modules/@types/bluebird/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/bluebird/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/bluebird/index.d.ts +1365 -0
- package/.cache/typescript/5.4/node_modules/@types/bluebird/package.json +25 -0
- package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +48 -0
- package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +29 -0
- package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +35 -0
- package/.cache/typescript/5.4/node_modules/@types/cheerio/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/cheerio/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/cheerio/index.d.ts +318 -0
- package/.cache/typescript/5.4/node_modules/@types/cheerio/package.json +71 -0
- package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/node/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +1040 -0
- package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +541 -0
- package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +2363 -0
- package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +1544 -0
- package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +578 -0
- package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +452 -0
- package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +19 -0
- package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +4523 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +596 -0
- package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +554 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +476 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +864 -0
- package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +124 -0
- package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +170 -0
- package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +931 -0
- package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +1245 -0
- package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +4317 -0
- package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +412 -0
- package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +1 -0
- package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +1908 -0
- package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +2418 -0
- package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +550 -0
- package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +89 -0
- package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +2746 -0
- package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +315 -0
- package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +999 -0
- package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +495 -0
- package/.cache/typescript/5.4/node_modules/@types/node/package.json +217 -0
- package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +191 -0
- package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +905 -0
- package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +1754 -0
- package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +117 -0
- package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +153 -0
- package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +150 -0
- package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +540 -0
- package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +430 -0
- package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +153 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +83 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +367 -0
- package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +1707 -0
- package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +1718 -0
- package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +97 -0
- package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +240 -0
- package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +1217 -0
- package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +197 -0
- package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +208 -0
- package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +952 -0
- package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +2292 -0
- package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +808 -0
- package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +924 -0
- package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +181 -0
- package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +694 -0
- package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +530 -0
- package/.cache/typescript/5.4/node_modules/@types/npmlog/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/npmlog/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/npmlog/index.d.ts +84 -0
- package/.cache/typescript/5.4/node_modules/@types/npmlog/package.json +32 -0
- package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/request/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +395 -0
- package/.cache/typescript/5.4/node_modules/@types/request/package.json +70 -0
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +15 -0
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +321 -0
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +35 -0
- package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +21 -0
- package/.cache/typescript/5.4/node_modules/asynckit/README.md +233 -0
- package/.cache/typescript/5.4/node_modules/asynckit/bench.js +76 -0
- package/.cache/typescript/5.4/node_modules/asynckit/index.js +6 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +29 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +34 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +26 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +75 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +91 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +25 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +25 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +29 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +37 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +141 -0
- package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +29 -0
- package/.cache/typescript/5.4/node_modules/asynckit/package.json +63 -0
- package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +43 -0
- package/.cache/typescript/5.4/node_modules/asynckit/serial.js +17 -0
- package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +75 -0
- package/.cache/typescript/5.4/node_modules/asynckit/stream.js +21 -0
- package/.cache/typescript/5.4/node_modules/combined-stream/License +19 -0
- package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +138 -0
- package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +208 -0
- package/.cache/typescript/5.4/node_modules/combined-stream/package.json +25 -0
- package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +17 -0
- package/.cache/typescript/5.4/node_modules/delayed-stream/License +19 -0
- package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +7 -0
- package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +141 -0
- package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +107 -0
- package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +27 -0
- package/.cache/typescript/5.4/node_modules/form-data/License +19 -0
- package/.cache/typescript/5.4/node_modules/form-data/README.md +350 -0
- package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +350 -0
- package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +51 -0
- package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +2 -0
- package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +483 -0
- package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +10 -0
- package/.cache/typescript/5.4/node_modules/form-data/package.json +68 -0
- package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +507 -0
- package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +23 -0
- package/.cache/typescript/5.4/node_modules/mime-db/README.md +100 -0
- package/.cache/typescript/5.4/node_modules/mime-db/db.json +8519 -0
- package/.cache/typescript/5.4/node_modules/mime-db/index.js +12 -0
- package/.cache/typescript/5.4/node_modules/mime-db/package.json +60 -0
- package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +397 -0
- package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +23 -0
- package/.cache/typescript/5.4/node_modules/mime-types/README.md +113 -0
- package/.cache/typescript/5.4/node_modules/mime-types/index.js +188 -0
- package/.cache/typescript/5.4/node_modules/mime-types/package.json +44 -0
- package/.cache/typescript/5.4/node_modules/types-registry/README.md +2 -0
- package/.cache/typescript/5.4/node_modules/types-registry/index.json +1 -0
- package/.cache/typescript/5.4/node_modules/types-registry/package.json +20 -0
- package/.cache/typescript/5.4/node_modules/undici-types/README.md +6 -0
- package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +31 -0
- package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +43 -0
- package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +18 -0
- package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +36 -0
- package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +97 -0
- package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +34 -0
- package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +21 -0
- package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +28 -0
- package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
- package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +241 -0
- package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +128 -0
- package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +209 -0
- package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +39 -0
- package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +54 -0
- package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +108 -0
- package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +7 -0
- package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +9 -0
- package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +4 -0
- package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +63 -0
- package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +5 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +25 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/.cache/typescript/5.4/node_modules/undici-types/package.json +55 -0
- package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +71 -0
- package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +28 -0
- package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +30 -0
- package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +61 -0
- package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +220 -0
- package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +131 -0
- package/.cache/typescript/5.4/package-lock.json +149 -0
- package/.cache/typescript/5.4/package.json +1 -0
- package/index.js +291 -71
- package/leiamnash/addExternalModule.js +15 -0
- package/leiamnash/addUserToGroup.js +77 -0
- package/leiamnash/changeAdminStatus.js +47 -0
- package/leiamnash/changeArchivedStatus.js +41 -0
- package/{src → leiamnash}/changeAvatar.js +3 -2
- package/leiamnash/changeBio.js +64 -0
- package/leiamnash/changeBlockedStatus.js +36 -0
- package/leiamnash/changeGroupImage.js +105 -0
- package/leiamnash/changeNickname.js +43 -0
- package/leiamnash/changeThreadColor.js +61 -0
- package/leiamnash/changeThreadEmoji.js +41 -0
- package/{src → leiamnash}/chat.js +4 -29
- package/leiamnash/createNewGroup.js +70 -0
- package/leiamnash/createPoll.js +59 -0
- package/leiamnash/deleteMessage.js +44 -0
- package/leiamnash/deleteThread.js +42 -0
- package/leiamnash/editMessage.js +62 -0
- package/leiamnash/forwardAttachment.js +47 -0
- package/leiamnash/forwardMessage.js +0 -0
- package/leiamnash/getCurrentUserID.js +7 -0
- package/leiamnash/getEmojiUrl.js +27 -0
- package/leiamnash/getFriendsList.js +73 -0
- package/leiamnash/getInfoVideo.js +134 -0
- package/leiamnash/getThreadHistory.js +537 -0
- package/leiamnash/getThreadHistoryDeprecated.js +71 -0
- package/leiamnash/getThreadInfo.js +171 -0
- package/leiamnash/getThreadInfoDeprecated.js +56 -0
- package/leiamnash/getThreadList.js +213 -0
- package/leiamnash/getThreadListDeprecated.js +46 -0
- package/leiamnash/getThreadPictures.js +59 -0
- package/leiamnash/getUserID.js +61 -0
- package/leiamnash/getUserInfo.js +66 -0
- package/leiamnash/handleFriendRequest.js +46 -0
- package/leiamnash/handleMessageRequest.js +47 -0
- package/leiamnash/httpGet.js +47 -0
- package/leiamnash/httpPost.js +47 -0
- package/leiamnash/httpPostFormData.js +42 -0
- package/leiamnash/listenMqtt.js +843 -0
- package/leiamnash/logout.js +68 -0
- package/leiamnash/markAsDelivered.js +47 -0
- package/leiamnash/markAsRead.js +70 -0
- package/leiamnash/markAsReadAll.js +40 -0
- package/leiamnash/markAsSeen.js +48 -0
- package/leiamnash/muteThread.js +45 -0
- package/leiamnash/pinMessage.js +58 -0
- package/leiamnash/react.js +109 -0
- package/{src → leiamnash}/refreshFb_dtsg.js +1 -1
- package/leiamnash/removeUserFromGroup.js +45 -0
- package/leiamnash/resolvePhotoUrl.js +36 -0
- package/leiamnash/searchForThread.js +42 -0
- package/leiamnash/seen.js +40 -0
- package/leiamnash/sendMessage.js +315 -0
- package/leiamnash/sendTypingIndicator.js +70 -0
- package/leiamnash/setMessageReaction.js +103 -0
- package/leiamnash/setPostReaction.js +63 -0
- package/leiamnash/setTitle.js +70 -0
- package/leiamnash/threadColors.js +41 -0
- package/leiamnash/token.js +112 -0
- package/leiamnash/unfriend.js +42 -0
- package/leiamnash/unsendMessage.js +39 -0
- package/{src → leiamnash}/uploadAttachment.js +2 -1
- package/package.json +3 -2
- package/utils.js +1345 -1382
- package/.cache/replit/modules/nodejs-20:v32-20240401-269b323.res +0 -1
- package/.cache/replit/modules/replit:v8-20240329-787bc7d.res +0 -1
- package/.replit +0 -1
- package/src/addExternalModule.js +0 -19
- package/src/addUserToGroup.js +0 -113
- package/src/changeAdminStatus.js +0 -79
- package/src/changeArchivedStatus.js +0 -55
- package/src/changeBio.js +0 -77
- package/src/changeBlockedStatus.js +0 -47
- package/src/changeGroupImage.js +0 -132
- package/src/changeNickname.js +0 -59
- package/src/changeThreadColor.js +0 -65
- package/src/changeThreadEmoji.js +0 -55
- package/src/createNewGroup.js +0 -86
- package/src/createPoll.js +0 -71
- package/src/deleteMessage.js +0 -56
- package/src/deleteThread.js +0 -56
- package/src/edit.js +0 -66
- package/src/forwardAttachment.js +0 -60
- package/src/getCurrentUserID.js +0 -7
- package/src/getEmojiUrl.js +0 -29
- package/src/getFriendsList.js +0 -83
- package/src/getThreadHistory.js +0 -666
- package/src/getThreadInfo.js +0 -232
- package/src/getThreadList.js +0 -241
- package/src/getThreadPictures.js +0 -79
- package/src/getUserID.js +0 -66
- package/src/getUserInfo.js +0 -74
- package/src/handleFriendRequest.js +0 -61
- package/src/handleMessageRequest.js +0 -65
- package/src/httpGet.js +0 -57
- package/src/httpPost.js +0 -57
- package/src/httpPostFormData.js +0 -63
- package/src/listenMqtt.js +0 -854
- package/src/logout.js +0 -75
- package/src/markAsDelivered.js +0 -58
- package/src/markAsRead.js +0 -80
- package/src/markAsReadAll.js +0 -50
- package/src/markAsSeen.js +0 -59
- package/src/muteThread.js +0 -52
- package/src/react.js +0 -121
- package/src/removeUserFromGroup.js +0 -79
- package/src/resolvePhotoUrl.js +0 -45
- package/src/searchForThread.js +0 -53
- package/src/seen.js +0 -50
- package/src/sendMessage.js +0 -477
- package/src/sendTypingIndicator.js +0 -103
- package/src/setMessageReaction.js +0 -121
- package/src/setPostReaction.js +0 -109
- package/src/setTitle.js +0 -86
- package/src/threadColors.js +0 -131
- package/src/unfriend.js +0 -52
- package/src/unsendMessage.js +0 -49
- /package/{src → leiamnash}/getMessage.js +0 -0
@@ -0,0 +1,808 @@
|
|
1
|
+
/**
|
2
|
+
* The `node: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('node:v8');
|
6
|
+
* ```
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/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
|
+
total_global_handles_size: number;
|
33
|
+
used_global_handles_size: number;
|
34
|
+
external_memory: number;
|
35
|
+
}
|
36
|
+
interface HeapCodeStatistics {
|
37
|
+
code_and_metadata_size: number;
|
38
|
+
bytecode_and_metadata_size: number;
|
39
|
+
external_script_source_size: number;
|
40
|
+
}
|
41
|
+
interface HeapSnapshotOptions {
|
42
|
+
/**
|
43
|
+
* If true, expose internals in the heap snapshot.
|
44
|
+
* @default false
|
45
|
+
*/
|
46
|
+
exposeInternals?: boolean;
|
47
|
+
/**
|
48
|
+
* If true, expose numeric values in artificial fields.
|
49
|
+
* @default false
|
50
|
+
*/
|
51
|
+
exposeNumericValues?: boolean;
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Returns an integer representing a version tag derived from the V8 version,
|
55
|
+
* command-line flags, and detected CPU features. This is useful for determining
|
56
|
+
* whether a `vm.Script` `cachedData` buffer is compatible with this instance
|
57
|
+
* of V8.
|
58
|
+
*
|
59
|
+
* ```js
|
60
|
+
* console.log(v8.cachedDataVersionTag()); // 3947234607
|
61
|
+
* // The value returned by v8.cachedDataVersionTag() is derived from the V8
|
62
|
+
* // version, command-line flags, and detected CPU features. Test that the value
|
63
|
+
* // does indeed update when flags are toggled.
|
64
|
+
* v8.setFlagsFromString('--allow_natives_syntax');
|
65
|
+
* console.log(v8.cachedDataVersionTag()); // 183726201
|
66
|
+
* ```
|
67
|
+
* @since v8.0.0
|
68
|
+
*/
|
69
|
+
function cachedDataVersionTag(): number;
|
70
|
+
/**
|
71
|
+
* Returns an object with the following properties:
|
72
|
+
*
|
73
|
+
* `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
|
74
|
+
* garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
|
75
|
+
* because it continuously touches all heap pages and that makes them less likely
|
76
|
+
* to get swapped out by the operating system.
|
77
|
+
*
|
78
|
+
* `number_of_native_contexts` The value of native\_context is the number of the
|
79
|
+
* top-level contexts currently active. Increase of this number over time indicates
|
80
|
+
* a memory leak.
|
81
|
+
*
|
82
|
+
* `number_of_detached_contexts` The value of detached\_context is the number
|
83
|
+
* of contexts that were detached and not yet garbage collected. This number
|
84
|
+
* being non-zero indicates a potential memory leak.
|
85
|
+
*
|
86
|
+
* `total_global_handles_size` The value of total\_global\_handles\_size is the
|
87
|
+
* total memory size of V8 global handles.
|
88
|
+
*
|
89
|
+
* `used_global_handles_size` The value of used\_global\_handles\_size is the
|
90
|
+
* used memory size of V8 global handles.
|
91
|
+
*
|
92
|
+
* `external_memory` The value of external\_memory is the memory size of array
|
93
|
+
* buffers and external strings.
|
94
|
+
*
|
95
|
+
* ```js
|
96
|
+
* {
|
97
|
+
* total_heap_size: 7326976,
|
98
|
+
* total_heap_size_executable: 4194304,
|
99
|
+
* total_physical_size: 7326976,
|
100
|
+
* total_available_size: 1152656,
|
101
|
+
* used_heap_size: 3476208,
|
102
|
+
* heap_size_limit: 1535115264,
|
103
|
+
* malloced_memory: 16384,
|
104
|
+
* peak_malloced_memory: 1127496,
|
105
|
+
* does_zap_garbage: 0,
|
106
|
+
* number_of_native_contexts: 1,
|
107
|
+
* number_of_detached_contexts: 0,
|
108
|
+
* total_global_handles_size: 8192,
|
109
|
+
* used_global_handles_size: 3296,
|
110
|
+
* external_memory: 318824
|
111
|
+
* }
|
112
|
+
* ```
|
113
|
+
* @since v1.0.0
|
114
|
+
*/
|
115
|
+
function getHeapStatistics(): HeapInfo;
|
116
|
+
/**
|
117
|
+
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
118
|
+
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
119
|
+
* heap space can be guaranteed as the statistics are provided via the
|
120
|
+
* 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
|
121
|
+
* next.
|
122
|
+
*
|
123
|
+
* The value returned is an array of objects containing the following properties:
|
124
|
+
*
|
125
|
+
* ```json
|
126
|
+
* [
|
127
|
+
* {
|
128
|
+
* "space_name": "new_space",
|
129
|
+
* "space_size": 2063872,
|
130
|
+
* "space_used_size": 951112,
|
131
|
+
* "space_available_size": 80824,
|
132
|
+
* "physical_space_size": 2063872
|
133
|
+
* },
|
134
|
+
* {
|
135
|
+
* "space_name": "old_space",
|
136
|
+
* "space_size": 3090560,
|
137
|
+
* "space_used_size": 2493792,
|
138
|
+
* "space_available_size": 0,
|
139
|
+
* "physical_space_size": 3090560
|
140
|
+
* },
|
141
|
+
* {
|
142
|
+
* "space_name": "code_space",
|
143
|
+
* "space_size": 1260160,
|
144
|
+
* "space_used_size": 644256,
|
145
|
+
* "space_available_size": 960,
|
146
|
+
* "physical_space_size": 1260160
|
147
|
+
* },
|
148
|
+
* {
|
149
|
+
* "space_name": "map_space",
|
150
|
+
* "space_size": 1094160,
|
151
|
+
* "space_used_size": 201608,
|
152
|
+
* "space_available_size": 0,
|
153
|
+
* "physical_space_size": 1094160
|
154
|
+
* },
|
155
|
+
* {
|
156
|
+
* "space_name": "large_object_space",
|
157
|
+
* "space_size": 0,
|
158
|
+
* "space_used_size": 0,
|
159
|
+
* "space_available_size": 1490980608,
|
160
|
+
* "physical_space_size": 0
|
161
|
+
* }
|
162
|
+
* ]
|
163
|
+
* ```
|
164
|
+
* @since v6.0.0
|
165
|
+
*/
|
166
|
+
function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
167
|
+
/**
|
168
|
+
* The `v8.setFlagsFromString()` method can be used to programmatically set
|
169
|
+
* V8 command-line flags. This method should be used with care. Changing settings
|
170
|
+
* after the VM has started may result in unpredictable behavior, including
|
171
|
+
* crashes and data loss; or it may simply do nothing.
|
172
|
+
*
|
173
|
+
* The V8 options available for a version of Node.js may be determined by running `node --v8-options`.
|
174
|
+
*
|
175
|
+
* Usage:
|
176
|
+
*
|
177
|
+
* ```js
|
178
|
+
* // Print GC events to stdout for one minute.
|
179
|
+
* const v8 = require('node:v8');
|
180
|
+
* v8.setFlagsFromString('--trace_gc');
|
181
|
+
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
182
|
+
* ```
|
183
|
+
* @since v1.0.0
|
184
|
+
*/
|
185
|
+
function setFlagsFromString(flags: string): void;
|
186
|
+
/**
|
187
|
+
* This is similar to the [`queryObjects()` console API](https://developer.chrome.com/docs/devtools/console/utilities#queryObjects-function)
|
188
|
+
* provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain
|
189
|
+
* in the heap after a full garbage collection, which can be useful for memory leak regression tests. To avoid surprising results, users should
|
190
|
+
* avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the
|
191
|
+
* application.
|
192
|
+
*
|
193
|
+
* To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects
|
194
|
+
* found. If `options.format` is `'summary'`, it returns an array containing brief string representations for each object. The visibility provided
|
195
|
+
* in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filter the
|
196
|
+
* target objects during the search.
|
197
|
+
*
|
198
|
+
* Only objects created in the current execution context are included in the results.
|
199
|
+
*
|
200
|
+
* ```js
|
201
|
+
* import { queryObjects } from 'node:v8';
|
202
|
+
* class A { foo = 'bar'; }
|
203
|
+
* console.log(queryObjects(A)); // 0
|
204
|
+
* const a = new A();
|
205
|
+
* console.log(queryObjects(A)); // 1
|
206
|
+
* // [ "A { foo: 'bar' }" ]
|
207
|
+
* console.log(queryObjects(A, { format: 'summary' }));
|
208
|
+
*
|
209
|
+
* class B extends A { bar = 'qux'; }
|
210
|
+
* const b = new B();
|
211
|
+
* console.log(queryObjects(B)); // 1
|
212
|
+
* // [ "B { foo: 'bar', bar: 'qux' }" ]
|
213
|
+
* console.log(queryObjects(B, { format: 'summary' }));
|
214
|
+
*
|
215
|
+
* // Note that, when there are child classes inheriting from a constructor,
|
216
|
+
* // the constructor also shows up in the prototype chain of the child
|
217
|
+
* // classes's prototoype, so the child classes's prototoype would also be
|
218
|
+
* // included in the result.
|
219
|
+
* console.log(queryObjects(A)); // 3
|
220
|
+
* // [ "B { foo: 'bar', bar: 'qux' }", 'A {}', "A { foo: 'bar' }" ]
|
221
|
+
* console.log(queryObjects(A, { format: 'summary' }));
|
222
|
+
* ```
|
223
|
+
* @param ctor The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.
|
224
|
+
* @since v20.13.0
|
225
|
+
* @experimental
|
226
|
+
*/
|
227
|
+
function queryObjects(ctor: Function): number | string[];
|
228
|
+
function queryObjects(ctor: Function, options: { format: "count" }): number;
|
229
|
+
function queryObjects(ctor: Function, options: { format: "summary" }): string[];
|
230
|
+
/**
|
231
|
+
* Generates a snapshot of the current V8 heap and returns a Readable
|
232
|
+
* Stream that may be used to read the JSON serialized representation.
|
233
|
+
* This JSON stream format is intended to be used with tools such as
|
234
|
+
* Chrome DevTools. The JSON schema is undocumented and specific to the
|
235
|
+
* V8 engine. Therefore, the schema may change from one version of V8 to the next.
|
236
|
+
*
|
237
|
+
* Creating a heap snapshot requires memory about twice the size of the heap at
|
238
|
+
* the time the snapshot is created. This results in the risk of OOM killers
|
239
|
+
* terminating the process.
|
240
|
+
*
|
241
|
+
* Generating a snapshot is a synchronous operation which blocks the event loop
|
242
|
+
* for a duration depending on the heap size.
|
243
|
+
*
|
244
|
+
* ```js
|
245
|
+
* // Print heap snapshot to the console
|
246
|
+
* const v8 = require('node:v8');
|
247
|
+
* const stream = v8.getHeapSnapshot();
|
248
|
+
* stream.pipe(process.stdout);
|
249
|
+
* ```
|
250
|
+
* @since v11.13.0
|
251
|
+
* @return A Readable containing the V8 heap snapshot.
|
252
|
+
*/
|
253
|
+
function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
|
254
|
+
/**
|
255
|
+
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
256
|
+
* file. This file is intended to be used with tools such as Chrome
|
257
|
+
* DevTools. The JSON schema is undocumented and specific to the V8
|
258
|
+
* engine, and may change from one version of V8 to the next.
|
259
|
+
*
|
260
|
+
* A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
|
261
|
+
* not contain any information about the workers, and vice versa.
|
262
|
+
*
|
263
|
+
* Creating a heap snapshot requires memory about twice the size of the heap at
|
264
|
+
* the time the snapshot is created. This results in the risk of OOM killers
|
265
|
+
* terminating the process.
|
266
|
+
*
|
267
|
+
* Generating a snapshot is a synchronous operation which blocks the event loop
|
268
|
+
* for a duration depending on the heap size.
|
269
|
+
*
|
270
|
+
* ```js
|
271
|
+
* const { writeHeapSnapshot } = require('node:v8');
|
272
|
+
* const {
|
273
|
+
* Worker,
|
274
|
+
* isMainThread,
|
275
|
+
* parentPort,
|
276
|
+
* } = require('node:worker_threads');
|
277
|
+
*
|
278
|
+
* if (isMainThread) {
|
279
|
+
* const worker = new Worker(__filename);
|
280
|
+
*
|
281
|
+
* worker.once('message', (filename) => {
|
282
|
+
* console.log(`worker heapdump: ${filename}`);
|
283
|
+
* // Now get a heapdump for the main thread.
|
284
|
+
* console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
|
285
|
+
* });
|
286
|
+
*
|
287
|
+
* // Tell the worker to create a heapdump.
|
288
|
+
* worker.postMessage('heapdump');
|
289
|
+
* } else {
|
290
|
+
* parentPort.once('message', (message) => {
|
291
|
+
* if (message === 'heapdump') {
|
292
|
+
* // Generate a heapdump for the worker
|
293
|
+
* // and return the filename to the parent.
|
294
|
+
* parentPort.postMessage(writeHeapSnapshot());
|
295
|
+
* }
|
296
|
+
* });
|
297
|
+
* }
|
298
|
+
* ```
|
299
|
+
* @since v11.13.0
|
300
|
+
* @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
|
301
|
+
* 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
|
302
|
+
* worker thread.
|
303
|
+
* @return The filename where the snapshot was saved.
|
304
|
+
*/
|
305
|
+
function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
|
306
|
+
/**
|
307
|
+
* Get statistics about code and its metadata in the heap, see
|
308
|
+
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
309
|
+
* following properties:
|
310
|
+
*
|
311
|
+
* ```js
|
312
|
+
* {
|
313
|
+
* code_and_metadata_size: 212208,
|
314
|
+
* bytecode_and_metadata_size: 161368,
|
315
|
+
* external_script_source_size: 1410794,
|
316
|
+
* cpu_profiler_metadata_size: 0,
|
317
|
+
* }
|
318
|
+
* ```
|
319
|
+
* @since v12.8.0
|
320
|
+
*/
|
321
|
+
function getHeapCodeStatistics(): HeapCodeStatistics;
|
322
|
+
/**
|
323
|
+
* @since v8.0.0
|
324
|
+
*/
|
325
|
+
class Serializer {
|
326
|
+
/**
|
327
|
+
* Writes out a header, which includes the serialization format version.
|
328
|
+
*/
|
329
|
+
writeHeader(): void;
|
330
|
+
/**
|
331
|
+
* Serializes a JavaScript value and adds the serialized representation to the
|
332
|
+
* internal buffer.
|
333
|
+
*
|
334
|
+
* This throws an error if `value` cannot be serialized.
|
335
|
+
*/
|
336
|
+
writeValue(val: any): boolean;
|
337
|
+
/**
|
338
|
+
* Returns the stored internal buffer. This serializer should not be used once
|
339
|
+
* the buffer is released. Calling this method results in undefined behavior
|
340
|
+
* if a previous write has failed.
|
341
|
+
*/
|
342
|
+
releaseBuffer(): Buffer;
|
343
|
+
/**
|
344
|
+
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
345
|
+
* Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
|
346
|
+
* @param id A 32-bit unsigned integer.
|
347
|
+
* @param arrayBuffer An `ArrayBuffer` instance.
|
348
|
+
*/
|
349
|
+
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
350
|
+
/**
|
351
|
+
* Write a raw 32-bit unsigned integer.
|
352
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
353
|
+
*/
|
354
|
+
writeUint32(value: number): void;
|
355
|
+
/**
|
356
|
+
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
|
357
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
358
|
+
*/
|
359
|
+
writeUint64(hi: number, lo: number): void;
|
360
|
+
/**
|
361
|
+
* Write a JS `number` value.
|
362
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
363
|
+
*/
|
364
|
+
writeDouble(value: number): void;
|
365
|
+
/**
|
366
|
+
* Write raw bytes into the serializer's internal buffer. The deserializer
|
367
|
+
* will require a way to compute the length of the buffer.
|
368
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
369
|
+
*/
|
370
|
+
writeRawBytes(buffer: NodeJS.TypedArray): void;
|
371
|
+
}
|
372
|
+
/**
|
373
|
+
* A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
|
374
|
+
* stores the part of their underlying `ArrayBuffer`s that they are referring to.
|
375
|
+
* @since v8.0.0
|
376
|
+
*/
|
377
|
+
class DefaultSerializer extends Serializer {}
|
378
|
+
/**
|
379
|
+
* @since v8.0.0
|
380
|
+
*/
|
381
|
+
class Deserializer {
|
382
|
+
constructor(data: NodeJS.TypedArray);
|
383
|
+
/**
|
384
|
+
* Reads and validates a header (including the format version).
|
385
|
+
* May, for example, reject an invalid or unsupported wire format. In that case,
|
386
|
+
* an `Error` is thrown.
|
387
|
+
*/
|
388
|
+
readHeader(): boolean;
|
389
|
+
/**
|
390
|
+
* Deserializes a JavaScript value from the buffer and returns it.
|
391
|
+
*/
|
392
|
+
readValue(): any;
|
393
|
+
/**
|
394
|
+
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
395
|
+
* Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
|
396
|
+
* `SharedArrayBuffer`s).
|
397
|
+
* @param id A 32-bit unsigned integer.
|
398
|
+
* @param arrayBuffer An `ArrayBuffer` instance.
|
399
|
+
*/
|
400
|
+
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
401
|
+
/**
|
402
|
+
* Reads the underlying wire format version. Likely mostly to be useful to
|
403
|
+
* legacy code reading old wire format versions. May not be called before `.readHeader()`.
|
404
|
+
*/
|
405
|
+
getWireFormatVersion(): number;
|
406
|
+
/**
|
407
|
+
* Read a raw 32-bit unsigned integer and return it.
|
408
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
409
|
+
*/
|
410
|
+
readUint32(): number;
|
411
|
+
/**
|
412
|
+
* Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]` with two 32-bit unsigned integer entries.
|
413
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
414
|
+
*/
|
415
|
+
readUint64(): [number, number];
|
416
|
+
/**
|
417
|
+
* Read a JS `number` value.
|
418
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
419
|
+
*/
|
420
|
+
readDouble(): number;
|
421
|
+
/**
|
422
|
+
* Read raw bytes from the deserializer's internal buffer. The `length` parameter
|
423
|
+
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
424
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
425
|
+
*/
|
426
|
+
readRawBytes(length: number): Buffer;
|
427
|
+
}
|
428
|
+
/**
|
429
|
+
* A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
|
430
|
+
* @since v8.0.0
|
431
|
+
*/
|
432
|
+
class DefaultDeserializer extends Deserializer {}
|
433
|
+
/**
|
434
|
+
* Uses a `DefaultSerializer` to serialize `value` into a buffer.
|
435
|
+
*
|
436
|
+
* `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
|
437
|
+
* serialize a huge object which requires buffer
|
438
|
+
* larger than `buffer.constants.MAX_LENGTH`.
|
439
|
+
* @since v8.0.0
|
440
|
+
*/
|
441
|
+
function serialize(value: any): Buffer;
|
442
|
+
/**
|
443
|
+
* Uses a `DefaultDeserializer` with default options to read a JS value
|
444
|
+
* from a buffer.
|
445
|
+
* @since v8.0.0
|
446
|
+
* @param buffer A buffer returned by {@link serialize}.
|
447
|
+
*/
|
448
|
+
function deserialize(buffer: NodeJS.TypedArray): any;
|
449
|
+
/**
|
450
|
+
* 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
|
451
|
+
* times during the lifetime of the process. Each time the execution counter will
|
452
|
+
* be reset and a new coverage report will be written to the directory specified
|
453
|
+
* by `NODE_V8_COVERAGE`.
|
454
|
+
*
|
455
|
+
* When the process is about to exit, one last coverage will still be written to
|
456
|
+
* disk unless {@link stopCoverage} is invoked before the process exits.
|
457
|
+
* @since v15.1.0, v14.18.0, v12.22.0
|
458
|
+
*/
|
459
|
+
function takeCoverage(): void;
|
460
|
+
/**
|
461
|
+
* The `v8.stopCoverage()` method allows the user to stop the coverage collection
|
462
|
+
* started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
|
463
|
+
* records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
|
464
|
+
* @since v15.1.0, v14.18.0, v12.22.0
|
465
|
+
*/
|
466
|
+
function stopCoverage(): void;
|
467
|
+
/**
|
468
|
+
* The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
|
469
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
470
|
+
* @experimental
|
471
|
+
* @since v18.10.0, v16.18.0
|
472
|
+
*/
|
473
|
+
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
474
|
+
/**
|
475
|
+
* This API collects GC data in current thread.
|
476
|
+
* @since v19.6.0, v18.15.0
|
477
|
+
*/
|
478
|
+
class GCProfiler {
|
479
|
+
/**
|
480
|
+
* Start collecting GC data.
|
481
|
+
* @since v19.6.0, v18.15.0
|
482
|
+
*/
|
483
|
+
start(): void;
|
484
|
+
/**
|
485
|
+
* Stop collecting GC data and return an object. The content of object
|
486
|
+
* is as follows.
|
487
|
+
*
|
488
|
+
* ```json
|
489
|
+
* {
|
490
|
+
* "version": 1,
|
491
|
+
* "startTime": 1674059033862,
|
492
|
+
* "statistics": [
|
493
|
+
* {
|
494
|
+
* "gcType": "Scavenge",
|
495
|
+
* "beforeGC": {
|
496
|
+
* "heapStatistics": {
|
497
|
+
* "totalHeapSize": 5005312,
|
498
|
+
* "totalHeapSizeExecutable": 524288,
|
499
|
+
* "totalPhysicalSize": 5226496,
|
500
|
+
* "totalAvailableSize": 4341325216,
|
501
|
+
* "totalGlobalHandlesSize": 8192,
|
502
|
+
* "usedGlobalHandlesSize": 2112,
|
503
|
+
* "usedHeapSize": 4883840,
|
504
|
+
* "heapSizeLimit": 4345298944,
|
505
|
+
* "mallocedMemory": 254128,
|
506
|
+
* "externalMemory": 225138,
|
507
|
+
* "peakMallocedMemory": 181760
|
508
|
+
* },
|
509
|
+
* "heapSpaceStatistics": [
|
510
|
+
* {
|
511
|
+
* "spaceName": "read_only_space",
|
512
|
+
* "spaceSize": 0,
|
513
|
+
* "spaceUsedSize": 0,
|
514
|
+
* "spaceAvailableSize": 0,
|
515
|
+
* "physicalSpaceSize": 0
|
516
|
+
* }
|
517
|
+
* ]
|
518
|
+
* },
|
519
|
+
* "cost": 1574.14,
|
520
|
+
* "afterGC": {
|
521
|
+
* "heapStatistics": {
|
522
|
+
* "totalHeapSize": 6053888,
|
523
|
+
* "totalHeapSizeExecutable": 524288,
|
524
|
+
* "totalPhysicalSize": 5500928,
|
525
|
+
* "totalAvailableSize": 4341101384,
|
526
|
+
* "totalGlobalHandlesSize": 8192,
|
527
|
+
* "usedGlobalHandlesSize": 2112,
|
528
|
+
* "usedHeapSize": 4059096,
|
529
|
+
* "heapSizeLimit": 4345298944,
|
530
|
+
* "mallocedMemory": 254128,
|
531
|
+
* "externalMemory": 225138,
|
532
|
+
* "peakMallocedMemory": 181760
|
533
|
+
* },
|
534
|
+
* "heapSpaceStatistics": [
|
535
|
+
* {
|
536
|
+
* "spaceName": "read_only_space",
|
537
|
+
* "spaceSize": 0,
|
538
|
+
* "spaceUsedSize": 0,
|
539
|
+
* "spaceAvailableSize": 0,
|
540
|
+
* "physicalSpaceSize": 0
|
541
|
+
* }
|
542
|
+
* ]
|
543
|
+
* }
|
544
|
+
* }
|
545
|
+
* ],
|
546
|
+
* "endTime": 1674059036865
|
547
|
+
* }
|
548
|
+
* ```
|
549
|
+
*
|
550
|
+
* Here's an example.
|
551
|
+
*
|
552
|
+
* ```js
|
553
|
+
* const { GCProfiler } = require('v8');
|
554
|
+
* const profiler = new GCProfiler();
|
555
|
+
* profiler.start();
|
556
|
+
* setTimeout(() => {
|
557
|
+
* console.log(profiler.stop());
|
558
|
+
* }, 1000);
|
559
|
+
* ```
|
560
|
+
* @since v19.6.0, v18.15.0
|
561
|
+
*/
|
562
|
+
stop(): GCProfilerResult;
|
563
|
+
}
|
564
|
+
interface GCProfilerResult {
|
565
|
+
version: number;
|
566
|
+
startTime: number;
|
567
|
+
endTime: number;
|
568
|
+
statistics: Array<{
|
569
|
+
gcType: string;
|
570
|
+
cost: number;
|
571
|
+
beforeGC: {
|
572
|
+
heapStatistics: HeapStatistics;
|
573
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
574
|
+
};
|
575
|
+
afterGC: {
|
576
|
+
heapStatistics: HeapStatistics;
|
577
|
+
heapSpaceStatistics: HeapSpaceStatistics[];
|
578
|
+
};
|
579
|
+
}>;
|
580
|
+
}
|
581
|
+
interface HeapStatistics {
|
582
|
+
totalHeapSize: number;
|
583
|
+
totalHeapSizeExecutable: number;
|
584
|
+
totalPhysicalSize: number;
|
585
|
+
totalAvailableSize: number;
|
586
|
+
totalGlobalHandlesSize: number;
|
587
|
+
usedGlobalHandlesSize: number;
|
588
|
+
usedHeapSize: number;
|
589
|
+
heapSizeLimit: number;
|
590
|
+
mallocedMemory: number;
|
591
|
+
externalMemory: number;
|
592
|
+
peakMallocedMemory: number;
|
593
|
+
}
|
594
|
+
interface HeapSpaceStatistics {
|
595
|
+
spaceName: string;
|
596
|
+
spaceSize: number;
|
597
|
+
spaceUsedSize: number;
|
598
|
+
spaceAvailableSize: number;
|
599
|
+
physicalSpaceSize: number;
|
600
|
+
}
|
601
|
+
/**
|
602
|
+
* Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
|
603
|
+
* happen if a promise is created without ever getting a continuation.
|
604
|
+
* @since v17.1.0, v16.14.0
|
605
|
+
* @param promise The promise being created.
|
606
|
+
* @param parent The promise continued from, if applicable.
|
607
|
+
*/
|
608
|
+
interface Init {
|
609
|
+
(promise: Promise<unknown>, parent: Promise<unknown>): void;
|
610
|
+
}
|
611
|
+
/**
|
612
|
+
* Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
|
613
|
+
*
|
614
|
+
* 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.
|
615
|
+
* The before callback may be called many times in the case where many continuations have been made from the same promise.
|
616
|
+
* @since v17.1.0, v16.14.0
|
617
|
+
*/
|
618
|
+
interface Before {
|
619
|
+
(promise: Promise<unknown>): void;
|
620
|
+
}
|
621
|
+
/**
|
622
|
+
* Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
|
623
|
+
* @since v17.1.0, v16.14.0
|
624
|
+
*/
|
625
|
+
interface After {
|
626
|
+
(promise: Promise<unknown>): void;
|
627
|
+
}
|
628
|
+
/**
|
629
|
+
* Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
|
630
|
+
* {@link Promise.reject()}.
|
631
|
+
* @since v17.1.0, v16.14.0
|
632
|
+
*/
|
633
|
+
interface Settled {
|
634
|
+
(promise: Promise<unknown>): void;
|
635
|
+
}
|
636
|
+
/**
|
637
|
+
* 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
|
638
|
+
* around an await, and when the promise resolves or rejects.
|
639
|
+
*
|
640
|
+
* Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
|
641
|
+
* `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
|
642
|
+
* @since v17.1.0, v16.14.0
|
643
|
+
*/
|
644
|
+
interface HookCallbacks {
|
645
|
+
init?: Init;
|
646
|
+
before?: Before;
|
647
|
+
after?: After;
|
648
|
+
settled?: Settled;
|
649
|
+
}
|
650
|
+
interface PromiseHooks {
|
651
|
+
/**
|
652
|
+
* The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
653
|
+
* @since v17.1.0, v16.14.0
|
654
|
+
* @param init The {@link Init | `init` callback} to call when a promise is created.
|
655
|
+
* @return Call to stop the hook.
|
656
|
+
*/
|
657
|
+
onInit: (init: Init) => Function;
|
658
|
+
/**
|
659
|
+
* The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
660
|
+
* @since v17.1.0, v16.14.0
|
661
|
+
* @param settled The {@link Settled | `settled` callback} to call when a promise is created.
|
662
|
+
* @return Call to stop the hook.
|
663
|
+
*/
|
664
|
+
onSettled: (settled: Settled) => Function;
|
665
|
+
/**
|
666
|
+
* The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
667
|
+
* @since v17.1.0, v16.14.0
|
668
|
+
* @param before The {@link Before | `before` callback} to call before a promise continuation executes.
|
669
|
+
* @return Call to stop the hook.
|
670
|
+
*/
|
671
|
+
onBefore: (before: Before) => Function;
|
672
|
+
/**
|
673
|
+
* The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
674
|
+
* @since v17.1.0, v16.14.0
|
675
|
+
* @param after The {@link After | `after` callback} to call after a promise continuation executes.
|
676
|
+
* @return Call to stop the hook.
|
677
|
+
*/
|
678
|
+
onAfter: (after: After) => Function;
|
679
|
+
/**
|
680
|
+
* Registers functions to be called for different lifetime events of each promise.
|
681
|
+
* The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
|
682
|
+
* All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
|
683
|
+
* The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
|
684
|
+
* @since v17.1.0, v16.14.0
|
685
|
+
* @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
|
686
|
+
* @return Used for disabling hooks
|
687
|
+
*/
|
688
|
+
createHook: (callbacks: HookCallbacks) => Function;
|
689
|
+
}
|
690
|
+
/**
|
691
|
+
* The `promiseHooks` interface can be used to track promise lifecycle events.
|
692
|
+
* @since v17.1.0, v16.14.0
|
693
|
+
*/
|
694
|
+
const promiseHooks: PromiseHooks;
|
695
|
+
type StartupSnapshotCallbackFn = (args: any) => any;
|
696
|
+
interface StartupSnapshot {
|
697
|
+
/**
|
698
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
699
|
+
* This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
|
700
|
+
* @since v18.6.0, v16.17.0
|
701
|
+
*/
|
702
|
+
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
703
|
+
/**
|
704
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
705
|
+
* The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
|
706
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
707
|
+
* @since v18.6.0, v16.17.0
|
708
|
+
*/
|
709
|
+
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
710
|
+
/**
|
711
|
+
* This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
|
712
|
+
* If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
|
713
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
714
|
+
* @since v18.6.0, v16.17.0
|
715
|
+
*/
|
716
|
+
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
717
|
+
/**
|
718
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
719
|
+
* @since v18.6.0, v16.17.0
|
720
|
+
*/
|
721
|
+
isBuildingSnapshot(): boolean;
|
722
|
+
}
|
723
|
+
/**
|
724
|
+
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
725
|
+
*
|
726
|
+
* ```bash
|
727
|
+
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
728
|
+
* # This launches a process with the snapshot
|
729
|
+
* $ node --snapshot-blob snapshot.blob
|
730
|
+
* ```
|
731
|
+
*
|
732
|
+
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
733
|
+
* in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
734
|
+
* For example, if the `entry.js` contains the following script:
|
735
|
+
*
|
736
|
+
* ```js
|
737
|
+
* 'use strict';
|
738
|
+
*
|
739
|
+
* const fs = require('node:fs');
|
740
|
+
* const zlib = require('node:zlib');
|
741
|
+
* const path = require('node:path');
|
742
|
+
* const assert = require('node:assert');
|
743
|
+
*
|
744
|
+
* const v8 = require('node:v8');
|
745
|
+
*
|
746
|
+
* class BookShelf {
|
747
|
+
* storage = new Map();
|
748
|
+
*
|
749
|
+
* // Reading a series of files from directory and store them into storage.
|
750
|
+
* constructor(directory, books) {
|
751
|
+
* for (const book of books) {
|
752
|
+
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
753
|
+
* }
|
754
|
+
* }
|
755
|
+
*
|
756
|
+
* static compressAll(shelf) {
|
757
|
+
* for (const [ book, content ] of shelf.storage) {
|
758
|
+
* shelf.storage.set(book, zlib.gzipSync(content));
|
759
|
+
* }
|
760
|
+
* }
|
761
|
+
*
|
762
|
+
* static decompressAll(shelf) {
|
763
|
+
* for (const [ book, content ] of shelf.storage) {
|
764
|
+
* shelf.storage.set(book, zlib.gunzipSync(content));
|
765
|
+
* }
|
766
|
+
* }
|
767
|
+
* }
|
768
|
+
*
|
769
|
+
* // __dirname here is where the snapshot script is placed
|
770
|
+
* // during snapshot building time.
|
771
|
+
* const shelf = new BookShelf(__dirname, [
|
772
|
+
* 'book1.en_US.txt',
|
773
|
+
* 'book1.es_ES.txt',
|
774
|
+
* 'book2.zh_CN.txt',
|
775
|
+
* ]);
|
776
|
+
*
|
777
|
+
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
778
|
+
* // On snapshot serialization, compress the books to reduce size.
|
779
|
+
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
780
|
+
* // On snapshot deserialization, decompress the books.
|
781
|
+
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
782
|
+
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
783
|
+
* // process.env and process.argv are refreshed during snapshot
|
784
|
+
* // deserialization.
|
785
|
+
* const lang = process.env.BOOK_LANG || 'en_US';
|
786
|
+
* const book = process.argv[1];
|
787
|
+
* const name = `${book}.${lang}.txt`;
|
788
|
+
* console.log(shelf.storage.get(name));
|
789
|
+
* }, shelf);
|
790
|
+
* ```
|
791
|
+
*
|
792
|
+
* The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
|
793
|
+
*
|
794
|
+
* ```bash
|
795
|
+
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
796
|
+
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
797
|
+
* ```
|
798
|
+
*
|
799
|
+
* Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
|
800
|
+
*
|
801
|
+
* @experimental
|
802
|
+
* @since v18.6.0, v16.17.0
|
803
|
+
*/
|
804
|
+
const startupSnapshot: StartupSnapshot;
|
805
|
+
}
|
806
|
+
declare module "node:v8" {
|
807
|
+
export * from "v8";
|
808
|
+
}
|