mirror of
https://gitlab.com/octtspacc/sitoctt
synced 2025-02-14 02:20:40 +01:00
.
This commit is contained in:
commit
eefa5f22b9
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
1
node_modules/.bin/acorn
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../acorn/bin/acorn
|
1
node_modules/.bin/escodegen
generated
vendored
Symbolic link
1
node_modules/.bin/escodegen
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../escodegen/bin/escodegen.js
|
1
node_modules/.bin/esgenerate
generated
vendored
Symbolic link
1
node_modules/.bin/esgenerate
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../escodegen/bin/esgenerate.js
|
1
node_modules/.bin/esparse
generated
vendored
Symbolic link
1
node_modules/.bin/esparse
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esparse.js
|
1
node_modules/.bin/esvalidate
generated
vendored
Symbolic link
1
node_modules/.bin/esvalidate
generated
vendored
Symbolic link
@ -0,0 +1 @@
|
||||
../esprima/bin/esvalidate.js
|
601
node_modules/.package-lock.json
generated
vendored
Normal file
601
node_modules/.package-lock.json
generated
vendored
Normal file
@ -0,0 +1,601 @@
|
||||
{
|
||||
"name": "Scripts",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
||||
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/abab": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.6.tgz",
|
||||
"integrity": "sha512-j2afSsaIENvHZN2B8GOpF566vZ5WVk5opAiMTvWgaQT8DkbOqsTfvNAvHoRGU2zzP8cPoqys+xHTRDWW8L+/BA=="
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.8.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-globals": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-7.0.1.tgz",
|
||||
"integrity": "sha512-umOSDSDrfHbTNPuNpC2NSnnA3LUrqpevPb4T9jRx4MagXNS0rs+gwiTcAvqCRmsD6utzsrzNt+ebm00SNWiC3Q==",
|
||||
"dependencies": {
|
||||
"acorn": "^8.1.0",
|
||||
"acorn-walk": "^8.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn-walk": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
|
||||
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agent-base": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
|
||||
"integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
|
||||
"dependencies": {
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/cssom": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.5.0.tgz",
|
||||
"integrity": "sha512-iKuQcq+NdHqlAcwUY0o/HL69XQrUaQdMjmStJ8JFmUaiiQErlhrmuigkg/CU4E2J0IyUKUrMAgl36TvN67MqTw=="
|
||||
},
|
||||
"node_modules/cssstyle": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz",
|
||||
"integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==",
|
||||
"dependencies": {
|
||||
"cssom": "~0.3.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/cssstyle/node_modules/cssom": {
|
||||
"version": "0.3.8",
|
||||
"resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz",
|
||||
"integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg=="
|
||||
},
|
||||
"node_modules/data-urls": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/data-urls/-/data-urls-3.0.2.tgz",
|
||||
"integrity": "sha512-Jy/tj3ldjZJo63sVAvg6LHt2mHvl4V6AgRAmNDtLdm7faqtsx+aJG42rsyCo9JCoRVKwPFzKlIPx3DIibwSIaQ==",
|
||||
"dependencies": {
|
||||
"abab": "^2.0.6",
|
||||
"whatwg-mimetype": "^3.0.0",
|
||||
"whatwg-url": "^11.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/decimal.js": {
|
||||
"version": "10.4.3",
|
||||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.4.3.tgz",
|
||||
"integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
|
||||
},
|
||||
"node_modules/deep-is": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
|
||||
"integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ=="
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/domexception": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/domexception/-/domexception-4.0.0.tgz",
|
||||
"integrity": "sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==",
|
||||
"dependencies": {
|
||||
"webidl-conversions": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/entities/-/entities-4.4.0.tgz",
|
||||
"integrity": "sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/escodegen": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz",
|
||||
"integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==",
|
||||
"dependencies": {
|
||||
"esprima": "^4.0.1",
|
||||
"estraverse": "^5.2.0",
|
||||
"esutils": "^2.0.2",
|
||||
"optionator": "^0.8.1"
|
||||
},
|
||||
"bin": {
|
||||
"escodegen": "bin/escodegen.js",
|
||||
"esgenerate": "bin/esgenerate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/estraverse": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-levenshtein": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
||||
"integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw=="
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
|
||||
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/html-encoding-sniffer": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
|
||||
"integrity": "sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==",
|
||||
"dependencies": {
|
||||
"whatwg-encoding": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/http-proxy-agent": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-5.0.0.tgz",
|
||||
"integrity": "sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==",
|
||||
"dependencies": {
|
||||
"@tootallnate/once": "2",
|
||||
"agent-base": "6",
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/https-proxy-agent": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
|
||||
"integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
|
||||
"dependencies": {
|
||||
"agent-base": "6",
|
||||
"debug": "4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-potential-custom-element-name": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
|
||||
"integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ=="
|
||||
},
|
||||
"node_modules/jsdom": {
|
||||
"version": "20.0.3",
|
||||
"resolved": "https://registry.npmjs.org/jsdom/-/jsdom-20.0.3.tgz",
|
||||
"integrity": "sha512-SYhBvTh89tTfCD/CRdSOm13mOBa42iTaTyfyEWBdKcGdPxPtLFBXuHR8XHb33YNYaP+lLbmSvBTsnoesCNJEsQ==",
|
||||
"dependencies": {
|
||||
"abab": "^2.0.6",
|
||||
"acorn": "^8.8.1",
|
||||
"acorn-globals": "^7.0.0",
|
||||
"cssom": "^0.5.0",
|
||||
"cssstyle": "^2.3.0",
|
||||
"data-urls": "^3.0.2",
|
||||
"decimal.js": "^10.4.2",
|
||||
"domexception": "^4.0.0",
|
||||
"escodegen": "^2.0.0",
|
||||
"form-data": "^4.0.0",
|
||||
"html-encoding-sniffer": "^3.0.0",
|
||||
"http-proxy-agent": "^5.0.0",
|
||||
"https-proxy-agent": "^5.0.1",
|
||||
"is-potential-custom-element-name": "^1.0.1",
|
||||
"nwsapi": "^2.2.2",
|
||||
"parse5": "^7.1.1",
|
||||
"saxes": "^6.0.0",
|
||||
"symbol-tree": "^3.2.4",
|
||||
"tough-cookie": "^4.1.2",
|
||||
"w3c-xmlserializer": "^4.0.0",
|
||||
"webidl-conversions": "^7.0.0",
|
||||
"whatwg-encoding": "^2.0.0",
|
||||
"whatwg-mimetype": "^3.0.0",
|
||||
"whatwg-url": "^11.0.0",
|
||||
"ws": "^8.11.0",
|
||||
"xml-name-validator": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"canvas": "^2.5.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"canvas": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/levn": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
|
||||
"integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==",
|
||||
"dependencies": {
|
||||
"prelude-ls": "~1.1.2",
|
||||
"type-check": "~0.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/nwsapi": {
|
||||
"version": "2.2.2",
|
||||
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.2.tgz",
|
||||
"integrity": "sha512-90yv+6538zuvUMnN+zCr8LuV6bPFdq50304114vJYJ8RDyK8D5O9Phpbd6SZWgI7PwzmmfN1upeOJlvybDSgCw=="
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.8.3",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
|
||||
"integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==",
|
||||
"dependencies": {
|
||||
"deep-is": "~0.1.3",
|
||||
"fast-levenshtein": "~2.0.6",
|
||||
"levn": "~0.3.0",
|
||||
"prelude-ls": "~1.1.2",
|
||||
"type-check": "~0.3.2",
|
||||
"word-wrap": "~1.2.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/parse5": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz",
|
||||
"integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==",
|
||||
"dependencies": {
|
||||
"entities": "^4.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/inikulin/parse5?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/prelude-ls": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
||||
"integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==",
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/psl": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
|
||||
"integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="
|
||||
},
|
||||
"node_modules/punycode": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
|
||||
"integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/querystringify": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
|
||||
"integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
|
||||
},
|
||||
"node_modules/requires-port": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||
},
|
||||
"node_modules/saxes": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",
|
||||
"integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",
|
||||
"dependencies": {
|
||||
"xmlchars": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=v12.22.7"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/symbol-tree": {
|
||||
"version": "3.2.4",
|
||||
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
|
||||
"integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw=="
|
||||
},
|
||||
"node_modules/tough-cookie": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.2.tgz",
|
||||
"integrity": "sha512-G9fqXWoYFZgTc2z8Q5zaHy/vJMjm+WV0AkAeHxVCQiEB1b+dGvWzFW6QV07cY5jQ5gRkeid2qIkzkxUnmoQZUQ==",
|
||||
"dependencies": {
|
||||
"psl": "^1.1.33",
|
||||
"punycode": "^2.1.1",
|
||||
"universalify": "^0.2.0",
|
||||
"url-parse": "^1.5.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/tr46": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
|
||||
"integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
|
||||
"dependencies": {
|
||||
"punycode": "^2.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/type-check": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
"integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==",
|
||||
"dependencies": {
|
||||
"prelude-ls": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
|
||||
"integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/url-parse": {
|
||||
"version": "1.5.10",
|
||||
"resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
|
||||
"integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
|
||||
"dependencies": {
|
||||
"querystringify": "^2.1.1",
|
||||
"requires-port": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/w3c-xmlserializer": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-4.0.0.tgz",
|
||||
"integrity": "sha512-d+BFHzbiCx6zGfz0HyQ6Rg69w9k19nviJspaj4yNscGjrHu94sVP+aRm75yEbCh+r2/yR+7q6hux9LVtbuTGBw==",
|
||||
"dependencies": {
|
||||
"xml-name-validator": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/webidl-conversions": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
||||
"integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-encoding": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-2.0.0.tgz",
|
||||
"integrity": "sha512-p41ogyeMUrw3jWclHWTQg1k05DSVXPLcVxRTYsXUk+ZooOCZLcoYgPZ/HL/D/N+uQPOtcp1me1WhBEaX02mhWg==",
|
||||
"dependencies": {
|
||||
"iconv-lite": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-mimetype": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-3.0.0.tgz",
|
||||
"integrity": "sha512-nt+N2dzIutVRxARx1nghPKGv1xHikU7HKdfafKkLNLindmPU/ch3U31NOCGGA/dmPcmb1VlofO0vnKAcsm0o/Q==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/whatwg-url": {
|
||||
"version": "11.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz",
|
||||
"integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==",
|
||||
"dependencies": {
|
||||
"tr46": "^3.0.0",
|
||||
"webidl-conversions": "^7.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/word-wrap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.11.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
|
||||
"integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": "^5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xml-name-validator": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-4.0.0.tgz",
|
||||
"integrity": "sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/xmlchars": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",
|
||||
"integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw=="
|
||||
}
|
||||
}
|
||||
}
|
21
node_modules/@tootallnate/once/LICENSE
generated
vendored
Normal file
21
node_modules/@tootallnate/once/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Nathan Rajlich
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
93
node_modules/@tootallnate/once/README.md
generated
vendored
Normal file
93
node_modules/@tootallnate/once/README.md
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
# @tootallnate/once
|
||||
|
||||
### Creates a Promise that waits for a single event
|
||||
|
||||
## Installation
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
```bash
|
||||
$ npm install @tootallnate/once
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### once(emitter: EventEmitter, name: string, opts?: OnceOptions): Promise<[...Args]>
|
||||
|
||||
Creates a Promise that waits for event `name` to occur on `emitter`, and resolves
|
||||
the promise with an array of the values provided to the event handler. If an
|
||||
`error` event occurs before the event specified by `name`, then the Promise is
|
||||
rejected with the error argument.
|
||||
|
||||
```typescript
|
||||
import once from '@tootallnate/once';
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
const emitter = new EventEmitter();
|
||||
|
||||
setTimeout(() => {
|
||||
emitter.emit('foo', 'bar');
|
||||
}, 100);
|
||||
|
||||
const [result] = await once(emitter, 'foo');
|
||||
console.log({ result });
|
||||
// { result: 'bar' }
|
||||
```
|
||||
|
||||
#### Promise Strong Typing
|
||||
|
||||
The main feature that this module provides over other "once" implementations is that
|
||||
the Promise that is returned is _**strongly typed**_ based on the type of `emitter`
|
||||
and the `name` of the event. Some examples are shown below.
|
||||
|
||||
_The process "exit" event contains a single number for exit code:_
|
||||
|
||||
```typescript
|
||||
const [code] = await once(process, 'exit');
|
||||
// ^ number
|
||||
```
|
||||
_A child process "exit" event contains either an exit code or a signal:_
|
||||
|
||||
```typescript
|
||||
const child = spawn('echo', []);
|
||||
const [code, signal] = await once(child, 'exit');
|
||||
// ^ number | null
|
||||
// ^ string | null
|
||||
```
|
||||
|
||||
_A forked child process "message" event is type `any`, so you can cast the Promise directly:_
|
||||
|
||||
```typescript
|
||||
const child = fork('file.js');
|
||||
|
||||
// With `await`
|
||||
const [message, _]: [WorkerPayload, unknown] = await once(child, 'message');
|
||||
|
||||
// With Promise
|
||||
const messagePromise: Promise<[WorkerPayload, unknown]> = once(child, 'message');
|
||||
|
||||
// Better yet would be to leave it as `any`, and validate the payload
|
||||
// at runtime with i.e. `ajv` + `json-schema-to-typescript`
|
||||
```
|
||||
|
||||
_If the TypeScript definition does not contain an overload for the specified event name, then the Promise will have type `unknown[]` and your code will need to narrow the result manually:_
|
||||
|
||||
```typescript
|
||||
interface CustomEmitter extends EventEmitter {
|
||||
on(name: 'foo', listener: (a: string, b: number) => void): this;
|
||||
}
|
||||
|
||||
const emitter: CustomEmitter = new EventEmitter();
|
||||
|
||||
// "foo" event is a defined overload, so it's properly typed
|
||||
const fooPromise = once(emitter, 'foo');
|
||||
// ^ Promise<[a: string, b: number]>
|
||||
|
||||
// "bar" event in not a defined overload, so it gets `unknown[]`
|
||||
const barPromise = once(emitter, 'bar');
|
||||
// ^ Promise<unknown[]>
|
||||
```
|
||||
|
||||
### OnceOptions
|
||||
|
||||
- `signal` - `AbortSignal` instance to unbind event handlers before the Promise has been fulfilled.
|
7
node_modules/@tootallnate/once/dist/index.d.ts
generated
vendored
Normal file
7
node_modules/@tootallnate/once/dist/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { EventNames, EventListenerParameters, AbortSignal } from './types';
|
||||
export interface OnceOptions {
|
||||
signal?: AbortSignal;
|
||||
}
|
||||
export default function once<Emitter extends EventEmitter, Event extends EventNames<Emitter>>(emitter: Emitter, name: Event, { signal }?: OnceOptions): Promise<EventListenerParameters<Emitter, Event>>;
|
24
node_modules/@tootallnate/once/dist/index.js
generated
vendored
Normal file
24
node_modules/@tootallnate/once/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function once(emitter, name, { signal } = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
function cleanup() {
|
||||
signal === null || signal === void 0 ? void 0 : signal.removeEventListener('abort', cleanup);
|
||||
emitter.removeListener(name, onEvent);
|
||||
emitter.removeListener('error', onError);
|
||||
}
|
||||
function onEvent(...args) {
|
||||
cleanup();
|
||||
resolve(args);
|
||||
}
|
||||
function onError(err) {
|
||||
cleanup();
|
||||
reject(err);
|
||||
}
|
||||
signal === null || signal === void 0 ? void 0 : signal.addEventListener('abort', cleanup);
|
||||
emitter.on(name, onEvent);
|
||||
emitter.on('error', onError);
|
||||
});
|
||||
}
|
||||
exports.default = once;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/@tootallnate/once/dist/index.js.map
generated
vendored
Normal file
1
node_modules/@tootallnate/once/dist/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAOA,SAAwB,IAAI,CAI3B,OAAgB,EAChB,IAAW,EACX,EAAE,MAAM,KAAkB,EAAE;IAE5B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtC,SAAS,OAAO;YACf,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACtC,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,SAAS,OAAO,CAAC,GAAG,IAAW;YAC9B,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,IAA+C,CAAC,CAAC;QAC1D,CAAC;QACD,SAAS,OAAO,CAAC,GAAU;YAC1B,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,CAAC,CAAC;QACb,CAAC;QACD,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1B,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;AACJ,CAAC;AA1BD,uBA0BC"}
|
231
node_modules/@tootallnate/once/dist/overloaded-parameters.d.ts
generated
vendored
Normal file
231
node_modules/@tootallnate/once/dist/overloaded-parameters.d.ts
generated
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
export declare type OverloadedParameters<T> = T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
(...args: infer A16): any;
|
||||
(...args: infer A17): any;
|
||||
(...args: infer A18): any;
|
||||
(...args: infer A19): any;
|
||||
(...args: infer A20): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | A20 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
(...args: infer A16): any;
|
||||
(...args: infer A17): any;
|
||||
(...args: infer A18): any;
|
||||
(...args: infer A19): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
(...args: infer A16): any;
|
||||
(...args: infer A17): any;
|
||||
(...args: infer A18): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 | A18 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
(...args: infer A16): any;
|
||||
(...args: infer A17): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 | A17 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
(...args: infer A16): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 | A16 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
(...args: infer A15): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 | A15 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
(...args: infer A14): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 | A14 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
(...args: infer A13): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 | A13 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
(...args: infer A12): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 | A12 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
(...args: infer A11): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 | A11 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
(...args: infer A10): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 | A10 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
(...args: infer A9): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 | A9 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
(...args: infer A8): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 | A8 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
(...args: infer A7): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 | A7 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
(...args: infer A6): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 | A6 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
(...args: infer A5): any;
|
||||
} ? A1 | A2 | A3 | A4 | A5 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
(...args: infer A4): any;
|
||||
} ? A1 | A2 | A3 | A4 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
(...args: infer A3): any;
|
||||
} ? A1 | A2 | A3 : T extends {
|
||||
(...args: infer A1): any;
|
||||
(...args: infer A2): any;
|
||||
} ? A1 | A2 : T extends {
|
||||
(...args: infer A1): any;
|
||||
} ? A1 : any;
|
3
node_modules/@tootallnate/once/dist/overloaded-parameters.js
generated
vendored
Normal file
3
node_modules/@tootallnate/once/dist/overloaded-parameters.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=overloaded-parameters.js.map
|
1
node_modules/@tootallnate/once/dist/overloaded-parameters.js.map
generated
vendored
Normal file
1
node_modules/@tootallnate/once/dist/overloaded-parameters.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"overloaded-parameters.js","sourceRoot":"","sources":["../src/overloaded-parameters.ts"],"names":[],"mappings":""}
|
17
node_modules/@tootallnate/once/dist/types.d.ts
generated
vendored
Normal file
17
node_modules/@tootallnate/once/dist/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { OverloadedParameters } from './overloaded-parameters';
|
||||
export declare type FirstParameter<T> = T extends [infer R, ...any[]] ? R : never;
|
||||
export declare type EventListener<F, T extends string | symbol> = F extends [
|
||||
T,
|
||||
infer R,
|
||||
...any[]
|
||||
] ? R : never;
|
||||
export declare type EventParameters<Emitter extends EventEmitter> = OverloadedParameters<Emitter['on']>;
|
||||
export declare type EventNames<Emitter extends EventEmitter> = FirstParameter<EventParameters<Emitter>>;
|
||||
export declare type EventListenerParameters<Emitter extends EventEmitter, Event extends EventNames<Emitter>> = WithDefault<Parameters<EventListener<EventParameters<Emitter>, Event>>, unknown[]>;
|
||||
export declare type WithDefault<T, D> = [T] extends [never] ? D : T;
|
||||
export interface AbortSignal {
|
||||
addEventListener: (name: string, listener: (...args: any[]) => any) => void;
|
||||
removeEventListener: (name: string, listener: (...args: any[]) => any) => void;
|
||||
}
|
3
node_modules/@tootallnate/once/dist/types.js
generated
vendored
Normal file
3
node_modules/@tootallnate/once/dist/types.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=types.js.map
|
1
node_modules/@tootallnate/once/dist/types.js.map
generated
vendored
Normal file
1
node_modules/@tootallnate/once/dist/types.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
52
node_modules/@tootallnate/once/package.json
generated
vendored
Normal file
52
node_modules/@tootallnate/once/package.json
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "@tootallnate/once",
|
||||
"version": "2.0.0",
|
||||
"description": "Creates a Promise that waits for a single event",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "tsc",
|
||||
"test": "jest",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/once.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/once/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/node": "^12.12.11",
|
||||
"abort-controller": "^3.0.0",
|
||||
"jest": "^27.2.1",
|
||||
"rimraf": "^3.0.0",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "ts-jest",
|
||||
"globals": {
|
||||
"ts-jest": {
|
||||
"diagnostics": false,
|
||||
"isolatedModules": true
|
||||
}
|
||||
},
|
||||
"verbose": false,
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"<rootDir>/test/**/*.test.ts"
|
||||
]
|
||||
}
|
||||
}
|
13
node_modules/abab/LICENSE.md
generated
vendored
Normal file
13
node_modules/abab/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
Copyright © 2019 W3C and Jeff Carpenter \<jeffcarp@chromium.org\>
|
||||
|
||||
Both the original source code and new contributions in this repository are released under the [3-Clause BSD license](https://opensource.org/licenses/BSD-3-Clause).
|
||||
|
||||
# The 3-Clause BSD License
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
51
node_modules/abab/README.md
generated
vendored
Normal file
51
node_modules/abab/README.md
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
# abab [![npm version](https://badge.fury.io/js/abab.svg)](https://www.npmjs.com/package/abab) [![Build Status](https://travis-ci.org/jsdom/abab.svg?branch=master)](https://travis-ci.org/jsdom/abab)
|
||||
|
||||
A JavaScript module that implements `window.atob` and `window.btoa` according the forgiving-base64 algorithm in the [Infra Standard](https://infra.spec.whatwg.org/#forgiving-base64). The original code was forked from [w3c/web-platform-tests](https://github.com/w3c/web-platform-tests/blob/master/html/webappapis/atob/base64.html).
|
||||
|
||||
Compatibility: Node.js version 3+ and all major browsers.
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
```sh
|
||||
npm install abab
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `btoa` (base64 encode)
|
||||
|
||||
```js
|
||||
const { btoa } = require('abab');
|
||||
btoa('Hello, world!'); // 'SGVsbG8sIHdvcmxkIQ=='
|
||||
```
|
||||
|
||||
### `atob` (base64 decode)
|
||||
|
||||
```js
|
||||
const { atob } = require('abab');
|
||||
atob('SGVsbG8sIHdvcmxkIQ=='); // 'Hello, world!'
|
||||
```
|
||||
|
||||
#### Valid characters
|
||||
|
||||
[Per the spec](https://html.spec.whatwg.org/multipage/webappapis.html#atob:dom-windowbase64-btoa-3), `btoa` will accept strings "containing only characters in the range `U+0000` to `U+00FF`." If passed a string with characters above `U+00FF`, `btoa` will return `null`. If `atob` is passed a string that is not base64-valid, it will also return `null`. In both cases when `null` is returned, the spec calls for throwing a `DOMException` of type `InvalidCharacterError`.
|
||||
|
||||
## Browsers
|
||||
|
||||
If you want to include just one of the methods to save bytes in your client-side code, you can `require` the desired module directly.
|
||||
|
||||
```js
|
||||
const atob = require('abab/lib/atob');
|
||||
const btoa = require('abab/lib/btoa');
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
If you're **submitting a PR** or **deploying to npm**, please use the [checklists in CONTRIBUTING.md](CONTRIBUTING.md#checklists).
|
||||
|
||||
## Remembering what `atob` and `btoa` stand for
|
||||
|
||||
Base64 comes from IETF [RFC 4648](https://tools.ietf.org/html/rfc4648#section-4) (2006).
|
||||
|
||||
- **`btoa`**, the encoder function, stands for **binary** to **ASCII**, meaning it converts any binary input into a subset of **ASCII** (Base64).
|
||||
- **`atob`**, the decoder function, converts **ASCII** (or Base64) to its original **binary** format.
|
2
node_modules/abab/index.d.ts
generated
vendored
Normal file
2
node_modules/abab/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export function atob(encodedData: string): string | null
|
||||
export function btoa(stringToEncode: string): string | null
|
9
node_modules/abab/index.js
generated
vendored
Normal file
9
node_modules/abab/index.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
const atob = require("./lib/atob");
|
||||
const btoa = require("./lib/btoa");
|
||||
|
||||
module.exports = {
|
||||
atob,
|
||||
btoa
|
||||
};
|
101
node_modules/abab/lib/atob.js
generated
vendored
Normal file
101
node_modules/abab/lib/atob.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Implementation of atob() according to the HTML and Infra specs, except that
|
||||
* instead of throwing INVALID_CHARACTER_ERR we return null.
|
||||
*/
|
||||
function atob(data) {
|
||||
if (arguments.length === 0) {
|
||||
throw new TypeError("1 argument required, but only 0 present.");
|
||||
}
|
||||
|
||||
// Web IDL requires DOMStrings to just be converted using ECMAScript
|
||||
// ToString, which in our case amounts to using a template literal.
|
||||
data = `${data}`;
|
||||
// "Remove all ASCII whitespace from data."
|
||||
data = data.replace(/[ \t\n\f\r]/g, "");
|
||||
// "If data's length divides by 4 leaving no remainder, then: if data ends
|
||||
// with one or two U+003D (=) code points, then remove them from data."
|
||||
if (data.length % 4 === 0) {
|
||||
data = data.replace(/==?$/, "");
|
||||
}
|
||||
// "If data's length divides by 4 leaving a remainder of 1, then return
|
||||
// failure."
|
||||
//
|
||||
// "If data contains a code point that is not one of
|
||||
//
|
||||
// U+002B (+)
|
||||
// U+002F (/)
|
||||
// ASCII alphanumeric
|
||||
//
|
||||
// then return failure."
|
||||
if (data.length % 4 === 1 || /[^+/0-9A-Za-z]/.test(data)) {
|
||||
return null;
|
||||
}
|
||||
// "Let output be an empty byte sequence."
|
||||
let output = "";
|
||||
// "Let buffer be an empty buffer that can have bits appended to it."
|
||||
//
|
||||
// We append bits via left-shift and or. accumulatedBits is used to track
|
||||
// when we've gotten to 24 bits.
|
||||
let buffer = 0;
|
||||
let accumulatedBits = 0;
|
||||
// "Let position be a position variable for data, initially pointing at the
|
||||
// start of data."
|
||||
//
|
||||
// "While position does not point past the end of data:"
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
// "Find the code point pointed to by position in the second column of
|
||||
// Table 1: The Base 64 Alphabet of RFC 4648. Let n be the number given in
|
||||
// the first cell of the same row.
|
||||
//
|
||||
// "Append to buffer the six bits corresponding to n, most significant bit
|
||||
// first."
|
||||
//
|
||||
// atobLookup() implements the table from RFC 4648.
|
||||
buffer <<= 6;
|
||||
buffer |= atobLookup(data[i]);
|
||||
accumulatedBits += 6;
|
||||
// "If buffer has accumulated 24 bits, interpret them as three 8-bit
|
||||
// big-endian numbers. Append three bytes with values equal to those
|
||||
// numbers to output, in the same order, and then empty buffer."
|
||||
if (accumulatedBits === 24) {
|
||||
output += String.fromCharCode((buffer & 0xff0000) >> 16);
|
||||
output += String.fromCharCode((buffer & 0xff00) >> 8);
|
||||
output += String.fromCharCode(buffer & 0xff);
|
||||
buffer = accumulatedBits = 0;
|
||||
}
|
||||
// "Advance position by 1."
|
||||
}
|
||||
// "If buffer is not empty, it contains either 12 or 18 bits. If it contains
|
||||
// 12 bits, then discard the last four and interpret the remaining eight as
|
||||
// an 8-bit big-endian number. If it contains 18 bits, then discard the last
|
||||
// two and interpret the remaining 16 as two 8-bit big-endian numbers. Append
|
||||
// the one or two bytes with values equal to those one or two numbers to
|
||||
// output, in the same order."
|
||||
if (accumulatedBits === 12) {
|
||||
buffer >>= 4;
|
||||
output += String.fromCharCode(buffer);
|
||||
} else if (accumulatedBits === 18) {
|
||||
buffer >>= 2;
|
||||
output += String.fromCharCode((buffer & 0xff00) >> 8);
|
||||
output += String.fromCharCode(buffer & 0xff);
|
||||
}
|
||||
// "Return output."
|
||||
return output;
|
||||
}
|
||||
/**
|
||||
* A lookup table for atob(), which converts an ASCII character to the
|
||||
* corresponding six-bit number.
|
||||
*/
|
||||
|
||||
const keystr =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
function atobLookup(chr) {
|
||||
const index = keystr.indexOf(chr);
|
||||
// Throw exception if character is not in the lookup string; should not be hit in tests
|
||||
return index < 0 ? undefined : index;
|
||||
}
|
||||
|
||||
module.exports = atob;
|
62
node_modules/abab/lib/btoa.js
generated
vendored
Normal file
62
node_modules/abab/lib/btoa.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* btoa() as defined by the HTML and Infra specs, which mostly just references
|
||||
* RFC 4648.
|
||||
*/
|
||||
function btoa(s) {
|
||||
if (arguments.length === 0) {
|
||||
throw new TypeError("1 argument required, but only 0 present.");
|
||||
}
|
||||
|
||||
let i;
|
||||
// String conversion as required by Web IDL.
|
||||
s = `${s}`;
|
||||
// "The btoa() method must throw an "InvalidCharacterError" DOMException if
|
||||
// data contains any character whose code point is greater than U+00FF."
|
||||
for (i = 0; i < s.length; i++) {
|
||||
if (s.charCodeAt(i) > 255) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
let out = "";
|
||||
for (i = 0; i < s.length; i += 3) {
|
||||
const groupsOfSix = [undefined, undefined, undefined, undefined];
|
||||
groupsOfSix[0] = s.charCodeAt(i) >> 2;
|
||||
groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4;
|
||||
if (s.length > i + 1) {
|
||||
groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4;
|
||||
groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2;
|
||||
}
|
||||
if (s.length > i + 2) {
|
||||
groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6;
|
||||
groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f;
|
||||
}
|
||||
for (let j = 0; j < groupsOfSix.length; j++) {
|
||||
if (typeof groupsOfSix[j] === "undefined") {
|
||||
out += "=";
|
||||
} else {
|
||||
out += btoaLookup(groupsOfSix[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup table for btoa(), which converts a six-bit number into the
|
||||
* corresponding ASCII character.
|
||||
*/
|
||||
const keystr =
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
function btoaLookup(index) {
|
||||
if (index >= 0 && index < 64) {
|
||||
return keystr[index];
|
||||
}
|
||||
|
||||
// Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
module.exports = btoa;
|
42
node_modules/abab/package.json
generated
vendored
Normal file
42
node_modules/abab/package.json
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "abab",
|
||||
"version": "2.0.6",
|
||||
"description": "WHATWG spec-compliant implementations of window.atob and window.btoa.",
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"mocha": "mocha test/node",
|
||||
"karma": "karma start",
|
||||
"test": "npm run lint && npm run mocha && npm run karma",
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jsdom/abab.git"
|
||||
},
|
||||
"keywords": [
|
||||
"atob",
|
||||
"btoa",
|
||||
"browser"
|
||||
],
|
||||
"author": "Jeff Carpenter <gcarpenterv@gmail.com>",
|
||||
"license": "BSD-3-Clause",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jsdom/abab/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jsdom/abab#readme",
|
||||
"devDependencies": {
|
||||
"eslint": "^4.19.1",
|
||||
"karma": "^2.0.0",
|
||||
"karma-cli": "^1.0.1",
|
||||
"karma-firefox-launcher": "^1.1.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-webpack": "^3.0.0",
|
||||
"mocha": "^5.1.0",
|
||||
"webpack": "^4.5.0"
|
||||
}
|
||||
}
|
19
node_modules/acorn-globals/LICENSE
generated
vendored
Normal file
19
node_modules/acorn-globals/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Forbes Lindesay
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
81
node_modules/acorn-globals/README.md
generated
vendored
Normal file
81
node_modules/acorn-globals/README.md
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
# acorn-globals
|
||||
|
||||
Detect global variables in JavaScript using acorn
|
||||
|
||||
[Get supported acorn-globals with the Tidelift Subscription](https://tidelift.com/subscription/pkg/npm-acorn_globals?utm_source=npm-acorn-globals&utm_medium=referral&utm_campaign=readme)
|
||||
|
||||
[![Build Status](https://img.shields.io/github/workflow/status/ForbesLindesay/acorn-globals/Publish%20Canary/master?style=for-the-badge)](https://github.com/ForbesLindesay/acorn-globals/actions?query=workflow%3APublish%20Canary+branch%3Amaster)
|
||||
[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen?style=for-the-badge)](https://rollingversions.com/ForbesLindesay/acorn-globals)
|
||||
[![NPM version](https://img.shields.io/npm/v/acorn-globals?style=for-the-badge)](https://www.npmjs.com/package/acorn-globals)
|
||||
|
||||
## Installation
|
||||
|
||||
npm install acorn-globals
|
||||
|
||||
## Usage
|
||||
|
||||
detect.js
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var detect = require('acorn-globals');
|
||||
|
||||
var src = fs.readFileSync(__dirname + '/input.js', 'utf8');
|
||||
|
||||
var scope = detect(src);
|
||||
console.dir(scope);
|
||||
```
|
||||
|
||||
input.js
|
||||
|
||||
```js
|
||||
var x = 5;
|
||||
var y = 3, z = 2;
|
||||
|
||||
w.foo();
|
||||
w = 2;
|
||||
|
||||
RAWR=444;
|
||||
RAWR.foo();
|
||||
|
||||
BLARG=3;
|
||||
|
||||
foo(function () {
|
||||
var BAR = 3;
|
||||
process.nextTick(function (ZZZZZZZZZZZZ) {
|
||||
console.log('beep boop');
|
||||
var xyz = 4;
|
||||
x += 10;
|
||||
x.zzzzzz;
|
||||
ZZZ=6;
|
||||
});
|
||||
function doom () {
|
||||
}
|
||||
ZZZ.foo();
|
||||
|
||||
});
|
||||
|
||||
console.log(xyz);
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
$ node example/detect.js
|
||||
[ { name: 'BLARG', nodes: [ [Object] ] },
|
||||
{ name: 'RAWR', nodes: [ [Object], [Object] ] },
|
||||
{ name: 'ZZZ', nodes: [ [Object], [Object] ] },
|
||||
{ name: 'console', nodes: [ [Object], [Object] ] },
|
||||
{ name: 'foo', nodes: [ [Object] ] },
|
||||
{ name: 'process', nodes: [ [Object] ] },
|
||||
{ name: 'w', nodes: [ [Object], [Object] ] },
|
||||
{ name: 'xyz', nodes: [ [Object] ] } ]
|
||||
```
|
||||
|
||||
## Security contact information
|
||||
|
||||
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
178
node_modules/acorn-globals/index.js
generated
vendored
Normal file
178
node_modules/acorn-globals/index.js
generated
vendored
Normal file
@ -0,0 +1,178 @@
|
||||
'use strict';
|
||||
|
||||
var acorn = require('acorn');
|
||||
var walk = require('acorn-walk');
|
||||
|
||||
function isScope(node) {
|
||||
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration' || node.type === 'ArrowFunctionExpression' || node.type === 'Program';
|
||||
}
|
||||
function isBlockScope(node) {
|
||||
// The body of switch statement is a block.
|
||||
return node.type === 'BlockStatement' || node.type === 'SwitchStatement' || isScope(node);
|
||||
}
|
||||
|
||||
function declaresArguments(node) {
|
||||
return node.type === 'FunctionExpression' || node.type === 'FunctionDeclaration';
|
||||
}
|
||||
|
||||
function reallyParse(source, options) {
|
||||
var parseOptions = Object.assign(
|
||||
{
|
||||
allowReturnOutsideFunction: true,
|
||||
allowImportExportEverywhere: true,
|
||||
allowHashBang: true,
|
||||
ecmaVersion: "latest"
|
||||
},
|
||||
options
|
||||
);
|
||||
return acorn.parse(source, parseOptions);
|
||||
}
|
||||
module.exports = findGlobals;
|
||||
module.exports.parse = reallyParse;
|
||||
function findGlobals(source, options) {
|
||||
options = options || {};
|
||||
var globals = [];
|
||||
var ast;
|
||||
// istanbul ignore else
|
||||
if (typeof source === 'string') {
|
||||
ast = reallyParse(source, options);
|
||||
} else {
|
||||
ast = source;
|
||||
}
|
||||
// istanbul ignore if
|
||||
if (!(ast && typeof ast === 'object' && ast.type === 'Program')) {
|
||||
throw new TypeError('Source must be either a string of JavaScript or an acorn AST');
|
||||
}
|
||||
var declareFunction = function (node) {
|
||||
var fn = node;
|
||||
fn.locals = fn.locals || Object.create(null);
|
||||
node.params.forEach(function (node) {
|
||||
declarePattern(node, fn);
|
||||
});
|
||||
if (node.id) {
|
||||
fn.locals[node.id.name] = true;
|
||||
}
|
||||
};
|
||||
var declareClass = function (node) {
|
||||
node.locals = node.locals || Object.create(null);
|
||||
if (node.id) {
|
||||
node.locals[node.id.name] = true;
|
||||
}
|
||||
};
|
||||
var declarePattern = function (node, parent) {
|
||||
switch (node.type) {
|
||||
case 'Identifier':
|
||||
parent.locals[node.name] = true;
|
||||
break;
|
||||
case 'ObjectPattern':
|
||||
node.properties.forEach(function (node) {
|
||||
declarePattern(node.value || node.argument, parent);
|
||||
});
|
||||
break;
|
||||
case 'ArrayPattern':
|
||||
node.elements.forEach(function (node) {
|
||||
if (node) declarePattern(node, parent);
|
||||
});
|
||||
break;
|
||||
case 'RestElement':
|
||||
declarePattern(node.argument, parent);
|
||||
break;
|
||||
case 'AssignmentPattern':
|
||||
declarePattern(node.left, parent);
|
||||
break;
|
||||
// istanbul ignore next
|
||||
default:
|
||||
throw new Error('Unrecognized pattern type: ' + node.type);
|
||||
}
|
||||
};
|
||||
var declareModuleSpecifier = function (node, parents) {
|
||||
ast.locals = ast.locals || Object.create(null);
|
||||
ast.locals[node.local.name] = true;
|
||||
};
|
||||
walk.ancestor(ast, {
|
||||
'VariableDeclaration': function (node, parents) {
|
||||
var parent = null;
|
||||
for (var i = parents.length - 1; i >= 0 && parent === null; i--) {
|
||||
if (node.kind === 'var' ? isScope(parents[i]) : isBlockScope(parents[i])) {
|
||||
parent = parents[i];
|
||||
}
|
||||
}
|
||||
parent.locals = parent.locals || Object.create(null);
|
||||
node.declarations.forEach(function (declaration) {
|
||||
declarePattern(declaration.id, parent);
|
||||
});
|
||||
},
|
||||
'FunctionDeclaration': function (node, parents) {
|
||||
var parent = null;
|
||||
for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
|
||||
if (isScope(parents[i])) {
|
||||
parent = parents[i];
|
||||
}
|
||||
}
|
||||
parent.locals = parent.locals || Object.create(null);
|
||||
if (node.id) {
|
||||
parent.locals[node.id.name] = true;
|
||||
}
|
||||
declareFunction(node);
|
||||
},
|
||||
'Function': declareFunction,
|
||||
'ClassDeclaration': function (node, parents) {
|
||||
var parent = null;
|
||||
for (var i = parents.length - 2; i >= 0 && parent === null; i--) {
|
||||
if (isBlockScope(parents[i])) {
|
||||
parent = parents[i];
|
||||
}
|
||||
}
|
||||
parent.locals = parent.locals || Object.create(null);
|
||||
if (node.id) {
|
||||
parent.locals[node.id.name] = true;
|
||||
}
|
||||
declareClass(node);
|
||||
},
|
||||
'Class': declareClass,
|
||||
'TryStatement': function (node) {
|
||||
if (node.handler === null || node.handler.param === null) return;
|
||||
node.handler.locals = node.handler.locals || Object.create(null);
|
||||
declarePattern(node.handler.param, node.handler);
|
||||
},
|
||||
'ImportDefaultSpecifier': declareModuleSpecifier,
|
||||
'ImportSpecifier': declareModuleSpecifier,
|
||||
'ImportNamespaceSpecifier': declareModuleSpecifier
|
||||
});
|
||||
function identifier(node, parents) {
|
||||
var name = node.name;
|
||||
if (name === 'undefined') return;
|
||||
for (var i = 0; i < parents.length; i++) {
|
||||
if (name === 'arguments' && declaresArguments(parents[i])) {
|
||||
return;
|
||||
}
|
||||
if (parents[i].locals && name in parents[i].locals) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
node.parents = parents.slice();
|
||||
globals.push(node);
|
||||
}
|
||||
walk.ancestor(ast, {
|
||||
'VariablePattern': identifier,
|
||||
'Identifier': identifier,
|
||||
'ThisExpression': function (node, parents) {
|
||||
for (var i = 0; i < parents.length; i++) {
|
||||
var parent = parents[i];
|
||||
if ( parent.type === 'FunctionExpression' || parent.type === 'FunctionDeclaration' ) { return; }
|
||||
if ( parent.type === 'PropertyDefinition' && parents[i+1]===parent.value ) { return; }
|
||||
}
|
||||
node.parents = parents.slice();
|
||||
globals.push(node);
|
||||
}
|
||||
});
|
||||
var groupedGlobals = Object.create(null);
|
||||
globals.forEach(function (node) {
|
||||
var name = node.type === 'ThisExpression' ? 'this' : node.name;
|
||||
groupedGlobals[name] = (groupedGlobals[name] || []);
|
||||
groupedGlobals[name].push(node);
|
||||
});
|
||||
return Object.keys(groupedGlobals).sort().map(function (name) {
|
||||
return {name: name, nodes: groupedGlobals[name]};
|
||||
});
|
||||
}
|
35
node_modules/acorn-globals/package.json
generated
vendored
Normal file
35
node_modules/acorn-globals/package.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "acorn-globals",
|
||||
"version": "7.0.1",
|
||||
"description": "Detect global variables in JavaScript using acorn",
|
||||
"keywords": [
|
||||
"ast",
|
||||
"variable",
|
||||
"name",
|
||||
"lexical",
|
||||
"scope",
|
||||
"local",
|
||||
"global",
|
||||
"implicit"
|
||||
],
|
||||
"files": [
|
||||
"index.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"dependencies": {
|
||||
"acorn": "^8.1.0",
|
||||
"acorn-walk": "^8.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"testit": "^3.1.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/ForbesLindesay/acorn-globals.git"
|
||||
},
|
||||
"author": "ForbesLindesay",
|
||||
"license": "MIT"
|
||||
}
|
167
node_modules/acorn-walk/CHANGELOG.md
generated
vendored
Normal file
167
node_modules/acorn-walk/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
## 8.2.0 (2021-09-06)
|
||||
|
||||
### New features
|
||||
|
||||
Add support for walking ES2022 class static blocks.
|
||||
|
||||
## 8.1.1 (2021-06-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Include `base` in the type declarations.
|
||||
|
||||
## 8.1.0 (2021-04-24)
|
||||
|
||||
### New features
|
||||
|
||||
Support node types for class fields and private methods.
|
||||
|
||||
## 8.0.2 (2021-01-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Adjust package.json to work with Node 12.16.0 and 13.0-13.6.
|
||||
|
||||
## 8.0.0 (2021-01-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `full` and `fullAncestor` would skip nodes with overridden types.
|
||||
|
||||
## 8.0.0 (2020-08-12)
|
||||
|
||||
### New features
|
||||
|
||||
The package can now be loaded directly as an ECMAScript module in node 13+.
|
||||
|
||||
## 7.2.0 (2020-06-17)
|
||||
|
||||
### New features
|
||||
|
||||
Support optional chaining and nullish coalescing.
|
||||
|
||||
Support `import.meta`.
|
||||
|
||||
Add support for `export * as ns from "source"`.
|
||||
|
||||
## 7.1.1 (2020-02-13)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Clean up the type definitions to actually work well with the main parser.
|
||||
|
||||
## 7.1.0 (2020-02-11)
|
||||
|
||||
### New features
|
||||
|
||||
Add a TypeScript definition file for the library.
|
||||
|
||||
## 7.0.0 (2017-08-12)
|
||||
|
||||
### New features
|
||||
|
||||
Support walking `ImportExpression` nodes.
|
||||
|
||||
## 6.2.0 (2017-07-04)
|
||||
|
||||
### New features
|
||||
|
||||
Add support for `Import` nodes.
|
||||
|
||||
## 6.1.0 (2018-09-28)
|
||||
|
||||
### New features
|
||||
|
||||
The walker now walks `TemplateElement` nodes.
|
||||
|
||||
## 6.0.1 (2018-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bad "main" field in package.json.
|
||||
|
||||
## 6.0.0 (2018-09-14)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
This is now a separate package, `acorn-walk`, rather than part of the main `acorn` package.
|
||||
|
||||
The `ScopeBody` and `ScopeExpression` meta-node-types are no longer supported.
|
||||
|
||||
## 5.7.1 (2018-06-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make sure the walker and bin files are rebuilt on release (the previous release didn't get the up-to-date versions).
|
||||
|
||||
## 5.7.0 (2018-06-15)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix crash in walker when walking a binding-less catch node.
|
||||
|
||||
## 5.6.2 (2018-06-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
In the walker, go back to allowing the `baseVisitor` argument to be null to default to the default base everywhere.
|
||||
|
||||
## 5.6.1 (2018-06-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix regression when passing `null` as fourth argument to `walk.recursive`.
|
||||
|
||||
## 5.6.0 (2018-05-31)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug in the walker that caused a crash when walking an object pattern spread.
|
||||
|
||||
## 5.5.1 (2018-03-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix regression in walker causing property values in object patterns to be walked as expressions.
|
||||
|
||||
## 5.5.0 (2018-02-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Support object spread in the AST walker.
|
||||
|
||||
## 5.4.1 (2018-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
5.4.0 somehow accidentally included an old version of walk.js.
|
||||
|
||||
## 5.2.0 (2017-10-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The `full` and `fullAncestor` walkers no longer visit nodes multiple times.
|
||||
|
||||
## 5.1.0 (2017-07-05)
|
||||
|
||||
### New features
|
||||
|
||||
New walker functions `full` and `fullAncestor`.
|
||||
|
||||
## 3.2.0 (2016-06-07)
|
||||
|
||||
### New features
|
||||
|
||||
Make it possible to use `visit.ancestor` with a walk state.
|
||||
|
||||
## 3.1.0 (2016-04-18)
|
||||
|
||||
### New features
|
||||
|
||||
The walker now allows defining handlers for `CatchClause` nodes.
|
||||
|
||||
## 2.5.2 (2015-10-27)
|
||||
|
||||
### Fixes
|
||||
|
||||
Fix bug where the walker walked an exported `let` statement as an expression.
|
21
node_modules/acorn-walk/LICENSE
generated
vendored
Normal file
21
node_modules/acorn-walk/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2012-2020 by various contributors (see AUTHORS)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
126
node_modules/acorn-walk/README.md
generated
vendored
Normal file
126
node_modules/acorn-walk/README.md
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
# Acorn AST walker
|
||||
|
||||
An abstract syntax tree walker for the
|
||||
[ESTree](https://github.com/estree/estree) format.
|
||||
|
||||
## Community
|
||||
|
||||
Acorn is open source software released under an
|
||||
[MIT license](https://github.com/acornjs/acorn/blob/master/acorn-walk/LICENSE).
|
||||
|
||||
You are welcome to
|
||||
[report bugs](https://github.com/acornjs/acorn/issues) or create pull
|
||||
requests on [github](https://github.com/acornjs/acorn). For questions
|
||||
and discussion, please use the
|
||||
[Tern discussion forum](https://discuss.ternjs.net).
|
||||
|
||||
## Installation
|
||||
|
||||
The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
npm install acorn-walk
|
||||
```
|
||||
|
||||
Alternately, you can download the source and build acorn yourself:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/acornjs/acorn.git
|
||||
cd acorn
|
||||
npm install
|
||||
```
|
||||
|
||||
## Interface
|
||||
|
||||
An algorithm for recursing through a syntax tree is stored as an
|
||||
object, with a property for each tree node type holding a function
|
||||
that will recurse through such a node. There are several ways to run
|
||||
such a walker.
|
||||
|
||||
**simple**`(node, visitors, base, state)` does a 'simple' walk over a
|
||||
tree. `node` should be the AST node to walk, and `visitors` an object
|
||||
with properties whose names correspond to node types in the [ESTree
|
||||
spec](https://github.com/estree/estree). The properties should contain
|
||||
functions that will be called with the node object and, if applicable
|
||||
the state at that point. The last two arguments are optional. `base`
|
||||
is a walker algorithm, and `state` is a start state. The default
|
||||
walker will simply visit all statements and expressions and not
|
||||
produce a meaningful state. (An example of a use of state is to track
|
||||
scope at each point in the tree.)
|
||||
|
||||
```js
|
||||
const acorn = require("acorn")
|
||||
const walk = require("acorn-walk")
|
||||
|
||||
walk.simple(acorn.parse("let x = 10"), {
|
||||
Literal(node) {
|
||||
console.log(`Found a literal: ${node.value}`)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**ancestor**`(node, visitors, base, state)` does a 'simple' walk over
|
||||
a tree, building up an array of ancestor nodes (including the current node)
|
||||
and passing the array to the callbacks as a third parameter.
|
||||
|
||||
```js
|
||||
const acorn = require("acorn")
|
||||
const walk = require("acorn-walk")
|
||||
|
||||
walk.ancestor(acorn.parse("foo('hi')"), {
|
||||
Literal(_, ancestors) {
|
||||
console.log("This literal's ancestors are:", ancestors.map(n => n.type))
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
**recursive**`(node, state, functions, base)` does a 'recursive'
|
||||
walk, where the walker functions are responsible for continuing the
|
||||
walk on the child nodes of their target node. `state` is the start
|
||||
state, and `functions` should contain an object that maps node types
|
||||
to walker functions. Such functions are called with `(node, state, c)`
|
||||
arguments, and can cause the walk to continue on a sub-node by calling
|
||||
the `c` argument on it with `(node, state)` arguments. The optional
|
||||
`base` argument provides the fallback walker functions for node types
|
||||
that aren't handled in the `functions` object. If not given, the
|
||||
default walkers will be used.
|
||||
|
||||
**make**`(functions, base)` builds a new walker object by using the
|
||||
walker functions in `functions` and filling in the missing ones by
|
||||
taking defaults from `base`.
|
||||
|
||||
**full**`(node, callback, base, state)` does a 'full' walk over a
|
||||
tree, calling the callback with the arguments (node, state, type) for
|
||||
each node
|
||||
|
||||
**fullAncestor**`(node, callback, base, state)` does a 'full' walk
|
||||
over a tree, building up an array of ancestor nodes (including the
|
||||
current node) and passing the array to the callbacks as a third
|
||||
parameter.
|
||||
|
||||
```js
|
||||
const acorn = require("acorn")
|
||||
const walk = require("acorn-walk")
|
||||
|
||||
walk.full(acorn.parse("1 + 1"), node => {
|
||||
console.log(`There's a ${node.type} node at ${node.ch}`)
|
||||
})
|
||||
```
|
||||
|
||||
**findNodeAt**`(node, start, end, test, base, state)` tries to locate
|
||||
a node in a tree at the given start and/or end offsets, which
|
||||
satisfies the predicate `test`. `start` and `end` can be either `null`
|
||||
(as wildcard) or a number. `test` may be a string (indicating a node
|
||||
type) or a function that takes `(nodeType, node)` arguments and
|
||||
returns a boolean indicating whether this node is interesting. `base`
|
||||
and `state` are optional, and can be used to specify a custom walker.
|
||||
Nodes are tested from inner to outer, so if two nodes match the
|
||||
boundaries, the inner one will be preferred.
|
||||
|
||||
**findNodeAround**`(node, pos, test, base, state)` is a lot like
|
||||
`findNodeAt`, but will match any node that exists 'around' (spanning)
|
||||
the given position.
|
||||
|
||||
**findNodeAfter**`(node, pos, test, base, state)` is similar to
|
||||
`findNodeAround`, but will match all nodes *after* the given position
|
||||
(testing outer nodes before inner nodes).
|
114
node_modules/acorn-walk/dist/walk.d.ts
generated
vendored
Normal file
114
node_modules/acorn-walk/dist/walk.d.ts
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
import {Node} from 'acorn';
|
||||
|
||||
declare module "acorn-walk" {
|
||||
type FullWalkerCallback<TState> = (
|
||||
node: Node,
|
||||
state: TState,
|
||||
type: string
|
||||
) => void;
|
||||
|
||||
type FullAncestorWalkerCallback<TState> = (
|
||||
node: Node,
|
||||
state: TState | Node[],
|
||||
ancestors: Node[],
|
||||
type: string
|
||||
) => void;
|
||||
type WalkerCallback<TState> = (node: Node, state: TState) => void;
|
||||
|
||||
type SimpleWalkerFn<TState> = (
|
||||
node: Node,
|
||||
state: TState
|
||||
) => void;
|
||||
|
||||
type AncestorWalkerFn<TState> = (
|
||||
node: Node,
|
||||
state: TState| Node[],
|
||||
ancestors: Node[]
|
||||
) => void;
|
||||
|
||||
type RecursiveWalkerFn<TState> = (
|
||||
node: Node,
|
||||
state: TState,
|
||||
callback: WalkerCallback<TState>
|
||||
) => void;
|
||||
|
||||
type SimpleVisitors<TState> = {
|
||||
[type: string]: SimpleWalkerFn<TState>
|
||||
};
|
||||
|
||||
type AncestorVisitors<TState> = {
|
||||
[type: string]: AncestorWalkerFn<TState>
|
||||
};
|
||||
|
||||
type RecursiveVisitors<TState> = {
|
||||
[type: string]: RecursiveWalkerFn<TState>
|
||||
};
|
||||
|
||||
type FindPredicate = (type: string, node: Node) => boolean;
|
||||
|
||||
interface Found<TState> {
|
||||
node: Node,
|
||||
state: TState
|
||||
}
|
||||
|
||||
export function simple<TState>(
|
||||
node: Node,
|
||||
visitors: SimpleVisitors<TState>,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): void;
|
||||
|
||||
export function ancestor<TState>(
|
||||
node: Node,
|
||||
visitors: AncestorVisitors<TState>,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): void;
|
||||
|
||||
export function recursive<TState>(
|
||||
node: Node,
|
||||
state: TState,
|
||||
functions: RecursiveVisitors<TState>,
|
||||
base?: RecursiveVisitors<TState>
|
||||
): void;
|
||||
|
||||
export function full<TState>(
|
||||
node: Node,
|
||||
callback: FullWalkerCallback<TState>,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): void;
|
||||
|
||||
export function fullAncestor<TState>(
|
||||
node: Node,
|
||||
callback: FullAncestorWalkerCallback<TState>,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): void;
|
||||
|
||||
export function make<TState>(
|
||||
functions: RecursiveVisitors<TState>,
|
||||
base?: RecursiveVisitors<TState>
|
||||
): RecursiveVisitors<TState>;
|
||||
|
||||
export function findNodeAt<TState>(
|
||||
node: Node,
|
||||
start: number | undefined,
|
||||
end?: number | undefined,
|
||||
type?: FindPredicate | string,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): Found<TState> | undefined;
|
||||
|
||||
export function findNodeAround<TState>(
|
||||
node: Node,
|
||||
start: number | undefined,
|
||||
type?: FindPredicate | string,
|
||||
base?: RecursiveVisitors<TState>,
|
||||
state?: TState
|
||||
): Found<TState> | undefined;
|
||||
|
||||
export const findNodeAfter: typeof findNodeAround;
|
||||
|
||||
export const base: RecursiveVisitors<any>;
|
||||
}
|
463
node_modules/acorn-walk/dist/walk.js
generated
vendored
Normal file
463
node_modules/acorn-walk/dist/walk.js
generated
vendored
Normal file
@ -0,0 +1,463 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
// AST walker module for Mozilla Parser API compatible trees
|
||||
|
||||
// A simple walk is one where you simply specify callbacks to be
|
||||
// called on specific nodes. The last two arguments are optional. A
|
||||
// simple use would be
|
||||
//
|
||||
// walk.simple(myTree, {
|
||||
// Expression: function(node) { ... }
|
||||
// });
|
||||
//
|
||||
// to do something with all expressions. All Parser API node types
|
||||
// can be used to identify node types, as well as Expression and
|
||||
// Statement, which denote categories of nodes.
|
||||
//
|
||||
// The base argument can be used to pass a custom (recursive)
|
||||
// walker, and state can be used to give this walked an initial
|
||||
// state.
|
||||
|
||||
function simple(node, visitors, baseVisitor, state, override) {
|
||||
if (!baseVisitor) { baseVisitor = base
|
||||
; }(function c(node, st, override) {
|
||||
var type = override || node.type, found = visitors[type];
|
||||
baseVisitor[type](node, st, c);
|
||||
if (found) { found(node, st); }
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// An ancestor walk keeps an array of ancestor nodes (including the
|
||||
// current node) and passes them to the callback as third parameter
|
||||
// (and also as state parameter when no other state is present).
|
||||
function ancestor(node, visitors, baseVisitor, state, override) {
|
||||
var ancestors = [];
|
||||
if (!baseVisitor) { baseVisitor = base
|
||||
; }(function c(node, st, override) {
|
||||
var type = override || node.type, found = visitors[type];
|
||||
var isNew = node !== ancestors[ancestors.length - 1];
|
||||
if (isNew) { ancestors.push(node); }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (found) { found(node, st || ancestors, ancestors); }
|
||||
if (isNew) { ancestors.pop(); }
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// A recursive walk is one where your functions override the default
|
||||
// walkers. They can modify and replace the state parameter that's
|
||||
// threaded through the walk, and can opt how and whether to walk
|
||||
// their child nodes (by calling their third argument on these
|
||||
// nodes).
|
||||
function recursive(node, state, funcs, baseVisitor, override) {
|
||||
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
||||
;(function c(node, st, override) {
|
||||
visitor[override || node.type](node, st, c);
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
function makeTest(test) {
|
||||
if (typeof test === "string")
|
||||
{ return function (type) { return type === test; } }
|
||||
else if (!test)
|
||||
{ return function () { return true; } }
|
||||
else
|
||||
{ return test }
|
||||
}
|
||||
|
||||
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
||||
|
||||
// A full walk triggers the callback on each node
|
||||
function full(node, callback, baseVisitor, state, override) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var last
|
||||
;(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
baseVisitor[type](node, st, c);
|
||||
if (last !== node) {
|
||||
callback(node, st, type);
|
||||
last = node;
|
||||
}
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// An fullAncestor walk is like an ancestor walk, but triggers
|
||||
// the callback on each node
|
||||
function fullAncestor(node, callback, baseVisitor, state) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var ancestors = [], last
|
||||
;(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
var isNew = node !== ancestors[ancestors.length - 1];
|
||||
if (isNew) { ancestors.push(node); }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (last !== node) {
|
||||
callback(node, st || ancestors, ancestors, type);
|
||||
last = node;
|
||||
}
|
||||
if (isNew) { ancestors.pop(); }
|
||||
})(node, state);
|
||||
}
|
||||
|
||||
// Find a node with a given start, end, and type (all are optional,
|
||||
// null can be used as wildcard). Returns a {node, state} object, or
|
||||
// undefined when it doesn't find a matching node.
|
||||
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
test = makeTest(test);
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if ((start == null || node.start <= start) &&
|
||||
(end == null || node.end >= end))
|
||||
{ baseVisitor[type](node, st, c); }
|
||||
if ((start == null || node.start === start) &&
|
||||
(end == null || node.end === end) &&
|
||||
test(type, node))
|
||||
{ throw new Found(node, st) }
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the innermost node of a given type that contains the given
|
||||
// position. Interface similar to findNodeAt.
|
||||
function findNodeAround(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if (node.start > pos || node.end < pos) { return }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (test(type, node)) { throw new Found(node, st) }
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the outermost matching node after a given position.
|
||||
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
if (node.end < pos) { return }
|
||||
var type = override || node.type;
|
||||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
||||
baseVisitor[type](node, st, c);
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the outermost matching node before a given position.
|
||||
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var max
|
||||
;(function c(node, st, override) {
|
||||
if (node.start > pos) { return }
|
||||
var type = override || node.type;
|
||||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
||||
{ max = new Found(node, st); }
|
||||
baseVisitor[type](node, st, c);
|
||||
})(node, state);
|
||||
return max
|
||||
}
|
||||
|
||||
// Used to create a custom walker. Will fill in all missing node
|
||||
// type properties with the defaults.
|
||||
function make(funcs, baseVisitor) {
|
||||
var visitor = Object.create(baseVisitor || base);
|
||||
for (var type in funcs) { visitor[type] = funcs[type]; }
|
||||
return visitor
|
||||
}
|
||||
|
||||
function skipThrough(node, st, c) { c(node, st); }
|
||||
function ignore(_node, _st, _c) {}
|
||||
|
||||
// Node walkers.
|
||||
|
||||
var base = {};
|
||||
|
||||
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var stmt = list[i];
|
||||
|
||||
c(stmt, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.Statement = skipThrough;
|
||||
base.EmptyStatement = ignore;
|
||||
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
||||
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
||||
base.IfStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Statement");
|
||||
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
||||
};
|
||||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
||||
base.BreakStatement = base.ContinueStatement = ignore;
|
||||
base.WithStatement = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.SwitchStatement = function (node, st, c) {
|
||||
c(node.discriminant, st, "Expression");
|
||||
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
||||
var cs = list$1[i$1];
|
||||
|
||||
if (cs.test) { c(cs.test, st, "Expression"); }
|
||||
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
||||
{
|
||||
var cons = list[i];
|
||||
|
||||
c(cons, st, "Statement");
|
||||
}
|
||||
}
|
||||
};
|
||||
base.SwitchCase = function (node, st, c) {
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
||||
{
|
||||
var cons = list[i];
|
||||
|
||||
c(cons, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
||||
if (node.argument) { c(node.argument, st, "Expression"); }
|
||||
};
|
||||
base.ThrowStatement = base.SpreadElement =
|
||||
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
||||
base.TryStatement = function (node, st, c) {
|
||||
c(node.block, st, "Statement");
|
||||
if (node.handler) { c(node.handler, st); }
|
||||
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
||||
};
|
||||
base.CatchClause = function (node, st, c) {
|
||||
if (node.param) { c(node.param, st, "Pattern"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForStatement = function (node, st, c) {
|
||||
if (node.init) { c(node.init, st, "ForInit"); }
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
if (node.update) { c(node.update, st, "Expression"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
||||
c(node.left, st, "ForInit");
|
||||
c(node.right, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInit = function (node, st, c) {
|
||||
if (node.type === "VariableDeclaration") { c(node, st); }
|
||||
else { c(node, st, "Expression"); }
|
||||
};
|
||||
base.DebuggerStatement = ignore;
|
||||
|
||||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
||||
base.VariableDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
||||
{
|
||||
var decl = list[i];
|
||||
|
||||
c(decl, st);
|
||||
}
|
||||
};
|
||||
base.VariableDeclarator = function (node, st, c) {
|
||||
c(node.id, st, "Pattern");
|
||||
if (node.init) { c(node.init, st, "Expression"); }
|
||||
};
|
||||
|
||||
base.Function = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
for (var i = 0, list = node.params; i < list.length; i += 1)
|
||||
{
|
||||
var param = list[i];
|
||||
|
||||
c(param, st, "Pattern");
|
||||
}
|
||||
c(node.body, st, node.expression ? "Expression" : "Statement");
|
||||
};
|
||||
|
||||
base.Pattern = function (node, st, c) {
|
||||
if (node.type === "Identifier")
|
||||
{ c(node, st, "VariablePattern"); }
|
||||
else if (node.type === "MemberExpression")
|
||||
{ c(node, st, "MemberPattern"); }
|
||||
else
|
||||
{ c(node, st); }
|
||||
};
|
||||
base.VariablePattern = ignore;
|
||||
base.MemberPattern = skipThrough;
|
||||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
||||
base.ArrayPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Pattern"); }
|
||||
}
|
||||
};
|
||||
base.ObjectPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
||||
var prop = list[i];
|
||||
|
||||
if (prop.type === "Property") {
|
||||
if (prop.computed) { c(prop.key, st, "Expression"); }
|
||||
c(prop.value, st, "Pattern");
|
||||
} else if (prop.type === "RestElement") {
|
||||
c(prop.argument, st, "Pattern");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
base.Expression = skipThrough;
|
||||
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
||||
base.ArrayExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Expression"); }
|
||||
}
|
||||
};
|
||||
base.ObjectExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
||||
{
|
||||
var prop = list[i];
|
||||
|
||||
c(prop, st);
|
||||
}
|
||||
};
|
||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
||||
{
|
||||
var expr = list[i];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateLiteral = function (node, st, c) {
|
||||
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
||||
{
|
||||
var quasi = list[i];
|
||||
|
||||
c(quasi, st);
|
||||
}
|
||||
|
||||
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
||||
{
|
||||
var expr = list$1[i$1];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateElement = ignore;
|
||||
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
||||
c(node.left, st, "Expression");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
||||
c(node.left, st, "Pattern");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.ConditionalExpression = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Expression");
|
||||
c(node.alternate, st, "Expression");
|
||||
};
|
||||
base.NewExpression = base.CallExpression = function (node, st, c) {
|
||||
c(node.callee, st, "Expression");
|
||||
if (node.arguments)
|
||||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
||||
{
|
||||
var arg = list[i];
|
||||
|
||||
c(arg, st, "Expression");
|
||||
} }
|
||||
};
|
||||
base.MemberExpression = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
if (node.computed) { c(node.property, st, "Expression"); }
|
||||
};
|
||||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
||||
if (node.declaration)
|
||||
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
||||
if (node.source) { c(node.source, st, "Expression"); }
|
||||
};
|
||||
base.ExportAllDeclaration = function (node, st, c) {
|
||||
if (node.exported)
|
||||
{ c(node.exported, st); }
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
||||
{
|
||||
var spec = list[i];
|
||||
|
||||
c(spec, st);
|
||||
}
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportExpression = function (node, st, c) {
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
||||
|
||||
base.TaggedTemplateExpression = function (node, st, c) {
|
||||
c(node.tag, st, "Expression");
|
||||
c(node.quasi, st, "Expression");
|
||||
};
|
||||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
||||
base.Class = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
||||
c(node.body, st);
|
||||
};
|
||||
base.ClassBody = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var elt = list[i];
|
||||
|
||||
c(elt, st);
|
||||
}
|
||||
};
|
||||
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
||||
if (node.computed) { c(node.key, st, "Expression"); }
|
||||
if (node.value) { c(node.value, st, "Expression"); }
|
||||
};
|
||||
|
||||
exports.ancestor = ancestor;
|
||||
exports.base = base;
|
||||
exports.findNodeAfter = findNodeAfter;
|
||||
exports.findNodeAround = findNodeAround;
|
||||
exports.findNodeAt = findNodeAt;
|
||||
exports.findNodeBefore = findNodeBefore;
|
||||
exports.full = full;
|
||||
exports.fullAncestor = fullAncestor;
|
||||
exports.make = make;
|
||||
exports.recursive = recursive;
|
||||
exports.simple = simple;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
443
node_modules/acorn-walk/dist/walk.mjs
generated
vendored
Normal file
443
node_modules/acorn-walk/dist/walk.mjs
generated
vendored
Normal file
@ -0,0 +1,443 @@
|
||||
// AST walker module for Mozilla Parser API compatible trees
|
||||
|
||||
// A simple walk is one where you simply specify callbacks to be
|
||||
// called on specific nodes. The last two arguments are optional. A
|
||||
// simple use would be
|
||||
//
|
||||
// walk.simple(myTree, {
|
||||
// Expression: function(node) { ... }
|
||||
// });
|
||||
//
|
||||
// to do something with all expressions. All Parser API node types
|
||||
// can be used to identify node types, as well as Expression and
|
||||
// Statement, which denote categories of nodes.
|
||||
//
|
||||
// The base argument can be used to pass a custom (recursive)
|
||||
// walker, and state can be used to give this walked an initial
|
||||
// state.
|
||||
|
||||
function simple(node, visitors, baseVisitor, state, override) {
|
||||
if (!baseVisitor) { baseVisitor = base
|
||||
; }(function c(node, st, override) {
|
||||
var type = override || node.type, found = visitors[type];
|
||||
baseVisitor[type](node, st, c);
|
||||
if (found) { found(node, st); }
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// An ancestor walk keeps an array of ancestor nodes (including the
|
||||
// current node) and passes them to the callback as third parameter
|
||||
// (and also as state parameter when no other state is present).
|
||||
function ancestor(node, visitors, baseVisitor, state, override) {
|
||||
var ancestors = [];
|
||||
if (!baseVisitor) { baseVisitor = base
|
||||
; }(function c(node, st, override) {
|
||||
var type = override || node.type, found = visitors[type];
|
||||
var isNew = node !== ancestors[ancestors.length - 1];
|
||||
if (isNew) { ancestors.push(node); }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (found) { found(node, st || ancestors, ancestors); }
|
||||
if (isNew) { ancestors.pop(); }
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// A recursive walk is one where your functions override the default
|
||||
// walkers. They can modify and replace the state parameter that's
|
||||
// threaded through the walk, and can opt how and whether to walk
|
||||
// their child nodes (by calling their third argument on these
|
||||
// nodes).
|
||||
function recursive(node, state, funcs, baseVisitor, override) {
|
||||
var visitor = funcs ? make(funcs, baseVisitor || undefined) : baseVisitor
|
||||
;(function c(node, st, override) {
|
||||
visitor[override || node.type](node, st, c);
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
function makeTest(test) {
|
||||
if (typeof test === "string")
|
||||
{ return function (type) { return type === test; } }
|
||||
else if (!test)
|
||||
{ return function () { return true; } }
|
||||
else
|
||||
{ return test }
|
||||
}
|
||||
|
||||
var Found = function Found(node, state) { this.node = node; this.state = state; };
|
||||
|
||||
// A full walk triggers the callback on each node
|
||||
function full(node, callback, baseVisitor, state, override) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var last
|
||||
;(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
baseVisitor[type](node, st, c);
|
||||
if (last !== node) {
|
||||
callback(node, st, type);
|
||||
last = node;
|
||||
}
|
||||
})(node, state, override);
|
||||
}
|
||||
|
||||
// An fullAncestor walk is like an ancestor walk, but triggers
|
||||
// the callback on each node
|
||||
function fullAncestor(node, callback, baseVisitor, state) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var ancestors = [], last
|
||||
;(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
var isNew = node !== ancestors[ancestors.length - 1];
|
||||
if (isNew) { ancestors.push(node); }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (last !== node) {
|
||||
callback(node, st || ancestors, ancestors, type);
|
||||
last = node;
|
||||
}
|
||||
if (isNew) { ancestors.pop(); }
|
||||
})(node, state);
|
||||
}
|
||||
|
||||
// Find a node with a given start, end, and type (all are optional,
|
||||
// null can be used as wildcard). Returns a {node, state} object, or
|
||||
// undefined when it doesn't find a matching node.
|
||||
function findNodeAt(node, start, end, test, baseVisitor, state) {
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
test = makeTest(test);
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if ((start == null || node.start <= start) &&
|
||||
(end == null || node.end >= end))
|
||||
{ baseVisitor[type](node, st, c); }
|
||||
if ((start == null || node.start === start) &&
|
||||
(end == null || node.end === end) &&
|
||||
test(type, node))
|
||||
{ throw new Found(node, st) }
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the innermost node of a given type that contains the given
|
||||
// position. Interface similar to findNodeAt.
|
||||
function findNodeAround(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
var type = override || node.type;
|
||||
if (node.start > pos || node.end < pos) { return }
|
||||
baseVisitor[type](node, st, c);
|
||||
if (test(type, node)) { throw new Found(node, st) }
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the outermost matching node after a given position.
|
||||
function findNodeAfter(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
try {
|
||||
(function c(node, st, override) {
|
||||
if (node.end < pos) { return }
|
||||
var type = override || node.type;
|
||||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) }
|
||||
baseVisitor[type](node, st, c);
|
||||
})(node, state);
|
||||
} catch (e) {
|
||||
if (e instanceof Found) { return e }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Find the outermost matching node before a given position.
|
||||
function findNodeBefore(node, pos, test, baseVisitor, state) {
|
||||
test = makeTest(test);
|
||||
if (!baseVisitor) { baseVisitor = base; }
|
||||
var max
|
||||
;(function c(node, st, override) {
|
||||
if (node.start > pos) { return }
|
||||
var type = override || node.type;
|
||||
if (node.end <= pos && (!max || max.node.end < node.end) && test(type, node))
|
||||
{ max = new Found(node, st); }
|
||||
baseVisitor[type](node, st, c);
|
||||
})(node, state);
|
||||
return max
|
||||
}
|
||||
|
||||
// Used to create a custom walker. Will fill in all missing node
|
||||
// type properties with the defaults.
|
||||
function make(funcs, baseVisitor) {
|
||||
var visitor = Object.create(baseVisitor || base);
|
||||
for (var type in funcs) { visitor[type] = funcs[type]; }
|
||||
return visitor
|
||||
}
|
||||
|
||||
function skipThrough(node, st, c) { c(node, st); }
|
||||
function ignore(_node, _st, _c) {}
|
||||
|
||||
// Node walkers.
|
||||
|
||||
var base = {};
|
||||
|
||||
base.Program = base.BlockStatement = base.StaticBlock = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var stmt = list[i];
|
||||
|
||||
c(stmt, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.Statement = skipThrough;
|
||||
base.EmptyStatement = ignore;
|
||||
base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
|
||||
function (node, st, c) { return c(node.expression, st, "Expression"); };
|
||||
base.IfStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Statement");
|
||||
if (node.alternate) { c(node.alternate, st, "Statement"); }
|
||||
};
|
||||
base.LabeledStatement = function (node, st, c) { return c(node.body, st, "Statement"); };
|
||||
base.BreakStatement = base.ContinueStatement = ignore;
|
||||
base.WithStatement = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.SwitchStatement = function (node, st, c) {
|
||||
c(node.discriminant, st, "Expression");
|
||||
for (var i$1 = 0, list$1 = node.cases; i$1 < list$1.length; i$1 += 1) {
|
||||
var cs = list$1[i$1];
|
||||
|
||||
if (cs.test) { c(cs.test, st, "Expression"); }
|
||||
for (var i = 0, list = cs.consequent; i < list.length; i += 1)
|
||||
{
|
||||
var cons = list[i];
|
||||
|
||||
c(cons, st, "Statement");
|
||||
}
|
||||
}
|
||||
};
|
||||
base.SwitchCase = function (node, st, c) {
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
for (var i = 0, list = node.consequent; i < list.length; i += 1)
|
||||
{
|
||||
var cons = list[i];
|
||||
|
||||
c(cons, st, "Statement");
|
||||
}
|
||||
};
|
||||
base.ReturnStatement = base.YieldExpression = base.AwaitExpression = function (node, st, c) {
|
||||
if (node.argument) { c(node.argument, st, "Expression"); }
|
||||
};
|
||||
base.ThrowStatement = base.SpreadElement =
|
||||
function (node, st, c) { return c(node.argument, st, "Expression"); };
|
||||
base.TryStatement = function (node, st, c) {
|
||||
c(node.block, st, "Statement");
|
||||
if (node.handler) { c(node.handler, st); }
|
||||
if (node.finalizer) { c(node.finalizer, st, "Statement"); }
|
||||
};
|
||||
base.CatchClause = function (node, st, c) {
|
||||
if (node.param) { c(node.param, st, "Pattern"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.WhileStatement = base.DoWhileStatement = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForStatement = function (node, st, c) {
|
||||
if (node.init) { c(node.init, st, "ForInit"); }
|
||||
if (node.test) { c(node.test, st, "Expression"); }
|
||||
if (node.update) { c(node.update, st, "Expression"); }
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInStatement = base.ForOfStatement = function (node, st, c) {
|
||||
c(node.left, st, "ForInit");
|
||||
c(node.right, st, "Expression");
|
||||
c(node.body, st, "Statement");
|
||||
};
|
||||
base.ForInit = function (node, st, c) {
|
||||
if (node.type === "VariableDeclaration") { c(node, st); }
|
||||
else { c(node, st, "Expression"); }
|
||||
};
|
||||
base.DebuggerStatement = ignore;
|
||||
|
||||
base.FunctionDeclaration = function (node, st, c) { return c(node, st, "Function"); };
|
||||
base.VariableDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.declarations; i < list.length; i += 1)
|
||||
{
|
||||
var decl = list[i];
|
||||
|
||||
c(decl, st);
|
||||
}
|
||||
};
|
||||
base.VariableDeclarator = function (node, st, c) {
|
||||
c(node.id, st, "Pattern");
|
||||
if (node.init) { c(node.init, st, "Expression"); }
|
||||
};
|
||||
|
||||
base.Function = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
for (var i = 0, list = node.params; i < list.length; i += 1)
|
||||
{
|
||||
var param = list[i];
|
||||
|
||||
c(param, st, "Pattern");
|
||||
}
|
||||
c(node.body, st, node.expression ? "Expression" : "Statement");
|
||||
};
|
||||
|
||||
base.Pattern = function (node, st, c) {
|
||||
if (node.type === "Identifier")
|
||||
{ c(node, st, "VariablePattern"); }
|
||||
else if (node.type === "MemberExpression")
|
||||
{ c(node, st, "MemberPattern"); }
|
||||
else
|
||||
{ c(node, st); }
|
||||
};
|
||||
base.VariablePattern = ignore;
|
||||
base.MemberPattern = skipThrough;
|
||||
base.RestElement = function (node, st, c) { return c(node.argument, st, "Pattern"); };
|
||||
base.ArrayPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Pattern"); }
|
||||
}
|
||||
};
|
||||
base.ObjectPattern = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1) {
|
||||
var prop = list[i];
|
||||
|
||||
if (prop.type === "Property") {
|
||||
if (prop.computed) { c(prop.key, st, "Expression"); }
|
||||
c(prop.value, st, "Pattern");
|
||||
} else if (prop.type === "RestElement") {
|
||||
c(prop.argument, st, "Pattern");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
base.Expression = skipThrough;
|
||||
base.ThisExpression = base.Super = base.MetaProperty = ignore;
|
||||
base.ArrayExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.elements; i < list.length; i += 1) {
|
||||
var elt = list[i];
|
||||
|
||||
if (elt) { c(elt, st, "Expression"); }
|
||||
}
|
||||
};
|
||||
base.ObjectExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.properties; i < list.length; i += 1)
|
||||
{
|
||||
var prop = list[i];
|
||||
|
||||
c(prop, st);
|
||||
}
|
||||
};
|
||||
base.FunctionExpression = base.ArrowFunctionExpression = base.FunctionDeclaration;
|
||||
base.SequenceExpression = function (node, st, c) {
|
||||
for (var i = 0, list = node.expressions; i < list.length; i += 1)
|
||||
{
|
||||
var expr = list[i];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateLiteral = function (node, st, c) {
|
||||
for (var i = 0, list = node.quasis; i < list.length; i += 1)
|
||||
{
|
||||
var quasi = list[i];
|
||||
|
||||
c(quasi, st);
|
||||
}
|
||||
|
||||
for (var i$1 = 0, list$1 = node.expressions; i$1 < list$1.length; i$1 += 1)
|
||||
{
|
||||
var expr = list$1[i$1];
|
||||
|
||||
c(expr, st, "Expression");
|
||||
}
|
||||
};
|
||||
base.TemplateElement = ignore;
|
||||
base.UnaryExpression = base.UpdateExpression = function (node, st, c) {
|
||||
c(node.argument, st, "Expression");
|
||||
};
|
||||
base.BinaryExpression = base.LogicalExpression = function (node, st, c) {
|
||||
c(node.left, st, "Expression");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.AssignmentExpression = base.AssignmentPattern = function (node, st, c) {
|
||||
c(node.left, st, "Pattern");
|
||||
c(node.right, st, "Expression");
|
||||
};
|
||||
base.ConditionalExpression = function (node, st, c) {
|
||||
c(node.test, st, "Expression");
|
||||
c(node.consequent, st, "Expression");
|
||||
c(node.alternate, st, "Expression");
|
||||
};
|
||||
base.NewExpression = base.CallExpression = function (node, st, c) {
|
||||
c(node.callee, st, "Expression");
|
||||
if (node.arguments)
|
||||
{ for (var i = 0, list = node.arguments; i < list.length; i += 1)
|
||||
{
|
||||
var arg = list[i];
|
||||
|
||||
c(arg, st, "Expression");
|
||||
} }
|
||||
};
|
||||
base.MemberExpression = function (node, st, c) {
|
||||
c(node.object, st, "Expression");
|
||||
if (node.computed) { c(node.property, st, "Expression"); }
|
||||
};
|
||||
base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st, c) {
|
||||
if (node.declaration)
|
||||
{ c(node.declaration, st, node.type === "ExportNamedDeclaration" || node.declaration.id ? "Statement" : "Expression"); }
|
||||
if (node.source) { c(node.source, st, "Expression"); }
|
||||
};
|
||||
base.ExportAllDeclaration = function (node, st, c) {
|
||||
if (node.exported)
|
||||
{ c(node.exported, st); }
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportDeclaration = function (node, st, c) {
|
||||
for (var i = 0, list = node.specifiers; i < list.length; i += 1)
|
||||
{
|
||||
var spec = list[i];
|
||||
|
||||
c(spec, st);
|
||||
}
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportExpression = function (node, st, c) {
|
||||
c(node.source, st, "Expression");
|
||||
};
|
||||
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.PrivateIdentifier = base.Literal = ignore;
|
||||
|
||||
base.TaggedTemplateExpression = function (node, st, c) {
|
||||
c(node.tag, st, "Expression");
|
||||
c(node.quasi, st, "Expression");
|
||||
};
|
||||
base.ClassDeclaration = base.ClassExpression = function (node, st, c) { return c(node, st, "Class"); };
|
||||
base.Class = function (node, st, c) {
|
||||
if (node.id) { c(node.id, st, "Pattern"); }
|
||||
if (node.superClass) { c(node.superClass, st, "Expression"); }
|
||||
c(node.body, st);
|
||||
};
|
||||
base.ClassBody = function (node, st, c) {
|
||||
for (var i = 0, list = node.body; i < list.length; i += 1)
|
||||
{
|
||||
var elt = list[i];
|
||||
|
||||
c(elt, st);
|
||||
}
|
||||
};
|
||||
base.MethodDefinition = base.PropertyDefinition = base.Property = function (node, st, c) {
|
||||
if (node.computed) { c(node.key, st, "Expression"); }
|
||||
if (node.value) { c(node.value, st, "Expression"); }
|
||||
};
|
||||
|
||||
export { ancestor, base, findNodeAfter, findNodeAround, findNodeAt, findNodeBefore, full, fullAncestor, make, recursive, simple };
|
45
node_modules/acorn-walk/package.json
generated
vendored
Normal file
45
node_modules/acorn-walk/package.json
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "acorn-walk",
|
||||
"description": "ECMAScript (ESTree) AST walker",
|
||||
"homepage": "https://github.com/acornjs/acorn",
|
||||
"main": "dist/walk.js",
|
||||
"types": "dist/walk.d.ts",
|
||||
"module": "dist/walk.mjs",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./dist/walk.mjs",
|
||||
"require": "./dist/walk.js",
|
||||
"default": "./dist/walk.js"
|
||||
},
|
||||
"./dist/walk.js"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"version": "8.2.0",
|
||||
"engines": {"node": ">=0.4.0"},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com",
|
||||
"web": "https://marijnhaverbeke.nl"
|
||||
},
|
||||
{
|
||||
"name": "Ingvar Stepanyan",
|
||||
"email": "me@rreverser.com",
|
||||
"web": "https://rreverser.com/"
|
||||
},
|
||||
{
|
||||
"name": "Adrian Heine",
|
||||
"web": "http://adrianheine.de"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/acornjs/acorn.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "cd ..; npm run build:walk"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
816
node_modules/acorn/CHANGELOG.md
generated
vendored
Normal file
816
node_modules/acorn/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,816 @@
|
||||
## 8.8.1 (2022-10-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make type for `Comment` compatible with estree types.
|
||||
|
||||
## 8.8.0 (2022-07-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow parentheses around spread args in destructuring object assignment.
|
||||
|
||||
Fix an issue where the tree contained `directive` properties in when parsing with a language version that doesn't support them.
|
||||
|
||||
### New features
|
||||
|
||||
Support hashbang comments by default in ECMAScript 2023 and later.
|
||||
|
||||
## 8.7.1 (2021-04-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Stop handling `"use strict"` directives in ECMAScript versions before 5.
|
||||
|
||||
Fix an issue where duplicate quoted export names in `export *` syntax were incorrectly checked.
|
||||
|
||||
Add missing type for `tokTypes`.
|
||||
|
||||
## 8.7.0 (2021-12-27)
|
||||
|
||||
### New features
|
||||
|
||||
Support quoted export names.
|
||||
|
||||
Upgrade to Unicode 14.
|
||||
|
||||
Add support for Unicode 13 properties in regular expressions.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Use a loop to find line breaks, because the existing regexp search would overrun the end of the searched range and waste a lot of time in minified code.
|
||||
|
||||
## 8.6.0 (2021-11-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where an object literal with multiple `__proto__` properties would incorrectly be accepted if a later property value held an assigment.
|
||||
|
||||
### New features
|
||||
|
||||
Support class private fields with the `in` operator.
|
||||
|
||||
## 8.5.0 (2021-09-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve context-dependent tokenization in a number of corner cases.
|
||||
|
||||
Fix location tracking after a 0x2028 or 0x2029 character in a string literal (which before did not increase the line number).
|
||||
|
||||
Fix an issue where arrow function bodies in for loop context would inappropriately consume `in` operators.
|
||||
|
||||
Fix wrong end locations stored on SequenceExpression nodes.
|
||||
|
||||
Implement restriction that `for`/`of` loop LHS can't start with `let`.
|
||||
|
||||
### New features
|
||||
|
||||
Add support for ES2022 class static blocks.
|
||||
|
||||
Allow multiple input files to be passed to the CLI tool.
|
||||
|
||||
## 8.4.1 (2021-06-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where `allowAwaitOutsideFunction` would allow `await` in class field initializers, and setting `ecmaVersion` to 13 or higher would allow top-level await in non-module sources.
|
||||
|
||||
## 8.4.0 (2021-06-11)
|
||||
|
||||
### New features
|
||||
|
||||
A new option, `allowSuperOutsideMethod`, can be used to suppress the error when `super` is used in the wrong context.
|
||||
|
||||
## 8.3.0 (2021-05-31)
|
||||
|
||||
### New features
|
||||
|
||||
Default `allowAwaitOutsideFunction` to true for ECMAScript 2022 an higher.
|
||||
|
||||
Add support for the `d` ([indices](https://github.com/tc39/proposal-regexp-match-indices)) regexp flag.
|
||||
|
||||
## 8.2.4 (2021-05-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix spec conformity in corner case 'for await (async of ...)'.
|
||||
|
||||
## 8.2.3 (2021-05-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix an issue where the library couldn't parse 'for (async of ...)'.
|
||||
|
||||
Fix a bug in UTF-16 decoding that would read characters incorrectly in some circumstances.
|
||||
|
||||
## 8.2.2 (2021-04-29)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug where a class field initialized to an async arrow function wouldn't allow await inside it. Same issue existed for generator arrow functions with yield.
|
||||
|
||||
## 8.2.1 (2021-04-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a regression introduced in 8.2.0 where static or async class methods with keyword names fail to parse.
|
||||
|
||||
## 8.2.0 (2021-04-24)
|
||||
|
||||
### New features
|
||||
|
||||
Add support for ES2022 class fields and private methods.
|
||||
|
||||
## 8.1.1 (2021-04-12)
|
||||
|
||||
### Various
|
||||
|
||||
Stop shipping source maps in the NPM package.
|
||||
|
||||
## 8.1.0 (2021-03-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a spurious error in nested destructuring arrays.
|
||||
|
||||
### New features
|
||||
|
||||
Expose `allowAwaitOutsideFunction` in CLI interface.
|
||||
|
||||
Make `allowImportExportAnywhere` also apply to `import.meta`.
|
||||
|
||||
## 8.0.5 (2021-01-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Adjust package.json to work with Node 12.16.0 and 13.0-13.6.
|
||||
|
||||
## 8.0.4 (2020-10-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make `await x ** y` an error, following the spec.
|
||||
|
||||
Fix potentially exponential regular expression.
|
||||
|
||||
## 8.0.3 (2020-10-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a wasteful loop during `Parser` creation when setting `ecmaVersion` to `"latest"`.
|
||||
|
||||
## 8.0.2 (2020-09-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make the TypeScript types reflect the current allowed values for `ecmaVersion`.
|
||||
|
||||
Fix another regexp/division tokenizer issue.
|
||||
|
||||
## 8.0.1 (2020-08-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Provide the correct value in the `version` export.
|
||||
|
||||
## 8.0.0 (2020-08-12)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disallow expressions like `(a = b) = c`.
|
||||
|
||||
Make non-octal escape sequences a syntax error in strict mode.
|
||||
|
||||
### New features
|
||||
|
||||
The package can now be loaded directly as an ECMAScript module in node 13+.
|
||||
|
||||
Update to the set of Unicode properties from ES2021.
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The `ecmaVersion` option is now required. For the moment, omitting it will still work with a warning, but that will change in a future release.
|
||||
|
||||
Some changes to method signatures that may be used by plugins.
|
||||
|
||||
## 7.4.0 (2020-08-03)
|
||||
|
||||
### New features
|
||||
|
||||
Add support for logical assignment operators.
|
||||
|
||||
Add support for numeric separators.
|
||||
|
||||
## 7.3.1 (2020-06-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Make the string in the `version` export match the actual library version.
|
||||
|
||||
## 7.3.0 (2020-06-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a bug that caused parsing of object patterns with a property named `set` that had a default value to fail.
|
||||
|
||||
### New features
|
||||
|
||||
Add support for optional chaining (`?.`).
|
||||
|
||||
## 7.2.0 (2020-05-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix precedence issue in parsing of async arrow functions.
|
||||
|
||||
### New features
|
||||
|
||||
Add support for nullish coalescing.
|
||||
|
||||
Add support for `import.meta`.
|
||||
|
||||
Support `export * as ...` syntax.
|
||||
|
||||
Upgrade to Unicode 13.
|
||||
|
||||
## 6.4.1 (2020-03-09)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
More carefully check for valid UTF16 surrogate pairs in regexp validator.
|
||||
|
||||
## 7.1.1 (2020-03-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Treat `\8` and `\9` as invalid escapes in template strings.
|
||||
|
||||
Allow unicode escapes in property names that are keywords.
|
||||
|
||||
Don't error on an exponential operator expression as argument to `await`.
|
||||
|
||||
More carefully check for valid UTF16 surrogate pairs in regexp validator.
|
||||
|
||||
## 7.1.0 (2019-09-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disallow trailing object literal commas when ecmaVersion is less than 5.
|
||||
|
||||
### New features
|
||||
|
||||
Add a static `acorn` property to the `Parser` class that contains the entire module interface, to allow plugins to access the instance of the library that they are acting on.
|
||||
|
||||
## 7.0.0 (2019-08-13)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Changes the node format for dynamic imports to use the `ImportExpression` node type, as defined in [ESTree](https://github.com/estree/estree/blob/master/es2020.md#importexpression).
|
||||
|
||||
Makes 10 (ES2019) the default value for the `ecmaVersion` option.
|
||||
|
||||
## 6.3.0 (2019-08-12)
|
||||
|
||||
### New features
|
||||
|
||||
`sourceType: "module"` can now be used even when `ecmaVersion` is less than 6, to parse module-style code that otherwise conforms to an older standard.
|
||||
|
||||
## 6.2.1 (2019-07-21)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bug causing Acorn to treat some characters as identifier characters that shouldn't be treated as such.
|
||||
|
||||
Fix issue where setting the `allowReserved` option to `"never"` allowed reserved words in some circumstances.
|
||||
|
||||
## 6.2.0 (2019-07-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve valid assignment checking in `for`/`in` and `for`/`of` loops.
|
||||
|
||||
Disallow binding `let` in patterns.
|
||||
|
||||
### New features
|
||||
|
||||
Support bigint syntax with `ecmaVersion` >= 11.
|
||||
|
||||
Support dynamic `import` syntax with `ecmaVersion` >= 11.
|
||||
|
||||
Upgrade to Unicode version 12.
|
||||
|
||||
## 6.1.1 (2019-02-27)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bug that caused parsing default exports of with names to fail.
|
||||
|
||||
## 6.1.0 (2019-02-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix scope checking when redefining a `var` as a lexical binding.
|
||||
|
||||
### New features
|
||||
|
||||
Split up `parseSubscripts` to use an internal `parseSubscript` method to make it easier to extend with plugins.
|
||||
|
||||
## 6.0.7 (2019-02-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Check that exported bindings are defined.
|
||||
|
||||
Don't treat `\u180e` as a whitespace character.
|
||||
|
||||
Check for duplicate parameter names in methods.
|
||||
|
||||
Don't allow shorthand properties when they are generators or async methods.
|
||||
|
||||
Forbid binding `await` in async arrow function's parameter list.
|
||||
|
||||
## 6.0.6 (2019-01-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The content of class declarations and expressions is now always parsed in strict mode.
|
||||
|
||||
Don't allow `let` or `const` to bind the variable name `let`.
|
||||
|
||||
Treat class declarations as lexical.
|
||||
|
||||
Don't allow a generator function declaration as the sole body of an `if` or `else`.
|
||||
|
||||
Ignore `"use strict"` when after an empty statement.
|
||||
|
||||
Allow string line continuations with special line terminator characters.
|
||||
|
||||
Treat `for` bodies as part of the `for` scope when checking for conflicting bindings.
|
||||
|
||||
Fix bug with parsing `yield` in a `for` loop initializer.
|
||||
|
||||
Implement special cases around scope checking for functions.
|
||||
|
||||
## 6.0.5 (2019-01-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix TypeScript type for `Parser.extend` and add `allowAwaitOutsideFunction` to options type.
|
||||
|
||||
Don't treat `let` as a keyword when the next token is `{` on the next line.
|
||||
|
||||
Fix bug that broke checking for parentheses around an object pattern in a destructuring assignment when `preserveParens` was on.
|
||||
|
||||
## 6.0.4 (2018-11-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Further improvements to tokenizing regular expressions in corner cases.
|
||||
|
||||
## 6.0.3 (2018-11-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bug in tokenizing an expression-less return followed by a function followed by a regular expression.
|
||||
|
||||
Remove stray symlink in the package tarball.
|
||||
|
||||
## 6.0.2 (2018-09-26)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bug where default expressions could fail to parse inside an object destructuring assignment expression.
|
||||
|
||||
## 6.0.1 (2018-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix wrong value in `version` export.
|
||||
|
||||
## 6.0.0 (2018-09-14)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Better handle variable-redefinition checks for catch bindings and functions directly under if statements.
|
||||
|
||||
Forbid `new.target` in top-level arrow functions.
|
||||
|
||||
Fix issue with parsing a regexp after `yield` in some contexts.
|
||||
|
||||
### New features
|
||||
|
||||
The package now comes with TypeScript definitions.
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The default value of the `ecmaVersion` option is now 9 (2018).
|
||||
|
||||
Plugins work differently, and will have to be rewritten to work with this version.
|
||||
|
||||
The loose parser and walker have been moved into separate packages (`acorn-loose` and `acorn-walk`).
|
||||
|
||||
## 5.7.3 (2018-09-10)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix failure to tokenize regexps after expressions like `x.of`.
|
||||
|
||||
Better error message for unterminated template literals.
|
||||
|
||||
## 5.7.2 (2018-08-24)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Properly handle `allowAwaitOutsideFunction` in for statements.
|
||||
|
||||
Treat function declarations at the top level of modules like let bindings.
|
||||
|
||||
Don't allow async function declarations as the only statement under a label.
|
||||
|
||||
## 5.7.0 (2018-06-15)
|
||||
|
||||
### New features
|
||||
|
||||
Upgraded to Unicode 11.
|
||||
|
||||
## 5.6.0 (2018-05-31)
|
||||
|
||||
### New features
|
||||
|
||||
Allow U+2028 and U+2029 in string when ECMAVersion >= 10.
|
||||
|
||||
Allow binding-less catch statements when ECMAVersion >= 10.
|
||||
|
||||
Add `allowAwaitOutsideFunction` option for parsing top-level `await`.
|
||||
|
||||
## 5.5.3 (2018-03-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
A _second_ republish of the code in 5.5.1, this time with yarn, to hopefully get valid timestamps.
|
||||
|
||||
## 5.5.2 (2018-03-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
A republish of the code in 5.5.1 in an attempt to solve an issue with the file timestamps in the npm package being 0.
|
||||
|
||||
## 5.5.1 (2018-03-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix misleading error message for octal escapes in template strings.
|
||||
|
||||
## 5.5.0 (2018-02-27)
|
||||
|
||||
### New features
|
||||
|
||||
The identifier character categorization is now based on Unicode version 10.
|
||||
|
||||
Acorn will now validate the content of regular expressions, including new ES9 features.
|
||||
|
||||
## 5.4.0 (2018-02-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disallow duplicate or escaped flags on regular expressions.
|
||||
|
||||
Disallow octal escapes in strings in strict mode.
|
||||
|
||||
### New features
|
||||
|
||||
Add support for async iteration.
|
||||
|
||||
Add support for object spread and rest.
|
||||
|
||||
## 5.3.0 (2017-12-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix parsing of floating point literals with leading zeroes in loose mode.
|
||||
|
||||
Allow duplicate property names in object patterns.
|
||||
|
||||
Don't allow static class methods named `prototype`.
|
||||
|
||||
Disallow async functions directly under `if` or `else`.
|
||||
|
||||
Parse right-hand-side of `for`/`of` as an assignment expression.
|
||||
|
||||
Stricter parsing of `for`/`in`.
|
||||
|
||||
Don't allow unicode escapes in contextual keywords.
|
||||
|
||||
### New features
|
||||
|
||||
Parsing class members was factored into smaller methods to allow plugins to hook into it.
|
||||
|
||||
## 5.2.1 (2017-10-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix a token context corruption bug.
|
||||
|
||||
## 5.2.0 (2017-10-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix token context tracking for `class` and `function` in property-name position.
|
||||
|
||||
Make sure `%*` isn't parsed as a valid operator.
|
||||
|
||||
Allow shorthand properties `get` and `set` to be followed by default values.
|
||||
|
||||
Disallow `super` when not in callee or object position.
|
||||
|
||||
### New features
|
||||
|
||||
Support [`directive` property](https://github.com/estree/estree/compare/b3de58c9997504d6fba04b72f76e6dd1619ee4eb...1da8e603237144f44710360f8feb7a9977e905e0) on directive expression statements.
|
||||
|
||||
## 5.1.2 (2017-09-04)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disable parsing of legacy HTML-style comments in modules.
|
||||
|
||||
Fix parsing of async methods whose names are keywords.
|
||||
|
||||
## 5.1.1 (2017-07-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix problem with disambiguating regexp and division after a class.
|
||||
|
||||
## 5.1.0 (2017-07-05)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix tokenizing of regexps in an object-desctructuring `for`/`of` loop and after `yield`.
|
||||
|
||||
Parse zero-prefixed numbers with non-octal digits as decimal.
|
||||
|
||||
Allow object/array patterns in rest parameters.
|
||||
|
||||
Don't error when `yield` is used as a property name.
|
||||
|
||||
Allow `async` as a shorthand object property.
|
||||
|
||||
### New features
|
||||
|
||||
Implement the [template literal revision proposal](https://github.com/tc39/proposal-template-literal-revision) for ES9.
|
||||
|
||||
## 5.0.3 (2017-04-01)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix spurious duplicate variable definition errors for named functions.
|
||||
|
||||
## 5.0.2 (2017-03-30)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
A binary operator after a parenthesized arrow expression is no longer incorrectly treated as an error.
|
||||
|
||||
## 5.0.0 (2017-03-28)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Raise an error for duplicated lexical bindings.
|
||||
|
||||
Fix spurious error when an assignement expression occurred after a spread expression.
|
||||
|
||||
Accept regular expressions after `of` (in `for`/`of`), `yield` (in a generator), and braced arrow functions.
|
||||
|
||||
Allow labels in front or `var` declarations, even in strict mode.
|
||||
|
||||
### Breaking changes
|
||||
|
||||
Parse declarations following `export default` as declaration nodes, not expressions. This means that class and function declarations nodes can now have `null` as their `id`.
|
||||
|
||||
## 4.0.11 (2017-02-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow all forms of member expressions to be parenthesized as lvalue.
|
||||
|
||||
## 4.0.10 (2017-02-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't expect semicolons after default-exported functions or classes, even when they are expressions.
|
||||
|
||||
Check for use of `'use strict'` directives in non-simple parameter functions, even when already in strict mode.
|
||||
|
||||
## 4.0.9 (2017-02-06)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix incorrect error raised for parenthesized simple assignment targets, so that `(x) = 1` parses again.
|
||||
|
||||
## 4.0.8 (2017-02-03)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Solve spurious parenthesized pattern errors by temporarily erring on the side of accepting programs that our delayed errors don't handle correctly yet.
|
||||
|
||||
## 4.0.7 (2017-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Accept invalidly rejected code like `(x).y = 2` again.
|
||||
|
||||
Don't raise an error when a function _inside_ strict code has a non-simple parameter list.
|
||||
|
||||
## 4.0.6 (2017-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix exponential behavior (manifesting itself as a complete hang for even relatively small source files) introduced by the new 'use strict' check.
|
||||
|
||||
## 4.0.5 (2017-02-02)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Disallow parenthesized pattern expressions.
|
||||
|
||||
Allow keywords as export names.
|
||||
|
||||
Don't allow the `async` keyword to be parenthesized.
|
||||
|
||||
Properly raise an error when a keyword contains a character escape.
|
||||
|
||||
Allow `"use strict"` to appear after other string literal expressions.
|
||||
|
||||
Disallow labeled declarations.
|
||||
|
||||
## 4.0.4 (2016-12-19)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix crash when `export` was followed by a keyword that can't be
|
||||
exported.
|
||||
|
||||
## 4.0.3 (2016-08-16)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Allow regular function declarations inside single-statement `if` branches in loose mode. Forbid them entirely in strict mode.
|
||||
|
||||
Properly parse properties named `async` in ES2017 mode.
|
||||
|
||||
Fix bug where reserved words were broken in ES2017 mode.
|
||||
|
||||
## 4.0.2 (2016-08-11)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Don't ignore period or 'e' characters after octal numbers.
|
||||
|
||||
Fix broken parsing for call expressions in default parameter values of arrow functions.
|
||||
|
||||
## 4.0.1 (2016-08-08)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix false positives in duplicated export name errors.
|
||||
|
||||
## 4.0.0 (2016-08-07)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The default `ecmaVersion` option value is now 7.
|
||||
|
||||
A number of internal method signatures changed, so plugins might need to be updated.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
The parser now raises errors on duplicated export names.
|
||||
|
||||
`arguments` and `eval` can now be used in shorthand properties.
|
||||
|
||||
Duplicate parameter names in non-simple argument lists now always produce an error.
|
||||
|
||||
### New features
|
||||
|
||||
The `ecmaVersion` option now also accepts year-style version numbers
|
||||
(2015, etc).
|
||||
|
||||
Support for `async`/`await` syntax when `ecmaVersion` is >= 8.
|
||||
|
||||
Support for trailing commas in call expressions when `ecmaVersion` is >= 8.
|
||||
|
||||
## 3.3.0 (2016-07-25)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Fix bug in tokenizing of regexp operator after a function declaration.
|
||||
|
||||
Fix parser crash when parsing an array pattern with a hole.
|
||||
|
||||
### New features
|
||||
|
||||
Implement check against complex argument lists in functions that enable strict mode in ES7.
|
||||
|
||||
## 3.2.0 (2016-06-07)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Improve handling of lack of unicode regexp support in host
|
||||
environment.
|
||||
|
||||
Properly reject shorthand properties whose name is a keyword.
|
||||
|
||||
### New features
|
||||
|
||||
Visitors created with `visit.make` now have their base as _prototype_, rather than copying properties into a fresh object.
|
||||
|
||||
## 3.1.0 (2016-04-18)
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Properly tokenize the division operator directly after a function expression.
|
||||
|
||||
Allow trailing comma in destructuring arrays.
|
||||
|
||||
## 3.0.4 (2016-02-25)
|
||||
|
||||
### Fixes
|
||||
|
||||
Allow update expressions as left-hand-side of the ES7 exponential operator.
|
||||
|
||||
## 3.0.2 (2016-02-10)
|
||||
|
||||
### Fixes
|
||||
|
||||
Fix bug that accidentally made `undefined` a reserved word when parsing ES7.
|
||||
|
||||
## 3.0.0 (2016-02-10)
|
||||
|
||||
### Breaking changes
|
||||
|
||||
The default value of the `ecmaVersion` option is now 6 (used to be 5).
|
||||
|
||||
Support for comprehension syntax (which was dropped from the draft spec) has been removed.
|
||||
|
||||
### Fixes
|
||||
|
||||
`let` and `yield` are now “contextual keywords”, meaning you can mostly use them as identifiers in ES5 non-strict code.
|
||||
|
||||
A parenthesized class or function expression after `export default` is now parsed correctly.
|
||||
|
||||
### New features
|
||||
|
||||
When `ecmaVersion` is set to 7, Acorn will parse the exponentiation operator (`**`).
|
||||
|
||||
The identifier character ranges are now based on Unicode 8.0.0.
|
||||
|
||||
Plugins can now override the `raiseRecoverable` method to override the way non-critical errors are handled.
|
||||
|
||||
## 2.7.0 (2016-01-04)
|
||||
|
||||
### Fixes
|
||||
|
||||
Stop allowing rest parameters in setters.
|
||||
|
||||
Disallow `y` rexexp flag in ES5.
|
||||
|
||||
Disallow `\00` and `\000` escapes in strict mode.
|
||||
|
||||
Raise an error when an import name is a reserved word.
|
||||
|
||||
## 2.6.2 (2015-11-10)
|
||||
|
||||
### Fixes
|
||||
|
||||
Don't crash when no options object is passed.
|
||||
|
||||
## 2.6.0 (2015-11-09)
|
||||
|
||||
### Fixes
|
||||
|
||||
Add `await` as a reserved word in module sources.
|
||||
|
||||
Disallow `yield` in a parameter default value for a generator.
|
||||
|
||||
Forbid using a comma after a rest pattern in an array destructuring.
|
||||
|
||||
### New features
|
||||
|
||||
Support parsing stdin in command-line tool.
|
||||
|
||||
## 2.5.0 (2015-10-27)
|
||||
|
||||
### Fixes
|
||||
|
||||
Fix tokenizer support in the command-line tool.
|
||||
|
||||
Stop allowing `new.target` outside of functions.
|
||||
|
||||
Remove legacy `guard` and `guardedHandler` properties from try nodes.
|
||||
|
||||
Stop allowing multiple `__proto__` properties on an object literal in strict mode.
|
||||
|
||||
Don't allow rest parameters to be non-identifier patterns.
|
||||
|
||||
Check for duplicate paramter names in arrow functions.
|
21
node_modules/acorn/LICENSE
generated
vendored
Normal file
21
node_modules/acorn/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2012-2022 by various contributors (see AUTHORS)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
273
node_modules/acorn/README.md
generated
vendored
Normal file
273
node_modules/acorn/README.md
generated
vendored
Normal file
@ -0,0 +1,273 @@
|
||||
# Acorn
|
||||
|
||||
A tiny, fast JavaScript parser written in JavaScript.
|
||||
|
||||
## Community
|
||||
|
||||
Acorn is open source software released under an
|
||||
[MIT license](https://github.com/acornjs/acorn/blob/master/acorn/LICENSE).
|
||||
|
||||
You are welcome to
|
||||
[report bugs](https://github.com/acornjs/acorn/issues) or create pull
|
||||
requests on [github](https://github.com/acornjs/acorn). For questions
|
||||
and discussion, please use the
|
||||
[Tern discussion forum](https://discuss.ternjs.net).
|
||||
|
||||
## Installation
|
||||
|
||||
The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
|
||||
|
||||
```sh
|
||||
npm install acorn
|
||||
```
|
||||
|
||||
Alternately, you can download the source and build acorn yourself:
|
||||
|
||||
```sh
|
||||
git clone https://github.com/acornjs/acorn.git
|
||||
cd acorn
|
||||
npm install
|
||||
```
|
||||
|
||||
## Interface
|
||||
|
||||
**parse**`(input, options)` is the main interface to the library. The
|
||||
`input` parameter is a string, `options` must be an object setting
|
||||
some of the options listed below. The return value will be an abstract
|
||||
syntax tree object as specified by the [ESTree
|
||||
spec](https://github.com/estree/estree).
|
||||
|
||||
```javascript
|
||||
let acorn = require("acorn");
|
||||
console.log(acorn.parse("1 + 1", {ecmaVersion: 2020}));
|
||||
```
|
||||
|
||||
When encountering a syntax error, the parser will raise a
|
||||
`SyntaxError` object with a meaningful message. The error object will
|
||||
have a `pos` property that indicates the string offset at which the
|
||||
error occurred, and a `loc` object that contains a `{line, column}`
|
||||
object referring to that same position.
|
||||
|
||||
Options are provided by in a second argument, which should be an
|
||||
object containing any of these fields (only `ecmaVersion` is
|
||||
required):
|
||||
|
||||
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
|
||||
either 3, 5, 6 (or 2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019),
|
||||
11 (2020), 12 (2021), 13 (2022), 14 (2023), or `"latest"` (the
|
||||
latest the library supports). This influences support for strict
|
||||
mode, the set of reserved words, and support for new syntax
|
||||
features.
|
||||
|
||||
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
|
||||
implemented by Acorn. Other proposed new features must be
|
||||
implemented through plugins.
|
||||
|
||||
- **sourceType**: Indicate the mode the code should be parsed in. Can be
|
||||
either `"script"` or `"module"`. This influences global strict mode
|
||||
and parsing of `import` and `export` declarations.
|
||||
|
||||
**NOTE**: If set to `"module"`, then static `import` / `export` syntax
|
||||
will be valid, even if `ecmaVersion` is less than 6.
|
||||
|
||||
- **onInsertedSemicolon**: If given a callback, that callback will be
|
||||
called whenever a missing semicolon is inserted by the parser. The
|
||||
callback will be given the character offset of the point where the
|
||||
semicolon is inserted as argument, and if `locations` is on, also a
|
||||
`{line, column}` object representing this position.
|
||||
|
||||
- **onTrailingComma**: Like `onInsertedSemicolon`, but for trailing
|
||||
commas.
|
||||
|
||||
- **allowReserved**: If `false`, using a reserved word will generate
|
||||
an error. Defaults to `true` for `ecmaVersion` 3, `false` for higher
|
||||
versions. When given the value `"never"`, reserved words and
|
||||
keywords can also not be used as property names (as in Internet
|
||||
Explorer's old parser).
|
||||
|
||||
- **allowReturnOutsideFunction**: By default, a return statement at
|
||||
the top level raises an error. Set this to `true` to accept such
|
||||
code.
|
||||
|
||||
- **allowImportExportEverywhere**: By default, `import` and `export`
|
||||
declarations can only appear at a program's top level. Setting this
|
||||
option to `true` allows them anywhere where a statement is allowed,
|
||||
and also allows `import.meta` expressions to appear in scripts
|
||||
(when `sourceType` is not `"module"`).
|
||||
|
||||
- **allowAwaitOutsideFunction**: If `false`, `await` expressions can
|
||||
only appear inside `async` functions. Defaults to `true` for
|
||||
`ecmaVersion` 2022 and later, `false` for lower versions. Setting this option to
|
||||
`true` allows to have top-level `await` expressions. They are
|
||||
still not allowed in non-`async` functions, though.
|
||||
|
||||
- **allowSuperOutsideMethod**: By default, `super` outside a method
|
||||
raises an error. Set this to `true` to accept such code.
|
||||
|
||||
- **allowHashBang**: When this is enabled, if the code starts with the
|
||||
characters `#!` (as in a shellscript), the first line will be
|
||||
treated as a comment. Defaults to true when `ecmaVersion` >= 2023.
|
||||
|
||||
- **locations**: When `true`, each node has a `loc` object attached
|
||||
with `start` and `end` subobjects, each of which contains the
|
||||
one-based line and zero-based column numbers in `{line, column}`
|
||||
form. Default is `false`.
|
||||
|
||||
- **onToken**: If a function is passed for this option, each found
|
||||
token will be passed in same format as tokens returned from
|
||||
`tokenizer().getToken()`.
|
||||
|
||||
If array is passed, each found token is pushed to it.
|
||||
|
||||
Note that you are not allowed to call the parser from the
|
||||
callback—that will corrupt its internal state.
|
||||
|
||||
- **onComment**: If a function is passed for this option, whenever a
|
||||
comment is encountered the function will be called with the
|
||||
following parameters:
|
||||
|
||||
- `block`: `true` if the comment is a block comment, false if it
|
||||
is a line comment.
|
||||
- `text`: The content of the comment.
|
||||
- `start`: Character offset of the start of the comment.
|
||||
- `end`: Character offset of the end of the comment.
|
||||
|
||||
When the `locations` options is on, the `{line, column}` locations
|
||||
of the comment’s start and end are passed as two additional
|
||||
parameters.
|
||||
|
||||
If array is passed for this option, each found comment is pushed
|
||||
to it as object in Esprima format:
|
||||
|
||||
```javascript
|
||||
{
|
||||
"type": "Line" | "Block",
|
||||
"value": "comment text",
|
||||
"start": Number,
|
||||
"end": Number,
|
||||
// If `locations` option is on:
|
||||
"loc": {
|
||||
"start": {line: Number, column: Number}
|
||||
"end": {line: Number, column: Number}
|
||||
},
|
||||
// If `ranges` option is on:
|
||||
"range": [Number, Number]
|
||||
}
|
||||
```
|
||||
|
||||
Note that you are not allowed to call the parser from the
|
||||
callback—that will corrupt its internal state.
|
||||
|
||||
- **ranges**: Nodes have their start and end characters offsets
|
||||
recorded in `start` and `end` properties (directly on the node,
|
||||
rather than the `loc` object, which holds line/column data. To also
|
||||
add a
|
||||
[semi-standardized](https://bugzilla.mozilla.org/show_bug.cgi?id=745678)
|
||||
`range` property holding a `[start, end]` array with the same
|
||||
numbers, set the `ranges` option to `true`.
|
||||
|
||||
- **program**: It is possible to parse multiple files into a single
|
||||
AST by passing the tree produced by parsing the first file as the
|
||||
`program` option in subsequent parses. This will add the toplevel
|
||||
forms of the parsed file to the "Program" (top) node of an existing
|
||||
parse tree.
|
||||
|
||||
- **sourceFile**: When the `locations` option is `true`, you can pass
|
||||
this option to add a `source` attribute in every node’s `loc`
|
||||
object. Note that the contents of this option are not examined or
|
||||
processed in any way; you are free to use whatever format you
|
||||
choose.
|
||||
|
||||
- **directSourceFile**: Like `sourceFile`, but a `sourceFile` property
|
||||
will be added (regardless of the `location` option) directly to the
|
||||
nodes, rather than the `loc` object.
|
||||
|
||||
- **preserveParens**: If this option is `true`, parenthesized expressions
|
||||
are represented by (non-standard) `ParenthesizedExpression` nodes
|
||||
that have a single `expression` property containing the expression
|
||||
inside parentheses.
|
||||
|
||||
**parseExpressionAt**`(input, offset, options)` will parse a single
|
||||
expression in a string, and return its AST. It will not complain if
|
||||
there is more of the string left after the expression.
|
||||
|
||||
**tokenizer**`(input, options)` returns an object with a `getToken`
|
||||
method that can be called repeatedly to get the next token, a `{start,
|
||||
end, type, value}` object (with added `loc` property when the
|
||||
`locations` option is enabled and `range` property when the `ranges`
|
||||
option is enabled). When the token's type is `tokTypes.eof`, you
|
||||
should stop calling the method, since it will keep returning that same
|
||||
token forever.
|
||||
|
||||
In ES6 environment, returned result can be used as any other
|
||||
protocol-compliant iterable:
|
||||
|
||||
```javascript
|
||||
for (let token of acorn.tokenizer(str)) {
|
||||
// iterate over the tokens
|
||||
}
|
||||
|
||||
// transform code to array of tokens:
|
||||
var tokens = [...acorn.tokenizer(str)];
|
||||
```
|
||||
|
||||
**tokTypes** holds an object mapping names to the token type objects
|
||||
that end up in the `type` properties of tokens.
|
||||
|
||||
**getLineInfo**`(input, offset)` can be used to get a `{line,
|
||||
column}` object for a given program string and offset.
|
||||
|
||||
### The `Parser` class
|
||||
|
||||
Instances of the **`Parser`** class contain all the state and logic
|
||||
that drives a parse. It has static methods `parse`,
|
||||
`parseExpressionAt`, and `tokenizer` that match the top-level
|
||||
functions by the same name.
|
||||
|
||||
When extending the parser with plugins, you need to call these methods
|
||||
on the extended version of the class. To extend a parser with plugins,
|
||||
you can use its static `extend` method.
|
||||
|
||||
```javascript
|
||||
var acorn = require("acorn");
|
||||
var jsx = require("acorn-jsx");
|
||||
var JSXParser = acorn.Parser.extend(jsx());
|
||||
JSXParser.parse("foo(<bar/>)", {ecmaVersion: 2020});
|
||||
```
|
||||
|
||||
The `extend` method takes any number of plugin values, and returns a
|
||||
new `Parser` class that includes the extra parser logic provided by
|
||||
the plugins.
|
||||
|
||||
## Command line interface
|
||||
|
||||
The `bin/acorn` utility can be used to parse a file from the command
|
||||
line. It accepts as arguments its input file and the following
|
||||
options:
|
||||
|
||||
- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version
|
||||
to parse. Default is version 9.
|
||||
|
||||
- `--module`: Sets the parsing mode to `"module"`. Is set to `"script"` otherwise.
|
||||
|
||||
- `--locations`: Attaches a "loc" object to each node with "start" and
|
||||
"end" subobjects, each of which contains the one-based line and
|
||||
zero-based column numbers in `{line, column}` form.
|
||||
|
||||
- `--allow-hash-bang`: If the code starts with the characters #! (as
|
||||
in a shellscript), the first line will be treated as a comment.
|
||||
|
||||
- `--allow-await-outside-function`: Allows top-level `await` expressions.
|
||||
See the `allowAwaitOutsideFunction` option for more information.
|
||||
|
||||
- `--compact`: No whitespace is used in the AST output.
|
||||
|
||||
- `--silent`: Do not output the AST, just return the exit status.
|
||||
|
||||
- `--help`: Print the usage information and quit.
|
||||
|
||||
The utility spits out the syntax tree as JSON data.
|
||||
|
||||
## Existing plugins
|
||||
|
||||
- [`acorn-jsx`](https://github.com/RReverser/acorn-jsx): Parse [Facebook JSX syntax extensions](https://github.com/facebook/jsx)
|
4
node_modules/acorn/bin/acorn
generated
vendored
Executable file
4
node_modules/acorn/bin/acorn
generated
vendored
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict"
|
||||
|
||||
require("../dist/bin.js")
|
252
node_modules/acorn/dist/acorn.d.ts
generated
vendored
Normal file
252
node_modules/acorn/dist/acorn.d.ts
generated
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
export as namespace acorn
|
||||
export = acorn
|
||||
|
||||
declare namespace acorn {
|
||||
function parse(input: string, options: Options): Node
|
||||
|
||||
function parseExpressionAt(input: string, pos: number, options: Options): Node
|
||||
|
||||
function tokenizer(input: string, options: Options): {
|
||||
getToken(): Token
|
||||
[Symbol.iterator](): Iterator<Token>
|
||||
}
|
||||
|
||||
type ecmaVersion = 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 'latest'
|
||||
|
||||
interface Options {
|
||||
ecmaVersion: ecmaVersion
|
||||
sourceType?: 'script' | 'module'
|
||||
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
||||
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
|
||||
allowReserved?: boolean | 'never'
|
||||
allowReturnOutsideFunction?: boolean
|
||||
allowImportExportEverywhere?: boolean
|
||||
allowAwaitOutsideFunction?: boolean
|
||||
allowSuperOutsideMethod?: boolean
|
||||
allowHashBang?: boolean
|
||||
locations?: boolean
|
||||
onToken?: ((token: Token) => any) | Token[]
|
||||
onComment?: ((
|
||||
isBlock: boolean, text: string, start: number, end: number, startLoc?: Position,
|
||||
endLoc?: Position
|
||||
) => void) | Comment[]
|
||||
ranges?: boolean
|
||||
program?: Node
|
||||
sourceFile?: string
|
||||
directSourceFile?: string
|
||||
preserveParens?: boolean
|
||||
}
|
||||
|
||||
class Parser {
|
||||
// state.js
|
||||
lineStart: number;
|
||||
options: Options;
|
||||
curLine: number;
|
||||
start: number;
|
||||
end: number;
|
||||
input: string;
|
||||
type: TokenType;
|
||||
|
||||
// state.js
|
||||
constructor(options: Options, input: string, startPos?: number)
|
||||
parse(this: Parser): Node
|
||||
|
||||
// tokenize.js
|
||||
next(): void;
|
||||
nextToken(): void;
|
||||
|
||||
// statement.js
|
||||
parseTopLevel(node: Node): Node;
|
||||
|
||||
// node.js
|
||||
finishNode(node: Node, type: string): Node;
|
||||
finishNodeAt(node: Node, type: string, pos: number, loc: Position): Node;
|
||||
|
||||
// location.js
|
||||
raise(pos: number, message: string) : void;
|
||||
raiseRecoverable?(pos: number, message: string) : void;
|
||||
|
||||
// parseutils.js
|
||||
unexpected(pos: number) : void;
|
||||
|
||||
// index.js
|
||||
static acorn: typeof acorn;
|
||||
|
||||
// state.js
|
||||
static parse(this: typeof Parser, input: string, options: Options): Node
|
||||
static parseExpressionAt(this: typeof Parser, input: string, pos: number, options: Options): Node
|
||||
static tokenizer(this: typeof Parser, input: string, options: Options): {
|
||||
getToken(): Token
|
||||
[Symbol.iterator](): Iterator<Token>
|
||||
}
|
||||
static extend(this: typeof Parser, ...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser
|
||||
}
|
||||
|
||||
interface Position { line: number; column: number; offset: number }
|
||||
|
||||
const defaultOptions: Options
|
||||
|
||||
function getLineInfo(input: string, offset: number): Position
|
||||
|
||||
class SourceLocation {
|
||||
start: Position
|
||||
end: Position
|
||||
source?: string | null
|
||||
constructor(p: Parser, start: Position, end: Position)
|
||||
}
|
||||
|
||||
class Node {
|
||||
type: string
|
||||
start: number
|
||||
end: number
|
||||
loc?: SourceLocation
|
||||
sourceFile?: string
|
||||
range?: [number, number]
|
||||
constructor(parser: Parser, pos: number, loc?: SourceLocation)
|
||||
}
|
||||
|
||||
class TokenType {
|
||||
label: string
|
||||
keyword: string
|
||||
beforeExpr: boolean
|
||||
startsExpr: boolean
|
||||
isLoop: boolean
|
||||
isAssign: boolean
|
||||
prefix: boolean
|
||||
postfix: boolean
|
||||
binop: number
|
||||
updateContext?: (prevType: TokenType) => void
|
||||
constructor(label: string, conf?: any)
|
||||
}
|
||||
|
||||
const tokTypes: {
|
||||
num: TokenType
|
||||
regexp: TokenType
|
||||
string: TokenType
|
||||
name: TokenType
|
||||
privateId: TokenType
|
||||
eof: TokenType
|
||||
bracketL: TokenType
|
||||
bracketR: TokenType
|
||||
braceL: TokenType
|
||||
braceR: TokenType
|
||||
parenL: TokenType
|
||||
parenR: TokenType
|
||||
comma: TokenType
|
||||
semi: TokenType
|
||||
colon: TokenType
|
||||
dot: TokenType
|
||||
question: TokenType
|
||||
questionDot: TokenType
|
||||
arrow: TokenType
|
||||
template: TokenType
|
||||
invalidTemplate: TokenType
|
||||
ellipsis: TokenType
|
||||
backQuote: TokenType
|
||||
dollarBraceL: TokenType
|
||||
eq: TokenType
|
||||
assign: TokenType
|
||||
incDec: TokenType
|
||||
prefix: TokenType
|
||||
logicalOR: TokenType
|
||||
logicalAND: TokenType
|
||||
bitwiseOR: TokenType
|
||||
bitwiseXOR: TokenType
|
||||
bitwiseAND: TokenType
|
||||
equality: TokenType
|
||||
relational: TokenType
|
||||
bitShift: TokenType
|
||||
plusMin: TokenType
|
||||
modulo: TokenType
|
||||
star: TokenType
|
||||
slash: TokenType
|
||||
starstar: TokenType
|
||||
coalesce: TokenType
|
||||
_break: TokenType
|
||||
_case: TokenType
|
||||
_catch: TokenType
|
||||
_continue: TokenType
|
||||
_debugger: TokenType
|
||||
_default: TokenType
|
||||
_do: TokenType
|
||||
_else: TokenType
|
||||
_finally: TokenType
|
||||
_for: TokenType
|
||||
_function: TokenType
|
||||
_if: TokenType
|
||||
_return: TokenType
|
||||
_switch: TokenType
|
||||
_throw: TokenType
|
||||
_try: TokenType
|
||||
_var: TokenType
|
||||
_const: TokenType
|
||||
_while: TokenType
|
||||
_with: TokenType
|
||||
_new: TokenType
|
||||
_this: TokenType
|
||||
_super: TokenType
|
||||
_class: TokenType
|
||||
_extends: TokenType
|
||||
_export: TokenType
|
||||
_import: TokenType
|
||||
_null: TokenType
|
||||
_true: TokenType
|
||||
_false: TokenType
|
||||
_in: TokenType
|
||||
_instanceof: TokenType
|
||||
_typeof: TokenType
|
||||
_void: TokenType
|
||||
_delete: TokenType
|
||||
}
|
||||
|
||||
class TokContext {
|
||||
constructor(token: string, isExpr: boolean, preserveSpace: boolean, override?: (p: Parser) => void)
|
||||
}
|
||||
|
||||
const tokContexts: {
|
||||
b_stat: TokContext
|
||||
b_expr: TokContext
|
||||
b_tmpl: TokContext
|
||||
p_stat: TokContext
|
||||
p_expr: TokContext
|
||||
q_tmpl: TokContext
|
||||
f_expr: TokContext
|
||||
f_stat: TokContext
|
||||
f_expr_gen: TokContext
|
||||
f_gen: TokContext
|
||||
}
|
||||
|
||||
function isIdentifierStart(code: number, astral?: boolean): boolean
|
||||
|
||||
function isIdentifierChar(code: number, astral?: boolean): boolean
|
||||
|
||||
interface AbstractToken {
|
||||
}
|
||||
|
||||
interface Comment extends AbstractToken {
|
||||
type: 'Line' | 'Block'
|
||||
value: string
|
||||
start: number
|
||||
end: number
|
||||
loc?: SourceLocation
|
||||
range?: [number, number]
|
||||
}
|
||||
|
||||
class Token {
|
||||
type: TokenType
|
||||
value: any
|
||||
start: number
|
||||
end: number
|
||||
loc?: SourceLocation
|
||||
range?: [number, number]
|
||||
constructor(p: Parser)
|
||||
}
|
||||
|
||||
function isNewLine(code: number): boolean
|
||||
|
||||
const lineBreak: RegExp
|
||||
|
||||
const lineBreakG: RegExp
|
||||
|
||||
const version: string
|
||||
}
|
5605
node_modules/acorn/dist/acorn.js
generated
vendored
Normal file
5605
node_modules/acorn/dist/acorn.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5574
node_modules/acorn/dist/acorn.mjs
generated
vendored
Normal file
5574
node_modules/acorn/dist/acorn.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/acorn/dist/acorn.mjs.d.ts
generated
vendored
Normal file
2
node_modules/acorn/dist/acorn.mjs.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import * as acorn from "./acorn";
|
||||
export = acorn;
|
91
node_modules/acorn/dist/bin.js
generated
vendored
Normal file
91
node_modules/acorn/dist/bin.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var acorn = require('./acorn.js');
|
||||
|
||||
function _interopNamespace(e) {
|
||||
if (e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (e) {
|
||||
Object.keys(e).forEach(function (k) {
|
||||
if (k !== 'default') {
|
||||
var d = Object.getOwnPropertyDescriptor(e, k);
|
||||
Object.defineProperty(n, k, d.get ? d : {
|
||||
enumerable: true,
|
||||
get: function () { return e[k]; }
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
n["default"] = e;
|
||||
return Object.freeze(n);
|
||||
}
|
||||
|
||||
var acorn__namespace = /*#__PURE__*/_interopNamespace(acorn);
|
||||
|
||||
var inputFilePaths = [], forceFileName = false, fileMode = false, silent = false, compact = false, tokenize = false;
|
||||
var options = {};
|
||||
|
||||
function help(status) {
|
||||
var print = (status === 0) ? console.log : console.error;
|
||||
print("usage: " + path.basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]");
|
||||
print(" [--tokenize] [--locations] [--allow-hash-bang] [--allow-await-outside-function] [--compact] [--silent] [--module] [--help] [--] [<infile>...]");
|
||||
process.exit(status);
|
||||
}
|
||||
|
||||
for (var i = 2; i < process.argv.length; ++i) {
|
||||
var arg = process.argv[i];
|
||||
if (arg[0] !== "-" || arg === "-") { inputFilePaths.push(arg); }
|
||||
else if (arg === "--") {
|
||||
inputFilePaths.push.apply(inputFilePaths, process.argv.slice(i + 1));
|
||||
forceFileName = true;
|
||||
break
|
||||
} else if (arg === "--locations") { options.locations = true; }
|
||||
else if (arg === "--allow-hash-bang") { options.allowHashBang = true; }
|
||||
else if (arg === "--allow-await-outside-function") { options.allowAwaitOutsideFunction = true; }
|
||||
else if (arg === "--silent") { silent = true; }
|
||||
else if (arg === "--compact") { compact = true; }
|
||||
else if (arg === "--help") { help(0); }
|
||||
else if (arg === "--tokenize") { tokenize = true; }
|
||||
else if (arg === "--module") { options.sourceType = "module"; }
|
||||
else {
|
||||
var match = arg.match(/^--ecma(\d+)$/);
|
||||
if (match)
|
||||
{ options.ecmaVersion = +match[1]; }
|
||||
else
|
||||
{ help(1); }
|
||||
}
|
||||
}
|
||||
|
||||
function run(codeList) {
|
||||
var result = [], fileIdx = 0;
|
||||
try {
|
||||
codeList.forEach(function (code, idx) {
|
||||
fileIdx = idx;
|
||||
if (!tokenize) {
|
||||
result = acorn__namespace.parse(code, options);
|
||||
options.program = result;
|
||||
} else {
|
||||
var tokenizer = acorn__namespace.tokenizer(code, options), token;
|
||||
do {
|
||||
token = tokenizer.getToken();
|
||||
result.push(token);
|
||||
} while (token.type !== acorn__namespace.tokTypes.eof)
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(fileMode ? e.message.replace(/\(\d+:\d+\)$/, function (m) { return m.slice(0, 1) + inputFilePaths[fileIdx] + " " + m.slice(1); }) : e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!silent) { console.log(JSON.stringify(result, null, compact ? null : 2)); }
|
||||
}
|
||||
|
||||
if (fileMode = inputFilePaths.length && (forceFileName || !inputFilePaths.includes("-") || inputFilePaths.length !== 1)) {
|
||||
run(inputFilePaths.map(function (path) { return fs.readFileSync(path, "utf8"); }));
|
||||
} else {
|
||||
var code = "";
|
||||
process.stdin.resume();
|
||||
process.stdin.on("data", function (chunk) { return code += chunk; });
|
||||
process.stdin.on("end", function () { return run([code]); });
|
||||
}
|
50
node_modules/acorn/package.json
generated
vendored
Normal file
50
node_modules/acorn/package.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "acorn",
|
||||
"description": "ECMAScript parser",
|
||||
"homepage": "https://github.com/acornjs/acorn",
|
||||
"main": "dist/acorn.js",
|
||||
"types": "dist/acorn.d.ts",
|
||||
"module": "dist/acorn.mjs",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./dist/acorn.mjs",
|
||||
"require": "./dist/acorn.js",
|
||||
"default": "./dist/acorn.js"
|
||||
},
|
||||
"./dist/acorn.js"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"version": "8.8.1",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Marijn Haverbeke",
|
||||
"email": "marijnh@gmail.com",
|
||||
"web": "https://marijnhaverbeke.nl"
|
||||
},
|
||||
{
|
||||
"name": "Ingvar Stepanyan",
|
||||
"email": "me@rreverser.com",
|
||||
"web": "https://rreverser.com/"
|
||||
},
|
||||
{
|
||||
"name": "Adrian Heine",
|
||||
"web": "http://adrianheine.de"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/acornjs/acorn.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"prepare": "cd ..; npm run build:main"
|
||||
},
|
||||
"bin": {
|
||||
"acorn": "./bin/acorn"
|
||||
}
|
||||
}
|
145
node_modules/agent-base/README.md
generated
vendored
Normal file
145
node_modules/agent-base/README.md
generated
vendored
Normal file
@ -0,0 +1,145 @@
|
||||
agent-base
|
||||
==========
|
||||
### Turn a function into an [`http.Agent`][http.Agent] instance
|
||||
[![Build Status](https://github.com/TooTallNate/node-agent-base/workflows/Node%20CI/badge.svg)](https://github.com/TooTallNate/node-agent-base/actions?workflow=Node+CI)
|
||||
|
||||
This module provides an `http.Agent` generator. That is, you pass it an async
|
||||
callback function, and it returns a new `http.Agent` instance that will invoke the
|
||||
given callback function when sending outbound HTTP requests.
|
||||
|
||||
#### Some subclasses:
|
||||
|
||||
Here's some more interesting uses of `agent-base`.
|
||||
Send a pull request to list yours!
|
||||
|
||||
* [`http-proxy-agent`][http-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTP endpoints
|
||||
* [`https-proxy-agent`][https-proxy-agent]: An HTTP(s) proxy `http.Agent` implementation for HTTPS endpoints
|
||||
* [`pac-proxy-agent`][pac-proxy-agent]: A PAC file proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
* [`socks-proxy-agent`][socks-proxy-agent]: A SOCKS proxy `http.Agent` implementation for HTTP and HTTPS
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Install with `npm`:
|
||||
|
||||
``` bash
|
||||
$ npm install agent-base
|
||||
```
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
Here's a minimal example that creates a new `net.Socket` connection to the server
|
||||
for every HTTP request (i.e. the equivalent of `agent: false` option):
|
||||
|
||||
```js
|
||||
var net = require('net');
|
||||
var tls = require('tls');
|
||||
var url = require('url');
|
||||
var http = require('http');
|
||||
var agent = require('agent-base');
|
||||
|
||||
var endpoint = 'http://nodejs.org/api/';
|
||||
var parsed = url.parse(endpoint);
|
||||
|
||||
// This is the important part!
|
||||
parsed.agent = agent(function (req, opts) {
|
||||
var socket;
|
||||
// `secureEndpoint` is true when using the https module
|
||||
if (opts.secureEndpoint) {
|
||||
socket = tls.connect(opts);
|
||||
} else {
|
||||
socket = net.connect(opts);
|
||||
}
|
||||
return socket;
|
||||
});
|
||||
|
||||
// Everything else works just like normal...
|
||||
http.get(parsed, function (res) {
|
||||
console.log('"response" event!', res.headers);
|
||||
res.pipe(process.stdout);
|
||||
});
|
||||
```
|
||||
|
||||
Returning a Promise or using an `async` function is also supported:
|
||||
|
||||
```js
|
||||
agent(async function (req, opts) {
|
||||
await sleep(1000);
|
||||
// etc…
|
||||
});
|
||||
```
|
||||
|
||||
Return another `http.Agent` instance to "pass through" the responsibility
|
||||
for that HTTP request to that agent:
|
||||
|
||||
```js
|
||||
agent(function (req, opts) {
|
||||
return opts.secureEndpoint ? https.globalAgent : http.globalAgent;
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
API
|
||||
---
|
||||
|
||||
## Agent(Function callback[, Object options]) → [http.Agent][]
|
||||
|
||||
Creates a base `http.Agent` that will execute the callback function `callback`
|
||||
for every HTTP request that it is used as the `agent` for. The callback function
|
||||
is responsible for creating a `stream.Duplex` instance of some kind that will be
|
||||
used as the underlying socket in the HTTP request.
|
||||
|
||||
The `options` object accepts the following properties:
|
||||
|
||||
* `timeout` - Number - Timeout for the `callback()` function in milliseconds. Defaults to Infinity (optional).
|
||||
|
||||
The callback function should have the following signature:
|
||||
|
||||
### callback(http.ClientRequest req, Object options, Function cb) → undefined
|
||||
|
||||
The ClientRequest `req` can be accessed to read request headers and
|
||||
and the path, etc. The `options` object contains the options passed
|
||||
to the `http.request()`/`https.request()` function call, and is formatted
|
||||
to be directly passed to `net.connect()`/`tls.connect()`, or however
|
||||
else you want a Socket to be created. Pass the created socket to
|
||||
the callback function `cb` once created, and the HTTP request will
|
||||
continue to proceed.
|
||||
|
||||
If the `https` module is used to invoke the HTTP request, then the
|
||||
`secureEndpoint` property on `options` _will be set to `true`_.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[http-proxy-agent]: https://github.com/TooTallNate/node-http-proxy-agent
|
||||
[https-proxy-agent]: https://github.com/TooTallNate/node-https-proxy-agent
|
||||
[pac-proxy-agent]: https://github.com/TooTallNate/node-pac-proxy-agent
|
||||
[socks-proxy-agent]: https://github.com/TooTallNate/node-socks-proxy-agent
|
||||
[http.Agent]: https://nodejs.org/api/http.html#http_class_http_agent
|
78
node_modules/agent-base/dist/src/index.d.ts
generated
vendored
Normal file
78
node_modules/agent-base/dist/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/// <reference types="node" />
|
||||
import net from 'net';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import { Duplex } from 'stream';
|
||||
import { EventEmitter } from 'events';
|
||||
declare function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
|
||||
declare function createAgent(callback: createAgent.AgentCallback, opts?: createAgent.AgentOptions): createAgent.Agent;
|
||||
declare namespace createAgent {
|
||||
interface ClientRequest extends http.ClientRequest {
|
||||
_last?: boolean;
|
||||
_hadError?: boolean;
|
||||
method: string;
|
||||
}
|
||||
interface AgentRequestOptions {
|
||||
host?: string;
|
||||
path?: string;
|
||||
port: number;
|
||||
}
|
||||
interface HttpRequestOptions extends AgentRequestOptions, Omit<http.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: false;
|
||||
}
|
||||
interface HttpsRequestOptions extends AgentRequestOptions, Omit<https.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: true;
|
||||
}
|
||||
type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
|
||||
type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
|
||||
type AgentCallbackReturn = Duplex | AgentLike;
|
||||
type AgentCallbackCallback = (err?: Error | null, socket?: createAgent.AgentCallbackReturn) => void;
|
||||
type AgentCallbackPromise = (req: createAgent.ClientRequest, opts: createAgent.RequestOptions) => createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
|
||||
type AgentCallback = typeof Agent.prototype.callback;
|
||||
type AgentOptions = {
|
||||
timeout?: number;
|
||||
};
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
class Agent extends EventEmitter {
|
||||
timeout: number | null;
|
||||
maxFreeSockets: number;
|
||||
maxTotalSockets: number;
|
||||
maxSockets: number;
|
||||
sockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
freeSockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
requests: {
|
||||
[key: string]: http.IncomingMessage[];
|
||||
};
|
||||
options: https.AgentOptions;
|
||||
private promisifiedCallback?;
|
||||
private explicitDefaultPort?;
|
||||
private explicitProtocol?;
|
||||
constructor(callback?: createAgent.AgentCallback | createAgent.AgentOptions, _opts?: createAgent.AgentOptions);
|
||||
get defaultPort(): number;
|
||||
set defaultPort(v: number);
|
||||
get protocol(): string;
|
||||
set protocol(v: string);
|
||||
callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions, fn: createAgent.AgentCallbackCallback): void;
|
||||
callback(req: createAgent.ClientRequest, opts: createAgent.RequestOptions): createAgent.AgentCallbackReturn | Promise<createAgent.AgentCallbackReturn>;
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req: ClientRequest, _opts: RequestOptions): void;
|
||||
freeSocket(socket: net.Socket, opts: AgentOptions): void;
|
||||
destroy(): void;
|
||||
}
|
||||
}
|
||||
export = createAgent;
|
203
node_modules/agent-base/dist/src/index.js
generated
vendored
Normal file
203
node_modules/agent-base/dist/src/index.js
generated
vendored
Normal file
@ -0,0 +1,203 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
const events_1 = require("events");
|
||||
const debug_1 = __importDefault(require("debug"));
|
||||
const promisify_1 = __importDefault(require("./promisify"));
|
||||
const debug = debug_1.default('agent-base');
|
||||
function isAgent(v) {
|
||||
return Boolean(v) && typeof v.addRequest === 'function';
|
||||
}
|
||||
function isSecureEndpoint() {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string')
|
||||
return false;
|
||||
return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
function createAgent(callback, opts) {
|
||||
return new createAgent.Agent(callback, opts);
|
||||
}
|
||||
(function (createAgent) {
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
class Agent extends events_1.EventEmitter {
|
||||
constructor(callback, _opts) {
|
||||
super();
|
||||
let opts = _opts;
|
||||
if (typeof callback === 'function') {
|
||||
this.callback = callback;
|
||||
}
|
||||
else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
// Timeout for the socket to be returned from the callback
|
||||
this.timeout = null;
|
||||
if (opts && typeof opts.timeout === 'number') {
|
||||
this.timeout = opts.timeout;
|
||||
}
|
||||
// These aren't actually used by `agent-base`, but are required
|
||||
// for the TypeScript definition files in `@types/node` :/
|
||||
this.maxFreeSockets = 1;
|
||||
this.maxSockets = 1;
|
||||
this.maxTotalSockets = Infinity;
|
||||
this.sockets = {};
|
||||
this.freeSockets = {};
|
||||
this.requests = {};
|
||||
this.options = {};
|
||||
}
|
||||
get defaultPort() {
|
||||
if (typeof this.explicitDefaultPort === 'number') {
|
||||
return this.explicitDefaultPort;
|
||||
}
|
||||
return isSecureEndpoint() ? 443 : 80;
|
||||
}
|
||||
set defaultPort(v) {
|
||||
this.explicitDefaultPort = v;
|
||||
}
|
||||
get protocol() {
|
||||
if (typeof this.explicitProtocol === 'string') {
|
||||
return this.explicitProtocol;
|
||||
}
|
||||
return isSecureEndpoint() ? 'https:' : 'http:';
|
||||
}
|
||||
set protocol(v) {
|
||||
this.explicitProtocol = v;
|
||||
}
|
||||
callback(req, opts, fn) {
|
||||
throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`');
|
||||
}
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req, _opts) {
|
||||
const opts = Object.assign({}, _opts);
|
||||
if (typeof opts.secureEndpoint !== 'boolean') {
|
||||
opts.secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
if (opts.host == null) {
|
||||
opts.host = 'localhost';
|
||||
}
|
||||
if (opts.port == null) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
if (opts.protocol == null) {
|
||||
opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
||||
}
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most
|
||||
// likely the result of a `url.parse()` call... we need to
|
||||
// remove the `path` portion so that `net.connect()` doesn't
|
||||
// attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
let timedOut = false;
|
||||
let timeoutId = null;
|
||||
const timeoutMs = opts.timeout || this.timeout;
|
||||
const onerror = (err) => {
|
||||
if (req._hadError)
|
||||
return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
};
|
||||
const ontimeout = () => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
const err = new Error(`A "socket" was not created for HTTP request before ${timeoutMs}ms`);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
};
|
||||
const callbackError = (err) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
onerror(err);
|
||||
};
|
||||
const onsocket = (socket) => {
|
||||
if (timedOut)
|
||||
return;
|
||||
if (timeoutId != null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an `http.Agent` instance, so
|
||||
// relinquish responsibility for this `req` to the Agent
|
||||
// from here on
|
||||
debug('Callback returned another Agent instance %o', socket.constructor.name);
|
||||
socket.addRequest(req, opts);
|
||||
return;
|
||||
}
|
||||
if (socket) {
|
||||
socket.once('free', () => {
|
||||
this.freeSocket(socket, opts);
|
||||
});
|
||||
req.onSocket(socket);
|
||||
return;
|
||||
}
|
||||
const err = new Error(`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``);
|
||||
onerror(err);
|
||||
};
|
||||
if (typeof this.callback !== 'function') {
|
||||
onerror(new Error('`callback` is not defined'));
|
||||
return;
|
||||
}
|
||||
if (!this.promisifiedCallback) {
|
||||
if (this.callback.length >= 3) {
|
||||
debug('Converting legacy callback function to promise');
|
||||
this.promisifiedCallback = promisify_1.default(this.callback);
|
||||
}
|
||||
else {
|
||||
this.promisifiedCallback = this.callback;
|
||||
}
|
||||
}
|
||||
if (typeof timeoutMs === 'number' && timeoutMs > 0) {
|
||||
timeoutId = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
if ('port' in opts && typeof opts.port !== 'number') {
|
||||
opts.port = Number(opts.port);
|
||||
}
|
||||
try {
|
||||
debug('Resolving socket for %o request: %o', opts.protocol, `${req.method} ${req.path}`);
|
||||
Promise.resolve(this.promisifiedCallback(req, opts)).then(onsocket, callbackError);
|
||||
}
|
||||
catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
}
|
||||
freeSocket(socket, opts) {
|
||||
debug('Freeing socket %o %o', socket.constructor.name, opts);
|
||||
socket.destroy();
|
||||
}
|
||||
destroy() {
|
||||
debug('Destroying agent %o', this.constructor.name);
|
||||
}
|
||||
}
|
||||
createAgent.Agent = Agent;
|
||||
// So that `instanceof` works correctly
|
||||
createAgent.prototype = createAgent.Agent.prototype;
|
||||
})(createAgent || (createAgent = {}));
|
||||
module.exports = createAgent;
|
||||
//# sourceMappingURL=index.js.map
|
1
node_modules/agent-base/dist/src/index.js.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/src/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/agent-base/dist/src/promisify.d.ts
generated
vendored
Normal file
4
node_modules/agent-base/dist/src/promisify.d.ts
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { ClientRequest, RequestOptions, AgentCallbackCallback, AgentCallbackPromise } from './index';
|
||||
declare type LegacyCallback = (req: ClientRequest, opts: RequestOptions, fn: AgentCallbackCallback) => void;
|
||||
export default function promisify(fn: LegacyCallback): AgentCallbackPromise;
|
||||
export {};
|
18
node_modules/agent-base/dist/src/promisify.js
generated
vendored
Normal file
18
node_modules/agent-base/dist/src/promisify.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function promisify(fn) {
|
||||
return function (req, opts) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn.call(this, req, opts, (err, rtn) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
else {
|
||||
resolve(rtn);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
exports.default = promisify;
|
||||
//# sourceMappingURL=promisify.js.map
|
1
node_modules/agent-base/dist/src/promisify.js.map
generated
vendored
Normal file
1
node_modules/agent-base/dist/src/promisify.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"promisify.js","sourceRoot":"","sources":["../../src/promisify.ts"],"names":[],"mappings":";;AAeA,SAAwB,SAAS,CAAC,EAAkB;IACnD,OAAO,UAAsB,GAAkB,EAAE,IAAoB;QACpE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACtC,EAAE,CAAC,IAAI,CACN,IAAI,EACJ,GAAG,EACH,IAAI,EACJ,CAAC,GAA6B,EAAE,GAAyB,EAAE,EAAE;gBAC5D,IAAI,GAAG,EAAE;oBACR,MAAM,CAAC,GAAG,CAAC,CAAC;iBACZ;qBAAM;oBACN,OAAO,CAAC,GAAG,CAAC,CAAC;iBACb;YACF,CAAC,CACD,CAAC;QACH,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;AACH,CAAC;AAjBD,4BAiBC"}
|
64
node_modules/agent-base/package.json
generated
vendored
Normal file
64
node_modules/agent-base/package.json
generated
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "agent-base",
|
||||
"version": "6.0.2",
|
||||
"description": "Turn a function into an `http.Agent` instance",
|
||||
"main": "dist/src/index",
|
||||
"typings": "dist/src/index",
|
||||
"files": [
|
||||
"dist/src",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "tsc",
|
||||
"postbuild": "cpy --parents src test '!**/*.ts' dist",
|
||||
"test": "mocha --reporter spec dist/test/*.js",
|
||||
"test-lint": "eslint src --ext .js,.ts",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/TooTallNate/node-agent-base.git"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"agent",
|
||||
"base",
|
||||
"barebones",
|
||||
"https"
|
||||
],
|
||||
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://n8.io/)",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TooTallNate/node-agent-base/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/debug": "4",
|
||||
"@types/mocha": "^5.2.7",
|
||||
"@types/node": "^14.0.20",
|
||||
"@types/semver": "^7.1.0",
|
||||
"@types/ws": "^6.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "1.6.0",
|
||||
"@typescript-eslint/parser": "1.1.0",
|
||||
"async-listen": "^1.2.0",
|
||||
"cpy-cli": "^2.0.0",
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-airbnb": "17.1.0",
|
||||
"eslint-config-prettier": "4.1.0",
|
||||
"eslint-import-resolver-typescript": "1.1.1",
|
||||
"eslint-plugin-import": "2.16.0",
|
||||
"eslint-plugin-jsx-a11y": "6.2.1",
|
||||
"eslint-plugin-react": "7.12.4",
|
||||
"mocha": "^6.2.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"semver": "^7.1.2",
|
||||
"typescript": "^3.5.3",
|
||||
"ws": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
}
|
345
node_modules/agent-base/src/index.ts
generated
vendored
Normal file
345
node_modules/agent-base/src/index.ts
generated
vendored
Normal file
@ -0,0 +1,345 @@
|
||||
import net from 'net';
|
||||
import http from 'http';
|
||||
import https from 'https';
|
||||
import { Duplex } from 'stream';
|
||||
import { EventEmitter } from 'events';
|
||||
import createDebug from 'debug';
|
||||
import promisify from './promisify';
|
||||
|
||||
const debug = createDebug('agent-base');
|
||||
|
||||
function isAgent(v: any): v is createAgent.AgentLike {
|
||||
return Boolean(v) && typeof v.addRequest === 'function';
|
||||
}
|
||||
|
||||
function isSecureEndpoint(): boolean {
|
||||
const { stack } = new Error();
|
||||
if (typeof stack !== 'string') return false;
|
||||
return stack.split('\n').some(l => l.indexOf('(https.js:') !== -1 || l.indexOf('node:https:') !== -1);
|
||||
}
|
||||
|
||||
function createAgent(opts?: createAgent.AgentOptions): createAgent.Agent;
|
||||
function createAgent(
|
||||
callback: createAgent.AgentCallback,
|
||||
opts?: createAgent.AgentOptions
|
||||
): createAgent.Agent;
|
||||
function createAgent(
|
||||
callback?: createAgent.AgentCallback | createAgent.AgentOptions,
|
||||
opts?: createAgent.AgentOptions
|
||||
) {
|
||||
return new createAgent.Agent(callback, opts);
|
||||
}
|
||||
|
||||
namespace createAgent {
|
||||
export interface ClientRequest extends http.ClientRequest {
|
||||
_last?: boolean;
|
||||
_hadError?: boolean;
|
||||
method: string;
|
||||
}
|
||||
|
||||
export interface AgentRequestOptions {
|
||||
host?: string;
|
||||
path?: string;
|
||||
// `port` on `http.RequestOptions` can be a string or undefined,
|
||||
// but `net.TcpNetConnectOpts` expects only a number
|
||||
port: number;
|
||||
}
|
||||
|
||||
export interface HttpRequestOptions
|
||||
extends AgentRequestOptions,
|
||||
Omit<http.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: false;
|
||||
}
|
||||
|
||||
export interface HttpsRequestOptions
|
||||
extends AgentRequestOptions,
|
||||
Omit<https.RequestOptions, keyof AgentRequestOptions> {
|
||||
secureEndpoint: true;
|
||||
}
|
||||
|
||||
export type RequestOptions = HttpRequestOptions | HttpsRequestOptions;
|
||||
|
||||
export type AgentLike = Pick<createAgent.Agent, 'addRequest'> | http.Agent;
|
||||
|
||||
export type AgentCallbackReturn = Duplex | AgentLike;
|
||||
|
||||
export type AgentCallbackCallback = (
|
||||
err?: Error | null,
|
||||
socket?: createAgent.AgentCallbackReturn
|
||||
) => void;
|
||||
|
||||
export type AgentCallbackPromise = (
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions
|
||||
) =>
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>;
|
||||
|
||||
export type AgentCallback = typeof Agent.prototype.callback;
|
||||
|
||||
export type AgentOptions = {
|
||||
timeout?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base `http.Agent` implementation.
|
||||
* No pooling/keep-alive is implemented by default.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @api public
|
||||
*/
|
||||
export class Agent extends EventEmitter {
|
||||
public timeout: number | null;
|
||||
public maxFreeSockets: number;
|
||||
public maxTotalSockets: number;
|
||||
public maxSockets: number;
|
||||
public sockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
public freeSockets: {
|
||||
[key: string]: net.Socket[];
|
||||
};
|
||||
public requests: {
|
||||
[key: string]: http.IncomingMessage[];
|
||||
};
|
||||
public options: https.AgentOptions;
|
||||
private promisifiedCallback?: createAgent.AgentCallbackPromise;
|
||||
private explicitDefaultPort?: number;
|
||||
private explicitProtocol?: string;
|
||||
|
||||
constructor(
|
||||
callback?: createAgent.AgentCallback | createAgent.AgentOptions,
|
||||
_opts?: createAgent.AgentOptions
|
||||
) {
|
||||
super();
|
||||
|
||||
let opts = _opts;
|
||||
if (typeof callback === 'function') {
|
||||
this.callback = callback;
|
||||
} else if (callback) {
|
||||
opts = callback;
|
||||
}
|
||||
|
||||
// Timeout for the socket to be returned from the callback
|
||||
this.timeout = null;
|
||||
if (opts && typeof opts.timeout === 'number') {
|
||||
this.timeout = opts.timeout;
|
||||
}
|
||||
|
||||
// These aren't actually used by `agent-base`, but are required
|
||||
// for the TypeScript definition files in `@types/node` :/
|
||||
this.maxFreeSockets = 1;
|
||||
this.maxSockets = 1;
|
||||
this.maxTotalSockets = Infinity;
|
||||
this.sockets = {};
|
||||
this.freeSockets = {};
|
||||
this.requests = {};
|
||||
this.options = {};
|
||||
}
|
||||
|
||||
get defaultPort(): number {
|
||||
if (typeof this.explicitDefaultPort === 'number') {
|
||||
return this.explicitDefaultPort;
|
||||
}
|
||||
return isSecureEndpoint() ? 443 : 80;
|
||||
}
|
||||
|
||||
set defaultPort(v: number) {
|
||||
this.explicitDefaultPort = v;
|
||||
}
|
||||
|
||||
get protocol(): string {
|
||||
if (typeof this.explicitProtocol === 'string') {
|
||||
return this.explicitProtocol;
|
||||
}
|
||||
return isSecureEndpoint() ? 'https:' : 'http:';
|
||||
}
|
||||
|
||||
set protocol(v: string) {
|
||||
this.explicitProtocol = v;
|
||||
}
|
||||
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions,
|
||||
fn: createAgent.AgentCallbackCallback
|
||||
): void;
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.RequestOptions
|
||||
):
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>;
|
||||
callback(
|
||||
req: createAgent.ClientRequest,
|
||||
opts: createAgent.AgentOptions,
|
||||
fn?: createAgent.AgentCallbackCallback
|
||||
):
|
||||
| createAgent.AgentCallbackReturn
|
||||
| Promise<createAgent.AgentCallbackReturn>
|
||||
| void {
|
||||
throw new Error(
|
||||
'"agent-base" has no default implementation, you must subclass and override `callback()`'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by node-core's "_http_client.js" module when creating
|
||||
* a new HTTP request with this Agent instance.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
addRequest(req: ClientRequest, _opts: RequestOptions): void {
|
||||
const opts: RequestOptions = { ..._opts };
|
||||
|
||||
if (typeof opts.secureEndpoint !== 'boolean') {
|
||||
opts.secureEndpoint = isSecureEndpoint();
|
||||
}
|
||||
|
||||
if (opts.host == null) {
|
||||
opts.host = 'localhost';
|
||||
}
|
||||
|
||||
if (opts.port == null) {
|
||||
opts.port = opts.secureEndpoint ? 443 : 80;
|
||||
}
|
||||
|
||||
if (opts.protocol == null) {
|
||||
opts.protocol = opts.secureEndpoint ? 'https:' : 'http:';
|
||||
}
|
||||
|
||||
if (opts.host && opts.path) {
|
||||
// If both a `host` and `path` are specified then it's most
|
||||
// likely the result of a `url.parse()` call... we need to
|
||||
// remove the `path` portion so that `net.connect()` doesn't
|
||||
// attempt to open that as a unix socket file.
|
||||
delete opts.path;
|
||||
}
|
||||
|
||||
delete opts.agent;
|
||||
delete opts.hostname;
|
||||
delete opts._defaultAgent;
|
||||
delete opts.defaultPort;
|
||||
delete opts.createConnection;
|
||||
|
||||
// Hint to use "Connection: close"
|
||||
// XXX: non-documented `http` module API :(
|
||||
req._last = true;
|
||||
req.shouldKeepAlive = false;
|
||||
|
||||
let timedOut = false;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | null = null;
|
||||
const timeoutMs = opts.timeout || this.timeout;
|
||||
|
||||
const onerror = (err: NodeJS.ErrnoException) => {
|
||||
if (req._hadError) return;
|
||||
req.emit('error', err);
|
||||
// For Safety. Some additional errors might fire later on
|
||||
// and we need to make sure we don't double-fire the error event.
|
||||
req._hadError = true;
|
||||
};
|
||||
|
||||
const ontimeout = () => {
|
||||
timeoutId = null;
|
||||
timedOut = true;
|
||||
const err: NodeJS.ErrnoException = new Error(
|
||||
`A "socket" was not created for HTTP request before ${timeoutMs}ms`
|
||||
);
|
||||
err.code = 'ETIMEOUT';
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
const callbackError = (err: NodeJS.ErrnoException) => {
|
||||
if (timedOut) return;
|
||||
if (timeoutId !== null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
const onsocket = (socket: AgentCallbackReturn) => {
|
||||
if (timedOut) return;
|
||||
if (timeoutId != null) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
if (isAgent(socket)) {
|
||||
// `socket` is actually an `http.Agent` instance, so
|
||||
// relinquish responsibility for this `req` to the Agent
|
||||
// from here on
|
||||
debug(
|
||||
'Callback returned another Agent instance %o',
|
||||
socket.constructor.name
|
||||
);
|
||||
(socket as createAgent.Agent).addRequest(req, opts);
|
||||
return;
|
||||
}
|
||||
|
||||
if (socket) {
|
||||
socket.once('free', () => {
|
||||
this.freeSocket(socket as net.Socket, opts);
|
||||
});
|
||||
req.onSocket(socket as net.Socket);
|
||||
return;
|
||||
}
|
||||
|
||||
const err = new Error(
|
||||
`no Duplex stream was returned to agent-base for \`${req.method} ${req.path}\``
|
||||
);
|
||||
onerror(err);
|
||||
};
|
||||
|
||||
if (typeof this.callback !== 'function') {
|
||||
onerror(new Error('`callback` is not defined'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.promisifiedCallback) {
|
||||
if (this.callback.length >= 3) {
|
||||
debug('Converting legacy callback function to promise');
|
||||
this.promisifiedCallback = promisify(this.callback);
|
||||
} else {
|
||||
this.promisifiedCallback = this.callback;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof timeoutMs === 'number' && timeoutMs > 0) {
|
||||
timeoutId = setTimeout(ontimeout, timeoutMs);
|
||||
}
|
||||
|
||||
if ('port' in opts && typeof opts.port !== 'number') {
|
||||
opts.port = Number(opts.port);
|
||||
}
|
||||
|
||||
try {
|
||||
debug(
|
||||
'Resolving socket for %o request: %o',
|
||||
opts.protocol,
|
||||
`${req.method} ${req.path}`
|
||||
);
|
||||
Promise.resolve(this.promisifiedCallback(req, opts)).then(
|
||||
onsocket,
|
||||
callbackError
|
||||
);
|
||||
} catch (err) {
|
||||
Promise.reject(err).catch(callbackError);
|
||||
}
|
||||
}
|
||||
|
||||
freeSocket(socket: net.Socket, opts: AgentOptions) {
|
||||
debug('Freeing socket %o %o', socket.constructor.name, opts);
|
||||
socket.destroy();
|
||||
}
|
||||
|
||||
destroy() {
|
||||
debug('Destroying agent %o', this.constructor.name);
|
||||
}
|
||||
}
|
||||
|
||||
// So that `instanceof` works correctly
|
||||
createAgent.prototype = createAgent.Agent.prototype;
|
||||
}
|
||||
|
||||
export = createAgent;
|
33
node_modules/agent-base/src/promisify.ts
generated
vendored
Normal file
33
node_modules/agent-base/src/promisify.ts
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
import {
|
||||
Agent,
|
||||
ClientRequest,
|
||||
RequestOptions,
|
||||
AgentCallbackCallback,
|
||||
AgentCallbackPromise,
|
||||
AgentCallbackReturn
|
||||
} from './index';
|
||||
|
||||
type LegacyCallback = (
|
||||
req: ClientRequest,
|
||||
opts: RequestOptions,
|
||||
fn: AgentCallbackCallback
|
||||
) => void;
|
||||
|
||||
export default function promisify(fn: LegacyCallback): AgentCallbackPromise {
|
||||
return function(this: Agent, req: ClientRequest, opts: RequestOptions) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fn.call(
|
||||
this,
|
||||
req,
|
||||
opts,
|
||||
(err: Error | null | undefined, rtn?: AgentCallbackReturn) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(rtn);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
}
|
21
node_modules/asynckit/LICENSE
generated
vendored
Normal file
21
node_modules/asynckit/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Alex Indigo
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
233
node_modules/asynckit/README.md
generated
vendored
Normal file
233
node_modules/asynckit/README.md
generated
vendored
Normal file
@ -0,0 +1,233 @@
|
||||
# asynckit [![NPM Module](https://img.shields.io/npm/v/asynckit.svg?style=flat)](https://www.npmjs.com/package/asynckit)
|
||||
|
||||
Minimal async jobs utility library, with streams support.
|
||||
|
||||
[![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit)
|
||||
[![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=linux:0.12-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit)
|
||||
[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/v0.4.0.svg?label=windows:0.12-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit)
|
||||
|
||||
[![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/v0.4.0.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master)
|
||||
[![Dependency Status](https://img.shields.io/david/alexindigo/asynckit/v0.4.0.svg?style=flat)](https://david-dm.org/alexindigo/asynckit)
|
||||
[![bitHound Overall Score](https://www.bithound.io/github/alexindigo/asynckit/badges/score.svg)](https://www.bithound.io/github/alexindigo/asynckit)
|
||||
|
||||
<!-- [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde) -->
|
||||
|
||||
AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects.
|
||||
Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method.
|
||||
|
||||
It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators.
|
||||
|
||||
| compression | size |
|
||||
| :----------------- | -------: |
|
||||
| asynckit.js | 12.34 kB |
|
||||
| asynckit.min.js | 4.11 kB |
|
||||
| asynckit.min.js.gz | 1.47 kB |
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save asynckit
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Parallel Jobs
|
||||
|
||||
Runs iterator over provided array in parallel. Stores output in the `result` array,
|
||||
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||
will terminate rest of the active jobs (if abort function is provided)
|
||||
and return error along with salvaged data to the main callback function.
|
||||
|
||||
#### Input Array
|
||||
|
||||
```javascript
|
||||
var parallel = require('asynckit').parallel
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
parallel(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// async job accepts one element from the array
|
||||
// and a callback function
|
||||
function asyncJob(item, cb)
|
||||
{
|
||||
// different delays (in ms) per item
|
||||
var delay = item * 25;
|
||||
|
||||
// pretend different jobs take different time to finish
|
||||
// and not in consequential order
|
||||
var timeoutId = setTimeout(function() {
|
||||
target.push(item);
|
||||
cb(null, item * 2);
|
||||
}, delay);
|
||||
|
||||
// allow to cancel "leftover" jobs upon error
|
||||
// return function, invoking of which will abort this job
|
||||
return clearTimeout.bind(null, timeoutId);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js).
|
||||
|
||||
#### Input Object
|
||||
|
||||
Also it supports named jobs, listed via object.
|
||||
|
||||
```javascript
|
||||
var parallel = require('asynckit/parallel')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||
, expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ]
|
||||
, expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ]
|
||||
, target = []
|
||||
, keys = []
|
||||
;
|
||||
|
||||
parallel(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
assert.deepEqual(keys, expectedKeys);
|
||||
});
|
||||
|
||||
// supports full value, key, callback (shortcut) interface
|
||||
function asyncJob(item, key, cb)
|
||||
{
|
||||
// different delays (in ms) per item
|
||||
var delay = item * 25;
|
||||
|
||||
// pretend different jobs take different time to finish
|
||||
// and not in consequential order
|
||||
var timeoutId = setTimeout(function() {
|
||||
keys.push(key);
|
||||
target.push(item);
|
||||
cb(null, item * 2);
|
||||
}, delay);
|
||||
|
||||
// allow to cancel "leftover" jobs upon error
|
||||
// return function, invoking of which will abort this job
|
||||
return clearTimeout.bind(null, timeoutId);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js).
|
||||
|
||||
### Serial Jobs
|
||||
|
||||
Runs iterator over provided array sequentially. Stores output in the `result` array,
|
||||
on the matching positions. In unlikely event of an error from one of the jobs,
|
||||
will not proceed to the rest of the items in the list
|
||||
and return error along with salvaged data to the main callback function.
|
||||
|
||||
#### Input Array
|
||||
|
||||
```javascript
|
||||
var serial = require('asynckit/serial')
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
serial(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// extended interface (item, key, callback)
|
||||
// also supported for arrays
|
||||
function asyncJob(item, key, cb)
|
||||
{
|
||||
target.push(key);
|
||||
|
||||
// it will be automatically made async
|
||||
// even it iterator "returns" in the same event loop
|
||||
cb(null, item * 2);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-serial-array.js](test/test-serial-array.js).
|
||||
|
||||
#### Input Object
|
||||
|
||||
Also it supports named jobs, listed via object.
|
||||
|
||||
```javascript
|
||||
var serial = require('asynckit').serial
|
||||
, assert = require('assert')
|
||||
;
|
||||
|
||||
var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ]
|
||||
, expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 }
|
||||
, expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 }
|
||||
, expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ]
|
||||
, target = []
|
||||
;
|
||||
|
||||
|
||||
serial(source, asyncJob, function(err, result)
|
||||
{
|
||||
assert.deepEqual(result, expectedResult);
|
||||
assert.deepEqual(target, expectedTarget);
|
||||
});
|
||||
|
||||
// shortcut interface (item, callback)
|
||||
// works for object as well as for the arrays
|
||||
function asyncJob(item, cb)
|
||||
{
|
||||
target.push(item);
|
||||
|
||||
// it will be automatically made async
|
||||
// even it iterator "returns" in the same event loop
|
||||
cb(null, item * 2);
|
||||
}
|
||||
```
|
||||
|
||||
More examples could be found in [test/test-serial-object.js](test/test-serial-object.js).
|
||||
|
||||
_Note: Since _object_ is an _unordered_ collection of properties,
|
||||
it may produce unexpected results with sequential iterations.
|
||||
Whenever order of the jobs' execution is important please use `serialOrdered` method._
|
||||
|
||||
### Ordered Serial Iterations
|
||||
|
||||
TBD
|
||||
|
||||
For example [compare-property](compare-property) package.
|
||||
|
||||
### Streaming interface
|
||||
|
||||
TBD
|
||||
|
||||
## Want to Know More?
|
||||
|
||||
More examples can be found in [test folder](test/).
|
||||
|
||||
Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions.
|
||||
|
||||
## License
|
||||
|
||||
AsyncKit is licensed under the MIT license.
|
76
node_modules/asynckit/bench.js
generated
vendored
Normal file
76
node_modules/asynckit/bench.js
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/* eslint no-console: "off" */
|
||||
|
||||
var asynckit = require('./')
|
||||
, async = require('async')
|
||||
, assert = require('assert')
|
||||
, expected = 0
|
||||
;
|
||||
|
||||
var Benchmark = require('benchmark');
|
||||
var suite = new Benchmark.Suite;
|
||||
|
||||
var source = [];
|
||||
for (var z = 1; z < 100; z++)
|
||||
{
|
||||
source.push(z);
|
||||
expected += z;
|
||||
}
|
||||
|
||||
suite
|
||||
// add tests
|
||||
|
||||
.add('async.map', function(deferred)
|
||||
{
|
||||
var total = 0;
|
||||
|
||||
async.map(source,
|
||||
function(i, cb)
|
||||
{
|
||||
setImmediate(function()
|
||||
{
|
||||
total += i;
|
||||
cb(null, total);
|
||||
});
|
||||
},
|
||||
function(err, result)
|
||||
{
|
||||
assert.ifError(err);
|
||||
assert.equal(result[result.length - 1], expected);
|
||||
deferred.resolve();
|
||||
});
|
||||
}, {'defer': true})
|
||||
|
||||
|
||||
.add('asynckit.parallel', function(deferred)
|
||||
{
|
||||
var total = 0;
|
||||
|
||||
asynckit.parallel(source,
|
||||
function(i, cb)
|
||||
{
|
||||
setImmediate(function()
|
||||
{
|
||||
total += i;
|
||||
cb(null, total);
|
||||
});
|
||||
},
|
||||
function(err, result)
|
||||
{
|
||||
assert.ifError(err);
|
||||
assert.equal(result[result.length - 1], expected);
|
||||
deferred.resolve();
|
||||
});
|
||||
}, {'defer': true})
|
||||
|
||||
|
||||
// add listeners
|
||||
.on('cycle', function(ev)
|
||||
{
|
||||
console.log(String(ev.target));
|
||||
})
|
||||
.on('complete', function()
|
||||
{
|
||||
console.log('Fastest is ' + this.filter('fastest').map('name'));
|
||||
})
|
||||
// run async
|
||||
.run({ 'async': true });
|
6
node_modules/asynckit/index.js
generated
vendored
Normal file
6
node_modules/asynckit/index.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports =
|
||||
{
|
||||
parallel : require('./parallel.js'),
|
||||
serial : require('./serial.js'),
|
||||
serialOrdered : require('./serialOrdered.js')
|
||||
};
|
29
node_modules/asynckit/lib/abort.js
generated
vendored
Normal file
29
node_modules/asynckit/lib/abort.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
// API
|
||||
module.exports = abort;
|
||||
|
||||
/**
|
||||
* Aborts leftover active jobs
|
||||
*
|
||||
* @param {object} state - current state object
|
||||
*/
|
||||
function abort(state)
|
||||
{
|
||||
Object.keys(state.jobs).forEach(clean.bind(state));
|
||||
|
||||
// reset leftover jobs
|
||||
state.jobs = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans up leftover job by invoking abort function for the provided job id
|
||||
*
|
||||
* @this state
|
||||
* @param {string|number} key - job id to abort
|
||||
*/
|
||||
function clean(key)
|
||||
{
|
||||
if (typeof this.jobs[key] == 'function')
|
||||
{
|
||||
this.jobs[key]();
|
||||
}
|
||||
}
|
34
node_modules/asynckit/lib/async.js
generated
vendored
Normal file
34
node_modules/asynckit/lib/async.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
var defer = require('./defer.js');
|
||||
|
||||
// API
|
||||
module.exports = async;
|
||||
|
||||
/**
|
||||
* Runs provided callback asynchronously
|
||||
* even if callback itself is not
|
||||
*
|
||||
* @param {function} callback - callback to invoke
|
||||
* @returns {function} - augmented callback
|
||||
*/
|
||||
function async(callback)
|
||||
{
|
||||
var isAsync = false;
|
||||
|
||||
// check if async happened
|
||||
defer(function() { isAsync = true; });
|
||||
|
||||
return function async_callback(err, result)
|
||||
{
|
||||
if (isAsync)
|
||||
{
|
||||
callback(err, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
defer(function nextTick_callback()
|
||||
{
|
||||
callback(err, result);
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
26
node_modules/asynckit/lib/defer.js
generated
vendored
Normal file
26
node_modules/asynckit/lib/defer.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
module.exports = defer;
|
||||
|
||||
/**
|
||||
* Runs provided function on next iteration of the event loop
|
||||
*
|
||||
* @param {function} fn - function to run
|
||||
*/
|
||||
function defer(fn)
|
||||
{
|
||||
var nextTick = typeof setImmediate == 'function'
|
||||
? setImmediate
|
||||
: (
|
||||
typeof process == 'object' && typeof process.nextTick == 'function'
|
||||
? process.nextTick
|
||||
: null
|
||||
);
|
||||
|
||||
if (nextTick)
|
||||
{
|
||||
nextTick(fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(fn, 0);
|
||||
}
|
||||
}
|
75
node_modules/asynckit/lib/iterate.js
generated
vendored
Normal file
75
node_modules/asynckit/lib/iterate.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
var async = require('./async.js')
|
||||
, abort = require('./abort.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = iterate;
|
||||
|
||||
/**
|
||||
* Iterates over each job object
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {object} state - current job status
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
*/
|
||||
function iterate(list, iterator, state, callback)
|
||||
{
|
||||
// store current index
|
||||
var key = state['keyedList'] ? state['keyedList'][state.index] : state.index;
|
||||
|
||||
state.jobs[key] = runJob(iterator, key, list[key], function(error, output)
|
||||
{
|
||||
// don't repeat yourself
|
||||
// skip secondary callbacks
|
||||
if (!(key in state.jobs))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up jobs
|
||||
delete state.jobs[key];
|
||||
|
||||
if (error)
|
||||
{
|
||||
// don't process rest of the results
|
||||
// stop still active jobs
|
||||
// and reset the list
|
||||
abort(state);
|
||||
}
|
||||
else
|
||||
{
|
||||
state.results[key] = output;
|
||||
}
|
||||
|
||||
// return salvaged results
|
||||
callback(error, state.results);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs iterator over provided job element
|
||||
*
|
||||
* @param {function} iterator - iterator to invoke
|
||||
* @param {string|number} key - key/index of the element in the list of jobs
|
||||
* @param {mixed} item - job description
|
||||
* @param {function} callback - invoked after iterator is done with the job
|
||||
* @returns {function|mixed} - job abort function or something else
|
||||
*/
|
||||
function runJob(iterator, key, item, callback)
|
||||
{
|
||||
var aborter;
|
||||
|
||||
// allow shortcut if iterator expects only two arguments
|
||||
if (iterator.length == 2)
|
||||
{
|
||||
aborter = iterator(item, async(callback));
|
||||
}
|
||||
// otherwise go with full three arguments
|
||||
else
|
||||
{
|
||||
aborter = iterator(item, key, async(callback));
|
||||
}
|
||||
|
||||
return aborter;
|
||||
}
|
91
node_modules/asynckit/lib/readable_asynckit.js
generated
vendored
Normal file
91
node_modules/asynckit/lib/readable_asynckit.js
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
var streamify = require('./streamify.js')
|
||||
, defer = require('./defer.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = ReadableAsyncKit;
|
||||
|
||||
/**
|
||||
* Base constructor for all streams
|
||||
* used to hold properties/methods
|
||||
*/
|
||||
function ReadableAsyncKit()
|
||||
{
|
||||
ReadableAsyncKit.super_.apply(this, arguments);
|
||||
|
||||
// list of active jobs
|
||||
this.jobs = {};
|
||||
|
||||
// add stream methods
|
||||
this.destroy = destroy;
|
||||
this._start = _start;
|
||||
this._read = _read;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys readable stream,
|
||||
* by aborting outstanding jobs
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
function destroy()
|
||||
{
|
||||
if (this.destroyed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.destroyed = true;
|
||||
|
||||
if (typeof this.terminator == 'function')
|
||||
{
|
||||
this.terminator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts provided jobs in async manner
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _start()
|
||||
{
|
||||
// first argument – runner function
|
||||
var runner = arguments[0]
|
||||
// take away first argument
|
||||
, args = Array.prototype.slice.call(arguments, 1)
|
||||
// second argument - input data
|
||||
, input = args[0]
|
||||
// last argument - result callback
|
||||
, endCb = streamify.callback.call(this, args[args.length - 1])
|
||||
;
|
||||
|
||||
args[args.length - 1] = endCb;
|
||||
// third argument - iterator
|
||||
args[1] = streamify.iterator.call(this, args[1]);
|
||||
|
||||
// allow time for proper setup
|
||||
defer(function()
|
||||
{
|
||||
if (!this.destroyed)
|
||||
{
|
||||
this.terminator = runner.apply(null, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
endCb(null, Array.isArray(input) ? [] : {});
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implement _read to comply with Readable streams
|
||||
* Doesn't really make sense for flowing object mode
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function _read()
|
||||
{
|
||||
|
||||
}
|
25
node_modules/asynckit/lib/readable_parallel.js
generated
vendored
Normal file
25
node_modules/asynckit/lib/readable_parallel.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
var parallel = require('../parallel.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableParallel;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.parallel`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableParallel(list, iterator, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableParallel))
|
||||
{
|
||||
return new ReadableParallel(list, iterator, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableParallel.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(parallel, list, iterator, callback);
|
||||
}
|
25
node_modules/asynckit/lib/readable_serial.js
generated
vendored
Normal file
25
node_modules/asynckit/lib/readable_serial.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
var serial = require('../serial.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableSerial;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.serial`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableSerial(list, iterator, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableSerial))
|
||||
{
|
||||
return new ReadableSerial(list, iterator, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableSerial.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(serial, list, iterator, callback);
|
||||
}
|
29
node_modules/asynckit/lib/readable_serial_ordered.js
generated
vendored
Normal file
29
node_modules/asynckit/lib/readable_serial_ordered.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
var serialOrdered = require('../serialOrdered.js');
|
||||
|
||||
// API
|
||||
module.exports = ReadableSerialOrdered;
|
||||
// expose sort helpers
|
||||
module.exports.ascending = serialOrdered.ascending;
|
||||
module.exports.descending = serialOrdered.descending;
|
||||
|
||||
/**
|
||||
* Streaming wrapper to `asynckit.serialOrdered`
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} sortMethod - custom sort function
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {stream.Readable#}
|
||||
*/
|
||||
function ReadableSerialOrdered(list, iterator, sortMethod, callback)
|
||||
{
|
||||
if (!(this instanceof ReadableSerialOrdered))
|
||||
{
|
||||
return new ReadableSerialOrdered(list, iterator, sortMethod, callback);
|
||||
}
|
||||
|
||||
// turn on object mode
|
||||
ReadableSerialOrdered.super_.call(this, {objectMode: true});
|
||||
|
||||
this._start(serialOrdered, list, iterator, sortMethod, callback);
|
||||
}
|
37
node_modules/asynckit/lib/state.js
generated
vendored
Normal file
37
node_modules/asynckit/lib/state.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
// API
|
||||
module.exports = state;
|
||||
|
||||
/**
|
||||
* Creates initial state object
|
||||
* for iteration over list
|
||||
*
|
||||
* @param {array|object} list - list to iterate over
|
||||
* @param {function|null} sortMethod - function to use for keys sort,
|
||||
* or `null` to keep them as is
|
||||
* @returns {object} - initial state object
|
||||
*/
|
||||
function state(list, sortMethod)
|
||||
{
|
||||
var isNamedList = !Array.isArray(list)
|
||||
, initState =
|
||||
{
|
||||
index : 0,
|
||||
keyedList: isNamedList || sortMethod ? Object.keys(list) : null,
|
||||
jobs : {},
|
||||
results : isNamedList ? {} : [],
|
||||
size : isNamedList ? Object.keys(list).length : list.length
|
||||
}
|
||||
;
|
||||
|
||||
if (sortMethod)
|
||||
{
|
||||
// sort array keys based on it's values
|
||||
// sort object's keys just on own merit
|
||||
initState.keyedList.sort(isNamedList ? sortMethod : function(a, b)
|
||||
{
|
||||
return sortMethod(list[a], list[b]);
|
||||
});
|
||||
}
|
||||
|
||||
return initState;
|
||||
}
|
141
node_modules/asynckit/lib/streamify.js
generated
vendored
Normal file
141
node_modules/asynckit/lib/streamify.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
var async = require('./async.js');
|
||||
|
||||
// API
|
||||
module.exports = {
|
||||
iterator: wrapIterator,
|
||||
callback: wrapCallback
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps iterators with long signature
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} iterator - function to wrap
|
||||
* @returns {function} - wrapped function
|
||||
*/
|
||||
function wrapIterator(iterator)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
return function(item, key, cb)
|
||||
{
|
||||
var aborter
|
||||
, wrappedCb = async(wrapIteratorCallback.call(stream, cb, key))
|
||||
;
|
||||
|
||||
stream.jobs[key] = wrappedCb;
|
||||
|
||||
// it's either shortcut (item, cb)
|
||||
if (iterator.length == 2)
|
||||
{
|
||||
aborter = iterator(item, wrappedCb);
|
||||
}
|
||||
// or long format (item, key, cb)
|
||||
else
|
||||
{
|
||||
aborter = iterator(item, key, wrappedCb);
|
||||
}
|
||||
|
||||
return aborter;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps provided callback function
|
||||
* allowing to execute snitch function before
|
||||
* real callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} callback - function to wrap
|
||||
* @returns {function} - wrapped function
|
||||
*/
|
||||
function wrapCallback(callback)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
var wrapped = function(error, result)
|
||||
{
|
||||
return finisher.call(stream, error, result, callback);
|
||||
};
|
||||
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps provided iterator callback function
|
||||
* makes sure snitch only called once,
|
||||
* but passes secondary calls to the original callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {function} callback - callback to wrap
|
||||
* @param {number|string} key - iteration key
|
||||
* @returns {function} wrapped callback
|
||||
*/
|
||||
function wrapIteratorCallback(callback, key)
|
||||
{
|
||||
var stream = this;
|
||||
|
||||
return function(error, output)
|
||||
{
|
||||
// don't repeat yourself
|
||||
if (!(key in stream.jobs))
|
||||
{
|
||||
callback(error, output);
|
||||
return;
|
||||
}
|
||||
|
||||
// clean up jobs
|
||||
delete stream.jobs[key];
|
||||
|
||||
return streamer.call(stream, error, {key: key, value: output}, callback);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream wrapper for iterator callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {mixed} error - error response
|
||||
* @param {mixed} output - iterator output
|
||||
* @param {function} callback - callback that expects iterator results
|
||||
*/
|
||||
function streamer(error, output, callback)
|
||||
{
|
||||
if (error && !this.error)
|
||||
{
|
||||
this.error = error;
|
||||
this.pause();
|
||||
this.emit('error', error);
|
||||
// send back value only, as expected
|
||||
callback(error, output && output.value);
|
||||
return;
|
||||
}
|
||||
|
||||
// stream stuff
|
||||
this.push(output);
|
||||
|
||||
// back to original track
|
||||
// send back value only, as expected
|
||||
callback(error, output && output.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream wrapper for finishing callback
|
||||
*
|
||||
* @this ReadableAsyncKit#
|
||||
* @param {mixed} error - error response
|
||||
* @param {mixed} output - iterator output
|
||||
* @param {function} callback - callback that expects final results
|
||||
*/
|
||||
function finisher(error, output, callback)
|
||||
{
|
||||
// signal end of the stream
|
||||
// only for successfully finished streams
|
||||
if (!error)
|
||||
{
|
||||
this.push(null);
|
||||
}
|
||||
|
||||
// back to original track
|
||||
callback(error, output);
|
||||
}
|
29
node_modules/asynckit/lib/terminator.js
generated
vendored
Normal file
29
node_modules/asynckit/lib/terminator.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
var abort = require('./abort.js')
|
||||
, async = require('./async.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports = terminator;
|
||||
|
||||
/**
|
||||
* Terminates jobs in the attached state context
|
||||
*
|
||||
* @this AsyncKitState#
|
||||
* @param {function} callback - final callback to invoke after termination
|
||||
*/
|
||||
function terminator(callback)
|
||||
{
|
||||
if (!Object.keys(this.jobs).length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// fast forward iteration index
|
||||
this.index = this.size;
|
||||
|
||||
// abort jobs
|
||||
abort(this);
|
||||
|
||||
// send back results we have so far
|
||||
async(callback)(null, this.results);
|
||||
}
|
63
node_modules/asynckit/package.json
generated
vendored
Normal file
63
node_modules/asynckit/package.json
generated
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"name": "asynckit",
|
||||
"version": "0.4.0",
|
||||
"description": "Minimal async jobs utility library, with streams support",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"clean": "rimraf coverage",
|
||||
"lint": "eslint *.js lib/*.js test/*.js",
|
||||
"test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec",
|
||||
"win-test": "tape test/test-*.js",
|
||||
"browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec",
|
||||
"report": "istanbul report",
|
||||
"size": "browserify index.js | size-table asynckit",
|
||||
"debug": "tape test/test-*.js"
|
||||
},
|
||||
"pre-commit": [
|
||||
"clean",
|
||||
"lint",
|
||||
"test",
|
||||
"browser",
|
||||
"report",
|
||||
"size"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/alexindigo/asynckit.git"
|
||||
},
|
||||
"keywords": [
|
||||
"async",
|
||||
"jobs",
|
||||
"parallel",
|
||||
"serial",
|
||||
"iterator",
|
||||
"array",
|
||||
"object",
|
||||
"stream",
|
||||
"destroy",
|
||||
"terminate",
|
||||
"abort"
|
||||
],
|
||||
"author": "Alex Indigo <iam@alexindigo.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/alexindigo/asynckit/issues"
|
||||
},
|
||||
"homepage": "https://github.com/alexindigo/asynckit#readme",
|
||||
"devDependencies": {
|
||||
"browserify": "^13.0.0",
|
||||
"browserify-istanbul": "^2.0.0",
|
||||
"coveralls": "^2.11.9",
|
||||
"eslint": "^2.9.0",
|
||||
"istanbul": "^0.4.3",
|
||||
"obake": "^0.1.2",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
"pre-commit": "^1.1.3",
|
||||
"reamde": "^1.1.0",
|
||||
"rimraf": "^2.5.2",
|
||||
"size-table": "^0.2.0",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.5.1"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
43
node_modules/asynckit/parallel.js
generated
vendored
Normal file
43
node_modules/asynckit/parallel.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
var iterate = require('./lib/iterate.js')
|
||||
, initState = require('./lib/state.js')
|
||||
, terminator = require('./lib/terminator.js')
|
||||
;
|
||||
|
||||
// Public API
|
||||
module.exports = parallel;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided array elements in parallel
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function parallel(list, iterator, callback)
|
||||
{
|
||||
var state = initState(list);
|
||||
|
||||
while (state.index < (state['keyedList'] || list).length)
|
||||
{
|
||||
iterate(list, iterator, state, function(error, result)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
callback(error, result);
|
||||
return;
|
||||
}
|
||||
|
||||
// looks like it's the last one
|
||||
if (Object.keys(state.jobs).length === 0)
|
||||
{
|
||||
callback(null, state.results);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
state.index++;
|
||||
}
|
||||
|
||||
return terminator.bind(state, callback);
|
||||
}
|
17
node_modules/asynckit/serial.js
generated
vendored
Normal file
17
node_modules/asynckit/serial.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
var serialOrdered = require('./serialOrdered.js');
|
||||
|
||||
// Public API
|
||||
module.exports = serial;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided array elements in series
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function serial(list, iterator, callback)
|
||||
{
|
||||
return serialOrdered(list, iterator, null, callback);
|
||||
}
|
75
node_modules/asynckit/serialOrdered.js
generated
vendored
Normal file
75
node_modules/asynckit/serialOrdered.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
var iterate = require('./lib/iterate.js')
|
||||
, initState = require('./lib/state.js')
|
||||
, terminator = require('./lib/terminator.js')
|
||||
;
|
||||
|
||||
// Public API
|
||||
module.exports = serialOrdered;
|
||||
// sorting helpers
|
||||
module.exports.ascending = ascending;
|
||||
module.exports.descending = descending;
|
||||
|
||||
/**
|
||||
* Runs iterator over provided sorted array elements in series
|
||||
*
|
||||
* @param {array|object} list - array or object (named list) to iterate over
|
||||
* @param {function} iterator - iterator to run
|
||||
* @param {function} sortMethod - custom sort function
|
||||
* @param {function} callback - invoked when all elements processed
|
||||
* @returns {function} - jobs terminator
|
||||
*/
|
||||
function serialOrdered(list, iterator, sortMethod, callback)
|
||||
{
|
||||
var state = initState(list, sortMethod);
|
||||
|
||||
iterate(list, iterator, state, function iteratorHandler(error, result)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
callback(error, result);
|
||||
return;
|
||||
}
|
||||
|
||||
state.index++;
|
||||
|
||||
// are we there yet?
|
||||
if (state.index < (state['keyedList'] || list).length)
|
||||
{
|
||||
iterate(list, iterator, state, iteratorHandler);
|
||||
return;
|
||||
}
|
||||
|
||||
// done here
|
||||
callback(null, state.results);
|
||||
});
|
||||
|
||||
return terminator.bind(state, callback);
|
||||
}
|
||||
|
||||
/*
|
||||
* -- Sort methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* sort helper to sort array elements in ascending order
|
||||
*
|
||||
* @param {mixed} a - an item to compare
|
||||
* @param {mixed} b - an item to compare
|
||||
* @returns {number} - comparison result
|
||||
*/
|
||||
function ascending(a, b)
|
||||
{
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sort helper to sort array elements in descending order
|
||||
*
|
||||
* @param {mixed} a - an item to compare
|
||||
* @param {mixed} b - an item to compare
|
||||
* @returns {number} - comparison result
|
||||
*/
|
||||
function descending(a, b)
|
||||
{
|
||||
return -1 * ascending(a, b);
|
||||
}
|
21
node_modules/asynckit/stream.js
generated
vendored
Normal file
21
node_modules/asynckit/stream.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var inherits = require('util').inherits
|
||||
, Readable = require('stream').Readable
|
||||
, ReadableAsyncKit = require('./lib/readable_asynckit.js')
|
||||
, ReadableParallel = require('./lib/readable_parallel.js')
|
||||
, ReadableSerial = require('./lib/readable_serial.js')
|
||||
, ReadableSerialOrdered = require('./lib/readable_serial_ordered.js')
|
||||
;
|
||||
|
||||
// API
|
||||
module.exports =
|
||||
{
|
||||
parallel : ReadableParallel,
|
||||
serial : ReadableSerial,
|
||||
serialOrdered : ReadableSerialOrdered,
|
||||
};
|
||||
|
||||
inherits(ReadableAsyncKit, Readable);
|
||||
|
||||
inherits(ReadableParallel, ReadableAsyncKit);
|
||||
inherits(ReadableSerial, ReadableAsyncKit);
|
||||
inherits(ReadableSerialOrdered, ReadableAsyncKit);
|
19
node_modules/combined-stream/License
generated
vendored
Normal file
19
node_modules/combined-stream/License
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2011 Debuggable Limited <felix@debuggable.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
138
node_modules/combined-stream/Readme.md
generated
vendored
Normal file
138
node_modules/combined-stream/Readme.md
generated
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
# combined-stream
|
||||
|
||||
A stream that emits multiple other streams one after another.
|
||||
|
||||
**NB** Currently `combined-stream` works with streams version 1 only. There is ongoing effort to switch this library to streams version 2. Any help is welcome. :) Meanwhile you can explore other libraries that provide streams2 support with more or less compatibility with `combined-stream`.
|
||||
|
||||
- [combined-stream2](https://www.npmjs.com/package/combined-stream2): A drop-in streams2-compatible replacement for the combined-stream module.
|
||||
|
||||
- [multistream](https://www.npmjs.com/package/multistream): A stream that emits multiple other streams one after another.
|
||||
|
||||
## Installation
|
||||
|
||||
``` bash
|
||||
npm install combined-stream
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a simple example that shows how you can use combined-stream to combine
|
||||
two files into one:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create();
|
||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
While the example above works great, it will pause all source streams until
|
||||
they are needed. If you don't want that to happen, you can set `pauseStreams`
|
||||
to `false`:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create({pauseStreams: false});
|
||||
combinedStream.append(fs.createReadStream('file1.txt'));
|
||||
combinedStream.append(fs.createReadStream('file2.txt'));
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
However, what if you don't have all the source streams yet, or you don't want
|
||||
to allocate the resources (file descriptors, memory, etc.) for them right away?
|
||||
Well, in that case you can simply provide a callback that supplies the stream
|
||||
by calling a `next()` function:
|
||||
|
||||
``` javascript
|
||||
var CombinedStream = require('combined-stream');
|
||||
var fs = require('fs');
|
||||
|
||||
var combinedStream = CombinedStream.create();
|
||||
combinedStream.append(function(next) {
|
||||
next(fs.createReadStream('file1.txt'));
|
||||
});
|
||||
combinedStream.append(function(next) {
|
||||
next(fs.createReadStream('file2.txt'));
|
||||
});
|
||||
|
||||
combinedStream.pipe(fs.createWriteStream('combined.txt'));
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### CombinedStream.create([options])
|
||||
|
||||
Returns a new combined stream object. Available options are:
|
||||
|
||||
* `maxDataSize`
|
||||
* `pauseStreams`
|
||||
|
||||
The effect of those options is described below.
|
||||
|
||||
### combinedStream.pauseStreams = `true`
|
||||
|
||||
Whether to apply back pressure to the underlaying streams. If set to `false`,
|
||||
the underlaying streams will never be paused. If set to `true`, the
|
||||
underlaying streams will be paused right after being appended, as well as when
|
||||
`delayedStream.pipe()` wants to throttle.
|
||||
|
||||
### combinedStream.maxDataSize = `2 * 1024 * 1024`
|
||||
|
||||
The maximum amount of bytes (or characters) to buffer for all source streams.
|
||||
If this value is exceeded, `combinedStream` emits an `'error'` event.
|
||||
|
||||
### combinedStream.dataSize = `0`
|
||||
|
||||
The amount of bytes (or characters) currently buffered by `combinedStream`.
|
||||
|
||||
### combinedStream.append(stream)
|
||||
|
||||
Appends the given `stream` to the combinedStream object. If `pauseStreams` is
|
||||
set to `true, this stream will also be paused right away.
|
||||
|
||||
`streams` can also be a function that takes one parameter called `next`. `next`
|
||||
is a function that must be invoked in order to provide the `next` stream, see
|
||||
example above.
|
||||
|
||||
Regardless of how the `stream` is appended, combined-stream always attaches an
|
||||
`'error'` listener to it, so you don't have to do that manually.
|
||||
|
||||
Special case: `stream` can also be a String or Buffer.
|
||||
|
||||
### combinedStream.write(data)
|
||||
|
||||
You should not call this, `combinedStream` takes care of piping the appended
|
||||
streams into itself for you.
|
||||
|
||||
### combinedStream.resume()
|
||||
|
||||
Causes `combinedStream` to start drain the streams it manages. The function is
|
||||
idempotent, and also emits a `'resume'` event each time which usually goes to
|
||||
the stream that is currently being drained.
|
||||
|
||||
### combinedStream.pause();
|
||||
|
||||
If `combinedStream.pauseStreams` is set to `false`, this does nothing.
|
||||
Otherwise a `'pause'` event is emitted, this goes to the stream that is
|
||||
currently being drained, so you can use it to apply back pressure.
|
||||
|
||||
### combinedStream.end();
|
||||
|
||||
Sets `combinedStream.writable` to false, emits an `'end'` event, and removes
|
||||
all streams from the queue.
|
||||
|
||||
### combinedStream.destroy();
|
||||
|
||||
Same as `combinedStream.end()`, except it emits a `'close'` event instead of
|
||||
`'end'`.
|
||||
|
||||
## License
|
||||
|
||||
combined-stream is licensed under the MIT license.
|
208
node_modules/combined-stream/lib/combined_stream.js
generated
vendored
Normal file
208
node_modules/combined-stream/lib/combined_stream.js
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
var util = require('util');
|
||||
var Stream = require('stream').Stream;
|
||||
var DelayedStream = require('delayed-stream');
|
||||
|
||||
module.exports = CombinedStream;
|
||||
function CombinedStream() {
|
||||
this.writable = false;
|
||||
this.readable = true;
|
||||
this.dataSize = 0;
|
||||
this.maxDataSize = 2 * 1024 * 1024;
|
||||
this.pauseStreams = true;
|
||||
|
||||
this._released = false;
|
||||
this._streams = [];
|
||||
this._currentStream = null;
|
||||
this._insideLoop = false;
|
||||
this._pendingNext = false;
|
||||
}
|
||||
util.inherits(CombinedStream, Stream);
|
||||
|
||||
CombinedStream.create = function(options) {
|
||||
var combinedStream = new this();
|
||||
|
||||
options = options || {};
|
||||
for (var option in options) {
|
||||
combinedStream[option] = options[option];
|
||||
}
|
||||
|
||||
return combinedStream;
|
||||
};
|
||||
|
||||
CombinedStream.isStreamLike = function(stream) {
|
||||
return (typeof stream !== 'function')
|
||||
&& (typeof stream !== 'string')
|
||||
&& (typeof stream !== 'boolean')
|
||||
&& (typeof stream !== 'number')
|
||||
&& (!Buffer.isBuffer(stream));
|
||||
};
|
||||
|
||||
CombinedStream.prototype.append = function(stream) {
|
||||
var isStreamLike = CombinedStream.isStreamLike(stream);
|
||||
|
||||
if (isStreamLike) {
|
||||
if (!(stream instanceof DelayedStream)) {
|
||||
var newStream = DelayedStream.create(stream, {
|
||||
maxDataSize: Infinity,
|
||||
pauseStream: this.pauseStreams,
|
||||
});
|
||||
stream.on('data', this._checkDataSize.bind(this));
|
||||
stream = newStream;
|
||||
}
|
||||
|
||||
this._handleErrors(stream);
|
||||
|
||||
if (this.pauseStreams) {
|
||||
stream.pause();
|
||||
}
|
||||
}
|
||||
|
||||
this._streams.push(stream);
|
||||
return this;
|
||||
};
|
||||
|
||||
CombinedStream.prototype.pipe = function(dest, options) {
|
||||
Stream.prototype.pipe.call(this, dest, options);
|
||||
this.resume();
|
||||
return dest;
|
||||
};
|
||||
|
||||
CombinedStream.prototype._getNext = function() {
|
||||
this._currentStream = null;
|
||||
|
||||
if (this._insideLoop) {
|
||||
this._pendingNext = true;
|
||||
return; // defer call
|
||||
}
|
||||
|
||||
this._insideLoop = true;
|
||||
try {
|
||||
do {
|
||||
this._pendingNext = false;
|
||||
this._realGetNext();
|
||||
} while (this._pendingNext);
|
||||
} finally {
|
||||
this._insideLoop = false;
|
||||
}
|
||||
};
|
||||
|
||||
CombinedStream.prototype._realGetNext = function() {
|
||||
var stream = this._streams.shift();
|
||||
|
||||
|
||||
if (typeof stream == 'undefined') {
|
||||
this.end();
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof stream !== 'function') {
|
||||
this._pipeNext(stream);
|
||||
return;
|
||||
}
|
||||
|
||||
var getStream = stream;
|
||||
getStream(function(stream) {
|
||||
var isStreamLike = CombinedStream.isStreamLike(stream);
|
||||
if (isStreamLike) {
|
||||
stream.on('data', this._checkDataSize.bind(this));
|
||||
this._handleErrors(stream);
|
||||
}
|
||||
|
||||
this._pipeNext(stream);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
CombinedStream.prototype._pipeNext = function(stream) {
|
||||
this._currentStream = stream;
|
||||
|
||||
var isStreamLike = CombinedStream.isStreamLike(stream);
|
||||
if (isStreamLike) {
|
||||
stream.on('end', this._getNext.bind(this));
|
||||
stream.pipe(this, {end: false});
|
||||
return;
|
||||
}
|
||||
|
||||
var value = stream;
|
||||
this.write(value);
|
||||
this._getNext();
|
||||
};
|
||||
|
||||
CombinedStream.prototype._handleErrors = function(stream) {
|
||||
var self = this;
|
||||
stream.on('error', function(err) {
|
||||
self._emitError(err);
|
||||
});
|
||||
};
|
||||
|
||||
CombinedStream.prototype.write = function(data) {
|
||||
this.emit('data', data);
|
||||
};
|
||||
|
||||
CombinedStream.prototype.pause = function() {
|
||||
if (!this.pauseStreams) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.pause) == 'function') this._currentStream.pause();
|
||||
this.emit('pause');
|
||||
};
|
||||
|
||||
CombinedStream.prototype.resume = function() {
|
||||
if (!this._released) {
|
||||
this._released = true;
|
||||
this.writable = true;
|
||||
this._getNext();
|
||||
}
|
||||
|
||||
if(this.pauseStreams && this._currentStream && typeof(this._currentStream.resume) == 'function') this._currentStream.resume();
|
||||
this.emit('resume');
|
||||
};
|
||||
|
||||
CombinedStream.prototype.end = function() {
|
||||
this._reset();
|
||||
this.emit('end');
|
||||
};
|
||||
|
||||
CombinedStream.prototype.destroy = function() {
|
||||
this._reset();
|
||||
this.emit('close');
|
||||
};
|
||||
|
||||
CombinedStream.prototype._reset = function() {
|
||||
this.writable = false;
|
||||
this._streams = [];
|
||||
this._currentStream = null;
|
||||
};
|
||||
|
||||
CombinedStream.prototype._checkDataSize = function() {
|
||||
this._updateDataSize();
|
||||
if (this.dataSize <= this.maxDataSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message =
|
||||
'DelayedStream#maxDataSize of ' + this.maxDataSize + ' bytes exceeded.';
|
||||
this._emitError(new Error(message));
|
||||
};
|
||||
|
||||
CombinedStream.prototype._updateDataSize = function() {
|
||||
this.dataSize = 0;
|
||||
|
||||
var self = this;
|
||||
this._streams.forEach(function(stream) {
|
||||
if (!stream.dataSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.dataSize += stream.dataSize;
|
||||
});
|
||||
|
||||
if (this._currentStream && this._currentStream.dataSize) {
|
||||
this.dataSize += this._currentStream.dataSize;
|
||||
}
|
||||
};
|
||||
|
||||
CombinedStream.prototype._emitError = function(err) {
|
||||
this._reset();
|
||||
this.emit('error', err);
|
||||
};
|
25
node_modules/combined-stream/package.json
generated
vendored
Normal file
25
node_modules/combined-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",
|
||||
"name": "combined-stream",
|
||||
"description": "A stream that emits multiple other streams one after another.",
|
||||
"version": "1.0.8",
|
||||
"homepage": "https://github.com/felixge/node-combined-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/felixge/node-combined-stream.git"
|
||||
},
|
||||
"main": "./lib/combined_stream",
|
||||
"scripts": {
|
||||
"test": "node test/run.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"far": "~0.0.7"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
17
node_modules/combined-stream/yarn.lock
generated
vendored
Normal file
17
node_modules/combined-stream/yarn.lock
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
delayed-stream@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
|
||||
|
||||
far@~0.0.7:
|
||||
version "0.0.7"
|
||||
resolved "https://registry.yarnpkg.com/far/-/far-0.0.7.tgz#01c1fd362bcd26ce9cf161af3938aa34619f79a7"
|
||||
dependencies:
|
||||
oop "0.0.3"
|
||||
|
||||
oop@0.0.3:
|
||||
version "0.0.3"
|
||||
resolved "https://registry.yarnpkg.com/oop/-/oop-0.0.3.tgz#70fa405a5650891a194fdc82ca68dad6dabf4401"
|
20
node_modules/cssom/LICENSE.txt
generated
vendored
Normal file
20
node_modules/cssom/LICENSE.txt
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
Copyright (c) Nikita Vasilyev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
67
node_modules/cssom/README.mdown
generated
vendored
Normal file
67
node_modules/cssom/README.mdown
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
# CSSOM
|
||||
|
||||
CSSOM.js is a CSS parser written in pure JavaScript. It is also a partial implementation of [CSS Object Model](http://dev.w3.org/csswg/cssom/).
|
||||
|
||||
CSSOM.parse("body {color: black}")
|
||||
-> {
|
||||
cssRules: [
|
||||
{
|
||||
selectorText: "body",
|
||||
style: {
|
||||
0: "color",
|
||||
color: "black",
|
||||
length: 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## [Parser demo](http://nv.github.com/CSSOM/docs/parse.html)
|
||||
|
||||
Works well in Google Chrome 6+, Safari 5+, Firefox 3.6+, Opera 10.63+.
|
||||
Doesn't work in IE < 9 because of unsupported getters/setters.
|
||||
|
||||
To use CSSOM.js in the browser you might want to build a one-file version that exposes a single `CSSOM` global variable:
|
||||
|
||||
➤ git clone https://github.com/NV/CSSOM.git
|
||||
➤ cd CSSOM
|
||||
➤ node build.js
|
||||
build/CSSOM.js is done
|
||||
|
||||
To use it with Node.js or any other CommonJS loader:
|
||||
|
||||
➤ npm install cssom
|
||||
|
||||
## Don’t use it if...
|
||||
|
||||
You parse CSS to mungle, minify or reformat code like this:
|
||||
|
||||
```css
|
||||
div {
|
||||
background: gray;
|
||||
background: linear-gradient(to bottom, white 0%, black 100%);
|
||||
}
|
||||
```
|
||||
|
||||
This pattern is often used to give browsers that don’t understand linear gradients a fallback solution (e.g. gray color in the example).
|
||||
In CSSOM, `background: gray` [gets overwritten](http://nv.github.io/CSSOM/docs/parse.html#css=div%20%7B%0A%20%20%20%20%20%20background%3A%20gray%3B%0A%20%20%20%20background%3A%20linear-gradient(to%20bottom%2C%20white%200%25%2C%20black%20100%25)%3B%0A%7D).
|
||||
It does **NOT** get preserved.
|
||||
|
||||
If you do CSS mungling, minification, or image inlining, considere using one of the following:
|
||||
|
||||
* [postcss](https://github.com/postcss/postcss)
|
||||
* [reworkcss/css](https://github.com/reworkcss/css)
|
||||
* [csso](https://github.com/css/csso)
|
||||
* [mensch](https://github.com/brettstimmerman/mensch)
|
||||
|
||||
|
||||
## [Tests](http://nv.github.com/CSSOM/spec/)
|
||||
|
||||
To run tests locally:
|
||||
|
||||
➤ git submodule init
|
||||
➤ git submodule update
|
||||
|
||||
|
||||
## [Who uses CSSOM.js](https://github.com/NV/CSSOM/wiki/Who-uses-CSSOM.js)
|
25
node_modules/cssom/lib/CSSConditionRule.js
generated
vendored
Normal file
25
node_modules/cssom/lib/CSSConditionRule.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see https://www.w3.org/TR/css-conditional-3/#the-cssconditionrule-interface
|
||||
*/
|
||||
CSSOM.CSSConditionRule = function CSSConditionRule() {
|
||||
CSSOM.CSSGroupingRule.call(this);
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
CSSOM.CSSConditionRule.prototype = new CSSOM.CSSGroupingRule();
|
||||
CSSOM.CSSConditionRule.prototype.constructor = CSSOM.CSSConditionRule;
|
||||
CSSOM.CSSConditionRule.prototype.conditionText = ''
|
||||
CSSOM.CSSConditionRule.prototype.cssText = ''
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSConditionRule = CSSOM.CSSConditionRule;
|
||||
///CommonJS
|
39
node_modules/cssom/lib/CSSDocumentRule.js
generated
vendored
Normal file
39
node_modules/cssom/lib/CSSDocumentRule.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
MatcherList: require("./MatcherList").MatcherList
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see https://developer.mozilla.org/en/CSS/@-moz-document
|
||||
*/
|
||||
CSSOM.CSSDocumentRule = function CSSDocumentRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.matcher = new CSSOM.MatcherList();
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
CSSOM.CSSDocumentRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSDocumentRule.prototype.constructor = CSSOM.CSSDocumentRule;
|
||||
CSSOM.CSSDocumentRule.prototype.type = 10;
|
||||
//FIXME
|
||||
//CSSOM.CSSDocumentRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
|
||||
//CSSOM.CSSDocumentRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
|
||||
|
||||
Object.defineProperty(CSSOM.CSSDocumentRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var cssTexts = [];
|
||||
for (var i=0, length=this.cssRules.length; i < length; i++) {
|
||||
cssTexts.push(this.cssRules[i].cssText);
|
||||
}
|
||||
return "@-moz-document " + this.matcher.matcherText + " {" + cssTexts.join("") + "}";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSDocumentRule = CSSOM.CSSDocumentRule;
|
||||
///CommonJS
|
36
node_modules/cssom/lib/CSSFontFaceRule.js
generated
vendored
Normal file
36
node_modules/cssom/lib/CSSFontFaceRule.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
|
||||
CSSRule: require("./CSSRule").CSSRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://dev.w3.org/csswg/cssom/#css-font-face-rule
|
||||
*/
|
||||
CSSOM.CSSFontFaceRule = function CSSFontFaceRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.style = new CSSOM.CSSStyleDeclaration();
|
||||
this.style.parentRule = this;
|
||||
};
|
||||
|
||||
CSSOM.CSSFontFaceRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSFontFaceRule.prototype.constructor = CSSOM.CSSFontFaceRule;
|
||||
CSSOM.CSSFontFaceRule.prototype.type = 5;
|
||||
//FIXME
|
||||
//CSSOM.CSSFontFaceRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
|
||||
//CSSOM.CSSFontFaceRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
|
||||
|
||||
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
|
||||
Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
return "@font-face {" + this.style.cssText + "}";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSFontFaceRule = CSSOM.CSSFontFaceRule;
|
||||
///CommonJS
|
68
node_modules/cssom/lib/CSSGroupingRule.js
generated
vendored
Normal file
68
node_modules/cssom/lib/CSSGroupingRule.js
generated
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see https://drafts.csswg.org/cssom/#the-cssgroupingrule-interface
|
||||
*/
|
||||
CSSOM.CSSGroupingRule = function CSSGroupingRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
CSSOM.CSSGroupingRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSGroupingRule.prototype.constructor = CSSOM.CSSGroupingRule;
|
||||
|
||||
|
||||
/**
|
||||
* Used to insert a new CSS rule to a list of CSS rules.
|
||||
*
|
||||
* @example
|
||||
* cssGroupingRule.cssText
|
||||
* -> "body{margin:0;}"
|
||||
* cssGroupingRule.insertRule("img{border:none;}", 1)
|
||||
* -> 1
|
||||
* cssGroupingRule.cssText
|
||||
* -> "body{margin:0;}img{border:none;}"
|
||||
*
|
||||
* @param {string} rule
|
||||
* @param {number} [index]
|
||||
* @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-insertrule
|
||||
* @return {number} The index within the grouping rule's collection of the newly inserted rule.
|
||||
*/
|
||||
CSSOM.CSSGroupingRule.prototype.insertRule = function insertRule(rule, index) {
|
||||
if (index < 0 || index > this.cssRules.length) {
|
||||
throw new RangeError("INDEX_SIZE_ERR");
|
||||
}
|
||||
var cssRule = CSSOM.parse(rule).cssRules[0];
|
||||
cssRule.parentRule = this;
|
||||
this.cssRules.splice(index, 0, cssRule);
|
||||
return index;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to delete a rule from the grouping rule.
|
||||
*
|
||||
* cssGroupingRule.cssText
|
||||
* -> "img{border:none;}body{margin:0;}"
|
||||
* cssGroupingRule.deleteRule(0)
|
||||
* cssGroupingRule.cssText
|
||||
* -> "body{margin:0;}"
|
||||
*
|
||||
* @param {number} index within the grouping rule's rule list of the rule to remove.
|
||||
* @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-deleterule
|
||||
*/
|
||||
CSSOM.CSSGroupingRule.prototype.deleteRule = function deleteRule(index) {
|
||||
if (index < 0 || index >= this.cssRules.length) {
|
||||
throw new RangeError("INDEX_SIZE_ERR");
|
||||
}
|
||||
this.cssRules.splice(index, 1)[0].parentRule = null;
|
||||
};
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSGroupingRule = CSSOM.CSSGroupingRule;
|
||||
///CommonJS
|
37
node_modules/cssom/lib/CSSHostRule.js
generated
vendored
Normal file
37
node_modules/cssom/lib/CSSHostRule.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/shadow-dom/#host-at-rule
|
||||
*/
|
||||
CSSOM.CSSHostRule = function CSSHostRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
CSSOM.CSSHostRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSHostRule.prototype.constructor = CSSOM.CSSHostRule;
|
||||
CSSOM.CSSHostRule.prototype.type = 1001;
|
||||
//FIXME
|
||||
//CSSOM.CSSHostRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
|
||||
//CSSOM.CSSHostRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
|
||||
|
||||
Object.defineProperty(CSSOM.CSSHostRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var cssTexts = [];
|
||||
for (var i=0, length=this.cssRules.length; i < length; i++) {
|
||||
cssTexts.push(this.cssRules[i].cssText);
|
||||
}
|
||||
return "@host {" + cssTexts.join("") + "}";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSHostRule = CSSOM.CSSHostRule;
|
||||
///CommonJS
|
132
node_modules/cssom/lib/CSSImportRule.js
generated
vendored
Normal file
132
node_modules/cssom/lib/CSSImportRule.js
generated
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
|
||||
MediaList: require("./MediaList").MediaList
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://dev.w3.org/csswg/cssom/#cssimportrule
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSImportRule
|
||||
*/
|
||||
CSSOM.CSSImportRule = function CSSImportRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.href = "";
|
||||
this.media = new CSSOM.MediaList();
|
||||
this.styleSheet = new CSSOM.CSSStyleSheet();
|
||||
};
|
||||
|
||||
CSSOM.CSSImportRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSImportRule.prototype.constructor = CSSOM.CSSImportRule;
|
||||
CSSOM.CSSImportRule.prototype.type = 3;
|
||||
|
||||
Object.defineProperty(CSSOM.CSSImportRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var mediaText = this.media.mediaText;
|
||||
return "@import url(" + this.href + ")" + (mediaText ? " " + mediaText : "") + ";";
|
||||
},
|
||||
set: function(cssText) {
|
||||
var i = 0;
|
||||
|
||||
/**
|
||||
* @import url(partial.css) screen, handheld;
|
||||
* || |
|
||||
* after-import media
|
||||
* |
|
||||
* url
|
||||
*/
|
||||
var state = '';
|
||||
|
||||
var buffer = '';
|
||||
var index;
|
||||
for (var character; (character = cssText.charAt(i)); i++) {
|
||||
|
||||
switch (character) {
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\r':
|
||||
case '\n':
|
||||
case '\f':
|
||||
if (state === 'after-import') {
|
||||
state = 'url';
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case '@':
|
||||
if (!state && cssText.indexOf('@import', i) === i) {
|
||||
state = 'after-import';
|
||||
i += 'import'.length;
|
||||
buffer = '';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
if (state === 'url' && cssText.indexOf('url(', i) === i) {
|
||||
index = cssText.indexOf(')', i + 1);
|
||||
if (index === -1) {
|
||||
throw i + ': ")" not found';
|
||||
}
|
||||
i += 'url('.length;
|
||||
var url = cssText.slice(i, index);
|
||||
if (url[0] === url[url.length - 1]) {
|
||||
if (url[0] === '"' || url[0] === "'") {
|
||||
url = url.slice(1, -1);
|
||||
}
|
||||
}
|
||||
this.href = url;
|
||||
i = index;
|
||||
state = 'media';
|
||||
}
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (state === 'url') {
|
||||
index = cssText.indexOf('"', i + 1);
|
||||
if (!index) {
|
||||
throw i + ": '\"' not found";
|
||||
}
|
||||
this.href = cssText.slice(i + 1, index);
|
||||
i = index;
|
||||
state = 'media';
|
||||
}
|
||||
break;
|
||||
|
||||
case "'":
|
||||
if (state === 'url') {
|
||||
index = cssText.indexOf("'", i + 1);
|
||||
if (!index) {
|
||||
throw i + ': "\'" not found';
|
||||
}
|
||||
this.href = cssText.slice(i + 1, index);
|
||||
i = index;
|
||||
state = 'media';
|
||||
}
|
||||
break;
|
||||
|
||||
case ';':
|
||||
if (state === 'media') {
|
||||
if (buffer) {
|
||||
this.media.mediaText = buffer.trim();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (state === 'media') {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSImportRule = CSSOM.CSSImportRule;
|
||||
///CommonJS
|
37
node_modules/cssom/lib/CSSKeyframeRule.js
generated
vendored
Normal file
37
node_modules/cssom/lib/CSSKeyframeRule.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframeRule
|
||||
*/
|
||||
CSSOM.CSSKeyframeRule = function CSSKeyframeRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.keyText = '';
|
||||
this.style = new CSSOM.CSSStyleDeclaration();
|
||||
this.style.parentRule = this;
|
||||
};
|
||||
|
||||
CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;
|
||||
CSSOM.CSSKeyframeRule.prototype.type = 8;
|
||||
//FIXME
|
||||
//CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
|
||||
//CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
|
||||
|
||||
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
|
||||
Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
return this.keyText + " {" + this.style.cssText + "} ";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSKeyframeRule = CSSOM.CSSKeyframeRule;
|
||||
///CommonJS
|
39
node_modules/cssom/lib/CSSKeyframesRule.js
generated
vendored
Normal file
39
node_modules/cssom/lib/CSSKeyframesRule.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframesRule
|
||||
*/
|
||||
CSSOM.CSSKeyframesRule = function CSSKeyframesRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.name = '';
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule;
|
||||
CSSOM.CSSKeyframesRule.prototype.type = 7;
|
||||
//FIXME
|
||||
//CSSOM.CSSKeyframesRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
|
||||
//CSSOM.CSSKeyframesRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
|
||||
|
||||
// http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframesRule.cpp
|
||||
Object.defineProperty(CSSOM.CSSKeyframesRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var cssTexts = [];
|
||||
for (var i=0, length=this.cssRules.length; i < length; i++) {
|
||||
cssTexts.push(" " + this.cssRules[i].cssText);
|
||||
}
|
||||
return "@" + (this._vendorPrefix || '') + "keyframes " + this.name + " { \n" + cssTexts.join("\n") + "\n}";
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSKeyframesRule = CSSOM.CSSKeyframesRule;
|
||||
///CommonJS
|
53
node_modules/cssom/lib/CSSMediaRule.js
generated
vendored
Normal file
53
node_modules/cssom/lib/CSSMediaRule.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
|
||||
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule,
|
||||
MediaList: require("./MediaList").MediaList
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://dev.w3.org/csswg/cssom/#cssmediarule
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule
|
||||
*/
|
||||
CSSOM.CSSMediaRule = function CSSMediaRule() {
|
||||
CSSOM.CSSConditionRule.call(this);
|
||||
this.media = new CSSOM.MediaList();
|
||||
};
|
||||
|
||||
CSSOM.CSSMediaRule.prototype = new CSSOM.CSSConditionRule();
|
||||
CSSOM.CSSMediaRule.prototype.constructor = CSSOM.CSSMediaRule;
|
||||
CSSOM.CSSMediaRule.prototype.type = 4;
|
||||
|
||||
// https://opensource.apple.com/source/WebCore/WebCore-7611.1.21.161.3/css/CSSMediaRule.cpp
|
||||
Object.defineProperties(CSSOM.CSSMediaRule.prototype, {
|
||||
"conditionText": {
|
||||
get: function() {
|
||||
return this.media.mediaText;
|
||||
},
|
||||
set: function(value) {
|
||||
this.media.mediaText = value;
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
},
|
||||
"cssText": {
|
||||
get: function() {
|
||||
var cssTexts = [];
|
||||
for (var i=0, length=this.cssRules.length; i < length; i++) {
|
||||
cssTexts.push(this.cssRules[i].cssText);
|
||||
}
|
||||
return "@media " + this.media.mediaText + " {" + cssTexts.join("") + "}";
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSMediaRule = CSSOM.CSSMediaRule;
|
||||
///CommonJS
|
3
node_modules/cssom/lib/CSSOM.js
generated
vendored
Normal file
3
node_modules/cssom/lib/CSSOM.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var CSSOM = {};
|
||||
|
||||
|
43
node_modules/cssom/lib/CSSRule.js
generated
vendored
Normal file
43
node_modules/cssom/lib/CSSRule.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://dev.w3.org/csswg/cssom/#the-cssrule-interface
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSRule
|
||||
*/
|
||||
CSSOM.CSSRule = function CSSRule() {
|
||||
this.parentRule = null;
|
||||
this.parentStyleSheet = null;
|
||||
};
|
||||
|
||||
CSSOM.CSSRule.UNKNOWN_RULE = 0; // obsolete
|
||||
CSSOM.CSSRule.STYLE_RULE = 1;
|
||||
CSSOM.CSSRule.CHARSET_RULE = 2; // obsolete
|
||||
CSSOM.CSSRule.IMPORT_RULE = 3;
|
||||
CSSOM.CSSRule.MEDIA_RULE = 4;
|
||||
CSSOM.CSSRule.FONT_FACE_RULE = 5;
|
||||
CSSOM.CSSRule.PAGE_RULE = 6;
|
||||
CSSOM.CSSRule.KEYFRAMES_RULE = 7;
|
||||
CSSOM.CSSRule.KEYFRAME_RULE = 8;
|
||||
CSSOM.CSSRule.MARGIN_RULE = 9;
|
||||
CSSOM.CSSRule.NAMESPACE_RULE = 10;
|
||||
CSSOM.CSSRule.COUNTER_STYLE_RULE = 11;
|
||||
CSSOM.CSSRule.SUPPORTS_RULE = 12;
|
||||
CSSOM.CSSRule.DOCUMENT_RULE = 13;
|
||||
CSSOM.CSSRule.FONT_FEATURE_VALUES_RULE = 14;
|
||||
CSSOM.CSSRule.VIEWPORT_RULE = 15;
|
||||
CSSOM.CSSRule.REGION_STYLE_RULE = 16;
|
||||
|
||||
|
||||
CSSOM.CSSRule.prototype = {
|
||||
constructor: CSSOM.CSSRule
|
||||
//FIXME
|
||||
};
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSRule = CSSOM.CSSRule;
|
||||
///CommonJS
|
148
node_modules/cssom/lib/CSSStyleDeclaration.js
generated
vendored
Normal file
148
node_modules/cssom/lib/CSSStyleDeclaration.js
generated
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration
|
||||
*/
|
||||
CSSOM.CSSStyleDeclaration = function CSSStyleDeclaration(){
|
||||
this.length = 0;
|
||||
this.parentRule = null;
|
||||
|
||||
// NON-STANDARD
|
||||
this._importants = {};
|
||||
};
|
||||
|
||||
|
||||
CSSOM.CSSStyleDeclaration.prototype = {
|
||||
|
||||
constructor: CSSOM.CSSStyleDeclaration,
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} name
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-getPropertyValue
|
||||
* @return {string} the value of the property if it has been explicitly set for this declaration block.
|
||||
* Returns the empty string if the property has not been set.
|
||||
*/
|
||||
getPropertyValue: function(name) {
|
||||
return this[name] || "";
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {string} value
|
||||
* @param {string} [priority=null] "important" or null
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-setProperty
|
||||
*/
|
||||
setProperty: function(name, value, priority) {
|
||||
if (this[name]) {
|
||||
// Property already exist. Overwrite it.
|
||||
var index = Array.prototype.indexOf.call(this, name);
|
||||
if (index < 0) {
|
||||
this[this.length] = name;
|
||||
this.length++;
|
||||
}
|
||||
} else {
|
||||
// New property.
|
||||
this[this.length] = name;
|
||||
this.length++;
|
||||
}
|
||||
this[name] = value + "";
|
||||
this._importants[name] = priority;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} name
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleDeclaration-removeProperty
|
||||
* @return {string} the value of the property if it has been explicitly set for this declaration block.
|
||||
* Returns the empty string if the property has not been set or the property name does not correspond to a known CSS property.
|
||||
*/
|
||||
removeProperty: function(name) {
|
||||
if (!(name in this)) {
|
||||
return "";
|
||||
}
|
||||
var index = Array.prototype.indexOf.call(this, name);
|
||||
if (index < 0) {
|
||||
return "";
|
||||
}
|
||||
var prevValue = this[name];
|
||||
this[name] = "";
|
||||
|
||||
// That's what WebKit and Opera do
|
||||
Array.prototype.splice.call(this, index, 1);
|
||||
|
||||
// That's what Firefox does
|
||||
//this[index] = ""
|
||||
|
||||
return prevValue;
|
||||
},
|
||||
|
||||
getPropertyCSSValue: function() {
|
||||
//FIXME
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {String} name
|
||||
*/
|
||||
getPropertyPriority: function(name) {
|
||||
return this._importants[name] || "";
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* element.style.overflow = "auto"
|
||||
* element.style.getPropertyShorthand("overflow-x")
|
||||
* -> "overflow"
|
||||
*/
|
||||
getPropertyShorthand: function() {
|
||||
//FIXME
|
||||
},
|
||||
|
||||
isPropertyImplicit: function() {
|
||||
//FIXME
|
||||
},
|
||||
|
||||
// Doesn't work in IE < 9
|
||||
get cssText(){
|
||||
var properties = [];
|
||||
for (var i=0, length=this.length; i < length; ++i) {
|
||||
var name = this[i];
|
||||
var value = this.getPropertyValue(name);
|
||||
var priority = this.getPropertyPriority(name);
|
||||
if (priority) {
|
||||
priority = " !" + priority;
|
||||
}
|
||||
properties[i] = name + ": " + value + priority + ";";
|
||||
}
|
||||
return properties.join(" ");
|
||||
},
|
||||
|
||||
set cssText(text){
|
||||
var i, name;
|
||||
for (i = this.length; i--;) {
|
||||
name = this[i];
|
||||
this[name] = "";
|
||||
}
|
||||
Array.prototype.splice.call(this, 0, this.length);
|
||||
this._importants = {};
|
||||
|
||||
var dummyRule = CSSOM.parse('#bogus{' + text + '}').cssRules[0].style;
|
||||
var length = dummyRule.length;
|
||||
for (i = 0; i < length; ++i) {
|
||||
name = dummyRule[i];
|
||||
this.setProperty(dummyRule[i], dummyRule.getPropertyValue(name), dummyRule.getPropertyPriority(name));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSStyleDeclaration = CSSOM.CSSStyleDeclaration;
|
||||
CSSOM.parse = require('./parse').parse; // Cannot be included sooner due to the mutual dependency between parse.js and CSSStyleDeclaration.js
|
||||
///CommonJS
|
190
node_modules/cssom/lib/CSSStyleRule.js
generated
vendored
Normal file
190
node_modules/cssom/lib/CSSStyleRule.js
generated
vendored
Normal file
@ -0,0 +1,190 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
|
||||
CSSRule: require("./CSSRule").CSSRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://dev.w3.org/csswg/cssom/#cssstylerule
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleRule
|
||||
*/
|
||||
CSSOM.CSSStyleRule = function CSSStyleRule() {
|
||||
CSSOM.CSSRule.call(this);
|
||||
this.selectorText = "";
|
||||
this.style = new CSSOM.CSSStyleDeclaration();
|
||||
this.style.parentRule = this;
|
||||
};
|
||||
|
||||
CSSOM.CSSStyleRule.prototype = new CSSOM.CSSRule();
|
||||
CSSOM.CSSStyleRule.prototype.constructor = CSSOM.CSSStyleRule;
|
||||
CSSOM.CSSStyleRule.prototype.type = 1;
|
||||
|
||||
Object.defineProperty(CSSOM.CSSStyleRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var text;
|
||||
if (this.selectorText) {
|
||||
text = this.selectorText + " {" + this.style.cssText + "}";
|
||||
} else {
|
||||
text = "";
|
||||
}
|
||||
return text;
|
||||
},
|
||||
set: function(cssText) {
|
||||
var rule = CSSOM.CSSStyleRule.parse(cssText);
|
||||
this.style = rule.style;
|
||||
this.selectorText = rule.selectorText;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* NON-STANDARD
|
||||
* lightweight version of parse.js.
|
||||
* @param {string} ruleText
|
||||
* @return CSSStyleRule
|
||||
*/
|
||||
CSSOM.CSSStyleRule.parse = function(ruleText) {
|
||||
var i = 0;
|
||||
var state = "selector";
|
||||
var index;
|
||||
var j = i;
|
||||
var buffer = "";
|
||||
|
||||
var SIGNIFICANT_WHITESPACE = {
|
||||
"selector": true,
|
||||
"value": true
|
||||
};
|
||||
|
||||
var styleRule = new CSSOM.CSSStyleRule();
|
||||
var name, priority="";
|
||||
|
||||
for (var character; (character = ruleText.charAt(i)); i++) {
|
||||
|
||||
switch (character) {
|
||||
|
||||
case " ":
|
||||
case "\t":
|
||||
case "\r":
|
||||
case "\n":
|
||||
case "\f":
|
||||
if (SIGNIFICANT_WHITESPACE[state]) {
|
||||
// Squash 2 or more white-spaces in the row into 1
|
||||
switch (ruleText.charAt(i - 1)) {
|
||||
case " ":
|
||||
case "\t":
|
||||
case "\r":
|
||||
case "\n":
|
||||
case "\f":
|
||||
break;
|
||||
default:
|
||||
buffer += " ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// String
|
||||
case '"':
|
||||
j = i + 1;
|
||||
index = ruleText.indexOf('"', j) + 1;
|
||||
if (!index) {
|
||||
throw '" is missing';
|
||||
}
|
||||
buffer += ruleText.slice(i, index);
|
||||
i = index - 1;
|
||||
break;
|
||||
|
||||
case "'":
|
||||
j = i + 1;
|
||||
index = ruleText.indexOf("'", j) + 1;
|
||||
if (!index) {
|
||||
throw "' is missing";
|
||||
}
|
||||
buffer += ruleText.slice(i, index);
|
||||
i = index - 1;
|
||||
break;
|
||||
|
||||
// Comment
|
||||
case "/":
|
||||
if (ruleText.charAt(i + 1) === "*") {
|
||||
i += 2;
|
||||
index = ruleText.indexOf("*/", i);
|
||||
if (index === -1) {
|
||||
throw new SyntaxError("Missing */");
|
||||
} else {
|
||||
i = index + 1;
|
||||
}
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case "{":
|
||||
if (state === "selector") {
|
||||
styleRule.selectorText = buffer.trim();
|
||||
buffer = "";
|
||||
state = "name";
|
||||
}
|
||||
break;
|
||||
|
||||
case ":":
|
||||
if (state === "name") {
|
||||
name = buffer.trim();
|
||||
buffer = "";
|
||||
state = "value";
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case "!":
|
||||
if (state === "value" && ruleText.indexOf("!important", i) === i) {
|
||||
priority = "important";
|
||||
i += "important".length;
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case ";":
|
||||
if (state === "value") {
|
||||
styleRule.style.setProperty(name, buffer.trim(), priority);
|
||||
priority = "";
|
||||
buffer = "";
|
||||
state = "name";
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case "}":
|
||||
if (state === "value") {
|
||||
styleRule.style.setProperty(name, buffer.trim(), priority);
|
||||
priority = "";
|
||||
buffer = "";
|
||||
} else if (state === "name") {
|
||||
break;
|
||||
} else {
|
||||
buffer += character;
|
||||
}
|
||||
state = "selector";
|
||||
break;
|
||||
|
||||
default:
|
||||
buffer += character;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return styleRule;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSStyleRule = CSSOM.CSSStyleRule;
|
||||
///CommonJS
|
88
node_modules/cssom/lib/CSSStyleSheet.js
generated
vendored
Normal file
88
node_modules/cssom/lib/CSSStyleSheet.js
generated
vendored
Normal file
@ -0,0 +1,88 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
StyleSheet: require("./StyleSheet").StyleSheet,
|
||||
CSSStyleRule: require("./CSSStyleRule").CSSStyleRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet
|
||||
*/
|
||||
CSSOM.CSSStyleSheet = function CSSStyleSheet() {
|
||||
CSSOM.StyleSheet.call(this);
|
||||
this.cssRules = [];
|
||||
};
|
||||
|
||||
|
||||
CSSOM.CSSStyleSheet.prototype = new CSSOM.StyleSheet();
|
||||
CSSOM.CSSStyleSheet.prototype.constructor = CSSOM.CSSStyleSheet;
|
||||
|
||||
|
||||
/**
|
||||
* Used to insert a new rule into the style sheet. The new rule now becomes part of the cascade.
|
||||
*
|
||||
* sheet = new Sheet("body {margin: 0}")
|
||||
* sheet.toString()
|
||||
* -> "body{margin:0;}"
|
||||
* sheet.insertRule("img {border: none}", 0)
|
||||
* -> 0
|
||||
* sheet.toString()
|
||||
* -> "img{border:none;}body{margin:0;}"
|
||||
*
|
||||
* @param {string} rule
|
||||
* @param {number} index
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-insertRule
|
||||
* @return {number} The index within the style sheet's rule collection of the newly inserted rule.
|
||||
*/
|
||||
CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
|
||||
if (index < 0 || index > this.cssRules.length) {
|
||||
throw new RangeError("INDEX_SIZE_ERR");
|
||||
}
|
||||
var cssRule = CSSOM.parse(rule).cssRules[0];
|
||||
cssRule.parentStyleSheet = this;
|
||||
this.cssRules.splice(index, 0, cssRule);
|
||||
return index;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Used to delete a rule from the style sheet.
|
||||
*
|
||||
* sheet = new Sheet("img{border:none} body{margin:0}")
|
||||
* sheet.toString()
|
||||
* -> "img{border:none;}body{margin:0;}"
|
||||
* sheet.deleteRule(0)
|
||||
* sheet.toString()
|
||||
* -> "body{margin:0;}"
|
||||
*
|
||||
* @param {number} index within the style sheet's rule list of the rule to remove.
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSStyleSheet-deleteRule
|
||||
*/
|
||||
CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
|
||||
if (index < 0 || index >= this.cssRules.length) {
|
||||
throw new RangeError("INDEX_SIZE_ERR");
|
||||
}
|
||||
this.cssRules.splice(index, 1);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* NON-STANDARD
|
||||
* @return {string} serialize stylesheet
|
||||
*/
|
||||
CSSOM.CSSStyleSheet.prototype.toString = function() {
|
||||
var result = "";
|
||||
var rules = this.cssRules;
|
||||
for (var i=0; i<rules.length; i++) {
|
||||
result += rules[i].cssText + "\n";
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSStyleSheet = CSSOM.CSSStyleSheet;
|
||||
CSSOM.parse = require('./parse').parse; // Cannot be included sooner due to the mutual dependency between parse.js and CSSStyleSheet.js
|
||||
///CommonJS
|
36
node_modules/cssom/lib/CSSSupportsRule.js
generated
vendored
Normal file
36
node_modules/cssom/lib/CSSSupportsRule.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSRule: require("./CSSRule").CSSRule,
|
||||
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule,
|
||||
CSSConditionRule: require("./CSSConditionRule").CSSConditionRule
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see https://drafts.csswg.org/css-conditional-3/#the-csssupportsrule-interface
|
||||
*/
|
||||
CSSOM.CSSSupportsRule = function CSSSupportsRule() {
|
||||
CSSOM.CSSConditionRule.call(this);
|
||||
};
|
||||
|
||||
CSSOM.CSSSupportsRule.prototype = new CSSOM.CSSConditionRule();
|
||||
CSSOM.CSSSupportsRule.prototype.constructor = CSSOM.CSSSupportsRule;
|
||||
CSSOM.CSSSupportsRule.prototype.type = 12;
|
||||
|
||||
Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "cssText", {
|
||||
get: function() {
|
||||
var cssTexts = [];
|
||||
|
||||
for (var i = 0, length = this.cssRules.length; i < length; i++) {
|
||||
cssTexts.push(this.cssRules[i].cssText);
|
||||
}
|
||||
|
||||
return "@supports " + this.conditionText + " {" + cssTexts.join("") + "}";
|
||||
}
|
||||
});
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSSupportsRule = CSSOM.CSSSupportsRule;
|
||||
///CommonJS
|
43
node_modules/cssom/lib/CSSValue.js
generated
vendored
Normal file
43
node_modules/cssom/lib/CSSValue.js
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSValue
|
||||
*
|
||||
* TODO: add if needed
|
||||
*/
|
||||
CSSOM.CSSValue = function CSSValue() {
|
||||
};
|
||||
|
||||
CSSOM.CSSValue.prototype = {
|
||||
constructor: CSSOM.CSSValue,
|
||||
|
||||
// @see: http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSValue
|
||||
set cssText(text) {
|
||||
var name = this._getConstructorName();
|
||||
|
||||
throw new Error('DOMException: property "cssText" of "' + name + '" is readonly and can not be replaced with "' + text + '"!');
|
||||
},
|
||||
|
||||
get cssText() {
|
||||
var name = this._getConstructorName();
|
||||
|
||||
throw new Error('getter "cssText" of "' + name + '" is not implemented!');
|
||||
},
|
||||
|
||||
_getConstructorName: function() {
|
||||
var s = this.constructor.toString(),
|
||||
c = s.match(/function\s([^\(]+)/),
|
||||
name = c[1];
|
||||
|
||||
return name;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSValue = CSSOM.CSSValue;
|
||||
///CommonJS
|
344
node_modules/cssom/lib/CSSValueExpression.js
generated
vendored
Normal file
344
node_modules/cssom/lib/CSSValueExpression.js
generated
vendored
Normal file
@ -0,0 +1,344 @@
|
||||
//.CommonJS
|
||||
var CSSOM = {
|
||||
CSSValue: require('./CSSValue').CSSValue
|
||||
};
|
||||
///CommonJS
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @see http://msdn.microsoft.com/en-us/library/ms537634(v=vs.85).aspx
|
||||
*
|
||||
*/
|
||||
CSSOM.CSSValueExpression = function CSSValueExpression(token, idx) {
|
||||
this._token = token;
|
||||
this._idx = idx;
|
||||
};
|
||||
|
||||
CSSOM.CSSValueExpression.prototype = new CSSOM.CSSValue();
|
||||
CSSOM.CSSValueExpression.prototype.constructor = CSSOM.CSSValueExpression;
|
||||
|
||||
/**
|
||||
* parse css expression() value
|
||||
*
|
||||
* @return {Object}
|
||||
* - error:
|
||||
* or
|
||||
* - idx:
|
||||
* - expression:
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* .selector {
|
||||
* zoom: expression(documentElement.clientWidth > 1000 ? '1000px' : 'auto');
|
||||
* }
|
||||
*/
|
||||
CSSOM.CSSValueExpression.prototype.parse = function() {
|
||||
var token = this._token,
|
||||
idx = this._idx;
|
||||
|
||||
var character = '',
|
||||
expression = '',
|
||||
error = '',
|
||||
info,
|
||||
paren = [];
|
||||
|
||||
|
||||
for (; ; ++idx) {
|
||||
character = token.charAt(idx);
|
||||
|
||||
// end of token
|
||||
if (character === '') {
|
||||
error = 'css expression error: unfinished expression!';
|
||||
break;
|
||||
}
|
||||
|
||||
switch(character) {
|
||||
case '(':
|
||||
paren.push(character);
|
||||
expression += character;
|
||||
break;
|
||||
|
||||
case ')':
|
||||
paren.pop(character);
|
||||
expression += character;
|
||||
break;
|
||||
|
||||
case '/':
|
||||
if ((info = this._parseJSComment(token, idx))) { // comment?
|
||||
if (info.error) {
|
||||
error = 'css expression error: unfinished comment in expression!';
|
||||
} else {
|
||||
idx = info.idx;
|
||||
// ignore the comment
|
||||
}
|
||||
} else if ((info = this._parseJSRexExp(token, idx))) { // regexp
|
||||
idx = info.idx;
|
||||
expression += info.text;
|
||||
} else { // other
|
||||
expression += character;
|
||||
}
|
||||
break;
|
||||
|
||||
case "'":
|
||||
case '"':
|
||||
info = this._parseJSString(token, idx, character);
|
||||
if (info) { // string
|
||||
idx = info.idx;
|
||||
expression += info.text;
|
||||
} else {
|
||||
expression += character;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
expression += character;
|
||||
break;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
break;
|
||||
}
|
||||
|
||||
// end of expression
|
||||
if (paren.length === 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var ret;
|
||||
if (error) {
|
||||
ret = {
|
||||
error: error
|
||||
};
|
||||
} else {
|
||||
ret = {
|
||||
idx: idx,
|
||||
expression: expression
|
||||
};
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {Object|false}
|
||||
* - idx:
|
||||
* - text:
|
||||
* or
|
||||
* - error:
|
||||
* or
|
||||
* false
|
||||
*
|
||||
*/
|
||||
CSSOM.CSSValueExpression.prototype._parseJSComment = function(token, idx) {
|
||||
var nextChar = token.charAt(idx + 1),
|
||||
text;
|
||||
|
||||
if (nextChar === '/' || nextChar === '*') {
|
||||
var startIdx = idx,
|
||||
endIdx,
|
||||
commentEndChar;
|
||||
|
||||
if (nextChar === '/') { // line comment
|
||||
commentEndChar = '\n';
|
||||
} else if (nextChar === '*') { // block comment
|
||||
commentEndChar = '*/';
|
||||
}
|
||||
|
||||
endIdx = token.indexOf(commentEndChar, startIdx + 1 + 1);
|
||||
if (endIdx !== -1) {
|
||||
endIdx = endIdx + commentEndChar.length - 1;
|
||||
text = token.substring(idx, endIdx + 1);
|
||||
return {
|
||||
idx: endIdx,
|
||||
text: text
|
||||
};
|
||||
} else {
|
||||
var error = 'css expression error: unfinished comment in expression!';
|
||||
return {
|
||||
error: error
|
||||
};
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return {Object|false}
|
||||
* - idx:
|
||||
* - text:
|
||||
* or
|
||||
* false
|
||||
*
|
||||
*/
|
||||
CSSOM.CSSValueExpression.prototype._parseJSString = function(token, idx, sep) {
|
||||
var endIdx = this._findMatchedIdx(token, idx, sep),
|
||||
text;
|
||||
|
||||
if (endIdx === -1) {
|
||||
return false;
|
||||
} else {
|
||||
text = token.substring(idx, endIdx + sep.length);
|
||||
|
||||
return {
|
||||
idx: endIdx,
|
||||
text: text
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* parse regexp in css expression
|
||||
*
|
||||
* @return {Object|false}
|
||||
* - idx:
|
||||
* - regExp:
|
||||
* or
|
||||
* false
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
all legal RegExp
|
||||
|
||||
/a/
|
||||
(/a/)
|
||||
[/a/]
|
||||
[12, /a/]
|
||||
|
||||
!/a/
|
||||
|
||||
+/a/
|
||||
-/a/
|
||||
* /a/
|
||||
/ /a/
|
||||
%/a/
|
||||
|
||||
===/a/
|
||||
!==/a/
|
||||
==/a/
|
||||
!=/a/
|
||||
>/a/
|
||||
>=/a/
|
||||
</a/
|
||||
<=/a/
|
||||
|
||||
&/a/
|
||||
|/a/
|
||||
^/a/
|
||||
~/a/
|
||||
<</a/
|
||||
>>/a/
|
||||
>>>/a/
|
||||
|
||||
&&/a/
|
||||
||/a/
|
||||
?/a/
|
||||
=/a/
|
||||
,/a/
|
||||
|
||||
delete /a/
|
||||
in /a/
|
||||
instanceof /a/
|
||||
new /a/
|
||||
typeof /a/
|
||||
void /a/
|
||||
|
||||
*/
|
||||
CSSOM.CSSValueExpression.prototype._parseJSRexExp = function(token, idx) {
|
||||
var before = token.substring(0, idx).replace(/\s+$/, ""),
|
||||
legalRegx = [
|
||||
/^$/,
|
||||
/\($/,
|
||||
/\[$/,
|
||||
/\!$/,
|
||||
/\+$/,
|
||||
/\-$/,
|
||||
/\*$/,
|
||||
/\/\s+/,
|
||||
/\%$/,
|
||||
/\=$/,
|
||||
/\>$/,
|
||||
/<$/,
|
||||
/\&$/,
|
||||
/\|$/,
|
||||
/\^$/,
|
||||
/\~$/,
|
||||
/\?$/,
|
||||
/\,$/,
|
||||
/delete$/,
|
||||
/in$/,
|
||||
/instanceof$/,
|
||||
/new$/,
|
||||
/typeof$/,
|
||||
/void$/
|
||||
];
|
||||
|
||||
var isLegal = legalRegx.some(function(reg) {
|
||||
return reg.test(before);
|
||||
});
|
||||
|
||||
if (!isLegal) {
|
||||
return false;
|
||||
} else {
|
||||
var sep = '/';
|
||||
|
||||
// same logic as string
|
||||
return this._parseJSString(token, idx, sep);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* find next sep(same line) index in `token`
|
||||
*
|
||||
* @return {Number}
|
||||
*
|
||||
*/
|
||||
CSSOM.CSSValueExpression.prototype._findMatchedIdx = function(token, idx, sep) {
|
||||
var startIdx = idx,
|
||||
endIdx;
|
||||
|
||||
var NOT_FOUND = -1;
|
||||
|
||||
while(true) {
|
||||
endIdx = token.indexOf(sep, startIdx + 1);
|
||||
|
||||
if (endIdx === -1) { // not found
|
||||
endIdx = NOT_FOUND;
|
||||
break;
|
||||
} else {
|
||||
var text = token.substring(idx + 1, endIdx),
|
||||
matched = text.match(/\\+$/);
|
||||
if (!matched || matched[0] % 2 === 0) { // not escaped
|
||||
break;
|
||||
} else {
|
||||
startIdx = endIdx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// boundary must be in the same line(js sting or regexp)
|
||||
var nextNewLineIdx = token.indexOf('\n', idx + 1);
|
||||
if (nextNewLineIdx < endIdx) {
|
||||
endIdx = NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
return endIdx;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//.CommonJS
|
||||
exports.CSSValueExpression = CSSOM.CSSValueExpression;
|
||||
///CommonJS
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user