Spaces:
Running
Running
Commit
·
57156b3
1
Parent(s):
e343169
radical simplification
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .editorconfig +0 -10
- .eslintignore +0 -1
- .eslintrc.cjs +0 -107
- .fossa.yml.template +0 -8
- .gitignore +0 -164
- .mercs.yaml +0 -309
- .npmignore +0 -162
- .prettierignore +0 -11
- .prettierrc +0 -9
- .vscode/launch.json +157 -0
- .yarn/install-state.gz +0 -0
- .yarn/plugins/@yarnpkg/plugin-engines.cjs +0 -9
- .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -0
- .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +0 -28
- .yarn/releases/yarn-3.3.1.cjs +0 -0
- .yarnrc.yml +0 -11
- CLA.md +0 -110
- CODE_OF_CONDUCT.md +0 -132
- COPYRIGHT.md +0 -2
- Dockerfile +6 -6
- LICENSE.md +0 -667
- NOTICE.md +0 -3
- ORIGIN.md +0 -1
- SOURCE.md +0 -2
- THIRD_PARTIES.md +0 -0
- assets/screenshot.jpg +0 -0
- assets/screenshot_collection.png +0 -0
- mini.js +0 -128
- myNodeServer.js +1 -1
- node_modules/.bin/mime +1 -0
- node_modules/.yarn-state.yml +373 -0
- node_modules/@types/http-proxy/LICENSE +21 -0
- node_modules/@types/http-proxy/README.md +15 -0
- node_modules/@types/http-proxy/index.d.ts +250 -0
- node_modules/@types/http-proxy/package.json +47 -0
- node_modules/@types/node/LICENSE +21 -0
- node_modules/@types/node/README.md +15 -0
- node_modules/@types/node/assert.d.ts +996 -0
- node_modules/@types/node/assert/strict.d.ts +8 -0
- node_modules/@types/node/async_hooks.d.ts +539 -0
- node_modules/@types/node/buffer.d.ts +0 -0
- node_modules/@types/node/child_process.d.ts +1540 -0
- node_modules/@types/node/cluster.d.ts +432 -0
- node_modules/@types/node/console.d.ts +415 -0
- node_modules/@types/node/constants.d.ts +19 -0
- node_modules/@types/node/crypto.d.ts +0 -0
- node_modules/@types/node/dgram.d.ts +586 -0
- node_modules/@types/node/diagnostics_channel.d.ts +191 -0
- node_modules/@types/node/dns.d.ts +809 -0
- node_modules/@types/node/dns/promises.d.ts +425 -0
.editorconfig
DELETED
@@ -1,10 +0,0 @@
|
|
1 |
-
root = true
|
2 |
-
|
3 |
-
[*]
|
4 |
-
end_of_line = lf
|
5 |
-
insert_final_newline = true
|
6 |
-
|
7 |
-
[*.{js,json,yml}]
|
8 |
-
charset = utf-8
|
9 |
-
indent_style = space
|
10 |
-
indent_size = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.eslintignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
.eslintrc.cjs
|
|
|
|
.eslintrc.cjs
DELETED
@@ -1,107 +0,0 @@
|
|
1 |
-
const path = require('path')
|
2 |
-
|
3 |
-
const project = [
|
4 |
-
path.join(__dirname, 'packages/omni-shared/tsconfig.json'),
|
5 |
-
path.join(__dirname, 'packages/omni-ui/omni-client-services/tsconfig.json'),
|
6 |
-
path.join(__dirname, 'packages/omni-sockets/tsconfig.json'),
|
7 |
-
path.join(__dirname, 'packages/omni-server/tsconfig.json'),
|
8 |
-
path.join(__dirname, 'packages/omni-server/tsconfig.eslint.json'),
|
9 |
-
path.join(__dirname, 'packages/omni-ui/omni-web/tsconfig.json'),
|
10 |
-
path.join(__dirname, 'packages/omni-sdk/tsconfig.json'),
|
11 |
-
]
|
12 |
-
|
13 |
-
module.exports = {
|
14 |
-
env: {
|
15 |
-
browser: true,
|
16 |
-
es2021: true
|
17 |
-
},
|
18 |
-
extends: ['standard-with-typescript', 'eslint-config-prettier'],
|
19 |
-
plugins: ['@typescript-eslint', 'prettier'],
|
20 |
-
overrides: [
|
21 |
-
{
|
22 |
-
env: {
|
23 |
-
node: true
|
24 |
-
},
|
25 |
-
files: ['.eslintrc.{js,cjs}'],
|
26 |
-
parserOptions: {
|
27 |
-
sourceType: 'script',
|
28 |
-
project
|
29 |
-
}
|
30 |
-
}
|
31 |
-
],
|
32 |
-
ignorePatterns: ['setup/**', 'vite.config.js', '*.cjs', '*.d.ts', '*/omni-server/extensions/**'],
|
33 |
-
parser: "@typescript-eslint/parser",
|
34 |
-
parserOptions: {
|
35 |
-
ecmaVersion: 'latest',
|
36 |
-
sourceType: 'module',
|
37 |
-
project
|
38 |
-
},
|
39 |
-
rules: {
|
40 |
-
'no-debugger': 'warn',
|
41 |
-
'prettier/prettier': 'off',
|
42 |
-
'no-prototype-builtins': 'off',
|
43 |
-
'eslint-disable-next-line': 'off',
|
44 |
-
"no-lone-blocks" : 'off',
|
45 |
-
'no-trailing-spaces': 'off',
|
46 |
-
'no-multi-spaces': 'off',
|
47 |
-
'padded-blocks': 'off',
|
48 |
-
'no-debugger': 'off',
|
49 |
-
'object-property-newline': 'off',
|
50 |
-
'object-curly-newline': 'off',
|
51 |
-
'arrow-spacing': 'off',
|
52 |
-
'no-multiple-empty-lines': 'off',
|
53 |
-
'eol-last': 'off',
|
54 |
-
'space-in-parens':'off',
|
55 |
-
'block-spacing':'off',
|
56 |
-
'spaced-comment': 'off',
|
57 |
-
'new-cap': 'off',
|
58 |
-
'@typescript-eslint/quotes': 'off',
|
59 |
-
'promise/param-names': 'off',
|
60 |
-
'@typescript-eslint/array-type': 'off', // candidate for code quality pass
|
61 |
-
'@typescript-eslint/space-before-blocks': 'off',
|
62 |
-
'@typescript-eslint/keyword-spacing': 'off',
|
63 |
-
'@typescript-eslint/member-delimiter-style': 'off',
|
64 |
-
'@typescript-eslint/brace-style': 'off',
|
65 |
-
'@typescript-eslint/lines-between-class-members': 'off',
|
66 |
-
'@typescript-eslint/comma-dangle': 'off',
|
67 |
-
'@typescript-eslint/comma-spacing': 'off',
|
68 |
-
'generator-star-spacing': 'off',
|
69 |
-
'no-unexpected-multiline': 'off',
|
70 |
-
'@typescript-eslint/space-infix-ops': 'off',
|
71 |
-
'@typescript-eslint/object-curly-spacing' : 'off',
|
72 |
-
'@typescript-eslint/key-spacing': 'off',
|
73 |
-
'@typescript-eslint/type-annotation-spacing': 'off',
|
74 |
-
'@typescript-eslint/naming-convention': 'off',
|
75 |
-
'@typescript-eslint/space-before-function-paren': 'off',
|
76 |
-
'@typescript-eslint/indent': ['off', 4],
|
77 |
-
'@typescript-eslint/strict-boolean-expressions': 'off',
|
78 |
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
79 |
-
'@typescript-eslint/ban-ts-comment': 'off',
|
80 |
-
'@typescript-eslint/semi': 'off',
|
81 |
-
'@typescript-eslint/no-unused-vars': 'warn',
|
82 |
-
'@typescript-eslint/no-unused-expressions': 'warn',
|
83 |
-
'@typescript-eslint/prefer-ts-expect-error': 'off',
|
84 |
-
'@typescript-eslint/restrict-template-expressions': 'off',
|
85 |
-
'@typescript-eslint/naming': 'off',
|
86 |
-
'@typescript-eslint/prefer-optional-chain': 'off',
|
87 |
-
'@typescript-eslint/no-floating-promises': 'warn',
|
88 |
-
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
89 |
-
'@typescript-eslint/ban-types': ['warn', {
|
90 |
-
'types': {
|
91 |
-
'Function': false
|
92 |
-
}
|
93 |
-
}],
|
94 |
-
'@typescript-eslint/restrict-plus-operands': 'warn',
|
95 |
-
'@typescript-eslint/no-dynamic-delete': 'warn',
|
96 |
-
'@typescript-eslint/no-misused-promises': 'warn',
|
97 |
-
'@typescript-eslint/no-useless-constructor': 'off',
|
98 |
-
'@typescript-eslint/await-thenable': 'warn',
|
99 |
-
'@typescript-eslint/restrict-plus-operands': 'off',
|
100 |
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
101 |
-
'@typescript-eslint/return-await': 'warn',
|
102 |
-
'@typescript-eslint/no-this-alias': 'off',
|
103 |
-
'@typescript-eslint/no-extraneous-class': 'warn',
|
104 |
-
'no-eval': 'warn',
|
105 |
-
'eqeqeq': 'warn'
|
106 |
-
}
|
107 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.fossa.yml.template
DELETED
@@ -1,8 +0,0 @@
|
|
1 |
-
version: 3
|
2 |
-
|
3 |
-
apiKey: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
4 |
-
|
5 |
-
paths:
|
6 |
-
exclude:
|
7 |
-
- ./packages/omni-server/extensions/
|
8 |
-
- ./packages/node_modules/omni-server/extensions/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
.DS_Store
|
2 |
-
.env.local
|
3 |
-
dist-ssr
|
4 |
-
*.local.*
|
5 |
-
.mercs.local.yaml
|
6 |
-
.vscode
|
7 |
-
*/etc/keystore/*
|
8 |
-
*/etc/registry/.cache/*
|
9 |
-
omni.zip
|
10 |
-
fossa*
|
11 |
-
.fossa.yml
|
12 |
-
assets/
|
13 |
-
packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1
|
14 |
-
packages/omni-server/scripts/huggingface.js
|
15 |
-
|
16 |
-
tsconfig.tsbuildinfo
|
17 |
-
/**/*/public/t
|
18 |
-
/**/*/public/sets
|
19 |
-
stats.html
|
20 |
-
|
21 |
-
# Created by .ignore support plugin (hsz.mobi)
|
22 |
-
### JetBrains template
|
23 |
-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
24 |
-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
25 |
-
|
26 |
-
# User-specific stuff:
|
27 |
-
.idea/workspace.xml
|
28 |
-
.idea/tasks.xml
|
29 |
-
*/cache/**
|
30 |
-
./var/**
|
31 |
-
content/
|
32 |
-
docker-certs/
|
33 |
-
log.txt
|
34 |
-
/.yarn/*
|
35 |
-
/**/*/.yarn/install-state.gz
|
36 |
-
!.yarn/patches
|
37 |
-
!.yarn/releases
|
38 |
-
!.yarn/plugins
|
39 |
-
!.yarn/sdks
|
40 |
-
!.yarn/versions
|
41 |
-
.pnp.*
|
42 |
-
/etc/ssl/
|
43 |
-
tmp/
|
44 |
-
Untitled*.md
|
45 |
-
user_files/*
|
46 |
-
!user_files/USER_FILES_GO_HERE
|
47 |
-
!user_files/oobabooga_models_directory.json
|
48 |
-
!user_files/local_llms_directories.json
|
49 |
-
packages/server/user_provided_models/*
|
50 |
-
!packages/server/USER_PROVIDED_MODELS_GO_HERE
|
51 |
-
packages/omni-server/user_provided_models/*
|
52 |
-
!packages/omni-server/USER_PROVIDED_MODELS_GO_HERE
|
53 |
-
|
54 |
-
# package bundles
|
55 |
-
build
|
56 |
-
setup/updates
|
57 |
-
|
58 |
-
# transient packaging
|
59 |
-
/build
|
60 |
-
|
61 |
-
# Sensitive or high-churn files:
|
62 |
-
.idea/dataSources/
|
63 |
-
.idea/dataSources.ids
|
64 |
-
.idea/dataSources.xml
|
65 |
-
.idea/dataSources.local.xml
|
66 |
-
.idea/sqlDataSources.xml
|
67 |
-
.idea/dynamic.xml
|
68 |
-
.idea/uiDesigner.xml
|
69 |
-
|
70 |
-
|
71 |
-
# Gradle:
|
72 |
-
.idea/gradle.xml
|
73 |
-
.idea/libraries
|
74 |
-
./tmp/
|
75 |
-
# Mongo Explorer plugin:
|
76 |
-
.idea/mongoSettings.xml
|
77 |
-
|
78 |
-
## File-based project format:
|
79 |
-
*.iws
|
80 |
-
|
81 |
-
## Plugin-specific files:
|
82 |
-
|
83 |
-
# IntelliJ
|
84 |
-
/out/
|
85 |
-
|
86 |
-
# mpeltonen/sbt-idea plugin
|
87 |
-
.idea_modules/
|
88 |
-
|
89 |
-
# JIRA plugin
|
90 |
-
atlassian-ide-plugin.xml
|
91 |
-
|
92 |
-
# Crashlytics plugin (for Android Studio and IntelliJ)
|
93 |
-
com_crashlytics_export_strings.xml
|
94 |
-
crashlytics.properties
|
95 |
-
crashlytics-build.properties
|
96 |
-
fabric.properties
|
97 |
-
### Node template
|
98 |
-
# Logs
|
99 |
-
logs
|
100 |
-
*.log
|
101 |
-
npm-debug.log*
|
102 |
-
|
103 |
-
# Runtime data
|
104 |
-
pids
|
105 |
-
*.pid
|
106 |
-
*.seed
|
107 |
-
*.pid.lock
|
108 |
-
|
109 |
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
110 |
-
lib-cov
|
111 |
-
|
112 |
-
# Coverage directory used by tools like istanbul
|
113 |
-
coverage
|
114 |
-
|
115 |
-
# nyc test coverage
|
116 |
-
.nyc_output
|
117 |
-
|
118 |
-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
119 |
-
.grunt
|
120 |
-
|
121 |
-
# node-waf configuration
|
122 |
-
.lock-wscript
|
123 |
-
|
124 |
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
125 |
-
build/Release
|
126 |
-
|
127 |
-
# Dependency directories
|
128 |
-
node_modules
|
129 |
-
jspm_packages
|
130 |
-
|
131 |
-
# Optional npm cache directory
|
132 |
-
.npm
|
133 |
-
|
134 |
-
# Optional eslint cache
|
135 |
-
.eslintcache
|
136 |
-
|
137 |
-
# Optional REPL history
|
138 |
-
.node_repl_history
|
139 |
-
|
140 |
-
# Output of 'npm pack'
|
141 |
-
*.tgz
|
142 |
-
|
143 |
-
# Yarn Integrity file
|
144 |
-
.yarn-integrity
|
145 |
-
|
146 |
-
.idea/
|
147 |
-
#.idea/watcherTasks.xml
|
148 |
-
.DS_Store
|
149 |
-
.env.local
|
150 |
-
server.local
|
151 |
-
~$*
|
152 |
-
/public/js/app.js
|
153 |
-
/public/js/app.js.map
|
154 |
-
/public/**/*.map
|
155 |
-
/webapp/public/js
|
156 |
-
.parcel-cache/
|
157 |
-
/docs/
|
158 |
-
/public/
|
159 |
-
config.yaml.local
|
160 |
-
/assets.local/
|
161 |
-
/assets.local2/
|
162 |
-
*.code-workspace
|
163 |
-
etc.local/
|
164 |
-
keystore.local.yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.mercs.yaml
DELETED
@@ -1,309 +0,0 @@
|
|
1 |
-
server:
|
2 |
-
network:
|
3 |
-
public_url: http://127.0.0.1:1688
|
4 |
-
rateLimit:
|
5 |
-
global: false
|
6 |
-
max: 1000
|
7 |
-
timeWindow: 60000 # 1 minute
|
8 |
-
|
9 |
-
session:
|
10 |
-
cookie:
|
11 |
-
maxAge: 604800000 # 1 week, 7*24*60*60*1000
|
12 |
-
secure: true
|
13 |
-
httpOnly: false
|
14 |
-
|
15 |
-
logger:
|
16 |
-
level: 2
|
17 |
-
|
18 |
-
kvStorage: # Location of the server KV Storage
|
19 |
-
dbPath: './data.local/db'
|
20 |
-
|
21 |
-
settings:
|
22 |
-
kvStorage:
|
23 |
-
dbPath: './data.local/db'
|
24 |
-
dbName: 'settings.db'
|
25 |
-
|
26 |
-
services:
|
27 |
-
messaging:
|
28 |
-
keepaliveInterval: 60000 # 60*1000 ms between sending keepalive packets to the client to prevent proxies from reaping the SSE connection
|
29 |
-
|
30 |
-
credentials:
|
31 |
-
disabled: false
|
32 |
-
type: default # default, local, vaultwarden (default to KV)
|
33 |
-
omniKeys: '../../keystore.local.yaml' # The default keystore to use if user doesn't have organization or user level credentials in the root folder
|
34 |
-
encryption:
|
35 |
-
keyPath: './data.local/keystore/encryption.key' # The key used to encrypt the credentials in the keystore
|
36 |
-
algorithm: aes-256-cbc
|
37 |
-
signature:
|
38 |
-
keyPath: './data.local/keystore/signature.key' # The key used to sign the credentials in the keystore
|
39 |
-
algorithm: sha256
|
40 |
-
storeConfig:
|
41 |
-
dbPath: './data.local/db'
|
42 |
-
oauth:
|
43 |
-
google-tts:
|
44 |
-
opts:
|
45 |
-
access_type: 'offline'
|
46 |
-
prompt: 'consent'
|
47 |
-
google-translate:
|
48 |
-
opts:
|
49 |
-
access_type: 'offline'
|
50 |
-
prompt: 'consent'
|
51 |
-
google-play:
|
52 |
-
opts:
|
53 |
-
access_type: 'offline'
|
54 |
-
prompt: 'consent'
|
55 |
-
google-llm:
|
56 |
-
opts:
|
57 |
-
access_type: 'offline'
|
58 |
-
prompt: 'consent'
|
59 |
-
google-vision:
|
60 |
-
opts:
|
61 |
-
access_type: 'offline'
|
62 |
-
prompt: 'consent'
|
63 |
-
google-gmail:
|
64 |
-
opts:
|
65 |
-
access_type: 'offline'
|
66 |
-
prompt: 'consent'
|
67 |
-
|
68 |
-
db:
|
69 |
-
pocketbase:
|
70 |
-
local:
|
71 |
-
dbUrl: 'http://127.0.0.1:8090'
|
72 |
-
login: '[email protected]'
|
73 |
-
development:
|
74 |
-
dbUrl: 'https://pocket.intern.mercenaries.ai'
|
75 |
-
|
76 |
-
rest_consumer:
|
77 |
-
exchange: { name: 'omni_tasks', type: 'topic', options: { durable: true, autoDelete: false, internal: false, arguments: {} } }
|
78 |
-
retry:
|
79 |
-
disabled: false
|
80 |
-
maxRetries: 3
|
81 |
-
delay: 3000
|
82 |
-
disabled: false
|
83 |
-
|
84 |
-
amqp:
|
85 |
-
exchanges:
|
86 |
-
- name: 'omni_tasks'
|
87 |
-
type: 'topic'
|
88 |
-
options:
|
89 |
-
durable: true
|
90 |
-
autoDelete: false
|
91 |
-
internal: false
|
92 |
-
arguments: {}
|
93 |
-
|
94 |
-
- name: 'omni_announce'
|
95 |
-
type: 'topic'
|
96 |
-
options:
|
97 |
-
durable: true
|
98 |
-
autoDelete: false
|
99 |
-
internal: false
|
100 |
-
arguments: {}
|
101 |
-
|
102 |
-
blockmanager:
|
103 |
-
preload: true
|
104 |
-
kvStorage:
|
105 |
-
dbPath: './data.local/db'
|
106 |
-
dbName: 'blocks.db'
|
107 |
-
|
108 |
-
# Integrations Configuration (Integrations are defined and added to the server in run.ts before it loads)
|
109 |
-
integrations:
|
110 |
-
|
111 |
-
cdn:
|
112 |
-
type: local
|
113 |
-
useLocalRoute: true #whether to use the local route or seaweed returned public url for serving images
|
114 |
-
localRoute: 'http://127.0.0.1:1688/fid'
|
115 |
-
kvStorage:
|
116 |
-
dbPath: './data.local/db'
|
117 |
-
|
118 |
-
local:
|
119 |
-
default_ttl: 7d #default ttl for temp artifacts
|
120 |
-
# ${{ if navigator.platform.startsWith("Win") }}:
|
121 |
-
# root: 'c://temp//cdn'
|
122 |
-
# url: '127.0.0.1:1688'
|
123 |
-
# insecure: true #whether to use https (e.g. behind reverse proxy) when talking to volume nodes on the backend
|
124 |
-
# ${{ else }}:
|
125 |
-
root: './data.local/files'
|
126 |
-
url: '127.0.0.1:1688'
|
127 |
-
insecure: true #whether to use https (e.g. behind reverse proxy) when talking to volume nodes on the backend
|
128 |
-
|
129 |
-
routes:
|
130 |
-
'/fid/:fid':
|
131 |
-
insecure: true
|
132 |
-
handler: 'fid'
|
133 |
-
clientExport: 'fid'
|
134 |
-
'POST /fid':
|
135 |
-
insecure: false
|
136 |
-
handler: 'fidupload'
|
137 |
-
clientExport: 'fidupload'
|
138 |
-
|
139 |
-
# Our own backend server APIs. These are declared as routes
|
140 |
-
mercenaries:
|
141 |
-
routes:
|
142 |
-
'/api/v1/mercenaries/ping': # Test route - defaults to GET
|
143 |
-
handler: 'ping'
|
144 |
-
clientExport: 'ping'
|
145 |
-
insecure: true
|
146 |
-
'POST /api/v1/mercenaries/ping': # Test route - adds the same handler responding to POST
|
147 |
-
handler: 'ping'
|
148 |
-
'/api/v1/mercenaries/fetch': # Server side fetch route (formerly /p) - GET
|
149 |
-
handler: 'fetch'
|
150 |
-
config:
|
151 |
-
rateLimit:
|
152 |
-
max: 300
|
153 |
-
timeWindow: 60000 # 1 minute
|
154 |
-
'POST /api/v1/mercenaries/fetch': # Server side fetch route (formerly /p) - POST
|
155 |
-
handler: 'fetch'
|
156 |
-
clientExport: 'fetch' # Auto register a client function in the client.api namespace
|
157 |
-
'/api/v1/mercenaries/integrations': # Server export of client routes
|
158 |
-
handler: 'integrations'
|
159 |
-
'/api/v1/mercenaries/components': # Server export of client routes
|
160 |
-
handler: 'components'
|
161 |
-
clientExport: 'components'
|
162 |
-
|
163 |
-
'/api/v1/mercenaries/extensions': # Get all extensions
|
164 |
-
handler: 'getExtensions'
|
165 |
-
|
166 |
-
'/api/v1/mercenaries/listen': # Server side listen route (sse)
|
167 |
-
handler: 'listen'
|
168 |
-
ignoreOnDevServer: true # unfortunately the vite dev server does not support SSE
|
169 |
-
# so we can't proxy this route
|
170 |
-
|
171 |
-
'POST /api/v1/mercenaries/runscript/:script' :
|
172 |
-
handler: runscript
|
173 |
-
'GET /api/v1/mercenaries/runscript/:script' :
|
174 |
-
handler: runscript
|
175 |
-
|
176 |
-
'GET /api/v1/mercenaries/user/requiredKeys':
|
177 |
-
handler: 'getRequiredKeys'
|
178 |
-
clientExport: 'getRequiredKeys'
|
179 |
-
|
180 |
-
'POST /api/v1/mercenaries/user/key':
|
181 |
-
handler: 'setUserKey'
|
182 |
-
clientExport: 'setUserKey'
|
183 |
-
'DELETE /api/v1/mercenaries/user/key':
|
184 |
-
handler: 'revokeUserKey'
|
185 |
-
clientExport: 'revokeUserKey'
|
186 |
-
'GET /api/v1/mercenaries/user/keys':
|
187 |
-
handler: 'listUserKeys'
|
188 |
-
clientExport: 'listUserKeys'
|
189 |
-
'POST /api/v1/mercenaries/user/keys/bulkAdd':
|
190 |
-
handler: 'bulkAddUserKeys'
|
191 |
-
|
192 |
-
|
193 |
-
auth: # Authentication and user related routes
|
194 |
-
kvStorage:
|
195 |
-
dbPath: './data.local/db'
|
196 |
-
dbName: 'auth.db'
|
197 |
-
routes:
|
198 |
-
'POST /api/v1/auth/login': # default username / pwd login
|
199 |
-
handler: login
|
200 |
-
authStrategy: local
|
201 |
-
'/api/v1/auth/autologin': # auto login : cloudflare , pocketbase single user
|
202 |
-
handler: login
|
203 |
-
authStrategy: ['cloudflare', 'pb_admin']
|
204 |
-
'POST /api/v1/auth/logout': # destroy session
|
205 |
-
handler: logout
|
206 |
-
'/api/v1/auth/user': # Get authenticated user info
|
207 |
-
handler: getAuthenticatedUser
|
208 |
-
'POST /api/v1/auth/token': # Generate token
|
209 |
-
handler: generateToken
|
210 |
-
'POST /api/v1/auth/accepttos':
|
211 |
-
handler: acceptTos
|
212 |
-
'GET /api/v1/auth/oauth2': # OAuth2.0
|
213 |
-
handler: oauth2
|
214 |
-
'GET /api/v1/auth/oauth2/:ns/callback': # OAuth2.0 callback
|
215 |
-
handler: oauth2Callback
|
216 |
-
|
217 |
-
chat:
|
218 |
-
routes:
|
219 |
-
'/api/v1/chat/:contextId': # Get associated chat history
|
220 |
-
handler: 'chatHistory'
|
221 |
-
clientExport: 'chatHistory'
|
222 |
-
|
223 |
-
'PUT /api/v1/chat/:contextId': # Append to persistent layer
|
224 |
-
handler: 'append'
|
225 |
-
clientExport: 'append'
|
226 |
-
|
227 |
-
'DELETE /api/v1/chat/:contextId': # Delete chat history
|
228 |
-
handler: 'clear'
|
229 |
-
clientExport: 'clear'
|
230 |
-
|
231 |
-
workflow: # Worklow related routes
|
232 |
-
routes:
|
233 |
-
'POST /api/v1/workflow/exec': # Execute a client workflow on the server
|
234 |
-
handler: 'exec'
|
235 |
-
clientExport: 'exec'
|
236 |
-
authStrategy: 'jwt'
|
237 |
-
|
238 |
-
'POST /api/v1/workflow/stop': # Stop all running workflows the user has access to
|
239 |
-
handler: 'stop'
|
240 |
-
clientExport: 'stop'
|
241 |
-
|
242 |
-
'/api/v1/workflow/workflows': # Get a users workflows
|
243 |
-
handler: 'getWorkflows'
|
244 |
-
clientExport: 'getWorkflows'
|
245 |
-
|
246 |
-
'/api/v1/workflow/workflowResults': # Get results for a workflow
|
247 |
-
handler: 'getWorkflowResults'
|
248 |
-
clientExport: 'getWorkflowResults'
|
249 |
-
|
250 |
-
'/api/v1/workflow/jobs': # Get a users running workflows (jobs)
|
251 |
-
handler: 'jobs'
|
252 |
-
clientExport: 'jobs'
|
253 |
-
|
254 |
-
'PUT /api/v1/workflow': # Update an existing workflow
|
255 |
-
handler: 'update'
|
256 |
-
clientExport: 'update'
|
257 |
-
|
258 |
-
'POST /api/v1/workflow': # Save/Create a new workflow
|
259 |
-
handler: 'create'
|
260 |
-
clientExport: 'create'
|
261 |
-
|
262 |
-
'POST /api/v1/workflow/clone': # Clone an existing workflow
|
263 |
-
handler: 'clone'
|
264 |
-
clientExport: 'clone'
|
265 |
-
|
266 |
-
'GET /api/v1/workflow/:workflowId/:version': # Load workflow from backend
|
267 |
-
handler: 'load'
|
268 |
-
clientExport: 'load'
|
269 |
-
|
270 |
-
'GET /api/v1/workflow/:workflowId': # Load the non-published version of a workflow
|
271 |
-
handler: 'load'
|
272 |
-
clientExport: 'load'
|
273 |
-
|
274 |
-
'DELETE /api/v1/workflow/:workflowId': # Delete a workflow
|
275 |
-
handler: 'deleteWorkflow'
|
276 |
-
clientExport: 'deleteWorkflow'
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
# Vite Configuration
|
281 |
-
vite:
|
282 |
-
# Configuration for the build visualizer plugin. Set to true or pass in the visualizer options
|
283 |
-
# https://github.com/btd/rollup-plugin-visualizer
|
284 |
-
visualizer:
|
285 |
-
open: false #whether or not to open statistics in a browser after build
|
286 |
-
gzipSize: true #whether to show the gzip size
|
287 |
-
template: 'treemap' # treemap, sunburst, network, list, raw-data
|
288 |
-
title: 'Mercenaries.ai Vite Build Statistics' # title for generated HTML
|
289 |
-
filename: 'stats.html'
|
290 |
-
|
291 |
-
# Additional API proxy routes
|
292 |
-
# Any route or proxy defined under server.integrations is automatically declared
|
293 |
-
# when vite.config.js builds the vite configuration
|
294 |
-
apiProxy:
|
295 |
-
'/t':
|
296 |
-
# not defining target: means use the address provided in the server.network section
|
297 |
-
# (this logic is implemented in vite.config.js)
|
298 |
-
changeOrigin: true
|
299 |
-
'/sets':
|
300 |
-
changeOrigin: true
|
301 |
-
|
302 |
-
'/fid':
|
303 |
-
changeOrigin: true
|
304 |
-
|
305 |
-
'/auth':
|
306 |
-
changeOrigin: true
|
307 |
-
|
308 |
-
'/img':
|
309 |
-
changeOrigin: true
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.npmignore
DELETED
@@ -1,162 +0,0 @@
|
|
1 |
-
.DS_Store
|
2 |
-
.env.local
|
3 |
-
dist-ssr
|
4 |
-
*.local.*
|
5 |
-
.mercs.local.yaml
|
6 |
-
.vscode
|
7 |
-
*/etc/keystore/*
|
8 |
-
*/etc/registry/.cache/*
|
9 |
-
omni.zip
|
10 |
-
fossa*
|
11 |
-
|
12 |
-
tsconfig.tsbuildinfo
|
13 |
-
/**/*/public/t
|
14 |
-
/**/*/public/sets
|
15 |
-
stats.html
|
16 |
-
|
17 |
-
# Created by .ignore support plugin (hsz.mobi)
|
18 |
-
### JetBrains template
|
19 |
-
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
20 |
-
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
21 |
-
|
22 |
-
# User-specific stuff:
|
23 |
-
.idea/workspace.xml
|
24 |
-
.idea/tasks.xml
|
25 |
-
*/cache/**
|
26 |
-
./var/**
|
27 |
-
content/
|
28 |
-
docker-certs/
|
29 |
-
log.txt
|
30 |
-
/.yarn/*
|
31 |
-
/**/*/.yarn/install-state.gz
|
32 |
-
!.yarn/patches
|
33 |
-
!.yarn/releases
|
34 |
-
!.yarn/plugins
|
35 |
-
!.yarn/sdks
|
36 |
-
!.yarn/versions
|
37 |
-
.pnp.*
|
38 |
-
/etc/ssl/
|
39 |
-
tmp/
|
40 |
-
Untitled*.md
|
41 |
-
user_files/*
|
42 |
-
!user_files/USER_FILES_GO_HERE
|
43 |
-
!user_files/oobabooga_models_directory.json
|
44 |
-
!user_files/local_llms_directories.json
|
45 |
-
packages/omni-server/user_provided_models/*
|
46 |
-
!packages/omni-server/USER_PROVIDED_MODELS_GO_HERE
|
47 |
-
packages/omni-server/data.local/
|
48 |
-
!packages/omni-server/data.local/README.md
|
49 |
-
packages/omni-server/config.local/
|
50 |
-
!packages/omni-server/config.local/README.md
|
51 |
-
|
52 |
-
# package bundles
|
53 |
-
build
|
54 |
-
setup/updates
|
55 |
-
|
56 |
-
# transient packaging
|
57 |
-
/build
|
58 |
-
|
59 |
-
# Sensitive or high-churn files:
|
60 |
-
.idea/dataSources/
|
61 |
-
.idea/dataSources.ids
|
62 |
-
.idea/dataSources.xml
|
63 |
-
.idea/dataSources.local.xml
|
64 |
-
.idea/sqlDataSources.xml
|
65 |
-
.idea/dynamic.xml
|
66 |
-
.idea/uiDesigner.xml
|
67 |
-
|
68 |
-
|
69 |
-
# Gradle:
|
70 |
-
.idea/gradle.xml
|
71 |
-
.idea/libraries
|
72 |
-
./tmp/
|
73 |
-
# Mongo Explorer plugin:
|
74 |
-
.idea/mongoSettings.xml
|
75 |
-
|
76 |
-
## File-based project format:
|
77 |
-
*.iws
|
78 |
-
|
79 |
-
## Plugin-specific files:
|
80 |
-
|
81 |
-
# IntelliJ
|
82 |
-
/out/
|
83 |
-
|
84 |
-
# mpeltonen/sbt-idea plugin
|
85 |
-
.idea_modules/
|
86 |
-
|
87 |
-
# JIRA plugin
|
88 |
-
atlassian-ide-plugin.xml
|
89 |
-
|
90 |
-
# Crashlytics plugin (for Android Studio and IntelliJ)
|
91 |
-
com_crashlytics_export_strings.xml
|
92 |
-
crashlytics.properties
|
93 |
-
crashlytics-build.properties
|
94 |
-
fabric.properties
|
95 |
-
### Node template
|
96 |
-
# Logs
|
97 |
-
logs
|
98 |
-
*.log
|
99 |
-
npm-debug.log*
|
100 |
-
|
101 |
-
# Runtime data
|
102 |
-
pids
|
103 |
-
*.pid
|
104 |
-
*.seed
|
105 |
-
*.pid.lock
|
106 |
-
|
107 |
-
# Directory for instrumented libs generated by jscoverage/JSCover
|
108 |
-
lib-cov
|
109 |
-
|
110 |
-
# Coverage directory used by tools like istanbul
|
111 |
-
coverage
|
112 |
-
|
113 |
-
# nyc test coverage
|
114 |
-
.nyc_output
|
115 |
-
|
116 |
-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
|
117 |
-
.grunt
|
118 |
-
|
119 |
-
# node-waf configuration
|
120 |
-
.lock-wscript
|
121 |
-
|
122 |
-
# Compiled binary addons (http://nodejs.org/api/addons.html)
|
123 |
-
build/Release
|
124 |
-
|
125 |
-
# Dependency directories
|
126 |
-
node_modules
|
127 |
-
jspm_packages
|
128 |
-
|
129 |
-
# Optional npm cache directory
|
130 |
-
.npm
|
131 |
-
|
132 |
-
# Optional eslint cache
|
133 |
-
.eslintcache
|
134 |
-
|
135 |
-
# Optional REPL history
|
136 |
-
.node_repl_history
|
137 |
-
|
138 |
-
# Output of 'npm pack'
|
139 |
-
*.tgz
|
140 |
-
|
141 |
-
# Yarn Integrity file
|
142 |
-
.yarn-integrity
|
143 |
-
|
144 |
-
.idea/
|
145 |
-
#.idea/watcherTasks.xml
|
146 |
-
.DS_Store
|
147 |
-
.env.local
|
148 |
-
server.local
|
149 |
-
~$*
|
150 |
-
/public/js/app.js
|
151 |
-
/public/js/app.js.map
|
152 |
-
/public/**/*.map
|
153 |
-
/webapp/public/js
|
154 |
-
.parcel-cache/
|
155 |
-
/docs/
|
156 |
-
/public/
|
157 |
-
config.yaml.local
|
158 |
-
/assets.local/
|
159 |
-
/assets.local2/
|
160 |
-
*.code-workspace
|
161 |
-
etc.local/
|
162 |
-
keystore.local.yaml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.prettierignore
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
*.mjs
|
2 |
-
*.cjs
|
3 |
-
packages/**/*.js
|
4 |
-
*.d.ts
|
5 |
-
*.map.ts
|
6 |
-
**/dist/**
|
7 |
-
**/lib/**
|
8 |
-
*.hbs
|
9 |
-
*.md
|
10 |
-
**/omni-server/public/**
|
11 |
-
**/omni-server/extensions/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.prettierrc
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"tabWidth": 2,
|
3 |
-
"useTabs": false,
|
4 |
-
"printWidth": 120,
|
5 |
-
"singleQuote": true,
|
6 |
-
"bracketSameLine": true,
|
7 |
-
"trailingComma": "none",
|
8 |
-
"endOfLine": "auto"
|
9 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.vscode/launch.json
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
// Use IntelliSense to learn about possible attributes.
|
3 |
+
// Hover to view descriptions of existing attributes.
|
4 |
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5 |
+
"version": "0.2.0",
|
6 |
+
"configurations": [
|
7 |
+
|
8 |
+
{
|
9 |
+
"name": "Launch Server (TS-Debug)",
|
10 |
+
"request": "launch",
|
11 |
+
"runtimeArgs": [
|
12 |
+
"server"
|
13 |
+
],
|
14 |
+
"outputCapture": "std",
|
15 |
+
"runtimeExecutable": "yarn",
|
16 |
+
"outFiles": [
|
17 |
+
"${workspaceFolder}/lib/*.js"
|
18 |
+
],
|
19 |
+
"skipFiles": [
|
20 |
+
"<node_internals>/**"
|
21 |
+
],
|
22 |
+
"type": "node"
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"name": "Launch Server (Debug)",
|
26 |
+
"request": "launch",
|
27 |
+
"runtimeArgs": [
|
28 |
+
"dev"
|
29 |
+
],
|
30 |
+
"outputCapture": "std",
|
31 |
+
"runtimeExecutable": "yarn",
|
32 |
+
"skipFiles": [
|
33 |
+
"<node_internals>/**"
|
34 |
+
],
|
35 |
+
"type": "node"
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"type": "node",
|
39 |
+
"request": "launch",
|
40 |
+
"name": "Debug Current NODE File",
|
41 |
+
"skipFiles": [
|
42 |
+
"<node_internals>/**"
|
43 |
+
],
|
44 |
+
"program": "${file}"
|
45 |
+
}
|
46 |
+
]
|
47 |
+
{
|
48 |
+
"name": "Launch Server (Manu)",
|
49 |
+
"request": "launch",
|
50 |
+
"runtimeArgs": [
|
51 |
+
"start",
|
52 |
+
"-u",
|
53 |
+
"-rb"
|
54 |
+
],
|
55 |
+
"console": "integratedTerminal",
|
56 |
+
"outputCapture": "std",
|
57 |
+
"runtimeExecutable": "yarn",
|
58 |
+
"skipFiles": [
|
59 |
+
"<node_internals>/**"
|
60 |
+
],
|
61 |
+
"type": "node"
|
62 |
+
},
|
63 |
+
{
|
64 |
+
"name": "Single node script",
|
65 |
+
"request": "launch",
|
66 |
+
"runtimeArgs": [
|
67 |
+
"node",
|
68 |
+
"-u",
|
69 |
+
"-rb"
|
70 |
+
],
|
71 |
+
"console": "integratedTerminal",
|
72 |
+
"outputCapture": "std",
|
73 |
+
"runtimeExecutable": "yarn",
|
74 |
+
"skipFiles": [
|
75 |
+
"<node_internals>/**"
|
76 |
+
],
|
77 |
+
"type": "node"
|
78 |
+
},
|
79 |
+
{
|
80 |
+
"name": "Attach by Process ID",
|
81 |
+
"processId": "${command:PickProcess}",
|
82 |
+
"request": "attach",
|
83 |
+
"skipFiles": [
|
84 |
+
"<node_internals>/**"
|
85 |
+
],
|
86 |
+
"type": "node"
|
87 |
+
},
|
88 |
+
{
|
89 |
+
"type": "node",
|
90 |
+
"request": "launch",
|
91 |
+
"name": "Launch Program",
|
92 |
+
"skipFiles": [
|
93 |
+
"<node_internals>/**"
|
94 |
+
],
|
95 |
+
"program": "${workspaceFolder}\\packages\\omni-server\\lib\\run.js",
|
96 |
+
"args": ["-l", "127.0.0.1"],
|
97 |
+
"outFiles": [
|
98 |
+
"${workspaceFolder}/**/*.js"
|
99 |
+
]
|
100 |
+
},
|
101 |
+
{
|
102 |
+
"name": "Launch Server Fast (LOCAL)(Launch Your Own Pocket+Vite)",
|
103 |
+
"env": {
|
104 |
+
"NODE_ENV": "development"
|
105 |
+
},
|
106 |
+
"type": "node",
|
107 |
+
"request": "launch",
|
108 |
+
"outputCapture": "std",
|
109 |
+
"program": "${workspaceFolder}/packages/omni-server/dist/run.js",
|
110 |
+
"args": ["-l", "127.0.0.1"],
|
111 |
+
"cwd": "${workspaceFolder}/packages/omni-server",
|
112 |
+
"skipFiles": [
|
113 |
+
"${workspaceFolder}/node_modules/**",
|
114 |
+
"<node_internals>/**"
|
115 |
+
],
|
116 |
+
"outFiles": [
|
117 |
+
"${workspaceFolder}/packages/omni-server/dist/**/*.js",
|
118 |
+
"${workspaceFolder}/packages/omni-ui/omni-client-services/lib/**/*.js",
|
119 |
+
"${workspaceFolder}/packages/omni-shared/lib/**/*.js",
|
120 |
+
"${workspaceFolder}/packages/omni-sockets/lib/**/*.js",
|
121 |
+
"${workspaceFolder}/packages/omni-sdk/lib/**/*.js",
|
122 |
+
],
|
123 |
+
"sourceMaps": true,
|
124 |
+
"smartStep": true,
|
125 |
+
"runtimeArgs": [
|
126 |
+
"--experimental-modules"
|
127 |
+
],
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"name": "Launch Server Fast (TAILNET)(Launch Your Own Vite)",
|
131 |
+
"env": {
|
132 |
+
"NODE_ENV": "development"
|
133 |
+
},
|
134 |
+
"type": "node",
|
135 |
+
"request": "launch",
|
136 |
+
"outputCapture": "std",
|
137 |
+
"sourceMaps": true,
|
138 |
+
"smartStep": true,
|
139 |
+
"runtimeArgs": [
|
140 |
+
"--experimental-modules"
|
141 |
+
],
|
142 |
+
"program": "${workspaceFolder}/packages/omni-server/dist/run.js",
|
143 |
+
"args": ["-l", "127.0.0.1"],
|
144 |
+
"cwd": "${workspaceFolder}/packages/omni-server",
|
145 |
+
"skipFiles": [
|
146 |
+
"${workspaceFolder}/node_modules/**",
|
147 |
+
"<node_internals>/**"
|
148 |
+
],
|
149 |
+
"outFiles": [
|
150 |
+
"${workspaceFolder}/packages/omni-server/dist/**/*.js",
|
151 |
+
"${workspaceFolder}/packages/omni-ui/omni-client-services/lib/**/*.js",
|
152 |
+
"${workspaceFolder}/packages/omni-shared/lib/**/*.js",
|
153 |
+
"${workspaceFolder}/packages/omni-ui/omni-sockets/lib/**/*.js"
|
154 |
+
],
|
155 |
+
}
|
156 |
+
]
|
157 |
+
}
|
.yarn/install-state.gz
ADDED
Binary file (51.8 kB). View file
|
|
.yarn/plugins/@yarnpkg/plugin-engines.cjs
DELETED
@@ -1,9 +0,0 @@
|
|
1 |
-
/* eslint-disable */
|
2 |
-
//prettier-ignore
|
3 |
-
module.exports = {
|
4 |
-
name: "@yarnpkg/plugin-engines",
|
5 |
-
factory: function (require) {
|
6 |
-
var plugin=(()=>{var P=Object.create,f=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var b=n=>f(n,"__esModule",{value:!0});var i=n=>{if(typeof require!="undefined")return require(n);throw new Error('Dynamic require of "'+n+'" is not supported')};var T=(n,e)=>{for(var r in e)f(n,r,{get:e[r],enumerable:!0})},V=(n,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of N(e))!Y.call(n,t)&&t!=="default"&&f(n,t,{get:()=>e[t],enumerable:!(r=R(e,t))||r.enumerable});return n},s=n=>V(b(f(n!=null?P(j(n)):{},"default",n&&n.__esModule&&"default"in n?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n);var U={};T(U,{default:()=>q});var o=s(i("@yarnpkg/core")),c;(function(r){r.Yarn="Yarn",r.Console="Console"})(c||(c={}));var h=class{constructor(e){this.throwWrongEngineError=(e,r)=>{let t=this.formatErrorMessage(e,r);this.throwError(t)};this.throwError=e=>{switch(this.errorReporter){case c.Yarn:this.reportYarnError(e);break;case c.Console:default:this.reportConsoleError(e);break}};this.reportYarnError=e=>{throw new o.ReportError(o.MessageName.UNNAMED,e)};this.reportConsoleError=e=>{console.error(e),process.exit(1)};this.formatErrorMessage=(e,r)=>{let{configuration:t}=this.project,p=o.formatUtils.applyStyle(t,o.formatUtils.pretty(t,this.engine,"green"),2),g=o.formatUtils.pretty(t,e,"cyan"),d=o.formatUtils.pretty(t,r,"cyan"),w=`The current ${p} version ${g} does not satisfy the required version ${d}.`;return o.formatUtils.pretty(t,w,"red")};this.project=e.project,this.errorReporter=e.errorReporter}};var m=s(i("fs")),y=s(i("path")),l=s(i("semver")),k=s(i("@yarnpkg/fslib")),a=s(i("@yarnpkg/core"));var v=class extends h{constructor(){super(...arguments);this.resolveNvmRequiredVersion=()=>{let{configuration:e,cwd:r}=this.project,t=(0,y.resolve)(k.npath.fromPortablePath(r),".nvmrc"),p=a.formatUtils.applyStyle(e,a.formatUtils.pretty(e,this.engine,"green"),2);if(!(0,m.existsSync)(t)){this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The .nvmrc file does not exist.`,"red"));return}let g=(0,m.readFileSync)(t,"utf-8").trim();if((0,l.validRange)(g))return g;let d=a.formatUtils.pretty(e,".nvmrc","yellow");this.throwError(a.formatUtils.pretty(e,`Unable to verify the ${p} version. The ${d} file contains an invalid semver range.`,"red"))}}get engine(){return"Node"}verifyEngine(e){let r=e.node;r!=null&&(r===".nvmrc"&&(r=this.resolveNvmRequiredVersion()),(0,l.satisfies)(process.version,r,{includePrerelease:!0})||this.throwWrongEngineError(process.version.replace(/^v/i,""),r.replace(/^v/i,"")))}};var x=s(i("semver")),E=s(i("@yarnpkg/core"));var u=class extends h{get engine(){return"Yarn"}verifyEngine(e){let r=e.yarn;r!=null&&((0,x.satisfies)(E.YarnVersion,r,{includePrerelease:!0})||this.throwWrongEngineError(E.YarnVersion,r))}};var C=n=>e=>{if(process.env.PLUGIN_YARN_ENGINES_DISABLE!=null)return;let{engines:r={}}=e.getWorkspaceByCwd(e.cwd).manifest.raw,t={project:e,errorReporter:n};[new v(t),new u(t)].forEach(g=>g.verifyEngine(r))},S={hooks:{validateProject:C(c.Yarn),setupScriptEnvironment:C(c.Console)}},q=S;return U;})();
|
7 |
-
return plugin;
|
8 |
-
}
|
9 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
DELETED
The diff for this file is too large to render.
See raw diff
|
|
.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
/* eslint-disable */
|
2 |
-
//prettier-ignore
|
3 |
-
module.exports = {
|
4 |
-
name: "@yarnpkg/plugin-workspace-tools",
|
5 |
-
factory: function (require) {
|
6 |
-
var plugin=(()=>{var _r=Object.create;var we=Object.defineProperty;var Er=Object.getOwnPropertyDescriptor;var br=Object.getOwnPropertyNames;var xr=Object.getPrototypeOf,Cr=Object.prototype.hasOwnProperty;var W=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)[t]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var q=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),wr=(e,r)=>{for(var t in r)we(e,t,{get:r[t],enumerable:!0})},Je=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of br(r))!Cr.call(e,s)&&s!==t&&we(e,s,{get:()=>r[s],enumerable:!(n=Er(r,s))||n.enumerable});return e};var Be=(e,r,t)=>(t=e!=null?_r(xr(e)):{},Je(r||!e||!e.__esModule?we(t,"default",{value:e,enumerable:!0}):t,e)),Sr=e=>Je(we({},"__esModule",{value:!0}),e);var ve=q(ee=>{"use strict";ee.isInteger=e=>typeof e=="number"?Number.isInteger(e):typeof e=="string"&&e.trim()!==""?Number.isInteger(Number(e)):!1;ee.find=(e,r)=>e.nodes.find(t=>t.type===r);ee.exceedsLimit=(e,r,t=1,n)=>n===!1||!ee.isInteger(e)||!ee.isInteger(r)?!1:(Number(r)-Number(e))/Number(t)>=n;ee.escapeNode=(e,r=0,t)=>{let n=e.nodes[r];!n||(t&&n.type===t||n.type==="open"||n.type==="close")&&n.escaped!==!0&&(n.value="\\"+n.value,n.escaped=!0)};ee.encloseBrace=e=>e.type!=="brace"?!1:e.commas>>0+e.ranges>>0===0?(e.invalid=!0,!0):!1;ee.isInvalidBrace=e=>e.type!=="brace"?!1:e.invalid===!0||e.dollar?!0:e.commas>>0+e.ranges>>0===0||e.open!==!0||e.close!==!0?(e.invalid=!0,!0):!1;ee.isOpenOrClose=e=>e.type==="open"||e.type==="close"?!0:e.open===!0||e.close===!0;ee.reduce=e=>e.reduce((r,t)=>(t.type==="text"&&r.push(t.value),t.type==="range"&&(t.type="text"),r),[]);ee.flatten=(...e)=>{let r=[],t=n=>{for(let s=0;s<n.length;s++){let i=n[s];Array.isArray(i)?t(i,r):i!==void 0&&r.push(i)}return r};return t(e),r}});var He=q((Vn,rt)=>{"use strict";var tt=ve();rt.exports=(e,r={})=>{let t=(n,s={})=>{let i=r.escapeInvalid&&tt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c="";if(n.value)return(i||a)&&tt.isOpenOrClose(n)?"\\"+n.value:n.value;if(n.value)return n.value;if(n.nodes)for(let p of n.nodes)c+=t(p);return c};return t(e)}});var st=q((Jn,nt)=>{"use strict";nt.exports=function(e){return typeof e=="number"?e-e===0:typeof e=="string"&&e.trim()!==""?Number.isFinite?Number.isFinite(+e):isFinite(+e):!1}});var ht=q((es,pt)=>{"use strict";var at=st(),le=(e,r,t)=>{if(at(e)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(r===void 0||e===r)return String(e);if(at(r)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let n={relaxZeros:!0,...t};typeof n.strictZeros=="boolean"&&(n.relaxZeros=n.strictZeros===!1);let s=String(n.relaxZeros),i=String(n.shorthand),a=String(n.capture),c=String(n.wrap),p=e+":"+r+"="+s+i+a+c;if(le.cache.hasOwnProperty(p))return le.cache[p].result;let m=Math.min(e,r),h=Math.max(e,r);if(Math.abs(m-h)===1){let y=e+"|"+r;return n.capture?`(${y})`:n.wrap===!1?y:`(?:${y})`}let R=ft(e)||ft(r),f={min:e,max:r,a:m,b:h},$=[],_=[];if(R&&(f.isPadded=R,f.maxLen=String(f.max).length),m<0){let y=h<0?Math.abs(h):1;_=it(y,Math.abs(m),f,n),m=f.a=0}return h>=0&&($=it(m,h,f,n)),f.negatives=_,f.positives=$,f.result=vr(_,$,n),n.capture===!0?f.result=`(${f.result})`:n.wrap!==!1&&$.length+_.length>1&&(f.result=`(?:${f.result})`),le.cache[p]=f,f.result};function vr(e,r,t){let n=Me(e,r,"-",!1,t)||[],s=Me(r,e,"",!1,t)||[],i=Me(e,r,"-?",!0,t)||[];return n.concat(i).concat(s).join("|")}function Hr(e,r){let t=1,n=1,s=ut(e,t),i=new Set([r]);for(;e<=s&&s<=r;)i.add(s),t+=1,s=ut(e,t);for(s=ct(r+1,n)-1;e<s&&s<=r;)i.add(s),n+=1,s=ct(r+1,n)-1;return i=[...i],i.sort(kr),i}function $r(e,r,t){if(e===r)return{pattern:e,count:[],digits:0};let n=Tr(e,r),s=n.length,i="",a=0;for(let c=0;c<s;c++){let[p,m]=n[c];p===m?i+=p:p!=="0"||m!=="9"?i+=Lr(p,m,t):a++}return a&&(i+=t.shorthand===!0?"\\d":"[0-9]"),{pattern:i,count:[a],digits:s}}function it(e,r,t,n){let s=Hr(e,r),i=[],a=e,c;for(let p=0;p<s.length;p++){let m=s[p],h=$r(String(a),String(m),n),R="";if(!t.isPadded&&c&&c.pattern===h.pattern){c.count.length>1&&c.count.pop(),c.count.push(h.count[0]),c.string=c.pattern+lt(c.count),a=m+1;continue}t.isPadded&&(R=Or(m,t,n)),h.string=R+h.pattern+lt(h.count),i.push(h),a=m+1,c=h}return i}function Me(e,r,t,n,s){let i=[];for(let a of e){let{string:c}=a;!n&&!ot(r,"string",c)&&i.push(t+c),n&&ot(r,"string",c)&&i.push(t+c)}return i}function Tr(e,r){let t=[];for(let n=0;n<e.length;n++)t.push([e[n],r[n]]);return t}function kr(e,r){return e>r?1:r>e?-1:0}function ot(e,r,t){return e.some(n=>n[r]===t)}function ut(e,r){return Number(String(e).slice(0,-r)+"9".repeat(r))}function ct(e,r){return e-e%Math.pow(10,r)}function lt(e){let[r=0,t=""]=e;return t||r>1?`{${r+(t?","+t:"")}}`:""}function Lr(e,r,t){return`[${e}${r-e===1?"":"-"}${r}]`}function ft(e){return/^-?(0+)\d/.test(e)}function Or(e,r,t){if(!r.isPadded)return e;let n=Math.abs(r.maxLen-String(e).length),s=t.relaxZeros!==!1;switch(n){case 0:return"";case 1:return s?"0?":"0";case 2:return s?"0{0,2}":"00";default:return s?`0{0,${n}}`:`0{${n}}`}}le.cache={};le.clearCache=()=>le.cache={};pt.exports=le});var Ue=q((ts,Et)=>{"use strict";var Nr=W("util"),At=ht(),dt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ir=e=>r=>e===!0?Number(r):String(r),Pe=e=>typeof e=="number"||typeof e=="string"&&e!=="",Ae=e=>Number.isInteger(+e),De=e=>{let r=`${e}`,t=-1;if(r[0]==="-"&&(r=r.slice(1)),r==="0")return!1;for(;r[++t]==="0";);return t>0},Br=(e,r,t)=>typeof e=="string"||typeof r=="string"?!0:t.stringify===!0,Mr=(e,r,t)=>{if(r>0){let n=e[0]==="-"?"-":"";n&&(e=e.slice(1)),e=n+e.padStart(n?r-1:r,"0")}return t===!1?String(e):e},gt=(e,r)=>{let t=e[0]==="-"?"-":"";for(t&&(e=e.slice(1),r--);e.length<r;)e="0"+e;return t?"-"+e:e},Pr=(e,r)=>{e.negatives.sort((a,c)=>a<c?-1:a>c?1:0),e.positives.sort((a,c)=>a<c?-1:a>c?1:0);let t=r.capture?"":"?:",n="",s="",i;return e.positives.length&&(n=e.positives.join("|")),e.negatives.length&&(s=`-(${t}${e.negatives.join("|")})`),n&&s?i=`${n}|${s}`:i=n||s,r.wrap?`(${t}${i})`:i},mt=(e,r,t,n)=>{if(t)return At(e,r,{wrap:!1,...n});let s=String.fromCharCode(e);if(e===r)return s;let i=String.fromCharCode(r);return`[${s}-${i}]`},Rt=(e,r,t)=>{if(Array.isArray(e)){let n=t.wrap===!0,s=t.capture?"":"?:";return n?`(${s}${e.join("|")})`:e.join("|")}return At(e,r,t)},yt=(...e)=>new RangeError("Invalid range arguments: "+Nr.inspect(...e)),_t=(e,r,t)=>{if(t.strictRanges===!0)throw yt([e,r]);return[]},Dr=(e,r)=>{if(r.strictRanges===!0)throw new TypeError(`Expected step "${e}" to be a number`);return[]},Ur=(e,r,t=1,n={})=>{let s=Number(e),i=Number(r);if(!Number.isInteger(s)||!Number.isInteger(i)){if(n.strictRanges===!0)throw yt([e,r]);return[]}s===0&&(s=0),i===0&&(i=0);let a=s>i,c=String(e),p=String(r),m=String(t);t=Math.max(Math.abs(t),1);let h=De(c)||De(p)||De(m),R=h?Math.max(c.length,p.length,m.length):0,f=h===!1&&Br(e,r,n)===!1,$=n.transform||Ir(f);if(n.toRegex&&t===1)return mt(gt(e,R),gt(r,R),!0,n);let _={negatives:[],positives:[]},y=T=>_[T<0?"negatives":"positives"].push(Math.abs(T)),E=[],S=0;for(;a?s>=i:s<=i;)n.toRegex===!0&&t>1?y(s):E.push(Mr($(s,S),R,f)),s=a?s-t:s+t,S++;return n.toRegex===!0?t>1?Pr(_,n):Rt(E,null,{wrap:!1,...n}):E},Gr=(e,r,t=1,n={})=>{if(!Ae(e)&&e.length>1||!Ae(r)&&r.length>1)return _t(e,r,n);let s=n.transform||(f=>String.fromCharCode(f)),i=`${e}`.charCodeAt(0),a=`${r}`.charCodeAt(0),c=i>a,p=Math.min(i,a),m=Math.max(i,a);if(n.toRegex&&t===1)return mt(p,m,!1,n);let h=[],R=0;for(;c?i>=a:i<=a;)h.push(s(i,R)),i=c?i-t:i+t,R++;return n.toRegex===!0?Rt(h,null,{wrap:!1,options:n}):h},$e=(e,r,t,n={})=>{if(r==null&&Pe(e))return[e];if(!Pe(e)||!Pe(r))return _t(e,r,n);if(typeof t=="function")return $e(e,r,1,{transform:t});if(dt(t))return $e(e,r,0,t);let s={...n};return s.capture===!0&&(s.wrap=!0),t=t||s.step||1,Ae(t)?Ae(e)&&Ae(r)?Ur(e,r,t,s):Gr(e,r,Math.max(Math.abs(t),1),s):t!=null&&!dt(t)?Dr(t,s):$e(e,r,1,t)};Et.exports=$e});var Ct=q((rs,xt)=>{"use strict";var qr=Ue(),bt=ve(),Kr=(e,r={})=>{let t=(n,s={})=>{let i=bt.isInvalidBrace(s),a=n.invalid===!0&&r.escapeInvalid===!0,c=i===!0||a===!0,p=r.escapeInvalid===!0?"\\":"",m="";if(n.isOpen===!0||n.isClose===!0)return p+n.value;if(n.type==="open")return c?p+n.value:"(";if(n.type==="close")return c?p+n.value:")";if(n.type==="comma")return n.prev.type==="comma"?"":c?n.value:"|";if(n.value)return n.value;if(n.nodes&&n.ranges>0){let h=bt.reduce(n.nodes),R=qr(...h,{...r,wrap:!1,toRegex:!0});if(R.length!==0)return h.length>1&&R.length>1?`(${R})`:R}if(n.nodes)for(let h of n.nodes)m+=t(h,n);return m};return t(e)};xt.exports=Kr});var vt=q((ns,St)=>{"use strict";var Wr=Ue(),wt=He(),he=ve(),fe=(e="",r="",t=!1)=>{let n=[];if(e=[].concat(e),r=[].concat(r),!r.length)return e;if(!e.length)return t?he.flatten(r).map(s=>`{${s}}`):r;for(let s of e)if(Array.isArray(s))for(let i of s)n.push(fe(i,r,t));else for(let i of r)t===!0&&typeof i=="string"&&(i=`{${i}}`),n.push(Array.isArray(i)?fe(s,i,t):s+i);return he.flatten(n)},jr=(e,r={})=>{let t=r.rangeLimit===void 0?1e3:r.rangeLimit,n=(s,i={})=>{s.queue=[];let a=i,c=i.queue;for(;a.type!=="brace"&&a.type!=="root"&&a.parent;)a=a.parent,c=a.queue;if(s.invalid||s.dollar){c.push(fe(c.pop(),wt(s,r)));return}if(s.type==="brace"&&s.invalid!==!0&&s.nodes.length===2){c.push(fe(c.pop(),["{}"]));return}if(s.nodes&&s.ranges>0){let R=he.reduce(s.nodes);if(he.exceedsLimit(...R,r.step,t))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let f=Wr(...R,r);f.length===0&&(f=wt(s,r)),c.push(fe(c.pop(),f)),s.nodes=[];return}let p=he.encloseBrace(s),m=s.queue,h=s;for(;h.type!=="brace"&&h.type!=="root"&&h.parent;)h=h.parent,m=h.queue;for(let R=0;R<s.nodes.length;R++){let f=s.nodes[R];if(f.type==="comma"&&s.type==="brace"){R===1&&m.push(""),m.push("");continue}if(f.type==="close"){c.push(fe(c.pop(),m,p));continue}if(f.value&&f.type!=="open"){m.push(fe(m.pop(),f.value));continue}f.nodes&&n(f,s)}return m};return he.flatten(n(e))};St.exports=jr});var $t=q((ss,Ht)=>{"use strict";Ht.exports={MAX_LENGTH:1024*64,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
7 |
-
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Nt=q((as,Ot)=>{"use strict";var Fr=He(),{MAX_LENGTH:Tt,CHAR_BACKSLASH:Ge,CHAR_BACKTICK:Qr,CHAR_COMMA:Xr,CHAR_DOT:Zr,CHAR_LEFT_PARENTHESES:Yr,CHAR_RIGHT_PARENTHESES:zr,CHAR_LEFT_CURLY_BRACE:Vr,CHAR_RIGHT_CURLY_BRACE:Jr,CHAR_LEFT_SQUARE_BRACKET:kt,CHAR_RIGHT_SQUARE_BRACKET:Lt,CHAR_DOUBLE_QUOTE:en,CHAR_SINGLE_QUOTE:tn,CHAR_NO_BREAK_SPACE:rn,CHAR_ZERO_WIDTH_NOBREAK_SPACE:nn}=$t(),sn=(e,r={})=>{if(typeof e!="string")throw new TypeError("Expected a string");let t=r||{},n=typeof t.maxLength=="number"?Math.min(Tt,t.maxLength):Tt;if(e.length>n)throw new SyntaxError(`Input length (${e.length}), exceeds max characters (${n})`);let s={type:"root",input:e,nodes:[]},i=[s],a=s,c=s,p=0,m=e.length,h=0,R=0,f,$={},_=()=>e[h++],y=E=>{if(E.type==="text"&&c.type==="dot"&&(c.type="text"),c&&c.type==="text"&&E.type==="text"){c.value+=E.value;return}return a.nodes.push(E),E.parent=a,E.prev=c,c=E,E};for(y({type:"bos"});h<m;)if(a=i[i.length-1],f=_(),!(f===nn||f===rn)){if(f===Ge){y({type:"text",value:(r.keepEscaping?f:"")+_()});continue}if(f===Lt){y({type:"text",value:"\\"+f});continue}if(f===kt){p++;let E=!0,S;for(;h<m&&(S=_());){if(f+=S,S===kt){p++;continue}if(S===Ge){f+=_();continue}if(S===Lt&&(p--,p===0))break}y({type:"text",value:f});continue}if(f===Yr){a=y({type:"paren",nodes:[]}),i.push(a),y({type:"text",value:f});continue}if(f===zr){if(a.type!=="paren"){y({type:"text",value:f});continue}a=i.pop(),y({type:"text",value:f}),a=i[i.length-1];continue}if(f===en||f===tn||f===Qr){let E=f,S;for(r.keepQuotes!==!0&&(f="");h<m&&(S=_());){if(S===Ge){f+=S+_();continue}if(S===E){r.keepQuotes===!0&&(f+=S);break}f+=S}y({type:"text",value:f});continue}if(f===Vr){R++;let E=c.value&&c.value.slice(-1)==="$"||a.dollar===!0;a=y({type:"brace",open:!0,close:!1,dollar:E,depth:R,commas:0,ranges:0,nodes:[]}),i.push(a),y({type:"open",value:f});continue}if(f===Jr){if(a.type!=="brace"){y({type:"text",value:f});continue}let E="close";a=i.pop(),a.close=!0,y({type:E,value:f}),R--,a=i[i.length-1];continue}if(f===Xr&&R>0){if(a.ranges>0){a.ranges=0;let E=a.nodes.shift();a.nodes=[E,{type:"text",value:Fr(a)}]}y({type:"comma",value:f}),a.commas++;continue}if(f===Zr&&R>0&&a.commas===0){let E=a.nodes;if(R===0||E.length===0){y({type:"text",value:f});continue}if(c.type==="dot"){if(a.range=[],c.value+=f,c.type="range",a.nodes.length!==3&&a.nodes.length!==5){a.invalid=!0,a.ranges=0,c.type="text";continue}a.ranges++,a.args=[];continue}if(c.type==="range"){E.pop();let S=E[E.length-1];S.value+=c.value+f,c=S,a.ranges--;continue}y({type:"dot",value:f});continue}y({type:"text",value:f})}do if(a=i.pop(),a.type!=="root"){a.nodes.forEach(T=>{T.nodes||(T.type==="open"&&(T.isOpen=!0),T.type==="close"&&(T.isClose=!0),T.nodes||(T.type="text"),T.invalid=!0)});let E=i[i.length-1],S=E.nodes.indexOf(a);E.nodes.splice(S,1,...a.nodes)}while(i.length>0);return y({type:"eos"}),s};Ot.exports=sn});var Mt=q((is,Bt)=>{"use strict";var It=He(),an=Ct(),on=vt(),un=Nt(),X=(e,r={})=>{let t=[];if(Array.isArray(e))for(let n of e){let s=X.create(n,r);Array.isArray(s)?t.push(...s):t.push(s)}else t=[].concat(X.create(e,r));return r&&r.expand===!0&&r.nodupes===!0&&(t=[...new Set(t)]),t};X.parse=(e,r={})=>un(e,r);X.stringify=(e,r={})=>It(typeof e=="string"?X.parse(e,r):e,r);X.compile=(e,r={})=>(typeof e=="string"&&(e=X.parse(e,r)),an(e,r));X.expand=(e,r={})=>{typeof e=="string"&&(e=X.parse(e,r));let t=on(e,r);return r.noempty===!0&&(t=t.filter(Boolean)),r.nodupes===!0&&(t=[...new Set(t)]),t};X.create=(e,r={})=>e===""||e.length<3?[e]:r.expand!==!0?X.compile(e,r):X.expand(e,r);Bt.exports=X});var me=q((os,qt)=>{"use strict";var cn=W("path"),se="\\\\/",Pt=`[^${se}]`,ie="\\.",ln="\\+",fn="\\?",Te="\\/",pn="(?=.)",Dt="[^/]",qe=`(?:${Te}|$)`,Ut=`(?:^|${Te})`,Ke=`${ie}{1,2}${qe}`,hn=`(?!${ie})`,dn=`(?!${Ut}${Ke})`,gn=`(?!${ie}{0,1}${qe})`,An=`(?!${Ke})`,mn=`[^.${Te}]`,Rn=`${Dt}*?`,Gt={DOT_LITERAL:ie,PLUS_LITERAL:ln,QMARK_LITERAL:fn,SLASH_LITERAL:Te,ONE_CHAR:pn,QMARK:Dt,END_ANCHOR:qe,DOTS_SLASH:Ke,NO_DOT:hn,NO_DOTS:dn,NO_DOT_SLASH:gn,NO_DOTS_SLASH:An,QMARK_NO_DOT:mn,STAR:Rn,START_ANCHOR:Ut},yn={...Gt,SLASH_LITERAL:`[${se}]`,QMARK:Pt,STAR:`${Pt}*?`,DOTS_SLASH:`${ie}{1,2}(?:[${se}]|$)`,NO_DOT:`(?!${ie})`,NO_DOTS:`(?!(?:^|[${se}])${ie}{1,2}(?:[${se}]|$))`,NO_DOT_SLASH:`(?!${ie}{0,1}(?:[${se}]|$))`,NO_DOTS_SLASH:`(?!${ie}{1,2}(?:[${se}]|$))`,QMARK_NO_DOT:`[^.${se}]`,START_ANCHOR:`(?:^|[${se}])`,END_ANCHOR:`(?:[${se}]|$)`},_n={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};qt.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:_n,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:cn.sep,extglobChars(e){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${e.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(e){return e===!0?yn:Gt}}});var Re=q(F=>{"use strict";var En=W("path"),bn=process.platform==="win32",{REGEX_BACKSLASH:xn,REGEX_REMOVE_BACKSLASH:Cn,REGEX_SPECIAL_CHARS:wn,REGEX_SPECIAL_CHARS_GLOBAL:Sn}=me();F.isObject=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);F.hasRegexChars=e=>wn.test(e);F.isRegexChar=e=>e.length===1&&F.hasRegexChars(e);F.escapeRegex=e=>e.replace(Sn,"\\$1");F.toPosixSlashes=e=>e.replace(xn,"/");F.removeBackslashes=e=>e.replace(Cn,r=>r==="\\"?"":r);F.supportsLookbehinds=()=>{let e=process.version.slice(1).split(".").map(Number);return e.length===3&&e[0]>=9||e[0]===8&&e[1]>=10};F.isWindows=e=>e&&typeof e.windows=="boolean"?e.windows:bn===!0||En.sep==="\\";F.escapeLast=(e,r,t)=>{let n=e.lastIndexOf(r,t);return n===-1?e:e[n-1]==="\\"?F.escapeLast(e,r,n-1):`${e.slice(0,n)}\\${e.slice(n)}`};F.removePrefix=(e,r={})=>{let t=e;return t.startsWith("./")&&(t=t.slice(2),r.prefix="./"),t};F.wrapOutput=(e,r={},t={})=>{let n=t.contains?"":"^",s=t.contains?"":"$",i=`${n}(?:${e})${s}`;return r.negated===!0&&(i=`(?:^(?!${i}).*$)`),i}});var Yt=q((cs,Zt)=>{"use strict";var Kt=Re(),{CHAR_ASTERISK:We,CHAR_AT:vn,CHAR_BACKWARD_SLASH:ye,CHAR_COMMA:Hn,CHAR_DOT:je,CHAR_EXCLAMATION_MARK:Fe,CHAR_FORWARD_SLASH:Xt,CHAR_LEFT_CURLY_BRACE:Qe,CHAR_LEFT_PARENTHESES:Xe,CHAR_LEFT_SQUARE_BRACKET:$n,CHAR_PLUS:Tn,CHAR_QUESTION_MARK:Wt,CHAR_RIGHT_CURLY_BRACE:kn,CHAR_RIGHT_PARENTHESES:jt,CHAR_RIGHT_SQUARE_BRACKET:Ln}=me(),Ft=e=>e===Xt||e===ye,Qt=e=>{e.isPrefix!==!0&&(e.depth=e.isGlobstar?1/0:1)},On=(e,r)=>{let t=r||{},n=e.length-1,s=t.parts===!0||t.scanToEnd===!0,i=[],a=[],c=[],p=e,m=-1,h=0,R=0,f=!1,$=!1,_=!1,y=!1,E=!1,S=!1,T=!1,L=!1,z=!1,I=!1,re=0,K,g,v={value:"",depth:0,isGlob:!1},k=()=>m>=n,l=()=>p.charCodeAt(m+1),H=()=>(K=g,p.charCodeAt(++m));for(;m<n;){g=H();let M;if(g===ye){T=v.backslashes=!0,g=H(),g===Qe&&(S=!0);continue}if(S===!0||g===Qe){for(re++;k()!==!0&&(g=H());){if(g===ye){T=v.backslashes=!0,H();continue}if(g===Qe){re++;continue}if(S!==!0&&g===je&&(g=H())===je){if(f=v.isBrace=!0,_=v.isGlob=!0,I=!0,s===!0)continue;break}if(S!==!0&&g===Hn){if(f=v.isBrace=!0,_=v.isGlob=!0,I=!0,s===!0)continue;break}if(g===kn&&(re--,re===0)){S=!1,f=v.isBrace=!0,I=!0;break}}if(s===!0)continue;break}if(g===Xt){if(i.push(m),a.push(v),v={value:"",depth:0,isGlob:!1},I===!0)continue;if(K===je&&m===h+1){h+=2;continue}R=m+1;continue}if(t.noext!==!0&&(g===Tn||g===vn||g===We||g===Wt||g===Fe)===!0&&l()===Xe){if(_=v.isGlob=!0,y=v.isExtglob=!0,I=!0,g===Fe&&m===h&&(z=!0),s===!0){for(;k()!==!0&&(g=H());){if(g===ye){T=v.backslashes=!0,g=H();continue}if(g===jt){_=v.isGlob=!0,I=!0;break}}continue}break}if(g===We){if(K===We&&(E=v.isGlobstar=!0),_=v.isGlob=!0,I=!0,s===!0)continue;break}if(g===Wt){if(_=v.isGlob=!0,I=!0,s===!0)continue;break}if(g===$n){for(;k()!==!0&&(M=H());){if(M===ye){T=v.backslashes=!0,H();continue}if(M===Ln){$=v.isBracket=!0,_=v.isGlob=!0,I=!0;break}}if(s===!0)continue;break}if(t.nonegate!==!0&&g===Fe&&m===h){L=v.negated=!0,h++;continue}if(t.noparen!==!0&&g===Xe){if(_=v.isGlob=!0,s===!0){for(;k()!==!0&&(g=H());){if(g===Xe){T=v.backslashes=!0,g=H();continue}if(g===jt){I=!0;break}}continue}break}if(_===!0){if(I=!0,s===!0)continue;break}}t.noext===!0&&(y=!1,_=!1);let w=p,B="",o="";h>0&&(B=p.slice(0,h),p=p.slice(h),R-=h),w&&_===!0&&R>0?(w=p.slice(0,R),o=p.slice(R)):_===!0?(w="",o=p):w=p,w&&w!==""&&w!=="/"&&w!==p&&Ft(w.charCodeAt(w.length-1))&&(w=w.slice(0,-1)),t.unescape===!0&&(o&&(o=Kt.removeBackslashes(o)),w&&T===!0&&(w=Kt.removeBackslashes(w)));let u={prefix:B,input:e,start:h,base:w,glob:o,isBrace:f,isBracket:$,isGlob:_,isExtglob:y,isGlobstar:E,negated:L,negatedExtglob:z};if(t.tokens===!0&&(u.maxDepth=0,Ft(g)||a.push(v),u.tokens=a),t.parts===!0||t.tokens===!0){let M;for(let b=0;b<i.length;b++){let V=M?M+1:h,J=i[b],Q=e.slice(V,J);t.tokens&&(b===0&&h!==0?(a[b].isPrefix=!0,a[b].value=B):a[b].value=Q,Qt(a[b]),u.maxDepth+=a[b].depth),(b!==0||Q!=="")&&c.push(Q),M=J}if(M&&M+1<e.length){let b=e.slice(M+1);c.push(b),t.tokens&&(a[a.length-1].value=b,Qt(a[a.length-1]),u.maxDepth+=a[a.length-1].depth)}u.slashes=i,u.parts=c}return u};Zt.exports=On});var er=q((ls,Jt)=>{"use strict";var ke=me(),Z=Re(),{MAX_LENGTH:Le,POSIX_REGEX_SOURCE:Nn,REGEX_NON_SPECIAL_CHARS:In,REGEX_SPECIAL_CHARS_BACKREF:Bn,REPLACEMENTS:zt}=ke,Mn=(e,r)=>{if(typeof r.expandRange=="function")return r.expandRange(...e,r);e.sort();let t=`[${e.join("-")}]`;try{new RegExp(t)}catch{return e.map(s=>Z.escapeRegex(s)).join("..")}return t},de=(e,r)=>`Missing ${e}: "${r}" - use "\\\\${r}" to match literal characters`,Vt=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");e=zt[e]||e;let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);let i={type:"bos",value:"",output:t.prepend||""},a=[i],c=t.capture?"":"?:",p=Z.isWindows(r),m=ke.globChars(p),h=ke.extglobChars(m),{DOT_LITERAL:R,PLUS_LITERAL:f,SLASH_LITERAL:$,ONE_CHAR:_,DOTS_SLASH:y,NO_DOT:E,NO_DOT_SLASH:S,NO_DOTS_SLASH:T,QMARK:L,QMARK_NO_DOT:z,STAR:I,START_ANCHOR:re}=m,K=A=>`(${c}(?:(?!${re}${A.dot?y:R}).)*?)`,g=t.dot?"":E,v=t.dot?L:z,k=t.bash===!0?K(t):I;t.capture&&(k=`(${k})`),typeof t.noext=="boolean"&&(t.noextglob=t.noext);let l={input:e,index:-1,start:0,dot:t.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:a};e=Z.removePrefix(e,l),s=e.length;let H=[],w=[],B=[],o=i,u,M=()=>l.index===s-1,b=l.peek=(A=1)=>e[l.index+A],V=l.advance=()=>e[++l.index]||"",J=()=>e.slice(l.index+1),Q=(A="",O=0)=>{l.consumed+=A,l.index+=O},Ee=A=>{l.output+=A.output!=null?A.output:A.value,Q(A.value)},Rr=()=>{let A=1;for(;b()==="!"&&(b(2)!=="("||b(3)==="?");)V(),l.start++,A++;return A%2===0?!1:(l.negated=!0,l.start++,!0)},be=A=>{l[A]++,B.push(A)},oe=A=>{l[A]--,B.pop()},C=A=>{if(o.type==="globstar"){let O=l.braces>0&&(A.type==="comma"||A.type==="brace"),d=A.extglob===!0||H.length&&(A.type==="pipe"||A.type==="paren");A.type!=="slash"&&A.type!=="paren"&&!O&&!d&&(l.output=l.output.slice(0,-o.output.length),o.type="star",o.value="*",o.output=k,l.output+=o.output)}if(H.length&&A.type!=="paren"&&(H[H.length-1].inner+=A.value),(A.value||A.output)&&Ee(A),o&&o.type==="text"&&A.type==="text"){o.value+=A.value,o.output=(o.output||"")+A.value;return}A.prev=o,a.push(A),o=A},xe=(A,O)=>{let d={...h[O],conditions:1,inner:""};d.prev=o,d.parens=l.parens,d.output=l.output;let x=(t.capture?"(":"")+d.open;be("parens"),C({type:A,value:O,output:l.output?"":_}),C({type:"paren",extglob:!0,value:V(),output:x}),H.push(d)},yr=A=>{let O=A.close+(t.capture?")":""),d;if(A.type==="negate"){let x=k;A.inner&&A.inner.length>1&&A.inner.includes("/")&&(x=K(t)),(x!==k||M()||/^\)+$/.test(J()))&&(O=A.close=`)$))${x}`),A.inner.includes("*")&&(d=J())&&/^\.[^\\/.]+$/.test(d)&&(O=A.close=`)${d})${x})`),A.prev.type==="bos"&&(l.negatedExtglob=!0)}C({type:"paren",extglob:!0,value:u,output:O}),oe("parens")};if(t.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(e)){let A=!1,O=e.replace(Bn,(d,x,P,j,G,Ie)=>j==="\\"?(A=!0,d):j==="?"?x?x+j+(G?L.repeat(G.length):""):Ie===0?v+(G?L.repeat(G.length):""):L.repeat(P.length):j==="."?R.repeat(P.length):j==="*"?x?x+j+(G?k:""):k:x?d:`\\${d}`);return A===!0&&(t.unescape===!0?O=O.replace(/\\/g,""):O=O.replace(/\\+/g,d=>d.length%2===0?"\\\\":d?"\\":"")),O===e&&t.contains===!0?(l.output=e,l):(l.output=Z.wrapOutput(O,l,r),l)}for(;!M();){if(u=V(),u==="\0")continue;if(u==="\\"){let d=b();if(d==="/"&&t.bash!==!0||d==="."||d===";")continue;if(!d){u+="\\",C({type:"text",value:u});continue}let x=/^\\+/.exec(J()),P=0;if(x&&x[0].length>2&&(P=x[0].length,l.index+=P,P%2!==0&&(u+="\\")),t.unescape===!0?u=V():u+=V(),l.brackets===0){C({type:"text",value:u});continue}}if(l.brackets>0&&(u!=="]"||o.value==="["||o.value==="[^")){if(t.posix!==!1&&u===":"){let d=o.value.slice(1);if(d.includes("[")&&(o.posix=!0,d.includes(":"))){let x=o.value.lastIndexOf("["),P=o.value.slice(0,x),j=o.value.slice(x+2),G=Nn[j];if(G){o.value=P+G,l.backtrack=!0,V(),!i.output&&a.indexOf(o)===1&&(i.output=_);continue}}}(u==="["&&b()!==":"||u==="-"&&b()==="]")&&(u=`\\${u}`),u==="]"&&(o.value==="["||o.value==="[^")&&(u=`\\${u}`),t.posix===!0&&u==="!"&&o.value==="["&&(u="^"),o.value+=u,Ee({value:u});continue}if(l.quotes===1&&u!=='"'){u=Z.escapeRegex(u),o.value+=u,Ee({value:u});continue}if(u==='"'){l.quotes=l.quotes===1?0:1,t.keepQuotes===!0&&C({type:"text",value:u});continue}if(u==="("){be("parens"),C({type:"paren",value:u});continue}if(u===")"){if(l.parens===0&&t.strictBrackets===!0)throw new SyntaxError(de("opening","("));let d=H[H.length-1];if(d&&l.parens===d.parens+1){yr(H.pop());continue}C({type:"paren",value:u,output:l.parens?")":"\\)"}),oe("parens");continue}if(u==="["){if(t.nobracket===!0||!J().includes("]")){if(t.nobracket!==!0&&t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));u=`\\${u}`}else be("brackets");C({type:"bracket",value:u});continue}if(u==="]"){if(t.nobracket===!0||o&&o.type==="bracket"&&o.value.length===1){C({type:"text",value:u,output:`\\${u}`});continue}if(l.brackets===0){if(t.strictBrackets===!0)throw new SyntaxError(de("opening","["));C({type:"text",value:u,output:`\\${u}`});continue}oe("brackets");let d=o.value.slice(1);if(o.posix!==!0&&d[0]==="^"&&!d.includes("/")&&(u=`/${u}`),o.value+=u,Ee({value:u}),t.literalBrackets===!1||Z.hasRegexChars(d))continue;let x=Z.escapeRegex(o.value);if(l.output=l.output.slice(0,-o.value.length),t.literalBrackets===!0){l.output+=x,o.value=x;continue}o.value=`(${c}${x}|${o.value})`,l.output+=o.value;continue}if(u==="{"&&t.nobrace!==!0){be("braces");let d={type:"brace",value:u,output:"(",outputIndex:l.output.length,tokensIndex:l.tokens.length};w.push(d),C(d);continue}if(u==="}"){let d=w[w.length-1];if(t.nobrace===!0||!d){C({type:"text",value:u,output:u});continue}let x=")";if(d.dots===!0){let P=a.slice(),j=[];for(let G=P.length-1;G>=0&&(a.pop(),P[G].type!=="brace");G--)P[G].type!=="dots"&&j.unshift(P[G].value);x=Mn(j,t),l.backtrack=!0}if(d.comma!==!0&&d.dots!==!0){let P=l.output.slice(0,d.outputIndex),j=l.tokens.slice(d.tokensIndex);d.value=d.output="\\{",u=x="\\}",l.output=P;for(let G of j)l.output+=G.output||G.value}C({type:"brace",value:u,output:x}),oe("braces"),w.pop();continue}if(u==="|"){H.length>0&&H[H.length-1].conditions++,C({type:"text",value:u});continue}if(u===","){let d=u,x=w[w.length-1];x&&B[B.length-1]==="braces"&&(x.comma=!0,d="|"),C({type:"comma",value:u,output:d});continue}if(u==="/"){if(o.type==="dot"&&l.index===l.start+1){l.start=l.index+1,l.consumed="",l.output="",a.pop(),o=i;continue}C({type:"slash",value:u,output:$});continue}if(u==="."){if(l.braces>0&&o.type==="dot"){o.value==="."&&(o.output=R);let d=w[w.length-1];o.type="dots",o.output+=u,o.value+=u,d.dots=!0;continue}if(l.braces+l.parens===0&&o.type!=="bos"&&o.type!=="slash"){C({type:"text",value:u,output:R});continue}C({type:"dot",value:u,output:R});continue}if(u==="?"){if(!(o&&o.value==="(")&&t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("qmark",u);continue}if(o&&o.type==="paren"){let x=b(),P=u;if(x==="<"&&!Z.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(o.value==="("&&!/[!=<:]/.test(x)||x==="<"&&!/<([!=]|\w+>)/.test(J()))&&(P=`\\${u}`),C({type:"text",value:u,output:P});continue}if(t.dot!==!0&&(o.type==="slash"||o.type==="bos")){C({type:"qmark",value:u,output:z});continue}C({type:"qmark",value:u,output:L});continue}if(u==="!"){if(t.noextglob!==!0&&b()==="("&&(b(2)!=="?"||!/[!=<:]/.test(b(3)))){xe("negate",u);continue}if(t.nonegate!==!0&&l.index===0){Rr();continue}}if(u==="+"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){xe("plus",u);continue}if(o&&o.value==="("||t.regex===!1){C({type:"plus",value:u,output:f});continue}if(o&&(o.type==="bracket"||o.type==="paren"||o.type==="brace")||l.parens>0){C({type:"plus",value:u});continue}C({type:"plus",value:f});continue}if(u==="@"){if(t.noextglob!==!0&&b()==="("&&b(2)!=="?"){C({type:"at",extglob:!0,value:u,output:""});continue}C({type:"text",value:u});continue}if(u!=="*"){(u==="$"||u==="^")&&(u=`\\${u}`);let d=In.exec(J());d&&(u+=d[0],l.index+=d[0].length),C({type:"text",value:u});continue}if(o&&(o.type==="globstar"||o.star===!0)){o.type="star",o.star=!0,o.value+=u,o.output=k,l.backtrack=!0,l.globstar=!0,Q(u);continue}let A=J();if(t.noextglob!==!0&&/^\([^?]/.test(A)){xe("star",u);continue}if(o.type==="star"){if(t.noglobstar===!0){Q(u);continue}let d=o.prev,x=d.prev,P=d.type==="slash"||d.type==="bos",j=x&&(x.type==="star"||x.type==="globstar");if(t.bash===!0&&(!P||A[0]&&A[0]!=="/")){C({type:"star",value:u,output:""});continue}let G=l.braces>0&&(d.type==="comma"||d.type==="brace"),Ie=H.length&&(d.type==="pipe"||d.type==="paren");if(!P&&d.type!=="paren"&&!G&&!Ie){C({type:"star",value:u,output:""});continue}for(;A.slice(0,3)==="/**";){let Ce=e[l.index+4];if(Ce&&Ce!=="/")break;A=A.slice(3),Q("/**",3)}if(d.type==="bos"&&M()){o.type="globstar",o.value+=u,o.output=K(t),l.output=o.output,l.globstar=!0,Q(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&!j&&M()){l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=K(t)+(t.strictSlashes?")":"|$)"),o.value+=u,l.globstar=!0,l.output+=d.output+o.output,Q(u);continue}if(d.type==="slash"&&d.prev.type!=="bos"&&A[0]==="/"){let Ce=A[1]!==void 0?"|$":"";l.output=l.output.slice(0,-(d.output+o.output).length),d.output=`(?:${d.output}`,o.type="globstar",o.output=`${K(t)}${$}|${$}${Ce})`,o.value+=u,l.output+=d.output+o.output,l.globstar=!0,Q(u+V()),C({type:"slash",value:"/",output:""});continue}if(d.type==="bos"&&A[0]==="/"){o.type="globstar",o.value+=u,o.output=`(?:^|${$}|${K(t)}${$})`,l.output=o.output,l.globstar=!0,Q(u+V()),C({type:"slash",value:"/",output:""});continue}l.output=l.output.slice(0,-o.output.length),o.type="globstar",o.output=K(t),o.value+=u,l.output+=o.output,l.globstar=!0,Q(u);continue}let O={type:"star",value:u,output:k};if(t.bash===!0){O.output=".*?",(o.type==="bos"||o.type==="slash")&&(O.output=g+O.output),C(O);continue}if(o&&(o.type==="bracket"||o.type==="paren")&&t.regex===!0){O.output=u,C(O);continue}(l.index===l.start||o.type==="slash"||o.type==="dot")&&(o.type==="dot"?(l.output+=S,o.output+=S):t.dot===!0?(l.output+=T,o.output+=T):(l.output+=g,o.output+=g),b()!=="*"&&(l.output+=_,o.output+=_)),C(O)}for(;l.brackets>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","]"));l.output=Z.escapeLast(l.output,"["),oe("brackets")}for(;l.parens>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing",")"));l.output=Z.escapeLast(l.output,"("),oe("parens")}for(;l.braces>0;){if(t.strictBrackets===!0)throw new SyntaxError(de("closing","}"));l.output=Z.escapeLast(l.output,"{"),oe("braces")}if(t.strictSlashes!==!0&&(o.type==="star"||o.type==="bracket")&&C({type:"maybe_slash",value:"",output:`${$}?`}),l.backtrack===!0){l.output="";for(let A of l.tokens)l.output+=A.output!=null?A.output:A.value,A.suffix&&(l.output+=A.suffix)}return l};Vt.fastpaths=(e,r)=>{let t={...r},n=typeof t.maxLength=="number"?Math.min(Le,t.maxLength):Le,s=e.length;if(s>n)throw new SyntaxError(`Input length: ${s}, exceeds maximum allowed length: ${n}`);e=zt[e]||e;let i=Z.isWindows(r),{DOT_LITERAL:a,SLASH_LITERAL:c,ONE_CHAR:p,DOTS_SLASH:m,NO_DOT:h,NO_DOTS:R,NO_DOTS_SLASH:f,STAR:$,START_ANCHOR:_}=ke.globChars(i),y=t.dot?R:h,E=t.dot?f:h,S=t.capture?"":"?:",T={negated:!1,prefix:""},L=t.bash===!0?".*?":$;t.capture&&(L=`(${L})`);let z=g=>g.noglobstar===!0?L:`(${S}(?:(?!${_}${g.dot?m:a}).)*?)`,I=g=>{switch(g){case"*":return`${y}${p}${L}`;case".*":return`${a}${p}${L}`;case"*.*":return`${y}${L}${a}${p}${L}`;case"*/*":return`${y}${L}${c}${p}${E}${L}`;case"**":return y+z(t);case"**/*":return`(?:${y}${z(t)}${c})?${E}${p}${L}`;case"**/*.*":return`(?:${y}${z(t)}${c})?${E}${L}${a}${p}${L}`;case"**/.*":return`(?:${y}${z(t)}${c})?${a}${p}${L}`;default:{let v=/^(.*?)\.(\w+)$/.exec(g);if(!v)return;let k=I(v[1]);return k?k+a+v[2]:void 0}}},re=Z.removePrefix(e,T),K=I(re);return K&&t.strictSlashes!==!0&&(K+=`${c}?`),K};Jt.exports=Vt});var rr=q((fs,tr)=>{"use strict";var Pn=W("path"),Dn=Yt(),Ze=er(),Ye=Re(),Un=me(),Gn=e=>e&&typeof e=="object"&&!Array.isArray(e),D=(e,r,t=!1)=>{if(Array.isArray(e)){let h=e.map(f=>D(f,r,t));return f=>{for(let $ of h){let _=$(f);if(_)return _}return!1}}let n=Gn(e)&&e.tokens&&e.input;if(e===""||typeof e!="string"&&!n)throw new TypeError("Expected pattern to be a non-empty string");let s=r||{},i=Ye.isWindows(r),a=n?D.compileRe(e,r):D.makeRe(e,r,!1,!0),c=a.state;delete a.state;let p=()=>!1;if(s.ignore){let h={...r,ignore:null,onMatch:null,onResult:null};p=D(s.ignore,h,t)}let m=(h,R=!1)=>{let{isMatch:f,match:$,output:_}=D.test(h,a,r,{glob:e,posix:i}),y={glob:e,state:c,regex:a,posix:i,input:h,output:_,match:$,isMatch:f};return typeof s.onResult=="function"&&s.onResult(y),f===!1?(y.isMatch=!1,R?y:!1):p(h)?(typeof s.onIgnore=="function"&&s.onIgnore(y),y.isMatch=!1,R?y:!1):(typeof s.onMatch=="function"&&s.onMatch(y),R?y:!0)};return t&&(m.state=c),m};D.test=(e,r,t,{glob:n,posix:s}={})=>{if(typeof e!="string")throw new TypeError("Expected input to be a string");if(e==="")return{isMatch:!1,output:""};let i=t||{},a=i.format||(s?Ye.toPosixSlashes:null),c=e===n,p=c&&a?a(e):e;return c===!1&&(p=a?a(e):e,c=p===n),(c===!1||i.capture===!0)&&(i.matchBase===!0||i.basename===!0?c=D.matchBase(e,r,t,s):c=r.exec(p)),{isMatch:Boolean(c),match:c,output:p}};D.matchBase=(e,r,t,n=Ye.isWindows(t))=>(r instanceof RegExp?r:D.makeRe(r,t)).test(Pn.basename(e));D.isMatch=(e,r,t)=>D(r,t)(e);D.parse=(e,r)=>Array.isArray(e)?e.map(t=>D.parse(t,r)):Ze(e,{...r,fastpaths:!1});D.scan=(e,r)=>Dn(e,r);D.compileRe=(e,r,t=!1,n=!1)=>{if(t===!0)return e.output;let s=r||{},i=s.contains?"":"^",a=s.contains?"":"$",c=`${i}(?:${e.output})${a}`;e&&e.negated===!0&&(c=`^(?!${c}).*$`);let p=D.toRegex(c,r);return n===!0&&(p.state=e),p};D.makeRe=(e,r={},t=!1,n=!1)=>{if(!e||typeof e!="string")throw new TypeError("Expected a non-empty string");let s={negated:!1,fastpaths:!0};return r.fastpaths!==!1&&(e[0]==="."||e[0]==="*")&&(s.output=Ze.fastpaths(e,r)),s.output||(s=Ze(e,r)),D.compileRe(s,r,t,n)};D.toRegex=(e,r)=>{try{let t=r||{};return new RegExp(e,t.flags||(t.nocase?"i":""))}catch(t){if(r&&r.debug===!0)throw t;return/$^/}};D.constants=Un;tr.exports=D});var sr=q((ps,nr)=>{"use strict";nr.exports=rr()});var cr=q((hs,ur)=>{"use strict";var ir=W("util"),or=Mt(),ae=sr(),ze=Re(),ar=e=>e===""||e==="./",N=(e,r,t)=>{r=[].concat(r),e=[].concat(e);let n=new Set,s=new Set,i=new Set,a=0,c=h=>{i.add(h.output),t&&t.onResult&&t.onResult(h)};for(let h=0;h<r.length;h++){let R=ae(String(r[h]),{...t,onResult:c},!0),f=R.state.negated||R.state.negatedExtglob;f&&a++;for(let $ of e){let _=R($,!0);!(f?!_.isMatch:_.isMatch)||(f?n.add(_.output):(n.delete(_.output),s.add(_.output)))}}let m=(a===r.length?[...i]:[...s]).filter(h=>!n.has(h));if(t&&m.length===0){if(t.failglob===!0)throw new Error(`No matches found for "${r.join(", ")}"`);if(t.nonull===!0||t.nullglob===!0)return t.unescape?r.map(h=>h.replace(/\\/g,"")):r}return m};N.match=N;N.matcher=(e,r)=>ae(e,r);N.isMatch=(e,r,t)=>ae(r,t)(e);N.any=N.isMatch;N.not=(e,r,t={})=>{r=[].concat(r).map(String);let n=new Set,s=[],a=N(e,r,{...t,onResult:c=>{t.onResult&&t.onResult(c),s.push(c.output)}});for(let c of s)a.includes(c)||n.add(c);return[...n]};N.contains=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);if(Array.isArray(r))return r.some(n=>N.contains(e,n,t));if(typeof r=="string"){if(ar(e)||ar(r))return!1;if(e.includes(r)||e.startsWith("./")&&e.slice(2).includes(r))return!0}return N.isMatch(e,r,{...t,contains:!0})};N.matchKeys=(e,r,t)=>{if(!ze.isObject(e))throw new TypeError("Expected the first argument to be an object");let n=N(Object.keys(e),r,t),s={};for(let i of n)s[i]=e[i];return s};N.some=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(n.some(a=>i(a)))return!0}return!1};N.every=(e,r,t)=>{let n=[].concat(e);for(let s of[].concat(r)){let i=ae(String(s),t);if(!n.every(a=>i(a)))return!1}return!0};N.all=(e,r,t)=>{if(typeof e!="string")throw new TypeError(`Expected a string: "${ir.inspect(e)}"`);return[].concat(r).every(n=>ae(n,t)(e))};N.capture=(e,r,t)=>{let n=ze.isWindows(t),i=ae.makeRe(String(e),{...t,capture:!0}).exec(n?ze.toPosixSlashes(r):r);if(i)return i.slice(1).map(a=>a===void 0?"":a)};N.makeRe=(...e)=>ae.makeRe(...e);N.scan=(...e)=>ae.scan(...e);N.parse=(e,r)=>{let t=[];for(let n of[].concat(e||[]))for(let s of or(String(n),r))t.push(ae.parse(s,r));return t};N.braces=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return r&&r.nobrace===!0||!/\{.*\}/.test(e)?[e]:or(e,r)};N.braceExpand=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a string");return N.braces(e,{...r,expand:!0})};ur.exports=N});var fr=q((ds,lr)=>{"use strict";lr.exports=(e,...r)=>new Promise(t=>{t(e(...r))})});var hr=q((gs,Ve)=>{"use strict";var qn=fr(),pr=e=>{if(e<1)throw new TypeError("Expected `concurrency` to be a number from 1 and up");let r=[],t=0,n=()=>{t--,r.length>0&&r.shift()()},s=(c,p,...m)=>{t++;let h=qn(c,...m);p(h),h.then(n,n)},i=(c,p,...m)=>{t<e?s(c,p,...m):r.push(s.bind(null,c,p,...m))},a=(c,...p)=>new Promise(m=>i(c,m,...p));return Object.defineProperties(a,{activeCount:{get:()=>t},pendingCount:{get:()=>r.length}}),a};Ve.exports=pr;Ve.exports.default=pr});var Fn={};wr(Fn,{default:()=>jn});var Se=W("@yarnpkg/cli"),ne=W("@yarnpkg/core"),et=W("@yarnpkg/core"),ue=W("clipanion"),ce=class extends Se.BaseCommand{constructor(){super(...arguments);this.json=ue.Option.Boolean("--json",!1,{description:"Format the output as an NDJSON stream"});this.production=ue.Option.Boolean("--production",!1,{description:"Only install regular dependencies by omitting dev dependencies"});this.all=ue.Option.Boolean("-A,--all",!1,{description:"Install the entire project"});this.workspaces=ue.Option.Rest()}async execute(){let t=await ne.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ne.Project.find(t,this.context.cwd),i=await ne.Cache.find(t);await n.restoreInstallState({restoreResolutions:!1});let a;if(this.all)a=new Set(n.workspaces);else if(this.workspaces.length===0){if(!s)throw new Se.WorkspaceRequiredError(n.cwd,this.context.cwd);a=new Set([s])}else a=new Set(this.workspaces.map(p=>n.getWorkspaceByIdent(et.structUtils.parseIdent(p))));for(let p of a)for(let m of this.production?["dependencies"]:ne.Manifest.hardDependencies)for(let h of p.manifest.getForScope(m).values()){let R=n.tryWorkspaceByDescriptor(h);R!==null&&a.add(R)}for(let p of n.workspaces)a.has(p)?this.production&&p.manifest.devDependencies.clear():(p.manifest.installConfig=p.manifest.installConfig||{},p.manifest.installConfig.selfReferences=!1,p.manifest.dependencies.clear(),p.manifest.devDependencies.clear(),p.manifest.peerDependencies.clear(),p.manifest.scripts.clear());return(await ne.StreamReport.start({configuration:t,json:this.json,stdout:this.context.stdout,includeLogs:!0},async p=>{await n.install({cache:i,report:p,persistProject:!1})})).exitCode()}};ce.paths=[["workspaces","focus"]],ce.usage=ue.Command.Usage({category:"Workspace-related commands",description:"install a single workspace and its dependencies",details:"\n This command will run an install as if the specified workspaces (and all other workspaces they depend on) were the only ones in the project. If no workspaces are explicitly listed, the active one will be assumed.\n\n Note that this command is only very moderately useful when using zero-installs, since the cache will contain all the packages anyway - meaning that the only difference between a full install and a focused install would just be a few extra lines in the `.pnp.cjs` file, at the cost of introducing an extra complexity.\n\n If the `-A,--all` flag is set, the entire project will be installed. Combine with `--production` to replicate the old `yarn install --production`.\n "});var Ne=W("@yarnpkg/cli"),ge=W("@yarnpkg/core"),_e=W("@yarnpkg/core"),Y=W("@yarnpkg/core"),gr=W("@yarnpkg/plugin-git"),U=W("clipanion"),Oe=Be(cr()),Ar=W("os"),mr=Be(hr()),te=Be(W("typanion")),pe=class extends Ne.BaseCommand{constructor(){super(...arguments);this.recursive=U.Option.Boolean("-R,--recursive",!1,{description:"Find packages via dependencies/devDependencies instead of using the workspaces field"});this.from=U.Option.Array("--from",[],{description:"An array of glob pattern idents from which to base any recursion"});this.all=U.Option.Boolean("-A,--all",!1,{description:"Run the command on all workspaces of a project"});this.verbose=U.Option.Boolean("-v,--verbose",!1,{description:"Prefix each output line with the name of the originating workspace"});this.parallel=U.Option.Boolean("-p,--parallel",!1,{description:"Run the commands in parallel"});this.interlaced=U.Option.Boolean("-i,--interlaced",!1,{description:"Print the output of commands in real-time instead of buffering it"});this.jobs=U.Option.String("-j,--jobs",{description:"The maximum number of parallel tasks that the execution will be limited to; or `unlimited`",validator:te.isOneOf([te.isEnum(["unlimited"]),te.applyCascade(te.isNumber(),[te.isInteger(),te.isAtLeast(1)])])});this.topological=U.Option.Boolean("-t,--topological",!1,{description:"Run the command after all workspaces it depends on (regular) have finished"});this.topologicalDev=U.Option.Boolean("--topological-dev",!1,{description:"Run the command after all workspaces it depends on (regular + dev) have finished"});this.include=U.Option.Array("--include",[],{description:"An array of glob pattern idents; only matching workspaces will be traversed"});this.exclude=U.Option.Array("--exclude",[],{description:"An array of glob pattern idents; matching workspaces won't be traversed"});this.publicOnly=U.Option.Boolean("--no-private",{description:"Avoid running the command on private workspaces"});this.since=U.Option.String("--since",{description:"Only include workspaces that have been changed since the specified ref.",tolerateBoolean:!0});this.commandName=U.Option.String();this.args=U.Option.Proxy()}async execute(){let t=await ge.Configuration.find(this.context.cwd,this.context.plugins),{project:n,workspace:s}=await ge.Project.find(t,this.context.cwd);if(!this.all&&!s)throw new Ne.WorkspaceRequiredError(n.cwd,this.context.cwd);await n.restoreInstallState();let i=this.cli.process([this.commandName,...this.args]),a=i.path.length===1&&i.path[0]==="run"&&typeof i.scriptName<"u"?i.scriptName:null;if(i.path.length===0)throw new U.UsageError("Invalid subcommand name for iteration - use the 'run' keyword if you wish to execute a script");let c=this.all?n.topLevelWorkspace:s,p=this.since?Array.from(await gr.gitUtils.fetchChangedWorkspaces({ref:this.since,project:n})):[c,...this.from.length>0?c.getRecursiveWorkspaceChildren():[]],m=g=>Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.from),h=this.from.length>0?p.filter(m):p,R=new Set([...h,...h.map(g=>[...this.recursive?this.since?g.getRecursiveWorkspaceDependents():g.getRecursiveWorkspaceDependencies():g.getRecursiveWorkspaceChildren()]).flat()]),f=[],$=!1;if(a!=null&&a.includes(":")){for(let g of n.workspaces)if(g.manifest.scripts.has(a)&&($=!$,$===!1))break}for(let g of R)a&&!g.manifest.scripts.has(a)&&!$&&!(await ge.scriptUtils.getWorkspaceAccessibleBinaries(g)).has(a)||a===process.env.npm_lifecycle_event&&g.cwd===s.cwd||this.include.length>0&&!Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.include)||this.exclude.length>0&&Oe.default.isMatch(Y.structUtils.stringifyIdent(g.locator),this.exclude)||this.publicOnly&&g.manifest.private===!0||f.push(g);let _=this.parallel?this.jobs==="unlimited"?1/0:Number(this.jobs)||Math.max(1,(0,Ar.cpus)().length/2):1,y=_===1?!1:this.parallel,E=y?this.interlaced:!0,S=(0,mr.default)(_),T=new Map,L=new Set,z=0,I=null,re=!1,K=await _e.StreamReport.start({configuration:t,stdout:this.context.stdout},async g=>{let v=async(k,{commandIndex:l})=>{if(re)return-1;!y&&this.verbose&&l>1&&g.reportSeparator();let H=Kn(k,{configuration:t,verbose:this.verbose,commandIndex:l}),[w,B]=dr(g,{prefix:H,interlaced:E}),[o,u]=dr(g,{prefix:H,interlaced:E});try{this.verbose&&g.reportInfo(null,`${H} Process started`);let M=Date.now(),b=await this.cli.run([this.commandName,...this.args],{cwd:k.cwd,stdout:w,stderr:o})||0;w.end(),o.end(),await B,await u;let V=Date.now();if(this.verbose){let J=t.get("enableTimers")?`, completed in ${Y.formatUtils.pretty(t,V-M,Y.formatUtils.Type.DURATION)}`:"";g.reportInfo(null,`${H} Process exited (exit code ${b})${J}`)}return b===130&&(re=!0,I=b),b}catch(M){throw w.end(),o.end(),await B,await u,M}};for(let k of f)T.set(k.anchoredLocator.locatorHash,k);for(;T.size>0&&!g.hasErrors();){let k=[];for(let[w,B]of T){if(L.has(B.anchoredDescriptor.descriptorHash))continue;let o=!0;if(this.topological||this.topologicalDev){let u=this.topologicalDev?new Map([...B.manifest.dependencies,...B.manifest.devDependencies]):B.manifest.dependencies;for(let M of u.values()){let b=n.tryWorkspaceByDescriptor(M);if(o=b===null||!T.has(b.anchoredLocator.locatorHash),!o)break}}if(!!o&&(L.add(B.anchoredDescriptor.descriptorHash),k.push(S(async()=>{let u=await v(B,{commandIndex:++z});return T.delete(w),L.delete(B.anchoredDescriptor.descriptorHash),u})),!y))break}if(k.length===0){let w=Array.from(T.values()).map(B=>Y.structUtils.prettyLocator(t,B.anchoredLocator)).join(", ");g.reportError(_e.MessageName.CYCLIC_DEPENDENCIES,`Dependency cycle detected (${w})`);return}let H=(await Promise.all(k)).find(w=>w!==0);I===null&&(I=typeof H<"u"?1:I),(this.topological||this.topologicalDev)&&typeof H<"u"&&g.reportError(_e.MessageName.UNNAMED,"The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph")}});return I!==null?I:K.exitCode()}};pe.paths=[["workspaces","foreach"]],pe.usage=U.Command.Usage({category:"Workspace-related commands",description:"run a command on all workspaces",details:"\n This command will run a given sub-command on current and all its descendant workspaces. Various flags can alter the exact behavior of the command:\n\n - If `-p,--parallel` is set, the commands will be ran in parallel; they'll by default be limited to a number of parallel tasks roughly equal to half your core number, but that can be overridden via `-j,--jobs`, or disabled by setting `-j unlimited`.\n\n - If `-p,--parallel` and `-i,--interlaced` are both set, Yarn will print the lines from the output as it receives them. If `-i,--interlaced` wasn't set, it would instead buffer the output from each process and print the resulting buffers only after their source processes have exited.\n\n - If `-t,--topological` is set, Yarn will only run the command after all workspaces that it depends on through the `dependencies` field have successfully finished executing. If `--topological-dev` is set, both the `dependencies` and `devDependencies` fields will be considered when figuring out the wait points.\n\n - If `-A,--all` is set, Yarn will run the command on all the workspaces of a project. By default yarn runs the command only on current and all its descendant workspaces.\n\n - If `-R,--recursive` is set, Yarn will find workspaces to run the command on by recursively evaluating `dependencies` and `devDependencies` fields, instead of looking at the `workspaces` fields.\n\n - If `--from` is set, Yarn will use the packages matching the 'from' glob as the starting point for any recursive search.\n\n - If `--since` is set, Yarn will only run the command on workspaces that have been modified since the specified ref. By default Yarn will use the refs specified by the `changesetBaseRefs` configuration option.\n\n - The command may apply to only some workspaces through the use of `--include` which acts as a whitelist. The `--exclude` flag will do the opposite and will be a list of packages that mustn't execute the script. Both flags accept glob patterns (if valid Idents and supported by [micromatch](https://github.com/micromatch/micromatch)). Make sure to escape the patterns, to prevent your own shell from trying to expand them.\n\n Adding the `-v,--verbose` flag will cause Yarn to print more information; in particular the name of the workspace that generated the output will be printed at the front of each line.\n\n If the command is `run` and the script being run does not exist the child workspace will be skipped without error.\n ",examples:[["Publish current and all descendant packages","yarn workspaces foreach npm publish --tolerate-republish"],["Run build script on current and all descendant packages","yarn workspaces foreach run build"],["Run build script on current and all descendant packages in parallel, building package dependencies first","yarn workspaces foreach -pt run build"],["Run build script on several packages and all their dependencies, building dependencies first","yarn workspaces foreach -ptR --from '{workspace-a,workspace-b}' run build"]]});function dr(e,{prefix:r,interlaced:t}){let n=e.createStreamReporter(r),s=new Y.miscUtils.DefaultStream;s.pipe(n,{end:!1}),s.on("finish",()=>{n.end()});let i=new Promise(c=>{n.on("finish",()=>{c(s.active)})});if(t)return[s,i];let a=new Y.miscUtils.BufferStream;return a.pipe(s,{end:!1}),a.on("finish",()=>{s.end()}),[a,i]}function Kn(e,{configuration:r,commandIndex:t,verbose:n}){if(!n)return null;let i=`[${Y.structUtils.stringifyIdent(e.locator)}]:`,a=["#2E86AB","#A23B72","#F18F01","#C73E1D","#CCE2A3"],c=a[t%a.length];return Y.formatUtils.pretty(r,i,c)}var Wn={commands:[ce,pe]},jn=Wn;return Sr(Fn);})();
|
8 |
-
/*!
|
9 |
-
* fill-range <https://github.com/jonschlinkert/fill-range>
|
10 |
-
*
|
11 |
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
12 |
-
* Licensed under the MIT License.
|
13 |
-
*/
|
14 |
-
/*!
|
15 |
-
* is-number <https://github.com/jonschlinkert/is-number>
|
16 |
-
*
|
17 |
-
* Copyright (c) 2014-present, Jon Schlinkert.
|
18 |
-
* Released under the MIT License.
|
19 |
-
*/
|
20 |
-
/*!
|
21 |
-
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
22 |
-
*
|
23 |
-
* Copyright (c) 2015-present, Jon Schlinkert.
|
24 |
-
* Released under the MIT License.
|
25 |
-
*/
|
26 |
-
return plugin;
|
27 |
-
}
|
28 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.yarn/releases/yarn-3.3.1.cjs
DELETED
The diff for this file is too large to render.
See raw diff
|
|
.yarnrc.yml
DELETED
@@ -1,11 +0,0 @@
|
|
1 |
-
nodeLinker: node-modules
|
2 |
-
|
3 |
-
plugins:
|
4 |
-
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
5 |
-
spec: "@yarnpkg/plugin-interactive-tools"
|
6 |
-
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
|
7 |
-
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"
|
8 |
-
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
9 |
-
spec: "@yarnpkg/plugin-workspace-tools"
|
10 |
-
|
11 |
-
yarnPath: .yarn/releases/yarn-3.3.1.cjs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CLA.md
DELETED
@@ -1,110 +0,0 @@
|
|
1 |
-
|
2 |
-
# Contributor Assignment and License Grant
|
3 |
-
|
4 |
-
### Introduction
|
5 |
-
|
6 |
-
This Contributor Assignment and License Grant("Agreement") outlines the terms under which Contributions may be made by the Contributor (“You” or “Your”)and MERCENARIES.AI PTE. LTD. (“Mercenaries” or "mercenaries.ai").
|
7 |
-
|
8 |
-
### Scope
|
9 |
-
|
10 |
-
This Agreement exclusively governs Contributions made to the Core Product and Core Extensions associated with Omnitool.ai. Contributions will be made publicly available under the terms of the GNU Affero General Public License version 3 (AGPLv3), as detailed in the LICENSE.md file. A commercial license option from mercenaries.ai is anticipated to be made available under a dual-licensing model.
|
11 |
-
|
12 |
-
**Please note that this Agreement does not apply to Non-Core Extensions, which are governed by their separate terms and conditions as specified in the respective extensions or projects.**
|
13 |
-
|
14 |
-
## DEFINITIONS
|
15 |
-
|
16 |
-
**Mercenaries** or **mercenaries.ai** or **MERCENARIES.AI PTE. LTD.**: Refers to the entity managing this Agreement and the Core Product, including its successors, assigns, and affiliates. For this Agreement, successors and assigns shall include, but not be limited to, any corporate entity that acquires all or substantially all of the assets or business of mercenaries.ai, any corporate entity into which mercenaries.ai may be merged or consolidated, and any corporate entity under common control with mercenaries.ai. Additionally, this definition encompasses any entity or organization, for-profit or non-profit, to which mercenaries.ai transfers its rights and obligations under this Agreement.
|
17 |
-
Omnitool.ai refers to the software project managed, owned, or operated by mercenaries.ai with genesis in the current repository found at `github.com/omnitool-ai`, irrespective of any future branding, trademark changes, or repository locations.
|
18 |
-
|
19 |
-
**"Core Product"** is defined as the code and assets integral to the functionality, operability, or user experience of Omnitool.ai, as identified by mercenaries.ai as “Core” in official documentation, repositories, or other authoritative communications. This encompasses, but is not limited to, source code, binary code, associated libraries, data sets, APIs, documentation, user interfaces, graphics, designs, algorithms, and other components. The Core Product includes updates, upgrades, patches, revisions, and associated intellectual property rights.
|
20 |
-
|
21 |
-
**“Core Extensions”** are any extension, plugin, or add-on integral to the functionality, operability, or user experience of Omnitool.ai, as identified by mercenaries.ai as “Core” in official documentation, repositories, or other authoritative communications. This encompasses, but is not limited to, source code, binary code, associated libraries, data sets, APIs, documentation, user interfaces, graphics, designs, algorithms, and other components. Core Extensions include updates, upgrades, patches, revisions, and associated intellectual property rights.
|
22 |
-
For this Agreement, "integral" refers to any components, features, or elements essential for the basic functioning or usability of Omnitool.ai as reasonably determined by mercenaries.ai.
|
23 |
-
|
24 |
-
**Non-Core Extensions**: Refers to any extensions, plugins, or add-ons developed or managed by third parties that are not integral to the basic functionality, operability, or user experience of Omnitool.ai. Non-Core Extensions are subject to licensing and contributor terms specified by those individual projects or extensions.
|
25 |
-
|
26 |
-
**Contributor**, You, Your: The individual or entity contributing to the Core Product or Core Extensions as defined herein.
|
27 |
-
Contributions: Any modifications, enhancements, algorithms, data sets, ideas, feedback, or additions related to the Core Product or Core Extensions that you Submit to Omnitool.ai. This encompasses source code, binary code, documentation, design elements, algorithms, feature requests, issue reports, and any other materials or intellectual property that can be used to improve, expand, or maintain the Core Product or Core Extensions.
|
28 |
-
Submit: Any act of transmitting, sharing, or otherwise making available Contributions to Omnitool.ai, whether through pull requests, merge requests, issue tracking systems, emails, code, repositories, data sets, documentation, or any other communication channels or platforms recognized by mercenaries.ai for such purposes.
|
29 |
-
|
30 |
-
**Effective Date**: The date You execute this Agreement or the date You first Submit a Contribution to Us, whichever is earlier. This is the date this Agreement takes legal effect.
|
31 |
-
|
32 |
-
## TERMS
|
33 |
-
|
34 |
-
### Copyright Assignment and Patent License Grant
|
35 |
-
|
36 |
-
mercenaries.ai manages the Core Product and Core Extensions for this project under a dual licensing model, incorporating the AGPL for the open-source license while leaving open the option for future commercial licensing. This approach aims to foster innovation and adoption within open-source and corporate communities. We incorporate a copyright transfer from contributors, coupled with a 'License Back' provision, to achieve these objectives while ensuring that You retain the flexibility to utilize Your Contributions in any manner You deem appropriate.
|
37 |
-
|
38 |
-
- **Copyright Assignment**
|
39 |
-
You hereby irrevocably assign, transfer, and convey to mercenaries.ai all rights, title, and interests in and to Your Contributions, including all copyrights and copyrightable materials therein, all moral and neighboring rights worldwide and beyond, in perpetuity. This assignment includes the right to initiate legal action for past or future infringement, misappropriation, or violation of these rights. Moral Rights remain unaffected to the extent they are recognized and not waivable by applicable law.
|
40 |
-
|
41 |
-
- **Patent License**
|
42 |
-
You hereby grant to mercenaries.ai a perpetual, worldwide, non-exclusive, no-charge, royalty-free, sublicensable license under any patents owned or controlled by You to make, have made, use, offer to sell, sell, import, and otherwise transfer Your Contributions and any derivative works thereof. mercenaries.ai is entitled to sublicense any patent rights to Your Contributions under the same licensing terms as the Core Product.
|
43 |
-
You reserve the right to revoke the patent license granted in this Section if mercenaries.ai initiates any patent infringement claims targeted explicitly at your Contributions and not asserted for a Defensive Purpose. For this Agreement, an assertion of patent claims shall be deemed for a 'Defensive Purpose' if such claims are asserted against an entity that has filed, maintained, threatened, or voluntarily participated in a patent infringement lawsuit against mercenaries.ai or any of its licensees.
|
44 |
-
|
45 |
-
- **License Back**
|
46 |
-
Notwithstanding the foregoing assignment of rights, title, and interests, mercenaries.ai hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, sublicensable license under any intellectual property rights covering Your Contributions to make, have made, use, offer to sell, sell, import, and otherwise transfer Your Contributions and derivative works thereof. This license back does not extend to the Core Product, Core Extensions, or other third-party contributions.
|
47 |
-
|
48 |
-
### Use of Contributions
|
49 |
-
|
50 |
-
You acknowledge that mercenaries.ai is not obligated to use Your Contributions.
|
51 |
-
|
52 |
-
### Contributor Warranties
|
53 |
-
|
54 |
-
You warrant that:
|
55 |
-
- You have the legal authority to enter into this Agreement,
|
56 |
-
- You are the author of and have the legal right to make the Contributions,
|
57 |
-
- Your Contributions do not violate any laws, and
|
58 |
-
- Your Contributions do not infringe upon any third party intellectual property rights.
|
59 |
-
You agree to indemnify, defend, and hold harmless mercenaries.ai and its directors, officers, employees, and agents from and against any claims, damages, losses, liabilities, costs, and expenses, including reasonable attorney's fees, arising out of or in connection with any breach by You of Your warranties as outlined in this Agreement.
|
60 |
-
|
61 |
-
### Third-Party Rights
|
62 |
-
|
63 |
-
You shall provide documentation that lists all third-party assets, all respective licenses as part of any Contribution.
|
64 |
-
|
65 |
-
### Intellectual Property Notification
|
66 |
-
|
67 |
-
Should You become aware of any intellectual property rights that the existing Core Product or any Core Extensions infringes upon, you must promptly notify mercenaries.ai in writing.
|
68 |
-
|
69 |
-
### Employment and Other Agreements
|
70 |
-
|
71 |
-
You affirm that Your Contributions to the Core Product and any Core Extensions do not conflict with employment or other contractual obligations.
|
72 |
-
|
73 |
-
### Disclaimer of Warranty
|
74 |
-
|
75 |
-
Except for the representations and other obligations herein, Your Contributions are provided "as is" without warranty, either express or implied.
|
76 |
-
|
77 |
-
### Limitation of Liability
|
78 |
-
|
79 |
-
Except as explicitly provided herein, You shall not be liable for any claims, damages, or other liability arising from using Your Contributions.
|
80 |
-
|
81 |
-
### Consequential Damage Waiver
|
82 |
-
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT WILL EITHER PARTY BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF ANTICIPATED SAVINGS, LOSS OF DATA, INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL AND EXEMPLARY DAMAGES ARISING OUT OF THIS AGREEMENT REGARDLESS OF THE LEGAL OR EQUITABLE THEORY (CONTRACT, TORT OR OTHERWISE) UPON WHICH THE CLAIM IS BASED.
|
83 |
-
|
84 |
-
### Assignment
|
85 |
-
|
86 |
-
Mercenaries may, at its option, assign the rights or obligations received through this Agreement to a third party provided that the third party agrees in writing to abide by all the rights and obligations in the Agreement.
|
87 |
-
|
88 |
-
### Forking Clause
|
89 |
-
|
90 |
-
This Agreement and all its terms, including but not limited to the assignment of copyrights and patent licenses, shall extend to any fork of the original Omnitool.ai repository that is managed, owned, or operated by mercenaries.ai or its successors, assigns, and affiliates. Contributions to such forked repositories shall be treated as Contributions to the original Omnitool.ai project for this Agreement. Contributors to any such fork acknowledge and agree that their Contributions to the fork are subject to all terms and conditions of this Agreement.
|
91 |
-
This Agreement does not extend to forks to Omnitool.ai that are not managed, owned, or operated by mercenaries.ai or its successors, assigns, and affiliates. Contributions to such third-party forks are not subject to this Agreement, and individuals making Contributions to those forks do so at their own risk unless otherwise agreed upon in writing by mercenaries.ai.
|
92 |
-
Contributions previously made to forks not managed, owned, or operated by mercenaries.ai or its successors, assigns, and affiliates must be identified and approved by mercenaries.ai before submission or as part of the submission to Omnitool.ai.
|
93 |
-
|
94 |
-
### Execution of Documents
|
95 |
-
|
96 |
-
You agree to execute any additional documents necessary to effectuate the purpose of this Agreement at mercenaries.ai's request.
|
97 |
-
|
98 |
-
### Governing Law and Jurisdiction
|
99 |
-
|
100 |
-
- **Claims Made Against mercenaries.ai.** This Agreement is governed by the laws of Singapore, without regard to its conflict of laws principles. Any disputes, controversies, or differences (each instance being a “Dispute”) brought against mercenaries.ai, including any question regarding its existence, validity, or termination, will be settled amicably by the parties wherever practicable. Any Dispute brought against mercenaries.ai that cannot be resolved will be referred to and finally resolved by arbitration administered by the Singapore International Arbitration Centre (“SIAC”) under the Arbitration Rules of the Singapore International Arbitration Centre (“SIAC Rules”) for the time being in force, which rules are deemed to be incorporated by reference in this clause. The governing law of the arbitration will be Singapore law. The seat of the arbitration for Disputes brought against mercenaries.ai will be Singapore. The venue of the arbitration will be Singapore or any other location (including by teleconference or videoconference) otherwise agreed between the Tribunal and the Parties. The Tribunal will consist of 1 arbitrator, to be appointed by the President of the Court of Arbitration of the SIAC. The language of the arbitration will be English.
|
101 |
-
- **Claims Made by mercenaries.ai.** "For claims initiated by mercenaries.ai against You, mercenaries.ai reserves the right to determine the forum for dispute resolution. mercenaries.ai may either (a) initiate legal proceedings in the jurisdiction where You are domiciled or conduct business or (b) pursue arbitration in Singapore at its sole discretion. Should mercenaries.ai choose to initiate legal proceedings in a jurisdiction where You are domiciled or conduct business, mercenaries.ai further reserves the right to elect the governing law for such proceedings, choosing either Singaporean law or the law of the jurisdiction where You are domiciled or conduct business."
|
102 |
-
|
103 |
-
### Signatures
|
104 |
-
|
105 |
-
By affixing Your signatures below, both parties acknowledge Your acceptance of the terms of this Agreement.
|
106 |
-
> Contributor Signature:
|
107 |
-
Date:
|
108 |
-
|
109 |
-
> MERCENARIES.AI PTE. LTD. Signature:
|
110 |
-
Date:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CODE_OF_CONDUCT.md
DELETED
@@ -1,132 +0,0 @@
|
|
1 |
-
|
2 |
-
# Contributor Covenant Code of Conduct
|
3 |
-
|
4 |
-
## Our Pledge
|
5 |
-
|
6 |
-
We as members, contributors, and leaders pledge to make participation in our
|
7 |
-
community a harassment-free experience for everyone, regardless of age, body
|
8 |
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
9 |
-
identity and expression, level of experience, education, socio-economic status,
|
10 |
-
nationality, personal appearance, race, caste, color, religion, or sexual
|
11 |
-
identity and orientation.
|
12 |
-
|
13 |
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
14 |
-
diverse, inclusive, and healthy community.
|
15 |
-
|
16 |
-
## Our Standards
|
17 |
-
|
18 |
-
Examples of behavior that contributes to a positive environment for our
|
19 |
-
community include:
|
20 |
-
|
21 |
-
* Demonstrating empathy and kindness toward other people
|
22 |
-
* Being respectful of differing opinions, viewpoints, and experiences
|
23 |
-
* Giving and gracefully accepting constructive feedback
|
24 |
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
25 |
-
and learning from the experience
|
26 |
-
* Focusing on what is best not just for us as individuals, but for the overall
|
27 |
-
community
|
28 |
-
|
29 |
-
Examples of unacceptable behavior include:
|
30 |
-
|
31 |
-
* The use of sexualized language or imagery, and sexual attention or advances of
|
32 |
-
any kind
|
33 |
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
34 |
-
* Public or private harassment
|
35 |
-
* Publishing others' private information, such as a physical or email address,
|
36 |
-
without their explicit permission
|
37 |
-
* Other conduct which could reasonably be considered inappropriate in a
|
38 |
-
professional setting
|
39 |
-
|
40 |
-
## Enforcement Responsibilities
|
41 |
-
|
42 |
-
Community leaders are responsible for clarifying and enforcing our standards of
|
43 |
-
acceptable behavior and will take appropriate and fair corrective action in
|
44 |
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
45 |
-
or harmful.
|
46 |
-
|
47 |
-
Community leaders have the right and responsibility to remove, edit, or reject
|
48 |
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
49 |
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
50 |
-
decisions when appropriate.
|
51 |
-
|
52 |
-
## Scope
|
53 |
-
|
54 |
-
This Code of Conduct applies within all community spaces, and also applies when
|
55 |
-
an individual is officially representing the community in public spaces.
|
56 |
-
Examples of representing our community include using an official e-mail address,
|
57 |
-
posting via an official social media account, or acting as an appointed
|
58 |
-
representative at an online or offline event.
|
59 |
-
|
60 |
-
## Enforcement
|
61 |
-
|
62 |
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
63 |
-
reported to the community leaders responsible for enforcement at conduct at omnitool.ai
|
64 |
-
All complaints will be reviewed and investigated promptly and fairly.
|
65 |
-
|
66 |
-
All community leaders are obligated to respect the privacy and security of the
|
67 |
-
reporter of any incident.
|
68 |
-
|
69 |
-
## Enforcement Guidelines
|
70 |
-
|
71 |
-
Community leaders will follow these Community Impact Guidelines in determining
|
72 |
-
the consequences for any action they deem in violation of this Code of Conduct:
|
73 |
-
|
74 |
-
### 1. Correction
|
75 |
-
|
76 |
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77 |
-
unprofessional or unwelcome in the community.
|
78 |
-
|
79 |
-
**Consequence**: A private, written warning from community leaders, providing
|
80 |
-
clarity around the nature of the violation and an explanation of why the
|
81 |
-
behavior was inappropriate. A public apology may be requested.
|
82 |
-
|
83 |
-
### 2. Warning
|
84 |
-
|
85 |
-
**Community Impact**: A violation through a single incident or series of
|
86 |
-
actions.
|
87 |
-
|
88 |
-
**Consequence**: A warning with consequences for continued behavior. No
|
89 |
-
interaction with the people involved, including unsolicited interaction with
|
90 |
-
those enforcing the Code of Conduct, for a specified period of time. This
|
91 |
-
includes avoiding interactions in community spaces as well as external channels
|
92 |
-
like social media. Violating these terms may lead to a temporary or permanent
|
93 |
-
ban.
|
94 |
-
|
95 |
-
### 3. Temporary Ban
|
96 |
-
|
97 |
-
**Community Impact**: A serious violation of community standards, including
|
98 |
-
sustained inappropriate behavior.
|
99 |
-
|
100 |
-
**Consequence**: A temporary ban from any sort of interaction or public
|
101 |
-
communication with the community for a specified period of time. No public or
|
102 |
-
private interaction with the people involved, including unsolicited interaction
|
103 |
-
with those enforcing the Code of Conduct, is allowed during this period.
|
104 |
-
Violating these terms may lead to a permanent ban.
|
105 |
-
|
106 |
-
### 4. Permanent Ban
|
107 |
-
|
108 |
-
**Community Impact**: Demonstrating a pattern of violation of community
|
109 |
-
standards, including sustained inappropriate behavior, harassment of an
|
110 |
-
individual, or aggression toward or disparagement of classes of individuals.
|
111 |
-
|
112 |
-
**Consequence**: A permanent ban from any sort of public interaction within the
|
113 |
-
community.
|
114 |
-
|
115 |
-
## Attribution
|
116 |
-
|
117 |
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118 |
-
version 2.1, available at
|
119 |
-
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120 |
-
|
121 |
-
Community Impact Guidelines were inspired by
|
122 |
-
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123 |
-
|
124 |
-
For answers to common questions about this code of conduct, see the FAQ at
|
125 |
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126 |
-
[https://www.contributor-covenant.org/translations][translations].
|
127 |
-
|
128 |
-
[homepage]: https://www.contributor-covenant.org
|
129 |
-
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130 |
-
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131 |
-
[FAQ]: https://www.contributor-covenant.org/faq
|
132 |
-
[translations]: https://www.contributor-covenant.org/translations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
COPYRIGHT.md
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
|
2 |
-
All rights reserved.
|
|
|
|
|
|
Dockerfile
CHANGED
@@ -3,14 +3,14 @@ FROM node:20.6.1
|
|
3 |
USER node
|
4 |
WORKDIR /app
|
5 |
|
6 |
-
RUN mkdir -p /app/node_modules
|
7 |
RUN chmod 777 /app
|
8 |
-
RUN chmod 777 /app/node_modules
|
9 |
|
10 |
-
RUN mkdir -p /app/
|
11 |
-
RUN chmod 777 /app/
|
12 |
-
RUN
|
13 |
-
RUN chmod 777 /app/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/
|
|
|
|
|
14 |
|
15 |
RUN chown -Rh $user:$user /app
|
16 |
|
|
|
3 |
USER node
|
4 |
WORKDIR /app
|
5 |
|
|
|
6 |
RUN chmod 777 /app
|
|
|
7 |
|
8 |
+
#RUN mkdir -p /app/omnitool/node_modules
|
9 |
+
#RUN chmod 777 /app/omnitool/node_modules
|
10 |
+
#RUN mkdir -p /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/
|
11 |
+
#RUN chmod 777 /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/
|
12 |
+
#RUN curl -L https://github.com/omnitool-ai/omnitool/raw/main/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1 -o /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1
|
13 |
+
#RUN chmod 777 /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1
|
14 |
|
15 |
RUN chown -Rh $user:$user /app
|
16 |
|
LICENSE.md
DELETED
@@ -1,667 +0,0 @@
|
|
1 |
-
Copyright (c) 2023 MERCENARIES.AI PTE. LTD.
|
2 |
-
All rights reserved.
|
3 |
-
|
4 |
-
Unless you have obtained this software directly from MERCENARIES.AI PTE. LTD. under the terms of a specific commercial license agreement, Omnitool.ai is provided to you under the GNU Affero General Public License version 3 (a.k.a. AGPLv3) license, the full text of which is included below. Information on accessing the source code for this distribution is detailed in the SOURCE.md file.
|
5 |
-
Omnitool.ai incorporates various open-source software components, the license terms of which are documented in the NOTICE.md file.
|
6 |
-
Additionally, the Windows and Mac versions of Omnitool.ai are bundled with binary copies of several utilities, the licensing terms for these are available in the SOURCE.md file.
|
7 |
-
|
8 |
-
# GNU AFFERO GENERAL PUBLIC LICENSE
|
9 |
-
|
10 |
-
Version 3, 19 November 2007
|
11 |
-
|
12 |
-
Copyright (C) 2007 Free Software Foundation, Inc.
|
13 |
-
<https://fsf.org/>
|
14 |
-
|
15 |
-
Everyone is permitted to copy and distribute verbatim copies of this
|
16 |
-
license document, but changing it is not allowed.
|
17 |
-
|
18 |
-
## Preamble
|
19 |
-
|
20 |
-
The GNU Affero General Public License is a free, copyleft license for
|
21 |
-
software and other kinds of works, specifically designed to ensure
|
22 |
-
cooperation with the community in the case of network server software.
|
23 |
-
|
24 |
-
The licenses for most software and other practical works are designed
|
25 |
-
to take away your freedom to share and change the works. By contrast,
|
26 |
-
our General Public Licenses are intended to guarantee your freedom to
|
27 |
-
share and change all versions of a program--to make sure it remains
|
28 |
-
free software for all its users.
|
29 |
-
|
30 |
-
When we speak of free software, we are referring to freedom, not
|
31 |
-
price. Our General Public Licenses are designed to make sure that you
|
32 |
-
have the freedom to distribute copies of free software (and charge for
|
33 |
-
them if you wish), that you receive source code or can get it if you
|
34 |
-
want it, that you can change the software or use pieces of it in new
|
35 |
-
free programs, and that you know you can do these things.
|
36 |
-
|
37 |
-
Developers that use our General Public Licenses protect your rights
|
38 |
-
with two steps: (1) assert copyright on the software, and (2) offer
|
39 |
-
you this License which gives you legal permission to copy, distribute
|
40 |
-
and/or modify the software.
|
41 |
-
|
42 |
-
A secondary benefit of defending all users' freedom is that
|
43 |
-
improvements made in alternate versions of the program, if they
|
44 |
-
receive widespread use, become available for other developers to
|
45 |
-
incorporate. Many developers of free software are heartened and
|
46 |
-
encouraged by the resulting cooperation. However, in the case of
|
47 |
-
software used on network servers, this result may fail to come about.
|
48 |
-
The GNU General Public License permits making a modified version and
|
49 |
-
letting the public access it on a server without ever releasing its
|
50 |
-
source code to the public.
|
51 |
-
|
52 |
-
The GNU Affero General Public License is designed specifically to
|
53 |
-
ensure that, in such cases, the modified source code becomes available
|
54 |
-
to the community. It requires the operator of a network server to
|
55 |
-
provide the source code of the modified version running there to the
|
56 |
-
users of that server. Therefore, public use of a modified version, on
|
57 |
-
a publicly accessible server, gives the public access to the source
|
58 |
-
code of the modified version.
|
59 |
-
|
60 |
-
An older license, called the Affero General Public License and
|
61 |
-
published by Affero, was designed to accomplish similar goals. This is
|
62 |
-
a different license, not a version of the Affero GPL, but Affero has
|
63 |
-
released a new version of the Affero GPL which permits relicensing
|
64 |
-
under this license.
|
65 |
-
|
66 |
-
The precise terms and conditions for copying, distribution and
|
67 |
-
modification follow.
|
68 |
-
|
69 |
-
## TERMS AND CONDITIONS
|
70 |
-
|
71 |
-
### 0. Definitions.
|
72 |
-
|
73 |
-
"This License" refers to version 3 of the GNU Affero General Public
|
74 |
-
License.
|
75 |
-
|
76 |
-
"Copyright" also means copyright-like laws that apply to other kinds
|
77 |
-
of works, such as semiconductor masks.
|
78 |
-
|
79 |
-
"The Program" refers to any copyrightable work licensed under this
|
80 |
-
License. Each licensee is addressed as "you". "Licensees" and
|
81 |
-
"recipients" may be individuals or organizations.
|
82 |
-
|
83 |
-
To "modify" a work means to copy from or adapt all or part of the work
|
84 |
-
in a fashion requiring copyright permission, other than the making of
|
85 |
-
an exact copy. The resulting work is called a "modified version" of
|
86 |
-
the earlier work or a work "based on" the earlier work.
|
87 |
-
|
88 |
-
A "covered work" means either the unmodified Program or a work based
|
89 |
-
on the Program.
|
90 |
-
|
91 |
-
To "propagate" a work means to do anything with it that, without
|
92 |
-
permission, would make you directly or secondarily liable for
|
93 |
-
infringement under applicable copyright law, except executing it on a
|
94 |
-
computer or modifying a private copy. Propagation includes copying,
|
95 |
-
distribution (with or without modification), making available to the
|
96 |
-
public, and in some countries other activities as well.
|
97 |
-
|
98 |
-
To "convey" a work means any kind of propagation that enables other
|
99 |
-
parties to make or receive copies. Mere interaction with a user
|
100 |
-
through a computer network, with no transfer of a copy, is not
|
101 |
-
conveying.
|
102 |
-
|
103 |
-
An interactive user interface displays "Appropriate Legal Notices" to
|
104 |
-
the extent that it includes a convenient and prominently visible
|
105 |
-
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
-
tells the user that there is no warranty for the work (except to the
|
107 |
-
extent that warranties are provided), that licensees may convey the
|
108 |
-
work under this License, and how to view a copy of this License. If
|
109 |
-
the interface presents a list of user commands or options, such as a
|
110 |
-
menu, a prominent item in the list meets this criterion.
|
111 |
-
|
112 |
-
### 1. Source Code.
|
113 |
-
|
114 |
-
The "source code" for a work means the preferred form of the work for
|
115 |
-
making modifications to it. "Object code" means any non-source form of
|
116 |
-
a work.
|
117 |
-
|
118 |
-
A "Standard Interface" means an interface that either is an official
|
119 |
-
standard defined by a recognized standards body, or, in the case of
|
120 |
-
interfaces specified for a particular programming language, one that
|
121 |
-
is widely used among developers working in that language.
|
122 |
-
|
123 |
-
The "System Libraries" of an executable work include anything, other
|
124 |
-
than the work as a whole, that (a) is included in the normal form of
|
125 |
-
packaging a Major Component, but which is not part of that Major
|
126 |
-
Component, and (b) serves only to enable use of the work with that
|
127 |
-
Major Component, or to implement a Standard Interface for which an
|
128 |
-
implementation is available to the public in source code form. A
|
129 |
-
"Major Component", in this context, means a major essential component
|
130 |
-
(kernel, window system, and so on) of the specific operating system
|
131 |
-
(if any) on which the executable work runs, or a compiler used to
|
132 |
-
produce the work, or an object code interpreter used to run it.
|
133 |
-
|
134 |
-
The "Corresponding Source" for a work in object code form means all
|
135 |
-
the source code needed to generate, install, and (for an executable
|
136 |
-
work) run the object code and to modify the work, including scripts to
|
137 |
-
control those activities. However, it does not include the work's
|
138 |
-
System Libraries, or general-purpose tools or generally available free
|
139 |
-
programs which are used unmodified in performing those activities but
|
140 |
-
which are not part of the work. For example, Corresponding Source
|
141 |
-
includes interface definition files associated with source files for
|
142 |
-
the work, and the source code for shared libraries and dynamically
|
143 |
-
linked subprograms that the work is specifically designed to require,
|
144 |
-
such as by intimate data communication or control flow between those
|
145 |
-
subprograms and other parts of the work.
|
146 |
-
|
147 |
-
The Corresponding Source need not include anything that users can
|
148 |
-
regenerate automatically from other parts of the Corresponding Source.
|
149 |
-
|
150 |
-
The Corresponding Source for a work in source code form is that same
|
151 |
-
work.
|
152 |
-
|
153 |
-
### 2. Basic Permissions.
|
154 |
-
|
155 |
-
All rights granted under this License are granted for the term of
|
156 |
-
copyright on the Program, and are irrevocable provided the stated
|
157 |
-
conditions are met. This License explicitly affirms your unlimited
|
158 |
-
permission to run the unmodified Program. The output from running a
|
159 |
-
covered work is covered by this License only if the output, given its
|
160 |
-
content, constitutes a covered work. This License acknowledges your
|
161 |
-
rights of fair use or other equivalent, as provided by copyright law.
|
162 |
-
|
163 |
-
You may make, run and propagate covered works that you do not convey,
|
164 |
-
without conditions so long as your license otherwise remains in force.
|
165 |
-
You may convey covered works to others for the sole purpose of having
|
166 |
-
them make modifications exclusively for you, or provide you with
|
167 |
-
facilities for running those works, provided that you comply with the
|
168 |
-
terms of this License in conveying all material for which you do not
|
169 |
-
control copyright. Those thus making or running the covered works for
|
170 |
-
you must do so exclusively on your behalf, under your direction and
|
171 |
-
control, on terms that prohibit them from making any copies of your
|
172 |
-
copyrighted material outside their relationship with you.
|
173 |
-
|
174 |
-
Conveying under any other circumstances is permitted solely under the
|
175 |
-
conditions stated below. Sublicensing is not allowed; section 10 makes
|
176 |
-
it unnecessary.
|
177 |
-
|
178 |
-
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
179 |
-
|
180 |
-
No covered work shall be deemed part of an effective technological
|
181 |
-
measure under any applicable law fulfilling obligations under article
|
182 |
-
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
183 |
-
similar laws prohibiting or restricting circumvention of such
|
184 |
-
measures.
|
185 |
-
|
186 |
-
When you convey a covered work, you waive any legal power to forbid
|
187 |
-
circumvention of technological measures to the extent such
|
188 |
-
circumvention is effected by exercising rights under this License with
|
189 |
-
respect to the covered work, and you disclaim any intention to limit
|
190 |
-
operation or modification of the work as a means of enforcing, against
|
191 |
-
the work's users, your or third parties' legal rights to forbid
|
192 |
-
circumvention of technological measures.
|
193 |
-
|
194 |
-
### 4. Conveying Verbatim Copies.
|
195 |
-
|
196 |
-
You may convey verbatim copies of the Program's source code as you
|
197 |
-
receive it, in any medium, provided that you conspicuously and
|
198 |
-
appropriately publish on each copy an appropriate copyright notice;
|
199 |
-
keep intact all notices stating that this License and any
|
200 |
-
non-permissive terms added in accord with section 7 apply to the code;
|
201 |
-
keep intact all notices of the absence of any warranty; and give all
|
202 |
-
recipients a copy of this License along with the Program.
|
203 |
-
|
204 |
-
You may charge any price or no price for each copy that you convey,
|
205 |
-
and you may offer support or warranty protection for a fee.
|
206 |
-
|
207 |
-
### 5. Conveying Modified Source Versions.
|
208 |
-
|
209 |
-
You may convey a work based on the Program, or the modifications to
|
210 |
-
produce it from the Program, in the form of source code under the
|
211 |
-
terms of section 4, provided that you also meet all of these
|
212 |
-
conditions:
|
213 |
-
|
214 |
-
- a) The work must carry prominent notices stating that you modified
|
215 |
-
it, and giving a relevant date.
|
216 |
-
- b) The work must carry prominent notices stating that it is
|
217 |
-
released under this License and any conditions added under
|
218 |
-
section 7. This requirement modifies the requirement in section 4
|
219 |
-
to "keep intact all notices".
|
220 |
-
- c) You must license the entire work, as a whole, under this
|
221 |
-
License to anyone who comes into possession of a copy. This
|
222 |
-
License will therefore apply, along with any applicable section 7
|
223 |
-
additional terms, to the whole of the work, and all its parts,
|
224 |
-
regardless of how they are packaged. This License gives no
|
225 |
-
permission to license the work in any other way, but it does not
|
226 |
-
invalidate such permission if you have separately received it.
|
227 |
-
- d) If the work has interactive user interfaces, each must display
|
228 |
-
Appropriate Legal Notices; however, if the Program has interactive
|
229 |
-
interfaces that do not display Appropriate Legal Notices, your
|
230 |
-
work need not make them do so.
|
231 |
-
|
232 |
-
A compilation of a covered work with other separate and independent
|
233 |
-
works, which are not by their nature extensions of the covered work,
|
234 |
-
and which are not combined with it such as to form a larger program,
|
235 |
-
in or on a volume of a storage or distribution medium, is called an
|
236 |
-
"aggregate" if the compilation and its resulting copyright are not
|
237 |
-
used to limit the access or legal rights of the compilation's users
|
238 |
-
beyond what the individual works permit. Inclusion of a covered work
|
239 |
-
in an aggregate does not cause this License to apply to the other
|
240 |
-
parts of the aggregate.
|
241 |
-
|
242 |
-
### 6. Conveying Non-Source Forms.
|
243 |
-
|
244 |
-
You may convey a covered work in object code form under the terms of
|
245 |
-
sections 4 and 5, provided that you also convey the machine-readable
|
246 |
-
Corresponding Source under the terms of this License, in one of these
|
247 |
-
ways:
|
248 |
-
|
249 |
-
- a) Convey the object code in, or embodied in, a physical product
|
250 |
-
(including a physical distribution medium), accompanied by the
|
251 |
-
Corresponding Source fixed on a durable physical medium
|
252 |
-
customarily used for software interchange.
|
253 |
-
- b) Convey the object code in, or embodied in, a physical product
|
254 |
-
(including a physical distribution medium), accompanied by a
|
255 |
-
written offer, valid for at least three years and valid for as
|
256 |
-
long as you offer spare parts or customer support for that product
|
257 |
-
model, to give anyone who possesses the object code either (1) a
|
258 |
-
copy of the Corresponding Source for all the software in the
|
259 |
-
product that is covered by this License, on a durable physical
|
260 |
-
medium customarily used for software interchange, for a price no
|
261 |
-
more than your reasonable cost of physically performing this
|
262 |
-
conveying of source, or (2) access to copy the Corresponding
|
263 |
-
Source from a network server at no charge.
|
264 |
-
- c) Convey individual copies of the object code with a copy of the
|
265 |
-
written offer to provide the Corresponding Source. This
|
266 |
-
alternative is allowed only occasionally and noncommercially, and
|
267 |
-
only if you received the object code with such an offer, in accord
|
268 |
-
with subsection 6b.
|
269 |
-
- d) Convey the object code by offering access from a designated
|
270 |
-
place (gratis or for a charge), and offer equivalent access to the
|
271 |
-
Corresponding Source in the same way through the same place at no
|
272 |
-
further charge. You need not require recipients to copy the
|
273 |
-
Corresponding Source along with the object code. If the place to
|
274 |
-
copy the object code is a network server, the Corresponding Source
|
275 |
-
may be on a different server (operated by you or a third party)
|
276 |
-
that supports equivalent copying facilities, provided you maintain
|
277 |
-
clear directions next to the object code saying where to find the
|
278 |
-
Corresponding Source. Regardless of what server hosts the
|
279 |
-
Corresponding Source, you remain obligated to ensure that it is
|
280 |
-
available for as long as needed to satisfy these requirements.
|
281 |
-
- e) Convey the object code using peer-to-peer transmission,
|
282 |
-
provided you inform other peers where the object code and
|
283 |
-
Corresponding Source of the work are being offered to the general
|
284 |
-
public at no charge under subsection 6d.
|
285 |
-
|
286 |
-
A separable portion of the object code, whose source code is excluded
|
287 |
-
from the Corresponding Source as a System Library, need not be
|
288 |
-
included in conveying the object code work.
|
289 |
-
|
290 |
-
A "User Product" is either (1) a "consumer product", which means any
|
291 |
-
tangible personal property which is normally used for personal,
|
292 |
-
family, or household purposes, or (2) anything designed or sold for
|
293 |
-
incorporation into a dwelling. In determining whether a product is a
|
294 |
-
consumer product, doubtful cases shall be resolved in favor of
|
295 |
-
coverage. For a particular product received by a particular user,
|
296 |
-
"normally used" refers to a typical or common use of that class of
|
297 |
-
product, regardless of the status of the particular user or of the way
|
298 |
-
in which the particular user actually uses, or expects or is expected
|
299 |
-
to use, the product. A product is a consumer product regardless of
|
300 |
-
whether the product has substantial commercial, industrial or
|
301 |
-
non-consumer uses, unless such uses represent the only significant
|
302 |
-
mode of use of the product.
|
303 |
-
|
304 |
-
"Installation Information" for a User Product means any methods,
|
305 |
-
procedures, authorization keys, or other information required to
|
306 |
-
install and execute modified versions of a covered work in that User
|
307 |
-
Product from a modified version of its Corresponding Source. The
|
308 |
-
information must suffice to ensure that the continued functioning of
|
309 |
-
the modified object code is in no case prevented or interfered with
|
310 |
-
solely because modification has been made.
|
311 |
-
|
312 |
-
If you convey an object code work under this section in, or with, or
|
313 |
-
specifically for use in, a User Product, and the conveying occurs as
|
314 |
-
part of a transaction in which the right of possession and use of the
|
315 |
-
User Product is transferred to the recipient in perpetuity or for a
|
316 |
-
fixed term (regardless of how the transaction is characterized), the
|
317 |
-
Corresponding Source conveyed under this section must be accompanied
|
318 |
-
by the Installation Information. But this requirement does not apply
|
319 |
-
if neither you nor any third party retains the ability to install
|
320 |
-
modified object code on the User Product (for example, the work has
|
321 |
-
been installed in ROM).
|
322 |
-
|
323 |
-
The requirement to provide Installation Information does not include a
|
324 |
-
requirement to continue to provide support service, warranty, or
|
325 |
-
updates for a work that has been modified or installed by the
|
326 |
-
recipient, or for the User Product in which it has been modified or
|
327 |
-
installed. Access to a network may be denied when the modification
|
328 |
-
itself materially and adversely affects the operation of the network
|
329 |
-
or violates the rules and protocols for communication across the
|
330 |
-
network.
|
331 |
-
|
332 |
-
Corresponding Source conveyed, and Installation Information provided,
|
333 |
-
in accord with this section must be in a format that is publicly
|
334 |
-
documented (and with an implementation available to the public in
|
335 |
-
source code form), and must require no special password or key for
|
336 |
-
unpacking, reading or copying.
|
337 |
-
|
338 |
-
### 7. Additional Terms.
|
339 |
-
|
340 |
-
"Additional permissions" are terms that supplement the terms of this
|
341 |
-
License by making exceptions from one or more of its conditions.
|
342 |
-
Additional permissions that are applicable to the entire Program shall
|
343 |
-
be treated as though they were included in this License, to the extent
|
344 |
-
that they are valid under applicable law. If additional permissions
|
345 |
-
apply only to part of the Program, that part may be used separately
|
346 |
-
under those permissions, but the entire Program remains governed by
|
347 |
-
this License without regard to the additional permissions.
|
348 |
-
|
349 |
-
When you convey a copy of a covered work, you may at your option
|
350 |
-
remove any additional permissions from that copy, or from any part of
|
351 |
-
it. (Additional permissions may be written to require their own
|
352 |
-
removal in certain cases when you modify the work.) You may place
|
353 |
-
additional permissions on material, added by you to a covered work,
|
354 |
-
for which you have or can give appropriate copyright permission.
|
355 |
-
|
356 |
-
Notwithstanding any other provision of this License, for material you
|
357 |
-
add to a covered work, you may (if authorized by the copyright holders
|
358 |
-
of that material) supplement the terms of this License with terms:
|
359 |
-
|
360 |
-
- a) Disclaiming warranty or limiting liability differently from the
|
361 |
-
terms of sections 15 and 16 of this License; or
|
362 |
-
- b) Requiring preservation of specified reasonable legal notices or
|
363 |
-
author attributions in that material or in the Appropriate Legal
|
364 |
-
Notices displayed by works containing it; or
|
365 |
-
- c) Prohibiting misrepresentation of the origin of that material,
|
366 |
-
or requiring that modified versions of such material be marked in
|
367 |
-
reasonable ways as different from the original version; or
|
368 |
-
- d) Limiting the use for publicity purposes of names of licensors
|
369 |
-
or authors of the material; or
|
370 |
-
- e) Declining to grant rights under trademark law for use of some
|
371 |
-
trade names, trademarks, or service marks; or
|
372 |
-
- f) Requiring indemnification of licensors and authors of that
|
373 |
-
material by anyone who conveys the material (or modified versions
|
374 |
-
of it) with contractual assumptions of liability to the recipient,
|
375 |
-
for any liability that these contractual assumptions directly
|
376 |
-
impose on those licensors and authors.
|
377 |
-
|
378 |
-
All other non-permissive additional terms are considered "further
|
379 |
-
restrictions" within the meaning of section 10. If the Program as you
|
380 |
-
received it, or any part of it, contains a notice stating that it is
|
381 |
-
governed by this License along with a term that is a further
|
382 |
-
restriction, you may remove that term. If a license document contains
|
383 |
-
a further restriction but permits relicensing or conveying under this
|
384 |
-
License, you may add to a covered work material governed by the terms
|
385 |
-
of that license document, provided that the further restriction does
|
386 |
-
not survive such relicensing or conveying.
|
387 |
-
|
388 |
-
If you add terms to a covered work in accord with this section, you
|
389 |
-
must place, in the relevant source files, a statement of the
|
390 |
-
additional terms that apply to those files, or a notice indicating
|
391 |
-
where to find the applicable terms.
|
392 |
-
|
393 |
-
Additional terms, permissive or non-permissive, may be stated in the
|
394 |
-
form of a separately written license, or stated as exceptions; the
|
395 |
-
above requirements apply either way.
|
396 |
-
|
397 |
-
### 8. Termination.
|
398 |
-
|
399 |
-
You may not propagate or modify a covered work except as expressly
|
400 |
-
provided under this License. Any attempt otherwise to propagate or
|
401 |
-
modify it is void, and will automatically terminate your rights under
|
402 |
-
this License (including any patent licenses granted under the third
|
403 |
-
paragraph of section 11).
|
404 |
-
|
405 |
-
However, if you cease all violation of this License, then your license
|
406 |
-
from a particular copyright holder is reinstated (a) provisionally,
|
407 |
-
unless and until the copyright holder explicitly and finally
|
408 |
-
terminates your license, and (b) permanently, if the copyright holder
|
409 |
-
fails to notify you of the violation by some reasonable means prior to
|
410 |
-
60 days after the cessation.
|
411 |
-
|
412 |
-
Moreover, your license from a particular copyright holder is
|
413 |
-
reinstated permanently if the copyright holder notifies you of the
|
414 |
-
violation by some reasonable means, this is the first time you have
|
415 |
-
received notice of violation of this License (for any work) from that
|
416 |
-
copyright holder, and you cure the violation prior to 30 days after
|
417 |
-
your receipt of the notice.
|
418 |
-
|
419 |
-
Termination of your rights under this section does not terminate the
|
420 |
-
licenses of parties who have received copies or rights from you under
|
421 |
-
this License. If your rights have been terminated and not permanently
|
422 |
-
reinstated, you do not qualify to receive new licenses for the same
|
423 |
-
material under section 10.
|
424 |
-
|
425 |
-
### 9. Acceptance Not Required for Having Copies.
|
426 |
-
|
427 |
-
You are not required to accept this License in order to receive or run
|
428 |
-
a copy of the Program. Ancillary propagation of a covered work
|
429 |
-
occurring solely as a consequence of using peer-to-peer transmission
|
430 |
-
to receive a copy likewise does not require acceptance. However,
|
431 |
-
nothing other than this License grants you permission to propagate or
|
432 |
-
modify any covered work. These actions infringe copyright if you do
|
433 |
-
not accept this License. Therefore, by modifying or propagating a
|
434 |
-
covered work, you indicate your acceptance of this License to do so.
|
435 |
-
|
436 |
-
### 10. Automatic Licensing of Downstream Recipients.
|
437 |
-
|
438 |
-
Each time you convey a covered work, the recipient automatically
|
439 |
-
receives a license from the original licensors, to run, modify and
|
440 |
-
propagate that work, subject to this License. You are not responsible
|
441 |
-
for enforcing compliance by third parties with this License.
|
442 |
-
|
443 |
-
An "entity transaction" is a transaction transferring control of an
|
444 |
-
organization, or substantially all assets of one, or subdividing an
|
445 |
-
organization, or merging organizations. If propagation of a covered
|
446 |
-
work results from an entity transaction, each party to that
|
447 |
-
transaction who receives a copy of the work also receives whatever
|
448 |
-
licenses to the work the party's predecessor in interest had or could
|
449 |
-
give under the previous paragraph, plus a right to possession of the
|
450 |
-
Corresponding Source of the work from the predecessor in interest, if
|
451 |
-
the predecessor has it or can get it with reasonable efforts.
|
452 |
-
|
453 |
-
You may not impose any further restrictions on the exercise of the
|
454 |
-
rights granted or affirmed under this License. For example, you may
|
455 |
-
not impose a license fee, royalty, or other charge for exercise of
|
456 |
-
rights granted under this License, and you may not initiate litigation
|
457 |
-
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
458 |
-
any patent claim is infringed by making, using, selling, offering for
|
459 |
-
sale, or importing the Program or any portion of it.
|
460 |
-
|
461 |
-
### 11. Patents.
|
462 |
-
|
463 |
-
A "contributor" is a copyright holder who authorizes use under this
|
464 |
-
License of the Program or a work on which the Program is based. The
|
465 |
-
work thus licensed is called the contributor's "contributor version".
|
466 |
-
|
467 |
-
A contributor's "essential patent claims" are all patent claims owned
|
468 |
-
or controlled by the contributor, whether already acquired or
|
469 |
-
hereafter acquired, that would be infringed by some manner, permitted
|
470 |
-
by this License, of making, using, or selling its contributor version,
|
471 |
-
but do not include claims that would be infringed only as a
|
472 |
-
consequence of further modification of the contributor version. For
|
473 |
-
purposes of this definition, "control" includes the right to grant
|
474 |
-
patent sublicenses in a manner consistent with the requirements of
|
475 |
-
this License.
|
476 |
-
|
477 |
-
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
478 |
-
patent license under the contributor's essential patent claims, to
|
479 |
-
make, use, sell, offer for sale, import and otherwise run, modify and
|
480 |
-
propagate the contents of its contributor version.
|
481 |
-
|
482 |
-
In the following three paragraphs, a "patent license" is any express
|
483 |
-
agreement or commitment, however denominated, not to enforce a patent
|
484 |
-
(such as an express permission to practice a patent or covenant not to
|
485 |
-
sue for patent infringement). To "grant" such a patent license to a
|
486 |
-
party means to make such an agreement or commitment not to enforce a
|
487 |
-
patent against the party.
|
488 |
-
|
489 |
-
If you convey a covered work, knowingly relying on a patent license,
|
490 |
-
and the Corresponding Source of the work is not available for anyone
|
491 |
-
to copy, free of charge and under the terms of this License, through a
|
492 |
-
publicly available network server or other readily accessible means,
|
493 |
-
then you must either (1) cause the Corresponding Source to be so
|
494 |
-
available, or (2) arrange to deprive yourself of the benefit of the
|
495 |
-
patent license for this particular work, or (3) arrange, in a manner
|
496 |
-
consistent with the requirements of this License, to extend the patent
|
497 |
-
license to downstream recipients. "Knowingly relying" means you have
|
498 |
-
actual knowledge that, but for the patent license, your conveying the
|
499 |
-
covered work in a country, or your recipient's use of the covered work
|
500 |
-
in a country, would infringe one or more identifiable patents in that
|
501 |
-
country that you have reason to believe are valid.
|
502 |
-
|
503 |
-
If, pursuant to or in connection with a single transaction or
|
504 |
-
arrangement, you convey, or propagate by procuring conveyance of, a
|
505 |
-
covered work, and grant a patent license to some of the parties
|
506 |
-
receiving the covered work authorizing them to use, propagate, modify
|
507 |
-
or convey a specific copy of the covered work, then the patent license
|
508 |
-
you grant is automatically extended to all recipients of the covered
|
509 |
-
work and works based on it.
|
510 |
-
|
511 |
-
A patent license is "discriminatory" if it does not include within the
|
512 |
-
scope of its coverage, prohibits the exercise of, or is conditioned on
|
513 |
-
the non-exercise of one or more of the rights that are specifically
|
514 |
-
granted under this License. You may not convey a covered work if you
|
515 |
-
are a party to an arrangement with a third party that is in the
|
516 |
-
business of distributing software, under which you make payment to the
|
517 |
-
third party based on the extent of your activity of conveying the
|
518 |
-
work, and under which the third party grants, to any of the parties
|
519 |
-
who would receive the covered work from you, a discriminatory patent
|
520 |
-
license (a) in connection with copies of the covered work conveyed by
|
521 |
-
you (or copies made from those copies), or (b) primarily for and in
|
522 |
-
connection with specific products or compilations that contain the
|
523 |
-
covered work, unless you entered into that arrangement, or that patent
|
524 |
-
license was granted, prior to 28 March 2007.
|
525 |
-
|
526 |
-
Nothing in this License shall be construed as excluding or limiting
|
527 |
-
any implied license or other defenses to infringement that may
|
528 |
-
otherwise be available to you under applicable patent law.
|
529 |
-
|
530 |
-
### 12. No Surrender of Others' Freedom.
|
531 |
-
|
532 |
-
If conditions are imposed on you (whether by court order, agreement or
|
533 |
-
otherwise) that contradict the conditions of this License, they do not
|
534 |
-
excuse you from the conditions of this License. If you cannot convey a
|
535 |
-
covered work so as to satisfy simultaneously your obligations under
|
536 |
-
this License and any other pertinent obligations, then as a
|
537 |
-
consequence you may not convey it at all. For example, if you agree to
|
538 |
-
terms that obligate you to collect a royalty for further conveying
|
539 |
-
from those to whom you convey the Program, the only way you could
|
540 |
-
satisfy both those terms and this License would be to refrain entirely
|
541 |
-
from conveying the Program.
|
542 |
-
|
543 |
-
### 13. Remote Network Interaction; Use with the GNU General Public License.
|
544 |
-
|
545 |
-
Notwithstanding any other provision of this License, if you modify the
|
546 |
-
Program, your modified version must prominently offer all users
|
547 |
-
interacting with it remotely through a computer network (if your
|
548 |
-
version supports such interaction) an opportunity to receive the
|
549 |
-
Corresponding Source of your version by providing access to the
|
550 |
-
Corresponding Source from a network server at no charge, through some
|
551 |
-
standard or customary means of facilitating copying of software. This
|
552 |
-
Corresponding Source shall include the Corresponding Source for any
|
553 |
-
work covered by version 3 of the GNU General Public License that is
|
554 |
-
incorporated pursuant to the following paragraph.
|
555 |
-
|
556 |
-
Notwithstanding any other provision of this License, you have
|
557 |
-
permission to link or combine any covered work with a work licensed
|
558 |
-
under version 3 of the GNU General Public License into a single
|
559 |
-
combined work, and to convey the resulting work. The terms of this
|
560 |
-
License will continue to apply to the part which is the covered work,
|
561 |
-
but the work with which it is combined will remain governed by version
|
562 |
-
3 of the GNU General Public License.
|
563 |
-
|
564 |
-
### 14. Revised Versions of this License.
|
565 |
-
|
566 |
-
The Free Software Foundation may publish revised and/or new versions
|
567 |
-
of the GNU Affero General Public License from time to time. Such new
|
568 |
-
versions will be similar in spirit to the present version, but may
|
569 |
-
differ in detail to address new problems or concerns.
|
570 |
-
|
571 |
-
Each version is given a distinguishing version number. If the Program
|
572 |
-
specifies that a certain numbered version of the GNU Affero General
|
573 |
-
Public License "or any later version" applies to it, you have the
|
574 |
-
option of following the terms and conditions either of that numbered
|
575 |
-
version or of any later version published by the Free Software
|
576 |
-
Foundation. If the Program does not specify a version number of the
|
577 |
-
GNU Affero General Public License, you may choose any version ever
|
578 |
-
published by the Free Software Foundation.
|
579 |
-
|
580 |
-
If the Program specifies that a proxy can decide which future versions
|
581 |
-
of the GNU Affero General Public License can be used, that proxy's
|
582 |
-
public statement of acceptance of a version permanently authorizes you
|
583 |
-
to choose that version for the Program.
|
584 |
-
|
585 |
-
Later license versions may give you additional or different
|
586 |
-
permissions. However, no additional obligations are imposed on any
|
587 |
-
author or copyright holder as a result of your choosing to follow a
|
588 |
-
later version.
|
589 |
-
|
590 |
-
### 15. Disclaimer of Warranty.
|
591 |
-
|
592 |
-
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
593 |
-
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
594 |
-
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
595 |
-
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
596 |
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
597 |
-
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
598 |
-
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
599 |
-
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
600 |
-
CORRECTION.
|
601 |
-
|
602 |
-
### 16. Limitation of Liability.
|
603 |
-
|
604 |
-
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
605 |
-
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
606 |
-
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
607 |
-
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
608 |
-
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
609 |
-
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
610 |
-
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
611 |
-
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
612 |
-
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
613 |
-
|
614 |
-
### 17. Interpretation of Sections 15 and 16.
|
615 |
-
|
616 |
-
If the disclaimer of warranty and limitation of liability provided
|
617 |
-
above cannot be given local legal effect according to their terms,
|
618 |
-
reviewing courts shall apply local law that most closely approximates
|
619 |
-
an absolute waiver of all civil liability in connection with the
|
620 |
-
Program, unless a warranty or assumption of liability accompanies a
|
621 |
-
copy of the Program in return for a fee.
|
622 |
-
|
623 |
-
END OF TERMS AND CONDITIONS
|
624 |
-
|
625 |
-
## How to Apply These Terms to Your New Programs
|
626 |
-
|
627 |
-
If you develop a new program, and you want it to be of the greatest
|
628 |
-
possible use to the public, the best way to achieve this is to make it
|
629 |
-
free software which everyone can redistribute and change under these
|
630 |
-
terms.
|
631 |
-
|
632 |
-
To do so, attach the following notices to the program. It is safest to
|
633 |
-
attach them to the start of each source file to most effectively state
|
634 |
-
the exclusion of warranty; and each file should have at least the
|
635 |
-
"copyright" line and a pointer to where the full notice is found.
|
636 |
-
|
637 |
-
<one line to give the program's name and a brief idea of what it does.>
|
638 |
-
Copyright (C) <year> <name of author>
|
639 |
-
|
640 |
-
This program is free software: you can redistribute it and/or modify
|
641 |
-
it under the terms of the GNU Affero General Public License as
|
642 |
-
published by the Free Software Foundation, either version 3 of the
|
643 |
-
License, or (at your option) any later version.
|
644 |
-
|
645 |
-
This program is distributed in the hope that it will be useful,
|
646 |
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
647 |
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
648 |
-
GNU Affero General Public License for more details.
|
649 |
-
|
650 |
-
You should have received a copy of the GNU Affero General Public License
|
651 |
-
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
652 |
-
|
653 |
-
Also add information on how to contact you by electronic and paper
|
654 |
-
mail.
|
655 |
-
|
656 |
-
If your software can interact with users remotely through a computer
|
657 |
-
network, you should also make sure that it provides a way for users to
|
658 |
-
get its source. For example, if your program is a web application, its
|
659 |
-
interface could display a "Source" link that leads users to an archive
|
660 |
-
of the code. There are many ways you could offer source, and different
|
661 |
-
solutions will be better for different programs; see section 13 for
|
662 |
-
the specific requirements.
|
663 |
-
|
664 |
-
You should also get your employer (if you work as a programmer) or
|
665 |
-
school, if any, to sign a "copyright disclaimer" for the program, if
|
666 |
-
necessary. For more information on this, and how to apply and follow
|
667 |
-
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NOTICE.md
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
Omnitool.ai utilizes a variety of open-source software components.
|
2 |
-
Presented in the file THIRD_PARTIES.md and, if present, THIRD_PARTIES_ADDITIONAL.md, is a list of these components, along with the complete texts of their corresponding license agreements.
|
3 |
-
Relevant information regarding the third-party vendors mentioned in THIRD_PARTIES.md and, if present, THIRD_PARTIES_ADDITIONAL.md has been gathered through common and reasonable methods.
|
|
|
|
|
|
|
|
ORIGIN.md
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
https://github.com/omnitool-ai/omnitool
|
|
|
|
SOURCE.md
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
Unless you have obtained this software directly from MERCENARIES PTE. LTD. under the terms of a specific commercial license agreement, Omnitool.ai is provided to you under the GNU Affero General Public License version 3 (a.k.a. AGPLv3) license, the full text of which is included in the LICENSE.md file.
|
2 |
-
The file ORIGIN.md lists the URL of the latest version of the source code of Omnitool.ai.
|
|
|
|
|
|
THIRD_PARTIES.md
DELETED
The diff for this file is too large to render.
See raw diff
|
|
assets/screenshot.jpg
DELETED
Binary file (66.6 kB)
|
|
assets/screenshot_collection.png
DELETED
Binary file (107 kB)
|
|
mini.js
DELETED
@@ -1,128 +0,0 @@
|
|
1 |
-
const express = require('express');
|
2 |
-
const http = require('http');
|
3 |
-
const session = require('express-session');
|
4 |
-
const axios = require('axios');
|
5 |
-
|
6 |
-
const app = express();
|
7 |
-
const CHECK_OMNI_INTERVAL = 60000; // 1 minute
|
8 |
-
|
9 |
-
// Global variable
|
10 |
-
global.OMNITOOL_RUNNING = false;
|
11 |
-
|
12 |
-
// Function to check the status of the external service
|
13 |
-
async function checkExternalService()
|
14 |
-
{
|
15 |
-
console.log("Checking external service");
|
16 |
-
try
|
17 |
-
{
|
18 |
-
const response = await axios.get('http://127.0.0.1:1688/api/v1/mercenaries/ping');
|
19 |
-
if (response.data && response.data.ping === 'pong' && Object.keys(response.data.payload).length === 0)
|
20 |
-
{
|
21 |
-
global.OMNITOOL_RUNNING = true;
|
22 |
-
}
|
23 |
-
} catch (error)
|
24 |
-
{
|
25 |
-
console.error('Cannot access OMNITOOL. It is probably not running...', error.message);
|
26 |
-
// Set to false but do not prevent server from starting
|
27 |
-
global.OMNITOOL_RUNNING = false;
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
|
32 |
-
async function setup()
|
33 |
-
{
|
34 |
-
// Call the function when the server starts
|
35 |
-
checkExternalService();
|
36 |
-
|
37 |
-
|
38 |
-
// Other server code...
|
39 |
-
}
|
40 |
-
|
41 |
-
async function main(app)
|
42 |
-
{
|
43 |
-
// Configure session middleware
|
44 |
-
app.use(session({
|
45 |
-
secret: 'your-secret-key',
|
46 |
-
resave: false,
|
47 |
-
saveUninitialized: true
|
48 |
-
}));
|
49 |
-
await startServer();
|
50 |
-
|
51 |
-
// Route to serve the webpage
|
52 |
-
app.get('/', handleRoutes);
|
53 |
-
|
54 |
-
app.get("status", (req, res) =>
|
55 |
-
{
|
56 |
-
res.send(global.OMNITOOL_RUNNING ? 'OMNITOOL IS RUNNING' : 'OMNITOOL IS NOT RUNNING');
|
57 |
-
}
|
58 |
-
);
|
59 |
-
|
60 |
-
// Call the function when the server starts
|
61 |
-
await setup();
|
62 |
-
}
|
63 |
-
|
64 |
-
function replyOmnitoolIsRunning()
|
65 |
-
{
|
66 |
-
return '<p>OMNITOOL IS RUNNING </p>';
|
67 |
-
}
|
68 |
-
|
69 |
-
async function handleRoutes(req, res)
|
70 |
-
{
|
71 |
-
|
72 |
-
if (req.session.isVisited)
|
73 |
-
{
|
74 |
-
if (global.OMNITOOL_RUNNING)
|
75 |
-
{
|
76 |
-
const reply = replyOmnitoolIsRunning();
|
77 |
-
res.send(reply);
|
78 |
-
}
|
79 |
-
else
|
80 |
-
{
|
81 |
-
const status = global.OMNITOOL_RUNNING ? 'External service is running' : 'External service is not running';
|
82 |
-
const message = `<p>WELCOME BACK</p><p>${status}</p>`;
|
83 |
-
res.send(message);
|
84 |
-
}
|
85 |
-
} else
|
86 |
-
{
|
87 |
-
await checkExternalService();
|
88 |
-
if (global.OMNITOOL_RUNNING)
|
89 |
-
{
|
90 |
-
const reply = replyOmnitoolIsRunning();
|
91 |
-
res.send(reply);
|
92 |
-
}
|
93 |
-
else
|
94 |
-
{
|
95 |
-
// Serve the webpage with a button for first-time visitors
|
96 |
-
req.session.isVisited = true;
|
97 |
-
res.send(`
|
98 |
-
<html>
|
99 |
-
<body>
|
100 |
-
<h1>Welcome!</h1>
|
101 |
-
<button onclick="window.open(window.location.href, '_blank')">CLICK ME</button>
|
102 |
-
</body>
|
103 |
-
</html>
|
104 |
-
`);
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
|
112 |
-
async function startServer()
|
113 |
-
{
|
114 |
-
// Start server
|
115 |
-
const PORT = 3000;
|
116 |
-
http.createServer(app).listen(PORT, () =>
|
117 |
-
{
|
118 |
-
console.log(`Server running on port ${PORT}`);
|
119 |
-
});
|
120 |
-
|
121 |
-
|
122 |
-
setInterval(async () =>
|
123 |
-
{
|
124 |
-
await checkExternalService();
|
125 |
-
}, CHECK_OMNI_INTERVAL);
|
126 |
-
|
127 |
-
}
|
128 |
-
main(app);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
myNodeServer.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
-
const VERSION = '0.0.
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
+
const VERSION = '0.6.0.hf.001';
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
node_modules/.bin/mime
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
../mime/cli.js
|
node_modules/.yarn-state.yml
ADDED
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Warning: This file is automatically generated. Removing it is fine, but will
|
2 |
+
# cause your node_modules installation to become invalidated.
|
3 |
+
|
4 |
+
__metadata:
|
5 |
+
version: 1
|
6 |
+
nmMode: classic
|
7 |
+
|
8 |
+
"@types/http-proxy@npm:1.17.14":
|
9 |
+
locations:
|
10 |
+
- "node_modules/@types/http-proxy"
|
11 |
+
|
12 |
+
"@types/node@npm:20.10.3":
|
13 |
+
locations:
|
14 |
+
- "node_modules/@types/node"
|
15 |
+
|
16 |
+
"accepts@npm:1.3.8":
|
17 |
+
locations:
|
18 |
+
- "node_modules/accepts"
|
19 |
+
|
20 |
+
"array-flatten@npm:1.1.1":
|
21 |
+
locations:
|
22 |
+
- "node_modules/array-flatten"
|
23 |
+
|
24 |
+
"asynckit@npm:0.4.0":
|
25 |
+
locations:
|
26 |
+
- "node_modules/asynckit"
|
27 |
+
|
28 |
+
"axios@npm:1.6.2":
|
29 |
+
locations:
|
30 |
+
- "node_modules/axios"
|
31 |
+
|
32 |
+
"body-parser@npm:1.20.1":
|
33 |
+
locations:
|
34 |
+
- "node_modules/body-parser"
|
35 |
+
|
36 |
+
"braces@npm:3.0.2":
|
37 |
+
locations:
|
38 |
+
- "node_modules/braces"
|
39 |
+
|
40 |
+
"bytes@npm:3.1.2":
|
41 |
+
locations:
|
42 |
+
- "node_modules/bytes"
|
43 |
+
|
44 |
+
"call-bind@npm:1.0.5":
|
45 |
+
locations:
|
46 |
+
- "node_modules/call-bind"
|
47 |
+
|
48 |
+
"combined-stream@npm:1.0.8":
|
49 |
+
locations:
|
50 |
+
- "node_modules/combined-stream"
|
51 |
+
|
52 |
+
"content-disposition@npm:0.5.4":
|
53 |
+
locations:
|
54 |
+
- "node_modules/content-disposition"
|
55 |
+
|
56 |
+
"content-type@npm:1.0.5":
|
57 |
+
locations:
|
58 |
+
- "node_modules/content-type"
|
59 |
+
|
60 |
+
"cookie-signature@npm:1.0.6":
|
61 |
+
locations:
|
62 |
+
- "node_modules/cookie-signature"
|
63 |
+
|
64 |
+
"cookie@npm:0.4.2":
|
65 |
+
locations:
|
66 |
+
- "node_modules/cookie"
|
67 |
+
|
68 |
+
"cookie@npm:0.5.0":
|
69 |
+
locations:
|
70 |
+
- "node_modules/express/node_modules/cookie"
|
71 |
+
|
72 |
+
"debug@virtual:0819dbe06c028ed82b45fc11021fc9e474d69a1dd2911cea2d866d094407eaa6ab88fb2220200e1c178168f363713875d8626748d6757a812c36c845e3d6e907#npm:2.6.9":
|
73 |
+
locations:
|
74 |
+
- "node_modules/debug"
|
75 |
+
|
76 |
+
"define-data-property@npm:1.1.1":
|
77 |
+
locations:
|
78 |
+
- "node_modules/define-data-property"
|
79 |
+
|
80 |
+
"delayed-stream@npm:1.0.0":
|
81 |
+
locations:
|
82 |
+
- "node_modules/delayed-stream"
|
83 |
+
|
84 |
+
"depd@npm:2.0.0":
|
85 |
+
locations:
|
86 |
+
- "node_modules/depd"
|
87 |
+
|
88 |
+
"destroy@npm:1.2.0":
|
89 |
+
locations:
|
90 |
+
- "node_modules/destroy"
|
91 |
+
|
92 |
+
"ee-first@npm:1.1.1":
|
93 |
+
locations:
|
94 |
+
- "node_modules/ee-first"
|
95 |
+
|
96 |
+
"encodeurl@npm:1.0.2":
|
97 |
+
locations:
|
98 |
+
- "node_modules/encodeurl"
|
99 |
+
|
100 |
+
"escape-html@npm:1.0.3":
|
101 |
+
locations:
|
102 |
+
- "node_modules/escape-html"
|
103 |
+
|
104 |
+
"etag@npm:1.8.1":
|
105 |
+
locations:
|
106 |
+
- "node_modules/etag"
|
107 |
+
|
108 |
+
"eventemitter3@npm:4.0.7":
|
109 |
+
locations:
|
110 |
+
- "node_modules/eventemitter3"
|
111 |
+
|
112 |
+
"express-session@npm:1.17.3":
|
113 |
+
locations:
|
114 |
+
- "node_modules/express-session"
|
115 |
+
|
116 |
+
"express@npm:4.18.2":
|
117 |
+
locations:
|
118 |
+
- "node_modules/express"
|
119 |
+
|
120 |
+
"fill-range@npm:7.0.1":
|
121 |
+
locations:
|
122 |
+
- "node_modules/fill-range"
|
123 |
+
|
124 |
+
"finalhandler@npm:1.2.0":
|
125 |
+
locations:
|
126 |
+
- "node_modules/finalhandler"
|
127 |
+
|
128 |
+
"follow-redirects@virtual:2334cb6eeeb6b3dfd608966f28539c2de97a7f40c2b9762074181b72a63a8cdcab5646db63b491e1572f204e304748e40aff79a28dbdc8ee85d2dd16cd3803c7#npm:1.15.3":
|
129 |
+
locations:
|
130 |
+
- "node_modules/follow-redirects"
|
131 |
+
|
132 |
+
"form-data@npm:4.0.0":
|
133 |
+
locations:
|
134 |
+
- "node_modules/form-data"
|
135 |
+
|
136 |
+
"forwarded@npm:0.2.0":
|
137 |
+
locations:
|
138 |
+
- "node_modules/forwarded"
|
139 |
+
|
140 |
+
"fresh@npm:0.5.2":
|
141 |
+
locations:
|
142 |
+
- "node_modules/fresh"
|
143 |
+
|
144 |
+
"function-bind@npm:1.1.2":
|
145 |
+
locations:
|
146 |
+
- "node_modules/function-bind"
|
147 |
+
|
148 |
+
"get-intrinsic@npm:1.2.2":
|
149 |
+
locations:
|
150 |
+
- "node_modules/get-intrinsic"
|
151 |
+
|
152 |
+
"gopd@npm:1.0.1":
|
153 |
+
locations:
|
154 |
+
- "node_modules/gopd"
|
155 |
+
|
156 |
+
"has-property-descriptors@npm:1.0.1":
|
157 |
+
locations:
|
158 |
+
- "node_modules/has-property-descriptors"
|
159 |
+
|
160 |
+
"has-proto@npm:1.0.1":
|
161 |
+
locations:
|
162 |
+
- "node_modules/has-proto"
|
163 |
+
|
164 |
+
"has-symbols@npm:1.0.3":
|
165 |
+
locations:
|
166 |
+
- "node_modules/has-symbols"
|
167 |
+
|
168 |
+
"hasown@npm:2.0.0":
|
169 |
+
locations:
|
170 |
+
- "node_modules/hasown"
|
171 |
+
|
172 |
+
"http-errors@npm:2.0.0":
|
173 |
+
locations:
|
174 |
+
- "node_modules/http-errors"
|
175 |
+
|
176 |
+
"http-proxy-middleware@virtual:ddbaaf5feb2fb477cdc1694b6534dcee6f008f7380c4eefc34002266e4860044ca2211f32921bfbbc16a5f053003a1ce5712707bb193bec7c255933bc9263e00#npm:2.0.6":
|
177 |
+
locations:
|
178 |
+
- "node_modules/http-proxy-middleware"
|
179 |
+
|
180 |
+
"http-proxy@npm:1.18.1":
|
181 |
+
locations:
|
182 |
+
- "node_modules/http-proxy"
|
183 |
+
|
184 |
+
"iconv-lite@npm:0.4.24":
|
185 |
+
locations:
|
186 |
+
- "node_modules/iconv-lite"
|
187 |
+
|
188 |
+
"inherits@npm:2.0.4":
|
189 |
+
locations:
|
190 |
+
- "node_modules/inherits"
|
191 |
+
|
192 |
+
"ipaddr.js@npm:1.9.1":
|
193 |
+
locations:
|
194 |
+
- "node_modules/ipaddr.js"
|
195 |
+
|
196 |
+
"is-extglob@npm:2.1.1":
|
197 |
+
locations:
|
198 |
+
- "node_modules/is-extglob"
|
199 |
+
|
200 |
+
"is-glob@npm:4.0.3":
|
201 |
+
locations:
|
202 |
+
- "node_modules/is-glob"
|
203 |
+
|
204 |
+
"is-number@npm:7.0.0":
|
205 |
+
locations:
|
206 |
+
- "node_modules/is-number"
|
207 |
+
|
208 |
+
"is-plain-obj@npm:3.0.0":
|
209 |
+
locations:
|
210 |
+
- "node_modules/is-plain-obj"
|
211 |
+
|
212 |
+
"media-typer@npm:0.3.0":
|
213 |
+
locations:
|
214 |
+
- "node_modules/media-typer"
|
215 |
+
|
216 |
+
"merge-descriptors@npm:1.0.1":
|
217 |
+
locations:
|
218 |
+
- "node_modules/merge-descriptors"
|
219 |
+
|
220 |
+
"methods@npm:1.1.2":
|
221 |
+
locations:
|
222 |
+
- "node_modules/methods"
|
223 |
+
|
224 |
+
"micromatch@npm:4.0.5":
|
225 |
+
locations:
|
226 |
+
- "node_modules/micromatch"
|
227 |
+
|
228 |
+
"mime-db@npm:1.52.0":
|
229 |
+
locations:
|
230 |
+
- "node_modules/mime-db"
|
231 |
+
|
232 |
+
"mime-types@npm:2.1.35":
|
233 |
+
locations:
|
234 |
+
- "node_modules/mime-types"
|
235 |
+
|
236 |
+
"mime@npm:1.6.0":
|
237 |
+
locations:
|
238 |
+
- "node_modules/mime"
|
239 |
+
|
240 |
+
"ms@npm:2.0.0":
|
241 |
+
locations:
|
242 |
+
- "node_modules/ms"
|
243 |
+
|
244 |
+
"ms@npm:2.1.3":
|
245 |
+
locations:
|
246 |
+
- "node_modules/send/node_modules/ms"
|
247 |
+
|
248 |
+
"negotiator@npm:0.6.3":
|
249 |
+
locations:
|
250 |
+
- "node_modules/negotiator"
|
251 |
+
|
252 |
+
"object-inspect@npm:1.13.1":
|
253 |
+
locations:
|
254 |
+
- "node_modules/object-inspect"
|
255 |
+
|
256 |
+
"omnitool_test_3@workspace:.":
|
257 |
+
locations:
|
258 |
+
- ""
|
259 |
+
bin:
|
260 |
+
".":
|
261 |
+
"mime": "mime/cli.js"
|
262 |
+
|
263 |
+
"on-finished@npm:2.4.1":
|
264 |
+
locations:
|
265 |
+
- "node_modules/on-finished"
|
266 |
+
|
267 |
+
"on-headers@npm:1.0.2":
|
268 |
+
locations:
|
269 |
+
- "node_modules/on-headers"
|
270 |
+
|
271 |
+
"parseurl@npm:1.3.3":
|
272 |
+
locations:
|
273 |
+
- "node_modules/parseurl"
|
274 |
+
|
275 |
+
"path-to-regexp@npm:0.1.7":
|
276 |
+
locations:
|
277 |
+
- "node_modules/path-to-regexp"
|
278 |
+
|
279 |
+
"picomatch@npm:2.3.1":
|
280 |
+
locations:
|
281 |
+
- "node_modules/picomatch"
|
282 |
+
|
283 |
+
"proxy-addr@npm:2.0.7":
|
284 |
+
locations:
|
285 |
+
- "node_modules/proxy-addr"
|
286 |
+
|
287 |
+
"proxy-from-env@npm:1.1.0":
|
288 |
+
locations:
|
289 |
+
- "node_modules/proxy-from-env"
|
290 |
+
|
291 |
+
"qs@npm:6.11.0":
|
292 |
+
locations:
|
293 |
+
- "node_modules/qs"
|
294 |
+
|
295 |
+
"random-bytes@npm:1.0.0":
|
296 |
+
locations:
|
297 |
+
- "node_modules/random-bytes"
|
298 |
+
|
299 |
+
"range-parser@npm:1.2.1":
|
300 |
+
locations:
|
301 |
+
- "node_modules/range-parser"
|
302 |
+
|
303 |
+
"raw-body@npm:2.5.1":
|
304 |
+
locations:
|
305 |
+
- "node_modules/raw-body"
|
306 |
+
|
307 |
+
"requires-port@npm:1.0.0":
|
308 |
+
locations:
|
309 |
+
- "node_modules/requires-port"
|
310 |
+
|
311 |
+
"safe-buffer@npm:5.2.1":
|
312 |
+
locations:
|
313 |
+
- "node_modules/safe-buffer"
|
314 |
+
|
315 |
+
"safer-buffer@npm:2.1.2":
|
316 |
+
locations:
|
317 |
+
- "node_modules/safer-buffer"
|
318 |
+
|
319 |
+
"send@npm:0.18.0":
|
320 |
+
locations:
|
321 |
+
- "node_modules/send"
|
322 |
+
|
323 |
+
"serve-static@npm:1.15.0":
|
324 |
+
locations:
|
325 |
+
- "node_modules/serve-static"
|
326 |
+
|
327 |
+
"set-function-length@npm:1.1.1":
|
328 |
+
locations:
|
329 |
+
- "node_modules/set-function-length"
|
330 |
+
|
331 |
+
"setprototypeof@npm:1.2.0":
|
332 |
+
locations:
|
333 |
+
- "node_modules/setprototypeof"
|
334 |
+
|
335 |
+
"side-channel@npm:1.0.4":
|
336 |
+
locations:
|
337 |
+
- "node_modules/side-channel"
|
338 |
+
|
339 |
+
"statuses@npm:2.0.1":
|
340 |
+
locations:
|
341 |
+
- "node_modules/statuses"
|
342 |
+
|
343 |
+
"to-regex-range@npm:5.0.1":
|
344 |
+
locations:
|
345 |
+
- "node_modules/to-regex-range"
|
346 |
+
|
347 |
+
"toidentifier@npm:1.0.1":
|
348 |
+
locations:
|
349 |
+
- "node_modules/toidentifier"
|
350 |
+
|
351 |
+
"type-is@npm:1.6.18":
|
352 |
+
locations:
|
353 |
+
- "node_modules/type-is"
|
354 |
+
|
355 |
+
"uid-safe@npm:2.1.5":
|
356 |
+
locations:
|
357 |
+
- "node_modules/uid-safe"
|
358 |
+
|
359 |
+
"undici-types@npm:5.26.5":
|
360 |
+
locations:
|
361 |
+
- "node_modules/undici-types"
|
362 |
+
|
363 |
+
"unpipe@npm:1.0.0":
|
364 |
+
locations:
|
365 |
+
- "node_modules/unpipe"
|
366 |
+
|
367 |
+
"utils-merge@npm:1.0.1":
|
368 |
+
locations:
|
369 |
+
- "node_modules/utils-merge"
|
370 |
+
|
371 |
+
"vary@npm:1.1.2":
|
372 |
+
locations:
|
373 |
+
- "node_modules/vary"
|
node_modules/@types/http-proxy/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
node_modules/@types/http-proxy/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/http-proxy`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for http-proxy (https://github.com/nodejitsu/node-http-proxy).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-proxy.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Tue, 07 Nov 2023 03:09:37 GMT
|
12 |
+
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
13 |
+
|
14 |
+
# Credits
|
15 |
+
These definitions were written by [Maxime LUCE](https://github.com/SomaticIT), [Florian Oellerich](https://github.com/Raigen), [Daniel Schmidt](https://github.com/DanielMSchmidt), [Jordan Abreu](https://github.com/jabreu610), and [Samuel Bodin](https://github.com/bodinsamuel).
|
node_modules/@types/http-proxy/index.d.ts
ADDED
@@ -0,0 +1,250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/// <reference types="node" />
|
2 |
+
|
3 |
+
import * as events from "events";
|
4 |
+
import * as http from "http";
|
5 |
+
import * as https from "https";
|
6 |
+
import * as net from "net";
|
7 |
+
import * as stream from "stream";
|
8 |
+
import * as url from "url";
|
9 |
+
|
10 |
+
interface ProxyTargetDetailed {
|
11 |
+
host: string;
|
12 |
+
port: number;
|
13 |
+
protocol?: string | undefined;
|
14 |
+
hostname?: string | undefined;
|
15 |
+
socketPath?: string | undefined;
|
16 |
+
key?: string | undefined;
|
17 |
+
passphrase?: string | undefined;
|
18 |
+
pfx?: Buffer | string | undefined;
|
19 |
+
cert?: string | undefined;
|
20 |
+
ca?: string | undefined;
|
21 |
+
ciphers?: string | undefined;
|
22 |
+
secureProtocol?: string | undefined;
|
23 |
+
}
|
24 |
+
|
25 |
+
declare class Server<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>
|
26 |
+
extends events.EventEmitter
|
27 |
+
{
|
28 |
+
/**
|
29 |
+
* Creates the proxy server with specified options.
|
30 |
+
* @param options - Config object passed to the proxy
|
31 |
+
*/
|
32 |
+
constructor(options?: Server.ServerOptions);
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Used for proxying regular HTTP(S) requests
|
36 |
+
* @param req - Client request.
|
37 |
+
* @param res - Client response.
|
38 |
+
* @param options - Additional options.
|
39 |
+
*/
|
40 |
+
web(
|
41 |
+
req: http.IncomingMessage,
|
42 |
+
res: http.ServerResponse,
|
43 |
+
options?: Server.ServerOptions,
|
44 |
+
callback?: Server.ErrorCallback,
|
45 |
+
): void;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Used for proxying regular HTTP(S) requests
|
49 |
+
* @param req - Client request.
|
50 |
+
* @param socket - Client socket.
|
51 |
+
* @param head - Client head.
|
52 |
+
* @param options - Additionnal options.
|
53 |
+
*/
|
54 |
+
ws(
|
55 |
+
req: http.IncomingMessage,
|
56 |
+
socket: any,
|
57 |
+
head: any,
|
58 |
+
options?: Server.ServerOptions,
|
59 |
+
callback?: Server.ErrorCallback,
|
60 |
+
): void;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* A function that wraps the object in a webserver, for your convenience
|
64 |
+
* @param port - Port to listen on
|
65 |
+
* @param hostname - The hostname to listen on
|
66 |
+
*/
|
67 |
+
listen(port: number, hostname?: string): Server<TIncomingMessage, TServerResponse>;
|
68 |
+
|
69 |
+
/**
|
70 |
+
* A function that closes the inner webserver and stops listening on given port
|
71 |
+
*/
|
72 |
+
close(callback?: () => void): void;
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Creates the proxy server with specified options.
|
76 |
+
* @param options Config object passed to the proxy
|
77 |
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
78 |
+
*/
|
79 |
+
// tslint:disable:no-unnecessary-generics
|
80 |
+
static createProxyServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
81 |
+
options?: Server.ServerOptions,
|
82 |
+
): Server<TIncomingMessage, TServerResponse>;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Creates the proxy server with specified options.
|
86 |
+
* @param options Config object passed to the proxy
|
87 |
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
88 |
+
*/
|
89 |
+
// tslint:disable:no-unnecessary-generics
|
90 |
+
static createServer<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
91 |
+
options?: Server.ServerOptions,
|
92 |
+
): Server<TIncomingMessage, TServerResponse>;
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Creates the proxy server with specified options.
|
96 |
+
* @param options Config object passed to the proxy
|
97 |
+
* @returns Proxy object with handlers for `ws` and `web` requests
|
98 |
+
*/
|
99 |
+
// tslint:disable:no-unnecessary-generics
|
100 |
+
static createProxy<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse>(
|
101 |
+
options?: Server.ServerOptions,
|
102 |
+
): Server<TIncomingMessage, TServerResponse>;
|
103 |
+
|
104 |
+
addListener(event: string, listener: () => void): this;
|
105 |
+
on(event: string, listener: () => void): this;
|
106 |
+
on(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this;
|
107 |
+
on(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this;
|
108 |
+
on(
|
109 |
+
event: "proxyReq",
|
110 |
+
listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>,
|
111 |
+
): this;
|
112 |
+
on(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this;
|
113 |
+
on(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this;
|
114 |
+
on(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this;
|
115 |
+
on(event: "end", listener: Server.EndCallback<TIncomingMessage, TServerResponse>): this;
|
116 |
+
on(event: "open", listener: Server.OpenCallback): this;
|
117 |
+
on(event: "close", listener: Server.CloseCallback<TIncomingMessage>): this;
|
118 |
+
|
119 |
+
once(event: string, listener: () => void): this;
|
120 |
+
once(event: "error", listener: Server.ErrorCallback<Error, TIncomingMessage, TServerResponse>): this;
|
121 |
+
once(event: "start", listener: Server.StartCallback<TIncomingMessage, TServerResponse>): this;
|
122 |
+
once(
|
123 |
+
event: "proxyReq",
|
124 |
+
listener: Server.ProxyReqCallback<http.ClientRequest, TIncomingMessage, TServerResponse>,
|
125 |
+
): this;
|
126 |
+
once(event: "proxyRes", listener: Server.ProxyResCallback<TIncomingMessage, TServerResponse>): this;
|
127 |
+
once(event: "proxyReqWs", listener: Server.ProxyReqWsCallback<http.ClientRequest, TIncomingMessage>): this;
|
128 |
+
once(event: "econnreset", listener: Server.EconnresetCallback<Error, TIncomingMessage, TServerResponse>): this;
|
129 |
+
once(event: "end", listener: Server.EndCallback<TIncomingMessage, TServerResponse>): this;
|
130 |
+
once(event: "open", listener: Server.OpenCallback): this;
|
131 |
+
once(event: "close", listener: Server.CloseCallback<TIncomingMessage>): this;
|
132 |
+
removeListener(event: string, listener: () => void): this;
|
133 |
+
removeAllListeners(event?: string): this;
|
134 |
+
getMaxListeners(): number;
|
135 |
+
setMaxListeners(n: number): this;
|
136 |
+
listeners(event: string): Array<() => void>;
|
137 |
+
emit(event: string, ...args: any[]): boolean;
|
138 |
+
listenerCount(type: string): number;
|
139 |
+
}
|
140 |
+
|
141 |
+
declare namespace Server {
|
142 |
+
type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed;
|
143 |
+
type ProxyTargetUrl = string | Partial<url.Url>;
|
144 |
+
|
145 |
+
interface ServerOptions {
|
146 |
+
/** URL string to be parsed with the url module. */
|
147 |
+
target?: ProxyTarget | undefined;
|
148 |
+
/** URL string to be parsed with the url module. */
|
149 |
+
forward?: ProxyTargetUrl | undefined;
|
150 |
+
/** Object to be passed to http(s).request. */
|
151 |
+
agent?: any;
|
152 |
+
/** Object to be passed to https.createServer(). */
|
153 |
+
ssl?: any;
|
154 |
+
/** If you want to proxy websockets. */
|
155 |
+
ws?: boolean | undefined;
|
156 |
+
/** Adds x- forward headers. */
|
157 |
+
xfwd?: boolean | undefined;
|
158 |
+
/** Verify SSL certificate. */
|
159 |
+
secure?: boolean | undefined;
|
160 |
+
/** Explicitly specify if we are proxying to another proxy. */
|
161 |
+
toProxy?: boolean | undefined;
|
162 |
+
/** Specify whether you want to prepend the target's path to the proxy path. */
|
163 |
+
prependPath?: boolean | undefined;
|
164 |
+
/** Specify whether you want to ignore the proxy path of the incoming request. */
|
165 |
+
ignorePath?: boolean | undefined;
|
166 |
+
/** Local interface string to bind for outgoing connections. */
|
167 |
+
localAddress?: string | undefined;
|
168 |
+
/** Changes the origin of the host header to the target URL. */
|
169 |
+
changeOrigin?: boolean | undefined;
|
170 |
+
/** specify whether you want to keep letter case of response header key */
|
171 |
+
preserveHeaderKeyCase?: boolean | undefined;
|
172 |
+
/** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
173 |
+
auth?: string | undefined;
|
174 |
+
/** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
175 |
+
hostRewrite?: string | undefined;
|
176 |
+
/** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
177 |
+
autoRewrite?: boolean | undefined;
|
178 |
+
/** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
179 |
+
protocolRewrite?: string | undefined;
|
180 |
+
/** rewrites domain of set-cookie headers. */
|
181 |
+
cookieDomainRewrite?: false | string | { [oldDomain: string]: string } | undefined;
|
182 |
+
/** rewrites path of set-cookie headers. Default: false */
|
183 |
+
cookiePathRewrite?: false | string | { [oldPath: string]: string } | undefined;
|
184 |
+
/** object with extra headers to be added to target requests. */
|
185 |
+
headers?: { [header: string]: string } | undefined;
|
186 |
+
/** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
187 |
+
proxyTimeout?: number | undefined;
|
188 |
+
/** Timeout (in milliseconds) for incoming requests */
|
189 |
+
timeout?: number | undefined;
|
190 |
+
/** Specify whether you want to follow redirects. Default: false */
|
191 |
+
followRedirects?: boolean | undefined;
|
192 |
+
/** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
193 |
+
selfHandleResponse?: boolean | undefined;
|
194 |
+
/** Buffer */
|
195 |
+
buffer?: stream.Stream | undefined;
|
196 |
+
}
|
197 |
+
|
198 |
+
type StartCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
199 |
+
req: TIncomingMessage,
|
200 |
+
res: TServerResponse,
|
201 |
+
target: ProxyTargetUrl,
|
202 |
+
) => void;
|
203 |
+
type ProxyReqCallback<
|
204 |
+
TClientRequest = http.ClientRequest,
|
205 |
+
TIncomingMessage = http.IncomingMessage,
|
206 |
+
TServerResponse = http.ServerResponse,
|
207 |
+
> = (proxyReq: TClientRequest, req: TIncomingMessage, res: TServerResponse, options: ServerOptions) => void;
|
208 |
+
type ProxyResCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
209 |
+
proxyRes: TIncomingMessage,
|
210 |
+
req: TIncomingMessage,
|
211 |
+
res: TServerResponse,
|
212 |
+
) => void;
|
213 |
+
type ProxyReqWsCallback<TClientRequest = http.ClientRequest, TIncomingMessage = http.IncomingMessage> = (
|
214 |
+
proxyReq: TClientRequest,
|
215 |
+
req: TIncomingMessage,
|
216 |
+
socket: net.Socket,
|
217 |
+
options: ServerOptions,
|
218 |
+
head: any,
|
219 |
+
) => void;
|
220 |
+
type EconnresetCallback<
|
221 |
+
TError = Error,
|
222 |
+
TIncomingMessage = http.IncomingMessage,
|
223 |
+
TServerResponse = http.ServerResponse,
|
224 |
+
> = (
|
225 |
+
err: TError,
|
226 |
+
req: TIncomingMessage,
|
227 |
+
res: TServerResponse,
|
228 |
+
target: ProxyTargetUrl,
|
229 |
+
) => void;
|
230 |
+
type EndCallback<TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> = (
|
231 |
+
req: TIncomingMessage,
|
232 |
+
res: TServerResponse,
|
233 |
+
proxyRes: TIncomingMessage,
|
234 |
+
) => void;
|
235 |
+
type OpenCallback = (proxySocket: net.Socket) => void;
|
236 |
+
type CloseCallback<TIncomingMessage = http.IncomingMessage> = (
|
237 |
+
proxyRes: TIncomingMessage,
|
238 |
+
proxySocket: net.Socket,
|
239 |
+
proxyHead: any,
|
240 |
+
) => void;
|
241 |
+
type ErrorCallback<TError = Error, TIncomingMessage = http.IncomingMessage, TServerResponse = http.ServerResponse> =
|
242 |
+
(
|
243 |
+
err: TError,
|
244 |
+
req: TIncomingMessage,
|
245 |
+
res: TServerResponse | net.Socket,
|
246 |
+
target?: ProxyTargetUrl,
|
247 |
+
) => void;
|
248 |
+
}
|
249 |
+
|
250 |
+
export = Server;
|
node_modules/@types/http-proxy/package.json
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@types/http-proxy",
|
3 |
+
"version": "1.17.14",
|
4 |
+
"description": "TypeScript definitions for http-proxy",
|
5 |
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/http-proxy",
|
6 |
+
"license": "MIT",
|
7 |
+
"contributors": [
|
8 |
+
{
|
9 |
+
"name": "Maxime LUCE",
|
10 |
+
"githubUsername": "SomaticIT",
|
11 |
+
"url": "https://github.com/SomaticIT"
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "Florian Oellerich",
|
15 |
+
"githubUsername": "Raigen",
|
16 |
+
"url": "https://github.com/Raigen"
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"name": "Daniel Schmidt",
|
20 |
+
"githubUsername": "DanielMSchmidt",
|
21 |
+
"url": "https://github.com/DanielMSchmidt"
|
22 |
+
},
|
23 |
+
{
|
24 |
+
"name": "Jordan Abreu",
|
25 |
+
"githubUsername": "jabreu610",
|
26 |
+
"url": "https://github.com/jabreu610"
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"name": "Samuel Bodin",
|
30 |
+
"githubUsername": "bodinsamuel",
|
31 |
+
"url": "https://github.com/bodinsamuel"
|
32 |
+
}
|
33 |
+
],
|
34 |
+
"main": "",
|
35 |
+
"types": "index.d.ts",
|
36 |
+
"repository": {
|
37 |
+
"type": "git",
|
38 |
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
39 |
+
"directory": "types/http-proxy"
|
40 |
+
},
|
41 |
+
"scripts": {},
|
42 |
+
"dependencies": {
|
43 |
+
"@types/node": "*"
|
44 |
+
},
|
45 |
+
"typesPublisherContentHash": "3e198b1ca48b5a5de433fc322508d2fec21a03c1b52c9470ee47b725146db123",
|
46 |
+
"typeScriptVersion": "4.5"
|
47 |
+
}
|
node_modules/@types/node/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
node_modules/@types/node/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/node`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for node (https://nodejs.org/).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Sun, 03 Dec 2023 18:07:12 GMT
|
12 |
+
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
|
13 |
+
|
14 |
+
# Credits
|
15 |
+
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
|
node_modules/@types/node/assert.d.ts
ADDED
@@ -0,0 +1,996 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:assert` module provides a set of assertion functions for verifying
|
3 |
+
* invariants.
|
4 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js)
|
5 |
+
*/
|
6 |
+
declare module "assert" {
|
7 |
+
/**
|
8 |
+
* An alias of {@link ok}.
|
9 |
+
* @since v0.5.9
|
10 |
+
* @param value The input that is checked for being truthy.
|
11 |
+
*/
|
12 |
+
function assert(value: unknown, message?: string | Error): asserts value;
|
13 |
+
namespace assert {
|
14 |
+
/**
|
15 |
+
* Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class.
|
16 |
+
*/
|
17 |
+
class AssertionError extends Error {
|
18 |
+
/**
|
19 |
+
* Set to the `actual` argument for methods such as {@link assert.strictEqual()}.
|
20 |
+
*/
|
21 |
+
actual: unknown;
|
22 |
+
/**
|
23 |
+
* Set to the `expected` argument for methods such as {@link assert.strictEqual()}.
|
24 |
+
*/
|
25 |
+
expected: unknown;
|
26 |
+
/**
|
27 |
+
* Set to the passed in operator value.
|
28 |
+
*/
|
29 |
+
operator: string;
|
30 |
+
/**
|
31 |
+
* Indicates if the message was auto-generated (`true`) or not.
|
32 |
+
*/
|
33 |
+
generatedMessage: boolean;
|
34 |
+
/**
|
35 |
+
* Value is always `ERR_ASSERTION` to show that the error is an assertion error.
|
36 |
+
*/
|
37 |
+
code: "ERR_ASSERTION";
|
38 |
+
constructor(options?: {
|
39 |
+
/** If provided, the error message is set to this value. */
|
40 |
+
message?: string | undefined;
|
41 |
+
/** The `actual` property on the error instance. */
|
42 |
+
actual?: unknown | undefined;
|
43 |
+
/** The `expected` property on the error instance. */
|
44 |
+
expected?: unknown | undefined;
|
45 |
+
/** The `operator` property on the error instance. */
|
46 |
+
operator?: string | undefined;
|
47 |
+
/** If provided, the generated stack trace omits frames before this function. */
|
48 |
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
49 |
+
stackStartFn?: Function | undefined;
|
50 |
+
});
|
51 |
+
}
|
52 |
+
/**
|
53 |
+
* This feature is deprecated and will be removed in a future version.
|
54 |
+
* Please consider using alternatives such as the `mock` helper function.
|
55 |
+
* @since v14.2.0, v12.19.0
|
56 |
+
* @deprecated Deprecated
|
57 |
+
*/
|
58 |
+
class CallTracker {
|
59 |
+
/**
|
60 |
+
* The wrapper function is expected to be called exactly `exact` times. If the
|
61 |
+
* function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
|
62 |
+
* error.
|
63 |
+
*
|
64 |
+
* ```js
|
65 |
+
* import assert from 'node:assert';
|
66 |
+
*
|
67 |
+
* // Creates call tracker.
|
68 |
+
* const tracker = new assert.CallTracker();
|
69 |
+
*
|
70 |
+
* function func() {}
|
71 |
+
*
|
72 |
+
* // Returns a function that wraps func() that must be called exact times
|
73 |
+
* // before tracker.verify().
|
74 |
+
* const callsfunc = tracker.calls(func);
|
75 |
+
* ```
|
76 |
+
* @since v14.2.0, v12.19.0
|
77 |
+
* @param [fn='A no-op function']
|
78 |
+
* @param [exact=1]
|
79 |
+
* @return that wraps `fn`.
|
80 |
+
*/
|
81 |
+
calls(exact?: number): () => void;
|
82 |
+
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
83 |
+
/**
|
84 |
+
* Example:
|
85 |
+
*
|
86 |
+
* ```js
|
87 |
+
* import assert from 'node:assert';
|
88 |
+
*
|
89 |
+
* const tracker = new assert.CallTracker();
|
90 |
+
*
|
91 |
+
* function func() {}
|
92 |
+
* const callsfunc = tracker.calls(func);
|
93 |
+
* callsfunc(1, 2, 3);
|
94 |
+
*
|
95 |
+
* assert.deepStrictEqual(tracker.getCalls(callsfunc),
|
96 |
+
* [{ thisArg: undefined, arguments: [1, 2, 3] }]);
|
97 |
+
* ```
|
98 |
+
* @since v18.8.0, v16.18.0
|
99 |
+
* @param fn
|
100 |
+
* @return An Array with all the calls to a tracked function.
|
101 |
+
*/
|
102 |
+
getCalls(fn: Function): CallTrackerCall[];
|
103 |
+
/**
|
104 |
+
* The arrays contains information about the expected and actual number of calls of
|
105 |
+
* the functions that have not been called the expected number of times.
|
106 |
+
*
|
107 |
+
* ```js
|
108 |
+
* import assert from 'node:assert';
|
109 |
+
*
|
110 |
+
* // Creates call tracker.
|
111 |
+
* const tracker = new assert.CallTracker();
|
112 |
+
*
|
113 |
+
* function func() {}
|
114 |
+
*
|
115 |
+
* // Returns a function that wraps func() that must be called exact times
|
116 |
+
* // before tracker.verify().
|
117 |
+
* const callsfunc = tracker.calls(func, 2);
|
118 |
+
*
|
119 |
+
* // Returns an array containing information on callsfunc()
|
120 |
+
* console.log(tracker.report());
|
121 |
+
* // [
|
122 |
+
* // {
|
123 |
+
* // message: 'Expected the func function to be executed 2 time(s) but was
|
124 |
+
* // executed 0 time(s).',
|
125 |
+
* // actual: 0,
|
126 |
+
* // expected: 2,
|
127 |
+
* // operator: 'func',
|
128 |
+
* // stack: stack trace
|
129 |
+
* // }
|
130 |
+
* // ]
|
131 |
+
* ```
|
132 |
+
* @since v14.2.0, v12.19.0
|
133 |
+
* @return An Array of objects containing information about the wrapper functions returned by `calls`.
|
134 |
+
*/
|
135 |
+
report(): CallTrackerReportInformation[];
|
136 |
+
/**
|
137 |
+
* Reset calls of the call tracker.
|
138 |
+
* If a tracked function is passed as an argument, the calls will be reset for it.
|
139 |
+
* If no arguments are passed, all tracked functions will be reset.
|
140 |
+
*
|
141 |
+
* ```js
|
142 |
+
* import assert from 'node:assert';
|
143 |
+
*
|
144 |
+
* const tracker = new assert.CallTracker();
|
145 |
+
*
|
146 |
+
* function func() {}
|
147 |
+
* const callsfunc = tracker.calls(func);
|
148 |
+
*
|
149 |
+
* callsfunc();
|
150 |
+
* // Tracker was called once
|
151 |
+
* assert.strictEqual(tracker.getCalls(callsfunc).length, 1);
|
152 |
+
*
|
153 |
+
* tracker.reset(callsfunc);
|
154 |
+
* assert.strictEqual(tracker.getCalls(callsfunc).length, 0);
|
155 |
+
* ```
|
156 |
+
* @since v18.8.0, v16.18.0
|
157 |
+
* @param fn a tracked function to reset.
|
158 |
+
*/
|
159 |
+
reset(fn?: Function): void;
|
160 |
+
/**
|
161 |
+
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
162 |
+
* have not been called the expected number of times.
|
163 |
+
*
|
164 |
+
* ```js
|
165 |
+
* import assert from 'node:assert';
|
166 |
+
*
|
167 |
+
* // Creates call tracker.
|
168 |
+
* const tracker = new assert.CallTracker();
|
169 |
+
*
|
170 |
+
* function func() {}
|
171 |
+
*
|
172 |
+
* // Returns a function that wraps func() that must be called exact times
|
173 |
+
* // before tracker.verify().
|
174 |
+
* const callsfunc = tracker.calls(func, 2);
|
175 |
+
*
|
176 |
+
* callsfunc();
|
177 |
+
*
|
178 |
+
* // Will throw an error since callsfunc() was only called once.
|
179 |
+
* tracker.verify();
|
180 |
+
* ```
|
181 |
+
* @since v14.2.0, v12.19.0
|
182 |
+
*/
|
183 |
+
verify(): void;
|
184 |
+
}
|
185 |
+
interface CallTrackerCall {
|
186 |
+
thisArg: object;
|
187 |
+
arguments: unknown[];
|
188 |
+
}
|
189 |
+
interface CallTrackerReportInformation {
|
190 |
+
message: string;
|
191 |
+
/** The actual number of times the function was called. */
|
192 |
+
actual: number;
|
193 |
+
/** The number of times the function was expected to be called. */
|
194 |
+
expected: number;
|
195 |
+
/** The name of the function that is wrapped. */
|
196 |
+
operator: string;
|
197 |
+
/** A stack trace of the function. */
|
198 |
+
stack: object;
|
199 |
+
}
|
200 |
+
type AssertPredicate = RegExp | (new() => object) | ((thrown: unknown) => boolean) | object | Error;
|
201 |
+
/**
|
202 |
+
* Throws an `AssertionError` with the provided error message or a default
|
203 |
+
* error message. If the `message` parameter is an instance of an `Error` then
|
204 |
+
* it will be thrown instead of the `AssertionError`.
|
205 |
+
*
|
206 |
+
* ```js
|
207 |
+
* import assert from 'node:assert/strict';
|
208 |
+
*
|
209 |
+
* assert.fail();
|
210 |
+
* // AssertionError [ERR_ASSERTION]: Failed
|
211 |
+
*
|
212 |
+
* assert.fail('boom');
|
213 |
+
* // AssertionError [ERR_ASSERTION]: boom
|
214 |
+
*
|
215 |
+
* assert.fail(new TypeError('need array'));
|
216 |
+
* // TypeError: need array
|
217 |
+
* ```
|
218 |
+
*
|
219 |
+
* Using `assert.fail()` with more than two arguments is possible but deprecated.
|
220 |
+
* See below for further details.
|
221 |
+
* @since v0.1.21
|
222 |
+
* @param [message='Failed']
|
223 |
+
*/
|
224 |
+
function fail(message?: string | Error): never;
|
225 |
+
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
226 |
+
function fail(
|
227 |
+
actual: unknown,
|
228 |
+
expected: unknown,
|
229 |
+
message?: string | Error,
|
230 |
+
operator?: string,
|
231 |
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
232 |
+
stackStartFn?: Function,
|
233 |
+
): never;
|
234 |
+
/**
|
235 |
+
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
236 |
+
*
|
237 |
+
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
238 |
+
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
239 |
+
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
240 |
+
*
|
241 |
+
* Be aware that in the `repl` the error message will be different to the one
|
242 |
+
* thrown in a file! See below for further details.
|
243 |
+
*
|
244 |
+
* ```js
|
245 |
+
* import assert from 'node:assert/strict';
|
246 |
+
*
|
247 |
+
* assert.ok(true);
|
248 |
+
* // OK
|
249 |
+
* assert.ok(1);
|
250 |
+
* // OK
|
251 |
+
*
|
252 |
+
* assert.ok();
|
253 |
+
* // AssertionError: No value argument passed to `assert.ok()`
|
254 |
+
*
|
255 |
+
* assert.ok(false, 'it\'s false');
|
256 |
+
* // AssertionError: it's false
|
257 |
+
*
|
258 |
+
* // In the repl:
|
259 |
+
* assert.ok(typeof 123 === 'string');
|
260 |
+
* // AssertionError: false == true
|
261 |
+
*
|
262 |
+
* // In a file (e.g. test.js):
|
263 |
+
* assert.ok(typeof 123 === 'string');
|
264 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
265 |
+
* //
|
266 |
+
* // assert.ok(typeof 123 === 'string')
|
267 |
+
*
|
268 |
+
* assert.ok(false);
|
269 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
270 |
+
* //
|
271 |
+
* // assert.ok(false)
|
272 |
+
*
|
273 |
+
* assert.ok(0);
|
274 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
275 |
+
* //
|
276 |
+
* // assert.ok(0)
|
277 |
+
* ```
|
278 |
+
*
|
279 |
+
* ```js
|
280 |
+
* import assert from 'node:assert/strict';
|
281 |
+
*
|
282 |
+
* // Using `assert()` works the same:
|
283 |
+
* assert(0);
|
284 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
285 |
+
* //
|
286 |
+
* // assert(0)
|
287 |
+
* ```
|
288 |
+
* @since v0.1.21
|
289 |
+
*/
|
290 |
+
function ok(value: unknown, message?: string | Error): asserts value;
|
291 |
+
/**
|
292 |
+
* **Strict assertion mode**
|
293 |
+
*
|
294 |
+
* An alias of {@link strictEqual}.
|
295 |
+
*
|
296 |
+
* **Legacy assertion mode**
|
297 |
+
*
|
298 |
+
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
299 |
+
*
|
300 |
+
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
301 |
+
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
302 |
+
* and treated as being identical if both sides are `NaN`.
|
303 |
+
*
|
304 |
+
* ```js
|
305 |
+
* import assert from 'node:assert';
|
306 |
+
*
|
307 |
+
* assert.equal(1, 1);
|
308 |
+
* // OK, 1 == 1
|
309 |
+
* assert.equal(1, '1');
|
310 |
+
* // OK, 1 == '1'
|
311 |
+
* assert.equal(NaN, NaN);
|
312 |
+
* // OK
|
313 |
+
*
|
314 |
+
* assert.equal(1, 2);
|
315 |
+
* // AssertionError: 1 == 2
|
316 |
+
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
317 |
+
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
318 |
+
* ```
|
319 |
+
*
|
320 |
+
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
321 |
+
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
322 |
+
* @since v0.1.21
|
323 |
+
*/
|
324 |
+
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
325 |
+
/**
|
326 |
+
* **Strict assertion mode**
|
327 |
+
*
|
328 |
+
* An alias of {@link notStrictEqual}.
|
329 |
+
*
|
330 |
+
* **Legacy assertion mode**
|
331 |
+
*
|
332 |
+
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
333 |
+
*
|
334 |
+
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
335 |
+
* specially handled and treated as being identical if both sides are `NaN`.
|
336 |
+
*
|
337 |
+
* ```js
|
338 |
+
* import assert from 'node:assert';
|
339 |
+
*
|
340 |
+
* assert.notEqual(1, 2);
|
341 |
+
* // OK
|
342 |
+
*
|
343 |
+
* assert.notEqual(1, 1);
|
344 |
+
* // AssertionError: 1 != 1
|
345 |
+
*
|
346 |
+
* assert.notEqual(1, '1');
|
347 |
+
* // AssertionError: 1 != '1'
|
348 |
+
* ```
|
349 |
+
*
|
350 |
+
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
351 |
+
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
352 |
+
* @since v0.1.21
|
353 |
+
*/
|
354 |
+
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
355 |
+
/**
|
356 |
+
* **Strict assertion mode**
|
357 |
+
*
|
358 |
+
* An alias of {@link deepStrictEqual}.
|
359 |
+
*
|
360 |
+
* **Legacy assertion mode**
|
361 |
+
*
|
362 |
+
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
363 |
+
*
|
364 |
+
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
365 |
+
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
366 |
+
* surprising results.
|
367 |
+
*
|
368 |
+
* _Deep equality_ means that the enumerable "own" properties of child objects
|
369 |
+
* are also recursively evaluated by the following rules.
|
370 |
+
* @since v0.1.21
|
371 |
+
*/
|
372 |
+
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
373 |
+
/**
|
374 |
+
* **Strict assertion mode**
|
375 |
+
*
|
376 |
+
* An alias of {@link notDeepStrictEqual}.
|
377 |
+
*
|
378 |
+
* **Legacy assertion mode**
|
379 |
+
*
|
380 |
+
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
381 |
+
*
|
382 |
+
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
383 |
+
*
|
384 |
+
* ```js
|
385 |
+
* import assert from 'node:assert';
|
386 |
+
*
|
387 |
+
* const obj1 = {
|
388 |
+
* a: {
|
389 |
+
* b: 1,
|
390 |
+
* },
|
391 |
+
* };
|
392 |
+
* const obj2 = {
|
393 |
+
* a: {
|
394 |
+
* b: 2,
|
395 |
+
* },
|
396 |
+
* };
|
397 |
+
* const obj3 = {
|
398 |
+
* a: {
|
399 |
+
* b: 1,
|
400 |
+
* },
|
401 |
+
* };
|
402 |
+
* const obj4 = { __proto__: obj1 };
|
403 |
+
*
|
404 |
+
* assert.notDeepEqual(obj1, obj1);
|
405 |
+
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
406 |
+
*
|
407 |
+
* assert.notDeepEqual(obj1, obj2);
|
408 |
+
* // OK
|
409 |
+
*
|
410 |
+
* assert.notDeepEqual(obj1, obj3);
|
411 |
+
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
412 |
+
*
|
413 |
+
* assert.notDeepEqual(obj1, obj4);
|
414 |
+
* // OK
|
415 |
+
* ```
|
416 |
+
*
|
417 |
+
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
418 |
+
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
419 |
+
* instead of the `AssertionError`.
|
420 |
+
* @since v0.1.21
|
421 |
+
*/
|
422 |
+
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
423 |
+
/**
|
424 |
+
* Tests strict equality between the `actual` and `expected` parameters as
|
425 |
+
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
426 |
+
*
|
427 |
+
* ```js
|
428 |
+
* import assert from 'node:assert/strict';
|
429 |
+
*
|
430 |
+
* assert.strictEqual(1, 2);
|
431 |
+
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
432 |
+
* //
|
433 |
+
* // 1 !== 2
|
434 |
+
*
|
435 |
+
* assert.strictEqual(1, 1);
|
436 |
+
* // OK
|
437 |
+
*
|
438 |
+
* assert.strictEqual('Hello foobar', 'Hello World!');
|
439 |
+
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
440 |
+
* // + actual - expected
|
441 |
+
* //
|
442 |
+
* // + 'Hello foobar'
|
443 |
+
* // - 'Hello World!'
|
444 |
+
* // ^
|
445 |
+
*
|
446 |
+
* const apples = 1;
|
447 |
+
* const oranges = 2;
|
448 |
+
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
449 |
+
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
450 |
+
*
|
451 |
+
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
452 |
+
* // TypeError: Inputs are not identical
|
453 |
+
* ```
|
454 |
+
*
|
455 |
+
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
456 |
+
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
457 |
+
* instead of the `AssertionError`.
|
458 |
+
* @since v0.1.21
|
459 |
+
*/
|
460 |
+
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
461 |
+
/**
|
462 |
+
* Tests strict inequality between the `actual` and `expected` parameters as
|
463 |
+
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
464 |
+
*
|
465 |
+
* ```js
|
466 |
+
* import assert from 'node:assert/strict';
|
467 |
+
*
|
468 |
+
* assert.notStrictEqual(1, 2);
|
469 |
+
* // OK
|
470 |
+
*
|
471 |
+
* assert.notStrictEqual(1, 1);
|
472 |
+
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
473 |
+
* //
|
474 |
+
* // 1
|
475 |
+
*
|
476 |
+
* assert.notStrictEqual(1, '1');
|
477 |
+
* // OK
|
478 |
+
* ```
|
479 |
+
*
|
480 |
+
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
481 |
+
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
482 |
+
* instead of the `AssertionError`.
|
483 |
+
* @since v0.1.21
|
484 |
+
*/
|
485 |
+
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
486 |
+
/**
|
487 |
+
* Tests for deep equality between the `actual` and `expected` parameters.
|
488 |
+
* "Deep" equality means that the enumerable "own" properties of child objects
|
489 |
+
* are recursively evaluated also by the following rules.
|
490 |
+
* @since v1.2.0
|
491 |
+
*/
|
492 |
+
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
493 |
+
/**
|
494 |
+
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
495 |
+
*
|
496 |
+
* ```js
|
497 |
+
* import assert from 'node:assert/strict';
|
498 |
+
*
|
499 |
+
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
500 |
+
* // OK
|
501 |
+
* ```
|
502 |
+
*
|
503 |
+
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
504 |
+
* with a `message` property set equal to the value of the `message` parameter. If
|
505 |
+
* the `message` parameter is undefined, a default error message is assigned. If
|
506 |
+
* the `message` parameter is an instance of an `Error` then it will be thrown
|
507 |
+
* instead of the `AssertionError`.
|
508 |
+
* @since v1.2.0
|
509 |
+
*/
|
510 |
+
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
511 |
+
/**
|
512 |
+
* Expects the function `fn` to throw an error.
|
513 |
+
*
|
514 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
515 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
516 |
+
* a validation object where each property will be tested for strict deep equality,
|
517 |
+
* or an instance of error where each property will be tested for strict deep
|
518 |
+
* equality including the non-enumerable `message` and `name` properties. When
|
519 |
+
* using an object, it is also possible to use a regular expression, when
|
520 |
+
* validating against a string property. See below for examples.
|
521 |
+
*
|
522 |
+
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
523 |
+
* fails.
|
524 |
+
*
|
525 |
+
* Custom validation object/error instance:
|
526 |
+
*
|
527 |
+
* ```js
|
528 |
+
* import assert from 'node:assert/strict';
|
529 |
+
*
|
530 |
+
* const err = new TypeError('Wrong value');
|
531 |
+
* err.code = 404;
|
532 |
+
* err.foo = 'bar';
|
533 |
+
* err.info = {
|
534 |
+
* nested: true,
|
535 |
+
* baz: 'text',
|
536 |
+
* };
|
537 |
+
* err.reg = /abc/i;
|
538 |
+
*
|
539 |
+
* assert.throws(
|
540 |
+
* () => {
|
541 |
+
* throw err;
|
542 |
+
* },
|
543 |
+
* {
|
544 |
+
* name: 'TypeError',
|
545 |
+
* message: 'Wrong value',
|
546 |
+
* info: {
|
547 |
+
* nested: true,
|
548 |
+
* baz: 'text',
|
549 |
+
* },
|
550 |
+
* // Only properties on the validation object will be tested for.
|
551 |
+
* // Using nested objects requires all properties to be present. Otherwise
|
552 |
+
* // the validation is going to fail.
|
553 |
+
* },
|
554 |
+
* );
|
555 |
+
*
|
556 |
+
* // Using regular expressions to validate error properties:
|
557 |
+
* assert.throws(
|
558 |
+
* () => {
|
559 |
+
* throw err;
|
560 |
+
* },
|
561 |
+
* {
|
562 |
+
* // The `name` and `message` properties are strings and using regular
|
563 |
+
* // expressions on those will match against the string. If they fail, an
|
564 |
+
* // error is thrown.
|
565 |
+
* name: /^TypeError$/,
|
566 |
+
* message: /Wrong/,
|
567 |
+
* foo: 'bar',
|
568 |
+
* info: {
|
569 |
+
* nested: true,
|
570 |
+
* // It is not possible to use regular expressions for nested properties!
|
571 |
+
* baz: 'text',
|
572 |
+
* },
|
573 |
+
* // The `reg` property contains a regular expression and only if the
|
574 |
+
* // validation object contains an identical regular expression, it is going
|
575 |
+
* // to pass.
|
576 |
+
* reg: /abc/i,
|
577 |
+
* },
|
578 |
+
* );
|
579 |
+
*
|
580 |
+
* // Fails due to the different `message` and `name` properties:
|
581 |
+
* assert.throws(
|
582 |
+
* () => {
|
583 |
+
* const otherErr = new Error('Not found');
|
584 |
+
* // Copy all enumerable properties from `err` to `otherErr`.
|
585 |
+
* for (const [key, value] of Object.entries(err)) {
|
586 |
+
* otherErr[key] = value;
|
587 |
+
* }
|
588 |
+
* throw otherErr;
|
589 |
+
* },
|
590 |
+
* // The error's `message` and `name` properties will also be checked when using
|
591 |
+
* // an error as validation object.
|
592 |
+
* err,
|
593 |
+
* );
|
594 |
+
* ```
|
595 |
+
*
|
596 |
+
* Validate instanceof using constructor:
|
597 |
+
*
|
598 |
+
* ```js
|
599 |
+
* import assert from 'node:assert/strict';
|
600 |
+
*
|
601 |
+
* assert.throws(
|
602 |
+
* () => {
|
603 |
+
* throw new Error('Wrong value');
|
604 |
+
* },
|
605 |
+
* Error,
|
606 |
+
* );
|
607 |
+
* ```
|
608 |
+
*
|
609 |
+
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
610 |
+
*
|
611 |
+
* Using a regular expression runs `.toString` on the error object, and will
|
612 |
+
* therefore also include the error name.
|
613 |
+
*
|
614 |
+
* ```js
|
615 |
+
* import assert from 'node:assert/strict';
|
616 |
+
*
|
617 |
+
* assert.throws(
|
618 |
+
* () => {
|
619 |
+
* throw new Error('Wrong value');
|
620 |
+
* },
|
621 |
+
* /^Error: Wrong value$/,
|
622 |
+
* );
|
623 |
+
* ```
|
624 |
+
*
|
625 |
+
* Custom error validation:
|
626 |
+
*
|
627 |
+
* The function must return `true` to indicate all internal validations passed.
|
628 |
+
* It will otherwise fail with an `AssertionError`.
|
629 |
+
*
|
630 |
+
* ```js
|
631 |
+
* import assert from 'node:assert/strict';
|
632 |
+
*
|
633 |
+
* assert.throws(
|
634 |
+
* () => {
|
635 |
+
* throw new Error('Wrong value');
|
636 |
+
* },
|
637 |
+
* (err) => {
|
638 |
+
* assert(err instanceof Error);
|
639 |
+
* assert(/value/.test(err));
|
640 |
+
* // Avoid returning anything from validation functions besides `true`.
|
641 |
+
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
642 |
+
* // throw an error about the specific validation that failed (as done in this
|
643 |
+
* // example) and add as much helpful debugging information to that error as
|
644 |
+
* // possible.
|
645 |
+
* return true;
|
646 |
+
* },
|
647 |
+
* 'unexpected error',
|
648 |
+
* );
|
649 |
+
* ```
|
650 |
+
*
|
651 |
+
* `error` cannot be a string. If a string is provided as the second
|
652 |
+
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
653 |
+
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
654 |
+
* a string as the second argument gets considered:
|
655 |
+
*
|
656 |
+
* ```js
|
657 |
+
* import assert from 'node:assert/strict';
|
658 |
+
*
|
659 |
+
* function throwingFirst() {
|
660 |
+
* throw new Error('First');
|
661 |
+
* }
|
662 |
+
*
|
663 |
+
* function throwingSecond() {
|
664 |
+
* throw new Error('Second');
|
665 |
+
* }
|
666 |
+
*
|
667 |
+
* function notThrowing() {}
|
668 |
+
*
|
669 |
+
* // The second argument is a string and the input function threw an Error.
|
670 |
+
* // The first case will not throw as it does not match for the error message
|
671 |
+
* // thrown by the input function!
|
672 |
+
* assert.throws(throwingFirst, 'Second');
|
673 |
+
* // In the next example the message has no benefit over the message from the
|
674 |
+
* // error and since it is not clear if the user intended to actually match
|
675 |
+
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
676 |
+
* assert.throws(throwingSecond, 'Second');
|
677 |
+
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
678 |
+
*
|
679 |
+
* // The string is only used (as message) in case the function does not throw:
|
680 |
+
* assert.throws(notThrowing, 'Second');
|
681 |
+
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
682 |
+
*
|
683 |
+
* // If it was intended to match for the error message do this instead:
|
684 |
+
* // It does not throw because the error messages match.
|
685 |
+
* assert.throws(throwingSecond, /Second$/);
|
686 |
+
*
|
687 |
+
* // If the error message does not match, an AssertionError is thrown.
|
688 |
+
* assert.throws(throwingFirst, /Second$/);
|
689 |
+
* // AssertionError [ERR_ASSERTION]
|
690 |
+
* ```
|
691 |
+
*
|
692 |
+
* Due to the confusing error-prone notation, avoid a string as the second
|
693 |
+
* argument.
|
694 |
+
* @since v0.1.21
|
695 |
+
*/
|
696 |
+
function throws(block: () => unknown, message?: string | Error): void;
|
697 |
+
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
698 |
+
/**
|
699 |
+
* Asserts that the function `fn` does not throw an error.
|
700 |
+
*
|
701 |
+
* Using `assert.doesNotThrow()` is actually not useful because there
|
702 |
+
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
703 |
+
* adding a comment next to the specific code path that should not throw and keep
|
704 |
+
* error messages as expressive as possible.
|
705 |
+
*
|
706 |
+
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
707 |
+
*
|
708 |
+
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
709 |
+
* different type, or if the `error` parameter is undefined, the error is
|
710 |
+
* propagated back to the caller.
|
711 |
+
*
|
712 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
713 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
714 |
+
* function. See {@link throws} for more details.
|
715 |
+
*
|
716 |
+
* The following, for instance, will throw the `TypeError` because there is no
|
717 |
+
* matching error type in the assertion:
|
718 |
+
*
|
719 |
+
* ```js
|
720 |
+
* import assert from 'node:assert/strict';
|
721 |
+
*
|
722 |
+
* assert.doesNotThrow(
|
723 |
+
* () => {
|
724 |
+
* throw new TypeError('Wrong value');
|
725 |
+
* },
|
726 |
+
* SyntaxError,
|
727 |
+
* );
|
728 |
+
* ```
|
729 |
+
*
|
730 |
+
* However, the following will result in an `AssertionError` with the message
|
731 |
+
* 'Got unwanted exception...':
|
732 |
+
*
|
733 |
+
* ```js
|
734 |
+
* import assert from 'node:assert/strict';
|
735 |
+
*
|
736 |
+
* assert.doesNotThrow(
|
737 |
+
* () => {
|
738 |
+
* throw new TypeError('Wrong value');
|
739 |
+
* },
|
740 |
+
* TypeError,
|
741 |
+
* );
|
742 |
+
* ```
|
743 |
+
*
|
744 |
+
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
745 |
+
*
|
746 |
+
* ```js
|
747 |
+
* import assert from 'node:assert/strict';
|
748 |
+
*
|
749 |
+
* assert.doesNotThrow(
|
750 |
+
* () => {
|
751 |
+
* throw new TypeError('Wrong value');
|
752 |
+
* },
|
753 |
+
* /Wrong value/,
|
754 |
+
* 'Whoops',
|
755 |
+
* );
|
756 |
+
* // Throws: AssertionError: Got unwanted exception: Whoops
|
757 |
+
* ```
|
758 |
+
* @since v0.1.21
|
759 |
+
*/
|
760 |
+
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
761 |
+
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
762 |
+
/**
|
763 |
+
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
764 |
+
* testing the `error` argument in callbacks. The stack trace contains all frames
|
765 |
+
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
766 |
+
*
|
767 |
+
* ```js
|
768 |
+
* import assert from 'node:assert/strict';
|
769 |
+
*
|
770 |
+
* assert.ifError(null);
|
771 |
+
* // OK
|
772 |
+
* assert.ifError(0);
|
773 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
774 |
+
* assert.ifError('error');
|
775 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
776 |
+
* assert.ifError(new Error());
|
777 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
778 |
+
*
|
779 |
+
* // Create some random error frames.
|
780 |
+
* let err;
|
781 |
+
* (function errorFrame() {
|
782 |
+
* err = new Error('test error');
|
783 |
+
* })();
|
784 |
+
*
|
785 |
+
* (function ifErrorFrame() {
|
786 |
+
* assert.ifError(err);
|
787 |
+
* })();
|
788 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
789 |
+
* // at ifErrorFrame
|
790 |
+
* // at errorFrame
|
791 |
+
* ```
|
792 |
+
* @since v0.1.97
|
793 |
+
*/
|
794 |
+
function ifError(value: unknown): asserts value is null | undefined;
|
795 |
+
/**
|
796 |
+
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
797 |
+
* calls the function and awaits the returned promise to complete. It will then
|
798 |
+
* check that the promise is rejected.
|
799 |
+
*
|
800 |
+
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
801 |
+
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
802 |
+
* handler is skipped.
|
803 |
+
*
|
804 |
+
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
805 |
+
*
|
806 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
807 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
808 |
+
* an object where each property will be tested for, or an instance of error where
|
809 |
+
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
810 |
+
*
|
811 |
+
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
812 |
+
*
|
813 |
+
* ```js
|
814 |
+
* import assert from 'node:assert/strict';
|
815 |
+
*
|
816 |
+
* await assert.rejects(
|
817 |
+
* async () => {
|
818 |
+
* throw new TypeError('Wrong value');
|
819 |
+
* },
|
820 |
+
* {
|
821 |
+
* name: 'TypeError',
|
822 |
+
* message: 'Wrong value',
|
823 |
+
* },
|
824 |
+
* );
|
825 |
+
* ```
|
826 |
+
*
|
827 |
+
* ```js
|
828 |
+
* import assert from 'node:assert/strict';
|
829 |
+
*
|
830 |
+
* await assert.rejects(
|
831 |
+
* async () => {
|
832 |
+
* throw new TypeError('Wrong value');
|
833 |
+
* },
|
834 |
+
* (err) => {
|
835 |
+
* assert.strictEqual(err.name, 'TypeError');
|
836 |
+
* assert.strictEqual(err.message, 'Wrong value');
|
837 |
+
* return true;
|
838 |
+
* },
|
839 |
+
* );
|
840 |
+
* ```
|
841 |
+
*
|
842 |
+
* ```js
|
843 |
+
* import assert from 'node:assert/strict';
|
844 |
+
*
|
845 |
+
* assert.rejects(
|
846 |
+
* Promise.reject(new Error('Wrong value')),
|
847 |
+
* Error,
|
848 |
+
* ).then(() => {
|
849 |
+
* // ...
|
850 |
+
* });
|
851 |
+
* ```
|
852 |
+
*
|
853 |
+
* `error` cannot be a string. If a string is provided as the second
|
854 |
+
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
855 |
+
* example in {@link throws} carefully if using a string as the second
|
856 |
+
* argument gets considered.
|
857 |
+
* @since v10.0.0
|
858 |
+
*/
|
859 |
+
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
860 |
+
function rejects(
|
861 |
+
block: (() => Promise<unknown>) | Promise<unknown>,
|
862 |
+
error: AssertPredicate,
|
863 |
+
message?: string | Error,
|
864 |
+
): Promise<void>;
|
865 |
+
/**
|
866 |
+
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
867 |
+
* calls the function and awaits the returned promise to complete. It will then
|
868 |
+
* check that the promise is not rejected.
|
869 |
+
*
|
870 |
+
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
871 |
+
* the function does not return a promise, `assert.doesNotReject()` will return a
|
872 |
+
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
873 |
+
* the error handler is skipped.
|
874 |
+
*
|
875 |
+
* Using `assert.doesNotReject()` is actually not useful because there is little
|
876 |
+
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
877 |
+
* adding a comment next to the specific code path that should not reject and keep
|
878 |
+
* error messages as expressive as possible.
|
879 |
+
*
|
880 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
881 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), or a validation
|
882 |
+
* function. See {@link throws} for more details.
|
883 |
+
*
|
884 |
+
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
885 |
+
*
|
886 |
+
* ```js
|
887 |
+
* import assert from 'node:assert/strict';
|
888 |
+
*
|
889 |
+
* await assert.doesNotReject(
|
890 |
+
* async () => {
|
891 |
+
* throw new TypeError('Wrong value');
|
892 |
+
* },
|
893 |
+
* SyntaxError,
|
894 |
+
* );
|
895 |
+
* ```
|
896 |
+
*
|
897 |
+
* ```js
|
898 |
+
* import assert from 'node:assert/strict';
|
899 |
+
*
|
900 |
+
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
901 |
+
* .then(() => {
|
902 |
+
* // ...
|
903 |
+
* });
|
904 |
+
* ```
|
905 |
+
* @since v10.0.0
|
906 |
+
*/
|
907 |
+
function doesNotReject(
|
908 |
+
block: (() => Promise<unknown>) | Promise<unknown>,
|
909 |
+
message?: string | Error,
|
910 |
+
): Promise<void>;
|
911 |
+
function doesNotReject(
|
912 |
+
block: (() => Promise<unknown>) | Promise<unknown>,
|
913 |
+
error: AssertPredicate,
|
914 |
+
message?: string | Error,
|
915 |
+
): Promise<void>;
|
916 |
+
/**
|
917 |
+
* Expects the `string` input to match the regular expression.
|
918 |
+
*
|
919 |
+
* ```js
|
920 |
+
* import assert from 'node:assert/strict';
|
921 |
+
*
|
922 |
+
* assert.match('I will fail', /pass/);
|
923 |
+
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
924 |
+
*
|
925 |
+
* assert.match(123, /pass/);
|
926 |
+
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
927 |
+
*
|
928 |
+
* assert.match('I will pass', /pass/);
|
929 |
+
* // OK
|
930 |
+
* ```
|
931 |
+
*
|
932 |
+
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
933 |
+
* to the value of the `message` parameter. If the `message` parameter is
|
934 |
+
* undefined, a default error message is assigned. If the `message` parameter is an
|
935 |
+
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
936 |
+
* @since v13.6.0, v12.16.0
|
937 |
+
*/
|
938 |
+
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
939 |
+
/**
|
940 |
+
* Expects the `string` input not to match the regular expression.
|
941 |
+
*
|
942 |
+
* ```js
|
943 |
+
* import assert from 'node:assert/strict';
|
944 |
+
*
|
945 |
+
* assert.doesNotMatch('I will fail', /fail/);
|
946 |
+
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
947 |
+
*
|
948 |
+
* assert.doesNotMatch(123, /pass/);
|
949 |
+
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
950 |
+
*
|
951 |
+
* assert.doesNotMatch('I will pass', /different/);
|
952 |
+
* // OK
|
953 |
+
* ```
|
954 |
+
*
|
955 |
+
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
956 |
+
* to the value of the `message` parameter. If the `message` parameter is
|
957 |
+
* undefined, a default error message is assigned. If the `message` parameter is an
|
958 |
+
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
959 |
+
* @since v13.6.0, v12.16.0
|
960 |
+
*/
|
961 |
+
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
962 |
+
const strict:
|
963 |
+
& Omit<
|
964 |
+
typeof assert,
|
965 |
+
| "equal"
|
966 |
+
| "notEqual"
|
967 |
+
| "deepEqual"
|
968 |
+
| "notDeepEqual"
|
969 |
+
| "ok"
|
970 |
+
| "strictEqual"
|
971 |
+
| "deepStrictEqual"
|
972 |
+
| "ifError"
|
973 |
+
| "strict"
|
974 |
+
>
|
975 |
+
& {
|
976 |
+
(value: unknown, message?: string | Error): asserts value;
|
977 |
+
equal: typeof strictEqual;
|
978 |
+
notEqual: typeof notStrictEqual;
|
979 |
+
deepEqual: typeof deepStrictEqual;
|
980 |
+
notDeepEqual: typeof notDeepStrictEqual;
|
981 |
+
// Mapped types and assertion functions are incompatible?
|
982 |
+
// TS2775: Assertions require every name in the call target
|
983 |
+
// to be declared with an explicit type annotation.
|
984 |
+
ok: typeof ok;
|
985 |
+
strictEqual: typeof strictEqual;
|
986 |
+
deepStrictEqual: typeof deepStrictEqual;
|
987 |
+
ifError: typeof ifError;
|
988 |
+
strict: typeof strict;
|
989 |
+
};
|
990 |
+
}
|
991 |
+
export = assert;
|
992 |
+
}
|
993 |
+
declare module "node:assert" {
|
994 |
+
import assert = require("assert");
|
995 |
+
export = assert;
|
996 |
+
}
|
node_modules/@types/node/assert/strict.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
declare module "assert/strict" {
|
2 |
+
import { strict } from "node:assert";
|
3 |
+
export = strict;
|
4 |
+
}
|
5 |
+
declare module "node:assert/strict" {
|
6 |
+
import { strict } from "node:assert";
|
7 |
+
export = strict;
|
8 |
+
}
|
node_modules/@types/node/async_hooks.d.ts
ADDED
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* We strongly discourage the use of the `async_hooks` API.
|
3 |
+
* Other APIs that can cover most of its use cases include:
|
4 |
+
*
|
5 |
+
* * `AsyncLocalStorage` tracks async context
|
6 |
+
* * `process.getActiveResourcesInfo()` tracks active resources
|
7 |
+
*
|
8 |
+
* The `node:async_hooks` module provides an API to track asynchronous resources.
|
9 |
+
* It can be accessed using:
|
10 |
+
*
|
11 |
+
* ```js
|
12 |
+
* import async_hooks from 'node:async_hooks';
|
13 |
+
* ```
|
14 |
+
* @experimental
|
15 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/async_hooks.js)
|
16 |
+
*/
|
17 |
+
declare module "async_hooks" {
|
18 |
+
/**
|
19 |
+
* ```js
|
20 |
+
* import { executionAsyncId } from 'node:async_hooks';
|
21 |
+
* import fs from 'node:fs';
|
22 |
+
*
|
23 |
+
* console.log(executionAsyncId()); // 1 - bootstrap
|
24 |
+
* const path = '.';
|
25 |
+
* fs.open(path, 'r', (err, fd) => {
|
26 |
+
* console.log(executionAsyncId()); // 6 - open()
|
27 |
+
* });
|
28 |
+
* ```
|
29 |
+
*
|
30 |
+
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
31 |
+
* causality (which is covered by `triggerAsyncId()`):
|
32 |
+
*
|
33 |
+
* ```js
|
34 |
+
* const server = net.createServer((conn) => {
|
35 |
+
* // Returns the ID of the server, not of the new connection, because the
|
36 |
+
* // callback runs in the execution scope of the server's MakeCallback().
|
37 |
+
* async_hooks.executionAsyncId();
|
38 |
+
*
|
39 |
+
* }).listen(port, () => {
|
40 |
+
* // Returns the ID of a TickObject (process.nextTick()) because all
|
41 |
+
* // callbacks passed to .listen() are wrapped in a nextTick().
|
42 |
+
* async_hooks.executionAsyncId();
|
43 |
+
* });
|
44 |
+
* ```
|
45 |
+
*
|
46 |
+
* Promise contexts may not get precise `executionAsyncIds` by default.
|
47 |
+
* See the section on `promise execution tracking`.
|
48 |
+
* @since v8.1.0
|
49 |
+
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
50 |
+
*/
|
51 |
+
function executionAsyncId(): number;
|
52 |
+
/**
|
53 |
+
* Resource objects returned by `executionAsyncResource()` are most often internal
|
54 |
+
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
55 |
+
* on the object is likely to crash your application and should be avoided.
|
56 |
+
*
|
57 |
+
* Using `executionAsyncResource()` in the top-level execution context will
|
58 |
+
* return an empty object as there is no handle or request object to use,
|
59 |
+
* but having an object representing the top-level can be helpful.
|
60 |
+
*
|
61 |
+
* ```js
|
62 |
+
* import { open } from 'node:fs';
|
63 |
+
* import { executionAsyncId, executionAsyncResource } from 'node:async_hooks';
|
64 |
+
*
|
65 |
+
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
66 |
+
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
67 |
+
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
68 |
+
* });
|
69 |
+
* ```
|
70 |
+
*
|
71 |
+
* This can be used to implement continuation local storage without the
|
72 |
+
* use of a tracking `Map` to store the metadata:
|
73 |
+
*
|
74 |
+
* ```js
|
75 |
+
* import { createServer } from 'node:http';
|
76 |
+
* import {
|
77 |
+
* executionAsyncId,
|
78 |
+
* executionAsyncResource,
|
79 |
+
* createHook,
|
80 |
+
* } from 'async_hooks';
|
81 |
+
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
82 |
+
*
|
83 |
+
* createHook({
|
84 |
+
* init(asyncId, type, triggerAsyncId, resource) {
|
85 |
+
* const cr = executionAsyncResource();
|
86 |
+
* if (cr) {
|
87 |
+
* resource[sym] = cr[sym];
|
88 |
+
* }
|
89 |
+
* },
|
90 |
+
* }).enable();
|
91 |
+
*
|
92 |
+
* const server = createServer((req, res) => {
|
93 |
+
* executionAsyncResource()[sym] = { state: req.url };
|
94 |
+
* setTimeout(function() {
|
95 |
+
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
96 |
+
* }, 100);
|
97 |
+
* }).listen(3000);
|
98 |
+
* ```
|
99 |
+
* @since v13.9.0, v12.17.0
|
100 |
+
* @return The resource representing the current execution. Useful to store data within the resource.
|
101 |
+
*/
|
102 |
+
function executionAsyncResource(): object;
|
103 |
+
/**
|
104 |
+
* ```js
|
105 |
+
* const server = net.createServer((conn) => {
|
106 |
+
* // The resource that caused (or triggered) this callback to be called
|
107 |
+
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
108 |
+
* // is the asyncId of "conn".
|
109 |
+
* async_hooks.triggerAsyncId();
|
110 |
+
*
|
111 |
+
* }).listen(port, () => {
|
112 |
+
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
113 |
+
* // the callback itself exists because the call to the server's .listen()
|
114 |
+
* // was made. So the return value would be the ID of the server.
|
115 |
+
* async_hooks.triggerAsyncId();
|
116 |
+
* });
|
117 |
+
* ```
|
118 |
+
*
|
119 |
+
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
120 |
+
* the section on `promise execution tracking`.
|
121 |
+
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
122 |
+
*/
|
123 |
+
function triggerAsyncId(): number;
|
124 |
+
interface HookCallbacks {
|
125 |
+
/**
|
126 |
+
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
127 |
+
* @param asyncId a unique ID for the async resource
|
128 |
+
* @param type the type of the async resource
|
129 |
+
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
130 |
+
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
131 |
+
*/
|
132 |
+
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
133 |
+
/**
|
134 |
+
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
135 |
+
* The before callback is called just before said callback is executed.
|
136 |
+
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
137 |
+
*/
|
138 |
+
before?(asyncId: number): void;
|
139 |
+
/**
|
140 |
+
* Called immediately after the callback specified in before is completed.
|
141 |
+
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
142 |
+
*/
|
143 |
+
after?(asyncId: number): void;
|
144 |
+
/**
|
145 |
+
* Called when a promise has resolve() called. This may not be in the same execution id
|
146 |
+
* as the promise itself.
|
147 |
+
* @param asyncId the unique id for the promise that was resolve()d.
|
148 |
+
*/
|
149 |
+
promiseResolve?(asyncId: number): void;
|
150 |
+
/**
|
151 |
+
* Called after the resource corresponding to asyncId is destroyed
|
152 |
+
* @param asyncId a unique ID for the async resource
|
153 |
+
*/
|
154 |
+
destroy?(asyncId: number): void;
|
155 |
+
}
|
156 |
+
interface AsyncHook {
|
157 |
+
/**
|
158 |
+
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
159 |
+
*/
|
160 |
+
enable(): this;
|
161 |
+
/**
|
162 |
+
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
163 |
+
*/
|
164 |
+
disable(): this;
|
165 |
+
}
|
166 |
+
/**
|
167 |
+
* Registers functions to be called for different lifetime events of each async
|
168 |
+
* operation.
|
169 |
+
*
|
170 |
+
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
171 |
+
* respective asynchronous event during a resource's lifetime.
|
172 |
+
*
|
173 |
+
* All callbacks are optional. For example, if only resource cleanup needs to
|
174 |
+
* be tracked, then only the `destroy` callback needs to be passed. The
|
175 |
+
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
176 |
+
*
|
177 |
+
* ```js
|
178 |
+
* import { createHook } from 'node:async_hooks';
|
179 |
+
*
|
180 |
+
* const asyncHook = createHook({
|
181 |
+
* init(asyncId, type, triggerAsyncId, resource) { },
|
182 |
+
* destroy(asyncId) { },
|
183 |
+
* });
|
184 |
+
* ```
|
185 |
+
*
|
186 |
+
* The callbacks will be inherited via the prototype chain:
|
187 |
+
*
|
188 |
+
* ```js
|
189 |
+
* class MyAsyncCallbacks {
|
190 |
+
* init(asyncId, type, triggerAsyncId, resource) { }
|
191 |
+
* destroy(asyncId) {}
|
192 |
+
* }
|
193 |
+
*
|
194 |
+
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
195 |
+
* before(asyncId) { }
|
196 |
+
* after(asyncId) { }
|
197 |
+
* }
|
198 |
+
*
|
199 |
+
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
200 |
+
* ```
|
201 |
+
*
|
202 |
+
* Because promises are asynchronous resources whose lifecycle is tracked
|
203 |
+
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
204 |
+
* @since v8.1.0
|
205 |
+
* @param callbacks The `Hook Callbacks` to register
|
206 |
+
* @return Instance used for disabling and enabling hooks
|
207 |
+
*/
|
208 |
+
function createHook(callbacks: HookCallbacks): AsyncHook;
|
209 |
+
interface AsyncResourceOptions {
|
210 |
+
/**
|
211 |
+
* The ID of the execution context that created this async event.
|
212 |
+
* @default executionAsyncId()
|
213 |
+
*/
|
214 |
+
triggerAsyncId?: number | undefined;
|
215 |
+
/**
|
216 |
+
* Disables automatic `emitDestroy` when the object is garbage collected.
|
217 |
+
* This usually does not need to be set (even if `emitDestroy` is called
|
218 |
+
* manually), unless the resource's `asyncId` is retrieved and the
|
219 |
+
* sensitive API's `emitDestroy` is called with it.
|
220 |
+
* @default false
|
221 |
+
*/
|
222 |
+
requireManualDestroy?: boolean | undefined;
|
223 |
+
}
|
224 |
+
/**
|
225 |
+
* The class `AsyncResource` is designed to be extended by the embedder's async
|
226 |
+
* resources. Using this, users can easily trigger the lifetime events of their
|
227 |
+
* own resources.
|
228 |
+
*
|
229 |
+
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
230 |
+
*
|
231 |
+
* The following is an overview of the `AsyncResource` API.
|
232 |
+
*
|
233 |
+
* ```js
|
234 |
+
* import { AsyncResource, executionAsyncId } from 'node:async_hooks';
|
235 |
+
*
|
236 |
+
* // AsyncResource() is meant to be extended. Instantiating a
|
237 |
+
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
238 |
+
* // async_hook.executionAsyncId() is used.
|
239 |
+
* const asyncResource = new AsyncResource(
|
240 |
+
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false },
|
241 |
+
* );
|
242 |
+
*
|
243 |
+
* // Run a function in the execution context of the resource. This will
|
244 |
+
* // * establish the context of the resource
|
245 |
+
* // * trigger the AsyncHooks before callbacks
|
246 |
+
* // * call the provided function `fn` with the supplied arguments
|
247 |
+
* // * trigger the AsyncHooks after callbacks
|
248 |
+
* // * restore the original execution context
|
249 |
+
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
250 |
+
*
|
251 |
+
* // Call AsyncHooks destroy callbacks.
|
252 |
+
* asyncResource.emitDestroy();
|
253 |
+
*
|
254 |
+
* // Return the unique ID assigned to the AsyncResource instance.
|
255 |
+
* asyncResource.asyncId();
|
256 |
+
*
|
257 |
+
* // Return the trigger ID for the AsyncResource instance.
|
258 |
+
* asyncResource.triggerAsyncId();
|
259 |
+
* ```
|
260 |
+
*/
|
261 |
+
class AsyncResource {
|
262 |
+
/**
|
263 |
+
* AsyncResource() is meant to be extended. Instantiating a
|
264 |
+
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
265 |
+
* async_hook.executionAsyncId() is used.
|
266 |
+
* @param type The type of async event.
|
267 |
+
* @param triggerAsyncId The ID of the execution context that created
|
268 |
+
* this async event (default: `executionAsyncId()`), or an
|
269 |
+
* AsyncResourceOptions object (since v9.3.0)
|
270 |
+
*/
|
271 |
+
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
272 |
+
/**
|
273 |
+
* Binds the given function to the current execution context.
|
274 |
+
* @since v14.8.0, v12.19.0
|
275 |
+
* @param fn The function to bind to the current execution context.
|
276 |
+
* @param type An optional name to associate with the underlying `AsyncResource`.
|
277 |
+
*/
|
278 |
+
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
279 |
+
fn: Func,
|
280 |
+
type?: string,
|
281 |
+
thisArg?: ThisArg,
|
282 |
+
): Func;
|
283 |
+
/**
|
284 |
+
* Binds the given function to execute to this `AsyncResource`'s scope.
|
285 |
+
* @since v14.8.0, v12.19.0
|
286 |
+
* @param fn The function to bind to the current `AsyncResource`.
|
287 |
+
*/
|
288 |
+
bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
289 |
+
/**
|
290 |
+
* Call the provided function with the provided arguments in the execution context
|
291 |
+
* of the async resource. This will establish the context, trigger the AsyncHooks
|
292 |
+
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
293 |
+
* then restore the original execution context.
|
294 |
+
* @since v9.6.0
|
295 |
+
* @param fn The function to call in the execution context of this async resource.
|
296 |
+
* @param thisArg The receiver to be used for the function call.
|
297 |
+
* @param args Optional arguments to pass to the function.
|
298 |
+
*/
|
299 |
+
runInAsyncScope<This, Result>(
|
300 |
+
fn: (this: This, ...args: any[]) => Result,
|
301 |
+
thisArg?: This,
|
302 |
+
...args: any[]
|
303 |
+
): Result;
|
304 |
+
/**
|
305 |
+
* Call all `destroy` hooks. This should only ever be called once. An error will
|
306 |
+
* be thrown if it is called more than once. This **must** be manually called. If
|
307 |
+
* the resource is left to be collected by the GC then the `destroy` hooks will
|
308 |
+
* never be called.
|
309 |
+
* @return A reference to `asyncResource`.
|
310 |
+
*/
|
311 |
+
emitDestroy(): this;
|
312 |
+
/**
|
313 |
+
* @return The unique `asyncId` assigned to the resource.
|
314 |
+
*/
|
315 |
+
asyncId(): number;
|
316 |
+
/**
|
317 |
+
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
318 |
+
*/
|
319 |
+
triggerAsyncId(): number;
|
320 |
+
}
|
321 |
+
/**
|
322 |
+
* This class creates stores that stay coherent through asynchronous operations.
|
323 |
+
*
|
324 |
+
* While you can create your own implementation on top of the `node:async_hooks`module, `AsyncLocalStorage` should be preferred as it is a performant and memory
|
325 |
+
* safe implementation that involves significant optimizations that are non-obvious
|
326 |
+
* to implement.
|
327 |
+
*
|
328 |
+
* The following example uses `AsyncLocalStorage` to build a simple logger
|
329 |
+
* that assigns IDs to incoming HTTP requests and includes them in messages
|
330 |
+
* logged within each request.
|
331 |
+
*
|
332 |
+
* ```js
|
333 |
+
* import http from 'node:http';
|
334 |
+
* import { AsyncLocalStorage } from 'node:async_hooks';
|
335 |
+
*
|
336 |
+
* const asyncLocalStorage = new AsyncLocalStorage();
|
337 |
+
*
|
338 |
+
* function logWithId(msg) {
|
339 |
+
* const id = asyncLocalStorage.getStore();
|
340 |
+
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
341 |
+
* }
|
342 |
+
*
|
343 |
+
* let idSeq = 0;
|
344 |
+
* http.createServer((req, res) => {
|
345 |
+
* asyncLocalStorage.run(idSeq++, () => {
|
346 |
+
* logWithId('start');
|
347 |
+
* // Imagine any chain of async operations here
|
348 |
+
* setImmediate(() => {
|
349 |
+
* logWithId('finish');
|
350 |
+
* res.end();
|
351 |
+
* });
|
352 |
+
* });
|
353 |
+
* }).listen(8080);
|
354 |
+
*
|
355 |
+
* http.get('http://localhost:8080');
|
356 |
+
* http.get('http://localhost:8080');
|
357 |
+
* // Prints:
|
358 |
+
* // 0: start
|
359 |
+
* // 1: start
|
360 |
+
* // 0: finish
|
361 |
+
* // 1: finish
|
362 |
+
* ```
|
363 |
+
*
|
364 |
+
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
365 |
+
* Multiple instances can safely exist simultaneously without risk of interfering
|
366 |
+
* with each other's data.
|
367 |
+
* @since v13.10.0, v12.17.0
|
368 |
+
*/
|
369 |
+
class AsyncLocalStorage<T> {
|
370 |
+
/**
|
371 |
+
* Binds the given function to the current execution context.
|
372 |
+
* @since v19.8.0
|
373 |
+
* @experimental
|
374 |
+
* @param fn The function to bind to the current execution context.
|
375 |
+
* @return A new function that calls `fn` within the captured execution context.
|
376 |
+
*/
|
377 |
+
static bind<Func extends (...args: any[]) => any>(fn: Func): Func;
|
378 |
+
/**
|
379 |
+
* Captures the current execution context and returns a function that accepts a
|
380 |
+
* function as an argument. Whenever the returned function is called, it
|
381 |
+
* calls the function passed to it within the captured context.
|
382 |
+
*
|
383 |
+
* ```js
|
384 |
+
* const asyncLocalStorage = new AsyncLocalStorage();
|
385 |
+
* const runInAsyncScope = asyncLocalStorage.run(123, () => AsyncLocalStorage.snapshot());
|
386 |
+
* const result = asyncLocalStorage.run(321, () => runInAsyncScope(() => asyncLocalStorage.getStore()));
|
387 |
+
* console.log(result); // returns 123
|
388 |
+
* ```
|
389 |
+
*
|
390 |
+
* AsyncLocalStorage.snapshot() can replace the use of AsyncResource for simple
|
391 |
+
* async context tracking purposes, for example:
|
392 |
+
*
|
393 |
+
* ```js
|
394 |
+
* class Foo {
|
395 |
+
* #runInAsyncScope = AsyncLocalStorage.snapshot();
|
396 |
+
*
|
397 |
+
* get() { return this.#runInAsyncScope(() => asyncLocalStorage.getStore()); }
|
398 |
+
* }
|
399 |
+
*
|
400 |
+
* const foo = asyncLocalStorage.run(123, () => new Foo());
|
401 |
+
* console.log(asyncLocalStorage.run(321, () => foo.get())); // returns 123
|
402 |
+
* ```
|
403 |
+
* @since v19.8.0
|
404 |
+
* @experimental
|
405 |
+
* @return A new function with the signature `(fn: (...args) : R, ...args) : R`.
|
406 |
+
*/
|
407 |
+
static snapshot(): <R, TArgs extends any[]>(fn: (...args: TArgs) => R, ...args: TArgs) => R;
|
408 |
+
/**
|
409 |
+
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
410 |
+
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
411 |
+
*
|
412 |
+
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
413 |
+
* instance will be exited.
|
414 |
+
*
|
415 |
+
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
416 |
+
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
417 |
+
* along with the corresponding async resources.
|
418 |
+
*
|
419 |
+
* Use this method when the `asyncLocalStorage` is not in use anymore
|
420 |
+
* in the current process.
|
421 |
+
* @since v13.10.0, v12.17.0
|
422 |
+
* @experimental
|
423 |
+
*/
|
424 |
+
disable(): void;
|
425 |
+
/**
|
426 |
+
* Returns the current store.
|
427 |
+
* If called outside of an asynchronous context initialized by
|
428 |
+
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
429 |
+
* returns `undefined`.
|
430 |
+
* @since v13.10.0, v12.17.0
|
431 |
+
*/
|
432 |
+
getStore(): T | undefined;
|
433 |
+
/**
|
434 |
+
* Runs a function synchronously within a context and returns its
|
435 |
+
* return value. The store is not accessible outside of the callback function.
|
436 |
+
* The store is accessible to any asynchronous operations created within the
|
437 |
+
* callback.
|
438 |
+
*
|
439 |
+
* The optional `args` are passed to the callback function.
|
440 |
+
*
|
441 |
+
* If the callback function throws an error, the error is thrown by `run()` too.
|
442 |
+
* The stacktrace is not impacted by this call and the context is exited.
|
443 |
+
*
|
444 |
+
* Example:
|
445 |
+
*
|
446 |
+
* ```js
|
447 |
+
* const store = { id: 2 };
|
448 |
+
* try {
|
449 |
+
* asyncLocalStorage.run(store, () => {
|
450 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
451 |
+
* setTimeout(() => {
|
452 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
453 |
+
* }, 200);
|
454 |
+
* throw new Error();
|
455 |
+
* });
|
456 |
+
* } catch (e) {
|
457 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
458 |
+
* // The error will be caught here
|
459 |
+
* }
|
460 |
+
* ```
|
461 |
+
* @since v13.10.0, v12.17.0
|
462 |
+
*/
|
463 |
+
run<R>(store: T, callback: () => R): R;
|
464 |
+
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
465 |
+
/**
|
466 |
+
* Runs a function synchronously outside of a context and returns its
|
467 |
+
* return value. The store is not accessible within the callback function or
|
468 |
+
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
469 |
+
*
|
470 |
+
* The optional `args` are passed to the callback function.
|
471 |
+
*
|
472 |
+
* If the callback function throws an error, the error is thrown by `exit()` too.
|
473 |
+
* The stacktrace is not impacted by this call and the context is re-entered.
|
474 |
+
*
|
475 |
+
* Example:
|
476 |
+
*
|
477 |
+
* ```js
|
478 |
+
* // Within a call to run
|
479 |
+
* try {
|
480 |
+
* asyncLocalStorage.getStore(); // Returns the store object or value
|
481 |
+
* asyncLocalStorage.exit(() => {
|
482 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
483 |
+
* throw new Error();
|
484 |
+
* });
|
485 |
+
* } catch (e) {
|
486 |
+
* asyncLocalStorage.getStore(); // Returns the same object or value
|
487 |
+
* // The error will be caught here
|
488 |
+
* }
|
489 |
+
* ```
|
490 |
+
* @since v13.10.0, v12.17.0
|
491 |
+
* @experimental
|
492 |
+
*/
|
493 |
+
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
494 |
+
/**
|
495 |
+
* Transitions into the context for the remainder of the current
|
496 |
+
* synchronous execution and then persists the store through any following
|
497 |
+
* asynchronous calls.
|
498 |
+
*
|
499 |
+
* Example:
|
500 |
+
*
|
501 |
+
* ```js
|
502 |
+
* const store = { id: 1 };
|
503 |
+
* // Replaces previous store with the given store object
|
504 |
+
* asyncLocalStorage.enterWith(store);
|
505 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
506 |
+
* someAsyncOperation(() => {
|
507 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
508 |
+
* });
|
509 |
+
* ```
|
510 |
+
*
|
511 |
+
* This transition will continue for the _entire_ synchronous execution.
|
512 |
+
* This means that if, for example, the context is entered within an event
|
513 |
+
* handler subsequent event handlers will also run within that context unless
|
514 |
+
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
515 |
+
* to use the latter method.
|
516 |
+
*
|
517 |
+
* ```js
|
518 |
+
* const store = { id: 1 };
|
519 |
+
*
|
520 |
+
* emitter.on('my-event', () => {
|
521 |
+
* asyncLocalStorage.enterWith(store);
|
522 |
+
* });
|
523 |
+
* emitter.on('my-event', () => {
|
524 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
525 |
+
* });
|
526 |
+
*
|
527 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
528 |
+
* emitter.emit('my-event');
|
529 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
530 |
+
* ```
|
531 |
+
* @since v13.11.0, v12.17.0
|
532 |
+
* @experimental
|
533 |
+
*/
|
534 |
+
enterWith(store: T): void;
|
535 |
+
}
|
536 |
+
}
|
537 |
+
declare module "node:async_hooks" {
|
538 |
+
export * from "async_hooks";
|
539 |
+
}
|
node_modules/@types/node/buffer.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@types/node/child_process.d.ts
ADDED
@@ -0,0 +1,1540 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:child_process` module provides the ability to spawn subprocesses in
|
3 |
+
* a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
|
4 |
+
* is primarily provided by the {@link spawn} function:
|
5 |
+
*
|
6 |
+
* ```js
|
7 |
+
* const { spawn } = require('node:child_process');
|
8 |
+
* const ls = spawn('ls', ['-lh', '/usr']);
|
9 |
+
*
|
10 |
+
* ls.stdout.on('data', (data) => {
|
11 |
+
* console.log(`stdout: ${data}`);
|
12 |
+
* });
|
13 |
+
*
|
14 |
+
* ls.stderr.on('data', (data) => {
|
15 |
+
* console.error(`stderr: ${data}`);
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* ls.on('close', (code) => {
|
19 |
+
* console.log(`child process exited with code ${code}`);
|
20 |
+
* });
|
21 |
+
* ```
|
22 |
+
*
|
23 |
+
* By default, pipes for `stdin`, `stdout`, and `stderr` are established between
|
24 |
+
* the parent Node.js process and the spawned subprocess. These pipes have
|
25 |
+
* limited (and platform-specific) capacity. If the subprocess writes to
|
26 |
+
* stdout in excess of that limit without the output being captured, the
|
27 |
+
* subprocess blocks waiting for the pipe buffer to accept more data. This is
|
28 |
+
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
|
29 |
+
*
|
30 |
+
* The command lookup is performed using the `options.env.PATH` environment
|
31 |
+
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
32 |
+
* used. If `options.env` is set without `PATH`, lookup on Unix is performed
|
33 |
+
* on a default search path search of `/usr/bin:/bin` (see your operating system's
|
34 |
+
* manual for execvpe/execvp), on Windows the current processes environment
|
35 |
+
* variable `PATH` is used.
|
36 |
+
*
|
37 |
+
* On Windows, environment variables are case-insensitive. Node.js
|
38 |
+
* lexicographically sorts the `env` keys and uses the first one that
|
39 |
+
* case-insensitively matches. Only first (in lexicographic order) entry will be
|
40 |
+
* passed to the subprocess. This might lead to issues on Windows when passing
|
41 |
+
* objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`.
|
42 |
+
*
|
43 |
+
* The {@link spawn} method spawns the child process asynchronously,
|
44 |
+
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
|
45 |
+
* the event loop until the spawned process either exits or is terminated.
|
46 |
+
*
|
47 |
+
* For convenience, the `node:child_process` module provides a handful of
|
48 |
+
* synchronous and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
49 |
+
* top of {@link spawn} or {@link spawnSync}.
|
50 |
+
*
|
51 |
+
* * {@link exec}: spawns a shell and runs a command within that
|
52 |
+
* shell, passing the `stdout` and `stderr` to a callback function when
|
53 |
+
* complete.
|
54 |
+
* * {@link execFile}: similar to {@link exec} except
|
55 |
+
* that it spawns the command directly without first spawning a shell by
|
56 |
+
* default.
|
57 |
+
* * {@link fork}: spawns a new Node.js process and invokes a
|
58 |
+
* specified module with an IPC communication channel established that allows
|
59 |
+
* sending messages between parent and child.
|
60 |
+
* * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop.
|
61 |
+
* * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop.
|
62 |
+
*
|
63 |
+
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
64 |
+
* the synchronous methods can have significant impact on performance due to
|
65 |
+
* stalling the event loop while spawned processes complete.
|
66 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/child_process.js)
|
67 |
+
*/
|
68 |
+
declare module "child_process" {
|
69 |
+
import { ObjectEncodingOptions } from "node:fs";
|
70 |
+
import { Abortable, EventEmitter } from "node:events";
|
71 |
+
import * as net from "node:net";
|
72 |
+
import { Pipe, Readable, Stream, Writable } from "node:stream";
|
73 |
+
import { URL } from "node:url";
|
74 |
+
type Serializable = string | object | number | boolean | bigint;
|
75 |
+
type SendHandle = net.Socket | net.Server;
|
76 |
+
/**
|
77 |
+
* Instances of the `ChildProcess` represent spawned child processes.
|
78 |
+
*
|
79 |
+
* Instances of `ChildProcess` are not intended to be created directly. Rather,
|
80 |
+
* use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
|
81 |
+
* instances of `ChildProcess`.
|
82 |
+
* @since v2.2.0
|
83 |
+
*/
|
84 |
+
class ChildProcess extends EventEmitter {
|
85 |
+
/**
|
86 |
+
* A `Writable Stream` that represents the child process's `stdin`.
|
87 |
+
*
|
88 |
+
* If a child process waits to read all of its input, the child will not continue
|
89 |
+
* until this stream has been closed via `end()`.
|
90 |
+
*
|
91 |
+
* If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
|
92 |
+
* then this will be `null`.
|
93 |
+
*
|
94 |
+
* `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
|
95 |
+
* refer to the same value.
|
96 |
+
*
|
97 |
+
* The `subprocess.stdin` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
98 |
+
* @since v0.1.90
|
99 |
+
*/
|
100 |
+
stdin: Writable | null;
|
101 |
+
/**
|
102 |
+
* A `Readable Stream` that represents the child process's `stdout`.
|
103 |
+
*
|
104 |
+
* If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
|
105 |
+
* then this will be `null`.
|
106 |
+
*
|
107 |
+
* `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
|
108 |
+
* refer to the same value.
|
109 |
+
*
|
110 |
+
* ```js
|
111 |
+
* const { spawn } = require('node:child_process');
|
112 |
+
*
|
113 |
+
* const subprocess = spawn('ls');
|
114 |
+
*
|
115 |
+
* subprocess.stdout.on('data', (data) => {
|
116 |
+
* console.log(`Received chunk ${data}`);
|
117 |
+
* });
|
118 |
+
* ```
|
119 |
+
*
|
120 |
+
* The `subprocess.stdout` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
121 |
+
* @since v0.1.90
|
122 |
+
*/
|
123 |
+
stdout: Readable | null;
|
124 |
+
/**
|
125 |
+
* A `Readable Stream` that represents the child process's `stderr`.
|
126 |
+
*
|
127 |
+
* If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
|
128 |
+
* then this will be `null`.
|
129 |
+
*
|
130 |
+
* `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
|
131 |
+
* refer to the same value.
|
132 |
+
*
|
133 |
+
* The `subprocess.stderr` property can be `null` or `undefined`if the child process could not be successfully spawned.
|
134 |
+
* @since v0.1.90
|
135 |
+
*/
|
136 |
+
stderr: Readable | null;
|
137 |
+
/**
|
138 |
+
* The `subprocess.channel` property is a reference to the child's IPC channel. If
|
139 |
+
* no IPC channel exists, this property is `undefined`.
|
140 |
+
* @since v7.1.0
|
141 |
+
*/
|
142 |
+
readonly channel?: Pipe | null | undefined;
|
143 |
+
/**
|
144 |
+
* A sparse array of pipes to the child process, corresponding with positions in
|
145 |
+
* the `stdio` option passed to {@link spawn} that have been set
|
146 |
+
* to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`,
|
147 |
+
* respectively.
|
148 |
+
*
|
149 |
+
* In the following example, only the child's fd `1` (stdout) is configured as a
|
150 |
+
* pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
|
151 |
+
* in the array are `null`.
|
152 |
+
*
|
153 |
+
* ```js
|
154 |
+
* const assert = require('node:assert');
|
155 |
+
* const fs = require('node:fs');
|
156 |
+
* const child_process = require('node:child_process');
|
157 |
+
*
|
158 |
+
* const subprocess = child_process.spawn('ls', {
|
159 |
+
* stdio: [
|
160 |
+
* 0, // Use parent's stdin for child.
|
161 |
+
* 'pipe', // Pipe child's stdout to parent.
|
162 |
+
* fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
|
163 |
+
* ],
|
164 |
+
* });
|
165 |
+
*
|
166 |
+
* assert.strictEqual(subprocess.stdio[0], null);
|
167 |
+
* assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
|
168 |
+
*
|
169 |
+
* assert(subprocess.stdout);
|
170 |
+
* assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
|
171 |
+
*
|
172 |
+
* assert.strictEqual(subprocess.stdio[2], null);
|
173 |
+
* assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
|
174 |
+
* ```
|
175 |
+
*
|
176 |
+
* The `subprocess.stdio` property can be `undefined` if the child process could
|
177 |
+
* not be successfully spawned.
|
178 |
+
* @since v0.7.10
|
179 |
+
*/
|
180 |
+
readonly stdio: [
|
181 |
+
Writable | null,
|
182 |
+
// stdin
|
183 |
+
Readable | null,
|
184 |
+
// stdout
|
185 |
+
Readable | null,
|
186 |
+
// stderr
|
187 |
+
Readable | Writable | null | undefined,
|
188 |
+
// extra
|
189 |
+
Readable | Writable | null | undefined, // extra
|
190 |
+
];
|
191 |
+
/**
|
192 |
+
* The `subprocess.killed` property indicates whether the child process
|
193 |
+
* successfully received a signal from `subprocess.kill()`. The `killed` property
|
194 |
+
* does not indicate that the child process has been terminated.
|
195 |
+
* @since v0.5.10
|
196 |
+
*/
|
197 |
+
readonly killed: boolean;
|
198 |
+
/**
|
199 |
+
* Returns the process identifier (PID) of the child process. If the child process
|
200 |
+
* fails to spawn due to errors, then the value is `undefined` and `error` is
|
201 |
+
* emitted.
|
202 |
+
*
|
203 |
+
* ```js
|
204 |
+
* const { spawn } = require('node:child_process');
|
205 |
+
* const grep = spawn('grep', ['ssh']);
|
206 |
+
*
|
207 |
+
* console.log(`Spawned child pid: ${grep.pid}`);
|
208 |
+
* grep.stdin.end();
|
209 |
+
* ```
|
210 |
+
* @since v0.1.90
|
211 |
+
*/
|
212 |
+
readonly pid?: number | undefined;
|
213 |
+
/**
|
214 |
+
* The `subprocess.connected` property indicates whether it is still possible to
|
215 |
+
* send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages.
|
216 |
+
* @since v0.7.2
|
217 |
+
*/
|
218 |
+
readonly connected: boolean;
|
219 |
+
/**
|
220 |
+
* The `subprocess.exitCode` property indicates the exit code of the child process.
|
221 |
+
* If the child process is still running, the field will be `null`.
|
222 |
+
*/
|
223 |
+
readonly exitCode: number | null;
|
224 |
+
/**
|
225 |
+
* The `subprocess.signalCode` property indicates the signal received by
|
226 |
+
* the child process if any, else `null`.
|
227 |
+
*/
|
228 |
+
readonly signalCode: NodeJS.Signals | null;
|
229 |
+
/**
|
230 |
+
* The `subprocess.spawnargs` property represents the full list of command-line
|
231 |
+
* arguments the child process was launched with.
|
232 |
+
*/
|
233 |
+
readonly spawnargs: string[];
|
234 |
+
/**
|
235 |
+
* The `subprocess.spawnfile` property indicates the executable file name of
|
236 |
+
* the child process that is launched.
|
237 |
+
*
|
238 |
+
* For {@link fork}, its value will be equal to `process.execPath`.
|
239 |
+
* For {@link spawn}, its value will be the name of
|
240 |
+
* the executable file.
|
241 |
+
* For {@link exec}, its value will be the name of the shell
|
242 |
+
* in which the child process is launched.
|
243 |
+
*/
|
244 |
+
readonly spawnfile: string;
|
245 |
+
/**
|
246 |
+
* The `subprocess.kill()` method sends a signal to the child process. If no
|
247 |
+
* argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
|
248 |
+
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
|
249 |
+
*
|
250 |
+
* ```js
|
251 |
+
* const { spawn } = require('node:child_process');
|
252 |
+
* const grep = spawn('grep', ['ssh']);
|
253 |
+
*
|
254 |
+
* grep.on('close', (code, signal) => {
|
255 |
+
* console.log(
|
256 |
+
* `child process terminated due to receipt of signal ${signal}`);
|
257 |
+
* });
|
258 |
+
*
|
259 |
+
* // Send SIGHUP to process.
|
260 |
+
* grep.kill('SIGHUP');
|
261 |
+
* ```
|
262 |
+
*
|
263 |
+
* The `ChildProcess` object may emit an `'error'` event if the signal
|
264 |
+
* cannot be delivered. Sending a signal to a child process that has already exited
|
265 |
+
* is not an error but may have unforeseen consequences. Specifically, if the
|
266 |
+
* process identifier (PID) has been reassigned to another process, the signal will
|
267 |
+
* be delivered to that process instead which can have unexpected results.
|
268 |
+
*
|
269 |
+
* While the function is called `kill`, the signal delivered to the child process
|
270 |
+
* may not actually terminate the process.
|
271 |
+
*
|
272 |
+
* See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
|
273 |
+
*
|
274 |
+
* On Windows, where POSIX signals do not exist, the `signal` argument will be
|
275 |
+
* ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`).
|
276 |
+
* See `Signal Events` for more details.
|
277 |
+
*
|
278 |
+
* On Linux, child processes of child processes will not be terminated
|
279 |
+
* when attempting to kill their parent. This is likely to happen when running a
|
280 |
+
* new process in a shell or with the use of the `shell` option of `ChildProcess`:
|
281 |
+
*
|
282 |
+
* ```js
|
283 |
+
* 'use strict';
|
284 |
+
* const { spawn } = require('node:child_process');
|
285 |
+
*
|
286 |
+
* const subprocess = spawn(
|
287 |
+
* 'sh',
|
288 |
+
* [
|
289 |
+
* '-c',
|
290 |
+
* `node -e "setInterval(() => {
|
291 |
+
* console.log(process.pid, 'is alive')
|
292 |
+
* }, 500);"`,
|
293 |
+
* ], {
|
294 |
+
* stdio: ['inherit', 'inherit', 'inherit'],
|
295 |
+
* },
|
296 |
+
* );
|
297 |
+
*
|
298 |
+
* setTimeout(() => {
|
299 |
+
* subprocess.kill(); // Does not terminate the Node.js process in the shell.
|
300 |
+
* }, 2000);
|
301 |
+
* ```
|
302 |
+
* @since v0.1.90
|
303 |
+
*/
|
304 |
+
kill(signal?: NodeJS.Signals | number): boolean;
|
305 |
+
/**
|
306 |
+
* Calls {@link ChildProcess.kill} with `'SIGTERM'`.
|
307 |
+
* @since v20.5.0
|
308 |
+
*/
|
309 |
+
[Symbol.dispose](): void;
|
310 |
+
/**
|
311 |
+
* When an IPC channel has been established between the parent and child (
|
312 |
+
* i.e. when using {@link fork}), the `subprocess.send()` method can
|
313 |
+
* be used to send messages to the child process. When the child process is a
|
314 |
+
* Node.js instance, these messages can be received via the `'message'` event.
|
315 |
+
*
|
316 |
+
* The message goes through serialization and parsing. The resulting
|
317 |
+
* message might not be the same as what is originally sent.
|
318 |
+
*
|
319 |
+
* For example, in the parent script:
|
320 |
+
*
|
321 |
+
* ```js
|
322 |
+
* const cp = require('node:child_process');
|
323 |
+
* const n = cp.fork(`${__dirname}/sub.js`);
|
324 |
+
*
|
325 |
+
* n.on('message', (m) => {
|
326 |
+
* console.log('PARENT got message:', m);
|
327 |
+
* });
|
328 |
+
*
|
329 |
+
* // Causes the child to print: CHILD got message: { hello: 'world' }
|
330 |
+
* n.send({ hello: 'world' });
|
331 |
+
* ```
|
332 |
+
*
|
333 |
+
* And then the child script, `'sub.js'` might look like this:
|
334 |
+
*
|
335 |
+
* ```js
|
336 |
+
* process.on('message', (m) => {
|
337 |
+
* console.log('CHILD got message:', m);
|
338 |
+
* });
|
339 |
+
*
|
340 |
+
* // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }
|
341 |
+
* process.send({ foo: 'bar', baz: NaN });
|
342 |
+
* ```
|
343 |
+
*
|
344 |
+
* Child Node.js processes will have a `process.send()` method of their own
|
345 |
+
* that allows the child to send messages back to the parent.
|
346 |
+
*
|
347 |
+
* There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
|
348 |
+
* containing a `NODE_` prefix in the `cmd` property are reserved for use within
|
349 |
+
* Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js.
|
350 |
+
* Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice.
|
351 |
+
*
|
352 |
+
* The optional `sendHandle` argument that may be passed to `subprocess.send()` is
|
353 |
+
* for passing a TCP server or socket object to the child process. The child will
|
354 |
+
* receive the object as the second argument passed to the callback function
|
355 |
+
* registered on the `'message'` event. Any data that is received
|
356 |
+
* and buffered in the socket will not be sent to the child.
|
357 |
+
*
|
358 |
+
* The optional `callback` is a function that is invoked after the message is
|
359 |
+
* sent but before the child may have received it. The function is called with a
|
360 |
+
* single argument: `null` on success, or an `Error` object on failure.
|
361 |
+
*
|
362 |
+
* If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can
|
363 |
+
* happen, for instance, when the child process has already exited.
|
364 |
+
*
|
365 |
+
* `subprocess.send()` will return `false` if the channel has closed or when the
|
366 |
+
* backlog of unsent messages exceeds a threshold that makes it unwise to send
|
367 |
+
* more. Otherwise, the method returns `true`. The `callback` function can be
|
368 |
+
* used to implement flow control.
|
369 |
+
*
|
370 |
+
* #### Example: sending a server object
|
371 |
+
*
|
372 |
+
* The `sendHandle` argument can be used, for instance, to pass the handle of
|
373 |
+
* a TCP server object to the child process as illustrated in the example below:
|
374 |
+
*
|
375 |
+
* ```js
|
376 |
+
* const subprocess = require('node:child_process').fork('subprocess.js');
|
377 |
+
*
|
378 |
+
* // Open up the server object and send the handle.
|
379 |
+
* const server = require('node:net').createServer();
|
380 |
+
* server.on('connection', (socket) => {
|
381 |
+
* socket.end('handled by parent');
|
382 |
+
* });
|
383 |
+
* server.listen(1337, () => {
|
384 |
+
* subprocess.send('server', server);
|
385 |
+
* });
|
386 |
+
* ```
|
387 |
+
*
|
388 |
+
* The child would then receive the server object as:
|
389 |
+
*
|
390 |
+
* ```js
|
391 |
+
* process.on('message', (m, server) => {
|
392 |
+
* if (m === 'server') {
|
393 |
+
* server.on('connection', (socket) => {
|
394 |
+
* socket.end('handled by child');
|
395 |
+
* });
|
396 |
+
* }
|
397 |
+
* });
|
398 |
+
* ```
|
399 |
+
*
|
400 |
+
* Once the server is now shared between the parent and child, some connections
|
401 |
+
* can be handled by the parent and some by the child.
|
402 |
+
*
|
403 |
+
* While the example above uses a server created using the `node:net` module,`node:dgram` module servers use exactly the same workflow with the exceptions of
|
404 |
+
* listening on a `'message'` event instead of `'connection'` and using`server.bind()` instead of `server.listen()`. This is, however, only
|
405 |
+
* supported on Unix platforms.
|
406 |
+
*
|
407 |
+
* #### Example: sending a socket object
|
408 |
+
*
|
409 |
+
* Similarly, the `sendHandler` argument can be used to pass the handle of a
|
410 |
+
* socket to the child process. The example below spawns two children that each
|
411 |
+
* handle connections with "normal" or "special" priority:
|
412 |
+
*
|
413 |
+
* ```js
|
414 |
+
* const { fork } = require('node:child_process');
|
415 |
+
* const normal = fork('subprocess.js', ['normal']);
|
416 |
+
* const special = fork('subprocess.js', ['special']);
|
417 |
+
*
|
418 |
+
* // Open up the server and send sockets to child. Use pauseOnConnect to prevent
|
419 |
+
* // the sockets from being read before they are sent to the child process.
|
420 |
+
* const server = require('node:net').createServer({ pauseOnConnect: true });
|
421 |
+
* server.on('connection', (socket) => {
|
422 |
+
*
|
423 |
+
* // If this is special priority...
|
424 |
+
* if (socket.remoteAddress === '74.125.127.100') {
|
425 |
+
* special.send('socket', socket);
|
426 |
+
* return;
|
427 |
+
* }
|
428 |
+
* // This is normal priority.
|
429 |
+
* normal.send('socket', socket);
|
430 |
+
* });
|
431 |
+
* server.listen(1337);
|
432 |
+
* ```
|
433 |
+
*
|
434 |
+
* The `subprocess.js` would receive the socket handle as the second argument
|
435 |
+
* passed to the event callback function:
|
436 |
+
*
|
437 |
+
* ```js
|
438 |
+
* process.on('message', (m, socket) => {
|
439 |
+
* if (m === 'socket') {
|
440 |
+
* if (socket) {
|
441 |
+
* // Check that the client socket exists.
|
442 |
+
* // It is possible for the socket to be closed between the time it is
|
443 |
+
* // sent and the time it is received in the child process.
|
444 |
+
* socket.end(`Request handled with ${process.argv[2]} priority`);
|
445 |
+
* }
|
446 |
+
* }
|
447 |
+
* });
|
448 |
+
* ```
|
449 |
+
*
|
450 |
+
* Do not use `.maxConnections` on a socket that has been passed to a subprocess.
|
451 |
+
* The parent cannot track when the socket is destroyed.
|
452 |
+
*
|
453 |
+
* Any `'message'` handlers in the subprocess should verify that `socket` exists,
|
454 |
+
* as the connection may have been closed during the time it takes to send the
|
455 |
+
* connection to the child.
|
456 |
+
* @since v0.5.9
|
457 |
+
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
458 |
+
*/
|
459 |
+
send(message: Serializable, callback?: (error: Error | null) => void): boolean;
|
460 |
+
send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
|
461 |
+
send(
|
462 |
+
message: Serializable,
|
463 |
+
sendHandle?: SendHandle,
|
464 |
+
options?: MessageOptions,
|
465 |
+
callback?: (error: Error | null) => void,
|
466 |
+
): boolean;
|
467 |
+
/**
|
468 |
+
* Closes the IPC channel between parent and child, allowing the child to exit
|
469 |
+
* gracefully once there are no other connections keeping it alive. After calling
|
470 |
+
* this method the `subprocess.connected` and `process.connected` properties in
|
471 |
+
* both the parent and child (respectively) will be set to `false`, and it will be
|
472 |
+
* no longer possible to pass messages between the processes.
|
473 |
+
*
|
474 |
+
* The `'disconnect'` event will be emitted when there are no messages in the
|
475 |
+
* process of being received. This will most often be triggered immediately after
|
476 |
+
* calling `subprocess.disconnect()`.
|
477 |
+
*
|
478 |
+
* When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
|
479 |
+
* within the child process to close the IPC channel as well.
|
480 |
+
* @since v0.7.2
|
481 |
+
*/
|
482 |
+
disconnect(): void;
|
483 |
+
/**
|
484 |
+
* By default, the parent will wait for the detached child to exit. To prevent the
|
485 |
+
* parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not
|
486 |
+
* include the child in its reference count, allowing the parent to exit
|
487 |
+
* independently of the child, unless there is an established IPC channel between
|
488 |
+
* the child and the parent.
|
489 |
+
*
|
490 |
+
* ```js
|
491 |
+
* const { spawn } = require('node:child_process');
|
492 |
+
*
|
493 |
+
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
494 |
+
* detached: true,
|
495 |
+
* stdio: 'ignore',
|
496 |
+
* });
|
497 |
+
*
|
498 |
+
* subprocess.unref();
|
499 |
+
* ```
|
500 |
+
* @since v0.7.10
|
501 |
+
*/
|
502 |
+
unref(): void;
|
503 |
+
/**
|
504 |
+
* Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
|
505 |
+
* restore the removed reference count for the child process, forcing the parent
|
506 |
+
* to wait for the child to exit before exiting itself.
|
507 |
+
*
|
508 |
+
* ```js
|
509 |
+
* const { spawn } = require('node:child_process');
|
510 |
+
*
|
511 |
+
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
512 |
+
* detached: true,
|
513 |
+
* stdio: 'ignore',
|
514 |
+
* });
|
515 |
+
*
|
516 |
+
* subprocess.unref();
|
517 |
+
* subprocess.ref();
|
518 |
+
* ```
|
519 |
+
* @since v0.7.10
|
520 |
+
*/
|
521 |
+
ref(): void;
|
522 |
+
/**
|
523 |
+
* events.EventEmitter
|
524 |
+
* 1. close
|
525 |
+
* 2. disconnect
|
526 |
+
* 3. error
|
527 |
+
* 4. exit
|
528 |
+
* 5. message
|
529 |
+
* 6. spawn
|
530 |
+
*/
|
531 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
532 |
+
addListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
533 |
+
addListener(event: "disconnect", listener: () => void): this;
|
534 |
+
addListener(event: "error", listener: (err: Error) => void): this;
|
535 |
+
addListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
536 |
+
addListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
537 |
+
addListener(event: "spawn", listener: () => void): this;
|
538 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
539 |
+
emit(event: "close", code: number | null, signal: NodeJS.Signals | null): boolean;
|
540 |
+
emit(event: "disconnect"): boolean;
|
541 |
+
emit(event: "error", err: Error): boolean;
|
542 |
+
emit(event: "exit", code: number | null, signal: NodeJS.Signals | null): boolean;
|
543 |
+
emit(event: "message", message: Serializable, sendHandle: SendHandle): boolean;
|
544 |
+
emit(event: "spawn", listener: () => void): boolean;
|
545 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
546 |
+
on(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
547 |
+
on(event: "disconnect", listener: () => void): this;
|
548 |
+
on(event: "error", listener: (err: Error) => void): this;
|
549 |
+
on(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
550 |
+
on(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
551 |
+
on(event: "spawn", listener: () => void): this;
|
552 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
553 |
+
once(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
554 |
+
once(event: "disconnect", listener: () => void): this;
|
555 |
+
once(event: "error", listener: (err: Error) => void): this;
|
556 |
+
once(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
557 |
+
once(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
558 |
+
once(event: "spawn", listener: () => void): this;
|
559 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
560 |
+
prependListener(event: "close", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
561 |
+
prependListener(event: "disconnect", listener: () => void): this;
|
562 |
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
563 |
+
prependListener(event: "exit", listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
564 |
+
prependListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
565 |
+
prependListener(event: "spawn", listener: () => void): this;
|
566 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
567 |
+
prependOnceListener(
|
568 |
+
event: "close",
|
569 |
+
listener: (code: number | null, signal: NodeJS.Signals | null) => void,
|
570 |
+
): this;
|
571 |
+
prependOnceListener(event: "disconnect", listener: () => void): this;
|
572 |
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
573 |
+
prependOnceListener(
|
574 |
+
event: "exit",
|
575 |
+
listener: (code: number | null, signal: NodeJS.Signals | null) => void,
|
576 |
+
): this;
|
577 |
+
prependOnceListener(event: "message", listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
578 |
+
prependOnceListener(event: "spawn", listener: () => void): this;
|
579 |
+
}
|
580 |
+
// return this object when stdio option is undefined or not specified
|
581 |
+
interface ChildProcessWithoutNullStreams extends ChildProcess {
|
582 |
+
stdin: Writable;
|
583 |
+
stdout: Readable;
|
584 |
+
stderr: Readable;
|
585 |
+
readonly stdio: [
|
586 |
+
Writable,
|
587 |
+
Readable,
|
588 |
+
Readable,
|
589 |
+
// stderr
|
590 |
+
Readable | Writable | null | undefined,
|
591 |
+
// extra, no modification
|
592 |
+
Readable | Writable | null | undefined, // extra, no modification
|
593 |
+
];
|
594 |
+
}
|
595 |
+
// return this object when stdio option is a tuple of 3
|
596 |
+
interface ChildProcessByStdio<I extends null | Writable, O extends null | Readable, E extends null | Readable>
|
597 |
+
extends ChildProcess
|
598 |
+
{
|
599 |
+
stdin: I;
|
600 |
+
stdout: O;
|
601 |
+
stderr: E;
|
602 |
+
readonly stdio: [
|
603 |
+
I,
|
604 |
+
O,
|
605 |
+
E,
|
606 |
+
Readable | Writable | null | undefined,
|
607 |
+
// extra, no modification
|
608 |
+
Readable | Writable | null | undefined, // extra, no modification
|
609 |
+
];
|
610 |
+
}
|
611 |
+
interface MessageOptions {
|
612 |
+
keepOpen?: boolean | undefined;
|
613 |
+
}
|
614 |
+
type IOType = "overlapped" | "pipe" | "ignore" | "inherit";
|
615 |
+
type StdioOptions = IOType | Array<IOType | "ipc" | Stream | number | null | undefined>;
|
616 |
+
type SerializationType = "json" | "advanced";
|
617 |
+
interface MessagingOptions extends Abortable {
|
618 |
+
/**
|
619 |
+
* Specify the kind of serialization used for sending messages between processes.
|
620 |
+
* @default 'json'
|
621 |
+
*/
|
622 |
+
serialization?: SerializationType | undefined;
|
623 |
+
/**
|
624 |
+
* The signal value to be used when the spawned process will be killed by the abort signal.
|
625 |
+
* @default 'SIGTERM'
|
626 |
+
*/
|
627 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
628 |
+
/**
|
629 |
+
* In milliseconds the maximum amount of time the process is allowed to run.
|
630 |
+
*/
|
631 |
+
timeout?: number | undefined;
|
632 |
+
}
|
633 |
+
interface ProcessEnvOptions {
|
634 |
+
uid?: number | undefined;
|
635 |
+
gid?: number | undefined;
|
636 |
+
cwd?: string | URL | undefined;
|
637 |
+
env?: NodeJS.ProcessEnv | undefined;
|
638 |
+
}
|
639 |
+
interface CommonOptions extends ProcessEnvOptions {
|
640 |
+
/**
|
641 |
+
* @default false
|
642 |
+
*/
|
643 |
+
windowsHide?: boolean | undefined;
|
644 |
+
/**
|
645 |
+
* @default 0
|
646 |
+
*/
|
647 |
+
timeout?: number | undefined;
|
648 |
+
}
|
649 |
+
interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
|
650 |
+
argv0?: string | undefined;
|
651 |
+
/**
|
652 |
+
* Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
|
653 |
+
* If passed as an array, the first element is used for `stdin`, the second for
|
654 |
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
655 |
+
* specify the `stdio` behavior beyond the standard streams. See
|
656 |
+
* {@link ChildProcess.stdio} for more information.
|
657 |
+
*
|
658 |
+
* @default 'pipe'
|
659 |
+
*/
|
660 |
+
stdio?: StdioOptions | undefined;
|
661 |
+
shell?: boolean | string | undefined;
|
662 |
+
windowsVerbatimArguments?: boolean | undefined;
|
663 |
+
}
|
664 |
+
interface SpawnOptions extends CommonSpawnOptions {
|
665 |
+
detached?: boolean | undefined;
|
666 |
+
}
|
667 |
+
interface SpawnOptionsWithoutStdio extends SpawnOptions {
|
668 |
+
stdio?: StdioPipeNamed | StdioPipe[] | undefined;
|
669 |
+
}
|
670 |
+
type StdioNull = "inherit" | "ignore" | Stream;
|
671 |
+
type StdioPipeNamed = "pipe" | "overlapped";
|
672 |
+
type StdioPipe = undefined | null | StdioPipeNamed;
|
673 |
+
interface SpawnOptionsWithStdioTuple<
|
674 |
+
Stdin extends StdioNull | StdioPipe,
|
675 |
+
Stdout extends StdioNull | StdioPipe,
|
676 |
+
Stderr extends StdioNull | StdioPipe,
|
677 |
+
> extends SpawnOptions {
|
678 |
+
stdio: [Stdin, Stdout, Stderr];
|
679 |
+
}
|
680 |
+
/**
|
681 |
+
* The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults
|
682 |
+
* to an empty array.
|
683 |
+
*
|
684 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
685 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
686 |
+
* **arbitrary command execution.**
|
687 |
+
*
|
688 |
+
* A third argument may be used to specify additional options, with these defaults:
|
689 |
+
*
|
690 |
+
* ```js
|
691 |
+
* const defaults = {
|
692 |
+
* cwd: undefined,
|
693 |
+
* env: process.env,
|
694 |
+
* };
|
695 |
+
* ```
|
696 |
+
*
|
697 |
+
* Use `cwd` to specify the working directory from which the process is spawned.
|
698 |
+
* If not given, the default is to inherit the current working directory. If given,
|
699 |
+
* but the path does not exist, the child process emits an `ENOENT` error
|
700 |
+
* and exits immediately. `ENOENT` is also emitted when the command
|
701 |
+
* does not exist.
|
702 |
+
*
|
703 |
+
* Use `env` to specify environment variables that will be visible to the new
|
704 |
+
* process, the default is `process.env`.
|
705 |
+
*
|
706 |
+
* `undefined` values in `env` will be ignored.
|
707 |
+
*
|
708 |
+
* Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
|
709 |
+
* exit code:
|
710 |
+
*
|
711 |
+
* ```js
|
712 |
+
* const { spawn } = require('node:child_process');
|
713 |
+
* const ls = spawn('ls', ['-lh', '/usr']);
|
714 |
+
*
|
715 |
+
* ls.stdout.on('data', (data) => {
|
716 |
+
* console.log(`stdout: ${data}`);
|
717 |
+
* });
|
718 |
+
*
|
719 |
+
* ls.stderr.on('data', (data) => {
|
720 |
+
* console.error(`stderr: ${data}`);
|
721 |
+
* });
|
722 |
+
*
|
723 |
+
* ls.on('close', (code) => {
|
724 |
+
* console.log(`child process exited with code ${code}`);
|
725 |
+
* });
|
726 |
+
* ```
|
727 |
+
*
|
728 |
+
* Example: A very elaborate way to run `ps ax | grep ssh`
|
729 |
+
*
|
730 |
+
* ```js
|
731 |
+
* const { spawn } = require('node:child_process');
|
732 |
+
* const ps = spawn('ps', ['ax']);
|
733 |
+
* const grep = spawn('grep', ['ssh']);
|
734 |
+
*
|
735 |
+
* ps.stdout.on('data', (data) => {
|
736 |
+
* grep.stdin.write(data);
|
737 |
+
* });
|
738 |
+
*
|
739 |
+
* ps.stderr.on('data', (data) => {
|
740 |
+
* console.error(`ps stderr: ${data}`);
|
741 |
+
* });
|
742 |
+
*
|
743 |
+
* ps.on('close', (code) => {
|
744 |
+
* if (code !== 0) {
|
745 |
+
* console.log(`ps process exited with code ${code}`);
|
746 |
+
* }
|
747 |
+
* grep.stdin.end();
|
748 |
+
* });
|
749 |
+
*
|
750 |
+
* grep.stdout.on('data', (data) => {
|
751 |
+
* console.log(data.toString());
|
752 |
+
* });
|
753 |
+
*
|
754 |
+
* grep.stderr.on('data', (data) => {
|
755 |
+
* console.error(`grep stderr: ${data}`);
|
756 |
+
* });
|
757 |
+
*
|
758 |
+
* grep.on('close', (code) => {
|
759 |
+
* if (code !== 0) {
|
760 |
+
* console.log(`grep process exited with code ${code}`);
|
761 |
+
* }
|
762 |
+
* });
|
763 |
+
* ```
|
764 |
+
*
|
765 |
+
* Example of checking for failed `spawn`:
|
766 |
+
*
|
767 |
+
* ```js
|
768 |
+
* const { spawn } = require('node:child_process');
|
769 |
+
* const subprocess = spawn('bad_command');
|
770 |
+
*
|
771 |
+
* subprocess.on('error', (err) => {
|
772 |
+
* console.error('Failed to start subprocess.');
|
773 |
+
* });
|
774 |
+
* ```
|
775 |
+
*
|
776 |
+
* Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
|
777 |
+
* title while others (Windows, SunOS) will use `command`.
|
778 |
+
*
|
779 |
+
* Node.js overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent. Retrieve
|
780 |
+
* it with the`process.argv0` property instead.
|
781 |
+
*
|
782 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
783 |
+
* the error passed to the callback will be an `AbortError`:
|
784 |
+
*
|
785 |
+
* ```js
|
786 |
+
* const { spawn } = require('node:child_process');
|
787 |
+
* const controller = new AbortController();
|
788 |
+
* const { signal } = controller;
|
789 |
+
* const grep = spawn('grep', ['ssh'], { signal });
|
790 |
+
* grep.on('error', (err) => {
|
791 |
+
* // This will be called with err being an AbortError if the controller aborts
|
792 |
+
* });
|
793 |
+
* controller.abort(); // Stops the child process
|
794 |
+
* ```
|
795 |
+
* @since v0.1.90
|
796 |
+
* @param command The command to run.
|
797 |
+
* @param args List of string arguments.
|
798 |
+
*/
|
799 |
+
function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
|
800 |
+
function spawn(
|
801 |
+
command: string,
|
802 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
|
803 |
+
): ChildProcessByStdio<Writable, Readable, Readable>;
|
804 |
+
function spawn(
|
805 |
+
command: string,
|
806 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
|
807 |
+
): ChildProcessByStdio<Writable, Readable, null>;
|
808 |
+
function spawn(
|
809 |
+
command: string,
|
810 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
|
811 |
+
): ChildProcessByStdio<Writable, null, Readable>;
|
812 |
+
function spawn(
|
813 |
+
command: string,
|
814 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
|
815 |
+
): ChildProcessByStdio<null, Readable, Readable>;
|
816 |
+
function spawn(
|
817 |
+
command: string,
|
818 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
|
819 |
+
): ChildProcessByStdio<Writable, null, null>;
|
820 |
+
function spawn(
|
821 |
+
command: string,
|
822 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
|
823 |
+
): ChildProcessByStdio<null, Readable, null>;
|
824 |
+
function spawn(
|
825 |
+
command: string,
|
826 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
|
827 |
+
): ChildProcessByStdio<null, null, Readable>;
|
828 |
+
function spawn(
|
829 |
+
command: string,
|
830 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
|
831 |
+
): ChildProcessByStdio<null, null, null>;
|
832 |
+
function spawn(command: string, options: SpawnOptions): ChildProcess;
|
833 |
+
// overloads of spawn with 'args'
|
834 |
+
function spawn(
|
835 |
+
command: string,
|
836 |
+
args?: readonly string[],
|
837 |
+
options?: SpawnOptionsWithoutStdio,
|
838 |
+
): ChildProcessWithoutNullStreams;
|
839 |
+
function spawn(
|
840 |
+
command: string,
|
841 |
+
args: readonly string[],
|
842 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>,
|
843 |
+
): ChildProcessByStdio<Writable, Readable, Readable>;
|
844 |
+
function spawn(
|
845 |
+
command: string,
|
846 |
+
args: readonly string[],
|
847 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>,
|
848 |
+
): ChildProcessByStdio<Writable, Readable, null>;
|
849 |
+
function spawn(
|
850 |
+
command: string,
|
851 |
+
args: readonly string[],
|
852 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>,
|
853 |
+
): ChildProcessByStdio<Writable, null, Readable>;
|
854 |
+
function spawn(
|
855 |
+
command: string,
|
856 |
+
args: readonly string[],
|
857 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>,
|
858 |
+
): ChildProcessByStdio<null, Readable, Readable>;
|
859 |
+
function spawn(
|
860 |
+
command: string,
|
861 |
+
args: readonly string[],
|
862 |
+
options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>,
|
863 |
+
): ChildProcessByStdio<Writable, null, null>;
|
864 |
+
function spawn(
|
865 |
+
command: string,
|
866 |
+
args: readonly string[],
|
867 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>,
|
868 |
+
): ChildProcessByStdio<null, Readable, null>;
|
869 |
+
function spawn(
|
870 |
+
command: string,
|
871 |
+
args: readonly string[],
|
872 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>,
|
873 |
+
): ChildProcessByStdio<null, null, Readable>;
|
874 |
+
function spawn(
|
875 |
+
command: string,
|
876 |
+
args: readonly string[],
|
877 |
+
options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>,
|
878 |
+
): ChildProcessByStdio<null, null, null>;
|
879 |
+
function spawn(command: string, args: readonly string[], options: SpawnOptions): ChildProcess;
|
880 |
+
interface ExecOptions extends CommonOptions {
|
881 |
+
shell?: string | undefined;
|
882 |
+
signal?: AbortSignal | undefined;
|
883 |
+
maxBuffer?: number | undefined;
|
884 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
885 |
+
}
|
886 |
+
interface ExecOptionsWithStringEncoding extends ExecOptions {
|
887 |
+
encoding: BufferEncoding;
|
888 |
+
}
|
889 |
+
interface ExecOptionsWithBufferEncoding extends ExecOptions {
|
890 |
+
encoding: BufferEncoding | null; // specify `null`.
|
891 |
+
}
|
892 |
+
interface ExecException extends Error {
|
893 |
+
cmd?: string | undefined;
|
894 |
+
killed?: boolean | undefined;
|
895 |
+
code?: number | undefined;
|
896 |
+
signal?: NodeJS.Signals | undefined;
|
897 |
+
}
|
898 |
+
/**
|
899 |
+
* Spawns a shell then executes the `command` within that shell, buffering any
|
900 |
+
* generated output. The `command` string passed to the exec function is processed
|
901 |
+
* directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
|
902 |
+
* need to be dealt with accordingly:
|
903 |
+
*
|
904 |
+
* ```js
|
905 |
+
* const { exec } = require('node:child_process');
|
906 |
+
*
|
907 |
+
* exec('"/path/to/test file/test.sh" arg1 arg2');
|
908 |
+
* // Double quotes are used so that the space in the path is not interpreted as
|
909 |
+
* // a delimiter of multiple arguments.
|
910 |
+
*
|
911 |
+
* exec('echo "The \\$HOME variable is $HOME"');
|
912 |
+
* // The $HOME variable is escaped in the first instance, but not in the second.
|
913 |
+
* ```
|
914 |
+
*
|
915 |
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
916 |
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
917 |
+
*
|
918 |
+
* If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The
|
919 |
+
* `error.code` property will be
|
920 |
+
* the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the
|
921 |
+
* process.
|
922 |
+
*
|
923 |
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
924 |
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
925 |
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
926 |
+
* can be used to specify the character encoding used to decode the stdout and
|
927 |
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
928 |
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
929 |
+
*
|
930 |
+
* ```js
|
931 |
+
* const { exec } = require('node:child_process');
|
932 |
+
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
933 |
+
* if (error) {
|
934 |
+
* console.error(`exec error: ${error}`);
|
935 |
+
* return;
|
936 |
+
* }
|
937 |
+
* console.log(`stdout: ${stdout}`);
|
938 |
+
* console.error(`stderr: ${stderr}`);
|
939 |
+
* });
|
940 |
+
* ```
|
941 |
+
*
|
942 |
+
* If `timeout` is greater than `0`, the parent will send the signal
|
943 |
+
* identified by the `killSignal` property (the default is `'SIGTERM'`) if the
|
944 |
+
* child runs longer than `timeout` milliseconds.
|
945 |
+
*
|
946 |
+
* Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
|
947 |
+
* the existing process and uses a shell to execute the command.
|
948 |
+
*
|
949 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
950 |
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
951 |
+
* case of an error (including any error resulting in an exit code other than 0), a
|
952 |
+
* rejected promise is returned, with the same `error` object given in the
|
953 |
+
* callback, but with two additional properties `stdout` and `stderr`.
|
954 |
+
*
|
955 |
+
* ```js
|
956 |
+
* const util = require('node:util');
|
957 |
+
* const exec = util.promisify(require('node:child_process').exec);
|
958 |
+
*
|
959 |
+
* async function lsExample() {
|
960 |
+
* const { stdout, stderr } = await exec('ls');
|
961 |
+
* console.log('stdout:', stdout);
|
962 |
+
* console.error('stderr:', stderr);
|
963 |
+
* }
|
964 |
+
* lsExample();
|
965 |
+
* ```
|
966 |
+
*
|
967 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
968 |
+
* the error passed to the callback will be an `AbortError`:
|
969 |
+
*
|
970 |
+
* ```js
|
971 |
+
* const { exec } = require('node:child_process');
|
972 |
+
* const controller = new AbortController();
|
973 |
+
* const { signal } = controller;
|
974 |
+
* const child = exec('grep ssh', { signal }, (error) => {
|
975 |
+
* console.error(error); // an AbortError
|
976 |
+
* });
|
977 |
+
* controller.abort();
|
978 |
+
* ```
|
979 |
+
* @since v0.1.90
|
980 |
+
* @param command The command to run, with space-separated arguments.
|
981 |
+
* @param callback called with the output when process terminates.
|
982 |
+
*/
|
983 |
+
function exec(
|
984 |
+
command: string,
|
985 |
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
986 |
+
): ChildProcess;
|
987 |
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
988 |
+
function exec(
|
989 |
+
command: string,
|
990 |
+
options: {
|
991 |
+
encoding: "buffer" | null;
|
992 |
+
} & ExecOptions,
|
993 |
+
callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void,
|
994 |
+
): ChildProcess;
|
995 |
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
996 |
+
function exec(
|
997 |
+
command: string,
|
998 |
+
options: {
|
999 |
+
encoding: BufferEncoding;
|
1000 |
+
} & ExecOptions,
|
1001 |
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
1002 |
+
): ChildProcess;
|
1003 |
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
1004 |
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
1005 |
+
function exec(
|
1006 |
+
command: string,
|
1007 |
+
options: {
|
1008 |
+
encoding: BufferEncoding;
|
1009 |
+
} & ExecOptions,
|
1010 |
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1011 |
+
): ChildProcess;
|
1012 |
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
1013 |
+
function exec(
|
1014 |
+
command: string,
|
1015 |
+
options: ExecOptions,
|
1016 |
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void,
|
1017 |
+
): ChildProcess;
|
1018 |
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
1019 |
+
function exec(
|
1020 |
+
command: string,
|
1021 |
+
options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
|
1022 |
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1023 |
+
): ChildProcess;
|
1024 |
+
interface PromiseWithChild<T> extends Promise<T> {
|
1025 |
+
child: ChildProcess;
|
1026 |
+
}
|
1027 |
+
namespace exec {
|
1028 |
+
function __promisify__(command: string): PromiseWithChild<{
|
1029 |
+
stdout: string;
|
1030 |
+
stderr: string;
|
1031 |
+
}>;
|
1032 |
+
function __promisify__(
|
1033 |
+
command: string,
|
1034 |
+
options: {
|
1035 |
+
encoding: "buffer" | null;
|
1036 |
+
} & ExecOptions,
|
1037 |
+
): PromiseWithChild<{
|
1038 |
+
stdout: Buffer;
|
1039 |
+
stderr: Buffer;
|
1040 |
+
}>;
|
1041 |
+
function __promisify__(
|
1042 |
+
command: string,
|
1043 |
+
options: {
|
1044 |
+
encoding: BufferEncoding;
|
1045 |
+
} & ExecOptions,
|
1046 |
+
): PromiseWithChild<{
|
1047 |
+
stdout: string;
|
1048 |
+
stderr: string;
|
1049 |
+
}>;
|
1050 |
+
function __promisify__(
|
1051 |
+
command: string,
|
1052 |
+
options: ExecOptions,
|
1053 |
+
): PromiseWithChild<{
|
1054 |
+
stdout: string;
|
1055 |
+
stderr: string;
|
1056 |
+
}>;
|
1057 |
+
function __promisify__(
|
1058 |
+
command: string,
|
1059 |
+
options?: (ObjectEncodingOptions & ExecOptions) | null,
|
1060 |
+
): PromiseWithChild<{
|
1061 |
+
stdout: string | Buffer;
|
1062 |
+
stderr: string | Buffer;
|
1063 |
+
}>;
|
1064 |
+
}
|
1065 |
+
interface ExecFileOptions extends CommonOptions, Abortable {
|
1066 |
+
maxBuffer?: number | undefined;
|
1067 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
1068 |
+
windowsVerbatimArguments?: boolean | undefined;
|
1069 |
+
shell?: boolean | string | undefined;
|
1070 |
+
signal?: AbortSignal | undefined;
|
1071 |
+
}
|
1072 |
+
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
|
1073 |
+
encoding: BufferEncoding;
|
1074 |
+
}
|
1075 |
+
interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
|
1076 |
+
encoding: "buffer" | null;
|
1077 |
+
}
|
1078 |
+
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
|
1079 |
+
encoding: BufferEncoding;
|
1080 |
+
}
|
1081 |
+
type ExecFileException =
|
1082 |
+
& Omit<ExecException, "code">
|
1083 |
+
& Omit<NodeJS.ErrnoException, "code">
|
1084 |
+
& { code?: string | number | undefined | null };
|
1085 |
+
/**
|
1086 |
+
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
|
1087 |
+
* executable `file` is spawned directly as a new process making it slightly more
|
1088 |
+
* efficient than {@link exec}.
|
1089 |
+
*
|
1090 |
+
* The same options as {@link exec} are supported. Since a shell is
|
1091 |
+
* not spawned, behaviors such as I/O redirection and file globbing are not
|
1092 |
+
* supported.
|
1093 |
+
*
|
1094 |
+
* ```js
|
1095 |
+
* const { execFile } = require('node:child_process');
|
1096 |
+
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
1097 |
+
* if (error) {
|
1098 |
+
* throw error;
|
1099 |
+
* }
|
1100 |
+
* console.log(stdout);
|
1101 |
+
* });
|
1102 |
+
* ```
|
1103 |
+
*
|
1104 |
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
1105 |
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
1106 |
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
1107 |
+
* can be used to specify the character encoding used to decode the stdout and
|
1108 |
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
1109 |
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
1110 |
+
*
|
1111 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
1112 |
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
1113 |
+
* case of an error (including any error resulting in an exit code other than 0), a
|
1114 |
+
* rejected promise is returned, with the same `error` object given in the
|
1115 |
+
* callback, but with two additional properties `stdout` and `stderr`.
|
1116 |
+
*
|
1117 |
+
* ```js
|
1118 |
+
* const util = require('node:util');
|
1119 |
+
* const execFile = util.promisify(require('node:child_process').execFile);
|
1120 |
+
* async function getVersion() {
|
1121 |
+
* const { stdout } = await execFile('node', ['--version']);
|
1122 |
+
* console.log(stdout);
|
1123 |
+
* }
|
1124 |
+
* getVersion();
|
1125 |
+
* ```
|
1126 |
+
*
|
1127 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1128 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1129 |
+
* **arbitrary command execution.**
|
1130 |
+
*
|
1131 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1132 |
+
* the error passed to the callback will be an `AbortError`:
|
1133 |
+
*
|
1134 |
+
* ```js
|
1135 |
+
* const { execFile } = require('node:child_process');
|
1136 |
+
* const controller = new AbortController();
|
1137 |
+
* const { signal } = controller;
|
1138 |
+
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
1139 |
+
* console.error(error); // an AbortError
|
1140 |
+
* });
|
1141 |
+
* controller.abort();
|
1142 |
+
* ```
|
1143 |
+
* @since v0.1.91
|
1144 |
+
* @param file The name or path of the executable file to run.
|
1145 |
+
* @param args List of string arguments.
|
1146 |
+
* @param callback Called with the output when process terminates.
|
1147 |
+
*/
|
1148 |
+
function execFile(file: string): ChildProcess;
|
1149 |
+
function execFile(
|
1150 |
+
file: string,
|
1151 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1152 |
+
): ChildProcess;
|
1153 |
+
function execFile(file: string, args?: readonly string[] | null): ChildProcess;
|
1154 |
+
function execFile(
|
1155 |
+
file: string,
|
1156 |
+
args: readonly string[] | undefined | null,
|
1157 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1158 |
+
): ChildProcess;
|
1159 |
+
// no `options` definitely means stdout/stderr are `string`.
|
1160 |
+
function execFile(
|
1161 |
+
file: string,
|
1162 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1163 |
+
): ChildProcess;
|
1164 |
+
function execFile(
|
1165 |
+
file: string,
|
1166 |
+
args: readonly string[] | undefined | null,
|
1167 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1168 |
+
): ChildProcess;
|
1169 |
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
1170 |
+
function execFile(
|
1171 |
+
file: string,
|
1172 |
+
options: ExecFileOptionsWithBufferEncoding,
|
1173 |
+
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
|
1174 |
+
): ChildProcess;
|
1175 |
+
function execFile(
|
1176 |
+
file: string,
|
1177 |
+
args: readonly string[] | undefined | null,
|
1178 |
+
options: ExecFileOptionsWithBufferEncoding,
|
1179 |
+
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void,
|
1180 |
+
): ChildProcess;
|
1181 |
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
1182 |
+
function execFile(
|
1183 |
+
file: string,
|
1184 |
+
options: ExecFileOptionsWithStringEncoding,
|
1185 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1186 |
+
): ChildProcess;
|
1187 |
+
function execFile(
|
1188 |
+
file: string,
|
1189 |
+
args: readonly string[] | undefined | null,
|
1190 |
+
options: ExecFileOptionsWithStringEncoding,
|
1191 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1192 |
+
): ChildProcess;
|
1193 |
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
1194 |
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
1195 |
+
function execFile(
|
1196 |
+
file: string,
|
1197 |
+
options: ExecFileOptionsWithOtherEncoding,
|
1198 |
+
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1199 |
+
): ChildProcess;
|
1200 |
+
function execFile(
|
1201 |
+
file: string,
|
1202 |
+
args: readonly string[] | undefined | null,
|
1203 |
+
options: ExecFileOptionsWithOtherEncoding,
|
1204 |
+
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void,
|
1205 |
+
): ChildProcess;
|
1206 |
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
1207 |
+
function execFile(
|
1208 |
+
file: string,
|
1209 |
+
options: ExecFileOptions,
|
1210 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1211 |
+
): ChildProcess;
|
1212 |
+
function execFile(
|
1213 |
+
file: string,
|
1214 |
+
args: readonly string[] | undefined | null,
|
1215 |
+
options: ExecFileOptions,
|
1216 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void,
|
1217 |
+
): ChildProcess;
|
1218 |
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
1219 |
+
function execFile(
|
1220 |
+
file: string,
|
1221 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1222 |
+
callback:
|
1223 |
+
| ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
|
1224 |
+
| undefined
|
1225 |
+
| null,
|
1226 |
+
): ChildProcess;
|
1227 |
+
function execFile(
|
1228 |
+
file: string,
|
1229 |
+
args: readonly string[] | undefined | null,
|
1230 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1231 |
+
callback:
|
1232 |
+
| ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void)
|
1233 |
+
| undefined
|
1234 |
+
| null,
|
1235 |
+
): ChildProcess;
|
1236 |
+
namespace execFile {
|
1237 |
+
function __promisify__(file: string): PromiseWithChild<{
|
1238 |
+
stdout: string;
|
1239 |
+
stderr: string;
|
1240 |
+
}>;
|
1241 |
+
function __promisify__(
|
1242 |
+
file: string,
|
1243 |
+
args: readonly string[] | undefined | null,
|
1244 |
+
): PromiseWithChild<{
|
1245 |
+
stdout: string;
|
1246 |
+
stderr: string;
|
1247 |
+
}>;
|
1248 |
+
function __promisify__(
|
1249 |
+
file: string,
|
1250 |
+
options: ExecFileOptionsWithBufferEncoding,
|
1251 |
+
): PromiseWithChild<{
|
1252 |
+
stdout: Buffer;
|
1253 |
+
stderr: Buffer;
|
1254 |
+
}>;
|
1255 |
+
function __promisify__(
|
1256 |
+
file: string,
|
1257 |
+
args: readonly string[] | undefined | null,
|
1258 |
+
options: ExecFileOptionsWithBufferEncoding,
|
1259 |
+
): PromiseWithChild<{
|
1260 |
+
stdout: Buffer;
|
1261 |
+
stderr: Buffer;
|
1262 |
+
}>;
|
1263 |
+
function __promisify__(
|
1264 |
+
file: string,
|
1265 |
+
options: ExecFileOptionsWithStringEncoding,
|
1266 |
+
): PromiseWithChild<{
|
1267 |
+
stdout: string;
|
1268 |
+
stderr: string;
|
1269 |
+
}>;
|
1270 |
+
function __promisify__(
|
1271 |
+
file: string,
|
1272 |
+
args: readonly string[] | undefined | null,
|
1273 |
+
options: ExecFileOptionsWithStringEncoding,
|
1274 |
+
): PromiseWithChild<{
|
1275 |
+
stdout: string;
|
1276 |
+
stderr: string;
|
1277 |
+
}>;
|
1278 |
+
function __promisify__(
|
1279 |
+
file: string,
|
1280 |
+
options: ExecFileOptionsWithOtherEncoding,
|
1281 |
+
): PromiseWithChild<{
|
1282 |
+
stdout: string | Buffer;
|
1283 |
+
stderr: string | Buffer;
|
1284 |
+
}>;
|
1285 |
+
function __promisify__(
|
1286 |
+
file: string,
|
1287 |
+
args: readonly string[] | undefined | null,
|
1288 |
+
options: ExecFileOptionsWithOtherEncoding,
|
1289 |
+
): PromiseWithChild<{
|
1290 |
+
stdout: string | Buffer;
|
1291 |
+
stderr: string | Buffer;
|
1292 |
+
}>;
|
1293 |
+
function __promisify__(
|
1294 |
+
file: string,
|
1295 |
+
options: ExecFileOptions,
|
1296 |
+
): PromiseWithChild<{
|
1297 |
+
stdout: string;
|
1298 |
+
stderr: string;
|
1299 |
+
}>;
|
1300 |
+
function __promisify__(
|
1301 |
+
file: string,
|
1302 |
+
args: readonly string[] | undefined | null,
|
1303 |
+
options: ExecFileOptions,
|
1304 |
+
): PromiseWithChild<{
|
1305 |
+
stdout: string;
|
1306 |
+
stderr: string;
|
1307 |
+
}>;
|
1308 |
+
function __promisify__(
|
1309 |
+
file: string,
|
1310 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1311 |
+
): PromiseWithChild<{
|
1312 |
+
stdout: string | Buffer;
|
1313 |
+
stderr: string | Buffer;
|
1314 |
+
}>;
|
1315 |
+
function __promisify__(
|
1316 |
+
file: string,
|
1317 |
+
args: readonly string[] | undefined | null,
|
1318 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1319 |
+
): PromiseWithChild<{
|
1320 |
+
stdout: string | Buffer;
|
1321 |
+
stderr: string | Buffer;
|
1322 |
+
}>;
|
1323 |
+
}
|
1324 |
+
interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
|
1325 |
+
execPath?: string | undefined;
|
1326 |
+
execArgv?: string[] | undefined;
|
1327 |
+
silent?: boolean | undefined;
|
1328 |
+
/**
|
1329 |
+
* Can be set to 'pipe', 'inherit', 'overlapped', or 'ignore', or an array of these strings.
|
1330 |
+
* If passed as an array, the first element is used for `stdin`, the second for
|
1331 |
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
1332 |
+
* specify the `stdio` behavior beyond the standard streams. See
|
1333 |
+
* {@link ChildProcess.stdio} for more information.
|
1334 |
+
*
|
1335 |
+
* @default 'pipe'
|
1336 |
+
*/
|
1337 |
+
stdio?: StdioOptions | undefined;
|
1338 |
+
detached?: boolean | undefined;
|
1339 |
+
windowsVerbatimArguments?: boolean | undefined;
|
1340 |
+
}
|
1341 |
+
/**
|
1342 |
+
* The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
|
1343 |
+
* Like {@link spawn}, a `ChildProcess` object is returned. The
|
1344 |
+
* returned `ChildProcess` will have an additional communication channel
|
1345 |
+
* built-in that allows messages to be passed back and forth between the parent and
|
1346 |
+
* child. See `subprocess.send()` for details.
|
1347 |
+
*
|
1348 |
+
* Keep in mind that spawned Node.js child processes are
|
1349 |
+
* independent of the parent with exception of the IPC communication channel
|
1350 |
+
* that is established between the two. Each process has its own memory, with
|
1351 |
+
* their own V8 instances. Because of the additional resource allocations
|
1352 |
+
* required, spawning a large number of child Node.js processes is not
|
1353 |
+
* recommended.
|
1354 |
+
*
|
1355 |
+
* By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative
|
1356 |
+
* execution path to be used.
|
1357 |
+
*
|
1358 |
+
* Node.js processes launched with a custom `execPath` will communicate with the
|
1359 |
+
* parent process using the file descriptor (fd) identified using the
|
1360 |
+
* environment variable `NODE_CHANNEL_FD` on the child process.
|
1361 |
+
*
|
1362 |
+
* Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
|
1363 |
+
* current process.
|
1364 |
+
*
|
1365 |
+
* The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
|
1366 |
+
*
|
1367 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1368 |
+
* the error passed to the callback will be an `AbortError`:
|
1369 |
+
*
|
1370 |
+
* ```js
|
1371 |
+
* if (process.argv[2] === 'child') {
|
1372 |
+
* setTimeout(() => {
|
1373 |
+
* console.log(`Hello from ${process.argv[2]}!`);
|
1374 |
+
* }, 1_000);
|
1375 |
+
* } else {
|
1376 |
+
* const { fork } = require('node:child_process');
|
1377 |
+
* const controller = new AbortController();
|
1378 |
+
* const { signal } = controller;
|
1379 |
+
* const child = fork(__filename, ['child'], { signal });
|
1380 |
+
* child.on('error', (err) => {
|
1381 |
+
* // This will be called with err being an AbortError if the controller aborts
|
1382 |
+
* });
|
1383 |
+
* controller.abort(); // Stops the child process
|
1384 |
+
* }
|
1385 |
+
* ```
|
1386 |
+
* @since v0.5.0
|
1387 |
+
* @param modulePath The module to run in the child.
|
1388 |
+
* @param args List of string arguments.
|
1389 |
+
*/
|
1390 |
+
function fork(modulePath: string, options?: ForkOptions): ChildProcess;
|
1391 |
+
function fork(modulePath: string, args?: readonly string[], options?: ForkOptions): ChildProcess;
|
1392 |
+
interface SpawnSyncOptions extends CommonSpawnOptions {
|
1393 |
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1394 |
+
maxBuffer?: number | undefined;
|
1395 |
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
1396 |
+
}
|
1397 |
+
interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
|
1398 |
+
encoding: BufferEncoding;
|
1399 |
+
}
|
1400 |
+
interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
|
1401 |
+
encoding?: "buffer" | null | undefined;
|
1402 |
+
}
|
1403 |
+
interface SpawnSyncReturns<T> {
|
1404 |
+
pid: number;
|
1405 |
+
output: Array<T | null>;
|
1406 |
+
stdout: T;
|
1407 |
+
stderr: T;
|
1408 |
+
status: number | null;
|
1409 |
+
signal: NodeJS.Signals | null;
|
1410 |
+
error?: Error | undefined;
|
1411 |
+
}
|
1412 |
+
/**
|
1413 |
+
* The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
|
1414 |
+
* until the child process has fully closed. When a timeout has been encountered
|
1415 |
+
* and `killSignal` is sent, the method won't return until the process has
|
1416 |
+
* completely exited. If the process intercepts and handles the `SIGTERM` signal
|
1417 |
+
* and doesn't exit, the parent process will wait until the child process has
|
1418 |
+
* exited.
|
1419 |
+
*
|
1420 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1421 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1422 |
+
* **arbitrary command execution.**
|
1423 |
+
* @since v0.11.12
|
1424 |
+
* @param command The command to run.
|
1425 |
+
* @param args List of string arguments.
|
1426 |
+
*/
|
1427 |
+
function spawnSync(command: string): SpawnSyncReturns<Buffer>;
|
1428 |
+
function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
1429 |
+
function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
|
1430 |
+
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
1431 |
+
function spawnSync(command: string, args: readonly string[]): SpawnSyncReturns<Buffer>;
|
1432 |
+
function spawnSync(
|
1433 |
+
command: string,
|
1434 |
+
args: readonly string[],
|
1435 |
+
options: SpawnSyncOptionsWithStringEncoding,
|
1436 |
+
): SpawnSyncReturns<string>;
|
1437 |
+
function spawnSync(
|
1438 |
+
command: string,
|
1439 |
+
args: readonly string[],
|
1440 |
+
options: SpawnSyncOptionsWithBufferEncoding,
|
1441 |
+
): SpawnSyncReturns<Buffer>;
|
1442 |
+
function spawnSync(
|
1443 |
+
command: string,
|
1444 |
+
args?: readonly string[],
|
1445 |
+
options?: SpawnSyncOptions,
|
1446 |
+
): SpawnSyncReturns<string | Buffer>;
|
1447 |
+
interface CommonExecOptions extends CommonOptions {
|
1448 |
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1449 |
+
/**
|
1450 |
+
* Can be set to 'pipe', 'inherit, or 'ignore', or an array of these strings.
|
1451 |
+
* If passed as an array, the first element is used for `stdin`, the second for
|
1452 |
+
* `stdout`, and the third for `stderr`. A fourth element can be used to
|
1453 |
+
* specify the `stdio` behavior beyond the standard streams. See
|
1454 |
+
* {@link ChildProcess.stdio} for more information.
|
1455 |
+
*
|
1456 |
+
* @default 'pipe'
|
1457 |
+
*/
|
1458 |
+
stdio?: StdioOptions | undefined;
|
1459 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
1460 |
+
maxBuffer?: number | undefined;
|
1461 |
+
encoding?: BufferEncoding | "buffer" | null | undefined;
|
1462 |
+
}
|
1463 |
+
interface ExecSyncOptions extends CommonExecOptions {
|
1464 |
+
shell?: string | undefined;
|
1465 |
+
}
|
1466 |
+
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
|
1467 |
+
encoding: BufferEncoding;
|
1468 |
+
}
|
1469 |
+
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
|
1470 |
+
encoding?: "buffer" | null | undefined;
|
1471 |
+
}
|
1472 |
+
/**
|
1473 |
+
* The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
|
1474 |
+
* until the child process has fully closed. When a timeout has been encountered
|
1475 |
+
* and `killSignal` is sent, the method won't return until the process has
|
1476 |
+
* completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process
|
1477 |
+
* has exited.
|
1478 |
+
*
|
1479 |
+
* If the process times out or has a non-zero exit code, this method will throw.
|
1480 |
+
* The `Error` object will contain the entire result from {@link spawnSync}.
|
1481 |
+
*
|
1482 |
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
1483 |
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
1484 |
+
* @since v0.11.12
|
1485 |
+
* @param command The command to run.
|
1486 |
+
* @return The stdout from the command.
|
1487 |
+
*/
|
1488 |
+
function execSync(command: string): Buffer;
|
1489 |
+
function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
|
1490 |
+
function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
|
1491 |
+
function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
|
1492 |
+
interface ExecFileSyncOptions extends CommonExecOptions {
|
1493 |
+
shell?: boolean | string | undefined;
|
1494 |
+
}
|
1495 |
+
interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
|
1496 |
+
encoding: BufferEncoding;
|
1497 |
+
}
|
1498 |
+
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
|
1499 |
+
encoding?: "buffer" | null; // specify `null`.
|
1500 |
+
}
|
1501 |
+
/**
|
1502 |
+
* The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
|
1503 |
+
* return until the child process has fully closed. When a timeout has been
|
1504 |
+
* encountered and `killSignal` is sent, the method won't return until the process
|
1505 |
+
* has completely exited.
|
1506 |
+
*
|
1507 |
+
* If the child process intercepts and handles the `SIGTERM` signal and
|
1508 |
+
* does not exit, the parent process will still wait until the child process has
|
1509 |
+
* exited.
|
1510 |
+
*
|
1511 |
+
* If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}.
|
1512 |
+
*
|
1513 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1514 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1515 |
+
* **arbitrary command execution.**
|
1516 |
+
* @since v0.11.12
|
1517 |
+
* @param file The name or path of the executable file to run.
|
1518 |
+
* @param args List of string arguments.
|
1519 |
+
* @return The stdout from the command.
|
1520 |
+
*/
|
1521 |
+
function execFileSync(file: string): Buffer;
|
1522 |
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
|
1523 |
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
1524 |
+
function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
|
1525 |
+
function execFileSync(file: string, args: readonly string[]): Buffer;
|
1526 |
+
function execFileSync(
|
1527 |
+
file: string,
|
1528 |
+
args: readonly string[],
|
1529 |
+
options: ExecFileSyncOptionsWithStringEncoding,
|
1530 |
+
): string;
|
1531 |
+
function execFileSync(
|
1532 |
+
file: string,
|
1533 |
+
args: readonly string[],
|
1534 |
+
options: ExecFileSyncOptionsWithBufferEncoding,
|
1535 |
+
): Buffer;
|
1536 |
+
function execFileSync(file: string, args?: readonly string[], options?: ExecFileSyncOptions): string | Buffer;
|
1537 |
+
}
|
1538 |
+
declare module "node:child_process" {
|
1539 |
+
export * from "child_process";
|
1540 |
+
}
|
node_modules/@types/node/cluster.d.ts
ADDED
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
3 |
+
* that can distribute workloads among their application threads. When process
|
4 |
+
* isolation is not needed, use the `worker_threads` module instead, which
|
5 |
+
* allows running multiple application threads within a single Node.js instance.
|
6 |
+
*
|
7 |
+
* The cluster module allows easy creation of child processes that all share
|
8 |
+
* server ports.
|
9 |
+
*
|
10 |
+
* ```js
|
11 |
+
* import cluster from 'node:cluster';
|
12 |
+
* import http from 'node:http';
|
13 |
+
* import { availableParallelism } from 'node:os';
|
14 |
+
* import process from 'node:process';
|
15 |
+
*
|
16 |
+
* const numCPUs = availableParallelism();
|
17 |
+
*
|
18 |
+
* if (cluster.isPrimary) {
|
19 |
+
* console.log(`Primary ${process.pid} is running`);
|
20 |
+
*
|
21 |
+
* // Fork workers.
|
22 |
+
* for (let i = 0; i < numCPUs; i++) {
|
23 |
+
* cluster.fork();
|
24 |
+
* }
|
25 |
+
*
|
26 |
+
* cluster.on('exit', (worker, code, signal) => {
|
27 |
+
* console.log(`worker ${worker.process.pid} died`);
|
28 |
+
* });
|
29 |
+
* } else {
|
30 |
+
* // Workers can share any TCP connection
|
31 |
+
* // In this case it is an HTTP server
|
32 |
+
* http.createServer((req, res) => {
|
33 |
+
* res.writeHead(200);
|
34 |
+
* res.end('hello world\n');
|
35 |
+
* }).listen(8000);
|
36 |
+
*
|
37 |
+
* console.log(`Worker ${process.pid} started`);
|
38 |
+
* }
|
39 |
+
* ```
|
40 |
+
*
|
41 |
+
* Running Node.js will now share port 8000 between the workers:
|
42 |
+
*
|
43 |
+
* ```console
|
44 |
+
* $ node server.js
|
45 |
+
* Primary 3596 is running
|
46 |
+
* Worker 4324 started
|
47 |
+
* Worker 4520 started
|
48 |
+
* Worker 6056 started
|
49 |
+
* Worker 5644 started
|
50 |
+
* ```
|
51 |
+
*
|
52 |
+
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
53 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/cluster.js)
|
54 |
+
*/
|
55 |
+
declare module "cluster" {
|
56 |
+
import * as child from "node:child_process";
|
57 |
+
import EventEmitter = require("node:events");
|
58 |
+
import * as net from "node:net";
|
59 |
+
type SerializationType = "json" | "advanced";
|
60 |
+
export interface ClusterSettings {
|
61 |
+
execArgv?: string[] | undefined; // default: process.execArgv
|
62 |
+
exec?: string | undefined;
|
63 |
+
args?: string[] | undefined;
|
64 |
+
silent?: boolean | undefined;
|
65 |
+
stdio?: any[] | undefined;
|
66 |
+
uid?: number | undefined;
|
67 |
+
gid?: number | undefined;
|
68 |
+
inspectPort?: number | (() => number) | undefined;
|
69 |
+
serialization?: SerializationType | undefined;
|
70 |
+
cwd?: string | undefined;
|
71 |
+
windowsHide?: boolean | undefined;
|
72 |
+
}
|
73 |
+
export interface Address {
|
74 |
+
address: string;
|
75 |
+
port: number;
|
76 |
+
addressType: number | "udp4" | "udp6"; // 4, 6, -1, "udp4", "udp6"
|
77 |
+
}
|
78 |
+
/**
|
79 |
+
* A `Worker` object contains all public information and method about a worker.
|
80 |
+
* In the primary it can be obtained using `cluster.workers`. In a worker
|
81 |
+
* it can be obtained using `cluster.worker`.
|
82 |
+
* @since v0.7.0
|
83 |
+
*/
|
84 |
+
export class Worker extends EventEmitter {
|
85 |
+
/**
|
86 |
+
* Each new worker is given its own unique id, this id is stored in the`id`.
|
87 |
+
*
|
88 |
+
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
89 |
+
* @since v0.8.0
|
90 |
+
*/
|
91 |
+
id: number;
|
92 |
+
/**
|
93 |
+
* All workers are created using `child_process.fork()`, the returned object
|
94 |
+
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
95 |
+
*
|
96 |
+
* See: `Child Process module`.
|
97 |
+
*
|
98 |
+
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
99 |
+
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
100 |
+
* accidental disconnection.
|
101 |
+
* @since v0.7.0
|
102 |
+
*/
|
103 |
+
process: child.ChildProcess;
|
104 |
+
/**
|
105 |
+
* Send a message to a worker or primary, optionally with a handle.
|
106 |
+
*
|
107 |
+
* In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
|
108 |
+
*
|
109 |
+
* In a worker, this sends a message to the primary. It is identical to`process.send()`.
|
110 |
+
*
|
111 |
+
* This example will echo back all messages from the primary:
|
112 |
+
*
|
113 |
+
* ```js
|
114 |
+
* if (cluster.isPrimary) {
|
115 |
+
* const worker = cluster.fork();
|
116 |
+
* worker.send('hi there');
|
117 |
+
*
|
118 |
+
* } else if (cluster.isWorker) {
|
119 |
+
* process.on('message', (msg) => {
|
120 |
+
* process.send(msg);
|
121 |
+
* });
|
122 |
+
* }
|
123 |
+
* ```
|
124 |
+
* @since v0.7.0
|
125 |
+
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
126 |
+
*/
|
127 |
+
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
128 |
+
send(
|
129 |
+
message: child.Serializable,
|
130 |
+
sendHandle: child.SendHandle,
|
131 |
+
callback?: (error: Error | null) => void,
|
132 |
+
): boolean;
|
133 |
+
send(
|
134 |
+
message: child.Serializable,
|
135 |
+
sendHandle: child.SendHandle,
|
136 |
+
options?: child.MessageOptions,
|
137 |
+
callback?: (error: Error | null) => void,
|
138 |
+
): boolean;
|
139 |
+
/**
|
140 |
+
* This function will kill the worker. In the primary worker, it does this by
|
141 |
+
* disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
|
142 |
+
*
|
143 |
+
* The `kill()` function kills the worker process without waiting for a graceful
|
144 |
+
* disconnect, it has the same behavior as `worker.process.kill()`.
|
145 |
+
*
|
146 |
+
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
147 |
+
*
|
148 |
+
* In a worker, `process.kill()` exists, but it is not this function;
|
149 |
+
* it is `kill()`.
|
150 |
+
* @since v0.9.12
|
151 |
+
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
152 |
+
*/
|
153 |
+
kill(signal?: string): void;
|
154 |
+
destroy(signal?: string): void;
|
155 |
+
/**
|
156 |
+
* In a worker, this function will close all servers, wait for the `'close'` event
|
157 |
+
* on those servers, and then disconnect the IPC channel.
|
158 |
+
*
|
159 |
+
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
160 |
+
*
|
161 |
+
* Causes `.exitedAfterDisconnect` to be set.
|
162 |
+
*
|
163 |
+
* After a server is closed, it will no longer accept new connections,
|
164 |
+
* but connections may be accepted by any other listening worker. Existing
|
165 |
+
* connections will be allowed to close as usual. When no more connections exist,
|
166 |
+
* see `server.close()`, the IPC channel to the worker will close allowing it
|
167 |
+
* to die gracefully.
|
168 |
+
*
|
169 |
+
* The above applies _only_ to server connections, client connections are not
|
170 |
+
* automatically closed by workers, and disconnect does not wait for them to close
|
171 |
+
* before exiting.
|
172 |
+
*
|
173 |
+
* In a worker, `process.disconnect` exists, but it is not this function;
|
174 |
+
* it is `disconnect()`.
|
175 |
+
*
|
176 |
+
* Because long living server connections may block workers from disconnecting, it
|
177 |
+
* may be useful to send a message, so application specific actions may be taken to
|
178 |
+
* close them. It also may be useful to implement a timeout, killing a worker if
|
179 |
+
* the `'disconnect'` event has not been emitted after some time.
|
180 |
+
*
|
181 |
+
* ```js
|
182 |
+
* if (cluster.isPrimary) {
|
183 |
+
* const worker = cluster.fork();
|
184 |
+
* let timeout;
|
185 |
+
*
|
186 |
+
* worker.on('listening', (address) => {
|
187 |
+
* worker.send('shutdown');
|
188 |
+
* worker.disconnect();
|
189 |
+
* timeout = setTimeout(() => {
|
190 |
+
* worker.kill();
|
191 |
+
* }, 2000);
|
192 |
+
* });
|
193 |
+
*
|
194 |
+
* worker.on('disconnect', () => {
|
195 |
+
* clearTimeout(timeout);
|
196 |
+
* });
|
197 |
+
*
|
198 |
+
* } else if (cluster.isWorker) {
|
199 |
+
* const net = require('node:net');
|
200 |
+
* const server = net.createServer((socket) => {
|
201 |
+
* // Connections never end
|
202 |
+
* });
|
203 |
+
*
|
204 |
+
* server.listen(8000);
|
205 |
+
*
|
206 |
+
* process.on('message', (msg) => {
|
207 |
+
* if (msg === 'shutdown') {
|
208 |
+
* // Initiate graceful close of any connections to server
|
209 |
+
* }
|
210 |
+
* });
|
211 |
+
* }
|
212 |
+
* ```
|
213 |
+
* @since v0.7.7
|
214 |
+
* @return A reference to `worker`.
|
215 |
+
*/
|
216 |
+
disconnect(): void;
|
217 |
+
/**
|
218 |
+
* This function returns `true` if the worker is connected to its primary via its
|
219 |
+
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
220 |
+
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
221 |
+
* @since v0.11.14
|
222 |
+
*/
|
223 |
+
isConnected(): boolean;
|
224 |
+
/**
|
225 |
+
* This function returns `true` if the worker's process has terminated (either
|
226 |
+
* because of exiting or being signaled). Otherwise, it returns `false`.
|
227 |
+
*
|
228 |
+
* ```js
|
229 |
+
* import cluster from 'node:cluster';
|
230 |
+
* import http from 'node:http';
|
231 |
+
* import { availableParallelism } from 'node:os';
|
232 |
+
* import process from 'node:process';
|
233 |
+
*
|
234 |
+
* const numCPUs = availableParallelism();
|
235 |
+
*
|
236 |
+
* if (cluster.isPrimary) {
|
237 |
+
* console.log(`Primary ${process.pid} is running`);
|
238 |
+
*
|
239 |
+
* // Fork workers.
|
240 |
+
* for (let i = 0; i < numCPUs; i++) {
|
241 |
+
* cluster.fork();
|
242 |
+
* }
|
243 |
+
*
|
244 |
+
* cluster.on('fork', (worker) => {
|
245 |
+
* console.log('worker is dead:', worker.isDead());
|
246 |
+
* });
|
247 |
+
*
|
248 |
+
* cluster.on('exit', (worker, code, signal) => {
|
249 |
+
* console.log('worker is dead:', worker.isDead());
|
250 |
+
* });
|
251 |
+
* } else {
|
252 |
+
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
253 |
+
* http.createServer((req, res) => {
|
254 |
+
* res.writeHead(200);
|
255 |
+
* res.end(`Current process\n ${process.pid}`);
|
256 |
+
* process.kill(process.pid);
|
257 |
+
* }).listen(8000);
|
258 |
+
* }
|
259 |
+
* ```
|
260 |
+
* @since v0.11.14
|
261 |
+
*/
|
262 |
+
isDead(): boolean;
|
263 |
+
/**
|
264 |
+
* This property is `true` if the worker exited due to `.disconnect()`.
|
265 |
+
* If the worker exited any other way, it is `false`. If the
|
266 |
+
* worker has not exited, it is `undefined`.
|
267 |
+
*
|
268 |
+
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
269 |
+
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
270 |
+
* based on this value.
|
271 |
+
*
|
272 |
+
* ```js
|
273 |
+
* cluster.on('exit', (worker, code, signal) => {
|
274 |
+
* if (worker.exitedAfterDisconnect === true) {
|
275 |
+
* console.log('Oh, it was just voluntary – no need to worry');
|
276 |
+
* }
|
277 |
+
* });
|
278 |
+
*
|
279 |
+
* // kill worker
|
280 |
+
* worker.kill();
|
281 |
+
* ```
|
282 |
+
* @since v6.0.0
|
283 |
+
*/
|
284 |
+
exitedAfterDisconnect: boolean;
|
285 |
+
/**
|
286 |
+
* events.EventEmitter
|
287 |
+
* 1. disconnect
|
288 |
+
* 2. error
|
289 |
+
* 3. exit
|
290 |
+
* 4. listening
|
291 |
+
* 5. message
|
292 |
+
* 6. online
|
293 |
+
*/
|
294 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
295 |
+
addListener(event: "disconnect", listener: () => void): this;
|
296 |
+
addListener(event: "error", listener: (error: Error) => void): this;
|
297 |
+
addListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
298 |
+
addListener(event: "listening", listener: (address: Address) => void): this;
|
299 |
+
addListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
300 |
+
addListener(event: "online", listener: () => void): this;
|
301 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
302 |
+
emit(event: "disconnect"): boolean;
|
303 |
+
emit(event: "error", error: Error): boolean;
|
304 |
+
emit(event: "exit", code: number, signal: string): boolean;
|
305 |
+
emit(event: "listening", address: Address): boolean;
|
306 |
+
emit(event: "message", message: any, handle: net.Socket | net.Server): boolean;
|
307 |
+
emit(event: "online"): boolean;
|
308 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
309 |
+
on(event: "disconnect", listener: () => void): this;
|
310 |
+
on(event: "error", listener: (error: Error) => void): this;
|
311 |
+
on(event: "exit", listener: (code: number, signal: string) => void): this;
|
312 |
+
on(event: "listening", listener: (address: Address) => void): this;
|
313 |
+
on(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
314 |
+
on(event: "online", listener: () => void): this;
|
315 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
316 |
+
once(event: "disconnect", listener: () => void): this;
|
317 |
+
once(event: "error", listener: (error: Error) => void): this;
|
318 |
+
once(event: "exit", listener: (code: number, signal: string) => void): this;
|
319 |
+
once(event: "listening", listener: (address: Address) => void): this;
|
320 |
+
once(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
321 |
+
once(event: "online", listener: () => void): this;
|
322 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
323 |
+
prependListener(event: "disconnect", listener: () => void): this;
|
324 |
+
prependListener(event: "error", listener: (error: Error) => void): this;
|
325 |
+
prependListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
326 |
+
prependListener(event: "listening", listener: (address: Address) => void): this;
|
327 |
+
prependListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
328 |
+
prependListener(event: "online", listener: () => void): this;
|
329 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
330 |
+
prependOnceListener(event: "disconnect", listener: () => void): this;
|
331 |
+
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
332 |
+
prependOnceListener(event: "exit", listener: (code: number, signal: string) => void): this;
|
333 |
+
prependOnceListener(event: "listening", listener: (address: Address) => void): this;
|
334 |
+
prependOnceListener(event: "message", listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
335 |
+
prependOnceListener(event: "online", listener: () => void): this;
|
336 |
+
}
|
337 |
+
export interface Cluster extends EventEmitter {
|
338 |
+
disconnect(callback?: () => void): void;
|
339 |
+
fork(env?: any): Worker;
|
340 |
+
/** @deprecated since v16.0.0 - use isPrimary. */
|
341 |
+
readonly isMaster: boolean;
|
342 |
+
readonly isPrimary: boolean;
|
343 |
+
readonly isWorker: boolean;
|
344 |
+
schedulingPolicy: number;
|
345 |
+
readonly settings: ClusterSettings;
|
346 |
+
/** @deprecated since v16.0.0 - use setupPrimary. */
|
347 |
+
setupMaster(settings?: ClusterSettings): void;
|
348 |
+
/**
|
349 |
+
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
350 |
+
*/
|
351 |
+
setupPrimary(settings?: ClusterSettings): void;
|
352 |
+
readonly worker?: Worker | undefined;
|
353 |
+
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
354 |
+
readonly SCHED_NONE: number;
|
355 |
+
readonly SCHED_RR: number;
|
356 |
+
/**
|
357 |
+
* events.EventEmitter
|
358 |
+
* 1. disconnect
|
359 |
+
* 2. exit
|
360 |
+
* 3. fork
|
361 |
+
* 4. listening
|
362 |
+
* 5. message
|
363 |
+
* 6. online
|
364 |
+
* 7. setup
|
365 |
+
*/
|
366 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
367 |
+
addListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
368 |
+
addListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
369 |
+
addListener(event: "fork", listener: (worker: Worker) => void): this;
|
370 |
+
addListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
371 |
+
addListener(
|
372 |
+
event: "message",
|
373 |
+
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
374 |
+
): this; // the handle is a net.Socket or net.Server object, or undefined.
|
375 |
+
addListener(event: "online", listener: (worker: Worker) => void): this;
|
376 |
+
addListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
377 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
378 |
+
emit(event: "disconnect", worker: Worker): boolean;
|
379 |
+
emit(event: "exit", worker: Worker, code: number, signal: string): boolean;
|
380 |
+
emit(event: "fork", worker: Worker): boolean;
|
381 |
+
emit(event: "listening", worker: Worker, address: Address): boolean;
|
382 |
+
emit(event: "message", worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
383 |
+
emit(event: "online", worker: Worker): boolean;
|
384 |
+
emit(event: "setup", settings: ClusterSettings): boolean;
|
385 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
386 |
+
on(event: "disconnect", listener: (worker: Worker) => void): this;
|
387 |
+
on(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
388 |
+
on(event: "fork", listener: (worker: Worker) => void): this;
|
389 |
+
on(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
390 |
+
on(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
391 |
+
on(event: "online", listener: (worker: Worker) => void): this;
|
392 |
+
on(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
393 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
394 |
+
once(event: "disconnect", listener: (worker: Worker) => void): this;
|
395 |
+
once(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
396 |
+
once(event: "fork", listener: (worker: Worker) => void): this;
|
397 |
+
once(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
398 |
+
once(event: "message", listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
399 |
+
once(event: "online", listener: (worker: Worker) => void): this;
|
400 |
+
once(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
401 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
402 |
+
prependListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
403 |
+
prependListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
404 |
+
prependListener(event: "fork", listener: (worker: Worker) => void): this;
|
405 |
+
prependListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
406 |
+
// the handle is a net.Socket or net.Server object, or undefined.
|
407 |
+
prependListener(
|
408 |
+
event: "message",
|
409 |
+
listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void,
|
410 |
+
): this;
|
411 |
+
prependListener(event: "online", listener: (worker: Worker) => void): this;
|
412 |
+
prependListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
413 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
414 |
+
prependOnceListener(event: "disconnect", listener: (worker: Worker) => void): this;
|
415 |
+
prependOnceListener(event: "exit", listener: (worker: Worker, code: number, signal: string) => void): this;
|
416 |
+
prependOnceListener(event: "fork", listener: (worker: Worker) => void): this;
|
417 |
+
prependOnceListener(event: "listening", listener: (worker: Worker, address: Address) => void): this;
|
418 |
+
// the handle is a net.Socket or net.Server object, or undefined.
|
419 |
+
prependOnceListener(
|
420 |
+
event: "message",
|
421 |
+
listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void,
|
422 |
+
): this;
|
423 |
+
prependOnceListener(event: "online", listener: (worker: Worker) => void): this;
|
424 |
+
prependOnceListener(event: "setup", listener: (settings: ClusterSettings) => void): this;
|
425 |
+
}
|
426 |
+
const cluster: Cluster;
|
427 |
+
export default cluster;
|
428 |
+
}
|
429 |
+
declare module "node:cluster" {
|
430 |
+
export * from "cluster";
|
431 |
+
export { default as default } from "cluster";
|
432 |
+
}
|
node_modules/@types/node/console.d.ts
ADDED
@@ -0,0 +1,415 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:console` module provides a simple debugging console that is similar to
|
3 |
+
* the JavaScript console mechanism provided by web browsers.
|
4 |
+
*
|
5 |
+
* The module exports two specific components:
|
6 |
+
*
|
7 |
+
* * A `Console` class with methods such as `console.log()`, `console.error()`, and`console.warn()` that can be used to write to any Node.js stream.
|
8 |
+
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('node:console')`.
|
9 |
+
*
|
10 |
+
* _**Warning**_: The global console object's methods are neither consistently
|
11 |
+
* synchronous like the browser APIs they resemble, nor are they consistently
|
12 |
+
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
13 |
+
* more information.
|
14 |
+
*
|
15 |
+
* Example using the global `console`:
|
16 |
+
*
|
17 |
+
* ```js
|
18 |
+
* console.log('hello world');
|
19 |
+
* // Prints: hello world, to stdout
|
20 |
+
* console.log('hello %s', 'world');
|
21 |
+
* // Prints: hello world, to stdout
|
22 |
+
* console.error(new Error('Whoops, something bad happened'));
|
23 |
+
* // Prints error message and stack trace to stderr:
|
24 |
+
* // Error: Whoops, something bad happened
|
25 |
+
* // at [eval]:5:15
|
26 |
+
* // at Script.runInThisContext (node:vm:132:18)
|
27 |
+
* // at Object.runInThisContext (node:vm:309:38)
|
28 |
+
* // at node:internal/process/execution:77:19
|
29 |
+
* // at [eval]-wrapper:6:22
|
30 |
+
* // at evalScript (node:internal/process/execution:76:60)
|
31 |
+
* // at node:internal/main/eval_string:23:3
|
32 |
+
*
|
33 |
+
* const name = 'Will Robinson';
|
34 |
+
* console.warn(`Danger ${name}! Danger!`);
|
35 |
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
36 |
+
* ```
|
37 |
+
*
|
38 |
+
* Example using the `Console` class:
|
39 |
+
*
|
40 |
+
* ```js
|
41 |
+
* const out = getStreamSomehow();
|
42 |
+
* const err = getStreamSomehow();
|
43 |
+
* const myConsole = new console.Console(out, err);
|
44 |
+
*
|
45 |
+
* myConsole.log('hello world');
|
46 |
+
* // Prints: hello world, to out
|
47 |
+
* myConsole.log('hello %s', 'world');
|
48 |
+
* // Prints: hello world, to out
|
49 |
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
50 |
+
* // Prints: [Error: Whoops, something bad happened], to err
|
51 |
+
*
|
52 |
+
* const name = 'Will Robinson';
|
53 |
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
54 |
+
* // Prints: Danger Will Robinson! Danger!, to err
|
55 |
+
* ```
|
56 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/console.js)
|
57 |
+
*/
|
58 |
+
declare module "console" {
|
59 |
+
import console = require("node:console");
|
60 |
+
export = console;
|
61 |
+
}
|
62 |
+
declare module "node:console" {
|
63 |
+
import { InspectOptions } from "node:util";
|
64 |
+
global {
|
65 |
+
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
66 |
+
interface Console {
|
67 |
+
Console: console.ConsoleConstructor;
|
68 |
+
/**
|
69 |
+
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
70 |
+
* writes a message and does not otherwise affect execution. The output always
|
71 |
+
* starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
|
72 |
+
*
|
73 |
+
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
74 |
+
*
|
75 |
+
* ```js
|
76 |
+
* console.assert(true, 'does nothing');
|
77 |
+
*
|
78 |
+
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
79 |
+
* // Assertion failed: Whoops didn't work
|
80 |
+
*
|
81 |
+
* console.assert();
|
82 |
+
* // Assertion failed
|
83 |
+
* ```
|
84 |
+
* @since v0.1.101
|
85 |
+
* @param value The value tested for being truthy.
|
86 |
+
* @param message All arguments besides `value` are used as error message.
|
87 |
+
*/
|
88 |
+
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
89 |
+
/**
|
90 |
+
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
91 |
+
* TTY. When `stdout` is not a TTY, this method does nothing.
|
92 |
+
*
|
93 |
+
* The specific operation of `console.clear()` can vary across operating systems
|
94 |
+
* and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
|
95 |
+
* current terminal viewport for the Node.js
|
96 |
+
* binary.
|
97 |
+
* @since v8.3.0
|
98 |
+
*/
|
99 |
+
clear(): void;
|
100 |
+
/**
|
101 |
+
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
102 |
+
* number of times `console.count()` has been called with the given `label`.
|
103 |
+
*
|
104 |
+
* ```js
|
105 |
+
* > console.count()
|
106 |
+
* default: 1
|
107 |
+
* undefined
|
108 |
+
* > console.count('default')
|
109 |
+
* default: 2
|
110 |
+
* undefined
|
111 |
+
* > console.count('abc')
|
112 |
+
* abc: 1
|
113 |
+
* undefined
|
114 |
+
* > console.count('xyz')
|
115 |
+
* xyz: 1
|
116 |
+
* undefined
|
117 |
+
* > console.count('abc')
|
118 |
+
* abc: 2
|
119 |
+
* undefined
|
120 |
+
* > console.count()
|
121 |
+
* default: 3
|
122 |
+
* undefined
|
123 |
+
* >
|
124 |
+
* ```
|
125 |
+
* @since v8.3.0
|
126 |
+
* @param [label='default'] The display label for the counter.
|
127 |
+
*/
|
128 |
+
count(label?: string): void;
|
129 |
+
/**
|
130 |
+
* Resets the internal counter specific to `label`.
|
131 |
+
*
|
132 |
+
* ```js
|
133 |
+
* > console.count('abc');
|
134 |
+
* abc: 1
|
135 |
+
* undefined
|
136 |
+
* > console.countReset('abc');
|
137 |
+
* undefined
|
138 |
+
* > console.count('abc');
|
139 |
+
* abc: 1
|
140 |
+
* undefined
|
141 |
+
* >
|
142 |
+
* ```
|
143 |
+
* @since v8.3.0
|
144 |
+
* @param [label='default'] The display label for the counter.
|
145 |
+
*/
|
146 |
+
countReset(label?: string): void;
|
147 |
+
/**
|
148 |
+
* The `console.debug()` function is an alias for {@link log}.
|
149 |
+
* @since v8.0.0
|
150 |
+
*/
|
151 |
+
debug(message?: any, ...optionalParams: any[]): void;
|
152 |
+
/**
|
153 |
+
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
154 |
+
* This function bypasses any custom `inspect()` function defined on `obj`.
|
155 |
+
* @since v0.1.101
|
156 |
+
*/
|
157 |
+
dir(obj: any, options?: InspectOptions): void;
|
158 |
+
/**
|
159 |
+
* This method calls `console.log()` passing it the arguments received.
|
160 |
+
* This method does not produce any XML formatting.
|
161 |
+
* @since v8.0.0
|
162 |
+
*/
|
163 |
+
dirxml(...data: any[]): void;
|
164 |
+
/**
|
165 |
+
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
166 |
+
* first used as the primary message and all additional used as substitution
|
167 |
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
168 |
+
*
|
169 |
+
* ```js
|
170 |
+
* const code = 5;
|
171 |
+
* console.error('error #%d', code);
|
172 |
+
* // Prints: error #5, to stderr
|
173 |
+
* console.error('error', code);
|
174 |
+
* // Prints: error 5, to stderr
|
175 |
+
* ```
|
176 |
+
*
|
177 |
+
* If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
|
178 |
+
* values are concatenated. See `util.format()` for more information.
|
179 |
+
* @since v0.1.100
|
180 |
+
*/
|
181 |
+
error(message?: any, ...optionalParams: any[]): void;
|
182 |
+
/**
|
183 |
+
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
184 |
+
*
|
185 |
+
* If one or more `label`s are provided, those are printed first without the
|
186 |
+
* additional indentation.
|
187 |
+
* @since v8.5.0
|
188 |
+
*/
|
189 |
+
group(...label: any[]): void;
|
190 |
+
/**
|
191 |
+
* An alias for {@link group}.
|
192 |
+
* @since v8.5.0
|
193 |
+
*/
|
194 |
+
groupCollapsed(...label: any[]): void;
|
195 |
+
/**
|
196 |
+
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
197 |
+
* @since v8.5.0
|
198 |
+
*/
|
199 |
+
groupEnd(): void;
|
200 |
+
/**
|
201 |
+
* The `console.info()` function is an alias for {@link log}.
|
202 |
+
* @since v0.1.100
|
203 |
+
*/
|
204 |
+
info(message?: any, ...optionalParams: any[]): void;
|
205 |
+
/**
|
206 |
+
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
207 |
+
* first used as the primary message and all additional used as substitution
|
208 |
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
209 |
+
*
|
210 |
+
* ```js
|
211 |
+
* const count = 5;
|
212 |
+
* console.log('count: %d', count);
|
213 |
+
* // Prints: count: 5, to stdout
|
214 |
+
* console.log('count:', count);
|
215 |
+
* // Prints: count: 5, to stdout
|
216 |
+
* ```
|
217 |
+
*
|
218 |
+
* See `util.format()` for more information.
|
219 |
+
* @since v0.1.100
|
220 |
+
*/
|
221 |
+
log(message?: any, ...optionalParams: any[]): void;
|
222 |
+
/**
|
223 |
+
* Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
224 |
+
* logging the argument if it can't be parsed as tabular.
|
225 |
+
*
|
226 |
+
* ```js
|
227 |
+
* // These can't be parsed as tabular data
|
228 |
+
* console.table(Symbol());
|
229 |
+
* // Symbol()
|
230 |
+
*
|
231 |
+
* console.table(undefined);
|
232 |
+
* // undefined
|
233 |
+
*
|
234 |
+
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
235 |
+
* // ┌─────────┬─────┬───��─┐
|
236 |
+
* // │ (index) │ a │ b │
|
237 |
+
* // ├─────────┼─────┼─────┤
|
238 |
+
* // │ 0 │ 1 │ 'Y' │
|
239 |
+
* // │ 1 │ 'Z' │ 2 │
|
240 |
+
* // └─────────┴─────┴─────┘
|
241 |
+
*
|
242 |
+
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
243 |
+
* // ┌─────────┬─────┐
|
244 |
+
* // │ (index) │ a │
|
245 |
+
* // ├─────────┼─────┤
|
246 |
+
* // │ 0 │ 1 │
|
247 |
+
* // │ 1 │ 'Z' │
|
248 |
+
* // └─────────┴─────┘
|
249 |
+
* ```
|
250 |
+
* @since v10.0.0
|
251 |
+
* @param properties Alternate properties for constructing the table.
|
252 |
+
*/
|
253 |
+
table(tabularData: any, properties?: readonly string[]): void;
|
254 |
+
/**
|
255 |
+
* Starts a timer that can be used to compute the duration of an operation. Timers
|
256 |
+
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
257 |
+
* suitable time units to `stdout`. For example, if the elapsed
|
258 |
+
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
259 |
+
* @since v0.1.104
|
260 |
+
* @param [label='default']
|
261 |
+
*/
|
262 |
+
time(label?: string): void;
|
263 |
+
/**
|
264 |
+
* Stops a timer that was previously started by calling {@link time} and
|
265 |
+
* prints the result to `stdout`:
|
266 |
+
*
|
267 |
+
* ```js
|
268 |
+
* console.time('bunch-of-stuff');
|
269 |
+
* // Do a bunch of stuff.
|
270 |
+
* console.timeEnd('bunch-of-stuff');
|
271 |
+
* // Prints: bunch-of-stuff: 225.438ms
|
272 |
+
* ```
|
273 |
+
* @since v0.1.104
|
274 |
+
* @param [label='default']
|
275 |
+
*/
|
276 |
+
timeEnd(label?: string): void;
|
277 |
+
/**
|
278 |
+
* For a timer that was previously started by calling {@link time}, prints
|
279 |
+
* the elapsed time and other `data` arguments to `stdout`:
|
280 |
+
*
|
281 |
+
* ```js
|
282 |
+
* console.time('process');
|
283 |
+
* const value = expensiveProcess1(); // Returns 42
|
284 |
+
* console.timeLog('process', value);
|
285 |
+
* // Prints "process: 365.227ms 42".
|
286 |
+
* doExpensiveProcess2(value);
|
287 |
+
* console.timeEnd('process');
|
288 |
+
* ```
|
289 |
+
* @since v10.7.0
|
290 |
+
* @param [label='default']
|
291 |
+
*/
|
292 |
+
timeLog(label?: string, ...data: any[]): void;
|
293 |
+
/**
|
294 |
+
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
|
295 |
+
*
|
296 |
+
* ```js
|
297 |
+
* console.trace('Show me');
|
298 |
+
* // Prints: (stack trace will vary based on where trace is called)
|
299 |
+
* // Trace: Show me
|
300 |
+
* // at repl:2:9
|
301 |
+
* // at REPLServer.defaultEval (repl.js:248:27)
|
302 |
+
* // at bound (domain.js:287:14)
|
303 |
+
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
304 |
+
* // at REPLServer.<anonymous> (repl.js:412:12)
|
305 |
+
* // at emitOne (events.js:82:20)
|
306 |
+
* // at REPLServer.emit (events.js:169:7)
|
307 |
+
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
308 |
+
* // at REPLServer.Interface._line (readline.js:549:8)
|
309 |
+
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
310 |
+
* ```
|
311 |
+
* @since v0.1.104
|
312 |
+
*/
|
313 |
+
trace(message?: any, ...optionalParams: any[]): void;
|
314 |
+
/**
|
315 |
+
* The `console.warn()` function is an alias for {@link error}.
|
316 |
+
* @since v0.1.100
|
317 |
+
*/
|
318 |
+
warn(message?: any, ...optionalParams: any[]): void;
|
319 |
+
// --- Inspector mode only ---
|
320 |
+
/**
|
321 |
+
* This method does not display anything unless used in the inspector.
|
322 |
+
* Starts a JavaScript CPU profile with an optional label.
|
323 |
+
*/
|
324 |
+
profile(label?: string): void;
|
325 |
+
/**
|
326 |
+
* This method does not display anything unless used in the inspector.
|
327 |
+
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
328 |
+
*/
|
329 |
+
profileEnd(label?: string): void;
|
330 |
+
/**
|
331 |
+
* This method does not display anything unless used in the inspector.
|
332 |
+
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
333 |
+
*/
|
334 |
+
timeStamp(label?: string): void;
|
335 |
+
}
|
336 |
+
/**
|
337 |
+
* The `console` module provides a simple debugging console that is similar to the
|
338 |
+
* JavaScript console mechanism provided by web browsers.
|
339 |
+
*
|
340 |
+
* The module exports two specific components:
|
341 |
+
*
|
342 |
+
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
343 |
+
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
344 |
+
*
|
345 |
+
* _**Warning**_: The global console object's methods are neither consistently
|
346 |
+
* synchronous like the browser APIs they resemble, nor are they consistently
|
347 |
+
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
348 |
+
* more information.
|
349 |
+
*
|
350 |
+
* Example using the global `console`:
|
351 |
+
*
|
352 |
+
* ```js
|
353 |
+
* console.log('hello world');
|
354 |
+
* // Prints: hello world, to stdout
|
355 |
+
* console.log('hello %s', 'world');
|
356 |
+
* // Prints: hello world, to stdout
|
357 |
+
* console.error(new Error('Whoops, something bad happened'));
|
358 |
+
* // Prints error message and stack trace to stderr:
|
359 |
+
* // Error: Whoops, something bad happened
|
360 |
+
* // at [eval]:5:15
|
361 |
+
* // at Script.runInThisContext (node:vm:132:18)
|
362 |
+
* // at Object.runInThisContext (node:vm:309:38)
|
363 |
+
* // at node:internal/process/execution:77:19
|
364 |
+
* // at [eval]-wrapper:6:22
|
365 |
+
* // at evalScript (node:internal/process/execution:76:60)
|
366 |
+
* // at node:internal/main/eval_string:23:3
|
367 |
+
*
|
368 |
+
* const name = 'Will Robinson';
|
369 |
+
* console.warn(`Danger ${name}! Danger!`);
|
370 |
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
371 |
+
* ```
|
372 |
+
*
|
373 |
+
* Example using the `Console` class:
|
374 |
+
*
|
375 |
+
* ```js
|
376 |
+
* const out = getStreamSomehow();
|
377 |
+
* const err = getStreamSomehow();
|
378 |
+
* const myConsole = new console.Console(out, err);
|
379 |
+
*
|
380 |
+
* myConsole.log('hello world');
|
381 |
+
* // Prints: hello world, to out
|
382 |
+
* myConsole.log('hello %s', 'world');
|
383 |
+
* // Prints: hello world, to out
|
384 |
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
385 |
+
* // Prints: [Error: Whoops, something bad happened], to err
|
386 |
+
*
|
387 |
+
* const name = 'Will Robinson';
|
388 |
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
389 |
+
* // Prints: Danger Will Robinson! Danger!, to err
|
390 |
+
* ```
|
391 |
+
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
392 |
+
*/
|
393 |
+
namespace console {
|
394 |
+
interface ConsoleConstructorOptions {
|
395 |
+
stdout: NodeJS.WritableStream;
|
396 |
+
stderr?: NodeJS.WritableStream | undefined;
|
397 |
+
ignoreErrors?: boolean | undefined;
|
398 |
+
colorMode?: boolean | "auto" | undefined;
|
399 |
+
inspectOptions?: InspectOptions | undefined;
|
400 |
+
/**
|
401 |
+
* Set group indentation
|
402 |
+
* @default 2
|
403 |
+
*/
|
404 |
+
groupIndentation?: number | undefined;
|
405 |
+
}
|
406 |
+
interface ConsoleConstructor {
|
407 |
+
prototype: Console;
|
408 |
+
new(stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
409 |
+
new(options: ConsoleConstructorOptions): Console;
|
410 |
+
}
|
411 |
+
}
|
412 |
+
var console: Console;
|
413 |
+
}
|
414 |
+
export = globalThis.console;
|
415 |
+
}
|
node_modules/@types/node/constants.d.ts
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
2 |
+
declare module "constants" {
|
3 |
+
import { constants as osConstants, SignalConstants } from "node:os";
|
4 |
+
import { constants as cryptoConstants } from "node:crypto";
|
5 |
+
import { constants as fsConstants } from "node:fs";
|
6 |
+
|
7 |
+
const exp:
|
8 |
+
& typeof osConstants.errno
|
9 |
+
& typeof osConstants.priority
|
10 |
+
& SignalConstants
|
11 |
+
& typeof cryptoConstants
|
12 |
+
& typeof fsConstants;
|
13 |
+
export = exp;
|
14 |
+
}
|
15 |
+
|
16 |
+
declare module "node:constants" {
|
17 |
+
import constants = require("constants");
|
18 |
+
export = constants;
|
19 |
+
}
|
node_modules/@types/node/crypto.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
node_modules/@types/node/dgram.d.ts
ADDED
@@ -0,0 +1,586 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:dgram` module provides an implementation of UDP datagram sockets.
|
3 |
+
*
|
4 |
+
* ```js
|
5 |
+
* import dgram from 'node:dgram';
|
6 |
+
*
|
7 |
+
* const server = dgram.createSocket('udp4');
|
8 |
+
*
|
9 |
+
* server.on('error', (err) => {
|
10 |
+
* console.error(`server error:\n${err.stack}`);
|
11 |
+
* server.close();
|
12 |
+
* });
|
13 |
+
*
|
14 |
+
* server.on('message', (msg, rinfo) => {
|
15 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* server.on('listening', () => {
|
19 |
+
* const address = server.address();
|
20 |
+
* console.log(`server listening ${address.address}:${address.port}`);
|
21 |
+
* });
|
22 |
+
*
|
23 |
+
* server.bind(41234);
|
24 |
+
* // Prints: server listening 0.0.0.0:41234
|
25 |
+
* ```
|
26 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dgram.js)
|
27 |
+
*/
|
28 |
+
declare module "dgram" {
|
29 |
+
import { AddressInfo } from "node:net";
|
30 |
+
import * as dns from "node:dns";
|
31 |
+
import { Abortable, EventEmitter } from "node:events";
|
32 |
+
interface RemoteInfo {
|
33 |
+
address: string;
|
34 |
+
family: "IPv4" | "IPv6";
|
35 |
+
port: number;
|
36 |
+
size: number;
|
37 |
+
}
|
38 |
+
interface BindOptions {
|
39 |
+
port?: number | undefined;
|
40 |
+
address?: string | undefined;
|
41 |
+
exclusive?: boolean | undefined;
|
42 |
+
fd?: number | undefined;
|
43 |
+
}
|
44 |
+
type SocketType = "udp4" | "udp6";
|
45 |
+
interface SocketOptions extends Abortable {
|
46 |
+
type: SocketType;
|
47 |
+
reuseAddr?: boolean | undefined;
|
48 |
+
/**
|
49 |
+
* @default false
|
50 |
+
*/
|
51 |
+
ipv6Only?: boolean | undefined;
|
52 |
+
recvBufferSize?: number | undefined;
|
53 |
+
sendBufferSize?: number | undefined;
|
54 |
+
lookup?:
|
55 |
+
| ((
|
56 |
+
hostname: string,
|
57 |
+
options: dns.LookupOneOptions,
|
58 |
+
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
59 |
+
) => void)
|
60 |
+
| undefined;
|
61 |
+
}
|
62 |
+
/**
|
63 |
+
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
64 |
+
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
65 |
+
* method will bind the socket to the "all interfaces" address on a random port
|
66 |
+
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
67 |
+
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
68 |
+
*
|
69 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
|
70 |
+
*
|
71 |
+
* ```js
|
72 |
+
* const controller = new AbortController();
|
73 |
+
* const { signal } = controller;
|
74 |
+
* const server = dgram.createSocket({ type: 'udp4', signal });
|
75 |
+
* server.on('message', (msg, rinfo) => {
|
76 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
77 |
+
* });
|
78 |
+
* // Later, when you want to close the server.
|
79 |
+
* controller.abort();
|
80 |
+
* ```
|
81 |
+
* @since v0.11.13
|
82 |
+
* @param options Available options are:
|
83 |
+
* @param callback Attached as a listener for `'message'` events. Optional.
|
84 |
+
*/
|
85 |
+
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
86 |
+
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
87 |
+
/**
|
88 |
+
* Encapsulates the datagram functionality.
|
89 |
+
*
|
90 |
+
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
91 |
+
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
92 |
+
* @since v0.1.99
|
93 |
+
*/
|
94 |
+
class Socket extends EventEmitter {
|
95 |
+
/**
|
96 |
+
* Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
|
97 |
+
* specified, the operating system will choose
|
98 |
+
* one interface and will add membership to it. To add membership to every
|
99 |
+
* available interface, call `addMembership` multiple times, once per interface.
|
100 |
+
*
|
101 |
+
* When called on an unbound socket, this method will implicitly bind to a random
|
102 |
+
* port, listening on all interfaces.
|
103 |
+
*
|
104 |
+
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
105 |
+
*
|
106 |
+
* ```js
|
107 |
+
* import cluster from 'node:cluster';
|
108 |
+
* import dgram from 'node:dgram';
|
109 |
+
*
|
110 |
+
* if (cluster.isPrimary) {
|
111 |
+
* cluster.fork(); // Works ok.
|
112 |
+
* cluster.fork(); // Fails with EADDRINUSE.
|
113 |
+
* } else {
|
114 |
+
* const s = dgram.createSocket('udp4');
|
115 |
+
* s.bind(1234, () => {
|
116 |
+
* s.addMembership('224.0.0.114');
|
117 |
+
* });
|
118 |
+
* }
|
119 |
+
* ```
|
120 |
+
* @since v0.6.9
|
121 |
+
*/
|
122 |
+
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
123 |
+
/**
|
124 |
+
* Returns an object containing the address information for a socket.
|
125 |
+
* For UDP sockets, this object will contain `address`, `family`, and `port`properties.
|
126 |
+
*
|
127 |
+
* This method throws `EBADF` if called on an unbound socket.
|
128 |
+
* @since v0.1.99
|
129 |
+
*/
|
130 |
+
address(): AddressInfo;
|
131 |
+
/**
|
132 |
+
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
133 |
+
* messages on a named `port` and optional `address`. If `port` is not
|
134 |
+
* specified or is `0`, the operating system will attempt to bind to a
|
135 |
+
* random port. If `address` is not specified, the operating system will
|
136 |
+
* attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
|
137 |
+
* called.
|
138 |
+
*
|
139 |
+
* Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
|
140 |
+
* useful.
|
141 |
+
*
|
142 |
+
* A bound datagram socket keeps the Node.js process running to receive
|
143 |
+
* datagram messages.
|
144 |
+
*
|
145 |
+
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
146 |
+
* attempting to bind with a closed socket), an `Error` may be thrown.
|
147 |
+
*
|
148 |
+
* Example of a UDP server listening on port 41234:
|
149 |
+
*
|
150 |
+
* ```js
|
151 |
+
* import dgram from 'node:dgram';
|
152 |
+
*
|
153 |
+
* const server = dgram.createSocket('udp4');
|
154 |
+
*
|
155 |
+
* server.on('error', (err) => {
|
156 |
+
* console.error(`server error:\n${err.stack}`);
|
157 |
+
* server.close();
|
158 |
+
* });
|
159 |
+
*
|
160 |
+
* server.on('message', (msg, rinfo) => {
|
161 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
162 |
+
* });
|
163 |
+
*
|
164 |
+
* server.on('listening', () => {
|
165 |
+
* const address = server.address();
|
166 |
+
* console.log(`server listening ${address.address}:${address.port}`);
|
167 |
+
* });
|
168 |
+
*
|
169 |
+
* server.bind(41234);
|
170 |
+
* // Prints: server listening 0.0.0.0:41234
|
171 |
+
* ```
|
172 |
+
* @since v0.1.99
|
173 |
+
* @param callback with no parameters. Called when binding is complete.
|
174 |
+
*/
|
175 |
+
bind(port?: number, address?: string, callback?: () => void): this;
|
176 |
+
bind(port?: number, callback?: () => void): this;
|
177 |
+
bind(callback?: () => void): this;
|
178 |
+
bind(options: BindOptions, callback?: () => void): this;
|
179 |
+
/**
|
180 |
+
* Close the underlying socket and stop listening for data on it. If a callback is
|
181 |
+
* provided, it is added as a listener for the `'close'` event.
|
182 |
+
* @since v0.1.99
|
183 |
+
* @param callback Called when the socket has been closed.
|
184 |
+
*/
|
185 |
+
close(callback?: () => void): this;
|
186 |
+
/**
|
187 |
+
* Associates the `dgram.Socket` to a remote address and port. Every
|
188 |
+
* message sent by this handle is automatically sent to that destination. Also,
|
189 |
+
* the socket will only receive messages from that remote peer.
|
190 |
+
* Trying to call `connect()` on an already connected socket will result
|
191 |
+
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
192 |
+
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
193 |
+
* will be used by default. Once the connection is complete, a `'connect'` event
|
194 |
+
* is emitted and the optional `callback` function is called. In case of failure,
|
195 |
+
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
196 |
+
* @since v12.0.0
|
197 |
+
* @param callback Called when the connection is completed or on error.
|
198 |
+
*/
|
199 |
+
connect(port: number, address?: string, callback?: () => void): void;
|
200 |
+
connect(port: number, callback: () => void): void;
|
201 |
+
/**
|
202 |
+
* A synchronous function that disassociates a connected `dgram.Socket` from
|
203 |
+
* its remote address. Trying to call `disconnect()` on an unbound or already
|
204 |
+
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
205 |
+
* @since v12.0.0
|
206 |
+
*/
|
207 |
+
disconnect(): void;
|
208 |
+
/**
|
209 |
+
* Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
210 |
+
* kernel when the socket is closed or the process terminates, so most apps will
|
211 |
+
* never have reason to call this.
|
212 |
+
*
|
213 |
+
* If `multicastInterface` is not specified, the operating system will attempt to
|
214 |
+
* drop membership on all valid interfaces.
|
215 |
+
* @since v0.6.9
|
216 |
+
*/
|
217 |
+
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
218 |
+
/**
|
219 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
220 |
+
* @since v8.7.0
|
221 |
+
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
222 |
+
*/
|
223 |
+
getRecvBufferSize(): number;
|
224 |
+
/**
|
225 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
226 |
+
* @since v8.7.0
|
227 |
+
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
228 |
+
*/
|
229 |
+
getSendBufferSize(): number;
|
230 |
+
/**
|
231 |
+
* By default, binding a socket will cause it to block the Node.js process from
|
232 |
+
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
233 |
+
* to exclude the socket from the reference counting that keeps the Node.js
|
234 |
+
* process active. The `socket.ref()` method adds the socket back to the reference
|
235 |
+
* counting and restores the default behavior.
|
236 |
+
*
|
237 |
+
* Calling `socket.ref()` multiples times will have no additional effect.
|
238 |
+
*
|
239 |
+
* The `socket.ref()` method returns a reference to the socket so calls can be
|
240 |
+
* chained.
|
241 |
+
* @since v0.9.1
|
242 |
+
*/
|
243 |
+
ref(): this;
|
244 |
+
/**
|
245 |
+
* Returns an object containing the `address`, `family`, and `port` of the remote
|
246 |
+
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
247 |
+
* if the socket is not connected.
|
248 |
+
* @since v12.0.0
|
249 |
+
*/
|
250 |
+
remoteAddress(): AddressInfo;
|
251 |
+
/**
|
252 |
+
* Broadcasts a datagram on the socket.
|
253 |
+
* For connectionless sockets, the destination `port` and `address` must be
|
254 |
+
* specified. Connected sockets, on the other hand, will use their associated
|
255 |
+
* remote endpoint, so the `port` and `address` arguments must not be set.
|
256 |
+
*
|
257 |
+
* The `msg` argument contains the message to be sent.
|
258 |
+
* Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
|
259 |
+
* any `TypedArray` or a `DataView`,
|
260 |
+
* the `offset` and `length` specify the offset within the `Buffer` where the
|
261 |
+
* message begins and the number of bytes in the message, respectively.
|
262 |
+
* If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that
|
263 |
+
* contain multi-byte characters, `offset` and `length` will be calculated with
|
264 |
+
* respect to `byte length` and not the character position.
|
265 |
+
* If `msg` is an array, `offset` and `length` must not be specified.
|
266 |
+
*
|
267 |
+
* The `address` argument is a string. If the value of `address` is a host name,
|
268 |
+
* DNS will be used to resolve the address of the host. If `address` is not
|
269 |
+
* provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
270 |
+
*
|
271 |
+
* If the socket has not been previously bound with a call to `bind`, the socket
|
272 |
+
* is assigned a random port number and is bound to the "all interfaces" address
|
273 |
+
* (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
|
274 |
+
*
|
275 |
+
* An optional `callback` function may be specified to as a way of reporting
|
276 |
+
* DNS errors or for determining when it is safe to reuse the `buf` object.
|
277 |
+
* DNS lookups delay the time to send for at least one tick of the
|
278 |
+
* Node.js event loop.
|
279 |
+
*
|
280 |
+
* The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be
|
281 |
+
* passed as the first argument to the `callback`. If a `callback` is not given,
|
282 |
+
* the error is emitted as an `'error'` event on the `socket` object.
|
283 |
+
*
|
284 |
+
* Offset and length are optional but both _must_ be set if either are used.
|
285 |
+
* They are supported only when the first argument is a `Buffer`, a `TypedArray`,
|
286 |
+
* or a `DataView`.
|
287 |
+
*
|
288 |
+
* This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
|
289 |
+
*
|
290 |
+
* Example of sending a UDP packet to a port on `localhost`;
|
291 |
+
*
|
292 |
+
* ```js
|
293 |
+
* import dgram from 'node:dgram';
|
294 |
+
* import { Buffer } from 'node:buffer';
|
295 |
+
*
|
296 |
+
* const message = Buffer.from('Some bytes');
|
297 |
+
* const client = dgram.createSocket('udp4');
|
298 |
+
* client.send(message, 41234, 'localhost', (err) => {
|
299 |
+
* client.close();
|
300 |
+
* });
|
301 |
+
* ```
|
302 |
+
*
|
303 |
+
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
304 |
+
*
|
305 |
+
* ```js
|
306 |
+
* import dgram from 'node:dgram';
|
307 |
+
* import { Buffer } from 'node:buffer';
|
308 |
+
*
|
309 |
+
* const buf1 = Buffer.from('Some ');
|
310 |
+
* const buf2 = Buffer.from('bytes');
|
311 |
+
* const client = dgram.createSocket('udp4');
|
312 |
+
* client.send([buf1, buf2], 41234, (err) => {
|
313 |
+
* client.close();
|
314 |
+
* });
|
315 |
+
* ```
|
316 |
+
*
|
317 |
+
* Sending multiple buffers might be faster or slower depending on the
|
318 |
+
* application and operating system. Run benchmarks to
|
319 |
+
* determine the optimal strategy on a case-by-case basis. Generally speaking,
|
320 |
+
* however, sending multiple buffers is faster.
|
321 |
+
*
|
322 |
+
* Example of sending a UDP packet using a socket connected to a port on`localhost`:
|
323 |
+
*
|
324 |
+
* ```js
|
325 |
+
* import dgram from 'node:dgram';
|
326 |
+
* import { Buffer } from 'node:buffer';
|
327 |
+
*
|
328 |
+
* const message = Buffer.from('Some bytes');
|
329 |
+
* const client = dgram.createSocket('udp4');
|
330 |
+
* client.connect(41234, 'localhost', (err) => {
|
331 |
+
* client.send(message, (err) => {
|
332 |
+
* client.close();
|
333 |
+
* });
|
334 |
+
* });
|
335 |
+
* ```
|
336 |
+
* @since v0.1.99
|
337 |
+
* @param msg Message to be sent.
|
338 |
+
* @param offset Offset in the buffer where the message starts.
|
339 |
+
* @param length Number of bytes in the message.
|
340 |
+
* @param port Destination port.
|
341 |
+
* @param address Destination host name or IP address.
|
342 |
+
* @param callback Called when the message has been sent.
|
343 |
+
*/
|
344 |
+
send(
|
345 |
+
msg: string | Uint8Array | readonly any[],
|
346 |
+
port?: number,
|
347 |
+
address?: string,
|
348 |
+
callback?: (error: Error | null, bytes: number) => void,
|
349 |
+
): void;
|
350 |
+
send(
|
351 |
+
msg: string | Uint8Array | readonly any[],
|
352 |
+
port?: number,
|
353 |
+
callback?: (error: Error | null, bytes: number) => void,
|
354 |
+
): void;
|
355 |
+
send(
|
356 |
+
msg: string | Uint8Array | readonly any[],
|
357 |
+
callback?: (error: Error | null, bytes: number) => void,
|
358 |
+
): void;
|
359 |
+
send(
|
360 |
+
msg: string | Uint8Array,
|
361 |
+
offset: number,
|
362 |
+
length: number,
|
363 |
+
port?: number,
|
364 |
+
address?: string,
|
365 |
+
callback?: (error: Error | null, bytes: number) => void,
|
366 |
+
): void;
|
367 |
+
send(
|
368 |
+
msg: string | Uint8Array,
|
369 |
+
offset: number,
|
370 |
+
length: number,
|
371 |
+
port?: number,
|
372 |
+
callback?: (error: Error | null, bytes: number) => void,
|
373 |
+
): void;
|
374 |
+
send(
|
375 |
+
msg: string | Uint8Array,
|
376 |
+
offset: number,
|
377 |
+
length: number,
|
378 |
+
callback?: (error: Error | null, bytes: number) => void,
|
379 |
+
): void;
|
380 |
+
/**
|
381 |
+
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
382 |
+
* packets may be sent to a local interface's broadcast address.
|
383 |
+
*
|
384 |
+
* This method throws `EBADF` if called on an unbound socket.
|
385 |
+
* @since v0.6.9
|
386 |
+
*/
|
387 |
+
setBroadcast(flag: boolean): void;
|
388 |
+
/**
|
389 |
+
* _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
390 |
+
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
391 |
+
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
392 |
+
* _or interface number._
|
393 |
+
*
|
394 |
+
* Sets the default outgoing multicast interface of the socket to a chosen
|
395 |
+
* interface or back to system interface selection. The `multicastInterface` must
|
396 |
+
* be a valid string representation of an IP from the socket's family.
|
397 |
+
*
|
398 |
+
* For IPv4 sockets, this should be the IP configured for the desired physical
|
399 |
+
* interface. All packets sent to multicast on the socket will be sent on the
|
400 |
+
* interface determined by the most recent successful use of this call.
|
401 |
+
*
|
402 |
+
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
403 |
+
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
404 |
+
* also use explicit scope in addresses, so only packets sent to a multicast
|
405 |
+
* address without specifying an explicit scope are affected by the most recent
|
406 |
+
* successful use of this call.
|
407 |
+
*
|
408 |
+
* This method throws `EBADF` if called on an unbound socket.
|
409 |
+
*
|
410 |
+
* #### Example: IPv6 outgoing multicast interface
|
411 |
+
*
|
412 |
+
* On most systems, where scope format uses the interface name:
|
413 |
+
*
|
414 |
+
* ```js
|
415 |
+
* const socket = dgram.createSocket('udp6');
|
416 |
+
*
|
417 |
+
* socket.bind(1234, () => {
|
418 |
+
* socket.setMulticastInterface('::%eth1');
|
419 |
+
* });
|
420 |
+
* ```
|
421 |
+
*
|
422 |
+
* On Windows, where scope format uses an interface number:
|
423 |
+
*
|
424 |
+
* ```js
|
425 |
+
* const socket = dgram.createSocket('udp6');
|
426 |
+
*
|
427 |
+
* socket.bind(1234, () => {
|
428 |
+
* socket.setMulticastInterface('::%2');
|
429 |
+
* });
|
430 |
+
* ```
|
431 |
+
*
|
432 |
+
* #### Example: IPv4 outgoing multicast interface
|
433 |
+
*
|
434 |
+
* All systems use an IP of the host on the desired physical interface:
|
435 |
+
*
|
436 |
+
* ```js
|
437 |
+
* const socket = dgram.createSocket('udp4');
|
438 |
+
*
|
439 |
+
* socket.bind(1234, () => {
|
440 |
+
* socket.setMulticastInterface('10.0.0.2');
|
441 |
+
* });
|
442 |
+
* ```
|
443 |
+
* @since v8.6.0
|
444 |
+
*/
|
445 |
+
setMulticastInterface(multicastInterface: string): void;
|
446 |
+
/**
|
447 |
+
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
448 |
+
* multicast packets will also be received on the local interface.
|
449 |
+
*
|
450 |
+
* This method throws `EBADF` if called on an unbound socket.
|
451 |
+
* @since v0.3.8
|
452 |
+
*/
|
453 |
+
setMulticastLoopback(flag: boolean): boolean;
|
454 |
+
/**
|
455 |
+
* Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
456 |
+
* "Time to Live", in this context it specifies the number of IP hops that a
|
457 |
+
* packet is allowed to travel through, specifically for multicast traffic. Each
|
458 |
+
* router or gateway that forwards a packet decrements the TTL. If the TTL is
|
459 |
+
* decremented to 0 by a router, it will not be forwarded.
|
460 |
+
*
|
461 |
+
* The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
|
462 |
+
*
|
463 |
+
* This method throws `EBADF` if called on an unbound socket.
|
464 |
+
* @since v0.3.8
|
465 |
+
*/
|
466 |
+
setMulticastTTL(ttl: number): number;
|
467 |
+
/**
|
468 |
+
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
469 |
+
* in bytes.
|
470 |
+
*
|
471 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
472 |
+
* @since v8.7.0
|
473 |
+
*/
|
474 |
+
setRecvBufferSize(size: number): void;
|
475 |
+
/**
|
476 |
+
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
477 |
+
* in bytes.
|
478 |
+
*
|
479 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
480 |
+
* @since v8.7.0
|
481 |
+
*/
|
482 |
+
setSendBufferSize(size: number): void;
|
483 |
+
/**
|
484 |
+
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
485 |
+
* in this context it specifies the number of IP hops that a packet is allowed to
|
486 |
+
* travel through. Each router or gateway that forwards a packet decrements the
|
487 |
+
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
488 |
+
* Changing TTL values is typically done for network probes or when multicasting.
|
489 |
+
*
|
490 |
+
* The `ttl` argument may be between 1 and 255\. The default on most systems
|
491 |
+
* is 64.
|
492 |
+
*
|
493 |
+
* This method throws `EBADF` if called on an unbound socket.
|
494 |
+
* @since v0.1.101
|
495 |
+
*/
|
496 |
+
setTTL(ttl: number): number;
|
497 |
+
/**
|
498 |
+
* By default, binding a socket will cause it to block the Node.js process from
|
499 |
+
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
500 |
+
* to exclude the socket from the reference counting that keeps the Node.js
|
501 |
+
* process active, allowing the process to exit even if the socket is still
|
502 |
+
* listening.
|
503 |
+
*
|
504 |
+
* Calling `socket.unref()` multiple times will have no additional effect.
|
505 |
+
*
|
506 |
+
* The `socket.unref()` method returns a reference to the socket so calls can be
|
507 |
+
* chained.
|
508 |
+
* @since v0.9.1
|
509 |
+
*/
|
510 |
+
unref(): this;
|
511 |
+
/**
|
512 |
+
* Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
|
513 |
+
* option. If the `multicastInterface` argument
|
514 |
+
* is not specified, the operating system will choose one interface and will add
|
515 |
+
* membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
|
516 |
+
*
|
517 |
+
* When called on an unbound socket, this method will implicitly bind to a random
|
518 |
+
* port, listening on all interfaces.
|
519 |
+
* @since v13.1.0, v12.16.0
|
520 |
+
*/
|
521 |
+
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
522 |
+
/**
|
523 |
+
* Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
|
524 |
+
* automatically called by the kernel when the
|
525 |
+
* socket is closed or the process terminates, so most apps will never have
|
526 |
+
* reason to call this.
|
527 |
+
*
|
528 |
+
* If `multicastInterface` is not specified, the operating system will attempt to
|
529 |
+
* drop membership on all valid interfaces.
|
530 |
+
* @since v13.1.0, v12.16.0
|
531 |
+
*/
|
532 |
+
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
533 |
+
/**
|
534 |
+
* events.EventEmitter
|
535 |
+
* 1. close
|
536 |
+
* 2. connect
|
537 |
+
* 3. error
|
538 |
+
* 4. listening
|
539 |
+
* 5. message
|
540 |
+
*/
|
541 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
542 |
+
addListener(event: "close", listener: () => void): this;
|
543 |
+
addListener(event: "connect", listener: () => void): this;
|
544 |
+
addListener(event: "error", listener: (err: Error) => void): this;
|
545 |
+
addListener(event: "listening", listener: () => void): this;
|
546 |
+
addListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
547 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
548 |
+
emit(event: "close"): boolean;
|
549 |
+
emit(event: "connect"): boolean;
|
550 |
+
emit(event: "error", err: Error): boolean;
|
551 |
+
emit(event: "listening"): boolean;
|
552 |
+
emit(event: "message", msg: Buffer, rinfo: RemoteInfo): boolean;
|
553 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
554 |
+
on(event: "close", listener: () => void): this;
|
555 |
+
on(event: "connect", listener: () => void): this;
|
556 |
+
on(event: "error", listener: (err: Error) => void): this;
|
557 |
+
on(event: "listening", listener: () => void): this;
|
558 |
+
on(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
559 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
560 |
+
once(event: "close", listener: () => void): this;
|
561 |
+
once(event: "connect", listener: () => void): this;
|
562 |
+
once(event: "error", listener: (err: Error) => void): this;
|
563 |
+
once(event: "listening", listener: () => void): this;
|
564 |
+
once(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
565 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
566 |
+
prependListener(event: "close", listener: () => void): this;
|
567 |
+
prependListener(event: "connect", listener: () => void): this;
|
568 |
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
569 |
+
prependListener(event: "listening", listener: () => void): this;
|
570 |
+
prependListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
571 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
572 |
+
prependOnceListener(event: "close", listener: () => void): this;
|
573 |
+
prependOnceListener(event: "connect", listener: () => void): this;
|
574 |
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
575 |
+
prependOnceListener(event: "listening", listener: () => void): this;
|
576 |
+
prependOnceListener(event: "message", listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
577 |
+
/**
|
578 |
+
* Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
|
579 |
+
* @since v20.5.0
|
580 |
+
*/
|
581 |
+
[Symbol.asyncDispose](): Promise<void>;
|
582 |
+
}
|
583 |
+
}
|
584 |
+
declare module "node:dgram" {
|
585 |
+
export * from "dgram";
|
586 |
+
}
|
node_modules/@types/node/diagnostics_channel.d.ts
ADDED
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:diagnostics_channel` module provides an API to create named channels
|
3 |
+
* to report arbitrary message data for diagnostics purposes.
|
4 |
+
*
|
5 |
+
* It can be accessed using:
|
6 |
+
*
|
7 |
+
* ```js
|
8 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
9 |
+
* ```
|
10 |
+
*
|
11 |
+
* It is intended that a module writer wanting to report diagnostics messages
|
12 |
+
* will create one or many top-level channels to report messages through.
|
13 |
+
* Channels may also be acquired at runtime but it is not encouraged
|
14 |
+
* due to the additional overhead of doing so. Channels may be exported for
|
15 |
+
* convenience, but as long as the name is known it can be acquired anywhere.
|
16 |
+
*
|
17 |
+
* If you intend for your module to produce diagnostics data for others to
|
18 |
+
* consume it is recommended that you include documentation of what named
|
19 |
+
* channels are used along with the shape of the message data. Channel names
|
20 |
+
* should generally include the module name to avoid collisions with data from
|
21 |
+
* other modules.
|
22 |
+
* @since v15.1.0, v14.17.0
|
23 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/diagnostics_channel.js)
|
24 |
+
*/
|
25 |
+
declare module "diagnostics_channel" {
|
26 |
+
/**
|
27 |
+
* Check if there are active subscribers to the named channel. This is helpful if
|
28 |
+
* the message you want to send might be expensive to prepare.
|
29 |
+
*
|
30 |
+
* This API is optional but helpful when trying to publish messages from very
|
31 |
+
* performance-sensitive code.
|
32 |
+
*
|
33 |
+
* ```js
|
34 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
35 |
+
*
|
36 |
+
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
37 |
+
* // There are subscribers, prepare and publish message
|
38 |
+
* }
|
39 |
+
* ```
|
40 |
+
* @since v15.1.0, v14.17.0
|
41 |
+
* @param name The channel name
|
42 |
+
* @return If there are active subscribers
|
43 |
+
*/
|
44 |
+
function hasSubscribers(name: string | symbol): boolean;
|
45 |
+
/**
|
46 |
+
* This is the primary entry-point for anyone wanting to publish to a named
|
47 |
+
* channel. It produces a channel object which is optimized to reduce overhead at
|
48 |
+
* publish time as much as possible.
|
49 |
+
*
|
50 |
+
* ```js
|
51 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
52 |
+
*
|
53 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
54 |
+
* ```
|
55 |
+
* @since v15.1.0, v14.17.0
|
56 |
+
* @param name The channel name
|
57 |
+
* @return The named channel object
|
58 |
+
*/
|
59 |
+
function channel(name: string | symbol): Channel;
|
60 |
+
type ChannelListener = (message: unknown, name: string | symbol) => void;
|
61 |
+
/**
|
62 |
+
* Register a message handler to subscribe to this channel. This message handler
|
63 |
+
* will be run synchronously whenever a message is published to the channel. Any
|
64 |
+
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
65 |
+
*
|
66 |
+
* ```js
|
67 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
68 |
+
*
|
69 |
+
* diagnostics_channel.subscribe('my-channel', (message, name) => {
|
70 |
+
* // Received data
|
71 |
+
* });
|
72 |
+
* ```
|
73 |
+
* @since v18.7.0, v16.17.0
|
74 |
+
* @param name The channel name
|
75 |
+
* @param onMessage The handler to receive channel messages
|
76 |
+
*/
|
77 |
+
function subscribe(name: string | symbol, onMessage: ChannelListener): void;
|
78 |
+
/**
|
79 |
+
* Remove a message handler previously registered to this channel with {@link subscribe}.
|
80 |
+
*
|
81 |
+
* ```js
|
82 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
83 |
+
*
|
84 |
+
* function onMessage(message, name) {
|
85 |
+
* // Received data
|
86 |
+
* }
|
87 |
+
*
|
88 |
+
* diagnostics_channel.subscribe('my-channel', onMessage);
|
89 |
+
*
|
90 |
+
* diagnostics_channel.unsubscribe('my-channel', onMessage);
|
91 |
+
* ```
|
92 |
+
* @since v18.7.0, v16.17.0
|
93 |
+
* @param name The channel name
|
94 |
+
* @param onMessage The previous subscribed handler to remove
|
95 |
+
* @return `true` if the handler was found, `false` otherwise.
|
96 |
+
*/
|
97 |
+
function unsubscribe(name: string | symbol, onMessage: ChannelListener): boolean;
|
98 |
+
/**
|
99 |
+
* The class `Channel` represents an individual named channel within the data
|
100 |
+
* pipeline. It is used to track subscribers and to publish messages when there
|
101 |
+
* are subscribers present. It exists as a separate object to avoid channel
|
102 |
+
* lookups at publish time, enabling very fast publish speeds and allowing
|
103 |
+
* for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
|
104 |
+
* with `new Channel(name)` is not supported.
|
105 |
+
* @since v15.1.0, v14.17.0
|
106 |
+
*/
|
107 |
+
class Channel {
|
108 |
+
readonly name: string | symbol;
|
109 |
+
/**
|
110 |
+
* Check if there are active subscribers to this channel. This is helpful if
|
111 |
+
* the message you want to send might be expensive to prepare.
|
112 |
+
*
|
113 |
+
* This API is optional but helpful when trying to publish messages from very
|
114 |
+
* performance-sensitive code.
|
115 |
+
*
|
116 |
+
* ```js
|
117 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
118 |
+
*
|
119 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
120 |
+
*
|
121 |
+
* if (channel.hasSubscribers) {
|
122 |
+
* // There are subscribers, prepare and publish message
|
123 |
+
* }
|
124 |
+
* ```
|
125 |
+
* @since v15.1.0, v14.17.0
|
126 |
+
*/
|
127 |
+
readonly hasSubscribers: boolean;
|
128 |
+
private constructor(name: string | symbol);
|
129 |
+
/**
|
130 |
+
* Publish a message to any subscribers to the channel. This will trigger
|
131 |
+
* message handlers synchronously so they will execute within the same context.
|
132 |
+
*
|
133 |
+
* ```js
|
134 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
135 |
+
*
|
136 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
137 |
+
*
|
138 |
+
* channel.publish({
|
139 |
+
* some: 'message',
|
140 |
+
* });
|
141 |
+
* ```
|
142 |
+
* @since v15.1.0, v14.17.0
|
143 |
+
* @param message The message to send to the channel subscribers
|
144 |
+
*/
|
145 |
+
publish(message: unknown): void;
|
146 |
+
/**
|
147 |
+
* Register a message handler to subscribe to this channel. This message handler
|
148 |
+
* will be run synchronously whenever a message is published to the channel. Any
|
149 |
+
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
150 |
+
*
|
151 |
+
* ```js
|
152 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
153 |
+
*
|
154 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
155 |
+
*
|
156 |
+
* channel.subscribe((message, name) => {
|
157 |
+
* // Received data
|
158 |
+
* });
|
159 |
+
* ```
|
160 |
+
* @since v15.1.0, v14.17.0
|
161 |
+
* @deprecated Since v18.7.0,v16.17.0 - Use {@link subscribe(name, onMessage)}
|
162 |
+
* @param onMessage The handler to receive channel messages
|
163 |
+
*/
|
164 |
+
subscribe(onMessage: ChannelListener): void;
|
165 |
+
/**
|
166 |
+
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
167 |
+
*
|
168 |
+
* ```js
|
169 |
+
* import diagnostics_channel from 'node:diagnostics_channel';
|
170 |
+
*
|
171 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
172 |
+
*
|
173 |
+
* function onMessage(message, name) {
|
174 |
+
* // Received data
|
175 |
+
* }
|
176 |
+
*
|
177 |
+
* channel.subscribe(onMessage);
|
178 |
+
*
|
179 |
+
* channel.unsubscribe(onMessage);
|
180 |
+
* ```
|
181 |
+
* @since v15.1.0, v14.17.0
|
182 |
+
* @deprecated Since v18.7.0,v16.17.0 - Use {@link unsubscribe(name, onMessage)}
|
183 |
+
* @param onMessage The previous subscribed handler to remove
|
184 |
+
* @return `true` if the handler was found, `false` otherwise.
|
185 |
+
*/
|
186 |
+
unsubscribe(onMessage: ChannelListener): void;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
declare module "node:diagnostics_channel" {
|
190 |
+
export * from "diagnostics_channel";
|
191 |
+
}
|
node_modules/@types/node/dns.d.ts
ADDED
@@ -0,0 +1,809 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `node:dns` module enables name resolution. For example, use it to look up IP
|
3 |
+
* addresses of host names.
|
4 |
+
*
|
5 |
+
* Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
|
6 |
+
* DNS protocol for lookups. {@link lookup} uses the operating system
|
7 |
+
* facilities to perform name resolution. It may not need to perform any network
|
8 |
+
* communication. To perform name resolution the way other applications on the same
|
9 |
+
* system do, use {@link lookup}.
|
10 |
+
*
|
11 |
+
* ```js
|
12 |
+
* const dns = require('node:dns');
|
13 |
+
*
|
14 |
+
* dns.lookup('example.org', (err, address, family) => {
|
15 |
+
* console.log('address: %j family: IPv%s', address, family);
|
16 |
+
* });
|
17 |
+
* // address: "93.184.216.34" family: IPv4
|
18 |
+
* ```
|
19 |
+
*
|
20 |
+
* All other functions in the `node:dns` module connect to an actual DNS server to
|
21 |
+
* perform name resolution. They will always use the network to perform DNS
|
22 |
+
* queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
|
23 |
+
* DNS queries, bypassing other name-resolution facilities.
|
24 |
+
*
|
25 |
+
* ```js
|
26 |
+
* const dns = require('node:dns');
|
27 |
+
*
|
28 |
+
* dns.resolve4('archive.org', (err, addresses) => {
|
29 |
+
* if (err) throw err;
|
30 |
+
*
|
31 |
+
* console.log(`addresses: ${JSON.stringify(addresses)}`);
|
32 |
+
*
|
33 |
+
* addresses.forEach((a) => {
|
34 |
+
* dns.reverse(a, (err, hostnames) => {
|
35 |
+
* if (err) {
|
36 |
+
* throw err;
|
37 |
+
* }
|
38 |
+
* console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
|
39 |
+
* });
|
40 |
+
* });
|
41 |
+
* });
|
42 |
+
* ```
|
43 |
+
*
|
44 |
+
* See the `Implementation considerations section` for more information.
|
45 |
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/dns.js)
|
46 |
+
*/
|
47 |
+
declare module "dns" {
|
48 |
+
import * as dnsPromises from "node:dns/promises";
|
49 |
+
// Supported getaddrinfo flags.
|
50 |
+
export const ADDRCONFIG: number;
|
51 |
+
export const V4MAPPED: number;
|
52 |
+
/**
|
53 |
+
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
54 |
+
* well as IPv4 mapped IPv6 addresses.
|
55 |
+
*/
|
56 |
+
export const ALL: number;
|
57 |
+
export interface LookupOptions {
|
58 |
+
family?: number | undefined;
|
59 |
+
hints?: number | undefined;
|
60 |
+
all?: boolean | undefined;
|
61 |
+
/**
|
62 |
+
* @default true
|
63 |
+
*/
|
64 |
+
verbatim?: boolean | undefined;
|
65 |
+
}
|
66 |
+
export interface LookupOneOptions extends LookupOptions {
|
67 |
+
all?: false | undefined;
|
68 |
+
}
|
69 |
+
export interface LookupAllOptions extends LookupOptions {
|
70 |
+
all: true;
|
71 |
+
}
|
72 |
+
export interface LookupAddress {
|
73 |
+
address: string;
|
74 |
+
family: number;
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
78 |
+
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
79 |
+
* integer, then it must be `4` or `6` – if `options` is `0` or not provided, then
|
80 |
+
* IPv4 and IPv6 addresses are both returned if found.
|
81 |
+
*
|
82 |
+
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
83 |
+
* properties `address` and `family`.
|
84 |
+
*
|
85 |
+
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
86 |
+
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
87 |
+
* the host name does not exist but also when the lookup fails in other ways
|
88 |
+
* such as no available file descriptors.
|
89 |
+
*
|
90 |
+
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
91 |
+
* The implementation uses an operating system facility that can associate names
|
92 |
+
* with addresses and vice versa. This implementation can have subtle but
|
93 |
+
* important consequences on the behavior of any Node.js program. Please take some
|
94 |
+
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
95 |
+
*
|
96 |
+
* Example usage:
|
97 |
+
*
|
98 |
+
* ```js
|
99 |
+
* const dns = require('node:dns');
|
100 |
+
* const options = {
|
101 |
+
* family: 6,
|
102 |
+
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
103 |
+
* };
|
104 |
+
* dns.lookup('example.com', options, (err, address, family) =>
|
105 |
+
* console.log('address: %j family: IPv%s', address, family));
|
106 |
+
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
107 |
+
*
|
108 |
+
* // When options.all is true, the result will be an Array.
|
109 |
+
* options.all = true;
|
110 |
+
* dns.lookup('example.com', options, (err, addresses) =>
|
111 |
+
* console.log('addresses: %j', addresses));
|
112 |
+
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
113 |
+
* ```
|
114 |
+
*
|
115 |
+
* If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
|
116 |
+
* @since v0.1.90
|
117 |
+
*/
|
118 |
+
export function lookup(
|
119 |
+
hostname: string,
|
120 |
+
family: number,
|
121 |
+
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
122 |
+
): void;
|
123 |
+
export function lookup(
|
124 |
+
hostname: string,
|
125 |
+
options: LookupOneOptions,
|
126 |
+
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
127 |
+
): void;
|
128 |
+
export function lookup(
|
129 |
+
hostname: string,
|
130 |
+
options: LookupAllOptions,
|
131 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void,
|
132 |
+
): void;
|
133 |
+
export function lookup(
|
134 |
+
hostname: string,
|
135 |
+
options: LookupOptions,
|
136 |
+
callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void,
|
137 |
+
): void;
|
138 |
+
export function lookup(
|
139 |
+
hostname: string,
|
140 |
+
callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void,
|
141 |
+
): void;
|
142 |
+
export namespace lookup {
|
143 |
+
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
144 |
+
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
145 |
+
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
146 |
+
}
|
147 |
+
/**
|
148 |
+
* Resolves the given `address` and `port` into a host name and service using
|
149 |
+
* the operating system's underlying `getnameinfo` implementation.
|
150 |
+
*
|
151 |
+
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
152 |
+
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
153 |
+
*
|
154 |
+
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
155 |
+
*
|
156 |
+
* ```js
|
157 |
+
* const dns = require('node:dns');
|
158 |
+
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
159 |
+
* console.log(hostname, service);
|
160 |
+
* // Prints: localhost ssh
|
161 |
+
* });
|
162 |
+
* ```
|
163 |
+
*
|
164 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
|
165 |
+
* @since v0.11.14
|
166 |
+
*/
|
167 |
+
export function lookupService(
|
168 |
+
address: string,
|
169 |
+
port: number,
|
170 |
+
callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void,
|
171 |
+
): void;
|
172 |
+
export namespace lookupService {
|
173 |
+
function __promisify__(
|
174 |
+
address: string,
|
175 |
+
port: number,
|
176 |
+
): Promise<{
|
177 |
+
hostname: string;
|
178 |
+
service: string;
|
179 |
+
}>;
|
180 |
+
}
|
181 |
+
export interface ResolveOptions {
|
182 |
+
ttl: boolean;
|
183 |
+
}
|
184 |
+
export interface ResolveWithTtlOptions extends ResolveOptions {
|
185 |
+
ttl: true;
|
186 |
+
}
|
187 |
+
export interface RecordWithTtl {
|
188 |
+
address: string;
|
189 |
+
ttl: number;
|
190 |
+
}
|
191 |
+
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
192 |
+
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
193 |
+
export interface AnyARecord extends RecordWithTtl {
|
194 |
+
type: "A";
|
195 |
+
}
|
196 |
+
export interface AnyAaaaRecord extends RecordWithTtl {
|
197 |
+
type: "AAAA";
|
198 |
+
}
|
199 |
+
export interface CaaRecord {
|
200 |
+
critical: number;
|
201 |
+
issue?: string | undefined;
|
202 |
+
issuewild?: string | undefined;
|
203 |
+
iodef?: string | undefined;
|
204 |
+
contactemail?: string | undefined;
|
205 |
+
contactphone?: string | undefined;
|
206 |
+
}
|
207 |
+
export interface MxRecord {
|
208 |
+
priority: number;
|
209 |
+
exchange: string;
|
210 |
+
}
|
211 |
+
export interface AnyMxRecord extends MxRecord {
|
212 |
+
type: "MX";
|
213 |
+
}
|
214 |
+
export interface NaptrRecord {
|
215 |
+
flags: string;
|
216 |
+
service: string;
|
217 |
+
regexp: string;
|
218 |
+
replacement: string;
|
219 |
+
order: number;
|
220 |
+
preference: number;
|
221 |
+
}
|
222 |
+
export interface AnyNaptrRecord extends NaptrRecord {
|
223 |
+
type: "NAPTR";
|
224 |
+
}
|
225 |
+
export interface SoaRecord {
|
226 |
+
nsname: string;
|
227 |
+
hostmaster: string;
|
228 |
+
serial: number;
|
229 |
+
refresh: number;
|
230 |
+
retry: number;
|
231 |
+
expire: number;
|
232 |
+
minttl: number;
|
233 |
+
}
|
234 |
+
export interface AnySoaRecord extends SoaRecord {
|
235 |
+
type: "SOA";
|
236 |
+
}
|
237 |
+
export interface SrvRecord {
|
238 |
+
priority: number;
|
239 |
+
weight: number;
|
240 |
+
port: number;
|
241 |
+
name: string;
|
242 |
+
}
|
243 |
+
export interface AnySrvRecord extends SrvRecord {
|
244 |
+
type: "SRV";
|
245 |
+
}
|
246 |
+
export interface AnyTxtRecord {
|
247 |
+
type: "TXT";
|
248 |
+
entries: string[];
|
249 |
+
}
|
250 |
+
export interface AnyNsRecord {
|
251 |
+
type: "NS";
|
252 |
+
value: string;
|
253 |
+
}
|
254 |
+
export interface AnyPtrRecord {
|
255 |
+
type: "PTR";
|
256 |
+
value: string;
|
257 |
+
}
|
258 |
+
export interface AnyCnameRecord {
|
259 |
+
type: "CNAME";
|
260 |
+
value: string;
|
261 |
+
}
|
262 |
+
export type AnyRecord =
|
263 |
+
| AnyARecord
|
264 |
+
| AnyAaaaRecord
|
265 |
+
| AnyCnameRecord
|
266 |
+
| AnyMxRecord
|
267 |
+
| AnyNaptrRecord
|
268 |
+
| AnyNsRecord
|
269 |
+
| AnyPtrRecord
|
270 |
+
| AnySoaRecord
|
271 |
+
| AnySrvRecord
|
272 |
+
| AnyTxtRecord;
|
273 |
+
/**
|
274 |
+
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
275 |
+
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
276 |
+
* records. The type and structure of individual results varies based on `rrtype`:
|
277 |
+
*
|
278 |
+
* <omitted>
|
279 |
+
*
|
280 |
+
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
281 |
+
* @since v0.1.27
|
282 |
+
* @param hostname Host name to resolve.
|
283 |
+
* @param [rrtype='A'] Resource record type.
|
284 |
+
*/
|
285 |
+
export function resolve(
|
286 |
+
hostname: string,
|
287 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
288 |
+
): void;
|
289 |
+
export function resolve(
|
290 |
+
hostname: string,
|
291 |
+
rrtype: "A",
|
292 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
293 |
+
): void;
|
294 |
+
export function resolve(
|
295 |
+
hostname: string,
|
296 |
+
rrtype: "AAAA",
|
297 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
298 |
+
): void;
|
299 |
+
export function resolve(
|
300 |
+
hostname: string,
|
301 |
+
rrtype: "ANY",
|
302 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
303 |
+
): void;
|
304 |
+
export function resolve(
|
305 |
+
hostname: string,
|
306 |
+
rrtype: "CNAME",
|
307 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
308 |
+
): void;
|
309 |
+
export function resolve(
|
310 |
+
hostname: string,
|
311 |
+
rrtype: "MX",
|
312 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
|
313 |
+
): void;
|
314 |
+
export function resolve(
|
315 |
+
hostname: string,
|
316 |
+
rrtype: "NAPTR",
|
317 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
318 |
+
): void;
|
319 |
+
export function resolve(
|
320 |
+
hostname: string,
|
321 |
+
rrtype: "NS",
|
322 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
323 |
+
): void;
|
324 |
+
export function resolve(
|
325 |
+
hostname: string,
|
326 |
+
rrtype: "PTR",
|
327 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
328 |
+
): void;
|
329 |
+
export function resolve(
|
330 |
+
hostname: string,
|
331 |
+
rrtype: "SOA",
|
332 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void,
|
333 |
+
): void;
|
334 |
+
export function resolve(
|
335 |
+
hostname: string,
|
336 |
+
rrtype: "SRV",
|
337 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
338 |
+
): void;
|
339 |
+
export function resolve(
|
340 |
+
hostname: string,
|
341 |
+
rrtype: "TXT",
|
342 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
343 |
+
): void;
|
344 |
+
export function resolve(
|
345 |
+
hostname: string,
|
346 |
+
rrtype: string,
|
347 |
+
callback: (
|
348 |
+
err: NodeJS.ErrnoException | null,
|
349 |
+
addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[],
|
350 |
+
) => void,
|
351 |
+
): void;
|
352 |
+
export namespace resolve {
|
353 |
+
function __promisify__(hostname: string, rrtype?: "A" | "AAAA" | "CNAME" | "NS" | "PTR"): Promise<string[]>;
|
354 |
+
function __promisify__(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
355 |
+
function __promisify__(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
356 |
+
function __promisify__(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
357 |
+
function __promisify__(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
358 |
+
function __promisify__(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
359 |
+
function __promisify__(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
360 |
+
function __promisify__(
|
361 |
+
hostname: string,
|
362 |
+
rrtype: string,
|
363 |
+
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
364 |
+
}
|
365 |
+
/**
|
366 |
+
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
367 |
+
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
368 |
+
* @since v0.1.16
|
369 |
+
* @param hostname Host name to resolve.
|
370 |
+
*/
|
371 |
+
export function resolve4(
|
372 |
+
hostname: string,
|
373 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
374 |
+
): void;
|
375 |
+
export function resolve4(
|
376 |
+
hostname: string,
|
377 |
+
options: ResolveWithTtlOptions,
|
378 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
379 |
+
): void;
|
380 |
+
export function resolve4(
|
381 |
+
hostname: string,
|
382 |
+
options: ResolveOptions,
|
383 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
384 |
+
): void;
|
385 |
+
export namespace resolve4 {
|
386 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
387 |
+
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
388 |
+
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
389 |
+
}
|
390 |
+
/**
|
391 |
+
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
392 |
+
* will contain an array of IPv6 addresses.
|
393 |
+
* @since v0.1.16
|
394 |
+
* @param hostname Host name to resolve.
|
395 |
+
*/
|
396 |
+
export function resolve6(
|
397 |
+
hostname: string,
|
398 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
399 |
+
): void;
|
400 |
+
export function resolve6(
|
401 |
+
hostname: string,
|
402 |
+
options: ResolveWithTtlOptions,
|
403 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void,
|
404 |
+
): void;
|
405 |
+
export function resolve6(
|
406 |
+
hostname: string,
|
407 |
+
options: ResolveOptions,
|
408 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void,
|
409 |
+
): void;
|
410 |
+
export namespace resolve6 {
|
411 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
412 |
+
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
413 |
+
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
414 |
+
}
|
415 |
+
/**
|
416 |
+
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
417 |
+
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
418 |
+
* @since v0.3.2
|
419 |
+
*/
|
420 |
+
export function resolveCname(
|
421 |
+
hostname: string,
|
422 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
423 |
+
): void;
|
424 |
+
export namespace resolveCname {
|
425 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
426 |
+
}
|
427 |
+
/**
|
428 |
+
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
429 |
+
* will contain an array of certification authority authorization records
|
430 |
+
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:[email protected]'}, {critical: 128, issue: 'pki.example.com'}]`).
|
431 |
+
* @since v15.0.0, v14.17.0
|
432 |
+
*/
|
433 |
+
export function resolveCaa(
|
434 |
+
hostname: string,
|
435 |
+
callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void,
|
436 |
+
): void;
|
437 |
+
export namespace resolveCaa {
|
438 |
+
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
439 |
+
}
|
440 |
+
/**
|
441 |
+
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
442 |
+
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
443 |
+
* @since v0.1.27
|
444 |
+
*/
|
445 |
+
export function resolveMx(
|
446 |
+
hostname: string,
|
447 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void,
|
448 |
+
): void;
|
449 |
+
export namespace resolveMx {
|
450 |
+
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
451 |
+
}
|
452 |
+
/**
|
453 |
+
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
454 |
+
* objects with the following properties:
|
455 |
+
*
|
456 |
+
* * `flags`
|
457 |
+
* * `service`
|
458 |
+
* * `regexp`
|
459 |
+
* * `replacement`
|
460 |
+
* * `order`
|
461 |
+
* * `preference`
|
462 |
+
*
|
463 |
+
* ```js
|
464 |
+
* {
|
465 |
+
* flags: 's',
|
466 |
+
* service: 'SIP+D2U',
|
467 |
+
* regexp: '',
|
468 |
+
* replacement: '_sip._udp.example.com',
|
469 |
+
* order: 30,
|
470 |
+
* preference: 100
|
471 |
+
* }
|
472 |
+
* ```
|
473 |
+
* @since v0.9.12
|
474 |
+
*/
|
475 |
+
export function resolveNaptr(
|
476 |
+
hostname: string,
|
477 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void,
|
478 |
+
): void;
|
479 |
+
export namespace resolveNaptr {
|
480 |
+
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
481 |
+
}
|
482 |
+
/**
|
483 |
+
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
484 |
+
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
485 |
+
* @since v0.1.90
|
486 |
+
*/
|
487 |
+
export function resolveNs(
|
488 |
+
hostname: string,
|
489 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
490 |
+
): void;
|
491 |
+
export namespace resolveNs {
|
492 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
493 |
+
}
|
494 |
+
/**
|
495 |
+
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
496 |
+
* be an array of strings containing the reply records.
|
497 |
+
* @since v6.0.0
|
498 |
+
*/
|
499 |
+
export function resolvePtr(
|
500 |
+
hostname: string,
|
501 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void,
|
502 |
+
): void;
|
503 |
+
export namespace resolvePtr {
|
504 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
505 |
+
}
|
506 |
+
/**
|
507 |
+
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
508 |
+
* the `hostname`. The `address` argument passed to the `callback` function will
|
509 |
+
* be an object with the following properties:
|
510 |
+
*
|
511 |
+
* * `nsname`
|
512 |
+
* * `hostmaster`
|
513 |
+
* * `serial`
|
514 |
+
* * `refresh`
|
515 |
+
* * `retry`
|
516 |
+
* * `expire`
|
517 |
+
* * `minttl`
|
518 |
+
*
|
519 |
+
* ```js
|
520 |
+
* {
|
521 |
+
* nsname: 'ns.example.com',
|
522 |
+
* hostmaster: 'root.example.com',
|
523 |
+
* serial: 2013101809,
|
524 |
+
* refresh: 10000,
|
525 |
+
* retry: 2400,
|
526 |
+
* expire: 604800,
|
527 |
+
* minttl: 3600
|
528 |
+
* }
|
529 |
+
* ```
|
530 |
+
* @since v0.11.10
|
531 |
+
*/
|
532 |
+
export function resolveSoa(
|
533 |
+
hostname: string,
|
534 |
+
callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void,
|
535 |
+
): void;
|
536 |
+
export namespace resolveSoa {
|
537 |
+
function __promisify__(hostname: string): Promise<SoaRecord>;
|
538 |
+
}
|
539 |
+
/**
|
540 |
+
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
541 |
+
* be an array of objects with the following properties:
|
542 |
+
*
|
543 |
+
* * `priority`
|
544 |
+
* * `weight`
|
545 |
+
* * `port`
|
546 |
+
* * `name`
|
547 |
+
*
|
548 |
+
* ```js
|
549 |
+
* {
|
550 |
+
* priority: 10,
|
551 |
+
* weight: 5,
|
552 |
+
* port: 21223,
|
553 |
+
* name: 'service.example.com'
|
554 |
+
* }
|
555 |
+
* ```
|
556 |
+
* @since v0.1.27
|
557 |
+
*/
|
558 |
+
export function resolveSrv(
|
559 |
+
hostname: string,
|
560 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void,
|
561 |
+
): void;
|
562 |
+
export namespace resolveSrv {
|
563 |
+
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
564 |
+
}
|
565 |
+
/**
|
566 |
+
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
567 |
+
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
568 |
+
* one record. Depending on the use case, these could be either joined together or
|
569 |
+
* treated separately.
|
570 |
+
* @since v0.1.27
|
571 |
+
*/
|
572 |
+
export function resolveTxt(
|
573 |
+
hostname: string,
|
574 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void,
|
575 |
+
): void;
|
576 |
+
export namespace resolveTxt {
|
577 |
+
function __promisify__(hostname: string): Promise<string[][]>;
|
578 |
+
}
|
579 |
+
/**
|
580 |
+
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
581 |
+
* The `ret` argument passed to the `callback` function will be an array containing
|
582 |
+
* various types of records. Each object has a property `type` that indicates the
|
583 |
+
* type of the current record. And depending on the `type`, additional properties
|
584 |
+
* will be present on the object:
|
585 |
+
*
|
586 |
+
* <omitted>
|
587 |
+
*
|
588 |
+
* Here is an example of the `ret` object passed to the callback:
|
589 |
+
*
|
590 |
+
* ```js
|
591 |
+
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
592 |
+
* { type: 'CNAME', value: 'example.com' },
|
593 |
+
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
594 |
+
* { type: 'NS', value: 'ns1.example.com' },
|
595 |
+
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
596 |
+
* { type: 'SOA',
|
597 |
+
* nsname: 'ns1.example.com',
|
598 |
+
* hostmaster: 'admin.example.com',
|
599 |
+
* serial: 156696742,
|
600 |
+
* refresh: 900,
|
601 |
+
* retry: 900,
|
602 |
+
* expire: 1800,
|
603 |
+
* minttl: 60 } ]
|
604 |
+
* ```
|
605 |
+
*
|
606 |
+
* DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
|
607 |
+
* 8482](https://tools.ietf.org/html/rfc8482).
|
608 |
+
*/
|
609 |
+
export function resolveAny(
|
610 |
+
hostname: string,
|
611 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void,
|
612 |
+
): void;
|
613 |
+
export namespace resolveAny {
|
614 |
+
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
615 |
+
}
|
616 |
+
/**
|
617 |
+
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
618 |
+
* array of host names.
|
619 |
+
*
|
620 |
+
* On error, `err` is an `Error` object, where `err.code` is
|
621 |
+
* one of the `DNS error codes`.
|
622 |
+
* @since v0.1.16
|
623 |
+
*/
|
624 |
+
export function reverse(
|
625 |
+
ip: string,
|
626 |
+
callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void,
|
627 |
+
): void;
|
628 |
+
/**
|
629 |
+
* Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
630 |
+
*
|
631 |
+
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
632 |
+
* * `verbatim`: for `verbatim` defaulting to `true`.
|
633 |
+
* @since v20.1.0
|
634 |
+
*/
|
635 |
+
export function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
636 |
+
/**
|
637 |
+
* Sets the IP address and port of servers to be used when performing DNS
|
638 |
+
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
639 |
+
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
640 |
+
*
|
641 |
+
* ```js
|
642 |
+
* dns.setServers([
|
643 |
+
* '4.4.4.4',
|
644 |
+
* '[2001:4860:4860::8888]',
|
645 |
+
* '4.4.4.4:1053',
|
646 |
+
* '[2001:4860:4860::8888]:1053',
|
647 |
+
* ]);
|
648 |
+
* ```
|
649 |
+
*
|
650 |
+
* An error will be thrown if an invalid address is provided.
|
651 |
+
*
|
652 |
+
* The `dns.setServers()` method must not be called while a DNS query is in
|
653 |
+
* progress.
|
654 |
+
*
|
655 |
+
* The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
|
656 |
+
*
|
657 |
+
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
658 |
+
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
659 |
+
* subsequent servers provided. Fallback DNS servers will only be used if the
|
660 |
+
* earlier ones time out or result in some other error.
|
661 |
+
* @since v0.11.3
|
662 |
+
* @param servers array of `RFC 5952` formatted addresses
|
663 |
+
*/
|
664 |
+
export function setServers(servers: readonly string[]): void;
|
665 |
+
/**
|
666 |
+
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
667 |
+
* that are currently configured for DNS resolution. A string will include a port
|
668 |
+
* section if a custom port is used.
|
669 |
+
*
|
670 |
+
* ```js
|
671 |
+
* [
|
672 |
+
* '4.4.4.4',
|
673 |
+
* '2001:4860:4860::8888',
|
674 |
+
* '4.4.4.4:1053',
|
675 |
+
* '[2001:4860:4860::8888]:1053',
|
676 |
+
* ]
|
677 |
+
* ```
|
678 |
+
* @since v0.11.3
|
679 |
+
*/
|
680 |
+
export function getServers(): string[];
|
681 |
+
/**
|
682 |
+
* Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
683 |
+
*
|
684 |
+
* * `ipv4first`: sets default `verbatim` `false`.
|
685 |
+
* * `verbatim`: sets default `verbatim` `true`.
|
686 |
+
*
|
687 |
+
* The default is `verbatim` and {@link setDefaultResultOrder} have higher
|
688 |
+
* priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default
|
689 |
+
* dns orders in workers.
|
690 |
+
* @since v16.4.0, v14.18.0
|
691 |
+
* @param order must be `'ipv4first'` or `'verbatim'`.
|
692 |
+
*/
|
693 |
+
export function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
694 |
+
// Error codes
|
695 |
+
export const NODATA: string;
|
696 |
+
export const FORMERR: string;
|
697 |
+
export const SERVFAIL: string;
|
698 |
+
export const NOTFOUND: string;
|
699 |
+
export const NOTIMP: string;
|
700 |
+
export const REFUSED: string;
|
701 |
+
export const BADQUERY: string;
|
702 |
+
export const BADNAME: string;
|
703 |
+
export const BADFAMILY: string;
|
704 |
+
export const BADRESP: string;
|
705 |
+
export const CONNREFUSED: string;
|
706 |
+
export const TIMEOUT: string;
|
707 |
+
export const EOF: string;
|
708 |
+
export const FILE: string;
|
709 |
+
export const NOMEM: string;
|
710 |
+
export const DESTRUCTION: string;
|
711 |
+
export const BADSTR: string;
|
712 |
+
export const BADFLAGS: string;
|
713 |
+
export const NONAME: string;
|
714 |
+
export const BADHINTS: string;
|
715 |
+
export const NOTINITIALIZED: string;
|
716 |
+
export const LOADIPHLPAPI: string;
|
717 |
+
export const ADDRGETNETWORKPARAMS: string;
|
718 |
+
export const CANCELLED: string;
|
719 |
+
export interface ResolverOptions {
|
720 |
+
timeout?: number | undefined;
|
721 |
+
/**
|
722 |
+
* @default 4
|
723 |
+
*/
|
724 |
+
tries?: number;
|
725 |
+
}
|
726 |
+
/**
|
727 |
+
* An independent resolver for DNS requests.
|
728 |
+
*
|
729 |
+
* Creating a new resolver uses the default server settings. Setting
|
730 |
+
* the servers used for a resolver using `resolver.setServers()` does not affect
|
731 |
+
* other resolvers:
|
732 |
+
*
|
733 |
+
* ```js
|
734 |
+
* const { Resolver } = require('node:dns');
|
735 |
+
* const resolver = new Resolver();
|
736 |
+
* resolver.setServers(['4.4.4.4']);
|
737 |
+
*
|
738 |
+
* // This request will use the server at 4.4.4.4, independent of global settings.
|
739 |
+
* resolver.resolve4('example.org', (err, addresses) => {
|
740 |
+
* // ...
|
741 |
+
* });
|
742 |
+
* ```
|
743 |
+
*
|
744 |
+
* The following methods from the `node:dns` module are available:
|
745 |
+
*
|
746 |
+
* * `resolver.getServers()`
|
747 |
+
* * `resolver.resolve()`
|
748 |
+
* * `resolver.resolve4()`
|
749 |
+
* * `resolver.resolve6()`
|
750 |
+
* * `resolver.resolveAny()`
|
751 |
+
* * `resolver.resolveCaa()`
|
752 |
+
* * `resolver.resolveCname()`
|
753 |
+
* * `resolver.resolveMx()`
|
754 |
+
* * `resolver.resolveNaptr()`
|
755 |
+
* * `resolver.resolveNs()`
|
756 |
+
* * `resolver.resolvePtr()`
|
757 |
+
* * `resolver.resolveSoa()`
|
758 |
+
* * `resolver.resolveSrv()`
|
759 |
+
* * `resolver.resolveTxt()`
|
760 |
+
* * `resolver.reverse()`
|
761 |
+
* * `resolver.setServers()`
|
762 |
+
* @since v8.3.0
|
763 |
+
*/
|
764 |
+
export class Resolver {
|
765 |
+
constructor(options?: ResolverOptions);
|
766 |
+
/**
|
767 |
+
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
768 |
+
* callbacks will be called with an error with code `ECANCELLED`.
|
769 |
+
* @since v8.3.0
|
770 |
+
*/
|
771 |
+
cancel(): void;
|
772 |
+
getServers: typeof getServers;
|
773 |
+
resolve: typeof resolve;
|
774 |
+
resolve4: typeof resolve4;
|
775 |
+
resolve6: typeof resolve6;
|
776 |
+
resolveAny: typeof resolveAny;
|
777 |
+
resolveCaa: typeof resolveCaa;
|
778 |
+
resolveCname: typeof resolveCname;
|
779 |
+
resolveMx: typeof resolveMx;
|
780 |
+
resolveNaptr: typeof resolveNaptr;
|
781 |
+
resolveNs: typeof resolveNs;
|
782 |
+
resolvePtr: typeof resolvePtr;
|
783 |
+
resolveSoa: typeof resolveSoa;
|
784 |
+
resolveSrv: typeof resolveSrv;
|
785 |
+
resolveTxt: typeof resolveTxt;
|
786 |
+
reverse: typeof reverse;
|
787 |
+
/**
|
788 |
+
* The resolver instance will send its requests from the specified IP address.
|
789 |
+
* This allows programs to specify outbound interfaces when used on multi-homed
|
790 |
+
* systems.
|
791 |
+
*
|
792 |
+
* If a v4 or v6 address is not specified, it is set to the default and the
|
793 |
+
* operating system will choose a local address automatically.
|
794 |
+
*
|
795 |
+
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
796 |
+
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
797 |
+
* The `rrtype` of resolution requests has no impact on the local address used.
|
798 |
+
* @since v15.1.0, v14.17.0
|
799 |
+
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
800 |
+
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
801 |
+
*/
|
802 |
+
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
803 |
+
setServers: typeof setServers;
|
804 |
+
}
|
805 |
+
export { dnsPromises as promises };
|
806 |
+
}
|
807 |
+
declare module "node:dns" {
|
808 |
+
export * from "dns";
|
809 |
+
}
|
node_modules/@types/node/dns/promises.d.ts
ADDED
@@ -0,0 +1,425 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
3 |
+
* that return `Promise` objects rather than using callbacks. The API is accessible
|
4 |
+
* via `require('node:dns').promises` or `require('node:dns/promises')`.
|
5 |
+
* @since v10.6.0
|
6 |
+
*/
|
7 |
+
declare module "dns/promises" {
|
8 |
+
import {
|
9 |
+
AnyRecord,
|
10 |
+
CaaRecord,
|
11 |
+
LookupAddress,
|
12 |
+
LookupAllOptions,
|
13 |
+
LookupOneOptions,
|
14 |
+
LookupOptions,
|
15 |
+
MxRecord,
|
16 |
+
NaptrRecord,
|
17 |
+
RecordWithTtl,
|
18 |
+
ResolveOptions,
|
19 |
+
ResolverOptions,
|
20 |
+
ResolveWithTtlOptions,
|
21 |
+
SoaRecord,
|
22 |
+
SrvRecord,
|
23 |
+
} from "node:dns";
|
24 |
+
/**
|
25 |
+
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
26 |
+
* that are currently configured for DNS resolution. A string will include a port
|
27 |
+
* section if a custom port is used.
|
28 |
+
*
|
29 |
+
* ```js
|
30 |
+
* [
|
31 |
+
* '4.4.4.4',
|
32 |
+
* '2001:4860:4860::8888',
|
33 |
+
* '4.4.4.4:1053',
|
34 |
+
* '[2001:4860:4860::8888]:1053',
|
35 |
+
* ]
|
36 |
+
* ```
|
37 |
+
* @since v10.6.0
|
38 |
+
*/
|
39 |
+
function getServers(): string[];
|
40 |
+
/**
|
41 |
+
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
42 |
+
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
43 |
+
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
44 |
+
* and IPv6 addresses are both returned if found.
|
45 |
+
*
|
46 |
+
* With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
|
47 |
+
*
|
48 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
49 |
+
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
50 |
+
* the host name does not exist but also when the lookup fails in other ways
|
51 |
+
* such as no available file descriptors.
|
52 |
+
*
|
53 |
+
* `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
|
54 |
+
* protocol. The implementation uses an operating system facility that can
|
55 |
+
* associate names with addresses and vice versa. This implementation can have
|
56 |
+
* subtle but important consequences on the behavior of any Node.js program. Please
|
57 |
+
* take some time to consult the `Implementation considerations section` before
|
58 |
+
* using `dnsPromises.lookup()`.
|
59 |
+
*
|
60 |
+
* Example usage:
|
61 |
+
*
|
62 |
+
* ```js
|
63 |
+
* const dns = require('node:dns');
|
64 |
+
* const dnsPromises = dns.promises;
|
65 |
+
* const options = {
|
66 |
+
* family: 6,
|
67 |
+
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
68 |
+
* };
|
69 |
+
*
|
70 |
+
* dnsPromises.lookup('example.com', options).then((result) => {
|
71 |
+
* console.log('address: %j family: IPv%s', result.address, result.family);
|
72 |
+
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
73 |
+
* });
|
74 |
+
*
|
75 |
+
* // When options.all is true, the result will be an Array.
|
76 |
+
* options.all = true;
|
77 |
+
* dnsPromises.lookup('example.com', options).then((result) => {
|
78 |
+
* console.log('addresses: %j', result);
|
79 |
+
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
80 |
+
* });
|
81 |
+
* ```
|
82 |
+
* @since v10.6.0
|
83 |
+
*/
|
84 |
+
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
85 |
+
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
86 |
+
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
87 |
+
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
88 |
+
function lookup(hostname: string): Promise<LookupAddress>;
|
89 |
+
/**
|
90 |
+
* Resolves the given `address` and `port` into a host name and service using
|
91 |
+
* the operating system's underlying `getnameinfo` implementation.
|
92 |
+
*
|
93 |
+
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
94 |
+
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
95 |
+
*
|
96 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
97 |
+
*
|
98 |
+
* ```js
|
99 |
+
* const dnsPromises = require('node:dns').promises;
|
100 |
+
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
101 |
+
* console.log(result.hostname, result.service);
|
102 |
+
* // Prints: localhost ssh
|
103 |
+
* });
|
104 |
+
* ```
|
105 |
+
* @since v10.6.0
|
106 |
+
*/
|
107 |
+
function lookupService(
|
108 |
+
address: string,
|
109 |
+
port: number,
|
110 |
+
): Promise<{
|
111 |
+
hostname: string;
|
112 |
+
service: string;
|
113 |
+
}>;
|
114 |
+
/**
|
115 |
+
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
116 |
+
* of the resource records. When successful, the `Promise` is resolved with an
|
117 |
+
* array of resource records. The type and structure of individual results vary
|
118 |
+
* based on `rrtype`:
|
119 |
+
*
|
120 |
+
* <omitted>
|
121 |
+
*
|
122 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
123 |
+
* @since v10.6.0
|
124 |
+
* @param hostname Host name to resolve.
|
125 |
+
* @param [rrtype='A'] Resource record type.
|
126 |
+
*/
|
127 |
+
function resolve(hostname: string): Promise<string[]>;
|
128 |
+
function resolve(hostname: string, rrtype: "A"): Promise<string[]>;
|
129 |
+
function resolve(hostname: string, rrtype: "AAAA"): Promise<string[]>;
|
130 |
+
function resolve(hostname: string, rrtype: "ANY"): Promise<AnyRecord[]>;
|
131 |
+
function resolve(hostname: string, rrtype: "CAA"): Promise<CaaRecord[]>;
|
132 |
+
function resolve(hostname: string, rrtype: "CNAME"): Promise<string[]>;
|
133 |
+
function resolve(hostname: string, rrtype: "MX"): Promise<MxRecord[]>;
|
134 |
+
function resolve(hostname: string, rrtype: "NAPTR"): Promise<NaptrRecord[]>;
|
135 |
+
function resolve(hostname: string, rrtype: "NS"): Promise<string[]>;
|
136 |
+
function resolve(hostname: string, rrtype: "PTR"): Promise<string[]>;
|
137 |
+
function resolve(hostname: string, rrtype: "SOA"): Promise<SoaRecord>;
|
138 |
+
function resolve(hostname: string, rrtype: "SRV"): Promise<SrvRecord[]>;
|
139 |
+
function resolve(hostname: string, rrtype: "TXT"): Promise<string[][]>;
|
140 |
+
function resolve(
|
141 |
+
hostname: string,
|
142 |
+
rrtype: string,
|
143 |
+
): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
144 |
+
/**
|
145 |
+
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
|
146 |
+
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
147 |
+
* @since v10.6.0
|
148 |
+
* @param hostname Host name to resolve.
|
149 |
+
*/
|
150 |
+
function resolve4(hostname: string): Promise<string[]>;
|
151 |
+
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
152 |
+
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
153 |
+
/**
|
154 |
+
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
|
155 |
+
* addresses.
|
156 |
+
* @since v10.6.0
|
157 |
+
* @param hostname Host name to resolve.
|
158 |
+
*/
|
159 |
+
function resolve6(hostname: string): Promise<string[]>;
|
160 |
+
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
161 |
+
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
162 |
+
/**
|
163 |
+
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
164 |
+
* On success, the `Promise` is resolved with an array containing various types of
|
165 |
+
* records. Each object has a property `type` that indicates the type of the
|
166 |
+
* current record. And depending on the `type`, additional properties will be
|
167 |
+
* present on the object:
|
168 |
+
*
|
169 |
+
* <omitted>
|
170 |
+
*
|
171 |
+
* Here is an example of the result object:
|
172 |
+
*
|
173 |
+
* ```js
|
174 |
+
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
175 |
+
* { type: 'CNAME', value: 'example.com' },
|
176 |
+
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
177 |
+
* { type: 'NS', value: 'ns1.example.com' },
|
178 |
+
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
179 |
+
* { type: 'SOA',
|
180 |
+
* nsname: 'ns1.example.com',
|
181 |
+
* hostmaster: 'admin.example.com',
|
182 |
+
* serial: 156696742,
|
183 |
+
* refresh: 900,
|
184 |
+
* retry: 900,
|
185 |
+
* expire: 1800,
|
186 |
+
* minttl: 60 } ]
|
187 |
+
* ```
|
188 |
+
* @since v10.6.0
|
189 |
+
*/
|
190 |
+
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
191 |
+
/**
|
192 |
+
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
193 |
+
* the `Promise` is resolved with an array of objects containing available
|
194 |
+
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:[email protected]'},{critical: 128, issue: 'pki.example.com'}]`).
|
195 |
+
* @since v15.0.0, v14.17.0
|
196 |
+
*/
|
197 |
+
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
198 |
+
/**
|
199 |
+
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
200 |
+
* the `Promise` is resolved with an array of canonical name records available for
|
201 |
+
* the `hostname` (e.g. `['bar.example.com']`).
|
202 |
+
* @since v10.6.0
|
203 |
+
*/
|
204 |
+
function resolveCname(hostname: string): Promise<string[]>;
|
205 |
+
/**
|
206 |
+
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
|
207 |
+
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
208 |
+
* @since v10.6.0
|
209 |
+
*/
|
210 |
+
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
211 |
+
/**
|
212 |
+
* Uses the DNS protocol to resolve regular expression-based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
|
213 |
+
* of objects with the following properties:
|
214 |
+
*
|
215 |
+
* * `flags`
|
216 |
+
* * `service`
|
217 |
+
* * `regexp`
|
218 |
+
* * `replacement`
|
219 |
+
* * `order`
|
220 |
+
* * `preference`
|
221 |
+
*
|
222 |
+
* ```js
|
223 |
+
* {
|
224 |
+
* flags: 's',
|
225 |
+
* service: 'SIP+D2U',
|
226 |
+
* regexp: '',
|
227 |
+
* replacement: '_sip._udp.example.com',
|
228 |
+
* order: 30,
|
229 |
+
* preference: 100
|
230 |
+
* }
|
231 |
+
* ```
|
232 |
+
* @since v10.6.0
|
233 |
+
*/
|
234 |
+
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
235 |
+
/**
|
236 |
+
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
|
237 |
+
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
238 |
+
* @since v10.6.0
|
239 |
+
*/
|
240 |
+
function resolveNs(hostname: string): Promise<string[]>;
|
241 |
+
/**
|
242 |
+
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
|
243 |
+
* containing the reply records.
|
244 |
+
* @since v10.6.0
|
245 |
+
*/
|
246 |
+
function resolvePtr(hostname: string): Promise<string[]>;
|
247 |
+
/**
|
248 |
+
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
249 |
+
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
250 |
+
* following properties:
|
251 |
+
*
|
252 |
+
* * `nsname`
|
253 |
+
* * `hostmaster`
|
254 |
+
* * `serial`
|
255 |
+
* * `refresh`
|
256 |
+
* * `retry`
|
257 |
+
* * `expire`
|
258 |
+
* * `minttl`
|
259 |
+
*
|
260 |
+
* ```js
|
261 |
+
* {
|
262 |
+
* nsname: 'ns.example.com',
|
263 |
+
* hostmaster: 'root.example.com',
|
264 |
+
* serial: 2013101809,
|
265 |
+
* refresh: 10000,
|
266 |
+
* retry: 2400,
|
267 |
+
* expire: 604800,
|
268 |
+
* minttl: 3600
|
269 |
+
* }
|
270 |
+
* ```
|
271 |
+
* @since v10.6.0
|
272 |
+
*/
|
273 |
+
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
274 |
+
/**
|
275 |
+
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
|
276 |
+
* the following properties:
|
277 |
+
*
|
278 |
+
* * `priority`
|
279 |
+
* * `weight`
|
280 |
+
* * `port`
|
281 |
+
* * `name`
|
282 |
+
*
|
283 |
+
* ```js
|
284 |
+
* {
|
285 |
+
* priority: 10,
|
286 |
+
* weight: 5,
|
287 |
+
* port: 21223,
|
288 |
+
* name: 'service.example.com'
|
289 |
+
* }
|
290 |
+
* ```
|
291 |
+
* @since v10.6.0
|
292 |
+
*/
|
293 |
+
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
294 |
+
/**
|
295 |
+
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
296 |
+
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
297 |
+
* one record. Depending on the use case, these could be either joined together or
|
298 |
+
* treated separately.
|
299 |
+
* @since v10.6.0
|
300 |
+
*/
|
301 |
+
function resolveTxt(hostname: string): Promise<string[][]>;
|
302 |
+
/**
|
303 |
+
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
304 |
+
* array of host names.
|
305 |
+
*
|
306 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
307 |
+
* @since v10.6.0
|
308 |
+
*/
|
309 |
+
function reverse(ip: string): Promise<string[]>;
|
310 |
+
/**
|
311 |
+
* Get the default value for `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
312 |
+
*
|
313 |
+
* * `ipv4first`: for `verbatim` defaulting to `false`.
|
314 |
+
* * `verbatim`: for `verbatim` defaulting to `true`.
|
315 |
+
* @since v20.1.0
|
316 |
+
*/
|
317 |
+
function getDefaultResultOrder(): "ipv4first" | "verbatim";
|
318 |
+
/**
|
319 |
+
* Sets the IP address and port of servers to be used when performing DNS
|
320 |
+
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
321 |
+
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
322 |
+
*
|
323 |
+
* ```js
|
324 |
+
* dnsPromises.setServers([
|
325 |
+
* '4.4.4.4',
|
326 |
+
* '[2001:4860:4860::8888]',
|
327 |
+
* '4.4.4.4:1053',
|
328 |
+
* '[2001:4860:4860::8888]:1053',
|
329 |
+
* ]);
|
330 |
+
* ```
|
331 |
+
*
|
332 |
+
* An error will be thrown if an invalid address is provided.
|
333 |
+
*
|
334 |
+
* The `dnsPromises.setServers()` method must not be called while a DNS query is in
|
335 |
+
* progress.
|
336 |
+
*
|
337 |
+
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
338 |
+
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
339 |
+
* subsequent servers provided. Fallback DNS servers will only be used if the
|
340 |
+
* earlier ones time out or result in some other error.
|
341 |
+
* @since v10.6.0
|
342 |
+
* @param servers array of `RFC 5952` formatted addresses
|
343 |
+
*/
|
344 |
+
function setServers(servers: readonly string[]): void;
|
345 |
+
/**
|
346 |
+
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
347 |
+
*
|
348 |
+
* * `ipv4first`: sets default `verbatim` `false`.
|
349 |
+
* * `verbatim`: sets default `verbatim` `true`.
|
350 |
+
*
|
351 |
+
* The default is `verbatim` and `dnsPromises.setDefaultResultOrder()` have
|
352 |
+
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the
|
353 |
+
* default dns orders in workers.
|
354 |
+
* @since v16.4.0, v14.18.0
|
355 |
+
* @param order must be `'ipv4first'` or `'verbatim'`.
|
356 |
+
*/
|
357 |
+
function setDefaultResultOrder(order: "ipv4first" | "verbatim"): void;
|
358 |
+
/**
|
359 |
+
* An independent resolver for DNS requests.
|
360 |
+
*
|
361 |
+
* Creating a new resolver uses the default server settings. Setting
|
362 |
+
* the servers used for a resolver using `resolver.setServers()` does not affect
|
363 |
+
* other resolvers:
|
364 |
+
*
|
365 |
+
* ```js
|
366 |
+
* const { Resolver } = require('node:dns').promises;
|
367 |
+
* const resolver = new Resolver();
|
368 |
+
* resolver.setServers(['4.4.4.4']);
|
369 |
+
*
|
370 |
+
* // This request will use the server at 4.4.4.4, independent of global settings.
|
371 |
+
* resolver.resolve4('example.org').then((addresses) => {
|
372 |
+
* // ...
|
373 |
+
* });
|
374 |
+
*
|
375 |
+
* // Alternatively, the same code can be written using async-await style.
|
376 |
+
* (async function() {
|
377 |
+
* const addresses = await resolver.resolve4('example.org');
|
378 |
+
* })();
|
379 |
+
* ```
|
380 |
+
*
|
381 |
+
* The following methods from the `dnsPromises` API are available:
|
382 |
+
*
|
383 |
+
* * `resolver.getServers()`
|
384 |
+
* * `resolver.resolve()`
|
385 |
+
* * `resolver.resolve4()`
|
386 |
+
* * `resolver.resolve6()`
|
387 |
+
* * `resolver.resolveAny()`
|
388 |
+
* * `resolver.resolveCaa()`
|
389 |
+
* * `resolver.resolveCname()`
|
390 |
+
* * `resolver.resolveMx()`
|
391 |
+
* * `resolver.resolveNaptr()`
|
392 |
+
* * `resolver.resolveNs()`
|
393 |
+
* * `resolver.resolvePtr()`
|
394 |
+
* * `resolver.resolveSoa()`
|
395 |
+
* * `resolver.resolveSrv()`
|
396 |
+
* * `resolver.resolveTxt()`
|
397 |
+
* * `resolver.reverse()`
|
398 |
+
* * `resolver.setServers()`
|
399 |
+
* @since v10.6.0
|
400 |
+
*/
|
401 |
+
class Resolver {
|
402 |
+
constructor(options?: ResolverOptions);
|
403 |
+
cancel(): void;
|
404 |
+
getServers: typeof getServers;
|
405 |
+
resolve: typeof resolve;
|
406 |
+
resolve4: typeof resolve4;
|
407 |
+
resolve6: typeof resolve6;
|
408 |
+
resolveAny: typeof resolveAny;
|
409 |
+
resolveCaa: typeof resolveCaa;
|
410 |
+
resolveCname: typeof resolveCname;
|
411 |
+
resolveMx: typeof resolveMx;
|
412 |
+
resolveNaptr: typeof resolveNaptr;
|
413 |
+
resolveNs: typeof resolveNs;
|
414 |
+
resolvePtr: typeof resolvePtr;
|
415 |
+
resolveSoa: typeof resolveSoa;
|
416 |
+
resolveSrv: typeof resolveSrv;
|
417 |
+
resolveTxt: typeof resolveTxt;
|
418 |
+
reverse: typeof reverse;
|
419 |
+
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
420 |
+
setServers: typeof setServers;
|
421 |
+
}
|
422 |
+
}
|
423 |
+
declare module "node:dns/promises" {
|
424 |
+
export * from "dns/promises";
|
425 |
+
}
|