diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 000000000..8a5eca55f
Binary files /dev/null and b/.DS_Store differ
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 000000000..3b6641073
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "git.ignoreLimitWarning": true
+}
\ No newline at end of file
diff --git a/api/node_modules/.bin/cleancss b/api/node_modules/.bin/cleancss
deleted file mode 120000
index 2a3439ebe..000000000
--- a/api/node_modules/.bin/cleancss
+++ /dev/null
@@ -1 +0,0 @@
-../clean-css/bin/cleancss
\ No newline at end of file
diff --git a/api/node_modules/.bin/jade b/api/node_modules/.bin/jade
deleted file mode 120000
index 65a3bac6f..000000000
--- a/api/node_modules/.bin/jade
+++ /dev/null
@@ -1 +0,0 @@
-../jade/bin/jade.js
\ No newline at end of file
diff --git a/api/node_modules/.bin/mkdirp b/api/node_modules/.bin/mkdirp
deleted file mode 120000
index 017896ceb..000000000
--- a/api/node_modules/.bin/mkdirp
+++ /dev/null
@@ -1 +0,0 @@
-../mkdirp/bin/cmd.js
\ No newline at end of file
diff --git a/api/node_modules/.bin/parser b/api/node_modules/.bin/parser
new file mode 120000
index 000000000..ce7bf97ef
--- /dev/null
+++ b/api/node_modules/.bin/parser
@@ -0,0 +1 @@
+../@babel/parser/bin/babel-parser.js
\ No newline at end of file
diff --git a/api/node_modules/.bin/uglifyjs b/api/node_modules/.bin/uglifyjs
deleted file mode 120000
index fef3468b6..000000000
--- a/api/node_modules/.bin/uglifyjs
+++ /dev/null
@@ -1 +0,0 @@
-../uglify-js/bin/uglifyjs
\ No newline at end of file
diff --git a/api/node_modules/.package-lock.json b/api/node_modules/.package-lock.json
new file mode 100644
index 000000000..ca504c489
--- /dev/null
+++ b/api/node_modules/.package-lock.json
@@ -0,0 +1,1007 @@
+{
+ "name": "api",
+ "version": "0.0.0",
+ "lockfileVersion": 2,
+ "requires": true,
+ "packages": {
+ "node_modules/@babel/helper-validator-identifier": {
+ "version": "7.12.11",
+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz",
+ "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw=="
+ },
+ "node_modules/@babel/parser": {
+ "version": "7.13.9",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.13.9.tgz",
+ "integrity": "sha512-nEUfRiARCcaVo3ny3ZQjURjHQZUo/JkEw7rLlSZy/psWGnvwXFtPcr6jb7Yb41DVW5LTe6KRq9LGleRNsg1Frw==",
+ "bin": {
+ "parser": "bin/babel-parser.js"
+ },
+ "engines": {
+ "node": ">=6.0.0"
+ }
+ },
+ "node_modules/@babel/types": {
+ "version": "7.13.0",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.13.0.tgz",
+ "integrity": "sha512-hE+HE8rnG1Z6Wzo+MhaKE5lM5eMx71T4EHJgku2E3xIfaULhDcxiiRxUYgwX8qwP1BBSlag+TdGOt6JAidIZTA==",
+ "dependencies": {
+ "@babel/helper-validator-identifier": "^7.12.11",
+ "lodash": "^4.17.19",
+ "to-fast-properties": "^2.0.0"
+ }
+ },
+ "node_modules/accepts": {
+ "version": "1.3.7",
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
+ "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
+ "dependencies": {
+ "mime-types": "~2.1.24",
+ "negotiator": "0.6.2"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/array-flatten": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
+ "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
+ },
+ "node_modules/assert-never": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/assert-never/-/assert-never-1.2.1.tgz",
+ "integrity": "sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw=="
+ },
+ "node_modules/babel-walk": {
+ "version": "3.0.0-canary-5",
+ "resolved": "https://registry.npmjs.org/babel-walk/-/babel-walk-3.0.0-canary-5.tgz",
+ "integrity": "sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==",
+ "dependencies": {
+ "@babel/types": "^7.9.6"
+ },
+ "engines": {
+ "node": ">= 10.0.0"
+ }
+ },
+ "node_modules/basic-auth": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
+ "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
+ "dependencies": {
+ "safe-buffer": "5.1.2"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/body-parser": {
+ "version": "1.19.0",
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
+ "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
+ "dependencies": {
+ "bytes": "3.1.0",
+ "content-type": "~1.0.4",
+ "debug": "2.6.9",
+ "depd": "~1.1.2",
+ "http-errors": "1.7.2",
+ "iconv-lite": "0.4.24",
+ "on-finished": "~2.3.0",
+ "qs": "6.7.0",
+ "raw-body": "2.4.0",
+ "type-is": "~1.6.17"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/body-parser/node_modules/http-errors": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
+ "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
+ "dependencies": {
+ "depd": "~1.1.2",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.1.1",
+ "statuses": ">= 1.5.0 < 2",
+ "toidentifier": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/body-parser/node_modules/setprototypeof": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
+ "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
+ },
+ "node_modules/bytes": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
+ "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/call-bind": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
+ "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
+ "dependencies": {
+ "function-bind": "^1.1.1",
+ "get-intrinsic": "^1.0.2"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/content-disposition": {
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
+ "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
+ "dependencies": {
+ "safe-buffer": "5.1.2"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/content-type": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
+ "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie": {
+ "version": "0.4.0",
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
+ "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/cookie-parser": {
+ "version": "1.4.5",
+ "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.5.tgz",
+ "integrity": "sha512-f13bPUj/gG/5mDr+xLmSxxDsB9DQiTIfhJS/sqjrmfAWiAN+x2O4i/XguTL9yDZ+/IFDanJ+5x7hC4CXT9Tdzw==",
+ "dependencies": {
+ "cookie": "0.4.0",
+ "cookie-signature": "1.0.6"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/cookie-signature": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
+ "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
+ },
+ "node_modules/cors": {
+ "version": "2.8.5",
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
+ "dependencies": {
+ "object-assign": "^4",
+ "vary": "^1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/debug": {
+ "version": "2.6.9",
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
+ "dependencies": {
+ "ms": "2.0.0"
+ }
+ },
+ "node_modules/depd": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
+ "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/destroy": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
+ "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
+ },
+ "node_modules/doctypes": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz",
+ "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk="
+ },
+ "node_modules/ee-first": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
+ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
+ },
+ "node_modules/encodeurl": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
+ "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/escape-html": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
+ "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
+ },
+ "node_modules/etag": {
+ "version": "1.8.1",
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
+ "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/express": {
+ "version": "4.17.1",
+ "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
+ "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
+ "dependencies": {
+ "accepts": "~1.3.7",
+ "array-flatten": "1.1.1",
+ "body-parser": "1.19.0",
+ "content-disposition": "0.5.3",
+ "content-type": "~1.0.4",
+ "cookie": "0.4.0",
+ "cookie-signature": "1.0.6",
+ "debug": "2.6.9",
+ "depd": "~1.1.2",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "finalhandler": "~1.1.2",
+ "fresh": "0.5.2",
+ "merge-descriptors": "1.0.1",
+ "methods": "~1.1.2",
+ "on-finished": "~2.3.0",
+ "parseurl": "~1.3.3",
+ "path-to-regexp": "0.1.7",
+ "proxy-addr": "~2.0.5",
+ "qs": "6.7.0",
+ "range-parser": "~1.2.1",
+ "safe-buffer": "5.1.2",
+ "send": "0.17.1",
+ "serve-static": "1.14.1",
+ "setprototypeof": "1.1.1",
+ "statuses": "~1.5.0",
+ "type-is": "~1.6.18",
+ "utils-merge": "1.0.1",
+ "vary": "~1.1.2"
+ },
+ "engines": {
+ "node": ">= 0.10.0"
+ }
+ },
+ "node_modules/express/node_modules/setprototypeof": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
+ "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
+ },
+ "node_modules/finalhandler": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
+ "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "on-finished": "~2.3.0",
+ "parseurl": "~1.3.3",
+ "statuses": "~1.5.0",
+ "unpipe": "~1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/forwarded": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
+ "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/fresh": {
+ "version": "0.5.2",
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
+ "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/function-bind": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
+ "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
+ },
+ "node_modules/get-intrinsic": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz",
+ "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==",
+ "dependencies": {
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-symbols": "^1.0.1"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/has": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
+ "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
+ "dependencies": {
+ "function-bind": "^1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.4.0"
+ }
+ },
+ "node_modules/has-symbols": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz",
+ "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==",
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/http-errors": {
+ "version": "1.6.3",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz",
+ "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=",
+ "dependencies": {
+ "depd": "~1.1.2",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.1.0",
+ "statuses": ">= 1.4.0 < 2"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/iconv-lite": {
+ "version": "0.4.24",
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
+ },
+ "node_modules/ipaddr.js": {
+ "version": "1.9.1",
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/is-core-module": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.2.0.tgz",
+ "integrity": "sha512-XRAfAdyyY5F5cOXn7hYQDqh2Xmii+DEfIcQGxK/uNwMHhIkPWO0g8msXcbzLe+MpGoR951MlqM/2iIlU4vKDdQ==",
+ "dependencies": {
+ "has": "^1.0.3"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/is-expression": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-4.0.0.tgz",
+ "integrity": "sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==",
+ "dependencies": {
+ "acorn": "^7.1.1",
+ "object-assign": "^4.1.1"
+ }
+ },
+ "node_modules/is-expression/node_modules/acorn": {
+ "version": "7.4.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz",
+ "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==",
+ "bin": {
+ "acorn": "bin/acorn"
+ },
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
+ "node_modules/is-promise": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz",
+ "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o="
+ },
+ "node_modules/is-regex": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz",
+ "integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==",
+ "dependencies": {
+ "call-bind": "^1.0.2",
+ "has-symbols": "^1.0.1"
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/js-stringify": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz",
+ "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds="
+ },
+ "node_modules/lodash": {
+ "version": "4.17.21",
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ },
+ "node_modules/media-typer": {
+ "version": "0.3.0",
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
+ "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/merge-descriptors": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
+ "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
+ },
+ "node_modules/methods": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
+ "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime": {
+ "version": "1.6.0",
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
+ "bin": {
+ "mime": "cli.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/mime-db": {
+ "version": "1.46.0",
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.46.0.tgz",
+ "integrity": "sha512-svXaP8UQRZ5K7or+ZmfNhg2xX3yKDMUzqadsSqi4NCH/KomcH75MAMYAGVlvXn4+b/xOPhS3I2uHKRUzvjY7BQ==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/mime-types": {
+ "version": "2.1.29",
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.29.tgz",
+ "integrity": "sha512-Y/jMt/S5sR9OaqteJtslsFZKWOIIqMACsJSiHghlCAyhf7jfVYjKBmLiX8OgpWeW+fjJ2b+Az69aPFPkUOY6xQ==",
+ "dependencies": {
+ "mime-db": "1.46.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/morgan": {
+ "version": "1.10.0",
+ "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz",
+ "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==",
+ "dependencies": {
+ "basic-auth": "~2.0.1",
+ "debug": "2.6.9",
+ "depd": "~2.0.0",
+ "on-finished": "~2.3.0",
+ "on-headers": "~1.0.2"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/morgan/node_modules/depd": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/ms": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
+ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
+ },
+ "node_modules/negotiator": {
+ "version": "0.6.2",
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
+ "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/object-assign": {
+ "version": "4.1.1",
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
+ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/on-finished": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
+ "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
+ "dependencies": {
+ "ee-first": "1.1.1"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/on-headers": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz",
+ "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/parseurl": {
+ "version": "1.3.3",
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/path-parse": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
+ "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
+ },
+ "node_modules/path-to-regexp": {
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
+ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
+ },
+ "node_modules/proxy-addr": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
+ "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
+ "dependencies": {
+ "forwarded": "~0.1.2",
+ "ipaddr.js": "1.9.1"
+ },
+ "engines": {
+ "node": ">= 0.10"
+ }
+ },
+ "node_modules/pug": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.2.tgz",
+ "integrity": "sha512-bp0I/hiK1D1vChHh6EfDxtndHji55XP/ZJKwsRqrz6lRia6ZC2OZbdAymlxdVFwd1L70ebrVJw4/eZ79skrIaw==",
+ "dependencies": {
+ "pug-code-gen": "^3.0.2",
+ "pug-filters": "^4.0.0",
+ "pug-lexer": "^5.0.1",
+ "pug-linker": "^4.0.0",
+ "pug-load": "^3.0.0",
+ "pug-parser": "^6.0.0",
+ "pug-runtime": "^3.0.1",
+ "pug-strip-comments": "^2.0.0"
+ }
+ },
+ "node_modules/pug-attrs": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-3.0.0.tgz",
+ "integrity": "sha512-azINV9dUtzPMFQktvTXciNAfAuVh/L/JCl0vtPCwvOA21uZrC08K/UnmrL+SXGEVc1FwzjW62+xw5S/uaLj6cA==",
+ "dependencies": {
+ "constantinople": "^4.0.1",
+ "js-stringify": "^1.0.2",
+ "pug-runtime": "^3.0.0"
+ }
+ },
+ "node_modules/pug-attrs/node_modules/constantinople": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz",
+ "integrity": "sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==",
+ "dependencies": {
+ "@babel/parser": "^7.6.0",
+ "@babel/types": "^7.6.1"
+ }
+ },
+ "node_modules/pug-code-gen": {
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.2.tgz",
+ "integrity": "sha512-nJMhW16MbiGRiyR4miDTQMRWDgKplnHyeLvioEJYbk1RsPI3FuA3saEP8uwnTb2nTJEKBU90NFVWJBk4OU5qyg==",
+ "dependencies": {
+ "constantinople": "^4.0.1",
+ "doctypes": "^1.1.0",
+ "js-stringify": "^1.0.2",
+ "pug-attrs": "^3.0.0",
+ "pug-error": "^2.0.0",
+ "pug-runtime": "^3.0.0",
+ "void-elements": "^3.1.0",
+ "with": "^7.0.0"
+ }
+ },
+ "node_modules/pug-code-gen/node_modules/constantinople": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz",
+ "integrity": "sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==",
+ "dependencies": {
+ "@babel/parser": "^7.6.0",
+ "@babel/types": "^7.6.1"
+ }
+ },
+ "node_modules/pug-code-gen/node_modules/void-elements": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
+ "integrity": "sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
+ "node_modules/pug-code-gen/node_modules/with": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz",
+ "integrity": "sha512-RNGKj82nUPg3g5ygxkQl0R937xLyho1J24ItRCBTr/m1YnZkzJy1hUiHUJrc/VlsDQzsCnInEGSg3bci0Lmd4w==",
+ "dependencies": {
+ "@babel/parser": "^7.9.6",
+ "@babel/types": "^7.9.6",
+ "assert-never": "^1.2.1",
+ "babel-walk": "3.0.0-canary-5"
+ },
+ "engines": {
+ "node": ">= 10.0.0"
+ }
+ },
+ "node_modules/pug-error": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.0.0.tgz",
+ "integrity": "sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ=="
+ },
+ "node_modules/pug-filters": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-4.0.0.tgz",
+ "integrity": "sha512-yeNFtq5Yxmfz0f9z2rMXGw/8/4i1cCFecw/Q7+D0V2DdtII5UvqE12VaZ2AY7ri6o5RNXiweGH79OCq+2RQU4A==",
+ "dependencies": {
+ "constantinople": "^4.0.1",
+ "jstransformer": "1.0.0",
+ "pug-error": "^2.0.0",
+ "pug-walk": "^2.0.0",
+ "resolve": "^1.15.1"
+ }
+ },
+ "node_modules/pug-filters/node_modules/asap": {
+ "version": "2.0.6",
+ "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
+ "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY="
+ },
+ "node_modules/pug-filters/node_modules/constantinople": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz",
+ "integrity": "sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==",
+ "dependencies": {
+ "@babel/parser": "^7.6.0",
+ "@babel/types": "^7.6.1"
+ }
+ },
+ "node_modules/pug-filters/node_modules/jstransformer": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz",
+ "integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM=",
+ "dependencies": {
+ "is-promise": "^2.0.0",
+ "promise": "^7.0.1"
+ }
+ },
+ "node_modules/pug-filters/node_modules/promise": {
+ "version": "7.3.1",
+ "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz",
+ "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==",
+ "dependencies": {
+ "asap": "~2.0.3"
+ }
+ },
+ "node_modules/pug-lexer": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-5.0.1.tgz",
+ "integrity": "sha512-0I6C62+keXlZPZkOJeVam9aBLVP2EnbeDw3An+k0/QlqdwH6rv8284nko14Na7c0TtqtogfWXcRoFE4O4Ff20w==",
+ "dependencies": {
+ "character-parser": "^2.2.0",
+ "is-expression": "^4.0.0",
+ "pug-error": "^2.0.0"
+ }
+ },
+ "node_modules/pug-lexer/node_modules/character-parser": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz",
+ "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=",
+ "dependencies": {
+ "is-regex": "^1.0.3"
+ }
+ },
+ "node_modules/pug-linker": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-4.0.0.tgz",
+ "integrity": "sha512-gjD1yzp0yxbQqnzBAdlhbgoJL5qIFJw78juN1NpTLt/mfPJ5VgC4BvkoD3G23qKzJtIIXBbcCt6FioLSFLOHdw==",
+ "dependencies": {
+ "pug-error": "^2.0.0",
+ "pug-walk": "^2.0.0"
+ }
+ },
+ "node_modules/pug-load": {
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-3.0.0.tgz",
+ "integrity": "sha512-OCjTEnhLWZBvS4zni/WUMjH2YSUosnsmjGBB1An7CsKQarYSWQ0GCVyd4eQPMFJqZ8w9xgs01QdiZXKVjk92EQ==",
+ "dependencies": {
+ "object-assign": "^4.1.1",
+ "pug-walk": "^2.0.0"
+ }
+ },
+ "node_modules/pug-parser": {
+ "version": "6.0.0",
+ "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-6.0.0.tgz",
+ "integrity": "sha512-ukiYM/9cH6Cml+AOl5kETtM9NR3WulyVP2y4HOU45DyMim1IeP/OOiyEWRr6qk5I5klpsBnbuHpwKmTx6WURnw==",
+ "dependencies": {
+ "pug-error": "^2.0.0",
+ "token-stream": "1.0.0"
+ }
+ },
+ "node_modules/pug-runtime": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-3.0.1.tgz",
+ "integrity": "sha512-L50zbvrQ35TkpHwv0G6aLSuueDRwc/97XdY8kL3tOT0FmhgG7UypU3VztfV/LATAvmUfYi4wNxSajhSAeNN+Kg=="
+ },
+ "node_modules/pug-strip-comments": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-2.0.0.tgz",
+ "integrity": "sha512-zo8DsDpH7eTkPHCXFeAk1xZXJbyoTfdPlNR0bK7rpOMuhBYb0f5qUVCO1xlsitYd3w5FQTK7zpNVKb3rZoUrrQ==",
+ "dependencies": {
+ "pug-error": "^2.0.0"
+ }
+ },
+ "node_modules/pug-walk": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-2.0.0.tgz",
+ "integrity": "sha512-yYELe9Q5q9IQhuvqsZNwA5hfPkMJ8u92bQLIMcsMxf/VADjNtEYptU+inlufAFYcWdHlwNfZOEnOOQrZrcyJCQ=="
+ },
+ "node_modules/qs": {
+ "version": "6.7.0",
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
+ "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/range-parser": {
+ "version": "1.2.1",
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/raw-body": {
+ "version": "2.4.0",
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
+ "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
+ "dependencies": {
+ "bytes": "3.1.0",
+ "http-errors": "1.7.2",
+ "iconv-lite": "0.4.24",
+ "unpipe": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/raw-body/node_modules/http-errors": {
+ "version": "1.7.2",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
+ "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
+ "dependencies": {
+ "depd": "~1.1.2",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.1.1",
+ "statuses": ">= 1.5.0 < 2",
+ "toidentifier": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/raw-body/node_modules/setprototypeof": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
+ "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
+ },
+ "node_modules/resolve": {
+ "version": "1.20.0",
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
+ "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
+ "dependencies": {
+ "is-core-module": "^2.2.0",
+ "path-parse": "^1.0.6"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ }
+ },
+ "node_modules/safe-buffer": {
+ "version": "5.1.2",
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
+ "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
+ },
+ "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/send": {
+ "version": "0.17.1",
+ "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
+ "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
+ "dependencies": {
+ "debug": "2.6.9",
+ "depd": "~1.1.2",
+ "destroy": "~1.0.4",
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "etag": "~1.8.1",
+ "fresh": "0.5.2",
+ "http-errors": "~1.7.2",
+ "mime": "1.6.0",
+ "ms": "2.1.1",
+ "on-finished": "~2.3.0",
+ "range-parser": "~1.2.1",
+ "statuses": "~1.5.0"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/send/node_modules/http-errors": {
+ "version": "1.7.3",
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.3.tgz",
+ "integrity": "sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw==",
+ "dependencies": {
+ "depd": "~1.1.2",
+ "inherits": "2.0.4",
+ "setprototypeof": "1.1.1",
+ "statuses": ">= 1.5.0 < 2",
+ "toidentifier": "1.0.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/send/node_modules/inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "node_modules/send/node_modules/ms": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
+ "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
+ },
+ "node_modules/send/node_modules/setprototypeof": {
+ "version": "1.1.1",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
+ "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
+ },
+ "node_modules/serve-static": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
+ "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
+ "dependencies": {
+ "encodeurl": "~1.0.2",
+ "escape-html": "~1.0.3",
+ "parseurl": "~1.3.3",
+ "send": "0.17.1"
+ },
+ "engines": {
+ "node": ">= 0.8.0"
+ }
+ },
+ "node_modules/setprototypeof": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz",
+ "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ=="
+ },
+ "node_modules/statuses": {
+ "version": "1.5.0",
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
+ "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=",
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/to-fast-properties": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
+ "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
+ "engines": {
+ "node": ">=4"
+ }
+ },
+ "node_modules/toidentifier": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
+ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==",
+ "engines": {
+ "node": ">=0.6"
+ }
+ },
+ "node_modules/token-stream": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz",
+ "integrity": "sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ="
+ },
+ "node_modules/type-is": {
+ "version": "1.6.18",
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
+ "dependencies": {
+ "media-typer": "0.3.0",
+ "mime-types": "~2.1.24"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ }
+ },
+ "node_modules/unpipe": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
+ "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ },
+ "node_modules/utils-merge": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
+ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=",
+ "engines": {
+ "node": ">= 0.4.0"
+ }
+ },
+ "node_modules/vary": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
+ "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
+ "engines": {
+ "node": ">= 0.8"
+ }
+ }
+ }
+}
diff --git a/api/node_modules/@babel/helper-validator-identifier/LICENSE b/api/node_modules/@babel/helper-validator-identifier/LICENSE
new file mode 100644
index 000000000..f31575ec7
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/LICENSE
@@ -0,0 +1,22 @@
+MIT License
+
+Copyright (c) 2014-present Sebastian McKenzie and other contributors
+
+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.
diff --git a/api/node_modules/@babel/helper-validator-identifier/README.md b/api/node_modules/@babel/helper-validator-identifier/README.md
new file mode 100644
index 000000000..6733576a8
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/README.md
@@ -0,0 +1,19 @@
+# @babel/helper-validator-identifier
+
+> Validate identifier/keywords name
+
+See our website [@babel/helper-validator-identifier](https://babeljs.io/docs/en/babel-helper-validator-identifier) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/helper-validator-identifier
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/helper-validator-identifier --dev
+```
diff --git a/api/node_modules/@babel/helper-validator-identifier/lib/identifier.js b/api/node_modules/@babel/helper-validator-identifier/lib/identifier.js
new file mode 100644
index 000000000..51ec76370
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/lib/identifier.js
@@ -0,0 +1,77 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.isIdentifierStart = isIdentifierStart;
+exports.isIdentifierChar = isIdentifierChar;
+exports.isIdentifierName = isIdentifierName;
+let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
+let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
+const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
+const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
+nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
+const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
+const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
+
+function isInAstralSet(code, set) {
+ let pos = 0x10000;
+
+ for (let i = 0, length = set.length; i < length; i += 2) {
+ pos += set[i];
+ if (pos > code) return false;
+ pos += set[i + 1];
+ if (pos >= code) return true;
+ }
+
+ return false;
+}
+
+function isIdentifierStart(code) {
+ if (code < 65) return code === 36;
+ if (code <= 90) return true;
+ if (code < 97) return code === 95;
+ if (code <= 122) return true;
+
+ if (code <= 0xffff) {
+ return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
+ }
+
+ return isInAstralSet(code, astralIdentifierStartCodes);
+}
+
+function isIdentifierChar(code) {
+ if (code < 48) return code === 36;
+ if (code < 58) return true;
+ if (code < 65) return false;
+ if (code <= 90) return true;
+ if (code < 97) return code === 95;
+ if (code <= 122) return true;
+
+ if (code <= 0xffff) {
+ return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
+ }
+
+ return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
+}
+
+function isIdentifierName(name) {
+ let isFirst = true;
+
+ for (let _i = 0, _Array$from = Array.from(name); _i < _Array$from.length; _i++) {
+ const char = _Array$from[_i];
+ const cp = char.codePointAt(0);
+
+ if (isFirst) {
+ if (!isIdentifierStart(cp)) {
+ return false;
+ }
+
+ isFirst = false;
+ } else if (!isIdentifierChar(cp)) {
+ return false;
+ }
+ }
+
+ return !isFirst;
+}
\ No newline at end of file
diff --git a/api/node_modules/@babel/helper-validator-identifier/lib/index.js b/api/node_modules/@babel/helper-validator-identifier/lib/index.js
new file mode 100644
index 000000000..7b623c90a
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/lib/index.js
@@ -0,0 +1,57 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+Object.defineProperty(exports, "isIdentifierName", {
+ enumerable: true,
+ get: function () {
+ return _identifier.isIdentifierName;
+ }
+});
+Object.defineProperty(exports, "isIdentifierChar", {
+ enumerable: true,
+ get: function () {
+ return _identifier.isIdentifierChar;
+ }
+});
+Object.defineProperty(exports, "isIdentifierStart", {
+ enumerable: true,
+ get: function () {
+ return _identifier.isIdentifierStart;
+ }
+});
+Object.defineProperty(exports, "isReservedWord", {
+ enumerable: true,
+ get: function () {
+ return _keyword.isReservedWord;
+ }
+});
+Object.defineProperty(exports, "isStrictBindOnlyReservedWord", {
+ enumerable: true,
+ get: function () {
+ return _keyword.isStrictBindOnlyReservedWord;
+ }
+});
+Object.defineProperty(exports, "isStrictBindReservedWord", {
+ enumerable: true,
+ get: function () {
+ return _keyword.isStrictBindReservedWord;
+ }
+});
+Object.defineProperty(exports, "isStrictReservedWord", {
+ enumerable: true,
+ get: function () {
+ return _keyword.isStrictReservedWord;
+ }
+});
+Object.defineProperty(exports, "isKeyword", {
+ enumerable: true,
+ get: function () {
+ return _keyword.isKeyword;
+ }
+});
+
+var _identifier = require("./identifier");
+
+var _keyword = require("./keyword");
\ No newline at end of file
diff --git a/api/node_modules/@babel/helper-validator-identifier/lib/keyword.js b/api/node_modules/@babel/helper-validator-identifier/lib/keyword.js
new file mode 100644
index 000000000..110cee400
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/lib/keyword.js
@@ -0,0 +1,38 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.isReservedWord = isReservedWord;
+exports.isStrictReservedWord = isStrictReservedWord;
+exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord;
+exports.isStrictBindReservedWord = isStrictBindReservedWord;
+exports.isKeyword = isKeyword;
+const reservedWords = {
+ keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
+ strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
+ strictBind: ["eval", "arguments"]
+};
+const keywords = new Set(reservedWords.keyword);
+const reservedWordsStrictSet = new Set(reservedWords.strict);
+const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
+
+function isReservedWord(word, inModule) {
+ return inModule && word === "await" || word === "enum";
+}
+
+function isStrictReservedWord(word, inModule) {
+ return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
+}
+
+function isStrictBindOnlyReservedWord(word) {
+ return reservedWordsStrictBindSet.has(word);
+}
+
+function isStrictBindReservedWord(word, inModule) {
+ return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
+}
+
+function isKeyword(word) {
+ return keywords.has(word);
+}
\ No newline at end of file
diff --git a/api/node_modules/@babel/helper-validator-identifier/package.json b/api/node_modules/@babel/helper-validator-identifier/package.json
new file mode 100644
index 000000000..464dbfa3a
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/package.json
@@ -0,0 +1,20 @@
+{
+ "name": "@babel/helper-validator-identifier",
+ "version": "7.12.11",
+ "description": "Validate identifier/keywords name",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-helper-validator-identifier"
+ },
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "exports": "./lib/index.js",
+ "devDependencies": {
+ "charcodes": "^0.2.0",
+ "unicode-13.0.0": "^0.8.0"
+ }
+}
\ No newline at end of file
diff --git a/api/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js b/api/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js
new file mode 100644
index 000000000..70b371508
--- /dev/null
+++ b/api/node_modules/@babel/helper-validator-identifier/scripts/generate-identifier-regex.js
@@ -0,0 +1,75 @@
+"use strict";
+
+// Always use the latest available version of Unicode!
+// https://tc39.github.io/ecma262/#sec-conformance
+const version = "13.0.0";
+
+const start = require("unicode-" +
+ version +
+ "/Binary_Property/ID_Start/code-points.js").filter(function (ch) {
+ return ch > 0x7f;
+});
+let last = -1;
+const cont = [0x200c, 0x200d].concat(
+ require("unicode-" +
+ version +
+ "/Binary_Property/ID_Continue/code-points.js").filter(function (ch) {
+ return ch > 0x7f && search(start, ch, last + 1) == -1;
+ })
+);
+
+function search(arr, ch, starting) {
+ for (let i = starting; arr[i] <= ch && i < arr.length; last = i++) {
+ if (arr[i] === ch) return i;
+ }
+ return -1;
+}
+
+function pad(str, width) {
+ while (str.length < width) str = "0" + str;
+ return str;
+}
+
+function esc(code) {
+ const hex = code.toString(16);
+ if (hex.length <= 2) return "\\x" + pad(hex, 2);
+ else return "\\u" + pad(hex, 4);
+}
+
+function generate(chars) {
+ const astral = [];
+ let re = "";
+ for (let i = 0, at = 0x10000; i < chars.length; i++) {
+ const from = chars[i];
+ let to = from;
+ while (i < chars.length - 1 && chars[i + 1] == to + 1) {
+ i++;
+ to++;
+ }
+ if (to <= 0xffff) {
+ if (from == to) re += esc(from);
+ else if (from + 1 == to) re += esc(from) + esc(to);
+ else re += esc(from) + "-" + esc(to);
+ } else {
+ astral.push(from - at, to - from);
+ at = to;
+ }
+ }
+ return { nonASCII: re, astral: astral };
+}
+
+const startData = generate(start);
+const contData = generate(cont);
+
+console.log("/* prettier-ignore */");
+console.log('let nonASCIIidentifierStartChars = "' + startData.nonASCII + '";');
+console.log("/* prettier-ignore */");
+console.log('let nonASCIIidentifierChars = "' + contData.nonASCII + '";');
+console.log("/* prettier-ignore */");
+console.log(
+ "const astralIdentifierStartCodes = " + JSON.stringify(startData.astral) + ";"
+);
+console.log("/* prettier-ignore */");
+console.log(
+ "const astralIdentifierCodes = " + JSON.stringify(contData.astral) + ";"
+);
diff --git a/api/node_modules/@babel/parser/CHANGELOG.md b/api/node_modules/@babel/parser/CHANGELOG.md
new file mode 100644
index 000000000..b3840ac8d
--- /dev/null
+++ b/api/node_modules/@babel/parser/CHANGELOG.md
@@ -0,0 +1,1073 @@
+# Changelog
+
+> **Tags:**
+> - :boom: [Breaking Change]
+> - :eyeglasses: [Spec Compliance]
+> - :rocket: [New Feature]
+> - :bug: [Bug Fix]
+> - :memo: [Documentation]
+> - :house: [Internal]
+> - :nail_care: [Polish]
+
+> Semver Policy: https://github.com/babel/babel/tree/main/packages/babel-parser#semver
+
+_Note: Gaps between patch versions are faulty, broken or test releases._
+
+See the [Babel Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) for the pre-6.8.0 version Changelog.
+
+## 6.17.1 (2017-05-10)
+
+### :bug: Bug Fix
+ * Fix typo in flow spread operator error (Brian Ng)
+ * Fixed invalid number literal parsing ([#473](https://github.com/babel/babylon/pull/473)) (Alex Kuzmenko)
+ * Fix number parser ([#433](https://github.com/babel/babylon/pull/433)) (Alex Kuzmenko)
+ * Ensure non pattern shorthand props are checked for reserved words ([#479](https://github.com/babel/babylon/pull/479)) (Brian Ng)
+ * Remove jsx context when parsing arrow functions ([#475](https://github.com/babel/babylon/pull/475)) (Brian Ng)
+ * Allow super in class properties ([#499](https://github.com/babel/babylon/pull/499)) (Brian Ng)
+ * Allow flow class field to be named constructor ([#510](https://github.com/babel/babylon/pull/510)) (Brian Ng)
+
+## 6.17.0 (2017-04-20)
+
+### :bug: Bug Fix
+ * Cherry-pick #418 to 6.x ([#476](https://github.com/babel/babylon/pull/476)) (Sebastian McKenzie)
+ * Add support for invalid escapes in tagged templates ([#274](https://github.com/babel/babylon/pull/274)) (Kevin Gibbons)
+ * Throw error if new.target is used outside of a function ([#402](https://github.com/babel/babylon/pull/402)) (Brian Ng)
+ * Fix parsing of class properties ([#351](https://github.com/babel/babylon/pull/351)) (Kevin Gibbons)
+ * Fix parsing yield with dynamicImport ([#383](https://github.com/babel/babylon/pull/383)) (Brian Ng)
+ * Ensure consistent start args for parseParenItem ([#386](https://github.com/babel/babylon/pull/386)) (Brian Ng)
+
+## 7.0.0-beta.8 (2017-04-04)
+
+### New Feature
+* Add support for flow type spread (#418) (Conrad Buck)
+* Allow statics in flow interfaces (#427) (Brian Ng)
+
+### Bug Fix
+* Fix predicate attachment to match flow parser (#428) (Brian Ng)
+* Add extra.raw back to JSXText and JSXAttribute (#344) (Alex Rattray)
+* Fix rest parameters with array and objects (#424) (Brian Ng)
+* Fix number parser (#433) (Alex Kuzmenko)
+
+### Docs
+* Fix CONTRIBUTING.md [skip ci] (#432) (Alex Kuzmenko)
+
+### Internal
+* Use babel-register script when running babel smoke tests (#442) (Brian Ng)
+
+## 7.0.0-beta.7 (2017-03-22)
+
+### Spec Compliance
+* Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu)
+
+### Bug Fix
+
+* Fix push-pop logic in flow (#405) (Daniel Tschinder)
+
+## 7.0.0-beta.6 (2017-03-21)
+
+### New Feature
+* Add support for invalid escapes in tagged templates (#274) (Kevin Gibbons)
+
+### Polish
+* Improves error message when super is called outside of constructor (#408) (Arshabh Kumar Agarwal)
+
+### Docs
+
+* [7.0] Moved value field in spec from ObjectMember to ObjectProperty as ObjectMethod's don't have it (#415) [skip ci] (James Browning)
+
+## 7.0.0-beta.5 (2017-03-21)
+
+### Bug Fix
+* Throw error if new.target is used outside of a function (#402) (Brian Ng)
+* Fix parsing of class properties (#351) (Kevin Gibbons)
+
+### Other
+ * Test runner: Detect extra property in 'actual' but not in 'expected'. (#407) (Andy)
+ * Optimize travis builds (#419) (Daniel Tschinder)
+ * Update codecov to 2.0 (#412) (Daniel Tschinder)
+ * Fix spec for ClassMethod: It doesn't have a function, it *is* a function. (#406) [skip ci] (Andy)
+ * Changed Non-existent RestPattern to RestElement which is what is actually parsed (#409) [skip ci] (James Browning)
+ * Upgrade flow to 0.41 (Daniel Tschinder)
+ * Fix watch command (#403) (Brian Ng)
+ * Update yarn lock (Daniel Tschinder)
+ * Fix watch command (#403) (Brian Ng)
+ * chore(package): update flow-bin to version 0.41.0 (#395) (greenkeeper[bot])
+ * Add estree test for correct order of directives (Daniel Tschinder)
+ * Add DoExpression to spec (#364) (Alex Kuzmenko)
+ * Mention cloning of repository in CONTRIBUTING.md (#391) [skip ci] (Sumedh Nimkarde)
+ * Explain how to run only one test (#389) [skip ci] (Aaron Ang)
+
+ ## 7.0.0-beta.4 (2017-03-01)
+
+* Don't consume async when checking for async func decl (#377) (Brian Ng)
+* add `ranges` option [skip ci] (Henry Zhu)
+* Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300) (Andrew Levine)
+
+## 7.0.0-beta.3 (2017-02-28)
+
+- [7.0] Change RestProperty/SpreadProperty to RestElement/SpreadElement (#384)
+- Merge changes from 6.x
+
+## 7.0.0-beta.2 (2017-02-20)
+
+- estree: correctly change literals in all cases (#368) (Daniel Tschinder)
+
+## 7.0.0-beta.1 (2017-02-20)
+
+- Fix negative number literal typeannotations (#366) (Daniel Tschinder)
+- Update contributing with more test info [skip ci] (#355) (Brian Ng)
+
+## 7.0.0-beta.0 (2017-02-15)
+
+- Reintroduce Variance node (#333) (Daniel Tschinder)
+- Rename NumericLiteralTypeAnnotation to NumberLiteralTypeAnnotation (#332) (Charles Pick)
+- [7.0] Remove ForAwaitStatement, add await flag to ForOfStatement (#349) (Brandon Dail)
+- chore(package): update ava to version 0.18.0 (#345) (greenkeeper[bot])
+- chore(package): update babel-plugin-istanbul to version 4.0.0 (#350) (greenkeeper[bot])
+- Change location of ObjectTypeIndexer to match flow (#228) (Daniel Tschinder)
+- Rename flow AST Type ExistentialTypeParam to ExistsTypeAnnotation (#322) (Toru Kobayashi)
+- Revert "Temporary rollback for erroring on trailing comma with spread (#154)" (#290) (Daniel Tschinder)
+- Remove classConstructorCall plugin (#291) (Brian Ng)
+- Update yarn.lock (Daniel Tschinder)
+- Update cross-env to 3.x (Daniel Tschinder)
+- [7.0] Remove node 0.10, 0.12 and 5 from Travis (#284) (Sergey Rubanov)
+- Remove `String.fromCodePoint` shim (#279) (Mathias Bynens)
+
+## 6.16.1 (2017-02-23)
+
+### :bug: Regression
+
+- Revert "Fix export default async function to be FunctionDeclaration" ([#375](https://github.com/babel/babylon/pull/375))
+
+Need to modify Babel for this AST node change, so moving to 7.0.
+
+- Revert "Don't parse class properties without initializers when classProperties plugin is disabled, and Flow is enabled" ([#376](https://github.com/babel/babylon/pull/376))
+
+[react-native](https://github.com/facebook/react-native/issues/12542) broke with this so we reverted.
+
+## 6.16.0 (2017-02-23)
+
+### :rocket: New Feature
+
+***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder)
+
+We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/)
+
+We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc.
+
+To enable `estree` mode simply add the plugin in the config:
+```json
+{
+ "plugins": [ "estree" ]
+}
+```
+
+If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned.
+
+Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew)
+
+Babylon exports a new function to parse a single expression
+
+```js
+import { parseExpression } from 'babylon';
+
+const ast = parseExpression('x || y && z', options);
+```
+
+The returned AST will only consist of the expression. The options are the same as for `parse()`
+
+Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
+
+A new option was added to babylon allowing to change the initial linenumber for the first line which is usually `1`.
+Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
+
+Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
+
+Added support for function predicates which flow introduced in version 0.33.0
+
+```js
+declare function is_number(x: mixed): boolean %checks(typeof x === "number");
+```
+
+Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder)
+
+Added support for imports within module declarations which flow introduced in version 0.37.0
+
+```js
+declare module "C" {
+ import type { DT } from "D";
+ declare export type CT = { D: DT };
+}
+```
+
+### :eyeglasses: Spec Compliance
+
+Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
+
+This example now correctly throws an error when there is a semicolon after the decorator:
+
+```js
+class A {
+@a;
+foo(){}
+}
+```
+
+Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder)
+
+Using keywords in imports is not allowed anymore:
+
+```js
+import { default } from "foo";
+import { a as debugger } from "foo";
+```
+
+Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
+
+In flow it is now forbidden to overwrite the primitive types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
+
+Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
+
+The following code now correctly throws an error
+
+```js
+import type { type a } from "foo";
+```
+
+Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine)
+
+Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour.
+
+If you enable the flow plugin you can only define the type of the class properties, but not initialize them.
+
+Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder)
+
+Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`.
+
+```js
+export default async function bar() {};
+```
+
+### :nail_care: Polish
+
+Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng)
+
+### :bug: Bug Fix
+
+Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder)
+
+Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng)
+
+ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder)
+
+Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder)
+
+Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder)
+
+Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder)
+
+Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng)
+
+Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper)
+
+
+### :house: Internal
+
+Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray)
+
+Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray)
+
+Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder)
+
+chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot])
+
+Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder)
+
+Update eslint-config-babel to the latest version 🚀 ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot])
+
+Update eslint-config-babel to the latest version 🚀 ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot])
+
+devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo)
+
+Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder)
+
+Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder)
+
+### :memo: Documentation
+
+Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng)
+
+Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu)
+
+Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro)
+
+AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens)
+
+## 6.15.0 (2017-01-10)
+
+### :eyeglasses: Spec Compliance
+
+Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
+
+This change implements flows new shorthand import syntax
+and where previously you had to write this code:
+
+```js
+import {someValue} from "blah";
+import type {someType} from "blah";
+import typeof {someOtherValue} from "blah";
+```
+
+you can now write it like this:
+
+```js
+import {
+ someValue,
+ type someType,
+ typeof someOtherValue,
+} from "blah";
+```
+
+For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request.
+
+flow: allow leading pipes in all positions ([#256](https://github.com/babel/babylon/pull/256)) (Vladimir Kurchatkin)
+
+This change now allows a leading pipe everywhere types can be used:
+```js
+var f = (x): | 1 | 2 => 1;
+```
+
+Throw error when exporting non-declaration ([#241](https://github.com/babel/babylon/pull/241)) (Kai Cataldo)
+
+Previously babylon parsed the following exports, although they are not valid:
+```js
+export typeof foo;
+export new Foo();
+export function() {};
+export for (;;);
+export while(foo);
+```
+
+### :bug: Bug Fix
+
+Don't set inType flag when parsing property names ([#266](https://github.com/babel/babylon/pull/266)) (Vladimir Kurchatkin)
+
+This fixes parsing of this case:
+
+```js
+const map = {
+ [age <= 17] : 'Too young'
+};
+```
+
+Fix source location for JSXEmptyExpression nodes (fixes #248) ([#249](https://github.com/babel/babylon/pull/249)) (James Long)
+
+The following case produced an invalid AST
+```js
+
{/* foo */}
+```
+
+Use fromCodePoint to convert high value unicode entities ([#243](https://github.com/babel/babylon/pull/243)) (Ryan Duffy)
+
+When high value unicode entities (e.g. 💩) were used in the input source code they are now correctly encoded in the resulting AST.
+
+Rename folder to avoid Windows-illegal characters ([#281](https://github.com/babel/babylon/pull/281)) (Ryan Plant)
+
+Allow this.state.clone() when parsing decorators ([#262](https://github.com/babel/babylon/pull/262)) (Alex Rattray)
+
+### :house: Internal
+
+User external-helpers ([#254](https://github.com/babel/babylon/pull/254)) (Daniel Tschinder)
+
+Add watch script for dev ([#234](https://github.com/babel/babylon/pull/234)) (Kai Cataldo)
+
+Freeze current plugins list for "*" option, and remove from README.md ([#245](https://github.com/babel/babylon/pull/245)) (Andrew Levine)
+
+Prepare tests for multiple fixture runners. ([#240](https://github.com/babel/babylon/pull/240)) (Daniel Tschinder)
+
+Add some test coverage for decorators stage-0 plugin ([#250](https://github.com/babel/babylon/pull/250)) (Andrew Levine)
+
+Refactor tokenizer types file ([#263](https://github.com/babel/babylon/pull/263)) (Sven SAULEAU)
+
+Update eslint-config-babel to the latest version 🚀 ([#273](https://github.com/babel/babylon/pull/273)) (greenkeeper[bot])
+
+chore(package): update rollup to version 0.41.0 ([#272](https://github.com/babel/babylon/pull/272)) (greenkeeper[bot])
+
+chore(package): update flow-bin to version 0.37.0 ([#255](https://github.com/babel/babylon/pull/255)) (greenkeeper[bot])
+
+## 6.14.1 (2016-11-17)
+
+### :bug: Bug Fix
+
+Allow `"plugins": ["*"]` ([#229](https://github.com/babel/babylon/pull/229)) (Daniel Tschinder)
+
+```js
+{
+ "plugins": ["*"]
+}
+```
+
+Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer.
+
+## 6.14.0 (2016-11-16)
+
+### :eyeglasses: Spec Compliance
+
+Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
+
+[11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words)
+
+Babylon will throw for more reserved words such as `enum` or `await` (in strict mode).
+
+```
+class enum {} // throws
+class await {} // throws in strict mode (module)
+```
+
+Optional names for function types and object type indexers ([#197](https://github.com/babel/babylon/pull/197)) (Gabe Levi)
+
+So where you used to have to write
+
+```js
+type A = (x: string, y: boolean) => number;
+type B = (z: string) => number;
+type C = { [key: string]: number };
+```
+
+you can now write (with flow 0.34.0)
+
+```js
+type A = (string, boolean) => number;
+type B = string => number;
+type C = { [string]: number };
+```
+
+Parse flow nested array type annotations like `number[][]` ([#219](https://github.com/babel/babylon/pull/219)) (Bernhard Häussner)
+
+Supports these form now of specifying array types:
+
+```js
+var a: number[][][][];
+var b: string[][];
+```
+
+### :bug: Bug Fix
+
+Correctly eat semicolon at the end of `DelcareModuleExports` ([#223](https://github.com/babel/babylon/pull/223)) (Daniel Tschinder)
+
+```
+declare module "foo" { declare module.exports: number }
+declare module "foo" { declare module.exports: number; } // also allowed now
+```
+
+### :house: Internal
+
+ * Count Babel tests towards Babylon code coverage ([#182](https://github.com/babel/babylon/pull/182)) (Moti Zilberman)
+ * Fix strange line endings ([#214](https://github.com/babel/babylon/pull/214)) (Thomas Grainger)
+ * Add node 7 (Daniel Tschinder)
+ * chore(package): update flow-bin to version 0.34.0 ([#204](https://github.com/babel/babylon/pull/204)) (Greenkeeper)
+
+## v6.13.1 (2016-10-26)
+
+### :nail_care: Polish
+
+- Use rollup for bundling to speed up startup time ([#190](https://github.com/babel/babylon/pull/190)) ([@drewml](https://github.com/DrewML))
+
+```js
+const babylon = require('babylon');
+const ast = babylon.parse('var foo = "lol";');
+```
+
+With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph.
+
+**Without bundling**
+![image](https://cloud.githubusercontent.com/assets/5233399/19420264/3133497e-93ad-11e6-9a6a-2da59c4f5c13.png)
+
+**With bundling**
+![image](https://cloud.githubusercontent.com/assets/5233399/19420267/388f556e-93ad-11e6-813e-7c5c396be322.png)
+
+- add clean command [skip ci] ([#201](https://github.com/babel/babylon/pull/201)) (Henry Zhu)
+- add ForAwaitStatement (async generator already added) [skip ci] ([#196](https://github.com/babel/babylon/pull/196)) (Henry Zhu)
+
+## v6.13.0 (2016-10-21)
+
+### :eyeglasses: Spec Compliance
+
+Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
+
+> See https://flowtype.org/docs/variance.html for more information
+
+```js
+type T = { +p: T };
+interface T { -p: T };
+declare class T { +[k:K]: V };
+class T { -[k:K]: V };
+class C2 { +p: T = e };
+```
+
+Raise error on duplicate definition of __proto__ ([#183](https://github.com/babel/babylon/pull/183)) (Moti Zilberman)
+
+```js
+({ __proto__: 1, __proto__: 2 }) // Throws an error now
+```
+
+### :bug: Bug Fix
+
+Flow: Allow class properties to be named `static` ([#184](https://github.com/babel/babylon/pull/184)) (Moti Zilberman)
+
+```js
+declare class A {
+ static: T;
+}
+```
+
+Allow "async" as identifier for object literal property shorthand ([#187](https://github.com/babel/babylon/pull/187)) (Andrew Levine)
+
+```js
+var foo = { async, bar };
+```
+
+### :nail_care: Polish
+
+Fix flowtype and add inType to state ([#189](https://github.com/babel/babylon/pull/189)) (Daniel Tschinder)
+
+> This improves the performance slightly (because of hidden classes)
+
+### :house: Internal
+
+Fix .gitattributes line ending setting ([#191](https://github.com/babel/babylon/pull/191)) (Moti Zilberman)
+
+Increase test coverage ([#175](https://github.com/babel/babylon/pull/175) (Moti Zilberman)
+
+Readd missin .eslinignore for IDEs (Daniel Tschinder)
+
+Error on missing expected.json fixture in CI ([#188](https://github.com/babel/babylon/pull/188)) (Moti Zilberman)
+
+Add .gitattributes and .editorconfig for LF line endings ([#179](https://github.com/babel/babylon/pull/179)) (Moti Zilberman)
+
+Fixes two tests that are failing after the merge of #172 ([#177](https://github.com/babel/babylon/pull/177)) (Moti Zilberman)
+
+## v6.12.0 (2016-10-14)
+
+### :eyeglasses: Spec Compliance
+
+Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)
+
+#### Dynamic Import
+
+- Proposal Repo: https://github.com/domenic/proposal-dynamic-import
+- Championed by [@domenic](https://github.com/domenic)
+- stage-2
+- [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import)
+
+> This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript
+
+```js
+import(`./section-modules/${link.dataset.entryModule}.js`)
+.then(module => {
+ module.loadPageInto(main);
+})
+```
+
+Add EmptyTypeAnnotation ([#171](https://github.com/babel/babylon/pull/171)) (Sam Goldman)
+
+#### EmptyTypeAnnotation
+
+Just wasn't covered before.
+
+```js
+type T = empty;
+```
+
+### :bug: Bug Fix
+
+Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
+
+```js
+// was failing due to sparse array
+export const { foo: [ ,, qux7 ] } = bar;
+```
+
+Allow keyword in Flow object declaration property names with type parameters ([#146](https://github.com/babel/babylon/pull/146)) (Dan Harper)
+
+```js
+declare class X {
+ foobar(): void;
+ static foobar(): void;
+}
+```
+
+Allow keyword in object/class property names with Flow type parameters ([#145](https://github.com/babel/babylon/pull/145)) (Dan Harper)
+
+```js
+class Foo {
+ delete(item: T): T {
+ return item;
+ }
+}
+```
+
+Allow typeAnnotations for yield expressions ([#174](https://github.com/babel/babylon/pull/174))) (Daniel Tschinder)
+
+```js
+function *foo() {
+ const x = (yield 5: any);
+}
+```
+
+### :nail_care: Polish
+
+Annotate more errors with expected token ([#172](https://github.com/babel/babylon/pull/172))) (Moti Zilberman)
+
+```js
+// Unexpected token, expected ; (1:6)
+{ set 1 }
+```
+
+### :house: Internal
+
+Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder)
+
+Also run flow, linting, babel tests on separate instances (add back node 0.10)
+
+## v6.11.6 (2016-10-12)
+
+### :bug: Bug Fix/Regression
+
+Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
+
+```js
+// was failing with `Cannot read property 'type' of null` because of null identifiers
+export const { foo: [ ,, qux7 ] } = bar;
+```
+
+## v6.11.5 (2016-10-12)
+
+### :eyeglasses: Spec Compliance
+
+Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo)
+
+```js
+// `foo` has already been exported. Exported identifiers must be unique. (2:20)
+export function foo() {};
+export const { a: [{foo}] } = bar;
+```
+
+Fix: Check for duplicate named exports in exported rest elements/properties ([#164](https://github.com/babel/babylon/pull/164)) (Kai Cataldo)
+
+```js
+// `foo` has already been exported. Exported identifiers must be unique. (2:22)
+export const foo = 1;
+export const [bar, ...foo] = baz;
+```
+
+### :bug: Bug Fix
+
+Fix: Allow identifier `async` for default param in arrow expression ([#165](https://github.com/babel/babylon/pull/165)) (Kai Cataldo)
+
+```js
+// this is ok now
+const test = ({async = true}) => {};
+```
+
+### :nail_care: Polish
+
+Babylon will now print out the token it's expecting if there's a `SyntaxError` ([#150](https://github.com/babel/babylon/pull/150)) (Daniel Tschinder)
+
+```bash
+# So in the case of a missing ending curly (`}`)
+Module build failed: SyntaxError: Unexpected token, expected } (30:0)
+ 28 | }
+ 29 |
+> 30 |
+ | ^
+```
+
+## v6.11.4 (2016-10-03)
+
+Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu)
+
+## v6.11.3 (2016-10-01)
+
+### :eyeglasses: Spec Compliance
+
+Add static errors for object rest (#149) ([@danez](https://github.com/danez))
+
+> https://github.com/sebmarkbage/ecmascript-rest-spread
+
+Object rest copies the *rest* of properties from the right hand side `obj` starting from the left to right.
+
+```js
+let { x, y, ...z } = { x: 1, y: 2, z: 3 };
+// x = 1
+// y = 2
+// z = { z: 3 }
+```
+
+#### New Syntax Errors:
+
+**SyntaxError**: The rest element has to be the last element when destructuring (1:10)
+```bash
+> 1 | let { ...x, y, z } = { x: 1, y: 2, z: 3};
+ | ^
+# Previous behavior:
+# x = { x: 1, y: 2, z: 3 }
+# y = 2
+# z = 3
+```
+
+Before, this was just a more verbose way of shallow copying `obj` since it doesn't actually do what you think.
+
+**SyntaxError**: Cannot have multiple rest elements when destructuring (1:13)
+
+```bash
+> 1 | let { x, ...y, ...z } = { x: 1, y: 2, z: 3};
+ | ^
+# Previous behavior:
+# x = 1
+# y = { y: 2, z: 3 }
+# z = { y: 2, z: 3 }
+```
+
+Before y and z would just be the same value anyway so there is no reason to need to have both.
+
+**SyntaxError**: A trailing comma is not permitted after the rest element (1:16)
+
+```js
+let { x, y, ...z, } = obj;
+```
+
+The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn't make sense.
+
+---
+
+get / set are valid property names in default assignment (#142) ([@jezell](https://github.com/jezell))
+
+```js
+// valid
+function something({ set = null, get = null }) {}
+```
+
+## v6.11.2 (2016-09-23)
+
+### Bug Fix
+
+- [#139](https://github.com/babel/babylon/issues/139) Don't do the duplicate check if not an identifier (#140) @hzoo
+
+```js
+// regression with duplicate export check
+SyntaxError: ./typography.js: `undefined` has already been exported. Exported identifiers must be unique. (22:13)
+ 20 |
+ 21 | export const { rhythm } = typography;
+> 22 | export const { TypographyStyle } = typography
+```
+
+Bail out for now, and make a change to account for destructuring in the next release.
+
+## 6.11.1 (2016-09-22)
+
+### Bug Fix
+- [#137](https://github.com/babel/babylon/pull/137) - Fix a regression with duplicate exports - it was erroring on all keys in `Object.prototype`. @danez
+
+```javascript
+export toString from './toString';
+```
+
+```bash
+`toString` has already been exported. Exported identifiers must be unique. (1:7)
+> 1 | export toString from './toString';
+ | ^
+ 2 |
+```
+
+## 6.11.0 (2016-09-22)
+
+### Spec Compliance (will break CI)
+
+- Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo
+
+```js
+// Only one default export allowed per module. (2:9)
+export default function() {};
+export { foo as default };
+
+// Only one default export allowed per module. (2:0)
+export default {};
+export default function() {};
+
+// `Foo` has already been exported. Exported identifiers must be unique. (2:0)
+export { Foo };
+export class Foo {};
+```
+
+### New Feature (Syntax)
+
+- Add support for computed class property names ([#121](https://github.com/babel/babylon/pull/121)) @motiz88
+
+```js
+// AST
+interface ClassProperty <: Node {
+ type: "ClassProperty";
+ key: Identifier;
+ value: Expression;
+ computed: boolean; // added
+}
+```
+
+```js
+// with "plugins": ["classProperties"]
+class Foo {
+ [x]
+ ['y']
+}
+
+class Bar {
+ [p]
+ [m] () {}
+}
+ ```
+
+### Bug Fix
+
+- Fix `static` property falling through in the declare class Flow AST ([#135](https://github.com/babel/babylon/pull/135)) @danharper
+
+```js
+declare class X {
+ a: number;
+ static b: number; // static
+ c: number; // this was being marked as static in the AST as well
+}
+```
+
+### Polish
+
+- Rephrase "assigning/binding to rvalue" errors to include context ([#119](https://github.com/babel/babylon/pull/119)) @motiz88
+
+```js
+// Used to error with:
+// SyntaxError: Assigning to rvalue (1:0)
+
+// Now:
+// Invalid left-hand side in assignment expression (1:0)
+3 = 4
+
+// Invalid left-hand side in for-in statement (1:5)
+for (+i in {});
+```
+
+### Internal
+
+- Fix call to `this.parseMaybeAssign` with correct arguments ([#133](https://github.com/babel/babylon/pull/133)) @danez
+- Add semver note to changelog ([#131](https://github.com/babel/babylon/pull/131)) @hzoo
+
+## 6.10.0 (2016-09-19)
+
+> We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue.
+
+### Spec Compliance
+
+* Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu)
+
+> It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false. https://tc39.github.io/ecma262/2016/#sec-function-definitions-static-semantics-early-errors
+
+More Context: [tc39-notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-29.md#611-the-scope-of-use-strict-with-respect-to-destructuring-in-parameter-lists)
+
+For example:
+
+```js
+// this errors because it uses destructuring and default parameters
+// in a function with a "use strict" directive
+function a([ option1, option2 ] = []) {
+ "use strict";
+}
+ ```
+
+The solution would be to use a top level "use strict" or to remove the destructuring or default parameters when using a function + "use strict" or to.
+
+### New Feature
+
+* Exact object type annotations for Flow plugin ([#104](https://github.com/babel/babylon/pull/104)) (Basil Hosmer)
+
+Added to flow in https://github.com/facebook/flow/commit/c710c40aa2a115435098d6c0dfeaadb023cd39b8
+
+Looks like:
+
+```js
+var a : {| x: number, y: string |} = { x: 0, y: 'foo' };
+```
+
+### Bug Fixes
+
+* Include `typeParameter` location in `ArrowFunctionExpression` ([#126](https://github.com/babel/babylon/pull/126)) (Daniel Tschinder)
+* Error on invalid flow type annotation with default assignment ([#122](https://github.com/babel/babylon/pull/122)) (Dan Harper)
+* Fix Flow return types on arrow functions ([#124](https://github.com/babel/babylon/pull/124)) (Dan Harper)
+
+### Misc
+
+* Add tests for export extensions ([#127](https://github.com/babel/babylon/pull/127)) (Daniel Tschinder)
+* Fix Contributing guidelines [skip ci] (Daniel Tschinder)
+
+## 6.9.2 (2016-09-09)
+
+The only change is to remove the `babel-runtime` dependency by compiling with Babel's ES2015 loose mode. So using babylon standalone should be smaller.
+
+## 6.9.1 (2016-08-23)
+
+This release contains mainly small bugfixes but also updates babylons default mode to es2017. The features for `exponentiationOperator`, `asyncFunctions` and `trailingFunctionCommas` which previously needed to be activated via plugin are now enabled by default and the plugins are now no-ops.
+
+### Bug Fixes
+
+- Fix issues with default object params in async functions ([#96](https://github.com/babel/babylon/pull/96)) @danez
+- Fix issues with flow-types and async function ([#95](https://github.com/babel/babylon/pull/95)) @danez
+- Fix arrow functions with destructuring, types & default value ([#94](https://github.com/babel/babylon/pull/94)) @danharper
+- Fix declare class with qualified type identifier ([#97](https://github.com/babel/babylon/pull/97)) @danez
+- Remove exponentiationOperator, asyncFunctions, trailingFunctionCommas plugins and enable them by default ([#98](https://github.com/babel/babylon/pull/98)) @danez
+
+## 6.9.0 (2016-08-16)
+
+### New syntax support
+
+- Add JSX spread children ([#42](https://github.com/babel/babylon/pull/42)) @calebmer
+
+(Be aware that React is not going to support this syntax)
+
+```js
+
+ {...todos.map(todo => )}
+
+```
+
+- Add support for declare module.exports ([#72](https://github.com/babel/babylon/pull/72)) @danez
+
+```js
+declare module "foo" {
+ declare module.exports: {}
+}
+```
+
+### New Features
+
+- If supplied, attach filename property to comment node loc. ([#80](https://github.com/babel/babylon/pull/80)) @divmain
+- Add identifier name to node loc field ([#90](https://github.com/babel/babylon/pull/90)) @kittens
+
+### Bug Fixes
+
+- Fix exponential operator to behave according to spec ([#75](https://github.com/babel/babylon/pull/75)) @danez
+- Fix lookahead to not add comments to arrays which are not cloned ([#76](https://github.com/babel/babylon/pull/76)) @danez
+- Fix accidental fall-through in Flow type parsing. ([#82](https://github.com/babel/babylon/pull/82)) @xiemaisi
+- Only allow declares inside declare module ([#73](https://github.com/babel/babylon/pull/73)) @danez
+- Small fix for parsing type parameter declarations ([#83](https://github.com/babel/babylon/pull/83)) @gabelevi
+- Fix arrow param locations with flow types ([#57](https://github.com/babel/babylon/pull/57)) @danez
+- Fixes SyntaxError position with flow optional type ([#65](https://github.com/babel/babylon/pull/65)) @danez
+
+### Internal
+
+- Add codecoverage to tests @danez
+- Fix tests to not save expected output if we expect the test to fail @danez
+- Make a shallow clone of babel for testing @danez
+- chore(package): update cross-env to version 2.0.0 ([#77](https://github.com/babel/babylon/pull/77)) @greenkeeperio-bot
+- chore(package): update ava to version 0.16.0 ([#86](https://github.com/babel/babylon/pull/86)) @greenkeeperio-bot
+- chore(package): update babel-plugin-istanbul to version 2.0.0 ([#89](https://github.com/babel/babylon/pull/89)) @greenkeeperio-bot
+- chore(package): update nyc to version 8.0.0 ([#88](https://github.com/babel/babylon/pull/88)) @greenkeeperio-bot
+
+## 6.8.4 (2016-07-06)
+
+### Bug Fixes
+
+- Fix the location of params, when flow and default value used ([#68](https://github.com/babel/babylon/pull/68)) @danez
+
+## 6.8.3 (2016-07-02)
+
+### Bug Fixes
+
+- Fix performance regression introduced in 6.8.2 with conditionals ([#63](https://github.com/babel/babylon/pull/63)) @danez
+
+## 6.8.2 (2016-06-24)
+
+### Bug Fixes
+
+- Fix parse error with yielding jsx elements in generators `function* it() { yield ; }` ([#31](https://github.com/babel/babylon/pull/31)) @eldereal
+- When cloning nodes do not clone its comments ([#24](https://github.com/babel/babylon/pull/24)) @danez
+- Fix parse errors when using arrow functions with an spread element and return type `(...props): void => {}` ([#10](https://github.com/babel/babylon/pull/10)) @danez
+- Fix leading comments added from previous node ([#23](https://github.com/babel/babylon/pull/23)) @danez
+- Fix parse errors with flow's optional arguments `(arg?) => {}` ([#19](https://github.com/babel/babylon/pull/19)) @danez
+- Support negative numeric type literals @kittens
+- Remove line terminator restriction after await keyword @kittens
+- Remove grouped type arrow restriction as it seems flow no longer has it @kittens
+- Fix parse error with generic methods that have the name `get` or `set` `class foo { get() {} }` ([#55](https://github.com/babel/babylon/pull/55)) @vkurchatkin
+- Fix parse error with arrow functions that have flow type parameter declarations `(x: T): T => x;` ([#54](https://github.com/babel/babylon/pull/54)) @gabelevi
+
+### Documentation
+
+- Document AST differences from ESTree ([#41](https://github.com/babel/babylon/pull/41)) @nene
+- Move ast spec from babel/babel ([#46](https://github.com/babel/babylon/pull/46)) @hzoo
+
+### Internal
+
+- Enable skipped tests ([#16](https://github.com/babel/babylon/pull/16)) @danez
+- Add script to test latest version of babylon with babel ([#21](https://github.com/babel/babylon/pull/21)) @danez
+- Upgrade test runner ava @kittens
+- Add missing generate-identifier-regex script @kittens
+- Rename parser context types @kittens
+- Add node v6 to travis testing @hzoo
+- Update to Unicode v9 ([#45](https://github.com/babel/babylon/pull/45)) @mathiasbynens
+
+## 6.8.1 (2016-06-06)
+
+### New Feature
+
+- Parse type parameter declarations with defaults like `type Foo = T`
+
+### Bug Fixes
+- Type parameter declarations need 1 or more type parameters.
+- The existential type `*` is not a valid type parameter.
+- The existential type `*` is a primary type
+
+### Spec Compliance
+- The param list for type parameter declarations now consists of `TypeParameter` nodes
+- New `TypeParameter` AST Node (replaces using the `Identifier` node before)
+
+```
+interface TypeParameter <: Node {
+ bound: TypeAnnotation;
+ default: TypeAnnotation;
+ name: string;
+ variance: "plus" | "minus";
+}
+```
+
+## 6.8.0 (2016-05-02)
+
+#### New Feature
+
+##### Parse Method Parameter Decorators ([#12](https://github.com/babel/babylon/pull/12))
+
+> [Method Parameter Decorators](https://goo.gl/8MmCMG) is now a TC39 [stage 0 proposal](https://github.com/tc39/ecma262/blob/master/stage0.md).
+
+Examples:
+
+```js
+class Foo {
+ constructor(@foo() x, @bar({ a: 123 }) @baz() y) {}
+}
+
+export default function func(@foo() x, @bar({ a: 123 }) @baz() y) {}
+
+var obj = {
+ method(@foo() x, @bar({ a: 123 }) @baz() y) {}
+};
+```
+
+##### Parse for-await statements (w/ `asyncGenerators` plugin) ([#17](https://github.com/babel/babylon/pull/17))
+
+There is also a new node type, `ForAwaitStatement`.
+
+> [Async generators and for-await](https://github.com/tc39/proposal-async-iteration) are now a [stage 2 proposal](https://github.com/tc39/ecma262#current-proposals).
+
+Example:
+
+```js
+async function f() {
+ for await (let x of y);
+}
+```
diff --git a/api/node_modules/acorn/LICENSE b/api/node_modules/@babel/parser/LICENSE
similarity index 100%
rename from api/node_modules/acorn/LICENSE
rename to api/node_modules/@babel/parser/LICENSE
diff --git a/api/node_modules/@babel/parser/README.md b/api/node_modules/@babel/parser/README.md
new file mode 100644
index 000000000..513748c37
--- /dev/null
+++ b/api/node_modules/@babel/parser/README.md
@@ -0,0 +1,19 @@
+# @babel/parser
+
+> A JavaScript parser
+
+See our website [@babel/parser](https://babeljs.io/docs/en/babel-parser) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20parser%20(babylon)%22+is%3Aopen) associated with this package.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/parser
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/parser --dev
+```
diff --git a/api/node_modules/@babel/parser/bin/babel-parser.js b/api/node_modules/@babel/parser/bin/babel-parser.js
new file mode 100755
index 000000000..3aca31453
--- /dev/null
+++ b/api/node_modules/@babel/parser/bin/babel-parser.js
@@ -0,0 +1,15 @@
+#!/usr/bin/env node
+/* eslint no-var: 0 */
+
+var parser = require("..");
+var fs = require("fs");
+
+var filename = process.argv[2];
+if (!filename) {
+ console.error("no filename specified");
+} else {
+ var file = fs.readFileSync(filename, "utf8");
+ var ast = parser.parse(file);
+
+ console.log(JSON.stringify(ast, null, " "));
+}
diff --git a/api/node_modules/@babel/parser/lib/index.js b/api/node_modules/@babel/parser/lib/index.js
new file mode 100644
index 000000000..1cbab72f9
--- /dev/null
+++ b/api/node_modules/@babel/parser/lib/index.js
@@ -0,0 +1,13917 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', { value: true });
+
+const beforeExpr = true;
+const startsExpr = true;
+const isLoop = true;
+const isAssign = true;
+const prefix = true;
+const postfix = true;
+class TokenType {
+ constructor(label, conf = {}) {
+ this.label = void 0;
+ this.keyword = void 0;
+ this.beforeExpr = void 0;
+ this.startsExpr = void 0;
+ this.rightAssociative = void 0;
+ this.isLoop = void 0;
+ this.isAssign = void 0;
+ this.prefix = void 0;
+ this.postfix = void 0;
+ this.binop = void 0;
+ this.updateContext = void 0;
+ this.label = label;
+ this.keyword = conf.keyword;
+ this.beforeExpr = !!conf.beforeExpr;
+ this.startsExpr = !!conf.startsExpr;
+ this.rightAssociative = !!conf.rightAssociative;
+ this.isLoop = !!conf.isLoop;
+ this.isAssign = !!conf.isAssign;
+ this.prefix = !!conf.prefix;
+ this.postfix = !!conf.postfix;
+ this.binop = conf.binop != null ? conf.binop : null;
+ this.updateContext = null;
+ }
+
+}
+const keywords = new Map();
+
+function createKeyword(name, options = {}) {
+ options.keyword = name;
+ const token = new TokenType(name, options);
+ keywords.set(name, token);
+ return token;
+}
+
+function createBinop(name, binop) {
+ return new TokenType(name, {
+ beforeExpr,
+ binop
+ });
+}
+
+const types = {
+ num: new TokenType("num", {
+ startsExpr
+ }),
+ bigint: new TokenType("bigint", {
+ startsExpr
+ }),
+ decimal: new TokenType("decimal", {
+ startsExpr
+ }),
+ regexp: new TokenType("regexp", {
+ startsExpr
+ }),
+ string: new TokenType("string", {
+ startsExpr
+ }),
+ name: new TokenType("name", {
+ startsExpr
+ }),
+ eof: new TokenType("eof"),
+ bracketL: new TokenType("[", {
+ beforeExpr,
+ startsExpr
+ }),
+ bracketHashL: new TokenType("#[", {
+ beforeExpr,
+ startsExpr
+ }),
+ bracketBarL: new TokenType("[|", {
+ beforeExpr,
+ startsExpr
+ }),
+ bracketR: new TokenType("]"),
+ bracketBarR: new TokenType("|]"),
+ braceL: new TokenType("{", {
+ beforeExpr,
+ startsExpr
+ }),
+ braceBarL: new TokenType("{|", {
+ beforeExpr,
+ startsExpr
+ }),
+ braceHashL: new TokenType("#{", {
+ beforeExpr,
+ startsExpr
+ }),
+ braceR: new TokenType("}"),
+ braceBarR: new TokenType("|}"),
+ parenL: new TokenType("(", {
+ beforeExpr,
+ startsExpr
+ }),
+ parenR: new TokenType(")"),
+ comma: new TokenType(",", {
+ beforeExpr
+ }),
+ semi: new TokenType(";", {
+ beforeExpr
+ }),
+ colon: new TokenType(":", {
+ beforeExpr
+ }),
+ doubleColon: new TokenType("::", {
+ beforeExpr
+ }),
+ dot: new TokenType("."),
+ question: new TokenType("?", {
+ beforeExpr
+ }),
+ questionDot: new TokenType("?."),
+ arrow: new TokenType("=>", {
+ beforeExpr
+ }),
+ template: new TokenType("template"),
+ ellipsis: new TokenType("...", {
+ beforeExpr
+ }),
+ backQuote: new TokenType("`", {
+ startsExpr
+ }),
+ dollarBraceL: new TokenType("${", {
+ beforeExpr,
+ startsExpr
+ }),
+ at: new TokenType("@"),
+ hash: new TokenType("#", {
+ startsExpr
+ }),
+ interpreterDirective: new TokenType("#!..."),
+ eq: new TokenType("=", {
+ beforeExpr,
+ isAssign
+ }),
+ assign: new TokenType("_=", {
+ beforeExpr,
+ isAssign
+ }),
+ incDec: new TokenType("++/--", {
+ prefix,
+ postfix,
+ startsExpr
+ }),
+ bang: new TokenType("!", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ }),
+ tilde: new TokenType("~", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ }),
+ pipeline: createBinop("|>", 0),
+ nullishCoalescing: createBinop("??", 1),
+ logicalOR: createBinop("||", 1),
+ logicalAND: createBinop("&&", 2),
+ bitwiseOR: createBinop("|", 3),
+ bitwiseXOR: createBinop("^", 4),
+ bitwiseAND: createBinop("&", 5),
+ equality: createBinop("==/!=/===/!==", 6),
+ relational: createBinop(">/<=/>=", 7),
+ bitShift: createBinop("<>>/>>>", 8),
+ plusMin: new TokenType("+/-", {
+ beforeExpr,
+ binop: 9,
+ prefix,
+ startsExpr
+ }),
+ modulo: new TokenType("%", {
+ beforeExpr,
+ binop: 10,
+ startsExpr
+ }),
+ star: new TokenType("*", {
+ binop: 10
+ }),
+ slash: createBinop("/", 10),
+ exponent: new TokenType("**", {
+ beforeExpr,
+ binop: 11,
+ rightAssociative: true
+ }),
+ _break: createKeyword("break"),
+ _case: createKeyword("case", {
+ beforeExpr
+ }),
+ _catch: createKeyword("catch"),
+ _continue: createKeyword("continue"),
+ _debugger: createKeyword("debugger"),
+ _default: createKeyword("default", {
+ beforeExpr
+ }),
+ _do: createKeyword("do", {
+ isLoop,
+ beforeExpr
+ }),
+ _else: createKeyword("else", {
+ beforeExpr
+ }),
+ _finally: createKeyword("finally"),
+ _for: createKeyword("for", {
+ isLoop
+ }),
+ _function: createKeyword("function", {
+ startsExpr
+ }),
+ _if: createKeyword("if"),
+ _return: createKeyword("return", {
+ beforeExpr
+ }),
+ _switch: createKeyword("switch"),
+ _throw: createKeyword("throw", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ }),
+ _try: createKeyword("try"),
+ _var: createKeyword("var"),
+ _const: createKeyword("const"),
+ _while: createKeyword("while", {
+ isLoop
+ }),
+ _with: createKeyword("with"),
+ _new: createKeyword("new", {
+ beforeExpr,
+ startsExpr
+ }),
+ _this: createKeyword("this", {
+ startsExpr
+ }),
+ _super: createKeyword("super", {
+ startsExpr
+ }),
+ _class: createKeyword("class", {
+ startsExpr
+ }),
+ _extends: createKeyword("extends", {
+ beforeExpr
+ }),
+ _export: createKeyword("export"),
+ _import: createKeyword("import", {
+ startsExpr
+ }),
+ _null: createKeyword("null", {
+ startsExpr
+ }),
+ _true: createKeyword("true", {
+ startsExpr
+ }),
+ _false: createKeyword("false", {
+ startsExpr
+ }),
+ _in: createKeyword("in", {
+ beforeExpr,
+ binop: 7
+ }),
+ _instanceof: createKeyword("instanceof", {
+ beforeExpr,
+ binop: 7
+ }),
+ _typeof: createKeyword("typeof", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ }),
+ _void: createKeyword("void", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ }),
+ _delete: createKeyword("delete", {
+ beforeExpr,
+ prefix,
+ startsExpr
+ })
+};
+
+const lineBreak = /\r\n?|[\n\u2028\u2029]/;
+const lineBreakG = new RegExp(lineBreak.source, "g");
+function isNewLine(code) {
+ switch (code) {
+ case 10:
+ case 13:
+ case 8232:
+ case 8233:
+ return true;
+
+ default:
+ return false;
+ }
+}
+const skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
+function isWhitespace(code) {
+ switch (code) {
+ case 0x0009:
+ case 0x000b:
+ case 0x000c:
+ case 32:
+ case 160:
+ case 5760:
+ case 0x2000:
+ case 0x2001:
+ case 0x2002:
+ case 0x2003:
+ case 0x2004:
+ case 0x2005:
+ case 0x2006:
+ case 0x2007:
+ case 0x2008:
+ case 0x2009:
+ case 0x200a:
+ case 0x202f:
+ case 0x205f:
+ case 0x3000:
+ case 0xfeff:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
+class Position {
+ constructor(line, col) {
+ this.line = void 0;
+ this.column = void 0;
+ this.line = line;
+ this.column = col;
+ }
+
+}
+class SourceLocation {
+ constructor(start, end) {
+ this.start = void 0;
+ this.end = void 0;
+ this.filename = void 0;
+ this.identifierName = void 0;
+ this.start = start;
+ this.end = end;
+ }
+
+}
+function getLineInfo(input, offset) {
+ let line = 1;
+ let lineStart = 0;
+ let match;
+ lineBreakG.lastIndex = 0;
+
+ while ((match = lineBreakG.exec(input)) && match.index < offset) {
+ line++;
+ lineStart = lineBreakG.lastIndex;
+ }
+
+ return new Position(line, offset - lineStart);
+}
+
+class BaseParser {
+ constructor() {
+ this.sawUnambiguousESM = false;
+ this.ambiguousScriptDifferentAst = false;
+ }
+
+ hasPlugin(name) {
+ return this.plugins.has(name);
+ }
+
+ getPluginOption(plugin, name) {
+ if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];
+ }
+
+}
+
+function last(stack) {
+ return stack[stack.length - 1];
+}
+
+class CommentsParser extends BaseParser {
+ addComment(comment) {
+ if (this.filename) comment.loc.filename = this.filename;
+ this.state.trailingComments.push(comment);
+ this.state.leadingComments.push(comment);
+ }
+
+ adjustCommentsAfterTrailingComma(node, elements, takeAllComments) {
+ if (this.state.leadingComments.length === 0) {
+ return;
+ }
+
+ let lastElement = null;
+ let i = elements.length;
+
+ while (lastElement === null && i > 0) {
+ lastElement = elements[--i];
+ }
+
+ if (lastElement === null) {
+ return;
+ }
+
+ for (let j = 0; j < this.state.leadingComments.length; j++) {
+ if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
+ this.state.leadingComments.splice(j, 1);
+ j--;
+ }
+ }
+
+ const newTrailingComments = [];
+
+ for (let i = 0; i < this.state.leadingComments.length; i++) {
+ const leadingComment = this.state.leadingComments[i];
+
+ if (leadingComment.end < node.end) {
+ newTrailingComments.push(leadingComment);
+
+ if (!takeAllComments) {
+ this.state.leadingComments.splice(i, 1);
+ i--;
+ }
+ } else {
+ if (node.trailingComments === undefined) {
+ node.trailingComments = [];
+ }
+
+ node.trailingComments.push(leadingComment);
+ }
+ }
+
+ if (takeAllComments) this.state.leadingComments = [];
+
+ if (newTrailingComments.length > 0) {
+ lastElement.trailingComments = newTrailingComments;
+ } else if (lastElement.trailingComments !== undefined) {
+ lastElement.trailingComments = [];
+ }
+ }
+
+ processComment(node) {
+ if (node.type === "Program" && node.body.length > 0) return;
+ const stack = this.state.commentStack;
+ let firstChild, lastChild, trailingComments, i, j;
+
+ if (this.state.trailingComments.length > 0) {
+ if (this.state.trailingComments[0].start >= node.end) {
+ trailingComments = this.state.trailingComments;
+ this.state.trailingComments = [];
+ } else {
+ this.state.trailingComments.length = 0;
+ }
+ } else if (stack.length > 0) {
+ const lastInStack = last(stack);
+
+ if (lastInStack.trailingComments && lastInStack.trailingComments[0].start >= node.end) {
+ trailingComments = lastInStack.trailingComments;
+ delete lastInStack.trailingComments;
+ }
+ }
+
+ if (stack.length > 0 && last(stack).start >= node.start) {
+ firstChild = stack.pop();
+ }
+
+ while (stack.length > 0 && last(stack).start >= node.start) {
+ lastChild = stack.pop();
+ }
+
+ if (!lastChild && firstChild) lastChild = firstChild;
+
+ if (firstChild) {
+ switch (node.type) {
+ case "ObjectExpression":
+ this.adjustCommentsAfterTrailingComma(node, node.properties);
+ break;
+
+ case "ObjectPattern":
+ this.adjustCommentsAfterTrailingComma(node, node.properties, true);
+ break;
+
+ case "CallExpression":
+ this.adjustCommentsAfterTrailingComma(node, node.arguments);
+ break;
+
+ case "ArrayExpression":
+ this.adjustCommentsAfterTrailingComma(node, node.elements);
+ break;
+
+ case "ArrayPattern":
+ this.adjustCommentsAfterTrailingComma(node, node.elements, true);
+ break;
+ }
+ } else if (this.state.commentPreviousNode && (this.state.commentPreviousNode.type === "ImportSpecifier" && node.type !== "ImportSpecifier" || this.state.commentPreviousNode.type === "ExportSpecifier" && node.type !== "ExportSpecifier")) {
+ this.adjustCommentsAfterTrailingComma(node, [this.state.commentPreviousNode]);
+ }
+
+ if (lastChild) {
+ if (lastChild.leadingComments) {
+ if (lastChild !== node && lastChild.leadingComments.length > 0 && last(lastChild.leadingComments).end <= node.start) {
+ node.leadingComments = lastChild.leadingComments;
+ delete lastChild.leadingComments;
+ } else {
+ for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {
+ if (lastChild.leadingComments[i].end <= node.start) {
+ node.leadingComments = lastChild.leadingComments.splice(0, i + 1);
+ break;
+ }
+ }
+ }
+ }
+ } else if (this.state.leadingComments.length > 0) {
+ if (last(this.state.leadingComments).end <= node.start) {
+ if (this.state.commentPreviousNode) {
+ for (j = 0; j < this.state.leadingComments.length; j++) {
+ if (this.state.leadingComments[j].end < this.state.commentPreviousNode.end) {
+ this.state.leadingComments.splice(j, 1);
+ j--;
+ }
+ }
+ }
+
+ if (this.state.leadingComments.length > 0) {
+ node.leadingComments = this.state.leadingComments;
+ this.state.leadingComments = [];
+ }
+ } else {
+ for (i = 0; i < this.state.leadingComments.length; i++) {
+ if (this.state.leadingComments[i].end > node.start) {
+ break;
+ }
+ }
+
+ const leadingComments = this.state.leadingComments.slice(0, i);
+
+ if (leadingComments.length) {
+ node.leadingComments = leadingComments;
+ }
+
+ trailingComments = this.state.leadingComments.slice(i);
+
+ if (trailingComments.length === 0) {
+ trailingComments = null;
+ }
+ }
+ }
+
+ this.state.commentPreviousNode = node;
+
+ if (trailingComments) {
+ if (trailingComments.length && trailingComments[0].start >= node.start && last(trailingComments).end <= node.end) {
+ node.innerComments = trailingComments;
+ } else {
+ const firstTrailingCommentIndex = trailingComments.findIndex(comment => comment.end >= node.end);
+
+ if (firstTrailingCommentIndex > 0) {
+ node.innerComments = trailingComments.slice(0, firstTrailingCommentIndex);
+ node.trailingComments = trailingComments.slice(firstTrailingCommentIndex);
+ } else {
+ node.trailingComments = trailingComments;
+ }
+ }
+ }
+
+ stack.push(node);
+ }
+
+}
+
+const ErrorMessages = Object.freeze({
+ AccessorIsGenerator: "A %0ter cannot be a generator",
+ ArgumentsInClass: "'arguments' is only allowed in functions and class methods",
+ AsyncFunctionInSingleStatementContext: "Async functions can only be declared at the top level or inside a block",
+ AwaitBindingIdentifier: "Can not use 'await' as identifier inside an async function",
+ AwaitBindingIdentifierInStaticBlock: "Can not use 'await' as identifier inside a static block",
+ AwaitExpressionFormalParameter: "await is not allowed in async function parameters",
+ AwaitNotInAsyncContext: "'await' is only allowed within async functions and at the top levels of modules",
+ AwaitNotInAsyncFunction: "'await' is only allowed within async functions",
+ BadGetterArity: "getter must not have any formal parameters",
+ BadSetterArity: "setter must have exactly one formal parameter",
+ BadSetterRestParameter: "setter function argument must not be a rest parameter",
+ ConstructorClassField: "Classes may not have a field named 'constructor'",
+ ConstructorClassPrivateField: "Classes may not have a private field named '#constructor'",
+ ConstructorIsAccessor: "Class constructor may not be an accessor",
+ ConstructorIsAsync: "Constructor can't be an async function",
+ ConstructorIsGenerator: "Constructor can't be a generator",
+ DeclarationMissingInitializer: "%0 require an initialization value",
+ DecoratorBeforeExport: "Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax",
+ DecoratorConstructor: "Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?",
+ DecoratorExportClass: "Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.",
+ DecoratorSemicolon: "Decorators must not be followed by a semicolon",
+ DecoratorStaticBlock: "Decorators can't be used with a static block",
+ DeletePrivateField: "Deleting a private field is not allowed",
+ DestructureNamedImport: "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
+ DuplicateConstructor: "Duplicate constructor in the same class",
+ DuplicateDefaultExport: "Only one default export allowed per module.",
+ DuplicateExport: "`%0` has already been exported. Exported identifiers must be unique.",
+ DuplicateProto: "Redefinition of __proto__ property",
+ DuplicateRegExpFlags: "Duplicate regular expression flag",
+ DuplicateStaticBlock: "Duplicate static block in the same class",
+ ElementAfterRest: "Rest element must be last element",
+ EscapedCharNotAnIdentifier: "Invalid Unicode escape",
+ ExportBindingIsString: "A string literal cannot be used as an exported binding without `from`.\n- Did you mean `export { '%0' as '%1' } from 'some-module'`?",
+ ExportDefaultFromAsIdentifier: "'from' is not allowed as an identifier after 'export default'",
+ ForInOfLoopInitializer: "%0 loop variable declaration may not have an initializer",
+ GeneratorInSingleStatementContext: "Generators can only be declared at the top level or inside a block",
+ IllegalBreakContinue: "Unsyntactic %0",
+ IllegalLanguageModeDirective: "Illegal 'use strict' directive in function with non-simple parameter list",
+ IllegalReturn: "'return' outside of function",
+ ImportBindingIsString: 'A string literal cannot be used as an imported binding.\n- Did you mean `import { "%0" as foo }`?',
+ ImportCallArgumentTrailingComma: "Trailing comma is disallowed inside import(...) arguments",
+ ImportCallArity: "import() requires exactly %0",
+ ImportCallNotNewExpression: "Cannot use new with import(...)",
+ ImportCallSpreadArgument: "... is not allowed in import()",
+ ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: "module"'`,
+ ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: "module"'`,
+ InvalidBigIntLiteral: "Invalid BigIntLiteral",
+ InvalidCodePoint: "Code point out of bounds",
+ InvalidDecimal: "Invalid decimal",
+ InvalidDigit: "Expected number in radix %0",
+ InvalidEscapeSequence: "Bad character escape sequence",
+ InvalidEscapeSequenceTemplate: "Invalid escape sequence in template",
+ InvalidEscapedReservedWord: "Escape sequence in keyword %0",
+ InvalidIdentifier: "Invalid identifier %0",
+ InvalidLhs: "Invalid left-hand side in %0",
+ InvalidLhsBinding: "Binding invalid left-hand side in %0",
+ InvalidNumber: "Invalid number",
+ InvalidOrMissingExponent: "Floating-point numbers require a valid exponent after the 'e'",
+ InvalidOrUnexpectedToken: "Unexpected character '%0'",
+ InvalidParenthesizedAssignment: "Invalid parenthesized assignment pattern",
+ InvalidPrivateFieldResolution: "Private name #%0 is not defined",
+ InvalidPropertyBindingPattern: "Binding member expression",
+ InvalidRecordProperty: "Only properties and spread elements are allowed in record definitions",
+ InvalidRestAssignmentPattern: "Invalid rest operator's argument",
+ LabelRedeclaration: "Label '%0' is already declared",
+ LetInLexicalBinding: "'let' is not allowed to be used as a name in 'let' or 'const' declarations.",
+ LineTerminatorBeforeArrow: "No line break is allowed before '=>'",
+ MalformedRegExpFlags: "Invalid regular expression flag",
+ MissingClassName: "A class name is required",
+ MissingEqInAssignment: "Only '=' operator can be used for specifying default value.",
+ MissingSemicolon: "Missing semicolon",
+ MissingUnicodeEscape: "Expecting Unicode escape sequence \\uXXXX",
+ MixingCoalesceWithLogical: "Nullish coalescing operator(??) requires parens when mixing with logical operators",
+ ModuleAttributeDifferentFromType: "The only accepted module attribute is `type`",
+ ModuleAttributeInvalidValue: "Only string literals are allowed as module attribute values",
+ ModuleAttributesWithDuplicateKeys: 'Duplicate key "%0" is not allowed in module attributes',
+ ModuleExportNameHasLoneSurrogate: "An export name cannot include a lone surrogate, found '\\u%0'",
+ ModuleExportUndefined: "Export '%0' is not defined",
+ MultipleDefaultsInSwitch: "Multiple default clauses",
+ NewlineAfterThrow: "Illegal newline after throw",
+ NoCatchOrFinally: "Missing catch or finally clause",
+ NumberIdentifier: "Identifier directly after number",
+ NumericSeparatorInEscapeSequence: "Numeric separators are not allowed inside unicode escape sequences or hex escape sequences",
+ ObsoleteAwaitStar: "await* has been removed from the async functions proposal. Use Promise.all() instead.",
+ OptionalChainingNoNew: "constructors in/after an Optional Chain are not allowed",
+ OptionalChainingNoTemplate: "Tagged Template Literals are not allowed in optionalChain",
+ ParamDupe: "Argument name clash",
+ PatternHasAccessor: "Object pattern can't contain getter or setter",
+ PatternHasMethod: "Object pattern can't contain methods",
+ PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized',
+ PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression",
+ PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression",
+ PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference",
+ PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding",
+ PrimaryTopicRequiresSmartPipeline: "Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.",
+ PrivateInExpectedIn: "Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`)",
+ PrivateNameRedeclaration: "Duplicate private name #%0",
+ RecordExpressionBarIncorrectEndSyntaxType: "Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
+ RecordExpressionBarIncorrectStartSyntaxType: "Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
+ RecordExpressionHashIncorrectStartSyntaxType: "Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'",
+ RecordNoProto: "'__proto__' is not allowed in Record expressions",
+ RestTrailingComma: "Unexpected trailing comma after rest element",
+ SloppyFunction: "In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement",
+ StaticPrototype: "Classes may not have static property named prototype",
+ StrictDelete: "Deleting local variable in strict mode",
+ StrictEvalArguments: "Assigning to '%0' in strict mode",
+ StrictEvalArgumentsBinding: "Binding '%0' in strict mode",
+ StrictFunction: "In strict mode code, functions can only be declared at top level or inside a block",
+ StrictNumericEscape: "The only valid numeric escape in strict mode is '\\0'",
+ StrictOctalLiteral: "Legacy octal literals are not allowed in strict mode",
+ StrictWith: "'with' in strict mode",
+ SuperNotAllowed: "super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?",
+ SuperPrivateField: "Private fields can't be accessed on super",
+ TrailingDecorator: "Decorators must be attached to a class element",
+ TupleExpressionBarIncorrectEndSyntaxType: "Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
+ TupleExpressionBarIncorrectStartSyntaxType: "Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'",
+ TupleExpressionHashIncorrectStartSyntaxType: "Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'",
+ UnexpectedArgumentPlaceholder: "Unexpected argument placeholder",
+ UnexpectedAwaitAfterPipelineBody: 'Unexpected "await" after pipeline body; await must have parentheses in minimal proposal',
+ UnexpectedDigitAfterHash: "Unexpected digit after hash token",
+ UnexpectedImportExport: "'import' and 'export' may only appear at the top level",
+ UnexpectedKeyword: "Unexpected keyword '%0'",
+ UnexpectedLeadingDecorator: "Leading decorators must be attached to a class declaration",
+ UnexpectedLexicalDeclaration: "Lexical declaration cannot appear in a single-statement context",
+ UnexpectedNewTarget: "new.target can only be used in functions",
+ UnexpectedNumericSeparator: "A numeric separator is only allowed between two digits",
+ UnexpectedPrivateField: "Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\n or a property of member expression (i.e. this.#p).",
+ UnexpectedReservedWord: "Unexpected reserved word '%0'",
+ UnexpectedSuper: "super is only allowed in object methods and classes",
+ UnexpectedToken: "Unexpected token '%0'",
+ UnexpectedTokenUnaryExponentiation: "Illegal expression. Wrap left hand side or entire exponentiation in parentheses.",
+ UnsupportedBind: "Binding should be performed on object property.",
+ UnsupportedDecoratorExport: "A decorated export must export a class declaration",
+ UnsupportedDefaultExport: "Only expressions, functions or classes are allowed as the `default` export.",
+ UnsupportedImport: "import can only be used in import() or import.meta",
+ UnsupportedMetaProperty: "The only valid meta property for %0 is %0.%1",
+ UnsupportedParameterDecorator: "Decorators cannot be used to decorate parameters",
+ UnsupportedPropertyDecorator: "Decorators cannot be used to decorate object literal properties",
+ UnsupportedSuper: "super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])",
+ UnterminatedComment: "Unterminated comment",
+ UnterminatedRegExp: "Unterminated regular expression",
+ UnterminatedString: "Unterminated string constant",
+ UnterminatedTemplate: "Unterminated template",
+ VarRedeclaration: "Identifier '%0' has already been declared",
+ YieldBindingIdentifier: "Can not use 'yield' as identifier inside a generator",
+ YieldInParameter: "Yield expression is not allowed in formal parameters",
+ ZeroDigitNumericSeparator: "Numeric separator can not be used after leading 0"
+});
+
+class ParserError extends CommentsParser {
+ getLocationForPosition(pos) {
+ let loc;
+ if (pos === this.state.start) loc = this.state.startLoc;else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;else if (pos === this.state.end) loc = this.state.endLoc;else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;else loc = getLineInfo(this.input, pos);
+ return loc;
+ }
+
+ raise(pos, errorTemplate, ...params) {
+ return this.raiseWithData(pos, undefined, errorTemplate, ...params);
+ }
+
+ raiseOverwrite(pos, errorTemplate, ...params) {
+ const loc = this.getLocationForPosition(pos);
+ const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`;
+
+ if (this.options.errorRecovery) {
+ const errors = this.state.errors;
+
+ for (let i = errors.length - 1; i >= 0; i--) {
+ const error = errors[i];
+
+ if (error.pos === pos) {
+ return Object.assign(error, {
+ message
+ });
+ } else if (error.pos < pos) {
+ break;
+ }
+ }
+ }
+
+ return this._raise({
+ loc,
+ pos
+ }, message);
+ }
+
+ raiseWithData(pos, data, errorTemplate, ...params) {
+ const loc = this.getLocationForPosition(pos);
+ const message = errorTemplate.replace(/%(\d+)/g, (_, i) => params[i]) + ` (${loc.line}:${loc.column})`;
+ return this._raise(Object.assign({
+ loc,
+ pos
+ }, data), message);
+ }
+
+ _raise(errorContext, message) {
+ const err = new SyntaxError(message);
+ Object.assign(err, errorContext);
+
+ if (this.options.errorRecovery) {
+ if (!this.isLookahead) this.state.errors.push(err);
+ return err;
+ } else {
+ throw err;
+ }
+ }
+
+}
+
+var estree = (superClass => class extends superClass {
+ estreeParseRegExpLiteral({
+ pattern,
+ flags
+ }) {
+ let regex = null;
+
+ try {
+ regex = new RegExp(pattern, flags);
+ } catch (e) {}
+
+ const node = this.estreeParseLiteral(regex);
+ node.regex = {
+ pattern,
+ flags
+ };
+ return node;
+ }
+
+ estreeParseBigIntLiteral(value) {
+ let bigInt;
+
+ try {
+ bigInt = BigInt(value);
+ } catch (_unused) {
+ bigInt = null;
+ }
+
+ const node = this.estreeParseLiteral(bigInt);
+ node.bigint = String(node.value || value);
+ return node;
+ }
+
+ estreeParseDecimalLiteral(value) {
+ const decimal = null;
+ const node = this.estreeParseLiteral(decimal);
+ node.decimal = String(node.value || value);
+ return node;
+ }
+
+ estreeParseLiteral(value) {
+ return this.parseLiteral(value, "Literal");
+ }
+
+ directiveToStmt(directive) {
+ const directiveLiteral = directive.value;
+ const stmt = this.startNodeAt(directive.start, directive.loc.start);
+ const expression = this.startNodeAt(directiveLiteral.start, directiveLiteral.loc.start);
+ expression.value = directiveLiteral.extra.expressionValue;
+ expression.raw = directiveLiteral.extra.raw;
+ stmt.expression = this.finishNodeAt(expression, "Literal", directiveLiteral.end, directiveLiteral.loc.end);
+ stmt.directive = directiveLiteral.extra.raw.slice(1, -1);
+ return this.finishNodeAt(stmt, "ExpressionStatement", directive.end, directive.loc.end);
+ }
+
+ initFunction(node, isAsync) {
+ super.initFunction(node, isAsync);
+ node.expression = false;
+ }
+
+ checkDeclaration(node) {
+ if (node != null && this.isObjectProperty(node)) {
+ this.checkDeclaration(node.value);
+ } else {
+ super.checkDeclaration(node);
+ }
+ }
+
+ getObjectOrClassMethodParams(method) {
+ return method.value.params;
+ }
+
+ isValidDirective(stmt) {
+ var _stmt$expression$extr;
+
+ return stmt.type === "ExpressionStatement" && stmt.expression.type === "Literal" && typeof stmt.expression.value === "string" && !((_stmt$expression$extr = stmt.expression.extra) != null && _stmt$expression$extr.parenthesized);
+ }
+
+ stmtToDirective(stmt) {
+ const directive = super.stmtToDirective(stmt);
+ const value = stmt.expression.value;
+ this.addExtra(directive.value, "expressionValue", value);
+ return directive;
+ }
+
+ parseBlockBody(node, ...args) {
+ super.parseBlockBody(node, ...args);
+ const directiveStatements = node.directives.map(d => this.directiveToStmt(d));
+ node.body = directiveStatements.concat(node.body);
+ delete node.directives;
+ }
+
+ pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
+ this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true);
+
+ if (method.typeParameters) {
+ method.value.typeParameters = method.typeParameters;
+ delete method.typeParameters;
+ }
+
+ classBody.body.push(method);
+ }
+
+ parseExprAtom(refExpressionErrors) {
+ switch (this.state.type) {
+ case types.num:
+ case types.string:
+ return this.estreeParseLiteral(this.state.value);
+
+ case types.regexp:
+ return this.estreeParseRegExpLiteral(this.state.value);
+
+ case types.bigint:
+ return this.estreeParseBigIntLiteral(this.state.value);
+
+ case types.decimal:
+ return this.estreeParseDecimalLiteral(this.state.value);
+
+ case types._null:
+ return this.estreeParseLiteral(null);
+
+ case types._true:
+ return this.estreeParseLiteral(true);
+
+ case types._false:
+ return this.estreeParseLiteral(false);
+
+ default:
+ return super.parseExprAtom(refExpressionErrors);
+ }
+ }
+
+ parseMaybePrivateName(...args) {
+ const node = super.parseMaybePrivateName(...args);
+
+ if (node.type === "PrivateName" && this.getPluginOption("estree", "classFeatures")) {
+ return this.convertPrivateNameToPrivateIdentifier(node);
+ }
+
+ return node;
+ }
+
+ convertPrivateNameToPrivateIdentifier(node) {
+ const name = super.getPrivateNameSV(node);
+ node = node;
+ delete node.id;
+ node.name = name;
+ node.type = "PrivateIdentifier";
+ return node;
+ }
+
+ isPrivateName(node) {
+ if (!this.getPluginOption("estree", "classFeatures")) {
+ return super.isPrivateName(node);
+ }
+
+ return node.type === "PrivateIdentifier";
+ }
+
+ getPrivateNameSV(node) {
+ if (!this.getPluginOption("estree", "classFeatures")) {
+ return super.getPrivateNameSV(node);
+ }
+
+ return node.name;
+ }
+
+ parseLiteral(value, type, startPos, startLoc) {
+ const node = super.parseLiteral(value, type, startPos, startLoc);
+ node.raw = node.extra.raw;
+ delete node.extra;
+ return node;
+ }
+
+ parseFunctionBody(node, allowExpression, isMethod = false) {
+ super.parseFunctionBody(node, allowExpression, isMethod);
+ node.expression = node.body.type !== "BlockStatement";
+ }
+
+ parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
+ let funcNode = this.startNode();
+ funcNode.kind = node.kind;
+ funcNode = super.parseMethod(funcNode, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope);
+ funcNode.type = "FunctionExpression";
+ delete funcNode.kind;
+ node.value = funcNode;
+
+ if (type === "ClassPrivateMethod") {
+ node.computed = false;
+ }
+
+ type = "MethodDefinition";
+ return this.finishNode(node, type);
+ }
+
+ parseClassProperty(...args) {
+ const propertyNode = super.parseClassProperty(...args);
+
+ if (this.getPluginOption("estree", "classFeatures")) {
+ propertyNode.type = "PropertyDefinition";
+ }
+
+ return propertyNode;
+ }
+
+ parseClassPrivateProperty(...args) {
+ const propertyNode = super.parseClassPrivateProperty(...args);
+
+ if (this.getPluginOption("estree", "classFeatures")) {
+ propertyNode.type = "PropertyDefinition";
+ propertyNode.computed = false;
+ }
+
+ return propertyNode;
+ }
+
+ parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
+ const node = super.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor);
+
+ if (node) {
+ node.type = "Property";
+ if (node.kind === "method") node.kind = "init";
+ node.shorthand = false;
+ }
+
+ return node;
+ }
+
+ parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) {
+ const node = super.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors);
+
+ if (node) {
+ node.kind = "init";
+ node.type = "Property";
+ }
+
+ return node;
+ }
+
+ toAssignable(node, isLHS = false) {
+ if (node != null && this.isObjectProperty(node)) {
+ this.toAssignable(node.value, isLHS);
+ return node;
+ }
+
+ return super.toAssignable(node, isLHS);
+ }
+
+ toAssignableObjectExpressionProp(prop, ...args) {
+ if (prop.kind === "get" || prop.kind === "set") {
+ this.raise(prop.key.start, ErrorMessages.PatternHasAccessor);
+ } else if (prop.method) {
+ this.raise(prop.key.start, ErrorMessages.PatternHasMethod);
+ } else {
+ super.toAssignableObjectExpressionProp(prop, ...args);
+ }
+ }
+
+ finishCallExpression(node, optional) {
+ super.finishCallExpression(node, optional);
+
+ if (node.callee.type === "Import") {
+ node.type = "ImportExpression";
+ node.source = node.arguments[0];
+ delete node.arguments;
+ delete node.callee;
+ }
+
+ return node;
+ }
+
+ toReferencedArguments(node) {
+ if (node.type === "ImportExpression") {
+ return;
+ }
+
+ super.toReferencedArguments(node);
+ }
+
+ parseExport(node) {
+ super.parseExport(node);
+
+ switch (node.type) {
+ case "ExportAllDeclaration":
+ node.exported = null;
+ break;
+
+ case "ExportNamedDeclaration":
+ if (node.specifiers.length === 1 && node.specifiers[0].type === "ExportNamespaceSpecifier") {
+ node.type = "ExportAllDeclaration";
+ node.exported = node.specifiers[0].exported;
+ delete node.specifiers;
+ }
+
+ break;
+ }
+
+ return node;
+ }
+
+ parseSubscript(base, startPos, startLoc, noCalls, state) {
+ const node = super.parseSubscript(base, startPos, startLoc, noCalls, state);
+
+ if (state.optionalChainMember) {
+ if (node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression") {
+ node.type = node.type.substring(8);
+ }
+
+ if (state.stop) {
+ const chain = this.startNodeAtNode(node);
+ chain.expression = node;
+ return this.finishNode(chain, "ChainExpression");
+ }
+ } else if (node.type === "MemberExpression" || node.type === "CallExpression") {
+ node.optional = false;
+ }
+
+ return node;
+ }
+
+ hasPropertyAsPrivateName(node) {
+ if (node.type === "ChainExpression") {
+ node = node.expression;
+ }
+
+ return super.hasPropertyAsPrivateName(node);
+ }
+
+ isOptionalChain(node) {
+ return node.type === "ChainExpression";
+ }
+
+ isObjectProperty(node) {
+ return node.type === "Property" && node.kind === "init" && !node.method;
+ }
+
+ isObjectMethod(node) {
+ return node.method || node.kind === "get" || node.kind === "set";
+ }
+
+});
+
+class TokContext {
+ constructor(token, isExpr, preserveSpace, override) {
+ this.token = void 0;
+ this.isExpr = void 0;
+ this.preserveSpace = void 0;
+ this.override = void 0;
+ this.token = token;
+ this.isExpr = !!isExpr;
+ this.preserveSpace = !!preserveSpace;
+ this.override = override;
+ }
+
+}
+const types$1 = {
+ braceStatement: new TokContext("{", false),
+ braceExpression: new TokContext("{", true),
+ recordExpression: new TokContext("#{", true),
+ templateQuasi: new TokContext("${", false),
+ parenStatement: new TokContext("(", false),
+ parenExpression: new TokContext("(", true),
+ template: new TokContext("`", true, true, p => p.readTmplToken()),
+ functionExpression: new TokContext("function", true),
+ functionStatement: new TokContext("function", false)
+};
+
+types.parenR.updateContext = types.braceR.updateContext = function () {
+ if (this.state.context.length === 1) {
+ this.state.exprAllowed = true;
+ return;
+ }
+
+ let out = this.state.context.pop();
+
+ if (out === types$1.braceStatement && this.curContext().token === "function") {
+ out = this.state.context.pop();
+ }
+
+ this.state.exprAllowed = !out.isExpr;
+};
+
+types.name.updateContext = function (prevType) {
+ let allowed = false;
+
+ if (prevType !== types.dot) {
+ if (this.state.value === "of" && !this.state.exprAllowed && prevType !== types._function && prevType !== types._class) {
+ allowed = true;
+ }
+ }
+
+ this.state.exprAllowed = allowed;
+
+ if (this.state.isIterator) {
+ this.state.isIterator = false;
+ }
+};
+
+types.braceL.updateContext = function (prevType) {
+ this.state.context.push(this.braceIsBlock(prevType) ? types$1.braceStatement : types$1.braceExpression);
+ this.state.exprAllowed = true;
+};
+
+types.dollarBraceL.updateContext = function () {
+ this.state.context.push(types$1.templateQuasi);
+ this.state.exprAllowed = true;
+};
+
+types.parenL.updateContext = function (prevType) {
+ const statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
+ this.state.context.push(statementParens ? types$1.parenStatement : types$1.parenExpression);
+ this.state.exprAllowed = true;
+};
+
+types.incDec.updateContext = function () {};
+
+types._function.updateContext = types._class.updateContext = function (prevType) {
+ if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else && !(prevType === types._return && this.hasPrecedingLineBreak()) && !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat)) {
+ this.state.context.push(types$1.functionExpression);
+ } else {
+ this.state.context.push(types$1.functionStatement);
+ }
+
+ this.state.exprAllowed = false;
+};
+
+types.backQuote.updateContext = function () {
+ if (this.curContext() === types$1.template) {
+ this.state.context.pop();
+ } else {
+ this.state.context.push(types$1.template);
+ }
+
+ this.state.exprAllowed = false;
+};
+
+types.braceHashL.updateContext = function () {
+ this.state.context.push(types$1.recordExpression);
+ this.state.exprAllowed = true;
+};
+
+let nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
+let nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
+const nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
+const nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
+nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
+const astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 157, 310, 10, 21, 11, 7, 153, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 71, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 349, 41, 7, 1, 79, 28, 11, 0, 9, 21, 107, 20, 28, 22, 13, 52, 76, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 85, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 159, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 230, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 35, 56, 264, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 328, 18, 190, 0, 80, 921, 103, 110, 18, 195, 2749, 1070, 4050, 582, 8634, 568, 8, 30, 114, 29, 19, 47, 17, 3, 32, 20, 6, 18, 689, 63, 129, 74, 6, 0, 67, 12, 65, 1, 2, 0, 29, 6135, 9, 1237, 43, 8, 8952, 286, 50, 2, 18, 3, 9, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 339, 3, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 2357, 44, 11, 6, 17, 0, 370, 43, 1301, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42717, 35, 4148, 12, 221, 3, 5761, 15, 7472, 3104, 541, 1507, 4938];
+const astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 176, 2, 54, 14, 32, 9, 16, 3, 46, 10, 54, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 135, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 5319, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 419, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
+
+function isInAstralSet(code, set) {
+ let pos = 0x10000;
+
+ for (let i = 0, length = set.length; i < length; i += 2) {
+ pos += set[i];
+ if (pos > code) return false;
+ pos += set[i + 1];
+ if (pos >= code) return true;
+ }
+
+ return false;
+}
+
+function isIdentifierStart(code) {
+ if (code < 65) return code === 36;
+ if (code <= 90) return true;
+ if (code < 97) return code === 95;
+ if (code <= 122) return true;
+
+ if (code <= 0xffff) {
+ return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code));
+ }
+
+ return isInAstralSet(code, astralIdentifierStartCodes);
+}
+function isIdentifierChar(code) {
+ if (code < 48) return code === 36;
+ if (code < 58) return true;
+ if (code < 65) return false;
+ if (code <= 90) return true;
+ if (code < 97) return code === 95;
+ if (code <= 122) return true;
+
+ if (code <= 0xffff) {
+ return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));
+ }
+
+ return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes);
+}
+
+const reservedWords = {
+ keyword: ["break", "case", "catch", "continue", "debugger", "default", "do", "else", "finally", "for", "function", "if", "return", "switch", "throw", "try", "var", "const", "while", "with", "new", "this", "super", "class", "extends", "export", "import", "null", "true", "false", "in", "instanceof", "typeof", "void", "delete"],
+ strict: ["implements", "interface", "let", "package", "private", "protected", "public", "static", "yield"],
+ strictBind: ["eval", "arguments"]
+};
+const keywords$1 = new Set(reservedWords.keyword);
+const reservedWordsStrictSet = new Set(reservedWords.strict);
+const reservedWordsStrictBindSet = new Set(reservedWords.strictBind);
+function isReservedWord(word, inModule) {
+ return inModule && word === "await" || word === "enum";
+}
+function isStrictReservedWord(word, inModule) {
+ return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);
+}
+function isStrictBindOnlyReservedWord(word) {
+ return reservedWordsStrictBindSet.has(word);
+}
+function isStrictBindReservedWord(word, inModule) {
+ return isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word);
+}
+function isKeyword(word) {
+ return keywords$1.has(word);
+}
+
+const keywordRelationalOperator = /^in(stanceof)?$/;
+function isIteratorStart(current, next) {
+ return current === 64 && next === 64;
+}
+
+const SCOPE_OTHER = 0b000000000,
+ SCOPE_PROGRAM = 0b000000001,
+ SCOPE_FUNCTION = 0b000000010,
+ SCOPE_ARROW = 0b000000100,
+ SCOPE_SIMPLE_CATCH = 0b000001000,
+ SCOPE_SUPER = 0b000010000,
+ SCOPE_DIRECT_SUPER = 0b000100000,
+ SCOPE_CLASS = 0b001000000,
+ SCOPE_STATIC_BLOCK = 0b010000000,
+ SCOPE_TS_MODULE = 0b100000000,
+ SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;
+const BIND_KIND_VALUE = 0b000000000001,
+ BIND_KIND_TYPE = 0b000000000010,
+ BIND_SCOPE_VAR = 0b000000000100,
+ BIND_SCOPE_LEXICAL = 0b000000001000,
+ BIND_SCOPE_FUNCTION = 0b000000010000,
+ BIND_FLAGS_NONE = 0b000001000000,
+ BIND_FLAGS_CLASS = 0b000010000000,
+ BIND_FLAGS_TS_ENUM = 0b000100000000,
+ BIND_FLAGS_TS_CONST_ENUM = 0b001000000000,
+ BIND_FLAGS_TS_EXPORT_ONLY = 0b010000000000,
+ BIND_FLAGS_FLOW_DECLARE_FN = 0b100000000000;
+const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS,
+ BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0,
+ BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0,
+ BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0,
+ BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS,
+ BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0,
+ BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,
+ BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
+ BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE,
+ BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE,
+ BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,
+ BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,
+ BIND_FLOW_DECLARE_FN = BIND_FLAGS_FLOW_DECLARE_FN;
+const CLASS_ELEMENT_FLAG_STATIC = 0b100,
+ CLASS_ELEMENT_KIND_GETTER = 0b010,
+ CLASS_ELEMENT_KIND_SETTER = 0b001,
+ CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;
+const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,
+ CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,
+ CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,
+ CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,
+ CLASS_ELEMENT_OTHER = 0;
+
+class Scope {
+ constructor(flags) {
+ this.flags = void 0;
+ this.var = [];
+ this.lexical = [];
+ this.functions = [];
+ this.flags = flags;
+ }
+
+}
+class ScopeHandler {
+ constructor(raise, inModule) {
+ this.scopeStack = [];
+ this.undefinedExports = new Map();
+ this.undefinedPrivateNames = new Map();
+ this.raise = raise;
+ this.inModule = inModule;
+ }
+
+ get inFunction() {
+ return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;
+ }
+
+ get allowSuper() {
+ return (this.currentThisScope().flags & SCOPE_SUPER) > 0;
+ }
+
+ get allowDirectSuper() {
+ return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;
+ }
+
+ get inClass() {
+ return (this.currentThisScope().flags & SCOPE_CLASS) > 0;
+ }
+
+ get inStaticBlock() {
+ return (this.currentThisScope().flags & SCOPE_STATIC_BLOCK) > 0;
+ }
+
+ get inNonArrowFunction() {
+ return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;
+ }
+
+ get treatFunctionsAsVar() {
+ return this.treatFunctionsAsVarInScope(this.currentScope());
+ }
+
+ createScope(flags) {
+ return new Scope(flags);
+ }
+
+ enter(flags) {
+ this.scopeStack.push(this.createScope(flags));
+ }
+
+ exit() {
+ this.scopeStack.pop();
+ }
+
+ treatFunctionsAsVarInScope(scope) {
+ return !!(scope.flags & SCOPE_FUNCTION || !this.inModule && scope.flags & SCOPE_PROGRAM);
+ }
+
+ declareName(name, bindingType, pos) {
+ let scope = this.currentScope();
+
+ if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {
+ this.checkRedeclarationInScope(scope, name, bindingType, pos);
+
+ if (bindingType & BIND_SCOPE_FUNCTION) {
+ scope.functions.push(name);
+ } else {
+ scope.lexical.push(name);
+ }
+
+ if (bindingType & BIND_SCOPE_LEXICAL) {
+ this.maybeExportDefined(scope, name);
+ }
+ } else if (bindingType & BIND_SCOPE_VAR) {
+ for (let i = this.scopeStack.length - 1; i >= 0; --i) {
+ scope = this.scopeStack[i];
+ this.checkRedeclarationInScope(scope, name, bindingType, pos);
+ scope.var.push(name);
+ this.maybeExportDefined(scope, name);
+ if (scope.flags & SCOPE_VAR) break;
+ }
+ }
+
+ if (this.inModule && scope.flags & SCOPE_PROGRAM) {
+ this.undefinedExports.delete(name);
+ }
+ }
+
+ maybeExportDefined(scope, name) {
+ if (this.inModule && scope.flags & SCOPE_PROGRAM) {
+ this.undefinedExports.delete(name);
+ }
+ }
+
+ checkRedeclarationInScope(scope, name, bindingType, pos) {
+ if (this.isRedeclaredInScope(scope, name, bindingType)) {
+ this.raise(pos, ErrorMessages.VarRedeclaration, name);
+ }
+ }
+
+ isRedeclaredInScope(scope, name, bindingType) {
+ if (!(bindingType & BIND_KIND_VALUE)) return false;
+
+ if (bindingType & BIND_SCOPE_LEXICAL) {
+ return scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
+ }
+
+ if (bindingType & BIND_SCOPE_FUNCTION) {
+ return scope.lexical.indexOf(name) > -1 || !this.treatFunctionsAsVarInScope(scope) && scope.var.indexOf(name) > -1;
+ }
+
+ return scope.lexical.indexOf(name) > -1 && !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name) || !this.treatFunctionsAsVarInScope(scope) && scope.functions.indexOf(name) > -1;
+ }
+
+ checkLocalExport(id) {
+ if (this.scopeStack[0].lexical.indexOf(id.name) === -1 && this.scopeStack[0].var.indexOf(id.name) === -1 && this.scopeStack[0].functions.indexOf(id.name) === -1) {
+ this.undefinedExports.set(id.name, id.start);
+ }
+ }
+
+ currentScope() {
+ return this.scopeStack[this.scopeStack.length - 1];
+ }
+
+ currentVarScope() {
+ for (let i = this.scopeStack.length - 1;; i--) {
+ const scope = this.scopeStack[i];
+
+ if (scope.flags & SCOPE_VAR) {
+ return scope;
+ }
+ }
+ }
+
+ currentThisScope() {
+ for (let i = this.scopeStack.length - 1;; i--) {
+ const scope = this.scopeStack[i];
+
+ if ((scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) && !(scope.flags & SCOPE_ARROW)) {
+ return scope;
+ }
+ }
+ }
+
+}
+
+class FlowScope extends Scope {
+ constructor(...args) {
+ super(...args);
+ this.declareFunctions = [];
+ }
+
+}
+
+class FlowScopeHandler extends ScopeHandler {
+ createScope(flags) {
+ return new FlowScope(flags);
+ }
+
+ declareName(name, bindingType, pos) {
+ const scope = this.currentScope();
+
+ if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
+ this.checkRedeclarationInScope(scope, name, bindingType, pos);
+ this.maybeExportDefined(scope, name);
+ scope.declareFunctions.push(name);
+ return;
+ }
+
+ super.declareName(...arguments);
+ }
+
+ isRedeclaredInScope(scope, name, bindingType) {
+ if (super.isRedeclaredInScope(...arguments)) return true;
+
+ if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {
+ return !scope.declareFunctions.includes(name) && (scope.lexical.includes(name) || scope.functions.includes(name));
+ }
+
+ return false;
+ }
+
+ checkLocalExport(id) {
+ if (this.scopeStack[0].declareFunctions.indexOf(id.name) === -1) {
+ super.checkLocalExport(id);
+ }
+ }
+
+}
+
+const reservedTypes = new Set(["_", "any", "bool", "boolean", "empty", "extends", "false", "interface", "mixed", "null", "number", "static", "string", "true", "typeof", "void"]);
+const FlowErrors = Object.freeze({
+ AmbiguousConditionalArrow: "Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.",
+ AmbiguousDeclareModuleKind: "Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module",
+ AssignReservedType: "Cannot overwrite reserved type %0",
+ DeclareClassElement: "The `declare` modifier can only appear on class fields.",
+ DeclareClassFieldInitializer: "Initializers are not allowed in fields with the `declare` modifier.",
+ DuplicateDeclareModuleExports: "Duplicate `declare module.exports` statement",
+ EnumBooleanMemberNotInitialized: "Boolean enum members need to be initialized. Use either `%0 = true,` or `%0 = false,` in enum `%1`.",
+ EnumDuplicateMemberName: "Enum member names need to be unique, but the name `%0` has already been used before in enum `%1`.",
+ EnumInconsistentMemberValues: "Enum `%0` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.",
+ EnumInvalidExplicitType: "Enum type `%1` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.",
+ EnumInvalidExplicitTypeUnknownSupplied: "Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.",
+ EnumInvalidMemberInitializerPrimaryType: "Enum `%0` has type `%2`, so the initializer of `%1` needs to be a %2 literal.",
+ EnumInvalidMemberInitializerSymbolType: "Symbol enum members cannot be initialized. Use `%1,` in enum `%0`.",
+ EnumInvalidMemberInitializerUnknownType: "The enum member initializer for `%1` needs to be a literal (either a boolean, number, or string) in enum `%0`.",
+ EnumInvalidMemberName: "Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%0`, consider using `%1`, in enum `%2`.",
+ EnumNumberMemberNotInitialized: "Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.",
+ EnumStringMemberInconsistentlyInitailized: "String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.",
+ GetterMayNotHaveThisParam: "A getter cannot have a `this` parameter.",
+ ImportTypeShorthandOnlyInPureImport: "The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements",
+ InexactInsideExact: "Explicit inexact syntax cannot appear inside an explicit exact object type",
+ InexactInsideNonObject: "Explicit inexact syntax cannot appear in class or interface definitions",
+ InexactVariance: "Explicit inexact syntax cannot have variance",
+ InvalidNonTypeImportInDeclareModule: "Imports within a `declare module` body must always be `import type` or `import typeof`",
+ MissingTypeParamDefault: "Type parameter declaration needs a default, since a preceding type parameter declaration has a default.",
+ NestedDeclareModule: "`declare module` cannot be used inside another `declare module`",
+ NestedFlowComment: "Cannot have a flow comment inside another flow comment",
+ OptionalBindingPattern: "A binding pattern parameter cannot be optional in an implementation signature.",
+ SetterMayNotHaveThisParam: "A setter cannot have a `this` parameter.",
+ SpreadVariance: "Spread properties cannot have variance",
+ ThisParamAnnotationRequired: "A type annotation is required for the `this` parameter.",
+ ThisParamBannedInConstructor: "Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.",
+ ThisParamMayNotBeOptional: "The `this` parameter cannot be optional.",
+ ThisParamMustBeFirst: "The `this` parameter must be the first function parameter.",
+ ThisParamNoDefault: "The `this` parameter may not have a default value.",
+ TypeBeforeInitializer: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`",
+ TypeCastInPattern: "The type cast expression is expected to be wrapped with parenthesis",
+ UnexpectedExplicitInexactInObject: "Explicit inexact syntax must appear at the end of an inexact object",
+ UnexpectedReservedType: "Unexpected reserved type %0",
+ UnexpectedReservedUnderscore: "`_` is only allowed as a type argument to call or new",
+ UnexpectedSpaceBetweenModuloChecks: "Spaces between `%` and `checks` are not allowed here.",
+ UnexpectedSpreadType: "Spread operator cannot appear in class or interface definitions",
+ UnexpectedSubtractionOperand: 'Unexpected token, expected "number" or "bigint"',
+ UnexpectedTokenAfterTypeParameter: "Expected an arrow function after this type parameter declaration",
+ UnexpectedTypeParameterBeforeAsyncArrowFunction: "Type parameters must come after the async keyword, e.g. instead of ` async () => {}`, use `async () => {}`",
+ UnsupportedDeclareExportKind: "`declare export %0` is not supported. Use `%1` instead",
+ UnsupportedStatementInDeclareModule: "Only declares and type imports are allowed inside declare module",
+ UnterminatedFlowComment: "Unterminated flow-comment"
+});
+
+function isEsModuleType(bodyElement) {
+ return bodyElement.type === "DeclareExportAllDeclaration" || bodyElement.type === "DeclareExportDeclaration" && (!bodyElement.declaration || bodyElement.declaration.type !== "TypeAlias" && bodyElement.declaration.type !== "InterfaceDeclaration");
+}
+
+function hasTypeImportKind(node) {
+ return node.importKind === "type" || node.importKind === "typeof";
+}
+
+function isMaybeDefaultImport(state) {
+ return (state.type === types.name || !!state.type.keyword) && state.value !== "from";
+}
+
+const exportSuggestions = {
+ const: "declare export var",
+ let: "declare export var",
+ type: "export type",
+ interface: "export interface"
+};
+
+function partition(list, test) {
+ const list1 = [];
+ const list2 = [];
+
+ for (let i = 0; i < list.length; i++) {
+ (test(list[i], i, list) ? list1 : list2).push(list[i]);
+ }
+
+ return [list1, list2];
+}
+
+const FLOW_PRAGMA_REGEX = /\*?\s*@((?:no)?flow)\b/;
+var flow = (superClass => {
+ var _temp;
+
+ return _temp = class extends superClass {
+ constructor(...args) {
+ super(...args);
+ this.flowPragma = undefined;
+ }
+
+ getScopeHandler() {
+ return FlowScopeHandler;
+ }
+
+ shouldParseTypes() {
+ return this.getPluginOption("flow", "all") || this.flowPragma === "flow";
+ }
+
+ shouldParseEnums() {
+ return !!this.getPluginOption("flow", "enums");
+ }
+
+ finishToken(type, val) {
+ if (type !== types.string && type !== types.semi && type !== types.interpreterDirective) {
+ if (this.flowPragma === undefined) {
+ this.flowPragma = null;
+ }
+ }
+
+ return super.finishToken(type, val);
+ }
+
+ addComment(comment) {
+ if (this.flowPragma === undefined) {
+ const matches = FLOW_PRAGMA_REGEX.exec(comment.value);
+
+ if (!matches) ; else if (matches[1] === "flow") {
+ this.flowPragma = "flow";
+ } else if (matches[1] === "noflow") {
+ this.flowPragma = "noflow";
+ } else {
+ throw new Error("Unexpected flow pragma");
+ }
+ }
+
+ return super.addComment(comment);
+ }
+
+ flowParseTypeInitialiser(tok) {
+ const oldInType = this.state.inType;
+ this.state.inType = true;
+ this.expect(tok || types.colon);
+ const type = this.flowParseType();
+ this.state.inType = oldInType;
+ return type;
+ }
+
+ flowParsePredicate() {
+ const node = this.startNode();
+ const moduloLoc = this.state.startLoc;
+ const moduloPos = this.state.start;
+ this.expect(types.modulo);
+ const checksLoc = this.state.startLoc;
+ this.expectContextual("checks");
+
+ if (moduloLoc.line !== checksLoc.line || moduloLoc.column !== checksLoc.column - 1) {
+ this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);
+ }
+
+ if (this.eat(types.parenL)) {
+ node.value = this.parseExpression();
+ this.expect(types.parenR);
+ return this.finishNode(node, "DeclaredPredicate");
+ } else {
+ return this.finishNode(node, "InferredPredicate");
+ }
+ }
+
+ flowParseTypeAndPredicateInitialiser() {
+ const oldInType = this.state.inType;
+ this.state.inType = true;
+ this.expect(types.colon);
+ let type = null;
+ let predicate = null;
+
+ if (this.match(types.modulo)) {
+ this.state.inType = oldInType;
+ predicate = this.flowParsePredicate();
+ } else {
+ type = this.flowParseType();
+ this.state.inType = oldInType;
+
+ if (this.match(types.modulo)) {
+ predicate = this.flowParsePredicate();
+ }
+ }
+
+ return [type, predicate];
+ }
+
+ flowParseDeclareClass(node) {
+ this.next();
+ this.flowParseInterfaceish(node, true);
+ return this.finishNode(node, "DeclareClass");
+ }
+
+ flowParseDeclareFunction(node) {
+ this.next();
+ const id = node.id = this.parseIdentifier();
+ const typeNode = this.startNode();
+ const typeContainer = this.startNode();
+
+ if (this.isRelational("<")) {
+ typeNode.typeParameters = this.flowParseTypeParameterDeclaration();
+ } else {
+ typeNode.typeParameters = null;
+ }
+
+ this.expect(types.parenL);
+ const tmp = this.flowParseFunctionTypeParams();
+ typeNode.params = tmp.params;
+ typeNode.rest = tmp.rest;
+ typeNode.this = tmp._this;
+ this.expect(types.parenR);
+ [typeNode.returnType, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
+ typeContainer.typeAnnotation = this.finishNode(typeNode, "FunctionTypeAnnotation");
+ id.typeAnnotation = this.finishNode(typeContainer, "TypeAnnotation");
+ this.resetEndLocation(id);
+ this.semicolon();
+ this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);
+ return this.finishNode(node, "DeclareFunction");
+ }
+
+ flowParseDeclare(node, insideModule) {
+ if (this.match(types._class)) {
+ return this.flowParseDeclareClass(node);
+ } else if (this.match(types._function)) {
+ return this.flowParseDeclareFunction(node);
+ } else if (this.match(types._var)) {
+ return this.flowParseDeclareVariable(node);
+ } else if (this.eatContextual("module")) {
+ if (this.match(types.dot)) {
+ return this.flowParseDeclareModuleExports(node);
+ } else {
+ if (insideModule) {
+ this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);
+ }
+
+ return this.flowParseDeclareModule(node);
+ }
+ } else if (this.isContextual("type")) {
+ return this.flowParseDeclareTypeAlias(node);
+ } else if (this.isContextual("opaque")) {
+ return this.flowParseDeclareOpaqueType(node);
+ } else if (this.isContextual("interface")) {
+ return this.flowParseDeclareInterface(node);
+ } else if (this.match(types._export)) {
+ return this.flowParseDeclareExportDeclaration(node, insideModule);
+ } else {
+ throw this.unexpected();
+ }
+ }
+
+ flowParseDeclareVariable(node) {
+ this.next();
+ node.id = this.flowParseTypeAnnotatableIdentifier(true);
+ this.scope.declareName(node.id.name, BIND_VAR, node.id.start);
+ this.semicolon();
+ return this.finishNode(node, "DeclareVariable");
+ }
+
+ flowParseDeclareModule(node) {
+ this.scope.enter(SCOPE_OTHER);
+
+ if (this.match(types.string)) {
+ node.id = this.parseExprAtom();
+ } else {
+ node.id = this.parseIdentifier();
+ }
+
+ const bodyNode = node.body = this.startNode();
+ const body = bodyNode.body = [];
+ this.expect(types.braceL);
+
+ while (!this.match(types.braceR)) {
+ let bodyNode = this.startNode();
+
+ if (this.match(types._import)) {
+ this.next();
+
+ if (!this.isContextual("type") && !this.match(types._typeof)) {
+ this.raise(this.state.lastTokStart, FlowErrors.InvalidNonTypeImportInDeclareModule);
+ }
+
+ this.parseImport(bodyNode);
+ } else {
+ this.expectContextual("declare", FlowErrors.UnsupportedStatementInDeclareModule);
+ bodyNode = this.flowParseDeclare(bodyNode, true);
+ }
+
+ body.push(bodyNode);
+ }
+
+ this.scope.exit();
+ this.expect(types.braceR);
+ this.finishNode(bodyNode, "BlockStatement");
+ let kind = null;
+ let hasModuleExport = false;
+ body.forEach(bodyElement => {
+ if (isEsModuleType(bodyElement)) {
+ if (kind === "CommonJS") {
+ this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
+ }
+
+ kind = "ES";
+ } else if (bodyElement.type === "DeclareModuleExports") {
+ if (hasModuleExport) {
+ this.raise(bodyElement.start, FlowErrors.DuplicateDeclareModuleExports);
+ }
+
+ if (kind === "ES") {
+ this.raise(bodyElement.start, FlowErrors.AmbiguousDeclareModuleKind);
+ }
+
+ kind = "CommonJS";
+ hasModuleExport = true;
+ }
+ });
+ node.kind = kind || "CommonJS";
+ return this.finishNode(node, "DeclareModule");
+ }
+
+ flowParseDeclareExportDeclaration(node, insideModule) {
+ this.expect(types._export);
+
+ if (this.eat(types._default)) {
+ if (this.match(types._function) || this.match(types._class)) {
+ node.declaration = this.flowParseDeclare(this.startNode());
+ } else {
+ node.declaration = this.flowParseType();
+ this.semicolon();
+ }
+
+ node.default = true;
+ return this.finishNode(node, "DeclareExportDeclaration");
+ } else {
+ if (this.match(types._const) || this.isLet() || (this.isContextual("type") || this.isContextual("interface")) && !insideModule) {
+ const label = this.state.value;
+ const suggestion = exportSuggestions[label];
+ throw this.raise(this.state.start, FlowErrors.UnsupportedDeclareExportKind, label, suggestion);
+ }
+
+ if (this.match(types._var) || this.match(types._function) || this.match(types._class) || this.isContextual("opaque")) {
+ node.declaration = this.flowParseDeclare(this.startNode());
+ node.default = false;
+ return this.finishNode(node, "DeclareExportDeclaration");
+ } else if (this.match(types.star) || this.match(types.braceL) || this.isContextual("interface") || this.isContextual("type") || this.isContextual("opaque")) {
+ node = this.parseExport(node);
+
+ if (node.type === "ExportNamedDeclaration") {
+ node.type = "ExportDeclaration";
+ node.default = false;
+ delete node.exportKind;
+ }
+
+ node.type = "Declare" + node.type;
+ return node;
+ }
+ }
+
+ throw this.unexpected();
+ }
+
+ flowParseDeclareModuleExports(node) {
+ this.next();
+ this.expectContextual("exports");
+ node.typeAnnotation = this.flowParseTypeAnnotation();
+ this.semicolon();
+ return this.finishNode(node, "DeclareModuleExports");
+ }
+
+ flowParseDeclareTypeAlias(node) {
+ this.next();
+ this.flowParseTypeAlias(node);
+ node.type = "DeclareTypeAlias";
+ return node;
+ }
+
+ flowParseDeclareOpaqueType(node) {
+ this.next();
+ this.flowParseOpaqueType(node, true);
+ node.type = "DeclareOpaqueType";
+ return node;
+ }
+
+ flowParseDeclareInterface(node) {
+ this.next();
+ this.flowParseInterfaceish(node);
+ return this.finishNode(node, "DeclareInterface");
+ }
+
+ flowParseInterfaceish(node, isClass = false) {
+ node.id = this.flowParseRestrictedIdentifier(!isClass, true);
+ this.scope.declareName(node.id.name, isClass ? BIND_FUNCTION : BIND_LEXICAL, node.id.start);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ } else {
+ node.typeParameters = null;
+ }
+
+ node.extends = [];
+ node.implements = [];
+ node.mixins = [];
+
+ if (this.eat(types._extends)) {
+ do {
+ node.extends.push(this.flowParseInterfaceExtends());
+ } while (!isClass && this.eat(types.comma));
+ }
+
+ if (this.isContextual("mixins")) {
+ this.next();
+
+ do {
+ node.mixins.push(this.flowParseInterfaceExtends());
+ } while (this.eat(types.comma));
+ }
+
+ if (this.isContextual("implements")) {
+ this.next();
+
+ do {
+ node.implements.push(this.flowParseInterfaceExtends());
+ } while (this.eat(types.comma));
+ }
+
+ node.body = this.flowParseObjectType({
+ allowStatic: isClass,
+ allowExact: false,
+ allowSpread: false,
+ allowProto: isClass,
+ allowInexact: false
+ });
+ }
+
+ flowParseInterfaceExtends() {
+ const node = this.startNode();
+ node.id = this.flowParseQualifiedTypeIdentifier();
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterInstantiation();
+ } else {
+ node.typeParameters = null;
+ }
+
+ return this.finishNode(node, "InterfaceExtends");
+ }
+
+ flowParseInterface(node) {
+ this.flowParseInterfaceish(node);
+ return this.finishNode(node, "InterfaceDeclaration");
+ }
+
+ checkNotUnderscore(word) {
+ if (word === "_") {
+ this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);
+ }
+ }
+
+ checkReservedType(word, startLoc, declaration) {
+ if (!reservedTypes.has(word)) return;
+ this.raise(startLoc, declaration ? FlowErrors.AssignReservedType : FlowErrors.UnexpectedReservedType, word);
+ }
+
+ flowParseRestrictedIdentifier(liberal, declaration) {
+ this.checkReservedType(this.state.value, this.state.start, declaration);
+ return this.parseIdentifier(liberal);
+ }
+
+ flowParseTypeAlias(node) {
+ node.id = this.flowParseRestrictedIdentifier(false, true);
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ } else {
+ node.typeParameters = null;
+ }
+
+ node.right = this.flowParseTypeInitialiser(types.eq);
+ this.semicolon();
+ return this.finishNode(node, "TypeAlias");
+ }
+
+ flowParseOpaqueType(node, declare) {
+ this.expectContextual("type");
+ node.id = this.flowParseRestrictedIdentifier(true, true);
+ this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ } else {
+ node.typeParameters = null;
+ }
+
+ node.supertype = null;
+
+ if (this.match(types.colon)) {
+ node.supertype = this.flowParseTypeInitialiser(types.colon);
+ }
+
+ node.impltype = null;
+
+ if (!declare) {
+ node.impltype = this.flowParseTypeInitialiser(types.eq);
+ }
+
+ this.semicolon();
+ return this.finishNode(node, "OpaqueType");
+ }
+
+ flowParseTypeParameter(requireDefault = false) {
+ const nodeStart = this.state.start;
+ const node = this.startNode();
+ const variance = this.flowParseVariance();
+ const ident = this.flowParseTypeAnnotatableIdentifier();
+ node.name = ident.name;
+ node.variance = variance;
+ node.bound = ident.typeAnnotation;
+
+ if (this.match(types.eq)) {
+ this.eat(types.eq);
+ node.default = this.flowParseType();
+ } else {
+ if (requireDefault) {
+ this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);
+ }
+ }
+
+ return this.finishNode(node, "TypeParameter");
+ }
+
+ flowParseTypeParameterDeclaration() {
+ const oldInType = this.state.inType;
+ const node = this.startNode();
+ node.params = [];
+ this.state.inType = true;
+
+ if (this.isRelational("<") || this.match(types.jsxTagStart)) {
+ this.next();
+ } else {
+ this.unexpected();
+ }
+
+ let defaultRequired = false;
+
+ do {
+ const typeParameter = this.flowParseTypeParameter(defaultRequired);
+ node.params.push(typeParameter);
+
+ if (typeParameter.default) {
+ defaultRequired = true;
+ }
+
+ if (!this.isRelational(">")) {
+ this.expect(types.comma);
+ }
+ } while (!this.isRelational(">"));
+
+ this.expectRelational(">");
+ this.state.inType = oldInType;
+ return this.finishNode(node, "TypeParameterDeclaration");
+ }
+
+ flowParseTypeParameterInstantiation() {
+ const node = this.startNode();
+ const oldInType = this.state.inType;
+ node.params = [];
+ this.state.inType = true;
+ this.expectRelational("<");
+ const oldNoAnonFunctionType = this.state.noAnonFunctionType;
+ this.state.noAnonFunctionType = false;
+
+ while (!this.isRelational(">")) {
+ node.params.push(this.flowParseType());
+
+ if (!this.isRelational(">")) {
+ this.expect(types.comma);
+ }
+ }
+
+ this.state.noAnonFunctionType = oldNoAnonFunctionType;
+ this.expectRelational(">");
+ this.state.inType = oldInType;
+ return this.finishNode(node, "TypeParameterInstantiation");
+ }
+
+ flowParseTypeParameterInstantiationCallOrNew() {
+ const node = this.startNode();
+ const oldInType = this.state.inType;
+ node.params = [];
+ this.state.inType = true;
+ this.expectRelational("<");
+
+ while (!this.isRelational(">")) {
+ node.params.push(this.flowParseTypeOrImplicitInstantiation());
+
+ if (!this.isRelational(">")) {
+ this.expect(types.comma);
+ }
+ }
+
+ this.expectRelational(">");
+ this.state.inType = oldInType;
+ return this.finishNode(node, "TypeParameterInstantiation");
+ }
+
+ flowParseInterfaceType() {
+ const node = this.startNode();
+ this.expectContextual("interface");
+ node.extends = [];
+
+ if (this.eat(types._extends)) {
+ do {
+ node.extends.push(this.flowParseInterfaceExtends());
+ } while (this.eat(types.comma));
+ }
+
+ node.body = this.flowParseObjectType({
+ allowStatic: false,
+ allowExact: false,
+ allowSpread: false,
+ allowProto: false,
+ allowInexact: false
+ });
+ return this.finishNode(node, "InterfaceTypeAnnotation");
+ }
+
+ flowParseObjectPropertyKey() {
+ return this.match(types.num) || this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true);
+ }
+
+ flowParseObjectTypeIndexer(node, isStatic, variance) {
+ node.static = isStatic;
+
+ if (this.lookahead().type === types.colon) {
+ node.id = this.flowParseObjectPropertyKey();
+ node.key = this.flowParseTypeInitialiser();
+ } else {
+ node.id = null;
+ node.key = this.flowParseType();
+ }
+
+ this.expect(types.bracketR);
+ node.value = this.flowParseTypeInitialiser();
+ node.variance = variance;
+ return this.finishNode(node, "ObjectTypeIndexer");
+ }
+
+ flowParseObjectTypeInternalSlot(node, isStatic) {
+ node.static = isStatic;
+ node.id = this.flowParseObjectPropertyKey();
+ this.expect(types.bracketR);
+ this.expect(types.bracketR);
+
+ if (this.isRelational("<") || this.match(types.parenL)) {
+ node.method = true;
+ node.optional = false;
+ node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
+ } else {
+ node.method = false;
+
+ if (this.eat(types.question)) {
+ node.optional = true;
+ }
+
+ node.value = this.flowParseTypeInitialiser();
+ }
+
+ return this.finishNode(node, "ObjectTypeInternalSlot");
+ }
+
+ flowParseObjectTypeMethodish(node) {
+ node.params = [];
+ node.rest = null;
+ node.typeParameters = null;
+ node.this = null;
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ }
+
+ this.expect(types.parenL);
+
+ if (this.match(types._this)) {
+ node.this = this.flowParseFunctionTypeParam(true);
+ node.this.name = null;
+
+ if (!this.match(types.parenR)) {
+ this.expect(types.comma);
+ }
+ }
+
+ while (!this.match(types.parenR) && !this.match(types.ellipsis)) {
+ node.params.push(this.flowParseFunctionTypeParam(false));
+
+ if (!this.match(types.parenR)) {
+ this.expect(types.comma);
+ }
+ }
+
+ if (this.eat(types.ellipsis)) {
+ node.rest = this.flowParseFunctionTypeParam(false);
+ }
+
+ this.expect(types.parenR);
+ node.returnType = this.flowParseTypeInitialiser();
+ return this.finishNode(node, "FunctionTypeAnnotation");
+ }
+
+ flowParseObjectTypeCallProperty(node, isStatic) {
+ const valueNode = this.startNode();
+ node.static = isStatic;
+ node.value = this.flowParseObjectTypeMethodish(valueNode);
+ return this.finishNode(node, "ObjectTypeCallProperty");
+ }
+
+ flowParseObjectType({
+ allowStatic,
+ allowExact,
+ allowSpread,
+ allowProto,
+ allowInexact
+ }) {
+ const oldInType = this.state.inType;
+ this.state.inType = true;
+ const nodeStart = this.startNode();
+ nodeStart.callProperties = [];
+ nodeStart.properties = [];
+ nodeStart.indexers = [];
+ nodeStart.internalSlots = [];
+ let endDelim;
+ let exact;
+ let inexact = false;
+
+ if (allowExact && this.match(types.braceBarL)) {
+ this.expect(types.braceBarL);
+ endDelim = types.braceBarR;
+ exact = true;
+ } else {
+ this.expect(types.braceL);
+ endDelim = types.braceR;
+ exact = false;
+ }
+
+ nodeStart.exact = exact;
+
+ while (!this.match(endDelim)) {
+ let isStatic = false;
+ let protoStart = null;
+ let inexactStart = null;
+ const node = this.startNode();
+
+ if (allowProto && this.isContextual("proto")) {
+ const lookahead = this.lookahead();
+
+ if (lookahead.type !== types.colon && lookahead.type !== types.question) {
+ this.next();
+ protoStart = this.state.start;
+ allowStatic = false;
+ }
+ }
+
+ if (allowStatic && this.isContextual("static")) {
+ const lookahead = this.lookahead();
+
+ if (lookahead.type !== types.colon && lookahead.type !== types.question) {
+ this.next();
+ isStatic = true;
+ }
+ }
+
+ const variance = this.flowParseVariance();
+
+ if (this.eat(types.bracketL)) {
+ if (protoStart != null) {
+ this.unexpected(protoStart);
+ }
+
+ if (this.eat(types.bracketL)) {
+ if (variance) {
+ this.unexpected(variance.start);
+ }
+
+ nodeStart.internalSlots.push(this.flowParseObjectTypeInternalSlot(node, isStatic));
+ } else {
+ nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance));
+ }
+ } else if (this.match(types.parenL) || this.isRelational("<")) {
+ if (protoStart != null) {
+ this.unexpected(protoStart);
+ }
+
+ if (variance) {
+ this.unexpected(variance.start);
+ }
+
+ nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, isStatic));
+ } else {
+ let kind = "init";
+
+ if (this.isContextual("get") || this.isContextual("set")) {
+ const lookahead = this.lookahead();
+
+ if (lookahead.type === types.name || lookahead.type === types.string || lookahead.type === types.num) {
+ kind = this.state.value;
+ this.next();
+ }
+ }
+
+ const propOrInexact = this.flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact != null ? allowInexact : !exact);
+
+ if (propOrInexact === null) {
+ inexact = true;
+ inexactStart = this.state.lastTokStart;
+ } else {
+ nodeStart.properties.push(propOrInexact);
+ }
+ }
+
+ this.flowObjectTypeSemicolon();
+
+ if (inexactStart && !this.match(types.braceR) && !this.match(types.braceBarR)) {
+ this.raise(inexactStart, FlowErrors.UnexpectedExplicitInexactInObject);
+ }
+ }
+
+ this.expect(endDelim);
+
+ if (allowSpread) {
+ nodeStart.inexact = inexact;
+ }
+
+ const out = this.finishNode(nodeStart, "ObjectTypeAnnotation");
+ this.state.inType = oldInType;
+ return out;
+ }
+
+ flowParseObjectTypeProperty(node, isStatic, protoStart, variance, kind, allowSpread, allowInexact) {
+ if (this.eat(types.ellipsis)) {
+ const isInexactToken = this.match(types.comma) || this.match(types.semi) || this.match(types.braceR) || this.match(types.braceBarR);
+
+ if (isInexactToken) {
+ if (!allowSpread) {
+ this.raise(this.state.lastTokStart, FlowErrors.InexactInsideNonObject);
+ } else if (!allowInexact) {
+ this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);
+ }
+
+ if (variance) {
+ this.raise(variance.start, FlowErrors.InexactVariance);
+ }
+
+ return null;
+ }
+
+ if (!allowSpread) {
+ this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);
+ }
+
+ if (protoStart != null) {
+ this.unexpected(protoStart);
+ }
+
+ if (variance) {
+ this.raise(variance.start, FlowErrors.SpreadVariance);
+ }
+
+ node.argument = this.flowParseType();
+ return this.finishNode(node, "ObjectTypeSpreadProperty");
+ } else {
+ node.key = this.flowParseObjectPropertyKey();
+ node.static = isStatic;
+ node.proto = protoStart != null;
+ node.kind = kind;
+ let optional = false;
+
+ if (this.isRelational("<") || this.match(types.parenL)) {
+ node.method = true;
+
+ if (protoStart != null) {
+ this.unexpected(protoStart);
+ }
+
+ if (variance) {
+ this.unexpected(variance.start);
+ }
+
+ node.value = this.flowParseObjectTypeMethodish(this.startNodeAt(node.start, node.loc.start));
+
+ if (kind === "get" || kind === "set") {
+ this.flowCheckGetterSetterParams(node);
+ }
+
+ if (!allowSpread && node.key.name === "constructor" && node.value.this) {
+ this.raise(node.value.this.start, FlowErrors.ThisParamBannedInConstructor);
+ }
+ } else {
+ if (kind !== "init") this.unexpected();
+ node.method = false;
+
+ if (this.eat(types.question)) {
+ optional = true;
+ }
+
+ node.value = this.flowParseTypeInitialiser();
+ node.variance = variance;
+ }
+
+ node.optional = optional;
+ return this.finishNode(node, "ObjectTypeProperty");
+ }
+ }
+
+ flowCheckGetterSetterParams(property) {
+ const paramCount = property.kind === "get" ? 0 : 1;
+ const start = property.start;
+ const length = property.value.params.length + (property.value.rest ? 1 : 0);
+
+ if (property.value.this) {
+ this.raise(property.value.this.start, property.kind === "get" ? FlowErrors.GetterMayNotHaveThisParam : FlowErrors.SetterMayNotHaveThisParam);
+ }
+
+ if (length !== paramCount) {
+ if (property.kind === "get") {
+ this.raise(start, ErrorMessages.BadGetterArity);
+ } else {
+ this.raise(start, ErrorMessages.BadSetterArity);
+ }
+ }
+
+ if (property.kind === "set" && property.value.rest) {
+ this.raise(start, ErrorMessages.BadSetterRestParameter);
+ }
+ }
+
+ flowObjectTypeSemicolon() {
+ if (!this.eat(types.semi) && !this.eat(types.comma) && !this.match(types.braceR) && !this.match(types.braceBarR)) {
+ this.unexpected();
+ }
+ }
+
+ flowParseQualifiedTypeIdentifier(startPos, startLoc, id) {
+ startPos = startPos || this.state.start;
+ startLoc = startLoc || this.state.startLoc;
+ let node = id || this.flowParseRestrictedIdentifier(true);
+
+ while (this.eat(types.dot)) {
+ const node2 = this.startNodeAt(startPos, startLoc);
+ node2.qualification = node;
+ node2.id = this.flowParseRestrictedIdentifier(true);
+ node = this.finishNode(node2, "QualifiedTypeIdentifier");
+ }
+
+ return node;
+ }
+
+ flowParseGenericType(startPos, startLoc, id) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.typeParameters = null;
+ node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterInstantiation();
+ }
+
+ return this.finishNode(node, "GenericTypeAnnotation");
+ }
+
+ flowParseTypeofType() {
+ const node = this.startNode();
+ this.expect(types._typeof);
+ node.argument = this.flowParsePrimaryType();
+ return this.finishNode(node, "TypeofTypeAnnotation");
+ }
+
+ flowParseTupleType() {
+ const node = this.startNode();
+ node.types = [];
+ this.expect(types.bracketL);
+
+ while (this.state.pos < this.length && !this.match(types.bracketR)) {
+ node.types.push(this.flowParseType());
+ if (this.match(types.bracketR)) break;
+ this.expect(types.comma);
+ }
+
+ this.expect(types.bracketR);
+ return this.finishNode(node, "TupleTypeAnnotation");
+ }
+
+ flowParseFunctionTypeParam(first) {
+ let name = null;
+ let optional = false;
+ let typeAnnotation = null;
+ const node = this.startNode();
+ const lh = this.lookahead();
+ const isThis = this.state.type === types._this;
+
+ if (lh.type === types.colon || lh.type === types.question) {
+ if (isThis && !first) {
+ this.raise(node.start, FlowErrors.ThisParamMustBeFirst);
+ }
+
+ name = this.parseIdentifier(isThis);
+
+ if (this.eat(types.question)) {
+ optional = true;
+
+ if (isThis) {
+ this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);
+ }
+ }
+
+ typeAnnotation = this.flowParseTypeInitialiser();
+ } else {
+ typeAnnotation = this.flowParseType();
+ }
+
+ node.name = name;
+ node.optional = optional;
+ node.typeAnnotation = typeAnnotation;
+ return this.finishNode(node, "FunctionTypeParam");
+ }
+
+ reinterpretTypeAsFunctionTypeParam(type) {
+ const node = this.startNodeAt(type.start, type.loc.start);
+ node.name = null;
+ node.optional = false;
+ node.typeAnnotation = type;
+ return this.finishNode(node, "FunctionTypeParam");
+ }
+
+ flowParseFunctionTypeParams(params = []) {
+ let rest = null;
+ let _this = null;
+
+ if (this.match(types._this)) {
+ _this = this.flowParseFunctionTypeParam(true);
+ _this.name = null;
+
+ if (!this.match(types.parenR)) {
+ this.expect(types.comma);
+ }
+ }
+
+ while (!this.match(types.parenR) && !this.match(types.ellipsis)) {
+ params.push(this.flowParseFunctionTypeParam(false));
+
+ if (!this.match(types.parenR)) {
+ this.expect(types.comma);
+ }
+ }
+
+ if (this.eat(types.ellipsis)) {
+ rest = this.flowParseFunctionTypeParam(false);
+ }
+
+ return {
+ params,
+ rest,
+ _this
+ };
+ }
+
+ flowIdentToTypeAnnotation(startPos, startLoc, node, id) {
+ switch (id.name) {
+ case "any":
+ return this.finishNode(node, "AnyTypeAnnotation");
+
+ case "bool":
+ case "boolean":
+ return this.finishNode(node, "BooleanTypeAnnotation");
+
+ case "mixed":
+ return this.finishNode(node, "MixedTypeAnnotation");
+
+ case "empty":
+ return this.finishNode(node, "EmptyTypeAnnotation");
+
+ case "number":
+ return this.finishNode(node, "NumberTypeAnnotation");
+
+ case "string":
+ return this.finishNode(node, "StringTypeAnnotation");
+
+ case "symbol":
+ return this.finishNode(node, "SymbolTypeAnnotation");
+
+ default:
+ this.checkNotUnderscore(id.name);
+ return this.flowParseGenericType(startPos, startLoc, id);
+ }
+ }
+
+ flowParsePrimaryType() {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const node = this.startNode();
+ let tmp;
+ let type;
+ let isGroupedType = false;
+ const oldNoAnonFunctionType = this.state.noAnonFunctionType;
+
+ switch (this.state.type) {
+ case types.name:
+ if (this.isContextual("interface")) {
+ return this.flowParseInterfaceType();
+ }
+
+ return this.flowIdentToTypeAnnotation(startPos, startLoc, node, this.parseIdentifier());
+
+ case types.braceL:
+ return this.flowParseObjectType({
+ allowStatic: false,
+ allowExact: false,
+ allowSpread: true,
+ allowProto: false,
+ allowInexact: true
+ });
+
+ case types.braceBarL:
+ return this.flowParseObjectType({
+ allowStatic: false,
+ allowExact: true,
+ allowSpread: true,
+ allowProto: false,
+ allowInexact: false
+ });
+
+ case types.bracketL:
+ this.state.noAnonFunctionType = false;
+ type = this.flowParseTupleType();
+ this.state.noAnonFunctionType = oldNoAnonFunctionType;
+ return type;
+
+ case types.relational:
+ if (this.state.value === "<") {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ this.expect(types.parenL);
+ tmp = this.flowParseFunctionTypeParams();
+ node.params = tmp.params;
+ node.rest = tmp.rest;
+ node.this = tmp._this;
+ this.expect(types.parenR);
+ this.expect(types.arrow);
+ node.returnType = this.flowParseType();
+ return this.finishNode(node, "FunctionTypeAnnotation");
+ }
+
+ break;
+
+ case types.parenL:
+ this.next();
+
+ if (!this.match(types.parenR) && !this.match(types.ellipsis)) {
+ if (this.match(types.name) || this.match(types._this)) {
+ const token = this.lookahead().type;
+ isGroupedType = token !== types.question && token !== types.colon;
+ } else {
+ isGroupedType = true;
+ }
+ }
+
+ if (isGroupedType) {
+ this.state.noAnonFunctionType = false;
+ type = this.flowParseType();
+ this.state.noAnonFunctionType = oldNoAnonFunctionType;
+
+ if (this.state.noAnonFunctionType || !(this.match(types.comma) || this.match(types.parenR) && this.lookahead().type === types.arrow)) {
+ this.expect(types.parenR);
+ return type;
+ } else {
+ this.eat(types.comma);
+ }
+ }
+
+ if (type) {
+ tmp = this.flowParseFunctionTypeParams([this.reinterpretTypeAsFunctionTypeParam(type)]);
+ } else {
+ tmp = this.flowParseFunctionTypeParams();
+ }
+
+ node.params = tmp.params;
+ node.rest = tmp.rest;
+ node.this = tmp._this;
+ this.expect(types.parenR);
+ this.expect(types.arrow);
+ node.returnType = this.flowParseType();
+ node.typeParameters = null;
+ return this.finishNode(node, "FunctionTypeAnnotation");
+
+ case types.string:
+ return this.parseLiteral(this.state.value, "StringLiteralTypeAnnotation");
+
+ case types._true:
+ case types._false:
+ node.value = this.match(types._true);
+ this.next();
+ return this.finishNode(node, "BooleanLiteralTypeAnnotation");
+
+ case types.plusMin:
+ if (this.state.value === "-") {
+ this.next();
+
+ if (this.match(types.num)) {
+ return this.parseLiteral(-this.state.value, "NumberLiteralTypeAnnotation", node.start, node.loc.start);
+ }
+
+ if (this.match(types.bigint)) {
+ return this.parseLiteral(-this.state.value, "BigIntLiteralTypeAnnotation", node.start, node.loc.start);
+ }
+
+ throw this.raise(this.state.start, FlowErrors.UnexpectedSubtractionOperand);
+ }
+
+ throw this.unexpected();
+
+ case types.num:
+ return this.parseLiteral(this.state.value, "NumberLiteralTypeAnnotation");
+
+ case types.bigint:
+ return this.parseLiteral(this.state.value, "BigIntLiteralTypeAnnotation");
+
+ case types._void:
+ this.next();
+ return this.finishNode(node, "VoidTypeAnnotation");
+
+ case types._null:
+ this.next();
+ return this.finishNode(node, "NullLiteralTypeAnnotation");
+
+ case types._this:
+ this.next();
+ return this.finishNode(node, "ThisTypeAnnotation");
+
+ case types.star:
+ this.next();
+ return this.finishNode(node, "ExistsTypeAnnotation");
+
+ default:
+ if (this.state.type.keyword === "typeof") {
+ return this.flowParseTypeofType();
+ } else if (this.state.type.keyword) {
+ const label = this.state.type.label;
+ this.next();
+ return super.createIdentifier(node, label);
+ }
+
+ }
+
+ throw this.unexpected();
+ }
+
+ flowParsePostfixType() {
+ const startPos = this.state.start,
+ startLoc = this.state.startLoc;
+ let type = this.flowParsePrimaryType();
+
+ while (this.match(types.bracketL) && !this.canInsertSemicolon()) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.elementType = type;
+ this.expect(types.bracketL);
+ this.expect(types.bracketR);
+ type = this.finishNode(node, "ArrayTypeAnnotation");
+ }
+
+ return type;
+ }
+
+ flowParsePrefixType() {
+ const node = this.startNode();
+
+ if (this.eat(types.question)) {
+ node.typeAnnotation = this.flowParsePrefixType();
+ return this.finishNode(node, "NullableTypeAnnotation");
+ } else {
+ return this.flowParsePostfixType();
+ }
+ }
+
+ flowParseAnonFunctionWithoutParens() {
+ const param = this.flowParsePrefixType();
+
+ if (!this.state.noAnonFunctionType && this.eat(types.arrow)) {
+ const node = this.startNodeAt(param.start, param.loc.start);
+ node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];
+ node.rest = null;
+ node.this = null;
+ node.returnType = this.flowParseType();
+ node.typeParameters = null;
+ return this.finishNode(node, "FunctionTypeAnnotation");
+ }
+
+ return param;
+ }
+
+ flowParseIntersectionType() {
+ const node = this.startNode();
+ this.eat(types.bitwiseAND);
+ const type = this.flowParseAnonFunctionWithoutParens();
+ node.types = [type];
+
+ while (this.eat(types.bitwiseAND)) {
+ node.types.push(this.flowParseAnonFunctionWithoutParens());
+ }
+
+ return node.types.length === 1 ? type : this.finishNode(node, "IntersectionTypeAnnotation");
+ }
+
+ flowParseUnionType() {
+ const node = this.startNode();
+ this.eat(types.bitwiseOR);
+ const type = this.flowParseIntersectionType();
+ node.types = [type];
+
+ while (this.eat(types.bitwiseOR)) {
+ node.types.push(this.flowParseIntersectionType());
+ }
+
+ return node.types.length === 1 ? type : this.finishNode(node, "UnionTypeAnnotation");
+ }
+
+ flowParseType() {
+ const oldInType = this.state.inType;
+ this.state.inType = true;
+ const type = this.flowParseUnionType();
+ this.state.inType = oldInType;
+ this.state.exprAllowed = this.state.exprAllowed || this.state.noAnonFunctionType;
+ return type;
+ }
+
+ flowParseTypeOrImplicitInstantiation() {
+ if (this.state.type === types.name && this.state.value === "_") {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const node = this.parseIdentifier();
+ return this.flowParseGenericType(startPos, startLoc, node);
+ } else {
+ return this.flowParseType();
+ }
+ }
+
+ flowParseTypeAnnotation() {
+ const node = this.startNode();
+ node.typeAnnotation = this.flowParseTypeInitialiser();
+ return this.finishNode(node, "TypeAnnotation");
+ }
+
+ flowParseTypeAnnotatableIdentifier(allowPrimitiveOverride) {
+ const ident = allowPrimitiveOverride ? this.parseIdentifier() : this.flowParseRestrictedIdentifier();
+
+ if (this.match(types.colon)) {
+ ident.typeAnnotation = this.flowParseTypeAnnotation();
+ this.resetEndLocation(ident);
+ }
+
+ return ident;
+ }
+
+ typeCastToParameter(node) {
+ node.expression.typeAnnotation = node.typeAnnotation;
+ this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
+ return node.expression;
+ }
+
+ flowParseVariance() {
+ let variance = null;
+
+ if (this.match(types.plusMin)) {
+ variance = this.startNode();
+
+ if (this.state.value === "+") {
+ variance.kind = "plus";
+ } else {
+ variance.kind = "minus";
+ }
+
+ this.next();
+ this.finishNode(variance, "Variance");
+ }
+
+ return variance;
+ }
+
+ parseFunctionBody(node, allowExpressionBody, isMethod = false) {
+ if (allowExpressionBody) {
+ return this.forwardNoArrowParamsConversionAt(node, () => super.parseFunctionBody(node, true, isMethod));
+ }
+
+ return super.parseFunctionBody(node, false, isMethod);
+ }
+
+ parseFunctionBodyAndFinish(node, type, isMethod = false) {
+ if (this.match(types.colon)) {
+ const typeNode = this.startNode();
+ [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
+ node.returnType = typeNode.typeAnnotation ? this.finishNode(typeNode, "TypeAnnotation") : null;
+ }
+
+ super.parseFunctionBodyAndFinish(node, type, isMethod);
+ }
+
+ parseStatement(context, topLevel) {
+ if (this.state.strict && this.match(types.name) && this.state.value === "interface") {
+ const lookahead = this.lookahead();
+
+ if (lookahead.type === types.name || isKeyword(lookahead.value)) {
+ const node = this.startNode();
+ this.next();
+ return this.flowParseInterface(node);
+ }
+ } else if (this.shouldParseEnums() && this.isContextual("enum")) {
+ const node = this.startNode();
+ this.next();
+ return this.flowParseEnumDeclaration(node);
+ }
+
+ const stmt = super.parseStatement(context, topLevel);
+
+ if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {
+ this.flowPragma = null;
+ }
+
+ return stmt;
+ }
+
+ parseExpressionStatement(node, expr) {
+ if (expr.type === "Identifier") {
+ if (expr.name === "declare") {
+ if (this.match(types._class) || this.match(types.name) || this.match(types._function) || this.match(types._var) || this.match(types._export)) {
+ return this.flowParseDeclare(node);
+ }
+ } else if (this.match(types.name)) {
+ if (expr.name === "interface") {
+ return this.flowParseInterface(node);
+ } else if (expr.name === "type") {
+ return this.flowParseTypeAlias(node);
+ } else if (expr.name === "opaque") {
+ return this.flowParseOpaqueType(node, false);
+ }
+ }
+ }
+
+ return super.parseExpressionStatement(node, expr);
+ }
+
+ shouldParseExportDeclaration() {
+ return this.isContextual("type") || this.isContextual("interface") || this.isContextual("opaque") || this.shouldParseEnums() && this.isContextual("enum") || super.shouldParseExportDeclaration();
+ }
+
+ isExportDefaultSpecifier() {
+ if (this.match(types.name) && (this.state.value === "type" || this.state.value === "interface" || this.state.value === "opaque" || this.shouldParseEnums() && this.state.value === "enum")) {
+ return false;
+ }
+
+ return super.isExportDefaultSpecifier();
+ }
+
+ parseExportDefaultExpression() {
+ if (this.shouldParseEnums() && this.isContextual("enum")) {
+ const node = this.startNode();
+ this.next();
+ return this.flowParseEnumDeclaration(node);
+ }
+
+ return super.parseExportDefaultExpression();
+ }
+
+ parseConditional(expr, startPos, startLoc, refNeedsArrowPos) {
+ if (!this.match(types.question)) return expr;
+
+ if (refNeedsArrowPos) {
+ const result = this.tryParse(() => super.parseConditional(expr, startPos, startLoc));
+
+ if (!result.node) {
+ refNeedsArrowPos.start = result.error.pos || this.state.start;
+ return expr;
+ }
+
+ if (result.error) this.state = result.failState;
+ return result.node;
+ }
+
+ this.expect(types.question);
+ const state = this.state.clone();
+ const originalNoArrowAt = this.state.noArrowAt;
+ const node = this.startNodeAt(startPos, startLoc);
+ let {
+ consequent,
+ failed
+ } = this.tryParseConditionalConsequent();
+ let [valid, invalid] = this.getArrowLikeExpressions(consequent);
+
+ if (failed || invalid.length > 0) {
+ const noArrowAt = [...originalNoArrowAt];
+
+ if (invalid.length > 0) {
+ this.state = state;
+ this.state.noArrowAt = noArrowAt;
+
+ for (let i = 0; i < invalid.length; i++) {
+ noArrowAt.push(invalid[i].start);
+ }
+
+ ({
+ consequent,
+ failed
+ } = this.tryParseConditionalConsequent());
+ [valid, invalid] = this.getArrowLikeExpressions(consequent);
+ }
+
+ if (failed && valid.length > 1) {
+ this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);
+ }
+
+ if (failed && valid.length === 1) {
+ this.state = state;
+ this.state.noArrowAt = noArrowAt.concat(valid[0].start);
+ ({
+ consequent,
+ failed
+ } = this.tryParseConditionalConsequent());
+ }
+ }
+
+ this.getArrowLikeExpressions(consequent, true);
+ this.state.noArrowAt = originalNoArrowAt;
+ this.expect(types.colon);
+ node.test = expr;
+ node.consequent = consequent;
+ node.alternate = this.forwardNoArrowParamsConversionAt(node, () => this.parseMaybeAssign(undefined, undefined, undefined));
+ return this.finishNode(node, "ConditionalExpression");
+ }
+
+ tryParseConditionalConsequent() {
+ this.state.noArrowParamsConversionAt.push(this.state.start);
+ const consequent = this.parseMaybeAssignAllowIn();
+ const failed = !this.match(types.colon);
+ this.state.noArrowParamsConversionAt.pop();
+ return {
+ consequent,
+ failed
+ };
+ }
+
+ getArrowLikeExpressions(node, disallowInvalid) {
+ const stack = [node];
+ const arrows = [];
+
+ while (stack.length !== 0) {
+ const node = stack.pop();
+
+ if (node.type === "ArrowFunctionExpression") {
+ if (node.typeParameters || !node.returnType) {
+ this.finishArrowValidation(node);
+ } else {
+ arrows.push(node);
+ }
+
+ stack.push(node.body);
+ } else if (node.type === "ConditionalExpression") {
+ stack.push(node.consequent);
+ stack.push(node.alternate);
+ }
+ }
+
+ if (disallowInvalid) {
+ arrows.forEach(node => this.finishArrowValidation(node));
+ return [arrows, []];
+ }
+
+ return partition(arrows, node => node.params.every(param => this.isAssignable(param, true)));
+ }
+
+ finishArrowValidation(node) {
+ var _node$extra;
+
+ this.toAssignableList(node.params, (_node$extra = node.extra) == null ? void 0 : _node$extra.trailingComma, false);
+ this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
+ super.checkParams(node, false, true);
+ this.scope.exit();
+ }
+
+ forwardNoArrowParamsConversionAt(node, parse) {
+ let result;
+
+ if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
+ this.state.noArrowParamsConversionAt.push(this.state.start);
+ result = parse();
+ this.state.noArrowParamsConversionAt.pop();
+ } else {
+ result = parse();
+ }
+
+ return result;
+ }
+
+ parseParenItem(node, startPos, startLoc) {
+ node = super.parseParenItem(node, startPos, startLoc);
+
+ if (this.eat(types.question)) {
+ node.optional = true;
+ this.resetEndLocation(node);
+ }
+
+ if (this.match(types.colon)) {
+ const typeCastNode = this.startNodeAt(startPos, startLoc);
+ typeCastNode.expression = node;
+ typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();
+ return this.finishNode(typeCastNode, "TypeCastExpression");
+ }
+
+ return node;
+ }
+
+ assertModuleNodeAllowed(node) {
+ if (node.type === "ImportDeclaration" && (node.importKind === "type" || node.importKind === "typeof") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "ExportAllDeclaration" && node.exportKind === "type") {
+ return;
+ }
+
+ super.assertModuleNodeAllowed(node);
+ }
+
+ parseExport(node) {
+ const decl = super.parseExport(node);
+
+ if (decl.type === "ExportNamedDeclaration" || decl.type === "ExportAllDeclaration") {
+ decl.exportKind = decl.exportKind || "value";
+ }
+
+ return decl;
+ }
+
+ parseExportDeclaration(node) {
+ if (this.isContextual("type")) {
+ node.exportKind = "type";
+ const declarationNode = this.startNode();
+ this.next();
+
+ if (this.match(types.braceL)) {
+ node.specifiers = this.parseExportSpecifiers();
+ this.parseExportFrom(node);
+ return null;
+ } else {
+ return this.flowParseTypeAlias(declarationNode);
+ }
+ } else if (this.isContextual("opaque")) {
+ node.exportKind = "type";
+ const declarationNode = this.startNode();
+ this.next();
+ return this.flowParseOpaqueType(declarationNode, false);
+ } else if (this.isContextual("interface")) {
+ node.exportKind = "type";
+ const declarationNode = this.startNode();
+ this.next();
+ return this.flowParseInterface(declarationNode);
+ } else if (this.shouldParseEnums() && this.isContextual("enum")) {
+ node.exportKind = "value";
+ const declarationNode = this.startNode();
+ this.next();
+ return this.flowParseEnumDeclaration(declarationNode);
+ } else {
+ return super.parseExportDeclaration(node);
+ }
+ }
+
+ eatExportStar(node) {
+ if (super.eatExportStar(...arguments)) return true;
+
+ if (this.isContextual("type") && this.lookahead().type === types.star) {
+ node.exportKind = "type";
+ this.next();
+ this.next();
+ return true;
+ }
+
+ return false;
+ }
+
+ maybeParseExportNamespaceSpecifier(node) {
+ const pos = this.state.start;
+ const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);
+
+ if (hasNamespace && node.exportKind === "type") {
+ this.unexpected(pos);
+ }
+
+ return hasNamespace;
+ }
+
+ parseClassId(node, isStatement, optionalId) {
+ super.parseClassId(node, isStatement, optionalId);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ }
+ }
+
+ parseClassMember(classBody, member, state) {
+ const pos = this.state.start;
+
+ if (this.isContextual("declare")) {
+ if (this.parseClassMemberFromModifier(classBody, member)) {
+ return;
+ }
+
+ member.declare = true;
+ }
+
+ super.parseClassMember(classBody, member, state);
+
+ if (member.declare) {
+ if (member.type !== "ClassProperty" && member.type !== "ClassPrivateProperty" && member.type !== "PropertyDefinition") {
+ this.raise(pos, FlowErrors.DeclareClassElement);
+ } else if (member.value) {
+ this.raise(member.value.start, FlowErrors.DeclareClassFieldInitializer);
+ }
+ }
+ }
+
+ getTokenFromCode(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (code === 123 && next === 124) {
+ return this.finishOp(types.braceBarL, 2);
+ } else if (this.state.inType && (code === 62 || code === 60)) {
+ return this.finishOp(types.relational, 1);
+ } else if (this.state.inType && code === 63) {
+ return this.finishOp(types.question, 1);
+ } else if (isIteratorStart(code, next)) {
+ this.state.isIterator = true;
+ return super.readWord();
+ } else {
+ return super.getTokenFromCode(code);
+ }
+ }
+
+ isAssignable(node, isBinding) {
+ switch (node.type) {
+ case "Identifier":
+ case "ObjectPattern":
+ case "ArrayPattern":
+ case "AssignmentPattern":
+ return true;
+
+ case "ObjectExpression":
+ {
+ const last = node.properties.length - 1;
+ return node.properties.every((prop, i) => {
+ return prop.type !== "ObjectMethod" && (i === last || prop.type === "SpreadElement") && this.isAssignable(prop);
+ });
+ }
+
+ case "ObjectProperty":
+ return this.isAssignable(node.value);
+
+ case "SpreadElement":
+ return this.isAssignable(node.argument);
+
+ case "ArrayExpression":
+ return node.elements.every(element => this.isAssignable(element));
+
+ case "AssignmentExpression":
+ return node.operator === "=";
+
+ case "ParenthesizedExpression":
+ case "TypeCastExpression":
+ return this.isAssignable(node.expression);
+
+ case "MemberExpression":
+ case "OptionalMemberExpression":
+ return !isBinding;
+
+ default:
+ return false;
+ }
+ }
+
+ toAssignable(node, isLHS = false) {
+ if (node.type === "TypeCastExpression") {
+ return super.toAssignable(this.typeCastToParameter(node), isLHS);
+ } else {
+ return super.toAssignable(node, isLHS);
+ }
+ }
+
+ toAssignableList(exprList, trailingCommaPos, isLHS) {
+ for (let i = 0; i < exprList.length; i++) {
+ const expr = exprList[i];
+
+ if ((expr == null ? void 0 : expr.type) === "TypeCastExpression") {
+ exprList[i] = this.typeCastToParameter(expr);
+ }
+ }
+
+ return super.toAssignableList(exprList, trailingCommaPos, isLHS);
+ }
+
+ toReferencedList(exprList, isParenthesizedExpr) {
+ for (let i = 0; i < exprList.length; i++) {
+ var _expr$extra;
+
+ const expr = exprList[i];
+
+ if (expr && expr.type === "TypeCastExpression" && !((_expr$extra = expr.extra) != null && _expr$extra.parenthesized) && (exprList.length > 1 || !isParenthesizedExpr)) {
+ this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);
+ }
+ }
+
+ return exprList;
+ }
+
+ parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
+ const node = super.parseArrayLike(close, canBePattern, isTuple, refExpressionErrors);
+
+ if (canBePattern && !this.state.maybeInArrowParameters) {
+ this.toReferencedList(node.elements);
+ }
+
+ return node;
+ }
+
+ checkLVal(expr, ...args) {
+ if (expr.type !== "TypeCastExpression") {
+ return super.checkLVal(expr, ...args);
+ }
+ }
+
+ parseClassProperty(node) {
+ if (this.match(types.colon)) {
+ node.typeAnnotation = this.flowParseTypeAnnotation();
+ }
+
+ return super.parseClassProperty(node);
+ }
+
+ parseClassPrivateProperty(node) {
+ if (this.match(types.colon)) {
+ node.typeAnnotation = this.flowParseTypeAnnotation();
+ }
+
+ return super.parseClassPrivateProperty(node);
+ }
+
+ isClassMethod() {
+ return this.isRelational("<") || super.isClassMethod();
+ }
+
+ isClassProperty() {
+ return this.match(types.colon) || super.isClassProperty();
+ }
+
+ isNonstaticConstructor(method) {
+ return !this.match(types.colon) && super.isNonstaticConstructor(method);
+ }
+
+ isThisParam(param) {
+ return param.type === "Identifier" && param.name === "this";
+ }
+
+ pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
+ if (method.variance) {
+ this.unexpected(method.variance.start);
+ }
+
+ delete method.variance;
+
+ if (this.isRelational("<")) {
+ method.typeParameters = this.flowParseTypeParameterDeclaration();
+ }
+
+ super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
+
+ if (method.params && isConstructor) {
+ const params = method.params;
+
+ if (params.length > 0 && this.isThisParam(params[0])) {
+ this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
+ }
+ } else if (method.type === "MethodDefinition" && isConstructor && method.value.params) {
+ const params = method.value.params;
+
+ if (params.length > 0 && this.isThisParam(params[0])) {
+ this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);
+ }
+ }
+ }
+
+ pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
+ if (method.variance) {
+ this.unexpected(method.variance.start);
+ }
+
+ delete method.variance;
+
+ if (this.isRelational("<")) {
+ method.typeParameters = this.flowParseTypeParameterDeclaration();
+ }
+
+ super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
+ }
+
+ parseClassSuper(node) {
+ super.parseClassSuper(node);
+
+ if (node.superClass && this.isRelational("<")) {
+ node.superTypeParameters = this.flowParseTypeParameterInstantiation();
+ }
+
+ if (this.isContextual("implements")) {
+ this.next();
+ const implemented = node.implements = [];
+
+ do {
+ const node = this.startNode();
+ node.id = this.flowParseRestrictedIdentifier(true);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterInstantiation();
+ } else {
+ node.typeParameters = null;
+ }
+
+ implemented.push(this.finishNode(node, "ClassImplements"));
+ } while (this.eat(types.comma));
+ }
+ }
+
+ checkGetterSetterParams(method) {
+ super.checkGetterSetterParams(method);
+ const params = this.getObjectOrClassMethodParams(method);
+
+ if (params.length > 0) {
+ const param = params[0];
+
+ if (this.isThisParam(param) && method.kind === "get") {
+ this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);
+ } else if (this.isThisParam(param)) {
+ this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);
+ }
+ }
+ }
+
+ parsePropertyName(node, isPrivateNameAllowed) {
+ const variance = this.flowParseVariance();
+ const key = super.parsePropertyName(node, isPrivateNameAllowed);
+ node.variance = variance;
+ return key;
+ }
+
+ parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
+ if (prop.variance) {
+ this.unexpected(prop.variance.start);
+ }
+
+ delete prop.variance;
+ let typeParameters;
+
+ if (this.isRelational("<") && !isAccessor) {
+ typeParameters = this.flowParseTypeParameterDeclaration();
+ if (!this.match(types.parenL)) this.unexpected();
+ }
+
+ super.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
+
+ if (typeParameters) {
+ (prop.value || prop).typeParameters = typeParameters;
+ }
+ }
+
+ parseAssignableListItemTypes(param) {
+ if (this.eat(types.question)) {
+ if (param.type !== "Identifier") {
+ this.raise(param.start, FlowErrors.OptionalBindingPattern);
+ }
+
+ if (this.isThisParam(param)) {
+ this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);
+ }
+
+ param.optional = true;
+ }
+
+ if (this.match(types.colon)) {
+ param.typeAnnotation = this.flowParseTypeAnnotation();
+ } else if (this.isThisParam(param)) {
+ this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);
+ }
+
+ if (this.match(types.eq) && this.isThisParam(param)) {
+ this.raise(param.start, FlowErrors.ThisParamNoDefault);
+ }
+
+ this.resetEndLocation(param);
+ return param;
+ }
+
+ parseMaybeDefault(startPos, startLoc, left) {
+ const node = super.parseMaybeDefault(startPos, startLoc, left);
+
+ if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
+ this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);
+ }
+
+ return node;
+ }
+
+ shouldParseDefaultImport(node) {
+ if (!hasTypeImportKind(node)) {
+ return super.shouldParseDefaultImport(node);
+ }
+
+ return isMaybeDefaultImport(this.state);
+ }
+
+ parseImportSpecifierLocal(node, specifier, type, contextDescription) {
+ specifier.local = hasTypeImportKind(node) ? this.flowParseRestrictedIdentifier(true, true) : this.parseIdentifier();
+ this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL);
+ node.specifiers.push(this.finishNode(specifier, type));
+ }
+
+ maybeParseDefaultImportSpecifier(node) {
+ node.importKind = "value";
+ let kind = null;
+
+ if (this.match(types._typeof)) {
+ kind = "typeof";
+ } else if (this.isContextual("type")) {
+ kind = "type";
+ }
+
+ if (kind) {
+ const lh = this.lookahead();
+
+ if (kind === "type" && lh.type === types.star) {
+ this.unexpected(lh.start);
+ }
+
+ if (isMaybeDefaultImport(lh) || lh.type === types.braceL || lh.type === types.star) {
+ this.next();
+ node.importKind = kind;
+ }
+ }
+
+ return super.maybeParseDefaultImportSpecifier(node);
+ }
+
+ parseImportSpecifier(node) {
+ const specifier = this.startNode();
+ const firstIdentLoc = this.state.start;
+ const firstIdent = this.parseModuleExportName();
+ let specifierTypeKind = null;
+
+ if (firstIdent.type === "Identifier") {
+ if (firstIdent.name === "type") {
+ specifierTypeKind = "type";
+ } else if (firstIdent.name === "typeof") {
+ specifierTypeKind = "typeof";
+ }
+ }
+
+ let isBinding = false;
+
+ if (this.isContextual("as") && !this.isLookaheadContextual("as")) {
+ const as_ident = this.parseIdentifier(true);
+
+ if (specifierTypeKind !== null && !this.match(types.name) && !this.state.type.keyword) {
+ specifier.imported = as_ident;
+ specifier.importKind = specifierTypeKind;
+ specifier.local = as_ident.__clone();
+ } else {
+ specifier.imported = firstIdent;
+ specifier.importKind = null;
+ specifier.local = this.parseIdentifier();
+ }
+ } else if (specifierTypeKind !== null && (this.match(types.name) || this.state.type.keyword)) {
+ specifier.imported = this.parseIdentifier(true);
+ specifier.importKind = specifierTypeKind;
+
+ if (this.eatContextual("as")) {
+ specifier.local = this.parseIdentifier();
+ } else {
+ isBinding = true;
+ specifier.local = specifier.imported.__clone();
+ }
+ } else {
+ if (firstIdent.type === "StringLiteral") {
+ throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, firstIdent.value);
+ }
+
+ isBinding = true;
+ specifier.imported = firstIdent;
+ specifier.importKind = null;
+ specifier.local = specifier.imported.__clone();
+ }
+
+ const nodeIsTypeImport = hasTypeImportKind(node);
+ const specifierIsTypeImport = hasTypeImportKind(specifier);
+
+ if (nodeIsTypeImport && specifierIsTypeImport) {
+ this.raise(firstIdentLoc, FlowErrors.ImportTypeShorthandOnlyInPureImport);
+ }
+
+ if (nodeIsTypeImport || specifierIsTypeImport) {
+ this.checkReservedType(specifier.local.name, specifier.local.start, true);
+ }
+
+ if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {
+ this.checkReservedWord(specifier.local.name, specifier.start, true, true);
+ }
+
+ this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
+ node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
+ }
+
+ parseBindingAtom() {
+ switch (this.state.type) {
+ case types._this:
+ return this.parseIdentifier(true);
+
+ default:
+ return super.parseBindingAtom();
+ }
+ }
+
+ parseFunctionParams(node, allowModifiers) {
+ const kind = node.kind;
+
+ if (kind !== "get" && kind !== "set" && this.isRelational("<")) {
+ node.typeParameters = this.flowParseTypeParameterDeclaration();
+ }
+
+ super.parseFunctionParams(node, allowModifiers);
+ }
+
+ parseVarId(decl, kind) {
+ super.parseVarId(decl, kind);
+
+ if (this.match(types.colon)) {
+ decl.id.typeAnnotation = this.flowParseTypeAnnotation();
+ this.resetEndLocation(decl.id);
+ }
+ }
+
+ parseAsyncArrowFromCallExpression(node, call) {
+ if (this.match(types.colon)) {
+ const oldNoAnonFunctionType = this.state.noAnonFunctionType;
+ this.state.noAnonFunctionType = true;
+ node.returnType = this.flowParseTypeAnnotation();
+ this.state.noAnonFunctionType = oldNoAnonFunctionType;
+ }
+
+ return super.parseAsyncArrowFromCallExpression(node, call);
+ }
+
+ shouldParseAsyncArrow() {
+ return this.match(types.colon) || super.shouldParseAsyncArrow();
+ }
+
+ parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos) {
+ var _jsx;
+
+ let state = null;
+ let jsx;
+
+ if (this.hasPlugin("jsx") && (this.match(types.jsxTagStart) || this.isRelational("<"))) {
+ state = this.state.clone();
+ jsx = this.tryParse(() => super.parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos), state);
+ if (!jsx.error) return jsx.node;
+ const {
+ context
+ } = this.state;
+
+ if (context[context.length - 1] === types$1.j_oTag) {
+ context.length -= 2;
+ } else if (context[context.length - 1] === types$1.j_expr) {
+ context.length -= 1;
+ }
+ }
+
+ if ((_jsx = jsx) != null && _jsx.error || this.isRelational("<")) {
+ var _jsx2, _jsx3;
+
+ state = state || this.state.clone();
+ let typeParameters;
+ const arrow = this.tryParse(abort => {
+ var _arrowExpression$extr;
+
+ typeParameters = this.flowParseTypeParameterDeclaration();
+ const arrowExpression = this.forwardNoArrowParamsConversionAt(typeParameters, () => {
+ const result = super.parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos);
+ this.resetStartLocationFromNode(result, typeParameters);
+ return result;
+ });
+
+ if (arrowExpression.type !== "ArrowFunctionExpression" && (_arrowExpression$extr = arrowExpression.extra) != null && _arrowExpression$extr.parenthesized) {
+ abort();
+ }
+
+ const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);
+ expr.typeParameters = typeParameters;
+ this.resetStartLocationFromNode(expr, typeParameters);
+ return arrowExpression;
+ }, state);
+ let arrowExpression = null;
+
+ if (arrow.node && this.maybeUnwrapTypeCastExpression(arrow.node).type === "ArrowFunctionExpression") {
+ if (!arrow.error && !arrow.aborted) {
+ if (arrow.node.async) {
+ this.raise(typeParameters.start, FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction);
+ }
+
+ return arrow.node;
+ }
+
+ arrowExpression = arrow.node;
+ }
+
+ if ((_jsx2 = jsx) != null && _jsx2.node) {
+ this.state = jsx.failState;
+ return jsx.node;
+ }
+
+ if (arrowExpression) {
+ this.state = arrow.failState;
+ return arrowExpression;
+ }
+
+ if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
+ if (arrow.thrown) throw arrow.error;
+ throw this.raise(typeParameters.start, FlowErrors.UnexpectedTokenAfterTypeParameter);
+ }
+
+ return super.parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos);
+ }
+
+ parseArrow(node) {
+ if (this.match(types.colon)) {
+ const result = this.tryParse(() => {
+ const oldNoAnonFunctionType = this.state.noAnonFunctionType;
+ this.state.noAnonFunctionType = true;
+ const typeNode = this.startNode();
+ [typeNode.typeAnnotation, node.predicate] = this.flowParseTypeAndPredicateInitialiser();
+ this.state.noAnonFunctionType = oldNoAnonFunctionType;
+ if (this.canInsertSemicolon()) this.unexpected();
+ if (!this.match(types.arrow)) this.unexpected();
+ return typeNode;
+ });
+ if (result.thrown) return null;
+ if (result.error) this.state = result.failState;
+ node.returnType = result.node.typeAnnotation ? this.finishNode(result.node, "TypeAnnotation") : null;
+ }
+
+ return super.parseArrow(node);
+ }
+
+ shouldParseArrow() {
+ return this.match(types.colon) || super.shouldParseArrow();
+ }
+
+ setArrowFunctionParameters(node, params) {
+ if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
+ node.params = params;
+ } else {
+ super.setArrowFunctionParameters(node, params);
+ }
+ }
+
+ checkParams(node, allowDuplicates, isArrowFunction) {
+ if (isArrowFunction && this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {
+ return;
+ }
+
+ for (let i = 0; i < node.params.length; i++) {
+ if (this.isThisParam(node.params[i]) && i > 0) {
+ this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);
+ }
+ }
+
+ return super.checkParams(...arguments);
+ }
+
+ parseParenAndDistinguishExpression(canBeArrow) {
+ return super.parseParenAndDistinguishExpression(canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1);
+ }
+
+ parseSubscripts(base, startPos, startLoc, noCalls) {
+ if (base.type === "Identifier" && base.name === "async" && this.state.noArrowAt.indexOf(startPos) !== -1) {
+ this.next();
+ const node = this.startNodeAt(startPos, startLoc);
+ node.callee = base;
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ base = this.finishNode(node, "CallExpression");
+ } else if (base.type === "Identifier" && base.name === "async" && this.isRelational("<")) {
+ const state = this.state.clone();
+ const arrow = this.tryParse(abort => this.parseAsyncArrowWithTypeParameters(startPos, startLoc) || abort(), state);
+ if (!arrow.error && !arrow.aborted) return arrow.node;
+ const result = this.tryParse(() => super.parseSubscripts(base, startPos, startLoc, noCalls), state);
+ if (result.node && !result.error) return result.node;
+
+ if (arrow.node) {
+ this.state = arrow.failState;
+ return arrow.node;
+ }
+
+ if (result.node) {
+ this.state = result.failState;
+ return result.node;
+ }
+
+ throw arrow.error || result.error;
+ }
+
+ return super.parseSubscripts(base, startPos, startLoc, noCalls);
+ }
+
+ parseSubscript(base, startPos, startLoc, noCalls, subscriptState) {
+ if (this.match(types.questionDot) && this.isLookaheadToken_lt()) {
+ subscriptState.optionalChainMember = true;
+
+ if (noCalls) {
+ subscriptState.stop = true;
+ return base;
+ }
+
+ this.next();
+ const node = this.startNodeAt(startPos, startLoc);
+ node.callee = base;
+ node.typeArguments = this.flowParseTypeParameterInstantiation();
+ this.expect(types.parenL);
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ node.optional = true;
+ return this.finishCallExpression(node, true);
+ } else if (!noCalls && this.shouldParseTypes() && this.isRelational("<")) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.callee = base;
+ const result = this.tryParse(() => {
+ node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
+ this.expect(types.parenL);
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ if (subscriptState.optionalChainMember) node.optional = false;
+ return this.finishCallExpression(node, subscriptState.optionalChainMember);
+ });
+
+ if (result.node) {
+ if (result.error) this.state = result.failState;
+ return result.node;
+ }
+ }
+
+ return super.parseSubscript(base, startPos, startLoc, noCalls, subscriptState);
+ }
+
+ parseNewArguments(node) {
+ let targs = null;
+
+ if (this.shouldParseTypes() && this.isRelational("<")) {
+ targs = this.tryParse(() => this.flowParseTypeParameterInstantiationCallOrNew()).node;
+ }
+
+ node.typeArguments = targs;
+ super.parseNewArguments(node);
+ }
+
+ parseAsyncArrowWithTypeParameters(startPos, startLoc) {
+ const node = this.startNodeAt(startPos, startLoc);
+ this.parseFunctionParams(node);
+ if (!this.parseArrow(node)) return;
+ return this.parseArrowExpression(node, undefined, true);
+ }
+
+ readToken_mult_modulo(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (code === 42 && next === 47 && this.state.hasFlowComment) {
+ this.state.hasFlowComment = false;
+ this.state.pos += 2;
+ this.nextToken();
+ return;
+ }
+
+ super.readToken_mult_modulo(code);
+ }
+
+ readToken_pipe_amp(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (code === 124 && next === 125) {
+ this.finishOp(types.braceBarR, 2);
+ return;
+ }
+
+ super.readToken_pipe_amp(code);
+ }
+
+ parseTopLevel(file, program) {
+ const fileNode = super.parseTopLevel(file, program);
+
+ if (this.state.hasFlowComment) {
+ this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);
+ }
+
+ return fileNode;
+ }
+
+ skipBlockComment() {
+ if (this.hasPlugin("flowComments") && this.skipFlowComment()) {
+ if (this.state.hasFlowComment) {
+ this.unexpected(null, FlowErrors.NestedFlowComment);
+ }
+
+ this.hasFlowCommentCompletion();
+ this.state.pos += this.skipFlowComment();
+ this.state.hasFlowComment = true;
+ return;
+ }
+
+ if (this.state.hasFlowComment) {
+ const end = this.input.indexOf("*-/", this.state.pos += 2);
+
+ if (end === -1) {
+ throw this.raise(this.state.pos - 2, ErrorMessages.UnterminatedComment);
+ }
+
+ this.state.pos = end + 3;
+ return;
+ }
+
+ super.skipBlockComment();
+ }
+
+ skipFlowComment() {
+ const {
+ pos
+ } = this.state;
+ let shiftToFirstNonWhiteSpace = 2;
+
+ while ([32, 9].includes(this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace))) {
+ shiftToFirstNonWhiteSpace++;
+ }
+
+ const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);
+ const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);
+
+ if (ch2 === 58 && ch3 === 58) {
+ return shiftToFirstNonWhiteSpace + 2;
+ }
+
+ if (this.input.slice(shiftToFirstNonWhiteSpace + pos, shiftToFirstNonWhiteSpace + pos + 12) === "flow-include") {
+ return shiftToFirstNonWhiteSpace + 12;
+ }
+
+ if (ch2 === 58 && ch3 !== 58) {
+ return shiftToFirstNonWhiteSpace;
+ }
+
+ return false;
+ }
+
+ hasFlowCommentCompletion() {
+ const end = this.input.indexOf("*/", this.state.pos);
+
+ if (end === -1) {
+ throw this.raise(this.state.pos, ErrorMessages.UnterminatedComment);
+ }
+ }
+
+ flowEnumErrorBooleanMemberNotInitialized(pos, {
+ enumName,
+ memberName
+ }) {
+ this.raise(pos, FlowErrors.EnumBooleanMemberNotInitialized, memberName, enumName);
+ }
+
+ flowEnumErrorInvalidMemberName(pos, {
+ enumName,
+ memberName
+ }) {
+ const suggestion = memberName[0].toUpperCase() + memberName.slice(1);
+ this.raise(pos, FlowErrors.EnumInvalidMemberName, memberName, suggestion, enumName);
+ }
+
+ flowEnumErrorDuplicateMemberName(pos, {
+ enumName,
+ memberName
+ }) {
+ this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);
+ }
+
+ flowEnumErrorInconsistentMemberValues(pos, {
+ enumName
+ }) {
+ this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);
+ }
+
+ flowEnumErrorInvalidExplicitType(pos, {
+ enumName,
+ suppliedType
+ }) {
+ return this.raise(pos, suppliedType === null ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied : FlowErrors.EnumInvalidExplicitType, enumName, suppliedType);
+ }
+
+ flowEnumErrorInvalidMemberInitializer(pos, {
+ enumName,
+ explicitType,
+ memberName
+ }) {
+ let message = null;
+
+ switch (explicitType) {
+ case "boolean":
+ case "number":
+ case "string":
+ message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;
+ break;
+
+ case "symbol":
+ message = FlowErrors.EnumInvalidMemberInitializerSymbolType;
+ break;
+
+ default:
+ message = FlowErrors.EnumInvalidMemberInitializerUnknownType;
+ }
+
+ return this.raise(pos, message, enumName, memberName, explicitType);
+ }
+
+ flowEnumErrorNumberMemberNotInitialized(pos, {
+ enumName,
+ memberName
+ }) {
+ this.raise(pos, FlowErrors.EnumNumberMemberNotInitialized, enumName, memberName);
+ }
+
+ flowEnumErrorStringMemberInconsistentlyInitailized(pos, {
+ enumName
+ }) {
+ this.raise(pos, FlowErrors.EnumStringMemberInconsistentlyInitailized, enumName);
+ }
+
+ flowEnumMemberInit() {
+ const startPos = this.state.start;
+
+ const endOfInit = () => this.match(types.comma) || this.match(types.braceR);
+
+ switch (this.state.type) {
+ case types.num:
+ {
+ const literal = this.parseLiteral(this.state.value, "NumericLiteral");
+
+ if (endOfInit()) {
+ return {
+ type: "number",
+ pos: literal.start,
+ value: literal
+ };
+ }
+
+ return {
+ type: "invalid",
+ pos: startPos
+ };
+ }
+
+ case types.string:
+ {
+ const literal = this.parseLiteral(this.state.value, "StringLiteral");
+
+ if (endOfInit()) {
+ return {
+ type: "string",
+ pos: literal.start,
+ value: literal
+ };
+ }
+
+ return {
+ type: "invalid",
+ pos: startPos
+ };
+ }
+
+ case types._true:
+ case types._false:
+ {
+ const literal = this.parseBooleanLiteral();
+
+ if (endOfInit()) {
+ return {
+ type: "boolean",
+ pos: literal.start,
+ value: literal
+ };
+ }
+
+ return {
+ type: "invalid",
+ pos: startPos
+ };
+ }
+
+ default:
+ return {
+ type: "invalid",
+ pos: startPos
+ };
+ }
+ }
+
+ flowEnumMemberRaw() {
+ const pos = this.state.start;
+ const id = this.parseIdentifier(true);
+ const init = this.eat(types.eq) ? this.flowEnumMemberInit() : {
+ type: "none",
+ pos
+ };
+ return {
+ id,
+ init
+ };
+ }
+
+ flowEnumCheckExplicitTypeMismatch(pos, context, expectedType) {
+ const {
+ explicitType
+ } = context;
+
+ if (explicitType === null) {
+ return;
+ }
+
+ if (explicitType !== expectedType) {
+ this.flowEnumErrorInvalidMemberInitializer(pos, context);
+ }
+ }
+
+ flowEnumMembers({
+ enumName,
+ explicitType
+ }) {
+ const seenNames = new Set();
+ const members = {
+ booleanMembers: [],
+ numberMembers: [],
+ stringMembers: [],
+ defaultedMembers: []
+ };
+ let hasUnknownMembers = false;
+
+ while (!this.match(types.braceR)) {
+ if (this.eat(types.ellipsis)) {
+ hasUnknownMembers = true;
+ break;
+ }
+
+ const memberNode = this.startNode();
+ const {
+ id,
+ init
+ } = this.flowEnumMemberRaw();
+ const memberName = id.name;
+
+ if (memberName === "") {
+ continue;
+ }
+
+ if (/^[a-z]/.test(memberName)) {
+ this.flowEnumErrorInvalidMemberName(id.start, {
+ enumName,
+ memberName
+ });
+ }
+
+ if (seenNames.has(memberName)) {
+ this.flowEnumErrorDuplicateMemberName(id.start, {
+ enumName,
+ memberName
+ });
+ }
+
+ seenNames.add(memberName);
+ const context = {
+ enumName,
+ explicitType,
+ memberName
+ };
+ memberNode.id = id;
+
+ switch (init.type) {
+ case "boolean":
+ {
+ this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "boolean");
+ memberNode.init = init.value;
+ members.booleanMembers.push(this.finishNode(memberNode, "EnumBooleanMember"));
+ break;
+ }
+
+ case "number":
+ {
+ this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "number");
+ memberNode.init = init.value;
+ members.numberMembers.push(this.finishNode(memberNode, "EnumNumberMember"));
+ break;
+ }
+
+ case "string":
+ {
+ this.flowEnumCheckExplicitTypeMismatch(init.pos, context, "string");
+ memberNode.init = init.value;
+ members.stringMembers.push(this.finishNode(memberNode, "EnumStringMember"));
+ break;
+ }
+
+ case "invalid":
+ {
+ throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);
+ }
+
+ case "none":
+ {
+ switch (explicitType) {
+ case "boolean":
+ this.flowEnumErrorBooleanMemberNotInitialized(init.pos, context);
+ break;
+
+ case "number":
+ this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);
+ break;
+
+ default:
+ members.defaultedMembers.push(this.finishNode(memberNode, "EnumDefaultedMember"));
+ }
+ }
+ }
+
+ if (!this.match(types.braceR)) {
+ this.expect(types.comma);
+ }
+ }
+
+ return {
+ members,
+ hasUnknownMembers
+ };
+ }
+
+ flowEnumStringMembers(initializedMembers, defaultedMembers, {
+ enumName
+ }) {
+ if (initializedMembers.length === 0) {
+ return defaultedMembers;
+ } else if (defaultedMembers.length === 0) {
+ return initializedMembers;
+ } else if (defaultedMembers.length > initializedMembers.length) {
+ for (const member of initializedMembers) {
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
+ enumName
+ });
+ }
+
+ return defaultedMembers;
+ } else {
+ for (const member of defaultedMembers) {
+ this.flowEnumErrorStringMemberInconsistentlyInitailized(member.start, {
+ enumName
+ });
+ }
+
+ return initializedMembers;
+ }
+ }
+
+ flowEnumParseExplicitType({
+ enumName
+ }) {
+ if (this.eatContextual("of")) {
+ if (!this.match(types.name)) {
+ throw this.flowEnumErrorInvalidExplicitType(this.state.start, {
+ enumName,
+ suppliedType: null
+ });
+ }
+
+ const {
+ value
+ } = this.state;
+ this.next();
+
+ if (value !== "boolean" && value !== "number" && value !== "string" && value !== "symbol") {
+ this.flowEnumErrorInvalidExplicitType(this.state.start, {
+ enumName,
+ suppliedType: value
+ });
+ }
+
+ return value;
+ }
+
+ return null;
+ }
+
+ flowEnumBody(node, {
+ enumName,
+ nameLoc
+ }) {
+ const explicitType = this.flowEnumParseExplicitType({
+ enumName
+ });
+ this.expect(types.braceL);
+ const {
+ members,
+ hasUnknownMembers
+ } = this.flowEnumMembers({
+ enumName,
+ explicitType
+ });
+ node.hasUnknownMembers = hasUnknownMembers;
+
+ switch (explicitType) {
+ case "boolean":
+ node.explicitType = true;
+ node.members = members.booleanMembers;
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumBooleanBody");
+
+ case "number":
+ node.explicitType = true;
+ node.members = members.numberMembers;
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumNumberBody");
+
+ case "string":
+ node.explicitType = true;
+ node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
+ enumName
+ });
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumStringBody");
+
+ case "symbol":
+ node.members = members.defaultedMembers;
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumSymbolBody");
+
+ default:
+ {
+ const empty = () => {
+ node.members = [];
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumStringBody");
+ };
+
+ node.explicitType = false;
+ const boolsLen = members.booleanMembers.length;
+ const numsLen = members.numberMembers.length;
+ const strsLen = members.stringMembers.length;
+ const defaultedLen = members.defaultedMembers.length;
+
+ if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {
+ return empty();
+ } else if (!boolsLen && !numsLen) {
+ node.members = this.flowEnumStringMembers(members.stringMembers, members.defaultedMembers, {
+ enumName
+ });
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumStringBody");
+ } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {
+ for (const member of members.defaultedMembers) {
+ this.flowEnumErrorBooleanMemberNotInitialized(member.start, {
+ enumName,
+ memberName: member.id.name
+ });
+ }
+
+ node.members = members.booleanMembers;
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumBooleanBody");
+ } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {
+ for (const member of members.defaultedMembers) {
+ this.flowEnumErrorNumberMemberNotInitialized(member.start, {
+ enumName,
+ memberName: member.id.name
+ });
+ }
+
+ node.members = members.numberMembers;
+ this.expect(types.braceR);
+ return this.finishNode(node, "EnumNumberBody");
+ } else {
+ this.flowEnumErrorInconsistentMemberValues(nameLoc, {
+ enumName
+ });
+ return empty();
+ }
+ }
+ }
+ }
+
+ flowParseEnumDeclaration(node) {
+ const id = this.parseIdentifier();
+ node.id = id;
+ node.body = this.flowEnumBody(this.startNode(), {
+ enumName: id.name,
+ nameLoc: id.start
+ });
+ return this.finishNode(node, "EnumDeclaration");
+ }
+
+ updateContext(prevType) {
+ if (this.match(types.name) && this.state.value === "of" && prevType === types.name && this.input.slice(this.state.lastTokStart, this.state.lastTokEnd) === "interface") {
+ this.state.exprAllowed = false;
+ } else {
+ super.updateContext(prevType);
+ }
+ }
+
+ isLookaheadToken_lt() {
+ const next = this.nextTokenStart();
+
+ if (this.input.charCodeAt(next) === 60) {
+ const afterNext = this.input.charCodeAt(next + 1);
+ return afterNext !== 60 && afterNext !== 61;
+ }
+
+ return false;
+ }
+
+ maybeUnwrapTypeCastExpression(node) {
+ return node.type === "TypeCastExpression" ? node.expression : node;
+ }
+
+ }, _temp;
+});
+
+const entities = {
+ quot: "\u0022",
+ amp: "&",
+ apos: "\u0027",
+ lt: "<",
+ gt: ">",
+ nbsp: "\u00A0",
+ iexcl: "\u00A1",
+ cent: "\u00A2",
+ pound: "\u00A3",
+ curren: "\u00A4",
+ yen: "\u00A5",
+ brvbar: "\u00A6",
+ sect: "\u00A7",
+ uml: "\u00A8",
+ copy: "\u00A9",
+ ordf: "\u00AA",
+ laquo: "\u00AB",
+ not: "\u00AC",
+ shy: "\u00AD",
+ reg: "\u00AE",
+ macr: "\u00AF",
+ deg: "\u00B0",
+ plusmn: "\u00B1",
+ sup2: "\u00B2",
+ sup3: "\u00B3",
+ acute: "\u00B4",
+ micro: "\u00B5",
+ para: "\u00B6",
+ middot: "\u00B7",
+ cedil: "\u00B8",
+ sup1: "\u00B9",
+ ordm: "\u00BA",
+ raquo: "\u00BB",
+ frac14: "\u00BC",
+ frac12: "\u00BD",
+ frac34: "\u00BE",
+ iquest: "\u00BF",
+ Agrave: "\u00C0",
+ Aacute: "\u00C1",
+ Acirc: "\u00C2",
+ Atilde: "\u00C3",
+ Auml: "\u00C4",
+ Aring: "\u00C5",
+ AElig: "\u00C6",
+ Ccedil: "\u00C7",
+ Egrave: "\u00C8",
+ Eacute: "\u00C9",
+ Ecirc: "\u00CA",
+ Euml: "\u00CB",
+ Igrave: "\u00CC",
+ Iacute: "\u00CD",
+ Icirc: "\u00CE",
+ Iuml: "\u00CF",
+ ETH: "\u00D0",
+ Ntilde: "\u00D1",
+ Ograve: "\u00D2",
+ Oacute: "\u00D3",
+ Ocirc: "\u00D4",
+ Otilde: "\u00D5",
+ Ouml: "\u00D6",
+ times: "\u00D7",
+ Oslash: "\u00D8",
+ Ugrave: "\u00D9",
+ Uacute: "\u00DA",
+ Ucirc: "\u00DB",
+ Uuml: "\u00DC",
+ Yacute: "\u00DD",
+ THORN: "\u00DE",
+ szlig: "\u00DF",
+ agrave: "\u00E0",
+ aacute: "\u00E1",
+ acirc: "\u00E2",
+ atilde: "\u00E3",
+ auml: "\u00E4",
+ aring: "\u00E5",
+ aelig: "\u00E6",
+ ccedil: "\u00E7",
+ egrave: "\u00E8",
+ eacute: "\u00E9",
+ ecirc: "\u00EA",
+ euml: "\u00EB",
+ igrave: "\u00EC",
+ iacute: "\u00ED",
+ icirc: "\u00EE",
+ iuml: "\u00EF",
+ eth: "\u00F0",
+ ntilde: "\u00F1",
+ ograve: "\u00F2",
+ oacute: "\u00F3",
+ ocirc: "\u00F4",
+ otilde: "\u00F5",
+ ouml: "\u00F6",
+ divide: "\u00F7",
+ oslash: "\u00F8",
+ ugrave: "\u00F9",
+ uacute: "\u00FA",
+ ucirc: "\u00FB",
+ uuml: "\u00FC",
+ yacute: "\u00FD",
+ thorn: "\u00FE",
+ yuml: "\u00FF",
+ OElig: "\u0152",
+ oelig: "\u0153",
+ Scaron: "\u0160",
+ scaron: "\u0161",
+ Yuml: "\u0178",
+ fnof: "\u0192",
+ circ: "\u02C6",
+ tilde: "\u02DC",
+ Alpha: "\u0391",
+ Beta: "\u0392",
+ Gamma: "\u0393",
+ Delta: "\u0394",
+ Epsilon: "\u0395",
+ Zeta: "\u0396",
+ Eta: "\u0397",
+ Theta: "\u0398",
+ Iota: "\u0399",
+ Kappa: "\u039A",
+ Lambda: "\u039B",
+ Mu: "\u039C",
+ Nu: "\u039D",
+ Xi: "\u039E",
+ Omicron: "\u039F",
+ Pi: "\u03A0",
+ Rho: "\u03A1",
+ Sigma: "\u03A3",
+ Tau: "\u03A4",
+ Upsilon: "\u03A5",
+ Phi: "\u03A6",
+ Chi: "\u03A7",
+ Psi: "\u03A8",
+ Omega: "\u03A9",
+ alpha: "\u03B1",
+ beta: "\u03B2",
+ gamma: "\u03B3",
+ delta: "\u03B4",
+ epsilon: "\u03B5",
+ zeta: "\u03B6",
+ eta: "\u03B7",
+ theta: "\u03B8",
+ iota: "\u03B9",
+ kappa: "\u03BA",
+ lambda: "\u03BB",
+ mu: "\u03BC",
+ nu: "\u03BD",
+ xi: "\u03BE",
+ omicron: "\u03BF",
+ pi: "\u03C0",
+ rho: "\u03C1",
+ sigmaf: "\u03C2",
+ sigma: "\u03C3",
+ tau: "\u03C4",
+ upsilon: "\u03C5",
+ phi: "\u03C6",
+ chi: "\u03C7",
+ psi: "\u03C8",
+ omega: "\u03C9",
+ thetasym: "\u03D1",
+ upsih: "\u03D2",
+ piv: "\u03D6",
+ ensp: "\u2002",
+ emsp: "\u2003",
+ thinsp: "\u2009",
+ zwnj: "\u200C",
+ zwj: "\u200D",
+ lrm: "\u200E",
+ rlm: "\u200F",
+ ndash: "\u2013",
+ mdash: "\u2014",
+ lsquo: "\u2018",
+ rsquo: "\u2019",
+ sbquo: "\u201A",
+ ldquo: "\u201C",
+ rdquo: "\u201D",
+ bdquo: "\u201E",
+ dagger: "\u2020",
+ Dagger: "\u2021",
+ bull: "\u2022",
+ hellip: "\u2026",
+ permil: "\u2030",
+ prime: "\u2032",
+ Prime: "\u2033",
+ lsaquo: "\u2039",
+ rsaquo: "\u203A",
+ oline: "\u203E",
+ frasl: "\u2044",
+ euro: "\u20AC",
+ image: "\u2111",
+ weierp: "\u2118",
+ real: "\u211C",
+ trade: "\u2122",
+ alefsym: "\u2135",
+ larr: "\u2190",
+ uarr: "\u2191",
+ rarr: "\u2192",
+ darr: "\u2193",
+ harr: "\u2194",
+ crarr: "\u21B5",
+ lArr: "\u21D0",
+ uArr: "\u21D1",
+ rArr: "\u21D2",
+ dArr: "\u21D3",
+ hArr: "\u21D4",
+ forall: "\u2200",
+ part: "\u2202",
+ exist: "\u2203",
+ empty: "\u2205",
+ nabla: "\u2207",
+ isin: "\u2208",
+ notin: "\u2209",
+ ni: "\u220B",
+ prod: "\u220F",
+ sum: "\u2211",
+ minus: "\u2212",
+ lowast: "\u2217",
+ radic: "\u221A",
+ prop: "\u221D",
+ infin: "\u221E",
+ ang: "\u2220",
+ and: "\u2227",
+ or: "\u2228",
+ cap: "\u2229",
+ cup: "\u222A",
+ int: "\u222B",
+ there4: "\u2234",
+ sim: "\u223C",
+ cong: "\u2245",
+ asymp: "\u2248",
+ ne: "\u2260",
+ equiv: "\u2261",
+ le: "\u2264",
+ ge: "\u2265",
+ sub: "\u2282",
+ sup: "\u2283",
+ nsub: "\u2284",
+ sube: "\u2286",
+ supe: "\u2287",
+ oplus: "\u2295",
+ otimes: "\u2297",
+ perp: "\u22A5",
+ sdot: "\u22C5",
+ lceil: "\u2308",
+ rceil: "\u2309",
+ lfloor: "\u230A",
+ rfloor: "\u230B",
+ lang: "\u2329",
+ rang: "\u232A",
+ loz: "\u25CA",
+ spades: "\u2660",
+ clubs: "\u2663",
+ hearts: "\u2665",
+ diams: "\u2666"
+};
+
+const HEX_NUMBER = /^[\da-fA-F]+$/;
+const DECIMAL_NUMBER = /^\d+$/;
+const JsxErrors = Object.freeze({
+ AttributeIsEmpty: "JSX attributes must only be assigned a non-empty expression",
+ MissingClosingTagFragment: "Expected corresponding JSX closing tag for <>",
+ MissingClosingTagElement: "Expected corresponding JSX closing tag for <%0>",
+ UnexpectedSequenceExpression: "Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?",
+ UnsupportedJsxValue: "JSX value should be either an expression or a quoted JSX text",
+ UnterminatedJsxContent: "Unterminated JSX contents",
+ UnwrappedAdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...>?"
+});
+types$1.j_oTag = new TokContext("...", true, true);
+types.jsxName = new TokenType("jsxName");
+types.jsxText = new TokenType("jsxText", {
+ beforeExpr: true
+});
+types.jsxTagStart = new TokenType("jsxTagStart", {
+ startsExpr: true
+});
+types.jsxTagEnd = new TokenType("jsxTagEnd");
+
+types.jsxTagStart.updateContext = function () {
+ this.state.context.push(types$1.j_expr);
+ this.state.context.push(types$1.j_oTag);
+ this.state.exprAllowed = false;
+};
+
+types.jsxTagEnd.updateContext = function (prevType) {
+ const out = this.state.context.pop();
+
+ if (out === types$1.j_oTag && prevType === types.slash || out === types$1.j_cTag) {
+ this.state.context.pop();
+ this.state.exprAllowed = this.curContext() === types$1.j_expr;
+ } else {
+ this.state.exprAllowed = true;
+ }
+};
+
+function isFragment(object) {
+ return object ? object.type === "JSXOpeningFragment" || object.type === "JSXClosingFragment" : false;
+}
+
+function getQualifiedJSXName(object) {
+ if (object.type === "JSXIdentifier") {
+ return object.name;
+ }
+
+ if (object.type === "JSXNamespacedName") {
+ return object.namespace.name + ":" + object.name.name;
+ }
+
+ if (object.type === "JSXMemberExpression") {
+ return getQualifiedJSXName(object.object) + "." + getQualifiedJSXName(object.property);
+ }
+
+ throw new Error("Node had unexpected type: " + object.type);
+}
+
+var jsx = (superClass => class extends superClass {
+ jsxReadToken() {
+ let out = "";
+ let chunkStart = this.state.pos;
+
+ for (;;) {
+ if (this.state.pos >= this.length) {
+ throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);
+ }
+
+ const ch = this.input.charCodeAt(this.state.pos);
+
+ switch (ch) {
+ case 60:
+ case 123:
+ if (this.state.pos === this.state.start) {
+ if (ch === 60 && this.state.exprAllowed) {
+ ++this.state.pos;
+ return this.finishToken(types.jsxTagStart);
+ }
+
+ return super.getTokenFromCode(ch);
+ }
+
+ out += this.input.slice(chunkStart, this.state.pos);
+ return this.finishToken(types.jsxText, out);
+
+ case 38:
+ out += this.input.slice(chunkStart, this.state.pos);
+ out += this.jsxReadEntity();
+ chunkStart = this.state.pos;
+ break;
+
+ case 62:
+ case 125:
+
+ default:
+ if (isNewLine(ch)) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ out += this.jsxReadNewLine(true);
+ chunkStart = this.state.pos;
+ } else {
+ ++this.state.pos;
+ }
+
+ }
+ }
+ }
+
+ jsxReadNewLine(normalizeCRLF) {
+ const ch = this.input.charCodeAt(this.state.pos);
+ let out;
+ ++this.state.pos;
+
+ if (ch === 13 && this.input.charCodeAt(this.state.pos) === 10) {
+ ++this.state.pos;
+ out = normalizeCRLF ? "\n" : "\r\n";
+ } else {
+ out = String.fromCharCode(ch);
+ }
+
+ ++this.state.curLine;
+ this.state.lineStart = this.state.pos;
+ return out;
+ }
+
+ jsxReadString(quote) {
+ let out = "";
+ let chunkStart = ++this.state.pos;
+
+ for (;;) {
+ if (this.state.pos >= this.length) {
+ throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
+ }
+
+ const ch = this.input.charCodeAt(this.state.pos);
+ if (ch === quote) break;
+
+ if (ch === 38) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ out += this.jsxReadEntity();
+ chunkStart = this.state.pos;
+ } else if (isNewLine(ch)) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ out += this.jsxReadNewLine(false);
+ chunkStart = this.state.pos;
+ } else {
+ ++this.state.pos;
+ }
+ }
+
+ out += this.input.slice(chunkStart, this.state.pos++);
+ return this.finishToken(types.string, out);
+ }
+
+ jsxReadEntity() {
+ let str = "";
+ let count = 0;
+ let entity;
+ let ch = this.input[this.state.pos];
+ const startPos = ++this.state.pos;
+
+ while (this.state.pos < this.length && count++ < 10) {
+ ch = this.input[this.state.pos++];
+
+ if (ch === ";") {
+ if (str[0] === "#") {
+ if (str[1] === "x") {
+ str = str.substr(2);
+
+ if (HEX_NUMBER.test(str)) {
+ entity = String.fromCodePoint(parseInt(str, 16));
+ }
+ } else {
+ str = str.substr(1);
+
+ if (DECIMAL_NUMBER.test(str)) {
+ entity = String.fromCodePoint(parseInt(str, 10));
+ }
+ }
+ } else {
+ entity = entities[str];
+ }
+
+ break;
+ }
+
+ str += ch;
+ }
+
+ if (!entity) {
+ this.state.pos = startPos;
+ return "&";
+ }
+
+ return entity;
+ }
+
+ jsxReadWord() {
+ let ch;
+ const start = this.state.pos;
+
+ do {
+ ch = this.input.charCodeAt(++this.state.pos);
+ } while (isIdentifierChar(ch) || ch === 45);
+
+ return this.finishToken(types.jsxName, this.input.slice(start, this.state.pos));
+ }
+
+ jsxParseIdentifier() {
+ const node = this.startNode();
+
+ if (this.match(types.jsxName)) {
+ node.name = this.state.value;
+ } else if (this.state.type.keyword) {
+ node.name = this.state.type.keyword;
+ } else {
+ this.unexpected();
+ }
+
+ this.next();
+ return this.finishNode(node, "JSXIdentifier");
+ }
+
+ jsxParseNamespacedName() {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const name = this.jsxParseIdentifier();
+ if (!this.eat(types.colon)) return name;
+ const node = this.startNodeAt(startPos, startLoc);
+ node.namespace = name;
+ node.name = this.jsxParseIdentifier();
+ return this.finishNode(node, "JSXNamespacedName");
+ }
+
+ jsxParseElementName() {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ let node = this.jsxParseNamespacedName();
+
+ if (node.type === "JSXNamespacedName") {
+ return node;
+ }
+
+ while (this.eat(types.dot)) {
+ const newNode = this.startNodeAt(startPos, startLoc);
+ newNode.object = node;
+ newNode.property = this.jsxParseIdentifier();
+ node = this.finishNode(newNode, "JSXMemberExpression");
+ }
+
+ return node;
+ }
+
+ jsxParseAttributeValue() {
+ let node;
+
+ switch (this.state.type) {
+ case types.braceL:
+ node = this.startNode();
+ this.next();
+ node = this.jsxParseExpressionContainer(node);
+
+ if (node.expression.type === "JSXEmptyExpression") {
+ this.raise(node.start, JsxErrors.AttributeIsEmpty);
+ }
+
+ return node;
+
+ case types.jsxTagStart:
+ case types.string:
+ return this.parseExprAtom();
+
+ default:
+ throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);
+ }
+ }
+
+ jsxParseEmptyExpression() {
+ const node = this.startNodeAt(this.state.lastTokEnd, this.state.lastTokEndLoc);
+ return this.finishNodeAt(node, "JSXEmptyExpression", this.state.start, this.state.startLoc);
+ }
+
+ jsxParseSpreadChild(node) {
+ this.next();
+ node.expression = this.parseExpression();
+ this.expect(types.braceR);
+ return this.finishNode(node, "JSXSpreadChild");
+ }
+
+ jsxParseExpressionContainer(node) {
+ if (this.match(types.braceR)) {
+ node.expression = this.jsxParseEmptyExpression();
+ } else {
+ const expression = this.parseExpression();
+ node.expression = expression;
+ }
+
+ this.expect(types.braceR);
+ return this.finishNode(node, "JSXExpressionContainer");
+ }
+
+ jsxParseAttribute() {
+ const node = this.startNode();
+
+ if (this.eat(types.braceL)) {
+ this.expect(types.ellipsis);
+ node.argument = this.parseMaybeAssignAllowIn();
+ this.expect(types.braceR);
+ return this.finishNode(node, "JSXSpreadAttribute");
+ }
+
+ node.name = this.jsxParseNamespacedName();
+ node.value = this.eat(types.eq) ? this.jsxParseAttributeValue() : null;
+ return this.finishNode(node, "JSXAttribute");
+ }
+
+ jsxParseOpeningElementAt(startPos, startLoc) {
+ const node = this.startNodeAt(startPos, startLoc);
+
+ if (this.match(types.jsxTagEnd)) {
+ this.expect(types.jsxTagEnd);
+ return this.finishNode(node, "JSXOpeningFragment");
+ }
+
+ node.name = this.jsxParseElementName();
+ return this.jsxParseOpeningElementAfterName(node);
+ }
+
+ jsxParseOpeningElementAfterName(node) {
+ const attributes = [];
+
+ while (!this.match(types.slash) && !this.match(types.jsxTagEnd)) {
+ attributes.push(this.jsxParseAttribute());
+ }
+
+ node.attributes = attributes;
+ node.selfClosing = this.eat(types.slash);
+ this.expect(types.jsxTagEnd);
+ return this.finishNode(node, "JSXOpeningElement");
+ }
+
+ jsxParseClosingElementAt(startPos, startLoc) {
+ const node = this.startNodeAt(startPos, startLoc);
+
+ if (this.match(types.jsxTagEnd)) {
+ this.expect(types.jsxTagEnd);
+ return this.finishNode(node, "JSXClosingFragment");
+ }
+
+ node.name = this.jsxParseElementName();
+ this.expect(types.jsxTagEnd);
+ return this.finishNode(node, "JSXClosingElement");
+ }
+
+ jsxParseElementAt(startPos, startLoc) {
+ const node = this.startNodeAt(startPos, startLoc);
+ const children = [];
+ const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);
+ let closingElement = null;
+
+ if (!openingElement.selfClosing) {
+ contents: for (;;) {
+ switch (this.state.type) {
+ case types.jsxTagStart:
+ startPos = this.state.start;
+ startLoc = this.state.startLoc;
+ this.next();
+
+ if (this.eat(types.slash)) {
+ closingElement = this.jsxParseClosingElementAt(startPos, startLoc);
+ break contents;
+ }
+
+ children.push(this.jsxParseElementAt(startPos, startLoc));
+ break;
+
+ case types.jsxText:
+ children.push(this.parseExprAtom());
+ break;
+
+ case types.braceL:
+ {
+ const node = this.startNode();
+ this.next();
+
+ if (this.match(types.ellipsis)) {
+ children.push(this.jsxParseSpreadChild(node));
+ } else {
+ children.push(this.jsxParseExpressionContainer(node));
+ }
+
+ break;
+ }
+
+ default:
+ throw this.unexpected();
+ }
+ }
+
+ if (isFragment(openingElement) && !isFragment(closingElement)) {
+ this.raise(closingElement.start, JsxErrors.MissingClosingTagFragment);
+ } else if (!isFragment(openingElement) && isFragment(closingElement)) {
+ this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
+ } else if (!isFragment(openingElement) && !isFragment(closingElement)) {
+ if (getQualifiedJSXName(closingElement.name) !== getQualifiedJSXName(openingElement.name)) {
+ this.raise(closingElement.start, JsxErrors.MissingClosingTagElement, getQualifiedJSXName(openingElement.name));
+ }
+ }
+ }
+
+ if (isFragment(openingElement)) {
+ node.openingFragment = openingElement;
+ node.closingFragment = closingElement;
+ } else {
+ node.openingElement = openingElement;
+ node.closingElement = closingElement;
+ }
+
+ node.children = children;
+
+ if (this.isRelational("<")) {
+ throw this.raise(this.state.start, JsxErrors.UnwrappedAdjacentJSXElements);
+ }
+
+ return isFragment(openingElement) ? this.finishNode(node, "JSXFragment") : this.finishNode(node, "JSXElement");
+ }
+
+ jsxParseElement() {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ this.next();
+ return this.jsxParseElementAt(startPos, startLoc);
+ }
+
+ parseExprAtom(refExpressionErrors) {
+ if (this.match(types.jsxText)) {
+ return this.parseLiteral(this.state.value, "JSXText");
+ } else if (this.match(types.jsxTagStart)) {
+ return this.jsxParseElement();
+ } else if (this.isRelational("<") && this.input.charCodeAt(this.state.pos) !== 33) {
+ this.finishToken(types.jsxTagStart);
+ return this.jsxParseElement();
+ } else {
+ return super.parseExprAtom(refExpressionErrors);
+ }
+ }
+
+ getTokenFromCode(code) {
+ if (this.state.inPropertyName) return super.getTokenFromCode(code);
+ const context = this.curContext();
+
+ if (context === types$1.j_expr) {
+ return this.jsxReadToken();
+ }
+
+ if (context === types$1.j_oTag || context === types$1.j_cTag) {
+ if (isIdentifierStart(code)) {
+ return this.jsxReadWord();
+ }
+
+ if (code === 62) {
+ ++this.state.pos;
+ return this.finishToken(types.jsxTagEnd);
+ }
+
+ if ((code === 34 || code === 39) && context === types$1.j_oTag) {
+ return this.jsxReadString(code);
+ }
+ }
+
+ if (code === 60 && this.state.exprAllowed && this.input.charCodeAt(this.state.pos + 1) !== 33) {
+ ++this.state.pos;
+ return this.finishToken(types.jsxTagStart);
+ }
+
+ return super.getTokenFromCode(code);
+ }
+
+ updateContext(prevType) {
+ if (this.match(types.braceL)) {
+ const curContext = this.curContext();
+
+ if (curContext === types$1.j_oTag) {
+ this.state.context.push(types$1.braceExpression);
+ } else if (curContext === types$1.j_expr) {
+ this.state.context.push(types$1.templateQuasi);
+ } else {
+ super.updateContext(prevType);
+ }
+
+ this.state.exprAllowed = true;
+ } else if (this.match(types.slash) && prevType === types.jsxTagStart) {
+ this.state.context.length -= 2;
+ this.state.context.push(types$1.j_cTag);
+ this.state.exprAllowed = false;
+ } else {
+ return super.updateContext(prevType);
+ }
+ }
+
+});
+
+class TypeScriptScope extends Scope {
+ constructor(...args) {
+ super(...args);
+ this.types = [];
+ this.enums = [];
+ this.constEnums = [];
+ this.classes = [];
+ this.exportOnlyBindings = [];
+ }
+
+}
+
+class TypeScriptScopeHandler extends ScopeHandler {
+ createScope(flags) {
+ return new TypeScriptScope(flags);
+ }
+
+ declareName(name, bindingType, pos) {
+ const scope = this.currentScope();
+
+ if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {
+ this.maybeExportDefined(scope, name);
+ scope.exportOnlyBindings.push(name);
+ return;
+ }
+
+ super.declareName(...arguments);
+
+ if (bindingType & BIND_KIND_TYPE) {
+ if (!(bindingType & BIND_KIND_VALUE)) {
+ this.checkRedeclarationInScope(scope, name, bindingType, pos);
+ this.maybeExportDefined(scope, name);
+ }
+
+ scope.types.push(name);
+ }
+
+ if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name);
+ if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);
+ if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name);
+ }
+
+ isRedeclaredInScope(scope, name, bindingType) {
+ if (scope.enums.indexOf(name) > -1) {
+ if (bindingType & BIND_FLAGS_TS_ENUM) {
+ const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);
+ const wasConst = scope.constEnums.indexOf(name) > -1;
+ return isConst !== wasConst;
+ }
+
+ return true;
+ }
+
+ if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {
+ if (scope.lexical.indexOf(name) > -1) {
+ return !!(bindingType & BIND_KIND_VALUE);
+ } else {
+ return false;
+ }
+ }
+
+ if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {
+ return true;
+ }
+
+ return super.isRedeclaredInScope(...arguments);
+ }
+
+ checkLocalExport(id) {
+ if (this.scopeStack[0].types.indexOf(id.name) === -1 && this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1) {
+ super.checkLocalExport(id);
+ }
+ }
+
+}
+
+const PARAM = 0b0000,
+ PARAM_YIELD = 0b0001,
+ PARAM_AWAIT = 0b0010,
+ PARAM_RETURN = 0b0100,
+ PARAM_IN = 0b1000;
+class ProductionParameterHandler {
+ constructor() {
+ this.stacks = [];
+ }
+
+ enter(flags) {
+ this.stacks.push(flags);
+ }
+
+ exit() {
+ this.stacks.pop();
+ }
+
+ currentFlags() {
+ return this.stacks[this.stacks.length - 1];
+ }
+
+ get hasAwait() {
+ return (this.currentFlags() & PARAM_AWAIT) > 0;
+ }
+
+ get hasYield() {
+ return (this.currentFlags() & PARAM_YIELD) > 0;
+ }
+
+ get hasReturn() {
+ return (this.currentFlags() & PARAM_RETURN) > 0;
+ }
+
+ get hasIn() {
+ return (this.currentFlags() & PARAM_IN) > 0;
+ }
+
+}
+function functionFlags(isAsync, isGenerator) {
+ return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);
+}
+
+function nonNull(x) {
+ if (x == null) {
+ throw new Error(`Unexpected ${x} value.`);
+ }
+
+ return x;
+}
+
+function assert(x) {
+ if (!x) {
+ throw new Error("Assert fail");
+ }
+}
+
+const TSErrors = Object.freeze({
+ ClassMethodHasDeclare: "Class methods cannot have the 'declare' modifier",
+ ClassMethodHasReadonly: "Class methods cannot have the 'readonly' modifier",
+ ConstructorHasTypeParameters: "Type parameters cannot appear on a constructor declaration.",
+ DeclareClassFieldHasInitializer: "Initializers are not allowed in ambient contexts.",
+ DeclareFunctionHasImplementation: "An implementation cannot be declared in ambient contexts.",
+ DuplicateModifier: "Duplicate modifier: '%0'",
+ DuplicateAccessibilityModifier: "Accessibility modifier already seen.",
+ EmptyHeritageClauseType: "'%0' list cannot be empty.",
+ EmptyTypeArguments: "Type argument list cannot be empty.",
+ EmptyTypeParameters: "Type parameter list cannot be empty.",
+ ExpectedAmbientAfterExportDeclare: "'export declare' must be followed by an ambient declaration.",
+ IndexSignatureHasAbstract: "Index signatures cannot have the 'abstract' modifier",
+ IndexSignatureHasAccessibility: "Index signatures cannot have an accessibility modifier ('%0')",
+ IndexSignatureHasStatic: "Index signatures cannot have the 'static' modifier",
+ IndexSignatureHasDeclare: "Index signatures cannot have the 'declare' modifier",
+ InvalidModifierOnTypeMember: "'%0' modifier cannot appear on a type member.",
+ InvalidTupleMemberLabel: "Tuple members must be labeled with a simple identifier.",
+ MixedLabeledAndUnlabeledElements: "Tuple members must all have names or all not have names.",
+ NonAbstractClassHasAbstractMethod: "Abstract methods can only appear within an abstract class.",
+ NonClassMethodPropertyHasAbstractModifer: "'abstract' modifier can only appear on a class, method, or property declaration.",
+ OptionalTypeBeforeRequired: "A required element cannot follow an optional element.",
+ PatternIsOptional: "A binding pattern parameter cannot be optional in an implementation signature.",
+ PrivateElementHasAbstract: "Private elements cannot have the 'abstract' modifier.",
+ PrivateElementHasAccessibility: "Private elements cannot have an accessibility modifier ('%0')",
+ ReadonlyForMethodSignature: "'readonly' modifier can only appear on a property declaration or index signature.",
+ TypeAnnotationAfterAssign: "Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`",
+ UnexpectedParameterModifier: "A parameter property is only allowed in a constructor implementation.",
+ UnexpectedReadonly: "'readonly' type modifier is only permitted on array and tuple literal types.",
+ UnexpectedTypeAnnotation: "Did not expect a type annotation here.",
+ UnexpectedTypeCastInParameter: "Unexpected type cast in parameter position.",
+ UnsupportedImportTypeArgument: "Argument in a type import must be a string literal",
+ UnsupportedParameterPropertyKind: "A parameter property may not be declared using a binding pattern.",
+ UnsupportedSignatureParameterKind: "Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0"
+});
+
+function keywordTypeFromName(value) {
+ switch (value) {
+ case "any":
+ return "TSAnyKeyword";
+
+ case "boolean":
+ return "TSBooleanKeyword";
+
+ case "bigint":
+ return "TSBigIntKeyword";
+
+ case "never":
+ return "TSNeverKeyword";
+
+ case "number":
+ return "TSNumberKeyword";
+
+ case "object":
+ return "TSObjectKeyword";
+
+ case "string":
+ return "TSStringKeyword";
+
+ case "symbol":
+ return "TSSymbolKeyword";
+
+ case "undefined":
+ return "TSUndefinedKeyword";
+
+ case "unknown":
+ return "TSUnknownKeyword";
+
+ default:
+ return undefined;
+ }
+}
+
+function tsIsAccessModifier(modifier) {
+ return modifier === "private" || modifier === "public" || modifier === "protected";
+}
+
+var typescript = (superClass => class extends superClass {
+ getScopeHandler() {
+ return TypeScriptScopeHandler;
+ }
+
+ tsIsIdentifier() {
+ return this.match(types.name);
+ }
+
+ tsNextTokenCanFollowModifier() {
+ this.next();
+ return (this.match(types.bracketL) || this.match(types.braceL) || this.match(types.star) || this.match(types.ellipsis) || this.match(types.hash) || this.isLiteralPropertyName()) && !this.hasPrecedingLineBreak();
+ }
+
+ tsParseModifier(allowedModifiers) {
+ if (!this.match(types.name)) {
+ return undefined;
+ }
+
+ const modifier = this.state.value;
+
+ if (allowedModifiers.indexOf(modifier) !== -1 && this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))) {
+ return modifier;
+ }
+
+ return undefined;
+ }
+
+ tsParseModifiers(modified, allowedModifiers, disallowedModifiers, errorTemplate) {
+ for (;;) {
+ const startPos = this.state.start;
+ const modifier = this.tsParseModifier(allowedModifiers.concat(disallowedModifiers != null ? disallowedModifiers : []));
+ if (!modifier) break;
+
+ if (tsIsAccessModifier(modifier)) {
+ if (modified.accessibility) {
+ this.raise(startPos, TSErrors.DuplicateAccessibilityModifier);
+ } else {
+ modified.accessibility = modifier;
+ }
+ } else {
+ if (Object.hasOwnProperty.call(modified, modifier)) {
+ this.raise(startPos, TSErrors.DuplicateModifier, modifier);
+ }
+
+ modified[modifier] = true;
+ }
+
+ if (disallowedModifiers != null && disallowedModifiers.includes(modifier)) {
+ this.raise(startPos, errorTemplate, modifier);
+ }
+ }
+ }
+
+ tsIsListTerminator(kind) {
+ switch (kind) {
+ case "EnumMembers":
+ case "TypeMembers":
+ return this.match(types.braceR);
+
+ case "HeritageClauseElement":
+ return this.match(types.braceL);
+
+ case "TupleElementTypes":
+ return this.match(types.bracketR);
+
+ case "TypeParametersOrArguments":
+ return this.isRelational(">");
+ }
+
+ throw new Error("Unreachable");
+ }
+
+ tsParseList(kind, parseElement) {
+ const result = [];
+
+ while (!this.tsIsListTerminator(kind)) {
+ result.push(parseElement());
+ }
+
+ return result;
+ }
+
+ tsParseDelimitedList(kind, parseElement) {
+ return nonNull(this.tsParseDelimitedListWorker(kind, parseElement, true));
+ }
+
+ tsParseDelimitedListWorker(kind, parseElement, expectSuccess) {
+ const result = [];
+
+ for (;;) {
+ if (this.tsIsListTerminator(kind)) {
+ break;
+ }
+
+ const element = parseElement();
+
+ if (element == null) {
+ return undefined;
+ }
+
+ result.push(element);
+
+ if (this.eat(types.comma)) {
+ continue;
+ }
+
+ if (this.tsIsListTerminator(kind)) {
+ break;
+ }
+
+ if (expectSuccess) {
+ this.expect(types.comma);
+ }
+
+ return undefined;
+ }
+
+ return result;
+ }
+
+ tsParseBracketedList(kind, parseElement, bracket, skipFirstToken) {
+ if (!skipFirstToken) {
+ if (bracket) {
+ this.expect(types.bracketL);
+ } else {
+ this.expectRelational("<");
+ }
+ }
+
+ const result = this.tsParseDelimitedList(kind, parseElement);
+
+ if (bracket) {
+ this.expect(types.bracketR);
+ } else {
+ this.expectRelational(">");
+ }
+
+ return result;
+ }
+
+ tsParseImportType() {
+ const node = this.startNode();
+ this.expect(types._import);
+ this.expect(types.parenL);
+
+ if (!this.match(types.string)) {
+ this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);
+ }
+
+ node.argument = this.parseExprAtom();
+ this.expect(types.parenR);
+
+ if (this.eat(types.dot)) {
+ node.qualifier = this.tsParseEntityName(true);
+ }
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.tsParseTypeArguments();
+ }
+
+ return this.finishNode(node, "TSImportType");
+ }
+
+ tsParseEntityName(allowReservedWords) {
+ let entity = this.parseIdentifier();
+
+ while (this.eat(types.dot)) {
+ const node = this.startNodeAtNode(entity);
+ node.left = entity;
+ node.right = this.parseIdentifier(allowReservedWords);
+ entity = this.finishNode(node, "TSQualifiedName");
+ }
+
+ return entity;
+ }
+
+ tsParseTypeReference() {
+ const node = this.startNode();
+ node.typeName = this.tsParseEntityName(false);
+
+ if (!this.hasPrecedingLineBreak() && this.isRelational("<")) {
+ node.typeParameters = this.tsParseTypeArguments();
+ }
+
+ return this.finishNode(node, "TSTypeReference");
+ }
+
+ tsParseThisTypePredicate(lhs) {
+ this.next();
+ const node = this.startNodeAtNode(lhs);
+ node.parameterName = lhs;
+ node.typeAnnotation = this.tsParseTypeAnnotation(false);
+ node.asserts = false;
+ return this.finishNode(node, "TSTypePredicate");
+ }
+
+ tsParseThisTypeNode() {
+ const node = this.startNode();
+ this.next();
+ return this.finishNode(node, "TSThisType");
+ }
+
+ tsParseTypeQuery() {
+ const node = this.startNode();
+ this.expect(types._typeof);
+
+ if (this.match(types._import)) {
+ node.exprName = this.tsParseImportType();
+ } else {
+ node.exprName = this.tsParseEntityName(true);
+ }
+
+ return this.finishNode(node, "TSTypeQuery");
+ }
+
+ tsParseTypeParameter() {
+ const node = this.startNode();
+ node.name = this.parseIdentifierName(node.start);
+ node.constraint = this.tsEatThenParseType(types._extends);
+ node.default = this.tsEatThenParseType(types.eq);
+ return this.finishNode(node, "TSTypeParameter");
+ }
+
+ tsTryParseTypeParameters() {
+ if (this.isRelational("<")) {
+ return this.tsParseTypeParameters();
+ }
+ }
+
+ tsParseTypeParameters() {
+ const node = this.startNode();
+
+ if (this.isRelational("<") || this.match(types.jsxTagStart)) {
+ this.next();
+ } else {
+ this.unexpected();
+ }
+
+ node.params = this.tsParseBracketedList("TypeParametersOrArguments", this.tsParseTypeParameter.bind(this), false, true);
+
+ if (node.params.length === 0) {
+ this.raise(node.start, TSErrors.EmptyTypeParameters);
+ }
+
+ return this.finishNode(node, "TSTypeParameterDeclaration");
+ }
+
+ tsTryNextParseConstantContext() {
+ if (this.lookahead().type === types._const) {
+ this.next();
+ return this.tsParseTypeReference();
+ }
+
+ return null;
+ }
+
+ tsFillSignature(returnToken, signature) {
+ const returnTokenRequired = returnToken === types.arrow;
+ signature.typeParameters = this.tsTryParseTypeParameters();
+ this.expect(types.parenL);
+ signature.parameters = this.tsParseBindingListForSignature();
+
+ if (returnTokenRequired) {
+ signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
+ } else if (this.match(returnToken)) {
+ signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(returnToken);
+ }
+ }
+
+ tsParseBindingListForSignature() {
+ return this.parseBindingList(types.parenR, 41).map(pattern => {
+ if (pattern.type !== "Identifier" && pattern.type !== "RestElement" && pattern.type !== "ObjectPattern" && pattern.type !== "ArrayPattern") {
+ this.raise(pattern.start, TSErrors.UnsupportedSignatureParameterKind, pattern.type);
+ }
+
+ return pattern;
+ });
+ }
+
+ tsParseTypeMemberSemicolon() {
+ if (!this.eat(types.comma)) {
+ this.semicolon();
+ }
+ }
+
+ tsParseSignatureMember(kind, node) {
+ this.tsFillSignature(types.colon, node);
+ this.tsParseTypeMemberSemicolon();
+ return this.finishNode(node, kind);
+ }
+
+ tsIsUnambiguouslyIndexSignature() {
+ this.next();
+ return this.eat(types.name) && this.match(types.colon);
+ }
+
+ tsTryParseIndexSignature(node) {
+ if (!(this.match(types.bracketL) && this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this)))) {
+ return undefined;
+ }
+
+ this.expect(types.bracketL);
+ const id = this.parseIdentifier();
+ id.typeAnnotation = this.tsParseTypeAnnotation();
+ this.resetEndLocation(id);
+ this.expect(types.bracketR);
+ node.parameters = [id];
+ const type = this.tsTryParseTypeAnnotation();
+ if (type) node.typeAnnotation = type;
+ this.tsParseTypeMemberSemicolon();
+ return this.finishNode(node, "TSIndexSignature");
+ }
+
+ tsParsePropertyOrMethodSignature(node, readonly) {
+ if (this.eat(types.question)) node.optional = true;
+ const nodeAny = node;
+
+ if (this.match(types.parenL) || this.isRelational("<")) {
+ if (readonly) {
+ this.raise(node.start, TSErrors.ReadonlyForMethodSignature);
+ }
+
+ const method = nodeAny;
+ this.tsFillSignature(types.colon, method);
+ this.tsParseTypeMemberSemicolon();
+ return this.finishNode(method, "TSMethodSignature");
+ } else {
+ const property = nodeAny;
+ if (readonly) property.readonly = true;
+ const type = this.tsTryParseTypeAnnotation();
+ if (type) property.typeAnnotation = type;
+ this.tsParseTypeMemberSemicolon();
+ return this.finishNode(property, "TSPropertySignature");
+ }
+ }
+
+ tsParseTypeMember() {
+ const node = this.startNode();
+
+ if (this.match(types.parenL) || this.isRelational("<")) {
+ return this.tsParseSignatureMember("TSCallSignatureDeclaration", node);
+ }
+
+ if (this.match(types._new)) {
+ const id = this.startNode();
+ this.next();
+
+ if (this.match(types.parenL) || this.isRelational("<")) {
+ return this.tsParseSignatureMember("TSConstructSignatureDeclaration", node);
+ } else {
+ node.key = this.createIdentifier(id, "new");
+ return this.tsParsePropertyOrMethodSignature(node, false);
+ }
+ }
+
+ this.tsParseModifiers(node, ["readonly"], ["declare", "abstract", "private", "protected", "public", "static"], TSErrors.InvalidModifierOnTypeMember);
+ const idx = this.tsTryParseIndexSignature(node);
+
+ if (idx) {
+ return idx;
+ }
+
+ this.parsePropertyName(node, false);
+ return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);
+ }
+
+ tsParseTypeLiteral() {
+ const node = this.startNode();
+ node.members = this.tsParseObjectTypeMembers();
+ return this.finishNode(node, "TSTypeLiteral");
+ }
+
+ tsParseObjectTypeMembers() {
+ this.expect(types.braceL);
+ const members = this.tsParseList("TypeMembers", this.tsParseTypeMember.bind(this));
+ this.expect(types.braceR);
+ return members;
+ }
+
+ tsIsStartOfMappedType() {
+ this.next();
+
+ if (this.eat(types.plusMin)) {
+ return this.isContextual("readonly");
+ }
+
+ if (this.isContextual("readonly")) {
+ this.next();
+ }
+
+ if (!this.match(types.bracketL)) {
+ return false;
+ }
+
+ this.next();
+
+ if (!this.tsIsIdentifier()) {
+ return false;
+ }
+
+ this.next();
+ return this.match(types._in);
+ }
+
+ tsParseMappedTypeParameter() {
+ const node = this.startNode();
+ node.name = this.parseIdentifierName(node.start);
+ node.constraint = this.tsExpectThenParseType(types._in);
+ return this.finishNode(node, "TSTypeParameter");
+ }
+
+ tsParseMappedType() {
+ const node = this.startNode();
+ this.expect(types.braceL);
+
+ if (this.match(types.plusMin)) {
+ node.readonly = this.state.value;
+ this.next();
+ this.expectContextual("readonly");
+ } else if (this.eatContextual("readonly")) {
+ node.readonly = true;
+ }
+
+ this.expect(types.bracketL);
+ node.typeParameter = this.tsParseMappedTypeParameter();
+ node.nameType = this.eatContextual("as") ? this.tsParseType() : null;
+ this.expect(types.bracketR);
+
+ if (this.match(types.plusMin)) {
+ node.optional = this.state.value;
+ this.next();
+ this.expect(types.question);
+ } else if (this.eat(types.question)) {
+ node.optional = true;
+ }
+
+ node.typeAnnotation = this.tsTryParseType();
+ this.semicolon();
+ this.expect(types.braceR);
+ return this.finishNode(node, "TSMappedType");
+ }
+
+ tsParseTupleType() {
+ const node = this.startNode();
+ node.elementTypes = this.tsParseBracketedList("TupleElementTypes", this.tsParseTupleElementType.bind(this), true, false);
+ let seenOptionalElement = false;
+ let labeledElements = null;
+ node.elementTypes.forEach(elementNode => {
+ var _labeledElements;
+
+ let {
+ type
+ } = elementNode;
+
+ if (seenOptionalElement && type !== "TSRestType" && type !== "TSOptionalType" && !(type === "TSNamedTupleMember" && elementNode.optional)) {
+ this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);
+ }
+
+ seenOptionalElement = seenOptionalElement || type === "TSNamedTupleMember" && elementNode.optional || type === "TSOptionalType";
+
+ if (type === "TSRestType") {
+ elementNode = elementNode.typeAnnotation;
+ type = elementNode.type;
+ }
+
+ const isLabeled = type === "TSNamedTupleMember";
+ labeledElements = (_labeledElements = labeledElements) != null ? _labeledElements : isLabeled;
+
+ if (labeledElements !== isLabeled) {
+ this.raise(elementNode.start, TSErrors.MixedLabeledAndUnlabeledElements);
+ }
+ });
+ return this.finishNode(node, "TSTupleType");
+ }
+
+ tsParseTupleElementType() {
+ const {
+ start: startPos,
+ startLoc
+ } = this.state;
+ const rest = this.eat(types.ellipsis);
+ let type = this.tsParseType();
+ const optional = this.eat(types.question);
+ const labeled = this.eat(types.colon);
+
+ if (labeled) {
+ const labeledNode = this.startNodeAtNode(type);
+ labeledNode.optional = optional;
+
+ if (type.type === "TSTypeReference" && !type.typeParameters && type.typeName.type === "Identifier") {
+ labeledNode.label = type.typeName;
+ } else {
+ this.raise(type.start, TSErrors.InvalidTupleMemberLabel);
+ labeledNode.label = type;
+ }
+
+ labeledNode.elementType = this.tsParseType();
+ type = this.finishNode(labeledNode, "TSNamedTupleMember");
+ } else if (optional) {
+ const optionalTypeNode = this.startNodeAtNode(type);
+ optionalTypeNode.typeAnnotation = type;
+ type = this.finishNode(optionalTypeNode, "TSOptionalType");
+ }
+
+ if (rest) {
+ const restNode = this.startNodeAt(startPos, startLoc);
+ restNode.typeAnnotation = type;
+ type = this.finishNode(restNode, "TSRestType");
+ }
+
+ return type;
+ }
+
+ tsParseParenthesizedType() {
+ const node = this.startNode();
+ this.expect(types.parenL);
+ node.typeAnnotation = this.tsParseType();
+ this.expect(types.parenR);
+ return this.finishNode(node, "TSParenthesizedType");
+ }
+
+ tsParseFunctionOrConstructorType(type, abstract) {
+ const node = this.startNode();
+
+ if (type === "TSConstructorType") {
+ node.abstract = !!abstract;
+ if (abstract) this.next();
+ this.next();
+ }
+
+ this.tsFillSignature(types.arrow, node);
+ return this.finishNode(node, type);
+ }
+
+ tsParseLiteralTypeNode() {
+ const node = this.startNode();
+
+ node.literal = (() => {
+ switch (this.state.type) {
+ case types.num:
+ case types.bigint:
+ case types.string:
+ case types._true:
+ case types._false:
+ return this.parseExprAtom();
+
+ default:
+ throw this.unexpected();
+ }
+ })();
+
+ return this.finishNode(node, "TSLiteralType");
+ }
+
+ tsParseTemplateLiteralType() {
+ const node = this.startNode();
+ node.literal = this.parseTemplate(false);
+ return this.finishNode(node, "TSLiteralType");
+ }
+
+ parseTemplateSubstitution() {
+ if (this.state.inType) return this.tsParseType();
+ return super.parseTemplateSubstitution();
+ }
+
+ tsParseThisTypeOrThisTypePredicate() {
+ const thisKeyword = this.tsParseThisTypeNode();
+
+ if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
+ return this.tsParseThisTypePredicate(thisKeyword);
+ } else {
+ return thisKeyword;
+ }
+ }
+
+ tsParseNonArrayType() {
+ switch (this.state.type) {
+ case types.name:
+ case types._void:
+ case types._null:
+ {
+ const type = this.match(types._void) ? "TSVoidKeyword" : this.match(types._null) ? "TSNullKeyword" : keywordTypeFromName(this.state.value);
+
+ if (type !== undefined && this.lookaheadCharCode() !== 46) {
+ const node = this.startNode();
+ this.next();
+ return this.finishNode(node, type);
+ }
+
+ return this.tsParseTypeReference();
+ }
+
+ case types.string:
+ case types.num:
+ case types.bigint:
+ case types._true:
+ case types._false:
+ return this.tsParseLiteralTypeNode();
+
+ case types.plusMin:
+ if (this.state.value === "-") {
+ const node = this.startNode();
+ const nextToken = this.lookahead();
+
+ if (nextToken.type !== types.num && nextToken.type !== types.bigint) {
+ throw this.unexpected();
+ }
+
+ node.literal = this.parseMaybeUnary();
+ return this.finishNode(node, "TSLiteralType");
+ }
+
+ break;
+
+ case types._this:
+ return this.tsParseThisTypeOrThisTypePredicate();
+
+ case types._typeof:
+ return this.tsParseTypeQuery();
+
+ case types._import:
+ return this.tsParseImportType();
+
+ case types.braceL:
+ return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this)) ? this.tsParseMappedType() : this.tsParseTypeLiteral();
+
+ case types.bracketL:
+ return this.tsParseTupleType();
+
+ case types.parenL:
+ return this.tsParseParenthesizedType();
+
+ case types.backQuote:
+ return this.tsParseTemplateLiteralType();
+ }
+
+ throw this.unexpected();
+ }
+
+ tsParseArrayTypeOrHigher() {
+ let type = this.tsParseNonArrayType();
+
+ while (!this.hasPrecedingLineBreak() && this.eat(types.bracketL)) {
+ if (this.match(types.bracketR)) {
+ const node = this.startNodeAtNode(type);
+ node.elementType = type;
+ this.expect(types.bracketR);
+ type = this.finishNode(node, "TSArrayType");
+ } else {
+ const node = this.startNodeAtNode(type);
+ node.objectType = type;
+ node.indexType = this.tsParseType();
+ this.expect(types.bracketR);
+ type = this.finishNode(node, "TSIndexedAccessType");
+ }
+ }
+
+ return type;
+ }
+
+ tsParseTypeOperator(operator) {
+ const node = this.startNode();
+ this.expectContextual(operator);
+ node.operator = operator;
+ node.typeAnnotation = this.tsParseTypeOperatorOrHigher();
+
+ if (operator === "readonly") {
+ this.tsCheckTypeAnnotationForReadOnly(node);
+ }
+
+ return this.finishNode(node, "TSTypeOperator");
+ }
+
+ tsCheckTypeAnnotationForReadOnly(node) {
+ switch (node.typeAnnotation.type) {
+ case "TSTupleType":
+ case "TSArrayType":
+ return;
+
+ default:
+ this.raise(node.start, TSErrors.UnexpectedReadonly);
+ }
+ }
+
+ tsParseInferType() {
+ const node = this.startNode();
+ this.expectContextual("infer");
+ const typeParameter = this.startNode();
+ typeParameter.name = this.parseIdentifierName(typeParameter.start);
+ node.typeParameter = this.finishNode(typeParameter, "TSTypeParameter");
+ return this.finishNode(node, "TSInferType");
+ }
+
+ tsParseTypeOperatorOrHigher() {
+ const operator = ["keyof", "unique", "readonly"].find(kw => this.isContextual(kw));
+ return operator ? this.tsParseTypeOperator(operator) : this.isContextual("infer") ? this.tsParseInferType() : this.tsParseArrayTypeOrHigher();
+ }
+
+ tsParseUnionOrIntersectionType(kind, parseConstituentType, operator) {
+ const node = this.startNode();
+ const hasLeadingOperator = this.eat(operator);
+ const types = [];
+
+ do {
+ types.push(parseConstituentType());
+ } while (this.eat(operator));
+
+ if (types.length === 1 && !hasLeadingOperator) {
+ return types[0];
+ }
+
+ node.types = types;
+ return this.finishNode(node, kind);
+ }
+
+ tsParseIntersectionTypeOrHigher() {
+ return this.tsParseUnionOrIntersectionType("TSIntersectionType", this.tsParseTypeOperatorOrHigher.bind(this), types.bitwiseAND);
+ }
+
+ tsParseUnionTypeOrHigher() {
+ return this.tsParseUnionOrIntersectionType("TSUnionType", this.tsParseIntersectionTypeOrHigher.bind(this), types.bitwiseOR);
+ }
+
+ tsIsStartOfFunctionType() {
+ if (this.isRelational("<")) {
+ return true;
+ }
+
+ return this.match(types.parenL) && this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this));
+ }
+
+ tsSkipParameterStart() {
+ if (this.match(types.name) || this.match(types._this)) {
+ this.next();
+ return true;
+ }
+
+ if (this.match(types.braceL)) {
+ let braceStackCounter = 1;
+ this.next();
+
+ while (braceStackCounter > 0) {
+ if (this.match(types.braceL)) {
+ ++braceStackCounter;
+ } else if (this.match(types.braceR)) {
+ --braceStackCounter;
+ }
+
+ this.next();
+ }
+
+ return true;
+ }
+
+ if (this.match(types.bracketL)) {
+ let braceStackCounter = 1;
+ this.next();
+
+ while (braceStackCounter > 0) {
+ if (this.match(types.bracketL)) {
+ ++braceStackCounter;
+ } else if (this.match(types.bracketR)) {
+ --braceStackCounter;
+ }
+
+ this.next();
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+ tsIsUnambiguouslyStartOfFunctionType() {
+ this.next();
+
+ if (this.match(types.parenR) || this.match(types.ellipsis)) {
+ return true;
+ }
+
+ if (this.tsSkipParameterStart()) {
+ if (this.match(types.colon) || this.match(types.comma) || this.match(types.question) || this.match(types.eq)) {
+ return true;
+ }
+
+ if (this.match(types.parenR)) {
+ this.next();
+
+ if (this.match(types.arrow)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ tsParseTypeOrTypePredicateAnnotation(returnToken) {
+ return this.tsInType(() => {
+ const t = this.startNode();
+ this.expect(returnToken);
+ const node = this.startNode();
+ const asserts = !!this.tsTryParse(this.tsParseTypePredicateAsserts.bind(this));
+
+ if (asserts && this.match(types._this)) {
+ let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();
+
+ if (thisTypePredicate.type === "TSThisType") {
+ node.parameterName = thisTypePredicate;
+ node.asserts = true;
+ thisTypePredicate = this.finishNode(node, "TSTypePredicate");
+ } else {
+ this.resetStartLocationFromNode(thisTypePredicate, node);
+ thisTypePredicate.asserts = true;
+ }
+
+ t.typeAnnotation = thisTypePredicate;
+ return this.finishNode(t, "TSTypeAnnotation");
+ }
+
+ const typePredicateVariable = this.tsIsIdentifier() && this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));
+
+ if (!typePredicateVariable) {
+ if (!asserts) {
+ return this.tsParseTypeAnnotation(false, t);
+ }
+
+ node.parameterName = this.parseIdentifier();
+ node.asserts = asserts;
+ t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
+ return this.finishNode(t, "TSTypeAnnotation");
+ }
+
+ const type = this.tsParseTypeAnnotation(false);
+ node.parameterName = typePredicateVariable;
+ node.typeAnnotation = type;
+ node.asserts = asserts;
+ t.typeAnnotation = this.finishNode(node, "TSTypePredicate");
+ return this.finishNode(t, "TSTypeAnnotation");
+ });
+ }
+
+ tsTryParseTypeOrTypePredicateAnnotation() {
+ return this.match(types.colon) ? this.tsParseTypeOrTypePredicateAnnotation(types.colon) : undefined;
+ }
+
+ tsTryParseTypeAnnotation() {
+ return this.match(types.colon) ? this.tsParseTypeAnnotation() : undefined;
+ }
+
+ tsTryParseType() {
+ return this.tsEatThenParseType(types.colon);
+ }
+
+ tsParseTypePredicatePrefix() {
+ const id = this.parseIdentifier();
+
+ if (this.isContextual("is") && !this.hasPrecedingLineBreak()) {
+ this.next();
+ return id;
+ }
+ }
+
+ tsParseTypePredicateAsserts() {
+ if (!this.match(types.name) || this.state.value !== "asserts" || this.hasPrecedingLineBreak()) {
+ return false;
+ }
+
+ const containsEsc = this.state.containsEsc;
+ this.next();
+
+ if (!this.match(types.name) && !this.match(types._this)) {
+ return false;
+ }
+
+ if (containsEsc) {
+ this.raise(this.state.lastTokStart, ErrorMessages.InvalidEscapedReservedWord, "asserts");
+ }
+
+ return true;
+ }
+
+ tsParseTypeAnnotation(eatColon = true, t = this.startNode()) {
+ this.tsInType(() => {
+ if (eatColon) this.expect(types.colon);
+ t.typeAnnotation = this.tsParseType();
+ });
+ return this.finishNode(t, "TSTypeAnnotation");
+ }
+
+ tsParseType() {
+ assert(this.state.inType);
+ const type = this.tsParseNonConditionalType();
+
+ if (this.hasPrecedingLineBreak() || !this.eat(types._extends)) {
+ return type;
+ }
+
+ const node = this.startNodeAtNode(type);
+ node.checkType = type;
+ node.extendsType = this.tsParseNonConditionalType();
+ this.expect(types.question);
+ node.trueType = this.tsParseType();
+ this.expect(types.colon);
+ node.falseType = this.tsParseType();
+ return this.finishNode(node, "TSConditionalType");
+ }
+
+ isAbstractConstructorSignature() {
+ return this.isContextual("abstract") && this.lookahead().type === types._new;
+ }
+
+ tsParseNonConditionalType() {
+ if (this.tsIsStartOfFunctionType()) {
+ return this.tsParseFunctionOrConstructorType("TSFunctionType");
+ }
+
+ if (this.match(types._new)) {
+ return this.tsParseFunctionOrConstructorType("TSConstructorType");
+ } else if (this.isAbstractConstructorSignature()) {
+ return this.tsParseFunctionOrConstructorType("TSConstructorType", true);
+ }
+
+ return this.tsParseUnionTypeOrHigher();
+ }
+
+ tsParseTypeAssertion() {
+ const node = this.startNode();
+
+ const _const = this.tsTryNextParseConstantContext();
+
+ node.typeAnnotation = _const || this.tsNextThenParseType();
+ this.expectRelational(">");
+ node.expression = this.parseMaybeUnary();
+ return this.finishNode(node, "TSTypeAssertion");
+ }
+
+ tsParseHeritageClause(descriptor) {
+ const originalStart = this.state.start;
+ const delimitedList = this.tsParseDelimitedList("HeritageClauseElement", this.tsParseExpressionWithTypeArguments.bind(this));
+
+ if (!delimitedList.length) {
+ this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);
+ }
+
+ return delimitedList;
+ }
+
+ tsParseExpressionWithTypeArguments() {
+ const node = this.startNode();
+ node.expression = this.tsParseEntityName(false);
+
+ if (this.isRelational("<")) {
+ node.typeParameters = this.tsParseTypeArguments();
+ }
+
+ return this.finishNode(node, "TSExpressionWithTypeArguments");
+ }
+
+ tsParseInterfaceDeclaration(node) {
+ node.id = this.parseIdentifier();
+ this.checkLVal(node.id, "typescript interface declaration", BIND_TS_INTERFACE);
+ node.typeParameters = this.tsTryParseTypeParameters();
+
+ if (this.eat(types._extends)) {
+ node.extends = this.tsParseHeritageClause("extends");
+ }
+
+ const body = this.startNode();
+ body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));
+ node.body = this.finishNode(body, "TSInterfaceBody");
+ return this.finishNode(node, "TSInterfaceDeclaration");
+ }
+
+ tsParseTypeAliasDeclaration(node) {
+ node.id = this.parseIdentifier();
+ this.checkLVal(node.id, "typescript type alias", BIND_TS_TYPE);
+ node.typeParameters = this.tsTryParseTypeParameters();
+ node.typeAnnotation = this.tsInType(() => {
+ this.expect(types.eq);
+
+ if (this.isContextual("intrinsic") && this.lookahead().type !== types.dot) {
+ const node = this.startNode();
+ this.next();
+ return this.finishNode(node, "TSIntrinsicKeyword");
+ }
+
+ return this.tsParseType();
+ });
+ this.semicolon();
+ return this.finishNode(node, "TSTypeAliasDeclaration");
+ }
+
+ tsInNoContext(cb) {
+ const oldContext = this.state.context;
+ this.state.context = [oldContext[0]];
+
+ try {
+ return cb();
+ } finally {
+ this.state.context = oldContext;
+ }
+ }
+
+ tsInType(cb) {
+ const oldInType = this.state.inType;
+ this.state.inType = true;
+
+ try {
+ return cb();
+ } finally {
+ this.state.inType = oldInType;
+ }
+ }
+
+ tsEatThenParseType(token) {
+ return !this.match(token) ? undefined : this.tsNextThenParseType();
+ }
+
+ tsExpectThenParseType(token) {
+ return this.tsDoThenParseType(() => this.expect(token));
+ }
+
+ tsNextThenParseType() {
+ return this.tsDoThenParseType(() => this.next());
+ }
+
+ tsDoThenParseType(cb) {
+ return this.tsInType(() => {
+ cb();
+ return this.tsParseType();
+ });
+ }
+
+ tsParseEnumMember() {
+ const node = this.startNode();
+ node.id = this.match(types.string) ? this.parseExprAtom() : this.parseIdentifier(true);
+
+ if (this.eat(types.eq)) {
+ node.initializer = this.parseMaybeAssignAllowIn();
+ }
+
+ return this.finishNode(node, "TSEnumMember");
+ }
+
+ tsParseEnumDeclaration(node, isConst) {
+ if (isConst) node.const = true;
+ node.id = this.parseIdentifier();
+ this.checkLVal(node.id, "typescript enum declaration", isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM);
+ this.expect(types.braceL);
+ node.members = this.tsParseDelimitedList("EnumMembers", this.tsParseEnumMember.bind(this));
+ this.expect(types.braceR);
+ return this.finishNode(node, "TSEnumDeclaration");
+ }
+
+ tsParseModuleBlock() {
+ const node = this.startNode();
+ this.scope.enter(SCOPE_OTHER);
+ this.expect(types.braceL);
+ this.parseBlockOrModuleBlockBody(node.body = [], undefined, true, types.braceR);
+ this.scope.exit();
+ return this.finishNode(node, "TSModuleBlock");
+ }
+
+ tsParseModuleOrNamespaceDeclaration(node, nested = false) {
+ node.id = this.parseIdentifier();
+
+ if (!nested) {
+ this.checkLVal(node.id, "module or namespace declaration", BIND_TS_NAMESPACE);
+ }
+
+ if (this.eat(types.dot)) {
+ const inner = this.startNode();
+ this.tsParseModuleOrNamespaceDeclaration(inner, true);
+ node.body = inner;
+ } else {
+ this.scope.enter(SCOPE_TS_MODULE);
+ this.prodParam.enter(PARAM);
+ node.body = this.tsParseModuleBlock();
+ this.prodParam.exit();
+ this.scope.exit();
+ }
+
+ return this.finishNode(node, "TSModuleDeclaration");
+ }
+
+ tsParseAmbientExternalModuleDeclaration(node) {
+ if (this.isContextual("global")) {
+ node.global = true;
+ node.id = this.parseIdentifier();
+ } else if (this.match(types.string)) {
+ node.id = this.parseExprAtom();
+ } else {
+ this.unexpected();
+ }
+
+ if (this.match(types.braceL)) {
+ this.scope.enter(SCOPE_TS_MODULE);
+ this.prodParam.enter(PARAM);
+ node.body = this.tsParseModuleBlock();
+ this.prodParam.exit();
+ this.scope.exit();
+ } else {
+ this.semicolon();
+ }
+
+ return this.finishNode(node, "TSModuleDeclaration");
+ }
+
+ tsParseImportEqualsDeclaration(node, isExport) {
+ node.isExport = isExport || false;
+ node.id = this.parseIdentifier();
+ this.checkLVal(node.id, "import equals declaration", BIND_LEXICAL);
+ this.expect(types.eq);
+ node.moduleReference = this.tsParseModuleReference();
+ this.semicolon();
+ return this.finishNode(node, "TSImportEqualsDeclaration");
+ }
+
+ tsIsExternalModuleReference() {
+ return this.isContextual("require") && this.lookaheadCharCode() === 40;
+ }
+
+ tsParseModuleReference() {
+ return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(false);
+ }
+
+ tsParseExternalModuleReference() {
+ const node = this.startNode();
+ this.expectContextual("require");
+ this.expect(types.parenL);
+
+ if (!this.match(types.string)) {
+ throw this.unexpected();
+ }
+
+ node.expression = this.parseExprAtom();
+ this.expect(types.parenR);
+ return this.finishNode(node, "TSExternalModuleReference");
+ }
+
+ tsLookAhead(f) {
+ const state = this.state.clone();
+ const res = f();
+ this.state = state;
+ return res;
+ }
+
+ tsTryParseAndCatch(f) {
+ const result = this.tryParse(abort => f() || abort());
+ if (result.aborted || !result.node) return undefined;
+ if (result.error) this.state = result.failState;
+ return result.node;
+ }
+
+ tsTryParse(f) {
+ const state = this.state.clone();
+ const result = f();
+
+ if (result !== undefined && result !== false) {
+ return result;
+ } else {
+ this.state = state;
+ return undefined;
+ }
+ }
+
+ tsTryParseDeclare(nany) {
+ if (this.isLineTerminator()) {
+ return;
+ }
+
+ let starttype = this.state.type;
+ let kind;
+
+ if (this.isContextual("let")) {
+ starttype = types._var;
+ kind = "let";
+ }
+
+ return this.tsInDeclareContext(() => {
+ switch (starttype) {
+ case types._function:
+ nany.declare = true;
+ return this.parseFunctionStatement(nany, false, true);
+
+ case types._class:
+ nany.declare = true;
+ return this.parseClass(nany, true, false);
+
+ case types._const:
+ if (this.match(types._const) && this.isLookaheadContextual("enum")) {
+ this.expect(types._const);
+ this.expectContextual("enum");
+ return this.tsParseEnumDeclaration(nany, true);
+ }
+
+ case types._var:
+ kind = kind || this.state.value;
+ return this.parseVarStatement(nany, kind);
+
+ case types.name:
+ {
+ const value = this.state.value;
+
+ if (value === "global") {
+ return this.tsParseAmbientExternalModuleDeclaration(nany);
+ } else {
+ return this.tsParseDeclaration(nany, value, true);
+ }
+ }
+ }
+ });
+ }
+
+ tsTryParseExportDeclaration() {
+ return this.tsParseDeclaration(this.startNode(), this.state.value, true);
+ }
+
+ tsParseExpressionStatement(node, expr) {
+ switch (expr.name) {
+ case "declare":
+ {
+ const declaration = this.tsTryParseDeclare(node);
+
+ if (declaration) {
+ declaration.declare = true;
+ return declaration;
+ }
+
+ break;
+ }
+
+ case "global":
+ if (this.match(types.braceL)) {
+ this.scope.enter(SCOPE_TS_MODULE);
+ this.prodParam.enter(PARAM);
+ const mod = node;
+ mod.global = true;
+ mod.id = expr;
+ mod.body = this.tsParseModuleBlock();
+ this.scope.exit();
+ this.prodParam.exit();
+ return this.finishNode(mod, "TSModuleDeclaration");
+ }
+
+ break;
+
+ default:
+ return this.tsParseDeclaration(node, expr.name, false);
+ }
+ }
+
+ tsParseDeclaration(node, value, next) {
+ switch (value) {
+ case "abstract":
+ if (this.tsCheckLineTerminator(next) && (this.match(types._class) || this.match(types.name))) {
+ return this.tsParseAbstractDeclaration(node);
+ }
+
+ break;
+
+ case "enum":
+ if (next || this.match(types.name)) {
+ if (next) this.next();
+ return this.tsParseEnumDeclaration(node, false);
+ }
+
+ break;
+
+ case "interface":
+ if (this.tsCheckLineTerminator(next) && this.match(types.name)) {
+ return this.tsParseInterfaceDeclaration(node);
+ }
+
+ break;
+
+ case "module":
+ if (this.tsCheckLineTerminator(next)) {
+ if (this.match(types.string)) {
+ return this.tsParseAmbientExternalModuleDeclaration(node);
+ } else if (this.match(types.name)) {
+ return this.tsParseModuleOrNamespaceDeclaration(node);
+ }
+ }
+
+ break;
+
+ case "namespace":
+ if (this.tsCheckLineTerminator(next) && this.match(types.name)) {
+ return this.tsParseModuleOrNamespaceDeclaration(node);
+ }
+
+ break;
+
+ case "type":
+ if (this.tsCheckLineTerminator(next) && this.match(types.name)) {
+ return this.tsParseTypeAliasDeclaration(node);
+ }
+
+ break;
+ }
+ }
+
+ tsCheckLineTerminator(next) {
+ if (next) {
+ if (this.hasFollowingLineBreak()) return false;
+ this.next();
+ return true;
+ }
+
+ return !this.isLineTerminator();
+ }
+
+ tsTryParseGenericAsyncArrowFunction(startPos, startLoc) {
+ if (!this.isRelational("<")) {
+ return undefined;
+ }
+
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
+ this.state.maybeInArrowParameters = true;
+ const res = this.tsTryParseAndCatch(() => {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.typeParameters = this.tsParseTypeParameters();
+ super.parseFunctionParams(node);
+ node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();
+ this.expect(types.arrow);
+ return node;
+ });
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
+
+ if (!res) {
+ return undefined;
+ }
+
+ return this.parseArrowExpression(res, null, true);
+ }
+
+ tsParseTypeArguments() {
+ const node = this.startNode();
+ node.params = this.tsInType(() => this.tsInNoContext(() => {
+ this.expectRelational("<");
+ return this.tsParseDelimitedList("TypeParametersOrArguments", this.tsParseType.bind(this));
+ }));
+
+ if (node.params.length === 0) {
+ this.raise(node.start, TSErrors.EmptyTypeArguments);
+ }
+
+ this.state.exprAllowed = false;
+ this.expectRelational(">");
+ return this.finishNode(node, "TSTypeParameterInstantiation");
+ }
+
+ tsIsDeclarationStart() {
+ if (this.match(types.name)) {
+ switch (this.state.value) {
+ case "abstract":
+ case "declare":
+ case "enum":
+ case "interface":
+ case "module":
+ case "namespace":
+ case "type":
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ isExportDefaultSpecifier() {
+ if (this.tsIsDeclarationStart()) return false;
+ return super.isExportDefaultSpecifier();
+ }
+
+ parseAssignableListItem(allowModifiers, decorators) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ let accessibility;
+ let readonly = false;
+
+ if (allowModifiers !== undefined) {
+ accessibility = this.parseAccessModifier();
+ readonly = !!this.tsParseModifier(["readonly"]);
+
+ if (allowModifiers === false && (accessibility || readonly)) {
+ this.raise(startPos, TSErrors.UnexpectedParameterModifier);
+ }
+ }
+
+ const left = this.parseMaybeDefault();
+ this.parseAssignableListItemTypes(left);
+ const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
+
+ if (accessibility || readonly) {
+ const pp = this.startNodeAt(startPos, startLoc);
+
+ if (decorators.length) {
+ pp.decorators = decorators;
+ }
+
+ if (accessibility) pp.accessibility = accessibility;
+ if (readonly) pp.readonly = readonly;
+
+ if (elt.type !== "Identifier" && elt.type !== "AssignmentPattern") {
+ this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);
+ }
+
+ pp.parameter = elt;
+ return this.finishNode(pp, "TSParameterProperty");
+ }
+
+ if (decorators.length) {
+ left.decorators = decorators;
+ }
+
+ return elt;
+ }
+
+ parseFunctionBodyAndFinish(node, type, isMethod = false) {
+ if (this.match(types.colon)) {
+ node.returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon);
+ }
+
+ const bodilessType = type === "FunctionDeclaration" ? "TSDeclareFunction" : type === "ClassMethod" ? "TSDeclareMethod" : undefined;
+
+ if (bodilessType && !this.match(types.braceL) && this.isLineTerminator()) {
+ this.finishNode(node, bodilessType);
+ return;
+ }
+
+ if (bodilessType === "TSDeclareFunction" && this.state.isDeclareContext) {
+ this.raise(node.start, TSErrors.DeclareFunctionHasImplementation);
+
+ if (node.declare) {
+ super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);
+ return;
+ }
+ }
+
+ super.parseFunctionBodyAndFinish(node, type, isMethod);
+ }
+
+ registerFunctionStatementId(node) {
+ if (!node.body && node.id) {
+ this.checkLVal(node.id, "function name", BIND_TS_AMBIENT);
+ } else {
+ super.registerFunctionStatementId(...arguments);
+ }
+ }
+
+ tsCheckForInvalidTypeCasts(items) {
+ items.forEach(node => {
+ if ((node == null ? void 0 : node.type) === "TSTypeCastExpression") {
+ this.raise(node.typeAnnotation.start, TSErrors.UnexpectedTypeAnnotation);
+ }
+ });
+ }
+
+ toReferencedList(exprList, isInParens) {
+ this.tsCheckForInvalidTypeCasts(exprList);
+ return exprList;
+ }
+
+ parseArrayLike(...args) {
+ const node = super.parseArrayLike(...args);
+
+ if (node.type === "ArrayExpression") {
+ this.tsCheckForInvalidTypeCasts(node.elements);
+ }
+
+ return node;
+ }
+
+ parseSubscript(base, startPos, startLoc, noCalls, state) {
+ if (!this.hasPrecedingLineBreak() && this.match(types.bang)) {
+ this.state.exprAllowed = false;
+ this.next();
+ const nonNullExpression = this.startNodeAt(startPos, startLoc);
+ nonNullExpression.expression = base;
+ return this.finishNode(nonNullExpression, "TSNonNullExpression");
+ }
+
+ if (this.isRelational("<")) {
+ const result = this.tsTryParseAndCatch(() => {
+ if (!noCalls && this.atPossibleAsyncArrow(base)) {
+ const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(startPos, startLoc);
+
+ if (asyncArrowFn) {
+ return asyncArrowFn;
+ }
+ }
+
+ const node = this.startNodeAt(startPos, startLoc);
+ node.callee = base;
+ const typeArguments = this.tsParseTypeArguments();
+
+ if (typeArguments) {
+ if (!noCalls && this.eat(types.parenL)) {
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ this.tsCheckForInvalidTypeCasts(node.arguments);
+ node.typeParameters = typeArguments;
+
+ if (state.optionalChainMember) {
+ node.optional = false;
+ }
+
+ return this.finishCallExpression(node, state.optionalChainMember);
+ } else if (this.match(types.backQuote)) {
+ const result = this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
+ result.typeParameters = typeArguments;
+ return result;
+ }
+ }
+
+ this.unexpected();
+ });
+ if (result) return result;
+ }
+
+ return super.parseSubscript(base, startPos, startLoc, noCalls, state);
+ }
+
+ parseNewArguments(node) {
+ if (this.isRelational("<")) {
+ const typeParameters = this.tsTryParseAndCatch(() => {
+ const args = this.tsParseTypeArguments();
+ if (!this.match(types.parenL)) this.unexpected();
+ return args;
+ });
+
+ if (typeParameters) {
+ node.typeParameters = typeParameters;
+ }
+ }
+
+ super.parseNewArguments(node);
+ }
+
+ parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
+ if (nonNull(types._in.binop) > minPrec && !this.hasPrecedingLineBreak() && this.isContextual("as")) {
+ const node = this.startNodeAt(leftStartPos, leftStartLoc);
+ node.expression = left;
+
+ const _const = this.tsTryNextParseConstantContext();
+
+ if (_const) {
+ node.typeAnnotation = _const;
+ } else {
+ node.typeAnnotation = this.tsNextThenParseType();
+ }
+
+ this.finishNode(node, "TSAsExpression");
+ this.reScan_lt_gt();
+ return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
+ }
+
+ return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec);
+ }
+
+ checkReservedWord(word, startLoc, checkKeywords, isBinding) {}
+
+ checkDuplicateExports() {}
+
+ parseImport(node) {
+ if (this.match(types.name) || this.match(types.star) || this.match(types.braceL)) {
+ const ahead = this.lookahead();
+
+ if (this.match(types.name) && ahead.type === types.eq) {
+ return this.tsParseImportEqualsDeclaration(node);
+ }
+
+ if (this.isContextual("type") && ahead.type !== types.comma && !(ahead.type === types.name && ahead.value === "from")) {
+ node.importKind = "type";
+ this.next();
+ }
+ }
+
+ if (!node.importKind) {
+ node.importKind = "value";
+ }
+
+ const importNode = super.parseImport(node);
+
+ if (importNode.importKind === "type" && importNode.specifiers.length > 1 && importNode.specifiers[0].type === "ImportDefaultSpecifier") {
+ this.raise(importNode.start, "A type-only import can specify a default import or named bindings, but not both.");
+ }
+
+ return importNode;
+ }
+
+ parseExport(node) {
+ if (this.match(types._import)) {
+ this.expect(types._import);
+ return this.tsParseImportEqualsDeclaration(node, true);
+ } else if (this.eat(types.eq)) {
+ const assign = node;
+ assign.expression = this.parseExpression();
+ this.semicolon();
+ return this.finishNode(assign, "TSExportAssignment");
+ } else if (this.eatContextual("as")) {
+ const decl = node;
+ this.expectContextual("namespace");
+ decl.id = this.parseIdentifier();
+ this.semicolon();
+ return this.finishNode(decl, "TSNamespaceExportDeclaration");
+ } else {
+ if (this.isContextual("type") && this.lookahead().type === types.braceL) {
+ this.next();
+ node.exportKind = "type";
+ } else {
+ node.exportKind = "value";
+ }
+
+ return super.parseExport(node);
+ }
+ }
+
+ isAbstractClass() {
+ return this.isContextual("abstract") && this.lookahead().type === types._class;
+ }
+
+ parseExportDefaultExpression() {
+ if (this.isAbstractClass()) {
+ const cls = this.startNode();
+ this.next();
+ cls.abstract = true;
+ this.parseClass(cls, true, true);
+ return cls;
+ }
+
+ if (this.state.value === "interface") {
+ const result = this.tsParseDeclaration(this.startNode(), this.state.value, true);
+ if (result) return result;
+ }
+
+ return super.parseExportDefaultExpression();
+ }
+
+ parseStatementContent(context, topLevel) {
+ if (this.state.type === types._const) {
+ const ahead = this.lookahead();
+
+ if (ahead.type === types.name && ahead.value === "enum") {
+ const node = this.startNode();
+ this.expect(types._const);
+ this.expectContextual("enum");
+ return this.tsParseEnumDeclaration(node, true);
+ }
+ }
+
+ return super.parseStatementContent(context, topLevel);
+ }
+
+ parseAccessModifier() {
+ return this.tsParseModifier(["public", "protected", "private"]);
+ }
+
+ parseClassMember(classBody, member, state) {
+ this.tsParseModifiers(member, ["declare", "private", "public", "protected"]);
+
+ const callParseClassMember = () => {
+ super.parseClassMember(classBody, member, state);
+ };
+
+ if (member.declare) {
+ this.tsInDeclareContext(callParseClassMember);
+ } else {
+ callParseClassMember();
+ }
+ }
+
+ parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
+ this.tsParseModifiers(member, ["abstract", "readonly", "declare"]);
+ const idx = this.tsTryParseIndexSignature(member);
+
+ if (idx) {
+ classBody.body.push(idx);
+
+ if (member.abstract) {
+ this.raise(member.start, TSErrors.IndexSignatureHasAbstract);
+ }
+
+ if (isStatic) {
+ this.raise(member.start, TSErrors.IndexSignatureHasStatic);
+ }
+
+ if (member.accessibility) {
+ this.raise(member.start, TSErrors.IndexSignatureHasAccessibility, member.accessibility);
+ }
+
+ if (member.declare) {
+ this.raise(member.start, TSErrors.IndexSignatureHasDeclare);
+ }
+
+ return;
+ }
+
+ if (!this.state.inAbstractClass && member.abstract) {
+ this.raise(member.start, TSErrors.NonAbstractClassHasAbstractMethod);
+ }
+
+ super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
+ }
+
+ parsePostMemberNameModifiers(methodOrProp) {
+ const optional = this.eat(types.question);
+ if (optional) methodOrProp.optional = true;
+
+ if (methodOrProp.readonly && this.match(types.parenL)) {
+ this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);
+ }
+
+ if (methodOrProp.declare && this.match(types.parenL)) {
+ this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);
+ }
+ }
+
+ parseExpressionStatement(node, expr) {
+ const decl = expr.type === "Identifier" ? this.tsParseExpressionStatement(node, expr) : undefined;
+ return decl || super.parseExpressionStatement(node, expr);
+ }
+
+ shouldParseExportDeclaration() {
+ if (this.tsIsDeclarationStart()) return true;
+ return super.shouldParseExportDeclaration();
+ }
+
+ parseConditional(expr, startPos, startLoc, refNeedsArrowPos) {
+ if (!refNeedsArrowPos || !this.match(types.question)) {
+ return super.parseConditional(expr, startPos, startLoc, refNeedsArrowPos);
+ }
+
+ const result = this.tryParse(() => super.parseConditional(expr, startPos, startLoc));
+
+ if (!result.node) {
+ refNeedsArrowPos.start = result.error.pos || this.state.start;
+ return expr;
+ }
+
+ if (result.error) this.state = result.failState;
+ return result.node;
+ }
+
+ parseParenItem(node, startPos, startLoc) {
+ node = super.parseParenItem(node, startPos, startLoc);
+
+ if (this.eat(types.question)) {
+ node.optional = true;
+ this.resetEndLocation(node);
+ }
+
+ if (this.match(types.colon)) {
+ const typeCastNode = this.startNodeAt(startPos, startLoc);
+ typeCastNode.expression = node;
+ typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();
+ return this.finishNode(typeCastNode, "TSTypeCastExpression");
+ }
+
+ return node;
+ }
+
+ parseExportDeclaration(node) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const isDeclare = this.eatContextual("declare");
+
+ if (isDeclare && (this.isContextual("declare") || !this.shouldParseExportDeclaration())) {
+ throw this.raise(this.state.start, TSErrors.ExpectedAmbientAfterExportDeclare);
+ }
+
+ let declaration;
+
+ if (this.match(types.name)) {
+ declaration = this.tsTryParseExportDeclaration();
+ }
+
+ if (!declaration) {
+ declaration = super.parseExportDeclaration(node);
+ }
+
+ if (declaration && (declaration.type === "TSInterfaceDeclaration" || declaration.type === "TSTypeAliasDeclaration" || isDeclare)) {
+ node.exportKind = "type";
+ }
+
+ if (declaration && isDeclare) {
+ this.resetStartLocation(declaration, startPos, startLoc);
+ declaration.declare = true;
+ }
+
+ return declaration;
+ }
+
+ parseClassId(node, isStatement, optionalId) {
+ if ((!isStatement || optionalId) && this.isContextual("implements")) {
+ return;
+ }
+
+ super.parseClassId(node, isStatement, optionalId, node.declare ? BIND_TS_AMBIENT : BIND_CLASS);
+ const typeParameters = this.tsTryParseTypeParameters();
+ if (typeParameters) node.typeParameters = typeParameters;
+ }
+
+ parseClassPropertyAnnotation(node) {
+ if (!node.optional && this.eat(types.bang)) {
+ node.definite = true;
+ }
+
+ const type = this.tsTryParseTypeAnnotation();
+ if (type) node.typeAnnotation = type;
+ }
+
+ parseClassProperty(node) {
+ this.parseClassPropertyAnnotation(node);
+
+ if (this.state.isDeclareContext && this.match(types.eq)) {
+ this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);
+ }
+
+ return super.parseClassProperty(node);
+ }
+
+ parseClassPrivateProperty(node) {
+ if (node.abstract) {
+ this.raise(node.start, TSErrors.PrivateElementHasAbstract);
+ }
+
+ if (node.accessibility) {
+ this.raise(node.start, TSErrors.PrivateElementHasAccessibility, node.accessibility);
+ }
+
+ this.parseClassPropertyAnnotation(node);
+ return super.parseClassPrivateProperty(node);
+ }
+
+ pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
+ const typeParameters = this.tsTryParseTypeParameters();
+
+ if (typeParameters && isConstructor) {
+ this.raise(typeParameters.start, TSErrors.ConstructorHasTypeParameters);
+ }
+
+ if (typeParameters) method.typeParameters = typeParameters;
+ super.pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper);
+ }
+
+ pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
+ const typeParameters = this.tsTryParseTypeParameters();
+ if (typeParameters) method.typeParameters = typeParameters;
+ super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);
+ }
+
+ parseClassSuper(node) {
+ super.parseClassSuper(node);
+
+ if (node.superClass && this.isRelational("<")) {
+ node.superTypeParameters = this.tsParseTypeArguments();
+ }
+
+ if (this.eatContextual("implements")) {
+ node.implements = this.tsParseHeritageClause("implements");
+ }
+ }
+
+ parseObjPropValue(prop, ...args) {
+ const typeParameters = this.tsTryParseTypeParameters();
+ if (typeParameters) prop.typeParameters = typeParameters;
+ super.parseObjPropValue(prop, ...args);
+ }
+
+ parseFunctionParams(node, allowModifiers) {
+ const typeParameters = this.tsTryParseTypeParameters();
+ if (typeParameters) node.typeParameters = typeParameters;
+ super.parseFunctionParams(node, allowModifiers);
+ }
+
+ parseVarId(decl, kind) {
+ super.parseVarId(decl, kind);
+
+ if (decl.id.type === "Identifier" && this.eat(types.bang)) {
+ decl.definite = true;
+ }
+
+ const type = this.tsTryParseTypeAnnotation();
+
+ if (type) {
+ decl.id.typeAnnotation = type;
+ this.resetEndLocation(decl.id);
+ }
+ }
+
+ parseAsyncArrowFromCallExpression(node, call) {
+ if (this.match(types.colon)) {
+ node.returnType = this.tsParseTypeAnnotation();
+ }
+
+ return super.parseAsyncArrowFromCallExpression(node, call);
+ }
+
+ parseMaybeAssign(...args) {
+ var _jsx, _jsx2, _typeCast, _jsx3, _typeCast2, _jsx4, _typeCast3;
+
+ let state;
+ let jsx;
+ let typeCast;
+
+ if (this.hasPlugin("jsx") && (this.match(types.jsxTagStart) || this.isRelational("<"))) {
+ state = this.state.clone();
+ jsx = this.tryParse(() => super.parseMaybeAssign(...args), state);
+ if (!jsx.error) return jsx.node;
+ const {
+ context
+ } = this.state;
+
+ if (context[context.length - 1] === types$1.j_oTag) {
+ context.length -= 2;
+ } else if (context[context.length - 1] === types$1.j_expr) {
+ context.length -= 1;
+ }
+ }
+
+ if (!((_jsx = jsx) != null && _jsx.error) && !this.isRelational("<")) {
+ return super.parseMaybeAssign(...args);
+ }
+
+ let typeParameters;
+ state = state || this.state.clone();
+ const arrow = this.tryParse(abort => {
+ var _typeParameters;
+
+ typeParameters = this.tsParseTypeParameters();
+ const expr = super.parseMaybeAssign(...args);
+
+ if (expr.type !== "ArrowFunctionExpression" || expr.extra && expr.extra.parenthesized) {
+ abort();
+ }
+
+ if (((_typeParameters = typeParameters) == null ? void 0 : _typeParameters.params.length) !== 0) {
+ this.resetStartLocationFromNode(expr, typeParameters);
+ }
+
+ expr.typeParameters = typeParameters;
+ return expr;
+ }, state);
+ if (!arrow.error && !arrow.aborted) return arrow.node;
+
+ if (!jsx) {
+ assert(!this.hasPlugin("jsx"));
+ typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state);
+ if (!typeCast.error) return typeCast.node;
+ }
+
+ if ((_jsx2 = jsx) != null && _jsx2.node) {
+ this.state = jsx.failState;
+ return jsx.node;
+ }
+
+ if (arrow.node) {
+ this.state = arrow.failState;
+ return arrow.node;
+ }
+
+ if ((_typeCast = typeCast) != null && _typeCast.node) {
+ this.state = typeCast.failState;
+ return typeCast.node;
+ }
+
+ if ((_jsx3 = jsx) != null && _jsx3.thrown) throw jsx.error;
+ if (arrow.thrown) throw arrow.error;
+ if ((_typeCast2 = typeCast) != null && _typeCast2.thrown) throw typeCast.error;
+ throw ((_jsx4 = jsx) == null ? void 0 : _jsx4.error) || arrow.error || ((_typeCast3 = typeCast) == null ? void 0 : _typeCast3.error);
+ }
+
+ parseMaybeUnary(refExpressionErrors) {
+ if (!this.hasPlugin("jsx") && this.isRelational("<")) {
+ return this.tsParseTypeAssertion();
+ } else {
+ return super.parseMaybeUnary(refExpressionErrors);
+ }
+ }
+
+ parseArrow(node) {
+ if (this.match(types.colon)) {
+ const result = this.tryParse(abort => {
+ const returnType = this.tsParseTypeOrTypePredicateAnnotation(types.colon);
+ if (this.canInsertSemicolon() || !this.match(types.arrow)) abort();
+ return returnType;
+ });
+ if (result.aborted) return;
+
+ if (!result.thrown) {
+ if (result.error) this.state = result.failState;
+ node.returnType = result.node;
+ }
+ }
+
+ return super.parseArrow(node);
+ }
+
+ parseAssignableListItemTypes(param) {
+ if (this.eat(types.question)) {
+ if (param.type !== "Identifier" && !this.state.isDeclareContext && !this.state.inType) {
+ this.raise(param.start, TSErrors.PatternIsOptional);
+ }
+
+ param.optional = true;
+ }
+
+ const type = this.tsTryParseTypeAnnotation();
+ if (type) param.typeAnnotation = type;
+ this.resetEndLocation(param);
+ return param;
+ }
+
+ toAssignable(node, isLHS = false) {
+ switch (node.type) {
+ case "TSTypeCastExpression":
+ return super.toAssignable(this.typeCastToParameter(node), isLHS);
+
+ case "TSParameterProperty":
+ return super.toAssignable(node, isLHS);
+
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "TSTypeAssertion":
+ node.expression = this.toAssignable(node.expression, isLHS);
+ return node;
+
+ default:
+ return super.toAssignable(node, isLHS);
+ }
+ }
+
+ checkLVal(expr, contextDescription, ...args) {
+ switch (expr.type) {
+ case "TSTypeCastExpression":
+ return;
+
+ case "TSParameterProperty":
+ this.checkLVal(expr.parameter, "parameter property", ...args);
+ return;
+
+ case "TSAsExpression":
+ case "TSNonNullExpression":
+ case "TSTypeAssertion":
+ this.checkLVal(expr.expression, contextDescription, ...args);
+ return;
+
+ default:
+ super.checkLVal(expr, contextDescription, ...args);
+ return;
+ }
+ }
+
+ parseBindingAtom() {
+ switch (this.state.type) {
+ case types._this:
+ return this.parseIdentifier(true);
+
+ default:
+ return super.parseBindingAtom();
+ }
+ }
+
+ parseMaybeDecoratorArguments(expr) {
+ if (this.isRelational("<")) {
+ const typeArguments = this.tsParseTypeArguments();
+
+ if (this.match(types.parenL)) {
+ const call = super.parseMaybeDecoratorArguments(expr);
+ call.typeParameters = typeArguments;
+ return call;
+ }
+
+ this.unexpected(this.state.start, types.parenL);
+ }
+
+ return super.parseMaybeDecoratorArguments(expr);
+ }
+
+ isClassMethod() {
+ return this.isRelational("<") || super.isClassMethod();
+ }
+
+ isClassProperty() {
+ return this.match(types.bang) || this.match(types.colon) || super.isClassProperty();
+ }
+
+ parseMaybeDefault(...args) {
+ const node = super.parseMaybeDefault(...args);
+
+ if (node.type === "AssignmentPattern" && node.typeAnnotation && node.right.start < node.typeAnnotation.start) {
+ this.raise(node.typeAnnotation.start, TSErrors.TypeAnnotationAfterAssign);
+ }
+
+ return node;
+ }
+
+ getTokenFromCode(code) {
+ if (this.state.inType && (code === 62 || code === 60)) {
+ return this.finishOp(types.relational, 1);
+ } else {
+ return super.getTokenFromCode(code);
+ }
+ }
+
+ reScan_lt_gt() {
+ if (this.match(types.relational)) {
+ const code = this.input.charCodeAt(this.state.start);
+
+ if (code === 60 || code === 62) {
+ this.state.pos -= 1;
+ this.readToken_lt_gt(code);
+ }
+ }
+ }
+
+ toAssignableList(exprList) {
+ for (let i = 0; i < exprList.length; i++) {
+ const expr = exprList[i];
+ if (!expr) continue;
+
+ switch (expr.type) {
+ case "TSTypeCastExpression":
+ exprList[i] = this.typeCastToParameter(expr);
+ break;
+
+ case "TSAsExpression":
+ case "TSTypeAssertion":
+ if (!this.state.maybeInArrowParameters) {
+ exprList[i] = this.typeCastToParameter(expr);
+ } else {
+ this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);
+ }
+
+ break;
+ }
+ }
+
+ return super.toAssignableList(...arguments);
+ }
+
+ typeCastToParameter(node) {
+ node.expression.typeAnnotation = node.typeAnnotation;
+ this.resetEndLocation(node.expression, node.typeAnnotation.end, node.typeAnnotation.loc.end);
+ return node.expression;
+ }
+
+ shouldParseArrow() {
+ return this.match(types.colon) || super.shouldParseArrow();
+ }
+
+ shouldParseAsyncArrow() {
+ return this.match(types.colon) || super.shouldParseAsyncArrow();
+ }
+
+ canHaveLeadingDecorator() {
+ return super.canHaveLeadingDecorator() || this.isAbstractClass();
+ }
+
+ jsxParseOpeningElementAfterName(node) {
+ if (this.isRelational("<")) {
+ const typeArguments = this.tsTryParseAndCatch(() => this.tsParseTypeArguments());
+ if (typeArguments) node.typeParameters = typeArguments;
+ }
+
+ return super.jsxParseOpeningElementAfterName(node);
+ }
+
+ getGetterSetterExpectedParamCount(method) {
+ const baseCount = super.getGetterSetterExpectedParamCount(method);
+ const params = this.getObjectOrClassMethodParams(method);
+ const firstParam = params[0];
+ const hasContextParam = firstParam && firstParam.type === "Identifier" && firstParam.name === "this";
+ return hasContextParam ? baseCount + 1 : baseCount;
+ }
+
+ parseCatchClauseParam() {
+ const param = super.parseCatchClauseParam();
+ const type = this.tsTryParseTypeAnnotation();
+
+ if (type) {
+ param.typeAnnotation = type;
+ this.resetEndLocation(param);
+ }
+
+ return param;
+ }
+
+ tsInDeclareContext(cb) {
+ const oldIsDeclareContext = this.state.isDeclareContext;
+ this.state.isDeclareContext = true;
+
+ try {
+ return cb();
+ } finally {
+ this.state.isDeclareContext = oldIsDeclareContext;
+ }
+ }
+
+ parseClass(node, ...args) {
+ const oldInAbstractClass = this.state.inAbstractClass;
+ this.state.inAbstractClass = !!node.abstract;
+
+ try {
+ return super.parseClass(node, ...args);
+ } finally {
+ this.state.inAbstractClass = oldInAbstractClass;
+ }
+ }
+
+ tsParseAbstractDeclaration(node) {
+ if (this.match(types._class)) {
+ node.abstract = true;
+ return this.parseClass(node, true, false);
+ } else if (this.isContextual("interface")) {
+ if (!this.hasFollowingLineBreak()) {
+ node.abstract = true;
+ this.raise(node.start, TSErrors.NonClassMethodPropertyHasAbstractModifer);
+ this.next();
+ return this.tsParseInterfaceDeclaration(node);
+ }
+ } else {
+ this.unexpected(null, types._class);
+ }
+ }
+
+});
+
+types.placeholder = new TokenType("%%", {
+ startsExpr: true
+});
+var placeholders = (superClass => class extends superClass {
+ parsePlaceholder(expectedNode) {
+ if (this.match(types.placeholder)) {
+ const node = this.startNode();
+ this.next();
+ this.assertNoSpace("Unexpected space in placeholder.");
+ node.name = super.parseIdentifier(true);
+ this.assertNoSpace("Unexpected space in placeholder.");
+ this.expect(types.placeholder);
+ return this.finishPlaceholder(node, expectedNode);
+ }
+ }
+
+ finishPlaceholder(node, expectedNode) {
+ const isFinished = !!(node.expectedNode && node.type === "Placeholder");
+ node.expectedNode = expectedNode;
+ return isFinished ? node : this.finishNode(node, "Placeholder");
+ }
+
+ getTokenFromCode(code) {
+ if (code === 37 && this.input.charCodeAt(this.state.pos + 1) === 37) {
+ return this.finishOp(types.placeholder, 2);
+ }
+
+ return super.getTokenFromCode(...arguments);
+ }
+
+ parseExprAtom() {
+ return this.parsePlaceholder("Expression") || super.parseExprAtom(...arguments);
+ }
+
+ parseIdentifier() {
+ return this.parsePlaceholder("Identifier") || super.parseIdentifier(...arguments);
+ }
+
+ checkReservedWord(word) {
+ if (word !== undefined) super.checkReservedWord(...arguments);
+ }
+
+ parseBindingAtom() {
+ return this.parsePlaceholder("Pattern") || super.parseBindingAtom(...arguments);
+ }
+
+ checkLVal(expr) {
+ if (expr.type !== "Placeholder") super.checkLVal(...arguments);
+ }
+
+ toAssignable(node) {
+ if (node && node.type === "Placeholder" && node.expectedNode === "Expression") {
+ node.expectedNode = "Pattern";
+ return node;
+ }
+
+ return super.toAssignable(...arguments);
+ }
+
+ isLet(context) {
+ if (super.isLet(context)) {
+ return true;
+ }
+
+ if (!this.isContextual("let")) {
+ return false;
+ }
+
+ if (context) return false;
+ const nextToken = this.lookahead();
+
+ if (nextToken.type === types.placeholder) {
+ return true;
+ }
+
+ return false;
+ }
+
+ verifyBreakContinue(node) {
+ if (node.label && node.label.type === "Placeholder") return;
+ super.verifyBreakContinue(...arguments);
+ }
+
+ parseExpressionStatement(node, expr) {
+ if (expr.type !== "Placeholder" || expr.extra && expr.extra.parenthesized) {
+ return super.parseExpressionStatement(...arguments);
+ }
+
+ if (this.match(types.colon)) {
+ const stmt = node;
+ stmt.label = this.finishPlaceholder(expr, "Identifier");
+ this.next();
+ stmt.body = this.parseStatement("label");
+ return this.finishNode(stmt, "LabeledStatement");
+ }
+
+ this.semicolon();
+ node.name = expr.name;
+ return this.finishPlaceholder(node, "Statement");
+ }
+
+ parseBlock() {
+ return this.parsePlaceholder("BlockStatement") || super.parseBlock(...arguments);
+ }
+
+ parseFunctionId() {
+ return this.parsePlaceholder("Identifier") || super.parseFunctionId(...arguments);
+ }
+
+ parseClass(node, isStatement, optionalId) {
+ const type = isStatement ? "ClassDeclaration" : "ClassExpression";
+ this.next();
+ this.takeDecorators(node);
+ const oldStrict = this.state.strict;
+ const placeholder = this.parsePlaceholder("Identifier");
+
+ if (placeholder) {
+ if (this.match(types._extends) || this.match(types.placeholder) || this.match(types.braceL)) {
+ node.id = placeholder;
+ } else if (optionalId || !isStatement) {
+ node.id = null;
+ node.body = this.finishPlaceholder(placeholder, "ClassBody");
+ return this.finishNode(node, type);
+ } else {
+ this.unexpected(null, "A class name is required");
+ }
+ } else {
+ this.parseClassId(node, isStatement, optionalId);
+ }
+
+ this.parseClassSuper(node);
+ node.body = this.parsePlaceholder("ClassBody") || this.parseClassBody(!!node.superClass, oldStrict);
+ return this.finishNode(node, type);
+ }
+
+ parseExport(node) {
+ const placeholder = this.parsePlaceholder("Identifier");
+ if (!placeholder) return super.parseExport(...arguments);
+
+ if (!this.isContextual("from") && !this.match(types.comma)) {
+ node.specifiers = [];
+ node.source = null;
+ node.declaration = this.finishPlaceholder(placeholder, "Declaration");
+ return this.finishNode(node, "ExportNamedDeclaration");
+ }
+
+ this.expectPlugin("exportDefaultFrom");
+ const specifier = this.startNode();
+ specifier.exported = placeholder;
+ node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
+ return super.parseExport(node);
+ }
+
+ isExportDefaultSpecifier() {
+ if (this.match(types._default)) {
+ const next = this.nextTokenStart();
+
+ if (this.isUnparsedContextual(next, "from")) {
+ if (this.input.startsWith(types.placeholder.label, this.nextTokenStartSince(next + 4))) {
+ return true;
+ }
+ }
+ }
+
+ return super.isExportDefaultSpecifier();
+ }
+
+ maybeParseExportDefaultSpecifier(node) {
+ if (node.specifiers && node.specifiers.length > 0) {
+ return true;
+ }
+
+ return super.maybeParseExportDefaultSpecifier(...arguments);
+ }
+
+ checkExport(node) {
+ const {
+ specifiers
+ } = node;
+
+ if (specifiers != null && specifiers.length) {
+ node.specifiers = specifiers.filter(node => node.exported.type === "Placeholder");
+ }
+
+ super.checkExport(node);
+ node.specifiers = specifiers;
+ }
+
+ parseImport(node) {
+ const placeholder = this.parsePlaceholder("Identifier");
+ if (!placeholder) return super.parseImport(...arguments);
+ node.specifiers = [];
+
+ if (!this.isContextual("from") && !this.match(types.comma)) {
+ node.source = this.finishPlaceholder(placeholder, "StringLiteral");
+ this.semicolon();
+ return this.finishNode(node, "ImportDeclaration");
+ }
+
+ const specifier = this.startNodeAtNode(placeholder);
+ specifier.local = placeholder;
+ this.finishNode(specifier, "ImportDefaultSpecifier");
+ node.specifiers.push(specifier);
+
+ if (this.eat(types.comma)) {
+ const hasStarImport = this.maybeParseStarImportSpecifier(node);
+ if (!hasStarImport) this.parseNamedImportSpecifiers(node);
+ }
+
+ this.expectContextual("from");
+ node.source = this.parseImportSource();
+ this.semicolon();
+ return this.finishNode(node, "ImportDeclaration");
+ }
+
+ parseImportSource() {
+ return this.parsePlaceholder("StringLiteral") || super.parseImportSource(...arguments);
+ }
+
+});
+
+var v8intrinsic = (superClass => class extends superClass {
+ parseV8Intrinsic() {
+ if (this.match(types.modulo)) {
+ const v8IntrinsicStart = this.state.start;
+ const node = this.startNode();
+ this.eat(types.modulo);
+
+ if (this.match(types.name)) {
+ const name = this.parseIdentifierName(this.state.start);
+ const identifier = this.createIdentifier(node, name);
+ identifier.type = "V8IntrinsicIdentifier";
+
+ if (this.match(types.parenL)) {
+ return identifier;
+ }
+ }
+
+ this.unexpected(v8IntrinsicStart);
+ }
+ }
+
+ parseExprAtom() {
+ return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);
+ }
+
+});
+
+function hasPlugin(plugins, name) {
+ return plugins.some(plugin => {
+ if (Array.isArray(plugin)) {
+ return plugin[0] === name;
+ } else {
+ return plugin === name;
+ }
+ });
+}
+function getPluginOption(plugins, name, option) {
+ const plugin = plugins.find(plugin => {
+ if (Array.isArray(plugin)) {
+ return plugin[0] === name;
+ } else {
+ return plugin === name;
+ }
+ });
+
+ if (plugin && Array.isArray(plugin)) {
+ return plugin[1][option];
+ }
+
+ return null;
+}
+const PIPELINE_PROPOSALS = ["minimal", "smart", "fsharp"];
+const RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
+function validatePlugins(plugins) {
+ if (hasPlugin(plugins, "decorators")) {
+ if (hasPlugin(plugins, "decorators-legacy")) {
+ throw new Error("Cannot use the decorators and decorators-legacy plugin together");
+ }
+
+ const decoratorsBeforeExport = getPluginOption(plugins, "decorators", "decoratorsBeforeExport");
+
+ if (decoratorsBeforeExport == null) {
+ throw new Error("The 'decorators' plugin requires a 'decoratorsBeforeExport' option," + " whose value must be a boolean. If you are migrating from" + " Babylon/Babel 6 or want to use the old decorators proposal, you" + " should use the 'decorators-legacy' plugin instead of 'decorators'.");
+ } else if (typeof decoratorsBeforeExport !== "boolean") {
+ throw new Error("'decoratorsBeforeExport' must be a boolean.");
+ }
+ }
+
+ if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {
+ throw new Error("Cannot combine flow and typescript plugins.");
+ }
+
+ if (hasPlugin(plugins, "placeholders") && hasPlugin(plugins, "v8intrinsic")) {
+ throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
+ }
+
+ if (hasPlugin(plugins, "pipelineOperator") && !PIPELINE_PROPOSALS.includes(getPluginOption(plugins, "pipelineOperator", "proposal"))) {
+ throw new Error("'pipelineOperator' requires 'proposal' option whose value should be one of: " + PIPELINE_PROPOSALS.map(p => `'${p}'`).join(", "));
+ }
+
+ if (hasPlugin(plugins, "moduleAttributes")) {
+ if (hasPlugin(plugins, "importAssertions")) {
+ throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
+ }
+
+ const moduleAttributesVerionPluginOption = getPluginOption(plugins, "moduleAttributes", "version");
+
+ if (moduleAttributesVerionPluginOption !== "may-2020") {
+ throw new Error("The 'moduleAttributes' plugin requires a 'version' option," + " representing the last proposal update. Currently, the" + " only supported value is 'may-2020'.");
+ }
+ }
+
+ if (hasPlugin(plugins, "recordAndTuple") && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins, "recordAndTuple", "syntaxType"))) {
+ throw new Error("'recordAndTuple' requires 'syntaxType' option whose value should be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(", "));
+ }
+}
+const mixinPlugins = {
+ estree,
+ jsx,
+ flow,
+ typescript,
+ v8intrinsic,
+ placeholders
+};
+const mixinPluginNames = Object.keys(mixinPlugins);
+
+const defaultOptions = {
+ sourceType: "script",
+ sourceFilename: undefined,
+ startLine: 1,
+ allowAwaitOutsideFunction: false,
+ allowReturnOutsideFunction: false,
+ allowImportExportEverywhere: false,
+ allowSuperOutsideMethod: false,
+ allowUndeclaredExports: false,
+ plugins: [],
+ strictMode: null,
+ ranges: false,
+ tokens: false,
+ createParenthesizedExpressions: false,
+ errorRecovery: false
+};
+function getOptions(opts) {
+ const options = {};
+
+ for (const key of Object.keys(defaultOptions)) {
+ options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];
+ }
+
+ return options;
+}
+
+class State {
+ constructor() {
+ this.strict = void 0;
+ this.curLine = void 0;
+ this.startLoc = void 0;
+ this.endLoc = void 0;
+ this.errors = [];
+ this.potentialArrowAt = -1;
+ this.noArrowAt = [];
+ this.noArrowParamsConversionAt = [];
+ this.maybeInArrowParameters = false;
+ this.inPipeline = false;
+ this.inType = false;
+ this.noAnonFunctionType = false;
+ this.inPropertyName = false;
+ this.hasFlowComment = false;
+ this.isIterator = false;
+ this.isDeclareContext = false;
+ this.inAbstractClass = false;
+ this.topicContext = {
+ maxNumOfResolvableTopics: 0,
+ maxTopicIndex: null
+ };
+ this.soloAwait = false;
+ this.inFSharpPipelineDirectBody = false;
+ this.labels = [];
+ this.decoratorStack = [[]];
+ this.comments = [];
+ this.trailingComments = [];
+ this.leadingComments = [];
+ this.commentStack = [];
+ this.commentPreviousNode = null;
+ this.pos = 0;
+ this.lineStart = 0;
+ this.type = types.eof;
+ this.value = null;
+ this.start = 0;
+ this.end = 0;
+ this.lastTokEndLoc = null;
+ this.lastTokStartLoc = null;
+ this.lastTokStart = 0;
+ this.lastTokEnd = 0;
+ this.context = [types$1.braceStatement];
+ this.exprAllowed = true;
+ this.containsEsc = false;
+ this.strictErrors = new Map();
+ this.exportedIdentifiers = [];
+ this.tokensLength = 0;
+ }
+
+ init(options) {
+ this.strict = options.strictMode === false ? false : options.sourceType === "module";
+ this.curLine = options.startLine;
+ this.startLoc = this.endLoc = this.curPosition();
+ }
+
+ curPosition() {
+ return new Position(this.curLine, this.pos - this.lineStart);
+ }
+
+ clone(skipArrays) {
+ const state = new State();
+ const keys = Object.keys(this);
+
+ for (let i = 0, length = keys.length; i < length; i++) {
+ const key = keys[i];
+ let val = this[key];
+
+ if (!skipArrays && Array.isArray(val)) {
+ val = val.slice();
+ }
+
+ state[key] = val;
+ }
+
+ return state;
+ }
+
+}
+
+var _isDigit = function isDigit(code) {
+ return code >= 48 && code <= 57;
+};
+const VALID_REGEX_FLAGS = new Set(["g", "m", "s", "i", "y", "u"]);
+const forbiddenNumericSeparatorSiblings = {
+ decBinOct: [46, 66, 69, 79, 95, 98, 101, 111],
+ hex: [46, 88, 95, 120]
+};
+const allowedNumericSeparatorSiblings = {};
+allowedNumericSeparatorSiblings.bin = [48, 49];
+allowedNumericSeparatorSiblings.oct = [...allowedNumericSeparatorSiblings.bin, 50, 51, 52, 53, 54, 55];
+allowedNumericSeparatorSiblings.dec = [...allowedNumericSeparatorSiblings.oct, 56, 57];
+allowedNumericSeparatorSiblings.hex = [...allowedNumericSeparatorSiblings.dec, 65, 66, 67, 68, 69, 70, 97, 98, 99, 100, 101, 102];
+class Token {
+ constructor(state) {
+ this.type = state.type;
+ this.value = state.value;
+ this.start = state.start;
+ this.end = state.end;
+ this.loc = new SourceLocation(state.startLoc, state.endLoc);
+ }
+
+}
+class Tokenizer extends ParserError {
+ constructor(options, input) {
+ super();
+ this.isLookahead = void 0;
+ this.tokens = [];
+ this.state = new State();
+ this.state.init(options);
+ this.input = input;
+ this.length = input.length;
+ this.isLookahead = false;
+ }
+
+ pushToken(token) {
+ this.tokens.length = this.state.tokensLength;
+ this.tokens.push(token);
+ ++this.state.tokensLength;
+ }
+
+ next() {
+ if (!this.isLookahead) {
+ this.checkKeywordEscapes();
+
+ if (this.options.tokens) {
+ this.pushToken(new Token(this.state));
+ }
+ }
+
+ this.state.lastTokEnd = this.state.end;
+ this.state.lastTokStart = this.state.start;
+ this.state.lastTokEndLoc = this.state.endLoc;
+ this.state.lastTokStartLoc = this.state.startLoc;
+ this.nextToken();
+ }
+
+ eat(type) {
+ if (this.match(type)) {
+ this.next();
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ match(type) {
+ return this.state.type === type;
+ }
+
+ lookahead() {
+ const old = this.state;
+ this.state = old.clone(true);
+ this.isLookahead = true;
+ this.next();
+ this.isLookahead = false;
+ const curr = this.state;
+ this.state = old;
+ return curr;
+ }
+
+ nextTokenStart() {
+ return this.nextTokenStartSince(this.state.pos);
+ }
+
+ nextTokenStartSince(pos) {
+ skipWhiteSpace.lastIndex = pos;
+ const skip = skipWhiteSpace.exec(this.input);
+ return pos + skip[0].length;
+ }
+
+ lookaheadCharCode() {
+ return this.input.charCodeAt(this.nextTokenStart());
+ }
+
+ setStrict(strict) {
+ this.state.strict = strict;
+
+ if (strict) {
+ this.state.strictErrors.forEach((message, pos) => this.raise(pos, message));
+ this.state.strictErrors.clear();
+ }
+ }
+
+ curContext() {
+ return this.state.context[this.state.context.length - 1];
+ }
+
+ nextToken() {
+ const curContext = this.curContext();
+ if (!(curContext != null && curContext.preserveSpace)) this.skipSpace();
+ this.state.start = this.state.pos;
+ this.state.startLoc = this.state.curPosition();
+
+ if (this.state.pos >= this.length) {
+ this.finishToken(types.eof);
+ return;
+ }
+
+ const override = curContext == null ? void 0 : curContext.override;
+
+ if (override) {
+ override(this);
+ } else {
+ this.getTokenFromCode(this.input.codePointAt(this.state.pos));
+ }
+ }
+
+ pushComment(block, text, start, end, startLoc, endLoc) {
+ const comment = {
+ type: block ? "CommentBlock" : "CommentLine",
+ value: text,
+ start: start,
+ end: end,
+ loc: new SourceLocation(startLoc, endLoc)
+ };
+ if (this.options.tokens) this.pushToken(comment);
+ this.state.comments.push(comment);
+ this.addComment(comment);
+ }
+
+ skipBlockComment() {
+ const startLoc = this.state.curPosition();
+ const start = this.state.pos;
+ const end = this.input.indexOf("*/", this.state.pos + 2);
+ if (end === -1) throw this.raise(start, ErrorMessages.UnterminatedComment);
+ this.state.pos = end + 2;
+ lineBreakG.lastIndex = start;
+ let match;
+
+ while ((match = lineBreakG.exec(this.input)) && match.index < this.state.pos) {
+ ++this.state.curLine;
+ this.state.lineStart = match.index + match[0].length;
+ }
+
+ if (this.isLookahead) return;
+ this.pushComment(true, this.input.slice(start + 2, end), start, this.state.pos, startLoc, this.state.curPosition());
+ }
+
+ skipLineComment(startSkip) {
+ const start = this.state.pos;
+ const startLoc = this.state.curPosition();
+ let ch = this.input.charCodeAt(this.state.pos += startSkip);
+
+ if (this.state.pos < this.length) {
+ while (!isNewLine(ch) && ++this.state.pos < this.length) {
+ ch = this.input.charCodeAt(this.state.pos);
+ }
+ }
+
+ if (this.isLookahead) return;
+ this.pushComment(false, this.input.slice(start + startSkip, this.state.pos), start, this.state.pos, startLoc, this.state.curPosition());
+ }
+
+ skipSpace() {
+ loop: while (this.state.pos < this.length) {
+ const ch = this.input.charCodeAt(this.state.pos);
+
+ switch (ch) {
+ case 32:
+ case 160:
+ case 9:
+ ++this.state.pos;
+ break;
+
+ case 13:
+ if (this.input.charCodeAt(this.state.pos + 1) === 10) {
+ ++this.state.pos;
+ }
+
+ case 10:
+ case 8232:
+ case 8233:
+ ++this.state.pos;
+ ++this.state.curLine;
+ this.state.lineStart = this.state.pos;
+ break;
+
+ case 47:
+ switch (this.input.charCodeAt(this.state.pos + 1)) {
+ case 42:
+ this.skipBlockComment();
+ break;
+
+ case 47:
+ this.skipLineComment(2);
+ break;
+
+ default:
+ break loop;
+ }
+
+ break;
+
+ default:
+ if (isWhitespace(ch)) {
+ ++this.state.pos;
+ } else {
+ break loop;
+ }
+
+ }
+ }
+ }
+
+ finishToken(type, val) {
+ this.state.end = this.state.pos;
+ this.state.endLoc = this.state.curPosition();
+ const prevType = this.state.type;
+ this.state.type = type;
+ this.state.value = val;
+ if (!this.isLookahead) this.updateContext(prevType);
+ }
+
+ readToken_numberSign() {
+ if (this.state.pos === 0 && this.readToken_interpreter()) {
+ return;
+ }
+
+ const nextPos = this.state.pos + 1;
+ const next = this.input.charCodeAt(nextPos);
+
+ if (next >= 48 && next <= 57) {
+ throw this.raise(this.state.pos, ErrorMessages.UnexpectedDigitAfterHash);
+ }
+
+ if (next === 123 || next === 91 && this.hasPlugin("recordAndTuple")) {
+ this.expectPlugin("recordAndTuple");
+
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "hash") {
+ throw this.raise(this.state.pos, next === 123 ? ErrorMessages.RecordExpressionHashIncorrectStartSyntaxType : ErrorMessages.TupleExpressionHashIncorrectStartSyntaxType);
+ }
+
+ if (next === 123) {
+ this.finishToken(types.braceHashL);
+ } else {
+ this.finishToken(types.bracketHashL);
+ }
+
+ this.state.pos += 2;
+ } else {
+ this.finishOp(types.hash, 1);
+ }
+ }
+
+ readToken_dot() {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next >= 48 && next <= 57) {
+ this.readNumber(true);
+ return;
+ }
+
+ if (next === 46 && this.input.charCodeAt(this.state.pos + 2) === 46) {
+ this.state.pos += 3;
+ this.finishToken(types.ellipsis);
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.dot);
+ }
+ }
+
+ readToken_slash() {
+ if (this.state.exprAllowed && !this.state.inType) {
+ ++this.state.pos;
+ this.readRegexp();
+ return;
+ }
+
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === 61) {
+ this.finishOp(types.assign, 2);
+ } else {
+ this.finishOp(types.slash, 1);
+ }
+ }
+
+ readToken_interpreter() {
+ if (this.state.pos !== 0 || this.length < 2) return false;
+ let ch = this.input.charCodeAt(this.state.pos + 1);
+ if (ch !== 33) return false;
+ const start = this.state.pos;
+ this.state.pos += 1;
+
+ while (!isNewLine(ch) && ++this.state.pos < this.length) {
+ ch = this.input.charCodeAt(this.state.pos);
+ }
+
+ const value = this.input.slice(start + 2, this.state.pos);
+ this.finishToken(types.interpreterDirective, value);
+ return true;
+ }
+
+ readToken_mult_modulo(code) {
+ let type = code === 42 ? types.star : types.modulo;
+ let width = 1;
+ let next = this.input.charCodeAt(this.state.pos + 1);
+ const exprAllowed = this.state.exprAllowed;
+
+ if (code === 42 && next === 42) {
+ width++;
+ next = this.input.charCodeAt(this.state.pos + 2);
+ type = types.exponent;
+ }
+
+ if (next === 61 && !exprAllowed) {
+ width++;
+ type = types.assign;
+ }
+
+ this.finishOp(type, width);
+ }
+
+ readToken_pipe_amp(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === code) {
+ if (this.input.charCodeAt(this.state.pos + 2) === 61) {
+ this.finishOp(types.assign, 3);
+ } else {
+ this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2);
+ }
+
+ return;
+ }
+
+ if (code === 124) {
+ if (next === 62) {
+ this.finishOp(types.pipeline, 2);
+ return;
+ }
+
+ if (this.hasPlugin("recordAndTuple") && next === 125) {
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
+ throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectEndSyntaxType);
+ }
+
+ this.finishOp(types.braceBarR, 2);
+ return;
+ }
+
+ if (this.hasPlugin("recordAndTuple") && next === 93) {
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
+ throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectEndSyntaxType);
+ }
+
+ this.finishOp(types.bracketBarR, 2);
+ return;
+ }
+ }
+
+ if (next === 61) {
+ this.finishOp(types.assign, 2);
+ return;
+ }
+
+ this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1);
+ }
+
+ readToken_caret() {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === 61) {
+ this.finishOp(types.assign, 2);
+ } else {
+ this.finishOp(types.bitwiseXOR, 1);
+ }
+ }
+
+ readToken_plus_min(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === code) {
+ if (next === 45 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 62 && (this.state.lastTokEnd === 0 || this.hasPrecedingLineBreak())) {
+ this.skipLineComment(3);
+ this.skipSpace();
+ this.nextToken();
+ return;
+ }
+
+ this.finishOp(types.incDec, 2);
+ return;
+ }
+
+ if (next === 61) {
+ this.finishOp(types.assign, 2);
+ } else {
+ this.finishOp(types.plusMin, 1);
+ }
+ }
+
+ readToken_lt_gt(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+ let size = 1;
+
+ if (next === code) {
+ size = code === 62 && this.input.charCodeAt(this.state.pos + 2) === 62 ? 3 : 2;
+
+ if (this.input.charCodeAt(this.state.pos + size) === 61) {
+ this.finishOp(types.assign, size + 1);
+ return;
+ }
+
+ this.finishOp(types.bitShift, size);
+ return;
+ }
+
+ if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.state.pos + 2) === 45 && this.input.charCodeAt(this.state.pos + 3) === 45) {
+ this.skipLineComment(4);
+ this.skipSpace();
+ this.nextToken();
+ return;
+ }
+
+ if (next === 61) {
+ size = 2;
+ }
+
+ this.finishOp(types.relational, size);
+ }
+
+ readToken_eq_excl(code) {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === 61) {
+ this.finishOp(types.equality, this.input.charCodeAt(this.state.pos + 2) === 61 ? 3 : 2);
+ return;
+ }
+
+ if (code === 61 && next === 62) {
+ this.state.pos += 2;
+ this.finishToken(types.arrow);
+ return;
+ }
+
+ this.finishOp(code === 61 ? types.eq : types.bang, 1);
+ }
+
+ readToken_question() {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+ const next2 = this.input.charCodeAt(this.state.pos + 2);
+
+ if (next === 63) {
+ if (next2 === 61) {
+ this.finishOp(types.assign, 3);
+ } else {
+ this.finishOp(types.nullishCoalescing, 2);
+ }
+ } else if (next === 46 && !(next2 >= 48 && next2 <= 57)) {
+ this.state.pos += 2;
+ this.finishToken(types.questionDot);
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.question);
+ }
+ }
+
+ getTokenFromCode(code) {
+ switch (code) {
+ case 46:
+ this.readToken_dot();
+ return;
+
+ case 40:
+ ++this.state.pos;
+ this.finishToken(types.parenL);
+ return;
+
+ case 41:
+ ++this.state.pos;
+ this.finishToken(types.parenR);
+ return;
+
+ case 59:
+ ++this.state.pos;
+ this.finishToken(types.semi);
+ return;
+
+ case 44:
+ ++this.state.pos;
+ this.finishToken(types.comma);
+ return;
+
+ case 91:
+ if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
+ throw this.raise(this.state.pos, ErrorMessages.TupleExpressionBarIncorrectStartSyntaxType);
+ }
+
+ this.finishToken(types.bracketBarL);
+ this.state.pos += 2;
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.bracketL);
+ }
+
+ return;
+
+ case 93:
+ ++this.state.pos;
+ this.finishToken(types.bracketR);
+ return;
+
+ case 123:
+ if (this.hasPlugin("recordAndTuple") && this.input.charCodeAt(this.state.pos + 1) === 124) {
+ if (this.getPluginOption("recordAndTuple", "syntaxType") !== "bar") {
+ throw this.raise(this.state.pos, ErrorMessages.RecordExpressionBarIncorrectStartSyntaxType);
+ }
+
+ this.finishToken(types.braceBarL);
+ this.state.pos += 2;
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.braceL);
+ }
+
+ return;
+
+ case 125:
+ ++this.state.pos;
+ this.finishToken(types.braceR);
+ return;
+
+ case 58:
+ if (this.hasPlugin("functionBind") && this.input.charCodeAt(this.state.pos + 1) === 58) {
+ this.finishOp(types.doubleColon, 2);
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.colon);
+ }
+
+ return;
+
+ case 63:
+ this.readToken_question();
+ return;
+
+ case 96:
+ ++this.state.pos;
+ this.finishToken(types.backQuote);
+ return;
+
+ case 48:
+ {
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (next === 120 || next === 88) {
+ this.readRadixNumber(16);
+ return;
+ }
+
+ if (next === 111 || next === 79) {
+ this.readRadixNumber(8);
+ return;
+ }
+
+ if (next === 98 || next === 66) {
+ this.readRadixNumber(2);
+ return;
+ }
+ }
+
+ case 49:
+ case 50:
+ case 51:
+ case 52:
+ case 53:
+ case 54:
+ case 55:
+ case 56:
+ case 57:
+ this.readNumber(false);
+ return;
+
+ case 34:
+ case 39:
+ this.readString(code);
+ return;
+
+ case 47:
+ this.readToken_slash();
+ return;
+
+ case 37:
+ case 42:
+ this.readToken_mult_modulo(code);
+ return;
+
+ case 124:
+ case 38:
+ this.readToken_pipe_amp(code);
+ return;
+
+ case 94:
+ this.readToken_caret();
+ return;
+
+ case 43:
+ case 45:
+ this.readToken_plus_min(code);
+ return;
+
+ case 60:
+ case 62:
+ this.readToken_lt_gt(code);
+ return;
+
+ case 61:
+ case 33:
+ this.readToken_eq_excl(code);
+ return;
+
+ case 126:
+ this.finishOp(types.tilde, 1);
+ return;
+
+ case 64:
+ ++this.state.pos;
+ this.finishToken(types.at);
+ return;
+
+ case 35:
+ this.readToken_numberSign();
+ return;
+
+ case 92:
+ this.readWord();
+ return;
+
+ default:
+ if (isIdentifierStart(code)) {
+ this.readWord();
+ return;
+ }
+
+ }
+
+ throw this.raise(this.state.pos, ErrorMessages.InvalidOrUnexpectedToken, String.fromCodePoint(code));
+ }
+
+ finishOp(type, size) {
+ const str = this.input.slice(this.state.pos, this.state.pos + size);
+ this.state.pos += size;
+ this.finishToken(type, str);
+ }
+
+ readRegexp() {
+ const start = this.state.pos;
+ let escaped, inClass;
+
+ for (;;) {
+ if (this.state.pos >= this.length) {
+ throw this.raise(start, ErrorMessages.UnterminatedRegExp);
+ }
+
+ const ch = this.input.charAt(this.state.pos);
+
+ if (lineBreak.test(ch)) {
+ throw this.raise(start, ErrorMessages.UnterminatedRegExp);
+ }
+
+ if (escaped) {
+ escaped = false;
+ } else {
+ if (ch === "[") {
+ inClass = true;
+ } else if (ch === "]" && inClass) {
+ inClass = false;
+ } else if (ch === "/" && !inClass) {
+ break;
+ }
+
+ escaped = ch === "\\";
+ }
+
+ ++this.state.pos;
+ }
+
+ const content = this.input.slice(start, this.state.pos);
+ ++this.state.pos;
+ let mods = "";
+
+ while (this.state.pos < this.length) {
+ const char = this.input[this.state.pos];
+ const charCode = this.input.codePointAt(this.state.pos);
+
+ if (VALID_REGEX_FLAGS.has(char)) {
+ if (mods.indexOf(char) > -1) {
+ this.raise(this.state.pos + 1, ErrorMessages.DuplicateRegExpFlags);
+ }
+ } else if (isIdentifierChar(charCode) || charCode === 92) {
+ this.raise(this.state.pos + 1, ErrorMessages.MalformedRegExpFlags);
+ } else {
+ break;
+ }
+
+ ++this.state.pos;
+ mods += char;
+ }
+
+ this.finishToken(types.regexp, {
+ pattern: content,
+ flags: mods
+ });
+ }
+
+ readInt(radix, len, forceLen, allowNumSeparator = true) {
+ const start = this.state.pos;
+ const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
+ const allowedSiblings = radix === 16 ? allowedNumericSeparatorSiblings.hex : radix === 10 ? allowedNumericSeparatorSiblings.dec : radix === 8 ? allowedNumericSeparatorSiblings.oct : allowedNumericSeparatorSiblings.bin;
+ let invalid = false;
+ let total = 0;
+
+ for (let i = 0, e = len == null ? Infinity : len; i < e; ++i) {
+ const code = this.input.charCodeAt(this.state.pos);
+ let val;
+
+ if (code === 95) {
+ const prev = this.input.charCodeAt(this.state.pos - 1);
+ const next = this.input.charCodeAt(this.state.pos + 1);
+
+ if (allowedSiblings.indexOf(next) === -1) {
+ this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
+ } else if (forbiddenSiblings.indexOf(prev) > -1 || forbiddenSiblings.indexOf(next) > -1 || Number.isNaN(next)) {
+ this.raise(this.state.pos, ErrorMessages.UnexpectedNumericSeparator);
+ }
+
+ if (!allowNumSeparator) {
+ this.raise(this.state.pos, ErrorMessages.NumericSeparatorInEscapeSequence);
+ }
+
+ ++this.state.pos;
+ continue;
+ }
+
+ if (code >= 97) {
+ val = code - 97 + 10;
+ } else if (code >= 65) {
+ val = code - 65 + 10;
+ } else if (_isDigit(code)) {
+ val = code - 48;
+ } else {
+ val = Infinity;
+ }
+
+ if (val >= radix) {
+ if (this.options.errorRecovery && val <= 9) {
+ val = 0;
+ this.raise(this.state.start + i + 2, ErrorMessages.InvalidDigit, radix);
+ } else if (forceLen) {
+ val = 0;
+ invalid = true;
+ } else {
+ break;
+ }
+ }
+
+ ++this.state.pos;
+ total = total * radix + val;
+ }
+
+ if (this.state.pos === start || len != null && this.state.pos - start !== len || invalid) {
+ return null;
+ }
+
+ return total;
+ }
+
+ readRadixNumber(radix) {
+ const start = this.state.pos;
+ let isBigInt = false;
+ this.state.pos += 2;
+ const val = this.readInt(radix);
+
+ if (val == null) {
+ this.raise(this.state.start + 2, ErrorMessages.InvalidDigit, radix);
+ }
+
+ const next = this.input.charCodeAt(this.state.pos);
+
+ if (next === 110) {
+ ++this.state.pos;
+ isBigInt = true;
+ } else if (next === 109) {
+ throw this.raise(start, ErrorMessages.InvalidDecimal);
+ }
+
+ if (isIdentifierStart(this.input.codePointAt(this.state.pos))) {
+ throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
+ }
+
+ if (isBigInt) {
+ const str = this.input.slice(start, this.state.pos).replace(/[_n]/g, "");
+ this.finishToken(types.bigint, str);
+ return;
+ }
+
+ this.finishToken(types.num, val);
+ }
+
+ readNumber(startsWithDot) {
+ const start = this.state.pos;
+ let isFloat = false;
+ let isBigInt = false;
+ let isDecimal = false;
+ let hasExponent = false;
+ let isOctal = false;
+
+ if (!startsWithDot && this.readInt(10) === null) {
+ this.raise(start, ErrorMessages.InvalidNumber);
+ }
+
+ const hasLeadingZero = this.state.pos - start >= 2 && this.input.charCodeAt(start) === 48;
+
+ if (hasLeadingZero) {
+ const integer = this.input.slice(start, this.state.pos);
+ this.recordStrictModeErrors(start, ErrorMessages.StrictOctalLiteral);
+
+ if (!this.state.strict) {
+ const underscorePos = integer.indexOf("_");
+
+ if (underscorePos > 0) {
+ this.raise(underscorePos + start, ErrorMessages.ZeroDigitNumericSeparator);
+ }
+ }
+
+ isOctal = hasLeadingZero && !/[89]/.test(integer);
+ }
+
+ let next = this.input.charCodeAt(this.state.pos);
+
+ if (next === 46 && !isOctal) {
+ ++this.state.pos;
+ this.readInt(10);
+ isFloat = true;
+ next = this.input.charCodeAt(this.state.pos);
+ }
+
+ if ((next === 69 || next === 101) && !isOctal) {
+ next = this.input.charCodeAt(++this.state.pos);
+
+ if (next === 43 || next === 45) {
+ ++this.state.pos;
+ }
+
+ if (this.readInt(10) === null) {
+ this.raise(start, ErrorMessages.InvalidOrMissingExponent);
+ }
+
+ isFloat = true;
+ hasExponent = true;
+ next = this.input.charCodeAt(this.state.pos);
+ }
+
+ if (next === 110) {
+ if (isFloat || hasLeadingZero) {
+ this.raise(start, ErrorMessages.InvalidBigIntLiteral);
+ }
+
+ ++this.state.pos;
+ isBigInt = true;
+ }
+
+ if (next === 109) {
+ this.expectPlugin("decimal", this.state.pos);
+
+ if (hasExponent || hasLeadingZero) {
+ this.raise(start, ErrorMessages.InvalidDecimal);
+ }
+
+ ++this.state.pos;
+ isDecimal = true;
+ }
+
+ if (isIdentifierStart(this.input.codePointAt(this.state.pos))) {
+ throw this.raise(this.state.pos, ErrorMessages.NumberIdentifier);
+ }
+
+ const str = this.input.slice(start, this.state.pos).replace(/[_mn]/g, "");
+
+ if (isBigInt) {
+ this.finishToken(types.bigint, str);
+ return;
+ }
+
+ if (isDecimal) {
+ this.finishToken(types.decimal, str);
+ return;
+ }
+
+ const val = isOctal ? parseInt(str, 8) : parseFloat(str);
+ this.finishToken(types.num, val);
+ }
+
+ readCodePoint(throwOnInvalid) {
+ const ch = this.input.charCodeAt(this.state.pos);
+ let code;
+
+ if (ch === 123) {
+ const codePos = ++this.state.pos;
+ code = this.readHexChar(this.input.indexOf("}", this.state.pos) - this.state.pos, true, throwOnInvalid);
+ ++this.state.pos;
+
+ if (code !== null && code > 0x10ffff) {
+ if (throwOnInvalid) {
+ this.raise(codePos, ErrorMessages.InvalidCodePoint);
+ } else {
+ return null;
+ }
+ }
+ } else {
+ code = this.readHexChar(4, false, throwOnInvalid);
+ }
+
+ return code;
+ }
+
+ readString(quote) {
+ let out = "",
+ chunkStart = ++this.state.pos;
+
+ for (;;) {
+ if (this.state.pos >= this.length) {
+ throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
+ }
+
+ const ch = this.input.charCodeAt(this.state.pos);
+ if (ch === quote) break;
+
+ if (ch === 92) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ out += this.readEscapedChar(false);
+ chunkStart = this.state.pos;
+ } else if (ch === 8232 || ch === 8233) {
+ ++this.state.pos;
+ ++this.state.curLine;
+ this.state.lineStart = this.state.pos;
+ } else if (isNewLine(ch)) {
+ throw this.raise(this.state.start, ErrorMessages.UnterminatedString);
+ } else {
+ ++this.state.pos;
+ }
+ }
+
+ out += this.input.slice(chunkStart, this.state.pos++);
+ this.finishToken(types.string, out);
+ }
+
+ readTmplToken() {
+ let out = "",
+ chunkStart = this.state.pos,
+ containsInvalid = false;
+
+ for (;;) {
+ if (this.state.pos >= this.length) {
+ throw this.raise(this.state.start, ErrorMessages.UnterminatedTemplate);
+ }
+
+ const ch = this.input.charCodeAt(this.state.pos);
+
+ if (ch === 96 || ch === 36 && this.input.charCodeAt(this.state.pos + 1) === 123) {
+ if (this.state.pos === this.state.start && this.match(types.template)) {
+ if (ch === 36) {
+ this.state.pos += 2;
+ this.finishToken(types.dollarBraceL);
+ return;
+ } else {
+ ++this.state.pos;
+ this.finishToken(types.backQuote);
+ return;
+ }
+ }
+
+ out += this.input.slice(chunkStart, this.state.pos);
+ this.finishToken(types.template, containsInvalid ? null : out);
+ return;
+ }
+
+ if (ch === 92) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ const escaped = this.readEscapedChar(true);
+
+ if (escaped === null) {
+ containsInvalid = true;
+ } else {
+ out += escaped;
+ }
+
+ chunkStart = this.state.pos;
+ } else if (isNewLine(ch)) {
+ out += this.input.slice(chunkStart, this.state.pos);
+ ++this.state.pos;
+
+ switch (ch) {
+ case 13:
+ if (this.input.charCodeAt(this.state.pos) === 10) {
+ ++this.state.pos;
+ }
+
+ case 10:
+ out += "\n";
+ break;
+
+ default:
+ out += String.fromCharCode(ch);
+ break;
+ }
+
+ ++this.state.curLine;
+ this.state.lineStart = this.state.pos;
+ chunkStart = this.state.pos;
+ } else {
+ ++this.state.pos;
+ }
+ }
+ }
+
+ recordStrictModeErrors(pos, message) {
+ if (this.state.strict && !this.state.strictErrors.has(pos)) {
+ this.raise(pos, message);
+ } else {
+ this.state.strictErrors.set(pos, message);
+ }
+ }
+
+ readEscapedChar(inTemplate) {
+ const throwOnInvalid = !inTemplate;
+ const ch = this.input.charCodeAt(++this.state.pos);
+ ++this.state.pos;
+
+ switch (ch) {
+ case 110:
+ return "\n";
+
+ case 114:
+ return "\r";
+
+ case 120:
+ {
+ const code = this.readHexChar(2, false, throwOnInvalid);
+ return code === null ? null : String.fromCharCode(code);
+ }
+
+ case 117:
+ {
+ const code = this.readCodePoint(throwOnInvalid);
+ return code === null ? null : String.fromCodePoint(code);
+ }
+
+ case 116:
+ return "\t";
+
+ case 98:
+ return "\b";
+
+ case 118:
+ return "\u000b";
+
+ case 102:
+ return "\f";
+
+ case 13:
+ if (this.input.charCodeAt(this.state.pos) === 10) {
+ ++this.state.pos;
+ }
+
+ case 10:
+ this.state.lineStart = this.state.pos;
+ ++this.state.curLine;
+
+ case 8232:
+ case 8233:
+ return "";
+
+ case 56:
+ case 57:
+ if (inTemplate) {
+ return null;
+ } else {
+ this.recordStrictModeErrors(this.state.pos - 1, ErrorMessages.StrictNumericEscape);
+ }
+
+ default:
+ if (ch >= 48 && ch <= 55) {
+ const codePos = this.state.pos - 1;
+ const match = this.input.substr(this.state.pos - 1, 3).match(/^[0-7]+/);
+ let octalStr = match[0];
+ let octal = parseInt(octalStr, 8);
+
+ if (octal > 255) {
+ octalStr = octalStr.slice(0, -1);
+ octal = parseInt(octalStr, 8);
+ }
+
+ this.state.pos += octalStr.length - 1;
+ const next = this.input.charCodeAt(this.state.pos);
+
+ if (octalStr !== "0" || next === 56 || next === 57) {
+ if (inTemplate) {
+ return null;
+ } else {
+ this.recordStrictModeErrors(codePos, ErrorMessages.StrictNumericEscape);
+ }
+ }
+
+ return String.fromCharCode(octal);
+ }
+
+ return String.fromCharCode(ch);
+ }
+ }
+
+ readHexChar(len, forceLen, throwOnInvalid) {
+ const codePos = this.state.pos;
+ const n = this.readInt(16, len, forceLen, false);
+
+ if (n === null) {
+ if (throwOnInvalid) {
+ this.raise(codePos, ErrorMessages.InvalidEscapeSequence);
+ } else {
+ this.state.pos = codePos - 1;
+ }
+ }
+
+ return n;
+ }
+
+ readWord1() {
+ let word = "";
+ this.state.containsEsc = false;
+ const start = this.state.pos;
+ let chunkStart = this.state.pos;
+
+ while (this.state.pos < this.length) {
+ const ch = this.input.codePointAt(this.state.pos);
+
+ if (isIdentifierChar(ch)) {
+ this.state.pos += ch <= 0xffff ? 1 : 2;
+ } else if (this.state.isIterator && ch === 64) {
+ ++this.state.pos;
+ } else if (ch === 92) {
+ this.state.containsEsc = true;
+ word += this.input.slice(chunkStart, this.state.pos);
+ const escStart = this.state.pos;
+ const identifierCheck = this.state.pos === start ? isIdentifierStart : isIdentifierChar;
+
+ if (this.input.charCodeAt(++this.state.pos) !== 117) {
+ this.raise(this.state.pos, ErrorMessages.MissingUnicodeEscape);
+ continue;
+ }
+
+ ++this.state.pos;
+ const esc = this.readCodePoint(true);
+
+ if (esc !== null) {
+ if (!identifierCheck(esc)) {
+ this.raise(escStart, ErrorMessages.EscapedCharNotAnIdentifier);
+ }
+
+ word += String.fromCodePoint(esc);
+ }
+
+ chunkStart = this.state.pos;
+ } else {
+ break;
+ }
+ }
+
+ return word + this.input.slice(chunkStart, this.state.pos);
+ }
+
+ isIterator(word) {
+ return word === "@@iterator" || word === "@@asyncIterator";
+ }
+
+ readWord() {
+ const word = this.readWord1();
+ const type = keywords.get(word) || types.name;
+
+ if (this.state.isIterator && (!this.isIterator(word) || !this.state.inType)) {
+ this.raise(this.state.pos, ErrorMessages.InvalidIdentifier, word);
+ }
+
+ this.finishToken(type, word);
+ }
+
+ checkKeywordEscapes() {
+ const kw = this.state.type.keyword;
+
+ if (kw && this.state.containsEsc) {
+ this.raise(this.state.start, ErrorMessages.InvalidEscapedReservedWord, kw);
+ }
+ }
+
+ braceIsBlock(prevType) {
+ const parent = this.curContext();
+
+ if (parent === types$1.functionExpression || parent === types$1.functionStatement) {
+ return true;
+ }
+
+ if (prevType === types.colon && (parent === types$1.braceStatement || parent === types$1.braceExpression)) {
+ return !parent.isExpr;
+ }
+
+ if (prevType === types._return || prevType === types.name && this.state.exprAllowed) {
+ return this.hasPrecedingLineBreak();
+ }
+
+ if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow) {
+ return true;
+ }
+
+ if (prevType === types.braceL) {
+ return parent === types$1.braceStatement;
+ }
+
+ if (prevType === types._var || prevType === types._const || prevType === types.name) {
+ return false;
+ }
+
+ if (prevType === types.relational) {
+ return true;
+ }
+
+ return !this.state.exprAllowed;
+ }
+
+ updateContext(prevType) {
+ const type = this.state.type;
+ let update;
+
+ if (type.keyword && (prevType === types.dot || prevType === types.questionDot)) {
+ this.state.exprAllowed = false;
+ } else if (update = type.updateContext) {
+ update.call(this, prevType);
+ } else {
+ this.state.exprAllowed = type.beforeExpr;
+ }
+ }
+
+}
+
+class ClassScope {
+ constructor() {
+ this.privateNames = new Set();
+ this.loneAccessors = new Map();
+ this.undefinedPrivateNames = new Map();
+ }
+
+}
+class ClassScopeHandler {
+ constructor(raise) {
+ this.stack = [];
+ this.undefinedPrivateNames = new Map();
+ this.raise = raise;
+ }
+
+ current() {
+ return this.stack[this.stack.length - 1];
+ }
+
+ enter() {
+ this.stack.push(new ClassScope());
+ }
+
+ exit() {
+ const oldClassScope = this.stack.pop();
+ const current = this.current();
+
+ for (const [name, pos] of Array.from(oldClassScope.undefinedPrivateNames)) {
+ if (current) {
+ if (!current.undefinedPrivateNames.has(name)) {
+ current.undefinedPrivateNames.set(name, pos);
+ }
+ } else {
+ this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
+ }
+ }
+ }
+
+ declarePrivateName(name, elementType, pos) {
+ const classScope = this.current();
+ let redefined = classScope.privateNames.has(name);
+
+ if (elementType & CLASS_ELEMENT_KIND_ACCESSOR) {
+ const accessor = redefined && classScope.loneAccessors.get(name);
+
+ if (accessor) {
+ const oldStatic = accessor & CLASS_ELEMENT_FLAG_STATIC;
+ const newStatic = elementType & CLASS_ELEMENT_FLAG_STATIC;
+ const oldKind = accessor & CLASS_ELEMENT_KIND_ACCESSOR;
+ const newKind = elementType & CLASS_ELEMENT_KIND_ACCESSOR;
+ redefined = oldKind === newKind || oldStatic !== newStatic;
+ if (!redefined) classScope.loneAccessors.delete(name);
+ } else if (!redefined) {
+ classScope.loneAccessors.set(name, elementType);
+ }
+ }
+
+ if (redefined) {
+ this.raise(pos, ErrorMessages.PrivateNameRedeclaration, name);
+ }
+
+ classScope.privateNames.add(name);
+ classScope.undefinedPrivateNames.delete(name);
+ }
+
+ usePrivateName(name, pos) {
+ let classScope;
+
+ for (classScope of this.stack) {
+ if (classScope.privateNames.has(name)) return;
+ }
+
+ if (classScope) {
+ classScope.undefinedPrivateNames.set(name, pos);
+ } else {
+ this.raise(pos, ErrorMessages.InvalidPrivateFieldResolution, name);
+ }
+ }
+
+}
+
+const kExpression = 0,
+ kMaybeArrowParameterDeclaration = 1,
+ kMaybeAsyncArrowParameterDeclaration = 2,
+ kParameterDeclaration = 3;
+
+class ExpressionScope {
+ constructor(type = kExpression) {
+ this.type = void 0;
+ this.type = type;
+ }
+
+ canBeArrowParameterDeclaration() {
+ return this.type === kMaybeAsyncArrowParameterDeclaration || this.type === kMaybeArrowParameterDeclaration;
+ }
+
+ isCertainlyParameterDeclaration() {
+ return this.type === kParameterDeclaration;
+ }
+
+}
+
+class ArrowHeadParsingScope extends ExpressionScope {
+ constructor(type) {
+ super(type);
+ this.errors = new Map();
+ }
+
+ recordDeclarationError(pos, message) {
+ this.errors.set(pos, message);
+ }
+
+ clearDeclarationError(pos) {
+ this.errors.delete(pos);
+ }
+
+ iterateErrors(iterator) {
+ this.errors.forEach(iterator);
+ }
+
+}
+
+class ExpressionScopeHandler {
+ constructor(raise) {
+ this.stack = [new ExpressionScope()];
+ this.raise = raise;
+ }
+
+ enter(scope) {
+ this.stack.push(scope);
+ }
+
+ exit() {
+ this.stack.pop();
+ }
+
+ recordParameterInitializerError(pos, message) {
+ const {
+ stack
+ } = this;
+ let i = stack.length - 1;
+ let scope = stack[i];
+
+ while (!scope.isCertainlyParameterDeclaration()) {
+ if (scope.canBeArrowParameterDeclaration()) {
+ scope.recordDeclarationError(pos, message);
+ } else {
+ return;
+ }
+
+ scope = stack[--i];
+ }
+
+ this.raise(pos, message);
+ }
+
+ recordParenthesizedIdentifierError(pos, message) {
+ const {
+ stack
+ } = this;
+ const scope = stack[stack.length - 1];
+
+ if (scope.isCertainlyParameterDeclaration()) {
+ this.raise(pos, message);
+ } else if (scope.canBeArrowParameterDeclaration()) {
+ scope.recordDeclarationError(pos, message);
+ } else {
+ return;
+ }
+ }
+
+ recordAsyncArrowParametersError(pos, message) {
+ const {
+ stack
+ } = this;
+ let i = stack.length - 1;
+ let scope = stack[i];
+
+ while (scope.canBeArrowParameterDeclaration()) {
+ if (scope.type === kMaybeAsyncArrowParameterDeclaration) {
+ scope.recordDeclarationError(pos, message);
+ }
+
+ scope = stack[--i];
+ }
+ }
+
+ validateAsPattern() {
+ const {
+ stack
+ } = this;
+ const currentScope = stack[stack.length - 1];
+ if (!currentScope.canBeArrowParameterDeclaration()) return;
+ currentScope.iterateErrors((message, pos) => {
+ this.raise(pos, message);
+ let i = stack.length - 2;
+ let scope = stack[i];
+
+ while (scope.canBeArrowParameterDeclaration()) {
+ scope.clearDeclarationError(pos);
+ scope = stack[--i];
+ }
+ });
+ }
+
+}
+function newParameterDeclarationScope() {
+ return new ExpressionScope(kParameterDeclaration);
+}
+function newArrowHeadScope() {
+ return new ArrowHeadParsingScope(kMaybeArrowParameterDeclaration);
+}
+function newAsyncArrowScope() {
+ return new ArrowHeadParsingScope(kMaybeAsyncArrowParameterDeclaration);
+}
+function newExpressionScope() {
+ return new ExpressionScope();
+}
+
+class UtilParser extends Tokenizer {
+ addExtra(node, key, val) {
+ if (!node) return;
+ const extra = node.extra = node.extra || {};
+ extra[key] = val;
+ }
+
+ isRelational(op) {
+ return this.match(types.relational) && this.state.value === op;
+ }
+
+ expectRelational(op) {
+ if (this.isRelational(op)) {
+ this.next();
+ } else {
+ this.unexpected(null, types.relational);
+ }
+ }
+
+ isContextual(name) {
+ return this.match(types.name) && this.state.value === name && !this.state.containsEsc;
+ }
+
+ isUnparsedContextual(nameStart, name) {
+ const nameEnd = nameStart + name.length;
+ return this.input.slice(nameStart, nameEnd) === name && (nameEnd === this.input.length || !isIdentifierChar(this.input.charCodeAt(nameEnd)));
+ }
+
+ isLookaheadContextual(name) {
+ const next = this.nextTokenStart();
+ return this.isUnparsedContextual(next, name);
+ }
+
+ eatContextual(name) {
+ return this.isContextual(name) && this.eat(types.name);
+ }
+
+ expectContextual(name, message) {
+ if (!this.eatContextual(name)) this.unexpected(null, message);
+ }
+
+ canInsertSemicolon() {
+ return this.match(types.eof) || this.match(types.braceR) || this.hasPrecedingLineBreak();
+ }
+
+ hasPrecedingLineBreak() {
+ return lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
+ }
+
+ hasFollowingLineBreak() {
+ return lineBreak.test(this.input.slice(this.state.end, this.nextTokenStart()));
+ }
+
+ isLineTerminator() {
+ return this.eat(types.semi) || this.canInsertSemicolon();
+ }
+
+ semicolon(allowAsi = true) {
+ if (allowAsi ? this.isLineTerminator() : this.eat(types.semi)) return;
+ this.raise(this.state.lastTokEnd, ErrorMessages.MissingSemicolon);
+ }
+
+ expect(type, pos) {
+ this.eat(type) || this.unexpected(pos, type);
+ }
+
+ assertNoSpace(message = "Unexpected space.") {
+ if (this.state.start > this.state.lastTokEnd) {
+ this.raise(this.state.lastTokEnd, message);
+ }
+ }
+
+ unexpected(pos, messageOrType = "Unexpected token") {
+ if (typeof messageOrType !== "string") {
+ messageOrType = `Unexpected token, expected "${messageOrType.label}"`;
+ }
+
+ throw this.raise(pos != null ? pos : this.state.start, messageOrType);
+ }
+
+ expectPlugin(name, pos) {
+ if (!this.hasPlugin(name)) {
+ throw this.raiseWithData(pos != null ? pos : this.state.start, {
+ missingPlugin: [name]
+ }, `This experimental syntax requires enabling the parser plugin: '${name}'`);
+ }
+
+ return true;
+ }
+
+ expectOnePlugin(names, pos) {
+ if (!names.some(n => this.hasPlugin(n))) {
+ throw this.raiseWithData(pos != null ? pos : this.state.start, {
+ missingPlugin: names
+ }, `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(", ")}'`);
+ }
+ }
+
+ tryParse(fn, oldState = this.state.clone()) {
+ const abortSignal = {
+ node: null
+ };
+
+ try {
+ const node = fn((node = null) => {
+ abortSignal.node = node;
+ throw abortSignal;
+ });
+
+ if (this.state.errors.length > oldState.errors.length) {
+ const failState = this.state;
+ this.state = oldState;
+ return {
+ node,
+ error: failState.errors[oldState.errors.length],
+ thrown: false,
+ aborted: false,
+ failState
+ };
+ }
+
+ return {
+ node,
+ error: null,
+ thrown: false,
+ aborted: false,
+ failState: null
+ };
+ } catch (error) {
+ const failState = this.state;
+ this.state = oldState;
+
+ if (error instanceof SyntaxError) {
+ return {
+ node: null,
+ error,
+ thrown: true,
+ aborted: false,
+ failState
+ };
+ }
+
+ if (error === abortSignal) {
+ return {
+ node: abortSignal.node,
+ error: null,
+ thrown: false,
+ aborted: true,
+ failState
+ };
+ }
+
+ throw error;
+ }
+ }
+
+ checkExpressionErrors(refExpressionErrors, andThrow) {
+ if (!refExpressionErrors) return false;
+ const {
+ shorthandAssign,
+ doubleProto
+ } = refExpressionErrors;
+ if (!andThrow) return shorthandAssign >= 0 || doubleProto >= 0;
+
+ if (shorthandAssign >= 0) {
+ this.unexpected(shorthandAssign);
+ }
+
+ if (doubleProto >= 0) {
+ this.raise(doubleProto, ErrorMessages.DuplicateProto);
+ }
+ }
+
+ isLiteralPropertyName() {
+ return this.match(types.name) || !!this.state.type.keyword || this.match(types.string) || this.match(types.num) || this.match(types.bigint) || this.match(types.decimal);
+ }
+
+ isPrivateName(node) {
+ return node.type === "PrivateName";
+ }
+
+ getPrivateNameSV(node) {
+ return node.id.name;
+ }
+
+ hasPropertyAsPrivateName(node) {
+ return (node.type === "MemberExpression" || node.type === "OptionalMemberExpression") && this.isPrivateName(node.property);
+ }
+
+ isOptionalChain(node) {
+ return node.type === "OptionalMemberExpression" || node.type === "OptionalCallExpression";
+ }
+
+ isObjectProperty(node) {
+ return node.type === "ObjectProperty";
+ }
+
+ isObjectMethod(node) {
+ return node.type === "ObjectMethod";
+ }
+
+ initializeScopes(inModule = this.options.sourceType === "module") {
+ const oldLabels = this.state.labels;
+ this.state.labels = [];
+ const oldExportedIdentifiers = this.state.exportedIdentifiers;
+ this.state.exportedIdentifiers = [];
+ const oldInModule = this.inModule;
+ this.inModule = inModule;
+ const oldScope = this.scope;
+ const ScopeHandler = this.getScopeHandler();
+ this.scope = new ScopeHandler(this.raise.bind(this), this.inModule);
+ const oldProdParam = this.prodParam;
+ this.prodParam = new ProductionParameterHandler();
+ const oldClassScope = this.classScope;
+ this.classScope = new ClassScopeHandler(this.raise.bind(this));
+ const oldExpressionScope = this.expressionScope;
+ this.expressionScope = new ExpressionScopeHandler(this.raise.bind(this));
+ return () => {
+ this.state.labels = oldLabels;
+ this.state.exportedIdentifiers = oldExportedIdentifiers;
+ this.inModule = oldInModule;
+ this.scope = oldScope;
+ this.prodParam = oldProdParam;
+ this.classScope = oldClassScope;
+ this.expressionScope = oldExpressionScope;
+ };
+ }
+
+ enterInitialScopes() {
+ let paramFlags = PARAM;
+
+ if (this.hasPlugin("topLevelAwait") && this.inModule) {
+ paramFlags |= PARAM_AWAIT;
+ }
+
+ this.scope.enter(SCOPE_PROGRAM);
+ this.prodParam.enter(paramFlags);
+ }
+
+}
+class ExpressionErrors {
+ constructor() {
+ this.shorthandAssign = -1;
+ this.doubleProto = -1;
+ }
+
+}
+
+class Node {
+ constructor(parser, pos, loc) {
+ this.type = void 0;
+ this.start = void 0;
+ this.end = void 0;
+ this.loc = void 0;
+ this.range = void 0;
+ this.leadingComments = void 0;
+ this.trailingComments = void 0;
+ this.innerComments = void 0;
+ this.extra = void 0;
+ this.type = "";
+ this.start = pos;
+ this.end = 0;
+ this.loc = new SourceLocation(loc);
+ if (parser != null && parser.options.ranges) this.range = [pos, 0];
+ if (parser != null && parser.filename) this.loc.filename = parser.filename;
+ }
+
+ __clone() {
+ const newNode = new Node();
+ const keys = Object.keys(this);
+
+ for (let i = 0, length = keys.length; i < length; i++) {
+ const key = keys[i];
+
+ if (key !== "leadingComments" && key !== "trailingComments" && key !== "innerComments") {
+ newNode[key] = this[key];
+ }
+ }
+
+ return newNode;
+ }
+
+}
+
+class NodeUtils extends UtilParser {
+ startNode() {
+ return new Node(this, this.state.start, this.state.startLoc);
+ }
+
+ startNodeAt(pos, loc) {
+ return new Node(this, pos, loc);
+ }
+
+ startNodeAtNode(type) {
+ return this.startNodeAt(type.start, type.loc.start);
+ }
+
+ finishNode(node, type) {
+ return this.finishNodeAt(node, type, this.state.lastTokEnd, this.state.lastTokEndLoc);
+ }
+
+ finishNodeAt(node, type, pos, loc) {
+
+ node.type = type;
+ node.end = pos;
+ node.loc.end = loc;
+ if (this.options.ranges) node.range[1] = pos;
+ this.processComment(node);
+ return node;
+ }
+
+ resetStartLocation(node, start, startLoc) {
+ node.start = start;
+ node.loc.start = startLoc;
+ if (this.options.ranges) node.range[0] = start;
+ }
+
+ resetEndLocation(node, end = this.state.lastTokEnd, endLoc = this.state.lastTokEndLoc) {
+ node.end = end;
+ node.loc.end = endLoc;
+ if (this.options.ranges) node.range[1] = end;
+ }
+
+ resetStartLocationFromNode(node, locationNode) {
+ this.resetStartLocation(node, locationNode.start, locationNode.loc.start);
+ }
+
+}
+
+const unwrapParenthesizedExpression = node => {
+ return node.type === "ParenthesizedExpression" ? unwrapParenthesizedExpression(node.expression) : node;
+};
+
+class LValParser extends NodeUtils {
+ toAssignable(node, isLHS = false) {
+ var _node$extra, _node$extra3;
+
+ let parenthesized = undefined;
+
+ if (node.type === "ParenthesizedExpression" || (_node$extra = node.extra) != null && _node$extra.parenthesized) {
+ parenthesized = unwrapParenthesizedExpression(node);
+
+ if (isLHS) {
+ if (parenthesized.type === "Identifier") {
+ this.expressionScope.recordParenthesizedIdentifierError(node.start, ErrorMessages.InvalidParenthesizedAssignment);
+ } else if (parenthesized.type !== "MemberExpression") {
+ this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
+ }
+ } else {
+ this.raise(node.start, ErrorMessages.InvalidParenthesizedAssignment);
+ }
+ }
+
+ switch (node.type) {
+ case "Identifier":
+ case "ObjectPattern":
+ case "ArrayPattern":
+ case "AssignmentPattern":
+ break;
+
+ case "ObjectExpression":
+ node.type = "ObjectPattern";
+
+ for (let i = 0, length = node.properties.length, last = length - 1; i < length; i++) {
+ var _node$extra2;
+
+ const prop = node.properties[i];
+ const isLast = i === last;
+ this.toAssignableObjectExpressionProp(prop, isLast, isLHS);
+
+ if (isLast && prop.type === "RestElement" && (_node$extra2 = node.extra) != null && _node$extra2.trailingComma) {
+ this.raiseRestNotLast(node.extra.trailingComma);
+ }
+ }
+
+ break;
+
+ case "ObjectProperty":
+ this.toAssignable(node.value, isLHS);
+ break;
+
+ case "SpreadElement":
+ {
+ this.checkToRestConversion(node);
+ node.type = "RestElement";
+ const arg = node.argument;
+ this.toAssignable(arg, isLHS);
+ break;
+ }
+
+ case "ArrayExpression":
+ node.type = "ArrayPattern";
+ this.toAssignableList(node.elements, (_node$extra3 = node.extra) == null ? void 0 : _node$extra3.trailingComma, isLHS);
+ break;
+
+ case "AssignmentExpression":
+ if (node.operator !== "=") {
+ this.raise(node.left.end, ErrorMessages.MissingEqInAssignment);
+ }
+
+ node.type = "AssignmentPattern";
+ delete node.operator;
+ this.toAssignable(node.left, isLHS);
+ break;
+
+ case "ParenthesizedExpression":
+ this.toAssignable(parenthesized, isLHS);
+ break;
+ }
+
+ return node;
+ }
+
+ toAssignableObjectExpressionProp(prop, isLast, isLHS) {
+ if (prop.type === "ObjectMethod") {
+ const error = prop.kind === "get" || prop.kind === "set" ? ErrorMessages.PatternHasAccessor : ErrorMessages.PatternHasMethod;
+ this.raise(prop.key.start, error);
+ } else if (prop.type === "SpreadElement" && !isLast) {
+ this.raiseRestNotLast(prop.start);
+ } else {
+ this.toAssignable(prop, isLHS);
+ }
+ }
+
+ toAssignableList(exprList, trailingCommaPos, isLHS) {
+ let end = exprList.length;
+
+ if (end) {
+ const last = exprList[end - 1];
+
+ if ((last == null ? void 0 : last.type) === "RestElement") {
+ --end;
+ } else if ((last == null ? void 0 : last.type) === "SpreadElement") {
+ last.type = "RestElement";
+ let arg = last.argument;
+ this.toAssignable(arg, isLHS);
+ arg = unwrapParenthesizedExpression(arg);
+
+ if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern" && arg.type !== "ObjectPattern") {
+ this.unexpected(arg.start);
+ }
+
+ if (trailingCommaPos) {
+ this.raiseTrailingCommaAfterRest(trailingCommaPos);
+ }
+
+ --end;
+ }
+ }
+
+ for (let i = 0; i < end; i++) {
+ const elt = exprList[i];
+
+ if (elt) {
+ this.toAssignable(elt, isLHS);
+
+ if (elt.type === "RestElement") {
+ this.raiseRestNotLast(elt.start);
+ }
+ }
+ }
+
+ return exprList;
+ }
+
+ toReferencedList(exprList, isParenthesizedExpr) {
+ return exprList;
+ }
+
+ toReferencedListDeep(exprList, isParenthesizedExpr) {
+ this.toReferencedList(exprList, isParenthesizedExpr);
+
+ for (const expr of exprList) {
+ if ((expr == null ? void 0 : expr.type) === "ArrayExpression") {
+ this.toReferencedListDeep(expr.elements);
+ }
+ }
+ }
+
+ parseSpread(refExpressionErrors, refNeedsArrowPos) {
+ const node = this.startNode();
+ this.next();
+ node.argument = this.parseMaybeAssignAllowIn(refExpressionErrors, undefined, refNeedsArrowPos);
+ return this.finishNode(node, "SpreadElement");
+ }
+
+ parseRestBinding() {
+ const node = this.startNode();
+ this.next();
+ node.argument = this.parseBindingAtom();
+ return this.finishNode(node, "RestElement");
+ }
+
+ parseBindingAtom() {
+ switch (this.state.type) {
+ case types.bracketL:
+ {
+ const node = this.startNode();
+ this.next();
+ node.elements = this.parseBindingList(types.bracketR, 93, true);
+ return this.finishNode(node, "ArrayPattern");
+ }
+
+ case types.braceL:
+ return this.parseObjectLike(types.braceR, true);
+ }
+
+ return this.parseIdentifier();
+ }
+
+ parseBindingList(close, closeCharCode, allowEmpty, allowModifiers) {
+ const elts = [];
+ let first = true;
+
+ while (!this.eat(close)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma);
+ }
+
+ if (allowEmpty && this.match(types.comma)) {
+ elts.push(null);
+ } else if (this.eat(close)) {
+ break;
+ } else if (this.match(types.ellipsis)) {
+ elts.push(this.parseAssignableListItemTypes(this.parseRestBinding()));
+ this.checkCommaAfterRest(closeCharCode);
+ this.expect(close);
+ break;
+ } else {
+ const decorators = [];
+
+ if (this.match(types.at) && this.hasPlugin("decorators")) {
+ this.raise(this.state.start, ErrorMessages.UnsupportedParameterDecorator);
+ }
+
+ while (this.match(types.at)) {
+ decorators.push(this.parseDecorator());
+ }
+
+ elts.push(this.parseAssignableListItem(allowModifiers, decorators));
+ }
+ }
+
+ return elts;
+ }
+
+ parseAssignableListItem(allowModifiers, decorators) {
+ const left = this.parseMaybeDefault();
+ this.parseAssignableListItemTypes(left);
+ const elt = this.parseMaybeDefault(left.start, left.loc.start, left);
+
+ if (decorators.length) {
+ left.decorators = decorators;
+ }
+
+ return elt;
+ }
+
+ parseAssignableListItemTypes(param) {
+ return param;
+ }
+
+ parseMaybeDefault(startPos, startLoc, left) {
+ var _startLoc, _startPos, _left;
+
+ startLoc = (_startLoc = startLoc) != null ? _startLoc : this.state.startLoc;
+ startPos = (_startPos = startPos) != null ? _startPos : this.state.start;
+ left = (_left = left) != null ? _left : this.parseBindingAtom();
+ if (!this.eat(types.eq)) return left;
+ const node = this.startNodeAt(startPos, startLoc);
+ node.left = left;
+ node.right = this.parseMaybeAssignAllowIn();
+ return this.finishNode(node, "AssignmentPattern");
+ }
+
+ checkLVal(expr, contextDescription, bindingType = BIND_NONE, checkClashes, disallowLetBinding, strictModeChanged = false) {
+ switch (expr.type) {
+ case "Identifier":
+ {
+ const {
+ name
+ } = expr;
+
+ if (this.state.strict && (strictModeChanged ? isStrictBindReservedWord(name, this.inModule) : isStrictBindOnlyReservedWord(name))) {
+ this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.StrictEvalArguments : ErrorMessages.StrictEvalArgumentsBinding, name);
+ }
+
+ if (checkClashes) {
+ if (checkClashes.has(name)) {
+ this.raise(expr.start, ErrorMessages.ParamDupe);
+ } else {
+ checkClashes.add(name);
+ }
+ }
+
+ if (disallowLetBinding && name === "let") {
+ this.raise(expr.start, ErrorMessages.LetInLexicalBinding);
+ }
+
+ if (!(bindingType & BIND_NONE)) {
+ this.scope.declareName(name, bindingType, expr.start);
+ }
+
+ break;
+ }
+
+ case "MemberExpression":
+ if (bindingType !== BIND_NONE) {
+ this.raise(expr.start, ErrorMessages.InvalidPropertyBindingPattern);
+ }
+
+ break;
+
+ case "ObjectPattern":
+ for (let prop of expr.properties) {
+ if (this.isObjectProperty(prop)) prop = prop.value;else if (this.isObjectMethod(prop)) continue;
+ this.checkLVal(prop, "object destructuring pattern", bindingType, checkClashes, disallowLetBinding);
+ }
+
+ break;
+
+ case "ArrayPattern":
+ for (const elem of expr.elements) {
+ if (elem) {
+ this.checkLVal(elem, "array destructuring pattern", bindingType, checkClashes, disallowLetBinding);
+ }
+ }
+
+ break;
+
+ case "AssignmentPattern":
+ this.checkLVal(expr.left, "assignment pattern", bindingType, checkClashes);
+ break;
+
+ case "RestElement":
+ this.checkLVal(expr.argument, "rest element", bindingType, checkClashes);
+ break;
+
+ case "ParenthesizedExpression":
+ this.checkLVal(expr.expression, "parenthesized expression", bindingType, checkClashes);
+ break;
+
+ default:
+ {
+ this.raise(expr.start, bindingType === BIND_NONE ? ErrorMessages.InvalidLhs : ErrorMessages.InvalidLhsBinding, contextDescription);
+ }
+ }
+ }
+
+ checkToRestConversion(node) {
+ if (node.argument.type !== "Identifier" && node.argument.type !== "MemberExpression") {
+ this.raise(node.argument.start, ErrorMessages.InvalidRestAssignmentPattern);
+ }
+ }
+
+ checkCommaAfterRest(close) {
+ if (this.match(types.comma)) {
+ if (this.lookaheadCharCode() === close) {
+ this.raiseTrailingCommaAfterRest(this.state.start);
+ } else {
+ this.raiseRestNotLast(this.state.start);
+ }
+ }
+ }
+
+ raiseRestNotLast(pos) {
+ throw this.raise(pos, ErrorMessages.ElementAfterRest);
+ }
+
+ raiseTrailingCommaAfterRest(pos) {
+ this.raise(pos, ErrorMessages.RestTrailingComma);
+ }
+
+}
+
+class ExpressionParser extends LValParser {
+ checkProto(prop, isRecord, protoRef, refExpressionErrors) {
+ if (prop.type === "SpreadElement" || this.isObjectMethod(prop) || prop.computed || prop.shorthand) {
+ return;
+ }
+
+ const key = prop.key;
+ const name = key.type === "Identifier" ? key.name : key.value;
+
+ if (name === "__proto__") {
+ if (isRecord) {
+ this.raise(key.start, ErrorMessages.RecordNoProto);
+ return;
+ }
+
+ if (protoRef.used) {
+ if (refExpressionErrors) {
+ if (refExpressionErrors.doubleProto === -1) {
+ refExpressionErrors.doubleProto = key.start;
+ }
+ } else {
+ this.raise(key.start, ErrorMessages.DuplicateProto);
+ }
+ }
+
+ protoRef.used = true;
+ }
+ }
+
+ shouldExitDescending(expr, potentialArrowAt) {
+ return expr.type === "ArrowFunctionExpression" && expr.start === potentialArrowAt;
+ }
+
+ getExpression() {
+ let paramFlags = PARAM;
+
+ if (this.hasPlugin("topLevelAwait") && this.inModule) {
+ paramFlags |= PARAM_AWAIT;
+ }
+
+ this.scope.enter(SCOPE_PROGRAM);
+ this.prodParam.enter(paramFlags);
+ this.nextToken();
+ const expr = this.parseExpression();
+
+ if (!this.match(types.eof)) {
+ this.unexpected();
+ }
+
+ expr.comments = this.state.comments;
+ expr.errors = this.state.errors;
+
+ if (this.options.tokens) {
+ expr.tokens = this.tokens;
+ }
+
+ return expr;
+ }
+
+ parseExpression(disallowIn, refExpressionErrors) {
+ if (disallowIn) {
+ return this.disallowInAnd(() => this.parseExpressionBase(refExpressionErrors));
+ }
+
+ return this.allowInAnd(() => this.parseExpressionBase(refExpressionErrors));
+ }
+
+ parseExpressionBase(refExpressionErrors) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const expr = this.parseMaybeAssign(refExpressionErrors);
+
+ if (this.match(types.comma)) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.expressions = [expr];
+
+ while (this.eat(types.comma)) {
+ node.expressions.push(this.parseMaybeAssign(refExpressionErrors));
+ }
+
+ this.toReferencedList(node.expressions);
+ return this.finishNode(node, "SequenceExpression");
+ }
+
+ return expr;
+ }
+
+ parseMaybeAssignDisallowIn(refExpressionErrors, afterLeftParse, refNeedsArrowPos) {
+ return this.disallowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos));
+ }
+
+ parseMaybeAssignAllowIn(refExpressionErrors, afterLeftParse, refNeedsArrowPos) {
+ return this.allowInAnd(() => this.parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos));
+ }
+
+ parseMaybeAssign(refExpressionErrors, afterLeftParse, refNeedsArrowPos) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+
+ if (this.isContextual("yield")) {
+ if (this.prodParam.hasYield) {
+ this.state.exprAllowed = true;
+ let left = this.parseYield();
+
+ if (afterLeftParse) {
+ left = afterLeftParse.call(this, left, startPos, startLoc);
+ }
+
+ return left;
+ }
+ }
+
+ let ownExpressionErrors;
+
+ if (refExpressionErrors) {
+ ownExpressionErrors = false;
+ } else {
+ refExpressionErrors = new ExpressionErrors();
+ ownExpressionErrors = true;
+ }
+
+ if (this.match(types.parenL) || this.match(types.name)) {
+ this.state.potentialArrowAt = this.state.start;
+ }
+
+ let left = this.parseMaybeConditional(refExpressionErrors, refNeedsArrowPos);
+
+ if (afterLeftParse) {
+ left = afterLeftParse.call(this, left, startPos, startLoc);
+ }
+
+ if (this.state.type.isAssign) {
+ const node = this.startNodeAt(startPos, startLoc);
+ const operator = this.state.value;
+ node.operator = operator;
+
+ if (this.match(types.eq)) {
+ node.left = this.toAssignable(left, true);
+ refExpressionErrors.doubleProto = -1;
+ } else {
+ node.left = left;
+ }
+
+ if (refExpressionErrors.shorthandAssign >= node.left.start) {
+ refExpressionErrors.shorthandAssign = -1;
+ }
+
+ this.checkLVal(left, "assignment expression");
+ this.next();
+ node.right = this.parseMaybeAssign();
+ return this.finishNode(node, "AssignmentExpression");
+ } else if (ownExpressionErrors) {
+ this.checkExpressionErrors(refExpressionErrors, true);
+ }
+
+ return left;
+ }
+
+ parseMaybeConditional(refExpressionErrors, refNeedsArrowPos) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const potentialArrowAt = this.state.potentialArrowAt;
+ const expr = this.parseExprOps(refExpressionErrors);
+
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
+ return expr;
+ }
+
+ return this.parseConditional(expr, startPos, startLoc, refNeedsArrowPos);
+ }
+
+ parseConditional(expr, startPos, startLoc, refNeedsArrowPos) {
+ if (this.eat(types.question)) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.test = expr;
+ node.consequent = this.parseMaybeAssignAllowIn();
+ this.expect(types.colon);
+ node.alternate = this.parseMaybeAssign();
+ return this.finishNode(node, "ConditionalExpression");
+ }
+
+ return expr;
+ }
+
+ parseExprOps(refExpressionErrors) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const potentialArrowAt = this.state.potentialArrowAt;
+ const expr = this.parseMaybeUnary(refExpressionErrors);
+
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
+ return expr;
+ }
+
+ return this.parseExprOp(expr, startPos, startLoc, -1);
+ }
+
+ parseExprOp(left, leftStartPos, leftStartLoc, minPrec) {
+ let prec = this.state.type.binop;
+
+ if (prec != null && (this.prodParam.hasIn || !this.match(types._in))) {
+ if (prec > minPrec) {
+ const op = this.state.type;
+
+ if (op === types.pipeline) {
+ this.expectPlugin("pipelineOperator");
+
+ if (this.state.inFSharpPipelineDirectBody) {
+ return left;
+ }
+
+ this.state.inPipeline = true;
+ this.checkPipelineAtInfixOperator(left, leftStartPos);
+ }
+
+ const node = this.startNodeAt(leftStartPos, leftStartLoc);
+ node.left = left;
+ node.operator = this.state.value;
+
+ if (op === types.exponent && left.type === "UnaryExpression" && (this.options.createParenthesizedExpressions || !(left.extra && left.extra.parenthesized))) {
+ this.raise(left.argument.start, ErrorMessages.UnexpectedTokenUnaryExponentiation);
+ }
+
+ const logical = op === types.logicalOR || op === types.logicalAND;
+ const coalesce = op === types.nullishCoalescing;
+
+ if (coalesce) {
+ prec = types.logicalAND.binop;
+ }
+
+ this.next();
+
+ if (op === types.pipeline && this.getPluginOption("pipelineOperator", "proposal") === "minimal") {
+ if (this.match(types.name) && this.state.value === "await" && this.prodParam.hasAwait) {
+ throw this.raise(this.state.start, ErrorMessages.UnexpectedAwaitAfterPipelineBody);
+ }
+ }
+
+ node.right = this.parseExprOpRightExpr(op, prec);
+ this.finishNode(node, logical || coalesce ? "LogicalExpression" : "BinaryExpression");
+ const nextOp = this.state.type;
+
+ if (coalesce && (nextOp === types.logicalOR || nextOp === types.logicalAND) || logical && nextOp === types.nullishCoalescing) {
+ throw this.raise(this.state.start, ErrorMessages.MixingCoalesceWithLogical);
+ }
+
+ return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);
+ }
+ }
+
+ return left;
+ }
+
+ parseExprOpRightExpr(op, prec) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+
+ switch (op) {
+ case types.pipeline:
+ switch (this.getPluginOption("pipelineOperator", "proposal")) {
+ case "smart":
+ return this.withTopicPermittingContext(() => {
+ return this.parseSmartPipelineBody(this.parseExprOpBaseRightExpr(op, prec), startPos, startLoc);
+ });
+
+ case "fsharp":
+ return this.withSoloAwaitPermittingContext(() => {
+ return this.parseFSharpPipelineBody(prec);
+ });
+ }
+
+ default:
+ return this.parseExprOpBaseRightExpr(op, prec);
+ }
+ }
+
+ parseExprOpBaseRightExpr(op, prec) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ return this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, op.rightAssociative ? prec - 1 : prec);
+ }
+
+ parseMaybeUnary(refExpressionErrors) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const isAwait = this.isContextual("await");
+
+ if (isAwait && this.isAwaitAllowed()) {
+ this.next();
+ return this.parseAwait(startPos, startLoc);
+ }
+
+ if (this.isContextual("module") && this.lookaheadCharCode() === 123 && !this.hasFollowingLineBreak()) {
+ return this.parseModuleExpression();
+ }
+
+ const update = this.match(types.incDec);
+ const node = this.startNode();
+
+ if (this.state.type.prefix) {
+ node.operator = this.state.value;
+ node.prefix = true;
+
+ if (this.match(types._throw)) {
+ this.expectPlugin("throwExpressions");
+ }
+
+ const isDelete = this.match(types._delete);
+ this.next();
+ node.argument = this.parseMaybeUnary();
+ this.checkExpressionErrors(refExpressionErrors, true);
+
+ if (this.state.strict && isDelete) {
+ const arg = node.argument;
+
+ if (arg.type === "Identifier") {
+ this.raise(node.start, ErrorMessages.StrictDelete);
+ } else if (this.hasPropertyAsPrivateName(arg)) {
+ this.raise(node.start, ErrorMessages.DeletePrivateField);
+ }
+ }
+
+ if (!update) {
+ return this.finishNode(node, "UnaryExpression");
+ }
+ }
+
+ const expr = this.parseUpdate(node, update, refExpressionErrors);
+
+ if (isAwait) {
+ const startsExpr = this.hasPlugin("v8intrinsic") ? this.state.type.startsExpr : this.state.type.startsExpr && !this.match(types.modulo);
+
+ if (startsExpr && !this.isAmbiguousAwait()) {
+ this.raiseOverwrite(startPos, this.hasPlugin("topLevelAwait") ? ErrorMessages.AwaitNotInAsyncContext : ErrorMessages.AwaitNotInAsyncFunction);
+ return this.parseAwait(startPos, startLoc);
+ }
+ }
+
+ return expr;
+ }
+
+ parseUpdate(node, update, refExpressionErrors) {
+ if (update) {
+ this.checkLVal(node.argument, "prefix operation");
+ return this.finishNode(node, "UpdateExpression");
+ }
+
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ let expr = this.parseExprSubscripts(refExpressionErrors);
+ if (this.checkExpressionErrors(refExpressionErrors, false)) return expr;
+
+ while (this.state.type.postfix && !this.canInsertSemicolon()) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.operator = this.state.value;
+ node.prefix = false;
+ node.argument = expr;
+ this.checkLVal(expr, "postfix operation");
+ this.next();
+ expr = this.finishNode(node, "UpdateExpression");
+ }
+
+ return expr;
+ }
+
+ parseExprSubscripts(refExpressionErrors) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ const potentialArrowAt = this.state.potentialArrowAt;
+ const expr = this.parseExprAtom(refExpressionErrors);
+
+ if (this.shouldExitDescending(expr, potentialArrowAt)) {
+ return expr;
+ }
+
+ return this.parseSubscripts(expr, startPos, startLoc);
+ }
+
+ parseSubscripts(base, startPos, startLoc, noCalls) {
+ const state = {
+ optionalChainMember: false,
+ maybeAsyncArrow: this.atPossibleAsyncArrow(base),
+ stop: false
+ };
+
+ do {
+ base = this.parseSubscript(base, startPos, startLoc, noCalls, state);
+ state.maybeAsyncArrow = false;
+ } while (!state.stop);
+
+ return base;
+ }
+
+ parseSubscript(base, startPos, startLoc, noCalls, state) {
+ if (!noCalls && this.eat(types.doubleColon)) {
+ return this.parseBind(base, startPos, startLoc, noCalls, state);
+ } else if (this.match(types.backQuote)) {
+ return this.parseTaggedTemplateExpression(base, startPos, startLoc, state);
+ }
+
+ let optional = false;
+
+ if (this.match(types.questionDot)) {
+ if (noCalls && this.lookaheadCharCode() === 40) {
+ state.stop = true;
+ return base;
+ }
+
+ state.optionalChainMember = optional = true;
+ this.next();
+ }
+
+ if (!noCalls && this.match(types.parenL)) {
+ return this.parseCoverCallAndAsyncArrowHead(base, startPos, startLoc, state, optional);
+ } else if (optional || this.match(types.bracketL) || this.eat(types.dot)) {
+ return this.parseMember(base, startPos, startLoc, state, optional);
+ } else {
+ state.stop = true;
+ return base;
+ }
+ }
+
+ parseMember(base, startPos, startLoc, state, optional) {
+ const node = this.startNodeAt(startPos, startLoc);
+ const computed = this.eat(types.bracketL);
+ node.object = base;
+ node.computed = computed;
+ const property = computed ? this.parseExpression() : this.parseMaybePrivateName(true);
+
+ if (this.isPrivateName(property)) {
+ if (node.object.type === "Super") {
+ this.raise(startPos, ErrorMessages.SuperPrivateField);
+ }
+
+ this.classScope.usePrivateName(this.getPrivateNameSV(property), property.start);
+ }
+
+ node.property = property;
+
+ if (computed) {
+ this.expect(types.bracketR);
+ }
+
+ if (state.optionalChainMember) {
+ node.optional = optional;
+ return this.finishNode(node, "OptionalMemberExpression");
+ } else {
+ return this.finishNode(node, "MemberExpression");
+ }
+ }
+
+ parseBind(base, startPos, startLoc, noCalls, state) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.object = base;
+ node.callee = this.parseNoCallExpr();
+ state.stop = true;
+ return this.parseSubscripts(this.finishNode(node, "BindExpression"), startPos, startLoc, noCalls);
+ }
+
+ parseCoverCallAndAsyncArrowHead(base, startPos, startLoc, state, optional) {
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
+ this.state.maybeInArrowParameters = true;
+ this.next();
+ let node = this.startNodeAt(startPos, startLoc);
+ node.callee = base;
+
+ if (state.maybeAsyncArrow) {
+ this.expressionScope.enter(newAsyncArrowScope());
+ }
+
+ if (state.optionalChainMember) {
+ node.optional = optional;
+ }
+
+ if (optional) {
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ } else {
+ node.arguments = this.parseCallExpressionArguments(types.parenR, state.maybeAsyncArrow, base.type === "Import", base.type !== "Super", node);
+ }
+
+ this.finishCallExpression(node, state.optionalChainMember);
+
+ if (state.maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
+ state.stop = true;
+ this.expressionScope.validateAsPattern();
+ this.expressionScope.exit();
+ node = this.parseAsyncArrowFromCallExpression(this.startNodeAt(startPos, startLoc), node);
+ } else {
+ if (state.maybeAsyncArrow) {
+ this.expressionScope.exit();
+ }
+
+ this.toReferencedArguments(node);
+ }
+
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
+ return node;
+ }
+
+ toReferencedArguments(node, isParenthesizedExpr) {
+ this.toReferencedListDeep(node.arguments, isParenthesizedExpr);
+ }
+
+ parseTaggedTemplateExpression(base, startPos, startLoc, state) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.tag = base;
+ node.quasi = this.parseTemplate(true);
+
+ if (state.optionalChainMember) {
+ this.raise(startPos, ErrorMessages.OptionalChainingNoTemplate);
+ }
+
+ return this.finishNode(node, "TaggedTemplateExpression");
+ }
+
+ atPossibleAsyncArrow(base) {
+ return base.type === "Identifier" && base.name === "async" && this.state.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 && base.start === this.state.potentialArrowAt;
+ }
+
+ finishCallExpression(node, optional) {
+ if (node.callee.type === "Import") {
+ if (node.arguments.length === 2) {
+ if (!this.hasPlugin("moduleAttributes")) {
+ this.expectPlugin("importAssertions");
+ }
+ }
+
+ if (node.arguments.length === 0 || node.arguments.length > 2) {
+ this.raise(node.start, ErrorMessages.ImportCallArity, this.hasPlugin("importAssertions") || this.hasPlugin("moduleAttributes") ? "one or two arguments" : "one argument");
+ } else {
+ for (const arg of node.arguments) {
+ if (arg.type === "SpreadElement") {
+ this.raise(arg.start, ErrorMessages.ImportCallSpreadArgument);
+ }
+ }
+ }
+ }
+
+ return this.finishNode(node, optional ? "OptionalCallExpression" : "CallExpression");
+ }
+
+ parseCallExpressionArguments(close, possibleAsyncArrow, dynamicImport, allowPlaceholder, nodeForExtra) {
+ const elts = [];
+ let first = true;
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
+ this.state.inFSharpPipelineDirectBody = false;
+
+ while (!this.eat(close)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma);
+
+ if (this.match(close)) {
+ if (dynamicImport && !this.hasPlugin("importAssertions") && !this.hasPlugin("moduleAttributes")) {
+ this.raise(this.state.lastTokStart, ErrorMessages.ImportCallArgumentTrailingComma);
+ }
+
+ if (nodeForExtra) {
+ this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
+ }
+
+ this.next();
+ break;
+ }
+ }
+
+ elts.push(this.parseExprListItem(false, possibleAsyncArrow ? new ExpressionErrors() : undefined, possibleAsyncArrow ? {
+ start: 0
+ } : undefined, allowPlaceholder));
+ }
+
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
+ return elts;
+ }
+
+ shouldParseAsyncArrow() {
+ return this.match(types.arrow) && !this.canInsertSemicolon();
+ }
+
+ parseAsyncArrowFromCallExpression(node, call) {
+ var _call$extra;
+
+ this.expect(types.arrow);
+ this.parseArrowExpression(node, call.arguments, true, (_call$extra = call.extra) == null ? void 0 : _call$extra.trailingComma);
+ return node;
+ }
+
+ parseNoCallExpr() {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ return this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
+ }
+
+ parseExprAtom(refExpressionErrors) {
+ if (this.state.type === types.slash) this.readRegexp();
+ const canBeArrow = this.state.potentialArrowAt === this.state.start;
+ let node;
+
+ switch (this.state.type) {
+ case types._super:
+ return this.parseSuper();
+
+ case types._import:
+ node = this.startNode();
+ this.next();
+
+ if (this.match(types.dot)) {
+ return this.parseImportMetaProperty(node);
+ }
+
+ if (!this.match(types.parenL)) {
+ this.raise(this.state.lastTokStart, ErrorMessages.UnsupportedImport);
+ }
+
+ return this.finishNode(node, "Import");
+
+ case types._this:
+ node = this.startNode();
+ this.next();
+ return this.finishNode(node, "ThisExpression");
+
+ case types.name:
+ {
+ const containsEsc = this.state.containsEsc;
+ const id = this.parseIdentifier();
+
+ if (!containsEsc && id.name === "async" && !this.canInsertSemicolon()) {
+ if (this.match(types._function)) {
+ const last = this.state.context.length - 1;
+
+ if (this.state.context[last] !== types$1.functionStatement) {
+ throw new Error("Internal error");
+ }
+
+ this.state.context[last] = types$1.functionExpression;
+ this.next();
+ return this.parseFunction(this.startNodeAtNode(id), undefined, true);
+ } else if (this.match(types.name)) {
+ return this.parseAsyncArrowUnaryFunction(id);
+ }
+ }
+
+ if (canBeArrow && this.match(types.arrow) && !this.canInsertSemicolon()) {
+ this.next();
+ return this.parseArrowExpression(this.startNodeAtNode(id), [id], false);
+ }
+
+ return id;
+ }
+
+ case types._do:
+ {
+ return this.parseDo();
+ }
+
+ case types.regexp:
+ {
+ const value = this.state.value;
+ node = this.parseLiteral(value.value, "RegExpLiteral");
+ node.pattern = value.pattern;
+ node.flags = value.flags;
+ return node;
+ }
+
+ case types.num:
+ return this.parseLiteral(this.state.value, "NumericLiteral");
+
+ case types.bigint:
+ return this.parseLiteral(this.state.value, "BigIntLiteral");
+
+ case types.decimal:
+ return this.parseLiteral(this.state.value, "DecimalLiteral");
+
+ case types.string:
+ return this.parseLiteral(this.state.value, "StringLiteral");
+
+ case types._null:
+ node = this.startNode();
+ this.next();
+ return this.finishNode(node, "NullLiteral");
+
+ case types._true:
+ case types._false:
+ return this.parseBooleanLiteral();
+
+ case types.parenL:
+ return this.parseParenAndDistinguishExpression(canBeArrow);
+
+ case types.bracketBarL:
+ case types.bracketHashL:
+ {
+ return this.parseArrayLike(this.state.type === types.bracketBarL ? types.bracketBarR : types.bracketR, false, true, refExpressionErrors);
+ }
+
+ case types.bracketL:
+ {
+ return this.parseArrayLike(types.bracketR, true, false, refExpressionErrors);
+ }
+
+ case types.braceBarL:
+ case types.braceHashL:
+ {
+ return this.parseObjectLike(this.state.type === types.braceBarL ? types.braceBarR : types.braceR, false, true, refExpressionErrors);
+ }
+
+ case types.braceL:
+ {
+ return this.parseObjectLike(types.braceR, false, false, refExpressionErrors);
+ }
+
+ case types._function:
+ return this.parseFunctionOrFunctionSent();
+
+ case types.at:
+ this.parseDecorators();
+
+ case types._class:
+ node = this.startNode();
+ this.takeDecorators(node);
+ return this.parseClass(node, false);
+
+ case types._new:
+ return this.parseNewOrNewTarget();
+
+ case types.backQuote:
+ return this.parseTemplate(false);
+
+ case types.doubleColon:
+ {
+ node = this.startNode();
+ this.next();
+ node.object = null;
+ const callee = node.callee = this.parseNoCallExpr();
+
+ if (callee.type === "MemberExpression") {
+ return this.finishNode(node, "BindExpression");
+ } else {
+ throw this.raise(callee.start, ErrorMessages.UnsupportedBind);
+ }
+ }
+
+ case types.hash:
+ {
+ if (this.state.inPipeline) {
+ node = this.startNode();
+
+ if (this.getPluginOption("pipelineOperator", "proposal") !== "smart") {
+ this.raise(node.start, ErrorMessages.PrimaryTopicRequiresSmartPipeline);
+ }
+
+ this.next();
+
+ if (!this.primaryTopicReferenceIsAllowedInCurrentTopicContext()) {
+ this.raise(node.start, ErrorMessages.PrimaryTopicNotAllowed);
+ }
+
+ this.registerTopicReference();
+ return this.finishNode(node, "PipelinePrimaryTopicReference");
+ }
+
+ const nextCh = this.input.codePointAt(this.state.end);
+
+ if (isIdentifierStart(nextCh) || nextCh === 92) {
+ const start = this.state.start;
+ node = this.parseMaybePrivateName(true);
+
+ if (this.match(types._in)) {
+ this.expectPlugin("privateIn");
+ this.classScope.usePrivateName(this.getPrivateNameSV(node), node.start);
+ } else if (this.hasPlugin("privateIn")) {
+ this.raise(this.state.start, ErrorMessages.PrivateInExpectedIn, this.getPrivateNameSV(node));
+ } else {
+ throw this.unexpected(start);
+ }
+
+ return node;
+ }
+ }
+
+ case types.relational:
+ {
+ if (this.state.value === "<") {
+ const lookaheadCh = this.input.codePointAt(this.nextTokenStart());
+
+ if (isIdentifierStart(lookaheadCh) || lookaheadCh === 62) {
+ this.expectOnePlugin(["jsx", "flow", "typescript"]);
+ }
+ }
+ }
+
+ default:
+ throw this.unexpected();
+ }
+ }
+
+ parseAsyncArrowUnaryFunction(id) {
+ const node = this.startNodeAtNode(id);
+ this.prodParam.enter(functionFlags(true, this.prodParam.hasYield));
+ const params = [this.parseIdentifier()];
+ this.prodParam.exit();
+
+ if (this.hasPrecedingLineBreak()) {
+ this.raise(this.state.pos, ErrorMessages.LineTerminatorBeforeArrow);
+ }
+
+ this.expect(types.arrow);
+ this.parseArrowExpression(node, params, true);
+ return node;
+ }
+
+ parseDo() {
+ this.expectPlugin("doExpressions");
+ const node = this.startNode();
+ this.next();
+ const oldLabels = this.state.labels;
+ this.state.labels = [];
+ node.body = this.parseBlock();
+ this.state.labels = oldLabels;
+ return this.finishNode(node, "DoExpression");
+ }
+
+ parseSuper() {
+ const node = this.startNode();
+ this.next();
+
+ if (this.match(types.parenL) && !this.scope.allowDirectSuper && !this.options.allowSuperOutsideMethod) {
+ this.raise(node.start, ErrorMessages.SuperNotAllowed);
+ } else if (!this.scope.allowSuper && !this.options.allowSuperOutsideMethod) {
+ this.raise(node.start, ErrorMessages.UnexpectedSuper);
+ }
+
+ if (!this.match(types.parenL) && !this.match(types.bracketL) && !this.match(types.dot)) {
+ this.raise(node.start, ErrorMessages.UnsupportedSuper);
+ }
+
+ return this.finishNode(node, "Super");
+ }
+
+ parseBooleanLiteral() {
+ const node = this.startNode();
+ node.value = this.match(types._true);
+ this.next();
+ return this.finishNode(node, "BooleanLiteral");
+ }
+
+ parseMaybePrivateName(isPrivateNameAllowed) {
+ const isPrivate = this.match(types.hash);
+
+ if (isPrivate) {
+ this.expectOnePlugin(["classPrivateProperties", "classPrivateMethods"]);
+
+ if (!isPrivateNameAllowed) {
+ this.raise(this.state.pos, ErrorMessages.UnexpectedPrivateField);
+ }
+
+ const node = this.startNode();
+ this.next();
+ this.assertNoSpace("Unexpected space between # and identifier");
+ node.id = this.parseIdentifier(true);
+ return this.finishNode(node, "PrivateName");
+ } else {
+ return this.parseIdentifier(true);
+ }
+ }
+
+ parseFunctionOrFunctionSent() {
+ const node = this.startNode();
+ this.next();
+
+ if (this.prodParam.hasYield && this.match(types.dot)) {
+ const meta = this.createIdentifier(this.startNodeAtNode(node), "function");
+ this.next();
+ return this.parseMetaProperty(node, meta, "sent");
+ }
+
+ return this.parseFunction(node);
+ }
+
+ parseMetaProperty(node, meta, propertyName) {
+ node.meta = meta;
+
+ if (meta.name === "function" && propertyName === "sent") {
+ if (this.isContextual(propertyName)) {
+ this.expectPlugin("functionSent");
+ } else if (!this.hasPlugin("functionSent")) {
+ this.unexpected();
+ }
+ }
+
+ const containsEsc = this.state.containsEsc;
+ node.property = this.parseIdentifier(true);
+
+ if (node.property.name !== propertyName || containsEsc) {
+ this.raise(node.property.start, ErrorMessages.UnsupportedMetaProperty, meta.name, propertyName);
+ }
+
+ return this.finishNode(node, "MetaProperty");
+ }
+
+ parseImportMetaProperty(node) {
+ const id = this.createIdentifier(this.startNodeAtNode(node), "import");
+ this.next();
+
+ if (this.isContextual("meta")) {
+ if (!this.inModule) {
+ this.raiseWithData(id.start, {
+ code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"
+ }, ErrorMessages.ImportMetaOutsideModule);
+ }
+
+ this.sawUnambiguousESM = true;
+ }
+
+ return this.parseMetaProperty(node, id, "meta");
+ }
+
+ parseLiteral(value, type, startPos, startLoc) {
+ startPos = startPos || this.state.start;
+ startLoc = startLoc || this.state.startLoc;
+ const node = this.startNodeAt(startPos, startLoc);
+ this.addExtra(node, "rawValue", value);
+ this.addExtra(node, "raw", this.input.slice(startPos, this.state.end));
+ node.value = value;
+ this.next();
+ return this.finishNode(node, type);
+ }
+
+ parseParenAndDistinguishExpression(canBeArrow) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ let val;
+ this.next();
+ this.expressionScope.enter(newArrowHeadScope());
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
+ this.state.maybeInArrowParameters = true;
+ this.state.inFSharpPipelineDirectBody = false;
+ const innerStartPos = this.state.start;
+ const innerStartLoc = this.state.startLoc;
+ const exprList = [];
+ const refExpressionErrors = new ExpressionErrors();
+ const refNeedsArrowPos = {
+ start: 0
+ };
+ let first = true;
+ let spreadStart;
+ let optionalCommaStart;
+
+ while (!this.match(types.parenR)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma, refNeedsArrowPos.start || null);
+
+ if (this.match(types.parenR)) {
+ optionalCommaStart = this.state.start;
+ break;
+ }
+ }
+
+ if (this.match(types.ellipsis)) {
+ const spreadNodeStartPos = this.state.start;
+ const spreadNodeStartLoc = this.state.startLoc;
+ spreadStart = this.state.start;
+ exprList.push(this.parseParenItem(this.parseRestBinding(), spreadNodeStartPos, spreadNodeStartLoc));
+ this.checkCommaAfterRest(41);
+ break;
+ } else {
+ exprList.push(this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem, refNeedsArrowPos));
+ }
+ }
+
+ const innerEndPos = this.state.lastTokEnd;
+ const innerEndLoc = this.state.lastTokEndLoc;
+ this.expect(types.parenR);
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
+ let arrowNode = this.startNodeAt(startPos, startLoc);
+
+ if (canBeArrow && this.shouldParseArrow() && (arrowNode = this.parseArrow(arrowNode))) {
+ this.expressionScope.validateAsPattern();
+ this.expressionScope.exit();
+ this.parseArrowExpression(arrowNode, exprList, false);
+ return arrowNode;
+ }
+
+ this.expressionScope.exit();
+
+ if (!exprList.length) {
+ this.unexpected(this.state.lastTokStart);
+ }
+
+ if (optionalCommaStart) this.unexpected(optionalCommaStart);
+ if (spreadStart) this.unexpected(spreadStart);
+ this.checkExpressionErrors(refExpressionErrors, true);
+ if (refNeedsArrowPos.start) this.unexpected(refNeedsArrowPos.start);
+ this.toReferencedListDeep(exprList, true);
+
+ if (exprList.length > 1) {
+ val = this.startNodeAt(innerStartPos, innerStartLoc);
+ val.expressions = exprList;
+ this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
+ } else {
+ val = exprList[0];
+ }
+
+ if (!this.options.createParenthesizedExpressions) {
+ this.addExtra(val, "parenthesized", true);
+ this.addExtra(val, "parenStart", startPos);
+ return val;
+ }
+
+ const parenExpression = this.startNodeAt(startPos, startLoc);
+ parenExpression.expression = val;
+ this.finishNode(parenExpression, "ParenthesizedExpression");
+ return parenExpression;
+ }
+
+ shouldParseArrow() {
+ return !this.canInsertSemicolon();
+ }
+
+ parseArrow(node) {
+ if (this.eat(types.arrow)) {
+ return node;
+ }
+ }
+
+ parseParenItem(node, startPos, startLoc) {
+ return node;
+ }
+
+ parseNewOrNewTarget() {
+ const node = this.startNode();
+ this.next();
+
+ if (this.match(types.dot)) {
+ const meta = this.createIdentifier(this.startNodeAtNode(node), "new");
+ this.next();
+ const metaProp = this.parseMetaProperty(node, meta, "target");
+
+ if (!this.scope.inNonArrowFunction && !this.scope.inClass) {
+ let error = ErrorMessages.UnexpectedNewTarget;
+
+ if (this.hasPlugin("classProperties")) {
+ error += " or class properties";
+ }
+
+ this.raise(metaProp.start, error);
+ }
+
+ return metaProp;
+ }
+
+ return this.parseNew(node);
+ }
+
+ parseNew(node) {
+ node.callee = this.parseNoCallExpr();
+
+ if (node.callee.type === "Import") {
+ this.raise(node.callee.start, ErrorMessages.ImportCallNotNewExpression);
+ } else if (this.isOptionalChain(node.callee)) {
+ this.raise(this.state.lastTokEnd, ErrorMessages.OptionalChainingNoNew);
+ } else if (this.eat(types.questionDot)) {
+ this.raise(this.state.start, ErrorMessages.OptionalChainingNoNew);
+ }
+
+ this.parseNewArguments(node);
+ return this.finishNode(node, "NewExpression");
+ }
+
+ parseNewArguments(node) {
+ if (this.eat(types.parenL)) {
+ const args = this.parseExprList(types.parenR);
+ this.toReferencedList(args);
+ node.arguments = args;
+ } else {
+ node.arguments = [];
+ }
+ }
+
+ parseTemplateElement(isTagged) {
+ const elem = this.startNode();
+
+ if (this.state.value === null) {
+ if (!isTagged) {
+ this.raise(this.state.start + 1, ErrorMessages.InvalidEscapeSequenceTemplate);
+ }
+ }
+
+ elem.value = {
+ raw: this.input.slice(this.state.start, this.state.end).replace(/\r\n?/g, "\n"),
+ cooked: this.state.value
+ };
+ this.next();
+ elem.tail = this.match(types.backQuote);
+ return this.finishNode(elem, "TemplateElement");
+ }
+
+ parseTemplate(isTagged) {
+ const node = this.startNode();
+ this.next();
+ node.expressions = [];
+ let curElt = this.parseTemplateElement(isTagged);
+ node.quasis = [curElt];
+
+ while (!curElt.tail) {
+ this.expect(types.dollarBraceL);
+ node.expressions.push(this.parseTemplateSubstitution());
+ this.expect(types.braceR);
+ node.quasis.push(curElt = this.parseTemplateElement(isTagged));
+ }
+
+ this.next();
+ return this.finishNode(node, "TemplateLiteral");
+ }
+
+ parseTemplateSubstitution() {
+ return this.parseExpression();
+ }
+
+ parseObjectLike(close, isPattern, isRecord, refExpressionErrors) {
+ if (isRecord) {
+ this.expectPlugin("recordAndTuple");
+ }
+
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
+ this.state.inFSharpPipelineDirectBody = false;
+ const propHash = Object.create(null);
+ let first = true;
+ const node = this.startNode();
+ node.properties = [];
+ this.next();
+
+ while (!this.match(close)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma);
+
+ if (this.match(close)) {
+ this.addExtra(node, "trailingComma", this.state.lastTokStart);
+ break;
+ }
+ }
+
+ const prop = this.parsePropertyDefinition(isPattern, refExpressionErrors);
+
+ if (!isPattern) {
+ this.checkProto(prop, isRecord, propHash, refExpressionErrors);
+ }
+
+ if (isRecord && !this.isObjectProperty(prop) && prop.type !== "SpreadElement") {
+ this.raise(prop.start, ErrorMessages.InvalidRecordProperty);
+ }
+
+ if (prop.shorthand) {
+ this.addExtra(prop, "shorthand", true);
+ }
+
+ node.properties.push(prop);
+ }
+
+ this.state.exprAllowed = false;
+ this.next();
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
+ let type = "ObjectExpression";
+
+ if (isPattern) {
+ type = "ObjectPattern";
+ } else if (isRecord) {
+ type = "RecordExpression";
+ }
+
+ return this.finishNode(node, type);
+ }
+
+ maybeAsyncOrAccessorProp(prop) {
+ return !prop.computed && prop.key.type === "Identifier" && (this.isLiteralPropertyName() || this.match(types.bracketL) || this.match(types.star));
+ }
+
+ parsePropertyDefinition(isPattern, refExpressionErrors) {
+ let decorators = [];
+
+ if (this.match(types.at)) {
+ if (this.hasPlugin("decorators")) {
+ this.raise(this.state.start, ErrorMessages.UnsupportedPropertyDecorator);
+ }
+
+ while (this.match(types.at)) {
+ decorators.push(this.parseDecorator());
+ }
+ }
+
+ const prop = this.startNode();
+ let isGenerator = false;
+ let isAsync = false;
+ let isAccessor = false;
+ let startPos;
+ let startLoc;
+
+ if (this.match(types.ellipsis)) {
+ if (decorators.length) this.unexpected();
+
+ if (isPattern) {
+ this.next();
+ prop.argument = this.parseIdentifier();
+ this.checkCommaAfterRest(125);
+ return this.finishNode(prop, "RestElement");
+ }
+
+ return this.parseSpread();
+ }
+
+ if (decorators.length) {
+ prop.decorators = decorators;
+ decorators = [];
+ }
+
+ prop.method = false;
+
+ if (isPattern || refExpressionErrors) {
+ startPos = this.state.start;
+ startLoc = this.state.startLoc;
+ }
+
+ if (!isPattern) {
+ isGenerator = this.eat(types.star);
+ }
+
+ const containsEsc = this.state.containsEsc;
+ const key = this.parsePropertyName(prop, false);
+
+ if (!isPattern && !isGenerator && !containsEsc && this.maybeAsyncOrAccessorProp(prop)) {
+ const keyName = key.name;
+
+ if (keyName === "async" && !this.hasPrecedingLineBreak()) {
+ isAsync = true;
+ isGenerator = this.eat(types.star);
+ this.parsePropertyName(prop, false);
+ }
+
+ if (keyName === "get" || keyName === "set") {
+ isAccessor = true;
+ prop.kind = keyName;
+
+ if (this.match(types.star)) {
+ isGenerator = true;
+ this.raise(this.state.pos, ErrorMessages.AccessorIsGenerator, keyName);
+ this.next();
+ }
+
+ this.parsePropertyName(prop, false);
+ }
+ }
+
+ this.parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors);
+ return prop;
+ }
+
+ getGetterSetterExpectedParamCount(method) {
+ return method.kind === "get" ? 0 : 1;
+ }
+
+ getObjectOrClassMethodParams(method) {
+ return method.params;
+ }
+
+ checkGetterSetterParams(method) {
+ var _params;
+
+ const paramCount = this.getGetterSetterExpectedParamCount(method);
+ const params = this.getObjectOrClassMethodParams(method);
+ const start = method.start;
+
+ if (params.length !== paramCount) {
+ if (method.kind === "get") {
+ this.raise(start, ErrorMessages.BadGetterArity);
+ } else {
+ this.raise(start, ErrorMessages.BadSetterArity);
+ }
+ }
+
+ if (method.kind === "set" && ((_params = params[params.length - 1]) == null ? void 0 : _params.type) === "RestElement") {
+ this.raise(start, ErrorMessages.BadSetterRestParameter);
+ }
+ }
+
+ parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) {
+ if (isAccessor) {
+ this.parseMethod(prop, isGenerator, false, false, false, "ObjectMethod");
+ this.checkGetterSetterParams(prop);
+ return prop;
+ }
+
+ if (isAsync || isGenerator || this.match(types.parenL)) {
+ if (isPattern) this.unexpected();
+ prop.kind = "method";
+ prop.method = true;
+ return this.parseMethod(prop, isGenerator, isAsync, false, false, "ObjectMethod");
+ }
+ }
+
+ parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors) {
+ prop.shorthand = false;
+
+ if (this.eat(types.colon)) {
+ prop.value = isPattern ? this.parseMaybeDefault(this.state.start, this.state.startLoc) : this.parseMaybeAssignAllowIn(refExpressionErrors);
+ return this.finishNode(prop, "ObjectProperty");
+ }
+
+ if (!prop.computed && prop.key.type === "Identifier") {
+ this.checkReservedWord(prop.key.name, prop.key.start, true, false);
+
+ if (isPattern) {
+ prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
+ } else if (this.match(types.eq) && refExpressionErrors) {
+ if (refExpressionErrors.shorthandAssign === -1) {
+ refExpressionErrors.shorthandAssign = this.state.start;
+ }
+
+ prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
+ } else {
+ prop.value = prop.key.__clone();
+ }
+
+ prop.shorthand = true;
+ return this.finishNode(prop, "ObjectProperty");
+ }
+ }
+
+ parseObjPropValue(prop, startPos, startLoc, isGenerator, isAsync, isPattern, isAccessor, refExpressionErrors) {
+ const node = this.parseObjectMethod(prop, isGenerator, isAsync, isPattern, isAccessor) || this.parseObjectProperty(prop, startPos, startLoc, isPattern, refExpressionErrors);
+ if (!node) this.unexpected();
+ return node;
+ }
+
+ parsePropertyName(prop, isPrivateNameAllowed) {
+ if (this.eat(types.bracketL)) {
+ prop.computed = true;
+ prop.key = this.parseMaybeAssignAllowIn();
+ this.expect(types.bracketR);
+ } else {
+ const oldInPropertyName = this.state.inPropertyName;
+ this.state.inPropertyName = true;
+ prop.key = this.match(types.num) || this.match(types.string) || this.match(types.bigint) || this.match(types.decimal) ? this.parseExprAtom() : this.parseMaybePrivateName(isPrivateNameAllowed);
+
+ if (!this.isPrivateName(prop.key)) {
+ prop.computed = false;
+ }
+
+ this.state.inPropertyName = oldInPropertyName;
+ }
+
+ return prop.key;
+ }
+
+ initFunction(node, isAsync) {
+ node.id = null;
+ node.generator = false;
+ node.async = !!isAsync;
+ }
+
+ parseMethod(node, isGenerator, isAsync, isConstructor, allowDirectSuper, type, inClassScope = false) {
+ this.initFunction(node, isAsync);
+ node.generator = !!isGenerator;
+ const allowModifiers = isConstructor;
+ this.scope.enter(SCOPE_FUNCTION | SCOPE_SUPER | (inClassScope ? SCOPE_CLASS : 0) | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
+ this.prodParam.enter(functionFlags(isAsync, node.generator));
+ this.parseFunctionParams(node, allowModifiers);
+ this.parseFunctionBodyAndFinish(node, type, true);
+ this.prodParam.exit();
+ this.scope.exit();
+ return node;
+ }
+
+ parseArrayLike(close, canBePattern, isTuple, refExpressionErrors) {
+ if (isTuple) {
+ this.expectPlugin("recordAndTuple");
+ }
+
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
+ this.state.inFSharpPipelineDirectBody = false;
+ const node = this.startNode();
+ this.next();
+ node.elements = this.parseExprList(close, !isTuple, refExpressionErrors, node);
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
+ return this.finishNode(node, isTuple ? "TupleExpression" : "ArrayExpression");
+ }
+
+ parseArrowExpression(node, params, isAsync, trailingCommaPos) {
+ this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);
+ let flags = functionFlags(isAsync, false);
+
+ if (!this.match(types.bracketL) && this.prodParam.hasIn) {
+ flags |= PARAM_IN;
+ }
+
+ this.prodParam.enter(flags);
+ this.initFunction(node, isAsync);
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
+
+ if (params) {
+ this.state.maybeInArrowParameters = true;
+ this.setArrowFunctionParameters(node, params, trailingCommaPos);
+ }
+
+ this.state.maybeInArrowParameters = false;
+ this.parseFunctionBody(node, true);
+ this.prodParam.exit();
+ this.scope.exit();
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
+ return this.finishNode(node, "ArrowFunctionExpression");
+ }
+
+ setArrowFunctionParameters(node, params, trailingCommaPos) {
+ node.params = this.toAssignableList(params, trailingCommaPos, false);
+ }
+
+ parseFunctionBodyAndFinish(node, type, isMethod = false) {
+ this.parseFunctionBody(node, false, isMethod);
+ this.finishNode(node, type);
+ }
+
+ parseFunctionBody(node, allowExpression, isMethod = false) {
+ const isExpression = allowExpression && !this.match(types.braceL);
+ this.expressionScope.enter(newExpressionScope());
+
+ if (isExpression) {
+ node.body = this.parseMaybeAssign();
+ this.checkParams(node, false, allowExpression, false);
+ } else {
+ const oldStrict = this.state.strict;
+ const oldLabels = this.state.labels;
+ this.state.labels = [];
+ this.prodParam.enter(this.prodParam.currentFlags() | PARAM_RETURN);
+ node.body = this.parseBlock(true, false, hasStrictModeDirective => {
+ const nonSimple = !this.isSimpleParamList(node.params);
+
+ if (hasStrictModeDirective && nonSimple) {
+ const errorPos = (node.kind === "method" || node.kind === "constructor") && !!node.key ? node.key.end : node.start;
+ this.raise(errorPos, ErrorMessages.IllegalLanguageModeDirective);
+ }
+
+ const strictModeChanged = !oldStrict && this.state.strict;
+ this.checkParams(node, !this.state.strict && !allowExpression && !isMethod && !nonSimple, allowExpression, strictModeChanged);
+
+ if (this.state.strict && node.id) {
+ this.checkLVal(node.id, "function name", BIND_OUTSIDE, undefined, undefined, strictModeChanged);
+ }
+ });
+ this.prodParam.exit();
+ this.expressionScope.exit();
+ this.state.labels = oldLabels;
+ }
+ }
+
+ isSimpleParamList(params) {
+ for (let i = 0, len = params.length; i < len; i++) {
+ if (params[i].type !== "Identifier") return false;
+ }
+
+ return true;
+ }
+
+ checkParams(node, allowDuplicates, isArrowFunction, strictModeChanged = true) {
+ const checkClashes = new Set();
+
+ for (const param of node.params) {
+ this.checkLVal(param, "function parameter list", BIND_VAR, allowDuplicates ? null : checkClashes, undefined, strictModeChanged);
+ }
+ }
+
+ parseExprList(close, allowEmpty, refExpressionErrors, nodeForExtra) {
+ const elts = [];
+ let first = true;
+
+ while (!this.eat(close)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma);
+
+ if (this.match(close)) {
+ if (nodeForExtra) {
+ this.addExtra(nodeForExtra, "trailingComma", this.state.lastTokStart);
+ }
+
+ this.next();
+ break;
+ }
+ }
+
+ elts.push(this.parseExprListItem(allowEmpty, refExpressionErrors));
+ }
+
+ return elts;
+ }
+
+ parseExprListItem(allowEmpty, refExpressionErrors, refNeedsArrowPos, allowPlaceholder) {
+ let elt;
+
+ if (this.match(types.comma)) {
+ if (!allowEmpty) {
+ this.raise(this.state.pos, ErrorMessages.UnexpectedToken, ",");
+ }
+
+ elt = null;
+ } else if (this.match(types.ellipsis)) {
+ const spreadNodeStartPos = this.state.start;
+ const spreadNodeStartLoc = this.state.startLoc;
+ elt = this.parseParenItem(this.parseSpread(refExpressionErrors, refNeedsArrowPos), spreadNodeStartPos, spreadNodeStartLoc);
+ } else if (this.match(types.question)) {
+ this.expectPlugin("partialApplication");
+
+ if (!allowPlaceholder) {
+ this.raise(this.state.start, ErrorMessages.UnexpectedArgumentPlaceholder);
+ }
+
+ const node = this.startNode();
+ this.next();
+ elt = this.finishNode(node, "ArgumentPlaceholder");
+ } else {
+ elt = this.parseMaybeAssignAllowIn(refExpressionErrors, this.parseParenItem, refNeedsArrowPos);
+ }
+
+ return elt;
+ }
+
+ parseIdentifier(liberal) {
+ const node = this.startNode();
+ const name = this.parseIdentifierName(node.start, liberal);
+ return this.createIdentifier(node, name);
+ }
+
+ createIdentifier(node, name) {
+ node.name = name;
+ node.loc.identifierName = name;
+ return this.finishNode(node, "Identifier");
+ }
+
+ parseIdentifierName(pos, liberal) {
+ let name;
+ const {
+ start,
+ type
+ } = this.state;
+
+ if (type === types.name) {
+ name = this.state.value;
+ } else if (type.keyword) {
+ name = type.keyword;
+ const curContext = this.curContext();
+
+ if ((type === types._class || type === types._function) && (curContext === types$1.functionStatement || curContext === types$1.functionExpression)) {
+ this.state.context.pop();
+ }
+ } else {
+ throw this.unexpected();
+ }
+
+ if (liberal) {
+ this.state.type = types.name;
+ } else {
+ this.checkReservedWord(name, start, !!type.keyword, false);
+ }
+
+ this.next();
+ return name;
+ }
+
+ checkReservedWord(word, startLoc, checkKeywords, isBinding) {
+ if (this.prodParam.hasYield && word === "yield") {
+ this.raise(startLoc, ErrorMessages.YieldBindingIdentifier);
+ return;
+ }
+
+ if (word === "await") {
+ if (this.prodParam.hasAwait) {
+ this.raise(startLoc, ErrorMessages.AwaitBindingIdentifier);
+ return;
+ } else if (this.scope.inStaticBlock && !this.scope.inNonArrowFunction) {
+ this.raise(startLoc, ErrorMessages.AwaitBindingIdentifierInStaticBlock);
+ return;
+ } else {
+ this.expressionScope.recordAsyncArrowParametersError(startLoc, ErrorMessages.AwaitBindingIdentifier);
+ }
+ }
+
+ if (this.scope.inClass && !this.scope.inNonArrowFunction && word === "arguments") {
+ this.raise(startLoc, ErrorMessages.ArgumentsInClass);
+ return;
+ }
+
+ if (checkKeywords && isKeyword(word)) {
+ this.raise(startLoc, ErrorMessages.UnexpectedKeyword, word);
+ return;
+ }
+
+ const reservedTest = !this.state.strict ? isReservedWord : isBinding ? isStrictBindReservedWord : isStrictReservedWord;
+
+ if (reservedTest(word, this.inModule)) {
+ this.raise(startLoc, ErrorMessages.UnexpectedReservedWord, word);
+ }
+ }
+
+ isAwaitAllowed() {
+ if (this.prodParam.hasAwait) return true;
+
+ if (this.options.allowAwaitOutsideFunction && !this.scope.inFunction) {
+ return true;
+ }
+
+ return false;
+ }
+
+ parseAwait(startPos, startLoc) {
+ const node = this.startNodeAt(startPos, startLoc);
+ this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.AwaitExpressionFormalParameter);
+
+ if (this.eat(types.star)) {
+ this.raise(node.start, ErrorMessages.ObsoleteAwaitStar);
+ }
+
+ if (!this.scope.inFunction && !this.options.allowAwaitOutsideFunction) {
+ if (this.isAmbiguousAwait()) {
+ this.ambiguousScriptDifferentAst = true;
+ } else {
+ this.sawUnambiguousESM = true;
+ }
+ }
+
+ if (!this.state.soloAwait) {
+ node.argument = this.parseMaybeUnary();
+ }
+
+ return this.finishNode(node, "AwaitExpression");
+ }
+
+ isAmbiguousAwait() {
+ return this.hasPrecedingLineBreak() || this.match(types.plusMin) || this.match(types.parenL) || this.match(types.bracketL) || this.match(types.backQuote) || this.match(types.regexp) || this.match(types.slash) || this.hasPlugin("v8intrinsic") && this.match(types.modulo);
+ }
+
+ parseYield() {
+ const node = this.startNode();
+ this.expressionScope.recordParameterInitializerError(node.start, ErrorMessages.YieldInParameter);
+ this.next();
+
+ if (this.match(types.semi) || !this.match(types.star) && !this.state.type.startsExpr || this.hasPrecedingLineBreak()) {
+ node.delegate = false;
+ node.argument = null;
+ } else {
+ node.delegate = this.eat(types.star);
+ node.argument = this.parseMaybeAssign();
+ }
+
+ return this.finishNode(node, "YieldExpression");
+ }
+
+ checkPipelineAtInfixOperator(left, leftStartPos) {
+ if (this.getPluginOption("pipelineOperator", "proposal") === "smart") {
+ if (left.type === "SequenceExpression") {
+ this.raise(leftStartPos, ErrorMessages.PipelineHeadSequenceExpression);
+ }
+ }
+ }
+
+ parseSmartPipelineBody(childExpression, startPos, startLoc) {
+ this.checkSmartPipelineBodyEarlyErrors(childExpression, startPos);
+ return this.parseSmartPipelineBodyInStyle(childExpression, startPos, startLoc);
+ }
+
+ checkSmartPipelineBodyEarlyErrors(childExpression, startPos) {
+ if (this.match(types.arrow)) {
+ throw this.raise(this.state.start, ErrorMessages.PipelineBodyNoArrow);
+ } else if (childExpression.type === "SequenceExpression") {
+ this.raise(startPos, ErrorMessages.PipelineBodySequenceExpression);
+ }
+ }
+
+ parseSmartPipelineBodyInStyle(childExpression, startPos, startLoc) {
+ const bodyNode = this.startNodeAt(startPos, startLoc);
+ const isSimpleReference = this.isSimpleReference(childExpression);
+
+ if (isSimpleReference) {
+ bodyNode.callee = childExpression;
+ } else {
+ if (!this.topicReferenceWasUsedInCurrentTopicContext()) {
+ this.raise(startPos, ErrorMessages.PipelineTopicUnused);
+ }
+
+ bodyNode.expression = childExpression;
+ }
+
+ return this.finishNode(bodyNode, isSimpleReference ? "PipelineBareFunction" : "PipelineTopicExpression");
+ }
+
+ isSimpleReference(expression) {
+ switch (expression.type) {
+ case "MemberExpression":
+ return !expression.computed && this.isSimpleReference(expression.object);
+
+ case "Identifier":
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+ withTopicPermittingContext(callback) {
+ const outerContextTopicState = this.state.topicContext;
+ this.state.topicContext = {
+ maxNumOfResolvableTopics: 1,
+ maxTopicIndex: null
+ };
+
+ try {
+ return callback();
+ } finally {
+ this.state.topicContext = outerContextTopicState;
+ }
+ }
+
+ withTopicForbiddingContext(callback) {
+ const outerContextTopicState = this.state.topicContext;
+ this.state.topicContext = {
+ maxNumOfResolvableTopics: 0,
+ maxTopicIndex: null
+ };
+
+ try {
+ return callback();
+ } finally {
+ this.state.topicContext = outerContextTopicState;
+ }
+ }
+
+ withSoloAwaitPermittingContext(callback) {
+ const outerContextSoloAwaitState = this.state.soloAwait;
+ this.state.soloAwait = true;
+
+ try {
+ return callback();
+ } finally {
+ this.state.soloAwait = outerContextSoloAwaitState;
+ }
+ }
+
+ allowInAnd(callback) {
+ const flags = this.prodParam.currentFlags();
+ const prodParamToSet = PARAM_IN & ~flags;
+
+ if (prodParamToSet) {
+ this.prodParam.enter(flags | PARAM_IN);
+
+ try {
+ return callback();
+ } finally {
+ this.prodParam.exit();
+ }
+ }
+
+ return callback();
+ }
+
+ disallowInAnd(callback) {
+ const flags = this.prodParam.currentFlags();
+ const prodParamToClear = PARAM_IN & flags;
+
+ if (prodParamToClear) {
+ this.prodParam.enter(flags & ~PARAM_IN);
+
+ try {
+ return callback();
+ } finally {
+ this.prodParam.exit();
+ }
+ }
+
+ return callback();
+ }
+
+ registerTopicReference() {
+ this.state.topicContext.maxTopicIndex = 0;
+ }
+
+ primaryTopicReferenceIsAllowedInCurrentTopicContext() {
+ return this.state.topicContext.maxNumOfResolvableTopics >= 1;
+ }
+
+ topicReferenceWasUsedInCurrentTopicContext() {
+ return this.state.topicContext.maxTopicIndex != null && this.state.topicContext.maxTopicIndex >= 0;
+ }
+
+ parseFSharpPipelineBody(prec) {
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ this.state.potentialArrowAt = this.state.start;
+ const oldInFSharpPipelineDirectBody = this.state.inFSharpPipelineDirectBody;
+ this.state.inFSharpPipelineDirectBody = true;
+ const ret = this.parseExprOp(this.parseMaybeUnary(), startPos, startLoc, prec);
+ this.state.inFSharpPipelineDirectBody = oldInFSharpPipelineDirectBody;
+ return ret;
+ }
+
+ parseModuleExpression() {
+ this.expectPlugin("moduleBlocks");
+ const node = this.startNode();
+ this.next();
+ this.eat(types.braceL);
+ const revertScopes = this.initializeScopes(true);
+ this.enterInitialScopes();
+ const program = this.startNode();
+
+ try {
+ node.body = this.parseProgram(program, types.braceR, "module");
+ } finally {
+ revertScopes();
+ }
+
+ this.eat(types.braceR);
+ return this.finishNode(node, "ModuleExpression");
+ }
+
+}
+
+const loopLabel = {
+ kind: "loop"
+},
+ switchLabel = {
+ kind: "switch"
+};
+const FUNC_NO_FLAGS = 0b000,
+ FUNC_STATEMENT = 0b001,
+ FUNC_HANGING_STATEMENT = 0b010,
+ FUNC_NULLABLE_ID = 0b100;
+const loneSurrogate = /[\uD800-\uDFFF]/u;
+class StatementParser extends ExpressionParser {
+ parseTopLevel(file, program) {
+ file.program = this.parseProgram(program);
+ file.comments = this.state.comments;
+ if (this.options.tokens) file.tokens = this.tokens;
+ return this.finishNode(file, "File");
+ }
+
+ parseProgram(program, end = types.eof, sourceType = this.options.sourceType) {
+ program.sourceType = sourceType;
+ program.interpreter = this.parseInterpreterDirective();
+ this.parseBlockBody(program, true, true, end);
+
+ if (this.inModule && !this.options.allowUndeclaredExports && this.scope.undefinedExports.size > 0) {
+ for (const [name] of Array.from(this.scope.undefinedExports)) {
+ const pos = this.scope.undefinedExports.get(name);
+ this.raise(pos, ErrorMessages.ModuleExportUndefined, name);
+ }
+ }
+
+ return this.finishNode(program, "Program");
+ }
+
+ stmtToDirective(stmt) {
+ const expr = stmt.expression;
+ const directiveLiteral = this.startNodeAt(expr.start, expr.loc.start);
+ const directive = this.startNodeAt(stmt.start, stmt.loc.start);
+ const raw = this.input.slice(expr.start, expr.end);
+ const val = directiveLiteral.value = raw.slice(1, -1);
+ this.addExtra(directiveLiteral, "raw", raw);
+ this.addExtra(directiveLiteral, "rawValue", val);
+ directive.value = this.finishNodeAt(directiveLiteral, "DirectiveLiteral", expr.end, expr.loc.end);
+ return this.finishNodeAt(directive, "Directive", stmt.end, stmt.loc.end);
+ }
+
+ parseInterpreterDirective() {
+ if (!this.match(types.interpreterDirective)) {
+ return null;
+ }
+
+ const node = this.startNode();
+ node.value = this.state.value;
+ this.next();
+ return this.finishNode(node, "InterpreterDirective");
+ }
+
+ isLet(context) {
+ if (!this.isContextual("let")) {
+ return false;
+ }
+
+ const next = this.nextTokenStart();
+ const nextCh = this.input.charCodeAt(next);
+ if (nextCh === 91) return true;
+ if (context) return false;
+ if (nextCh === 123) return true;
+
+ if (isIdentifierStart(nextCh)) {
+ let pos = next + 1;
+
+ while (isIdentifierChar(this.input.charCodeAt(pos))) {
+ ++pos;
+ }
+
+ const ident = this.input.slice(next, pos);
+ if (!keywordRelationalOperator.test(ident)) return true;
+ }
+
+ return false;
+ }
+
+ parseStatement(context, topLevel) {
+ if (this.match(types.at)) {
+ this.parseDecorators(true);
+ }
+
+ return this.parseStatementContent(context, topLevel);
+ }
+
+ parseStatementContent(context, topLevel) {
+ let starttype = this.state.type;
+ const node = this.startNode();
+ let kind;
+
+ if (this.isLet(context)) {
+ starttype = types._var;
+ kind = "let";
+ }
+
+ switch (starttype) {
+ case types._break:
+ case types._continue:
+ return this.parseBreakContinueStatement(node, starttype.keyword);
+
+ case types._debugger:
+ return this.parseDebuggerStatement(node);
+
+ case types._do:
+ return this.parseDoStatement(node);
+
+ case types._for:
+ return this.parseForStatement(node);
+
+ case types._function:
+ if (this.lookaheadCharCode() === 46) break;
+
+ if (context) {
+ if (this.state.strict) {
+ this.raise(this.state.start, ErrorMessages.StrictFunction);
+ } else if (context !== "if" && context !== "label") {
+ this.raise(this.state.start, ErrorMessages.SloppyFunction);
+ }
+ }
+
+ return this.parseFunctionStatement(node, false, !context);
+
+ case types._class:
+ if (context) this.unexpected();
+ return this.parseClass(node, true);
+
+ case types._if:
+ return this.parseIfStatement(node);
+
+ case types._return:
+ return this.parseReturnStatement(node);
+
+ case types._switch:
+ return this.parseSwitchStatement(node);
+
+ case types._throw:
+ return this.parseThrowStatement(node);
+
+ case types._try:
+ return this.parseTryStatement(node);
+
+ case types._const:
+ case types._var:
+ kind = kind || this.state.value;
+
+ if (context && kind !== "var") {
+ this.raise(this.state.start, ErrorMessages.UnexpectedLexicalDeclaration);
+ }
+
+ return this.parseVarStatement(node, kind);
+
+ case types._while:
+ return this.parseWhileStatement(node);
+
+ case types._with:
+ return this.parseWithStatement(node);
+
+ case types.braceL:
+ return this.parseBlock();
+
+ case types.semi:
+ return this.parseEmptyStatement(node);
+
+ case types._import:
+ {
+ const nextTokenCharCode = this.lookaheadCharCode();
+
+ if (nextTokenCharCode === 40 || nextTokenCharCode === 46) {
+ break;
+ }
+ }
+
+ case types._export:
+ {
+ if (!this.options.allowImportExportEverywhere && !topLevel) {
+ this.raise(this.state.start, ErrorMessages.UnexpectedImportExport);
+ }
+
+ this.next();
+ let result;
+
+ if (starttype === types._import) {
+ result = this.parseImport(node);
+
+ if (result.type === "ImportDeclaration" && (!result.importKind || result.importKind === "value")) {
+ this.sawUnambiguousESM = true;
+ }
+ } else {
+ result = this.parseExport(node);
+
+ if (result.type === "ExportNamedDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportAllDeclaration" && (!result.exportKind || result.exportKind === "value") || result.type === "ExportDefaultDeclaration") {
+ this.sawUnambiguousESM = true;
+ }
+ }
+
+ this.assertModuleNodeAllowed(node);
+ return result;
+ }
+
+ default:
+ {
+ if (this.isAsyncFunction()) {
+ if (context) {
+ this.raise(this.state.start, ErrorMessages.AsyncFunctionInSingleStatementContext);
+ }
+
+ this.next();
+ return this.parseFunctionStatement(node, true, !context);
+ }
+ }
+ }
+
+ const maybeName = this.state.value;
+ const expr = this.parseExpression();
+
+ if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon)) {
+ return this.parseLabeledStatement(node, maybeName, expr, context);
+ } else {
+ return this.parseExpressionStatement(node, expr);
+ }
+ }
+
+ assertModuleNodeAllowed(node) {
+ if (!this.options.allowImportExportEverywhere && !this.inModule) {
+ this.raiseWithData(node.start, {
+ code: "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED"
+ }, ErrorMessages.ImportOutsideModule);
+ }
+ }
+
+ takeDecorators(node) {
+ const decorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
+
+ if (decorators.length) {
+ node.decorators = decorators;
+ this.resetStartLocationFromNode(node, decorators[0]);
+ this.state.decoratorStack[this.state.decoratorStack.length - 1] = [];
+ }
+ }
+
+ canHaveLeadingDecorator() {
+ return this.match(types._class);
+ }
+
+ parseDecorators(allowExport) {
+ const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
+
+ while (this.match(types.at)) {
+ const decorator = this.parseDecorator();
+ currentContextDecorators.push(decorator);
+ }
+
+ if (this.match(types._export)) {
+ if (!allowExport) {
+ this.unexpected();
+ }
+
+ if (this.hasPlugin("decorators") && !this.getPluginOption("decorators", "decoratorsBeforeExport")) {
+ this.raise(this.state.start, ErrorMessages.DecoratorExportClass);
+ }
+ } else if (!this.canHaveLeadingDecorator()) {
+ throw this.raise(this.state.start, ErrorMessages.UnexpectedLeadingDecorator);
+ }
+ }
+
+ parseDecorator() {
+ this.expectOnePlugin(["decorators-legacy", "decorators"]);
+ const node = this.startNode();
+ this.next();
+
+ if (this.hasPlugin("decorators")) {
+ this.state.decoratorStack.push([]);
+ const startPos = this.state.start;
+ const startLoc = this.state.startLoc;
+ let expr;
+
+ if (this.eat(types.parenL)) {
+ expr = this.parseExpression();
+ this.expect(types.parenR);
+ } else {
+ expr = this.parseIdentifier(false);
+
+ while (this.eat(types.dot)) {
+ const node = this.startNodeAt(startPos, startLoc);
+ node.object = expr;
+ node.property = this.parseIdentifier(true);
+ node.computed = false;
+ expr = this.finishNode(node, "MemberExpression");
+ }
+ }
+
+ node.expression = this.parseMaybeDecoratorArguments(expr);
+ this.state.decoratorStack.pop();
+ } else {
+ node.expression = this.parseExprSubscripts();
+ }
+
+ return this.finishNode(node, "Decorator");
+ }
+
+ parseMaybeDecoratorArguments(expr) {
+ if (this.eat(types.parenL)) {
+ const node = this.startNodeAtNode(expr);
+ node.callee = expr;
+ node.arguments = this.parseCallExpressionArguments(types.parenR, false);
+ this.toReferencedList(node.arguments);
+ return this.finishNode(node, "CallExpression");
+ }
+
+ return expr;
+ }
+
+ parseBreakContinueStatement(node, keyword) {
+ const isBreak = keyword === "break";
+ this.next();
+
+ if (this.isLineTerminator()) {
+ node.label = null;
+ } else {
+ node.label = this.parseIdentifier();
+ this.semicolon();
+ }
+
+ this.verifyBreakContinue(node, keyword);
+ return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement");
+ }
+
+ verifyBreakContinue(node, keyword) {
+ const isBreak = keyword === "break";
+ let i;
+
+ for (i = 0; i < this.state.labels.length; ++i) {
+ const lab = this.state.labels[i];
+
+ if (node.label == null || lab.name === node.label.name) {
+ if (lab.kind != null && (isBreak || lab.kind === "loop")) break;
+ if (node.label && isBreak) break;
+ }
+ }
+
+ if (i === this.state.labels.length) {
+ this.raise(node.start, ErrorMessages.IllegalBreakContinue, keyword);
+ }
+ }
+
+ parseDebuggerStatement(node) {
+ this.next();
+ this.semicolon();
+ return this.finishNode(node, "DebuggerStatement");
+ }
+
+ parseHeaderExpression() {
+ this.expect(types.parenL);
+ const val = this.parseExpression();
+ this.expect(types.parenR);
+ return val;
+ }
+
+ parseDoStatement(node) {
+ this.next();
+ this.state.labels.push(loopLabel);
+ node.body = this.withTopicForbiddingContext(() => this.parseStatement("do"));
+ this.state.labels.pop();
+ this.expect(types._while);
+ node.test = this.parseHeaderExpression();
+ this.eat(types.semi);
+ return this.finishNode(node, "DoWhileStatement");
+ }
+
+ parseForStatement(node) {
+ this.next();
+ this.state.labels.push(loopLabel);
+ let awaitAt = -1;
+
+ if (this.isAwaitAllowed() && this.eatContextual("await")) {
+ awaitAt = this.state.lastTokStart;
+ }
+
+ this.scope.enter(SCOPE_OTHER);
+ this.expect(types.parenL);
+
+ if (this.match(types.semi)) {
+ if (awaitAt > -1) {
+ this.unexpected(awaitAt);
+ }
+
+ return this.parseFor(node, null);
+ }
+
+ const isLet = this.isLet();
+
+ if (this.match(types._var) || this.match(types._const) || isLet) {
+ const init = this.startNode();
+ const kind = isLet ? "let" : this.state.value;
+ this.next();
+ this.parseVar(init, true, kind);
+ this.finishNode(init, "VariableDeclaration");
+
+ if ((this.match(types._in) || this.isContextual("of")) && init.declarations.length === 1) {
+ return this.parseForIn(node, init, awaitAt);
+ }
+
+ if (awaitAt > -1) {
+ this.unexpected(awaitAt);
+ }
+
+ return this.parseFor(node, init);
+ }
+
+ const refExpressionErrors = new ExpressionErrors();
+ const init = this.parseExpression(true, refExpressionErrors);
+
+ if (this.match(types._in) || this.isContextual("of")) {
+ this.toAssignable(init, true);
+ const description = this.isContextual("of") ? "for-of statement" : "for-in statement";
+ this.checkLVal(init, description);
+ return this.parseForIn(node, init, awaitAt);
+ } else {
+ this.checkExpressionErrors(refExpressionErrors, true);
+ }
+
+ if (awaitAt > -1) {
+ this.unexpected(awaitAt);
+ }
+
+ return this.parseFor(node, init);
+ }
+
+ parseFunctionStatement(node, isAsync, declarationPosition) {
+ this.next();
+ return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), isAsync);
+ }
+
+ parseIfStatement(node) {
+ this.next();
+ node.test = this.parseHeaderExpression();
+ node.consequent = this.parseStatement("if");
+ node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
+ return this.finishNode(node, "IfStatement");
+ }
+
+ parseReturnStatement(node) {
+ if (!this.prodParam.hasReturn && !this.options.allowReturnOutsideFunction) {
+ this.raise(this.state.start, ErrorMessages.IllegalReturn);
+ }
+
+ this.next();
+
+ if (this.isLineTerminator()) {
+ node.argument = null;
+ } else {
+ node.argument = this.parseExpression();
+ this.semicolon();
+ }
+
+ return this.finishNode(node, "ReturnStatement");
+ }
+
+ parseSwitchStatement(node) {
+ this.next();
+ node.discriminant = this.parseHeaderExpression();
+ const cases = node.cases = [];
+ this.expect(types.braceL);
+ this.state.labels.push(switchLabel);
+ this.scope.enter(SCOPE_OTHER);
+ let cur;
+
+ for (let sawDefault; !this.match(types.braceR);) {
+ if (this.match(types._case) || this.match(types._default)) {
+ const isCase = this.match(types._case);
+ if (cur) this.finishNode(cur, "SwitchCase");
+ cases.push(cur = this.startNode());
+ cur.consequent = [];
+ this.next();
+
+ if (isCase) {
+ cur.test = this.parseExpression();
+ } else {
+ if (sawDefault) {
+ this.raise(this.state.lastTokStart, ErrorMessages.MultipleDefaultsInSwitch);
+ }
+
+ sawDefault = true;
+ cur.test = null;
+ }
+
+ this.expect(types.colon);
+ } else {
+ if (cur) {
+ cur.consequent.push(this.parseStatement(null));
+ } else {
+ this.unexpected();
+ }
+ }
+ }
+
+ this.scope.exit();
+ if (cur) this.finishNode(cur, "SwitchCase");
+ this.next();
+ this.state.labels.pop();
+ return this.finishNode(node, "SwitchStatement");
+ }
+
+ parseThrowStatement(node) {
+ this.next();
+
+ if (this.hasPrecedingLineBreak()) {
+ this.raise(this.state.lastTokEnd, ErrorMessages.NewlineAfterThrow);
+ }
+
+ node.argument = this.parseExpression();
+ this.semicolon();
+ return this.finishNode(node, "ThrowStatement");
+ }
+
+ parseCatchClauseParam() {
+ const param = this.parseBindingAtom();
+ const simple = param.type === "Identifier";
+ this.scope.enter(simple ? SCOPE_SIMPLE_CATCH : 0);
+ this.checkLVal(param, "catch clause", BIND_LEXICAL);
+ return param;
+ }
+
+ parseTryStatement(node) {
+ this.next();
+ node.block = this.parseBlock();
+ node.handler = null;
+
+ if (this.match(types._catch)) {
+ const clause = this.startNode();
+ this.next();
+
+ if (this.match(types.parenL)) {
+ this.expect(types.parenL);
+ clause.param = this.parseCatchClauseParam();
+ this.expect(types.parenR);
+ } else {
+ clause.param = null;
+ this.scope.enter(SCOPE_OTHER);
+ }
+
+ clause.body = this.withTopicForbiddingContext(() => this.parseBlock(false, false));
+ this.scope.exit();
+ node.handler = this.finishNode(clause, "CatchClause");
+ }
+
+ node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
+
+ if (!node.handler && !node.finalizer) {
+ this.raise(node.start, ErrorMessages.NoCatchOrFinally);
+ }
+
+ return this.finishNode(node, "TryStatement");
+ }
+
+ parseVarStatement(node, kind) {
+ this.next();
+ this.parseVar(node, false, kind);
+ this.semicolon();
+ return this.finishNode(node, "VariableDeclaration");
+ }
+
+ parseWhileStatement(node) {
+ this.next();
+ node.test = this.parseHeaderExpression();
+ this.state.labels.push(loopLabel);
+ node.body = this.withTopicForbiddingContext(() => this.parseStatement("while"));
+ this.state.labels.pop();
+ return this.finishNode(node, "WhileStatement");
+ }
+
+ parseWithStatement(node) {
+ if (this.state.strict) {
+ this.raise(this.state.start, ErrorMessages.StrictWith);
+ }
+
+ this.next();
+ node.object = this.parseHeaderExpression();
+ node.body = this.withTopicForbiddingContext(() => this.parseStatement("with"));
+ return this.finishNode(node, "WithStatement");
+ }
+
+ parseEmptyStatement(node) {
+ this.next();
+ return this.finishNode(node, "EmptyStatement");
+ }
+
+ parseLabeledStatement(node, maybeName, expr, context) {
+ for (const label of this.state.labels) {
+ if (label.name === maybeName) {
+ this.raise(expr.start, ErrorMessages.LabelRedeclaration, maybeName);
+ }
+ }
+
+ const kind = this.state.type.isLoop ? "loop" : this.match(types._switch) ? "switch" : null;
+
+ for (let i = this.state.labels.length - 1; i >= 0; i--) {
+ const label = this.state.labels[i];
+
+ if (label.statementStart === node.start) {
+ label.statementStart = this.state.start;
+ label.kind = kind;
+ } else {
+ break;
+ }
+ }
+
+ this.state.labels.push({
+ name: maybeName,
+ kind: kind,
+ statementStart: this.state.start
+ });
+ node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
+ this.state.labels.pop();
+ node.label = expr;
+ return this.finishNode(node, "LabeledStatement");
+ }
+
+ parseExpressionStatement(node, expr) {
+ node.expression = expr;
+ this.semicolon();
+ return this.finishNode(node, "ExpressionStatement");
+ }
+
+ parseBlock(allowDirectives = false, createNewLexicalScope = true, afterBlockParse) {
+ const node = this.startNode();
+
+ if (allowDirectives) {
+ this.state.strictErrors.clear();
+ }
+
+ this.expect(types.braceL);
+
+ if (createNewLexicalScope) {
+ this.scope.enter(SCOPE_OTHER);
+ }
+
+ this.parseBlockBody(node, allowDirectives, false, types.braceR, afterBlockParse);
+
+ if (createNewLexicalScope) {
+ this.scope.exit();
+ }
+
+ return this.finishNode(node, "BlockStatement");
+ }
+
+ isValidDirective(stmt) {
+ return stmt.type === "ExpressionStatement" && stmt.expression.type === "StringLiteral" && !stmt.expression.extra.parenthesized;
+ }
+
+ parseBlockBody(node, allowDirectives, topLevel, end, afterBlockParse) {
+ const body = node.body = [];
+ const directives = node.directives = [];
+ this.parseBlockOrModuleBlockBody(body, allowDirectives ? directives : undefined, topLevel, end, afterBlockParse);
+ }
+
+ parseBlockOrModuleBlockBody(body, directives, topLevel, end, afterBlockParse) {
+ const oldStrict = this.state.strict;
+ let hasStrictModeDirective = false;
+ let parsedNonDirective = false;
+
+ while (!this.match(end)) {
+ const stmt = this.parseStatement(null, topLevel);
+
+ if (directives && !parsedNonDirective) {
+ if (this.isValidDirective(stmt)) {
+ const directive = this.stmtToDirective(stmt);
+ directives.push(directive);
+
+ if (!hasStrictModeDirective && directive.value.value === "use strict") {
+ hasStrictModeDirective = true;
+ this.setStrict(true);
+ }
+
+ continue;
+ }
+
+ parsedNonDirective = true;
+ this.state.strictErrors.clear();
+ }
+
+ body.push(stmt);
+ }
+
+ if (afterBlockParse) {
+ afterBlockParse.call(this, hasStrictModeDirective);
+ }
+
+ if (!oldStrict) {
+ this.setStrict(false);
+ }
+
+ this.next();
+ }
+
+ parseFor(node, init) {
+ node.init = init;
+ this.semicolon(false);
+ node.test = this.match(types.semi) ? null : this.parseExpression();
+ this.semicolon(false);
+ node.update = this.match(types.parenR) ? null : this.parseExpression();
+ this.expect(types.parenR);
+ node.body = this.withTopicForbiddingContext(() => this.parseStatement("for"));
+ this.scope.exit();
+ this.state.labels.pop();
+ return this.finishNode(node, "ForStatement");
+ }
+
+ parseForIn(node, init, awaitAt) {
+ const isForIn = this.match(types._in);
+ this.next();
+
+ if (isForIn) {
+ if (awaitAt > -1) this.unexpected(awaitAt);
+ } else {
+ node.await = awaitAt > -1;
+ }
+
+ if (init.type === "VariableDeclaration" && init.declarations[0].init != null && (!isForIn || this.state.strict || init.kind !== "var" || init.declarations[0].id.type !== "Identifier")) {
+ this.raise(init.start, ErrorMessages.ForInOfLoopInitializer, isForIn ? "for-in" : "for-of");
+ } else if (init.type === "AssignmentPattern") {
+ this.raise(init.start, ErrorMessages.InvalidLhs, "for-loop");
+ }
+
+ node.left = init;
+ node.right = isForIn ? this.parseExpression() : this.parseMaybeAssignAllowIn();
+ this.expect(types.parenR);
+ node.body = this.withTopicForbiddingContext(() => this.parseStatement("for"));
+ this.scope.exit();
+ this.state.labels.pop();
+ return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement");
+ }
+
+ parseVar(node, isFor, kind) {
+ const declarations = node.declarations = [];
+ const isTypescript = this.hasPlugin("typescript");
+ node.kind = kind;
+
+ for (;;) {
+ const decl = this.startNode();
+ this.parseVarId(decl, kind);
+
+ if (this.eat(types.eq)) {
+ decl.init = isFor ? this.parseMaybeAssignDisallowIn() : this.parseMaybeAssignAllowIn();
+ } else {
+ if (kind === "const" && !(this.match(types._in) || this.isContextual("of"))) {
+ if (!isTypescript) {
+ this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Const declarations");
+ }
+ } else if (decl.id.type !== "Identifier" && !(isFor && (this.match(types._in) || this.isContextual("of")))) {
+ this.raise(this.state.lastTokEnd, ErrorMessages.DeclarationMissingInitializer, "Complex binding patterns");
+ }
+
+ decl.init = null;
+ }
+
+ declarations.push(this.finishNode(decl, "VariableDeclarator"));
+ if (!this.eat(types.comma)) break;
+ }
+
+ return node;
+ }
+
+ parseVarId(decl, kind) {
+ decl.id = this.parseBindingAtom();
+ this.checkLVal(decl.id, "variable declaration", kind === "var" ? BIND_VAR : BIND_LEXICAL, undefined, kind !== "var");
+ }
+
+ parseFunction(node, statement = FUNC_NO_FLAGS, isAsync = false) {
+ const isStatement = statement & FUNC_STATEMENT;
+ const isHangingStatement = statement & FUNC_HANGING_STATEMENT;
+ const requireId = !!isStatement && !(statement & FUNC_NULLABLE_ID);
+ this.initFunction(node, isAsync);
+
+ if (this.match(types.star) && isHangingStatement) {
+ this.raise(this.state.start, ErrorMessages.GeneratorInSingleStatementContext);
+ }
+
+ node.generator = this.eat(types.star);
+
+ if (isStatement) {
+ node.id = this.parseFunctionId(requireId);
+ }
+
+ const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
+ this.state.maybeInArrowParameters = false;
+ this.scope.enter(SCOPE_FUNCTION);
+ this.prodParam.enter(functionFlags(isAsync, node.generator));
+
+ if (!isStatement) {
+ node.id = this.parseFunctionId();
+ }
+
+ this.parseFunctionParams(node, false);
+ this.withTopicForbiddingContext(() => {
+ this.parseFunctionBodyAndFinish(node, isStatement ? "FunctionDeclaration" : "FunctionExpression");
+ });
+ this.prodParam.exit();
+ this.scope.exit();
+
+ if (isStatement && !isHangingStatement) {
+ this.registerFunctionStatementId(node);
+ }
+
+ this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
+ return node;
+ }
+
+ parseFunctionId(requireId) {
+ return requireId || this.match(types.name) ? this.parseIdentifier() : null;
+ }
+
+ parseFunctionParams(node, allowModifiers) {
+ this.expect(types.parenL);
+ this.expressionScope.enter(newParameterDeclarationScope());
+ node.params = this.parseBindingList(types.parenR, 41, false, allowModifiers);
+ this.expressionScope.exit();
+ }
+
+ registerFunctionStatementId(node) {
+ if (!node.id) return;
+ this.scope.declareName(node.id.name, this.state.strict || node.generator || node.async ? this.scope.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION, node.id.start);
+ }
+
+ parseClass(node, isStatement, optionalId) {
+ this.next();
+ this.takeDecorators(node);
+ const oldStrict = this.state.strict;
+ this.state.strict = true;
+ this.parseClassId(node, isStatement, optionalId);
+ this.parseClassSuper(node);
+ node.body = this.parseClassBody(!!node.superClass, oldStrict);
+ return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression");
+ }
+
+ isClassProperty() {
+ return this.match(types.eq) || this.match(types.semi) || this.match(types.braceR);
+ }
+
+ isClassMethod() {
+ return this.match(types.parenL);
+ }
+
+ isNonstaticConstructor(method) {
+ return !method.computed && !method.static && (method.key.name === "constructor" || method.key.value === "constructor");
+ }
+
+ parseClassBody(constructorAllowsSuper, oldStrict) {
+ this.classScope.enter();
+ const state = {
+ constructorAllowsSuper,
+ hadConstructor: false,
+ hadStaticBlock: false
+ };
+ let decorators = [];
+ const classBody = this.startNode();
+ classBody.body = [];
+ this.expect(types.braceL);
+ this.withTopicForbiddingContext(() => {
+ while (!this.match(types.braceR)) {
+ if (this.eat(types.semi)) {
+ if (decorators.length > 0) {
+ throw this.raise(this.state.lastTokEnd, ErrorMessages.DecoratorSemicolon);
+ }
+
+ continue;
+ }
+
+ if (this.match(types.at)) {
+ decorators.push(this.parseDecorator());
+ continue;
+ }
+
+ const member = this.startNode();
+
+ if (decorators.length) {
+ member.decorators = decorators;
+ this.resetStartLocationFromNode(member, decorators[0]);
+ decorators = [];
+ }
+
+ this.parseClassMember(classBody, member, state);
+
+ if (member.kind === "constructor" && member.decorators && member.decorators.length > 0) {
+ this.raise(member.start, ErrorMessages.DecoratorConstructor);
+ }
+ }
+ });
+ this.state.strict = oldStrict;
+ this.next();
+
+ if (decorators.length) {
+ throw this.raise(this.state.start, ErrorMessages.TrailingDecorator);
+ }
+
+ this.classScope.exit();
+ return this.finishNode(classBody, "ClassBody");
+ }
+
+ parseClassMemberFromModifier(classBody, member) {
+ const key = this.parseIdentifier(true);
+
+ if (this.isClassMethod()) {
+ const method = member;
+ method.kind = "method";
+ method.computed = false;
+ method.key = key;
+ method.static = false;
+ this.pushClassMethod(classBody, method, false, false, false, false);
+ return true;
+ } else if (this.isClassProperty()) {
+ const prop = member;
+ prop.computed = false;
+ prop.key = key;
+ prop.static = false;
+ classBody.body.push(this.parseClassProperty(prop));
+ return true;
+ }
+
+ return false;
+ }
+
+ parseClassMember(classBody, member, state) {
+ const isStatic = this.isContextual("static");
+
+ if (isStatic) {
+ if (this.parseClassMemberFromModifier(classBody, member)) {
+ return;
+ }
+
+ if (this.eat(types.braceL)) {
+ this.parseClassStaticBlock(classBody, member, state);
+ return;
+ }
+ }
+
+ this.parseClassMemberWithIsStatic(classBody, member, state, isStatic);
+ }
+
+ parseClassMemberWithIsStatic(classBody, member, state, isStatic) {
+ const publicMethod = member;
+ const privateMethod = member;
+ const publicProp = member;
+ const privateProp = member;
+ const method = publicMethod;
+ const publicMember = publicMethod;
+ member.static = isStatic;
+
+ if (this.eat(types.star)) {
+ method.kind = "method";
+ this.parseClassElementName(method);
+
+ if (this.isPrivateName(method.key)) {
+ this.pushClassPrivateMethod(classBody, privateMethod, true, false);
+ return;
+ }
+
+ if (this.isNonstaticConstructor(publicMethod)) {
+ this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsGenerator);
+ }
+
+ this.pushClassMethod(classBody, publicMethod, true, false, false, false);
+ return;
+ }
+
+ const containsEsc = this.state.containsEsc;
+ const key = this.parseClassElementName(member);
+ const isPrivate = this.isPrivateName(key);
+ const isSimple = key.type === "Identifier";
+ const maybeQuestionTokenStart = this.state.start;
+ this.parsePostMemberNameModifiers(publicMember);
+
+ if (this.isClassMethod()) {
+ method.kind = "method";
+
+ if (isPrivate) {
+ this.pushClassPrivateMethod(classBody, privateMethod, false, false);
+ return;
+ }
+
+ const isConstructor = this.isNonstaticConstructor(publicMethod);
+ let allowsDirectSuper = false;
+
+ if (isConstructor) {
+ publicMethod.kind = "constructor";
+
+ if (state.hadConstructor && !this.hasPlugin("typescript")) {
+ this.raise(key.start, ErrorMessages.DuplicateConstructor);
+ }
+
+ state.hadConstructor = true;
+ allowsDirectSuper = state.constructorAllowsSuper;
+ }
+
+ this.pushClassMethod(classBody, publicMethod, false, false, isConstructor, allowsDirectSuper);
+ } else if (this.isClassProperty()) {
+ if (isPrivate) {
+ this.pushClassPrivateProperty(classBody, privateProp);
+ } else {
+ this.pushClassProperty(classBody, publicProp);
+ }
+ } else if (isSimple && key.name === "async" && !containsEsc && !this.isLineTerminator()) {
+ const isGenerator = this.eat(types.star);
+
+ if (publicMember.optional) {
+ this.unexpected(maybeQuestionTokenStart);
+ }
+
+ method.kind = "method";
+ this.parseClassElementName(method);
+ this.parsePostMemberNameModifiers(publicMember);
+
+ if (this.isPrivateName(method.key)) {
+ this.pushClassPrivateMethod(classBody, privateMethod, isGenerator, true);
+ } else {
+ if (this.isNonstaticConstructor(publicMethod)) {
+ this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAsync);
+ }
+
+ this.pushClassMethod(classBody, publicMethod, isGenerator, true, false, false);
+ }
+ } else if (isSimple && (key.name === "get" || key.name === "set") && !containsEsc && !(this.match(types.star) && this.isLineTerminator())) {
+ method.kind = key.name;
+ this.parseClassElementName(publicMethod);
+
+ if (this.isPrivateName(method.key)) {
+ this.pushClassPrivateMethod(classBody, privateMethod, false, false);
+ } else {
+ if (this.isNonstaticConstructor(publicMethod)) {
+ this.raise(publicMethod.key.start, ErrorMessages.ConstructorIsAccessor);
+ }
+
+ this.pushClassMethod(classBody, publicMethod, false, false, false, false);
+ }
+
+ this.checkGetterSetterParams(publicMethod);
+ } else if (this.isLineTerminator()) {
+ if (isPrivate) {
+ this.pushClassPrivateProperty(classBody, privateProp);
+ } else {
+ this.pushClassProperty(classBody, publicProp);
+ }
+ } else {
+ this.unexpected();
+ }
+ }
+
+ parseClassElementName(member) {
+ const key = this.parsePropertyName(member, true);
+
+ if (!member.computed && member.static && (key.name === "prototype" || key.value === "prototype")) {
+ this.raise(key.start, ErrorMessages.StaticPrototype);
+ }
+
+ if (this.isPrivateName(key) && this.getPrivateNameSV(key) === "constructor") {
+ this.raise(key.start, ErrorMessages.ConstructorClassPrivateField);
+ }
+
+ return key;
+ }
+
+ parseClassStaticBlock(classBody, member, state) {
+ var _member$decorators;
+
+ this.expectPlugin("classStaticBlock", member.start);
+ this.scope.enter(SCOPE_CLASS | SCOPE_STATIC_BLOCK | SCOPE_SUPER);
+ const oldLabels = this.state.labels;
+ this.state.labels = [];
+ this.prodParam.enter(PARAM);
+ const body = member.body = [];
+ this.parseBlockOrModuleBlockBody(body, undefined, false, types.braceR);
+ this.prodParam.exit();
+ this.scope.exit();
+ this.state.labels = oldLabels;
+ classBody.body.push(this.finishNode(member, "StaticBlock"));
+
+ if (state.hadStaticBlock) {
+ this.raise(member.start, ErrorMessages.DuplicateStaticBlock);
+ }
+
+ if ((_member$decorators = member.decorators) != null && _member$decorators.length) {
+ this.raise(member.start, ErrorMessages.DecoratorStaticBlock);
+ }
+
+ state.hadStaticBlock = true;
+ }
+
+ pushClassProperty(classBody, prop) {
+ if (!prop.computed && (prop.key.name === "constructor" || prop.key.value === "constructor")) {
+ this.raise(prop.key.start, ErrorMessages.ConstructorClassField);
+ }
+
+ classBody.body.push(this.parseClassProperty(prop));
+ }
+
+ pushClassPrivateProperty(classBody, prop) {
+ this.expectPlugin("classPrivateProperties", prop.key.start);
+ const node = this.parseClassPrivateProperty(prop);
+ classBody.body.push(node);
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), CLASS_ELEMENT_OTHER, node.key.start);
+ }
+
+ pushClassMethod(classBody, method, isGenerator, isAsync, isConstructor, allowsDirectSuper) {
+ classBody.body.push(this.parseMethod(method, isGenerator, isAsync, isConstructor, allowsDirectSuper, "ClassMethod", true));
+ }
+
+ pushClassPrivateMethod(classBody, method, isGenerator, isAsync) {
+ this.expectPlugin("classPrivateMethods", method.key.start);
+ const node = this.parseMethod(method, isGenerator, isAsync, false, false, "ClassPrivateMethod", true);
+ classBody.body.push(node);
+ const kind = node.kind === "get" ? node.static ? CLASS_ELEMENT_STATIC_GETTER : CLASS_ELEMENT_INSTANCE_GETTER : node.kind === "set" ? node.static ? CLASS_ELEMENT_STATIC_SETTER : CLASS_ELEMENT_INSTANCE_SETTER : CLASS_ELEMENT_OTHER;
+ this.classScope.declarePrivateName(this.getPrivateNameSV(node.key), kind, node.key.start);
+ }
+
+ parsePostMemberNameModifiers(methodOrProp) {}
+
+ parseClassPrivateProperty(node) {
+ this.parseInitializer(node);
+ this.semicolon();
+ return this.finishNode(node, "ClassPrivateProperty");
+ }
+
+ parseClassProperty(node) {
+ if (!node.typeAnnotation || this.match(types.eq)) {
+ this.expectPlugin("classProperties");
+ }
+
+ this.parseInitializer(node);
+ this.semicolon();
+ return this.finishNode(node, "ClassProperty");
+ }
+
+ parseInitializer(node) {
+ this.scope.enter(SCOPE_CLASS | SCOPE_SUPER);
+ this.expressionScope.enter(newExpressionScope());
+ this.prodParam.enter(PARAM);
+ node.value = this.eat(types.eq) ? this.parseMaybeAssignAllowIn() : null;
+ this.expressionScope.exit();
+ this.prodParam.exit();
+ this.scope.exit();
+ }
+
+ parseClassId(node, isStatement, optionalId, bindingType = BIND_CLASS) {
+ if (this.match(types.name)) {
+ node.id = this.parseIdentifier();
+
+ if (isStatement) {
+ this.checkLVal(node.id, "class name", bindingType);
+ }
+ } else {
+ if (optionalId || !isStatement) {
+ node.id = null;
+ } else {
+ this.unexpected(null, ErrorMessages.MissingClassName);
+ }
+ }
+ }
+
+ parseClassSuper(node) {
+ node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
+ }
+
+ parseExport(node) {
+ const hasDefault = this.maybeParseExportDefaultSpecifier(node);
+ const parseAfterDefault = !hasDefault || this.eat(types.comma);
+ const hasStar = parseAfterDefault && this.eatExportStar(node);
+ const hasNamespace = hasStar && this.maybeParseExportNamespaceSpecifier(node);
+ const parseAfterNamespace = parseAfterDefault && (!hasNamespace || this.eat(types.comma));
+ const isFromRequired = hasDefault || hasStar;
+
+ if (hasStar && !hasNamespace) {
+ if (hasDefault) this.unexpected();
+ this.parseExportFrom(node, true);
+ return this.finishNode(node, "ExportAllDeclaration");
+ }
+
+ const hasSpecifiers = this.maybeParseExportNamedSpecifiers(node);
+
+ if (hasDefault && parseAfterDefault && !hasStar && !hasSpecifiers || hasNamespace && parseAfterNamespace && !hasSpecifiers) {
+ throw this.unexpected(null, types.braceL);
+ }
+
+ let hasDeclaration;
+
+ if (isFromRequired || hasSpecifiers) {
+ hasDeclaration = false;
+ this.parseExportFrom(node, isFromRequired);
+ } else {
+ hasDeclaration = this.maybeParseExportDeclaration(node);
+ }
+
+ if (isFromRequired || hasSpecifiers || hasDeclaration) {
+ this.checkExport(node, true, false, !!node.source);
+ return this.finishNode(node, "ExportNamedDeclaration");
+ }
+
+ if (this.eat(types._default)) {
+ node.declaration = this.parseExportDefaultExpression();
+ this.checkExport(node, true, true);
+ return this.finishNode(node, "ExportDefaultDeclaration");
+ }
+
+ throw this.unexpected(null, types.braceL);
+ }
+
+ eatExportStar(node) {
+ return this.eat(types.star);
+ }
+
+ maybeParseExportDefaultSpecifier(node) {
+ if (this.isExportDefaultSpecifier()) {
+ this.expectPlugin("exportDefaultFrom");
+ const specifier = this.startNode();
+ specifier.exported = this.parseIdentifier(true);
+ node.specifiers = [this.finishNode(specifier, "ExportDefaultSpecifier")];
+ return true;
+ }
+
+ return false;
+ }
+
+ maybeParseExportNamespaceSpecifier(node) {
+ if (this.isContextual("as")) {
+ if (!node.specifiers) node.specifiers = [];
+ const specifier = this.startNodeAt(this.state.lastTokStart, this.state.lastTokStartLoc);
+ this.next();
+ specifier.exported = this.parseModuleExportName();
+ node.specifiers.push(this.finishNode(specifier, "ExportNamespaceSpecifier"));
+ return true;
+ }
+
+ return false;
+ }
+
+ maybeParseExportNamedSpecifiers(node) {
+ if (this.match(types.braceL)) {
+ if (!node.specifiers) node.specifiers = [];
+ node.specifiers.push(...this.parseExportSpecifiers());
+ node.source = null;
+ node.declaration = null;
+ return true;
+ }
+
+ return false;
+ }
+
+ maybeParseExportDeclaration(node) {
+ if (this.shouldParseExportDeclaration()) {
+ node.specifiers = [];
+ node.source = null;
+ node.declaration = this.parseExportDeclaration(node);
+ return true;
+ }
+
+ return false;
+ }
+
+ isAsyncFunction() {
+ if (!this.isContextual("async")) return false;
+ const next = this.nextTokenStart();
+ return !lineBreak.test(this.input.slice(this.state.pos, next)) && this.isUnparsedContextual(next, "function");
+ }
+
+ parseExportDefaultExpression() {
+ const expr = this.startNode();
+ const isAsync = this.isAsyncFunction();
+
+ if (this.match(types._function) || isAsync) {
+ this.next();
+
+ if (isAsync) {
+ this.next();
+ }
+
+ return this.parseFunction(expr, FUNC_STATEMENT | FUNC_NULLABLE_ID, isAsync);
+ } else if (this.match(types._class)) {
+ return this.parseClass(expr, true, true);
+ } else if (this.match(types.at)) {
+ if (this.hasPlugin("decorators") && this.getPluginOption("decorators", "decoratorsBeforeExport")) {
+ this.raise(this.state.start, ErrorMessages.DecoratorBeforeExport);
+ }
+
+ this.parseDecorators(false);
+ return this.parseClass(expr, true, true);
+ } else if (this.match(types._const) || this.match(types._var) || this.isLet()) {
+ throw this.raise(this.state.start, ErrorMessages.UnsupportedDefaultExport);
+ } else {
+ const res = this.parseMaybeAssignAllowIn();
+ this.semicolon();
+ return res;
+ }
+ }
+
+ parseExportDeclaration(node) {
+ return this.parseStatement(null);
+ }
+
+ isExportDefaultSpecifier() {
+ if (this.match(types.name)) {
+ const value = this.state.value;
+
+ if (value === "async" && !this.state.containsEsc || value === "let") {
+ return false;
+ }
+
+ if ((value === "type" || value === "interface") && !this.state.containsEsc) {
+ const l = this.lookahead();
+
+ if (l.type === types.name && l.value !== "from" || l.type === types.braceL) {
+ this.expectOnePlugin(["flow", "typescript"]);
+ return false;
+ }
+ }
+ } else if (!this.match(types._default)) {
+ return false;
+ }
+
+ const next = this.nextTokenStart();
+ const hasFrom = this.isUnparsedContextual(next, "from");
+
+ if (this.input.charCodeAt(next) === 44 || this.match(types.name) && hasFrom) {
+ return true;
+ }
+
+ if (this.match(types._default) && hasFrom) {
+ const nextAfterFrom = this.input.charCodeAt(this.nextTokenStartSince(next + 4));
+ return nextAfterFrom === 34 || nextAfterFrom === 39;
+ }
+
+ return false;
+ }
+
+ parseExportFrom(node, expect) {
+ if (this.eatContextual("from")) {
+ node.source = this.parseImportSource();
+ this.checkExport(node);
+ const assertions = this.maybeParseImportAssertions();
+
+ if (assertions) {
+ node.assertions = assertions;
+ }
+ } else {
+ if (expect) {
+ this.unexpected();
+ } else {
+ node.source = null;
+ }
+ }
+
+ this.semicolon();
+ }
+
+ shouldParseExportDeclaration() {
+ if (this.match(types.at)) {
+ this.expectOnePlugin(["decorators", "decorators-legacy"]);
+
+ if (this.hasPlugin("decorators")) {
+ if (this.getPluginOption("decorators", "decoratorsBeforeExport")) {
+ this.unexpected(this.state.start, ErrorMessages.DecoratorBeforeExport);
+ } else {
+ return true;
+ }
+ }
+ }
+
+ return this.state.type.keyword === "var" || this.state.type.keyword === "const" || this.state.type.keyword === "function" || this.state.type.keyword === "class" || this.isLet() || this.isAsyncFunction();
+ }
+
+ checkExport(node, checkNames, isDefault, isFrom) {
+ if (checkNames) {
+ if (isDefault) {
+ this.checkDuplicateExports(node, "default");
+
+ if (this.hasPlugin("exportDefaultFrom")) {
+ var _declaration$extra;
+
+ const declaration = node.declaration;
+
+ if (declaration.type === "Identifier" && declaration.name === "from" && declaration.end - declaration.start === 4 && !((_declaration$extra = declaration.extra) != null && _declaration$extra.parenthesized)) {
+ this.raise(declaration.start, ErrorMessages.ExportDefaultFromAsIdentifier);
+ }
+ }
+ } else if (node.specifiers && node.specifiers.length) {
+ for (const specifier of node.specifiers) {
+ const {
+ exported
+ } = specifier;
+ const exportedName = exported.type === "Identifier" ? exported.name : exported.value;
+ this.checkDuplicateExports(specifier, exportedName);
+
+ if (!isFrom && specifier.local) {
+ const {
+ local
+ } = specifier;
+
+ if (local.type === "StringLiteral") {
+ this.raise(specifier.start, ErrorMessages.ExportBindingIsString, local.value, exportedName);
+ } else {
+ this.checkReservedWord(local.name, local.start, true, false);
+ this.scope.checkLocalExport(local);
+ }
+ }
+ }
+ } else if (node.declaration) {
+ if (node.declaration.type === "FunctionDeclaration" || node.declaration.type === "ClassDeclaration") {
+ const id = node.declaration.id;
+ if (!id) throw new Error("Assertion failure");
+ this.checkDuplicateExports(node, id.name);
+ } else if (node.declaration.type === "VariableDeclaration") {
+ for (const declaration of node.declaration.declarations) {
+ this.checkDeclaration(declaration.id);
+ }
+ }
+ }
+ }
+
+ const currentContextDecorators = this.state.decoratorStack[this.state.decoratorStack.length - 1];
+
+ if (currentContextDecorators.length) {
+ throw this.raise(node.start, ErrorMessages.UnsupportedDecoratorExport);
+ }
+ }
+
+ checkDeclaration(node) {
+ if (node.type === "Identifier") {
+ this.checkDuplicateExports(node, node.name);
+ } else if (node.type === "ObjectPattern") {
+ for (const prop of node.properties) {
+ this.checkDeclaration(prop);
+ }
+ } else if (node.type === "ArrayPattern") {
+ for (const elem of node.elements) {
+ if (elem) {
+ this.checkDeclaration(elem);
+ }
+ }
+ } else if (node.type === "ObjectProperty") {
+ this.checkDeclaration(node.value);
+ } else if (node.type === "RestElement") {
+ this.checkDeclaration(node.argument);
+ } else if (node.type === "AssignmentPattern") {
+ this.checkDeclaration(node.left);
+ }
+ }
+
+ checkDuplicateExports(node, name) {
+ if (this.state.exportedIdentifiers.indexOf(name) > -1) {
+ this.raise(node.start, name === "default" ? ErrorMessages.DuplicateDefaultExport : ErrorMessages.DuplicateExport, name);
+ }
+
+ this.state.exportedIdentifiers.push(name);
+ }
+
+ parseExportSpecifiers() {
+ const nodes = [];
+ let first = true;
+ this.expect(types.braceL);
+
+ while (!this.eat(types.braceR)) {
+ if (first) {
+ first = false;
+ } else {
+ this.expect(types.comma);
+ if (this.eat(types.braceR)) break;
+ }
+
+ const node = this.startNode();
+ node.local = this.parseModuleExportName();
+ node.exported = this.eatContextual("as") ? this.parseModuleExportName() : node.local.__clone();
+ nodes.push(this.finishNode(node, "ExportSpecifier"));
+ }
+
+ return nodes;
+ }
+
+ parseModuleExportName() {
+ if (this.match(types.string)) {
+ this.expectPlugin("moduleStringNames");
+ const result = this.parseLiteral(this.state.value, "StringLiteral");
+ const surrogate = result.value.match(loneSurrogate);
+
+ if (surrogate) {
+ this.raise(result.start, ErrorMessages.ModuleExportNameHasLoneSurrogate, surrogate[0].charCodeAt(0).toString(16));
+ }
+
+ return result;
+ }
+
+ return this.parseIdentifier(true);
+ }
+
+ parseImport(node) {
+ node.specifiers = [];
+
+ if (!this.match(types.string)) {
+ const hasDefault = this.maybeParseDefaultImportSpecifier(node);
+ const parseNext = !hasDefault || this.eat(types.comma);
+ const hasStar = parseNext && this.maybeParseStarImportSpecifier(node);
+ if (parseNext && !hasStar) this.parseNamedImportSpecifiers(node);
+ this.expectContextual("from");
+ }
+
+ node.source = this.parseImportSource();
+ const assertions = this.maybeParseImportAssertions();
+
+ if (assertions) {
+ node.assertions = assertions;
+ } else {
+ const attributes = this.maybeParseModuleAttributes();
+
+ if (attributes) {
+ node.attributes = attributes;
+ }
+ }
+
+ this.semicolon();
+ return this.finishNode(node, "ImportDeclaration");
+ }
+
+ parseImportSource() {
+ if (!this.match(types.string)) this.unexpected();
+ return this.parseExprAtom();
+ }
+
+ shouldParseDefaultImport(node) {
+ return this.match(types.name);
+ }
+
+ parseImportSpecifierLocal(node, specifier, type, contextDescription) {
+ specifier.local = this.parseIdentifier();
+ this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL);
+ node.specifiers.push(this.finishNode(specifier, type));
+ }
+
+ parseAssertEntries() {
+ const attrs = [];
+ const attrNames = new Set();
+
+ do {
+ if (this.match(types.braceR)) {
+ break;
+ }
+
+ const node = this.startNode();
+ const keyName = this.state.value;
+
+ if (this.match(types.string)) {
+ node.key = this.parseLiteral(keyName, "StringLiteral");
+ } else {
+ node.key = this.parseIdentifier(true);
+ }
+
+ this.expect(types.colon);
+
+ if (keyName !== "type") {
+ this.raise(node.key.start, ErrorMessages.ModuleAttributeDifferentFromType, keyName);
+ }
+
+ if (attrNames.has(keyName)) {
+ this.raise(node.key.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, keyName);
+ }
+
+ attrNames.add(keyName);
+
+ if (!this.match(types.string)) {
+ throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
+ }
+
+ node.value = this.parseLiteral(this.state.value, "StringLiteral");
+ this.finishNode(node, "ImportAttribute");
+ attrs.push(node);
+ } while (this.eat(types.comma));
+
+ return attrs;
+ }
+
+ maybeParseModuleAttributes() {
+ if (this.match(types._with) && !this.hasPrecedingLineBreak()) {
+ this.expectPlugin("moduleAttributes");
+ this.next();
+ } else {
+ if (this.hasPlugin("moduleAttributes")) return [];
+ return null;
+ }
+
+ const attrs = [];
+ const attributes = new Set();
+
+ do {
+ const node = this.startNode();
+ node.key = this.parseIdentifier(true);
+
+ if (node.key.name !== "type") {
+ this.raise(node.key.start, ErrorMessages.ModuleAttributeDifferentFromType, node.key.name);
+ }
+
+ if (attributes.has(node.key.name)) {
+ this.raise(node.key.start, ErrorMessages.ModuleAttributesWithDuplicateKeys, node.key.name);
+ }
+
+ attributes.add(node.key.name);
+ this.expect(types.colon);
+
+ if (!this.match(types.string)) {
+ throw this.unexpected(this.state.start, ErrorMessages.ModuleAttributeInvalidValue);
+ }
+
+ node.value = this.parseLiteral(this.state.value, "StringLiteral");
+ this.finishNode(node, "ImportAttribute");
+ attrs.push(node);
+ } while (this.eat(types.comma));
+
+ return attrs;
+ }
+
+ maybeParseImportAssertions() {
+ if (this.isContextual("assert") && !this.hasPrecedingLineBreak()) {
+ this.expectPlugin("importAssertions");
+ this.next();
+ } else {
+ if (this.hasPlugin("importAssertions")) return [];
+ return null;
+ }
+
+ this.eat(types.braceL);
+ const attrs = this.parseAssertEntries();
+ this.eat(types.braceR);
+ return attrs;
+ }
+
+ maybeParseDefaultImportSpecifier(node) {
+ if (this.shouldParseDefaultImport(node)) {
+ this.parseImportSpecifierLocal(node, this.startNode(), "ImportDefaultSpecifier", "default import specifier");
+ return true;
+ }
+
+ return false;
+ }
+
+ maybeParseStarImportSpecifier(node) {
+ if (this.match(types.star)) {
+ const specifier = this.startNode();
+ this.next();
+ this.expectContextual("as");
+ this.parseImportSpecifierLocal(node, specifier, "ImportNamespaceSpecifier", "import namespace specifier");
+ return true;
+ }
+
+ return false;
+ }
+
+ parseNamedImportSpecifiers(node) {
+ let first = true;
+ this.expect(types.braceL);
+
+ while (!this.eat(types.braceR)) {
+ if (first) {
+ first = false;
+ } else {
+ if (this.eat(types.colon)) {
+ throw this.raise(this.state.start, ErrorMessages.DestructureNamedImport);
+ }
+
+ this.expect(types.comma);
+ if (this.eat(types.braceR)) break;
+ }
+
+ this.parseImportSpecifier(node);
+ }
+ }
+
+ parseImportSpecifier(node) {
+ const specifier = this.startNode();
+ specifier.imported = this.parseModuleExportName();
+
+ if (this.eatContextual("as")) {
+ specifier.local = this.parseIdentifier();
+ } else {
+ const {
+ imported
+ } = specifier;
+
+ if (imported.type === "StringLiteral") {
+ throw this.raise(specifier.start, ErrorMessages.ImportBindingIsString, imported.value);
+ }
+
+ this.checkReservedWord(imported.name, specifier.start, true, true);
+ specifier.local = imported.__clone();
+ }
+
+ this.checkLVal(specifier.local, "import specifier", BIND_LEXICAL);
+ node.specifiers.push(this.finishNode(specifier, "ImportSpecifier"));
+ }
+
+}
+
+class Parser extends StatementParser {
+ constructor(options, input) {
+ options = getOptions(options);
+ super(options, input);
+ this.options = options;
+ this.initializeScopes();
+ this.plugins = pluginsMap(this.options.plugins);
+ this.filename = options.sourceFilename;
+ }
+
+ getScopeHandler() {
+ return ScopeHandler;
+ }
+
+ parse() {
+ this.enterInitialScopes();
+ const file = this.startNode();
+ const program = this.startNode();
+ this.nextToken();
+ file.errors = null;
+ this.parseTopLevel(file, program);
+ file.errors = this.state.errors;
+ return file;
+ }
+
+}
+
+function pluginsMap(plugins) {
+ const pluginMap = new Map();
+
+ for (const plugin of plugins) {
+ const [name, options] = Array.isArray(plugin) ? plugin : [plugin, {}];
+ if (!pluginMap.has(name)) pluginMap.set(name, options || {});
+ }
+
+ return pluginMap;
+}
+
+function parse(input, options) {
+ var _options;
+
+ if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
+ options = Object.assign({}, options);
+
+ try {
+ options.sourceType = "module";
+ const parser = getParser(options, input);
+ const ast = parser.parse();
+
+ if (parser.sawUnambiguousESM) {
+ return ast;
+ }
+
+ if (parser.ambiguousScriptDifferentAst) {
+ try {
+ options.sourceType = "script";
+ return getParser(options, input).parse();
+ } catch (_unused) {}
+ } else {
+ ast.program.sourceType = "script";
+ }
+
+ return ast;
+ } catch (moduleError) {
+ try {
+ options.sourceType = "script";
+ return getParser(options, input).parse();
+ } catch (_unused2) {}
+
+ throw moduleError;
+ }
+ } else {
+ return getParser(options, input).parse();
+ }
+}
+function parseExpression(input, options) {
+ const parser = getParser(options, input);
+
+ if (parser.options.strictMode) {
+ parser.state.strict = true;
+ }
+
+ return parser.getExpression();
+}
+
+function getParser(options, input) {
+ let cls = Parser;
+
+ if (options != null && options.plugins) {
+ validatePlugins(options.plugins);
+ cls = getParserClass(options.plugins);
+ }
+
+ return new cls(options, input);
+}
+
+const parserClassCache = {};
+
+function getParserClass(pluginsFromOptions) {
+ const pluginList = mixinPluginNames.filter(name => hasPlugin(pluginsFromOptions, name));
+ const key = pluginList.join("/");
+ let cls = parserClassCache[key];
+
+ if (!cls) {
+ cls = Parser;
+
+ for (const plugin of pluginList) {
+ cls = mixinPlugins[plugin](cls);
+ }
+
+ parserClassCache[key] = cls;
+ }
+
+ return cls;
+}
+
+exports.parse = parse;
+exports.parseExpression = parseExpression;
+exports.tokTypes = types;
+//# sourceMappingURL=index.js.map
diff --git a/api/node_modules/@babel/parser/lib/index.js.map b/api/node_modules/@babel/parser/lib/index.js.map
new file mode 100644
index 000000000..c3bff89f3
--- /dev/null
+++ b/api/node_modules/@babel/parser/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"index.js","sources":["../src/tokenizer/types.js","../src/util/whitespace.js","../src/util/location.js","../src/parser/base.js","../src/parser/comments.js","../src/parser/error-message.js","../src/parser/error.js","../src/plugins/estree.js","../src/tokenizer/context.js","../../babel-helper-validator-identifier/src/identifier.ts","../../babel-helper-validator-identifier/src/keyword.ts","../src/util/identifier.js","../src/util/scopeflags.js","../src/util/scope.js","../src/plugins/flow/scope.js","../src/plugins/flow/index.js","../src/plugins/jsx/xhtml.js","../src/plugins/jsx/index.js","../src/plugins/typescript/scope.js","../src/util/production-parameter.js","../src/plugins/typescript/index.js","../src/plugins/placeholders.js","../src/plugins/v8intrinsic.js","../src/plugin-utils.js","../src/options.js","../src/tokenizer/state.js","../src/tokenizer/index.js","../src/util/class-scope.js","../src/util/expression-scope.js","../src/parser/util.js","../src/parser/node.js","../src/parser/lval.js","../src/parser/expression.js","../src/parser/statement.js","../src/parser/index.js","../src/index.js"],"sourcesContent":["// @flow\n\n// ## Token types\n\n// The assignment of fine-grained, information-carrying type objects\n// allows the tokenizer to store the information it has about a\n// token in a way that is very cheap for the parser to look up.\n\n// All token type variables start with an underscore, to make them\n// easy to recognize.\n\n// The `beforeExpr` property is used to disambiguate between regular\n// expressions and divisions. It is set on all token types that can\n// be followed by an expression (thus, a slash after them would be a\n// regular expression).\n\n// The `startsExpr` property is used to determine whether an expression\n// may be the “argument” subexpression of a `yield` expression or\n// `yield` statement. It is set on all token types that may be at the\n// start of a subexpression.\n\n// `isLoop` marks a keyword as starting a loop, which is important\n// to know when parsing a label, in order to allow or disallow\n// continue jumps to that label.\n\nconst beforeExpr = true;\nconst startsExpr = true;\nconst isLoop = true;\nconst isAssign = true;\nconst prefix = true;\nconst postfix = true;\n\ntype TokenOptions = {\n keyword?: string,\n beforeExpr?: boolean,\n startsExpr?: boolean,\n rightAssociative?: boolean,\n isLoop?: boolean,\n isAssign?: boolean,\n prefix?: boolean,\n postfix?: boolean,\n binop?: ?number,\n};\n\nexport class TokenType {\n label: string;\n keyword: ?string;\n beforeExpr: boolean;\n startsExpr: boolean;\n rightAssociative: boolean;\n isLoop: boolean;\n isAssign: boolean;\n prefix: boolean;\n postfix: boolean;\n binop: ?number;\n updateContext: ?(prevType: TokenType) => void;\n\n constructor(label: string, conf: TokenOptions = {}) {\n this.label = label;\n this.keyword = conf.keyword;\n this.beforeExpr = !!conf.beforeExpr;\n this.startsExpr = !!conf.startsExpr;\n this.rightAssociative = !!conf.rightAssociative;\n this.isLoop = !!conf.isLoop;\n this.isAssign = !!conf.isAssign;\n this.prefix = !!conf.prefix;\n this.postfix = !!conf.postfix;\n this.binop = conf.binop != null ? conf.binop : null;\n this.updateContext = null;\n }\n}\n\nexport const keywords = new Map();\n\nfunction createKeyword(name: string, options: TokenOptions = {}): TokenType {\n options.keyword = name;\n const token = new TokenType(name, options);\n keywords.set(name, token);\n return token;\n}\n\nfunction createBinop(name: string, binop: number) {\n return new TokenType(name, { beforeExpr, binop });\n}\n\nexport const types: { [name: string]: TokenType } = {\n num: new TokenType(\"num\", { startsExpr }),\n bigint: new TokenType(\"bigint\", { startsExpr }),\n decimal: new TokenType(\"decimal\", { startsExpr }),\n regexp: new TokenType(\"regexp\", { startsExpr }),\n string: new TokenType(\"string\", { startsExpr }),\n name: new TokenType(\"name\", { startsExpr }),\n eof: new TokenType(\"eof\"),\n\n // Punctuation token types.\n bracketL: new TokenType(\"[\", { beforeExpr, startsExpr }),\n bracketHashL: new TokenType(\"#[\", { beforeExpr, startsExpr }),\n bracketBarL: new TokenType(\"[|\", { beforeExpr, startsExpr }),\n bracketR: new TokenType(\"]\"),\n bracketBarR: new TokenType(\"|]\"),\n braceL: new TokenType(\"{\", { beforeExpr, startsExpr }),\n braceBarL: new TokenType(\"{|\", { beforeExpr, startsExpr }),\n braceHashL: new TokenType(\"#{\", { beforeExpr, startsExpr }),\n braceR: new TokenType(\"}\"),\n braceBarR: new TokenType(\"|}\"),\n parenL: new TokenType(\"(\", { beforeExpr, startsExpr }),\n parenR: new TokenType(\")\"),\n comma: new TokenType(\",\", { beforeExpr }),\n semi: new TokenType(\";\", { beforeExpr }),\n colon: new TokenType(\":\", { beforeExpr }),\n doubleColon: new TokenType(\"::\", { beforeExpr }),\n dot: new TokenType(\".\"),\n question: new TokenType(\"?\", { beforeExpr }),\n questionDot: new TokenType(\"?.\"),\n arrow: new TokenType(\"=>\", { beforeExpr }),\n template: new TokenType(\"template\"),\n ellipsis: new TokenType(\"...\", { beforeExpr }),\n backQuote: new TokenType(\"`\", { startsExpr }),\n dollarBraceL: new TokenType(\"${\", { beforeExpr, startsExpr }),\n at: new TokenType(\"@\"),\n hash: new TokenType(\"#\", { startsExpr }),\n\n // Special hashbang token.\n interpreterDirective: new TokenType(\"#!...\"),\n\n // Operators. These carry several kinds of properties to help the\n // parser use them properly (the presence of these properties is\n // what categorizes them as operators).\n //\n // `binop`, when present, specifies that this operator is a binary\n // operator, and will refer to its precedence.\n //\n // `prefix` and `postfix` mark the operator as a prefix or postfix\n // unary operator.\n //\n // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as\n // binary operators with a very low precedence, that should result\n // in AssignmentExpression nodes.\n\n eq: new TokenType(\"=\", { beforeExpr, isAssign }),\n assign: new TokenType(\"_=\", { beforeExpr, isAssign }),\n incDec: new TokenType(\"++/--\", { prefix, postfix, startsExpr }),\n bang: new TokenType(\"!\", { beforeExpr, prefix, startsExpr }),\n tilde: new TokenType(\"~\", { beforeExpr, prefix, startsExpr }),\n pipeline: createBinop(\"|>\", 0),\n nullishCoalescing: createBinop(\"??\", 1),\n logicalOR: createBinop(\"||\", 1),\n logicalAND: createBinop(\"&&\", 2),\n bitwiseOR: createBinop(\"|\", 3),\n bitwiseXOR: createBinop(\"^\", 4),\n bitwiseAND: createBinop(\"&\", 5),\n equality: createBinop(\"==/!=/===/!==\", 6),\n relational: createBinop(\">/<=/>=\", 7),\n bitShift: createBinop(\"<>>/>>>\", 8),\n plusMin: new TokenType(\"+/-\", { beforeExpr, binop: 9, prefix, startsExpr }),\n // startsExpr: required by v8intrinsic plugin\n modulo: new TokenType(\"%\", { beforeExpr, binop: 10, startsExpr }),\n // unset `beforeExpr` as it can be `function *`\n star: new TokenType(\"*\", { binop: 10 }),\n slash: createBinop(\"/\", 10),\n exponent: new TokenType(\"**\", {\n beforeExpr,\n binop: 11,\n rightAssociative: true,\n }),\n\n // Keywords\n // Don't forget to update packages/babel-helper-validator-identifier/src/keyword.js\n // when new keywords are added\n _break: createKeyword(\"break\"),\n _case: createKeyword(\"case\", { beforeExpr }),\n _catch: createKeyword(\"catch\"),\n _continue: createKeyword(\"continue\"),\n _debugger: createKeyword(\"debugger\"),\n _default: createKeyword(\"default\", { beforeExpr }),\n _do: createKeyword(\"do\", { isLoop, beforeExpr }),\n _else: createKeyword(\"else\", { beforeExpr }),\n _finally: createKeyword(\"finally\"),\n _for: createKeyword(\"for\", { isLoop }),\n _function: createKeyword(\"function\", { startsExpr }),\n _if: createKeyword(\"if\"),\n _return: createKeyword(\"return\", { beforeExpr }),\n _switch: createKeyword(\"switch\"),\n _throw: createKeyword(\"throw\", { beforeExpr, prefix, startsExpr }),\n _try: createKeyword(\"try\"),\n _var: createKeyword(\"var\"),\n _const: createKeyword(\"const\"),\n _while: createKeyword(\"while\", { isLoop }),\n _with: createKeyword(\"with\"),\n _new: createKeyword(\"new\", { beforeExpr, startsExpr }),\n _this: createKeyword(\"this\", { startsExpr }),\n _super: createKeyword(\"super\", { startsExpr }),\n _class: createKeyword(\"class\", { startsExpr }),\n _extends: createKeyword(\"extends\", { beforeExpr }),\n _export: createKeyword(\"export\"),\n _import: createKeyword(\"import\", { startsExpr }),\n _null: createKeyword(\"null\", { startsExpr }),\n _true: createKeyword(\"true\", { startsExpr }),\n _false: createKeyword(\"false\", { startsExpr }),\n _in: createKeyword(\"in\", { beforeExpr, binop: 7 }),\n _instanceof: createKeyword(\"instanceof\", { beforeExpr, binop: 7 }),\n _typeof: createKeyword(\"typeof\", { beforeExpr, prefix, startsExpr }),\n _void: createKeyword(\"void\", { beforeExpr, prefix, startsExpr }),\n _delete: createKeyword(\"delete\", { beforeExpr, prefix, startsExpr }),\n};\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\n// Matches a whole line break (where CRLF is considered a single\n// line break). Used to count lines.\nexport const lineBreak = /\\r\\n?|[\\n\\u2028\\u2029]/;\nexport const lineBreakG = new RegExp(lineBreak.source, \"g\");\n\n// https://tc39.github.io/ecma262/#sec-line-terminators\nexport function isNewLine(code: number): boolean {\n switch (code) {\n case charCodes.lineFeed:\n case charCodes.carriageReturn:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n return true;\n\n default:\n return false;\n }\n}\n\nexport const skipWhiteSpace = /(?:\\s|\\/\\/.*|\\/\\*[^]*?\\*\\/)*/g;\n\n// https://tc39.github.io/ecma262/#sec-white-space\nexport function isWhitespace(code: number): boolean {\n switch (code) {\n case 0x0009: // CHARACTER TABULATION\n case 0x000b: // LINE TABULATION\n case 0x000c: // FORM FEED\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.oghamSpaceMark:\n case 0x2000: // EN QUAD\n case 0x2001: // EM QUAD\n case 0x2002: // EN SPACE\n case 0x2003: // EM SPACE\n case 0x2004: // THREE-PER-EM SPACE\n case 0x2005: // FOUR-PER-EM SPACE\n case 0x2006: // SIX-PER-EM SPACE\n case 0x2007: // FIGURE SPACE\n case 0x2008: // PUNCTUATION SPACE\n case 0x2009: // THIN SPACE\n case 0x200a: // HAIR SPACE\n case 0x202f: // NARROW NO-BREAK SPACE\n case 0x205f: // MEDIUM MATHEMATICAL SPACE\n case 0x3000: // IDEOGRAPHIC SPACE\n case 0xfeff: // ZERO WIDTH NO-BREAK SPACE\n return true;\n\n default:\n return false;\n }\n}\n","// @flow\n\nimport { lineBreakG } from \"./whitespace\";\n\nexport type Pos = {\n start: number,\n};\n\n// These are used when `options.locations` is on, for the\n// `startLoc` and `endLoc` properties.\n\nexport class Position {\n line: number;\n column: number;\n\n constructor(line: number, col: number) {\n this.line = line;\n this.column = col;\n }\n}\n\nexport class SourceLocation {\n start: Position;\n end: Position;\n filename: string;\n identifierName: ?string;\n\n constructor(start: Position, end?: Position) {\n this.start = start;\n // $FlowIgnore (may start as null, but initialized later)\n this.end = end;\n }\n}\n\n// The `getLineInfo` function is mostly useful when the\n// `locations` option is off (for performance reasons) and you\n// want to find the line/column position for a given character\n// offset. `input` should be the code string that the offset refers\n// into.\n\nexport function getLineInfo(input: string, offset: number): Position {\n let line = 1;\n let lineStart = 0;\n let match;\n lineBreakG.lastIndex = 0;\n while ((match = lineBreakG.exec(input)) && match.index < offset) {\n line++;\n lineStart = lineBreakG.lastIndex;\n }\n\n return new Position(line, offset - lineStart);\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport type State from \"../tokenizer/state\";\nimport type { PluginsMap } from \"./index\";\nimport type ScopeHandler from \"../util/scope\";\nimport type ExpressionScopeHandler from \"../util/expression-scope\";\nimport type ClassScopeHandler from \"../util/class-scope\";\nimport type ProductionParameterHandler from \"../util/production-parameter\";\n\nexport default class BaseParser {\n // Properties set by constructor in index.js\n declare options: Options;\n declare inModule: boolean;\n declare scope: ScopeHandler<*>;\n declare classScope: ClassScopeHandler;\n declare prodParam: ProductionParameterHandler;\n declare expressionScope: ExpressionScopeHandler;\n declare plugins: PluginsMap;\n declare filename: ?string;\n sawUnambiguousESM: boolean = false;\n ambiguousScriptDifferentAst: boolean = false;\n\n // Initialized by Tokenizer\n declare state: State;\n // input and length are not in state as they are constant and we do\n // not want to ever copy them, which happens if state gets cloned\n declare input: string;\n declare length: number;\n\n hasPlugin(name: string): boolean {\n return this.plugins.has(name);\n }\n\n getPluginOption(plugin: string, name: string) {\n // $FlowIssue\n if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name];\n }\n}\n","// @flow\n\n/**\n * Based on the comment attachment algorithm used in espree and estraverse.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nimport BaseParser from \"./base\";\nimport type { Comment, Node } from \"../types\";\n\nfunction last(stack: $ReadOnlyArray): T {\n return stack[stack.length - 1];\n}\n\nexport default class CommentsParser extends BaseParser {\n addComment(comment: Comment): void {\n if (this.filename) comment.loc.filename = this.filename;\n this.state.trailingComments.push(comment);\n this.state.leadingComments.push(comment);\n }\n\n adjustCommentsAfterTrailingComma(\n node: Node,\n elements: (Node | null)[],\n // When the current node is followed by a token which hasn't a respective AST node, we\n // need to take all the trailing comments to prevent them from being attached to an\n // unrelated node. e.g. in\n // var { x } /* cmt */ = { y }\n // we don't want /* cmt */ to be attached to { y }.\n // On the other hand, in\n // fn(x) [new line] /* cmt */ [new line] y\n // /* cmt */ is both a trailing comment of fn(x) and a leading comment of y\n takeAllComments?: boolean,\n ) {\n if (this.state.leadingComments.length === 0) {\n return;\n }\n\n let lastElement = null;\n let i = elements.length;\n while (lastElement === null && i > 0) {\n lastElement = elements[--i];\n }\n if (lastElement === null) {\n return;\n }\n\n for (let j = 0; j < this.state.leadingComments.length; j++) {\n if (\n this.state.leadingComments[j].end < this.state.commentPreviousNode.end\n ) {\n this.state.leadingComments.splice(j, 1);\n j--;\n }\n }\n\n const newTrailingComments = [];\n for (let i = 0; i < this.state.leadingComments.length; i++) {\n const leadingComment = this.state.leadingComments[i];\n if (leadingComment.end < node.end) {\n newTrailingComments.push(leadingComment);\n\n // Perf: we don't need to splice if we are going to reset the array anyway\n if (!takeAllComments) {\n this.state.leadingComments.splice(i, 1);\n i--;\n }\n } else {\n if (node.trailingComments === undefined) {\n node.trailingComments = [];\n }\n node.trailingComments.push(leadingComment);\n }\n }\n if (takeAllComments) this.state.leadingComments = [];\n\n if (newTrailingComments.length > 0) {\n lastElement.trailingComments = newTrailingComments;\n } else if (lastElement.trailingComments !== undefined) {\n lastElement.trailingComments = [];\n }\n }\n\n processComment(node: Node): void {\n if (node.type === \"Program\" && node.body.length > 0) return;\n\n const stack = this.state.commentStack;\n\n let firstChild, lastChild, trailingComments, i, j;\n\n if (this.state.trailingComments.length > 0) {\n // If the first comment in trailingComments comes after the\n // current node, then we're good - all comments in the array will\n // come after the node and so it's safe to add them as official\n // trailingComments.\n if (this.state.trailingComments[0].start >= node.end) {\n trailingComments = this.state.trailingComments;\n this.state.trailingComments = [];\n } else {\n // Otherwise, if the first comment doesn't come after the\n // current node, that means we have a mix of leading and trailing\n // comments in the array and that leadingComments contains the\n // same items as trailingComments. Reset trailingComments to\n // zero items and we'll handle this by evaluating leadingComments\n // later.\n this.state.trailingComments.length = 0;\n }\n } else if (stack.length > 0) {\n const lastInStack = last(stack);\n if (\n lastInStack.trailingComments &&\n lastInStack.trailingComments[0].start >= node.end\n ) {\n trailingComments = lastInStack.trailingComments;\n delete lastInStack.trailingComments;\n }\n }\n\n // Eating the stack.\n if (stack.length > 0 && last(stack).start >= node.start) {\n firstChild = stack.pop();\n }\n\n while (stack.length > 0 && last(stack).start >= node.start) {\n lastChild = stack.pop();\n }\n\n if (!lastChild && firstChild) lastChild = firstChild;\n\n // Adjust comments that follow a trailing comma on the last element in a\n // comma separated list of nodes to be the trailing comments on the last\n // element\n if (firstChild) {\n switch (node.type) {\n case \"ObjectExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.properties);\n break;\n case \"ObjectPattern\":\n this.adjustCommentsAfterTrailingComma(node, node.properties, true);\n break;\n case \"CallExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.arguments);\n break;\n case \"ArrayExpression\":\n this.adjustCommentsAfterTrailingComma(node, node.elements);\n break;\n case \"ArrayPattern\":\n this.adjustCommentsAfterTrailingComma(node, node.elements, true);\n break;\n }\n } else if (\n this.state.commentPreviousNode &&\n ((this.state.commentPreviousNode.type === \"ImportSpecifier\" &&\n node.type !== \"ImportSpecifier\") ||\n (this.state.commentPreviousNode.type === \"ExportSpecifier\" &&\n node.type !== \"ExportSpecifier\"))\n ) {\n this.adjustCommentsAfterTrailingComma(node, [\n this.state.commentPreviousNode,\n ]);\n }\n\n if (lastChild) {\n if (lastChild.leadingComments) {\n if (\n lastChild !== node &&\n lastChild.leadingComments.length > 0 &&\n last(lastChild.leadingComments).end <= node.start\n ) {\n node.leadingComments = lastChild.leadingComments;\n delete lastChild.leadingComments;\n } else {\n // A leading comment for an anonymous class had been stolen by its first ClassMethod,\n // so this takes back the leading comment.\n // See also: https://github.com/eslint/espree/issues/158\n for (i = lastChild.leadingComments.length - 2; i >= 0; --i) {\n if (lastChild.leadingComments[i].end <= node.start) {\n node.leadingComments = lastChild.leadingComments.splice(0, i + 1);\n break;\n }\n }\n }\n }\n } else if (this.state.leadingComments.length > 0) {\n if (last(this.state.leadingComments).end <= node.start) {\n if (this.state.commentPreviousNode) {\n for (j = 0; j < this.state.leadingComments.length; j++) {\n if (\n this.state.leadingComments[j].end <\n this.state.commentPreviousNode.end\n ) {\n this.state.leadingComments.splice(j, 1);\n j--;\n }\n }\n }\n if (this.state.leadingComments.length > 0) {\n node.leadingComments = this.state.leadingComments;\n this.state.leadingComments = [];\n }\n } else {\n // https://github.com/eslint/espree/issues/2\n //\n // In special cases, such as return (without a value) and\n // debugger, all comments will end up as leadingComments and\n // will otherwise be eliminated. This step runs when the\n // commentStack is empty and there are comments left\n // in leadingComments.\n //\n // This loop figures out the stopping point between the actual\n // leading and trailing comments by finding the location of the\n // first comment that comes after the given node.\n for (i = 0; i < this.state.leadingComments.length; i++) {\n if (this.state.leadingComments[i].end > node.start) {\n break;\n }\n }\n\n // Split the array based on the location of the first comment\n // that comes after the node. Keep in mind that this could\n // result in an empty array, and if so, the array must be\n // deleted.\n const leadingComments = this.state.leadingComments.slice(0, i);\n\n if (leadingComments.length) {\n node.leadingComments = leadingComments;\n }\n\n // Similarly, trailing comments are attached later. The variable\n // must be reset to null if there are no trailing comments.\n trailingComments = this.state.leadingComments.slice(i);\n if (trailingComments.length === 0) {\n trailingComments = null;\n }\n }\n }\n\n this.state.commentPreviousNode = node;\n\n if (trailingComments) {\n if (\n trailingComments.length &&\n trailingComments[0].start >= node.start &&\n last(trailingComments).end <= node.end\n ) {\n node.innerComments = trailingComments;\n } else {\n // TrailingComments maybe contain innerComments\n const firstTrailingCommentIndex = trailingComments.findIndex(\n comment => comment.end >= node.end,\n );\n\n if (firstTrailingCommentIndex > 0) {\n node.innerComments = trailingComments.slice(\n 0,\n firstTrailingCommentIndex,\n );\n node.trailingComments = trailingComments.slice(\n firstTrailingCommentIndex,\n );\n } else {\n node.trailingComments = trailingComments;\n }\n }\n }\n\n stack.push(node);\n }\n}\n","// @flow\n/* eslint sort-keys: \"error\" */\n\n/**\n * @module parser/error-message\n */\n\n// The Errors key follows https://cs.chromium.org/chromium/src/v8/src/common/message-template.h unless it does not exist\nexport const ErrorMessages = Object.freeze({\n AccessorIsGenerator: \"A %0ter cannot be a generator\",\n ArgumentsInClass:\n \"'arguments' is only allowed in functions and class methods\",\n AsyncFunctionInSingleStatementContext:\n \"Async functions can only be declared at the top level or inside a block\",\n AwaitBindingIdentifier:\n \"Can not use 'await' as identifier inside an async function\",\n AwaitBindingIdentifierInStaticBlock:\n \"Can not use 'await' as identifier inside a static block\",\n AwaitExpressionFormalParameter:\n \"await is not allowed in async function parameters\",\n AwaitNotInAsyncContext:\n \"'await' is only allowed within async functions and at the top levels of modules\",\n AwaitNotInAsyncFunction: \"'await' is only allowed within async functions\",\n BadGetterArity: \"getter must not have any formal parameters\",\n BadSetterArity: \"setter must have exactly one formal parameter\",\n BadSetterRestParameter:\n \"setter function argument must not be a rest parameter\",\n ConstructorClassField: \"Classes may not have a field named 'constructor'\",\n ConstructorClassPrivateField:\n \"Classes may not have a private field named '#constructor'\",\n ConstructorIsAccessor: \"Class constructor may not be an accessor\",\n ConstructorIsAsync: \"Constructor can't be an async function\",\n ConstructorIsGenerator: \"Constructor can't be a generator\",\n DeclarationMissingInitializer: \"%0 require an initialization value\",\n DecoratorBeforeExport:\n \"Decorators must be placed *before* the 'export' keyword. You can set the 'decoratorsBeforeExport' option to false to use the 'export @decorator class {}' syntax\",\n DecoratorConstructor:\n \"Decorators can't be used with a constructor. Did you mean '@dec class { ... }'?\",\n DecoratorExportClass:\n \"Using the export keyword between a decorator and a class is not allowed. Please use `export @dec class` instead.\",\n DecoratorSemicolon: \"Decorators must not be followed by a semicolon\",\n DecoratorStaticBlock: \"Decorators can't be used with a static block\",\n DeletePrivateField: \"Deleting a private field is not allowed\",\n DestructureNamedImport:\n \"ES2015 named imports do not destructure. Use another statement for destructuring after the import.\",\n DuplicateConstructor: \"Duplicate constructor in the same class\",\n DuplicateDefaultExport: \"Only one default export allowed per module.\",\n DuplicateExport:\n \"`%0` has already been exported. Exported identifiers must be unique.\",\n DuplicateProto: \"Redefinition of __proto__ property\",\n DuplicateRegExpFlags: \"Duplicate regular expression flag\",\n DuplicateStaticBlock: \"Duplicate static block in the same class\",\n ElementAfterRest: \"Rest element must be last element\",\n EscapedCharNotAnIdentifier: \"Invalid Unicode escape\",\n ExportBindingIsString:\n \"A string literal cannot be used as an exported binding without `from`.\\n- Did you mean `export { '%0' as '%1' } from 'some-module'`?\",\n ExportDefaultFromAsIdentifier:\n \"'from' is not allowed as an identifier after 'export default'\",\n ForInOfLoopInitializer:\n \"%0 loop variable declaration may not have an initializer\",\n GeneratorInSingleStatementContext:\n \"Generators can only be declared at the top level or inside a block\",\n IllegalBreakContinue: \"Unsyntactic %0\",\n IllegalLanguageModeDirective:\n \"Illegal 'use strict' directive in function with non-simple parameter list\",\n IllegalReturn: \"'return' outside of function\",\n ImportBindingIsString:\n 'A string literal cannot be used as an imported binding.\\n- Did you mean `import { \"%0\" as foo }`?',\n ImportCallArgumentTrailingComma:\n \"Trailing comma is disallowed inside import(...) arguments\",\n ImportCallArity: \"import() requires exactly %0\",\n ImportCallNotNewExpression: \"Cannot use new with import(...)\",\n ImportCallSpreadArgument: \"... is not allowed in import()\",\n ImportMetaOutsideModule: `import.meta may appear only with 'sourceType: \"module\"'`,\n ImportOutsideModule: `'import' and 'export' may appear only with 'sourceType: \"module\"'`,\n InvalidBigIntLiteral: \"Invalid BigIntLiteral\",\n InvalidCodePoint: \"Code point out of bounds\",\n InvalidDecimal: \"Invalid decimal\",\n InvalidDigit: \"Expected number in radix %0\",\n InvalidEscapeSequence: \"Bad character escape sequence\",\n InvalidEscapeSequenceTemplate: \"Invalid escape sequence in template\",\n InvalidEscapedReservedWord: \"Escape sequence in keyword %0\",\n InvalidIdentifier: \"Invalid identifier %0\",\n InvalidLhs: \"Invalid left-hand side in %0\",\n InvalidLhsBinding: \"Binding invalid left-hand side in %0\",\n InvalidNumber: \"Invalid number\",\n InvalidOrMissingExponent:\n \"Floating-point numbers require a valid exponent after the 'e'\",\n InvalidOrUnexpectedToken: \"Unexpected character '%0'\",\n InvalidParenthesizedAssignment: \"Invalid parenthesized assignment pattern\",\n InvalidPrivateFieldResolution: \"Private name #%0 is not defined\",\n InvalidPropertyBindingPattern: \"Binding member expression\",\n InvalidRecordProperty:\n \"Only properties and spread elements are allowed in record definitions\",\n InvalidRestAssignmentPattern: \"Invalid rest operator's argument\",\n LabelRedeclaration: \"Label '%0' is already declared\",\n LetInLexicalBinding:\n \"'let' is not allowed to be used as a name in 'let' or 'const' declarations.\",\n LineTerminatorBeforeArrow: \"No line break is allowed before '=>'\",\n MalformedRegExpFlags: \"Invalid regular expression flag\",\n MissingClassName: \"A class name is required\",\n MissingEqInAssignment:\n \"Only '=' operator can be used for specifying default value.\",\n MissingSemicolon: \"Missing semicolon\",\n MissingUnicodeEscape: \"Expecting Unicode escape sequence \\\\uXXXX\",\n MixingCoalesceWithLogical:\n \"Nullish coalescing operator(??) requires parens when mixing with logical operators\",\n ModuleAttributeDifferentFromType:\n \"The only accepted module attribute is `type`\",\n ModuleAttributeInvalidValue:\n \"Only string literals are allowed as module attribute values\",\n ModuleAttributesWithDuplicateKeys:\n 'Duplicate key \"%0\" is not allowed in module attributes',\n ModuleExportNameHasLoneSurrogate:\n \"An export name cannot include a lone surrogate, found '\\\\u%0'\",\n ModuleExportUndefined: \"Export '%0' is not defined\",\n MultipleDefaultsInSwitch: \"Multiple default clauses\",\n NewlineAfterThrow: \"Illegal newline after throw\",\n NoCatchOrFinally: \"Missing catch or finally clause\",\n NumberIdentifier: \"Identifier directly after number\",\n NumericSeparatorInEscapeSequence:\n \"Numeric separators are not allowed inside unicode escape sequences or hex escape sequences\",\n ObsoleteAwaitStar:\n \"await* has been removed from the async functions proposal. Use Promise.all() instead.\",\n OptionalChainingNoNew:\n \"constructors in/after an Optional Chain are not allowed\",\n OptionalChainingNoTemplate:\n \"Tagged Template Literals are not allowed in optionalChain\",\n ParamDupe: \"Argument name clash\",\n PatternHasAccessor: \"Object pattern can't contain getter or setter\",\n PatternHasMethod: \"Object pattern can't contain methods\",\n PipelineBodyNoArrow:\n 'Unexpected arrow \"=>\" after pipeline body; arrow function in pipeline body must be parenthesized',\n PipelineBodySequenceExpression:\n \"Pipeline body may not be a comma-separated sequence expression\",\n PipelineHeadSequenceExpression:\n \"Pipeline head should not be a comma-separated sequence expression\",\n PipelineTopicUnused:\n \"Pipeline is in topic style but does not use topic reference\",\n PrimaryTopicNotAllowed:\n \"Topic reference was used in a lexical context without topic binding\",\n PrimaryTopicRequiresSmartPipeline:\n \"Primary Topic Reference found but pipelineOperator not passed 'smart' for 'proposal' option.\",\n PrivateInExpectedIn:\n \"Private names are only allowed in property accesses (`obj.#%0`) or in `in` expressions (`#%0 in obj`)\",\n PrivateNameRedeclaration: \"Duplicate private name #%0\",\n RecordExpressionBarIncorrectEndSyntaxType:\n \"Record expressions ending with '|}' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n RecordExpressionBarIncorrectStartSyntaxType:\n \"Record expressions starting with '{|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n RecordExpressionHashIncorrectStartSyntaxType:\n \"Record expressions starting with '#{' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'\",\n RecordNoProto: \"'__proto__' is not allowed in Record expressions\",\n RestTrailingComma: \"Unexpected trailing comma after rest element\",\n SloppyFunction:\n \"In non-strict mode code, functions can only be declared at top level, inside a block, or as the body of an if statement\",\n StaticPrototype: \"Classes may not have static property named prototype\",\n StrictDelete: \"Deleting local variable in strict mode\",\n StrictEvalArguments: \"Assigning to '%0' in strict mode\",\n StrictEvalArgumentsBinding: \"Binding '%0' in strict mode\",\n StrictFunction:\n \"In strict mode code, functions can only be declared at top level or inside a block\",\n StrictNumericEscape: \"The only valid numeric escape in strict mode is '\\\\0'\",\n StrictOctalLiteral: \"Legacy octal literals are not allowed in strict mode\",\n StrictWith: \"'with' in strict mode\",\n SuperNotAllowed:\n \"super() is only valid inside a class constructor of a subclass. Maybe a typo in the method name ('constructor') or not extending another class?\",\n SuperPrivateField: \"Private fields can't be accessed on super\",\n TrailingDecorator: \"Decorators must be attached to a class element\",\n TupleExpressionBarIncorrectEndSyntaxType:\n \"Tuple expressions ending with '|]' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n TupleExpressionBarIncorrectStartSyntaxType:\n \"Tuple expressions starting with '[|' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'bar'\",\n TupleExpressionHashIncorrectStartSyntaxType:\n \"Tuple expressions starting with '#[' are only allowed when the 'syntaxType' option of the 'recordAndTuple' plugin is set to 'hash'\",\n UnexpectedArgumentPlaceholder: \"Unexpected argument placeholder\",\n UnexpectedAwaitAfterPipelineBody:\n 'Unexpected \"await\" after pipeline body; await must have parentheses in minimal proposal',\n UnexpectedDigitAfterHash: \"Unexpected digit after hash token\",\n UnexpectedImportExport:\n \"'import' and 'export' may only appear at the top level\",\n UnexpectedKeyword: \"Unexpected keyword '%0'\",\n UnexpectedLeadingDecorator:\n \"Leading decorators must be attached to a class declaration\",\n UnexpectedLexicalDeclaration:\n \"Lexical declaration cannot appear in a single-statement context\",\n UnexpectedNewTarget: \"new.target can only be used in functions\",\n UnexpectedNumericSeparator:\n \"A numeric separator is only allowed between two digits\",\n UnexpectedPrivateField:\n \"Private names can only be used as the name of a class element (i.e. class C { #p = 42; #m() {} } )\\n or a property of member expression (i.e. this.#p).\",\n UnexpectedReservedWord: \"Unexpected reserved word '%0'\",\n UnexpectedSuper: \"super is only allowed in object methods and classes\",\n UnexpectedToken: \"Unexpected token '%0'\",\n UnexpectedTokenUnaryExponentiation:\n \"Illegal expression. Wrap left hand side or entire exponentiation in parentheses.\",\n UnsupportedBind: \"Binding should be performed on object property.\",\n UnsupportedDecoratorExport:\n \"A decorated export must export a class declaration\",\n UnsupportedDefaultExport:\n \"Only expressions, functions or classes are allowed as the `default` export.\",\n UnsupportedImport: \"import can only be used in import() or import.meta\",\n UnsupportedMetaProperty: \"The only valid meta property for %0 is %0.%1\",\n UnsupportedParameterDecorator:\n \"Decorators cannot be used to decorate parameters\",\n UnsupportedPropertyDecorator:\n \"Decorators cannot be used to decorate object literal properties\",\n UnsupportedSuper:\n \"super can only be used with function calls (i.e. super()) or in property accesses (i.e. super.prop or super[prop])\",\n UnterminatedComment: \"Unterminated comment\",\n UnterminatedRegExp: \"Unterminated regular expression\",\n UnterminatedString: \"Unterminated string constant\",\n UnterminatedTemplate: \"Unterminated template\",\n VarRedeclaration: \"Identifier '%0' has already been declared\",\n YieldBindingIdentifier:\n \"Can not use 'yield' as identifier inside a generator\",\n YieldInParameter: \"Yield expression is not allowed in formal parameters\",\n ZeroDigitNumericSeparator:\n \"Numeric separator can not be used after leading 0\",\n});\n","// @flow\n/* eslint sort-keys: \"error\" */\nimport { getLineInfo, type Position } from \"../util/location\";\nimport CommentsParser from \"./comments\";\n\n// This function is used to raise exceptions on parse errors. It\n// takes an offset integer (into the current `input`) to indicate\n// the location of the error, attaches the position to the end\n// of the error message, and then raises a `SyntaxError` with that\n// message.\n\ntype ErrorContext = {\n pos: number,\n loc: Position,\n missingPlugin?: Array,\n code?: string,\n};\n\nexport type ParsingError = SyntaxError & ErrorContext;\n\nexport { ErrorMessages as Errors } from \"./error-message\";\n\nexport default class ParserError extends CommentsParser {\n // Forward-declaration: defined in tokenizer/index.js\n /*::\n +isLookahead: boolean;\n */\n\n getLocationForPosition(pos: number): Position {\n let loc;\n if (pos === this.state.start) loc = this.state.startLoc;\n else if (pos === this.state.lastTokStart) loc = this.state.lastTokStartLoc;\n else if (pos === this.state.end) loc = this.state.endLoc;\n else if (pos === this.state.lastTokEnd) loc = this.state.lastTokEndLoc;\n else loc = getLineInfo(this.input, pos);\n\n return loc;\n }\n\n raise(pos: number, errorTemplate: string, ...params: any): Error | empty {\n return this.raiseWithData(pos, undefined, errorTemplate, ...params);\n }\n\n /**\n * Raise a parsing error on given position pos. If errorRecovery is true,\n * it will first search current errors and overwrite the error thrown on the exact\n * position before with the new error message. If errorRecovery is false, it\n * fallbacks to `raise`.\n *\n * @param {number} pos\n * @param {string} errorTemplate\n * @param {...any} params\n * @returns {(Error | empty)}\n * @memberof ParserError\n */\n raiseOverwrite(\n pos: number,\n errorTemplate: string,\n ...params: any\n ): Error | empty {\n const loc = this.getLocationForPosition(pos);\n const message =\n errorTemplate.replace(/%(\\d+)/g, (_, i: number) => params[i]) +\n ` (${loc.line}:${loc.column})`;\n if (this.options.errorRecovery) {\n const errors = this.state.errors;\n for (let i = errors.length - 1; i >= 0; i--) {\n const error = errors[i];\n if (error.pos === pos) {\n return Object.assign(error, { message });\n } else if (error.pos < pos) {\n break;\n }\n }\n }\n return this._raise({ loc, pos }, message);\n }\n\n raiseWithData(\n pos: number,\n data?: {\n missingPlugin?: Array,\n code?: string,\n },\n errorTemplate: string,\n ...params: any\n ): Error | empty {\n const loc = this.getLocationForPosition(pos);\n const message =\n errorTemplate.replace(/%(\\d+)/g, (_, i: number) => params[i]) +\n ` (${loc.line}:${loc.column})`;\n return this._raise(Object.assign(({ loc, pos }: Object), data), message);\n }\n\n _raise(errorContext: ErrorContext, message: string): Error | empty {\n // $FlowIgnore\n const err: SyntaxError & ErrorContext = new SyntaxError(message);\n Object.assign(err, errorContext);\n if (this.options.errorRecovery) {\n if (!this.isLookahead) this.state.errors.push(err);\n return err;\n } else {\n throw err;\n }\n }\n}\n","// @flow\n\nimport { types as tt, TokenType } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport type { ExpressionErrors } from \"../parser/util\";\nimport * as N from \"../types\";\nimport type { Position } from \"../util/location\";\nimport { Errors } from \"../parser/error\";\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n estreeParseRegExpLiteral({ pattern, flags }: N.RegExpLiteral): N.Node {\n let regex = null;\n try {\n regex = new RegExp(pattern, flags);\n } catch (e) {\n // In environments that don't support these flags value will\n // be null as the regex can't be represented natively.\n }\n const node = this.estreeParseLiteral(regex);\n node.regex = { pattern, flags };\n\n return node;\n }\n\n estreeParseBigIntLiteral(value: any): N.Node {\n // https://github.com/estree/estree/blob/master/es2020.md#bigintliteral\n let bigInt;\n try {\n // $FlowIgnore\n bigInt = BigInt(value);\n } catch {\n bigInt = null;\n }\n const node = this.estreeParseLiteral(bigInt);\n node.bigint = String(node.value || value);\n\n return node;\n }\n\n estreeParseDecimalLiteral(value: any): N.Node {\n // https://github.com/estree/estree/blob/master/experimental/decimal.md\n // todo: use BigDecimal when node supports it.\n const decimal = null;\n const node = this.estreeParseLiteral(decimal);\n node.decimal = String(node.value || value);\n\n return node;\n }\n\n estreeParseLiteral(value: any): N.Node {\n return this.parseLiteral(value, \"Literal\");\n }\n\n directiveToStmt(directive: N.Directive): N.ExpressionStatement {\n const directiveLiteral = directive.value;\n\n const stmt = this.startNodeAt(directive.start, directive.loc.start);\n const expression = this.startNodeAt(\n directiveLiteral.start,\n directiveLiteral.loc.start,\n );\n\n expression.value = directiveLiteral.extra.expressionValue;\n expression.raw = directiveLiteral.extra.raw;\n\n stmt.expression = this.finishNodeAt(\n expression,\n \"Literal\",\n directiveLiteral.end,\n directiveLiteral.loc.end,\n );\n stmt.directive = directiveLiteral.extra.raw.slice(1, -1);\n\n return this.finishNodeAt(\n stmt,\n \"ExpressionStatement\",\n directive.end,\n directive.loc.end,\n );\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n initFunction(\n node: N.BodilessFunctionOrMethodBase,\n isAsync: ?boolean,\n ): void {\n super.initFunction(node, isAsync);\n node.expression = false;\n }\n\n checkDeclaration(node: N.Pattern | N.ObjectProperty): void {\n if (node != null && this.isObjectProperty(node)) {\n this.checkDeclaration(((node: any): N.EstreeProperty).value);\n } else {\n super.checkDeclaration(node);\n }\n }\n\n getObjectOrClassMethodParams(method: N.ObjectMethod | N.ClassMethod) {\n return ((method: any): N.EstreeProperty | N.EstreeMethodDefinition).value\n .params;\n }\n\n isValidDirective(stmt: N.Statement): boolean {\n return (\n stmt.type === \"ExpressionStatement\" &&\n stmt.expression.type === \"Literal\" &&\n typeof stmt.expression.value === \"string\" &&\n !stmt.expression.extra?.parenthesized\n );\n }\n\n stmtToDirective(stmt: N.Statement): N.Directive {\n const directive = super.stmtToDirective(stmt);\n const value = stmt.expression.value;\n\n // Record the expression value as in estree mode we want\n // the stmt to have the real value e.g. (\"use strict\") and\n // not the raw value e.g. (\"use\\\\x20strict\")\n this.addExtra(directive.value, \"expressionValue\", value);\n\n return directive;\n }\n\n parseBlockBody(\n node: N.BlockStatementLike,\n ...args: [?boolean, boolean, TokenType, void | (boolean => void)]\n ): void {\n super.parseBlockBody(node, ...args);\n\n const directiveStatements = node.directives.map(d =>\n this.directiveToStmt(d),\n );\n node.body = directiveStatements.concat(node.body);\n // $FlowIgnore - directives isn't optional in the type definition\n delete node.directives;\n }\n\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n this.parseMethod(\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n \"ClassMethod\",\n true,\n );\n if (method.typeParameters) {\n // $FlowIgnore\n method.value.typeParameters = method.typeParameters;\n delete method.typeParameters;\n }\n classBody.body.push(method);\n }\n\n parseExprAtom(refExpressionErrors?: ?ExpressionErrors): N.Expression {\n switch (this.state.type) {\n case tt.num:\n case tt.string:\n return this.estreeParseLiteral(this.state.value);\n\n case tt.regexp:\n return this.estreeParseRegExpLiteral(this.state.value);\n\n case tt.bigint:\n return this.estreeParseBigIntLiteral(this.state.value);\n\n case tt.decimal:\n return this.estreeParseDecimalLiteral(this.state.value);\n\n case tt._null:\n return this.estreeParseLiteral(null);\n\n case tt._true:\n return this.estreeParseLiteral(true);\n\n case tt._false:\n return this.estreeParseLiteral(false);\n\n default:\n return super.parseExprAtom(refExpressionErrors);\n }\n }\n\n parseMaybePrivateName(...args: [boolean]): any {\n const node = super.parseMaybePrivateName(...args);\n if (\n node.type === \"PrivateName\" &&\n this.getPluginOption(\"estree\", \"classFeatures\")\n ) {\n return this.convertPrivateNameToPrivateIdentifier(node);\n }\n return node;\n }\n\n convertPrivateNameToPrivateIdentifier(\n node: N.PrivateName,\n ): N.EstreePrivateIdentifier {\n const name = super.getPrivateNameSV(node);\n node = (node: any);\n delete node.id;\n node.name = name;\n node.type = \"PrivateIdentifier\";\n return node;\n }\n\n isPrivateName(node: N.Node): boolean {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return super.isPrivateName(node);\n }\n return node.type === \"PrivateIdentifier\";\n }\n\n getPrivateNameSV(node: N.Node): string {\n if (!this.getPluginOption(\"estree\", \"classFeatures\")) {\n return super.getPrivateNameSV(node);\n }\n return node.name;\n }\n\n parseLiteral(\n value: any,\n type: /*T[\"kind\"]*/ string,\n startPos?: number,\n startLoc?: Position,\n ): T {\n const node = super.parseLiteral(value, type, startPos, startLoc);\n node.raw = node.extra.raw;\n delete node.extra;\n\n return node;\n }\n\n parseFunctionBody(\n node: N.Function,\n allowExpression: ?boolean,\n isMethod?: boolean = false,\n ): void {\n super.parseFunctionBody(node, allowExpression, isMethod);\n node.expression = node.body.type !== \"BlockStatement\";\n }\n\n parseMethod(\n node: T,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowDirectSuper: boolean,\n type: string,\n inClassScope: boolean = false,\n ): T {\n let funcNode = this.startNode();\n funcNode.kind = node.kind; // provide kind, so super method correctly sets state\n funcNode = super.parseMethod(\n funcNode,\n isGenerator,\n isAsync,\n isConstructor,\n allowDirectSuper,\n type,\n inClassScope,\n );\n funcNode.type = \"FunctionExpression\";\n delete funcNode.kind;\n // $FlowIgnore\n node.value = funcNode;\n if (type === \"ClassPrivateMethod\") {\n // $FlowIgnore\n node.computed = false;\n }\n type = \"MethodDefinition\";\n return this.finishNode(node, type);\n }\n\n parseClassProperty(...args: [N.ClassProperty]): any {\n const propertyNode = (super.parseClassProperty(...args): any);\n if (this.getPluginOption(\"estree\", \"classFeatures\")) {\n propertyNode.type = \"PropertyDefinition\";\n }\n return (propertyNode: N.EstreePropertyDefinition);\n }\n\n parseClassPrivateProperty(...args: [N.ClassPrivateProperty]): any {\n const propertyNode = (super.parseClassPrivateProperty(...args): any);\n if (this.getPluginOption(\"estree\", \"classFeatures\")) {\n propertyNode.type = \"PropertyDefinition\";\n propertyNode.computed = false;\n }\n return (propertyNode: N.EstreePropertyDefinition);\n }\n\n parseObjectMethod(\n prop: N.ObjectMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isPattern: boolean,\n isAccessor: boolean,\n ): ?N.ObjectMethod {\n const node: N.EstreeProperty = (super.parseObjectMethod(\n prop,\n isGenerator,\n isAsync,\n isPattern,\n isAccessor,\n ): any);\n\n if (node) {\n node.type = \"Property\";\n if (((node: any): N.ClassMethod).kind === \"method\") node.kind = \"init\";\n node.shorthand = false;\n }\n\n return (node: any);\n }\n\n parseObjectProperty(\n prop: N.ObjectProperty,\n startPos: ?number,\n startLoc: ?Position,\n isPattern: boolean,\n refExpressionErrors: ?ExpressionErrors,\n ): ?N.ObjectProperty {\n const node: N.EstreeProperty = (super.parseObjectProperty(\n prop,\n startPos,\n startLoc,\n isPattern,\n refExpressionErrors,\n ): any);\n\n if (node) {\n node.kind = \"init\";\n node.type = \"Property\";\n }\n\n return (node: any);\n }\n\n toAssignable(node: N.Node, isLHS: boolean = false): N.Node {\n if (node != null && this.isObjectProperty(node)) {\n this.toAssignable(node.value, isLHS);\n\n return node;\n }\n\n return super.toAssignable(node, isLHS);\n }\n\n toAssignableObjectExpressionProp(prop: N.Node, ...args) {\n if (prop.kind === \"get\" || prop.kind === \"set\") {\n this.raise(prop.key.start, Errors.PatternHasAccessor);\n } else if (prop.method) {\n this.raise(prop.key.start, Errors.PatternHasMethod);\n } else {\n super.toAssignableObjectExpressionProp(prop, ...args);\n }\n }\n\n finishCallExpression(\n node: T,\n optional: boolean,\n ): N.Expression {\n super.finishCallExpression(node, optional);\n\n if (node.callee.type === \"Import\") {\n ((node: N.Node): N.EstreeImportExpression).type = \"ImportExpression\";\n ((node: N.Node): N.EstreeImportExpression).source = node.arguments[0];\n // $FlowIgnore - arguments isn't optional in the type definition\n delete node.arguments;\n // $FlowIgnore - callee isn't optional in the type definition\n delete node.callee;\n }\n\n return node;\n }\n\n toReferencedArguments(\n node:\n | N.CallExpression\n | N.OptionalCallExpression\n | N.EstreeImportExpression,\n /* isParenthesizedExpr?: boolean, */\n ) {\n // ImportExpressions do not have an arguments array.\n if (node.type === \"ImportExpression\") {\n return;\n }\n\n super.toReferencedArguments(node);\n }\n\n parseExport(node: N.Node) {\n super.parseExport(node);\n\n switch (node.type) {\n case \"ExportAllDeclaration\":\n node.exported = null;\n break;\n\n case \"ExportNamedDeclaration\":\n if (\n node.specifiers.length === 1 &&\n node.specifiers[0].type === \"ExportNamespaceSpecifier\"\n ) {\n node.type = \"ExportAllDeclaration\";\n node.exported = node.specifiers[0].exported;\n delete node.specifiers;\n }\n\n break;\n }\n\n return node;\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n state: N.ParseSubscriptState,\n ) {\n const node = super.parseSubscript(\n base,\n startPos,\n startLoc,\n noCalls,\n state,\n );\n\n if (state.optionalChainMember) {\n // https://github.com/estree/estree/blob/master/es2020.md#chainexpression\n if (\n node.type === \"OptionalMemberExpression\" ||\n node.type === \"OptionalCallExpression\"\n ) {\n node.type = node.type.substring(8); // strip Optional prefix\n }\n if (state.stop) {\n const chain = this.startNodeAtNode(node);\n chain.expression = node;\n return this.finishNode(chain, \"ChainExpression\");\n }\n } else if (\n node.type === \"MemberExpression\" ||\n node.type === \"CallExpression\"\n ) {\n node.optional = false;\n }\n\n return node;\n }\n\n hasPropertyAsPrivateName(node: N.Node): boolean {\n if (node.type === \"ChainExpression\") {\n node = node.expression;\n }\n return super.hasPropertyAsPrivateName(node);\n }\n\n isOptionalChain(node: N.Node): boolean {\n return node.type === \"ChainExpression\";\n }\n\n isObjectProperty(node: N.Node): boolean {\n return node.type === \"Property\" && node.kind === \"init\" && !node.method;\n }\n\n isObjectMethod(node: N.Node): boolean {\n return node.method || node.kind === \"get\" || node.kind === \"set\";\n }\n };\n","// @flow\n\n// The algorithm used to determine whether a regexp can appear at a\n// given point in the program is loosely based on sweet.js' approach.\n// See https://github.com/mozilla/sweet.js/wiki/design\n\nimport { types as tt } from \"./types\";\n\nexport class TokContext {\n constructor(\n token: string,\n isExpr?: boolean,\n preserveSpace?: boolean,\n override?: ?Function, // Takes a Tokenizer as a this-parameter, and returns void.\n ) {\n this.token = token;\n this.isExpr = !!isExpr;\n this.preserveSpace = !!preserveSpace;\n this.override = override;\n }\n\n token: string;\n isExpr: boolean;\n preserveSpace: boolean;\n override: ?Function;\n}\n\nexport const types: {\n [key: string]: TokContext,\n} = {\n braceStatement: new TokContext(\"{\", false),\n braceExpression: new TokContext(\"{\", true),\n recordExpression: new TokContext(\"#{\", true),\n templateQuasi: new TokContext(\"${\", false),\n parenStatement: new TokContext(\"(\", false),\n parenExpression: new TokContext(\"(\", true),\n template: new TokContext(\"`\", true, true, p => p.readTmplToken()),\n functionExpression: new TokContext(\"function\", true),\n functionStatement: new TokContext(\"function\", false),\n};\n\n// Token-specific context update code\n// Note that we should avoid accessing `this.prodParam` in context update,\n// because it is executed immediately when last token is consumed, which may be\n// before `this.prodParam` is updated. e.g.\n// ```\n// function *g() { () => yield / 2 }\n// ```\n// When `=>` is eaten, the context update of `yield` is executed, however,\n// `this.prodParam` still has `[Yield]` production because it is not yet updated\n\ntt.parenR.updateContext = tt.braceR.updateContext = function () {\n if (this.state.context.length === 1) {\n this.state.exprAllowed = true;\n return;\n }\n\n let out = this.state.context.pop();\n if (out === types.braceStatement && this.curContext().token === \"function\") {\n out = this.state.context.pop();\n }\n\n this.state.exprAllowed = !out.isExpr;\n};\n\ntt.name.updateContext = function (prevType) {\n let allowed = false;\n if (prevType !== tt.dot) {\n if (\n this.state.value === \"of\" &&\n !this.state.exprAllowed &&\n prevType !== tt._function &&\n prevType !== tt._class\n ) {\n allowed = true;\n }\n }\n this.state.exprAllowed = allowed;\n\n if (this.state.isIterator) {\n this.state.isIterator = false;\n }\n};\n\ntt.braceL.updateContext = function (prevType) {\n this.state.context.push(\n this.braceIsBlock(prevType) ? types.braceStatement : types.braceExpression,\n );\n this.state.exprAllowed = true;\n};\n\ntt.dollarBraceL.updateContext = function () {\n this.state.context.push(types.templateQuasi);\n this.state.exprAllowed = true;\n};\n\ntt.parenL.updateContext = function (prevType) {\n const statementParens =\n prevType === tt._if ||\n prevType === tt._for ||\n prevType === tt._with ||\n prevType === tt._while;\n this.state.context.push(\n statementParens ? types.parenStatement : types.parenExpression,\n );\n this.state.exprAllowed = true;\n};\n\ntt.incDec.updateContext = function () {\n // tokExprAllowed stays unchanged\n};\n\ntt._function.updateContext = tt._class.updateContext = function (prevType) {\n if (\n prevType.beforeExpr &&\n prevType !== tt.semi &&\n prevType !== tt._else &&\n !(prevType === tt._return && this.hasPrecedingLineBreak()) &&\n !(\n (prevType === tt.colon || prevType === tt.braceL) &&\n this.curContext() === types.b_stat\n )\n ) {\n this.state.context.push(types.functionExpression);\n } else {\n this.state.context.push(types.functionStatement);\n }\n\n this.state.exprAllowed = false;\n};\n\ntt.backQuote.updateContext = function () {\n if (this.curContext() === types.template) {\n this.state.context.pop();\n } else {\n this.state.context.push(types.template);\n }\n this.state.exprAllowed = false;\n};\n\n// we don't need to update context for tt.braceBarL because we do not pop context for tt.braceBarR\ntt.braceHashL.updateContext = function () {\n this.state.context.push(types.recordExpression);\n this.state.exprAllowed = true; /* tt.braceHashL.beforeExpr */\n};\n","import * as charCodes from \"charcodes\";\n\n// ## Character categories\n\n// Big ugly regular expressions that match characters in the\n// whitespace, identifier, and identifier-start categories. These\n// are only applied when a character is found to actually have a\n// code point between 0x80 and 0xffff.\n// Generated by `scripts/generate-identifier-regex.js`.\n\n/* prettier-ignore */\nlet nonASCIIidentifierStartChars = \"\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u037f\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u052f\\u0531-\\u0556\\u0559\\u0560-\\u0588\\u05d0-\\u05ea\\u05ef-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u0860-\\u086a\\u08a0-\\u08b4\\u08b6-\\u08c7\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u09fc\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0af9\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c39\\u0c3d\\u0c58-\\u0c5a\\u0c60\\u0c61\\u0c80\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d04-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d54-\\u0d56\\u0d5f-\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e86-\\u0e8a\\u0e8c-\\u0ea3\\u0ea5\\u0ea7-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f5\\u13f8-\\u13fd\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f8\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1878\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191e\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19b0-\\u19c9\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1c80-\\u1c88\\u1c90-\\u1cba\\u1cbd-\\u1cbf\\u1ce9-\\u1cec\\u1cee-\\u1cf3\\u1cf5\\u1cf6\\u1cfa\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2118-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309b-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u31a0-\\u31bf\\u31f0-\\u31ff\\u3400-\\u4dbf\\u4e00-\\u9ffc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua69d\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua7bf\\ua7c2-\\ua7ca\\ua7f5-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua8fd\\ua8fe\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\ua9e0-\\ua9e4\\ua9e6-\\ua9ef\\ua9fa-\\ua9fe\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa7e-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uab30-\\uab5a\\uab5c-\\uab69\\uab70-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\";\n/* prettier-ignore */\nlet nonASCIIidentifierChars = \"\\u200c\\u200d\\xb7\\u0300-\\u036f\\u0387\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u064b-\\u0669\\u0670\\u06d6-\\u06dc\\u06df-\\u06e4\\u06e7\\u06e8\\u06ea-\\u06ed\\u06f0-\\u06f9\\u0711\\u0730-\\u074a\\u07a6-\\u07b0\\u07c0-\\u07c9\\u07eb-\\u07f3\\u07fd\\u0816-\\u0819\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0859-\\u085b\\u08d3-\\u08e1\\u08e3-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09cb-\\u09cd\\u09d7\\u09e2\\u09e3\\u09e6-\\u09ef\\u09fe\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2\\u0ae3\\u0ae6-\\u0aef\\u0afa-\\u0aff\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b55-\\u0b57\\u0b62\\u0b63\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c00-\\u0c04\\u0c3e-\\u0c44\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62\\u0c63\\u0c66-\\u0c6f\\u0c81-\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2\\u0ce3\\u0ce6-\\u0cef\\u0d00-\\u0d03\\u0d3b\\u0d3c\\u0d3e-\\u0d44\\u0d46-\\u0d48\\u0d4a-\\u0d4d\\u0d57\\u0d62\\u0d63\\u0d66-\\u0d6f\\u0d81-\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0de6-\\u0def\\u0df2\\u0df3\\u0e31\\u0e34-\\u0e3a\\u0e47-\\u0e4e\\u0e50-\\u0e59\\u0eb1\\u0eb4-\\u0ebc\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f3e\\u0f3f\\u0f71-\\u0f84\\u0f86\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u102b-\\u103e\\u1040-\\u1049\\u1056-\\u1059\\u105e-\\u1060\\u1062-\\u1064\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u1369-\\u1371\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17b4-\\u17d3\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u18a9\\u1920-\\u192b\\u1930-\\u193b\\u1946-\\u194f\\u19d0-\\u19da\\u1a17-\\u1a1b\\u1a55-\\u1a5e\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1ab0-\\u1abd\\u1abf\\u1ac0\\u1b00-\\u1b04\\u1b34-\\u1b44\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1b80-\\u1b82\\u1ba1-\\u1bad\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c24-\\u1c37\\u1c40-\\u1c49\\u1c50-\\u1c59\\u1cd0-\\u1cd2\\u1cd4-\\u1ce8\\u1ced\\u1cf4\\u1cf7-\\u1cf9\\u1dc0-\\u1df9\\u1dfb-\\u1dff\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2cef-\\u2cf1\\u2d7f\\u2de0-\\u2dff\\u302a-\\u302f\\u3099\\u309a\\ua620-\\ua629\\ua66f\\ua674-\\ua67d\\ua69e\\ua69f\\ua6f0\\ua6f1\\ua802\\ua806\\ua80b\\ua823-\\ua827\\ua82c\\ua880\\ua881\\ua8b4-\\ua8c5\\ua8d0-\\ua8d9\\ua8e0-\\ua8f1\\ua8ff-\\ua909\\ua926-\\ua92d\\ua947-\\ua953\\ua980-\\ua983\\ua9b3-\\ua9c0\\ua9d0-\\ua9d9\\ua9e5\\ua9f0-\\ua9f9\\uaa29-\\uaa36\\uaa43\\uaa4c\\uaa4d\\uaa50-\\uaa59\\uaa7b-\\uaa7d\\uaab0\\uaab2-\\uaab4\\uaab7\\uaab8\\uaabe\\uaabf\\uaac1\\uaaeb-\\uaaef\\uaaf5\\uaaf6\\uabe3-\\uabea\\uabec\\uabed\\uabf0-\\uabf9\\ufb1e\\ufe00-\\ufe0f\\ufe20-\\ufe2f\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f\";\n\nconst nonASCIIidentifierStart = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + \"]\",\n);\nconst nonASCIIidentifier = new RegExp(\n \"[\" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + \"]\",\n);\n\nnonASCIIidentifierStartChars = nonASCIIidentifierChars = null;\n\n// These are a run-length and offset-encoded representation of the\n// >0xffff code points that are a valid part of identifiers. The\n// offset starts at 0x10000, and each pair of numbers represents an\n// offset to the next range, and then a size of the range. They were\n// generated by `scripts/generate-identifier-regex.js`.\n/* prettier-ignore */\n/* prettier-ignore */\nconst astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];\n/* prettier-ignore */\nconst astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];\n\n// This has a complexity linear to the value of the code. The\n// assumption is that looking up astral identifier characters is\n// rare.\nfunction isInAstralSet(code: number, set: readonly number[]): boolean {\n let pos = 0x10000;\n for (let i = 0, length = set.length; i < length; i += 2) {\n pos += set[i];\n if (pos > code) return false;\n\n pos += set[i + 1];\n if (pos >= code) return true;\n }\n return false;\n}\n\n// Test whether a given character code starts an identifier.\n\nexport function isIdentifierStart(code: number): boolean {\n if (code < charCodes.uppercaseA) return code === charCodes.dollarSign;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return (\n code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code))\n );\n }\n return isInAstralSet(code, astralIdentifierStartCodes);\n}\n\n// Test whether a given character is part of an identifier.\n\nexport function isIdentifierChar(code: number): boolean {\n if (code < charCodes.digit0) return code === charCodes.dollarSign;\n if (code < charCodes.colon) return true;\n if (code < charCodes.uppercaseA) return false;\n if (code <= charCodes.uppercaseZ) return true;\n if (code < charCodes.lowercaseA) return code === charCodes.underscore;\n if (code <= charCodes.lowercaseZ) return true;\n if (code <= 0xffff) {\n return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code));\n }\n return (\n isInAstralSet(code, astralIdentifierStartCodes) ||\n isInAstralSet(code, astralIdentifierCodes)\n );\n}\n\n// Test whether a given string is a valid identifier name\n\nexport function isIdentifierName(name: string): boolean {\n let isFirst = true;\n for (const char of Array.from(name)) {\n const cp = char.codePointAt(0);\n if (isFirst) {\n if (!isIdentifierStart(cp)) {\n return false;\n }\n isFirst = false;\n } else if (!isIdentifierChar(cp)) {\n return false;\n }\n }\n return !isFirst;\n}\n","const reservedWords = {\n keyword: [\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"return\",\n \"switch\",\n \"throw\",\n \"try\",\n \"var\",\n \"const\",\n \"while\",\n \"with\",\n \"new\",\n \"this\",\n \"super\",\n \"class\",\n \"extends\",\n \"export\",\n \"import\",\n \"null\",\n \"true\",\n \"false\",\n \"in\",\n \"instanceof\",\n \"typeof\",\n \"void\",\n \"delete\",\n ],\n strict: [\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n ],\n strictBind: [\"eval\", \"arguments\"],\n};\nconst keywords = new Set(reservedWords.keyword);\nconst reservedWordsStrictSet = new Set(reservedWords.strict);\nconst reservedWordsStrictBindSet = new Set(reservedWords.strictBind);\n\n/**\n * Checks if word is a reserved word in non-strict mode\n */\nexport function isReservedWord(word: string, inModule: boolean): boolean {\n return (inModule && word === \"await\") || word === \"enum\";\n}\n\n/**\n * Checks if word is a reserved word in non-binding strict mode\n *\n * Includes non-strict reserved words\n */\nexport function isStrictReservedWord(word: string, inModule: boolean): boolean {\n return isReservedWord(word, inModule) || reservedWordsStrictSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode, but it is allowed as\n * a normal identifier.\n */\nexport function isStrictBindOnlyReservedWord(word: string): boolean {\n return reservedWordsStrictBindSet.has(word);\n}\n\n/**\n * Checks if word is a reserved word in binding strict mode\n *\n * Includes non-strict reserved words and non-binding strict reserved words\n */\nexport function isStrictBindReservedWord(\n word: string,\n inModule: boolean,\n): boolean {\n return (\n isStrictReservedWord(word, inModule) || isStrictBindOnlyReservedWord(word)\n );\n}\n\nexport function isKeyword(word: string): boolean {\n return keywords.has(word);\n}\n","/* eslint max-len: 0 */\n\n// @flow\n\nimport * as charCodes from \"charcodes\";\n\nexport {\n isIdentifierStart,\n isIdentifierChar,\n isReservedWord,\n isStrictBindOnlyReservedWord,\n isStrictBindReservedWord,\n isStrictReservedWord,\n isKeyword,\n} from \"@babel/helper-validator-identifier\";\n\nexport const keywordRelationalOperator = /^in(stanceof)?$/;\n\n// Test whether a current state character code and next character code is @\n\nexport function isIteratorStart(current: number, next: number): boolean {\n return current === charCodes.atSign && next === charCodes.atSign;\n}\n","// @flow\n\n// Each scope gets a bitset that may contain these flags\n// prettier-ignore\nexport const SCOPE_OTHER = 0b000000000,\n SCOPE_PROGRAM = 0b000000001,\n SCOPE_FUNCTION = 0b000000010,\n SCOPE_ARROW = 0b000000100,\n SCOPE_SIMPLE_CATCH = 0b000001000,\n SCOPE_SUPER = 0b000010000,\n SCOPE_DIRECT_SUPER = 0b000100000,\n SCOPE_CLASS = 0b001000000,\n SCOPE_STATIC_BLOCK = 0b010000000,\n SCOPE_TS_MODULE = 0b100000000,\n SCOPE_VAR = SCOPE_PROGRAM | SCOPE_FUNCTION | SCOPE_TS_MODULE;\n\nexport type ScopeFlags =\n | typeof SCOPE_OTHER\n | typeof SCOPE_PROGRAM\n | typeof SCOPE_FUNCTION\n | typeof SCOPE_VAR\n | typeof SCOPE_ARROW\n | typeof SCOPE_SIMPLE_CATCH\n | typeof SCOPE_SUPER\n | typeof SCOPE_DIRECT_SUPER\n | typeof SCOPE_CLASS\n | typeof SCOPE_STATIC_BLOCK;\n\n// These flags are meant to be _only_ used inside the Scope class (or subclasses).\n// prettier-ignore\nexport const BIND_KIND_VALUE = 0b000000_0000_01,\n BIND_KIND_TYPE = 0b000000_0000_10,\n // Used in checkLVal and declareName to determine the type of a binding\n BIND_SCOPE_VAR = 0b000000_0001_00, // Var-style binding\n BIND_SCOPE_LEXICAL = 0b000000_0010_00, // Let- or const-style binding\n BIND_SCOPE_FUNCTION = 0b000000_0100_00, // Function declaration\n BIND_SCOPE_OUTSIDE = 0b000000_1000_00, // Special case for function names as\n // bound inside the function\n // Misc flags\n BIND_FLAGS_NONE = 0b000001_0000_00,\n BIND_FLAGS_CLASS = 0b000010_0000_00,\n BIND_FLAGS_TS_ENUM = 0b000100_0000_00,\n BIND_FLAGS_TS_CONST_ENUM = 0b001000_0000_00,\n BIND_FLAGS_TS_EXPORT_ONLY = 0b010000_0000_00,\n BIND_FLAGS_FLOW_DECLARE_FN = 0b100000_0000_00;\n\n// These flags are meant to be _only_ used by Scope consumers\n// prettier-ignore\n/* = is value? | is type? | scope | misc flags */\nexport const BIND_CLASS = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_CLASS ,\n BIND_LEXICAL = BIND_KIND_VALUE | 0 | BIND_SCOPE_LEXICAL | 0 ,\n BIND_VAR = BIND_KIND_VALUE | 0 | BIND_SCOPE_VAR | 0 ,\n BIND_FUNCTION = BIND_KIND_VALUE | 0 | BIND_SCOPE_FUNCTION | 0 ,\n BIND_TS_INTERFACE = 0 | BIND_KIND_TYPE | 0 | BIND_FLAGS_CLASS ,\n BIND_TS_TYPE = 0 | BIND_KIND_TYPE | 0 | 0 ,\n BIND_TS_ENUM = BIND_KIND_VALUE | BIND_KIND_TYPE | BIND_SCOPE_LEXICAL | BIND_FLAGS_TS_ENUM,\n BIND_TS_AMBIENT = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,\n // These bindings don't introduce anything in the scope. They are used for assignments and\n // function expressions IDs.\n BIND_NONE = 0 | 0 | 0 | BIND_FLAGS_NONE ,\n BIND_OUTSIDE = BIND_KIND_VALUE | 0 | 0 | BIND_FLAGS_NONE ,\n\n BIND_TS_CONST_ENUM = BIND_TS_ENUM | BIND_FLAGS_TS_CONST_ENUM,\n BIND_TS_NAMESPACE = 0 | 0 | 0 | BIND_FLAGS_TS_EXPORT_ONLY,\n\n BIND_FLOW_DECLARE_FN = BIND_FLAGS_FLOW_DECLARE_FN;\n\nexport type BindingTypes =\n | typeof BIND_NONE\n | typeof BIND_OUTSIDE\n | typeof BIND_VAR\n | typeof BIND_LEXICAL\n | typeof BIND_CLASS\n | typeof BIND_FUNCTION\n | typeof BIND_TS_INTERFACE\n | typeof BIND_TS_TYPE\n | typeof BIND_TS_ENUM\n | typeof BIND_TS_AMBIENT\n | typeof BIND_TS_NAMESPACE;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_FLAG_STATIC = 0b1_00,\n CLASS_ELEMENT_KIND_GETTER = 0b0_10,\n CLASS_ELEMENT_KIND_SETTER = 0b0_01,\n CLASS_ELEMENT_KIND_ACCESSOR = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_KIND_SETTER;\n\n// prettier-ignore\nexport const CLASS_ELEMENT_STATIC_GETTER = CLASS_ELEMENT_KIND_GETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_STATIC_SETTER = CLASS_ELEMENT_KIND_SETTER | CLASS_ELEMENT_FLAG_STATIC,\n CLASS_ELEMENT_INSTANCE_GETTER = CLASS_ELEMENT_KIND_GETTER,\n CLASS_ELEMENT_INSTANCE_SETTER = CLASS_ELEMENT_KIND_SETTER,\n CLASS_ELEMENT_OTHER = 0;\n\nexport type ClassElementTypes =\n | typeof CLASS_ELEMENT_STATIC_GETTER\n | typeof CLASS_ELEMENT_STATIC_SETTER\n | typeof CLASS_ELEMENT_INSTANCE_GETTER\n | typeof CLASS_ELEMENT_INSTANCE_SETTER\n | typeof CLASS_ELEMENT_OTHER;\n","// @flow\nimport {\n SCOPE_ARROW,\n SCOPE_DIRECT_SUPER,\n SCOPE_FUNCTION,\n SCOPE_SIMPLE_CATCH,\n SCOPE_SUPER,\n SCOPE_PROGRAM,\n SCOPE_VAR,\n SCOPE_CLASS,\n SCOPE_STATIC_BLOCK,\n BIND_SCOPE_FUNCTION,\n BIND_SCOPE_VAR,\n BIND_SCOPE_LEXICAL,\n BIND_KIND_VALUE,\n type ScopeFlags,\n type BindingTypes,\n} from \"./scopeflags\";\nimport * as N from \"../types\";\nimport { Errors } from \"../parser/error\";\n\n// Start an AST node, attaching a start offset.\nexport class Scope {\n flags: ScopeFlags;\n // A list of var-declared names in the current lexical scope\n var: string[] = [];\n // A list of lexically-declared names in the current lexical scope\n lexical: string[] = [];\n // A list of lexically-declared FunctionDeclaration names in the current lexical scope\n functions: string[] = [];\n\n constructor(flags: ScopeFlags) {\n this.flags = flags;\n }\n}\n\ntype raiseFunction = (number, string, ...any) => void;\n\n// The functions in this module keep track of declared variables in the\n// current scope in order to detect duplicate variable names.\nexport default class ScopeHandler {\n scopeStack: Array = [];\n declare raise: raiseFunction;\n declare inModule: boolean;\n undefinedExports: Map = new Map();\n undefinedPrivateNames: Map = new Map();\n\n constructor(raise: raiseFunction, inModule: boolean) {\n this.raise = raise;\n this.inModule = inModule;\n }\n\n get inFunction() {\n return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0;\n }\n get allowSuper() {\n return (this.currentThisScope().flags & SCOPE_SUPER) > 0;\n }\n get allowDirectSuper() {\n return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0;\n }\n get inClass() {\n return (this.currentThisScope().flags & SCOPE_CLASS) > 0;\n }\n get inStaticBlock() {\n return (this.currentThisScope().flags & SCOPE_STATIC_BLOCK) > 0;\n }\n get inNonArrowFunction() {\n return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0;\n }\n get treatFunctionsAsVar() {\n return this.treatFunctionsAsVarInScope(this.currentScope());\n }\n\n createScope(flags: ScopeFlags): Scope {\n return new Scope(flags);\n }\n // This method will be overwritten by subclasses\n /*:: +createScope: (flags: ScopeFlags) => IScope; */\n\n enter(flags: ScopeFlags) {\n this.scopeStack.push(this.createScope(flags));\n }\n\n exit() {\n this.scopeStack.pop();\n }\n\n // The spec says:\n // > At the top level of a function, or script, function declarations are\n // > treated like var declarations rather than like lexical declarations.\n treatFunctionsAsVarInScope(scope: IScope): boolean {\n return !!(\n scope.flags & SCOPE_FUNCTION ||\n (!this.inModule && scope.flags & SCOPE_PROGRAM)\n );\n }\n\n declareName(name: string, bindingType: BindingTypes, pos: number) {\n let scope = this.currentScope();\n if (bindingType & BIND_SCOPE_LEXICAL || bindingType & BIND_SCOPE_FUNCTION) {\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n scope.functions.push(name);\n } else {\n scope.lexical.push(name);\n }\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n this.maybeExportDefined(scope, name);\n }\n } else if (bindingType & BIND_SCOPE_VAR) {\n for (let i = this.scopeStack.length - 1; i >= 0; --i) {\n scope = this.scopeStack[i];\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n scope.var.push(name);\n this.maybeExportDefined(scope, name);\n\n if (scope.flags & SCOPE_VAR) break;\n }\n }\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n maybeExportDefined(scope: IScope, name: string) {\n if (this.inModule && scope.flags & SCOPE_PROGRAM) {\n this.undefinedExports.delete(name);\n }\n }\n\n checkRedeclarationInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n pos: number,\n ) {\n if (this.isRedeclaredInScope(scope, name, bindingType)) {\n this.raise(pos, Errors.VarRedeclaration, name);\n }\n }\n\n isRedeclaredInScope(\n scope: IScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (!(bindingType & BIND_KIND_VALUE)) return false;\n\n if (bindingType & BIND_SCOPE_LEXICAL) {\n return (\n scope.lexical.indexOf(name) > -1 ||\n scope.functions.indexOf(name) > -1 ||\n scope.var.indexOf(name) > -1\n );\n }\n\n if (bindingType & BIND_SCOPE_FUNCTION) {\n return (\n scope.lexical.indexOf(name) > -1 ||\n (!this.treatFunctionsAsVarInScope(scope) &&\n scope.var.indexOf(name) > -1)\n );\n }\n\n return (\n (scope.lexical.indexOf(name) > -1 &&\n !(scope.flags & SCOPE_SIMPLE_CATCH && scope.lexical[0] === name)) ||\n (!this.treatFunctionsAsVarInScope(scope) &&\n scope.functions.indexOf(name) > -1)\n );\n }\n\n checkLocalExport(id: N.Identifier) {\n if (\n this.scopeStack[0].lexical.indexOf(id.name) === -1 &&\n this.scopeStack[0].var.indexOf(id.name) === -1 &&\n // In strict mode, scope.functions will always be empty.\n // Modules are strict by default, but the `scriptMode` option\n // can overwrite this behavior.\n this.scopeStack[0].functions.indexOf(id.name) === -1\n ) {\n this.undefinedExports.set(id.name, id.start);\n }\n }\n\n currentScope(): IScope {\n return this.scopeStack[this.scopeStack.length - 1];\n }\n\n // $FlowIgnore\n currentVarScope(): IScope {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const scope = this.scopeStack[i];\n if (scope.flags & SCOPE_VAR) {\n return scope;\n }\n }\n }\n\n // Could be useful for `arguments`, `this`, `new.target`, `super()`, `super.property`, and `super[property]`.\n // $FlowIgnore\n currentThisScope(): IScope {\n for (let i = this.scopeStack.length - 1; ; i--) {\n const scope = this.scopeStack[i];\n if (\n (scope.flags & SCOPE_VAR || scope.flags & SCOPE_CLASS) &&\n !(scope.flags & SCOPE_ARROW)\n ) {\n return scope;\n }\n }\n }\n}\n","// @flow\n\nimport ScopeHandler, { Scope } from \"../../util/scope\";\nimport {\n BIND_FLAGS_FLOW_DECLARE_FN,\n type ScopeFlags,\n type BindingTypes,\n} from \"../../util/scopeflags\";\nimport * as N from \"../../types\";\n\n// Reference implementation: https://github.com/facebook/flow/blob/23aeb2a2ef6eb4241ce178fde5d8f17c5f747fb5/src/typing/env.ml#L536-L584\nclass FlowScope extends Scope {\n // declare function foo(): type;\n declareFunctions: string[] = [];\n}\n\nexport default class FlowScopeHandler extends ScopeHandler {\n createScope(flags: ScopeFlags): FlowScope {\n return new FlowScope(flags);\n }\n\n declareName(name: string, bindingType: BindingTypes, pos: number) {\n const scope = this.currentScope();\n if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n this.maybeExportDefined(scope, name);\n scope.declareFunctions.push(name);\n return;\n }\n\n super.declareName(...arguments);\n }\n\n isRedeclaredInScope(\n scope: FlowScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (super.isRedeclaredInScope(...arguments)) return true;\n\n if (bindingType & BIND_FLAGS_FLOW_DECLARE_FN) {\n return (\n !scope.declareFunctions.includes(name) &&\n (scope.lexical.includes(name) || scope.functions.includes(name))\n );\n }\n\n return false;\n }\n\n checkLocalExport(id: N.Identifier) {\n if (this.scopeStack[0].declareFunctions.indexOf(id.name) === -1) {\n super.checkLocalExport(id);\n }\n }\n}\n","// @flow\n\n/*:: declare var invariant; */\n\n// Error messages are colocated with the plugin.\n/* eslint-disable @babel/development-internal/dry-error-messages */\n\nimport type Parser from \"../../parser\";\nimport { types as tt, type TokenType } from \"../../tokenizer/types\";\nimport * as N from \"../../types\";\nimport type { Pos, Position } from \"../../util/location\";\nimport type State from \"../../tokenizer/state\";\nimport { types as tc } from \"../../tokenizer/context\";\nimport * as charCodes from \"charcodes\";\nimport { isIteratorStart, isKeyword } from \"../../util/identifier\";\nimport FlowScopeHandler from \"./scope\";\nimport {\n type BindingTypes,\n BIND_LEXICAL,\n BIND_VAR,\n BIND_FUNCTION,\n BIND_FLOW_DECLARE_FN,\n SCOPE_ARROW,\n SCOPE_FUNCTION,\n SCOPE_OTHER,\n} from \"../../util/scopeflags\";\nimport type { ExpressionErrors } from \"../../parser/util\";\nimport { Errors } from \"../../parser/error\";\n\nconst reservedTypes = new Set([\n \"_\",\n \"any\",\n \"bool\",\n \"boolean\",\n \"empty\",\n \"extends\",\n \"false\",\n \"interface\",\n \"mixed\",\n \"null\",\n \"number\",\n \"static\",\n \"string\",\n \"true\",\n \"typeof\",\n \"void\",\n]);\n\n/* eslint sort-keys: \"error\" */\n// The Errors key follows https://github.com/facebook/flow/blob/master/src/parser/parse_error.ml unless it does not exist\nconst FlowErrors = Object.freeze({\n AmbiguousConditionalArrow:\n \"Ambiguous expression: wrap the arrow functions in parentheses to disambiguate.\",\n AmbiguousDeclareModuleKind:\n \"Found both `declare module.exports` and `declare export` in the same module. Modules can only have 1 since they are either an ES module or they are a CommonJS module\",\n AssignReservedType: \"Cannot overwrite reserved type %0\",\n DeclareClassElement:\n \"The `declare` modifier can only appear on class fields.\",\n DeclareClassFieldInitializer:\n \"Initializers are not allowed in fields with the `declare` modifier.\",\n DuplicateDeclareModuleExports: \"Duplicate `declare module.exports` statement\",\n EnumBooleanMemberNotInitialized:\n \"Boolean enum members need to be initialized. Use either `%0 = true,` or `%0 = false,` in enum `%1`.\",\n EnumDuplicateMemberName:\n \"Enum member names need to be unique, but the name `%0` has already been used before in enum `%1`.\",\n EnumInconsistentMemberValues:\n \"Enum `%0` has inconsistent member initializers. Either use no initializers, or consistently use literals (either booleans, numbers, or strings) for all member initializers.\",\n EnumInvalidExplicitType:\n \"Enum type `%1` is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.\",\n EnumInvalidExplicitTypeUnknownSupplied:\n \"Supplied enum type is not valid. Use one of `boolean`, `number`, `string`, or `symbol` in enum `%0`.\",\n EnumInvalidMemberInitializerPrimaryType:\n \"Enum `%0` has type `%2`, so the initializer of `%1` needs to be a %2 literal.\",\n EnumInvalidMemberInitializerSymbolType:\n \"Symbol enum members cannot be initialized. Use `%1,` in enum `%0`.\",\n EnumInvalidMemberInitializerUnknownType:\n \"The enum member initializer for `%1` needs to be a literal (either a boolean, number, or string) in enum `%0`.\",\n EnumInvalidMemberName:\n \"Enum member names cannot start with lowercase 'a' through 'z'. Instead of using `%0`, consider using `%1`, in enum `%2`.\",\n EnumNumberMemberNotInitialized:\n \"Number enum members need to be initialized, e.g. `%1 = 1` in enum `%0`.\",\n EnumStringMemberInconsistentlyInitailized:\n \"String enum members need to consistently either all use initializers, or use no initializers, in enum `%0`.\",\n GetterMayNotHaveThisParam: \"A getter cannot have a `this` parameter.\",\n ImportTypeShorthandOnlyInPureImport:\n \"The `type` and `typeof` keywords on named imports can only be used on regular `import` statements. It cannot be used with `import type` or `import typeof` statements\",\n InexactInsideExact:\n \"Explicit inexact syntax cannot appear inside an explicit exact object type\",\n InexactInsideNonObject:\n \"Explicit inexact syntax cannot appear in class or interface definitions\",\n InexactVariance: \"Explicit inexact syntax cannot have variance\",\n InvalidNonTypeImportInDeclareModule:\n \"Imports within a `declare module` body must always be `import type` or `import typeof`\",\n MissingTypeParamDefault:\n \"Type parameter declaration needs a default, since a preceding type parameter declaration has a default.\",\n NestedDeclareModule:\n \"`declare module` cannot be used inside another `declare module`\",\n NestedFlowComment: \"Cannot have a flow comment inside another flow comment\",\n OptionalBindingPattern:\n \"A binding pattern parameter cannot be optional in an implementation signature.\",\n SetterMayNotHaveThisParam: \"A setter cannot have a `this` parameter.\",\n SpreadVariance: \"Spread properties cannot have variance\",\n ThisParamAnnotationRequired:\n \"A type annotation is required for the `this` parameter.\",\n ThisParamBannedInConstructor:\n \"Constructors cannot have a `this` parameter; constructors don't bind `this` like other functions.\",\n ThisParamMayNotBeOptional: \"The `this` parameter cannot be optional.\",\n ThisParamMustBeFirst:\n \"The `this` parameter must be the first function parameter.\",\n ThisParamNoDefault: \"The `this` parameter may not have a default value.\",\n TypeBeforeInitializer:\n \"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`\",\n TypeCastInPattern:\n \"The type cast expression is expected to be wrapped with parenthesis\",\n UnexpectedExplicitInexactInObject:\n \"Explicit inexact syntax must appear at the end of an inexact object\",\n UnexpectedReservedType: \"Unexpected reserved type %0\",\n UnexpectedReservedUnderscore:\n \"`_` is only allowed as a type argument to call or new\",\n UnexpectedSpaceBetweenModuloChecks:\n \"Spaces between `%` and `checks` are not allowed here.\",\n UnexpectedSpreadType:\n \"Spread operator cannot appear in class or interface definitions\",\n UnexpectedSubtractionOperand:\n 'Unexpected token, expected \"number\" or \"bigint\"',\n UnexpectedTokenAfterTypeParameter:\n \"Expected an arrow function after this type parameter declaration\",\n UnexpectedTypeParameterBeforeAsyncArrowFunction:\n \"Type parameters must come after the async keyword, e.g. instead of ` async () => {}`, use `async () => {}`\",\n UnsupportedDeclareExportKind:\n \"`declare export %0` is not supported. Use `%1` instead\",\n UnsupportedStatementInDeclareModule:\n \"Only declares and type imports are allowed inside declare module\",\n UnterminatedFlowComment: \"Unterminated flow-comment\",\n});\n/* eslint-disable sort-keys */\n\nfunction isEsModuleType(bodyElement: N.Node): boolean {\n return (\n bodyElement.type === \"DeclareExportAllDeclaration\" ||\n (bodyElement.type === \"DeclareExportDeclaration\" &&\n (!bodyElement.declaration ||\n (bodyElement.declaration.type !== \"TypeAlias\" &&\n bodyElement.declaration.type !== \"InterfaceDeclaration\")))\n );\n}\n\nfunction hasTypeImportKind(node: N.Node): boolean {\n return node.importKind === \"type\" || node.importKind === \"typeof\";\n}\n\nfunction isMaybeDefaultImport(state: State): boolean {\n return (\n (state.type === tt.name || !!state.type.keyword) && state.value !== \"from\"\n );\n}\n\nconst exportSuggestions = {\n const: \"declare export var\",\n let: \"declare export var\",\n type: \"export type\",\n interface: \"export interface\",\n};\n\n// Like Array#filter, but returns a tuple [ acceptedElements, discardedElements ]\nfunction partition(\n list: T[],\n test: (T, number, T[]) => ?boolean,\n): [T[], T[]] {\n const list1 = [];\n const list2 = [];\n for (let i = 0; i < list.length; i++) {\n (test(list[i], i, list) ? list1 : list2).push(list[i]);\n }\n return [list1, list2];\n}\n\nconst FLOW_PRAGMA_REGEX = /\\*?\\s*@((?:no)?flow)\\b/;\n\n// Flow enums types\ntype EnumExplicitType = null | \"boolean\" | \"number\" | \"string\" | \"symbol\";\ntype EnumContext = {|\n enumName: string,\n explicitType: EnumExplicitType,\n memberName: string,\n|};\ntype EnumMemberInit =\n | {| type: \"number\", pos: number, value: N.Node |}\n | {| type: \"string\", pos: number, value: N.Node |}\n | {| type: \"boolean\", pos: number, value: N.Node |}\n | {| type: \"invalid\", pos: number |}\n | {| type: \"none\", pos: number |};\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n // The value of the @flow/@noflow pragma. Initially undefined, transitions\n // to \"@flow\" or \"@noflow\" if we see a pragma. Transitions to null if we are\n // past the initial comment.\n flowPragma: void | null | \"flow\" | \"noflow\" = undefined;\n\n getScopeHandler(): Class {\n return FlowScopeHandler;\n }\n\n shouldParseTypes(): boolean {\n return this.getPluginOption(\"flow\", \"all\") || this.flowPragma === \"flow\";\n }\n\n shouldParseEnums(): boolean {\n return !!this.getPluginOption(\"flow\", \"enums\");\n }\n\n finishToken(type: TokenType, val: any): void {\n if (\n type !== tt.string &&\n type !== tt.semi &&\n type !== tt.interpreterDirective\n ) {\n if (this.flowPragma === undefined) {\n this.flowPragma = null;\n }\n }\n return super.finishToken(type, val);\n }\n\n addComment(comment: N.Comment): void {\n if (this.flowPragma === undefined) {\n // Try to parse a flow pragma.\n const matches = FLOW_PRAGMA_REGEX.exec(comment.value);\n if (!matches) {\n // do nothing\n } else if (matches[1] === \"flow\") {\n this.flowPragma = \"flow\";\n } else if (matches[1] === \"noflow\") {\n this.flowPragma = \"noflow\";\n } else {\n throw new Error(\"Unexpected flow pragma\");\n }\n }\n return super.addComment(comment);\n }\n\n flowParseTypeInitialiser(tok?: TokenType): N.FlowType {\n const oldInType = this.state.inType;\n this.state.inType = true;\n this.expect(tok || tt.colon);\n\n const type = this.flowParseType();\n this.state.inType = oldInType;\n return type;\n }\n\n flowParsePredicate(): N.FlowType {\n const node = this.startNode();\n const moduloLoc = this.state.startLoc;\n const moduloPos = this.state.start;\n this.expect(tt.modulo);\n const checksLoc = this.state.startLoc;\n this.expectContextual(\"checks\");\n // Force '%' and 'checks' to be adjacent\n if (\n moduloLoc.line !== checksLoc.line ||\n moduloLoc.column !== checksLoc.column - 1\n ) {\n this.raise(moduloPos, FlowErrors.UnexpectedSpaceBetweenModuloChecks);\n }\n if (this.eat(tt.parenL)) {\n node.value = this.parseExpression();\n this.expect(tt.parenR);\n return this.finishNode(node, \"DeclaredPredicate\");\n } else {\n return this.finishNode(node, \"InferredPredicate\");\n }\n }\n\n flowParseTypeAndPredicateInitialiser(): [?N.FlowType, ?N.FlowPredicate] {\n const oldInType = this.state.inType;\n this.state.inType = true;\n this.expect(tt.colon);\n let type = null;\n let predicate = null;\n if (this.match(tt.modulo)) {\n this.state.inType = oldInType;\n predicate = this.flowParsePredicate();\n } else {\n type = this.flowParseType();\n this.state.inType = oldInType;\n if (this.match(tt.modulo)) {\n predicate = this.flowParsePredicate();\n }\n }\n return [type, predicate];\n }\n\n flowParseDeclareClass(node: N.FlowDeclareClass): N.FlowDeclareClass {\n this.next();\n this.flowParseInterfaceish(node, /*isClass*/ true);\n return this.finishNode(node, \"DeclareClass\");\n }\n\n flowParseDeclareFunction(\n node: N.FlowDeclareFunction,\n ): N.FlowDeclareFunction {\n this.next();\n\n const id = (node.id = this.parseIdentifier());\n\n const typeNode = this.startNode();\n const typeContainer = this.startNode();\n\n if (this.isRelational(\"<\")) {\n typeNode.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n typeNode.typeParameters = null;\n }\n\n this.expect(tt.parenL);\n const tmp = this.flowParseFunctionTypeParams();\n typeNode.params = tmp.params;\n typeNode.rest = tmp.rest;\n typeNode.this = tmp._this;\n this.expect(tt.parenR);\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.returnType,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n typeContainer.typeAnnotation = this.finishNode(\n typeNode,\n \"FunctionTypeAnnotation\",\n );\n\n id.typeAnnotation = this.finishNode(typeContainer, \"TypeAnnotation\");\n\n this.resetEndLocation(id);\n this.semicolon();\n\n this.scope.declareName(node.id.name, BIND_FLOW_DECLARE_FN, node.id.start);\n\n return this.finishNode(node, \"DeclareFunction\");\n }\n\n flowParseDeclare(\n node: N.FlowDeclare,\n insideModule?: boolean,\n ): N.FlowDeclare {\n if (this.match(tt._class)) {\n return this.flowParseDeclareClass(node);\n } else if (this.match(tt._function)) {\n return this.flowParseDeclareFunction(node);\n } else if (this.match(tt._var)) {\n return this.flowParseDeclareVariable(node);\n } else if (this.eatContextual(\"module\")) {\n if (this.match(tt.dot)) {\n return this.flowParseDeclareModuleExports(node);\n } else {\n if (insideModule) {\n this.raise(this.state.lastTokStart, FlowErrors.NestedDeclareModule);\n }\n return this.flowParseDeclareModule(node);\n }\n } else if (this.isContextual(\"type\")) {\n return this.flowParseDeclareTypeAlias(node);\n } else if (this.isContextual(\"opaque\")) {\n return this.flowParseDeclareOpaqueType(node);\n } else if (this.isContextual(\"interface\")) {\n return this.flowParseDeclareInterface(node);\n } else if (this.match(tt._export)) {\n return this.flowParseDeclareExportDeclaration(node, insideModule);\n } else {\n throw this.unexpected();\n }\n }\n\n flowParseDeclareVariable(\n node: N.FlowDeclareVariable,\n ): N.FlowDeclareVariable {\n this.next();\n node.id = this.flowParseTypeAnnotatableIdentifier(\n /*allowPrimitiveOverride*/ true,\n );\n this.scope.declareName(node.id.name, BIND_VAR, node.id.start);\n this.semicolon();\n return this.finishNode(node, \"DeclareVariable\");\n }\n\n flowParseDeclareModule(node: N.FlowDeclareModule): N.FlowDeclareModule {\n this.scope.enter(SCOPE_OTHER);\n\n if (this.match(tt.string)) {\n node.id = this.parseExprAtom();\n } else {\n node.id = this.parseIdentifier();\n }\n\n const bodyNode = (node.body = this.startNode());\n const body = (bodyNode.body = []);\n this.expect(tt.braceL);\n while (!this.match(tt.braceR)) {\n let bodyNode = this.startNode();\n\n if (this.match(tt._import)) {\n this.next();\n if (!this.isContextual(\"type\") && !this.match(tt._typeof)) {\n this.raise(\n this.state.lastTokStart,\n FlowErrors.InvalidNonTypeImportInDeclareModule,\n );\n }\n this.parseImport(bodyNode);\n } else {\n this.expectContextual(\n \"declare\",\n FlowErrors.UnsupportedStatementInDeclareModule,\n );\n\n bodyNode = this.flowParseDeclare(bodyNode, true);\n }\n\n body.push(bodyNode);\n }\n\n this.scope.exit();\n\n this.expect(tt.braceR);\n\n this.finishNode(bodyNode, \"BlockStatement\");\n\n let kind = null;\n let hasModuleExport = false;\n body.forEach(bodyElement => {\n if (isEsModuleType(bodyElement)) {\n if (kind === \"CommonJS\") {\n this.raise(\n bodyElement.start,\n FlowErrors.AmbiguousDeclareModuleKind,\n );\n }\n kind = \"ES\";\n } else if (bodyElement.type === \"DeclareModuleExports\") {\n if (hasModuleExport) {\n this.raise(\n bodyElement.start,\n FlowErrors.DuplicateDeclareModuleExports,\n );\n }\n if (kind === \"ES\") {\n this.raise(\n bodyElement.start,\n FlowErrors.AmbiguousDeclareModuleKind,\n );\n }\n kind = \"CommonJS\";\n hasModuleExport = true;\n }\n });\n\n node.kind = kind || \"CommonJS\";\n return this.finishNode(node, \"DeclareModule\");\n }\n\n flowParseDeclareExportDeclaration(\n node: N.FlowDeclareExportDeclaration,\n insideModule: ?boolean,\n ): N.FlowDeclareExportDeclaration {\n this.expect(tt._export);\n\n if (this.eat(tt._default)) {\n if (this.match(tt._function) || this.match(tt._class)) {\n // declare export default class ...\n // declare export default function ...\n node.declaration = this.flowParseDeclare(this.startNode());\n } else {\n // declare export default [type];\n node.declaration = this.flowParseType();\n this.semicolon();\n }\n node.default = true;\n\n return this.finishNode(node, \"DeclareExportDeclaration\");\n } else {\n if (\n this.match(tt._const) ||\n this.isLet() ||\n ((this.isContextual(\"type\") || this.isContextual(\"interface\")) &&\n !insideModule)\n ) {\n const label = this.state.value;\n const suggestion = exportSuggestions[label];\n\n throw this.raise(\n this.state.start,\n FlowErrors.UnsupportedDeclareExportKind,\n label,\n suggestion,\n );\n }\n\n if (\n this.match(tt._var) || // declare export var ...\n this.match(tt._function) || // declare export function ...\n this.match(tt._class) || // declare export class ...\n this.isContextual(\"opaque\") // declare export opaque ..\n ) {\n node.declaration = this.flowParseDeclare(this.startNode());\n node.default = false;\n\n return this.finishNode(node, \"DeclareExportDeclaration\");\n } else if (\n this.match(tt.star) || // declare export * from ''\n this.match(tt.braceL) || // declare export {} ...\n this.isContextual(\"interface\") || // declare export interface ...\n this.isContextual(\"type\") || // declare export type ...\n this.isContextual(\"opaque\") // declare export opaque type ...\n ) {\n node = this.parseExport(node);\n if (node.type === \"ExportNamedDeclaration\") {\n // flow does not support the ExportNamedDeclaration\n // $FlowIgnore\n node.type = \"ExportDeclaration\";\n // $FlowFixMe\n node.default = false;\n delete node.exportKind;\n }\n\n // $FlowIgnore\n node.type = \"Declare\" + node.type;\n\n return node;\n }\n }\n\n throw this.unexpected();\n }\n\n flowParseDeclareModuleExports(\n node: N.FlowDeclareModuleExports,\n ): N.FlowDeclareModuleExports {\n this.next();\n this.expectContextual(\"exports\");\n node.typeAnnotation = this.flowParseTypeAnnotation();\n this.semicolon();\n\n return this.finishNode(node, \"DeclareModuleExports\");\n }\n\n flowParseDeclareTypeAlias(\n node: N.FlowDeclareTypeAlias,\n ): N.FlowDeclareTypeAlias {\n this.next();\n this.flowParseTypeAlias(node);\n // Don't do finishNode as we don't want to process comments twice\n node.type = \"DeclareTypeAlias\";\n return node;\n }\n\n flowParseDeclareOpaqueType(\n node: N.FlowDeclareOpaqueType,\n ): N.FlowDeclareOpaqueType {\n this.next();\n this.flowParseOpaqueType(node, true);\n // Don't do finishNode as we don't want to process comments twice\n node.type = \"DeclareOpaqueType\";\n return node;\n }\n\n flowParseDeclareInterface(\n node: N.FlowDeclareInterface,\n ): N.FlowDeclareInterface {\n this.next();\n this.flowParseInterfaceish(node);\n return this.finishNode(node, \"DeclareInterface\");\n }\n\n // Interfaces\n\n flowParseInterfaceish(\n node: N.FlowDeclare,\n isClass?: boolean = false,\n ): void {\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ !isClass,\n /* declaration */ true,\n );\n\n this.scope.declareName(\n node.id.name,\n isClass ? BIND_FUNCTION : BIND_LEXICAL,\n node.id.start,\n );\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n node.extends = [];\n node.implements = [];\n node.mixins = [];\n\n if (this.eat(tt._extends)) {\n do {\n node.extends.push(this.flowParseInterfaceExtends());\n } while (!isClass && this.eat(tt.comma));\n }\n\n if (this.isContextual(\"mixins\")) {\n this.next();\n do {\n node.mixins.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n if (this.isContextual(\"implements\")) {\n this.next();\n do {\n node.implements.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n node.body = this.flowParseObjectType({\n allowStatic: isClass,\n allowExact: false,\n allowSpread: false,\n allowProto: isClass,\n allowInexact: false,\n });\n }\n\n flowParseInterfaceExtends(): N.FlowInterfaceExtends {\n const node = this.startNode();\n\n node.id = this.flowParseQualifiedTypeIdentifier();\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n } else {\n node.typeParameters = null;\n }\n\n return this.finishNode(node, \"InterfaceExtends\");\n }\n\n flowParseInterface(node: N.FlowInterface): N.FlowInterface {\n this.flowParseInterfaceish(node);\n return this.finishNode(node, \"InterfaceDeclaration\");\n }\n\n checkNotUnderscore(word: string) {\n if (word === \"_\") {\n this.raise(this.state.start, FlowErrors.UnexpectedReservedUnderscore);\n }\n }\n\n checkReservedType(word: string, startLoc: number, declaration?: boolean) {\n if (!reservedTypes.has(word)) return;\n\n this.raise(\n startLoc,\n declaration\n ? FlowErrors.AssignReservedType\n : FlowErrors.UnexpectedReservedType,\n word,\n );\n }\n\n flowParseRestrictedIdentifier(\n liberal?: boolean,\n declaration?: boolean,\n ): N.Identifier {\n this.checkReservedType(this.state.value, this.state.start, declaration);\n return this.parseIdentifier(liberal);\n }\n\n // Type aliases\n\n flowParseTypeAlias(node: N.FlowTypeAlias): N.FlowTypeAlias {\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ false,\n /* declaration */ true,\n );\n this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n node.right = this.flowParseTypeInitialiser(tt.eq);\n this.semicolon();\n\n return this.finishNode(node, \"TypeAlias\");\n }\n\n flowParseOpaqueType(\n node: N.FlowOpaqueType,\n declare: boolean,\n ): N.FlowOpaqueType {\n this.expectContextual(\"type\");\n node.id = this.flowParseRestrictedIdentifier(\n /* liberal */ true,\n /* declaration */ true,\n );\n this.scope.declareName(node.id.name, BIND_LEXICAL, node.id.start);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n } else {\n node.typeParameters = null;\n }\n\n // Parse the supertype\n node.supertype = null;\n if (this.match(tt.colon)) {\n node.supertype = this.flowParseTypeInitialiser(tt.colon);\n }\n\n node.impltype = null;\n if (!declare) {\n node.impltype = this.flowParseTypeInitialiser(tt.eq);\n }\n this.semicolon();\n\n return this.finishNode(node, \"OpaqueType\");\n }\n\n // Type annotations\n\n flowParseTypeParameter(requireDefault?: boolean = false): N.TypeParameter {\n const nodeStart = this.state.start;\n\n const node = this.startNode();\n\n const variance = this.flowParseVariance();\n\n const ident = this.flowParseTypeAnnotatableIdentifier();\n node.name = ident.name;\n node.variance = variance;\n node.bound = ident.typeAnnotation;\n\n if (this.match(tt.eq)) {\n this.eat(tt.eq);\n node.default = this.flowParseType();\n } else {\n if (requireDefault) {\n this.raise(nodeStart, FlowErrors.MissingTypeParamDefault);\n }\n }\n\n return this.finishNode(node, \"TypeParameter\");\n }\n\n flowParseTypeParameterDeclaration(): N.TypeParameterDeclaration {\n const oldInType = this.state.inType;\n const node = this.startNode();\n node.params = [];\n\n this.state.inType = true;\n\n // istanbul ignore else: this condition is already checked at all call sites\n if (this.isRelational(\"<\") || this.match(tt.jsxTagStart)) {\n this.next();\n } else {\n this.unexpected();\n }\n\n let defaultRequired = false;\n\n do {\n const typeParameter = this.flowParseTypeParameter(defaultRequired);\n\n node.params.push(typeParameter);\n\n if (typeParameter.default) {\n defaultRequired = true;\n }\n\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n } while (!this.isRelational(\">\"));\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterDeclaration\");\n }\n\n flowParseTypeParameterInstantiation(): N.TypeParameterInstantiation {\n const node = this.startNode();\n const oldInType = this.state.inType;\n node.params = [];\n\n this.state.inType = true;\n\n this.expectRelational(\"<\");\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = false;\n while (!this.isRelational(\">\")) {\n node.params.push(this.flowParseType());\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n }\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterInstantiation\");\n }\n\n flowParseTypeParameterInstantiationCallOrNew(): N.TypeParameterInstantiation {\n const node = this.startNode();\n const oldInType = this.state.inType;\n node.params = [];\n\n this.state.inType = true;\n\n this.expectRelational(\"<\");\n while (!this.isRelational(\">\")) {\n node.params.push(this.flowParseTypeOrImplicitInstantiation());\n if (!this.isRelational(\">\")) {\n this.expect(tt.comma);\n }\n }\n this.expectRelational(\">\");\n\n this.state.inType = oldInType;\n\n return this.finishNode(node, \"TypeParameterInstantiation\");\n }\n\n flowParseInterfaceType(): N.FlowInterfaceType {\n const node = this.startNode();\n this.expectContextual(\"interface\");\n\n node.extends = [];\n if (this.eat(tt._extends)) {\n do {\n node.extends.push(this.flowParseInterfaceExtends());\n } while (this.eat(tt.comma));\n }\n\n node.body = this.flowParseObjectType({\n allowStatic: false,\n allowExact: false,\n allowSpread: false,\n allowProto: false,\n allowInexact: false,\n });\n\n return this.finishNode(node, \"InterfaceTypeAnnotation\");\n }\n\n flowParseObjectPropertyKey(): N.Expression {\n return this.match(tt.num) || this.match(tt.string)\n ? this.parseExprAtom()\n : this.parseIdentifier(true);\n }\n\n flowParseObjectTypeIndexer(\n node: N.FlowObjectTypeIndexer,\n isStatic: boolean,\n variance: ?N.FlowVariance,\n ): N.FlowObjectTypeIndexer {\n node.static = isStatic;\n\n // Note: bracketL has already been consumed\n if (this.lookahead().type === tt.colon) {\n node.id = this.flowParseObjectPropertyKey();\n node.key = this.flowParseTypeInitialiser();\n } else {\n node.id = null;\n node.key = this.flowParseType();\n }\n this.expect(tt.bracketR);\n node.value = this.flowParseTypeInitialiser();\n node.variance = variance;\n\n return this.finishNode(node, \"ObjectTypeIndexer\");\n }\n\n flowParseObjectTypeInternalSlot(\n node: N.FlowObjectTypeInternalSlot,\n isStatic: boolean,\n ): N.FlowObjectTypeInternalSlot {\n node.static = isStatic;\n // Note: both bracketL have already been consumed\n node.id = this.flowParseObjectPropertyKey();\n this.expect(tt.bracketR);\n this.expect(tt.bracketR);\n if (this.isRelational(\"<\") || this.match(tt.parenL)) {\n node.method = true;\n node.optional = false;\n node.value = this.flowParseObjectTypeMethodish(\n this.startNodeAt(node.start, node.loc.start),\n );\n } else {\n node.method = false;\n if (this.eat(tt.question)) {\n node.optional = true;\n }\n node.value = this.flowParseTypeInitialiser();\n }\n return this.finishNode(node, \"ObjectTypeInternalSlot\");\n }\n\n flowParseObjectTypeMethodish(\n node: N.FlowFunctionTypeAnnotation,\n ): N.FlowFunctionTypeAnnotation {\n node.params = [];\n node.rest = null;\n node.typeParameters = null;\n node.this = null;\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n this.expect(tt.parenL);\n if (this.match(tt._this)) {\n node.this = this.flowParseFunctionTypeParam(/* first */ true);\n // match Flow parser behavior\n node.this.name = null;\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n node.params.push(this.flowParseFunctionTypeParam(false));\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n\n if (this.eat(tt.ellipsis)) {\n node.rest = this.flowParseFunctionTypeParam(false);\n }\n this.expect(tt.parenR);\n node.returnType = this.flowParseTypeInitialiser();\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n\n flowParseObjectTypeCallProperty(\n node: N.FlowObjectTypeCallProperty,\n isStatic: boolean,\n ): N.FlowObjectTypeCallProperty {\n const valueNode = this.startNode();\n node.static = isStatic;\n node.value = this.flowParseObjectTypeMethodish(valueNode);\n return this.finishNode(node, \"ObjectTypeCallProperty\");\n }\n\n flowParseObjectType({\n allowStatic,\n allowExact,\n allowSpread,\n allowProto,\n allowInexact,\n }: {\n allowStatic: boolean,\n allowExact: boolean,\n allowSpread: boolean,\n allowProto: boolean,\n allowInexact: boolean,\n }): N.FlowObjectTypeAnnotation {\n const oldInType = this.state.inType;\n this.state.inType = true;\n\n const nodeStart = this.startNode();\n\n nodeStart.callProperties = [];\n nodeStart.properties = [];\n nodeStart.indexers = [];\n nodeStart.internalSlots = [];\n\n let endDelim;\n let exact;\n let inexact = false;\n if (allowExact && this.match(tt.braceBarL)) {\n this.expect(tt.braceBarL);\n endDelim = tt.braceBarR;\n exact = true;\n } else {\n this.expect(tt.braceL);\n endDelim = tt.braceR;\n exact = false;\n }\n\n nodeStart.exact = exact;\n\n while (!this.match(endDelim)) {\n let isStatic = false;\n let protoStart: ?number = null;\n let inexactStart: ?number = null;\n const node = this.startNode();\n\n if (allowProto && this.isContextual(\"proto\")) {\n const lookahead = this.lookahead();\n\n if (lookahead.type !== tt.colon && lookahead.type !== tt.question) {\n this.next();\n protoStart = this.state.start;\n allowStatic = false;\n }\n }\n\n if (allowStatic && this.isContextual(\"static\")) {\n const lookahead = this.lookahead();\n\n // static is a valid identifier name\n if (lookahead.type !== tt.colon && lookahead.type !== tt.question) {\n this.next();\n isStatic = true;\n }\n }\n\n const variance = this.flowParseVariance();\n\n if (this.eat(tt.bracketL)) {\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (this.eat(tt.bracketL)) {\n if (variance) {\n this.unexpected(variance.start);\n }\n nodeStart.internalSlots.push(\n this.flowParseObjectTypeInternalSlot(node, isStatic),\n );\n } else {\n nodeStart.indexers.push(\n this.flowParseObjectTypeIndexer(node, isStatic, variance),\n );\n }\n } else if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.unexpected(variance.start);\n }\n nodeStart.callProperties.push(\n this.flowParseObjectTypeCallProperty(node, isStatic),\n );\n } else {\n let kind = \"init\";\n\n if (this.isContextual(\"get\") || this.isContextual(\"set\")) {\n const lookahead = this.lookahead();\n if (\n lookahead.type === tt.name ||\n lookahead.type === tt.string ||\n lookahead.type === tt.num\n ) {\n kind = this.state.value;\n this.next();\n }\n }\n\n const propOrInexact = this.flowParseObjectTypeProperty(\n node,\n isStatic,\n protoStart,\n variance,\n kind,\n allowSpread,\n allowInexact ?? !exact,\n );\n\n if (propOrInexact === null) {\n inexact = true;\n inexactStart = this.state.lastTokStart;\n } else {\n nodeStart.properties.push(propOrInexact);\n }\n }\n\n this.flowObjectTypeSemicolon();\n\n if (\n inexactStart &&\n !this.match(tt.braceR) &&\n !this.match(tt.braceBarR)\n ) {\n this.raise(\n inexactStart,\n FlowErrors.UnexpectedExplicitInexactInObject,\n );\n }\n }\n\n this.expect(endDelim);\n\n /* The inexact flag should only be added on ObjectTypeAnnotations that\n * are not the body of an interface, declare interface, or declare class.\n * Since spreads are only allowed in object types, checking that is\n * sufficient here.\n */\n if (allowSpread) {\n nodeStart.inexact = inexact;\n }\n\n const out = this.finishNode(nodeStart, \"ObjectTypeAnnotation\");\n\n this.state.inType = oldInType;\n\n return out;\n }\n\n flowParseObjectTypeProperty(\n node: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty,\n isStatic: boolean,\n protoStart: ?number,\n variance: ?N.FlowVariance,\n kind: string,\n allowSpread: boolean,\n allowInexact: boolean,\n ): (N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty) | null {\n if (this.eat(tt.ellipsis)) {\n const isInexactToken =\n this.match(tt.comma) ||\n this.match(tt.semi) ||\n this.match(tt.braceR) ||\n this.match(tt.braceBarR);\n\n if (isInexactToken) {\n if (!allowSpread) {\n this.raise(\n this.state.lastTokStart,\n FlowErrors.InexactInsideNonObject,\n );\n } else if (!allowInexact) {\n this.raise(this.state.lastTokStart, FlowErrors.InexactInsideExact);\n }\n if (variance) {\n this.raise(variance.start, FlowErrors.InexactVariance);\n }\n\n return null;\n }\n\n if (!allowSpread) {\n this.raise(this.state.lastTokStart, FlowErrors.UnexpectedSpreadType);\n }\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.raise(variance.start, FlowErrors.SpreadVariance);\n }\n\n node.argument = this.flowParseType();\n return this.finishNode(node, \"ObjectTypeSpreadProperty\");\n } else {\n node.key = this.flowParseObjectPropertyKey();\n node.static = isStatic;\n node.proto = protoStart != null;\n node.kind = kind;\n\n let optional = false;\n if (this.isRelational(\"<\") || this.match(tt.parenL)) {\n // This is a method property\n node.method = true;\n\n if (protoStart != null) {\n this.unexpected(protoStart);\n }\n if (variance) {\n this.unexpected(variance.start);\n }\n\n node.value = this.flowParseObjectTypeMethodish(\n this.startNodeAt(node.start, node.loc.start),\n );\n if (kind === \"get\" || kind === \"set\") {\n this.flowCheckGetterSetterParams(node);\n }\n /** Declared classes/interfaces do not allow spread */\n if (\n !allowSpread &&\n node.key.name === \"constructor\" &&\n node.value.this\n ) {\n this.raise(\n node.value.this.start,\n FlowErrors.ThisParamBannedInConstructor,\n );\n }\n } else {\n if (kind !== \"init\") this.unexpected();\n\n node.method = false;\n\n if (this.eat(tt.question)) {\n optional = true;\n }\n node.value = this.flowParseTypeInitialiser();\n node.variance = variance;\n }\n\n node.optional = optional;\n\n return this.finishNode(node, \"ObjectTypeProperty\");\n }\n }\n\n // This is similar to checkGetterSetterParams, but as\n // @babel/parser uses non estree properties we cannot reuse it here\n flowCheckGetterSetterParams(\n property: N.FlowObjectTypeProperty | N.FlowObjectTypeSpreadProperty,\n ): void {\n const paramCount = property.kind === \"get\" ? 0 : 1;\n const start = property.start;\n const length =\n property.value.params.length + (property.value.rest ? 1 : 0);\n\n if (property.value.this) {\n this.raise(\n property.value.this.start,\n property.kind === \"get\"\n ? FlowErrors.GetterMayNotHaveThisParam\n : FlowErrors.SetterMayNotHaveThisParam,\n );\n }\n\n if (length !== paramCount) {\n if (property.kind === \"get\") {\n this.raise(start, Errors.BadGetterArity);\n } else {\n this.raise(start, Errors.BadSetterArity);\n }\n }\n\n if (property.kind === \"set\" && property.value.rest) {\n this.raise(start, Errors.BadSetterRestParameter);\n }\n }\n\n flowObjectTypeSemicolon(): void {\n if (\n !this.eat(tt.semi) &&\n !this.eat(tt.comma) &&\n !this.match(tt.braceR) &&\n !this.match(tt.braceBarR)\n ) {\n this.unexpected();\n }\n }\n\n flowParseQualifiedTypeIdentifier(\n startPos?: number,\n startLoc?: Position,\n id?: N.Identifier,\n ): N.FlowQualifiedTypeIdentifier {\n startPos = startPos || this.state.start;\n startLoc = startLoc || this.state.startLoc;\n let node = id || this.flowParseRestrictedIdentifier(true);\n\n while (this.eat(tt.dot)) {\n const node2 = this.startNodeAt(startPos, startLoc);\n node2.qualification = node;\n node2.id = this.flowParseRestrictedIdentifier(true);\n node = this.finishNode(node2, \"QualifiedTypeIdentifier\");\n }\n\n return node;\n }\n\n flowParseGenericType(\n startPos: number,\n startLoc: Position,\n id: N.Identifier,\n ): N.FlowGenericTypeAnnotation {\n const node = this.startNodeAt(startPos, startLoc);\n\n node.typeParameters = null;\n node.id = this.flowParseQualifiedTypeIdentifier(startPos, startLoc, id);\n\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n }\n\n return this.finishNode(node, \"GenericTypeAnnotation\");\n }\n\n flowParseTypeofType(): N.FlowTypeofTypeAnnotation {\n const node = this.startNode();\n this.expect(tt._typeof);\n node.argument = this.flowParsePrimaryType();\n return this.finishNode(node, \"TypeofTypeAnnotation\");\n }\n\n flowParseTupleType(): N.FlowTupleTypeAnnotation {\n const node = this.startNode();\n node.types = [];\n this.expect(tt.bracketL);\n // We allow trailing commas\n while (this.state.pos < this.length && !this.match(tt.bracketR)) {\n node.types.push(this.flowParseType());\n if (this.match(tt.bracketR)) break;\n this.expect(tt.comma);\n }\n this.expect(tt.bracketR);\n return this.finishNode(node, \"TupleTypeAnnotation\");\n }\n\n flowParseFunctionTypeParam(first: boolean): N.FlowFunctionTypeParam {\n let name = null;\n let optional = false;\n let typeAnnotation = null;\n const node = this.startNode();\n const lh = this.lookahead();\n const isThis = this.state.type === tt._this;\n\n if (lh.type === tt.colon || lh.type === tt.question) {\n if (isThis && !first) {\n this.raise(node.start, FlowErrors.ThisParamMustBeFirst);\n }\n name = this.parseIdentifier(isThis);\n if (this.eat(tt.question)) {\n optional = true;\n if (isThis) {\n this.raise(node.start, FlowErrors.ThisParamMayNotBeOptional);\n }\n }\n typeAnnotation = this.flowParseTypeInitialiser();\n } else {\n typeAnnotation = this.flowParseType();\n }\n node.name = name;\n node.optional = optional;\n node.typeAnnotation = typeAnnotation;\n return this.finishNode(node, \"FunctionTypeParam\");\n }\n\n reinterpretTypeAsFunctionTypeParam(\n type: N.FlowType,\n ): N.FlowFunctionTypeParam {\n const node = this.startNodeAt(type.start, type.loc.start);\n node.name = null;\n node.optional = false;\n node.typeAnnotation = type;\n return this.finishNode(node, \"FunctionTypeParam\");\n }\n\n flowParseFunctionTypeParams(\n params: N.FlowFunctionTypeParam[] = [],\n ): {\n params: N.FlowFunctionTypeParam[],\n rest: ?N.FlowFunctionTypeParam,\n _this: ?N.FlowFunctionTypeParam,\n } {\n let rest: ?N.FlowFunctionTypeParam = null;\n let _this: ?N.FlowFunctionTypeParam = null;\n if (this.match(tt._this)) {\n _this = this.flowParseFunctionTypeParam(/* first */ true);\n // match Flow parser behavior\n _this.name = null;\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n while (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n params.push(this.flowParseFunctionTypeParam(false));\n if (!this.match(tt.parenR)) {\n this.expect(tt.comma);\n }\n }\n if (this.eat(tt.ellipsis)) {\n rest = this.flowParseFunctionTypeParam(false);\n }\n return { params, rest, _this };\n }\n\n flowIdentToTypeAnnotation(\n startPos: number,\n startLoc: Position,\n node: N.FlowTypeAnnotation,\n id: N.Identifier,\n ): N.FlowTypeAnnotation {\n switch (id.name) {\n case \"any\":\n return this.finishNode(node, \"AnyTypeAnnotation\");\n\n case \"bool\":\n case \"boolean\":\n return this.finishNode(node, \"BooleanTypeAnnotation\");\n\n case \"mixed\":\n return this.finishNode(node, \"MixedTypeAnnotation\");\n\n case \"empty\":\n return this.finishNode(node, \"EmptyTypeAnnotation\");\n\n case \"number\":\n return this.finishNode(node, \"NumberTypeAnnotation\");\n\n case \"string\":\n return this.finishNode(node, \"StringTypeAnnotation\");\n\n case \"symbol\":\n return this.finishNode(node, \"SymbolTypeAnnotation\");\n\n default:\n this.checkNotUnderscore(id.name);\n return this.flowParseGenericType(startPos, startLoc, id);\n }\n }\n\n // The parsing of types roughly parallels the parsing of expressions, and\n // primary types are kind of like primary expressions...they're the\n // primitives with which other types are constructed.\n flowParsePrimaryType(): N.FlowTypeAnnotation {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const node = this.startNode();\n let tmp;\n let type;\n let isGroupedType = false;\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n\n switch (this.state.type) {\n case tt.name:\n if (this.isContextual(\"interface\")) {\n return this.flowParseInterfaceType();\n }\n\n return this.flowIdentToTypeAnnotation(\n startPos,\n startLoc,\n node,\n this.parseIdentifier(),\n );\n\n case tt.braceL:\n return this.flowParseObjectType({\n allowStatic: false,\n allowExact: false,\n allowSpread: true,\n allowProto: false,\n allowInexact: true,\n });\n\n case tt.braceBarL:\n return this.flowParseObjectType({\n allowStatic: false,\n allowExact: true,\n allowSpread: true,\n allowProto: false,\n allowInexact: false,\n });\n\n case tt.bracketL:\n this.state.noAnonFunctionType = false;\n type = this.flowParseTupleType();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n return type;\n\n case tt.relational:\n if (this.state.value === \"<\") {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n this.expect(tt.parenL);\n tmp = this.flowParseFunctionTypeParams();\n node.params = tmp.params;\n node.rest = tmp.rest;\n node.this = tmp._this;\n this.expect(tt.parenR);\n\n this.expect(tt.arrow);\n\n node.returnType = this.flowParseType();\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n break;\n\n case tt.parenL:\n this.next();\n\n // Check to see if this is actually a grouped type\n if (!this.match(tt.parenR) && !this.match(tt.ellipsis)) {\n if (this.match(tt.name) || this.match(tt._this)) {\n const token = this.lookahead().type;\n isGroupedType = token !== tt.question && token !== tt.colon;\n } else {\n isGroupedType = true;\n }\n }\n\n if (isGroupedType) {\n this.state.noAnonFunctionType = false;\n type = this.flowParseType();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n\n // A `,` or a `) =>` means this is an anonymous function type\n if (\n this.state.noAnonFunctionType ||\n !(\n this.match(tt.comma) ||\n (this.match(tt.parenR) && this.lookahead().type === tt.arrow)\n )\n ) {\n this.expect(tt.parenR);\n return type;\n } else {\n // Eat a comma if there is one\n this.eat(tt.comma);\n }\n }\n\n if (type) {\n tmp = this.flowParseFunctionTypeParams([\n this.reinterpretTypeAsFunctionTypeParam(type),\n ]);\n } else {\n tmp = this.flowParseFunctionTypeParams();\n }\n\n node.params = tmp.params;\n node.rest = tmp.rest;\n node.this = tmp._this;\n\n this.expect(tt.parenR);\n\n this.expect(tt.arrow);\n\n node.returnType = this.flowParseType();\n\n node.typeParameters = null;\n\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n\n case tt.string:\n return this.parseLiteral(\n this.state.value,\n \"StringLiteralTypeAnnotation\",\n );\n\n case tt._true:\n case tt._false:\n node.value = this.match(tt._true);\n this.next();\n return this.finishNode(node, \"BooleanLiteralTypeAnnotation\");\n\n case tt.plusMin:\n if (this.state.value === \"-\") {\n this.next();\n if (this.match(tt.num)) {\n return this.parseLiteral(\n -this.state.value,\n \"NumberLiteralTypeAnnotation\",\n node.start,\n node.loc.start,\n );\n }\n\n if (this.match(tt.bigint)) {\n return this.parseLiteral(\n -this.state.value,\n \"BigIntLiteralTypeAnnotation\",\n node.start,\n node.loc.start,\n );\n }\n\n throw this.raise(\n this.state.start,\n FlowErrors.UnexpectedSubtractionOperand,\n );\n }\n\n throw this.unexpected();\n case tt.num:\n return this.parseLiteral(\n this.state.value,\n \"NumberLiteralTypeAnnotation\",\n );\n\n case tt.bigint:\n return this.parseLiteral(\n this.state.value,\n \"BigIntLiteralTypeAnnotation\",\n );\n\n case tt._void:\n this.next();\n return this.finishNode(node, \"VoidTypeAnnotation\");\n\n case tt._null:\n this.next();\n return this.finishNode(node, \"NullLiteralTypeAnnotation\");\n\n case tt._this:\n this.next();\n return this.finishNode(node, \"ThisTypeAnnotation\");\n\n case tt.star:\n this.next();\n return this.finishNode(node, \"ExistsTypeAnnotation\");\n\n default:\n if (this.state.type.keyword === \"typeof\") {\n return this.flowParseTypeofType();\n } else if (this.state.type.keyword) {\n const label = this.state.type.label;\n this.next();\n return super.createIdentifier(node, label);\n }\n }\n\n throw this.unexpected();\n }\n\n flowParsePostfixType(): N.FlowTypeAnnotation {\n const startPos = this.state.start,\n startLoc = this.state.startLoc;\n let type = this.flowParsePrimaryType();\n while (this.match(tt.bracketL) && !this.canInsertSemicolon()) {\n const node = this.startNodeAt(startPos, startLoc);\n node.elementType = type;\n this.expect(tt.bracketL);\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"ArrayTypeAnnotation\");\n }\n return type;\n }\n\n flowParsePrefixType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n if (this.eat(tt.question)) {\n node.typeAnnotation = this.flowParsePrefixType();\n return this.finishNode(node, \"NullableTypeAnnotation\");\n } else {\n return this.flowParsePostfixType();\n }\n }\n\n flowParseAnonFunctionWithoutParens(): N.FlowTypeAnnotation {\n const param = this.flowParsePrefixType();\n if (!this.state.noAnonFunctionType && this.eat(tt.arrow)) {\n // TODO: This should be a type error. Passing in a SourceLocation, and it expects a Position.\n const node = this.startNodeAt(param.start, param.loc.start);\n node.params = [this.reinterpretTypeAsFunctionTypeParam(param)];\n node.rest = null;\n node.this = null;\n node.returnType = this.flowParseType();\n node.typeParameters = null;\n return this.finishNode(node, \"FunctionTypeAnnotation\");\n }\n return param;\n }\n\n flowParseIntersectionType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n this.eat(tt.bitwiseAND);\n const type = this.flowParseAnonFunctionWithoutParens();\n node.types = [type];\n while (this.eat(tt.bitwiseAND)) {\n node.types.push(this.flowParseAnonFunctionWithoutParens());\n }\n return node.types.length === 1\n ? type\n : this.finishNode(node, \"IntersectionTypeAnnotation\");\n }\n\n flowParseUnionType(): N.FlowTypeAnnotation {\n const node = this.startNode();\n this.eat(tt.bitwiseOR);\n const type = this.flowParseIntersectionType();\n node.types = [type];\n while (this.eat(tt.bitwiseOR)) {\n node.types.push(this.flowParseIntersectionType());\n }\n return node.types.length === 1\n ? type\n : this.finishNode(node, \"UnionTypeAnnotation\");\n }\n\n flowParseType(): N.FlowTypeAnnotation {\n const oldInType = this.state.inType;\n this.state.inType = true;\n const type = this.flowParseUnionType();\n this.state.inType = oldInType;\n // Ensure that a brace after a function generic type annotation is a\n // statement, except in arrow functions (noAnonFunctionType)\n this.state.exprAllowed =\n this.state.exprAllowed || this.state.noAnonFunctionType;\n return type;\n }\n\n flowParseTypeOrImplicitInstantiation(): N.FlowTypeAnnotation {\n if (this.state.type === tt.name && this.state.value === \"_\") {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const node = this.parseIdentifier();\n return this.flowParseGenericType(startPos, startLoc, node);\n } else {\n return this.flowParseType();\n }\n }\n\n flowParseTypeAnnotation(): N.FlowTypeAnnotation {\n const node = this.startNode();\n node.typeAnnotation = this.flowParseTypeInitialiser();\n return this.finishNode(node, \"TypeAnnotation\");\n }\n\n flowParseTypeAnnotatableIdentifier(\n allowPrimitiveOverride?: boolean,\n ): N.Identifier {\n const ident = allowPrimitiveOverride\n ? this.parseIdentifier()\n : this.flowParseRestrictedIdentifier();\n if (this.match(tt.colon)) {\n ident.typeAnnotation = this.flowParseTypeAnnotation();\n this.resetEndLocation(ident);\n }\n return ident;\n }\n\n typeCastToParameter(node: N.Node): N.Node {\n node.expression.typeAnnotation = node.typeAnnotation;\n\n this.resetEndLocation(\n node.expression,\n node.typeAnnotation.end,\n node.typeAnnotation.loc.end,\n );\n\n return node.expression;\n }\n\n flowParseVariance(): ?N.FlowVariance {\n let variance = null;\n if (this.match(tt.plusMin)) {\n variance = this.startNode();\n if (this.state.value === \"+\") {\n variance.kind = \"plus\";\n } else {\n variance.kind = \"minus\";\n }\n this.next();\n this.finishNode(variance, \"Variance\");\n }\n return variance;\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n parseFunctionBody(\n node: N.Function,\n allowExpressionBody: ?boolean,\n isMethod?: boolean = false,\n ): void {\n if (allowExpressionBody) {\n return this.forwardNoArrowParamsConversionAt(node, () =>\n super.parseFunctionBody(node, true, isMethod),\n );\n }\n\n return super.parseFunctionBody(node, false, isMethod);\n }\n\n parseFunctionBodyAndFinish(\n node: N.BodilessFunctionOrMethodBase,\n type: string,\n isMethod?: boolean = false,\n ): void {\n if (this.match(tt.colon)) {\n const typeNode = this.startNode();\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.typeAnnotation,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n node.returnType = typeNode.typeAnnotation\n ? this.finishNode(typeNode, \"TypeAnnotation\")\n : null;\n }\n\n super.parseFunctionBodyAndFinish(node, type, isMethod);\n }\n\n // interfaces and enums\n parseStatement(context: ?string, topLevel?: boolean): N.Statement {\n // strict mode handling of `interface` since it's a reserved word\n if (\n this.state.strict &&\n this.match(tt.name) &&\n this.state.value === \"interface\"\n ) {\n const lookahead = this.lookahead();\n if (lookahead.type === tt.name || isKeyword(lookahead.value)) {\n const node = this.startNode();\n this.next();\n return this.flowParseInterface(node);\n }\n } else if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n const node = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(node);\n }\n const stmt = super.parseStatement(context, topLevel);\n // We will parse a flow pragma in any comment before the first statement.\n if (this.flowPragma === undefined && !this.isValidDirective(stmt)) {\n this.flowPragma = null;\n }\n return stmt;\n }\n\n // declares, interfaces and type aliases\n parseExpressionStatement(\n node: N.ExpressionStatement,\n expr: N.Expression,\n ): N.ExpressionStatement {\n if (expr.type === \"Identifier\") {\n if (expr.name === \"declare\") {\n if (\n this.match(tt._class) ||\n this.match(tt.name) ||\n this.match(tt._function) ||\n this.match(tt._var) ||\n this.match(tt._export)\n ) {\n return this.flowParseDeclare(node);\n }\n } else if (this.match(tt.name)) {\n if (expr.name === \"interface\") {\n return this.flowParseInterface(node);\n } else if (expr.name === \"type\") {\n return this.flowParseTypeAlias(node);\n } else if (expr.name === \"opaque\") {\n return this.flowParseOpaqueType(node, false);\n }\n }\n }\n\n return super.parseExpressionStatement(node, expr);\n }\n\n // export type\n shouldParseExportDeclaration(): boolean {\n return (\n this.isContextual(\"type\") ||\n this.isContextual(\"interface\") ||\n this.isContextual(\"opaque\") ||\n (this.shouldParseEnums() && this.isContextual(\"enum\")) ||\n super.shouldParseExportDeclaration()\n );\n }\n\n isExportDefaultSpecifier(): boolean {\n if (\n this.match(tt.name) &&\n (this.state.value === \"type\" ||\n this.state.value === \"interface\" ||\n this.state.value === \"opaque\" ||\n (this.shouldParseEnums() && this.state.value === \"enum\"))\n ) {\n return false;\n }\n\n return super.isExportDefaultSpecifier();\n }\n\n parseExportDefaultExpression(): N.Expression | N.Declaration {\n if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n const node = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(node);\n }\n return super.parseExportDefaultExpression();\n }\n\n parseConditional(\n expr: N.Expression,\n startPos: number,\n startLoc: Position,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n if (!this.match(tt.question)) return expr;\n\n // only use the expensive \"tryParse\" method if there is a question mark\n // and if we come from inside parens\n if (refNeedsArrowPos) {\n const result = this.tryParse(() =>\n super.parseConditional(expr, startPos, startLoc),\n );\n\n if (!result.node) {\n // $FlowIgnore\n refNeedsArrowPos.start = result.error.pos || this.state.start;\n return expr;\n }\n\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n this.expect(tt.question);\n const state = this.state.clone();\n const originalNoArrowAt = this.state.noArrowAt;\n const node = this.startNodeAt(startPos, startLoc);\n let { consequent, failed } = this.tryParseConditionalConsequent();\n let [valid, invalid] = this.getArrowLikeExpressions(consequent);\n\n if (failed || invalid.length > 0) {\n const noArrowAt = [...originalNoArrowAt];\n\n if (invalid.length > 0) {\n this.state = state;\n this.state.noArrowAt = noArrowAt;\n\n for (let i = 0; i < invalid.length; i++) {\n noArrowAt.push(invalid[i].start);\n }\n\n ({ consequent, failed } = this.tryParseConditionalConsequent());\n [valid, invalid] = this.getArrowLikeExpressions(consequent);\n }\n\n if (failed && valid.length > 1) {\n // if there are two or more possible correct ways of parsing, throw an\n // error.\n // e.g. Source: a ? (b): c => (d): e => f\n // Result 1: a ? b : (c => ((d): e => f))\n // Result 2: a ? ((b): c => d) : (e => f)\n this.raise(state.start, FlowErrors.AmbiguousConditionalArrow);\n }\n\n if (failed && valid.length === 1) {\n this.state = state;\n this.state.noArrowAt = noArrowAt.concat(valid[0].start);\n ({ consequent, failed } = this.tryParseConditionalConsequent());\n }\n }\n\n this.getArrowLikeExpressions(consequent, true);\n\n this.state.noArrowAt = originalNoArrowAt;\n this.expect(tt.colon);\n\n node.test = expr;\n node.consequent = consequent;\n node.alternate = this.forwardNoArrowParamsConversionAt(node, () =>\n this.parseMaybeAssign(undefined, undefined, undefined),\n );\n\n return this.finishNode(node, \"ConditionalExpression\");\n }\n\n tryParseConditionalConsequent(): {\n consequent: N.Expression,\n failed: boolean,\n } {\n this.state.noArrowParamsConversionAt.push(this.state.start);\n\n const consequent = this.parseMaybeAssignAllowIn();\n const failed = !this.match(tt.colon);\n\n this.state.noArrowParamsConversionAt.pop();\n\n return { consequent, failed };\n }\n\n // Given an expression, walks through out its arrow functions whose body is\n // an expression and through out conditional expressions. It returns every\n // function which has been parsed with a return type but could have been\n // parenthesized expressions.\n // These functions are separated into two arrays: one containing the ones\n // whose parameters can be converted to assignable lists, one containing the\n // others.\n getArrowLikeExpressions(\n node: N.Expression,\n disallowInvalid?: boolean,\n ): [N.ArrowFunctionExpression[], N.ArrowFunctionExpression[]] {\n const stack = [node];\n const arrows: N.ArrowFunctionExpression[] = [];\n\n while (stack.length !== 0) {\n const node = stack.pop();\n if (node.type === \"ArrowFunctionExpression\") {\n if (node.typeParameters || !node.returnType) {\n // This is an arrow expression without ambiguity, so check its parameters\n this.finishArrowValidation(node);\n } else {\n arrows.push(node);\n }\n stack.push(node.body);\n } else if (node.type === \"ConditionalExpression\") {\n stack.push(node.consequent);\n stack.push(node.alternate);\n }\n }\n\n if (disallowInvalid) {\n arrows.forEach(node => this.finishArrowValidation(node));\n return [arrows, []];\n }\n\n return partition(arrows, node =>\n node.params.every(param => this.isAssignable(param, true)),\n );\n }\n\n finishArrowValidation(node: N.ArrowFunctionExpression) {\n this.toAssignableList(\n // node.params is Expression[] instead of $ReadOnlyArray because it\n // has not been converted yet.\n ((node.params: any): N.Expression[]),\n node.extra?.trailingComma,\n /* isLHS */ false,\n );\n // Enter scope, as checkParams defines bindings\n this.scope.enter(SCOPE_FUNCTION | SCOPE_ARROW);\n // Use super's method to force the parameters to be checked\n super.checkParams(node, false, true);\n this.scope.exit();\n }\n\n forwardNoArrowParamsConversionAt(node: N.Node, parse: () => T): T {\n let result: T;\n if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {\n this.state.noArrowParamsConversionAt.push(this.state.start);\n result = parse();\n this.state.noArrowParamsConversionAt.pop();\n } else {\n result = parse();\n }\n\n return result;\n }\n\n parseParenItem(\n node: N.Expression,\n startPos: number,\n startLoc: Position,\n ): N.Expression {\n node = super.parseParenItem(node, startPos, startLoc);\n if (this.eat(tt.question)) {\n node.optional = true;\n // Include questionmark in location of node\n // Don't use this.finishNode() as otherwise we might process comments twice and\n // include already consumed parens\n this.resetEndLocation(node);\n }\n\n if (this.match(tt.colon)) {\n const typeCastNode = this.startNodeAt(startPos, startLoc);\n typeCastNode.expression = node;\n typeCastNode.typeAnnotation = this.flowParseTypeAnnotation();\n\n return this.finishNode(typeCastNode, \"TypeCastExpression\");\n }\n\n return node;\n }\n\n assertModuleNodeAllowed(node: N.Node) {\n if (\n (node.type === \"ImportDeclaration\" &&\n (node.importKind === \"type\" || node.importKind === \"typeof\")) ||\n (node.type === \"ExportNamedDeclaration\" &&\n node.exportKind === \"type\") ||\n (node.type === \"ExportAllDeclaration\" && node.exportKind === \"type\")\n ) {\n // Allow Flowtype imports and exports in all conditions because\n // Flow itself does not care about 'sourceType'.\n return;\n }\n\n super.assertModuleNodeAllowed(node);\n }\n\n parseExport(node: N.Node): N.AnyExport {\n const decl = super.parseExport(node);\n if (\n decl.type === \"ExportNamedDeclaration\" ||\n decl.type === \"ExportAllDeclaration\"\n ) {\n decl.exportKind = decl.exportKind || \"value\";\n }\n return decl;\n }\n\n parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {\n if (this.isContextual(\"type\")) {\n node.exportKind = \"type\";\n\n const declarationNode = this.startNode();\n this.next();\n\n if (this.match(tt.braceL)) {\n // export type { foo, bar };\n node.specifiers = this.parseExportSpecifiers();\n this.parseExportFrom(node);\n return null;\n } else {\n // export type Foo = Bar;\n return this.flowParseTypeAlias(declarationNode);\n }\n } else if (this.isContextual(\"opaque\")) {\n node.exportKind = \"type\";\n\n const declarationNode = this.startNode();\n this.next();\n // export opaque type Foo = Bar;\n return this.flowParseOpaqueType(declarationNode, false);\n } else if (this.isContextual(\"interface\")) {\n node.exportKind = \"type\";\n const declarationNode = this.startNode();\n this.next();\n return this.flowParseInterface(declarationNode);\n } else if (this.shouldParseEnums() && this.isContextual(\"enum\")) {\n node.exportKind = \"value\";\n const declarationNode = this.startNode();\n this.next();\n return this.flowParseEnumDeclaration(declarationNode);\n } else {\n return super.parseExportDeclaration(node);\n }\n }\n\n eatExportStar(node: N.Node): boolean {\n if (super.eatExportStar(...arguments)) return true;\n\n if (this.isContextual(\"type\") && this.lookahead().type === tt.star) {\n node.exportKind = \"type\";\n this.next();\n this.next();\n return true;\n }\n\n return false;\n }\n\n maybeParseExportNamespaceSpecifier(node: N.Node): boolean {\n const pos = this.state.start;\n const hasNamespace = super.maybeParseExportNamespaceSpecifier(node);\n if (hasNamespace && node.exportKind === \"type\") {\n this.unexpected(pos);\n }\n return hasNamespace;\n }\n\n parseClassId(node: N.Class, isStatement: boolean, optionalId: ?boolean) {\n super.parseClassId(node, isStatement, optionalId);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n }\n\n parseClassMember(\n classBody: N.ClassBody,\n member: any,\n state: N.ParseClassMemberState,\n ): void {\n const pos = this.state.start;\n if (this.isContextual(\"declare\")) {\n if (this.parseClassMemberFromModifier(classBody, member)) {\n // 'declare' is a class element name\n return;\n }\n\n member.declare = true;\n }\n\n super.parseClassMember(classBody, member, state);\n\n if (member.declare) {\n if (\n member.type !== \"ClassProperty\" &&\n member.type !== \"ClassPrivateProperty\" &&\n member.type !== \"PropertyDefinition\" // Used by estree plugin\n ) {\n this.raise(pos, FlowErrors.DeclareClassElement);\n } else if (member.value) {\n this.raise(\n member.value.start,\n FlowErrors.DeclareClassFieldInitializer,\n );\n }\n }\n }\n\n // ensure that inside flow types, we bypass the jsx parser plugin\n getTokenFromCode(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (code === charCodes.leftCurlyBrace && next === charCodes.verticalBar) {\n return this.finishOp(tt.braceBarL, 2);\n } else if (\n this.state.inType &&\n (code === charCodes.greaterThan || code === charCodes.lessThan)\n ) {\n return this.finishOp(tt.relational, 1);\n } else if (this.state.inType && code === charCodes.questionMark) {\n // allow double nullable types in Flow: ??string\n return this.finishOp(tt.question, 1);\n } else if (isIteratorStart(code, next)) {\n this.state.isIterator = true;\n return super.readWord();\n } else {\n return super.getTokenFromCode(code);\n }\n }\n\n isAssignable(node: N.Node, isBinding?: boolean): boolean {\n switch (node.type) {\n case \"Identifier\":\n case \"ObjectPattern\":\n case \"ArrayPattern\":\n case \"AssignmentPattern\":\n return true;\n\n case \"ObjectExpression\": {\n const last = node.properties.length - 1;\n return node.properties.every((prop, i) => {\n return (\n prop.type !== \"ObjectMethod\" &&\n (i === last || prop.type === \"SpreadElement\") &&\n this.isAssignable(prop)\n );\n });\n }\n\n case \"ObjectProperty\":\n return this.isAssignable(node.value);\n\n case \"SpreadElement\":\n return this.isAssignable(node.argument);\n\n case \"ArrayExpression\":\n return node.elements.every(element => this.isAssignable(element));\n\n case \"AssignmentExpression\":\n return node.operator === \"=\";\n\n case \"ParenthesizedExpression\":\n case \"TypeCastExpression\":\n return this.isAssignable(node.expression);\n\n case \"MemberExpression\":\n case \"OptionalMemberExpression\":\n return !isBinding;\n\n default:\n return false;\n }\n }\n\n toAssignable(node: N.Node, isLHS: boolean = false): N.Node {\n if (node.type === \"TypeCastExpression\") {\n return super.toAssignable(this.typeCastToParameter(node), isLHS);\n } else {\n return super.toAssignable(node, isLHS);\n }\n }\n\n // turn type casts that we found in function parameter head into type annotated params\n toAssignableList(\n exprList: N.Expression[],\n trailingCommaPos?: ?number,\n isLHS: boolean,\n ): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (expr?.type === \"TypeCastExpression\") {\n exprList[i] = this.typeCastToParameter(expr);\n }\n }\n return super.toAssignableList(exprList, trailingCommaPos, isLHS);\n }\n\n // this is a list of nodes, from something like a call expression, we need to filter the\n // type casts that we've found that are illegal in this context\n toReferencedList(\n exprList: $ReadOnlyArray,\n isParenthesizedExpr?: boolean,\n ): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (\n expr &&\n expr.type === \"TypeCastExpression\" &&\n !expr.extra?.parenthesized &&\n (exprList.length > 1 || !isParenthesizedExpr)\n ) {\n this.raise(expr.typeAnnotation.start, FlowErrors.TypeCastInPattern);\n }\n }\n\n return exprList;\n }\n\n parseArrayLike(\n close: TokenType,\n canBePattern: boolean,\n isTuple: boolean,\n refExpressionErrors: ?ExpressionErrors,\n ): N.ArrayExpression | N.TupleExpression {\n const node = super.parseArrayLike(\n close,\n canBePattern,\n isTuple,\n refExpressionErrors,\n );\n\n // This could be an array pattern:\n // ([a: string, b: string]) => {}\n // In this case, we don't have to call toReferencedList. We will\n // call it, if needed, when we are sure that it is a parenthesized\n // expression by calling toReferencedListDeep.\n if (canBePattern && !this.state.maybeInArrowParameters) {\n this.toReferencedList(node.elements);\n }\n\n return node;\n }\n\n checkLVal(\n expr: N.Expression,\n ...args:\n | [string, BindingTypes | void]\n | [\n string,\n BindingTypes | void,\n ?Set,\n boolean | void,\n boolean | void,\n ]\n ): void {\n if (expr.type !== \"TypeCastExpression\") {\n return super.checkLVal(expr, ...args);\n }\n }\n\n // parse class property type annotations\n parseClassProperty(node: N.ClassProperty): N.ClassProperty {\n if (this.match(tt.colon)) {\n node.typeAnnotation = this.flowParseTypeAnnotation();\n }\n return super.parseClassProperty(node);\n }\n\n parseClassPrivateProperty(\n node: N.ClassPrivateProperty,\n ): N.ClassPrivateProperty {\n if (this.match(tt.colon)) {\n node.typeAnnotation = this.flowParseTypeAnnotation();\n }\n return super.parseClassPrivateProperty(node);\n }\n\n // determine whether or not we're currently in the position where a class method would appear\n isClassMethod(): boolean {\n return this.isRelational(\"<\") || super.isClassMethod();\n }\n\n // determine whether or not we're currently in the position where a class property would appear\n isClassProperty(): boolean {\n return this.match(tt.colon) || super.isClassProperty();\n }\n\n isNonstaticConstructor(method: N.ClassMethod | N.ClassProperty): boolean {\n return !this.match(tt.colon) && super.isNonstaticConstructor(method);\n }\n\n // determine whether a parameter is a this param\n isThisParam(param) {\n return param.type === \"Identifier\" && param.name === \"this\";\n }\n\n // parse type parameters for class methods\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n if ((method: $FlowFixMe).variance) {\n this.unexpected((method: $FlowFixMe).variance.start);\n }\n delete (method: $FlowFixMe).variance;\n if (this.isRelational(\"<\")) {\n method.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n super.pushClassMethod(\n classBody,\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n );\n\n if (method.params && isConstructor) {\n const params = method.params;\n if (params.length > 0 && this.isThisParam(params[0])) {\n this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);\n }\n // estree support\n } else if (\n // $FlowFixMe flow does not know about the face that estree can replace ClassMethod with MethodDefinition\n method.type === \"MethodDefinition\" &&\n isConstructor &&\n method.value.params\n ) {\n const params = method.value.params;\n if (params.length > 0 && this.isThisParam(params[0])) {\n this.raise(method.start, FlowErrors.ThisParamBannedInConstructor);\n }\n }\n }\n\n pushClassPrivateMethod(\n classBody: N.ClassBody,\n method: N.ClassPrivateMethod,\n isGenerator: boolean,\n isAsync: boolean,\n ): void {\n if ((method: $FlowFixMe).variance) {\n this.unexpected((method: $FlowFixMe).variance.start);\n }\n delete (method: $FlowFixMe).variance;\n if (this.isRelational(\"<\")) {\n method.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n\n super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);\n }\n\n // parse a the super class type parameters and implements\n parseClassSuper(node: N.Class): void {\n super.parseClassSuper(node);\n if (node.superClass && this.isRelational(\"<\")) {\n node.superTypeParameters = this.flowParseTypeParameterInstantiation();\n }\n if (this.isContextual(\"implements\")) {\n this.next();\n const implemented: N.FlowClassImplements[] = (node.implements = []);\n do {\n const node = this.startNode();\n node.id = this.flowParseRestrictedIdentifier(/*liberal*/ true);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterInstantiation();\n } else {\n node.typeParameters = null;\n }\n implemented.push(this.finishNode(node, \"ClassImplements\"));\n } while (this.eat(tt.comma));\n }\n }\n\n checkGetterSetterParams(method: N.ObjectMethod | N.ClassMethod): void {\n super.checkGetterSetterParams(method);\n const params = this.getObjectOrClassMethodParams(method);\n if (params.length > 0) {\n const param = params[0];\n if (this.isThisParam(param) && method.kind === \"get\") {\n this.raise(param.start, FlowErrors.GetterMayNotHaveThisParam);\n } else if (this.isThisParam(param)) {\n this.raise(param.start, FlowErrors.SetterMayNotHaveThisParam);\n }\n }\n }\n\n parsePropertyName(\n node: N.ObjectOrClassMember | N.ClassMember | N.TsNamedTypeElementBase,\n isPrivateNameAllowed: boolean,\n ): N.Identifier {\n const variance = this.flowParseVariance();\n const key = super.parsePropertyName(node, isPrivateNameAllowed);\n // $FlowIgnore (\"variance\" not defined on TsNamedTypeElementBase)\n node.variance = variance;\n return key;\n }\n\n // parse type parameters for object method shorthand\n parseObjPropValue(\n prop: N.ObjectMember,\n startPos: ?number,\n startLoc: ?Position,\n isGenerator: boolean,\n isAsync: boolean,\n isPattern: boolean,\n isAccessor: boolean,\n refExpressionErrors: ?ExpressionErrors,\n ): void {\n if ((prop: $FlowFixMe).variance) {\n this.unexpected((prop: $FlowFixMe).variance.start);\n }\n delete (prop: $FlowFixMe).variance;\n\n let typeParameters;\n\n // method shorthand\n if (this.isRelational(\"<\") && !isAccessor) {\n typeParameters = this.flowParseTypeParameterDeclaration();\n if (!this.match(tt.parenL)) this.unexpected();\n }\n\n super.parseObjPropValue(\n prop,\n startPos,\n startLoc,\n isGenerator,\n isAsync,\n isPattern,\n isAccessor,\n refExpressionErrors,\n );\n\n // add typeParameters if we found them\n if (typeParameters) {\n (prop.value || prop).typeParameters = typeParameters;\n }\n }\n\n parseAssignableListItemTypes(param: N.Pattern): N.Pattern {\n if (this.eat(tt.question)) {\n if (param.type !== \"Identifier\") {\n this.raise(param.start, FlowErrors.OptionalBindingPattern);\n }\n if (this.isThisParam(param)) {\n this.raise(param.start, FlowErrors.ThisParamMayNotBeOptional);\n }\n\n ((param: any): N.Identifier).optional = true;\n }\n if (this.match(tt.colon)) {\n param.typeAnnotation = this.flowParseTypeAnnotation();\n } else if (this.isThisParam(param)) {\n this.raise(param.start, FlowErrors.ThisParamAnnotationRequired);\n }\n\n if (this.match(tt.eq) && this.isThisParam(param)) {\n this.raise(param.start, FlowErrors.ThisParamNoDefault);\n }\n\n this.resetEndLocation(param);\n return param;\n }\n\n parseMaybeDefault(\n startPos?: ?number,\n startLoc?: ?Position,\n left?: ?N.Pattern,\n ): N.Pattern {\n const node = super.parseMaybeDefault(startPos, startLoc, left);\n\n if (\n node.type === \"AssignmentPattern\" &&\n node.typeAnnotation &&\n node.right.start < node.typeAnnotation.start\n ) {\n this.raise(node.typeAnnotation.start, FlowErrors.TypeBeforeInitializer);\n }\n\n return node;\n }\n\n shouldParseDefaultImport(node: N.ImportDeclaration): boolean {\n if (!hasTypeImportKind(node)) {\n return super.shouldParseDefaultImport(node);\n }\n\n return isMaybeDefaultImport(this.state);\n }\n\n parseImportSpecifierLocal(\n node: N.ImportDeclaration,\n specifier: N.Node,\n type: string,\n contextDescription: string,\n ): void {\n specifier.local = hasTypeImportKind(node)\n ? this.flowParseRestrictedIdentifier(\n /* liberal */ true,\n /* declaration */ true,\n )\n : this.parseIdentifier();\n\n this.checkLVal(specifier.local, contextDescription, BIND_LEXICAL);\n node.specifiers.push(this.finishNode(specifier, type));\n }\n\n // parse typeof and type imports\n maybeParseDefaultImportSpecifier(node: N.ImportDeclaration): boolean {\n node.importKind = \"value\";\n\n let kind = null;\n if (this.match(tt._typeof)) {\n kind = \"typeof\";\n } else if (this.isContextual(\"type\")) {\n kind = \"type\";\n }\n if (kind) {\n const lh = this.lookahead();\n\n // import type * is not allowed\n if (kind === \"type\" && lh.type === tt.star) {\n this.unexpected(lh.start);\n }\n\n if (\n isMaybeDefaultImport(lh) ||\n lh.type === tt.braceL ||\n lh.type === tt.star\n ) {\n this.next();\n node.importKind = kind;\n }\n }\n\n return super.maybeParseDefaultImportSpecifier(node);\n }\n\n // parse import-type/typeof shorthand\n parseImportSpecifier(node: N.ImportDeclaration): void {\n const specifier = this.startNode();\n const firstIdentLoc = this.state.start;\n const firstIdent = this.parseModuleExportName();\n\n let specifierTypeKind = null;\n if (firstIdent.type === \"Identifier\") {\n if (firstIdent.name === \"type\") {\n specifierTypeKind = \"type\";\n } else if (firstIdent.name === \"typeof\") {\n specifierTypeKind = \"typeof\";\n }\n }\n\n let isBinding = false;\n if (this.isContextual(\"as\") && !this.isLookaheadContextual(\"as\")) {\n const as_ident = this.parseIdentifier(true);\n if (\n specifierTypeKind !== null &&\n !this.match(tt.name) &&\n !this.state.type.keyword\n ) {\n // `import {type as ,` or `import {type as }`\n specifier.imported = as_ident;\n specifier.importKind = specifierTypeKind;\n specifier.local = as_ident.__clone();\n } else {\n // `import {type as foo`\n specifier.imported = firstIdent;\n specifier.importKind = null;\n specifier.local = this.parseIdentifier();\n }\n } else if (\n specifierTypeKind !== null &&\n (this.match(tt.name) || this.state.type.keyword)\n ) {\n // `import {type foo`\n specifier.imported = this.parseIdentifier(true);\n specifier.importKind = specifierTypeKind;\n if (this.eatContextual(\"as\")) {\n specifier.local = this.parseIdentifier();\n } else {\n isBinding = true;\n specifier.local = specifier.imported.__clone();\n }\n } else {\n if (firstIdent.type === \"StringLiteral\") {\n throw this.raise(\n specifier.start,\n Errors.ImportBindingIsString,\n firstIdent.value,\n );\n }\n isBinding = true;\n specifier.imported = firstIdent;\n specifier.importKind = null;\n specifier.local = specifier.imported.__clone();\n }\n\n const nodeIsTypeImport = hasTypeImportKind(node);\n const specifierIsTypeImport = hasTypeImportKind(specifier);\n\n if (nodeIsTypeImport && specifierIsTypeImport) {\n this.raise(\n firstIdentLoc,\n FlowErrors.ImportTypeShorthandOnlyInPureImport,\n );\n }\n\n if (nodeIsTypeImport || specifierIsTypeImport) {\n this.checkReservedType(\n specifier.local.name,\n specifier.local.start,\n /* declaration */ true,\n );\n }\n\n if (isBinding && !nodeIsTypeImport && !specifierIsTypeImport) {\n this.checkReservedWord(\n specifier.local.name,\n specifier.start,\n true,\n true,\n );\n }\n\n this.checkLVal(specifier.local, \"import specifier\", BIND_LEXICAL);\n node.specifiers.push(this.finishNode(specifier, \"ImportSpecifier\"));\n }\n\n parseBindingAtom(): N.Pattern {\n switch (this.state.type) {\n case tt._this:\n // \"this\" may be the name of a parameter, so allow it.\n return this.parseIdentifier(/* liberal */ true);\n default:\n return super.parseBindingAtom();\n }\n }\n\n // parse function type parameters - function foo() {}\n parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {\n // $FlowFixMe\n const kind = node.kind;\n if (kind !== \"get\" && kind !== \"set\" && this.isRelational(\"<\")) {\n node.typeParameters = this.flowParseTypeParameterDeclaration();\n }\n super.parseFunctionParams(node, allowModifiers);\n }\n\n // parse flow type annotations on variable declarator heads - let foo: string = bar\n parseVarId(\n decl: N.VariableDeclarator,\n kind: \"var\" | \"let\" | \"const\",\n ): void {\n super.parseVarId(decl, kind);\n if (this.match(tt.colon)) {\n decl.id.typeAnnotation = this.flowParseTypeAnnotation();\n this.resetEndLocation(decl.id); // set end position to end of type\n }\n }\n\n // parse the return type of an async arrow function - let foo = (async (): number => {});\n parseAsyncArrowFromCallExpression(\n node: N.ArrowFunctionExpression,\n call: N.CallExpression,\n ): N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = true;\n node.returnType = this.flowParseTypeAnnotation();\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n }\n\n return super.parseAsyncArrowFromCallExpression(node, call);\n }\n\n // todo description\n shouldParseAsyncArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseAsyncArrow();\n }\n\n // We need to support type parameter declarations for arrow functions. This\n // is tricky. There are three situations we need to handle\n //\n // 1. This is either JSX or an arrow function. We'll try JSX first. If that\n // fails, we'll try an arrow function. If that fails, we'll throw the JSX\n // error.\n // 2. This is an arrow function. We'll parse the type parameter declaration,\n // parse the rest, make sure the rest is an arrow function, and go from\n // there\n // 3. This is neither. Just call the super method\n parseMaybeAssign(\n refExpressionErrors?: ?ExpressionErrors,\n afterLeftParse?: Function,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n let state = null;\n\n let jsx;\n\n if (\n this.hasPlugin(\"jsx\") &&\n (this.match(tt.jsxTagStart) || this.isRelational(\"<\"))\n ) {\n state = this.state.clone();\n\n jsx = this.tryParse(\n () =>\n super.parseMaybeAssign(\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n ),\n state,\n );\n /*:: invariant(!jsx.aborted) */\n\n if (!jsx.error) return jsx.node;\n\n // Remove `tc.j_expr` and `tc.j_oTag` from context added\n // by parsing `jsxTagStart` to stop the JSX plugin from\n // messing with the tokens\n const { context } = this.state;\n if (context[context.length - 1] === tc.j_oTag) {\n context.length -= 2;\n } else if (context[context.length - 1] === tc.j_expr) {\n context.length -= 1;\n }\n }\n\n if (jsx?.error || this.isRelational(\"<\")) {\n state = state || this.state.clone();\n\n let typeParameters;\n\n const arrow = this.tryParse(abort => {\n typeParameters = this.flowParseTypeParameterDeclaration();\n\n const arrowExpression = this.forwardNoArrowParamsConversionAt(\n typeParameters,\n () => {\n const result = super.parseMaybeAssign(\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n );\n\n this.resetStartLocationFromNode(result, typeParameters);\n\n return result;\n },\n );\n\n // (() => {}: any);\n if (\n arrowExpression.type !== \"ArrowFunctionExpression\" &&\n arrowExpression.extra?.parenthesized\n ) {\n abort();\n }\n\n // The above can return a TypeCastExpression when the arrow\n // expression is not wrapped in parens. See also `this.parseParenItem`.\n const expr = this.maybeUnwrapTypeCastExpression(arrowExpression);\n expr.typeParameters = typeParameters;\n this.resetStartLocationFromNode(expr, typeParameters);\n\n return arrowExpression;\n }, state);\n\n let arrowExpression: ?(\n | N.ArrowFunctionExpression\n | N.TypeCastExpression\n ) = null;\n\n if (\n arrow.node &&\n this.maybeUnwrapTypeCastExpression(arrow.node).type ===\n \"ArrowFunctionExpression\"\n ) {\n if (!arrow.error && !arrow.aborted) {\n // async () => {}\n if (arrow.node.async) {\n /*:: invariant(typeParameters) */\n this.raise(\n typeParameters.start,\n FlowErrors.UnexpectedTypeParameterBeforeAsyncArrowFunction,\n );\n }\n\n return arrow.node;\n }\n\n arrowExpression = arrow.node;\n }\n\n // If we are here, both JSX and Flow parsing attempts failed.\n // Give the precedence to the JSX error, except if JSX had an\n // unrecoverable error while Flow didn't.\n // If the error is recoverable, we can only re-report it if there is\n // a node we can return.\n\n if (jsx?.node) {\n /*:: invariant(jsx.failState) */\n this.state = jsx.failState;\n return jsx.node;\n }\n\n if (arrowExpression) {\n /*:: invariant(arrow.failState) */\n this.state = arrow.failState;\n return arrowExpression;\n }\n\n if (jsx?.thrown) throw jsx.error;\n if (arrow.thrown) throw arrow.error;\n\n /*:: invariant(typeParameters) */\n throw this.raise(\n typeParameters.start,\n FlowErrors.UnexpectedTokenAfterTypeParameter,\n );\n }\n\n return super.parseMaybeAssign(\n refExpressionErrors,\n afterLeftParse,\n refNeedsArrowPos,\n );\n }\n\n // handle return types for arrow functions\n parseArrow(node: N.ArrowFunctionExpression): ?N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n const result = this.tryParse(() => {\n const oldNoAnonFunctionType = this.state.noAnonFunctionType;\n this.state.noAnonFunctionType = true;\n\n const typeNode = this.startNode();\n\n [\n // $FlowFixMe (destructuring not supported yet)\n typeNode.typeAnnotation,\n // $FlowFixMe (destructuring not supported yet)\n node.predicate,\n ] = this.flowParseTypeAndPredicateInitialiser();\n\n this.state.noAnonFunctionType = oldNoAnonFunctionType;\n\n if (this.canInsertSemicolon()) this.unexpected();\n if (!this.match(tt.arrow)) this.unexpected();\n\n return typeNode;\n });\n\n if (result.thrown) return null;\n /*:: invariant(result.node) */\n\n if (result.error) this.state = result.failState;\n\n // assign after it is clear it is an arrow\n node.returnType = result.node.typeAnnotation\n ? this.finishNode(result.node, \"TypeAnnotation\")\n : null;\n }\n\n return super.parseArrow(node);\n }\n\n shouldParseArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseArrow();\n }\n\n setArrowFunctionParameters(\n node: N.ArrowFunctionExpression,\n params: N.Expression[],\n ): void {\n if (this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1) {\n node.params = params;\n } else {\n super.setArrowFunctionParameters(node, params);\n }\n }\n\n checkParams(\n node: N.Function,\n allowDuplicates: boolean,\n isArrowFunction: ?boolean,\n ): void {\n if (\n isArrowFunction &&\n this.state.noArrowParamsConversionAt.indexOf(node.start) !== -1\n ) {\n return;\n }\n\n // ensure the `this` param is first, if it exists\n for (let i = 0; i < node.params.length; i++) {\n if (this.isThisParam(node.params[i]) && i > 0) {\n this.raise(node.params[i].start, FlowErrors.ThisParamMustBeFirst);\n }\n }\n\n return super.checkParams(...arguments);\n }\n\n parseParenAndDistinguishExpression(canBeArrow: boolean): N.Expression {\n return super.parseParenAndDistinguishExpression(\n canBeArrow && this.state.noArrowAt.indexOf(this.state.start) === -1,\n );\n }\n\n parseSubscripts(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls?: ?boolean,\n ): N.Expression {\n if (\n base.type === \"Identifier\" &&\n base.name === \"async\" &&\n this.state.noArrowAt.indexOf(startPos) !== -1\n ) {\n this.next();\n\n const node = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n base = this.finishNode(node, \"CallExpression\");\n } else if (\n base.type === \"Identifier\" &&\n base.name === \"async\" &&\n this.isRelational(\"<\")\n ) {\n const state = this.state.clone();\n const arrow = this.tryParse(\n abort =>\n this.parseAsyncArrowWithTypeParameters(startPos, startLoc) ||\n abort(),\n state,\n );\n\n if (!arrow.error && !arrow.aborted) return arrow.node;\n\n const result = this.tryParse(\n () => super.parseSubscripts(base, startPos, startLoc, noCalls),\n state,\n );\n\n if (result.node && !result.error) return result.node;\n\n if (arrow.node) {\n this.state = arrow.failState;\n return arrow.node;\n }\n\n if (result.node) {\n this.state = result.failState;\n return result.node;\n }\n\n throw arrow.error || result.error;\n }\n\n return super.parseSubscripts(base, startPos, startLoc, noCalls);\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n subscriptState: N.ParseSubscriptState,\n ): N.Expression {\n if (this.match(tt.questionDot) && this.isLookaheadToken_lt()) {\n subscriptState.optionalChainMember = true;\n if (noCalls) {\n subscriptState.stop = true;\n return base;\n }\n this.next();\n const node: N.OptionalCallExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n node.callee = base;\n node.typeArguments = this.flowParseTypeParameterInstantiation();\n this.expect(tt.parenL);\n // $FlowFixMe\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n node.optional = true;\n return this.finishCallExpression(node, /* optional */ true);\n } else if (\n !noCalls &&\n this.shouldParseTypes() &&\n this.isRelational(\"<\")\n ) {\n const node = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n\n const result = this.tryParse(() => {\n node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();\n this.expect(tt.parenL);\n node.arguments = this.parseCallExpressionArguments(tt.parenR, false);\n if (subscriptState.optionalChainMember) node.optional = false;\n return this.finishCallExpression(\n node,\n subscriptState.optionalChainMember,\n );\n });\n\n if (result.node) {\n if (result.error) this.state = result.failState;\n return result.node;\n }\n }\n\n return super.parseSubscript(\n base,\n startPos,\n startLoc,\n noCalls,\n subscriptState,\n );\n }\n\n parseNewArguments(node: N.NewExpression): void {\n let targs = null;\n if (this.shouldParseTypes() && this.isRelational(\"<\")) {\n targs = this.tryParse(() =>\n this.flowParseTypeParameterInstantiationCallOrNew(),\n ).node;\n }\n node.typeArguments = targs;\n\n super.parseNewArguments(node);\n }\n\n parseAsyncArrowWithTypeParameters(\n startPos: number,\n startLoc: Position,\n ): ?N.ArrowFunctionExpression {\n const node = this.startNodeAt(startPos, startLoc);\n this.parseFunctionParams(node);\n if (!this.parseArrow(node)) return;\n return this.parseArrowExpression(\n node,\n /* params */ undefined,\n /* isAsync */ true,\n );\n }\n\n readToken_mult_modulo(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (\n code === charCodes.asterisk &&\n next === charCodes.slash &&\n this.state.hasFlowComment\n ) {\n this.state.hasFlowComment = false;\n this.state.pos += 2;\n this.nextToken();\n return;\n }\n\n super.readToken_mult_modulo(code);\n }\n\n readToken_pipe_amp(code: number): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (\n code === charCodes.verticalBar &&\n next === charCodes.rightCurlyBrace\n ) {\n // '|}'\n this.finishOp(tt.braceBarR, 2);\n return;\n }\n\n super.readToken_pipe_amp(code);\n }\n\n parseTopLevel(file: N.File, program: N.Program): N.File {\n const fileNode = super.parseTopLevel(file, program);\n if (this.state.hasFlowComment) {\n this.raise(this.state.pos, FlowErrors.UnterminatedFlowComment);\n }\n return fileNode;\n }\n\n skipBlockComment(): void {\n if (this.hasPlugin(\"flowComments\") && this.skipFlowComment()) {\n if (this.state.hasFlowComment) {\n this.unexpected(null, FlowErrors.NestedFlowComment);\n }\n this.hasFlowCommentCompletion();\n this.state.pos += this.skipFlowComment();\n this.state.hasFlowComment = true;\n return;\n }\n\n if (this.state.hasFlowComment) {\n const end = this.input.indexOf(\"*-/\", (this.state.pos += 2));\n if (end === -1) {\n throw this.raise(this.state.pos - 2, Errors.UnterminatedComment);\n }\n this.state.pos = end + 3;\n return;\n }\n\n super.skipBlockComment();\n }\n\n skipFlowComment(): number | boolean {\n const { pos } = this.state;\n let shiftToFirstNonWhiteSpace = 2;\n while (\n [charCodes.space, charCodes.tab].includes(\n this.input.charCodeAt(pos + shiftToFirstNonWhiteSpace),\n )\n ) {\n shiftToFirstNonWhiteSpace++;\n }\n\n const ch2 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos);\n const ch3 = this.input.charCodeAt(shiftToFirstNonWhiteSpace + pos + 1);\n\n if (ch2 === charCodes.colon && ch3 === charCodes.colon) {\n return shiftToFirstNonWhiteSpace + 2; // check for /*::\n }\n if (\n this.input.slice(\n shiftToFirstNonWhiteSpace + pos,\n shiftToFirstNonWhiteSpace + pos + 12,\n ) === \"flow-include\"\n ) {\n return shiftToFirstNonWhiteSpace + 12; // check for /*flow-include\n }\n if (ch2 === charCodes.colon && ch3 !== charCodes.colon) {\n return shiftToFirstNonWhiteSpace; // check for /*:, advance up to :\n }\n return false;\n }\n\n hasFlowCommentCompletion(): void {\n const end = this.input.indexOf(\"*/\", this.state.pos);\n if (end === -1) {\n throw this.raise(this.state.pos, Errors.UnterminatedComment);\n }\n }\n\n // Flow enum parsing\n\n flowEnumErrorBooleanMemberNotInitialized(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumBooleanMemberNotInitialized,\n memberName,\n enumName,\n );\n }\n\n flowEnumErrorInvalidMemberName(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n const suggestion = memberName[0].toUpperCase() + memberName.slice(1);\n this.raise(\n pos,\n FlowErrors.EnumInvalidMemberName,\n memberName,\n suggestion,\n enumName,\n );\n }\n\n flowEnumErrorDuplicateMemberName(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(pos, FlowErrors.EnumDuplicateMemberName, memberName, enumName);\n }\n\n flowEnumErrorInconsistentMemberValues(\n pos: number,\n { enumName }: { enumName: string },\n ): void {\n this.raise(pos, FlowErrors.EnumInconsistentMemberValues, enumName);\n }\n\n flowEnumErrorInvalidExplicitType(\n pos: number,\n {\n enumName,\n suppliedType,\n }: { enumName: string, suppliedType: null | string },\n ) {\n return this.raise(\n pos,\n suppliedType === null\n ? FlowErrors.EnumInvalidExplicitTypeUnknownSupplied\n : FlowErrors.EnumInvalidExplicitType,\n enumName,\n suppliedType,\n );\n }\n\n flowEnumErrorInvalidMemberInitializer(\n pos: number,\n { enumName, explicitType, memberName }: EnumContext,\n ) {\n let message = null;\n switch (explicitType) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n message = FlowErrors.EnumInvalidMemberInitializerPrimaryType;\n break;\n case \"symbol\":\n message = FlowErrors.EnumInvalidMemberInitializerSymbolType;\n break;\n default:\n // null\n message = FlowErrors.EnumInvalidMemberInitializerUnknownType;\n }\n return this.raise(pos, message, enumName, memberName, explicitType);\n }\n\n flowEnumErrorNumberMemberNotInitialized(\n pos: number,\n { enumName, memberName }: { enumName: string, memberName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumNumberMemberNotInitialized,\n enumName,\n memberName,\n );\n }\n\n flowEnumErrorStringMemberInconsistentlyInitailized(\n pos: number,\n { enumName }: { enumName: string },\n ): void {\n this.raise(\n pos,\n FlowErrors.EnumStringMemberInconsistentlyInitailized,\n enumName,\n );\n }\n\n flowEnumMemberInit(): EnumMemberInit {\n const startPos = this.state.start;\n const endOfInit = () => this.match(tt.comma) || this.match(tt.braceR);\n switch (this.state.type) {\n case tt.num: {\n const literal = this.parseLiteral(this.state.value, \"NumericLiteral\");\n if (endOfInit()) {\n return { type: \"number\", pos: literal.start, value: literal };\n }\n return { type: \"invalid\", pos: startPos };\n }\n case tt.string: {\n const literal = this.parseLiteral(this.state.value, \"StringLiteral\");\n if (endOfInit()) {\n return { type: \"string\", pos: literal.start, value: literal };\n }\n return { type: \"invalid\", pos: startPos };\n }\n case tt._true:\n case tt._false: {\n const literal = this.parseBooleanLiteral();\n if (endOfInit()) {\n return {\n type: \"boolean\",\n pos: literal.start,\n value: literal,\n };\n }\n return { type: \"invalid\", pos: startPos };\n }\n default:\n return { type: \"invalid\", pos: startPos };\n }\n }\n\n flowEnumMemberRaw(): { id: N.Node, init: EnumMemberInit } {\n const pos = this.state.start;\n const id = this.parseIdentifier(true);\n const init = this.eat(tt.eq)\n ? this.flowEnumMemberInit()\n : { type: \"none\", pos };\n return { id, init };\n }\n\n flowEnumCheckExplicitTypeMismatch(\n pos: number,\n context: EnumContext,\n expectedType: EnumExplicitType,\n ): void {\n const { explicitType } = context;\n if (explicitType === null) {\n return;\n }\n if (explicitType !== expectedType) {\n this.flowEnumErrorInvalidMemberInitializer(pos, context);\n }\n }\n\n flowEnumMembers({\n enumName,\n explicitType,\n }: {\n enumName: string,\n explicitType: EnumExplicitType,\n }): {|\n members: {|\n booleanMembers: Array,\n numberMembers: Array,\n stringMembers: Array,\n defaultedMembers: Array,\n |},\n hasUnknownMembers: boolean,\n |} {\n const seenNames = new Set();\n const members = {\n booleanMembers: [],\n numberMembers: [],\n stringMembers: [],\n defaultedMembers: [],\n };\n let hasUnknownMembers = false;\n while (!this.match(tt.braceR)) {\n if (this.eat(tt.ellipsis)) {\n hasUnknownMembers = true;\n break;\n }\n const memberNode = this.startNode();\n const { id, init } = this.flowEnumMemberRaw();\n const memberName = id.name;\n if (memberName === \"\") {\n continue;\n }\n if (/^[a-z]/.test(memberName)) {\n this.flowEnumErrorInvalidMemberName(id.start, {\n enumName,\n memberName,\n });\n }\n if (seenNames.has(memberName)) {\n this.flowEnumErrorDuplicateMemberName(id.start, {\n enumName,\n memberName,\n });\n }\n seenNames.add(memberName);\n const context = { enumName, explicitType, memberName };\n memberNode.id = id;\n switch (init.type) {\n case \"boolean\": {\n this.flowEnumCheckExplicitTypeMismatch(\n init.pos,\n context,\n \"boolean\",\n );\n memberNode.init = init.value;\n members.booleanMembers.push(\n this.finishNode(memberNode, \"EnumBooleanMember\"),\n );\n break;\n }\n case \"number\": {\n this.flowEnumCheckExplicitTypeMismatch(init.pos, context, \"number\");\n memberNode.init = init.value;\n members.numberMembers.push(\n this.finishNode(memberNode, \"EnumNumberMember\"),\n );\n break;\n }\n case \"string\": {\n this.flowEnumCheckExplicitTypeMismatch(init.pos, context, \"string\");\n memberNode.init = init.value;\n members.stringMembers.push(\n this.finishNode(memberNode, \"EnumStringMember\"),\n );\n break;\n }\n case \"invalid\": {\n throw this.flowEnumErrorInvalidMemberInitializer(init.pos, context);\n }\n case \"none\": {\n switch (explicitType) {\n case \"boolean\":\n this.flowEnumErrorBooleanMemberNotInitialized(\n init.pos,\n context,\n );\n break;\n case \"number\":\n this.flowEnumErrorNumberMemberNotInitialized(init.pos, context);\n break;\n default:\n members.defaultedMembers.push(\n this.finishNode(memberNode, \"EnumDefaultedMember\"),\n );\n }\n }\n }\n\n if (!this.match(tt.braceR)) {\n this.expect(tt.comma);\n }\n }\n return { members, hasUnknownMembers };\n }\n\n flowEnumStringMembers(\n initializedMembers: Array,\n defaultedMembers: Array,\n { enumName }: { enumName: string },\n ): Array {\n if (initializedMembers.length === 0) {\n return defaultedMembers;\n } else if (defaultedMembers.length === 0) {\n return initializedMembers;\n } else if (defaultedMembers.length > initializedMembers.length) {\n for (const member of initializedMembers) {\n this.flowEnumErrorStringMemberInconsistentlyInitailized(\n member.start,\n { enumName },\n );\n }\n return defaultedMembers;\n } else {\n for (const member of defaultedMembers) {\n this.flowEnumErrorStringMemberInconsistentlyInitailized(\n member.start,\n { enumName },\n );\n }\n return initializedMembers;\n }\n }\n\n flowEnumParseExplicitType({\n enumName,\n }: {\n enumName: string,\n }): EnumExplicitType {\n if (this.eatContextual(\"of\")) {\n if (!this.match(tt.name)) {\n throw this.flowEnumErrorInvalidExplicitType(this.state.start, {\n enumName,\n suppliedType: null,\n });\n }\n\n const { value } = this.state;\n this.next();\n\n if (\n value !== \"boolean\" &&\n value !== \"number\" &&\n value !== \"string\" &&\n value !== \"symbol\"\n ) {\n this.flowEnumErrorInvalidExplicitType(this.state.start, {\n enumName,\n suppliedType: value,\n });\n }\n\n return value;\n }\n return null;\n }\n\n flowEnumBody(node: N.Node, { enumName, nameLoc }): N.Node {\n const explicitType = this.flowEnumParseExplicitType({ enumName });\n this.expect(tt.braceL);\n const { members, hasUnknownMembers } = this.flowEnumMembers({\n enumName,\n explicitType,\n });\n node.hasUnknownMembers = hasUnknownMembers;\n\n switch (explicitType) {\n case \"boolean\":\n node.explicitType = true;\n node.members = members.booleanMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumBooleanBody\");\n case \"number\":\n node.explicitType = true;\n node.members = members.numberMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumNumberBody\");\n case \"string\":\n node.explicitType = true;\n node.members = this.flowEnumStringMembers(\n members.stringMembers,\n members.defaultedMembers,\n { enumName },\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n case \"symbol\":\n node.members = members.defaultedMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumSymbolBody\");\n default: {\n // `explicitType` is `null`\n const empty = () => {\n node.members = [];\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n };\n node.explicitType = false;\n\n const boolsLen = members.booleanMembers.length;\n const numsLen = members.numberMembers.length;\n const strsLen = members.stringMembers.length;\n const defaultedLen = members.defaultedMembers.length;\n\n if (!boolsLen && !numsLen && !strsLen && !defaultedLen) {\n return empty();\n } else if (!boolsLen && !numsLen) {\n node.members = this.flowEnumStringMembers(\n members.stringMembers,\n members.defaultedMembers,\n { enumName },\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumStringBody\");\n } else if (!numsLen && !strsLen && boolsLen >= defaultedLen) {\n for (const member of members.defaultedMembers) {\n this.flowEnumErrorBooleanMemberNotInitialized(member.start, {\n enumName,\n memberName: member.id.name,\n });\n }\n node.members = members.booleanMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumBooleanBody\");\n } else if (!boolsLen && !strsLen && numsLen >= defaultedLen) {\n for (const member of members.defaultedMembers) {\n this.flowEnumErrorNumberMemberNotInitialized(member.start, {\n enumName,\n memberName: member.id.name,\n });\n }\n node.members = members.numberMembers;\n this.expect(tt.braceR);\n return this.finishNode(node, \"EnumNumberBody\");\n } else {\n this.flowEnumErrorInconsistentMemberValues(nameLoc, { enumName });\n return empty();\n }\n }\n }\n }\n\n flowParseEnumDeclaration(node: N.Node): N.Node {\n const id = this.parseIdentifier();\n node.id = id;\n node.body = this.flowEnumBody(this.startNode(), {\n enumName: id.name,\n nameLoc: id.start,\n });\n return this.finishNode(node, \"EnumDeclaration\");\n }\n\n updateContext(prevType: TokenType): void {\n if (\n this.match(tt.name) &&\n this.state.value === \"of\" &&\n prevType === tt.name &&\n this.input.slice(this.state.lastTokStart, this.state.lastTokEnd) ===\n \"interface\"\n ) {\n this.state.exprAllowed = false;\n } else {\n super.updateContext(prevType);\n }\n }\n\n // check if the next token is a tt.relation(\"<\")\n isLookaheadToken_lt(): boolean {\n const next = this.nextTokenStart();\n if (this.input.charCodeAt(next) === charCodes.lessThan) {\n const afterNext = this.input.charCodeAt(next + 1);\n return (\n afterNext !== charCodes.lessThan && afterNext !== charCodes.equalsTo\n );\n }\n return false;\n }\n\n maybeUnwrapTypeCastExpression(node: N.Node) {\n return node.type === \"TypeCastExpression\" ? node.expression : node;\n }\n };\n","// @flow\n\nconst entities: { [name: string]: string } = {\n quot: \"\\u0022\",\n amp: \"&\",\n apos: \"\\u0027\",\n lt: \"<\",\n gt: \">\",\n nbsp: \"\\u00A0\",\n iexcl: \"\\u00A1\",\n cent: \"\\u00A2\",\n pound: \"\\u00A3\",\n curren: \"\\u00A4\",\n yen: \"\\u00A5\",\n brvbar: \"\\u00A6\",\n sect: \"\\u00A7\",\n uml: \"\\u00A8\",\n copy: \"\\u00A9\",\n ordf: \"\\u00AA\",\n laquo: \"\\u00AB\",\n not: \"\\u00AC\",\n shy: \"\\u00AD\",\n reg: \"\\u00AE\",\n macr: \"\\u00AF\",\n deg: \"\\u00B0\",\n plusmn: \"\\u00B1\",\n sup2: \"\\u00B2\",\n sup3: \"\\u00B3\",\n acute: \"\\u00B4\",\n micro: \"\\u00B5\",\n para: \"\\u00B6\",\n middot: \"\\u00B7\",\n cedil: \"\\u00B8\",\n sup1: \"\\u00B9\",\n ordm: \"\\u00BA\",\n raquo: \"\\u00BB\",\n frac14: \"\\u00BC\",\n frac12: \"\\u00BD\",\n frac34: \"\\u00BE\",\n iquest: \"\\u00BF\",\n Agrave: \"\\u00C0\",\n Aacute: \"\\u00C1\",\n Acirc: \"\\u00C2\",\n Atilde: \"\\u00C3\",\n Auml: \"\\u00C4\",\n Aring: \"\\u00C5\",\n AElig: \"\\u00C6\",\n Ccedil: \"\\u00C7\",\n Egrave: \"\\u00C8\",\n Eacute: \"\\u00C9\",\n Ecirc: \"\\u00CA\",\n Euml: \"\\u00CB\",\n Igrave: \"\\u00CC\",\n Iacute: \"\\u00CD\",\n Icirc: \"\\u00CE\",\n Iuml: \"\\u00CF\",\n ETH: \"\\u00D0\",\n Ntilde: \"\\u00D1\",\n Ograve: \"\\u00D2\",\n Oacute: \"\\u00D3\",\n Ocirc: \"\\u00D4\",\n Otilde: \"\\u00D5\",\n Ouml: \"\\u00D6\",\n times: \"\\u00D7\",\n Oslash: \"\\u00D8\",\n Ugrave: \"\\u00D9\",\n Uacute: \"\\u00DA\",\n Ucirc: \"\\u00DB\",\n Uuml: \"\\u00DC\",\n Yacute: \"\\u00DD\",\n THORN: \"\\u00DE\",\n szlig: \"\\u00DF\",\n agrave: \"\\u00E0\",\n aacute: \"\\u00E1\",\n acirc: \"\\u00E2\",\n atilde: \"\\u00E3\",\n auml: \"\\u00E4\",\n aring: \"\\u00E5\",\n aelig: \"\\u00E6\",\n ccedil: \"\\u00E7\",\n egrave: \"\\u00E8\",\n eacute: \"\\u00E9\",\n ecirc: \"\\u00EA\",\n euml: \"\\u00EB\",\n igrave: \"\\u00EC\",\n iacute: \"\\u00ED\",\n icirc: \"\\u00EE\",\n iuml: \"\\u00EF\",\n eth: \"\\u00F0\",\n ntilde: \"\\u00F1\",\n ograve: \"\\u00F2\",\n oacute: \"\\u00F3\",\n ocirc: \"\\u00F4\",\n otilde: \"\\u00F5\",\n ouml: \"\\u00F6\",\n divide: \"\\u00F7\",\n oslash: \"\\u00F8\",\n ugrave: \"\\u00F9\",\n uacute: \"\\u00FA\",\n ucirc: \"\\u00FB\",\n uuml: \"\\u00FC\",\n yacute: \"\\u00FD\",\n thorn: \"\\u00FE\",\n yuml: \"\\u00FF\",\n OElig: \"\\u0152\",\n oelig: \"\\u0153\",\n Scaron: \"\\u0160\",\n scaron: \"\\u0161\",\n Yuml: \"\\u0178\",\n fnof: \"\\u0192\",\n circ: \"\\u02C6\",\n tilde: \"\\u02DC\",\n Alpha: \"\\u0391\",\n Beta: \"\\u0392\",\n Gamma: \"\\u0393\",\n Delta: \"\\u0394\",\n Epsilon: \"\\u0395\",\n Zeta: \"\\u0396\",\n Eta: \"\\u0397\",\n Theta: \"\\u0398\",\n Iota: \"\\u0399\",\n Kappa: \"\\u039A\",\n Lambda: \"\\u039B\",\n Mu: \"\\u039C\",\n Nu: \"\\u039D\",\n Xi: \"\\u039E\",\n Omicron: \"\\u039F\",\n Pi: \"\\u03A0\",\n Rho: \"\\u03A1\",\n Sigma: \"\\u03A3\",\n Tau: \"\\u03A4\",\n Upsilon: \"\\u03A5\",\n Phi: \"\\u03A6\",\n Chi: \"\\u03A7\",\n Psi: \"\\u03A8\",\n Omega: \"\\u03A9\",\n alpha: \"\\u03B1\",\n beta: \"\\u03B2\",\n gamma: \"\\u03B3\",\n delta: \"\\u03B4\",\n epsilon: \"\\u03B5\",\n zeta: \"\\u03B6\",\n eta: \"\\u03B7\",\n theta: \"\\u03B8\",\n iota: \"\\u03B9\",\n kappa: \"\\u03BA\",\n lambda: \"\\u03BB\",\n mu: \"\\u03BC\",\n nu: \"\\u03BD\",\n xi: \"\\u03BE\",\n omicron: \"\\u03BF\",\n pi: \"\\u03C0\",\n rho: \"\\u03C1\",\n sigmaf: \"\\u03C2\",\n sigma: \"\\u03C3\",\n tau: \"\\u03C4\",\n upsilon: \"\\u03C5\",\n phi: \"\\u03C6\",\n chi: \"\\u03C7\",\n psi: \"\\u03C8\",\n omega: \"\\u03C9\",\n thetasym: \"\\u03D1\",\n upsih: \"\\u03D2\",\n piv: \"\\u03D6\",\n ensp: \"\\u2002\",\n emsp: \"\\u2003\",\n thinsp: \"\\u2009\",\n zwnj: \"\\u200C\",\n zwj: \"\\u200D\",\n lrm: \"\\u200E\",\n rlm: \"\\u200F\",\n ndash: \"\\u2013\",\n mdash: \"\\u2014\",\n lsquo: \"\\u2018\",\n rsquo: \"\\u2019\",\n sbquo: \"\\u201A\",\n ldquo: \"\\u201C\",\n rdquo: \"\\u201D\",\n bdquo: \"\\u201E\",\n dagger: \"\\u2020\",\n Dagger: \"\\u2021\",\n bull: \"\\u2022\",\n hellip: \"\\u2026\",\n permil: \"\\u2030\",\n prime: \"\\u2032\",\n Prime: \"\\u2033\",\n lsaquo: \"\\u2039\",\n rsaquo: \"\\u203A\",\n oline: \"\\u203E\",\n frasl: \"\\u2044\",\n euro: \"\\u20AC\",\n image: \"\\u2111\",\n weierp: \"\\u2118\",\n real: \"\\u211C\",\n trade: \"\\u2122\",\n alefsym: \"\\u2135\",\n larr: \"\\u2190\",\n uarr: \"\\u2191\",\n rarr: \"\\u2192\",\n darr: \"\\u2193\",\n harr: \"\\u2194\",\n crarr: \"\\u21B5\",\n lArr: \"\\u21D0\",\n uArr: \"\\u21D1\",\n rArr: \"\\u21D2\",\n dArr: \"\\u21D3\",\n hArr: \"\\u21D4\",\n forall: \"\\u2200\",\n part: \"\\u2202\",\n exist: \"\\u2203\",\n empty: \"\\u2205\",\n nabla: \"\\u2207\",\n isin: \"\\u2208\",\n notin: \"\\u2209\",\n ni: \"\\u220B\",\n prod: \"\\u220F\",\n sum: \"\\u2211\",\n minus: \"\\u2212\",\n lowast: \"\\u2217\",\n radic: \"\\u221A\",\n prop: \"\\u221D\",\n infin: \"\\u221E\",\n ang: \"\\u2220\",\n and: \"\\u2227\",\n or: \"\\u2228\",\n cap: \"\\u2229\",\n cup: \"\\u222A\",\n int: \"\\u222B\",\n there4: \"\\u2234\",\n sim: \"\\u223C\",\n cong: \"\\u2245\",\n asymp: \"\\u2248\",\n ne: \"\\u2260\",\n equiv: \"\\u2261\",\n le: \"\\u2264\",\n ge: \"\\u2265\",\n sub: \"\\u2282\",\n sup: \"\\u2283\",\n nsub: \"\\u2284\",\n sube: \"\\u2286\",\n supe: \"\\u2287\",\n oplus: \"\\u2295\",\n otimes: \"\\u2297\",\n perp: \"\\u22A5\",\n sdot: \"\\u22C5\",\n lceil: \"\\u2308\",\n rceil: \"\\u2309\",\n lfloor: \"\\u230A\",\n rfloor: \"\\u230B\",\n lang: \"\\u2329\",\n rang: \"\\u232A\",\n loz: \"\\u25CA\",\n spades: \"\\u2660\",\n clubs: \"\\u2663\",\n hearts: \"\\u2665\",\n diams: \"\\u2666\",\n};\nexport default entities;\n","// @flow\n\n// Error messages are colocated with the plugin.\n/* eslint-disable @babel/development-internal/dry-error-messages */\n\nimport * as charCodes from \"charcodes\";\n\nimport XHTMLEntities from \"./xhtml\";\nimport type Parser from \"../../parser\";\nimport type { ExpressionErrors } from \"../../parser/util\";\nimport { TokenType, types as tt } from \"../../tokenizer/types\";\nimport { TokContext, types as tc } from \"../../tokenizer/context\";\nimport * as N from \"../../types\";\nimport { isIdentifierChar, isIdentifierStart } from \"../../util/identifier\";\nimport type { Position } from \"../../util/location\";\nimport { isNewLine } from \"../../util/whitespace\";\nimport { Errors } from \"../../parser/error\";\n\nconst HEX_NUMBER = /^[\\da-fA-F]+$/;\nconst DECIMAL_NUMBER = /^\\d+$/;\n\nconst JsxErrors = Object.freeze({\n AttributeIsEmpty:\n \"JSX attributes must only be assigned a non-empty expression\",\n MissingClosingTagFragment: \"Expected corresponding JSX closing tag for <>\",\n MissingClosingTagElement: \"Expected corresponding JSX closing tag for <%0>\",\n UnexpectedSequenceExpression:\n \"Sequence expressions cannot be directly nested inside JSX. Did you mean to wrap it in parentheses (...)?\",\n UnsupportedJsxValue:\n \"JSX value should be either an expression or a quoted JSX text\",\n UnterminatedJsxContent: \"Unterminated JSX contents\",\n UnwrappedAdjacentJSXElements:\n \"Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragment <>...>?\",\n});\n\n// Be aware that this file is always executed and not only when the plugin is enabled.\n// Therefore this contexts and tokens do always exist.\ntc.j_oTag = new TokContext(\"...\", true, true);\n\ntt.jsxName = new TokenType(\"jsxName\");\ntt.jsxText = new TokenType(\"jsxText\", { beforeExpr: true });\ntt.jsxTagStart = new TokenType(\"jsxTagStart\", { startsExpr: true });\ntt.jsxTagEnd = new TokenType(\"jsxTagEnd\");\n\ntt.jsxTagStart.updateContext = function () {\n this.state.context.push(tc.j_expr); // treat as beginning of JSX expression\n this.state.context.push(tc.j_oTag); // start opening tag context\n this.state.exprAllowed = false;\n};\n\ntt.jsxTagEnd.updateContext = function (prevType) {\n const out = this.state.context.pop();\n if ((out === tc.j_oTag && prevType === tt.slash) || out === tc.j_cTag) {\n this.state.context.pop();\n this.state.exprAllowed = this.curContext() === tc.j_expr;\n } else {\n this.state.exprAllowed = true;\n }\n};\n\nfunction isFragment(object: ?N.JSXElement): boolean {\n return object\n ? object.type === \"JSXOpeningFragment\" ||\n object.type === \"JSXClosingFragment\"\n : false;\n}\n\n// Transforms JSX element name to string.\n\nfunction getQualifiedJSXName(\n object: N.JSXIdentifier | N.JSXNamespacedName | N.JSXMemberExpression,\n): string {\n if (object.type === \"JSXIdentifier\") {\n return object.name;\n }\n\n if (object.type === \"JSXNamespacedName\") {\n return object.namespace.name + \":\" + object.name.name;\n }\n\n if (object.type === \"JSXMemberExpression\") {\n return (\n getQualifiedJSXName(object.object) +\n \".\" +\n getQualifiedJSXName(object.property)\n );\n }\n\n // istanbul ignore next\n throw new Error(\"Node had unexpected type: \" + object.type);\n}\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n // Reads inline JSX contents token.\n\n jsxReadToken(): void {\n let out = \"\";\n let chunkStart = this.state.pos;\n for (;;) {\n if (this.state.pos >= this.length) {\n throw this.raise(this.state.start, JsxErrors.UnterminatedJsxContent);\n }\n\n const ch = this.input.charCodeAt(this.state.pos);\n\n switch (ch) {\n case charCodes.lessThan:\n case charCodes.leftCurlyBrace:\n if (this.state.pos === this.state.start) {\n if (ch === charCodes.lessThan && this.state.exprAllowed) {\n ++this.state.pos;\n return this.finishToken(tt.jsxTagStart);\n }\n return super.getTokenFromCode(ch);\n }\n out += this.input.slice(chunkStart, this.state.pos);\n return this.finishToken(tt.jsxText, out);\n\n case charCodes.ampersand:\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadEntity();\n chunkStart = this.state.pos;\n break;\n\n case charCodes.greaterThan:\n case charCodes.rightCurlyBrace:\n if (process.env.BABEL_8_BREAKING) {\n const htmlEntity =\n ch === charCodes.rightCurlyBrace ? \"}\" : \">\";\n const char = this.input[this.state.pos];\n this.raise(\n this.state.pos,\n `Unexpected token \\`${char}\\`. Did you mean \\`${htmlEntity}\\` or \\`{'${char}'}\\`?`,\n );\n }\n /* falls through */\n\n default:\n if (isNewLine(ch)) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadNewLine(true);\n chunkStart = this.state.pos;\n } else {\n ++this.state.pos;\n }\n }\n }\n }\n\n jsxReadNewLine(normalizeCRLF: boolean): string {\n const ch = this.input.charCodeAt(this.state.pos);\n let out;\n ++this.state.pos;\n if (\n ch === charCodes.carriageReturn &&\n this.input.charCodeAt(this.state.pos) === charCodes.lineFeed\n ) {\n ++this.state.pos;\n out = normalizeCRLF ? \"\\n\" : \"\\r\\n\";\n } else {\n out = String.fromCharCode(ch);\n }\n ++this.state.curLine;\n this.state.lineStart = this.state.pos;\n\n return out;\n }\n\n jsxReadString(quote: number): void {\n let out = \"\";\n let chunkStart = ++this.state.pos;\n for (;;) {\n if (this.state.pos >= this.length) {\n throw this.raise(this.state.start, Errors.UnterminatedString);\n }\n\n const ch = this.input.charCodeAt(this.state.pos);\n if (ch === quote) break;\n if (ch === charCodes.ampersand) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadEntity();\n chunkStart = this.state.pos;\n } else if (isNewLine(ch)) {\n out += this.input.slice(chunkStart, this.state.pos);\n out += this.jsxReadNewLine(false);\n chunkStart = this.state.pos;\n } else {\n ++this.state.pos;\n }\n }\n out += this.input.slice(chunkStart, this.state.pos++);\n return this.finishToken(tt.string, out);\n }\n\n jsxReadEntity(): string {\n let str = \"\";\n let count = 0;\n let entity;\n let ch = this.input[this.state.pos];\n\n const startPos = ++this.state.pos;\n while (this.state.pos < this.length && count++ < 10) {\n ch = this.input[this.state.pos++];\n if (ch === \";\") {\n if (str[0] === \"#\") {\n if (str[1] === \"x\") {\n str = str.substr(2);\n if (HEX_NUMBER.test(str)) {\n entity = String.fromCodePoint(parseInt(str, 16));\n }\n } else {\n str = str.substr(1);\n if (DECIMAL_NUMBER.test(str)) {\n entity = String.fromCodePoint(parseInt(str, 10));\n }\n }\n } else {\n entity = XHTMLEntities[str];\n }\n break;\n }\n str += ch;\n }\n if (!entity) {\n this.state.pos = startPos;\n return \"&\";\n }\n return entity;\n }\n\n // Read a JSX identifier (valid tag or attribute name).\n //\n // Optimized version since JSX identifiers can\"t contain\n // escape characters and so can be read as single slice.\n // Also assumes that first character was already checked\n // by isIdentifierStart in readToken.\n\n jsxReadWord(): void {\n let ch;\n const start = this.state.pos;\n do {\n ch = this.input.charCodeAt(++this.state.pos);\n } while (isIdentifierChar(ch) || ch === charCodes.dash);\n return this.finishToken(\n tt.jsxName,\n this.input.slice(start, this.state.pos),\n );\n }\n\n // Parse next token as JSX identifier\n\n jsxParseIdentifier(): N.JSXIdentifier {\n const node = this.startNode();\n if (this.match(tt.jsxName)) {\n node.name = this.state.value;\n } else if (this.state.type.keyword) {\n node.name = this.state.type.keyword;\n } else {\n this.unexpected();\n }\n this.next();\n return this.finishNode(node, \"JSXIdentifier\");\n }\n\n // Parse namespaced identifier.\n\n jsxParseNamespacedName(): N.JSXNamespacedName {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n const name = this.jsxParseIdentifier();\n if (!this.eat(tt.colon)) return name;\n\n const node = this.startNodeAt(startPos, startLoc);\n node.namespace = name;\n node.name = this.jsxParseIdentifier();\n return this.finishNode(node, \"JSXNamespacedName\");\n }\n\n // Parses element name in any form - namespaced, member\n // or single identifier.\n\n jsxParseElementName():\n | N.JSXIdentifier\n | N.JSXNamespacedName\n | N.JSXMemberExpression {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n let node = this.jsxParseNamespacedName();\n if (node.type === \"JSXNamespacedName\") {\n return node;\n }\n while (this.eat(tt.dot)) {\n const newNode = this.startNodeAt(startPos, startLoc);\n newNode.object = node;\n newNode.property = this.jsxParseIdentifier();\n node = this.finishNode(newNode, \"JSXMemberExpression\");\n }\n return node;\n }\n\n // Parses any type of JSX attribute value.\n\n jsxParseAttributeValue(): N.Expression {\n let node;\n switch (this.state.type) {\n case tt.braceL:\n node = this.startNode();\n this.next();\n node = this.jsxParseExpressionContainer(node);\n if (node.expression.type === \"JSXEmptyExpression\") {\n this.raise(node.start, JsxErrors.AttributeIsEmpty);\n }\n return node;\n\n case tt.jsxTagStart:\n case tt.string:\n return this.parseExprAtom();\n\n default:\n throw this.raise(this.state.start, JsxErrors.UnsupportedJsxValue);\n }\n }\n\n // JSXEmptyExpression is unique type since it doesn't actually parse anything,\n // and so it should start at the end of last read token (left brace) and finish\n // at the beginning of the next one (right brace).\n\n jsxParseEmptyExpression(): N.JSXEmptyExpression {\n const node = this.startNodeAt(\n this.state.lastTokEnd,\n this.state.lastTokEndLoc,\n );\n return this.finishNodeAt(\n node,\n \"JSXEmptyExpression\",\n this.state.start,\n this.state.startLoc,\n );\n }\n\n // Parse JSX spread child\n\n jsxParseSpreadChild(node: N.JSXSpreadChild): N.JSXSpreadChild {\n this.next(); // ellipsis\n node.expression = this.parseExpression();\n this.expect(tt.braceR);\n\n return this.finishNode(node, \"JSXSpreadChild\");\n }\n\n // Parses JSX expression enclosed into curly brackets.\n\n jsxParseExpressionContainer(\n node: N.JSXExpressionContainer,\n ): N.JSXExpressionContainer {\n if (this.match(tt.braceR)) {\n node.expression = this.jsxParseEmptyExpression();\n } else {\n const expression = this.parseExpression();\n\n if (process.env.BABEL_8_BREAKING) {\n if (\n expression.type === \"SequenceExpression\" &&\n !expression.extra?.parenthesized\n ) {\n this.raise(\n expression.expressions[1].start,\n JsxErrors.UnexpectedSequenceExpression,\n );\n }\n }\n\n node.expression = expression;\n }\n this.expect(tt.braceR);\n\n return this.finishNode(node, \"JSXExpressionContainer\");\n }\n\n // Parses following JSX attribute name-value pair.\n\n jsxParseAttribute(): N.JSXAttribute {\n const node = this.startNode();\n if (this.eat(tt.braceL)) {\n this.expect(tt.ellipsis);\n node.argument = this.parseMaybeAssignAllowIn();\n this.expect(tt.braceR);\n return this.finishNode(node, \"JSXSpreadAttribute\");\n }\n node.name = this.jsxParseNamespacedName();\n node.value = this.eat(tt.eq) ? this.jsxParseAttributeValue() : null;\n return this.finishNode(node, \"JSXAttribute\");\n }\n\n // Parses JSX opening tag starting after \"<\".\n\n jsxParseOpeningElementAt(\n startPos: number,\n startLoc: Position,\n ): N.JSXOpeningElement {\n const node = this.startNodeAt(startPos, startLoc);\n if (this.match(tt.jsxTagEnd)) {\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXOpeningFragment\");\n }\n node.name = this.jsxParseElementName();\n return this.jsxParseOpeningElementAfterName(node);\n }\n\n jsxParseOpeningElementAfterName(\n node: N.JSXOpeningElement,\n ): N.JSXOpeningElement {\n const attributes: N.JSXAttribute[] = [];\n while (!this.match(tt.slash) && !this.match(tt.jsxTagEnd)) {\n attributes.push(this.jsxParseAttribute());\n }\n node.attributes = attributes;\n node.selfClosing = this.eat(tt.slash);\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXOpeningElement\");\n }\n\n // Parses JSX closing tag starting after \"\".\n\n jsxParseClosingElementAt(\n startPos: number,\n startLoc: Position,\n ): N.JSXClosingElement {\n const node = this.startNodeAt(startPos, startLoc);\n if (this.match(tt.jsxTagEnd)) {\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXClosingFragment\");\n }\n node.name = this.jsxParseElementName();\n this.expect(tt.jsxTagEnd);\n return this.finishNode(node, \"JSXClosingElement\");\n }\n\n // Parses entire JSX element, including it\"s opening tag\n // (starting after \"<\"), attributes, contents and closing tag.\n\n jsxParseElementAt(startPos: number, startLoc: Position): N.JSXElement {\n const node = this.startNodeAt(startPos, startLoc);\n const children = [];\n const openingElement = this.jsxParseOpeningElementAt(startPos, startLoc);\n let closingElement = null;\n\n if (!openingElement.selfClosing) {\n contents: for (;;) {\n switch (this.state.type) {\n case tt.jsxTagStart:\n startPos = this.state.start;\n startLoc = this.state.startLoc;\n this.next();\n if (this.eat(tt.slash)) {\n closingElement = this.jsxParseClosingElementAt(\n startPos,\n startLoc,\n );\n break contents;\n }\n children.push(this.jsxParseElementAt(startPos, startLoc));\n break;\n\n case tt.jsxText:\n children.push(this.parseExprAtom());\n break;\n\n case tt.braceL: {\n const node = this.startNode();\n this.next();\n if (this.match(tt.ellipsis)) {\n children.push(this.jsxParseSpreadChild(node));\n } else {\n children.push(this.jsxParseExpressionContainer(node));\n }\n\n break;\n }\n // istanbul ignore next - should never happen\n default:\n throw this.unexpected();\n }\n }\n\n if (isFragment(openingElement) && !isFragment(closingElement)) {\n this.raise(\n // $FlowIgnore\n closingElement.start,\n JsxErrors.MissingClosingTagFragment,\n );\n } else if (!isFragment(openingElement) && isFragment(closingElement)) {\n this.raise(\n // $FlowIgnore\n closingElement.start,\n JsxErrors.MissingClosingTagElement,\n getQualifiedJSXName(openingElement.name),\n );\n } else if (!isFragment(openingElement) && !isFragment(closingElement)) {\n if (\n // $FlowIgnore\n getQualifiedJSXName(closingElement.name) !==\n getQualifiedJSXName(openingElement.name)\n ) {\n this.raise(\n // $FlowIgnore\n closingElement.start,\n JsxErrors.MissingClosingTagElement,\n getQualifiedJSXName(openingElement.name),\n );\n }\n }\n }\n\n if (isFragment(openingElement)) {\n node.openingFragment = openingElement;\n node.closingFragment = closingElement;\n } else {\n node.openingElement = openingElement;\n node.closingElement = closingElement;\n }\n node.children = children;\n if (this.isRelational(\"<\")) {\n throw this.raise(\n this.state.start,\n JsxErrors.UnwrappedAdjacentJSXElements,\n );\n }\n\n return isFragment(openingElement)\n ? this.finishNode(node, \"JSXFragment\")\n : this.finishNode(node, \"JSXElement\");\n }\n\n // Parses entire JSX element from current position.\n\n jsxParseElement(): N.JSXElement {\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n this.next();\n return this.jsxParseElementAt(startPos, startLoc);\n }\n\n // ==================================\n // Overrides\n // ==================================\n\n parseExprAtom(refExpressionErrors: ?ExpressionErrors): N.Expression {\n if (this.match(tt.jsxText)) {\n return this.parseLiteral(this.state.value, \"JSXText\");\n } else if (this.match(tt.jsxTagStart)) {\n return this.jsxParseElement();\n } else if (\n this.isRelational(\"<\") &&\n this.input.charCodeAt(this.state.pos) !== charCodes.exclamationMark\n ) {\n // In case we encounter an lt token here it will always be the start of\n // jsx as the lt sign is not allowed in places that expect an expression\n this.finishToken(tt.jsxTagStart);\n return this.jsxParseElement();\n } else {\n return super.parseExprAtom(refExpressionErrors);\n }\n }\n\n getTokenFromCode(code: number): void {\n if (this.state.inPropertyName) return super.getTokenFromCode(code);\n\n const context = this.curContext();\n\n if (context === tc.j_expr) {\n return this.jsxReadToken();\n }\n\n if (context === tc.j_oTag || context === tc.j_cTag) {\n if (isIdentifierStart(code)) {\n return this.jsxReadWord();\n }\n\n if (code === charCodes.greaterThan) {\n ++this.state.pos;\n return this.finishToken(tt.jsxTagEnd);\n }\n\n if (\n (code === charCodes.quotationMark || code === charCodes.apostrophe) &&\n context === tc.j_oTag\n ) {\n return this.jsxReadString(code);\n }\n }\n\n if (\n code === charCodes.lessThan &&\n this.state.exprAllowed &&\n this.input.charCodeAt(this.state.pos + 1) !== charCodes.exclamationMark\n ) {\n ++this.state.pos;\n return this.finishToken(tt.jsxTagStart);\n }\n\n return super.getTokenFromCode(code);\n }\n\n updateContext(prevType: TokenType): void {\n if (this.match(tt.braceL)) {\n const curContext = this.curContext();\n if (curContext === tc.j_oTag) {\n this.state.context.push(tc.braceExpression);\n } else if (curContext === tc.j_expr) {\n this.state.context.push(tc.templateQuasi);\n } else {\n super.updateContext(prevType);\n }\n this.state.exprAllowed = true;\n } else if (this.match(tt.slash) && prevType === tt.jsxTagStart) {\n this.state.context.length -= 2; // do not consider JSX expr -> JSX open tag -> ... anymore\n this.state.context.push(tc.j_cTag); // reconsider as closing tag context\n this.state.exprAllowed = false;\n } else {\n return super.updateContext(prevType);\n }\n }\n };\n","// @flow\n\nimport ScopeHandler, { Scope } from \"../../util/scope\";\nimport {\n BIND_KIND_TYPE,\n BIND_FLAGS_TS_ENUM,\n BIND_FLAGS_TS_CONST_ENUM,\n BIND_FLAGS_TS_EXPORT_ONLY,\n BIND_KIND_VALUE,\n BIND_FLAGS_CLASS,\n type ScopeFlags,\n type BindingTypes,\n} from \"../../util/scopeflags\";\nimport * as N from \"../../types\";\n\nclass TypeScriptScope extends Scope {\n types: string[] = [];\n\n // enums (which are also in .types)\n enums: string[] = [];\n\n // const enums (which are also in .enums and .types)\n constEnums: string[] = [];\n\n // classes (which are also in .lexical) and interface (which are also in .types)\n classes: string[] = [];\n\n // namespaces and ambient functions (or classes) are too difficult to track,\n // especially without type analysis.\n // We need to track them anyway, to avoid \"X is not defined\" errors\n // when exporting them.\n exportOnlyBindings: string[] = [];\n}\n\n// See https://github.com/babel/babel/pull/9766#discussion_r268920730 for an\n// explanation of how typescript handles scope.\n\nexport default class TypeScriptScopeHandler extends ScopeHandler {\n createScope(flags: ScopeFlags): TypeScriptScope {\n return new TypeScriptScope(flags);\n }\n\n declareName(name: string, bindingType: BindingTypes, pos: number) {\n const scope = this.currentScope();\n if (bindingType & BIND_FLAGS_TS_EXPORT_ONLY) {\n this.maybeExportDefined(scope, name);\n scope.exportOnlyBindings.push(name);\n return;\n }\n\n super.declareName(...arguments);\n\n if (bindingType & BIND_KIND_TYPE) {\n if (!(bindingType & BIND_KIND_VALUE)) {\n // \"Value\" bindings have already been registered by the superclass.\n this.checkRedeclarationInScope(scope, name, bindingType, pos);\n this.maybeExportDefined(scope, name);\n }\n scope.types.push(name);\n }\n if (bindingType & BIND_FLAGS_TS_ENUM) scope.enums.push(name);\n if (bindingType & BIND_FLAGS_TS_CONST_ENUM) scope.constEnums.push(name);\n if (bindingType & BIND_FLAGS_CLASS) scope.classes.push(name);\n }\n\n isRedeclaredInScope(\n scope: TypeScriptScope,\n name: string,\n bindingType: BindingTypes,\n ): boolean {\n if (scope.enums.indexOf(name) > -1) {\n if (bindingType & BIND_FLAGS_TS_ENUM) {\n // Enums can be merged with other enums if they are both\n // const or both non-const.\n const isConst = !!(bindingType & BIND_FLAGS_TS_CONST_ENUM);\n const wasConst = scope.constEnums.indexOf(name) > -1;\n return isConst !== wasConst;\n }\n return true;\n }\n if (bindingType & BIND_FLAGS_CLASS && scope.classes.indexOf(name) > -1) {\n if (scope.lexical.indexOf(name) > -1) {\n // Classes can be merged with interfaces\n return !!(bindingType & BIND_KIND_VALUE);\n } else {\n // Interface can be merged with other classes or interfaces\n return false;\n }\n }\n if (bindingType & BIND_KIND_TYPE && scope.types.indexOf(name) > -1) {\n return true;\n }\n\n return super.isRedeclaredInScope(...arguments);\n }\n\n checkLocalExport(id: N.Identifier) {\n if (\n this.scopeStack[0].types.indexOf(id.name) === -1 &&\n this.scopeStack[0].exportOnlyBindings.indexOf(id.name) === -1\n ) {\n super.checkLocalExport(id);\n }\n }\n}\n","// @flow\nexport const PARAM = 0b0000, // Initial Parameter flags\n PARAM_YIELD = 0b0001, // track [Yield] production parameter\n PARAM_AWAIT = 0b0010, // track [Await] production parameter\n PARAM_RETURN = 0b0100, // track [Return] production parameter\n PARAM_IN = 0b1000; // track [In] production parameter\n\n// ProductionParameterHandler is a stack fashioned production parameter tracker\n// https://tc39.es/ecma262/#sec-grammar-notation\n// The tracked parameters are defined above.\n//\n// Whenever [+Await]/[+Yield] appears in the right-hand sides of a production,\n// we must enter a new tracking stack. For example when parsing\n//\n// AsyncFunctionDeclaration [Yield, Await]:\n// async [no LineTerminator here] function BindingIdentifier[?Yield, ?Await]\n// ( FormalParameters[~Yield, +Await] ) { AsyncFunctionBody }\n//\n// we must follow such process:\n//\n// 1. parse async keyword\n// 2. parse function keyword\n// 3. parse bindingIdentifier <= inherit current parameters: [?Await]\n// 4. enter new stack with (PARAM_AWAIT)\n// 5. parse formal parameters <= must have [Await] parameter [+Await]\n// 6. parse function body\n// 7. exit current stack\n\nexport type ParamKind =\n | typeof PARAM\n | typeof PARAM_AWAIT\n | typeof PARAM_IN\n | typeof PARAM_RETURN\n | typeof PARAM_YIELD;\n\nexport default class ProductionParameterHandler {\n stacks: Array = [];\n enter(flags: ParamKind) {\n this.stacks.push(flags);\n }\n\n exit() {\n this.stacks.pop();\n }\n\n currentFlags(): ParamKind {\n return this.stacks[this.stacks.length - 1];\n }\n\n get hasAwait(): boolean {\n return (this.currentFlags() & PARAM_AWAIT) > 0;\n }\n\n get hasYield(): boolean {\n return (this.currentFlags() & PARAM_YIELD) > 0;\n }\n\n get hasReturn(): boolean {\n return (this.currentFlags() & PARAM_RETURN) > 0;\n }\n\n get hasIn(): boolean {\n return (this.currentFlags() & PARAM_IN) > 0;\n }\n}\n\nexport function functionFlags(\n isAsync: boolean,\n isGenerator: boolean,\n): ParamKind {\n return (isAsync ? PARAM_AWAIT : 0) | (isGenerator ? PARAM_YIELD : 0);\n}\n","// @flow\n\n/*:: declare var invariant; */\n\n// Error messages are colocated with the plugin.\n/* eslint-disable @babel/development-internal/dry-error-messages */\n\nimport type { TokenType } from \"../../tokenizer/types\";\nimport type State from \"../../tokenizer/state\";\nimport { types as tt } from \"../../tokenizer/types\";\nimport { types as ct } from \"../../tokenizer/context\";\nimport * as N from \"../../types\";\nimport type { Pos, Position } from \"../../util/location\";\nimport type Parser from \"../../parser\";\nimport {\n type BindingTypes,\n SCOPE_TS_MODULE,\n SCOPE_OTHER,\n BIND_TS_ENUM,\n BIND_TS_CONST_ENUM,\n BIND_TS_TYPE,\n BIND_TS_INTERFACE,\n BIND_TS_AMBIENT,\n BIND_TS_NAMESPACE,\n BIND_CLASS,\n BIND_LEXICAL,\n} from \"../../util/scopeflags\";\nimport TypeScriptScopeHandler from \"./scope\";\nimport * as charCodes from \"charcodes\";\nimport type { ExpressionErrors } from \"../../parser/util\";\nimport { PARAM } from \"../../util/production-parameter\";\nimport { Errors } from \"../../parser/error\";\n\ntype TsModifier =\n | \"readonly\"\n | \"abstract\"\n | \"declare\"\n | \"static\"\n | N.Accessibility;\n\nfunction nonNull(x: ?T): T {\n if (x == null) {\n // $FlowIgnore\n throw new Error(`Unexpected ${x} value.`);\n }\n return x;\n}\n\nfunction assert(x: boolean): void {\n if (!x) {\n throw new Error(\"Assert fail\");\n }\n}\n\ntype ParsingContext =\n | \"EnumMembers\"\n | \"HeritageClauseElement\"\n | \"TupleElementTypes\"\n | \"TypeMembers\"\n | \"TypeParametersOrArguments\";\n\nconst TSErrors = Object.freeze({\n ClassMethodHasDeclare: \"Class methods cannot have the 'declare' modifier\",\n ClassMethodHasReadonly: \"Class methods cannot have the 'readonly' modifier\",\n ConstructorHasTypeParameters:\n \"Type parameters cannot appear on a constructor declaration.\",\n DeclareClassFieldHasInitializer:\n \"Initializers are not allowed in ambient contexts.\",\n DeclareFunctionHasImplementation:\n \"An implementation cannot be declared in ambient contexts.\",\n DuplicateModifier: \"Duplicate modifier: '%0'\",\n DuplicateAccessibilityModifier: \"Accessibility modifier already seen.\",\n EmptyHeritageClauseType: \"'%0' list cannot be empty.\",\n EmptyTypeArguments: \"Type argument list cannot be empty.\",\n EmptyTypeParameters: \"Type parameter list cannot be empty.\",\n ExpectedAmbientAfterExportDeclare:\n \"'export declare' must be followed by an ambient declaration.\",\n IndexSignatureHasAbstract:\n \"Index signatures cannot have the 'abstract' modifier\",\n IndexSignatureHasAccessibility:\n \"Index signatures cannot have an accessibility modifier ('%0')\",\n IndexSignatureHasStatic: \"Index signatures cannot have the 'static' modifier\",\n IndexSignatureHasDeclare:\n \"Index signatures cannot have the 'declare' modifier\",\n InvalidModifierOnTypeMember: \"'%0' modifier cannot appear on a type member.\",\n InvalidTupleMemberLabel:\n \"Tuple members must be labeled with a simple identifier.\",\n MixedLabeledAndUnlabeledElements:\n \"Tuple members must all have names or all not have names.\",\n NonAbstractClassHasAbstractMethod:\n \"Abstract methods can only appear within an abstract class.\",\n NonClassMethodPropertyHasAbstractModifer:\n \"'abstract' modifier can only appear on a class, method, or property declaration.\",\n OptionalTypeBeforeRequired:\n \"A required element cannot follow an optional element.\",\n PatternIsOptional:\n \"A binding pattern parameter cannot be optional in an implementation signature.\",\n PrivateElementHasAbstract:\n \"Private elements cannot have the 'abstract' modifier.\",\n PrivateElementHasAccessibility:\n \"Private elements cannot have an accessibility modifier ('%0')\",\n ReadonlyForMethodSignature:\n \"'readonly' modifier can only appear on a property declaration or index signature.\",\n TypeAnnotationAfterAssign:\n \"Type annotations must come before default assignments, e.g. instead of `age = 25: number` use `age: number = 25`\",\n UnexpectedParameterModifier:\n \"A parameter property is only allowed in a constructor implementation.\",\n UnexpectedReadonly:\n \"'readonly' type modifier is only permitted on array and tuple literal types.\",\n UnexpectedTypeAnnotation: \"Did not expect a type annotation here.\",\n UnexpectedTypeCastInParameter: \"Unexpected type cast in parameter position.\",\n UnsupportedImportTypeArgument:\n \"Argument in a type import must be a string literal\",\n UnsupportedParameterPropertyKind:\n \"A parameter property may not be declared using a binding pattern.\",\n UnsupportedSignatureParameterKind:\n \"Name in a signature must be an Identifier, ObjectPattern or ArrayPattern, instead got %0\",\n});\n\n// Doesn't handle \"void\" or \"null\" because those are keywords, not identifiers.\n// It also doesn't handle \"intrinsic\", since usually it's not a keyword.\nfunction keywordTypeFromName(\n value: string,\n): N.TsKeywordTypeType | typeof undefined {\n switch (value) {\n case \"any\":\n return \"TSAnyKeyword\";\n case \"boolean\":\n return \"TSBooleanKeyword\";\n case \"bigint\":\n return \"TSBigIntKeyword\";\n case \"never\":\n return \"TSNeverKeyword\";\n case \"number\":\n return \"TSNumberKeyword\";\n case \"object\":\n return \"TSObjectKeyword\";\n case \"string\":\n return \"TSStringKeyword\";\n case \"symbol\":\n return \"TSSymbolKeyword\";\n case \"undefined\":\n return \"TSUndefinedKeyword\";\n case \"unknown\":\n return \"TSUnknownKeyword\";\n default:\n return undefined;\n }\n}\n\nfunction tsIsAccessModifier(modifier: string): boolean %checks {\n return (\n modifier === \"private\" || modifier === \"public\" || modifier === \"protected\"\n );\n}\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n getScopeHandler(): Class {\n return TypeScriptScopeHandler;\n }\n\n tsIsIdentifier(): boolean {\n // TODO: actually a bit more complex in TypeScript, but shouldn't matter.\n // See https://github.com/Microsoft/TypeScript/issues/15008\n return this.match(tt.name);\n }\n\n tsNextTokenCanFollowModifier() {\n // Note: TypeScript's implementation is much more complicated because\n // more things are considered modifiers there.\n // This implementation only handles modifiers not handled by @babel/parser itself. And \"static\".\n // TODO: Would be nice to avoid lookahead. Want a hasLineBreakUpNext() method...\n this.next();\n return (\n (this.match(tt.bracketL) ||\n this.match(tt.braceL) ||\n this.match(tt.star) ||\n this.match(tt.ellipsis) ||\n this.match(tt.hash) ||\n this.isLiteralPropertyName()) &&\n !this.hasPrecedingLineBreak()\n );\n }\n\n /** Parses a modifier matching one the given modifier names. */\n tsParseModifier(allowedModifiers: T[]): ?T {\n if (!this.match(tt.name)) {\n return undefined;\n }\n\n const modifier = this.state.value;\n if (\n allowedModifiers.indexOf(modifier) !== -1 &&\n this.tsTryParse(this.tsNextTokenCanFollowModifier.bind(this))\n ) {\n return modifier;\n }\n return undefined;\n }\n\n /** Parses a list of modifiers, in any order.\n * If you need a specific order, you must call this function multiple times:\n * this.tsParseModifiers(node, [\"public\"]);\n * this.tsParseModifiers(node, [\"abstract\", \"readonly\"]);\n */\n tsParseModifiers(\n modified: {\n [key: TsModifier]: ?true,\n accessibility?: N.Accessibility,\n },\n allowedModifiers: TsModifier[],\n disallowedModifiers?: TsModifier[],\n errorTemplate?: string,\n ): void {\n for (;;) {\n const startPos = this.state.start;\n const modifier: ?TsModifier = this.tsParseModifier(\n allowedModifiers.concat(disallowedModifiers ?? []),\n );\n\n if (!modifier) break;\n\n if (tsIsAccessModifier(modifier)) {\n if (modified.accessibility) {\n this.raise(startPos, TSErrors.DuplicateAccessibilityModifier);\n } else {\n modified.accessibility = modifier;\n }\n } else {\n if (Object.hasOwnProperty.call(modified, modifier)) {\n this.raise(startPos, TSErrors.DuplicateModifier, modifier);\n }\n modified[modifier] = true;\n }\n\n if (disallowedModifiers?.includes(modifier)) {\n this.raise(\n startPos,\n // $FlowIgnore\n errorTemplate,\n modifier,\n );\n }\n }\n }\n\n tsIsListTerminator(kind: ParsingContext): boolean {\n switch (kind) {\n case \"EnumMembers\":\n case \"TypeMembers\":\n return this.match(tt.braceR);\n case \"HeritageClauseElement\":\n return this.match(tt.braceL);\n case \"TupleElementTypes\":\n return this.match(tt.bracketR);\n case \"TypeParametersOrArguments\":\n return this.isRelational(\">\");\n }\n\n throw new Error(\"Unreachable\");\n }\n\n tsParseList(kind: ParsingContext, parseElement: () => T): T[] {\n const result: T[] = [];\n while (!this.tsIsListTerminator(kind)) {\n // Skipping \"parseListElement\" from the TS source since that's just for error handling.\n result.push(parseElement());\n }\n return result;\n }\n\n tsParseDelimitedList(\n kind: ParsingContext,\n parseElement: () => T,\n ): T[] {\n return nonNull(\n this.tsParseDelimitedListWorker(\n kind,\n parseElement,\n /* expectSuccess */ true,\n ),\n );\n }\n\n /**\n * If !expectSuccess, returns undefined instead of failing to parse.\n * If expectSuccess, parseElement should always return a defined value.\n */\n tsParseDelimitedListWorker(\n kind: ParsingContext,\n parseElement: () => ?T,\n expectSuccess: boolean,\n ): ?(T[]) {\n const result = [];\n\n for (;;) {\n if (this.tsIsListTerminator(kind)) {\n break;\n }\n\n const element = parseElement();\n if (element == null) {\n return undefined;\n }\n result.push(element);\n\n if (this.eat(tt.comma)) {\n continue;\n }\n\n if (this.tsIsListTerminator(kind)) {\n break;\n }\n\n if (expectSuccess) {\n // This will fail with an error about a missing comma\n this.expect(tt.comma);\n }\n return undefined;\n }\n\n return result;\n }\n\n tsParseBracketedList(\n kind: ParsingContext,\n parseElement: () => T,\n bracket: boolean,\n skipFirstToken: boolean,\n ): T[] {\n if (!skipFirstToken) {\n if (bracket) {\n this.expect(tt.bracketL);\n } else {\n this.expectRelational(\"<\");\n }\n }\n\n const result = this.tsParseDelimitedList(kind, parseElement);\n\n if (bracket) {\n this.expect(tt.bracketR);\n } else {\n this.expectRelational(\">\");\n }\n\n return result;\n }\n\n tsParseImportType(): N.TsImportType {\n const node: N.TsImportType = this.startNode();\n this.expect(tt._import);\n this.expect(tt.parenL);\n if (!this.match(tt.string)) {\n this.raise(this.state.start, TSErrors.UnsupportedImportTypeArgument);\n }\n\n // For compatibility to estree we cannot call parseLiteral directly here\n node.argument = this.parseExprAtom();\n this.expect(tt.parenR);\n\n if (this.eat(tt.dot)) {\n node.qualifier = this.tsParseEntityName(/* allowReservedWords */ true);\n }\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n return this.finishNode(node, \"TSImportType\");\n }\n\n tsParseEntityName(allowReservedWords: boolean): N.TsEntityName {\n let entity: N.TsEntityName = this.parseIdentifier();\n while (this.eat(tt.dot)) {\n const node: N.TsQualifiedName = this.startNodeAtNode(entity);\n node.left = entity;\n node.right = this.parseIdentifier(allowReservedWords);\n entity = this.finishNode(node, \"TSQualifiedName\");\n }\n return entity;\n }\n\n tsParseTypeReference(): N.TsTypeReference {\n const node: N.TsTypeReference = this.startNode();\n node.typeName = this.tsParseEntityName(/* allowReservedWords */ false);\n if (!this.hasPrecedingLineBreak() && this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n return this.finishNode(node, \"TSTypeReference\");\n }\n\n tsParseThisTypePredicate(lhs: N.TsThisType): N.TsTypePredicate {\n this.next();\n const node: N.TsTypePredicate = this.startNodeAtNode(lhs);\n node.parameterName = lhs;\n node.typeAnnotation = this.tsParseTypeAnnotation(/* eatColon */ false);\n node.asserts = false;\n return this.finishNode(node, \"TSTypePredicate\");\n }\n\n tsParseThisTypeNode(): N.TsThisType {\n const node: N.TsThisType = this.startNode();\n this.next();\n return this.finishNode(node, \"TSThisType\");\n }\n\n tsParseTypeQuery(): N.TsTypeQuery {\n const node: N.TsTypeQuery = this.startNode();\n this.expect(tt._typeof);\n if (this.match(tt._import)) {\n node.exprName = this.tsParseImportType();\n } else {\n node.exprName = this.tsParseEntityName(/* allowReservedWords */ true);\n }\n return this.finishNode(node, \"TSTypeQuery\");\n }\n\n tsParseTypeParameter(): N.TsTypeParameter {\n const node: N.TsTypeParameter = this.startNode();\n node.name = this.parseIdentifierName(node.start);\n node.constraint = this.tsEatThenParseType(tt._extends);\n node.default = this.tsEatThenParseType(tt.eq);\n return this.finishNode(node, \"TSTypeParameter\");\n }\n\n tsTryParseTypeParameters(): ?N.TsTypeParameterDeclaration {\n if (this.isRelational(\"<\")) {\n return this.tsParseTypeParameters();\n }\n }\n\n tsParseTypeParameters() {\n const node: N.TsTypeParameterDeclaration = this.startNode();\n\n if (this.isRelational(\"<\") || this.match(tt.jsxTagStart)) {\n this.next();\n } else {\n this.unexpected();\n }\n\n node.params = this.tsParseBracketedList(\n \"TypeParametersOrArguments\",\n this.tsParseTypeParameter.bind(this),\n /* bracket */ false,\n /* skipFirstToken */ true,\n );\n if (node.params.length === 0) {\n this.raise(node.start, TSErrors.EmptyTypeParameters);\n }\n return this.finishNode(node, \"TSTypeParameterDeclaration\");\n }\n\n tsTryNextParseConstantContext(): ?N.TsTypeReference {\n if (this.lookahead().type === tt._const) {\n this.next();\n return this.tsParseTypeReference();\n }\n return null;\n }\n\n // Note: In TypeScript implementation we must provide `yieldContext` and `awaitContext`,\n // but here it's always false, because this is only used for types.\n tsFillSignature(\n returnToken: TokenType,\n signature: N.TsSignatureDeclaration,\n ): void {\n // Arrow fns *must* have return token (`=>`). Normal functions can omit it.\n const returnTokenRequired = returnToken === tt.arrow;\n signature.typeParameters = this.tsTryParseTypeParameters();\n this.expect(tt.parenL);\n signature.parameters = this.tsParseBindingListForSignature();\n if (returnTokenRequired) {\n signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(\n returnToken,\n );\n } else if (this.match(returnToken)) {\n signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(\n returnToken,\n );\n }\n }\n\n tsParseBindingListForSignature(): $ReadOnlyArray<\n N.Identifier | N.RestElement | N.ObjectPattern | N.ArrayPattern,\n > {\n return this.parseBindingList(tt.parenR, charCodes.rightParenthesis).map(\n pattern => {\n if (\n pattern.type !== \"Identifier\" &&\n pattern.type !== \"RestElement\" &&\n pattern.type !== \"ObjectPattern\" &&\n pattern.type !== \"ArrayPattern\"\n ) {\n this.raise(\n pattern.start,\n TSErrors.UnsupportedSignatureParameterKind,\n pattern.type,\n );\n }\n return (pattern: any);\n },\n );\n }\n\n tsParseTypeMemberSemicolon(): void {\n if (!this.eat(tt.comma)) {\n this.semicolon();\n }\n }\n\n tsParseSignatureMember(\n kind: \"TSCallSignatureDeclaration\" | \"TSConstructSignatureDeclaration\",\n node: N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration,\n ): N.TsCallSignatureDeclaration | N.TsConstructSignatureDeclaration {\n this.tsFillSignature(tt.colon, node);\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(node, kind);\n }\n\n tsIsUnambiguouslyIndexSignature() {\n this.next(); // Skip '{'\n return this.eat(tt.name) && this.match(tt.colon);\n }\n\n tsTryParseIndexSignature(node: N.Node): ?N.TsIndexSignature {\n if (\n !(\n this.match(tt.bracketL) &&\n this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))\n )\n ) {\n return undefined;\n }\n\n this.expect(tt.bracketL);\n const id = this.parseIdentifier();\n id.typeAnnotation = this.tsParseTypeAnnotation();\n this.resetEndLocation(id); // set end position to end of type\n\n this.expect(tt.bracketR);\n node.parameters = [id];\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) node.typeAnnotation = type;\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(node, \"TSIndexSignature\");\n }\n\n tsParsePropertyOrMethodSignature(\n node: N.TsPropertySignature | N.TsMethodSignature,\n readonly: boolean,\n ): N.TsPropertySignature | N.TsMethodSignature {\n if (this.eat(tt.question)) node.optional = true;\n const nodeAny: any = node;\n\n if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n if (readonly) {\n this.raise(node.start, TSErrors.ReadonlyForMethodSignature);\n }\n const method: N.TsMethodSignature = nodeAny;\n this.tsFillSignature(tt.colon, method);\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(method, \"TSMethodSignature\");\n } else {\n const property: N.TsPropertySignature = nodeAny;\n if (readonly) property.readonly = true;\n const type = this.tsTryParseTypeAnnotation();\n if (type) property.typeAnnotation = type;\n this.tsParseTypeMemberSemicolon();\n return this.finishNode(property, \"TSPropertySignature\");\n }\n }\n\n tsParseTypeMember(): N.TsTypeElement {\n const node: any = this.startNode();\n\n if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n return this.tsParseSignatureMember(\"TSCallSignatureDeclaration\", node);\n }\n\n if (this.match(tt._new)) {\n const id: N.Identifier = this.startNode();\n this.next();\n if (this.match(tt.parenL) || this.isRelational(\"<\")) {\n return this.tsParseSignatureMember(\n \"TSConstructSignatureDeclaration\",\n node,\n );\n } else {\n node.key = this.createIdentifier(id, \"new\");\n return this.tsParsePropertyOrMethodSignature(node, false);\n }\n }\n\n this.tsParseModifiers(\n node,\n [\"readonly\"],\n [\"declare\", \"abstract\", \"private\", \"protected\", \"public\", \"static\"],\n TSErrors.InvalidModifierOnTypeMember,\n );\n\n const idx = this.tsTryParseIndexSignature(node);\n if (idx) {\n return idx;\n }\n\n this.parsePropertyName(node, /* isPrivateNameAllowed */ false);\n return this.tsParsePropertyOrMethodSignature(node, !!node.readonly);\n }\n\n tsParseTypeLiteral(): N.TsTypeLiteral {\n const node: N.TsTypeLiteral = this.startNode();\n node.members = this.tsParseObjectTypeMembers();\n return this.finishNode(node, \"TSTypeLiteral\");\n }\n\n tsParseObjectTypeMembers(): $ReadOnlyArray {\n this.expect(tt.braceL);\n const members = this.tsParseList(\n \"TypeMembers\",\n this.tsParseTypeMember.bind(this),\n );\n this.expect(tt.braceR);\n return members;\n }\n\n tsIsStartOfMappedType(): boolean {\n this.next();\n if (this.eat(tt.plusMin)) {\n return this.isContextual(\"readonly\");\n }\n if (this.isContextual(\"readonly\")) {\n this.next();\n }\n if (!this.match(tt.bracketL)) {\n return false;\n }\n this.next();\n if (!this.tsIsIdentifier()) {\n return false;\n }\n this.next();\n return this.match(tt._in);\n }\n\n tsParseMappedTypeParameter(): N.TsTypeParameter {\n const node: N.TsTypeParameter = this.startNode();\n node.name = this.parseIdentifierName(node.start);\n node.constraint = this.tsExpectThenParseType(tt._in);\n return this.finishNode(node, \"TSTypeParameter\");\n }\n\n tsParseMappedType(): N.TsMappedType {\n const node: N.TsMappedType = this.startNode();\n\n this.expect(tt.braceL);\n\n if (this.match(tt.plusMin)) {\n node.readonly = this.state.value;\n this.next();\n this.expectContextual(\"readonly\");\n } else if (this.eatContextual(\"readonly\")) {\n node.readonly = true;\n }\n\n this.expect(tt.bracketL);\n node.typeParameter = this.tsParseMappedTypeParameter();\n node.nameType = this.eatContextual(\"as\") ? this.tsParseType() : null;\n\n this.expect(tt.bracketR);\n\n if (this.match(tt.plusMin)) {\n node.optional = this.state.value;\n this.next();\n this.expect(tt.question);\n } else if (this.eat(tt.question)) {\n node.optional = true;\n }\n\n node.typeAnnotation = this.tsTryParseType();\n this.semicolon();\n this.expect(tt.braceR);\n\n return this.finishNode(node, \"TSMappedType\");\n }\n\n tsParseTupleType(): N.TsTupleType {\n const node: N.TsTupleType = this.startNode();\n node.elementTypes = this.tsParseBracketedList(\n \"TupleElementTypes\",\n this.tsParseTupleElementType.bind(this),\n /* bracket */ true,\n /* skipFirstToken */ false,\n );\n\n // Validate the elementTypes to ensure that no mandatory elements\n // follow optional elements\n let seenOptionalElement = false;\n let labeledElements = null;\n node.elementTypes.forEach(elementNode => {\n let { type } = elementNode;\n\n if (\n seenOptionalElement &&\n type !== \"TSRestType\" &&\n type !== \"TSOptionalType\" &&\n !(type === \"TSNamedTupleMember\" && elementNode.optional)\n ) {\n this.raise(elementNode.start, TSErrors.OptionalTypeBeforeRequired);\n }\n\n // Flow doesn't support ||=\n seenOptionalElement =\n seenOptionalElement ||\n (type === \"TSNamedTupleMember\" && elementNode.optional) ||\n type === \"TSOptionalType\";\n\n // When checking labels, check the argument of the spread operator\n if (type === \"TSRestType\") {\n elementNode = elementNode.typeAnnotation;\n type = elementNode.type;\n }\n\n const isLabeled = type === \"TSNamedTupleMember\";\n // Flow doesn't support ??=\n labeledElements = labeledElements ?? isLabeled;\n if (labeledElements !== isLabeled) {\n this.raise(\n elementNode.start,\n TSErrors.MixedLabeledAndUnlabeledElements,\n );\n }\n });\n\n return this.finishNode(node, \"TSTupleType\");\n }\n\n tsParseTupleElementType(): N.TsType | N.TsNamedTupleMember {\n // parses `...TsType[]`\n\n const { start: startPos, startLoc } = this.state;\n\n const rest = this.eat(tt.ellipsis);\n let type = this.tsParseType();\n const optional = this.eat(tt.question);\n const labeled = this.eat(tt.colon);\n\n if (labeled) {\n const labeledNode: N.TsNamedTupleMember = this.startNodeAtNode(type);\n labeledNode.optional = optional;\n\n if (\n type.type === \"TSTypeReference\" &&\n !type.typeParameters &&\n type.typeName.type === \"Identifier\"\n ) {\n labeledNode.label = (type.typeName: N.Identifier);\n } else {\n this.raise(type.start, TSErrors.InvalidTupleMemberLabel);\n // This produces an invalid AST, but at least we don't drop\n // nodes representing the invalid source.\n // $FlowIgnore\n labeledNode.label = type;\n }\n\n labeledNode.elementType = this.tsParseType();\n type = this.finishNode(labeledNode, \"TSNamedTupleMember\");\n } else if (optional) {\n const optionalTypeNode: N.TsOptionalType = this.startNodeAtNode(type);\n optionalTypeNode.typeAnnotation = type;\n type = this.finishNode(optionalTypeNode, \"TSOptionalType\");\n }\n\n if (rest) {\n const restNode: N.TsRestType = this.startNodeAt(startPos, startLoc);\n restNode.typeAnnotation = type;\n type = this.finishNode(restNode, \"TSRestType\");\n }\n\n return type;\n }\n\n tsParseParenthesizedType(): N.TsParenthesizedType {\n const node = this.startNode();\n this.expect(tt.parenL);\n node.typeAnnotation = this.tsParseType();\n this.expect(tt.parenR);\n return this.finishNode(node, \"TSParenthesizedType\");\n }\n\n tsParseFunctionOrConstructorType(\n type: \"TSFunctionType\" | \"TSConstructorType\",\n abstract?: boolean,\n ): N.TsFunctionOrConstructorType {\n const node: N.TsFunctionOrConstructorType = this.startNode();\n if (type === \"TSConstructorType\") {\n // $FlowIgnore\n node.abstract = !!abstract;\n if (abstract) this.next();\n this.next(); // eat `new`\n }\n this.tsFillSignature(tt.arrow, node);\n return this.finishNode(node, type);\n }\n\n tsParseLiteralTypeNode(): N.TsLiteralType {\n const node: N.TsLiteralType = this.startNode();\n node.literal = (() => {\n switch (this.state.type) {\n case tt.num:\n case tt.bigint:\n case tt.string:\n case tt._true:\n case tt._false:\n // For compatibility to estree we cannot call parseLiteral directly here\n return this.parseExprAtom();\n default:\n throw this.unexpected();\n }\n })();\n return this.finishNode(node, \"TSLiteralType\");\n }\n\n tsParseTemplateLiteralType(): N.TsType {\n const node: N.TsLiteralType = this.startNode();\n node.literal = this.parseTemplate(false);\n return this.finishNode(node, \"TSLiteralType\");\n }\n\n parseTemplateSubstitution(): N.TsType {\n if (this.state.inType) return this.tsParseType();\n return super.parseTemplateSubstitution();\n }\n\n tsParseThisTypeOrThisTypePredicate(): N.TsThisType | N.TsTypePredicate {\n const thisKeyword = this.tsParseThisTypeNode();\n if (this.isContextual(\"is\") && !this.hasPrecedingLineBreak()) {\n return this.tsParseThisTypePredicate(thisKeyword);\n } else {\n return thisKeyword;\n }\n }\n\n tsParseNonArrayType(): N.TsType {\n switch (this.state.type) {\n case tt.name:\n case tt._void:\n case tt._null: {\n const type = this.match(tt._void)\n ? \"TSVoidKeyword\"\n : this.match(tt._null)\n ? \"TSNullKeyword\"\n : keywordTypeFromName(this.state.value);\n if (\n type !== undefined &&\n this.lookaheadCharCode() !== charCodes.dot\n ) {\n const node: N.TsKeywordType = this.startNode();\n this.next();\n return this.finishNode(node, type);\n }\n return this.tsParseTypeReference();\n }\n case tt.string:\n case tt.num:\n case tt.bigint:\n case tt._true:\n case tt._false:\n return this.tsParseLiteralTypeNode();\n case tt.plusMin:\n if (this.state.value === \"-\") {\n const node: N.TsLiteralType = this.startNode();\n const nextToken = this.lookahead();\n if (nextToken.type !== tt.num && nextToken.type !== tt.bigint) {\n throw this.unexpected();\n }\n node.literal = this.parseMaybeUnary();\n return this.finishNode(node, \"TSLiteralType\");\n }\n break;\n case tt._this:\n return this.tsParseThisTypeOrThisTypePredicate();\n case tt._typeof:\n return this.tsParseTypeQuery();\n case tt._import:\n return this.tsParseImportType();\n case tt.braceL:\n return this.tsLookAhead(this.tsIsStartOfMappedType.bind(this))\n ? this.tsParseMappedType()\n : this.tsParseTypeLiteral();\n case tt.bracketL:\n return this.tsParseTupleType();\n case tt.parenL:\n if (process.env.BABEL_8_BREAKING) {\n if (!this.options.createParenthesizedExpressions) {\n const startPos = this.state.start;\n this.next();\n const type = this.tsParseType();\n this.expect(tt.parenR);\n this.addExtra(type, \"parenthesized\", true);\n this.addExtra(type, \"parenStart\", startPos);\n return type;\n }\n }\n\n return this.tsParseParenthesizedType();\n case tt.backQuote:\n return this.tsParseTemplateLiteralType();\n }\n\n throw this.unexpected();\n }\n\n tsParseArrayTypeOrHigher(): N.TsType {\n let type = this.tsParseNonArrayType();\n while (!this.hasPrecedingLineBreak() && this.eat(tt.bracketL)) {\n if (this.match(tt.bracketR)) {\n const node: N.TsArrayType = this.startNodeAtNode(type);\n node.elementType = type;\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"TSArrayType\");\n } else {\n const node: N.TsIndexedAccessType = this.startNodeAtNode(type);\n node.objectType = type;\n node.indexType = this.tsParseType();\n this.expect(tt.bracketR);\n type = this.finishNode(node, \"TSIndexedAccessType\");\n }\n }\n return type;\n }\n\n tsParseTypeOperator(\n operator: \"keyof\" | \"unique\" | \"readonly\",\n ): N.TsTypeOperator {\n const node: N.TsTypeOperator = this.startNode();\n this.expectContextual(operator);\n node.operator = operator;\n node.typeAnnotation = this.tsParseTypeOperatorOrHigher();\n\n if (operator === \"readonly\") {\n this.tsCheckTypeAnnotationForReadOnly(node);\n }\n\n return this.finishNode(node, \"TSTypeOperator\");\n }\n\n tsCheckTypeAnnotationForReadOnly(node: N.Node) {\n switch (node.typeAnnotation.type) {\n case \"TSTupleType\":\n case \"TSArrayType\":\n return;\n default:\n this.raise(node.start, TSErrors.UnexpectedReadonly);\n }\n }\n\n tsParseInferType(): N.TsInferType {\n const node = this.startNode();\n this.expectContextual(\"infer\");\n const typeParameter = this.startNode();\n typeParameter.name = this.parseIdentifierName(typeParameter.start);\n node.typeParameter = this.finishNode(typeParameter, \"TSTypeParameter\");\n return this.finishNode(node, \"TSInferType\");\n }\n\n tsParseTypeOperatorOrHigher(): N.TsType {\n const operator = [\"keyof\", \"unique\", \"readonly\"].find(kw =>\n this.isContextual(kw),\n );\n return operator\n ? this.tsParseTypeOperator(operator)\n : this.isContextual(\"infer\")\n ? this.tsParseInferType()\n : this.tsParseArrayTypeOrHigher();\n }\n\n tsParseUnionOrIntersectionType(\n kind: \"TSUnionType\" | \"TSIntersectionType\",\n parseConstituentType: () => N.TsType,\n operator: TokenType,\n ): N.TsType {\n const node: N.TsUnionType | N.TsIntersectionType = this.startNode();\n const hasLeadingOperator = this.eat(operator);\n const types = [];\n do {\n types.push(parseConstituentType());\n } while (this.eat(operator));\n if (types.length === 1 && !hasLeadingOperator) {\n return types[0];\n }\n node.types = types;\n return this.finishNode(node, kind);\n }\n\n tsParseIntersectionTypeOrHigher(): N.TsType {\n return this.tsParseUnionOrIntersectionType(\n \"TSIntersectionType\",\n this.tsParseTypeOperatorOrHigher.bind(this),\n tt.bitwiseAND,\n );\n }\n\n tsParseUnionTypeOrHigher() {\n return this.tsParseUnionOrIntersectionType(\n \"TSUnionType\",\n this.tsParseIntersectionTypeOrHigher.bind(this),\n tt.bitwiseOR,\n );\n }\n\n tsIsStartOfFunctionType() {\n if (this.isRelational(\"<\")) {\n return true;\n }\n return (\n this.match(tt.parenL) &&\n this.tsLookAhead(this.tsIsUnambiguouslyStartOfFunctionType.bind(this))\n );\n }\n\n tsSkipParameterStart(): boolean {\n if (this.match(tt.name) || this.match(tt._this)) {\n this.next();\n return true;\n }\n\n if (this.match(tt.braceL)) {\n let braceStackCounter = 1;\n this.next();\n\n while (braceStackCounter > 0) {\n if (this.match(tt.braceL)) {\n ++braceStackCounter;\n } else if (this.match(tt.braceR)) {\n --braceStackCounter;\n }\n this.next();\n }\n return true;\n }\n\n if (this.match(tt.bracketL)) {\n let braceStackCounter = 1;\n this.next();\n\n while (braceStackCounter > 0) {\n if (this.match(tt.bracketL)) {\n ++braceStackCounter;\n } else if (this.match(tt.bracketR)) {\n --braceStackCounter;\n }\n this.next();\n }\n return true;\n }\n\n return false;\n }\n\n tsIsUnambiguouslyStartOfFunctionType(): boolean {\n this.next();\n if (this.match(tt.parenR) || this.match(tt.ellipsis)) {\n // ( )\n // ( ...\n return true;\n }\n if (this.tsSkipParameterStart()) {\n if (\n this.match(tt.colon) ||\n this.match(tt.comma) ||\n this.match(tt.question) ||\n this.match(tt.eq)\n ) {\n // ( xxx :\n // ( xxx ,\n // ( xxx ?\n // ( xxx =\n return true;\n }\n if (this.match(tt.parenR)) {\n this.next();\n if (this.match(tt.arrow)) {\n // ( xxx ) =>\n return true;\n }\n }\n }\n return false;\n }\n\n tsParseTypeOrTypePredicateAnnotation(\n returnToken: TokenType,\n ): N.TsTypeAnnotation {\n return this.tsInType(() => {\n const t: N.TsTypeAnnotation = this.startNode();\n this.expect(returnToken);\n\n const node = this.startNode();\n\n const asserts = !!this.tsTryParse(\n this.tsParseTypePredicateAsserts.bind(this),\n );\n\n if (asserts && this.match(tt._this)) {\n // When asserts is false, thisKeyword is handled by tsParseNonArrayType\n // : asserts this is type\n let thisTypePredicate = this.tsParseThisTypeOrThisTypePredicate();\n // if it turns out to be a `TSThisType`, wrap it with `TSTypePredicate`\n // : asserts this\n if (thisTypePredicate.type === \"TSThisType\") {\n node.parameterName = (thisTypePredicate: N.TsThisType);\n node.asserts = true;\n thisTypePredicate = this.finishNode(node, \"TSTypePredicate\");\n } else {\n this.resetStartLocationFromNode(thisTypePredicate, node);\n (thisTypePredicate: N.TsTypePredicate).asserts = true;\n }\n t.typeAnnotation = thisTypePredicate;\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n const typePredicateVariable =\n this.tsIsIdentifier() &&\n this.tsTryParse(this.tsParseTypePredicatePrefix.bind(this));\n\n if (!typePredicateVariable) {\n if (!asserts) {\n // : type\n return this.tsParseTypeAnnotation(/* eatColon */ false, t);\n }\n\n // : asserts foo\n node.parameterName = this.parseIdentifier();\n node.asserts = asserts;\n t.typeAnnotation = this.finishNode(node, \"TSTypePredicate\");\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n // : asserts foo is type\n const type = this.tsParseTypeAnnotation(/* eatColon */ false);\n node.parameterName = typePredicateVariable;\n node.typeAnnotation = type;\n node.asserts = asserts;\n t.typeAnnotation = this.finishNode(node, \"TSTypePredicate\");\n return this.finishNode(t, \"TSTypeAnnotation\");\n });\n }\n\n tsTryParseTypeOrTypePredicateAnnotation(): ?N.TsTypeAnnotation {\n return this.match(tt.colon)\n ? this.tsParseTypeOrTypePredicateAnnotation(tt.colon)\n : undefined;\n }\n\n tsTryParseTypeAnnotation(): ?N.TsTypeAnnotation {\n return this.match(tt.colon) ? this.tsParseTypeAnnotation() : undefined;\n }\n\n tsTryParseType(): ?N.TsType {\n return this.tsEatThenParseType(tt.colon);\n }\n\n tsParseTypePredicatePrefix(): ?N.Identifier {\n const id = this.parseIdentifier();\n if (this.isContextual(\"is\") && !this.hasPrecedingLineBreak()) {\n this.next();\n return id;\n }\n }\n\n tsParseTypePredicateAsserts(): boolean {\n if (\n !this.match(tt.name) ||\n this.state.value !== \"asserts\" ||\n this.hasPrecedingLineBreak()\n ) {\n return false;\n }\n const containsEsc = this.state.containsEsc;\n this.next();\n if (!this.match(tt.name) && !this.match(tt._this)) {\n return false;\n }\n\n if (containsEsc) {\n this.raise(\n this.state.lastTokStart,\n Errors.InvalidEscapedReservedWord,\n \"asserts\",\n );\n }\n\n return true;\n }\n\n tsParseTypeAnnotation(\n eatColon = true,\n t: N.TsTypeAnnotation = this.startNode(),\n ): N.TsTypeAnnotation {\n this.tsInType(() => {\n if (eatColon) this.expect(tt.colon);\n t.typeAnnotation = this.tsParseType();\n });\n return this.finishNode(t, \"TSTypeAnnotation\");\n }\n\n /** Be sure to be in a type context before calling this, using `tsInType`. */\n tsParseType(): N.TsType {\n // Need to set `state.inType` so that we don't parse JSX in a type context.\n assert(this.state.inType);\n const type = this.tsParseNonConditionalType();\n if (this.hasPrecedingLineBreak() || !this.eat(tt._extends)) {\n return type;\n }\n const node: N.TsConditionalType = this.startNodeAtNode(type);\n node.checkType = type;\n node.extendsType = this.tsParseNonConditionalType();\n this.expect(tt.question);\n node.trueType = this.tsParseType();\n this.expect(tt.colon);\n node.falseType = this.tsParseType();\n return this.finishNode(node, \"TSConditionalType\");\n }\n\n isAbstractConstructorSignature(): boolean {\n return this.isContextual(\"abstract\") && this.lookahead().type === tt._new;\n }\n\n tsParseNonConditionalType(): N.TsType {\n if (this.tsIsStartOfFunctionType()) {\n return this.tsParseFunctionOrConstructorType(\"TSFunctionType\");\n }\n if (this.match(tt._new)) {\n // As in `new () => Date`\n return this.tsParseFunctionOrConstructorType(\"TSConstructorType\");\n } else if (this.isAbstractConstructorSignature()) {\n // As in `abstract new () => Date`\n return this.tsParseFunctionOrConstructorType(\n \"TSConstructorType\",\n /* abstract */ true,\n );\n }\n return this.tsParseUnionTypeOrHigher();\n }\n\n tsParseTypeAssertion(): N.TsTypeAssertion {\n const node: N.TsTypeAssertion = this.startNode();\n const _const = this.tsTryNextParseConstantContext();\n node.typeAnnotation = _const || this.tsNextThenParseType();\n this.expectRelational(\">\");\n node.expression = this.parseMaybeUnary();\n return this.finishNode(node, \"TSTypeAssertion\");\n }\n\n tsParseHeritageClause(\n descriptor: string,\n ): $ReadOnlyArray {\n const originalStart = this.state.start;\n\n const delimitedList = this.tsParseDelimitedList(\n \"HeritageClauseElement\",\n this.tsParseExpressionWithTypeArguments.bind(this),\n );\n\n if (!delimitedList.length) {\n this.raise(originalStart, TSErrors.EmptyHeritageClauseType, descriptor);\n }\n\n return delimitedList;\n }\n\n tsParseExpressionWithTypeArguments(): N.TsExpressionWithTypeArguments {\n const node: N.TsExpressionWithTypeArguments = this.startNode();\n // Note: TS uses parseLeftHandSideExpressionOrHigher,\n // then has grammar errors later if it's not an EntityName.\n node.expression = this.tsParseEntityName(/* allowReservedWords */ false);\n if (this.isRelational(\"<\")) {\n node.typeParameters = this.tsParseTypeArguments();\n }\n\n return this.finishNode(node, \"TSExpressionWithTypeArguments\");\n }\n\n tsParseInterfaceDeclaration(\n node: N.TsInterfaceDeclaration,\n ): N.TsInterfaceDeclaration {\n node.id = this.parseIdentifier();\n this.checkLVal(\n node.id,\n \"typescript interface declaration\",\n BIND_TS_INTERFACE,\n );\n node.typeParameters = this.tsTryParseTypeParameters();\n if (this.eat(tt._extends)) {\n node.extends = this.tsParseHeritageClause(\"extends\");\n }\n const body: N.TSInterfaceBody = this.startNode();\n body.body = this.tsInType(this.tsParseObjectTypeMembers.bind(this));\n node.body = this.finishNode(body, \"TSInterfaceBody\");\n return this.finishNode(node, \"TSInterfaceDeclaration\");\n }\n\n tsParseTypeAliasDeclaration(\n node: N.TsTypeAliasDeclaration,\n ): N.TsTypeAliasDeclaration {\n node.id = this.parseIdentifier();\n this.checkLVal(node.id, \"typescript type alias\", BIND_TS_TYPE);\n\n node.typeParameters = this.tsTryParseTypeParameters();\n node.typeAnnotation = this.tsInType(() => {\n this.expect(tt.eq);\n\n if (\n this.isContextual(\"intrinsic\") &&\n this.lookahead().type !== tt.dot\n ) {\n const node: N.TsKeywordType = this.startNode();\n this.next();\n return this.finishNode(node, \"TSIntrinsicKeyword\");\n }\n\n return this.tsParseType();\n });\n\n this.semicolon();\n return this.finishNode(node, \"TSTypeAliasDeclaration\");\n }\n\n tsInNoContext(cb: () => T): T {\n const oldContext = this.state.context;\n this.state.context = [oldContext[0]];\n try {\n return cb();\n } finally {\n this.state.context = oldContext;\n }\n }\n\n /**\n * Runs `cb` in a type context.\n * This should be called one token *before* the first type token,\n * so that the call to `next()` is run in type context.\n */\n tsInType(cb: () => T): T {\n const oldInType = this.state.inType;\n this.state.inType = true;\n try {\n return cb();\n } finally {\n this.state.inType = oldInType;\n }\n }\n\n tsEatThenParseType(token: TokenType): N.TsType | typeof undefined {\n return !this.match(token) ? undefined : this.tsNextThenParseType();\n }\n\n tsExpectThenParseType(token: TokenType): N.TsType {\n return this.tsDoThenParseType(() => this.expect(token));\n }\n\n tsNextThenParseType(): N.TsType {\n return this.tsDoThenParseType(() => this.next());\n }\n\n tsDoThenParseType(cb: () => void): N.TsType {\n return this.tsInType(() => {\n cb();\n return this.tsParseType();\n });\n }\n\n tsParseEnumMember(): N.TsEnumMember {\n const node: N.TsEnumMember = this.startNode();\n // Computed property names are grammar errors in an enum, so accept just string literal or identifier.\n node.id = this.match(tt.string)\n ? this.parseExprAtom()\n : this.parseIdentifier(/* liberal */ true);\n if (this.eat(tt.eq)) {\n node.initializer = this.parseMaybeAssignAllowIn();\n }\n return this.finishNode(node, \"TSEnumMember\");\n }\n\n tsParseEnumDeclaration(\n node: N.TsEnumDeclaration,\n isConst: boolean,\n ): N.TsEnumDeclaration {\n if (isConst) node.const = true;\n node.id = this.parseIdentifier();\n this.checkLVal(\n node.id,\n \"typescript enum declaration\",\n isConst ? BIND_TS_CONST_ENUM : BIND_TS_ENUM,\n );\n\n this.expect(tt.braceL);\n node.members = this.tsParseDelimitedList(\n \"EnumMembers\",\n this.tsParseEnumMember.bind(this),\n );\n this.expect(tt.braceR);\n return this.finishNode(node, \"TSEnumDeclaration\");\n }\n\n tsParseModuleBlock(): N.TsModuleBlock {\n const node: N.TsModuleBlock = this.startNode();\n this.scope.enter(SCOPE_OTHER);\n\n this.expect(tt.braceL);\n // Inside of a module block is considered \"top-level\", meaning it can have imports and exports.\n this.parseBlockOrModuleBlockBody(\n (node.body = []),\n /* directives */ undefined,\n /* topLevel */ true,\n /* end */ tt.braceR,\n );\n this.scope.exit();\n return this.finishNode(node, \"TSModuleBlock\");\n }\n\n tsParseModuleOrNamespaceDeclaration(\n node: N.TsModuleDeclaration,\n nested?: boolean = false,\n ): N.TsModuleDeclaration {\n node.id = this.parseIdentifier();\n\n if (!nested) {\n this.checkLVal(\n node.id,\n \"module or namespace declaration\",\n BIND_TS_NAMESPACE,\n );\n }\n\n if (this.eat(tt.dot)) {\n const inner = this.startNode();\n this.tsParseModuleOrNamespaceDeclaration(inner, true);\n node.body = inner;\n } else {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n node.body = this.tsParseModuleBlock();\n this.prodParam.exit();\n this.scope.exit();\n }\n return this.finishNode(node, \"TSModuleDeclaration\");\n }\n\n tsParseAmbientExternalModuleDeclaration(\n node: N.TsModuleDeclaration,\n ): N.TsModuleDeclaration {\n if (this.isContextual(\"global\")) {\n node.global = true;\n node.id = this.parseIdentifier();\n } else if (this.match(tt.string)) {\n node.id = this.parseExprAtom();\n } else {\n this.unexpected();\n }\n if (this.match(tt.braceL)) {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n node.body = this.tsParseModuleBlock();\n this.prodParam.exit();\n this.scope.exit();\n } else {\n this.semicolon();\n }\n\n return this.finishNode(node, \"TSModuleDeclaration\");\n }\n\n tsParseImportEqualsDeclaration(\n node: N.TsImportEqualsDeclaration,\n isExport?: boolean,\n ): N.TsImportEqualsDeclaration {\n node.isExport = isExport || false;\n node.id = this.parseIdentifier();\n this.checkLVal(node.id, \"import equals declaration\", BIND_LEXICAL);\n this.expect(tt.eq);\n node.moduleReference = this.tsParseModuleReference();\n this.semicolon();\n return this.finishNode(node, \"TSImportEqualsDeclaration\");\n }\n\n tsIsExternalModuleReference(): boolean {\n return (\n this.isContextual(\"require\") &&\n this.lookaheadCharCode() === charCodes.leftParenthesis\n );\n }\n\n tsParseModuleReference(): N.TsModuleReference {\n return this.tsIsExternalModuleReference()\n ? this.tsParseExternalModuleReference()\n : this.tsParseEntityName(/* allowReservedWords */ false);\n }\n\n tsParseExternalModuleReference(): N.TsExternalModuleReference {\n const node: N.TsExternalModuleReference = this.startNode();\n this.expectContextual(\"require\");\n this.expect(tt.parenL);\n if (!this.match(tt.string)) {\n throw this.unexpected();\n }\n // For compatibility to estree we cannot call parseLiteral directly here\n node.expression = this.parseExprAtom();\n this.expect(tt.parenR);\n return this.finishNode(node, \"TSExternalModuleReference\");\n }\n\n // Utilities\n\n tsLookAhead(f: () => T): T {\n const state = this.state.clone();\n const res = f();\n this.state = state;\n return res;\n }\n\n tsTryParseAndCatch(f: () => T): ?T {\n const result = this.tryParse(abort => f() || abort());\n\n if (result.aborted || !result.node) return undefined;\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n tsTryParse(f: () => ?T): ?T {\n const state = this.state.clone();\n const result = f();\n if (result !== undefined && result !== false) {\n return result;\n } else {\n this.state = state;\n return undefined;\n }\n }\n\n tsTryParseDeclare(nany: any): ?N.Declaration {\n if (this.isLineTerminator()) {\n return;\n }\n let starttype = this.state.type;\n let kind;\n\n if (this.isContextual(\"let\")) {\n starttype = tt._var;\n kind = \"let\";\n }\n\n return this.tsInDeclareContext(() => {\n switch (starttype) {\n case tt._function:\n nany.declare = true;\n return this.parseFunctionStatement(\n nany,\n /* async */ false,\n /* declarationPosition */ true,\n );\n case tt._class:\n // While this is also set by tsParseExpressionStatement, we need to set it\n // before parsing the class declaration to now how to register it in the scope.\n nany.declare = true;\n return this.parseClass(\n nany,\n /* isStatement */ true,\n /* optionalId */ false,\n );\n case tt._const:\n if (this.match(tt._const) && this.isLookaheadContextual(\"enum\")) {\n // `const enum = 0;` not allowed because \"enum\" is a strict mode reserved word.\n this.expect(tt._const);\n this.expectContextual(\"enum\");\n return this.tsParseEnumDeclaration(nany, /* isConst */ true);\n }\n // falls through\n case tt._var:\n kind = kind || this.state.value;\n return this.parseVarStatement(nany, kind);\n case tt.name: {\n const value = this.state.value;\n if (value === \"global\") {\n return this.tsParseAmbientExternalModuleDeclaration(nany);\n } else {\n return this.tsParseDeclaration(nany, value, /* next */ true);\n }\n }\n }\n });\n }\n\n // Note: this won't be called unless the keyword is allowed in `shouldParseExportDeclaration`.\n tsTryParseExportDeclaration(): ?N.Declaration {\n return this.tsParseDeclaration(\n this.startNode(),\n this.state.value,\n /* next */ true,\n );\n }\n\n tsParseExpressionStatement(node: any, expr: N.Identifier): ?N.Declaration {\n switch (expr.name) {\n case \"declare\": {\n const declaration = this.tsTryParseDeclare(node);\n if (declaration) {\n declaration.declare = true;\n return declaration;\n }\n break;\n }\n case \"global\":\n // `global { }` (with no `declare`) may appear inside an ambient module declaration.\n // Would like to use tsParseAmbientExternalModuleDeclaration here, but already ran past \"global\".\n if (this.match(tt.braceL)) {\n this.scope.enter(SCOPE_TS_MODULE);\n this.prodParam.enter(PARAM);\n const mod: N.TsModuleDeclaration = node;\n mod.global = true;\n mod.id = expr;\n mod.body = this.tsParseModuleBlock();\n this.scope.exit();\n this.prodParam.exit();\n return this.finishNode(mod, \"TSModuleDeclaration\");\n }\n break;\n\n default:\n return this.tsParseDeclaration(node, expr.name, /* next */ false);\n }\n }\n\n // Common to tsTryParseDeclare, tsTryParseExportDeclaration, and tsParseExpressionStatement.\n tsParseDeclaration(\n node: any,\n value: string,\n next: boolean,\n ): ?N.Declaration {\n // no declaration apart from enum can be followed by a line break.\n switch (value) {\n case \"abstract\":\n if (\n this.tsCheckLineTerminator(next) &&\n (this.match(tt._class) || this.match(tt.name))\n ) {\n return this.tsParseAbstractDeclaration(node);\n }\n break;\n\n case \"enum\":\n if (next || this.match(tt.name)) {\n if (next) this.next();\n return this.tsParseEnumDeclaration(node, /* isConst */ false);\n }\n break;\n\n case \"interface\":\n if (this.tsCheckLineTerminator(next) && this.match(tt.name)) {\n return this.tsParseInterfaceDeclaration(node);\n }\n break;\n\n case \"module\":\n if (this.tsCheckLineTerminator(next)) {\n if (this.match(tt.string)) {\n return this.tsParseAmbientExternalModuleDeclaration(node);\n } else if (this.match(tt.name)) {\n return this.tsParseModuleOrNamespaceDeclaration(node);\n }\n }\n break;\n\n case \"namespace\":\n if (this.tsCheckLineTerminator(next) && this.match(tt.name)) {\n return this.tsParseModuleOrNamespaceDeclaration(node);\n }\n break;\n\n case \"type\":\n if (this.tsCheckLineTerminator(next) && this.match(tt.name)) {\n return this.tsParseTypeAliasDeclaration(node);\n }\n break;\n }\n }\n\n tsCheckLineTerminator(next: boolean) {\n if (next) {\n if (this.hasFollowingLineBreak()) return false;\n this.next();\n return true;\n }\n return !this.isLineTerminator();\n }\n\n tsTryParseGenericAsyncArrowFunction(\n startPos: number,\n startLoc: Position,\n ): ?N.ArrowFunctionExpression {\n if (!this.isRelational(\"<\")) {\n return undefined;\n }\n\n const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;\n this.state.maybeInArrowParameters = true;\n\n const res: ?N.ArrowFunctionExpression = this.tsTryParseAndCatch(() => {\n const node: N.ArrowFunctionExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n node.typeParameters = this.tsParseTypeParameters();\n // Don't use overloaded parseFunctionParams which would look for \"<\" again.\n super.parseFunctionParams(node);\n node.returnType = this.tsTryParseTypeOrTypePredicateAnnotation();\n this.expect(tt.arrow);\n return node;\n });\n\n this.state.maybeInArrowParameters = oldMaybeInArrowParameters;\n\n if (!res) {\n return undefined;\n }\n\n return this.parseArrowExpression(\n res,\n /* params are already set */ null,\n /* async */ true,\n );\n }\n\n tsParseTypeArguments(): N.TsTypeParameterInstantiation {\n const node = this.startNode();\n node.params = this.tsInType(() =>\n // Temporarily remove a JSX parsing context, which makes us scan different tokens.\n this.tsInNoContext(() => {\n this.expectRelational(\"<\");\n return this.tsParseDelimitedList(\n \"TypeParametersOrArguments\",\n this.tsParseType.bind(this),\n );\n }),\n );\n if (node.params.length === 0) {\n this.raise(node.start, TSErrors.EmptyTypeArguments);\n }\n // This reads the next token after the `>` too, so do this in the enclosing context.\n // But be sure not to parse a regex in the jsx expression ` />`, so set exprAllowed = false\n this.state.exprAllowed = false;\n this.expectRelational(\">\");\n return this.finishNode(node, \"TSTypeParameterInstantiation\");\n }\n\n tsIsDeclarationStart(): boolean {\n if (this.match(tt.name)) {\n switch (this.state.value) {\n case \"abstract\":\n case \"declare\":\n case \"enum\":\n case \"interface\":\n case \"module\":\n case \"namespace\":\n case \"type\":\n return true;\n }\n }\n\n return false;\n }\n\n // ======================================================\n // OVERRIDES\n // ======================================================\n\n isExportDefaultSpecifier(): boolean {\n if (this.tsIsDeclarationStart()) return false;\n return super.isExportDefaultSpecifier();\n }\n\n parseAssignableListItem(\n allowModifiers: ?boolean,\n decorators: N.Decorator[],\n ): N.Pattern | N.TSParameterProperty {\n // Store original location/position to include modifiers in range\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n\n let accessibility: ?N.Accessibility;\n let readonly = false;\n if (allowModifiers !== undefined) {\n accessibility = this.parseAccessModifier();\n readonly = !!this.tsParseModifier([\"readonly\"]);\n if (allowModifiers === false && (accessibility || readonly)) {\n this.raise(startPos, TSErrors.UnexpectedParameterModifier);\n }\n }\n\n const left = this.parseMaybeDefault();\n this.parseAssignableListItemTypes(left);\n const elt = this.parseMaybeDefault(left.start, left.loc.start, left);\n if (accessibility || readonly) {\n const pp: N.TSParameterProperty = this.startNodeAt(startPos, startLoc);\n if (decorators.length) {\n pp.decorators = decorators;\n }\n if (accessibility) pp.accessibility = accessibility;\n if (readonly) pp.readonly = readonly;\n if (elt.type !== \"Identifier\" && elt.type !== \"AssignmentPattern\") {\n this.raise(pp.start, TSErrors.UnsupportedParameterPropertyKind);\n }\n pp.parameter = ((elt: any): N.Identifier | N.AssignmentPattern);\n return this.finishNode(pp, \"TSParameterProperty\");\n }\n\n if (decorators.length) {\n left.decorators = decorators;\n }\n\n return elt;\n }\n\n parseFunctionBodyAndFinish(\n node: N.BodilessFunctionOrMethodBase,\n type: string,\n isMethod?: boolean = false,\n ): void {\n if (this.match(tt.colon)) {\n node.returnType = this.tsParseTypeOrTypePredicateAnnotation(tt.colon);\n }\n\n const bodilessType =\n type === \"FunctionDeclaration\"\n ? \"TSDeclareFunction\"\n : type === \"ClassMethod\"\n ? \"TSDeclareMethod\"\n : undefined;\n if (bodilessType && !this.match(tt.braceL) && this.isLineTerminator()) {\n this.finishNode(node, bodilessType);\n return;\n }\n if (bodilessType === \"TSDeclareFunction\" && this.state.isDeclareContext) {\n this.raise(node.start, TSErrors.DeclareFunctionHasImplementation);\n if (\n // $FlowIgnore\n node.declare\n ) {\n super.parseFunctionBodyAndFinish(node, bodilessType, isMethod);\n return;\n }\n }\n\n super.parseFunctionBodyAndFinish(node, type, isMethod);\n }\n\n registerFunctionStatementId(node: N.Function): void {\n if (!node.body && node.id) {\n // Function ids are validated after parsing their body.\n // For bodyless function, we need to do it here.\n this.checkLVal(node.id, \"function name\", BIND_TS_AMBIENT);\n } else {\n super.registerFunctionStatementId(...arguments);\n }\n }\n\n tsCheckForInvalidTypeCasts(items: $ReadOnlyArray) {\n items.forEach(node => {\n if (node?.type === \"TSTypeCastExpression\") {\n this.raise(\n node.typeAnnotation.start,\n TSErrors.UnexpectedTypeAnnotation,\n );\n }\n });\n }\n\n toReferencedList(\n exprList: $ReadOnlyArray,\n isInParens?: boolean, // eslint-disable-line no-unused-vars\n ): $ReadOnlyArray {\n // Handles invalid scenarios like: `f(a:b)`, `(a:b);`, and `(a:b,c:d)`.\n //\n // Note that `f(a:b)` goes through a different path and is handled\n // in `parseSubscript` directly.\n this.tsCheckForInvalidTypeCasts(exprList);\n return exprList;\n }\n\n parseArrayLike(...args): N.ArrayExpression | N.TupleExpression {\n const node = super.parseArrayLike(...args);\n\n if (node.type === \"ArrayExpression\") {\n this.tsCheckForInvalidTypeCasts(node.elements);\n }\n\n return node;\n }\n\n parseSubscript(\n base: N.Expression,\n startPos: number,\n startLoc: Position,\n noCalls: ?boolean,\n state: N.ParseSubscriptState,\n ): N.Expression {\n if (!this.hasPrecedingLineBreak() && this.match(tt.bang)) {\n this.state.exprAllowed = false;\n this.next();\n\n const nonNullExpression: N.TsNonNullExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n nonNullExpression.expression = base;\n return this.finishNode(nonNullExpression, \"TSNonNullExpression\");\n }\n\n if (this.isRelational(\"<\")) {\n // tsTryParseAndCatch is expensive, so avoid if not necessary.\n // There are number of things we are going to \"maybe\" parse, like type arguments on\n // tagged template expressions. If any of them fail, walk it back and continue.\n const result = this.tsTryParseAndCatch(() => {\n if (!noCalls && this.atPossibleAsyncArrow(base)) {\n // Almost certainly this is a generic async function `async () => ...\n // But it might be a call with a type argument `async();`\n const asyncArrowFn = this.tsTryParseGenericAsyncArrowFunction(\n startPos,\n startLoc,\n );\n if (asyncArrowFn) {\n return asyncArrowFn;\n }\n }\n\n const node: N.CallExpression = this.startNodeAt(startPos, startLoc);\n node.callee = base;\n\n const typeArguments = this.tsParseTypeArguments();\n\n if (typeArguments) {\n if (!noCalls && this.eat(tt.parenL)) {\n // possibleAsync always false here, because we would have handled it above.\n // $FlowIgnore (won't be any undefined arguments)\n node.arguments = this.parseCallExpressionArguments(\n tt.parenR,\n /* possibleAsync */ false,\n );\n\n // Handles invalid case: `f(a:b)`\n this.tsCheckForInvalidTypeCasts(node.arguments);\n\n node.typeParameters = typeArguments;\n if (state.optionalChainMember) {\n // $FlowIgnore\n node.optional = false;\n }\n return this.finishCallExpression(node, state.optionalChainMember);\n } else if (this.match(tt.backQuote)) {\n const result = this.parseTaggedTemplateExpression(\n base,\n startPos,\n startLoc,\n state,\n );\n result.typeParameters = typeArguments;\n return result;\n }\n }\n\n this.unexpected();\n });\n\n if (result) return result;\n }\n\n return super.parseSubscript(base, startPos, startLoc, noCalls, state);\n }\n\n parseNewArguments(node: N.NewExpression): void {\n if (this.isRelational(\"<\")) {\n // tsTryParseAndCatch is expensive, so avoid if not necessary.\n // 99% certain this is `new C();`. But may be `new C < T;`, which is also legal.\n const typeParameters = this.tsTryParseAndCatch(() => {\n const args = this.tsParseTypeArguments();\n if (!this.match(tt.parenL)) this.unexpected();\n return args;\n });\n if (typeParameters) {\n node.typeParameters = typeParameters;\n }\n }\n\n super.parseNewArguments(node);\n }\n\n parseExprOp(\n left: N.Expression,\n leftStartPos: number,\n leftStartLoc: Position,\n minPrec: number,\n ) {\n if (\n nonNull(tt._in.binop) > minPrec &&\n !this.hasPrecedingLineBreak() &&\n this.isContextual(\"as\")\n ) {\n const node: N.TsAsExpression = this.startNodeAt(\n leftStartPos,\n leftStartLoc,\n );\n node.expression = left;\n const _const = this.tsTryNextParseConstantContext();\n if (_const) {\n node.typeAnnotation = _const;\n } else {\n node.typeAnnotation = this.tsNextThenParseType();\n }\n this.finishNode(node, \"TSAsExpression\");\n // rescan `<`, `>` because they were scanned when this.state.inType was true\n this.reScan_lt_gt();\n return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec);\n }\n\n return super.parseExprOp(left, leftStartPos, leftStartLoc, minPrec);\n }\n\n checkReservedWord(\n word: string, // eslint-disable-line no-unused-vars\n startLoc: number, // eslint-disable-line no-unused-vars\n checkKeywords: boolean, // eslint-disable-line no-unused-vars\n // eslint-disable-next-line no-unused-vars\n isBinding: boolean,\n ): void {\n // Don't bother checking for TypeScript code.\n // Strict mode words may be allowed as in `declare namespace N { const static: number; }`.\n // And we have a type checker anyway, so don't bother having the parser do it.\n }\n\n /*\n Don't bother doing this check in TypeScript code because:\n 1. We may have a nested export statement with the same name:\n export const x = 0;\n export namespace N {\n export const x = 1;\n }\n 2. We have a type checker to warn us about this sort of thing.\n */\n checkDuplicateExports() {}\n\n parseImport(node: N.Node): N.AnyImport {\n if (this.match(tt.name) || this.match(tt.star) || this.match(tt.braceL)) {\n const ahead = this.lookahead();\n\n if (this.match(tt.name) && ahead.type === tt.eq) {\n return this.tsParseImportEqualsDeclaration(node);\n }\n\n if (\n this.isContextual(\"type\") &&\n // import type, { a } from \"b\";\n ahead.type !== tt.comma &&\n // import type from \"a\";\n !(ahead.type === tt.name && ahead.value === \"from\")\n ) {\n node.importKind = \"type\";\n this.next();\n }\n }\n\n if (!node.importKind) {\n node.importKind = \"value\";\n }\n\n const importNode = super.parseImport(node);\n /*:: invariant(importNode.type !== \"TSImportEqualsDeclaration\") */\n\n // `import type` can only be used on imports with named imports or with a\n // default import - but not both\n if (\n importNode.importKind === \"type\" &&\n importNode.specifiers.length > 1 &&\n importNode.specifiers[0].type === \"ImportDefaultSpecifier\"\n ) {\n this.raise(\n importNode.start,\n \"A type-only import can specify a default import or named bindings, but not both.\",\n );\n }\n\n return importNode;\n }\n\n parseExport(node: N.Node): N.AnyExport {\n if (this.match(tt._import)) {\n // `export import A = B;`\n this.expect(tt._import);\n return this.tsParseImportEqualsDeclaration(node, /* isExport */ true);\n } else if (this.eat(tt.eq)) {\n // `export = x;`\n const assign: N.TsExportAssignment = node;\n assign.expression = this.parseExpression();\n this.semicolon();\n return this.finishNode(assign, \"TSExportAssignment\");\n } else if (this.eatContextual(\"as\")) {\n // `export as namespace A;`\n const decl: N.TsNamespaceExportDeclaration = node;\n // See `parseNamespaceExportDeclaration` in TypeScript's own parser\n this.expectContextual(\"namespace\");\n decl.id = this.parseIdentifier();\n this.semicolon();\n return this.finishNode(decl, \"TSNamespaceExportDeclaration\");\n } else {\n if (this.isContextual(\"type\") && this.lookahead().type === tt.braceL) {\n this.next();\n node.exportKind = \"type\";\n } else {\n node.exportKind = \"value\";\n }\n\n return super.parseExport(node);\n }\n }\n\n isAbstractClass(): boolean {\n return (\n this.isContextual(\"abstract\") && this.lookahead().type === tt._class\n );\n }\n\n parseExportDefaultExpression(): N.Expression | N.Declaration {\n if (this.isAbstractClass()) {\n const cls = this.startNode();\n this.next(); // Skip \"abstract\"\n cls.abstract = true;\n this.parseClass(cls, true, true);\n return cls;\n }\n\n // export default interface allowed in:\n // https://github.com/Microsoft/TypeScript/pull/16040\n if (this.state.value === \"interface\") {\n const result = this.tsParseDeclaration(\n this.startNode(),\n this.state.value,\n true,\n );\n\n if (result) return result;\n }\n\n return super.parseExportDefaultExpression();\n }\n\n parseStatementContent(context: ?string, topLevel: ?boolean): N.Statement {\n if (this.state.type === tt._const) {\n const ahead = this.lookahead();\n if (ahead.type === tt.name && ahead.value === \"enum\") {\n const node: N.TsEnumDeclaration = this.startNode();\n this.expect(tt._const);\n this.expectContextual(\"enum\");\n return this.tsParseEnumDeclaration(node, /* isConst */ true);\n }\n }\n return super.parseStatementContent(context, topLevel);\n }\n\n parseAccessModifier(): ?N.Accessibility {\n return this.tsParseModifier([\"public\", \"protected\", \"private\"]);\n }\n\n parseClassMember(\n classBody: N.ClassBody,\n member: any,\n state: N.ParseClassMemberState,\n ): void {\n this.tsParseModifiers(member, [\n \"declare\",\n \"private\",\n \"public\",\n \"protected\",\n ]);\n\n const callParseClassMember = () => {\n super.parseClassMember(classBody, member, state);\n };\n if (member.declare) {\n this.tsInDeclareContext(callParseClassMember);\n } else {\n callParseClassMember();\n }\n }\n\n parseClassMemberWithIsStatic(\n classBody: N.ClassBody,\n member: N.ClassMember | N.TsIndexSignature,\n state: N.ParseClassMemberState,\n isStatic: boolean,\n ): void {\n this.tsParseModifiers(member, [\"abstract\", \"readonly\", \"declare\"]);\n\n const idx = this.tsTryParseIndexSignature(member);\n if (idx) {\n classBody.body.push(idx);\n\n if ((member: any).abstract) {\n this.raise(member.start, TSErrors.IndexSignatureHasAbstract);\n }\n if (isStatic) {\n this.raise(member.start, TSErrors.IndexSignatureHasStatic);\n }\n if ((member: any).accessibility) {\n this.raise(\n member.start,\n TSErrors.IndexSignatureHasAccessibility,\n (member: any).accessibility,\n );\n }\n if ((member: any).declare) {\n this.raise(member.start, TSErrors.IndexSignatureHasDeclare);\n }\n\n return;\n }\n\n if (!this.state.inAbstractClass && (member: any).abstract) {\n this.raise(member.start, TSErrors.NonAbstractClassHasAbstractMethod);\n }\n\n /*:: invariant(member.type !== \"TSIndexSignature\") */\n\n super.parseClassMemberWithIsStatic(classBody, member, state, isStatic);\n }\n\n parsePostMemberNameModifiers(\n methodOrProp: N.ClassMethod | N.ClassProperty | N.ClassPrivateProperty,\n ): void {\n const optional = this.eat(tt.question);\n if (optional) methodOrProp.optional = true;\n\n if ((methodOrProp: any).readonly && this.match(tt.parenL)) {\n this.raise(methodOrProp.start, TSErrors.ClassMethodHasReadonly);\n }\n\n if ((methodOrProp: any).declare && this.match(tt.parenL)) {\n this.raise(methodOrProp.start, TSErrors.ClassMethodHasDeclare);\n }\n }\n\n // Note: The reason we do this in `parseExpressionStatement` and not `parseStatement`\n // is that e.g. `type()` is valid JS, so we must try parsing that first.\n // If it's really a type, we will parse `type` as the statement, and can correct it here\n // by parsing the rest.\n parseExpressionStatement(\n node: N.ExpressionStatement,\n expr: N.Expression,\n ): N.Statement {\n const decl =\n expr.type === \"Identifier\"\n ? this.tsParseExpressionStatement(node, expr)\n : undefined;\n return decl || super.parseExpressionStatement(node, expr);\n }\n\n // export type\n // Should be true for anything parsed by `tsTryParseExportDeclaration`.\n shouldParseExportDeclaration(): boolean {\n if (this.tsIsDeclarationStart()) return true;\n return super.shouldParseExportDeclaration();\n }\n\n // An apparent conditional expression could actually be an optional parameter in an arrow function.\n parseConditional(\n expr: N.Expression,\n startPos: number,\n startLoc: Position,\n refNeedsArrowPos?: ?Pos,\n ): N.Expression {\n // only do the expensive clone if there is a question mark\n // and if we come from inside parens\n if (!refNeedsArrowPos || !this.match(tt.question)) {\n return super.parseConditional(\n expr,\n startPos,\n startLoc,\n refNeedsArrowPos,\n );\n }\n\n const result = this.tryParse(() =>\n super.parseConditional(expr, startPos, startLoc),\n );\n\n if (!result.node) {\n // $FlowIgnore\n refNeedsArrowPos.start = result.error.pos || this.state.start;\n return expr;\n }\n if (result.error) this.state = result.failState;\n return result.node;\n }\n\n // Note: These \"type casts\" are *not* valid TS expressions.\n // But we parse them here and change them when completing the arrow function.\n parseParenItem(\n node: N.Expression,\n startPos: number,\n startLoc: Position,\n ): N.Expression {\n node = super.parseParenItem(node, startPos, startLoc);\n if (this.eat(tt.question)) {\n node.optional = true;\n // Include questionmark in location of node\n // Don't use this.finishNode() as otherwise we might process comments twice and\n // include already consumed parens\n this.resetEndLocation(node);\n }\n\n if (this.match(tt.colon)) {\n const typeCastNode: N.TsTypeCastExpression = this.startNodeAt(\n startPos,\n startLoc,\n );\n typeCastNode.expression = node;\n typeCastNode.typeAnnotation = this.tsParseTypeAnnotation();\n\n return this.finishNode(typeCastNode, \"TSTypeCastExpression\");\n }\n\n return node;\n }\n\n parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {\n // Store original location/position\n const startPos = this.state.start;\n const startLoc = this.state.startLoc;\n\n // \"export declare\" is equivalent to just \"export\".\n const isDeclare = this.eatContextual(\"declare\");\n\n if (\n isDeclare &&\n (this.isContextual(\"declare\") || !this.shouldParseExportDeclaration())\n ) {\n throw this.raise(\n this.state.start,\n TSErrors.ExpectedAmbientAfterExportDeclare,\n );\n }\n\n let declaration: ?N.Declaration;\n\n if (this.match(tt.name)) {\n declaration = this.tsTryParseExportDeclaration();\n }\n if (!declaration) {\n declaration = super.parseExportDeclaration(node);\n }\n if (\n declaration &&\n (declaration.type === \"TSInterfaceDeclaration\" ||\n declaration.type === \"TSTypeAliasDeclaration\" ||\n isDeclare)\n ) {\n node.exportKind = \"type\";\n }\n\n if (declaration && isDeclare) {\n // Reset location to include `declare` in range\n this.resetStartLocation(declaration, startPos, startLoc);\n\n declaration.declare = true;\n }\n\n return declaration;\n }\n\n parseClassId(\n node: N.Class,\n isStatement: boolean,\n optionalId: ?boolean,\n ): void {\n if ((!isStatement || optionalId) && this.isContextual(\"implements\")) {\n return;\n }\n\n super.parseClassId(\n node,\n isStatement,\n optionalId,\n (node: any).declare ? BIND_TS_AMBIENT : BIND_CLASS,\n );\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) node.typeParameters = typeParameters;\n }\n\n parseClassPropertyAnnotation(\n node: N.ClassProperty | N.ClassPrivateProperty,\n ): void {\n if (!node.optional && this.eat(tt.bang)) {\n node.definite = true;\n }\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) node.typeAnnotation = type;\n }\n\n parseClassProperty(node: N.ClassProperty): N.ClassProperty {\n this.parseClassPropertyAnnotation(node);\n\n if (this.state.isDeclareContext && this.match(tt.eq)) {\n this.raise(this.state.start, TSErrors.DeclareClassFieldHasInitializer);\n }\n\n return super.parseClassProperty(node);\n }\n\n parseClassPrivateProperty(\n node: N.ClassPrivateProperty,\n ): N.ClassPrivateProperty {\n // $FlowIgnore\n if (node.abstract) {\n this.raise(node.start, TSErrors.PrivateElementHasAbstract);\n }\n\n // $FlowIgnore\n if (node.accessibility) {\n this.raise(\n node.start,\n TSErrors.PrivateElementHasAccessibility,\n node.accessibility,\n );\n }\n\n this.parseClassPropertyAnnotation(node);\n return super.parseClassPrivateProperty(node);\n }\n\n pushClassMethod(\n classBody: N.ClassBody,\n method: N.ClassMethod,\n isGenerator: boolean,\n isAsync: boolean,\n isConstructor: boolean,\n allowsDirectSuper: boolean,\n ): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters && isConstructor) {\n this.raise(typeParameters.start, TSErrors.ConstructorHasTypeParameters);\n }\n if (typeParameters) method.typeParameters = typeParameters;\n super.pushClassMethod(\n classBody,\n method,\n isGenerator,\n isAsync,\n isConstructor,\n allowsDirectSuper,\n );\n }\n\n pushClassPrivateMethod(\n classBody: N.ClassBody,\n method: N.ClassPrivateMethod,\n isGenerator: boolean,\n isAsync: boolean,\n ): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) method.typeParameters = typeParameters;\n super.pushClassPrivateMethod(classBody, method, isGenerator, isAsync);\n }\n\n parseClassSuper(node: N.Class): void {\n super.parseClassSuper(node);\n if (node.superClass && this.isRelational(\"<\")) {\n node.superTypeParameters = this.tsParseTypeArguments();\n }\n if (this.eatContextual(\"implements\")) {\n node.implements = this.tsParseHeritageClause(\"implements\");\n }\n }\n\n parseObjPropValue(prop: N.ObjectMember, ...args): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) prop.typeParameters = typeParameters;\n\n super.parseObjPropValue(prop, ...args);\n }\n\n parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {\n const typeParameters = this.tsTryParseTypeParameters();\n if (typeParameters) node.typeParameters = typeParameters;\n super.parseFunctionParams(node, allowModifiers);\n }\n\n // `let x: number;`\n parseVarId(\n decl: N.VariableDeclarator,\n kind: \"var\" | \"let\" | \"const\",\n ): void {\n super.parseVarId(decl, kind);\n if (decl.id.type === \"Identifier\" && this.eat(tt.bang)) {\n decl.definite = true;\n }\n\n const type = this.tsTryParseTypeAnnotation();\n if (type) {\n decl.id.typeAnnotation = type;\n this.resetEndLocation(decl.id); // set end position to end of type\n }\n }\n\n // parse the return type of an async arrow function - let foo = (async (): number => {});\n parseAsyncArrowFromCallExpression(\n node: N.ArrowFunctionExpression,\n call: N.CallExpression,\n ): N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n node.returnType = this.tsParseTypeAnnotation();\n }\n return super.parseAsyncArrowFromCallExpression(node, call);\n }\n\n parseMaybeAssign(...args): N.Expression {\n // Note: When the JSX plugin is on, type assertions (` x`) aren't valid syntax.\n\n let state: ?State;\n let jsx;\n let typeCast;\n\n if (\n this.hasPlugin(\"jsx\") &&\n (this.match(tt.jsxTagStart) || this.isRelational(\"<\"))\n ) {\n // Prefer to parse JSX if possible. But may be an arrow fn.\n state = this.state.clone();\n\n jsx = this.tryParse(() => super.parseMaybeAssign(...args), state);\n /*:: invariant(!jsx.aborted) */\n\n if (!jsx.error) return jsx.node;\n\n // Remove `tc.j_expr` and `tc.j_oTag` from context added\n // by parsing `jsxTagStart` to stop the JSX plugin from\n // messing with the tokens\n const { context } = this.state;\n if (context[context.length - 1] === ct.j_oTag) {\n context.length -= 2;\n } else if (context[context.length - 1] === ct.j_expr) {\n context.length -= 1;\n }\n }\n\n if (!jsx?.error && !this.isRelational(\"<\")) {\n return super.parseMaybeAssign(...args);\n }\n\n // Either way, we're looking at a '<': tt.jsxTagStart or relational.\n\n let typeParameters: N.TsTypeParameterDeclaration;\n state = state || this.state.clone();\n\n const arrow = this.tryParse(abort => {\n // This is similar to TypeScript's `tryParseParenthesizedArrowFunctionExpression`.\n typeParameters = this.tsParseTypeParameters();\n const expr = super.parseMaybeAssign(...args);\n\n if (\n expr.type !== \"ArrowFunctionExpression\" ||\n (expr.extra && expr.extra.parenthesized)\n ) {\n abort();\n }\n\n // Correct TypeScript code should have at least 1 type parameter, but don't crash on bad code.\n if (typeParameters?.params.length !== 0) {\n this.resetStartLocationFromNode(expr, typeParameters);\n }\n expr.typeParameters = typeParameters;\n return expr;\n }, state);\n\n if (!arrow.error && !arrow.aborted) return arrow.node;\n\n if (!jsx) {\n // Try parsing a type cast instead of an arrow function.\n // This will never happen outside of JSX.\n // (Because in JSX the '<' should be a jsxTagStart and not a relational.\n assert(!this.hasPlugin(\"jsx\"));\n\n // This will start with a type assertion (via parseMaybeUnary).\n // But don't directly call `this.tsParseTypeAssertion` because we want to handle any binary after it.\n typeCast = this.tryParse(() => super.parseMaybeAssign(...args), state);\n /*:: invariant(!typeCast.aborted) */\n if (!typeCast.error) return typeCast.node;\n }\n\n if (jsx?.node) {\n /*:: invariant(jsx.failState) */\n this.state = jsx.failState;\n return jsx.node;\n }\n\n if (arrow.node) {\n /*:: invariant(arrow.failState) */\n this.state = arrow.failState;\n return arrow.node;\n }\n\n if (typeCast?.node) {\n /*:: invariant(typeCast.failState) */\n this.state = typeCast.failState;\n return typeCast.node;\n }\n\n if (jsx?.thrown) throw jsx.error;\n if (arrow.thrown) throw arrow.error;\n if (typeCast?.thrown) throw typeCast.error;\n\n throw jsx?.error || arrow.error || typeCast?.error;\n }\n\n // Handle type assertions\n parseMaybeUnary(refExpressionErrors?: ?ExpressionErrors): N.Expression {\n if (!this.hasPlugin(\"jsx\") && this.isRelational(\"<\")) {\n return this.tsParseTypeAssertion();\n } else {\n return super.parseMaybeUnary(refExpressionErrors);\n }\n }\n\n parseArrow(node: N.ArrowFunctionExpression): ?N.ArrowFunctionExpression {\n if (this.match(tt.colon)) {\n // This is different from how the TS parser does it.\n // TS uses lookahead. The Babel Parser parses it as a parenthesized expression and converts.\n\n const result = this.tryParse(abort => {\n const returnType = this.tsParseTypeOrTypePredicateAnnotation(\n tt.colon,\n );\n if (this.canInsertSemicolon() || !this.match(tt.arrow)) abort();\n return returnType;\n });\n\n if (result.aborted) return;\n\n if (!result.thrown) {\n if (result.error) this.state = result.failState;\n node.returnType = result.node;\n }\n }\n\n return super.parseArrow(node);\n }\n\n // Allow type annotations inside of a parameter list.\n parseAssignableListItemTypes(param: N.Pattern) {\n if (this.eat(tt.question)) {\n if (\n param.type !== \"Identifier\" &&\n !this.state.isDeclareContext &&\n !this.state.inType\n ) {\n this.raise(param.start, TSErrors.PatternIsOptional);\n }\n\n ((param: any): N.Identifier).optional = true;\n }\n const type = this.tsTryParseTypeAnnotation();\n if (type) param.typeAnnotation = type;\n this.resetEndLocation(param);\n\n return param;\n }\n\n toAssignable(node: N.Node, isLHS: boolean = false): N.Node {\n switch (node.type) {\n case \"TSTypeCastExpression\":\n return super.toAssignable(this.typeCastToParameter(node), isLHS);\n case \"TSParameterProperty\":\n return super.toAssignable(node, isLHS);\n case \"TSAsExpression\":\n case \"TSNonNullExpression\":\n case \"TSTypeAssertion\":\n node.expression = this.toAssignable(node.expression, isLHS);\n return node;\n default:\n return super.toAssignable(node, isLHS);\n }\n }\n\n checkLVal(\n expr: N.Expression,\n contextDescription: string,\n ...args:\n | [BindingTypes | void]\n | [BindingTypes | void, ?Set, boolean | void, boolean | void]\n ): void {\n switch (expr.type) {\n case \"TSTypeCastExpression\":\n // Allow \"typecasts\" to appear on the left of assignment expressions,\n // because it may be in an arrow function.\n // e.g. `const f = (foo: number = 0) => foo;`\n return;\n case \"TSParameterProperty\":\n this.checkLVal(expr.parameter, \"parameter property\", ...args);\n return;\n case \"TSAsExpression\":\n case \"TSNonNullExpression\":\n case \"TSTypeAssertion\":\n this.checkLVal(expr.expression, contextDescription, ...args);\n return;\n default:\n super.checkLVal(expr, contextDescription, ...args);\n return;\n }\n }\n\n parseBindingAtom(): N.Pattern {\n switch (this.state.type) {\n case tt._this:\n // \"this\" may be the name of a parameter, so allow it.\n return this.parseIdentifier(/* liberal */ true);\n default:\n return super.parseBindingAtom();\n }\n }\n\n parseMaybeDecoratorArguments(expr: N.Expression): N.Expression {\n if (this.isRelational(\"<\")) {\n const typeArguments = this.tsParseTypeArguments();\n\n if (this.match(tt.parenL)) {\n const call = super.parseMaybeDecoratorArguments(expr);\n call.typeParameters = typeArguments;\n return call;\n }\n\n this.unexpected(this.state.start, tt.parenL);\n }\n\n return super.parseMaybeDecoratorArguments(expr);\n }\n\n // === === === === === === === === === === === === === === === ===\n // Note: All below methods are duplicates of something in flow.js.\n // Not sure what the best way to combine these is.\n // === === === === === === === === === === === === === === === ===\n\n isClassMethod(): boolean {\n return this.isRelational(\"<\") || super.isClassMethod();\n }\n\n isClassProperty(): boolean {\n return (\n this.match(tt.bang) || this.match(tt.colon) || super.isClassProperty()\n );\n }\n\n parseMaybeDefault(...args): N.Pattern {\n const node = super.parseMaybeDefault(...args);\n\n if (\n node.type === \"AssignmentPattern\" &&\n node.typeAnnotation &&\n node.right.start < node.typeAnnotation.start\n ) {\n this.raise(\n node.typeAnnotation.start,\n TSErrors.TypeAnnotationAfterAssign,\n );\n }\n\n return node;\n }\n\n // ensure that inside types, we bypass the jsx parser plugin\n getTokenFromCode(code: number): void {\n if (\n this.state.inType &&\n (code === charCodes.greaterThan || code === charCodes.lessThan)\n ) {\n return this.finishOp(tt.relational, 1);\n } else {\n return super.getTokenFromCode(code);\n }\n }\n\n // used after we have finished parsing types\n reScan_lt_gt() {\n if (this.match(tt.relational)) {\n const code = this.input.charCodeAt(this.state.start);\n if (code === charCodes.lessThan || code === charCodes.greaterThan) {\n this.state.pos -= 1;\n this.readToken_lt_gt(code);\n }\n }\n }\n\n toAssignableList(exprList: N.Expression[]): $ReadOnlyArray {\n for (let i = 0; i < exprList.length; i++) {\n const expr = exprList[i];\n if (!expr) continue;\n switch (expr.type) {\n case \"TSTypeCastExpression\":\n exprList[i] = this.typeCastToParameter(expr);\n break;\n case \"TSAsExpression\":\n case \"TSTypeAssertion\":\n if (!this.state.maybeInArrowParameters) {\n exprList[i] = this.typeCastToParameter(expr);\n } else {\n this.raise(expr.start, TSErrors.UnexpectedTypeCastInParameter);\n }\n break;\n }\n }\n return super.toAssignableList(...arguments);\n }\n\n typeCastToParameter(node: N.TsTypeCastExpression): N.Node {\n node.expression.typeAnnotation = node.typeAnnotation;\n\n this.resetEndLocation(\n node.expression,\n node.typeAnnotation.end,\n node.typeAnnotation.loc.end,\n );\n\n return node.expression;\n }\n\n shouldParseArrow() {\n return this.match(tt.colon) || super.shouldParseArrow();\n }\n\n shouldParseAsyncArrow(): boolean {\n return this.match(tt.colon) || super.shouldParseAsyncArrow();\n }\n\n canHaveLeadingDecorator() {\n // Avoid unnecessary lookahead in checking for abstract class unless needed!\n return super.canHaveLeadingDecorator() || this.isAbstractClass();\n }\n\n jsxParseOpeningElementAfterName(\n node: N.JSXOpeningElement,\n ): N.JSXOpeningElement {\n if (this.isRelational(\"<\")) {\n const typeArguments = this.tsTryParseAndCatch(() =>\n this.tsParseTypeArguments(),\n );\n if (typeArguments) node.typeParameters = typeArguments;\n }\n return super.jsxParseOpeningElementAfterName(node);\n }\n\n getGetterSetterExpectedParamCount(\n method: N.ObjectMethod | N.ClassMethod,\n ): number {\n const baseCount = super.getGetterSetterExpectedParamCount(method);\n const params = this.getObjectOrClassMethodParams(method);\n const firstParam = params[0];\n const hasContextParam =\n firstParam &&\n firstParam.type === \"Identifier\" &&\n firstParam.name === \"this\";\n\n return hasContextParam ? baseCount + 1 : baseCount;\n }\n\n parseCatchClauseParam(): N.Pattern {\n const param = super.parseCatchClauseParam();\n const type = this.tsTryParseTypeAnnotation();\n\n if (type) {\n param.typeAnnotation = type;\n this.resetEndLocation(param);\n }\n\n return param;\n }\n\n tsInDeclareContext(cb: () => T): T {\n const oldIsDeclareContext = this.state.isDeclareContext;\n this.state.isDeclareContext = true;\n try {\n return cb();\n } finally {\n this.state.isDeclareContext = oldIsDeclareContext;\n }\n }\n\n parseClass(node: T, ...args: any[]): T {\n const oldInAbstractClass = this.state.inAbstractClass;\n this.state.inAbstractClass = !!(node: any).abstract;\n try {\n return super.parseClass(node, ...args);\n } finally {\n this.state.inAbstractClass = oldInAbstractClass;\n }\n }\n\n tsParseAbstractDeclaration(\n node: any,\n ): N.ClassDeclaration | N.TsInterfaceDeclaration | typeof undefined {\n if (this.match(tt._class)) {\n node.abstract = true;\n return this.parseClass(\n (node: N.ClassDeclaration),\n /* isStatement */ true,\n /* optionalId */ false,\n );\n } else if (this.isContextual(\"interface\")) {\n // for invalid abstract interface\n\n // To avoid\n // abstract interface\n // Foo {}\n if (!this.hasFollowingLineBreak()) {\n node.abstract = true;\n this.raise(\n node.start,\n TSErrors.NonClassMethodPropertyHasAbstractModifer,\n );\n this.next();\n return this.tsParseInterfaceDeclaration(\n (node: N.TsInterfaceDeclaration),\n );\n }\n } else {\n this.unexpected(null, tt._class);\n }\n }\n };\n","// @flow\n\nimport * as charCodes from \"charcodes\";\n\nimport { types as tt, TokenType } from \"../tokenizer/types\";\nimport type Parser from \"../parser\";\nimport * as N from \"../types\";\n\ntt.placeholder = new TokenType(\"%%\", { startsExpr: true });\n\nexport type PlaceholderTypes =\n | \"Identifier\"\n | \"StringLiteral\"\n | \"Expression\"\n | \"Statement\"\n | \"Declaration\"\n | \"BlockStatement\"\n | \"ClassBody\"\n | \"Pattern\";\n\n// $PropertyType doesn't support enums. Use a fake \"switch\" (GetPlaceholderNode)\n//type MaybePlaceholder = $PropertyType | N.Placeholder;\n\ntype _Switch = $Call<\n (\n $ElementType<$ElementType, 0>,\n ) => $ElementType<$ElementType, 1>,\n Value,\n>;\ntype $Switch = _Switch;\n\ntype NodeOf = $Switch<\n T,\n [\n [\"Identifier\", N.Identifier],\n [\"StringLiteral\", N.StringLiteral],\n [\"Expression\", N.Expression],\n [\"Statement\", N.Statement],\n [\"Declaration\", N.Declaration],\n [\"BlockStatement\", N.BlockStatement],\n [\"ClassBody\", N.ClassBody],\n [\"Pattern\", N.Pattern],\n ],\n>;\n\n// Placeholder breaks everything, because its type is incompatible with\n// the substituted nodes.\ntype MaybePlaceholder = NodeOf; // | Placeholder\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n parsePlaceholder(\n expectedNode: T,\n ): /*?N.Placeholder*/ ?MaybePlaceholder {\n if (this.match(tt.placeholder)) {\n const node = this.startNode();\n this.next();\n this.assertNoSpace(\"Unexpected space in placeholder.\");\n\n // We can't use this.parseIdentifier because\n // we don't want nested placeholders.\n node.name = super.parseIdentifier(/* liberal */ true);\n\n this.assertNoSpace(\"Unexpected space in placeholder.\");\n this.expect(tt.placeholder);\n return this.finishPlaceholder(node, expectedNode);\n }\n }\n\n finishPlaceholder(\n node: N.Node,\n expectedNode: T,\n ): /*N.Placeholder*/ MaybePlaceholder {\n const isFinished = !!(node.expectedNode && node.type === \"Placeholder\");\n node.expectedNode = expectedNode;\n\n return isFinished ? node : this.finishNode(node, \"Placeholder\");\n }\n\n /* ============================================================ *\n * tokenizer/index.js *\n * ============================================================ */\n\n getTokenFromCode(code: number) {\n if (\n code === charCodes.percentSign &&\n this.input.charCodeAt(this.state.pos + 1) === charCodes.percentSign\n ) {\n return this.finishOp(tt.placeholder, 2);\n }\n\n return super.getTokenFromCode(...arguments);\n }\n\n /* ============================================================ *\n * parser/expression.js *\n * ============================================================ */\n\n parseExprAtom(): MaybePlaceholder<\"Expression\"> {\n return (\n this.parsePlaceholder(\"Expression\") || super.parseExprAtom(...arguments)\n );\n }\n\n parseIdentifier(): MaybePlaceholder<\"Identifier\"> {\n // NOTE: This function only handles identifiers outside of\n // expressions and binding patterns, since they are already\n // handled by the parseExprAtom and parseBindingAtom functions.\n // This is needed, for example, to parse \"class %%NAME%% {}\".\n return (\n this.parsePlaceholder(\"Identifier\") ||\n super.parseIdentifier(...arguments)\n );\n }\n\n checkReservedWord(word: string): void {\n // Sometimes we call #checkReservedWord(node.name), expecting\n // that node is an Identifier. If it is a Placeholder, name\n // will be undefined.\n if (word !== undefined) super.checkReservedWord(...arguments);\n }\n\n /* ============================================================ *\n * parser/lval.js *\n * ============================================================ */\n\n parseBindingAtom(): MaybePlaceholder<\"Pattern\"> {\n return (\n this.parsePlaceholder(\"Pattern\") || super.parseBindingAtom(...arguments)\n );\n }\n\n checkLVal(expr: N.Expression): void {\n if (expr.type !== \"Placeholder\") super.checkLVal(...arguments);\n }\n\n toAssignable(node: N.Node): N.Node {\n if (\n node &&\n node.type === \"Placeholder\" &&\n node.expectedNode === \"Expression\"\n ) {\n node.expectedNode = \"Pattern\";\n return node;\n }\n return super.toAssignable(...arguments);\n }\n\n /* ============================================================ *\n * parser/statement.js *\n * ============================================================ */\n\n isLet(context: ?string): boolean {\n if (super.isLet(context)) {\n return true;\n }\n\n // Replicate the original checks that lead to looking ahead for an\n // identifier.\n if (!this.isContextual(\"let\")) {\n return false;\n }\n if (context) return false;\n\n // Accept \"let %%\" as the start of \"let %%placeholder%%\", as though the\n // placeholder were an identifier.\n const nextToken = this.lookahead();\n if (nextToken.type === tt.placeholder) {\n return true;\n }\n\n return false;\n }\n\n verifyBreakContinue(node: N.BreakStatement | N.ContinueStatement) {\n if (node.label && node.label.type === \"Placeholder\") return;\n super.verifyBreakContinue(...arguments);\n }\n\n parseExpressionStatement(\n node: MaybePlaceholder<\"Statement\">,\n expr: N.Expression,\n ): MaybePlaceholder<\"Statement\"> {\n if (\n expr.type !== \"Placeholder\" ||\n (expr.extra && expr.extra.parenthesized)\n ) {\n return super.parseExpressionStatement(...arguments);\n }\n\n if (this.match(tt.colon)) {\n const stmt: N.LabeledStatement = node;\n stmt.label = this.finishPlaceholder(expr, \"Identifier\");\n this.next();\n stmt.body = this.parseStatement(\"label\");\n return this.finishNode(stmt, \"LabeledStatement\");\n }\n\n this.semicolon();\n\n node.name = expr.name;\n return this.finishPlaceholder(node, \"Statement\");\n }\n\n parseBlock(): MaybePlaceholder<\"BlockStatement\"> {\n return (\n this.parsePlaceholder(\"BlockStatement\") ||\n super.parseBlock(...arguments)\n );\n }\n\n parseFunctionId(): ?MaybePlaceholder<\"Identifier\"> {\n return (\n this.parsePlaceholder(\"Identifier\") ||\n super.parseFunctionId(...arguments)\n );\n }\n\n parseClass(\n node: T,\n isStatement: /* T === ClassDeclaration */ boolean,\n optionalId?: boolean,\n ): T {\n const type = isStatement ? \"ClassDeclaration\" : \"ClassExpression\";\n\n this.next();\n this.takeDecorators(node);\n const oldStrict = this.state.strict;\n\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (placeholder) {\n if (\n this.match(tt._extends) ||\n this.match(tt.placeholder) ||\n this.match(tt.braceL)\n ) {\n node.id = placeholder;\n } else if (optionalId || !isStatement) {\n node.id = null;\n node.body = this.finishPlaceholder(placeholder, \"ClassBody\");\n return this.finishNode(node, type);\n } else {\n this.unexpected(null, \"A class name is required\");\n }\n } else {\n this.parseClassId(node, isStatement, optionalId);\n }\n\n this.parseClassSuper(node);\n node.body =\n this.parsePlaceholder(\"ClassBody\") ||\n this.parseClassBody(!!node.superClass, oldStrict);\n return this.finishNode(node, type);\n }\n\n parseExport(node: N.Node): N.Node {\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (!placeholder) return super.parseExport(...arguments);\n\n if (!this.isContextual(\"from\") && !this.match(tt.comma)) {\n // export %%DECL%%;\n node.specifiers = [];\n node.source = null;\n node.declaration = this.finishPlaceholder(placeholder, \"Declaration\");\n return this.finishNode(node, \"ExportNamedDeclaration\");\n }\n\n // export %%NAME%% from \"foo\";\n this.expectPlugin(\"exportDefaultFrom\");\n const specifier = this.startNode();\n specifier.exported = placeholder;\n node.specifiers = [this.finishNode(specifier, \"ExportDefaultSpecifier\")];\n\n return super.parseExport(node);\n }\n\n isExportDefaultSpecifier(): boolean {\n if (this.match(tt._default)) {\n const next = this.nextTokenStart();\n if (this.isUnparsedContextual(next, \"from\")) {\n if (\n this.input.startsWith(\n tt.placeholder.label,\n this.nextTokenStartSince(next + 4),\n )\n ) {\n return true;\n }\n }\n }\n return super.isExportDefaultSpecifier();\n }\n\n maybeParseExportDefaultSpecifier(node: N.Node): boolean {\n if (node.specifiers && node.specifiers.length > 0) {\n // \"export %%NAME%%\" has already been parsed by #parseExport.\n return true;\n }\n return super.maybeParseExportDefaultSpecifier(...arguments);\n }\n\n checkExport(node: N.ExportNamedDeclaration): void {\n const { specifiers } = node;\n if (specifiers?.length) {\n node.specifiers = specifiers.filter(\n node => node.exported.type === \"Placeholder\",\n );\n }\n super.checkExport(node);\n node.specifiers = specifiers;\n }\n\n parseImport(\n node: N.Node,\n ): N.ImportDeclaration | N.TsImportEqualsDeclaration {\n const placeholder = this.parsePlaceholder(\"Identifier\");\n if (!placeholder) return super.parseImport(...arguments);\n\n node.specifiers = [];\n\n if (!this.isContextual(\"from\") && !this.match(tt.comma)) {\n // import %%STRING%%;\n node.source = this.finishPlaceholder(placeholder, \"StringLiteral\");\n this.semicolon();\n return this.finishNode(node, \"ImportDeclaration\");\n }\n\n // import %%DEFAULT%% ...\n const specifier = this.startNodeAtNode(placeholder);\n specifier.local = placeholder;\n this.finishNode(specifier, \"ImportDefaultSpecifier\");\n node.specifiers.push(specifier);\n\n if (this.eat(tt.comma)) {\n // import %%DEFAULT%%, * as ...\n const hasStarImport = this.maybeParseStarImportSpecifier(node);\n\n // import %%DEFAULT%%, { ...\n if (!hasStarImport) this.parseNamedImportSpecifiers(node);\n }\n\n this.expectContextual(\"from\");\n node.source = this.parseImportSource();\n this.semicolon();\n return this.finishNode(node, \"ImportDeclaration\");\n }\n\n parseImportSource(): MaybePlaceholder<\"StringLiteral\"> {\n // import ... from %%STRING%%;\n\n return (\n this.parsePlaceholder(\"StringLiteral\") ||\n super.parseImportSource(...arguments)\n );\n }\n };\n","import type Parser from \"../parser\";\nimport { types as tt } from \"../tokenizer/types\";\nimport * as N from \"../types\";\n\nexport default (superClass: Class): Class =>\n class extends superClass {\n parseV8Intrinsic(): N.Expression {\n if (this.match(tt.modulo)) {\n const v8IntrinsicStart = this.state.start;\n // let the `loc` of Identifier starts from `%`\n const node = this.startNode();\n this.eat(tt.modulo);\n if (this.match(tt.name)) {\n const name = this.parseIdentifierName(this.state.start);\n const identifier = this.createIdentifier(node, name);\n identifier.type = \"V8IntrinsicIdentifier\";\n if (this.match(tt.parenL)) {\n return identifier;\n }\n }\n this.unexpected(v8IntrinsicStart);\n }\n }\n\n /* ============================================================ *\n * parser/expression.js *\n * ============================================================ */\n\n parseExprAtom(): N.Expression {\n return this.parseV8Intrinsic() || super.parseExprAtom(...arguments);\n }\n };\n","// @flow\n\nimport type Parser from \"./parser\";\n\nexport type Plugin = string | [string, Object];\n\nexport type PluginList = $ReadOnlyArray;\n\nexport type MixinPlugin = (superClass: Class) => Class;\n\nexport function hasPlugin(plugins: PluginList, name: string): boolean {\n return plugins.some(plugin => {\n if (Array.isArray(plugin)) {\n return plugin[0] === name;\n } else {\n return plugin === name;\n }\n });\n}\n\nexport function getPluginOption(\n plugins: PluginList,\n name: string,\n option: string,\n) {\n const plugin = plugins.find(plugin => {\n if (Array.isArray(plugin)) {\n return plugin[0] === name;\n } else {\n return plugin === name;\n }\n });\n\n if (plugin && Array.isArray(plugin)) {\n return plugin[1][option];\n }\n\n return null;\n}\n\nconst PIPELINE_PROPOSALS = [\"minimal\", \"smart\", \"fsharp\"];\nconst RECORD_AND_TUPLE_SYNTAX_TYPES = [\"hash\", \"bar\"];\n\nexport function validatePlugins(plugins: PluginList) {\n if (hasPlugin(plugins, \"decorators\")) {\n if (hasPlugin(plugins, \"decorators-legacy\")) {\n throw new Error(\n \"Cannot use the decorators and decorators-legacy plugin together\",\n );\n }\n\n const decoratorsBeforeExport = getPluginOption(\n plugins,\n \"decorators\",\n \"decoratorsBeforeExport\",\n );\n if (decoratorsBeforeExport == null) {\n throw new Error(\n \"The 'decorators' plugin requires a 'decoratorsBeforeExport' option,\" +\n \" whose value must be a boolean. If you are migrating from\" +\n \" Babylon/Babel 6 or want to use the old decorators proposal, you\" +\n \" should use the 'decorators-legacy' plugin instead of 'decorators'.\",\n );\n } else if (typeof decoratorsBeforeExport !== \"boolean\") {\n throw new Error(\"'decoratorsBeforeExport' must be a boolean.\");\n }\n }\n\n if (hasPlugin(plugins, \"flow\") && hasPlugin(plugins, \"typescript\")) {\n throw new Error(\"Cannot combine flow and typescript plugins.\");\n }\n\n if (hasPlugin(plugins, \"placeholders\") && hasPlugin(plugins, \"v8intrinsic\")) {\n throw new Error(\"Cannot combine placeholders and v8intrinsic plugins.\");\n }\n\n if (\n hasPlugin(plugins, \"pipelineOperator\") &&\n !PIPELINE_PROPOSALS.includes(\n getPluginOption(plugins, \"pipelineOperator\", \"proposal\"),\n )\n ) {\n throw new Error(\n \"'pipelineOperator' requires 'proposal' option whose value should be one of: \" +\n PIPELINE_PROPOSALS.map(p => `'${p}'`).join(\", \"),\n );\n }\n\n if (hasPlugin(plugins, \"moduleAttributes\")) {\n if (hasPlugin(plugins, \"importAssertions\")) {\n throw new Error(\n \"Cannot combine importAssertions and moduleAttributes plugins.\",\n );\n }\n const moduleAttributesVerionPluginOption = getPluginOption(\n plugins,\n \"moduleAttributes\",\n \"version\",\n );\n if (moduleAttributesVerionPluginOption !== \"may-2020\") {\n throw new Error(\n \"The 'moduleAttributes' plugin requires a 'version' option,\" +\n \" representing the last proposal update. Currently, the\" +\n \" only supported value is 'may-2020'.\",\n );\n }\n }\n\n if (\n hasPlugin(plugins, \"recordAndTuple\") &&\n !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(\n getPluginOption(plugins, \"recordAndTuple\", \"syntaxType\"),\n )\n ) {\n throw new Error(\n \"'recordAndTuple' requires 'syntaxType' option whose value should be one of: \" +\n RECORD_AND_TUPLE_SYNTAX_TYPES.map(p => `'${p}'`).join(\", \"),\n );\n }\n}\n\n// These plugins are defined using a mixin which extends the parser class.\n\nimport estree from \"./plugins/estree\";\nimport flow from \"./plugins/flow\";\nimport jsx from \"./plugins/jsx\";\nimport typescript from \"./plugins/typescript\";\nimport placeholders from \"./plugins/placeholders\";\nimport v8intrinsic from \"./plugins/v8intrinsic\";\n\n// NOTE: order is important. estree must come first; placeholders must come last.\nexport const mixinPlugins: { [name: string]: MixinPlugin } = {\n estree,\n jsx,\n flow,\n typescript,\n v8intrinsic,\n placeholders,\n};\n\nexport const mixinPluginNames: $ReadOnlyArray = Object.keys(\n mixinPlugins,\n);\n","// @flow\n\nimport type { PluginList } from \"./plugin-utils\";\n\n// A second optional argument can be given to further configure\n// the parser process. These options are recognized:\n\nexport type SourceType = \"script\" | \"module\" | \"unambiguous\";\n\nexport type Options = {\n sourceType: SourceType,\n sourceFilename?: string,\n startLine: number,\n allowAwaitOutsideFunction: boolean,\n allowReturnOutsideFunction: boolean,\n allowImportExportEverywhere: boolean,\n allowSuperOutsideMethod: boolean,\n allowUndeclaredExports: boolean,\n plugins: PluginList,\n strictMode: ?boolean,\n ranges: boolean,\n tokens: boolean,\n createParenthesizedExpressions: boolean,\n errorRecovery: boolean,\n};\n\nexport const defaultOptions: Options = {\n // Source type (\"script\" or \"module\") for different semantics\n sourceType: \"script\",\n // Source filename.\n sourceFilename: undefined,\n // Line from which to start counting source. Useful for\n // integration with other tools.\n startLine: 1,\n // When enabled, await at the top level is not considered an\n // error.\n allowAwaitOutsideFunction: false,\n // When enabled, a return at the top level is not considered an\n // error.\n allowReturnOutsideFunction: false,\n // When enabled, import/export statements are not constrained to\n // appearing at the top of the program.\n allowImportExportEverywhere: false,\n // TODO\n allowSuperOutsideMethod: false,\n // When enabled, export statements can reference undeclared variables.\n allowUndeclaredExports: false,\n // An array of plugins to enable\n plugins: [],\n // TODO\n strictMode: null,\n // Nodes have their start and end characters offsets recorded in\n // `start` and `end` properties (directly on the node, rather than\n // the `loc` object, which holds line/column data. To also add a\n // [semi-standardized][range] `range` property holding a `[start,\n // end]` array with the same numbers, set the `ranges` option to\n // `true`.\n //\n // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678\n ranges: false,\n // Adds all parsed tokens to a `tokens` property on the `File` node\n tokens: false,\n // Whether to create ParenthesizedExpression AST nodes (if false\n // the parser sets extra.parenthesized on the expression nodes instead).\n createParenthesizedExpressions: false,\n // When enabled, errors are attached to the AST instead of being directly thrown.\n // Some errors will still throw, because @babel/parser can't always recover.\n errorRecovery: false,\n};\n\n// Interpret and default an options object\n\nexport function getOptions(opts: ?Options): Options {\n const options: any = {};\n for (const key of Object.keys(defaultOptions)) {\n options[key] = opts && opts[key] != null ? opts[key] : defaultOptions[key];\n }\n return options;\n}\n","// @flow\n\nimport type { Options } from \"../options\";\nimport * as N from \"../types\";\nimport { Position } from \"../util/location\";\n\nimport { types as ct, type TokContext } from \"./context\";\nimport { types as tt, type TokenType } from \"./types\";\nimport type { ParsingError } from \"../parser/error\";\n\ntype TopicContextState = {\n // When a topic binding has been currently established,\n // then this is 1. Otherwise, it is 0. This is forwards compatible\n // with a future plugin for multiple lexical topics.\n maxNumOfResolvableTopics: number,\n\n // When a topic binding has been currently established, and if that binding\n // has been used as a topic reference `#`, then this is 0. Otherwise, it is\n // `null`. This is forwards compatible with a future plugin for multiple\n // lexical topics.\n maxTopicIndex: null | 0,\n};\n\nexport default class State {\n strict: boolean;\n curLine: number;\n\n // And, if locations are used, the {line, column} object\n // corresponding to those offsets\n startLoc: Position;\n endLoc: Position;\n\n init(options: Options): void {\n this.strict =\n options.strictMode === false ? false : options.sourceType === \"module\";\n\n this.curLine = options.startLine;\n this.startLoc = this.endLoc = this.curPosition();\n }\n\n errors: ParsingError[] = [];\n\n // Used to signify the start of a potential arrow function\n potentialArrowAt: number = -1;\n\n // Used to signify the start of an expression which looks like a\n // typed arrow function, but it isn't\n // e.g. a ? (b) : c => d\n // ^\n noArrowAt: number[] = [];\n\n // Used to signify the start of an expression whose params, if it looks like\n // an arrow function, shouldn't be converted to assignable nodes.\n // This is used to defer the validation of typed arrow functions inside\n // conditional expressions.\n // e.g. a ? (b) : c => d\n // ^\n noArrowParamsConversionAt: number[] = [];\n\n // Flags to track\n maybeInArrowParameters: boolean = false;\n inPipeline: boolean = false;\n inType: boolean = false;\n noAnonFunctionType: boolean = false;\n inPropertyName: boolean = false;\n hasFlowComment: boolean = false;\n isIterator: boolean = false;\n isDeclareContext: boolean = false;\n inAbstractClass: boolean = false;\n\n // For the smartPipelines plugin:\n topicContext: TopicContextState = {\n maxNumOfResolvableTopics: 0,\n maxTopicIndex: null,\n };\n\n // For the F# plugin\n soloAwait: boolean = false;\n inFSharpPipelineDirectBody: boolean = false;\n\n // Labels in scope.\n labels: Array<{\n kind: ?(\"loop\" | \"switch\"),\n name?: ?string,\n statementStart?: number,\n }> = [];\n\n // Leading decorators. Last element of the stack represents the decorators in current context.\n // Supports nesting of decorators, e.g. @foo(@bar class inner {}) class outer {}\n // where @foo belongs to the outer class and @bar to the inner\n decoratorStack: Array> = [[]];\n\n // Comment store.\n comments: Array = [];\n\n // Comment attachment store\n trailingComments: Array = [];\n leadingComments: Array = [];\n commentStack: Array<{\n start: number,\n leadingComments: ?Array,\n trailingComments: ?Array,\n type: string,\n }> = [];\n // $FlowIgnore this is initialized when the parser starts.\n commentPreviousNode: N.Node = null;\n\n // The current position of the tokenizer in the input.\n pos: number = 0;\n lineStart: number = 0;\n\n // Properties of the current token:\n // Its type\n type: TokenType = tt.eof;\n\n // For tokens that include more information than their type, the value\n value: any = null;\n\n // Its start and end offset\n start: number = 0;\n end: number = 0;\n\n // Position information for the previous token\n // $FlowIgnore this is initialized when generating the second token.\n lastTokEndLoc: Position = null;\n // $FlowIgnore this is initialized when generating the second token.\n lastTokStartLoc: Position = null;\n lastTokStart: number = 0;\n lastTokEnd: number = 0;\n\n // The context stack is used to superficially track syntactic\n // context to predict whether a regular expression is allowed in a\n // given position.\n context: Array = [ct.braceStatement];\n exprAllowed: boolean = true;\n\n // Used to signal to callers of `readWord1` whether the word\n // contained any escape sequences. This is needed because words with\n // escape sequences must not be interpreted as keywords.\n containsEsc: boolean = false;\n\n // This property is used to track the following errors\n // - StrictNumericEscape\n // - StrictOctalLiteral\n //\n // in a literal that occurs prior to/immediately after a \"use strict\" directive.\n\n // todo(JLHwung): set strictErrors to null and avoid recording string errors\n // after a non-directive is parsed\n strictErrors: Map = new Map();\n\n // Names of exports store. `default` is stored as a name for both\n // `export default foo;` and `export { foo as default };`.\n exportedIdentifiers: Array = [];\n\n // Tokens length in token store\n tokensLength: number = 0;\n\n curPosition(): Position {\n return new Position(this.curLine, this.pos - this.lineStart);\n }\n\n clone(skipArrays?: boolean): State {\n const state = new State();\n const keys = Object.keys(this);\n for (let i = 0, length = keys.length; i < length; i++) {\n const key = keys[i];\n // $FlowIgnore\n let val = this[key];\n\n if (!skipArrays && Array.isArray(val)) {\n val = val.slice();\n }\n\n // $FlowIgnore\n state[key] = val;\n }\n\n return state;\n }\n}\n","// @flow\n\n/*:: declare var invariant; */\n\nimport type { Options } from \"../options\";\nimport * as N from \"../types\";\nimport type { Position } from \"../util/location\";\nimport * as charCodes from \"charcodes\";\nimport { isIdentifierStart, isIdentifierChar } from \"../util/identifier\";\nimport { types as tt, keywords as keywordTypes, type TokenType } from \"./types\";\nimport { type TokContext, types as ct } from \"./context\";\nimport ParserErrors, { Errors } from \"../parser/error\";\nimport { SourceLocation } from \"../util/location\";\nimport {\n lineBreak,\n lineBreakG,\n isNewLine,\n isWhitespace,\n skipWhiteSpace,\n} from \"../util/whitespace\";\nimport State from \"./state\";\n\nconst VALID_REGEX_FLAGS = new Set([\"g\", \"m\", \"s\", \"i\", \"y\", \"u\"]);\n\n// The following character codes are forbidden from being\n// an immediate sibling of NumericLiteralSeparator _\n\nconst forbiddenNumericSeparatorSiblings = {\n decBinOct: [\n charCodes.dot,\n charCodes.uppercaseB,\n charCodes.uppercaseE,\n charCodes.uppercaseO,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseB,\n charCodes.lowercaseE,\n charCodes.lowercaseO,\n ],\n hex: [\n charCodes.dot,\n charCodes.uppercaseX,\n charCodes.underscore, // multiple separators are not allowed\n charCodes.lowercaseX,\n ],\n};\n\nconst allowedNumericSeparatorSiblings = {};\nallowedNumericSeparatorSiblings.bin = [\n // 0 - 1\n charCodes.digit0,\n charCodes.digit1,\n];\nallowedNumericSeparatorSiblings.oct = [\n // 0 - 7\n ...allowedNumericSeparatorSiblings.bin,\n\n charCodes.digit2,\n charCodes.digit3,\n charCodes.digit4,\n charCodes.digit5,\n charCodes.digit6,\n charCodes.digit7,\n];\nallowedNumericSeparatorSiblings.dec = [\n // 0 - 9\n ...allowedNumericSeparatorSiblings.oct,\n\n charCodes.digit8,\n charCodes.digit9,\n];\n\nallowedNumericSeparatorSiblings.hex = [\n // 0 - 9, A - F, a - f,\n ...allowedNumericSeparatorSiblings.dec,\n\n charCodes.uppercaseA,\n charCodes.uppercaseB,\n charCodes.uppercaseC,\n charCodes.uppercaseD,\n charCodes.uppercaseE,\n charCodes.uppercaseF,\n\n charCodes.lowercaseA,\n charCodes.lowercaseB,\n charCodes.lowercaseC,\n charCodes.lowercaseD,\n charCodes.lowercaseE,\n charCodes.lowercaseF,\n];\n\n// Object type used to represent tokens. Note that normally, tokens\n// simply exist as properties on the parser object. This is only\n// used for the onToken callback and the external tokenizer.\n\nexport class Token {\n constructor(state: State) {\n this.type = state.type;\n this.value = state.value;\n this.start = state.start;\n this.end = state.end;\n this.loc = new SourceLocation(state.startLoc, state.endLoc);\n }\n\n declare type: TokenType;\n declare value: any;\n declare start: number;\n declare end: number;\n declare loc: SourceLocation;\n}\n\n// ## Tokenizer\n\nexport default class Tokenizer extends ParserErrors {\n // Forward-declarations\n // parser/util.js\n /*::\n +hasPrecedingLineBreak: () => boolean;\n +unexpected: (pos?: ?number, messageOrType?: string | TokenType) => empty;\n +expectPlugin: (name: string, pos?: ?number) => true;\n */\n\n isLookahead: boolean;\n\n // Token store.\n tokens: Array = [];\n\n constructor(options: Options, input: string) {\n super();\n this.state = new State();\n this.state.init(options);\n this.input = input;\n this.length = input.length;\n this.isLookahead = false;\n }\n\n pushToken(token: Token | N.Comment) {\n // Pop out invalid tokens trapped by try-catch parsing.\n // Those parsing branches are mainly created by typescript and flow plugins.\n this.tokens.length = this.state.tokensLength;\n this.tokens.push(token);\n ++this.state.tokensLength;\n }\n\n // Move to the next token\n\n next(): void {\n if (!this.isLookahead) {\n this.checkKeywordEscapes();\n if (this.options.tokens) {\n this.pushToken(new Token(this.state));\n }\n }\n\n this.state.lastTokEnd = this.state.end;\n this.state.lastTokStart = this.state.start;\n this.state.lastTokEndLoc = this.state.endLoc;\n this.state.lastTokStartLoc = this.state.startLoc;\n this.nextToken();\n }\n\n // TODO\n\n eat(type: TokenType): boolean {\n if (this.match(type)) {\n this.next();\n return true;\n } else {\n return false;\n }\n }\n\n // TODO\n\n match(type: TokenType): boolean {\n return this.state.type === type;\n }\n\n // TODO\n\n lookahead(): State {\n const old = this.state;\n this.state = old.clone(true);\n\n this.isLookahead = true;\n this.next();\n this.isLookahead = false;\n\n const curr = this.state;\n this.state = old;\n return curr;\n }\n\n nextTokenStart(): number {\n return this.nextTokenStartSince(this.state.pos);\n }\n\n nextTokenStartSince(pos: number): number {\n skipWhiteSpace.lastIndex = pos;\n const skip = skipWhiteSpace.exec(this.input);\n // $FlowIgnore: The skipWhiteSpace ensures to match any string\n return pos + skip[0].length;\n }\n\n lookaheadCharCode(): number {\n return this.input.charCodeAt(this.nextTokenStart());\n }\n\n // Toggle strict mode. Re-reads the next number or string to please\n // pedantic tests (`\"use strict\"; 010;` should fail).\n\n setStrict(strict: boolean): void {\n this.state.strict = strict;\n if (strict) {\n // Throw an error for any string decimal escape found before/immediately\n // after a \"use strict\" directive. Strict mode will be set at parse\n // time for any literals that occur after the next node of the strict\n // directive.\n this.state.strictErrors.forEach((message, pos) =>\n /* eslint-disable @babel/development-internal/dry-error-messages */\n this.raise(pos, message),\n );\n this.state.strictErrors.clear();\n }\n }\n\n curContext(): TokContext {\n return this.state.context[this.state.context.length - 1];\n }\n\n // Read a single token, updating the parser object's token-related\n // properties.\n\n nextToken(): void {\n const curContext = this.curContext();\n if (!curContext?.preserveSpace) this.skipSpace();\n this.state.start = this.state.pos;\n this.state.startLoc = this.state.curPosition();\n if (this.state.pos >= this.length) {\n this.finishToken(tt.eof);\n return;\n }\n\n const override = curContext?.override;\n if (override) {\n override(this);\n } else {\n this.getTokenFromCode(this.input.codePointAt(this.state.pos));\n }\n }\n\n pushComment(\n block: boolean,\n text: string,\n start: number,\n end: number,\n startLoc: Position,\n endLoc: Position,\n ): void {\n const comment = {\n type: block ? \"CommentBlock\" : \"CommentLine\",\n value: text,\n start: start,\n end: end,\n loc: new SourceLocation(startLoc, endLoc),\n };\n\n if (this.options.tokens) this.pushToken(comment);\n this.state.comments.push(comment);\n this.addComment(comment);\n }\n\n skipBlockComment(): void {\n const startLoc = this.state.curPosition();\n const start = this.state.pos;\n const end = this.input.indexOf(\"*/\", this.state.pos + 2);\n if (end === -1) throw this.raise(start, Errors.UnterminatedComment);\n\n this.state.pos = end + 2;\n lineBreakG.lastIndex = start;\n let match;\n while (\n (match = lineBreakG.exec(this.input)) &&\n match.index < this.state.pos\n ) {\n ++this.state.curLine;\n this.state.lineStart = match.index + match[0].length;\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n\n this.pushComment(\n true,\n this.input.slice(start + 2, end),\n start,\n this.state.pos,\n startLoc,\n this.state.curPosition(),\n );\n }\n\n skipLineComment(startSkip: number): void {\n const start = this.state.pos;\n const startLoc = this.state.curPosition();\n let ch = this.input.charCodeAt((this.state.pos += startSkip));\n if (this.state.pos < this.length) {\n while (!isNewLine(ch) && ++this.state.pos < this.length) {\n ch = this.input.charCodeAt(this.state.pos);\n }\n }\n\n // If we are doing a lookahead right now we need to advance the position (above code)\n // but we do not want to push the comment to the state.\n if (this.isLookahead) return;\n\n this.pushComment(\n false,\n this.input.slice(start + startSkip, this.state.pos),\n start,\n this.state.pos,\n startLoc,\n this.state.curPosition(),\n );\n }\n\n // Called at the start of the parse and after every token. Skips\n // whitespace and comments, and.\n\n skipSpace(): void {\n loop: while (this.state.pos < this.length) {\n const ch = this.input.charCodeAt(this.state.pos);\n switch (ch) {\n case charCodes.space:\n case charCodes.nonBreakingSpace:\n case charCodes.tab:\n ++this.state.pos;\n break;\n case charCodes.carriageReturn:\n if (\n this.input.charCodeAt(this.state.pos + 1) === charCodes.lineFeed\n ) {\n ++this.state.pos;\n }\n // fall through\n case charCodes.lineFeed:\n case charCodes.lineSeparator:\n case charCodes.paragraphSeparator:\n ++this.state.pos;\n ++this.state.curLine;\n this.state.lineStart = this.state.pos;\n break;\n\n case charCodes.slash:\n switch (this.input.charCodeAt(this.state.pos + 1)) {\n case charCodes.asterisk:\n this.skipBlockComment();\n break;\n\n case charCodes.slash:\n this.skipLineComment(2);\n break;\n\n default:\n break loop;\n }\n break;\n\n default:\n if (isWhitespace(ch)) {\n ++this.state.pos;\n } else {\n break loop;\n }\n }\n }\n }\n\n // Called at the end of every token. Sets `end`, `val`, and\n // maintains `context` and `exprAllowed`, and skips the space after\n // the token, so that the next one's `start` will point at the\n // right position.\n\n finishToken(type: TokenType, val: any): void {\n this.state.end = this.state.pos;\n this.state.endLoc = this.state.curPosition();\n const prevType = this.state.type;\n this.state.type = type;\n this.state.value = val;\n\n if (!this.isLookahead) this.updateContext(prevType);\n }\n\n // ### Token reading\n\n // This is the function that is called to fetch the next token. It\n // is somewhat obscure, because it works in character codes rather\n // than characters, and because operator parsing has been inlined\n // into it.\n //\n // All in the name of speed.\n\n // number sign is \"#\"\n readToken_numberSign(): void {\n if (this.state.pos === 0 && this.readToken_interpreter()) {\n return;\n }\n\n const nextPos = this.state.pos + 1;\n const next = this.input.charCodeAt(nextPos);\n if (next >= charCodes.digit0 && next <= charCodes.digit9) {\n throw this.raise(this.state.pos, Errors.UnexpectedDigitAfterHash);\n }\n\n if (\n next === charCodes.leftCurlyBrace ||\n (next === charCodes.leftSquareBracket && this.hasPlugin(\"recordAndTuple\"))\n ) {\n // When we see `#{`, it is likely to be a hash record.\n // However we don't yell at `#[` since users may intend to use \"computed private fields\",\n // which is not allowed in the spec. Throwing expecting recordAndTuple is\n // misleading\n this.expectPlugin(\"recordAndTuple\");\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"hash\") {\n throw this.raise(\n this.state.pos,\n next === charCodes.leftCurlyBrace\n ? Errors.RecordExpressionHashIncorrectStartSyntaxType\n : Errors.TupleExpressionHashIncorrectStartSyntaxType,\n );\n }\n\n if (next === charCodes.leftCurlyBrace) {\n // #{\n this.finishToken(tt.braceHashL);\n } else {\n // #[\n this.finishToken(tt.bracketHashL);\n }\n this.state.pos += 2;\n } else {\n this.finishOp(tt.hash, 1);\n }\n }\n\n readToken_dot(): void {\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next >= charCodes.digit0 && next <= charCodes.digit9) {\n this.readNumber(true);\n return;\n }\n\n if (\n next === charCodes.dot &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.dot\n ) {\n this.state.pos += 3;\n this.finishToken(tt.ellipsis);\n } else {\n ++this.state.pos;\n this.finishToken(tt.dot);\n }\n }\n\n readToken_slash(): void {\n // '/'\n if (this.state.exprAllowed && !this.state.inType) {\n ++this.state.pos;\n this.readRegexp();\n return;\n }\n\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.slash, 1);\n }\n }\n\n readToken_interpreter(): boolean {\n if (this.state.pos !== 0 || this.length < 2) return false;\n\n let ch = this.input.charCodeAt(this.state.pos + 1);\n if (ch !== charCodes.exclamationMark) return false;\n\n const start = this.state.pos;\n this.state.pos += 1;\n\n while (!isNewLine(ch) && ++this.state.pos < this.length) {\n ch = this.input.charCodeAt(this.state.pos);\n }\n\n const value = this.input.slice(start + 2, this.state.pos);\n\n this.finishToken(tt.interpreterDirective, value);\n\n return true;\n }\n\n readToken_mult_modulo(code: number): void {\n // '%*'\n let type = code === charCodes.asterisk ? tt.star : tt.modulo;\n let width = 1;\n let next = this.input.charCodeAt(this.state.pos + 1);\n const exprAllowed = this.state.exprAllowed;\n\n // Exponentiation operator **\n if (code === charCodes.asterisk && next === charCodes.asterisk) {\n width++;\n next = this.input.charCodeAt(this.state.pos + 2);\n type = tt.exponent;\n }\n\n if (next === charCodes.equalsTo && !exprAllowed) {\n width++;\n type = tt.assign;\n }\n\n this.finishOp(type, width);\n }\n\n readToken_pipe_amp(code: number): void {\n // '||' '&&' '||=' '&&='\n const next = this.input.charCodeAt(this.state.pos + 1);\n\n if (next === code) {\n if (this.input.charCodeAt(this.state.pos + 2) === charCodes.equalsTo) {\n this.finishOp(tt.assign, 3);\n } else {\n this.finishOp(\n code === charCodes.verticalBar ? tt.logicalOR : tt.logicalAND,\n 2,\n );\n }\n return;\n }\n\n if (code === charCodes.verticalBar) {\n // '|>'\n if (next === charCodes.greaterThan) {\n this.finishOp(tt.pipeline, 2);\n return;\n }\n // '|}'\n if (\n this.hasPlugin(\"recordAndTuple\") &&\n next === charCodes.rightCurlyBrace\n ) {\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"bar\") {\n throw this.raise(\n this.state.pos,\n Errors.RecordExpressionBarIncorrectEndSyntaxType,\n );\n }\n\n this.finishOp(tt.braceBarR, 2);\n return;\n }\n\n // '|]'\n if (\n this.hasPlugin(\"recordAndTuple\") &&\n next === charCodes.rightSquareBracket\n ) {\n if (this.getPluginOption(\"recordAndTuple\", \"syntaxType\") !== \"bar\") {\n throw this.raise(\n this.state.pos,\n Errors.TupleExpressionBarIncorrectEndSyntaxType,\n );\n }\n\n this.finishOp(tt.bracketBarR, 2);\n return;\n }\n }\n\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n return;\n }\n\n this.finishOp(\n code === charCodes.verticalBar ? tt.bitwiseOR : tt.bitwiseAND,\n 1,\n );\n }\n\n readToken_caret(): void {\n // '^'\n const next = this.input.charCodeAt(this.state.pos + 1);\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.bitwiseXOR, 1);\n }\n }\n\n readToken_plus_min(code: number): void {\n // '+-'\n const next = this.input.charCodeAt(this.state.pos + 1);\n\n if (next === code) {\n if (\n next === charCodes.dash &&\n !this.inModule &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.greaterThan &&\n (this.state.lastTokEnd === 0 || this.hasPrecedingLineBreak())\n ) {\n // A `-->` line comment\n this.skipLineComment(3);\n this.skipSpace();\n this.nextToken();\n return;\n }\n this.finishOp(tt.incDec, 2);\n return;\n }\n\n if (next === charCodes.equalsTo) {\n this.finishOp(tt.assign, 2);\n } else {\n this.finishOp(tt.plusMin, 1);\n }\n }\n\n readToken_lt_gt(code: number): void {\n // '<>'\n const next = this.input.charCodeAt(this.state.pos + 1);\n let size = 1;\n\n if (next === code) {\n size =\n code === charCodes.greaterThan &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.greaterThan\n ? 3\n : 2;\n if (this.input.charCodeAt(this.state.pos + size) === charCodes.equalsTo) {\n this.finishOp(tt.assign, size + 1);\n return;\n }\n this.finishOp(tt.bitShift, size);\n return;\n }\n\n if (\n next === charCodes.exclamationMark &&\n code === charCodes.lessThan &&\n !this.inModule &&\n this.input.charCodeAt(this.state.pos + 2) === charCodes.dash &&\n this.input.charCodeAt(this.state.pos + 3) === charCodes.dash\n ) {\n // `` line comment
- this.skipLineComment(3);
- this.skipSpace();
- return this.nextToken();
- }
- return this.finishOp(_tokentype.types.incDec, 2);
- }
- if (next === 61) return this.finishOp(_tokentype.types.assign, 2);
- return this.finishOp(_tokentype.types.plusMin, 1);
-};
-
-pp.readToken_lt_gt = function (code) {
- // '<>'
- var next = this.input.charCodeAt(this.pos + 1);
- var size = 1;
- if (next === code) {
- size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
- if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(_tokentype.types.assign, size + 1);
- return this.finishOp(_tokentype.types.bitShift, size);
- }
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && this.input.charCodeAt(this.pos + 3) == 45) {
- if (this.inModule) this.unexpected();
- // `` line comment
- this.skipLineComment(3)
- this.skipSpace()
- return this.nextToken()
- }
- return this.finishOp(tt.incDec, 2)
- }
- if (next === 61) return this.finishOp(tt.assign, 2)
- return this.finishOp(tt.plusMin, 1)
-}
-
-pp.readToken_lt_gt = function(code) { // '<>'
- let next = this.input.charCodeAt(this.pos + 1)
- let size = 1
- if (next === code) {
- size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2
- if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)
- return this.finishOp(tt.bitShift, size)
- }
- if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 &&
- this.input.charCodeAt(this.pos + 3) == 45) {
- if (this.inModule) this.unexpected()
- // `
+
+```js
+var err = createError(404, 'This video does not exist!')
+```
+
+- `status: 500` - the status code as a number
+- `message` - the message of the error, defaulting to node's text for that status code.
+- `properties` - custom properties to attach to the object
+
+### createError([status], [error], [properties])
+
+Extend the given `error` object with `createError.HttpError`
+properties. This will not alter the inheritance of the given
+`error` object, and the modified `error` object is the
+return value.
+
+
+
+```js
+fs.readFile('foo.txt', function (err, buf) {
+ if (err) {
+ if (err.code === 'ENOENT') {
+ var httpError = createError(404, err, { expose: false })
+ } else {
+ var httpError = createError(500, err)
+ }
+ }
+})
+```
+
+- `status` - the status code as a number
+- `error` - the error object to extend
+- `properties` - custom properties to attach to the object
+
+### new createError\[code || name\](\[msg]\))
+
+Create a new error object with the given message `msg`.
+The error object inherits from `createError.HttpError`.
+
+
+
+```js
+var err = new createError.NotFound()
+```
+
+- `code` - the status code as a number
+- `name` - the name of the error as a "bumpy case", i.e. `NotFound` or `InternalServerError`.
+
+#### List of all constructors
+
+|Status Code|Constructor Name |
+|-----------|-----------------------------|
+|400 |BadRequest |
+|401 |Unauthorized |
+|402 |PaymentRequired |
+|403 |Forbidden |
+|404 |NotFound |
+|405 |MethodNotAllowed |
+|406 |NotAcceptable |
+|407 |ProxyAuthenticationRequired |
+|408 |RequestTimeout |
+|409 |Conflict |
+|410 |Gone |
+|411 |LengthRequired |
+|412 |PreconditionFailed |
+|413 |PayloadTooLarge |
+|414 |URITooLong |
+|415 |UnsupportedMediaType |
+|416 |RangeNotSatisfiable |
+|417 |ExpectationFailed |
+|418 |ImATeapot |
+|421 |MisdirectedRequest |
+|422 |UnprocessableEntity |
+|423 |Locked |
+|424 |FailedDependency |
+|425 |UnorderedCollection |
+|426 |UpgradeRequired |
+|428 |PreconditionRequired |
+|429 |TooManyRequests |
+|431 |RequestHeaderFieldsTooLarge |
+|451 |UnavailableForLegalReasons |
+|500 |InternalServerError |
+|501 |NotImplemented |
+|502 |BadGateway |
+|503 |ServiceUnavailable |
+|504 |GatewayTimeout |
+|505 |HTTPVersionNotSupported |
+|506 |VariantAlsoNegotiates |
+|507 |InsufficientStorage |
+|508 |LoopDetected |
+|509 |BandwidthLimitExceeded |
+|510 |NotExtended |
+|511 |NetworkAuthenticationRequired|
+
+## License
+
+[MIT](LICENSE)
+
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/http-errors/master
+[coveralls-url]: https://coveralls.io/r/jshttp/http-errors?branch=master
+[node-image]: https://badgen.net/npm/node/http-errors
+[node-url]: https://nodejs.org/en/download
+[npm-downloads-image]: https://badgen.net/npm/dm/http-errors
+[npm-url]: https://npmjs.org/package/http-errors
+[npm-version-image]: https://badgen.net/npm/v/http-errors
+[travis-image]: https://badgen.net/travis/jshttp/http-errors/master
+[travis-url]: https://travis-ci.org/jshttp/http-errors
diff --git a/api/node_modules/body-parser/node_modules/http-errors/index.js b/api/node_modules/body-parser/node_modules/http-errors/index.js
new file mode 100644
index 000000000..10ca4adc0
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/http-errors/index.js
@@ -0,0 +1,266 @@
+/*!
+ * http-errors
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2016 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var deprecate = require('depd')('http-errors')
+var setPrototypeOf = require('setprototypeof')
+var statuses = require('statuses')
+var inherits = require('inherits')
+var toIdentifier = require('toidentifier')
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = createError
+module.exports.HttpError = createHttpErrorConstructor()
+
+// Populate exports for all constructors
+populateConstructorExports(module.exports, statuses.codes, module.exports.HttpError)
+
+/**
+ * Get the code class of a status code.
+ * @private
+ */
+
+function codeClass (status) {
+ return Number(String(status).charAt(0) + '00')
+}
+
+/**
+ * Create a new HTTP Error.
+ *
+ * @returns {Error}
+ * @public
+ */
+
+function createError () {
+ // so much arity going on ~_~
+ var err
+ var msg
+ var status = 500
+ var props = {}
+ for (var i = 0; i < arguments.length; i++) {
+ var arg = arguments[i]
+ if (arg instanceof Error) {
+ err = arg
+ status = err.status || err.statusCode || status
+ continue
+ }
+ switch (typeof arg) {
+ case 'string':
+ msg = arg
+ break
+ case 'number':
+ status = arg
+ if (i !== 0) {
+ deprecate('non-first-argument status code; replace with createError(' + arg + ', ...)')
+ }
+ break
+ case 'object':
+ props = arg
+ break
+ }
+ }
+
+ if (typeof status === 'number' && (status < 400 || status >= 600)) {
+ deprecate('non-error status code; use only 4xx or 5xx status codes')
+ }
+
+ if (typeof status !== 'number' ||
+ (!statuses[status] && (status < 400 || status >= 600))) {
+ status = 500
+ }
+
+ // constructor
+ var HttpError = createError[status] || createError[codeClass(status)]
+
+ if (!err) {
+ // create error
+ err = HttpError
+ ? new HttpError(msg)
+ : new Error(msg || statuses[status])
+ Error.captureStackTrace(err, createError)
+ }
+
+ if (!HttpError || !(err instanceof HttpError) || err.status !== status) {
+ // add properties to generic error
+ err.expose = status < 500
+ err.status = err.statusCode = status
+ }
+
+ for (var key in props) {
+ if (key !== 'status' && key !== 'statusCode') {
+ err[key] = props[key]
+ }
+ }
+
+ return err
+}
+
+/**
+ * Create HTTP error abstract base class.
+ * @private
+ */
+
+function createHttpErrorConstructor () {
+ function HttpError () {
+ throw new TypeError('cannot construct abstract class')
+ }
+
+ inherits(HttpError, Error)
+
+ return HttpError
+}
+
+/**
+ * Create a constructor for a client error.
+ * @private
+ */
+
+function createClientErrorConstructor (HttpError, name, code) {
+ var className = name.match(/Error$/) ? name : name + 'Error'
+
+ function ClientError (message) {
+ // create the error object
+ var msg = message != null ? message : statuses[code]
+ var err = new Error(msg)
+
+ // capture a stack trace to the construction point
+ Error.captureStackTrace(err, ClientError)
+
+ // adjust the [[Prototype]]
+ setPrototypeOf(err, ClientError.prototype)
+
+ // redefine the error message
+ Object.defineProperty(err, 'message', {
+ enumerable: true,
+ configurable: true,
+ value: msg,
+ writable: true
+ })
+
+ // redefine the error name
+ Object.defineProperty(err, 'name', {
+ enumerable: false,
+ configurable: true,
+ value: className,
+ writable: true
+ })
+
+ return err
+ }
+
+ inherits(ClientError, HttpError)
+ nameFunc(ClientError, className)
+
+ ClientError.prototype.status = code
+ ClientError.prototype.statusCode = code
+ ClientError.prototype.expose = true
+
+ return ClientError
+}
+
+/**
+ * Create a constructor for a server error.
+ * @private
+ */
+
+function createServerErrorConstructor (HttpError, name, code) {
+ var className = name.match(/Error$/) ? name : name + 'Error'
+
+ function ServerError (message) {
+ // create the error object
+ var msg = message != null ? message : statuses[code]
+ var err = new Error(msg)
+
+ // capture a stack trace to the construction point
+ Error.captureStackTrace(err, ServerError)
+
+ // adjust the [[Prototype]]
+ setPrototypeOf(err, ServerError.prototype)
+
+ // redefine the error message
+ Object.defineProperty(err, 'message', {
+ enumerable: true,
+ configurable: true,
+ value: msg,
+ writable: true
+ })
+
+ // redefine the error name
+ Object.defineProperty(err, 'name', {
+ enumerable: false,
+ configurable: true,
+ value: className,
+ writable: true
+ })
+
+ return err
+ }
+
+ inherits(ServerError, HttpError)
+ nameFunc(ServerError, className)
+
+ ServerError.prototype.status = code
+ ServerError.prototype.statusCode = code
+ ServerError.prototype.expose = false
+
+ return ServerError
+}
+
+/**
+ * Set the name of a function, if possible.
+ * @private
+ */
+
+function nameFunc (func, name) {
+ var desc = Object.getOwnPropertyDescriptor(func, 'name')
+
+ if (desc && desc.configurable) {
+ desc.value = name
+ Object.defineProperty(func, 'name', desc)
+ }
+}
+
+/**
+ * Populate the exports object with constructors for every error class.
+ * @private
+ */
+
+function populateConstructorExports (exports, codes, HttpError) {
+ codes.forEach(function forEachCode (code) {
+ var CodeError
+ var name = toIdentifier(statuses[code])
+
+ switch (codeClass(code)) {
+ case 400:
+ CodeError = createClientErrorConstructor(HttpError, name, code)
+ break
+ case 500:
+ CodeError = createServerErrorConstructor(HttpError, name, code)
+ break
+ }
+
+ if (CodeError) {
+ // export the constructor
+ exports[code] = CodeError
+ exports[name] = CodeError
+ }
+ })
+
+ // backwards-compatibility
+ exports["I'mateapot"] = deprecate.function(exports.ImATeapot,
+ '"I\'mateapot"; use "ImATeapot" instead')
+}
diff --git a/api/node_modules/body-parser/node_modules/http-errors/package.json b/api/node_modules/body-parser/node_modules/http-errors/package.json
new file mode 100644
index 000000000..96cd630d0
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/http-errors/package.json
@@ -0,0 +1,49 @@
+{
+ "name": "http-errors",
+ "description": "Create HTTP error objects",
+ "version": "1.7.2",
+ "author": "Jonathan Ong (http://jongleberry.com)",
+ "contributors": [
+ "Alan Plum ",
+ "Douglas Christopher Wilson "
+ ],
+ "license": "MIT",
+ "repository": "jshttp/http-errors",
+ "dependencies": {
+ "depd": "~1.1.2",
+ "inherits": "2.0.3",
+ "setprototypeof": "1.1.1",
+ "statuses": ">= 1.5.0 < 2",
+ "toidentifier": "1.0.0"
+ },
+ "devDependencies": {
+ "eslint": "5.13.0",
+ "eslint-config-standard": "12.0.0",
+ "eslint-plugin-import": "2.16.0",
+ "eslint-plugin-markdown": "1.0.0",
+ "eslint-plugin-node": "7.0.1",
+ "eslint-plugin-promise": "4.0.1",
+ "eslint-plugin-standard": "4.0.0",
+ "istanbul": "0.4.5",
+ "mocha": "5.2.0"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "scripts": {
+ "lint": "eslint --plugin markdown --ext js,md . && node ./scripts/lint-readme-list.js",
+ "test": "mocha --reporter spec --bail",
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
+ "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
+ },
+ "keywords": [
+ "http",
+ "error"
+ ],
+ "files": [
+ "index.js",
+ "HISTORY.md",
+ "LICENSE",
+ "README.md"
+ ]
+}
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/LICENSE b/api/node_modules/body-parser/node_modules/setprototypeof/LICENSE
new file mode 100644
index 000000000..61afa2f18
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2015, Wes Todd
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/README.md b/api/node_modules/body-parser/node_modules/setprototypeof/README.md
new file mode 100644
index 000000000..f120044b6
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/README.md
@@ -0,0 +1,31 @@
+# Polyfill for `Object.setPrototypeOf`
+
+[![NPM Version](https://img.shields.io/npm/v/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
+[![NPM Downloads](https://img.shields.io/npm/dm/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
+[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard)
+
+A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
+
+## Usage:
+
+```
+$ npm install --save setprototypeof
+```
+
+```javascript
+var setPrototypeOf = require('setprototypeof')
+
+var obj = {}
+setPrototypeOf(obj, {
+ foo: function () {
+ return 'bar'
+ }
+})
+obj.foo() // bar
+```
+
+TypeScript is also supported:
+
+```typescript
+import setPrototypeOf = require('setprototypeof')
+```
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/index.d.ts b/api/node_modules/body-parser/node_modules/setprototypeof/index.d.ts
new file mode 100644
index 000000000..f108ecd0a
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/index.d.ts
@@ -0,0 +1,2 @@
+declare function setPrototypeOf(o: any, proto: object | null): any;
+export = setPrototypeOf;
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/index.js b/api/node_modules/body-parser/node_modules/setprototypeof/index.js
new file mode 100644
index 000000000..81fd5d7af
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/index.js
@@ -0,0 +1,17 @@
+'use strict'
+/* eslint no-proto: 0 */
+module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties)
+
+function setProtoOf (obj, proto) {
+ obj.__proto__ = proto
+ return obj
+}
+
+function mixinProperties (obj, proto) {
+ for (var prop in proto) {
+ if (!obj.hasOwnProperty(prop)) {
+ obj[prop] = proto[prop]
+ }
+ }
+ return obj
+}
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/package.json b/api/node_modules/body-parser/node_modules/setprototypeof/package.json
new file mode 100644
index 000000000..41368e1b5
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "setprototypeof",
+ "version": "1.1.1",
+ "description": "A small polyfill for Object.setprototypeof",
+ "main": "index.js",
+ "typings": "index.d.ts",
+ "scripts": {
+ "test": "standard && mocha",
+ "testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11",
+ "testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t",
+ "node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion",
+ "node4": "NODE_VER=4 npm run testversion",
+ "node6": "NODE_VER=6 npm run testversion",
+ "node9": "NODE_VER=9 npm run testversion",
+ "node11": "NODE_VER=11 npm run testversion"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/wesleytodd/setprototypeof.git"
+ },
+ "keywords": [
+ "polyfill",
+ "object",
+ "setprototypeof"
+ ],
+ "author": "Wes Todd",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/wesleytodd/setprototypeof/issues"
+ },
+ "homepage": "https://github.com/wesleytodd/setprototypeof",
+ "devDependencies": {
+ "mocha": "^5.2.0",
+ "standard": "^12.0.1"
+ }
+}
diff --git a/api/node_modules/body-parser/node_modules/setprototypeof/test/index.js b/api/node_modules/body-parser/node_modules/setprototypeof/test/index.js
new file mode 100644
index 000000000..afeb4ddb2
--- /dev/null
+++ b/api/node_modules/body-parser/node_modules/setprototypeof/test/index.js
@@ -0,0 +1,24 @@
+'use strict'
+/* eslint-env mocha */
+/* eslint no-proto: 0 */
+var assert = require('assert')
+var setPrototypeOf = require('..')
+
+describe('setProtoOf(obj, proto)', function () {
+ it('should merge objects', function () {
+ var obj = { a: 1, b: 2 }
+ var proto = { b: 3, c: 4 }
+ var mergeObj = setPrototypeOf(obj, proto)
+
+ if (Object.getPrototypeOf) {
+ assert.strictEqual(Object.getPrototypeOf(obj), proto)
+ } else if ({ __proto__: [] } instanceof Array) {
+ assert.strictEqual(obj.__proto__, proto)
+ } else {
+ assert.strictEqual(obj.a, 1)
+ assert.strictEqual(obj.b, 2)
+ assert.strictEqual(obj.c, 4)
+ }
+ assert.strictEqual(mergeObj, obj)
+ })
+})
diff --git a/api/node_modules/body-parser/package.json b/api/node_modules/body-parser/package.json
index 3f6fe6db5..269ebf285 100644
--- a/api/node_modules/body-parser/package.json
+++ b/api/node_modules/body-parser/package.json
@@ -1,72 +1,38 @@
{
- "_from": "body-parser@1.18.2",
- "_id": "body-parser@1.18.2",
- "_inBundle": false,
- "_integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=",
- "_location": "/body-parser",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "body-parser@1.18.2",
- "name": "body-parser",
- "escapedName": "body-parser",
- "rawSpec": "1.18.2",
- "saveSpec": null,
- "fetchSpec": "1.18.2"
- },
- "_requiredBy": [
- "/express"
- ],
- "_resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz",
- "_shasum": "87678a19d84b47d859b83199bd59bce222b10454",
- "_spec": "body-parser@1.18.2",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/express",
- "bugs": {
- "url": "https://github.com/expressjs/body-parser/issues"
- },
- "bundleDependencies": false,
+ "name": "body-parser",
+ "description": "Node.js body parsing middleware",
+ "version": "1.19.0",
"contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- },
- {
- "name": "Jonathan Ong",
- "email": "me@jongleberry.com",
- "url": "http://jongleberry.com"
- }
+ "Douglas Christopher Wilson ",
+ "Jonathan Ong (http://jongleberry.com)"
],
+ "license": "MIT",
+ "repository": "expressjs/body-parser",
"dependencies": {
- "bytes": "3.0.0",
+ "bytes": "3.1.0",
"content-type": "~1.0.4",
"debug": "2.6.9",
- "depd": "~1.1.1",
- "http-errors": "~1.6.2",
- "iconv-lite": "0.4.19",
+ "depd": "~1.1.2",
+ "http-errors": "1.7.2",
+ "iconv-lite": "0.4.24",
"on-finished": "~2.3.0",
- "qs": "6.5.1",
- "raw-body": "2.3.2",
- "type-is": "~1.6.15"
+ "qs": "6.7.0",
+ "raw-body": "2.4.0",
+ "type-is": "~1.6.17"
},
- "deprecated": false,
- "description": "Node.js body parsing middleware",
"devDependencies": {
- "eslint": "3.19.0",
- "eslint-config-standard": "10.2.1",
- "eslint-plugin-import": "2.7.0",
- "eslint-plugin-markdown": "1.0.0-beta.6",
- "eslint-plugin-node": "5.1.1",
- "eslint-plugin-promise": "3.5.0",
- "eslint-plugin-standard": "3.0.1",
+ "eslint": "5.16.0",
+ "eslint-config-standard": "12.0.0",
+ "eslint-plugin-import": "2.17.2",
+ "eslint-plugin-markdown": "1.0.0",
+ "eslint-plugin-node": "8.0.1",
+ "eslint-plugin-promise": "4.1.1",
+ "eslint-plugin-standard": "4.0.0",
"istanbul": "0.4.5",
"methods": "1.1.2",
- "mocha": "2.5.3",
- "safe-buffer": "5.1.1",
- "supertest": "1.1.0"
- },
- "engines": {
- "node": ">= 0.8"
+ "mocha": "6.1.4",
+ "safe-buffer": "5.1.2",
+ "supertest": "4.0.2"
},
"files": [
"lib/",
@@ -74,18 +40,13 @@
"HISTORY.md",
"index.js"
],
- "homepage": "https://github.com/expressjs/body-parser#readme",
- "license": "MIT",
- "name": "body-parser",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/expressjs/body-parser.git"
+ "engines": {
+ "node": ">= 0.8"
},
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/"
- },
- "version": "1.18.2"
+ }
}
diff --git a/api/node_modules/bytes/History.md b/api/node_modules/bytes/History.md
index 13d463ab1..cf6a5bb9c 100644
--- a/api/node_modules/bytes/History.md
+++ b/api/node_modules/bytes/History.md
@@ -1,3 +1,8 @@
+3.1.0 / 2019-01-22
+==================
+
+ * Add petabyte (`pb`) support
+
3.0.0 / 2017-08-31
==================
diff --git a/api/node_modules/bytes/Readme.md b/api/node_modules/bytes/Readme.md
index 9b53745d1..6ad1ec6e2 100644
--- a/api/node_modules/bytes/Readme.md
+++ b/api/node_modules/bytes/Readme.md
@@ -83,6 +83,7 @@ Supported units and abbreviations are as follows and are case-insensitive:
* `mb` for megabytes
* `gb` for gigabytes
* `tb` for terabytes
+ * `pb` for petabytes
The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
@@ -108,18 +109,18 @@ bytes('1024');
// output: 1024
bytes(1024);
-// output: 1024
+// output: 1KB
```
## License
[MIT](LICENSE)
-[downloads-image]: https://img.shields.io/npm/dm/bytes.svg
+[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
+[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
+[downloads-image]: https://badgen.net/npm/dm/bytes
[downloads-url]: https://npmjs.org/package/bytes
-[npm-image]: https://img.shields.io/npm/v/bytes.svg
+[npm-image]: https://badgen.net/npm/node/bytes
[npm-url]: https://npmjs.org/package/bytes
-[travis-image]: https://img.shields.io/travis/visionmedia/bytes.js/master.svg
+[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master
[travis-url]: https://travis-ci.org/visionmedia/bytes.js
-[coveralls-image]: https://img.shields.io/coveralls/visionmedia/bytes.js/master.svg
-[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
diff --git a/api/node_modules/bytes/index.js b/api/node_modules/bytes/index.js
index 1e39afd1d..4975bfb0c 100644
--- a/api/node_modules/bytes/index.js
+++ b/api/node_modules/bytes/index.js
@@ -30,10 +30,11 @@ var map = {
kb: 1 << 10,
mb: 1 << 20,
gb: 1 << 30,
- tb: ((1 << 30) * 1024)
+ tb: Math.pow(1024, 4),
+ pb: Math.pow(1024, 5),
};
-var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb)$/i;
+var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
/**
* Convert the given value in bytes into a string or parse to string to an integer in bytes.
@@ -93,7 +94,9 @@ function format(value, options) {
var unit = (options && options.unit) || '';
if (!unit || !map[unit.toLowerCase()]) {
- if (mag >= map.tb) {
+ if (mag >= map.pb) {
+ unit = 'PB';
+ } else if (mag >= map.tb) {
unit = 'TB';
} else if (mag >= map.gb) {
unit = 'GB';
diff --git a/api/node_modules/bytes/package.json b/api/node_modules/bytes/package.json
index 10f32db28..72ee63d03 100644
--- a/api/node_modules/bytes/package.json
+++ b/api/node_modules/bytes/package.json
@@ -1,63 +1,13 @@
{
- "_from": "bytes@3.0.0",
- "_id": "bytes@3.0.0",
- "_inBundle": false,
- "_integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=",
- "_location": "/bytes",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "bytes@3.0.0",
- "name": "bytes",
- "escapedName": "bytes",
- "rawSpec": "3.0.0",
- "saveSpec": null,
- "fetchSpec": "3.0.0"
- },
- "_requiredBy": [
- "/body-parser",
- "/raw-body"
- ],
- "_resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
- "_shasum": "d32815404d689699f85a4ea4fa8755dd13a96048",
- "_spec": "bytes@3.0.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/body-parser",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca",
- "url": "http://tjholowaychuk.com"
- },
- "bugs": {
- "url": "https://github.com/visionmedia/bytes.js/issues"
- },
- "bundleDependencies": false,
- "contributors": [
- {
- "name": "Jed Watson",
- "email": "jed.watson@me.com"
- },
- {
- "name": "Théo FIDRY",
- "email": "theo.fidry@gmail.com"
- }
- ],
- "deprecated": false,
+ "name": "bytes",
"description": "Utility to parse a string bytes to bytes and vice-versa",
- "devDependencies": {
- "mocha": "2.5.3",
- "nyc": "10.3.2"
- },
- "engines": {
- "node": ">= 0.8"
- },
- "files": [
- "History.md",
- "LICENSE",
- "Readme.md",
- "index.js"
+ "version": "3.1.0",
+ "author": "TJ Holowaychuk (http://tjholowaychuk.com)",
+ "contributors": [
+ "Jed Watson ",
+ "Théo FIDRY "
],
- "homepage": "https://github.com/visionmedia/bytes.js#readme",
+ "license": "MIT",
"keywords": [
"byte",
"bytes",
@@ -67,16 +17,25 @@
"convert",
"converter"
],
- "license": "MIT",
- "name": "bytes",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/visionmedia/bytes.js.git"
+ "repository": "visionmedia/bytes.js",
+ "devDependencies": {
+ "eslint": "5.12.1",
+ "mocha": "5.2.0",
+ "nyc": "13.1.0"
+ },
+ "files": [
+ "History.md",
+ "LICENSE",
+ "Readme.md",
+ "index.js"
+ ],
+ "engines": {
+ "node": ">= 0.8"
},
"scripts": {
+ "lint": "eslint .",
"test": "mocha --check-leaks --reporter spec",
"test-ci": "nyc --reporter=text npm test",
"test-cov": "nyc --reporter=html --reporter=text npm test"
- },
- "version": "3.0.0"
+ }
}
diff --git a/api/node_modules/call-bind/.eslintignore b/api/node_modules/call-bind/.eslintignore
new file mode 100644
index 000000000..404abb221
--- /dev/null
+++ b/api/node_modules/call-bind/.eslintignore
@@ -0,0 +1 @@
+coverage/
diff --git a/api/node_modules/call-bind/.eslintrc b/api/node_modules/call-bind/.eslintrc
new file mode 100644
index 000000000..e5d3c9a94
--- /dev/null
+++ b/api/node_modules/call-bind/.eslintrc
@@ -0,0 +1,17 @@
+{
+ "root": true,
+
+ "extends": "@ljharb",
+
+ "rules": {
+ "func-name-matching": 0,
+ "id-length": 0,
+ "new-cap": [2, {
+ "capIsNewExceptions": [
+ "GetIntrinsic",
+ ],
+ }],
+ "no-magic-numbers": 0,
+ "operator-linebreak": [2, "before"],
+ },
+}
diff --git a/api/node_modules/call-bind/.github/FUNDING.yml b/api/node_modules/call-bind/.github/FUNDING.yml
new file mode 100644
index 000000000..c70c2ecdb
--- /dev/null
+++ b/api/node_modules/call-bind/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ljharb]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/call-bind
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/api/node_modules/call-bind/.nycrc b/api/node_modules/call-bind/.nycrc
new file mode 100644
index 000000000..1826526e0
--- /dev/null
+++ b/api/node_modules/call-bind/.nycrc
@@ -0,0 +1,13 @@
+{
+ "all": true,
+ "check-coverage": false,
+ "reporter": ["text-summary", "text", "html", "json"],
+ "lines": 86,
+ "statements": 85.93,
+ "functions": 82.43,
+ "branches": 76.06,
+ "exclude": [
+ "coverage",
+ "test"
+ ]
+}
diff --git a/api/node_modules/call-bind/CHANGELOG.md b/api/node_modules/call-bind/CHANGELOG.md
new file mode 100644
index 000000000..62a37279e
--- /dev/null
+++ b/api/node_modules/call-bind/CHANGELOG.md
@@ -0,0 +1,42 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v1.0.2](https://github.com/ljharb/call-bind/compare/v1.0.1...v1.0.2) - 2021-01-11
+
+### Commits
+
+- [Fix] properly include the receiver in the bound length [`dbae7bc`](https://github.com/ljharb/call-bind/commit/dbae7bc676c079a0d33c0a43e9ef92cb7b01345d)
+
+## [v1.0.1](https://github.com/ljharb/call-bind/compare/v1.0.0...v1.0.1) - 2021-01-08
+
+### Commits
+
+- [Tests] migrate tests to Github Actions [`b6db284`](https://github.com/ljharb/call-bind/commit/b6db284c36f8ccd195b88a6764fe84b7223a0da1)
+- [meta] do not publish github action workflow files [`ec7fe46`](https://github.com/ljharb/call-bind/commit/ec7fe46e60cfa4764ee943d2755f5e5a366e578e)
+- [Fix] preserve original function’s length when possible [`adbceaa`](https://github.com/ljharb/call-bind/commit/adbceaa3cac4b41ea78bb19d7ccdbaaf7e0bdadb)
+- [Tests] gather coverage data on every job [`d69e23c`](https://github.com/ljharb/call-bind/commit/d69e23cc65f101ba1d4c19bb07fa8eb0ec624be8)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`2fd3586`](https://github.com/ljharb/call-bind/commit/2fd3586c5d47b335364c14293114c6b625ae1f71)
+- [Deps] update `get-intrinsic` [`f23e931`](https://github.com/ljharb/call-bind/commit/f23e9318cc271c2add8bb38cfded85ee7baf8eee)
+- [Deps] update `get-intrinsic` [`72d9f44`](https://github.com/ljharb/call-bind/commit/72d9f44e184465ba8dd3fb48260bbcff234985f2)
+- [meta] fix FUNDING.yml [`e723573`](https://github.com/ljharb/call-bind/commit/e723573438c5a68dcec31fb5d96ea6b7e4a93be8)
+- [eslint] ignore coverage output [`15e76d2`](https://github.com/ljharb/call-bind/commit/15e76d28a5f43e504696401e5b31ebb78ee1b532)
+- [meta] add Automatic Rebase and Require Allow Edits workflows [`8fa4dab`](https://github.com/ljharb/call-bind/commit/8fa4dabb23ba3dd7bb92c9571c1241c08b56e4b6)
+
+## v1.0.0 - 2020-10-30
+
+### Commits
+
+- Initial commit [`306cf98`](https://github.com/ljharb/call-bind/commit/306cf98c7ec9e7ef66b653ec152277ac1381eb50)
+- Tests [`e10d0bb`](https://github.com/ljharb/call-bind/commit/e10d0bbdadc7a10ecedc9a1c035112d3e368b8df)
+- Implementation [`43852ed`](https://github.com/ljharb/call-bind/commit/43852eda0f187327b7fad2423ca972149a52bd65)
+- npm init [`408f860`](https://github.com/ljharb/call-bind/commit/408f860b773a2f610805fd3613d0d71bac1b6249)
+- [meta] add Automatic Rebase and Require Allow Edits workflows [`fb349b2`](https://github.com/ljharb/call-bind/commit/fb349b2e48defbec8b5ec8a8395cc8f69f220b13)
+- [meta] add `auto-changelog` [`c4001fc`](https://github.com/ljharb/call-bind/commit/c4001fc43031799ef908211c98d3b0fb2b60fde4)
+- [meta] add "funding"; create `FUNDING.yml` [`d4d6d29`](https://github.com/ljharb/call-bind/commit/d4d6d2974a14bc2e98830468eda7fe6d6a776717)
+- [Tests] add `npm run lint` [`dedfb98`](https://github.com/ljharb/call-bind/commit/dedfb98bd0ecefb08ddb9a94061bd10cde4332af)
+- Only apps should have lockfiles [`54ac776`](https://github.com/ljharb/call-bind/commit/54ac77653db45a7361dc153d2f478e743f110650)
+- [meta] add `safe-publish-latest` [`9ea8e43`](https://github.com/ljharb/call-bind/commit/9ea8e435b950ce9b705559cd651039f9bf40140f)
diff --git a/api/node_modules/call-bind/LICENSE b/api/node_modules/call-bind/LICENSE
new file mode 100644
index 000000000..48f05d01d
--- /dev/null
+++ b/api/node_modules/call-bind/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 Jordan Harband
+
+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.
diff --git a/api/node_modules/call-bind/README.md b/api/node_modules/call-bind/README.md
new file mode 100644
index 000000000..53649eb46
--- /dev/null
+++ b/api/node_modules/call-bind/README.md
@@ -0,0 +1,2 @@
+# call-bind
+Robustly `.call.bind()` a function.
diff --git a/api/node_modules/call-bind/callBound.js b/api/node_modules/call-bind/callBound.js
new file mode 100644
index 000000000..8374adfd0
--- /dev/null
+++ b/api/node_modules/call-bind/callBound.js
@@ -0,0 +1,15 @@
+'use strict';
+
+var GetIntrinsic = require('get-intrinsic');
+
+var callBind = require('./');
+
+var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf'));
+
+module.exports = function callBoundIntrinsic(name, allowMissing) {
+ var intrinsic = GetIntrinsic(name, !!allowMissing);
+ if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
+ return callBind(intrinsic);
+ }
+ return intrinsic;
+};
diff --git a/api/node_modules/call-bind/index.js b/api/node_modules/call-bind/index.js
new file mode 100644
index 000000000..6fa3e4af7
--- /dev/null
+++ b/api/node_modules/call-bind/index.js
@@ -0,0 +1,47 @@
+'use strict';
+
+var bind = require('function-bind');
+var GetIntrinsic = require('get-intrinsic');
+
+var $apply = GetIntrinsic('%Function.prototype.apply%');
+var $call = GetIntrinsic('%Function.prototype.call%');
+var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply);
+
+var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true);
+var $defineProperty = GetIntrinsic('%Object.defineProperty%', true);
+var $max = GetIntrinsic('%Math.max%');
+
+if ($defineProperty) {
+ try {
+ $defineProperty({}, 'a', { value: 1 });
+ } catch (e) {
+ // IE 8 has a broken defineProperty
+ $defineProperty = null;
+ }
+}
+
+module.exports = function callBind(originalFunction) {
+ var func = $reflectApply(bind, $call, arguments);
+ if ($gOPD && $defineProperty) {
+ var desc = $gOPD(func, 'length');
+ if (desc.configurable) {
+ // original length, plus the receiver, minus any additional arguments (after the receiver)
+ $defineProperty(
+ func,
+ 'length',
+ { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
+ );
+ }
+ }
+ return func;
+};
+
+var applyBind = function applyBind() {
+ return $reflectApply(bind, $apply, arguments);
+};
+
+if ($defineProperty) {
+ $defineProperty(module.exports, 'apply', { value: applyBind });
+} else {
+ module.exports.apply = applyBind;
+}
diff --git a/api/node_modules/call-bind/package.json b/api/node_modules/call-bind/package.json
new file mode 100644
index 000000000..4360556a7
--- /dev/null
+++ b/api/node_modules/call-bind/package.json
@@ -0,0 +1,80 @@
+{
+ "name": "call-bind",
+ "version": "1.0.2",
+ "description": "Robustly `.call.bind()` a function",
+ "main": "index.js",
+ "exports": {
+ ".": [
+ {
+ "default": "./index.js"
+ },
+ "./index.js"
+ ],
+ "./callBound": [
+ {
+ "default": "./callBound.js"
+ },
+ "./callBound.js"
+ ],
+ "./package.json": "./package.json"
+ },
+ "scripts": {
+ "prepublish": "safe-publish-latest",
+ "lint": "eslint --ext=.js,.mjs .",
+ "pretest": "npm run lint",
+ "tests-only": "nyc tape 'test/*'",
+ "test": "npm run tests-only",
+ "posttest": "aud --production",
+ "version": "auto-changelog && git add CHANGELOG.md",
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ljharb/call-bind.git"
+ },
+ "keywords": [
+ "javascript",
+ "ecmascript",
+ "es",
+ "js",
+ "callbind",
+ "callbound",
+ "call",
+ "bind",
+ "bound",
+ "call-bind",
+ "call-bound",
+ "function",
+ "es-abstract"
+ ],
+ "author": "Jordan Harband ",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/ljharb/call-bind/issues"
+ },
+ "homepage": "https://github.com/ljharb/call-bind#readme",
+ "devDependencies": {
+ "@ljharb/eslint-config": "^17.3.0",
+ "aud": "^1.1.3",
+ "auto-changelog": "^2.2.1",
+ "eslint": "^7.17.0",
+ "nyc": "^10.3.2",
+ "safe-publish-latest": "^1.1.4",
+ "tape": "^5.1.1"
+ },
+ "dependencies": {
+ "function-bind": "^1.1.1",
+ "get-intrinsic": "^1.0.2"
+ },
+ "auto-changelog": {
+ "output": "CHANGELOG.md",
+ "template": "keepachangelog",
+ "unreleased": false,
+ "commitLimit": false,
+ "backfillLimit": false,
+ "hideCredit": true
+ }
+}
diff --git a/api/node_modules/call-bind/test/callBound.js b/api/node_modules/call-bind/test/callBound.js
new file mode 100644
index 000000000..209ce3cc3
--- /dev/null
+++ b/api/node_modules/call-bind/test/callBound.js
@@ -0,0 +1,55 @@
+'use strict';
+
+var test = require('tape');
+
+var callBound = require('../callBound');
+
+test('callBound', function (t) {
+ // static primitive
+ t.equal(callBound('Array.length'), Array.length, 'Array.length yields itself');
+ t.equal(callBound('%Array.length%'), Array.length, '%Array.length% yields itself');
+
+ // static non-function object
+ t.equal(callBound('Array.prototype'), Array.prototype, 'Array.prototype yields itself');
+ t.equal(callBound('%Array.prototype%'), Array.prototype, '%Array.prototype% yields itself');
+ t.equal(callBound('Array.constructor'), Array.constructor, 'Array.constructor yields itself');
+ t.equal(callBound('%Array.constructor%'), Array.constructor, '%Array.constructor% yields itself');
+
+ // static function
+ t.equal(callBound('Date.parse'), Date.parse, 'Date.parse yields itself');
+ t.equal(callBound('%Date.parse%'), Date.parse, '%Date.parse% yields itself');
+
+ // prototype primitive
+ t.equal(callBound('Error.prototype.message'), Error.prototype.message, 'Error.prototype.message yields itself');
+ t.equal(callBound('%Error.prototype.message%'), Error.prototype.message, '%Error.prototype.message% yields itself');
+
+ // prototype function
+ t.notEqual(callBound('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString does not yield itself');
+ t.notEqual(callBound('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% does not yield itself');
+ t.equal(callBound('Object.prototype.toString')(true), Object.prototype.toString.call(true), 'call-bound Object.prototype.toString calls into the original');
+ t.equal(callBound('%Object.prototype.toString%')(true), Object.prototype.toString.call(true), 'call-bound %Object.prototype.toString% calls into the original');
+
+ t['throws'](
+ function () { callBound('does not exist'); },
+ SyntaxError,
+ 'nonexistent intrinsic throws'
+ );
+ t['throws'](
+ function () { callBound('does not exist', true); },
+ SyntaxError,
+ 'allowMissing arg still throws for unknown intrinsic'
+ );
+
+ /* globals WeakRef: false */
+ t.test('real but absent intrinsic', { skip: typeof WeakRef !== 'undefined' }, function (st) {
+ st['throws'](
+ function () { callBound('WeakRef'); },
+ TypeError,
+ 'real but absent intrinsic throws'
+ );
+ st.equal(callBound('WeakRef', true), undefined, 'allowMissing arg avoids exception');
+ st.end();
+ });
+
+ t.end();
+});
diff --git a/api/node_modules/call-bind/test/index.js b/api/node_modules/call-bind/test/index.js
new file mode 100644
index 000000000..bf6769c7c
--- /dev/null
+++ b/api/node_modules/call-bind/test/index.js
@@ -0,0 +1,66 @@
+'use strict';
+
+var callBind = require('../');
+var bind = require('function-bind');
+
+var test = require('tape');
+
+/*
+ * older engines have length nonconfigurable
+ * in io.js v3, it is configurable except on bound functions, hence the .bind()
+ */
+var functionsHaveConfigurableLengths = !!(
+ Object.getOwnPropertyDescriptor
+ && Object.getOwnPropertyDescriptor(bind.call(function () {}), 'length').configurable
+);
+
+test('callBind', function (t) {
+ var sentinel = { sentinel: true };
+ var func = function (a, b) {
+ // eslint-disable-next-line no-invalid-this
+ return [this, a, b];
+ };
+ t.equal(func.length, 2, 'original function length is 2');
+ t.deepEqual(func(), [undefined, undefined, undefined], 'unbound func with too few args');
+ t.deepEqual(func(1, 2), [undefined, 1, 2], 'unbound func with right args');
+ t.deepEqual(func(1, 2, 3), [undefined, 1, 2], 'unbound func with too many args');
+
+ var bound = callBind(func);
+ t.equal(bound.length, func.length + 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
+ t.deepEqual(bound(), [undefined, undefined, undefined], 'bound func with too few args');
+ t.deepEqual(bound(1, 2), [1, 2, undefined], 'bound func with right args');
+ t.deepEqual(bound(1, 2, 3), [1, 2, 3], 'bound func with too many args');
+
+ var boundR = callBind(func, sentinel);
+ t.equal(boundR.length, func.length, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
+ t.deepEqual(boundR(), [sentinel, undefined, undefined], 'bound func with receiver, with too few args');
+ t.deepEqual(boundR(1, 2), [sentinel, 1, 2], 'bound func with receiver, with right args');
+ t.deepEqual(boundR(1, 2, 3), [sentinel, 1, 2], 'bound func with receiver, with too many args');
+
+ var boundArg = callBind(func, sentinel, 1);
+ t.equal(boundArg.length, func.length - 1, 'function length is preserved', { skip: !functionsHaveConfigurableLengths });
+ t.deepEqual(boundArg(), [sentinel, 1, undefined], 'bound func with receiver and arg, with too few args');
+ t.deepEqual(boundArg(2), [sentinel, 1, 2], 'bound func with receiver and arg, with right arg');
+ t.deepEqual(boundArg(2, 3), [sentinel, 1, 2], 'bound func with receiver and arg, with too many args');
+
+ t.test('callBind.apply', function (st) {
+ var aBound = callBind.apply(func);
+ st.deepEqual(aBound(sentinel), [sentinel, undefined, undefined], 'apply-bound func with no args');
+ st.deepEqual(aBound(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args');
+ st.deepEqual(aBound(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args');
+
+ var aBoundArg = callBind.apply(func);
+ st.deepEqual(aBoundArg(sentinel, [1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with too many args');
+ st.deepEqual(aBoundArg(sentinel, [1, 2], 4), [sentinel, 1, 2], 'apply-bound func with right args');
+ st.deepEqual(aBoundArg(sentinel, [1], 4), [sentinel, 1, undefined], 'apply-bound func with too few args');
+
+ var aBoundR = callBind.apply(func, sentinel);
+ st.deepEqual(aBoundR([1, 2, 3], 4), [sentinel, 1, 2], 'apply-bound func with receiver and too many args');
+ st.deepEqual(aBoundR([1, 2], 4), [sentinel, 1, 2], 'apply-bound func with receiver and right args');
+ st.deepEqual(aBoundR([1], 4), [sentinel, 1, undefined], 'apply-bound func with receiver and too few args');
+
+ st.end();
+ });
+
+ t.end();
+});
diff --git a/api/node_modules/camelcase/index.js b/api/node_modules/camelcase/index.js
deleted file mode 100644
index b46e10094..000000000
--- a/api/node_modules/camelcase/index.js
+++ /dev/null
@@ -1,27 +0,0 @@
-'use strict';
-module.exports = function () {
- var str = [].map.call(arguments, function (str) {
- return str.trim();
- }).filter(function (str) {
- return str.length;
- }).join('-');
-
- if (!str.length) {
- return '';
- }
-
- if (str.length === 1 || !(/[_.\- ]+/).test(str) ) {
- if (str[0] === str[0].toLowerCase() && str.slice(1) !== str.slice(1).toLowerCase()) {
- return str;
- }
-
- return str.toLowerCase();
- }
-
- return str
- .replace(/^[_.\- ]+/, '')
- .toLowerCase()
- .replace(/[_.\- ]+(\w|$)/g, function (m, p1) {
- return p1.toUpperCase();
- });
-};
diff --git a/api/node_modules/camelcase/license b/api/node_modules/camelcase/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/api/node_modules/camelcase/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus (sindresorhus.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.
diff --git a/api/node_modules/camelcase/package.json b/api/node_modules/camelcase/package.json
deleted file mode 100644
index c3f20e600..000000000
--- a/api/node_modules/camelcase/package.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "_from": "camelcase@^1.0.2",
- "_id": "camelcase@1.2.1",
- "_inBundle": false,
- "_integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=",
- "_location": "/camelcase",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "camelcase@^1.0.2",
- "name": "camelcase",
- "escapedName": "camelcase",
- "rawSpec": "^1.0.2",
- "saveSpec": null,
- "fetchSpec": "^1.0.2"
- },
- "_requiredBy": [
- "/yargs"
- ],
- "_resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
- "_shasum": "9bb5304d2e0b56698b2c758b08a3eaa9daa58a39",
- "_spec": "camelcase@^1.0.2",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/yargs",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "http://sindresorhus.com"
- },
- "bugs": {
- "url": "https://github.com/sindresorhus/camelcase/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar",
- "devDependencies": {
- "ava": "0.0.4"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/sindresorhus/camelcase#readme",
- "keywords": [
- "camelcase",
- "camel-case",
- "camel",
- "case",
- "dash",
- "hyphen",
- "dot",
- "underscore",
- "separator",
- "string",
- "text",
- "convert"
- ],
- "license": "MIT",
- "name": "camelcase",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/sindresorhus/camelcase.git"
- },
- "scripts": {
- "test": "node test.js"
- },
- "version": "1.2.1"
-}
diff --git a/api/node_modules/camelcase/readme.md b/api/node_modules/camelcase/readme.md
deleted file mode 100644
index 516dc3984..000000000
--- a/api/node_modules/camelcase/readme.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# camelcase [![Build Status](https://travis-ci.org/sindresorhus/camelcase.svg?branch=master)](https://travis-ci.org/sindresorhus/camelcase)
-
-> Convert a dash/dot/underscore/space separated string to camelCase: `foo-bar` → `fooBar`
-
-
-## Install
-
-```sh
-$ npm install --save camelcase
-```
-
-
-## Usage
-
-```js
-var camelCase = require('camelcase');
-
-camelCase('foo-bar');
-//=> fooBar
-
-camelCase('foo_bar');
-//=> fooBar
-
-camelCase('Foo-Bar');
-//=> fooBar
-
-camelCase('--foo.bar');
-//=> fooBar
-
-camelCase('__foo__bar__');
-//=> fooBar
-
-camelCase('foo bar');
-//=> fooBar
-
-console.log(process.argv[3]);
-//=> --foo-bar
-camelCase(process.argv[3]);
-//=> fooBar
-
-camelCase('foo', 'bar');
-//=> fooBar
-
-camelCase('__foo__', '--bar');
-//=> fooBar
-```
-
-
-## Related
-
-See [`decamelize`](https://github.com/sindresorhus/decamelize) for the inverse.
-
-
-## License
-
-MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/api/node_modules/center-align/LICENSE b/api/node_modules/center-align/LICENSE
deleted file mode 100644
index 65f90aca8..000000000
--- a/api/node_modules/center-align/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2015, Jon Schlinkert.
-
-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.
diff --git a/api/node_modules/center-align/README.md b/api/node_modules/center-align/README.md
deleted file mode 100644
index cbcf3befc..000000000
--- a/api/node_modules/center-align/README.md
+++ /dev/null
@@ -1,74 +0,0 @@
-# center-align [![NPM version](https://badge.fury.io/js/center-align.svg)](http://badge.fury.io/js/center-align)
-
-> Center-align the text in a string.
-
-Install with [npm](https://www.npmjs.com/)
-
-```sh
-$ npm i center-align --save
-```
-
-## Usage
-
-```js
-var centerAlign = require('center-align');
-```
-
-**Example**
-
-If used on the following:
-
-```
-Lorem ipsum dolor sit amet,
-consectetur adipiscing
-elit, sed do eiusmod tempor incididunt
-ut labore et dolore
-magna aliqua. Ut enim ad minim
-veniam, quis
-```
-
-The result would be:
-
-```
- Lorem ipsum dolor sit amet,
- consectetur adipiscing
-elit, sed do eiusmod tempor incididunt
- ut labore et dolore
- magna aliqua. Ut enim ad minim
- veniam, quis
-```
-
-## Related projects
-
-* [align-text](https://www.npmjs.com/package/align-text): Align the text in a string. | [homepage](https://github.com/jonschlinkert/align-text)
-* [justified](https://www.npmjs.com/package/justified): Wrap words to a specified length and justified the text. | [homepage](https://github.com/jonschlinkert/justified)
-* [right-align](https://www.npmjs.com/package/right-align): Right-align the text in a string. | [homepage](https://github.com/jonschlinkert/right-align)
-* [word-wrap](https://www.npmjs.com/package/word-wrap): Wrap words to a specified length. | [homepage](https://github.com/jonschlinkert/word-wrap)
-
-## Running tests
-
-Install dev dependencies:
-
-```sh
-$ npm i -d && npm test
-```
-
-## Contributing
-
-Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/center-align/issues/new).
-
-## Author
-
-**Jon Schlinkert**
-
-+ [github/jonschlinkert](https://github.com/jonschlinkert)
-+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
-
-## License
-
-Copyright © 2015 Jon Schlinkert
-Released under the MIT license.
-
-***
-
-_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 27, 2015._
\ No newline at end of file
diff --git a/api/node_modules/center-align/index.js b/api/node_modules/center-align/index.js
deleted file mode 100644
index c6ed54a94..000000000
--- a/api/node_modules/center-align/index.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/*!
- * center-align
- *
- * Copycenter (c) 2015, Jon Schlinkert.
- * Licensed under the MIT License.
- */
-
-'use strict';
-
-var utils = require('./utils');
-
-module.exports = function centerAlign(val) {
- return utils.align(val, function (len, longest) {
- return Math.floor((longest - len) / 2);
- });
-};
diff --git a/api/node_modules/center-align/package.json b/api/node_modules/center-align/package.json
deleted file mode 100644
index 3ab1df88d..000000000
--- a/api/node_modules/center-align/package.json
+++ /dev/null
@@ -1,82 +0,0 @@
-{
- "_from": "center-align@^0.1.1",
- "_id": "center-align@0.1.3",
- "_inBundle": false,
- "_integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=",
- "_location": "/center-align",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "center-align@^0.1.1",
- "name": "center-align",
- "escapedName": "center-align",
- "rawSpec": "^0.1.1",
- "saveSpec": null,
- "fetchSpec": "^0.1.1"
- },
- "_requiredBy": [
- "/cliui"
- ],
- "_resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz",
- "_shasum": "aa0d32629b6ee972200411cbd4461c907bc2b7ad",
- "_spec": "center-align@^0.1.1",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/cliui",
- "author": {
- "name": "Jon Schlinkert",
- "url": "https://github.com/jonschlinkert"
- },
- "bugs": {
- "url": "https://github.com/jonschlinkert/center-align/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "align-text": "^0.1.3",
- "lazy-cache": "^1.0.3"
- },
- "deprecated": false,
- "description": "Center-align the text in a string.",
- "devDependencies": {
- "mocha": "^2.2.0"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "index.js",
- "utils.js"
- ],
- "homepage": "https://github.com/jonschlinkert/center-align",
- "keywords": [
- "align",
- "align-center",
- "center",
- "center-align",
- "right",
- "right-align",
- "text",
- "typography"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "center-align",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jonschlinkert/center-align.git"
- },
- "scripts": {
- "test": "mocha"
- },
- "verb": {
- "related": {
- "description": "",
- "list": [
- "align-text",
- "right-align",
- "justified",
- "word-wrap"
- ]
- }
- },
- "version": "0.1.3"
-}
diff --git a/api/node_modules/center-align/utils.js b/api/node_modules/center-align/utils.js
deleted file mode 100644
index aead6d2f0..000000000
--- a/api/node_modules/center-align/utils.js
+++ /dev/null
@@ -1,40 +0,0 @@
-'use strict';
-
-/**
- * Lazily-required module dependencies (makes the application
- * faster)
- */
-
-var utils = require('lazy-cache')(require);
-
-/**
- * Temporarily re-assign `require` to trick browserify and
- * webpack into reconizing lazy dependencies.
- *
- * This tiny bit of ugliness has the huge dual advantage of
- * only loading modules that are actually called at some
- * point in the lifecycle of the application, whilst also
- * allowing browserify and webpack to find modules that
- * are depended on but never actually called.
- */
-
-var fn = require;
-require = utils;
-
-/**
- * Lazily required module dependencies
- */
-
-require('align-text', 'align');
-
-/**
- * Restore `require`
- */
-
-require = fn;
-
-/**
- * Expose `utils` modules
- */
-
-module.exports = utils;
diff --git a/api/node_modules/character-parser/.npmignore b/api/node_modules/character-parser/.npmignore
deleted file mode 100644
index 2a7217433..000000000
--- a/api/node_modules/character-parser/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-test/
-.travis.yml
\ No newline at end of file
diff --git a/api/node_modules/character-parser/LICENSE b/api/node_modules/character-parser/LICENSE
deleted file mode 100644
index 2ecc0d14f..000000000
--- a/api/node_modules/character-parser/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2013 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.
diff --git a/api/node_modules/character-parser/README.md b/api/node_modules/character-parser/README.md
deleted file mode 100644
index 1ea313645..000000000
--- a/api/node_modules/character-parser/README.md
+++ /dev/null
@@ -1,142 +0,0 @@
-# character-parser
-
-Parse JavaScript one character at a time to look for snippets in Templates. This is not a validator, it's just designed to allow you to have sections of JavaScript delimited by brackets robustly.
-
-[![Build Status](https://img.shields.io/travis/ForbesLindesay/character-parser/master.svg)](https://travis-ci.org/ForbesLindesay/character-parser)
-
-## Installation
-
- npm install character-parser
-
-## Usage
-
-Work out how much depth changes:
-
-```js
-var state = parse('foo(arg1, arg2, {\n foo: [a, b\n');
-assert(state.roundDepth === 1);
-assert(state.curlyDepth === 1);
-assert(state.squareDepth === 1);
-parse(' c, d]\n })', state);
-assert(state.squareDepth === 0);
-assert(state.curlyDepth === 0);
-assert(state.roundDepth === 0);
-```
-
-### Bracketed Expressions
-
-Find all the contents of a bracketed expression:
-
-```js
-var section = parser.parseMax('foo="(", bar="}") bing bong');
-assert(section.start === 0);
-assert(section.end === 16);//exclusive end of string
-assert(section.src = 'foo="(", bar="}"');
-
-
-var section = parser.parseMax('{foo="(", bar="}"} bing bong', {start: 1});
-assert(section.start === 1);
-assert(section.end === 17);//exclusive end of string
-assert(section.src = 'foo="(", bar="}"');
-```
-
-The bracketed expression parsing simply parses up to but excluding the first unmatched closed bracket (`)`, `}`, `]`). It is clever enough to ignore brackets in comments or strings.
-
-
-### Custom Delimited Expressions
-
-Find code up to a custom delimiter:
-
-```js
-var section = parser.parseUntil('foo.bar("%>").baz%> bing bong', '%>');
-assert(section.start === 0);
-assert(section.end === 17);//exclusive end of string
-assert(section.src = 'foo.bar("%>").baz');
-
-var section = parser.parseUntil('<%foo.bar("%>").baz%> bing bong', '%>', {start: 2});
-assert(section.start === 2);
-assert(section.end === 19);//exclusive end of string
-assert(section.src = 'foo.bar("%>").baz');
-```
-
-Delimiters are ignored if they are inside strings or comments.
-
-## API
-
-### parse(str, state = defaultState(), options = {start: 0, end: src.length})
-
-Parse a string starting at the index start, and return the state after parsing that string.
-
-If you want to parse one string in multiple sections you should keep passing the resulting state to the next parse operation.
-
-Returns a `State` object.
-
-### parseMax(src, options = {start: 0})
-
-Parses the source until the first unmatched close bracket (any of `)`, `}`, `]`). It returns an object with the structure:
-
-```js
-{
- start: 0,//index of first character of string
- end: 13,//index of first character after the end of string
- src: 'source string'
-}
-```
-
-### parseUntil(src, delimiter, options = {start: 0, includeLineComment: false})
-
-Parses the source until the first occurence of `delimiter` which is not in a string or a comment. If `includeLineComment` is `true`, it will still count if the delimiter occurs in a line comment, but not in a block comment. It returns an object with the structure:
-
-```js
-{
- start: 0,//index of first character of string
- end: 13,//index of first character after the end of string
- src: 'source string'
-}
-```
-
-### parseChar(character, state = defaultState())
-
-Parses the single character and returns the state. See `parse` for the structure of the returned state object. N.B. character must be a single character not a multi character string.
-
-### defaultState()
-
-Get a default starting state.
-
-### isPunctuator(character)
-
-Returns `true` if `character` represents punctuation in JavaScript.
-
-### isKeyword(name)
-
-Returns `true` if `name` is a keyword in JavaScript.
-
-## State
-
-A state is an object with the following structure
-
-```js
-{
- lineComment: false, //true if inside a line comment
- blockComment: false, //true if inside a block comment
-
- singleQuote: false, //true if inside a single quoted string
- doubleQuote: false, //true if inside a double quoted string
- regexp: false, //true if inside a regular expression
- escaped: false, //true if in a string and the last character was an escape character
-
- roundDepth: 0, //number of un-closed open `(` brackets
- curlyDepth: 0, //number of un-closed open `{` brackets
- squareDepth: 0 //number of un-closed open `[` brackets
-}
-```
-
-It also has the following useful methods:
-
-- `.isString()` returns `true` if the current location is inside a string.
-- `.isComment()` returns `true` if the current location is inside a comment.
-- `isNesting()` returns `true` if the current location is anything but at the top level, i.e. with no nesting.
-
-## License
-
-MIT
\ No newline at end of file
diff --git a/api/node_modules/character-parser/index.js b/api/node_modules/character-parser/index.js
deleted file mode 100644
index 08afbcd4e..000000000
--- a/api/node_modules/character-parser/index.js
+++ /dev/null
@@ -1,231 +0,0 @@
-exports = (module.exports = parse);
-exports.parse = parse;
-function parse(src, state, options) {
- options = options || {};
- state = state || exports.defaultState();
- var start = options.start || 0;
- var end = options.end || src.length;
- var index = start;
- while (index < end) {
- if (state.roundDepth < 0 || state.curlyDepth < 0 || state.squareDepth < 0) {
- throw new SyntaxError('Mismatched Bracket: ' + src[index - 1]);
- }
- exports.parseChar(src[index++], state);
- }
- return state;
-}
-
-exports.parseMax = parseMax;
-function parseMax(src, options) {
- options = options || {};
- var start = options.start || 0;
- var index = start;
- var state = exports.defaultState();
- while (state.roundDepth >= 0 && state.curlyDepth >= 0 && state.squareDepth >= 0) {
- if (index >= src.length) {
- throw new Error('The end of the string was reached with no closing bracket found.');
- }
- exports.parseChar(src[index++], state);
- }
- var end = index - 1;
- return {
- start: start,
- end: end,
- src: src.substring(start, end)
- };
-}
-
-exports.parseUntil = parseUntil;
-function parseUntil(src, delimiter, options) {
- options = options || {};
- var includeLineComment = options.includeLineComment || false;
- var start = options.start || 0;
- var index = start;
- var state = exports.defaultState();
- while (state.isString() || state.regexp || state.blockComment ||
- (!includeLineComment && state.lineComment) || !startsWith(src, delimiter, index)) {
- exports.parseChar(src[index++], state);
- }
- var end = index;
- return {
- start: start,
- end: end,
- src: src.substring(start, end)
- };
-}
-
-
-exports.parseChar = parseChar;
-function parseChar(character, state) {
- if (character.length !== 1) throw new Error('Character must be a string of length 1');
- state = state || exports.defaultState();
- state.src = state.src || '';
- state.src += character;
- var wasComment = state.blockComment || state.lineComment;
- var lastChar = state.history ? state.history[0] : '';
-
- if (state.regexpStart) {
- if (character === '/' || character == '*') {
- state.regexp = false;
- }
- state.regexpStart = false;
- }
- if (state.lineComment) {
- if (character === '\n') {
- state.lineComment = false;
- }
- } else if (state.blockComment) {
- if (state.lastChar === '*' && character === '/') {
- state.blockComment = false;
- }
- } else if (state.singleQuote) {
- if (character === '\'' && !state.escaped) {
- state.singleQuote = false;
- } else if (character === '\\' && !state.escaped) {
- state.escaped = true;
- } else {
- state.escaped = false;
- }
- } else if (state.doubleQuote) {
- if (character === '"' && !state.escaped) {
- state.doubleQuote = false;
- } else if (character === '\\' && !state.escaped) {
- state.escaped = true;
- } else {
- state.escaped = false;
- }
- } else if (state.regexp) {
- if (character === '/' && !state.escaped) {
- state.regexp = false;
- } else if (character === '\\' && !state.escaped) {
- state.escaped = true;
- } else {
- state.escaped = false;
- }
- } else if (lastChar === '/' && character === '/') {
- state.history = state.history.substr(1);
- state.lineComment = true;
- } else if (lastChar === '/' && character === '*') {
- state.history = state.history.substr(1);
- state.blockComment = true;
- } else if (character === '/' && isRegexp(state.history)) {
- state.regexp = true;
- state.regexpStart = true;
- } else if (character === '\'') {
- state.singleQuote = true;
- } else if (character === '"') {
- state.doubleQuote = true;
- } else if (character === '(') {
- state.roundDepth++;
- } else if (character === ')') {
- state.roundDepth--;
- } else if (character === '{') {
- state.curlyDepth++;
- } else if (character === '}') {
- state.curlyDepth--;
- } else if (character === '[') {
- state.squareDepth++;
- } else if (character === ']') {
- state.squareDepth--;
- }
- if (!state.blockComment && !state.lineComment && !wasComment) state.history = character + state.history;
- state.lastChar = character; // store last character for ending block comments
- return state;
-}
-
-exports.defaultState = function () { return new State() };
-function State() {
- this.lineComment = false;
- this.blockComment = false;
-
- this.singleQuote = false;
- this.doubleQuote = false;
- this.regexp = false;
-
- this.escaped = false;
-
- this.roundDepth = 0;
- this.curlyDepth = 0;
- this.squareDepth = 0;
-
- this.history = ''
- this.lastChar = ''
-}
-State.prototype.isString = function () {
- return this.singleQuote || this.doubleQuote;
-}
-State.prototype.isComment = function () {
- return this.lineComment || this.blockComment;
-}
-State.prototype.isNesting = function () {
- return this.isString() || this.isComment() || this.regexp || this.roundDepth > 0 || this.curlyDepth > 0 || this.squareDepth > 0
-}
-
-function startsWith(str, start, i) {
- return str.substr(i || 0, start.length) === start;
-}
-
-exports.isPunctuator = isPunctuator
-function isPunctuator(c) {
- if (!c) return true; // the start of a string is a punctuator
- var code = c.charCodeAt(0)
-
- switch (code) {
- case 46: // . dot
- case 40: // ( open bracket
- case 41: // ) close bracket
- case 59: // ; semicolon
- case 44: // , comma
- case 123: // { open curly brace
- case 125: // } close curly brace
- case 91: // [
- case 93: // ]
- case 58: // :
- case 63: // ?
- case 126: // ~
- case 37: // %
- case 38: // &
- case 42: // *:
- case 43: // +
- case 45: // -
- case 47: // /
- case 60: // <
- case 62: // >
- case 94: // ^
- case 124: // |
- case 33: // !
- case 61: // =
- return true;
- default:
- return false;
- }
-}
-exports.isKeyword = isKeyword
-function isKeyword(id) {
- return (id === 'if') || (id === 'in') || (id === 'do') || (id === 'var') || (id === 'for') || (id === 'new') ||
- (id === 'try') || (id === 'let') || (id === 'this') || (id === 'else') || (id === 'case') ||
- (id === 'void') || (id === 'with') || (id === 'enum') || (id === 'while') || (id === 'break') || (id === 'catch') ||
- (id === 'throw') || (id === 'const') || (id === 'yield') || (id === 'class') || (id === 'super') ||
- (id === 'return') || (id === 'typeof') || (id === 'delete') || (id === 'switch') || (id === 'export') ||
- (id === 'import') || (id === 'default') || (id === 'finally') || (id === 'extends') || (id === 'function') ||
- (id === 'continue') || (id === 'debugger') || (id === 'package') || (id === 'private') || (id === 'interface') ||
- (id === 'instanceof') || (id === 'implements') || (id === 'protected') || (id === 'public') || (id === 'static') ||
- (id === 'yield') || (id === 'let');
-}
-
-function isRegexp(history) {
- //could be start of regexp or divide sign
-
- history = history.replace(/^\s*/, '');
-
- //unless its an `if`, `while`, `for` or `with` it's a divide, so we assume it's a divide
- if (history[0] === ')') return false;
- //unless it's a function expression, it's a regexp, so we assume it's a regexp
- if (history[0] === '}') return true;
- //any punctuation means it's a regexp
- if (isPunctuator(history[0])) return true;
- //if the last thing was a keyword then it must be a regexp (e.g. `typeof /foo/`)
- if (/^\w+\b/.test(history) && isKeyword(/^\w+\b/.exec(history)[0].split('').reverse().join(''))) return true;
-
- return false;
-}
diff --git a/api/node_modules/character-parser/package.json b/api/node_modules/character-parser/package.json
deleted file mode 100644
index ce78e18a5..000000000
--- a/api/node_modules/character-parser/package.json
+++ /dev/null
@@ -1,60 +0,0 @@
-{
- "_from": "character-parser@1.2.1",
- "_id": "character-parser@1.2.1",
- "_inBundle": false,
- "_integrity": "sha1-wN3kqxgnE7kZuXCVmhI+zBow/NY=",
- "_location": "/character-parser",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "character-parser@1.2.1",
- "name": "character-parser",
- "escapedName": "character-parser",
- "rawSpec": "1.2.1",
- "saveSpec": null,
- "fetchSpec": "1.2.1"
- },
- "_requiredBy": [
- "/jade"
- ],
- "_resolved": "https://registry.npmjs.org/character-parser/-/character-parser-1.2.1.tgz",
- "_shasum": "c0dde4ab182713b919b970959a123ecc1a30fcd6",
- "_spec": "character-parser@1.2.1",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/jade",
- "author": {
- "name": "ForbesLindesay"
- },
- "bugs": {
- "url": "https://github.com/ForbesLindesay/character-parser/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Parse JavaScript one character at a time to look for snippets in Templates. This is not a validator, it's just designed to allow you to have sections of JavaScript delimited by brackets robustly.",
- "devDependencies": {
- "better-assert": "~1.0.0",
- "mocha": "~1.9.0"
- },
- "homepage": "https://github.com/ForbesLindesay/character-parser#readme",
- "keywords": [
- "parser",
- "JavaScript",
- "bracket",
- "nesting",
- "comment",
- "string",
- "escape",
- "escaping"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "character-parser",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/ForbesLindesay/character-parser.git"
- },
- "scripts": {
- "test": "mocha -R spec"
- },
- "version": "1.2.1"
-}
diff --git a/api/node_modules/clean-css/History.md b/api/node_modules/clean-css/History.md
deleted file mode 100644
index 2d6a203fa..000000000
--- a/api/node_modules/clean-css/History.md
+++ /dev/null
@@ -1,1138 +0,0 @@
-[3.4.28 / 2017-07-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.27...v3.4.28)
-==================
-
-* Backports [#957](https://github.com/jakubpawlowicz/clean-css/issues/957) - `0%` minification of `width` property.
-
-[3.4.27 / 2017-06-09](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.26...v3.4.27)
-==================
-
-* Fixes [#948](https://github.com/jakubpawlowicz/clean-css/issues/948) - enforces line break before source map comment.
-
-[3.4.26 / 2017-05-10](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.25...v3.4.26)
-==================
-
-* Backports [#939](https://github.com/jakubpawlowicz/clean-css/issues/939) - semicolon after `@apply` at-rule.
-
-[3.4.25 / 2017-02-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.24...v3.4.25)
-==================
-
-* Fixed issue [#897](https://github.com/jakubpawlowicz/clean-css/issues/897) - tokenization with escaped markers.
-
-[3.4.24 / 2017-01-20](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.23...v3.4.24)
-==================
-
-* Fixed issue [#859](https://github.com/jakubpawlowicz/clean-css/issues/859) - avoid `-webkit-border-radius` optimizations.
-
-[3.4.23 / 2016-12-17](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.22...v3.4.23)
-==================
-
-* Fixed issue [#844](https://github.com/jakubpawlowicz/clean-css/issues/844) - regression in property values extraction.
-
-[3.4.22 / 2016-12-12](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.21...v3.4.22)
-==================
-
-* Fixed issue [#841](https://github.com/jakubpawlowicz/clean-css/issues/841) - disabled importing and files passed as array.
-* Ignores `@import` at-rules if appearing after any non-`@import` rules.
-
-[3.4.21 / 2016-11-16](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.20...v3.4.21)
-==================
-
-* Fixed issue [#821](https://github.com/jakubpawlowicz/clean-css/issues/821) - reducing non-adjacent rules.
-* Fixed issue [#830](https://github.com/jakubpawlowicz/clean-css/issues/830) - reordering border-* properties.
-* Fixed issue [#833](https://github.com/jakubpawlowicz/clean-css/issues/833) - moving `@media` queries.
-
-[3.4.20 / 2016-09-26](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.19...v3.4.20)
-==================
-
-* Fixed issue [#814](https://github.com/jakubpawlowicz/clean-css/issues/814) - `:selection` rule merging.
-
-[3.4.19 / 2016-07-25](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.18...v3.4.19)
-==================
-
-* Fixed issue [#795](https://github.com/jakubpawlowicz/clean-css/issues/795) - `!important` and override compacting.
-
-[3.4.18 / 2016-06-15](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.17...v3.4.18)
-==================
-
-* Fixed issue [#787](https://github.com/jakubpawlowicz/clean-css/issues/787) - regression in processing data URIs.
-
-[3.4.17 / 2016-06-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.16...v3.4.17)
-==================
-
-* Fixed issue [#783](https://github.com/jakubpawlowicz/clean-css/issues/783) - regression in processing data URIs.
-
-[3.4.16 / 2016-06-02](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.15...v3.4.16)
-==================
-
-* Fixed issue [#781](https://github.com/jakubpawlowicz/clean-css/issues/781) - regression in override compacting.
-* Fixed issue [#782](https://github.com/jakubpawlowicz/clean-css/issues/782) - regression in processing data URIs.
-
-[3.4.15 / 2016-06-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.14...v3.4.15)
-==================
-
-* Fixed issue [#776](https://github.com/jakubpawlowicz/clean-css/issues/776) - edge case in quoted data URIs.
-* Fixed issue [#779](https://github.com/jakubpawlowicz/clean-css/issues/779) - merging `background-(position|size)`.
-* Fixed issue [#780](https://github.com/jakubpawlowicz/clean-css/issues/780) - space after inlined variables.
-
-[3.4.14 / 2016-05-31](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.13...v3.4.14)
-==================
-
-* Fixed issue [#751](https://github.com/jakubpawlowicz/clean-css/issues/751) - stringifying CSS variables.
-* Fixed issue [#763](https://github.com/jakubpawlowicz/clean-css/issues/763) - data URI SVG and quoting.
-* Fixed issue [#765](https://github.com/jakubpawlowicz/clean-css/issues/765) - two values of border-radius.
-* Fixed issue [#768](https://github.com/jakubpawlowicz/clean-css/issues/768) - invalid border-radius property.
-
-[3.4.13 / 2016-05-23](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.12...v3.4.13)
-==================
-
-* Fixed issue [#734](https://github.com/jakubpawlowicz/clean-css/issues/769) - Node.js 6.x support.
-
-[3.4.12 / 2016-04-09](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.11...v3.4.12)
-==================
-
-* Fixed issue [#734](https://github.com/jakubpawlowicz/clean-css/issues/734) - `--root` option edge case.
-* Fixed issue [#758](https://github.com/jakubpawlowicz/clean-css/issues/758) - treats empty rule as unmergeable.
-
-[3.4.11 / 2016-04-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.10...v3.4.11)
-==================
-
-* Fixed issue [#738](https://github.com/jakubpawlowicz/clean-css/issues/738) - edge case in comment processing.
-* Fixed issue [#741](https://github.com/jakubpawlowicz/clean-css/issues/741) - HTTP proxy with HTTPS inlining.
-* Fixed issue [#743](https://github.com/jakubpawlowicz/clean-css/issues/743) - background shorthand and source maps.
-* Fixed issue [#745](https://github.com/jakubpawlowicz/clean-css/issues/745) - matching mixed case `!important`.
-
-[3.4.10 / 2016-02-29](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.9...v3.4.10)
-==================
-
-* Fixed issue [#735](https://github.com/jakubpawlowicz/clean-css/issues/735) - whitespace removal with escaped chars.
-
-[3.4.9 / 2016-01-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.8...v3.4.9)
-==================
-
-* Sped up merging by body advanced optimization.
-* Fixed issue [#693](https://github.com/jakubpawlowicz/clean-css/issues/693) - restructuring edge case.
-* Fixed issue [#711](https://github.com/jakubpawlowicz/clean-css/issues/711) - border fuzzy matching.
-* Fixed issue [#714](https://github.com/jakubpawlowicz/clean-css/issues/714) - stringifying property level at rules.
-* Fixed issue [#715](https://github.com/jakubpawlowicz/clean-css/issues/715) - stack too deep in comment scan.
-
-[3.4.8 / 2015-11-13](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.7...v3.4.8)
-==================
-
-* Fixed issue [#676](https://github.com/jakubpawlowicz/clean-css/issues/676) - fuzzy matching unqoted data URIs.
-
-[3.4.7 / 2015-11-10](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.6...v3.4.7)
-==================
-
-* Fixed issue [#692](https://github.com/jakubpawlowicz/clean-css/issues/692) - edge case in URL quoting.
-* Fixed issue [#695](https://github.com/jakubpawlowicz/clean-css/issues/695) - shorthand overriding edge case.
-* Fixed issue [#699](https://github.com/jakubpawlowicz/clean-css/issues/699) - IE9 transparent hack.
-* Fixed issue [#701](https://github.com/jakubpawlowicz/clean-css/issues/701) - `url` quoting with hash arguments.
-
-[3.4.6 / 2015-10-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.5...v3.4.6)
-==================
-
-* Fixed issue [#679](https://github.com/jakubpawlowicz/clean-css/issues/679) - wrong rebasing of remote URLs.
-
-[3.4.5 / 2015-09-28](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.4...v3.4.5)
-==================
-
-* Fixed issue [#681](https://github.com/jakubpawlowicz/clean-css/issues/681) - property inheritance & restructuring.
-* Fixed issue [#675](https://github.com/jakubpawlowicz/clean-css/issues/675) - overriding with `!important`.
-
-[3.4.4 / 2015-09-21](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.3...v3.4.4)
-==================
-
-* Fixed issue [#626](https://github.com/jakubpawlowicz/clean-css/issues/626) - edge case in import rebasing.
-* Fixed issue [#674](https://github.com/jakubpawlowicz/clean-css/issues/674) - adjacent merging order.
-
-[3.4.3 / 2015-09-15](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.2...v3.4.3)
-==================
-
-* Fixed issue [#668](https://github.com/jakubpawlowicz/clean-css/issues/668) - node v4 path.join.
-* Fixed issue [#669](https://github.com/jakubpawlowicz/clean-css/issues/669) - adjacent overriding with `!important`.
-
-[3.4.2 / 2015-09-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.1...v3.4.2)
-==================
-
-* Fixed issue [#598](https://github.com/jakubpawlowicz/clean-css/issues/598) - restructuring border properties.
-* Fixed issue [#654](https://github.com/jakubpawlowicz/clean-css/issues/654) - disables length optimizations.
-* Fixed issue [#655](https://github.com/jakubpawlowicz/clean-css/issues/655) - shorthands override merging.
-* Fixed issue [#660](https://github.com/jakubpawlowicz/clean-css/issues/660) - !important token overriding.
-* Fixed issue [#662](https://github.com/jakubpawlowicz/clean-css/issues/662) - !important selector reducing.
-* Fixed issue [#667](https://github.com/jakubpawlowicz/clean-css/issues/667) - rebasing remote URLs.
-
-[3.4.1 / 2015-08-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.4.0...v3.4.1)
-==================
-
-* Fixed issue [#652](https://github.com/jakubpawlowicz/clean-css/issues/652) - order of restoring and removing tokens.
-
-[3.4.0 / 2015-08-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.10...v3.4.0)
-==================
-
-* Adds an option for a fine-grained `@import` control.
-* Adds unit compatibility switches to disable length optimizations.
-* Adds inferring proxy settings from HTTP_PROXY environment variable.
-* Adds support for Polymer / Web Components special selectors.
-* Adds support for Polymer mixins.
-* Adds testing source maps in batch mode.
-* Unifies wrappers for simple & advanced optimizations.
-* Fixed issue [#596](https://github.com/jakubpawlowicz/clean-css/issues/596) - support for !ie IE<8 hack.
-* Fixed issue [#599](https://github.com/jakubpawlowicz/clean-css/issues/599) - support for inlined source maps.
-* Fixed issue [#607](https://github.com/jakubpawlowicz/clean-css/issues/607) - adds better rule reordering.
-* Fixed issue [#612](https://github.com/jakubpawlowicz/clean-css/issues/612) - adds HTTP proxy support.
-* Fixed issue [#618](https://github.com/jakubpawlowicz/clean-css/issues/618) - adds safer function validation.
-* Fixed issue [#625](https://github.com/jakubpawlowicz/clean-css/issues/625) - adds length unit optimizations.
-* Fixed issue [#632](https://github.com/jakubpawlowicz/clean-css/issues/632) - adds disabling remote `import`s.
-* Fixed issue [#635](https://github.com/jakubpawlowicz/clean-css/issues/635) - adds safer `0%` optimizations.
-* Fixed issue [#644](https://github.com/jakubpawlowicz/clean-css/issues/644) - adds time unit optimizations.
-* Fixed issue [#645](https://github.com/jakubpawlowicz/clean-css/issues/645) - adds bottom to top `media` merging.
-* Fixed issue [#648](https://github.com/jakubpawlowicz/clean-css/issues/648) - adds property level at-rule support.
-
-[3.3.10 / 2015-08-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.9...v3.3.10)
-==================
-
-* Adds better comments + keepBreaks handling.
-* Adds better text normalizing in source maps mode.
-* Fixes non-adjacent optimizations for source maps.
-* Fixes removing unused items.
-* Improves `outline` break up with source maps.
-* Refixed issue [#629](https://github.com/jakubpawlowicz/clean-css/issues/629) - source maps & background shorthands.
-
-[3.3.9 / 2015-08-09](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.8...v3.3.9)
-==================
-
-* Fixed issue [#640](https://github.com/jakubpawlowicz/clean-css/issues/640) - URI processing regression.
-
-[3.3.8 / 2015-08-06](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.7...v3.3.8)
-==================
-
-* Fixed issue [#629](https://github.com/jakubpawlowicz/clean-css/issues/629) - source maps & background shorthands.
-* Fixed issue [#630](https://github.com/jakubpawlowicz/clean-css/issues/630) - vendor prefixed flex optimizations.
-* Fixed issue [#633](https://github.com/jakubpawlowicz/clean-css/issues/633) - handling data URI with brackets.
-* Fixed issue [#634](https://github.com/jakubpawlowicz/clean-css/issues/634) - merging :placeholder selectors.
-
-[3.3.7 / 2015-07-29](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.6...v3.3.7)
-==================
-
-* Fixed issue [#616](https://github.com/jakubpawlowicz/clean-css/issues/616) - ordering in restructuring.
-
-[3.3.6 / 2015-07-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.5...v3.3.6)
-==================
-
-* Fixed issue [#620](https://github.com/jakubpawlowicz/clean-css/issues/620) - `bold` style in font shorthands.
-
-[3.3.5 / 2015-07-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.4...v3.3.5)
-==================
-
-* Fixed issue [#608](https://github.com/jakubpawlowicz/clean-css/issues/608) - custom URI protocols handling.
-
-[3.3.4 / 2015-06-24](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.3...v3.3.4)
-==================
-
-* Fixed issue [#610](https://github.com/jakubpawlowicz/clean-css/issues/610) - `border:inherit` restoring.
-* Fixed issue [#611](https://github.com/jakubpawlowicz/clean-css/issues/611) - edge case in quote stripping.
-
-[3.3.3 / 2015-06-16](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.2...v3.3.3)
-==================
-
-* Fixed issue [#603](https://github.com/jakubpawlowicz/clean-css/issues/603) - IE suffix hack defaults to on.
-
-[3.3.2 / 2015-06-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.1...v3.3.2)
-==================
-
-* Fixed issue [#595](https://github.com/jakubpawlowicz/clean-css/issues/595) - more relaxed block matching.
-* Fixed issue [#601](https://github.com/jakubpawlowicz/clean-css/issues/601) - percentage minifying inside `flex`.
-* Fixed issue [#602](https://github.com/jakubpawlowicz/clean-css/issues/602) - backslash IE hacks after a space.
-
-[3.3.1 / 2015-06-02](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.0...v3.3.1)
-==================
-
-* Fixed issue [#590](https://github.com/jakubpawlowicz/clean-css/issues/590) - edge case in `@import` processing.
-
-[3.3.0 / 2015-05-31](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.11...v3.3.0)
-==================
-
-* Cleans up url rebase code getting rid of unnecessary state.
-* Cleans up tokenizer code getting rid of unnecessary state.
-* Moves source maps tracker into lib/source-maps/track.
-* Moves tokenizer code into lib/tokenizer.
-* Moves URL scanner into lib/urls/reduce (was named incorrectly before).
-* Moves URL rebasing & rewriting into lib/urls.
-* Fixed issue [#375](https://github.com/jakubpawlowicz/clean-css/issues/375) - unit compatibility switches.
-* Fixed issue [#436](https://github.com/jakubpawlowicz/clean-css/issues/436) - refactors URI rewriting.
-* Fixed issue [#448](https://github.com/jakubpawlowicz/clean-css/issues/448) - rebasing no protocol URIs.
-* Fixed issue [#517](https://github.com/jakubpawlowicz/clean-css/issues/517) - turning off color optimizations.
-* Fixed issue [#542](https://github.com/jakubpawlowicz/clean-css/issues/542) - space after closing brace in IE.
-* Fixed issue [#562](https://github.com/jakubpawlowicz/clean-css/issues/562) - optimizing invalid color values.
-* Fixed issue [#563](https://github.com/jakubpawlowicz/clean-css/issues/563) - `background:inherit` restoring.
-* Fixed issue [#570](https://github.com/jakubpawlowicz/clean-css/issues/570) - rebasing "no-url()" imports.
-* Fixed issue [#574](https://github.com/jakubpawlowicz/clean-css/issues/574) - rewriting internal URLs.
-* Fixed issue [#575](https://github.com/jakubpawlowicz/clean-css/issues/575) - missing directory as a `target`.
-* Fixed issue [#577](https://github.com/jakubpawlowicz/clean-css/issues/577) - `background-clip` into shorthand.
-* Fixed issue [#579](https://github.com/jakubpawlowicz/clean-css/issues/579) - `background-origin` into shorthand.
-* Fixed issue [#580](https://github.com/jakubpawlowicz/clean-css/issues/580) - mixed `@import` processing.
-* Fixed issue [#582](https://github.com/jakubpawlowicz/clean-css/issues/582) - overriding with prefixed values.
-* Fixed issue [#583](https://github.com/jakubpawlowicz/clean-css/issues/583) - URL quoting for SVG data.
-* Fixed issue [#587](https://github.com/jakubpawlowicz/clean-css/issues/587) - too aggressive `border` reordering.
-
-[3.2.11 / 2015-05-31](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.10...v3.2.11)
-==================
-
-* Fixed issue [#563](https://github.com/jakubpawlowicz/clean-css/issues/563) - `background:inherit` restoring.
-* Fixed issue [#582](https://github.com/jakubpawlowicz/clean-css/issues/582) - overriding with prefixed values.
-* Fixed issue [#583](https://github.com/jakubpawlowicz/clean-css/issues/583) - URL quoting for SVG data.
-* Fixed issue [#587](https://github.com/jakubpawlowicz/clean-css/issues/587) - too aggressive `border` reordering.
-
-[3.2.10 / 2015-05-14](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.9...v3.2.10)
-==================
-
-* Fixed issue [#572](https://github.com/jakubpawlowicz/clean-css/issues/572) - empty elements removal.
-
-[3.2.9 / 2015-05-08](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.8...v3.2.9)
-==================
-
-* Fixed issue [#567](https://github.com/jakubpawlowicz/clean-css/issues/567) - merging colors as functions.
-
-[3.2.8 / 2015-05-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.7...v3.2.8)
-==================
-
-* Fixed issue [#561](https://github.com/jakubpawlowicz/clean-css/issues/561) - restructuring special selectors.
-
-[3.2.7 / 2015-05-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.6...v3.2.7)
-==================
-
-* Fixed issue [#551](https://github.com/jakubpawlowicz/clean-css/issues/551) - edge case in restructuring.
-* Fixed issue [#553](https://github.com/jakubpawlowicz/clean-css/issues/553) - another style of SVG fallback.
-* Fixed issue [#558](https://github.com/jakubpawlowicz/clean-css/issues/558) - units in same selector merging.
-
-[3.2.6 / 2015-04-28](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.5...v3.2.6)
-==================
-
-* Fixed issue [#550](https://github.com/jakubpawlowicz/clean-css/issues/550) - proper `contentSources` tracking.
-* Fixed issue [#556](https://github.com/jakubpawlowicz/clean-css/issues/556) - regression in IE backslash hacks.
-
-[3.2.5 / 2015-04-25](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.4...v3.2.5)
-==================
-
-* Fixed issue [#543](https://github.com/jakubpawlowicz/clean-css/issues/543) - better "comment in body" handling.
-* Fixed issue [#548](https://github.com/jakubpawlowicz/clean-css/issues/548) - regression in font minifying.
-* Fixed issue [#549](https://github.com/jakubpawlowicz/clean-css/issues/549) - special comments in source maps.
-
-[3.2.4 / 2015-04-24](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.3...v3.2.4)
-==================
-
-* Fixed issue [#544](https://github.com/jakubpawlowicz/clean-css/issues/544) - regression in same value merging.
-* Fixed issue [#546](https://github.com/jakubpawlowicz/clean-css/issues/546) - IE<11 `calc()` issue.
-
-[3.2.3 / 2015-04-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.2...v3.2.3)
-==================
-
-* Fixed issue [#541](https://github.com/jakubpawlowicz/clean-css/issues/541) - `outline-style:auto` in shorthand.
-
-[3.2.2 / 2015-04-21](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.1...v3.2.2)
-==================
-
-* Fixed issue [#537](https://github.com/jakubpawlowicz/clean-css/issues/537) - regression in simple optimizer.
-
-[3.2.1 / 2015-04-20](https://github.com/jakubpawlowicz/clean-css/compare/v3.2.0...v3.2.1)
-==================
-
-* Fixed issue [#534](https://github.com/jakubpawlowicz/clean-css/issues/534) - wrong `@font-face` stringifying.
-
-[3.2.0 / 2015-04-19](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.9...v3.2.0)
-==================
-
-* Bumps commander to 2.8.x.
-* Fixes remote asset rebasing when passing data as a hash.
-* Improves path resolution inside source maps.
-* Makes `root` option implicitely default to `process.cwd()`.
-* Fixed issue [#371](https://github.com/jakubpawlowicz/clean-css/issues/371) - `background` fallback with `none`.
-* Fixed issue [#376](https://github.com/jakubpawlowicz/clean-css/issues/376) - option to disable `0[unit]` -> `0`.
-* Fixed issue [#396](https://github.com/jakubpawlowicz/clean-css/issues/396) - better input source maps tracking.
-* Fixed issue [#397](https://github.com/jakubpawlowicz/clean-css/issues/397) - support for source map sources.
-* Fixed issue [#399](https://github.com/jakubpawlowicz/clean-css/issues/399) - support compacting with source maps.
-* Fixed issue [#429](https://github.com/jakubpawlowicz/clean-css/issues/429) - unifies data tokenization.
-* Fixed issue [#446](https://github.com/jakubpawlowicz/clean-css/issues/446) - `list-style` fuzzy matching.
-* Fixed issue [#468](https://github.com/jakubpawlowicz/clean-css/issues/468) - bumps `source-map` to 0.4.x.
-* Fixed issue [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - extracting uppercase property names.
-* Fixed issue [#487](https://github.com/jakubpawlowicz/clean-css/issues/487) - source map paths under Windows.
-* Fixed issue [#490](https://github.com/jakubpawlowicz/clean-css/issues/490) - vendor prefixed multivalue `background`.
-* Fixed issue [#500](https://github.com/jakubpawlowicz/clean-css/issues/500) - merging duplicate adjacent properties.
-* Fixed issue [#504](https://github.com/jakubpawlowicz/clean-css/issues/504) - keeping `url()` quotes.
-* Fixed issue [#507](https://github.com/jakubpawlowicz/clean-css/issues/507) - merging longhands into many shorthands.
-* Fixed issue [#508](https://github.com/jakubpawlowicz/clean-css/issues/508) - removing duplicate media queries.
-* Fixed issue [#521](https://github.com/jakubpawlowicz/clean-css/issues/521) - unit optimizations inside `calc()`.
-* Fixed issue [#524](https://github.com/jakubpawlowicz/clean-css/issues/524) - timeouts in `@import` inlining.
-* Fixed issue [#526](https://github.com/jakubpawlowicz/clean-css/issues/526) - shorthand overriding into a function.
-* Fixed issue [#528](https://github.com/jakubpawlowicz/clean-css/issues/528) - better support for IE<9 hacks.
-* Fixed issue [#529](https://github.com/jakubpawlowicz/clean-css/issues/529) - wrong font weight minification.
-
-[3.1.9 / 2015-04-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.8...v3.1.9)
-==================
-
-* Fixes issue [#511](https://github.com/jakubpawlowicz/clean-css/issues/511) - `)` advanced processing.
-
-[3.1.8 / 2015-03-17](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.7...v3.1.8)
-==================
-
-* Fixes issue [#498](https://github.com/jakubpawlowicz/clean-css/issues/498) - reordering and flexbox.
-* Fixes issue [#499](https://github.com/jakubpawlowicz/clean-css/issues/499) - too aggressive `-` removal.
-
-[3.1.7 / 2015-03-16](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.6...v3.1.7)
-==================
-
-* Backports fix to [#480](https://github.com/jakubpawlowicz/clean-css/issues/480) - reordering and uppercase properties.
-* Fixes issue [#496](https://github.com/jakubpawlowicz/clean-css/issues/496) - space after bracket removal.
-
-[3.1.6 / 2015-03-12](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.5...v3.1.6)
-==================
-
-* Fixes issue [#489](https://github.com/jakubpawlowicz/clean-css/issues/489) - `AlphaImageLoader` IE filter.
-
-[3.1.5 / 2015-03-06](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.4...v3.1.5)
-==================
-
-* Fixes issue [#483](https://github.com/jakubpawlowicz/clean-css/issues/483) - property order in restructuring.
-
-[3.1.4 / 2015-03-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.3...v3.1.4)
-==================
-
-* Fixes issue [#472](https://github.com/jakubpawlowicz/clean-css/issues/472) - broken function minification.
-* Fixes issue [#477](https://github.com/jakubpawlowicz/clean-css/issues/477) - `@import`s order in restructuring.
-* Fixes issue [#478](https://github.com/jakubpawlowicz/clean-css/issues/478) - ultimate fix to brace whitespace.
-
-[3.1.3 / 2015-03-03](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.2...v3.1.3)
-==================
-
-* Fixes issue [#464](https://github.com/jakubpawlowicz/clean-css/issues/464) - data URI with quoted braces.
-* Fixes issue [#475](https://github.com/jakubpawlowicz/clean-css/issues/475) - whitespace after closing brace.
-
-[3.1.2 / 2015-03-01](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.1...v3.1.2)
-==================
-
-* Refixed issue [#471](https://github.com/jakubpawlowicz/clean-css/issues/471) - correct order after restructuring.
-* Fixes issue [#466](https://github.com/jakubpawlowicz/clean-css/issues/466) - rebuilding background shorthand.
-* Fixes issue [#462](https://github.com/jakubpawlowicz/clean-css/issues/462) - escaped apostrophes in selectors.
-
-[3.1.1 / 2015-02-27](https://github.com/jakubpawlowicz/clean-css/compare/v3.1.0...v3.1.1)
-==================
-
-* Fixed issue [#469](https://github.com/jakubpawlowicz/clean-css/issues/469) - extracting broken property.
-* Fixed issue [#470](https://github.com/jakubpawlowicz/clean-css/issues/470) - negative padding removal.
-* Fixed issue [#471](https://github.com/jakubpawlowicz/clean-css/issues/471) - correct order after restructuring.
-
-[3.1.0 / 2015-02-26](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.10...v3.1.0)
-==================
-
-* Adds `0deg` to `0` minification where possible.
-* Adds better non-adjacent selector merging when body is the same.
-* Adds official support for node.js 0.12.
-* Adds official support for io.js 1.0.
-* Adds restructuring optimizations to reorganize selectors, which vastly improves minification.
-* Fixed issue [#158](https://github.com/jakubpawlowicz/clean-css/issues/158) - adds body-based selectors reduction.
-* Fixed issue [#182](https://github.com/jakubpawlowicz/clean-css/issues/182) - removing space after closing brace.
-* Fixed issue [#204](https://github.com/jakubpawlowicz/clean-css/issues/204) - `@media` merging.
-* Fixed issue [#351](https://github.com/jakubpawlowicz/clean-css/issues/351) - remote `@import`s after content.
-* Fixed issue [#357](https://github.com/jakubpawlowicz/clean-css/issues/357) - non-standard but valid URLs.
-* Fixed issue [#416](https://github.com/jakubpawlowicz/clean-css/issues/416) - accepts hash as `minify` argument.
-* Fixed issue [#419](https://github.com/jakubpawlowicz/clean-css/issues/419) - multiple input source maps.
-* Fixed issue [#435](https://github.com/jakubpawlowicz/clean-css/issues/435) - `background-clip` in shorthand.
-* Fixed issue [#439](https://github.com/jakubpawlowicz/clean-css/issues/439) - `background-origin` in shorthand.
-* Fixed issue [#442](https://github.com/jakubpawlowicz/clean-css/issues/442) - space before adjacent `nav`.
-* Fixed issue [#445](https://github.com/jakubpawlowicz/clean-css/issues/445) - regression issue in url processor.
-* Fixed issue [#449](https://github.com/jakubpawlowicz/clean-css/issues/449) - warns of missing close braces.
-* Fixed issue [#463](https://github.com/jakubpawlowicz/clean-css/issues/463) - relative remote `@import` URLs.
-
-[3.0.10 / 2015-02-07](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.9...v3.0.10)
-==================
-
-* Fixed issue [#453](https://github.com/jakubpawlowicz/clean-css/issues/453) - double `background-repeat`.
-* Fixed issue [#455](https://github.com/jakubpawlowicz/clean-css/issues/455) - property extracting regression.
-
-[3.0.9 / 2015-02-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.8...v3.0.9)
-==================
-
-* Fixed issue [#452](https://github.com/jakubpawlowicz/clean-css/issues/452) - regression in advanced merging.
-
-[3.0.8 / 2015-01-31](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.7...v3.0.8)
-==================
-
-* Fixed issue [#447](https://github.com/jakubpawlowicz/clean-css/issues/447) - `background-color` in shorthands.
-* Fixed issue [#450](https://github.com/jakubpawlowicz/clean-css/issues/450) - name to hex color converting.
-
-[3.0.7 / 2015-01-22](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.6...v3.0.7)
-==================
-
-* Fixed issue [#441](https://github.com/jakubpawlowicz/clean-css/issues/441) - hex to name color converting.
-
-[3.0.6 / 2015-01-20](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.5...v3.0.6)
-==================
-
-* Refixed issue [#414](https://github.com/jakubpawlowicz/clean-css/issues/414) - source maps position fallback.
-
-[3.0.5 / 2015-01-18](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.4...v3.0.5)
-==================
-
-* Fixed issue [#414](https://github.com/jakubpawlowicz/clean-css/issues/414) - source maps position fallback.
-* Fixed issue [#433](https://github.com/jakubpawlowicz/clean-css/issues/433) - meging `!important` in shorthands.
-
-[3.0.4 / 2015-01-11](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.3...v3.0.4)
-==================
-
-* Fixed issue [#314](https://github.com/jakubpawlowicz/clean-css/issues/314) - spaces inside `calc`.
-
-[3.0.3 / 2015-01-07](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.2...v3.0.3)
-==================
-
-* Just a version bump as npm incorrectly things 2.2.23 is the latest one.
-
-[3.0.2 / 2015-01-04](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.1...v3.0.2)
-==================
-
-* Fixed issue [#422](https://github.com/jakubpawlowicz/clean-css/issues/422) - handling `calc` as a unit.
-
-[3.0.1 / 2014-12-19](https://github.com/jakubpawlowicz/clean-css/compare/v3.0.0...v3.0.1)
-==================
-
-* Fixed issue [#410](https://github.com/jakubpawlowicz/clean-css/issues/410) - advanced merging and comments.
-* Fixed issue [#411](https://github.com/jakubpawlowicz/clean-css/issues/411) - properties and important comments.
-
-[3.0.0 / 2014-12-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.22...v3.0.0)
-==================
-
-* Adds more granular control over compatibility settings.
-* Adds support for @counter-style at-rule.
-* Adds `--source-map`/`sourceMap` switch for building input's source map.
-* Adds `--skip-shorthand-compacting`/`shorthandComacting` option for disabling shorthand compacting.
-* Allows `target` option to be a path to a folder instead of a file.
-* Allows disabling rounding precision. By [@superlukas](https://github.com/superlukas).
-* Breaks 2.x compatibility for using CleanCSS as a function.
-* Changes `minify` method output to handle multiple outputs.
-* Reworks minification to tokenize first then minify.
- See [changes](https://github.com/jakubpawlowicz/clean-css/compare/b06f37d...dd8c14a).
-* Removes support for node.js 0.8.x.
-* Renames `noAdvanced` option into `advanced`.
-* Renames `noAggressiveMerging` option into `aggressiveMerging`.
-* Renames `noRebase` option into `rebase`.
-* Speeds up advanced processing by shortening optimize loop.
-* Fixed issue [#125](https://github.com/jakubpawlowicz/clean-css/issues/125) - source maps!
-* Fixed issue [#344](https://github.com/jakubpawlowicz/clean-css/issues/344) - merging `background-size` into shorthand.
-* Fixed issue [#352](https://github.com/jakubpawlowicz/clean-css/issues/352) - honors rebasing in imported stylesheets.
-* Fixed issue [#360](https://github.com/jakubpawlowicz/clean-css/issues/360) - adds 7 extra CSS colors.
-* Fixed issue [#363](https://github.com/jakubpawlowicz/clean-css/issues/363) - `rem` units overriding `px`.
-* Fixed issue [#373](https://github.com/jakubpawlowicz/clean-css/issues/373) - proper `background` shorthand merging.
-* Fixed issue [#395](https://github.com/jakubpawlowicz/clean-css/issues/395) - unescaped brackets in data URIs.
-* Fixed issue [#398](https://github.com/jakubpawlowicz/clean-css/issues/398) - restoring important comments.
-* Fixed issue [#400](https://github.com/jakubpawlowicz/clean-css/issues/400) - API to accept an array of filenames.
-* Fixed issue [#403](https://github.com/jakubpawlowicz/clean-css/issues/403) - tracking input files in source maps.
-* Fixed issue [#404](https://github.com/jakubpawlowicz/clean-css/issues/404) - no state sharing in API.
-* Fixed issue [#405](https://github.com/jakubpawlowicz/clean-css/issues/405) - disables default `background-size` merging.
-* Refixed issue [#304](https://github.com/jakubpawlowicz/clean-css/issues/304) - `background-position` merging.
-
-[2.2.22 / 2014-12-13](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.21...v2.2.22)
-==================
-
-* Backports fix to issue [#304](https://github.com/jakubpawlowicz/clean-css/issues/304) - `background-position` merging.
-
-[2.2.21 / 2014-12-10](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.20...v2.2.21)
-==================
-
-* Backports fix to issue [#373](https://github.com/jakubpawlowicz/clean-css/issues/373) - `background` shorthand merging.
-
-[2.2.20 / 2014-12-02](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.19...v2.2.20)
-==================
-
-* Backports fix to issue [#390](https://github.com/jakubpawlowicz/clean-css/issues/390) - pseudo-class merging.
-
-[2.2.19 / 2014-11-20](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.18...v2.2.19)
-==================
-
-* Fixed issue [#385](https://github.com/jakubpawlowicz/clean-css/issues/385) - edge cases in processing cut off data.
-
-[2.2.18 / 2014-11-17](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.17...v2.2.18)
-==================
-
-* Fixed issue [#383](https://github.com/jakubpawlowicz/clean-css/issues/383) - rounding fractions once again.
-
-[2.2.17 / 2014-11-09](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.16...v2.2.17)
-==================
-
-* Fixed issue [#380](https://github.com/jakubpawlowicz/clean-css/issues/380) - rounding fractions to a whole number.
-
-[2.2.16 / 2014-09-16](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.15...v2.2.16)
-==================
-
-* Fixed issue [#359](https://github.com/jakubpawlowicz/clean-css/issues/359) - handling escaped double backslash.
-* Fixed issue [#358](https://github.com/jakubpawlowicz/clean-css/issues/358) - property merging in compatibility mode.
-* Fixed issue [#356](https://github.com/jakubpawlowicz/clean-css/issues/356) - preserving `*+html` hack.
-* Fixed issue [#354](https://github.com/jakubpawlowicz/clean-css/issues/354) - `!important` overriding in shorthands.
-
-[2.2.15 / 2014-09-01](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.14...v2.2.15)
-==================
-
-* Fixed issue [#343](https://github.com/jakubpawlowicz/clean-css/issues/343) - too aggressive `rgba`/`hsla` minification.
-* Fixed issue [#345](https://github.com/jakubpawlowicz/clean-css/issues/345) - URL rebasing for document relative ones.
-* Fixed issue [#346](https://github.com/jakubpawlowicz/clean-css/issues/346) - overriding `!important` by `!important`.
-* Fixed issue [#350](https://github.com/jakubpawlowicz/clean-css/issues/350) - edge cases in `@import` processing.
-
-[2.2.14 / 2014-08-25](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.13...v2.2.14)
-==================
-
-* Makes multival operations idempotent.
-* Fixed issue [#339](https://github.com/jakubpawlowicz/clean-css/issues/339) - skips invalid properties.
-* Fixed issue [#341](https://github.com/jakubpawlowicz/clean-css/issues/341) - ensure output is shorter than input.
-
-[2.2.13 / 2014-08-12](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.12...v2.2.13)
-==================
-
-* Fixed issue [#337](https://github.com/jakubpawlowicz/clean-css/issues/337) - handling component importance.
-
-[2.2.12 / 2014-08-02](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.11...v2.2.12)
-==================
-
-* Fixed issue with tokenizer removing first selector after an unknown @ rule.
-* Fixed issue [#329](https://github.com/jakubpawlowicz/clean-css/issues/329) - `font` shorthands incorrectly processed.
-* Fixed issue [#332](https://github.com/jakubpawlowicz/clean-css/issues/332) - `background` shorthand with colors.
-* Refixed issue [#325](https://github.com/jakubpawlowicz/clean-css/issues/325) - invalid charset declarations.
-
-[2.2.11 / 2014-07-28](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.10...v2.2.11)
-==================
-
-* Fixed issue [#326](https://github.com/jakubpawlowicz/clean-css/issues/326) - `background-size` regression.
-
-[2.2.10 / 2014-07-27](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.9...v2.2.10)
-==================
-
-* Improved performance of advanced mode validators.
-* Fixed issue [#307](https://github.com/jakubpawlowicz/clean-css/issues/307) - `background-color` in multiple backgrounds.
-* Fixed issue [#322](https://github.com/jakubpawlowicz/clean-css/issues/322) - adds `background-size` support.
-* Fixed issue [#323](https://github.com/jakubpawlowicz/clean-css/issues/323) - stripping variable references.
-* Fixed issue [#325](https://github.com/jakubpawlowicz/clean-css/issues/325) - removing invalid `@charset` declarations.
-
-[2.2.9 / 2014-07-23](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.8...v2.2.9)
-==================
-
-* Adds `background` normalization according to W3C spec.
-* Fixed issue [#316](https://github.com/jakubpawlowicz/clean-css/issues/316) - incorrect `background` processing.
-
-[2.2.8 / 2014-07-14](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.7...v2.2.8)
-==================
-
-* Fixed issue [#313](https://github.com/jakubpawlowicz/clean-css/issues/313) - processing comment marks in URLs.
-* Fixed issue [#315](https://github.com/jakubpawlowicz/clean-css/issues/315) - `rgba`/`hsla` -> `transparent` in gradients.
-
-[2.2.7 / 2014-07-10](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.6...v2.2.7)
-==================
-
-* Fixed issue [#304](https://github.com/jakubpawlowicz/clean-css/issues/304) - merging multiple backgrounds.
-* Fixed issue [#312](https://github.com/jakubpawlowicz/clean-css/issues/312) - merging with mixed repeat.
-
-[2.2.6 / 2014-07-05](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.5...v2.2.6)
-==================
-
-* Adds faster quote matching in QuoteScanner.
-* Improves QuoteScanner to handle comments correctly.
-* Fixed issue [#308](https://github.com/jakubpawlowicz/clean-css/issues/308) - parsing comments in quoted URLs.
-* Fixed issue [#311](https://github.com/jakubpawlowicz/clean-css/issues/311) - leading/trailing decimal points.
-
-[2.2.5 / 2014-06-29](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.4...v2.2.5)
-==================
-
-* Adds removing extra spaces around / in border-radius.
-* Adds replacing same horizontal & vertical value in border-radius.
-* Fixed issue [#305](https://github.com/jakubpawlowicz/clean-css/issues/305) - allows width keywords in `border-width`.
-
-[2.2.4 / 2014-06-27](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.3...v2.2.4)
-==================
-
-* Fixed issue [#301](https://github.com/jakubpawlowicz/clean-css/issues/301) - proper `border-radius` processing.
-* Fixed issue [#303](https://github.com/jakubpawlowicz/clean-css/issues/303) - correctly preserves viewport units.
-
-[2.2.3 / 2014-06-24](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.2...v2.2.3)
-==================
-
-* Fixed issue [#302](https://github.com/jakubpawlowicz/clean-css/issues/302) - handling of `outline-style: auto`.
-
-[2.2.2 / 2014-06-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.1...v2.2.2)
-==================
-
-* Fixed issue [#297](https://github.com/jakubpawlowicz/clean-css/issues/297) - `box-shadow` zeros minification.
-
-[2.2.1 / 2014-06-14](https://github.com/jakubpawlowicz/clean-css/compare/v2.2.0...v2.2.1)
-==================
-
-* Fixes new property optimizer for 'none' values.
-* Fixed issue [#294](https://github.com/jakubpawlowicz/clean-css/issues/294) - space after `rgba`/`hsla` in IE<=11.
-
-[2.2.0 / 2014-06-11](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.8...v2.2.0)
-==================
-
-* Adds a better algorithm for quotation marks' removal.
-* Adds a better non-adjacent optimizer compatible with the upcoming new property optimizer.
-* Adds minifying remote files directly from CLI.
-* Adds `--rounding-precision` to control rounding precision.
-* Moves quotation matching into a `QuoteScanner` class.
-* Adds `npm run browserify` for creating embeddable version of clean-css.
-* Fixed list-style-* advanced processing.
-* Fixed issue [#134](https://github.com/jakubpawlowicz/clean-css/issues/134) - merges properties into shorthand form.
-* Fixed issue [#164](https://github.com/jakubpawlowicz/clean-css/issues/164) - removes default values if not needed.
-* Fixed issue [#168](https://github.com/jakubpawlowicz/clean-css/issues/168) - adds better property merging algorithm.
-* Fixed issue [#173](https://github.com/jakubpawlowicz/clean-css/issues/173) - merges same properties if grouped.
-* Fixed issue [#184](https://github.com/jakubpawlowicz/clean-css/issues/184) - uses `!important` for optimization opportunities.
-* Fixed issue [#190](https://github.com/jakubpawlowicz/clean-css/issues/190) - uses shorthand to override another shorthand.
-* Fixed issue [#197](https://github.com/jakubpawlowicz/clean-css/issues/197) - adds borders merging by understandability.
-* Fixed issue [#210](https://github.com/jakubpawlowicz/clean-css/issues/210) - adds temporary workaround for aggressive merging.
-* Fixed issue [#246](https://github.com/jakubpawlowicz/clean-css/issues/246) - removes IE hacks when not in compatibility mode.
-* Fixed issue [#247](https://github.com/jakubpawlowicz/clean-css/issues/247) - removes deprecated `selectorsMergeMode` switch.
-* Refixed issue [#250](https://github.com/jakubpawlowicz/clean-css/issues/250) - based on new quotation marks removal.
-* Fixed issue [#257](https://github.com/jakubpawlowicz/clean-css/issues/257) - turns `rgba`/`hsla` to `transparent` if possible.
-* Fixed issue [#265](https://github.com/jakubpawlowicz/clean-css/issues/265) - adds support for multiple input files.
-* Fixed issue [#275](https://github.com/jakubpawlowicz/clean-css/issues/275) - handling transform properties.
-* Fixed issue [#276](https://github.com/jakubpawlowicz/clean-css/issues/276) - corrects unicode handling.
-* Fixed issue [#288](https://github.com/jakubpawlowicz/clean-css/issues/288) - adds smarter expression parsing.
-* Fixed issue [#293](https://github.com/jakubpawlowicz/clean-css/issues/293) - handles escaped `@` symbols in class names and IDs.
-
-[2.1.8 / 2014-03-28](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.7...v2.1.8)
-==================
-
-* Fixed issue [#267](https://github.com/jakubpawlowicz/clean-css/issues/267) - incorrect non-adjacent selector merging.
-
-[2.1.7 / 2014-03-24](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.6...v2.1.7)
-==================
-
-* Fixed issue [#264](https://github.com/jakubpawlowicz/clean-css/issues/264) - `@import` statements inside comments.
-
-[2.1.6 / 2014-03-10](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.5...v2.1.6)
-==================
-
-* Fixed issue [#258](https://github.com/jakubpawlowicz/clean-css/issues/258) - wrong `@import` handling in `EmptyRemoval`.
-
-[2.1.5 / 2014-03-07](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.4...v2.1.5)
-==================
-
-* Fixed issue [#255](https://github.com/jakubpawlowicz/clean-css/issues/255) - incorrect processing of a trailing `-0`.
-
-[2.1.4 / 2014-03-01](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.3...v2.1.4)
-==================
-
-* Fixed issue [#250](https://github.com/jakubpawlowicz/clean-css/issues/250) - correctly handle JSON data in quotations.
-
-[2.1.3 / 2014-02-26](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.2...v2.1.3)
-==================
-
-* Fixed issue [#248](https://github.com/jakubpawlowicz/clean-css/issues/248) - incorrect merging for vendor selectors.
-
-[2.1.2 / 2014-02-25](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.1...v2.1.2)
-==================
-
-* Fixed issue [#245](https://github.com/jakubpawlowicz/clean-css/issues/245) - incorrect handling of backslash IE hack.
-
-[2.1.1 / 2014-02-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.1.0...v2.1.1)
-==================
-
-* Adds faster selectors processing in advanced optimizer.
-* Fixed issue [#241](https://github.com/jakubpawlowicz/clean-css/issues/241) - incorrect handling of `:not()` selectors.
-
-[2.1.0 / 2014-02-13](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.8...v2.1.0)
-==================
-
-* Adds an optional callback to minify method.
-* Deprecates `--selectors-merge-mode` / `selectorsMergeMode` in favor to `--compatibility` / `compatibility`.
-* Fixes debug mode stats for stylesheets using `@import` statements.
-* Skips empty removal if advanced processing is enabled.
-* Fixed issue [#85](https://github.com/jakubpawlowicz/clean-css/issues/85) - resolving protocol `@import`s.
-* Fixed issue [#160](https://github.com/jakubpawlowicz/clean-css/issues/160) - re-runs optimizer until a clean pass.
-* Fixed issue [#161](https://github.com/jakubpawlowicz/clean-css/issues/161) - improves tokenizer performance.
-* Fixed issue [#163](https://github.com/jakubpawlowicz/clean-css/issues/163) - round pixels to 2nd decimal place.
-* Fixed issue [#165](https://github.com/jakubpawlowicz/clean-css/issues/165) - extra space after trailing parenthesis.
-* Fixed issue [#186](https://github.com/jakubpawlowicz/clean-css/issues/186) - strip unit from `0rem`.
-* Fixed issue [#207](https://github.com/jakubpawlowicz/clean-css/issues/207) - bug in parsing protocol `@import`s.
-* Fixed issue [#213](https://github.com/jakubpawlowicz/clean-css/issues/213) - faster `rgb` to `hex` transforms.
-* Fixed issue [#215](https://github.com/jakubpawlowicz/clean-css/issues/215) - leading zeros in numerical values.
-* Fixed issue [#217](https://github.com/jakubpawlowicz/clean-css/issues/217) - whitespace inside attribute selectors and URLs.
-* Fixed issue [#218](https://github.com/jakubpawlowicz/clean-css/issues/218) - `@import` statements cleanup.
-* Fixed issue [#220](https://github.com/jakubpawlowicz/clean-css/issues/220) - selector between comments.
-* Fixed issue [#223](https://github.com/jakubpawlowicz/clean-css/issues/223) - two-pass adjacent selectors merging.
-* Fixed issue [#226](https://github.com/jakubpawlowicz/clean-css/issues/226) - don't minify `border:none` to `border:0`.
-* Fixed issue [#229](https://github.com/jakubpawlowicz/clean-css/issues/229) - improved processing of fraction numbers.
-* Fixed issue [#230](https://github.com/jakubpawlowicz/clean-css/issues/230) - better handling of zero values.
-* Fixed issue [#235](https://github.com/jakubpawlowicz/clean-css/issues/235) - IE7 compatibility mode.
-* Fixed issue [#236](https://github.com/jakubpawlowicz/clean-css/issues/236) - incorrect rebasing with nested `import`s.
-
-[2.0.8 / 2014-02-07](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.7...v2.0.8)
-==================
-
-* Fixed issue [#232](https://github.com/jakubpawlowicz/clean-css/issues/232) - edge case in non-adjacent selectors merging.
-
-[2.0.7 / 2014-01-16](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.6...v2.0.7)
-==================
-
-* Fixed issue [#208](https://github.com/jakubpawlowicz/clean-css/issues/208) - don't swallow `@page` and `@viewport`.
-
-[2.0.6 / 2014-01-04](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.5...v2.0.6)
-==================
-
-* Fixed issue [#198](https://github.com/jakubpawlowicz/clean-css/issues/198) - process comments and `@import`s correctly.
-* Fixed issue [#205](https://github.com/jakubpawlowicz/clean-css/issues/205) - freeze on broken `@import` declaration.
-
-[2.0.5 / 2014-01-03](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.4...v2.0.5)
-==================
-
-* Fixed issue [#199](https://github.com/jakubpawlowicz/clean-css/issues/199) - keep line breaks with no advanced optimizations.
-* Fixed issue [#203](https://github.com/jakubpawlowicz/clean-css/issues/203) - Buffer as a first argument to minify method.
-
-[2.0.4 / 2013-12-19](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.3...v2.0.4)
-==================
-
-* Fixed issue [#193](https://github.com/jakubpawlowicz/clean-css/issues/193) - HSL color space normalization.
-
-[2.0.3 / 2013-12-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.2...v2.0.3)
-==================
-
-* Fixed issue [#191](https://github.com/jakubpawlowicz/clean-css/issues/191) - leading numbers in `font`/`animation` names.
-* Fixed issue [#192](https://github.com/jakubpawlowicz/clean-css/issues/192) - many `@import`s inside a comment.
-
-[2.0.2 / 2013-11-18](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.1...v2.0.2)
-==================
-
-* Fixed issue [#177](https://github.com/jakubpawlowicz/clean-css/issues/177) - process broken content correctly.
-
-[2.0.1 / 2013-11-14](https://github.com/jakubpawlowicz/clean-css/compare/v2.0.0...v2.0.1)
-==================
-
-* Fixed issue [#176](https://github.com/jakubpawlowicz/clean-css/issues/176) - hangs on `undefined` keyword.
-
-[2.0.0 / 2013-11-04](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.7...v2.0.0)
-==================
-
-* Adds simplified and more advanced text escaping / restoring via `EscapeStore` class.
-* Adds simplified and much faster empty elements removal.
-* Adds missing `@import` processing to our benchmark (run via `npm run bench`).
-* Adds CSS tokenizer which will make it possible to optimize content by reordering and/or merging selectors.
-* Adds basic optimizer removing duplicate selectors from a list.
-* Adds merging duplicate properties within a single selector's body.
-* Adds merging adjacent selectors within a scope (single and multiple ones).
-* Changes behavior of `--keep-line-breaks`/`keepBreaks` option to keep breaks after trailing braces only.
-* Makes all multiple selectors ordered alphabetically (aids merging).
-* Adds property overriding so more coarse properties override more granular ones.
-* Adds reducing non-adjacent selectors.
-* Adds `--skip-advanced`/`noAdvanced` switch to disable advanced optimizations.
-* Adds reducing non-adjacent selectors when overridden by more complex selectors.
-* Fixed issue [#138](https://github.com/jakubpawlowicz/clean-css/issues/138) - makes CleanCSS interface OO.
-* Fixed issue [#139](https://github.com/jakubpawlowicz/clean-css/issues/138) - consistent error & warning handling.
-* Fixed issue [#145](https://github.com/jakubpawlowicz/clean-css/issues/145) - debug mode in library too.
-* Fixed issue [#157](https://github.com/jakubpawlowicz/clean-css/issues/157) - gets rid of `removeEmpty` option.
-* Fixed issue [#159](https://github.com/jakubpawlowicz/clean-css/issues/159) - escaped quotes inside content.
-* Fixed issue [#162](https://github.com/jakubpawlowicz/clean-css/issues/162) - strip quotes from Base64 encoded URLs.
-* Fixed issue [#166](https://github.com/jakubpawlowicz/clean-css/issues/166) - `debug` formatting in CLI
-* Fixed issue [#167](https://github.com/jakubpawlowicz/clean-css/issues/167) - `background:transparent` minification.
-
-[1.1.7 / 2013-10-28](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.6...v1.1.7)
-==================
-
-* Fixed issue [#156](https://github.com/jakubpawlowicz/clean-css/issues/156) - `@import`s inside comments.
-
-[1.1.6 / 2013-10-26](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.5...v1.1.6)
-==================
-
-* Fixed issue [#155](https://github.com/jakubpawlowicz/clean-css/issues/155) - broken irregular CSS content.
-
-[1.1.5 / 2013-10-24](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.4...v1.1.5)
-==================
-
-* Fixed issue [#153](https://github.com/jakubpawlowicz/clean-css/issues/153) - `keepSpecialComments` `0`/`1` as a string.
-
-[1.1.4 / 2013-10-23](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.3...v1.1.4)
-==================
-
-* Fixed issue [#152](https://github.com/jakubpawlowicz/clean-css/issues/152) - adds an option to disable rebasing.
-
-[1.1.3 / 2013-10-04](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.2...v1.1.3)
-==================
-
-* Fixed issue [#150](https://github.com/jakubpawlowicz/clean-css/issues/150) - minifying `background:none`.
-
-[1.1.2 / 2013-09-29](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.1...v1.1.2)
-==================
-
-* Fixed issue [#149](https://github.com/jakubpawlowicz/clean-css/issues/149) - shorthand `font` property.
-
-[1.1.1 / 2013-09-07](https://github.com/jakubpawlowicz/clean-css/compare/v1.1.0...v1.1.1)
-==================
-
-* Fixed issue [#144](https://github.com/jakubpawlowicz/clean-css/issues/144) - skip URLs rebasing by default.
-
-[1.1.0 / 2013-09-06](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.12...v1.1.0)
-==================
-
-* Renamed lib's `debug` option to `benchmark` when doing per-minification benchmarking.
-* Added simplified comments processing & imports.
-* Fixed issue [#43](https://github.com/jakubpawlowicz/clean-css/issues/43) - `--debug` switch for minification stats.
-* Fixed issue [#65](https://github.com/jakubpawlowicz/clean-css/issues/65) - full color name / hex shortening.
-* Fixed issue [#84](https://github.com/jakubpawlowicz/clean-css/issues/84) - support for `@import` with media queries.
-* Fixed issue [#124](https://github.com/jakubpawlowicz/clean-css/issues/124) - raise error on broken imports.
-* Fixed issue [#126](https://github.com/jakubpawlowicz/clean-css/issues/126) - proper CSS expressions handling.
-* Fixed issue [#129](https://github.com/jakubpawlowicz/clean-css/issues/129) - rebasing imported URLs.
-* Fixed issue [#130](https://github.com/jakubpawlowicz/clean-css/issues/130) - better code modularity.
-* Fixed issue [#135](https://github.com/jakubpawlowicz/clean-css/issues/135) - require node.js 0.8+.
-
-[1.0.12 / 2013-07-19](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.11...v1.0.12)
-===================
-
-* Fixed issue [#121](https://github.com/jakubpawlowicz/clean-css/issues/121) - ability to skip `@import` processing.
-
-[1.0.11 / 2013-07-08](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.10...v1.0.11)
-===================
-
-* Fixed issue [#117](https://github.com/jakubpawlowicz/clean-css/issues/117) - line break escaping in comments.
-
-[1.0.10 / 2013-06-13](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.9...v1.0.10)
-===================
-
-* Fixed issue [#114](https://github.com/jakubpawlowicz/clean-css/issues/114) - comments in imported stylesheets.
-
-[1.0.9 / 2013-06-11](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.8...v1.0.9)
-==================
-
-* Fixed issue [#113](https://github.com/jakubpawlowicz/clean-css/issues/113) - `@import` in comments.
-
-[1.0.8 / 2013-06-10](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.7...v1.0.8)
-==================
-
-* Fixed issue [#112](https://github.com/jakubpawlowicz/clean-css/issues/112) - reducing `box-shadow` zeros.
-
-[1.0.7 / 2013-06-05](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.6...v1.0.7)
-==================
-
-* Support for `@import` URLs starting with `//`. By [@petetak](https://github.com/petetak).
-
-[1.0.6 / 2013-06-04](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.5...v1.0.6)
-==================
-
-* Fixed issue [#110](https://github.com/jakubpawlowicz/clean-css/issues/110) - data URIs in URLs.
-
-[1.0.5 / 2013-05-26](https://github.com/jakubpawlowicz/clean-css/compare/v1.0.4...v1.0.5)
-==================
-
-* Fixed issue [#107](https://github.com/jakubpawlowicz/clean-css/issues/107) - data URIs in imported stylesheets.
-
-1.0.4 / 2013-05-23
-==================
-
-* Rewrite relative URLs in imported stylesheets. By [@bluej100](https://github.com/bluej100).
-
-1.0.3 / 2013-05-20
-==================
-
-* Support alternative `@import` syntax with file name not wrapped inside `url()` statement.
- By [@bluej100](https://github.com/bluej100).
-
-1.0.2 / 2013-04-29
-==================
-
-* Fixed issue [#97](https://github.com/jakubpawlowicz/clean-css/issues/97) - `--remove-empty` & FontAwesome.
-
-1.0.1 / 2013-04-08
-==================
-
-* Do not pick up `bench` and `test` while building `npm` package.
- By [@sindresorhus](https://https://github.com/sindresorhus).
-
-1.0.0 / 2013-03-30
-==================
-
-* Fixed issue [#2](https://github.com/jakubpawlowicz/clean-css/issues/2) - resolving `@import` rules.
-* Fixed issue [#44](https://github.com/jakubpawlowicz/clean-css/issues/44) - examples in `--help`.
-* Fixed issue [#46](https://github.com/jakubpawlowicz/clean-css/issues/46) - preserving special characters in URLs and attributes.
-* Fixed issue [#80](https://github.com/jakubpawlowicz/clean-css/issues/80) - quotation in multi line strings.
-* Fixed issue [#83](https://github.com/jakubpawlowicz/clean-css/issues/83) - HSL to hex color conversions.
-* Fixed issue [#86](https://github.com/jakubpawlowicz/clean-css/issues/86) - broken `@charset` replacing.
-* Fixed issue [#88](https://github.com/jakubpawlowicz/clean-css/issues/88) - removes space in `! important`.
-* Fixed issue [#92](https://github.com/jakubpawlowicz/clean-css/issues/92) - uppercase hex to short versions.
-
-0.10.2 / 2013-03-19
-===================
-
-* Fixed issue [#79](https://github.com/jakubpawlowicz/clean-css/issues/79) - node.js 0.10.x compatibility.
-
-0.10.1 / 2013-02-14
-===================
-
-* Fixed issue [#66](https://github.com/jakubpawlowicz/clean-css/issues/66) - line breaks without extra spaces should
- be handled correctly.
-
-0.10.0 / 2013-02-09
-===================
-
-* Switched from [optimist](https://github.com/substack/node-optimist) to
- [commander](https://github.com/visionmedia/commander.js) for CLI processing.
-* Changed long options from `--removeempty` to `--remove-empty` and from `--keeplinebreaks` to `--keep-line-breaks`.
-* Fixed performance issue with replacing multiple `@charset` declarations and issue
- with line break after `@charset` when using `keepLineBreaks` option. By [@rrjaime](https://github.com/rrjamie).
-* Removed Makefile in favor to `npm run` commands (e.g. `make check` -> `npm run check`).
-* Fixed issue [#47](https://github.com/jakubpawlowicz/clean-css/issues/47) - commandline issues on Windows.
-* Fixed issue [#49](https://github.com/jakubpawlowicz/clean-css/issues/49) - remove empty selectors from media query.
-* Fixed issue [#52](https://github.com/jakubpawlowicz/clean-css/issues/52) - strip fraction zeros if not needed.
-* Fixed issue [#58](https://github.com/jakubpawlowicz/clean-css/issues/58) - remove colon where possible.
-* Fixed issue [#59](https://github.com/jakubpawlowicz/clean-css/issues/59) - content property handling.
-
-0.9.1 / 2012-12-19
-==================
-
-* Fixed issue [#37](https://github.com/jakubpawlowicz/clean-css/issues/37) - converting
- `white` and other colors in class names (reported by [@malgorithms](https://github.com/malgorithms)).
-
-0.9.0 / 2012-12-15
-==================
-
-* Added stripping quotation from font names (if possible).
-* Added stripping quotation from `@keyframes` declaration, `animation` and
- `animation-name` property.
-* Added stripping quotations from attributes' value (e.g. `[data-target='x']`).
-* Added better hex->name and name->hex color shortening.
-* Added `font: normal` and `font: bold` shortening the same way as `font-weight` is.
-* Refactored shorthand selectors and added `border-radius`, `border-style`
- and `border-color` shortening.
-* Added `margin`, `padding` and `border-width` shortening.
-* Added removing line break after commas.
-* Fixed removing whitespace inside media query definition.
-* Added removing line breaks after a comma, so all declarations are one-liners now.
-* Speed optimizations (~10% despite many new features).
-* Added [JSHint](https://github.com/jshint/jshint/) validation rules via `make check`.
-
-0.8.3 / 2012-11-29
-==================
-
-* Fixed HSL/HSLA colors processing.
-
-0.8.2 / 2012-10-31
-==================
-
-* Fixed shortening hex colors and their relation to hashes in URLs.
-* Cleanup by [@XhmikosR](https://github.com/XhmikosR).
-
-0.8.1 / 2012-10-28
-==================
-
-* Added better zeros processing for `rect(...)` syntax (clip property).
-
-0.8.0 / 2012-10-21
-==================
-
-* Added removing URLs quotation if possible.
-* Rewrote breaks processing.
-* Added `keepBreaks`/`-b` option to keep line breaks in the minimized file.
-* Reformatted [lib/clean.js](/lib/clean.js) so it's easier to follow the rules.
-* Minimized test data is now minimized with line breaks so it's easier to
- compare the changes line by line.
-
-0.7.0 / 2012-10-14
-==================
-
-* Added stripping special comments to CLI (`--s0` and `--s1` options).
-* Added stripping special comments to programmatic interface
- (`keepSpecialComments` option).
-
-0.6.0 / 2012-08-05
-==================
-
-* Full Windows support with tests (./test.bat).
-
-0.5.0 / 2012-08-02
-==================
-
-* Made path to vows local.
-* Explicit node.js 0.6 requirement.
-
-0.4.2 / 2012-06-28
-==================
-
-* Updated binary `-v` option (version).
-* Updated binary to output help when no options given (but not in piped mode).
-* Added binary tests.
-
-0.4.1 / 2012-06-10
-==================
-
-* Fixed stateless mode where calling `CleanCSS#process` directly was giving
- errors (reported by [@facelessuser](https://github.com/facelessuser)).
-
-0.4.0 / 2012-06-04
-==================
-
-* Speed improvements up to 4x thanks to the rewrite of comments and CSS' content
- processing.
-* Stripping empty CSS tags is now optional (see [bin/cleancss](/bin/cleancss) for details).
-* Improved debugging mode (see [test/bench.js](/test/bench.js))
-* Added `make bench` for a one-pass benchmark.
-
-0.3.3 / 2012-05-27
-==================
-
-* Fixed tests, [package.json](/package.json) for development, and regex
- for removing empty declarations (thanks to [@vvo](https://github.com/vvo)).
-
-0.3.2 / 2012-01-17
-==================
-
-* Fixed output method under node.js 0.6 which incorrectly tried to close
- `process.stdout`.
-
-0.3.1 / 2011-12-16
-==================
-
-* Fixed cleaning up `0 0 0 0` expressions.
-
-0.3.0 / 2011-11-29
-==================
-
-* Clean-css requires node.js 0.4.0+ to run.
-* Removed node.js's 0.2.x 'sys' package dependency
- (thanks to [@jmalonzo](https://github.com/jmalonzo) for a patch).
-
-0.2.6 / 2011-11-27
-==================
-
-* Fixed expanding `+` signs in `calc()` when mixed up with adjacent `+` selector.
-
-0.2.5 / 2011-11-27
-==================
-
-* Fixed issue with cleaning up spaces inside `calc`/`-moz-calc` declarations
- (thanks to [@cvan](https://github.com/cvan) for reporting it).
-* Fixed converting `#f00` to `red` in borders and gradients.
-
-0.2.4 / 2011-05-25
-==================
-
-* Fixed problem with expanding `none` to `0` in partial/full background
- declarations.
-* Fixed including clean-css library from binary (global to local).
-
-0.2.3 / 2011-04-18
-==================
-
-* Fixed problem with optimizing IE filters.
-
-0.2.2 / 2011-04-17
-==================
-
-* Fixed problem with space before color in `border` property.
-
-0.2.1 / 2011-03-19
-==================
-
-* Added stripping space before `!important` keyword.
-* Updated repository location and author information in [package.json](/package.json).
-
-0.2.0 / 2011-03-02
-==================
-
-* Added options parsing via optimist.
-* Changed code inclusion (thus the version bump).
-
-0.1.0 / 2011-02-27
-==================
-
-* First version of clean-css library.
-* Implemented all basic CSS transformations.
diff --git a/api/node_modules/clean-css/LICENSE b/api/node_modules/clean-css/LICENSE
deleted file mode 100644
index 32bb13fc2..000000000
--- a/api/node_modules/clean-css/LICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (C) 2015 JakubPawlowicz.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.
diff --git a/api/node_modules/clean-css/README.md b/api/node_modules/clean-css/README.md
deleted file mode 100644
index ee08b7a63..000000000
--- a/api/node_modules/clean-css/README.md
+++ /dev/null
@@ -1,369 +0,0 @@
-[![NPM version](https://img.shields.io/npm/v/clean-css.svg?style=flat)](https://www.npmjs.com/package/clean-css)
-[![Linux Build Status](https://img.shields.io/travis/jakubpawlowicz/clean-css/master.svg?style=flat&label=Linux%20build)](https://travis-ci.org/jakubpawlowicz/clean-css)
-[![Windows Build status](https://img.shields.io/appveyor/ci/jakubpawlowicz/clean-css/master.svg?style=flat&label=Windows%20build)](https://ci.appveyor.com/project/jakubpawlowicz/clean-css/branch/master)
-[![Dependency Status](https://img.shields.io/david/jakubpawlowicz/clean-css.svg?style=flat)](https://david-dm.org/jakubpawlowicz/clean-css)
-[![devDependency Status](https://img.shields.io/david/dev/jakubpawlowicz/clean-css.svg?style=flat)](https://david-dm.org/jakubpawlowicz/clean-css#info=devDependencies)
-
-## What is clean-css?
-
-Clean-css is a fast and efficient [Node.js](http://nodejs.org/) library for minifying CSS files.
-
-According to [tests](http://goalsmashers.github.io/css-minification-benchmark/) it is one of the best available.
-
-
-## Usage
-
-### What are the requirements?
-
-```
-Node.js 0.10+ (tested on CentOS, Ubuntu, OS X 10.6+, and Windows 7+) or io.js 3.0+
-```
-
-### How to install clean-css?
-
-```
-npm install clean-css
-```
-
-### How to use clean-css CLI?
-
-Clean-css accepts the following command line arguments (please make sure
-you use `` as the very last argument to avoid potential issues):
-
-```
-cleancss [options] source-file, [source-file, ...]
-
--h, --help output usage information
--v, --version output the version number
--b, --keep-line-breaks Keep line breaks
--c, --compatibility [ie7|ie8] Force compatibility mode (see Readme for advanced examples)
--d, --debug Shows debug information (minification time & compression efficiency)
--o, --output [output-file] Use [output-file] as output instead of STDOUT
--r, --root [root-path] Set a root path to which resolve absolute @import rules
--s, --skip-import Disable @import processing
--t, --timeout [seconds] Per connection timeout when fetching remote @imports (defaults to 5 seconds)
---rounding-precision [n] Rounds to `N` decimal places. Defaults to 2. -1 disables rounding
---s0 Remove all special comments, i.e. /*! comment */
---s1 Remove all special comments but the first one
---semantic-merging Enables unsafe mode by assuming BEM-like semantic stylesheets (warning, this may break your styling!)
---skip-advanced Disable advanced optimizations - ruleset reordering & merging
---skip-aggressive-merging Disable properties merging based on their order
---skip-import-from [rules] Disable @import processing for specified rules
---skip-media-merging Disable @media merging
---skip-rebase Disable URLs rebasing
---skip-restructuring Disable restructuring optimizations
---skip-shorthand-compacting Disable shorthand compacting
---source-map Enables building input's source map
---source-map-inline-sources Enables inlining sources inside source maps
-```
-
-#### Examples:
-
-To minify a **public.css** file into **public-min.css** do:
-
-```
-cleancss -o public-min.css public.css
-```
-
-To minify the same **public.css** into the standard output skip the `-o` parameter:
-
-```
-cleancss public.css
-```
-
-More likely you would like to concatenate a couple of files.
-If you are on a Unix-like system:
-
-```bash
-cat one.css two.css three.css | cleancss -o merged-and-minified.css
-```
-
-On Windows:
-
-```bat
-type one.css two.css three.css | cleancss -o merged-and-minified.css
-```
-
-Or even gzip the result at once:
-
-```bash
-cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz
-```
-
-### How to use clean-css API?
-
-```js
-var CleanCSS = require('clean-css');
-var source = 'a{font-weight:bold;}';
-var minified = new CleanCSS().minify(source).styles;
-```
-
-CleanCSS constructor accepts a hash as a parameter, i.e.,
-`new CleanCSS(options)` with the following options available:
-
-* `advanced` - set to false to disable advanced optimizations - selector & property merging, reduction, etc.
-* `aggressiveMerging` - set to false to disable aggressive merging of properties.
-* `benchmark` - turns on benchmarking mode measuring time spent on cleaning up (run `npm run bench` to see example)
-* `compatibility` - enables compatibility mode, see [below for more examples](#how-to-set-a-compatibility-mode)
-* `debug` - set to true to get minification statistics under `stats` property (see `test/custom-test.js` for examples)
-* `inliner` - a hash of options for `@import` inliner, see [test/protocol-imports-test.js](https://github.com/jakubpawlowicz/clean-css/blob/master/test/protocol-imports-test.js#L372) for examples, or [this comment](https://github.com/jakubpawlowicz/clean-css/issues/612#issuecomment-119594185) for a proxy use case.
-* `keepBreaks` - whether to keep line breaks (default is false)
-* `keepSpecialComments` - `*` for keeping all (default), `1` for keeping first one only, `0` for removing all
-* `mediaMerging` - whether to merge `@media` at-rules (default is true)
-* `processImport` - whether to process `@import` rules
-* `processImportFrom` - a list of `@import` rules, can be `['all']` (default), `['local']`, `['remote']`, or a blacklisted path e.g. `['!fonts.googleapis.com']`
-* `rebase` - set to false to skip URL rebasing
-* `relativeTo` - path to **resolve** relative `@import` rules and URLs
-* `restructuring` - set to false to disable restructuring in advanced optimizations
-* `root` - path to **resolve** absolute `@import` rules and **rebase** relative URLs
-* `roundingPrecision` - rounding precision; defaults to `2`; `-1` disables rounding
-* `semanticMerging` - set to true to enable semantic merging mode which assumes BEM-like content (default is false as it's highly likely this will break your stylesheets - **use with caution**!)
-* `shorthandCompacting` - set to false to skip shorthand compacting (default is true unless sourceMap is set when it's false)
-* `sourceMap` - exposes source map under `sourceMap` property, e.g. `new CleanCSS().minify(source).sourceMap` (default is false)
- If input styles are a product of CSS preprocessor (Less, Sass) an input source map can be passed as a string.
-* `sourceMapInlineSources` - set to true to inline sources inside a source map's `sourcesContent` field (defaults to false)
- It is also required to process inlined sources from input source maps.
-* `target` - path to a folder or an output file to which **rebase** all URLs
-
-The output of `minify` method (or the 2nd argument to passed callback) is a hash containing the following fields:
-
-* `styles` - optimized output CSS as a string
-* `sourceMap` - output source map (if requested with `sourceMap` option)
-* `errors` - a list of errors raised
-* `warnings` - a list of warnings raised
-* `stats` - a hash of statistic information (if requested with `debug` option):
- * `originalSize` - original content size (after import inlining)
- * `minifiedSize` - optimized content size
- * `timeSpent` - time spent on optimizations
- * `efficiency` - a ratio of output size to input size (e.g. 25% if content was reduced from 100 bytes to 75 bytes)
-
-#### How to make sure remote `@import`s are processed correctly?
-
-In order to inline remote `@import` statements you need to provide a callback to minify method, e.g.:
-
-```js
-var CleanCSS = require('clean-css');
-var source = '@import url(http://path/to/remote/styles);';
-new CleanCSS().minify(source, function (errors, minified) {
- // minified.styles
-});
-```
-
-This is due to a fact, that, while local files can be read synchronously, remote resources can only be processed asynchronously.
-If you don't provide a callback, then remote `@import`s will be left intact.
-
-### How to use clean-css with build tools?
-
-* [Broccoli](https://github.com/broccolijs/broccoli#broccoli): [broccoli-clean-css](https://github.com/shinnn/broccoli-clean-css)
-* [Brunch](http://brunch.io/): [clean-css-brunch](https://github.com/brunch/clean-css-brunch)
-* [Grunt](http://gruntjs.com): [grunt-contrib-cssmin](https://github.com/gruntjs/grunt-contrib-cssmin)
-* [Gulp](http://gulpjs.com/): [gulp-minify-css](https://github.com/jonathanepollack/gulp-minify-css)
-* [Gulp](http://gulpjs.com/): [using vinyl-map as a wrapper - courtesy of @sogko](https://github.com/jakubpawlowicz/clean-css/issues/342)
-* [component-builder2](https://github.com/component/builder2.js): [builder-clean-css](https://github.com/poying/builder-clean-css)
-* [Metalsmith](http://metalsmith.io): [metalsmith-clean-css](https://github.com/aymericbeaumet/metalsmith-clean-css)
-* [Lasso](https://github.com/lasso-js/lasso): [lasso-clean-css](https://github.com/yomed/lasso-clean-css)
-
-### What are the clean-css' dev commands?
-
-First clone the source, then run:
-
-* `npm run bench` for clean-css benchmarks (see [test/bench.js](https://github.com/jakubpawlowicz/clean-css/blob/master/test/bench.js) for details)
-* `npm run browserify` to create the browser-ready clean-css version
-* `npm run check` to check JS sources with [JSHint](https://github.com/jshint/jshint/)
-* `npm test` for the test suite
-
-## How to contribute to clean-css?
-
-See [CONTRIBUTING.md](https://github.com/jakubpawlowicz/clean-css/blob/master/CONTRIBUTING.md).
-
-## Tips & Tricks
-
-### How to preserve a comment block?
-
-Use the `/*!` notation instead of the standard one `/*`:
-
-```css
-/*!
- Important comments included in minified output.
-*/
-```
-
-### How to rebase relative image URLs?
-
-Clean-css will handle it automatically for you (since version 1.1) in the following cases:
-
-* When using the CLI:
- 1. Use an output path via `-o`/`--output` to rebase URLs as relative to the output file.
- 2. Use a root path via `-r`/`--root` to rebase URLs as absolute from the given root path.
- 3. If you specify both then `-r`/`--root` takes precendence.
-* When using clean-css as a library:
- 1. Use a combination of `relativeTo` and `target` options for relative rebase (same as 1 in CLI).
- 2. Use a combination of `relativeTo` and `root` options for absolute rebase (same as 2 in CLI).
- 3. `root` takes precendence over `target` as in CLI.
-
-### How to generate source maps?
-
-Source maps are supported since version 3.0.
-
-Additionally to mapping original CSS files, clean-css also supports input source maps, so minified styles can be mapped into their [Less](http://lesscss.org/) or [Sass](http://sass-lang.com/) sources directly.
-
-Source maps are generated using [source-map](https://github.com/mozilla/source-map/) module from Mozilla.
-
-#### Using CLI
-
-To generate a source map, use `--source-map` switch, e.g.:
-
-```
-cleancss --source-map --output styles.min.css styles.css
-```
-
-Name of the output file is required, so a map file, named by adding `.map` suffix to output file name, can be created (styles.min.css.map in this case).
-
-#### Using API
-
-To generate a source map, use `sourceMap: true` option, e.g.:
-
-```js
-new CleanCSS({ sourceMap: true, target: pathToOutputDirectory })
- .minify(source, function (minified) {
- // access minified.sourceMap for SourceMapGenerator object
- // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details
- // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI
-});
-```
-
-Using API you can also pass an input source map directly:
-
-```js
-new CleanCSS({ sourceMap: inputSourceMapAsString, target: pathToOutputDirectory })
- .minify(source, function (minified) {
- // access minified.sourceMap to access SourceMapGenerator object
- // see https://github.com/mozilla/source-map/#sourcemapgenerator for more details
- // see https://github.com/jakubpawlowicz/clean-css/blob/master/bin/cleancss#L114 on how it's used in clean-css' CLI
-});
-```
-
-Or even multiple input source maps at once (available since version 3.1):
-
-```js
-new CleanCSS({ sourceMap: true, target: pathToOutputDirectory }).minify({
- 'path/to/source/1': {
- styles: '...styles...',
- sourceMap: '...source-map...'
- },
- 'path/to/source/2': {
- styles: '...styles...',
- sourceMap: '...source-map...'
- }
-}, function (minified) {
- // access minified.sourceMap as above
-});
-```
-
-### How to minify multiple files with API?
-
-#### Passing an array
-
-```js
-new CleanCSS().minify(['path/to/file/one', 'path/to/file/two']);
-```
-
-#### Passing a hash
-
-```js
-new CleanCSS().minify({
- 'path/to/file/one': {
- styles: 'contents of file one'
- },
- 'path/to/file/two': {
- styles: 'contents of file two'
- }
-});
-```
-
-### How to set a compatibility mode?
-
-Compatibility settings are controlled by `--compatibility` switch (CLI) and `compatibility` option (library mode).
-
-In both modes the following values are allowed:
-
-* `'ie7'` - Internet Explorer 7 compatibility mode
-* `'ie8'` - Internet Explorer 8 compatibility mode
-* `''` or `'*'` (default) - Internet Explorer 9+ compatibility mode
-
-Since clean-css 3 a fine grained control is available over
-[those settings](https://github.com/jakubpawlowicz/clean-css/blob/master/lib/utils/compatibility.js),
-with the following options available:
-
-* `'[+-]colors.opacity'` - - turn on (+) / off (-) `rgba()` / `hsla()` declarations removal
-* `'[+-]properties.backgroundClipMerging'` - turn on / off background-clip merging into shorthand
-* `'[+-]properties.backgroundOriginMerging'` - turn on / off background-origin merging into shorthand
-* `'[+-]properties.backgroundSizeMerging'` - turn on / off background-size merging into shorthand
-* `'[+-]properties.colors'` - turn on / off any color optimizations
-* `'[+-]properties.ieBangHack'` - turn on / off IE bang hack removal
-* `'[+-]properties.iePrefixHack'` - turn on / off IE prefix hack removal
-* `'[+-]properties.ieSuffixHack'` - turn on / off IE suffix hack removal
-* `'[+-]properties.merging'` - turn on / off property merging based on understandability
-* `'[+-]properties.spaceAfterClosingBrace'` - turn on / off removing space after closing brace - `url() no-repeat` into `url()no-repeat`
-* `'[+-]properties.urlQuotes'` - turn on / off `url()` quoting
-* `'[+-]properties.zeroUnits'` - turn on / off units removal after a `0` value
-* `'[+-]selectors.adjacentSpace'` - turn on / off extra space before `nav` element
-* `'[+-]selectors.ie7Hack'` - turn on / off IE7 selector hack removal (`*+html...`)
-* `'[+-]selectors.special'` - a regular expression with all special, unmergeable selectors (leave it empty unless you know what you are doing)
-* `'[+-]units.ch'` - turn on / off treating `ch` as a proper unit
-* `'[+-]units.in'` - turn on / off treating `in` as a proper unit
-* `'[+-]units.pc'` - turn on / off treating `pc` as a proper unit
-* `'[+-]units.pt'` - turn on / off treating `pt` as a proper unit
-* `'[+-]units.rem'` - turn on / off treating `rem` as a proper unit
-* `'[+-]units.vh'` - turn on / off treating `vh` as a proper unit
-* `'[+-]units.vm'` - turn on / off treating `vm` as a proper unit
-* `'[+-]units.vmax'` - turn on / off treating `vmax` as a proper unit
-* `'[+-]units.vmin'` - turn on / off treating `vmin` as a proper unit
-* `'[+-]units.vm'` - turn on / off treating `vm` as a proper unit
-
-For example, using `--compatibility 'ie8,+units.rem'` will ensure IE8 compatibility while enabling `rem` units so the following style `margin:0px 0rem` can be shortened to `margin:0`, while in pure IE8 mode it can't be.
-
-To pass a single off (-) switch in CLI please use the following syntax `--compatibility *,-units.rem`.
-
-In library mode you can also pass `compatibility` as a hash of options.
-
-### What advanced optimizations are applied?
-
-All advanced optimizations are dispatched [here](https://github.com/jakubpawlowicz/clean-css/blob/master/lib/selectors/advanced.js#L59), and this is what they do:
-
-* `recursivelyOptimizeBlocks` - does all the following operations on a block (think `@media` or `@keyframe` at-rules);
-* `recursivelyOptimizeProperties` - optimizes properties in rulesets and "flat at-rules" (like @font-face) by splitting them into components (e.g. `margin` into `margin-(*)`), optimizing, and rebuilding them back. You may want to use `shorthandCompacting` option to control whether you want to turn multiple (long-hand) properties into a shorthand ones;
-* `removeDuplicates` - gets rid of duplicate rulesets with exactly the same set of properties (think of including the same Sass / Less partial twice for no good reason);
-* `mergeAdjacent` - merges adjacent rulesets with the same selector or rules;
-* `reduceNonAdjacent` - identifies which properties are overridden in same-selector non-adjacent rulesets, and removes them;
-* `mergeNonAdjacentBySelector` - identifies same-selector non-adjacent rulesets which can be moved (!) to be merged, requires all intermediate rulesets to not redefine the moved properties, or if redefined to be either more coarse grained (e.g. `margin` vs `margin-top`) or have the same value;
-* `mergeNonAdjacentByBody` - same as the one above but for same-rules non-adjacent rulesets;
-* `restructure` - tries to reorganize different-selector different-rules rulesets so they take less space, e.g. `.one{padding:0}.two{margin:0}.one{margin-bottom:3px}` into `.two{margin:0}.one{padding:0;margin-bottom:3px}`;
-* `removeDuplicateMediaQueries` - removes duplicated `@media` at-rules;
-* `mergeMediaQueries` - merges non-adjacent `@media` at-rules by same rules as `mergeNonAdjacentBy*` above;
-
-## Acknowledgments (sorted alphabetically)
-
-* Anthony Barre ([@abarre](https://github.com/abarre)) for improvements to
- `@import` processing, namely introducing the `--skip-import` /
- `processImport` options.
-* Simon Altschuler ([@altschuler](https://github.com/altschuler)) for fixing
- `@import` processing inside comments.
-* Isaac ([@facelessuser](https://github.com/facelessuser)) for pointing out
- a flaw in clean-css' stateless mode.
-* Jan Michael Alonzo ([@jmalonzo](https://github.com/jmalonzo)) for a patch
- removing node.js' old `sys` package.
-* Luke Page ([@lukeapage](https://github.com/lukeapage)) for suggestions and testing the source maps feature.
- Plus everyone else involved in [#125](https://github.com/jakubpawlowicz/clean-css/issues/125) for pushing it forward.
-* Timur Kristóf ([@Venemo](https://github.com/Venemo)) for an outstanding
- contribution of advanced property optimizer for 2.2 release.
-* Vincent Voyer ([@vvo](https://github.com/vvo)) for a patch with better
- empty element regex and for inspiring us to do many performance improvements
- in 0.4 release.
-* [@XhmikosR](https://github.com/XhmikosR) for suggesting new features
- (option to remove special comments and strip out URLs quotation) and
- pointing out numerous improvements (JSHint, media queries).
-
-## License
-
-Clean-css is released under the [MIT License](https://github.com/jakubpawlowicz/clean-css/blob/master/LICENSE).
diff --git a/api/node_modules/clean-css/bin/cleancss b/api/node_modules/clean-css/bin/cleancss
deleted file mode 100755
index 72148cfca..000000000
--- a/api/node_modules/clean-css/bin/cleancss
+++ /dev/null
@@ -1,184 +0,0 @@
-#!/usr/bin/env node
-
-var fs = require('fs');
-var path = require('path');
-var CleanCSS = require('../index');
-
-var commands = require('commander');
-
-var packageConfig = fs.readFileSync(path.join(path.dirname(fs.realpathSync(process.argv[1])), '../package.json'));
-var buildVersion = JSON.parse(packageConfig).version;
-
-var isWindows = process.platform == 'win32';
-var lineBreak = require('os').EOL;
-
-// Specify commander options to parse command line params correctly
-commands
- .version(buildVersion, '-v, --version')
- .usage('[options] source-file, [source-file, ...]')
- .option('-b, --keep-line-breaks', 'Keep line breaks')
- .option('-c, --compatibility [ie7|ie8]', 'Force compatibility mode (see Readme for advanced examples)')
- .option('-d, --debug', 'Shows debug information (minification time & compression efficiency)')
- .option('-o, --output [output-file]', 'Use [output-file] as output instead of STDOUT')
- .option('-r, --root [root-path]', 'Set a root path to which resolve absolute @import rules')
- .option('-s, --skip-import', 'Disable @import processing')
- .option('-t, --timeout [seconds]', 'Per connection timeout when fetching remote @imports (defaults to 5 seconds)')
- .option('--rounding-precision [n]', 'Rounds to `N` decimal places. Defaults to 2. -1 disables rounding', parseInt)
- .option('--s0', 'Remove all special comments, i.e. /*! comment */')
- .option('--s1', 'Remove all special comments but the first one')
- .option('--semantic-merging', 'Enables unsafe mode by assuming BEM-like semantic stylesheets (warning, this may break your styling!)')
- .option('--skip-advanced', 'Disable advanced optimizations - ruleset reordering & merging')
- .option('--skip-aggressive-merging', 'Disable properties merging based on their order')
- .option('--skip-import-from [rules]', 'Disable @import processing for specified rules', function (val) { return val.split(','); }, [])
- .option('--skip-media-merging', 'Disable @media merging')
- .option('--skip-rebase', 'Disable URLs rebasing')
- .option('--skip-restructuring', 'Disable restructuring optimizations')
- .option('--skip-shorthand-compacting', 'Disable shorthand compacting')
- .option('--source-map', 'Enables building input\'s source map')
- .option('--source-map-inline-sources', 'Enables inlining sources inside source maps');
-
-commands.on('--help', function () {
- console.log(' Examples:\n');
- console.log(' %> cleancss one.css');
- console.log(' %> cleancss -o one-min.css one.css');
- if (isWindows) {
- console.log(' %> type one.css two.css three.css | cleancss -o merged-and-minified.css');
- } else {
- console.log(' %> cat one.css two.css three.css | cleancss -o merged-and-minified.css');
- console.log(' %> cat one.css two.css three.css | cleancss | gzip -9 -c > merged-minified-and-gzipped.css.gz');
- }
- console.log('');
- process.exit();
-});
-
-commands.parse(process.argv);
-
-// If no sensible data passed in just print help and exit
-var fromStdin = !process.env.__DIRECT__ && !process.stdin.isTTY;
-if (!fromStdin && commands.args.length === 0) {
- commands.outputHelp();
- return 0;
-}
-
-// Now coerce commands into CleanCSS configuration...
-var options = {
- advanced: commands.skipAdvanced ? false : true,
- aggressiveMerging: commands.skipAggressiveMerging ? false : true,
- compatibility: commands.compatibility,
- debug: commands.debug,
- inliner: commands.timeout ? { timeout: parseFloat(commands.timeout) * 1000 } : undefined,
- keepBreaks: !!commands.keepLineBreaks,
- keepSpecialComments: commands.s0 ? 0 : (commands.s1 ? 1 : '*'),
- mediaMerging: commands.skipMediaMerging ? false : true,
- processImport: commands.skipImport ? false : true,
- processImportFrom: processImportFrom(commands.skipImportFrom),
- rebase: commands.skipRebase ? false : true,
- restructuring: commands.skipRestructuring ? false : true,
- root: commands.root,
- roundingPrecision: commands.roundingPrecision,
- semanticMerging: commands.semanticMerging ? true : false,
- shorthandCompacting: commands.skipShorthandCompacting ? false : true,
- sourceMap: commands.sourceMap,
- sourceMapInlineSources: commands.sourceMapInlineSources,
- target: commands.output
-};
-
-if (options.root || commands.args.length > 0) {
- var relativeTo = options.root || commands.args[0];
-
- if (isRemote(relativeTo)) {
- options.relativeTo = relativeTo;
- } else {
- var resolvedRelativeTo = path.resolve(relativeTo);
-
- options.relativeTo = fs.statSync(resolvedRelativeTo).isFile() ?
- path.dirname(resolvedRelativeTo) :
- resolvedRelativeTo;
- }
-}
-
-if (options.sourceMap && !options.target) {
- outputFeedback(['Source maps will not be built because you have not specified an output file.'], true);
- options.sourceMap = false;
-}
-
-// ... and do the magic!
-if (commands.args.length > 0) {
- minify(commands.args);
-} else {
- var stdin = process.openStdin();
- stdin.setEncoding('utf-8');
- var data = '';
- stdin.on('data', function (chunk) {
- data += chunk;
- });
- stdin.on('end', function () {
- minify(data);
- });
-}
-
-function isRemote(path) {
- return /^https?:\/\//.test(path) || /^\/\//.test(path);
-}
-
-function processImportFrom(rules) {
- if (rules.length === 0) {
- return ['all'];
- } else if (rules.length == 1 && rules[0] == 'all') {
- return [];
- } else {
- return rules.map(function (rule) {
- if (rule == 'local')
- return 'remote';
- else if (rule == 'remote')
- return 'local';
- else
- return '!' + rule;
- });
- }
-}
-
-function minify(data) {
- new CleanCSS(options).minify(data, function (errors, minified) {
- if (options.debug) {
- console.error('Original: %d bytes', minified.stats.originalSize);
- console.error('Minified: %d bytes', minified.stats.minifiedSize);
- console.error('Efficiency: %d%', ~~(minified.stats.efficiency * 10000) / 100.0);
- console.error('Time spent: %dms', minified.stats.timeSpent);
- }
-
- outputFeedback(minified.errors, true);
- outputFeedback(minified.warnings);
-
- if (minified.errors.length > 0)
- process.exit(1);
-
- if (minified.sourceMap) {
- var mapFilename = path.basename(options.target) + '.map';
- output(minified.styles + lineBreak + '/*# sourceMappingURL=' + mapFilename + ' */');
- outputMap(minified.sourceMap, mapFilename);
- } else {
- output(minified.styles);
- }
- });
-}
-
-function output(minified) {
- if (options.target)
- fs.writeFileSync(options.target, minified, 'utf8');
- else
- process.stdout.write(minified);
-}
-
-function outputMap(sourceMap, mapFilename) {
- var mapPath = path.join(path.dirname(options.target), mapFilename);
- fs.writeFileSync(mapPath, sourceMap.toString(), 'utf-8');
-}
-
-function outputFeedback(messages, isError) {
- var prefix = isError ? '\x1B[31mERROR\x1B[39m:' : 'WARNING:';
-
- messages.forEach(function (message) {
- console.error('%s %s', prefix, message);
- });
-}
diff --git a/api/node_modules/clean-css/index.js b/api/node_modules/clean-css/index.js
deleted file mode 100644
index d7b05030f..000000000
--- a/api/node_modules/clean-css/index.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./lib/clean');
diff --git a/api/node_modules/clean-css/lib/clean.js b/api/node_modules/clean-css/lib/clean.js
deleted file mode 100644
index c9ce2e935..000000000
--- a/api/node_modules/clean-css/lib/clean.js
+++ /dev/null
@@ -1,231 +0,0 @@
-/**
- * Clean-css - https://github.com/jakubpawlowicz/clean-css
- * Released under the terms of MIT license
- *
- * Copyright (C) 2015 JakubPawlowicz.com
- */
-
-var ImportInliner = require('./imports/inliner');
-var rebaseUrls = require('./urls/rebase');
-
-var tokenize = require('./tokenizer/tokenize');
-var simpleOptimize = require('./selectors/simple');
-var advancedOptimize = require('./selectors/advanced');
-
-var simpleStringify = require('./stringifier/simple');
-var sourceMapStringify = require('./stringifier/source-maps');
-
-var CommentsProcessor = require('./text/comments-processor');
-var ExpressionsProcessor = require('./text/expressions-processor');
-var FreeTextProcessor = require('./text/free-text-processor');
-var UrlsProcessor = require('./text/urls-processor');
-
-var Compatibility = require('./utils/compatibility');
-var InputSourceMapTracker = require('./utils/input-source-map-tracker');
-var SourceTracker = require('./utils/source-tracker');
-var SourceReader = require('./utils/source-reader');
-var Validator = require('./properties/validator');
-
-var fs = require('fs');
-var path = require('path');
-var url = require('url');
-
-var override = require('./utils/object').override;
-
-var DEFAULT_TIMEOUT = 5000;
-
-var CleanCSS = module.exports = function CleanCSS(options) {
- options = options || {};
-
- this.options = {
- advanced: undefined === options.advanced ? true : !!options.advanced,
- aggressiveMerging: undefined === options.aggressiveMerging ? true : !!options.aggressiveMerging,
- benchmark: options.benchmark,
- compatibility: new Compatibility(options.compatibility).toOptions(),
- debug: options.debug,
- explicitRoot: !!options.root,
- explicitTarget: !!options.target,
- inliner: options.inliner || {},
- keepBreaks: options.keepBreaks || false,
- keepSpecialComments: 'keepSpecialComments' in options ? options.keepSpecialComments : '*',
- mediaMerging: undefined === options.mediaMerging ? true : !!options.mediaMerging,
- processImport: undefined === options.processImport ? true : !!options.processImport,
- processImportFrom: importOptionsFrom(options.processImportFrom),
- rebase: undefined === options.rebase ? true : !!options.rebase,
- relativeTo: options.relativeTo,
- restructuring: undefined === options.restructuring ? true : !!options.restructuring,
- root: options.root || process.cwd(),
- roundingPrecision: options.roundingPrecision,
- semanticMerging: undefined === options.semanticMerging ? false : !!options.semanticMerging,
- shorthandCompacting: undefined === options.shorthandCompacting ? true : !!options.shorthandCompacting,
- sourceMap: options.sourceMap,
- sourceMapInlineSources: !!options.sourceMapInlineSources,
- target: !options.target || missingDirectory(options.target) || presentDirectory(options.target) ? options.target : path.dirname(options.target)
- };
-
- this.options.inliner.timeout = this.options.inliner.timeout || DEFAULT_TIMEOUT;
- this.options.inliner.request = override(
- /* jshint camelcase: false */
- proxyOptionsFrom(process.env.HTTP_PROXY || process.env.http_proxy),
- this.options.inliner.request || {}
- );
-};
-
-function importOptionsFrom(rules) {
- return undefined === rules ? ['all'] : rules;
-}
-
-function missingDirectory(filepath) {
- return !fs.existsSync(filepath) && !/\.css$/.test(filepath);
-}
-
-function presentDirectory(filepath) {
- return fs.existsSync(filepath) && fs.statSync(filepath).isDirectory();
-}
-
-function proxyOptionsFrom(httpProxy) {
- return httpProxy ?
- {
- hostname: url.parse(httpProxy).hostname,
- port: parseInt(url.parse(httpProxy).port)
- } :
- {};
-}
-
-CleanCSS.prototype.minify = function (data, callback) {
- var context = {
- stats: {},
- errors: [],
- warnings: [],
- options: this.options,
- debug: this.options.debug,
- localOnly: !callback,
- sourceTracker: new SourceTracker(),
- validator: new Validator(this.options.compatibility)
- };
-
- if (context.options.sourceMap)
- context.inputSourceMapTracker = new InputSourceMapTracker(context);
-
- context.sourceReader = new SourceReader(context, data);
- data = context.sourceReader.toString();
-
- if (context.options.processImport || data.indexOf('@shallow') > 0) {
- // inline all imports
- var runner = callback ?
- process.nextTick :
- function (callback) { return callback(); };
-
- return runner(function () {
- return new ImportInliner(context).process(data, {
- localOnly: context.localOnly,
- imports: context.options.processImportFrom,
- whenDone: runMinifier(callback, context)
- });
- });
- } else {
- return runMinifier(callback, context)(data);
- }
-};
-
-function runMinifier(callback, context) {
- function whenSourceMapReady (data) {
- data = context.options.debug ?
- minifyWithDebug(context, data) :
- minify(context, data);
- data = withMetadata(context, data);
-
- return callback ?
- callback.call(null, context.errors.length > 0 ? context.errors : null, data) :
- data;
- }
-
- return function (data) {
- if (context.options.sourceMap) {
- return context.inputSourceMapTracker.track(data, function () {
- if (context.options.sourceMapInlineSources) {
- return context.inputSourceMapTracker.resolveSources(function () {
- return whenSourceMapReady(data);
- });
- } else {
- return whenSourceMapReady(data);
- }
- });
- } else {
- return whenSourceMapReady(data);
- }
- };
-}
-
-function withMetadata(context, data) {
- data.stats = context.stats;
- data.errors = context.errors;
- data.warnings = context.warnings;
- return data;
-}
-
-function minifyWithDebug(context, data) {
- var startedAt = process.hrtime();
- context.stats.originalSize = context.sourceTracker.removeAll(data).length;
-
- data = minify(context, data);
-
- var elapsed = process.hrtime(startedAt);
- context.stats.timeSpent = ~~(elapsed[0] * 1e3 + elapsed[1] / 1e6);
- context.stats.efficiency = 1 - data.styles.length / context.stats.originalSize;
- context.stats.minifiedSize = data.styles.length;
-
- return data;
-}
-
-function benchmark(runner) {
- return function (processor, action) {
- var name = processor.constructor.name + '#' + action;
- var start = process.hrtime();
- runner(processor, action);
- var itTook = process.hrtime(start);
- console.log('%d ms: ' + name, 1000 * itTook[0] + itTook[1] / 1000000);
- };
-}
-
-function minify(context, data) {
- var options = context.options;
-
- var commentsProcessor = new CommentsProcessor(context, options.keepSpecialComments, options.keepBreaks, options.sourceMap);
- var expressionsProcessor = new ExpressionsProcessor(options.sourceMap);
- var freeTextProcessor = new FreeTextProcessor(options.sourceMap);
- var urlsProcessor = new UrlsProcessor(context, options.sourceMap, options.compatibility.properties.urlQuotes);
-
- var stringify = options.sourceMap ? sourceMapStringify : simpleStringify;
-
- var run = function (processor, action) {
- data = typeof processor == 'function' ?
- processor(data) :
- processor[action](data);
- };
-
- if (options.benchmark)
- run = benchmark(run);
-
- run(commentsProcessor, 'escape');
- run(expressionsProcessor, 'escape');
- run(urlsProcessor, 'escape');
- run(freeTextProcessor, 'escape');
-
- function restoreEscapes(data, prefixContent) {
- data = freeTextProcessor.restore(data, prefixContent);
- data = urlsProcessor.restore(data);
- data = options.rebase ? rebaseUrls(data, context) : data;
- data = expressionsProcessor.restore(data);
- return commentsProcessor.restore(data);
- }
-
- var tokens = tokenize(data, context);
-
- simpleOptimize(tokens, options, context);
-
- if (options.advanced)
- advancedOptimize(tokens, options, context, true);
-
- return stringify(tokens, options, restoreEscapes, context.inputSourceMapTracker);
-}
diff --git a/api/node_modules/clean-css/lib/colors/hex-name-shortener.js b/api/node_modules/clean-css/lib/colors/hex-name-shortener.js
deleted file mode 100644
index 2af2f4e21..000000000
--- a/api/node_modules/clean-css/lib/colors/hex-name-shortener.js
+++ /dev/null
@@ -1,186 +0,0 @@
-var HexNameShortener = {};
-
-var COLORS = {
- aliceblue: '#f0f8ff',
- antiquewhite: '#faebd7',
- aqua: '#0ff',
- aquamarine: '#7fffd4',
- azure: '#f0ffff',
- beige: '#f5f5dc',
- bisque: '#ffe4c4',
- black: '#000',
- blanchedalmond: '#ffebcd',
- blue: '#00f',
- blueviolet: '#8a2be2',
- brown: '#a52a2a',
- burlywood: '#deb887',
- cadetblue: '#5f9ea0',
- chartreuse: '#7fff00',
- chocolate: '#d2691e',
- coral: '#ff7f50',
- cornflowerblue: '#6495ed',
- cornsilk: '#fff8dc',
- crimson: '#dc143c',
- cyan: '#0ff',
- darkblue: '#00008b',
- darkcyan: '#008b8b',
- darkgoldenrod: '#b8860b',
- darkgray: '#a9a9a9',
- darkgreen: '#006400',
- darkgrey: '#a9a9a9',
- darkkhaki: '#bdb76b',
- darkmagenta: '#8b008b',
- darkolivegreen: '#556b2f',
- darkorange: '#ff8c00',
- darkorchid: '#9932cc',
- darkred: '#8b0000',
- darksalmon: '#e9967a',
- darkseagreen: '#8fbc8f',
- darkslateblue: '#483d8b',
- darkslategray: '#2f4f4f',
- darkslategrey: '#2f4f4f',
- darkturquoise: '#00ced1',
- darkviolet: '#9400d3',
- deeppink: '#ff1493',
- deepskyblue: '#00bfff',
- dimgray: '#696969',
- dimgrey: '#696969',
- dodgerblue: '#1e90ff',
- firebrick: '#b22222',
- floralwhite: '#fffaf0',
- forestgreen: '#228b22',
- fuchsia: '#f0f',
- gainsboro: '#dcdcdc',
- ghostwhite: '#f8f8ff',
- gold: '#ffd700',
- goldenrod: '#daa520',
- gray: '#808080',
- green: '#008000',
- greenyellow: '#adff2f',
- grey: '#808080',
- honeydew: '#f0fff0',
- hotpink: '#ff69b4',
- indianred: '#cd5c5c',
- indigo: '#4b0082',
- ivory: '#fffff0',
- khaki: '#f0e68c',
- lavender: '#e6e6fa',
- lavenderblush: '#fff0f5',
- lawngreen: '#7cfc00',
- lemonchiffon: '#fffacd',
- lightblue: '#add8e6',
- lightcoral: '#f08080',
- lightcyan: '#e0ffff',
- lightgoldenrodyellow: '#fafad2',
- lightgray: '#d3d3d3',
- lightgreen: '#90ee90',
- lightgrey: '#d3d3d3',
- lightpink: '#ffb6c1',
- lightsalmon: '#ffa07a',
- lightseagreen: '#20b2aa',
- lightskyblue: '#87cefa',
- lightslategray: '#778899',
- lightslategrey: '#778899',
- lightsteelblue: '#b0c4de',
- lightyellow: '#ffffe0',
- lime: '#0f0',
- limegreen: '#32cd32',
- linen: '#faf0e6',
- magenta: '#ff00ff',
- maroon: '#800000',
- mediumaquamarine: '#66cdaa',
- mediumblue: '#0000cd',
- mediumorchid: '#ba55d3',
- mediumpurple: '#9370db',
- mediumseagreen: '#3cb371',
- mediumslateblue: '#7b68ee',
- mediumspringgreen: '#00fa9a',
- mediumturquoise: '#48d1cc',
- mediumvioletred: '#c71585',
- midnightblue: '#191970',
- mintcream: '#f5fffa',
- mistyrose: '#ffe4e1',
- moccasin: '#ffe4b5',
- navajowhite: '#ffdead',
- navy: '#000080',
- oldlace: '#fdf5e6',
- olive: '#808000',
- olivedrab: '#6b8e23',
- orange: '#ffa500',
- orangered: '#ff4500',
- orchid: '#da70d6',
- palegoldenrod: '#eee8aa',
- palegreen: '#98fb98',
- paleturquoise: '#afeeee',
- palevioletred: '#db7093',
- papayawhip: '#ffefd5',
- peachpuff: '#ffdab9',
- peru: '#cd853f',
- pink: '#ffc0cb',
- plum: '#dda0dd',
- powderblue: '#b0e0e6',
- purple: '#800080',
- rebeccapurple: '#663399',
- red: '#f00',
- rosybrown: '#bc8f8f',
- royalblue: '#4169e1',
- saddlebrown: '#8b4513',
- salmon: '#fa8072',
- sandybrown: '#f4a460',
- seagreen: '#2e8b57',
- seashell: '#fff5ee',
- sienna: '#a0522d',
- silver: '#c0c0c0',
- skyblue: '#87ceeb',
- slateblue: '#6a5acd',
- slategray: '#708090',
- slategrey: '#708090',
- snow: '#fffafa',
- springgreen: '#00ff7f',
- steelblue: '#4682b4',
- tan: '#d2b48c',
- teal: '#008080',
- thistle: '#d8bfd8',
- tomato: '#ff6347',
- turquoise: '#40e0d0',
- violet: '#ee82ee',
- wheat: '#f5deb3',
- white: '#fff',
- whitesmoke: '#f5f5f5',
- yellow: '#ff0',
- yellowgreen: '#9acd32'
-};
-
-var toHex = {};
-var toName = {};
-
-for (var name in COLORS) {
- var hex = COLORS[name];
- if (name.length < hex.length)
- toName[hex] = name;
- else
- toHex[name] = hex;
-}
-
-var toHexPattern = new RegExp('(^| |,|\\))(' + Object.keys(toHex).join('|') + ')( |,|\\)|$)', 'ig');
-var toNamePattern = new RegExp('(' + Object.keys(toName).join('|') + ')([^a-f0-9]|$)', 'ig');
-
-function hexConverter(match, prefix, colorValue, suffix) {
- return prefix + toHex[colorValue.toLowerCase()] + suffix;
-}
-
-function nameConverter(match, colorValue, suffix) {
- return toName[colorValue.toLowerCase()] + suffix;
-}
-
-HexNameShortener.shorten = function (value) {
- var hasHex = value.indexOf('#') > -1;
- var shortened = value.replace(toHexPattern, hexConverter);
-
- if (shortened != value)
- shortened = shortened.replace(toHexPattern, hexConverter);
-
- return hasHex ? shortened.replace(toNamePattern, nameConverter) : shortened;
-};
-
-module.exports = HexNameShortener;
diff --git a/api/node_modules/clean-css/lib/colors/hsl.js b/api/node_modules/clean-css/lib/colors/hsl.js
deleted file mode 100644
index 5c76b6e64..000000000
--- a/api/node_modules/clean-css/lib/colors/hsl.js
+++ /dev/null
@@ -1,67 +0,0 @@
-// HSL to RGB converter. Both methods adapted from:
-// http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript
-
-function HSLColor(hue, saturation, lightness) {
- this.hue = hue;
- this.saturation = saturation;
- this.lightness = lightness;
-}
-
-function hslToRgb(h, s, l) {
- var r, g, b;
-
- // normalize hue orientation b/w 0 and 360 degrees
- h = h % 360;
- if (h < 0)
- h += 360;
- h = ~~h / 360;
-
- if (s < 0)
- s = 0;
- else if (s > 100)
- s = 100;
- s = ~~s / 100;
-
- if (l < 0)
- l = 0;
- else if (l > 100)
- l = 100;
- l = ~~l / 100;
-
- if (s === 0) {
- r = g = b = l; // achromatic
- } else {
- var q = l < 0.5 ?
- l * (1 + s) :
- l + s - l * s;
- var p = 2 * l - q;
- r = hueToRgb(p, q, h + 1/3);
- g = hueToRgb(p, q, h);
- b = hueToRgb(p, q, h - 1/3);
- }
-
- return [~~(r * 255), ~~(g * 255), ~~(b * 255)];
-}
-
-function hueToRgb(p, q, t) {
- if (t < 0) t += 1;
- if (t > 1) t -= 1;
- if (t < 1/6) return p + (q - p) * 6 * t;
- if (t < 1/2) return q;
- if (t < 2/3) return p + (q - p) * (2/3 - t) * 6;
- return p;
-}
-
-HSLColor.prototype.toHex = function () {
- var asRgb = hslToRgb(this.hue, this.saturation, this.lightness);
- var redAsHex = asRgb[0].toString(16);
- var greenAsHex = asRgb[1].toString(16);
- var blueAsHex = asRgb[2].toString(16);
-
- return '#' +
- ((redAsHex.length == 1 ? '0' : '') + redAsHex) +
- ((greenAsHex.length == 1 ? '0' : '') + greenAsHex) +
- ((blueAsHex.length == 1 ? '0' : '') + blueAsHex);
-};
-
-module.exports = HSLColor;
diff --git a/api/node_modules/clean-css/lib/colors/rgb.js b/api/node_modules/clean-css/lib/colors/rgb.js
deleted file mode 100644
index 2f9454821..000000000
--- a/api/node_modules/clean-css/lib/colors/rgb.js
+++ /dev/null
@@ -1,16 +0,0 @@
-function RGB(red, green, blue) {
- this.red = red;
- this.green = green;
- this.blue = blue;
-}
-
-RGB.prototype.toHex = function () {
- var red = Math.max(0, Math.min(~~this.red, 255));
- var green = Math.max(0, Math.min(~~this.green, 255));
- var blue = Math.max(0, Math.min(~~this.blue, 255));
-
- // Credit: Asen http://jsbin.com/UPUmaGOc/2/edit?js,console
- return '#' + ('00000' + (red << 16 | green << 8 | blue).toString(16)).slice(-6);
-};
-
-module.exports = RGB;
diff --git a/api/node_modules/clean-css/lib/imports/inliner.js b/api/node_modules/clean-css/lib/imports/inliner.js
deleted file mode 100644
index 041d73355..000000000
--- a/api/node_modules/clean-css/lib/imports/inliner.js
+++ /dev/null
@@ -1,399 +0,0 @@
-var fs = require('fs');
-var path = require('path');
-var http = require('http');
-var https = require('https');
-var url = require('url');
-
-var rewriteUrls = require('../urls/rewrite');
-var split = require('../utils/split');
-var override = require('../utils/object.js').override;
-
-var MAP_MARKER = /\/\*# sourceMappingURL=(\S+) \*\//;
-var REMOTE_RESOURCE = /^(https?:)?\/\//;
-var NO_PROTOCOL_RESOURCE = /^\/\//;
-
-function ImportInliner (context) {
- this.outerContext = context;
-}
-
-ImportInliner.prototype.process = function (data, context) {
- var root = this.outerContext.options.root;
-
- context = override(context, {
- baseRelativeTo: this.outerContext.options.relativeTo || root,
- debug: this.outerContext.options.debug,
- done: [],
- errors: this.outerContext.errors,
- left: [],
- inliner: this.outerContext.options.inliner,
- rebase: this.outerContext.options.rebase,
- relativeTo: this.outerContext.options.relativeTo || root,
- root: root,
- sourceReader: this.outerContext.sourceReader,
- sourceTracker: this.outerContext.sourceTracker,
- warnings: this.outerContext.warnings,
- visited: []
- });
-
- return importFrom(data, context);
-};
-
-function importFrom(data, context) {
- if (context.shallow) {
- context.shallow = false;
- context.done.push(data);
- return processNext(context);
- }
-
- var nextStart = 0;
- var nextEnd = 0;
- var cursor = 0;
- var isComment = commentScanner(data);
-
- for (; nextEnd < data.length;) {
- nextStart = nextImportAt(data, cursor);
- if (nextStart == -1)
- break;
-
- if (isComment(nextStart)) {
- cursor = nextStart + 1;
- continue;
- }
-
- nextEnd = data.indexOf(';', nextStart);
- if (nextEnd == -1) {
- cursor = data.length;
- data = '';
- break;
- }
-
- var noImportPart = data.substring(0, nextStart);
- context.done.push(noImportPart);
- context.left.unshift([data.substring(nextEnd + 1), override(context, { shallow: false })]);
- context.afterContent = hasContent(noImportPart);
- return inline(data, nextStart, nextEnd, context);
- }
-
- // no @import matched in current data
- context.done.push(data);
- return processNext(context);
-}
-
-function rebaseMap(data, source) {
- return data.replace(MAP_MARKER, function (match, sourceMapUrl) {
- return REMOTE_RESOURCE.test(sourceMapUrl) ?
- match :
- match.replace(sourceMapUrl, url.resolve(source, sourceMapUrl));
- });
-}
-
-function nextImportAt(data, cursor) {
- var nextLowerCase = data.indexOf('@import', cursor);
- var nextUpperCase = data.indexOf('@IMPORT', cursor);
-
- if (nextLowerCase > -1 && nextUpperCase == -1)
- return nextLowerCase;
- else if (nextLowerCase == -1 && nextUpperCase > -1)
- return nextUpperCase;
- else
- return Math.min(nextLowerCase, nextUpperCase);
-}
-
-function processNext(context) {
- return context.left.length > 0 ?
- importFrom.apply(null, context.left.shift()) :
- context.whenDone(context.done.join(''));
-}
-
-function commentScanner(data) {
- var commentRegex = /(\/\*(?!\*\/)[\s\S]*?\*\/)/;
- var lastStartIndex = 0;
- var lastEndIndex = 0;
- var noComments = false;
-
- // test whether an index is located within a comment
- return function scanner(idx) {
- var comment;
- var localStartIndex = 0;
- var localEndIndex = 0;
- var globalStartIndex = 0;
- var globalEndIndex = 0;
-
- // return if we know there are no more comments
- if (noComments)
- return false;
-
- do {
- // idx can be still within last matched comment (many @import statements inside one comment)
- if (idx > lastStartIndex && idx < lastEndIndex)
- return true;
-
- comment = data.match(commentRegex);
-
- if (!comment) {
- noComments = true;
- return false;
- }
-
- // get the indexes relative to the current data chunk
- lastStartIndex = localStartIndex = comment.index;
- localEndIndex = localStartIndex + comment[0].length;
-
- // calculate the indexes relative to the full original data
- globalEndIndex = localEndIndex + lastEndIndex;
- globalStartIndex = globalEndIndex - comment[0].length;
-
- // chop off data up to and including current comment block
- data = data.substring(localEndIndex);
- lastEndIndex = globalEndIndex;
- } while (globalEndIndex < idx);
-
- return globalEndIndex > idx && idx > globalStartIndex;
- };
-}
-
-function hasContent(data) {
- var isComment = commentScanner(data);
- var firstContentIdx = -1;
- while (true) {
- firstContentIdx = data.indexOf('{', firstContentIdx + 1);
- if (firstContentIdx == -1 || !isComment(firstContentIdx))
- break;
- }
-
- return firstContentIdx > -1;
-}
-
-function inline(data, nextStart, nextEnd, context) {
- context.shallow = data.indexOf('@shallow') > 0;
-
- var importDeclaration = data
- .substring(nextImportAt(data, nextStart) + '@import'.length + 1, nextEnd)
- .replace(/@shallow\)$/, ')')
- .trim();
-
- var viaUrl = importDeclaration.indexOf('url(') === 0;
- var urlStartsAt = viaUrl ? 4 : 0;
- var isQuoted = /^['"]/.exec(importDeclaration.substring(urlStartsAt, urlStartsAt + 2));
- var urlEndsAt = isQuoted ?
- importDeclaration.indexOf(isQuoted[0], urlStartsAt + 1) :
- split(importDeclaration, ' ')[0].length - (viaUrl ? 1 : 0);
-
- var importedFile = importDeclaration
- .substring(urlStartsAt, urlEndsAt)
- .replace(/['"]/g, '')
- .replace(/\)$/, '')
- .trim();
-
- var mediaQuery = importDeclaration
- .substring(urlEndsAt + 1)
- .replace(/^\)/, '')
- .trim();
-
- var isRemote = context.isRemote || REMOTE_RESOURCE.test(importedFile);
-
- if (isRemote && (context.localOnly || !allowedResource(importedFile, true, context.imports))) {
- if (context.afterContent || hasContent(context.done.join('')))
- context.warnings.push('Ignoring remote @import of "' + importedFile + '" as no callback given.');
- else
- restoreImport(importedFile, mediaQuery, context);
-
- return processNext(context);
- }
-
- if (!isRemote && !allowedResource(importedFile, false, context.imports)) {
- if (context.afterImport)
- context.warnings.push('Ignoring local @import of "' + importedFile + '" as after other inlined content.');
- else
- restoreImport(importedFile, mediaQuery, context);
- return processNext(context);
- }
-
- if (!isRemote && context.afterContent) {
- context.warnings.push('Ignoring local @import of "' + importedFile + '" as after other CSS content.');
- return processNext(context);
- }
-
- var method = isRemote ? inlineRemoteResource : inlineLocalResource;
- return method(importedFile, mediaQuery, context);
-}
-
-function allowedResource(importedFile, isRemote, rules) {
- if (rules.length === 0)
- return false;
-
- if (isRemote && NO_PROTOCOL_RESOURCE.test(importedFile))
- importedFile = 'http:' + importedFile;
-
- var match = isRemote ?
- url.parse(importedFile).host :
- importedFile;
- var allowed = true;
-
- for (var i = 0; i < rules.length; i++) {
- var rule = rules[i];
-
- if (rule == 'all')
- allowed = true;
- else if (isRemote && rule == 'local')
- allowed = false;
- else if (isRemote && rule == 'remote')
- allowed = true;
- else if (!isRemote && rule == 'remote')
- allowed = false;
- else if (!isRemote && rule == 'local')
- allowed = true;
- else if (rule[0] == '!' && rule.substring(1) === match)
- allowed = false;
- }
-
- return allowed;
-}
-
-function inlineRemoteResource(importedFile, mediaQuery, context) {
- var importedUrl = REMOTE_RESOURCE.test(importedFile) ?
- importedFile :
- url.resolve(context.relativeTo, importedFile);
- var originalUrl = importedUrl;
-
- if (NO_PROTOCOL_RESOURCE.test(importedUrl))
- importedUrl = 'http:' + importedUrl;
-
- if (context.visited.indexOf(importedUrl) > -1)
- return processNext(context);
-
-
- if (context.debug)
- console.error('Inlining remote stylesheet: ' + importedUrl);
-
- context.visited.push(importedUrl);
-
- var proxyProtocol = context.inliner.request.protocol || context.inliner.request.hostname;
- var get =
- ((proxyProtocol && proxyProtocol.indexOf('https://') !== 0 ) ||
- importedUrl.indexOf('http://') === 0) ?
- http.get :
- https.get;
-
- var errorHandled = false;
- function handleError(message) {
- if (errorHandled)
- return;
-
- errorHandled = true;
- context.errors.push('Broken @import declaration of "' + importedUrl + '" - ' + message);
- restoreImport(importedUrl, mediaQuery, context);
-
- process.nextTick(function () {
- processNext(context);
- });
- }
-
- var requestOptions = override(url.parse(importedUrl), context.inliner.request);
- if (context.inliner.request.hostname !== undefined) {
-
- //overwrite as we always expect a http proxy currently
- requestOptions.protocol = context.inliner.request.protocol || 'http:';
- requestOptions.path = requestOptions.href;
- }
-
-
- get(requestOptions, function (res) {
- if (res.statusCode < 200 || res.statusCode > 399) {
- return handleError('error ' + res.statusCode);
- } else if (res.statusCode > 299) {
- var movedUrl = url.resolve(importedUrl, res.headers.location);
- return inlineRemoteResource(movedUrl, mediaQuery, context);
- }
-
- var chunks = [];
- var parsedUrl = url.parse(importedUrl);
- res.on('data', function (chunk) {
- chunks.push(chunk.toString());
- });
- res.on('end', function () {
- var importedData = chunks.join('');
- if (context.rebase)
- importedData = rewriteUrls(importedData, { toBase: originalUrl }, context);
- context.sourceReader.trackSource(importedUrl, importedData);
- importedData = context.sourceTracker.store(importedUrl, importedData);
- importedData = rebaseMap(importedData, importedUrl);
-
- if (mediaQuery.length > 0)
- importedData = '@media ' + mediaQuery + '{' + importedData + '}';
-
- context.afterImport = true;
-
- var newContext = override(context, {
- isRemote: true,
- relativeTo: parsedUrl.protocol + '//' + parsedUrl.host + parsedUrl.pathname
- });
-
- process.nextTick(function () {
- importFrom(importedData, newContext);
- });
- });
- })
- .on('error', function (res) {
- handleError(res.message);
- })
- .on('timeout', function () {
- handleError('timeout');
- })
- .setTimeout(context.inliner.timeout);
-}
-
-function inlineLocalResource(importedFile, mediaQuery, context) {
- var relativeTo = importedFile[0] == '/' ?
- context.root :
- context.relativeTo;
-
- var fullPath = path.resolve(path.join(relativeTo, importedFile));
-
- if (!fs.existsSync(fullPath) || !fs.statSync(fullPath).isFile()) {
- context.errors.push('Broken @import declaration of "' + importedFile + '"');
- return processNext(context);
- }
-
- if (context.visited.indexOf(fullPath) > -1)
- return processNext(context);
-
-
- if (context.debug)
- console.error('Inlining local stylesheet: ' + fullPath);
-
- context.visited.push(fullPath);
-
- var importRelativeTo = path.dirname(fullPath);
- var importedData = fs.readFileSync(fullPath, 'utf8');
- if (context.rebase) {
- var rewriteOptions = {
- relative: true,
- fromBase: importRelativeTo,
- toBase: context.baseRelativeTo
- };
- importedData = rewriteUrls(importedData, rewriteOptions, context);
- }
-
- var relativePath = path.relative(context.root, fullPath);
- context.sourceReader.trackSource(relativePath, importedData);
- importedData = context.sourceTracker.store(relativePath, importedData);
-
- if (mediaQuery.length > 0)
- importedData = '@media ' + mediaQuery + '{' + importedData + '}';
-
- context.afterImport = true;
-
- var newContext = override(context, {
- relativeTo: importRelativeTo
- });
-
- return importFrom(importedData, newContext);
-}
-
-function restoreImport(importedUrl, mediaQuery, context) {
- var restoredImport = '@import url(' + importedUrl + ')' + (mediaQuery.length > 0 ? ' ' + mediaQuery : '') + ';';
- context.done.push(restoredImport);
-}
-
-module.exports = ImportInliner;
diff --git a/api/node_modules/clean-css/lib/properties/break-up.js b/api/node_modules/clean-css/lib/properties/break-up.js
deleted file mode 100644
index 6657b7a70..000000000
--- a/api/node_modules/clean-css/lib/properties/break-up.js
+++ /dev/null
@@ -1,335 +0,0 @@
-var wrapSingle = require('./wrap-for-optimizing').single;
-var InvalidPropertyError = require('./invalid-property-error');
-
-var split = require('../utils/split');
-var MULTIPLEX_SEPARATOR = ',';
-
-function _colorFilter(validator) {
- return function (value) {
- return value[0] == 'invert' || validator.isValidColor(value[0]);
- };
-}
-
-function _styleFilter(validator) {
- return function (value) {
- return value[0] != 'inherit' && validator.isValidStyle(value[0]) && !validator.isValidColorValue(value[0]);
- };
-}
-
-function _wrapDefault(name, property, compactable) {
- var descriptor = compactable[name];
- if (descriptor.doubleValues && descriptor.defaultValue.length == 2)
- return wrapSingle([[name, property.important], [descriptor.defaultValue[0]], [descriptor.defaultValue[1]]]);
- else if (descriptor.doubleValues && descriptor.defaultValue.length == 1)
- return wrapSingle([[name, property.important], [descriptor.defaultValue[0]]]);
- else
- return wrapSingle([[name, property.important], [descriptor.defaultValue]]);
-}
-
-function _widthFilter(validator) {
- return function (value) {
- return value[0] != 'inherit' && validator.isValidWidth(value[0]) && !validator.isValidStyleKeyword(value[0]) && !validator.isValidColorValue(value[0]);
- };
-}
-
-function background(property, compactable, validator) {
- var image = _wrapDefault('background-image', property, compactable);
- var position = _wrapDefault('background-position', property, compactable);
- var size = _wrapDefault('background-size', property, compactable);
- var repeat = _wrapDefault('background-repeat', property, compactable);
- var attachment = _wrapDefault('background-attachment', property, compactable);
- var origin = _wrapDefault('background-origin', property, compactable);
- var clip = _wrapDefault('background-clip', property, compactable);
- var color = _wrapDefault('background-color', property, compactable);
- var components = [image, position, size, repeat, attachment, origin, clip, color];
- var values = property.value;
-
- var positionSet = false;
- var clipSet = false;
- var originSet = false;
- var repeatSet = false;
-
- if (property.value.length == 1 && property.value[0][0] == 'inherit') {
- // NOTE: 'inherit' is not a valid value for background-attachment
- color.value = image.value = repeat.value = position.value = size.value = origin.value = clip.value = property.value;
- return components;
- }
-
- for (var i = values.length - 1; i >= 0; i--) {
- var value = values[i];
-
- if (validator.isValidBackgroundAttachment(value[0])) {
- attachment.value = [value];
- } else if (validator.isValidBackgroundBox(value[0])) {
- if (clipSet) {
- origin.value = [value];
- originSet = true;
- } else {
- clip.value = [value];
- clipSet = true;
- }
- } else if (validator.isValidBackgroundRepeat(value[0])) {
- if (repeatSet) {
- repeat.value.unshift(value);
- } else {
- repeat.value = [value];
- repeatSet = true;
- }
- } else if (validator.isValidBackgroundPositionPart(value[0]) || validator.isValidBackgroundSizePart(value[0])) {
- if (i > 0) {
- var previousValue = values[i - 1];
-
- if (previousValue[0].indexOf('/') > 0) {
- var twoParts = split(previousValue[0], '/');
- // NOTE: we do this slicing as value may contain metadata too, like for source maps
- size.value = [[twoParts.pop()].concat(previousValue.slice(1)), value];
- values[i - 1] = [twoParts.pop()].concat(previousValue.slice(1));
- } else if (i > 1 && values[i - 2][0] == '/') {
- size.value = [previousValue, value];
- i -= 2;
- } else if (previousValue[0] == '/') {
- size.value = [value];
- } else {
- if (!positionSet)
- position.value = [];
-
- position.value.unshift(value);
- positionSet = true;
- }
- } else {
- if (!positionSet)
- position.value = [];
-
- position.value.unshift(value);
- positionSet = true;
- }
- } else if (validator.isValidBackgroundPositionAndSize(value[0])) {
- var sizeValue = split(value[0], '/');
- // NOTE: we do this slicing as value may contain metadata too, like for source maps
- size.value = [[sizeValue.pop()].concat(value.slice(1))];
- position.value = [[sizeValue.pop()].concat(value.slice(1))];
- } else if ((color.value[0][0] == compactable[color.name].defaultValue || color.value[0][0] == 'none') && validator.isValidColor(value[0])) {
- color.value = [value];
- } else if (validator.isValidUrl(value[0]) || validator.isValidFunction(value[0])) {
- image.value = [value];
- }
- }
-
- if (clipSet && !originSet)
- origin.value = clip.value.slice(0);
-
- return components;
-}
-
-function borderRadius(property, compactable) {
- var values = property.value;
- var splitAt = -1;
-
- for (var i = 0, l = values.length; i < l; i++) {
- if (values[i][0] == '/') {
- splitAt = i;
- break;
- }
- }
-
- if (splitAt === 0 || splitAt === values.length - 1) {
- throw new InvalidPropertyError('Invalid border-radius value.');
- }
-
- var target = _wrapDefault(property.name, property, compactable);
- target.value = splitAt > -1 ?
- values.slice(0, splitAt) :
- values.slice(0);
- target.components = fourValues(target, compactable);
-
- var remainder = _wrapDefault(property.name, property, compactable);
- remainder.value = splitAt > -1 ?
- values.slice(splitAt + 1) :
- values.slice(0);
- remainder.components = fourValues(remainder, compactable);
-
- for (var j = 0; j < 4; j++) {
- target.components[j].multiplex = true;
- target.components[j].value = target.components[j].value.concat(remainder.components[j].value);
- }
-
- return target.components;
-}
-
-function fourValues(property, compactable) {
- var componentNames = compactable[property.name].components;
- var components = [];
- var value = property.value;
-
- if (value.length < 1)
- return [];
-
- if (value.length < 2)
- value[1] = value[0].slice(0);
- if (value.length < 3)
- value[2] = value[0].slice(0);
- if (value.length < 4)
- value[3] = value[1].slice(0);
-
- for (var i = componentNames.length - 1; i >= 0; i--) {
- var component = wrapSingle([[componentNames[i], property.important]]);
- component.value = [value[i]];
- components.unshift(component);
- }
-
- return components;
-}
-
-function multiplex(splitWith) {
- return function (property, compactable, validator) {
- var splitsAt = [];
- var values = property.value;
- var i, j, l, m;
-
- // find split commas
- for (i = 0, l = values.length; i < l; i++) {
- if (values[i][0] == ',')
- splitsAt.push(i);
- }
-
- if (splitsAt.length === 0)
- return splitWith(property, compactable, validator);
-
- var splitComponents = [];
-
- // split over commas, and into components
- for (i = 0, l = splitsAt.length; i <= l; i++) {
- var from = i === 0 ? 0 : splitsAt[i - 1] + 1;
- var to = i < l ? splitsAt[i] : values.length;
-
- var _property = _wrapDefault(property.name, property, compactable);
- _property.value = values.slice(from, to);
-
- splitComponents.push(splitWith(_property, compactable, validator));
- }
-
- var components = splitComponents[0];
-
- // group component values from each split
- for (i = 0, l = components.length; i < l; i++) {
- components[i].multiplex = true;
-
- for (j = 1, m = splitComponents.length; j < m; j++) {
- components[i].value.push([MULTIPLEX_SEPARATOR]);
- Array.prototype.push.apply(components[i].value, splitComponents[j][i].value);
- }
- }
-
- return components;
- };
-}
-
-function listStyle(property, compactable, validator) {
- var type = _wrapDefault('list-style-type', property, compactable);
- var position = _wrapDefault('list-style-position', property, compactable);
- var image = _wrapDefault('list-style-image', property, compactable);
- var components = [type, position, image];
-
- if (property.value.length == 1 && property.value[0][0] == 'inherit') {
- type.value = position.value = image.value = [property.value[0]];
- return components;
- }
-
- var values = property.value.slice(0);
- var total = values.length;
- var index = 0;
-
- // `image` first...
- for (index = 0, total = values.length; index < total; index++) {
- if (validator.isValidUrl(values[index][0]) || values[index][0] == '0') {
- image.value = [values[index]];
- values.splice(index, 1);
- break;
- }
- }
-
- // ... then `type`...
- for (index = 0, total = values.length; index < total; index++) {
- if (validator.isValidListStyleType(values[index][0])) {
- type.value = [values[index]];
- values.splice(index, 1);
- break;
- }
- }
-
- // ... and what's left is a `position`
- if (values.length > 0 && validator.isValidListStylePosition(values[0][0]))
- position.value = [values[0]];
-
- return components;
-}
-
-function widthStyleColor(property, compactable, validator) {
- var descriptor = compactable[property.name];
- var components = [
- _wrapDefault(descriptor.components[0], property, compactable),
- _wrapDefault(descriptor.components[1], property, compactable),
- _wrapDefault(descriptor.components[2], property, compactable)
- ];
- var color, style, width;
-
- for (var i = 0; i < 3; i++) {
- var component = components[i];
-
- if (component.name.indexOf('color') > 0)
- color = component;
- else if (component.name.indexOf('style') > 0)
- style = component;
- else
- width = component;
- }
-
- if ((property.value.length == 1 && property.value[0][0] == 'inherit') ||
- (property.value.length == 3 && property.value[0][0] == 'inherit' && property.value[1][0] == 'inherit' && property.value[2][0] == 'inherit')) {
- color.value = style.value = width.value = [property.value[0]];
- return components;
- }
-
- var values = property.value.slice(0);
- var match, matches;
-
- // NOTE: usually users don't follow the required order of parts in this shorthand,
- // so we'll try to parse it caring as little about order as possible
-
- if (values.length > 0) {
- matches = values.filter(_widthFilter(validator));
- match = matches.length > 1 && (matches[0][0] == 'none' || matches[0][0] == 'auto') ? matches[1] : matches[0];
- if (match) {
- width.value = [match];
- values.splice(values.indexOf(match), 1);
- }
- }
-
- if (values.length > 0) {
- match = values.filter(_styleFilter(validator))[0];
- if (match) {
- style.value = [match];
- values.splice(values.indexOf(match), 1);
- }
- }
-
- if (values.length > 0) {
- match = values.filter(_colorFilter(validator))[0];
- if (match) {
- color.value = [match];
- values.splice(values.indexOf(match), 1);
- }
- }
-
- return components;
-}
-
-module.exports = {
- background: background,
- border: widthStyleColor,
- borderRadius: borderRadius,
- fourValues: fourValues,
- listStyle: listStyle,
- multiplex: multiplex,
- outline: widthStyleColor
-};
diff --git a/api/node_modules/clean-css/lib/properties/can-override.js b/api/node_modules/clean-css/lib/properties/can-override.js
deleted file mode 100644
index 474e2373c..000000000
--- a/api/node_modules/clean-css/lib/properties/can-override.js
+++ /dev/null
@@ -1,142 +0,0 @@
-// Functions that decide what value can override what.
-// The main purpose is to disallow removing CSS fallbacks.
-// A separate implementation is needed for every different kind of CSS property.
-// -----
-// The generic idea is that properties that have wider browser support are 'more understandable'
-// than others and that 'less understandable' values can't override more understandable ones.
-
-// Use when two tokens of the same property can always be merged
-function always() {
- return true;
-}
-
-function alwaysButIntoFunction(property1, property2, validator) {
- var value1 = property1.value[0][0];
- var value2 = property2.value[0][0];
-
- var validFunction1 = validator.isValidFunction(value1);
- var validFunction2 = validator.isValidFunction(value2);
-
- if (validFunction1 && validFunction2) {
- return validator.areSameFunction(value1, value2);
- } else if (!validFunction1 && validFunction2) {
- return false;
- } else {
- return true;
- }
-}
-
-function backgroundImage(property1, property2, validator) {
- // The idea here is that 'more understandable' values override 'less understandable' values, but not vice versa
- // Understandability: (none | url | inherit) > (same function) > (same value)
-
- // (none | url)
- var image1 = property1.value[0][0];
- var image2 = property2.value[0][0];
-
- if (image2 == 'none' || image2 == 'inherit' || validator.isValidUrl(image2))
- return true;
- if (image1 == 'none' || image1 == 'inherit' || validator.isValidUrl(image1))
- return false;
-
- // Functions with the same name can override each other; same values can override each other
- return sameFunctionOrValue(property1, property2, validator);
-}
-
-function border(property1, property2, validator) {
- return color(property1.components[2], property2.components[2], validator);
-}
-
-// Use for color properties (color, background-color, border-color, etc.)
-function color(property1, property2, validator) {
- // The idea here is that 'more understandable' values override 'less understandable' values, but not vice versa
- // Understandability: (hex | named) > (rgba | hsla) > (same function name) > anything else
- // NOTE: at this point rgb and hsl are replaced by hex values by clean-css
-
- var color1 = property1.value[0][0];
- var color2 = property2.value[0][0];
-
- if (!validator.colorOpacity && (validator.isValidRgbaColor(color1) || validator.isValidHslaColor(color1)))
- return false;
- if (!validator.colorOpacity && (validator.isValidRgbaColor(color2) || validator.isValidHslaColor(color2)))
- return false;
-
- // (hex | named)
- if (validator.isValidNamedColor(color2) || validator.isValidHexColor(color2))
- return true;
- if (validator.isValidNamedColor(color1) || validator.isValidHexColor(color1))
- return false;
-
- // (rgba|hsla)
- if (validator.isValidRgbaColor(color2) || validator.isValidHslaColor(color2))
- return true;
- if (validator.isValidRgbaColor(color1) || validator.isValidHslaColor(color1))
- return false;
-
- // Functions with the same name can override each other; same values can override each other
- return sameFunctionOrValue(property1, property2, validator);
-}
-
-function twoOptionalFunctions(property1, property2, validator) {
- var value1 = property1.value[0][0];
- var value2 = property2.value[0][0];
-
- return !(validator.isValidFunction(value1) ^ validator.isValidFunction(value2));
-}
-
-function sameValue(property1, property2) {
- var value1 = property1.value[0][0];
- var value2 = property2.value[0][0];
-
- return value1 === value2;
-}
-
-function sameFunctionOrValue(property1, property2, validator) {
- var value1 = property1.value[0][0];
- var value2 = property2.value[0][0];
-
- // Functions with the same name can override each other
- if (validator.areSameFunction(value1, value2))
- return true;
-
- return value1 === value2;
-}
-
-// Use for properties containing CSS units (margin-top, padding-left, etc.)
-function unit(property1, property2, validator) {
- // The idea here is that 'more understandable' values override 'less understandable' values, but not vice versa
- // Understandability: (unit without functions) > (same functions | standard functions) > anything else
- // NOTE: there is no point in having different vendor-specific functions override each other or standard functions,
- // or having standard functions override vendor-specific functions, but standard functions can override each other
- // NOTE: vendor-specific property values are not taken into consideration here at the moment
- var value1 = property1.value[0][0];
- var value2 = property2.value[0][0];
-
- if (validator.isValidAndCompatibleUnitWithoutFunction(value1) && !validator.isValidAndCompatibleUnitWithoutFunction(value2))
- return false;
-
- if (validator.isValidUnitWithoutFunction(value2))
- return true;
- if (validator.isValidUnitWithoutFunction(value1))
- return false;
-
- // Standard non-vendor-prefixed functions can override each other
- if (validator.isValidFunctionWithoutVendorPrefix(value2) && validator.isValidFunctionWithoutVendorPrefix(value1)) {
- return true;
- }
-
- // Functions with the same name can override each other; same values can override each other
- return sameFunctionOrValue(property1, property2, validator);
-}
-
-module.exports = {
- always: always,
- alwaysButIntoFunction: alwaysButIntoFunction,
- backgroundImage: backgroundImage,
- border: border,
- color: color,
- sameValue: sameValue,
- sameFunctionOrValue: sameFunctionOrValue,
- twoOptionalFunctions: twoOptionalFunctions,
- unit: unit
-};
diff --git a/api/node_modules/clean-css/lib/properties/clone.js b/api/node_modules/clean-css/lib/properties/clone.js
deleted file mode 100644
index 5be6441b6..000000000
--- a/api/node_modules/clean-css/lib/properties/clone.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var wrapSingle = require('./wrap-for-optimizing').single;
-
-function deep(property) {
- var cloned = shallow(property);
- for (var i = property.components.length - 1; i >= 0; i--) {
- var component = shallow(property.components[i]);
- component.value = property.components[i].value.slice(0);
- cloned.components.unshift(component);
- }
-
- cloned.dirty = true;
- cloned.value = property.value.slice(0);
-
- return cloned;
-}
-
-function shallow(property) {
- var cloned = wrapSingle([[property.name, property.important, property.hack]]);
- cloned.unused = false;
- return cloned;
-}
-
-module.exports = {
- deep: deep,
- shallow: shallow
-};
diff --git a/api/node_modules/clean-css/lib/properties/compactable.js b/api/node_modules/clean-css/lib/properties/compactable.js
deleted file mode 100644
index 5131233cf..000000000
--- a/api/node_modules/clean-css/lib/properties/compactable.js
+++ /dev/null
@@ -1,285 +0,0 @@
-// Contains the interpretation of CSS properties, as used by the property optimizer
-
-var breakUp = require('./break-up');
-var canOverride = require('./can-override');
-var restore = require('./restore');
-
-// Properties to process
-// Extend this object in order to add support for more properties in the optimizer.
-//
-// Each key in this object represents a CSS property and should be an object.
-// Such an object contains properties that describe how the represented CSS property should be handled.
-// Possible options:
-//
-// * components: array (Only specify for shorthand properties.)
-// Contains the names of the granular properties this shorthand compacts.
-//
-// * canOverride: function (Default is canOverride.sameValue - meaning that they'll only be merged if they have the same value.)
-// Returns whether two tokens of this property can be merged with each other.
-// This property has no meaning for shorthands.
-//
-// * defaultValue: string
-// Specifies the default value of the property according to the CSS standard.
-// For shorthand, this is used when every component is set to its default value, therefore it should be the shortest possible default value of all the components.
-//
-// * shortestValue: string
-// Specifies the shortest possible value the property can possibly have.
-// (Falls back to defaultValue if unspecified.)
-//
-// * breakUp: function (Only specify for shorthand properties.)
-// Breaks the shorthand up to its components.
-//
-// * restore: function (Only specify for shorthand properties.)
-// Puts the shorthand together from its components.
-//
-var compactable = {
- 'color': {
- canOverride: canOverride.color,
- defaultValue: 'transparent',
- shortestValue: 'red'
- },
- 'background': {
- components: [
- 'background-image',
- 'background-position',
- 'background-size',
- 'background-repeat',
- 'background-attachment',
- 'background-origin',
- 'background-clip',
- 'background-color'
- ],
- breakUp: breakUp.multiplex(breakUp.background),
- defaultValue: '0 0',
- restore: restore.multiplex(restore.background),
- shortestValue: '0',
- shorthand: true
- },
- 'background-clip': {
- canOverride: canOverride.always,
- defaultValue: 'border-box',
- shortestValue: 'border-box'
- },
- 'background-color': {
- canOverride: canOverride.color,
- defaultValue: 'transparent',
- multiplexLastOnly: true,
- nonMergeableValue: 'none',
- shortestValue: 'red'
- },
- 'background-image': {
- canOverride: canOverride.backgroundImage,
- defaultValue: 'none'
- },
- 'background-origin': {
- canOverride: canOverride.always,
- defaultValue: 'padding-box',
- shortestValue: 'border-box'
- },
- 'background-repeat': {
- canOverride: canOverride.always,
- defaultValue: ['repeat'],
- doubleValues: true
- },
- 'background-position': {
- canOverride: canOverride.alwaysButIntoFunction,
- defaultValue: ['0', '0'],
- doubleValues: true,
- shortestValue: '0'
- },
- 'background-size': {
- canOverride: canOverride.alwaysButIntoFunction,
- defaultValue: ['auto'],
- doubleValues: true,
- shortestValue: '0 0'
- },
- 'background-attachment': {
- canOverride: canOverride.always,
- defaultValue: 'scroll'
- },
- 'border': {
- breakUp: breakUp.border,
- canOverride: canOverride.border,
- components: [
- 'border-width',
- 'border-style',
- 'border-color'
- ],
- defaultValue: 'none',
- restore: restore.withoutDefaults,
- shorthand: true
- },
- 'border-color': {
- canOverride: canOverride.color,
- defaultValue: 'none',
- shorthand: true
- },
- 'border-style': {
- canOverride: canOverride.always,
- defaultValue: 'none',
- shorthand: true
- },
- 'border-width': {
- canOverride: canOverride.unit,
- defaultValue: 'medium',
- shortestValue: '0',
- shorthand: true
- },
- 'list-style': {
- components: [
- 'list-style-type',
- 'list-style-position',
- 'list-style-image'
- ],
- canOverride: canOverride.always,
- breakUp: breakUp.listStyle,
- restore: restore.withoutDefaults,
- defaultValue: 'outside', // can't use 'disc' because that'd override default 'decimal' for
- shortestValue: 'none',
- shorthand: true
- },
- 'list-style-type' : {
- canOverride: canOverride.always,
- defaultValue: '__hack',
- // NOTE: we can't tell the real default value here, it's 'disc' for and 'decimal' for
- // -- this is a hack, but it doesn't matter because this value will be either overridden or it will disappear at the final step anyway
- shortestValue: 'none'
- },
- 'list-style-position' : {
- canOverride: canOverride.always,
- defaultValue: 'outside',
- shortestValue: 'inside'
- },
- 'list-style-image' : {
- canOverride: canOverride.always,
- defaultValue: 'none'
- },
- 'outline': {
- components: [
- 'outline-color',
- 'outline-style',
- 'outline-width'
- ],
- breakUp: breakUp.outline,
- restore: restore.withoutDefaults,
- defaultValue: '0',
- shorthand: true
- },
- 'outline-color': {
- canOverride: canOverride.color,
- defaultValue: 'invert',
- shortestValue: 'red'
- },
- 'outline-style': {
- canOverride: canOverride.always,
- defaultValue: 'none'
- },
- 'outline-width': {
- canOverride: canOverride.unit,
- defaultValue: 'medium',
- shortestValue: '0'
- },
- '-moz-transform': {
- canOverride: canOverride.sameFunctionOrValue
- },
- '-ms-transform': {
- canOverride: canOverride.sameFunctionOrValue
- },
- '-webkit-transform': {
- canOverride: canOverride.sameFunctionOrValue
- },
- 'transform': {
- canOverride: canOverride.sameFunctionOrValue
- }
-};
-
-var addFourValueShorthand = function (prop, components, options) {
- options = options || {};
- compactable[prop] = {
- canOverride: options.canOverride,
- components: components,
- breakUp: options.breakUp || breakUp.fourValues,
- defaultValue: options.defaultValue || '0',
- restore: options.restore || restore.fourValues,
- shortestValue: options.shortestValue,
- shorthand: true
- };
- for (var i = 0; i < components.length; i++) {
- compactable[components[i]] = {
- breakUp: options.breakUp || breakUp.fourValues,
- canOverride: options.canOverride || canOverride.unit,
- defaultValue: options.defaultValue || '0',
- shortestValue: options.shortestValue
- };
- }
-};
-
-['', '-moz-', '-o-'].forEach(function (prefix) {
- addFourValueShorthand(prefix + 'border-radius', [
- prefix + 'border-top-left-radius',
- prefix + 'border-top-right-radius',
- prefix + 'border-bottom-right-radius',
- prefix + 'border-bottom-left-radius'
- ], {
- breakUp: breakUp.borderRadius,
- restore: restore.borderRadius
- });
-});
-
-addFourValueShorthand('border-color', [
- 'border-top-color',
- 'border-right-color',
- 'border-bottom-color',
- 'border-left-color'
-], {
- breakUp: breakUp.fourValues,
- canOverride: canOverride.color,
- defaultValue: 'none',
- shortestValue: 'red'
-});
-
-addFourValueShorthand('border-style', [
- 'border-top-style',
- 'border-right-style',
- 'border-bottom-style',
- 'border-left-style'
-], {
- breakUp: breakUp.fourValues,
- canOverride: canOverride.always,
- defaultValue: 'none'
-});
-
-addFourValueShorthand('border-width', [
- 'border-top-width',
- 'border-right-width',
- 'border-bottom-width',
- 'border-left-width'
-], {
- defaultValue: 'medium',
- shortestValue: '0'
-});
-
-addFourValueShorthand('padding', [
- 'padding-top',
- 'padding-right',
- 'padding-bottom',
- 'padding-left'
-]);
-
-addFourValueShorthand('margin', [
- 'margin-top',
- 'margin-right',
- 'margin-bottom',
- 'margin-left'
-]);
-
-// Adds `componentOf` field to all longhands
-for (var property in compactable) {
- if (compactable[property].shorthand) {
- for (var i = 0, l = compactable[property].components.length; i < l; i++) {
- compactable[compactable[property].components[i]].componentOf = property;
- }
- }
-}
-
-module.exports = compactable;
diff --git a/api/node_modules/clean-css/lib/properties/every-combination.js b/api/node_modules/clean-css/lib/properties/every-combination.js
deleted file mode 100644
index be3faa69c..000000000
--- a/api/node_modules/clean-css/lib/properties/every-combination.js
+++ /dev/null
@@ -1,28 +0,0 @@
-var shallowClone = require('./clone').shallow;
-
-var MULTIPLEX_SEPARATOR = ',';
-
-function everyCombination(fn, left, right, validator) {
- var samePositon = !left.shorthand && !right.shorthand && !left.multiplex && !right.multiplex;
- var _left = shallowClone(left);
- var _right = shallowClone(right);
-
- for (var i = 0, l = left.value.length; i < l; i++) {
- for (var j = 0, m = right.value.length; j < m; j++) {
- if (left.value[i][0] == MULTIPLEX_SEPARATOR || right.value[j][0] == MULTIPLEX_SEPARATOR)
- continue;
-
- if (samePositon && i != j)
- continue;
-
- _left.value = [left.value[i]];
- _right.value = [right.value[j]];
- if (!fn(_left, _right, validator))
- return false;
- }
- }
-
- return true;
-}
-
-module.exports = everyCombination;
diff --git a/api/node_modules/clean-css/lib/properties/has-inherit.js b/api/node_modules/clean-css/lib/properties/has-inherit.js
deleted file mode 100644
index 96a103baf..000000000
--- a/api/node_modules/clean-css/lib/properties/has-inherit.js
+++ /dev/null
@@ -1,10 +0,0 @@
-function hasInherit(property) {
- for (var i = property.value.length - 1; i >= 0; i--) {
- if (property.value[i][0] == 'inherit')
- return true;
- }
-
- return false;
-}
-
-module.exports = hasInherit;
diff --git a/api/node_modules/clean-css/lib/properties/invalid-property-error.js b/api/node_modules/clean-css/lib/properties/invalid-property-error.js
deleted file mode 100644
index 86d5b5f9b..000000000
--- a/api/node_modules/clean-css/lib/properties/invalid-property-error.js
+++ /dev/null
@@ -1,10 +0,0 @@
-function InvalidPropertyError(message) {
- this.name = 'InvalidPropertyError';
- this.message = message;
- this.stack = (new Error()).stack;
-}
-
-InvalidPropertyError.prototype = Object.create(Error.prototype);
-InvalidPropertyError.prototype.constructor = InvalidPropertyError;
-
-module.exports = InvalidPropertyError;
diff --git a/api/node_modules/clean-css/lib/properties/optimizer.js b/api/node_modules/clean-css/lib/properties/optimizer.js
deleted file mode 100644
index 855b7f9da..000000000
--- a/api/node_modules/clean-css/lib/properties/optimizer.js
+++ /dev/null
@@ -1,215 +0,0 @@
-var compactable = require('./compactable');
-var wrapForOptimizing = require('./wrap-for-optimizing').all;
-var populateComponents = require('./populate-components');
-var compactOverrides = require('./override-compactor');
-var compactShorthands = require('./shorthand-compactor');
-var removeUnused = require('./remove-unused');
-var restoreFromOptimizing = require('./restore-from-optimizing');
-var stringifyProperty = require('../stringifier/one-time').property;
-
-var shorthands = {
- 'animation-delay': ['animation'],
- 'animation-direction': ['animation'],
- 'animation-duration': ['animation'],
- 'animation-fill-mode': ['animation'],
- 'animation-iteration-count': ['animation'],
- 'animation-name': ['animation'],
- 'animation-play-state': ['animation'],
- 'animation-timing-function': ['animation'],
- '-moz-animation-delay': ['-moz-animation'],
- '-moz-animation-direction': ['-moz-animation'],
- '-moz-animation-duration': ['-moz-animation'],
- '-moz-animation-fill-mode': ['-moz-animation'],
- '-moz-animation-iteration-count': ['-moz-animation'],
- '-moz-animation-name': ['-moz-animation'],
- '-moz-animation-play-state': ['-moz-animation'],
- '-moz-animation-timing-function': ['-moz-animation'],
- '-o-animation-delay': ['-o-animation'],
- '-o-animation-direction': ['-o-animation'],
- '-o-animation-duration': ['-o-animation'],
- '-o-animation-fill-mode': ['-o-animation'],
- '-o-animation-iteration-count': ['-o-animation'],
- '-o-animation-name': ['-o-animation'],
- '-o-animation-play-state': ['-o-animation'],
- '-o-animation-timing-function': ['-o-animation'],
- '-webkit-animation-delay': ['-webkit-animation'],
- '-webkit-animation-direction': ['-webkit-animation'],
- '-webkit-animation-duration': ['-webkit-animation'],
- '-webkit-animation-fill-mode': ['-webkit-animation'],
- '-webkit-animation-iteration-count': ['-webkit-animation'],
- '-webkit-animation-name': ['-webkit-animation'],
- '-webkit-animation-play-state': ['-webkit-animation'],
- '-webkit-animation-timing-function': ['-webkit-animation'],
- 'border-color': ['border'],
- 'border-style': ['border'],
- 'border-width': ['border'],
- 'border-bottom': ['border'],
- 'border-bottom-color': ['border-bottom', 'border-color', 'border'],
- 'border-bottom-style': ['border-bottom', 'border-style', 'border'],
- 'border-bottom-width': ['border-bottom', 'border-width', 'border'],
- 'border-left': ['border'],
- 'border-left-color': ['border-left', 'border-color', 'border'],
- 'border-left-style': ['border-left', 'border-style', 'border'],
- 'border-left-width': ['border-left', 'border-width', 'border'],
- 'border-right': ['border'],
- 'border-right-color': ['border-right', 'border-color', 'border'],
- 'border-right-style': ['border-right', 'border-style', 'border'],
- 'border-right-width': ['border-right', 'border-width', 'border'],
- 'border-top': ['border'],
- 'border-top-color': ['border-top', 'border-color', 'border'],
- 'border-top-style': ['border-top', 'border-style', 'border'],
- 'border-top-width': ['border-top', 'border-width', 'border'],
- 'font-family': ['font'],
- 'font-size': ['font'],
- 'font-style': ['font'],
- 'font-variant': ['font'],
- 'font-weight': ['font'],
- 'transition-delay': ['transition'],
- 'transition-duration': ['transition'],
- 'transition-property': ['transition'],
- 'transition-timing-function': ['transition'],
- '-moz-transition-delay': ['-moz-transition'],
- '-moz-transition-duration': ['-moz-transition'],
- '-moz-transition-property': ['-moz-transition'],
- '-moz-transition-timing-function': ['-moz-transition'],
- '-o-transition-delay': ['-o-transition'],
- '-o-transition-duration': ['-o-transition'],
- '-o-transition-property': ['-o-transition'],
- '-o-transition-timing-function': ['-o-transition'],
- '-webkit-transition-delay': ['-webkit-transition'],
- '-webkit-transition-duration': ['-webkit-transition'],
- '-webkit-transition-property': ['-webkit-transition'],
- '-webkit-transition-timing-function': ['-webkit-transition']
-};
-
-function _optimize(properties, mergeAdjacent, aggressiveMerging, validator) {
- var overrideMapping = {};
- var lastName = null;
- var lastProperty;
- var j;
-
- function mergeablePosition(position) {
- if (mergeAdjacent === false || mergeAdjacent === true)
- return mergeAdjacent;
-
- return mergeAdjacent.indexOf(position) > -1;
- }
-
- function sameValue(position) {
- var left = properties[position - 1];
- var right = properties[position];
-
- return stringifyProperty(left.all, left.position) == stringifyProperty(right.all, right.position);
- }
-
- propertyLoop:
- for (var position = 0, total = properties.length; position < total; position++) {
- var property = properties[position];
- var _name = (property.name == '-ms-filter' || property.name == 'filter') ?
- (lastName == 'background' || lastName == 'background-image' ? lastName : property.name) :
- property.name;
- var isImportant = property.important;
- var isHack = property.hack;
-
- if (property.unused)
- continue;
-
- if (position > 0 && lastProperty && _name == lastName && isImportant == lastProperty.important && isHack == lastProperty.hack && sameValue(position) && !lastProperty.unused) {
- property.unused = true;
- continue;
- }
-
- // comment is necessary - we assume that if two properties are one after another
- // then it is intentional way of redefining property which may not be widely supported
- // e.g. a{display:inline-block;display:-moz-inline-box}
- // however if `mergeablePosition` yields true then the rule does not apply
- // (e.g merging two adjacent selectors: `a{display:block}a{display:block}`)
- if (_name in overrideMapping && (aggressiveMerging && _name != lastName || mergeablePosition(position))) {
- var toOverridePositions = overrideMapping[_name];
- var canOverride = compactable[_name] && compactable[_name].canOverride;
- var anyRemoved = false;
-
- for (j = toOverridePositions.length - 1; j >= 0; j--) {
- var toRemove = properties[toOverridePositions[j]];
- var longhandToShorthand = toRemove.name != _name;
- var wasImportant = toRemove.important;
- var wasHack = toRemove.hack;
-
- if (toRemove.unused)
- continue;
-
- if (longhandToShorthand && wasImportant)
- continue;
-
- if (!wasImportant && (wasHack && !isHack || !wasHack && isHack))
- continue;
-
- if (wasImportant && (isHack == 'star' || isHack == 'underscore'))
- continue;
-
- if (!wasHack && !isHack && !longhandToShorthand && canOverride && !canOverride(toRemove, property, validator))
- continue;
-
- if (wasImportant && !isImportant || wasImportant && isHack) {
- property.unused = true;
- lastProperty = property;
- continue propertyLoop;
- } else {
- anyRemoved = true;
- toRemove.unused = true;
- }
- }
-
- if (anyRemoved) {
- position = -1;
- lastProperty = null;
- lastName = null;
- overrideMapping = {};
- continue;
- }
- } else {
- overrideMapping[_name] = overrideMapping[_name] || [];
- overrideMapping[_name].push(position);
-
- // TODO: to be removed with
- // certain shorthand (see values of `shorthands`) should trigger removal of
- // longhand properties (see keys of `shorthands`)
- var _shorthands = shorthands[_name];
- if (_shorthands) {
- for (j = _shorthands.length - 1; j >= 0; j--) {
- var shorthand = _shorthands[j];
- overrideMapping[shorthand] = overrideMapping[shorthand] || [];
- overrideMapping[shorthand].push(position);
- }
- }
- }
-
- lastName = _name;
- lastProperty = property;
- }
-}
-
-function optimize(selector, properties, mergeAdjacent, withCompacting, options, context) {
- var validator = context.validator;
- var warnings = context.warnings;
-
- var _properties = wrapForOptimizing(properties);
- populateComponents(_properties, validator, warnings);
- _optimize(_properties, mergeAdjacent, options.aggressiveMerging, validator);
-
- for (var i = 0, l = _properties.length; i < l; i++) {
- var _property = _properties[i];
- if (_property.variable && _property.block)
- optimize(selector, _property.value[0], mergeAdjacent, withCompacting, options, context);
- }
-
- if (withCompacting && options.shorthandCompacting) {
- compactOverrides(_properties, options.compatibility, validator);
- compactShorthands(_properties, options.sourceMap, validator);
- }
-
- restoreFromOptimizing(_properties);
- removeUnused(_properties);
-}
-
-module.exports = optimize;
diff --git a/api/node_modules/clean-css/lib/properties/override-compactor.js b/api/node_modules/clean-css/lib/properties/override-compactor.js
deleted file mode 100644
index bbf13ed33..000000000
--- a/api/node_modules/clean-css/lib/properties/override-compactor.js
+++ /dev/null
@@ -1,384 +0,0 @@
-var canOverride = require('./can-override');
-var compactable = require('./compactable');
-var deepClone = require('./clone').deep;
-var shallowClone = require('./clone').shallow;
-var hasInherit = require('./has-inherit');
-var restoreFromOptimizing = require('./restore-from-optimizing');
-var everyCombination = require('./every-combination');
-var sameVendorPrefixesIn = require('./vendor-prefixes').same;
-
-var stringifyProperty = require('../stringifier/one-time').property;
-
-var MULTIPLEX_SEPARATOR = ',';
-
-// Used when searching for a component that matches property
-function nameMatchFilter(to) {
- return function (property) {
- return to.name === property.name;
- };
-}
-
-function wouldBreakCompatibility(property, validator) {
- for (var i = 0; i < property.components.length; i++) {
- var component = property.components[i];
- var descriptor = compactable[component.name];
- var canOverride = descriptor && descriptor.canOverride || canOverride.sameValue;
-
- var _component = shallowClone(component);
- _component.value = [[descriptor.defaultValue]];
-
- if (!canOverride(_component, component, validator))
- return true;
- }
-
- return false;
-}
-
-function isComponentOf(shorthand, longhand) {
- return compactable[shorthand.name].components.indexOf(longhand.name) > -1;
-}
-
-function overrideIntoMultiplex(property, by) {
- by.unused = true;
-
- turnIntoMultiplex(by, multiplexSize(property));
- property.value = by.value;
-}
-
-function overrideByMultiplex(property, by) {
- by.unused = true;
- property.multiplex = true;
- property.value = by.value;
-}
-
-function overrideSimple(property, by) {
- by.unused = true;
- property.value = by.value;
-}
-
-function override(property, by) {
- if (by.multiplex)
- overrideByMultiplex(property, by);
- else if (property.multiplex)
- overrideIntoMultiplex(property, by);
- else
- overrideSimple(property, by);
-}
-
-function overrideShorthand(property, by) {
- by.unused = true;
-
- for (var i = 0, l = property.components.length; i < l; i++) {
- override(property.components[i], by.components[i], property.multiplex);
- }
-}
-
-function turnIntoMultiplex(property, size) {
- property.multiplex = true;
-
- for (var i = 0, l = property.components.length; i < l; i++) {
- var component = property.components[i];
- if (component.multiplex)
- continue;
-
- var value = component.value.slice(0);
-
- for (var j = 1; j < size; j++) {
- component.value.push([MULTIPLEX_SEPARATOR]);
- Array.prototype.push.apply(component.value, value);
- }
- }
-}
-
-function multiplexSize(component) {
- var size = 0;
-
- for (var i = 0, l = component.value.length; i < l; i++) {
- if (component.value[i][0] == MULTIPLEX_SEPARATOR)
- size++;
- }
-
- return size + 1;
-}
-
-function lengthOf(property) {
- var fakeAsArray = [[property.name]].concat(property.value);
- return stringifyProperty([fakeAsArray], 0).length;
-}
-
-function moreSameShorthands(properties, startAt, name) {
- // Since we run the main loop in `compactOverrides` backwards, at this point some
- // properties may not be marked as unused.
- // We should consider reverting the order if possible
- var count = 0;
-
- for (var i = startAt; i >= 0; i--) {
- if (properties[i].name == name && !properties[i].unused)
- count++;
- if (count > 1)
- break;
- }
-
- return count > 1;
-}
-
-function overridingFunction(shorthand, validator) {
- for (var i = 0, l = shorthand.components.length; i < l; i++) {
- if (anyValue(validator.isValidFunction, shorthand.components[i]))
- return true;
- }
-
- return false;
-}
-
-function anyValue(fn, property) {
- for (var i = 0, l = property.value.length; i < l; i++) {
- if (property.value[i][0] == MULTIPLEX_SEPARATOR)
- continue;
-
- if (fn(property.value[i][0]))
- return true;
- }
-
- return false;
-}
-
-function wouldResultInLongerValue(left, right) {
- if (!left.multiplex && !right.multiplex || left.multiplex && right.multiplex)
- return false;
-
- var multiplex = left.multiplex ? left : right;
- var simple = left.multiplex ? right : left;
- var component;
-
- var multiplexClone = deepClone(multiplex);
- restoreFromOptimizing([multiplexClone]);
-
- var simpleClone = deepClone(simple);
- restoreFromOptimizing([simpleClone]);
-
- var lengthBefore = lengthOf(multiplexClone) + 1 + lengthOf(simpleClone);
-
- if (left.multiplex) {
- component = multiplexClone.components.filter(nameMatchFilter(simpleClone))[0];
- overrideIntoMultiplex(component, simpleClone);
- } else {
- component = simpleClone.components.filter(nameMatchFilter(multiplexClone))[0];
- turnIntoMultiplex(simpleClone, multiplexSize(multiplexClone));
- overrideByMultiplex(component, multiplexClone);
- }
-
- restoreFromOptimizing([simpleClone]);
-
- var lengthAfter = lengthOf(simpleClone);
-
- return lengthBefore < lengthAfter;
-}
-
-function isCompactable(property) {
- return property.name in compactable;
-}
-
-function noneOverrideHack(left, right) {
- return !left.multiplex &&
- (left.name == 'background' || left.name == 'background-image') &&
- right.multiplex &&
- (right.name == 'background' || right.name == 'background-image') &&
- anyLayerIsNone(right.value);
-}
-
-function anyLayerIsNone(values) {
- var layers = intoLayers(values);
-
- for (var i = 0, l = layers.length; i < l; i++) {
- if (layers[i].length == 1 && layers[i][0][0] == 'none')
- return true;
- }
-
- return false;
-}
-
-function intoLayers(values) {
- var layers = [];
-
- for (var i = 0, layer = [], l = values.length; i < l; i++) {
- var value = values[i];
- if (value[0] == MULTIPLEX_SEPARATOR) {
- layers.push(layer);
- layer = [];
- } else {
- layer.push(value);
- }
- }
-
- layers.push(layer);
- return layers;
-}
-
-function compactOverrides(properties, compatibility, validator) {
- var mayOverride, right, left, component;
- var i, j, k;
-
- propertyLoop:
- for (i = properties.length - 1; i >= 0; i--) {
- right = properties[i];
-
- if (!isCompactable(right))
- continue;
-
- if (right.variable)
- continue;
-
- mayOverride = compactable[right.name].canOverride || canOverride.sameValue;
-
- for (j = i - 1; j >= 0; j--) {
- left = properties[j];
-
- if (!isCompactable(left))
- continue;
-
- if (left.variable)
- continue;
-
- if (left.unused || right.unused)
- continue;
-
- if (left.hack && !right.hack || !left.hack && right.hack)
- continue;
-
- if (hasInherit(right))
- continue;
-
- if (noneOverrideHack(left, right))
- continue;
-
- if (!left.shorthand && right.shorthand && isComponentOf(right, left)) {
- // maybe `left` can be overridden by `right` which is a shorthand?
- if (!right.important && left.important)
- continue;
-
- if (!sameVendorPrefixesIn([left], right.components))
- continue;
-
- if (!anyValue(validator.isValidFunction, left) && overridingFunction(right, validator))
- continue;
-
- component = right.components.filter(nameMatchFilter(left))[0];
- mayOverride = (compactable[left.name] && compactable[left.name].canOverride) || canOverride.sameValue;
- if (everyCombination(mayOverride, left, component, validator)) {
- left.unused = true;
- }
- } else if (left.shorthand && !right.shorthand && isComponentOf(left, right)) {
- // maybe `right` can be pulled into `left` which is a shorthand?
- if (right.important && !left.important)
- continue;
-
- if (!right.important && left.important) {
- right.unused = true;
- continue;
- }
-
- // Pending more clever algorithm in #527
- if (moreSameShorthands(properties, i - 1, left.name))
- continue;
-
- if (overridingFunction(left, validator))
- continue;
-
- component = left.components.filter(nameMatchFilter(right))[0];
- if (everyCombination(mayOverride, component, right, validator)) {
- var disabledBackgroundMerging =
- !compatibility.properties.backgroundClipMerging && component.name.indexOf('background-clip') > -1 ||
- !compatibility.properties.backgroundOriginMerging && component.name.indexOf('background-origin') > -1 ||
- !compatibility.properties.backgroundSizeMerging && component.name.indexOf('background-size') > -1;
- var nonMergeableValue = compactable[right.name].nonMergeableValue === right.value[0][0];
-
- if (disabledBackgroundMerging || nonMergeableValue)
- continue;
-
- if (!compatibility.properties.merging && wouldBreakCompatibility(left, validator))
- continue;
-
- if (component.value[0][0] != right.value[0][0] && (hasInherit(left) || hasInherit(right)))
- continue;
-
- if (wouldResultInLongerValue(left, right))
- continue;
-
- if (!left.multiplex && right.multiplex)
- turnIntoMultiplex(left, multiplexSize(right));
-
- override(component, right);
- left.dirty = true;
- }
- } else if (left.shorthand && right.shorthand && left.name == right.name) {
- // merge if all components can be merged
-
- if (!left.multiplex && right.multiplex)
- continue;
-
- if (!right.important && left.important) {
- right.unused = true;
- continue propertyLoop;
- }
-
- if (right.important && !left.important) {
- left.unused = true;
- continue;
- }
-
- for (k = left.components.length - 1; k >= 0; k--) {
- var leftComponent = left.components[k];
- var rightComponent = right.components[k];
-
- mayOverride = compactable[leftComponent.name].canOverride || canOverride.sameValue;
- if (!everyCombination(mayOverride, leftComponent, rightComponent, validator))
- continue propertyLoop;
- if (!everyCombination(canOverride.twoOptionalFunctions, leftComponent, rightComponent, validator) && validator.isValidFunction(rightComponent))
- continue propertyLoop;
- }
-
- overrideShorthand(left, right);
- left.dirty = true;
- } else if (left.shorthand && right.shorthand && isComponentOf(left, right)) {
- // border is a shorthand but any of its components is a shorthand too
-
- if (!left.important && right.important)
- continue;
-
- component = left.components.filter(nameMatchFilter(right))[0];
- mayOverride = compactable[right.name].canOverride || canOverride.sameValue;
- if (!everyCombination(mayOverride, component, right, validator))
- continue;
-
- if (left.important && !right.important) {
- right.unused = true;
- continue;
- }
-
- var rightRestored = compactable[right.name].restore(right, compactable);
- if (rightRestored.length > 1)
- continue;
-
- component = left.components.filter(nameMatchFilter(right))[0];
- override(component, right);
- right.dirty = true;
- } else if (left.name == right.name) {
- // two non-shorthands should be merged based on understandability
-
- if (left.important && !right.important) {
- right.unused = true;
- continue;
- }
-
- mayOverride = compactable[right.name].canOverride || canOverride.sameValue;
- if (!everyCombination(mayOverride, left, right, validator))
- continue;
-
- left.unused = true;
- }
- }
- }
-}
-
-module.exports = compactOverrides;
diff --git a/api/node_modules/clean-css/lib/properties/populate-components.js b/api/node_modules/clean-css/lib/properties/populate-components.js
deleted file mode 100644
index dd8700ccc..000000000
--- a/api/node_modules/clean-css/lib/properties/populate-components.js
+++ /dev/null
@@ -1,32 +0,0 @@
-var compactable = require('./compactable');
-var InvalidPropertyError = require('./invalid-property-error');
-
-function populateComponents(properties, validator, warnings) {
- for (var i = properties.length - 1; i >= 0; i--) {
- var property = properties[i];
- var descriptor = compactable[property.name];
-
- if (descriptor && descriptor.shorthand) {
- property.shorthand = true;
- property.dirty = true;
-
- try {
- property.components = descriptor.breakUp(property, compactable, validator);
- } catch (e) {
- if (e instanceof InvalidPropertyError) {
- property.components = []; // this will set property.unused to true below
- warnings.push(e.message);
- } else {
- throw e;
- }
- }
-
- if (property.components.length > 0)
- property.multiplex = property.components[0].multiplex;
- else
- property.unused = true;
- }
- }
-}
-
-module.exports = populateComponents;
diff --git a/api/node_modules/clean-css/lib/properties/remove-unused.js b/api/node_modules/clean-css/lib/properties/remove-unused.js
deleted file mode 100644
index 08cb9b6ad..000000000
--- a/api/node_modules/clean-css/lib/properties/remove-unused.js
+++ /dev/null
@@ -1,10 +0,0 @@
-function removeUnused(properties) {
- for (var i = properties.length - 1; i >= 0; i--) {
- var property = properties[i];
-
- if (property.unused)
- property.all.splice(property.position, 1);
- }
-}
-
-module.exports = removeUnused;
diff --git a/api/node_modules/clean-css/lib/properties/restore-from-optimizing.js b/api/node_modules/clean-css/lib/properties/restore-from-optimizing.js
deleted file mode 100644
index f0dfc182c..000000000
--- a/api/node_modules/clean-css/lib/properties/restore-from-optimizing.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var compactable = require('./compactable');
-
-var BACKSLASH_HACK = '\\9';
-var IMPORTANT_TOKEN = '!important';
-var STAR_HACK = '*';
-var UNDERSCORE_HACK = '_';
-var BANG_HACK = '!ie';
-
-function restoreImportant(property) {
- property.value[property.value.length - 1][0] += IMPORTANT_TOKEN;
-}
-
-function restoreHack(property) {
- if (property.hack == 'underscore')
- property.name = UNDERSCORE_HACK + property.name;
- else if (property.hack == 'star')
- property.name = STAR_HACK + property.name;
- else if (property.hack == 'backslash')
- property.value[property.value.length - 1][0] += BACKSLASH_HACK;
- else if (property.hack == 'bang')
- property.value[property.value.length - 1][0] += ' ' + BANG_HACK;
-}
-
-function restoreFromOptimizing(properties, simpleMode) {
- for (var i = properties.length - 1; i >= 0; i--) {
- var property = properties[i];
- var descriptor = compactable[property.name];
- var restored;
-
- if (property.unused)
- continue;
-
- if (!property.dirty && !property.important && !property.hack)
- continue;
-
- if (!simpleMode && descriptor && descriptor.shorthand) {
- restored = descriptor.restore(property, compactable);
- property.value = restored;
- } else {
- restored = property.value;
- }
-
- if (property.important)
- restoreImportant(property);
-
- if (property.hack)
- restoreHack(property);
-
- if (!('all' in property))
- continue;
-
- var current = property.all[property.position];
- current[0][0] = property.name;
-
- current.splice(1, current.length - 1);
- Array.prototype.push.apply(current, restored);
- }
-}
-
-module.exports = restoreFromOptimizing;
diff --git a/api/node_modules/clean-css/lib/properties/restore.js b/api/node_modules/clean-css/lib/properties/restore.js
deleted file mode 100644
index a9f8e6f9e..000000000
--- a/api/node_modules/clean-css/lib/properties/restore.js
+++ /dev/null
@@ -1,232 +0,0 @@
-var shallowClone = require('./clone').shallow;
-var MULTIPLEX_SEPARATOR = ',';
-var SIZE_POSITION_SEPARATOR = '/';
-
-function isInheritOnly(values) {
- for (var i = 0, l = values.length; i < l; i++) {
- var value = values[i][0];
-
- if (value != 'inherit' && value != MULTIPLEX_SEPARATOR && value != SIZE_POSITION_SEPARATOR)
- return false;
- }
-
- return true;
-}
-
-function background(property, compactable, lastInMultiplex) {
- var components = property.components;
- var restored = [];
- var needsOne, needsBoth;
-
- function restoreValue(component) {
- Array.prototype.unshift.apply(restored, component.value);
- }
-
- function isDefaultValue(component) {
- var descriptor = compactable[component.name];
- if (descriptor.doubleValues) {
- if (descriptor.defaultValue.length == 1)
- return component.value[0][0] == descriptor.defaultValue[0] && (component.value[1] ? component.value[1][0] == descriptor.defaultValue[0] : true);
- else
- return component.value[0][0] == descriptor.defaultValue[0] && (component.value[1] ? component.value[1][0] : component.value[0][0]) == descriptor.defaultValue[1];
- } else {
- return component.value[0][0] == descriptor.defaultValue;
- }
- }
-
- for (var i = components.length - 1; i >= 0; i--) {
- var component = components[i];
- var isDefault = isDefaultValue(component);
-
- if (component.name == 'background-clip') {
- var originComponent = components[i - 1];
- var isOriginDefault = isDefaultValue(originComponent);
-
- needsOne = component.value[0][0] == originComponent.value[0][0];
-
- needsBoth = !needsOne && (
- (isOriginDefault && !isDefault) ||
- (!isOriginDefault && !isDefault) ||
- (!isOriginDefault && isDefault && component.value[0][0] != originComponent.value[0][0]));
-
- if (needsOne) {
- restoreValue(originComponent);
- } else if (needsBoth) {
- restoreValue(component);
- restoreValue(originComponent);
- }
-
- i--;
- } else if (component.name == 'background-size') {
- var positionComponent = components[i - 1];
- var isPositionDefault = isDefaultValue(positionComponent);
-
- needsOne = !isPositionDefault && isDefault;
-
- needsBoth = !needsOne &&
- (isPositionDefault && !isDefault || !isPositionDefault && !isDefault);
-
- if (needsOne) {
- restoreValue(positionComponent);
- } else if (needsBoth) {
- restoreValue(component);
- restored.unshift([SIZE_POSITION_SEPARATOR]);
- restoreValue(positionComponent);
- } else if (positionComponent.value.length == 1) {
- restoreValue(positionComponent);
- }
-
- i--;
- } else {
- if (isDefault || compactable[component.name].multiplexLastOnly && !lastInMultiplex)
- continue;
-
- restoreValue(component);
- }
- }
-
- if (restored.length === 0 && property.value.length == 1 && property.value[0][0] == '0')
- restored.push(property.value[0]);
-
- if (restored.length === 0)
- restored.push([compactable[property.name].defaultValue]);
-
- if (isInheritOnly(restored))
- return [restored[0]];
-
- return restored;
-}
-
-function borderRadius(property, compactable) {
- if (property.multiplex) {
- var horizontal = shallowClone(property);
- var vertical = shallowClone(property);
-
- for (var i = 0; i < 4; i++) {
- var component = property.components[i];
-
- var horizontalComponent = shallowClone(property);
- horizontalComponent.value = [component.value[0]];
- horizontal.components.push(horizontalComponent);
-
- var verticalComponent = shallowClone(property);
- // FIXME: only shorthand compactor (see breakup#borderRadius) knows that border radius
- // longhands have two values, whereas tokenizer does not care about populating 2nd value
- // if it's missing, hence this fallback
- verticalComponent.value = [component.value[1] || component.value[0]];
- vertical.components.push(verticalComponent);
- }
-
- var horizontalValues = fourValues(horizontal, compactable);
- var verticalValues = fourValues(vertical, compactable);
-
- if (horizontalValues.length == verticalValues.length &&
- horizontalValues[0][0] == verticalValues[0][0] &&
- (horizontalValues.length > 1 ? horizontalValues[1][0] == verticalValues[1][0] : true) &&
- (horizontalValues.length > 2 ? horizontalValues[2][0] == verticalValues[2][0] : true) &&
- (horizontalValues.length > 3 ? horizontalValues[3][0] == verticalValues[3][0] : true)) {
- return horizontalValues;
- } else {
- return horizontalValues.concat([['/']]).concat(verticalValues);
- }
- } else {
- return fourValues(property, compactable);
- }
-}
-
-function fourValues(property) {
- var components = property.components;
- var value1 = components[0].value[0];
- var value2 = components[1].value[0];
- var value3 = components[2].value[0];
- var value4 = components[3].value[0];
-
- if (value1[0] == value2[0] && value1[0] == value3[0] && value1[0] == value4[0]) {
- return [value1];
- } else if (value1[0] == value3[0] && value2[0] == value4[0]) {
- return [value1, value2];
- } else if (value2[0] == value4[0]) {
- return [value1, value2, value3];
- } else {
- return [value1, value2, value3, value4];
- }
-}
-
-function multiplex(restoreWith) {
- return function (property, compactable) {
- if (!property.multiplex)
- return restoreWith(property, compactable, true);
-
- var multiplexSize = 0;
- var restored = [];
- var componentMultiplexSoFar = {};
- var i, l;
-
- // At this point we don't know what's the multiplex size, e.g. how many background layers are there
- for (i = 0, l = property.components[0].value.length; i < l; i++) {
- if (property.components[0].value[i][0] == MULTIPLEX_SEPARATOR)
- multiplexSize++;
- }
-
- for (i = 0; i <= multiplexSize; i++) {
- var _property = shallowClone(property);
-
- // We split multiplex into parts and restore them one by one
- for (var j = 0, m = property.components.length; j < m; j++) {
- var componentToClone = property.components[j];
- var _component = shallowClone(componentToClone);
- _property.components.push(_component);
-
- // The trick is some properties has more than one value, so we iterate over values looking for
- // a multiplex separator - a comma
- for (var k = componentMultiplexSoFar[_component.name] || 0, n = componentToClone.value.length; k < n; k++) {
- if (componentToClone.value[k][0] == MULTIPLEX_SEPARATOR) {
- componentMultiplexSoFar[_component.name] = k + 1;
- break;
- }
-
- _component.value.push(componentToClone.value[k]);
- }
- }
-
- // No we can restore shorthand value
- var lastInMultiplex = i == multiplexSize;
- var _restored = restoreWith(_property, compactable, lastInMultiplex);
- Array.prototype.push.apply(restored, _restored);
-
- if (i < multiplexSize)
- restored.push([',']);
- }
-
- return restored;
- };
-}
-
-function withoutDefaults(property, compactable) {
- var components = property.components;
- var restored = [];
-
- for (var i = components.length - 1; i >= 0; i--) {
- var component = components[i];
- var descriptor = compactable[component.name];
-
- if (component.value[0][0] != descriptor.defaultValue)
- restored.unshift(component.value[0]);
- }
-
- if (restored.length === 0)
- restored.push([compactable[property.name].defaultValue]);
-
- if (isInheritOnly(restored))
- return [restored[0]];
-
- return restored;
-}
-
-module.exports = {
- background: background,
- borderRadius: borderRadius,
- fourValues: fourValues,
- multiplex: multiplex,
- withoutDefaults: withoutDefaults
-};
diff --git a/api/node_modules/clean-css/lib/properties/shorthand-compactor.js b/api/node_modules/clean-css/lib/properties/shorthand-compactor.js
deleted file mode 100644
index 9be76236a..000000000
--- a/api/node_modules/clean-css/lib/properties/shorthand-compactor.js
+++ /dev/null
@@ -1,134 +0,0 @@
-var compactable = require('./compactable');
-var deepClone = require('./clone').deep;
-var hasInherit = require('./has-inherit');
-var populateComponents = require('./populate-components');
-var wrapSingle = require('./wrap-for-optimizing').single;
-var everyCombination = require('./every-combination');
-
-function mixedImportance(components) {
- var important;
-
- for (var name in components) {
- if (undefined !== important && components[name].important != important)
- return true;
-
- important = components[name].important;
- }
-
- return false;
-}
-
-function componentSourceMaps(components) {
- var sourceMapping = [];
-
- for (var name in components) {
- var component = components[name];
- var originalValue = component.all[component.position];
- var mapping = originalValue[0][originalValue[0].length - 1];
-
- if (Array.isArray(mapping))
- Array.prototype.push.apply(sourceMapping, mapping);
- }
-
- return sourceMapping;
-}
-
-function replaceWithShorthand(properties, candidateComponents, name, sourceMaps, validator) {
- var descriptor = compactable[name];
- var newValuePlaceholder = [[name], [descriptor.defaultValue]];
- var all;
-
- var newProperty = wrapSingle(newValuePlaceholder);
- newProperty.shorthand = true;
- newProperty.dirty = true;
-
- populateComponents([newProperty], validator, []);
-
- for (var i = 0, l = descriptor.components.length; i < l; i++) {
- var component = candidateComponents[descriptor.components[i]];
- var canOverride = compactable[component.name].canOverride;
-
- if (hasInherit(component))
- return;
-
- if (!everyCombination(canOverride, newProperty.components[i], component, validator))
- return;
-
- newProperty.components[i] = deepClone(component);
- newProperty.important = component.important;
-
- all = component.all;
- }
-
- for (var componentName in candidateComponents) {
- candidateComponents[componentName].unused = true;
- }
-
- if (sourceMaps) {
- var sourceMapping = componentSourceMaps(candidateComponents);
- if (sourceMapping.length > 0)
- newValuePlaceholder[0].push(sourceMapping);
- }
-
- newProperty.position = all.length;
- newProperty.all = all;
- newProperty.all.push(newValuePlaceholder);
-
- properties.push(newProperty);
-}
-
-function invalidateOrCompact(properties, position, candidates, sourceMaps, validator) {
- var property = properties[position];
-
- for (var name in candidates) {
- if (undefined !== property && name == property.name)
- continue;
-
- var descriptor = compactable[name];
- var candidateComponents = candidates[name];
- if (descriptor.components.length > Object.keys(candidateComponents).length) {
- delete candidates[name];
- continue;
- }
-
- if (mixedImportance(candidateComponents))
- continue;
-
- replaceWithShorthand(properties, candidateComponents, name, sourceMaps, validator);
- }
-}
-
-function compactShortands(properties, sourceMaps, validator) {
- var candidates = {};
-
- if (properties.length < 3)
- return;
-
- for (var i = 0, l = properties.length; i < l; i++) {
- var property = properties[i];
- if (property.unused)
- continue;
-
- if (property.hack)
- continue;
-
- if (property.variable)
- continue;
-
- var descriptor = compactable[property.name];
- if (!descriptor || !descriptor.componentOf)
- continue;
-
- if (property.shorthand) {
- invalidateOrCompact(properties, i, candidates, sourceMaps, validator);
- } else {
- var componentOf = descriptor.componentOf;
- candidates[componentOf] = candidates[componentOf] || {};
- candidates[componentOf][property.name] = property;
- }
- }
-
- invalidateOrCompact(properties, i, candidates, sourceMaps, validator);
-}
-
-module.exports = compactShortands;
diff --git a/api/node_modules/clean-css/lib/properties/validator.js b/api/node_modules/clean-css/lib/properties/validator.js
deleted file mode 100644
index db4ee8925..000000000
--- a/api/node_modules/clean-css/lib/properties/validator.js
+++ /dev/null
@@ -1,197 +0,0 @@
-// Validates various CSS property values
-
-var split = require('../utils/split');
-
-var widthKeywords = ['thin', 'thick', 'medium', 'inherit', 'initial'];
-var allUnits = ['px', '%', 'em', 'in', 'cm', 'mm', 'ex', 'pt', 'pc', 'ch', 'rem', 'vh', 'vm', 'vmin', 'vmax', 'vw'];
-var cssUnitRegexStr = '(\\-?\\.?\\d+\\.?\\d*(' + allUnits.join('|') + '|)|auto|inherit)';
-var cssCalcRegexStr = '(\\-moz\\-|\\-webkit\\-)?calc\\([^\\)]+\\)';
-var cssFunctionNoVendorRegexStr = '[A-Z]+(\\-|[A-Z]|[0-9])+\\(.*?\\)';
-var cssFunctionVendorRegexStr = '\\-(\\-|[A-Z]|[0-9])+\\(.*?\\)';
-var cssVariableRegexStr = 'var\\(\\-\\-[^\\)]+\\)';
-var cssFunctionAnyRegexStr = '(' + cssVariableRegexStr + '|' + cssFunctionNoVendorRegexStr + '|' + cssFunctionVendorRegexStr + ')';
-var cssUnitOrCalcRegexStr = '(' + cssUnitRegexStr + '|' + cssCalcRegexStr + ')';
-var cssUnitAnyRegexStr = '(none|' + widthKeywords.join('|') + '|' + cssUnitRegexStr + '|' + cssVariableRegexStr + '|' + cssFunctionNoVendorRegexStr + '|' + cssFunctionVendorRegexStr + ')';
-
-var cssFunctionNoVendorRegex = new RegExp('^' + cssFunctionNoVendorRegexStr + '$', 'i');
-var cssFunctionVendorRegex = new RegExp('^' + cssFunctionVendorRegexStr + '$', 'i');
-var cssVariableRegex = new RegExp('^' + cssVariableRegexStr + '$', 'i');
-var cssFunctionAnyRegex = new RegExp('^' + cssFunctionAnyRegexStr + '$', 'i');
-var cssUnitRegex = new RegExp('^' + cssUnitRegexStr + '$', 'i');
-var cssUnitOrCalcRegex = new RegExp('^' + cssUnitOrCalcRegexStr + '$', 'i');
-var cssUnitAnyRegex = new RegExp('^' + cssUnitAnyRegexStr + '$', 'i');
-
-var backgroundRepeatKeywords = ['repeat', 'no-repeat', 'repeat-x', 'repeat-y', 'inherit'];
-var backgroundAttachmentKeywords = ['inherit', 'scroll', 'fixed', 'local'];
-var backgroundPositionKeywords = ['center', 'top', 'bottom', 'left', 'right'];
-var backgroundSizeKeywords = ['contain', 'cover'];
-var backgroundBoxKeywords = ['border-box', 'content-box', 'padding-box'];
-var styleKeywords = ['auto', 'inherit', 'hidden', 'none', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset'];
-var listStyleTypeKeywords = ['armenian', 'circle', 'cjk-ideographic', 'decimal', 'decimal-leading-zero', 'disc', 'georgian', 'hebrew', 'hiragana', 'hiragana-iroha', 'inherit', 'katakana', 'katakana-iroha', 'lower-alpha', 'lower-greek', 'lower-latin', 'lower-roman', 'none', 'square', 'upper-alpha', 'upper-latin', 'upper-roman'];
-var listStylePositionKeywords = ['inside', 'outside', 'inherit'];
-
-function Validator(compatibility) {
- var validUnits = allUnits.slice(0).filter(function (value) {
- return !(value in compatibility.units) || compatibility.units[value] === true;
- });
-
- var compatibleCssUnitRegexStr = '(\\-?\\.?\\d+\\.?\\d*(' + validUnits.join('|') + '|)|auto|inherit)';
- this.compatibleCssUnitRegex = new RegExp('^' + compatibleCssUnitRegexStr + '$', 'i');
- this.compatibleCssUnitAnyRegex = new RegExp('^(none|' + widthKeywords.join('|') + '|' + compatibleCssUnitRegexStr + '|' + cssVariableRegexStr + '|' + cssFunctionNoVendorRegexStr + '|' + cssFunctionVendorRegexStr + ')$', 'i');
-
- this.colorOpacity = compatibility.colors.opacity;
-}
-
-Validator.prototype.isValidHexColor = function (s) {
- return (s.length === 4 || s.length === 7) && s[0] === '#';
-};
-
-Validator.prototype.isValidRgbaColor = function (s) {
- s = s.split(' ').join('');
- return s.length > 0 && s.indexOf('rgba(') === 0 && s.indexOf(')') === s.length - 1;
-};
-
-Validator.prototype.isValidHslaColor = function (s) {
- s = s.split(' ').join('');
- return s.length > 0 && s.indexOf('hsla(') === 0 && s.indexOf(')') === s.length - 1;
-};
-
-Validator.prototype.isValidNamedColor = function (s) {
- // We don't really check if it's a valid color value, but allow any letters in it
- return s !== 'auto' && (s === 'transparent' || s === 'inherit' || /^[a-zA-Z]+$/.test(s));
-};
-
-Validator.prototype.isValidVariable = function (s) {
- return cssVariableRegex.test(s);
-};
-
-Validator.prototype.isValidColor = function (s) {
- return this.isValidNamedColor(s) ||
- this.isValidColorValue(s) ||
- this.isValidVariable(s) ||
- this.isValidVendorPrefixedValue(s);
-};
-
-Validator.prototype.isValidColorValue = function (s) {
- return this.isValidHexColor(s) ||
- this.isValidRgbaColor(s) ||
- this.isValidHslaColor(s);
-};
-
-Validator.prototype.isValidUrl = function (s) {
- // NOTE: at this point all URLs are replaced with placeholders by clean-css, so we check for those placeholders
- return s.indexOf('__ESCAPED_URL_CLEAN_CSS') === 0;
-};
-
-Validator.prototype.isValidUnit = function (s) {
- return cssUnitAnyRegex.test(s);
-};
-
-Validator.prototype.isValidUnitWithoutFunction = function (s) {
- return cssUnitRegex.test(s);
-};
-
-Validator.prototype.isValidAndCompatibleUnit = function (s) {
- return this.compatibleCssUnitAnyRegex.test(s);
-};
-
-Validator.prototype.isValidAndCompatibleUnitWithoutFunction = function (s) {
- return this.compatibleCssUnitRegex.test(s);
-};
-
-Validator.prototype.isValidFunctionWithoutVendorPrefix = function (s) {
- return cssFunctionNoVendorRegex.test(s);
-};
-
-Validator.prototype.isValidFunctionWithVendorPrefix = function (s) {
- return cssFunctionVendorRegex.test(s);
-};
-
-Validator.prototype.isValidFunction = function (s) {
- return cssFunctionAnyRegex.test(s);
-};
-
-Validator.prototype.isValidBackgroundRepeat = function (s) {
- return backgroundRepeatKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidBackgroundAttachment = function (s) {
- return backgroundAttachmentKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidBackgroundBox = function (s) {
- return backgroundBoxKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidBackgroundPositionPart = function (s) {
- return backgroundPositionKeywords.indexOf(s) >= 0 || cssUnitOrCalcRegex.test(s) || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidBackgroundPosition = function (s) {
- if (s === 'inherit')
- return true;
-
- var parts = s.split(' ');
- for (var i = 0, l = parts.length; i < l; i++) {
- if (parts[i] === '')
- continue;
- if (this.isValidBackgroundPositionPart(parts[i]) || this.isValidVariable(parts[i]))
- continue;
-
- return false;
- }
-
- return true;
-};
-
-Validator.prototype.isValidBackgroundSizePart = function (s) {
- return backgroundSizeKeywords.indexOf(s) >= 0 || cssUnitRegex.test(s) || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidBackgroundPositionAndSize = function (s) {
- if (s.indexOf('/') < 0)
- return false;
-
- var twoParts = split(s, '/');
- return this.isValidBackgroundSizePart(twoParts.pop()) && this.isValidBackgroundPositionPart(twoParts.pop());
-};
-
-Validator.prototype.isValidListStyleType = function (s) {
- return listStyleTypeKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidListStylePosition = function (s) {
- return listStylePositionKeywords.indexOf(s) >= 0 || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidStyle = function (s) {
- return this.isValidStyleKeyword(s) || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidStyleKeyword = function (s) {
- return styleKeywords.indexOf(s) >= 0;
-};
-
-Validator.prototype.isValidWidth = function (s) {
- return this.isValidUnit(s) || this.isValidWidthKeyword(s) || this.isValidVariable(s);
-};
-
-Validator.prototype.isValidWidthKeyword = function (s) {
- return widthKeywords.indexOf(s) >= 0;
-};
-
-Validator.prototype.isValidVendorPrefixedValue = function (s) {
- return /^-([A-Za-z0-9]|-)*$/gi.test(s);
-};
-
-Validator.prototype.areSameFunction = function (a, b) {
- if (!this.isValidFunction(a) || !this.isValidFunction(b))
- return false;
-
- var f1name = a.substring(0, a.indexOf('('));
- var f2name = b.substring(0, b.indexOf('('));
-
- return f1name === f2name;
-};
-
-module.exports = Validator;
diff --git a/api/node_modules/clean-css/lib/properties/vendor-prefixes.js b/api/node_modules/clean-css/lib/properties/vendor-prefixes.js
deleted file mode 100644
index 511fd604e..000000000
--- a/api/node_modules/clean-css/lib/properties/vendor-prefixes.js
+++ /dev/null
@@ -1,26 +0,0 @@
-var VENDOR_PREFIX_PATTERN = /$\-moz\-|\-ms\-|\-o\-|\-webkit\-/;
-
-function prefixesIn(tokens) {
- var prefixes = [];
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- for (var j = 0, m = token.value.length; j < m; j++) {
- var match = VENDOR_PREFIX_PATTERN.exec(token.value[j][0]);
-
- if (match && prefixes.indexOf(match[0]) == -1)
- prefixes.push(match[0]);
- }
- }
-
- return prefixes;
-}
-
-function same(left, right) {
- return prefixesIn(left).sort().join(',') == prefixesIn(right).sort().join(',');
-}
-
-module.exports = {
- same: same
-};
diff --git a/api/node_modules/clean-css/lib/properties/wrap-for-optimizing.js b/api/node_modules/clean-css/lib/properties/wrap-for-optimizing.js
deleted file mode 100644
index cb12a2b3d..000000000
--- a/api/node_modules/clean-css/lib/properties/wrap-for-optimizing.js
+++ /dev/null
@@ -1,118 +0,0 @@
-var BACKSLASH_HACK = '\\';
-var IMPORTANT_WORD = 'important';
-var IMPORTANT_TOKEN = '!'+IMPORTANT_WORD;
-var IMPORTANT_WORD_MATCH = new RegExp(IMPORTANT_WORD+'$', 'i');
-var IMPORTANT_TOKEN_MATCH = new RegExp(IMPORTANT_TOKEN+'$', 'i');
-var STAR_HACK = '*';
-var UNDERSCORE_HACK = '_';
-var BANG_HACK = '!';
-
-function wrapAll(properties) {
- var wrapped = [];
-
- for (var i = properties.length - 1; i >= 0; i--) {
- if (typeof properties[i][0] == 'string')
- continue;
-
- var single = wrapSingle(properties[i]);
- single.all = properties;
- single.position = i;
- wrapped.unshift(single);
- }
-
- return wrapped;
-}
-
-function isMultiplex(property) {
- for (var i = 1, l = property.length; i < l; i++) {
- if (property[i][0] == ',' || property[i][0] == '/')
- return true;
- }
-
- return false;
-}
-
-function hackType(property) {
- var type = false;
- var name = property[0][0];
- var lastValue = property[property.length - 1];
-
- if (name[0] == UNDERSCORE_HACK) {
- type = 'underscore';
- } else if (name[0] == STAR_HACK) {
- type = 'star';
- } else if (lastValue[0][0] == BANG_HACK && !lastValue[0].match(IMPORTANT_WORD_MATCH)) {
- type = 'bang';
- } else if (lastValue[0].indexOf(BANG_HACK) > 0 && !lastValue[0].match(IMPORTANT_WORD_MATCH)) {
- type = 'bang';
- } else if (lastValue[0].indexOf(BACKSLASH_HACK) > 0 && lastValue[0].indexOf(BACKSLASH_HACK) == lastValue[0].length - BACKSLASH_HACK.length - 1) {
- type = 'backslash';
- } else if (lastValue[0].indexOf(BACKSLASH_HACK) === 0 && lastValue[0].length == 2) {
- type = 'backslash';
- }
-
- return type;
-}
-
-function isImportant(property) {
- if (property.length > 1) {
- var p = property[property.length - 1][0];
- if (typeof(p) === 'string') {
- return IMPORTANT_TOKEN_MATCH.test(p);
- }
- }
- return false;
-}
-
-function stripImportant(property) {
- if (property.length > 0)
- property[property.length - 1][0] = property[property.length - 1][0].replace(IMPORTANT_TOKEN_MATCH, '');
-}
-
-function stripPrefixHack(property) {
- property[0][0] = property[0][0].substring(1);
-}
-
-function stripSuffixHack(property, hackType) {
- var lastValue = property[property.length - 1];
- lastValue[0] = lastValue[0]
- .substring(0, lastValue[0].indexOf(hackType == 'backslash' ? BACKSLASH_HACK : BANG_HACK))
- .trim();
-
- if (lastValue[0].length === 0)
- property.pop();
-}
-
-function wrapSingle(property) {
- var _isImportant = isImportant(property);
- if (_isImportant)
- stripImportant(property);
-
- var _hackType = hackType(property);
- if (_hackType == 'star' || _hackType == 'underscore')
- stripPrefixHack(property);
- else if (_hackType == 'backslash' || _hackType == 'bang')
- stripSuffixHack(property, _hackType);
-
- var isVariable = property[0][0].indexOf('--') === 0;
-
- return {
- block: isVariable && property[1] && Array.isArray(property[1][0][0]),
- components: [],
- dirty: false,
- hack: _hackType,
- important: _isImportant,
- name: property[0][0],
- multiplex: property.length > 2 ? isMultiplex(property) : false,
- position: 0,
- shorthand: false,
- unused: property.length < 2,
- value: property.slice(1),
- variable: isVariable
- };
-}
-
-module.exports = {
- all: wrapAll,
- single: wrapSingle
-};
diff --git a/api/node_modules/clean-css/lib/selectors/advanced.js b/api/node_modules/clean-css/lib/selectors/advanced.js
deleted file mode 100644
index 38630e6ae..000000000
--- a/api/node_modules/clean-css/lib/selectors/advanced.js
+++ /dev/null
@@ -1,86 +0,0 @@
-var optimizeProperties = require('../properties/optimizer');
-
-var removeDuplicates = require('./remove-duplicates');
-var mergeAdjacent = require('./merge-adjacent');
-var reduceNonAdjacent = require('./reduce-non-adjacent');
-var mergeNonAdjacentBySelector = require('./merge-non-adjacent-by-selector');
-var mergeNonAdjacentByBody = require('./merge-non-adjacent-by-body');
-var restructure = require('./restructure');
-var removeDuplicateMediaQueries = require('./remove-duplicate-media-queries');
-var mergeMediaQueries = require('./merge-media-queries');
-
-function removeEmpty(tokens) {
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
- var isEmpty = false;
-
- switch (token[0]) {
- case 'selector':
- isEmpty = token[1].length === 0 || token[2].length === 0;
- break;
- case 'block':
- removeEmpty(token[2]);
- isEmpty = token[2].length === 0;
- }
-
- if (isEmpty) {
- tokens.splice(i, 1);
- i--;
- l--;
- }
- }
-}
-
-function recursivelyOptimizeBlocks(tokens, options, context) {
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- if (token[0] == 'block') {
- var isKeyframes = /@(-moz-|-o-|-webkit-)?keyframes/.test(token[1][0]);
- optimize(token[2], options, context, !isKeyframes);
- }
- }
-}
-
-function recursivelyOptimizeProperties(tokens, options, context) {
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- switch (token[0]) {
- case 'selector':
- optimizeProperties(token[1], token[2], false, true, options, context);
- break;
- case 'block':
- recursivelyOptimizeProperties(token[2], options, context);
- }
- }
-}
-
-function optimize(tokens, options, context, withRestructuring) {
- recursivelyOptimizeBlocks(tokens, options, context);
- recursivelyOptimizeProperties(tokens, options, context);
-
- removeDuplicates(tokens);
- mergeAdjacent(tokens, options, context);
- reduceNonAdjacent(tokens, options, context);
-
- mergeNonAdjacentBySelector(tokens, options, context);
- mergeNonAdjacentByBody(tokens, options);
-
- if (options.restructuring && withRestructuring) {
- restructure(tokens, options);
- mergeAdjacent(tokens, options, context);
- }
-
- if (options.mediaMerging) {
- removeDuplicateMediaQueries(tokens);
- var reduced = mergeMediaQueries(tokens);
- for (var i = reduced.length - 1; i >= 0; i--) {
- optimize(reduced[i][2], options, context, false);
- }
- }
-
- removeEmpty(tokens);
-}
-
-module.exports = optimize;
diff --git a/api/node_modules/clean-css/lib/selectors/clean-up.js b/api/node_modules/clean-css/lib/selectors/clean-up.js
deleted file mode 100644
index 6bb17b99c..000000000
--- a/api/node_modules/clean-css/lib/selectors/clean-up.js
+++ /dev/null
@@ -1,89 +0,0 @@
-function removeWhitespace(match, value) {
- return '[' + value.replace(/ /g, '') + ']';
-}
-
-function selectorSorter(s1, s2) {
- return s1[0] > s2[0] ? 1 : -1;
-}
-
-function whitespaceReplacements(_, p1, p2, p3) {
- if (p1 && p2 && p3.length)
- return p1 + p2 + ' ';
- else if (p1 && p2)
- return p1 + p2;
- else
- return p2;
-}
-
-var CleanUp = {
- selectors: function (selectors, removeUnsupported, adjacentSpace) {
- var list = [];
- var repeated = [];
-
- for (var i = 0, l = selectors.length; i < l; i++) {
- var selector = selectors[i];
- var reduced = selector[0]
- .replace(/\s+/g, ' ')
- .replace(/ ?, ?/g, ',')
- .replace(/\s*(\\)?([>+~])(\s*)/g, whitespaceReplacements)
- .trim();
-
- if (adjacentSpace && reduced.indexOf('nav') > 0)
- reduced = reduced.replace(/\+nav(\S|$)/, '+ nav$1');
-
- if (removeUnsupported && (reduced.indexOf('*+html ') != -1 || reduced.indexOf('*:first-child+html ') != -1))
- continue;
-
- if (reduced.indexOf('*') > -1) {
- reduced = reduced
- .replace(/\*([:#\.\[])/g, '$1')
- .replace(/^(\:first\-child)?\+html/, '*$1+html');
- }
-
- if (reduced.indexOf('[') > -1)
- reduced = reduced.replace(/\[([^\]]+)\]/g, removeWhitespace);
-
- if (repeated.indexOf(reduced) == -1) {
- selector[0] = reduced;
- repeated.push(reduced);
- list.push(selector);
- }
- }
-
- return list.sort(selectorSorter);
- },
-
- selectorDuplicates: function (selectors) {
- var list = [];
- var repeated = [];
-
- for (var i = 0, l = selectors.length; i < l; i++) {
- var selector = selectors[i];
-
- if (repeated.indexOf(selector[0]) == -1) {
- repeated.push(selector[0]);
- list.push(selector);
- }
- }
-
- return list.sort(selectorSorter);
- },
-
- block: function (values, spaceAfterClosingBrace) {
- values[0] = values[0]
- .replace(/\s+/g, ' ')
- .replace(/(,|:|\() /g, '$1')
- .replace(/ \)/g, ')');
-
- if (!spaceAfterClosingBrace)
- values[0] = values[0].replace(/\) /g, ')');
- },
-
- atRule: function (values) {
- values[0] = values[0]
- .replace(/\s+/g, ' ')
- .trim();
- }
-};
-
-module.exports = CleanUp;
diff --git a/api/node_modules/clean-css/lib/selectors/extractor.js b/api/node_modules/clean-css/lib/selectors/extractor.js
deleted file mode 100644
index 497198b23..000000000
--- a/api/node_modules/clean-css/lib/selectors/extractor.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// This extractor is used in advanced optimizations
-// IMPORTANT: Mind Token class and this code is not related!
-// Properties will be tokenized in one step, see #429
-
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var stringifyValue = require('../stringifier/one-time').value;
-
-var AT_RULE = 'at-rule';
-
-function extract(token) {
- var properties = [];
-
- if (token[0] == 'selector') {
- var inSpecificSelector = !/[\.\+>~]/.test(stringifySelectors(token[1]));
- for (var i = 0, l = token[2].length; i < l; i++) {
- var property = token[2][i];
-
- if (property.indexOf('__ESCAPED') === 0)
- continue;
-
- if (property[0] == AT_RULE)
- continue;
-
- var name = token[2][i][0][0];
- if (name.length === 0)
- continue;
-
- if (name.indexOf('--') === 0)
- continue;
-
- var value = stringifyValue(token[2], i);
-
- properties.push([
- name,
- value,
- findNameRoot(name),
- token[2][i],
- name + ':' + value,
- token[1],
- inSpecificSelector
- ]);
- }
- } else if (token[0] == 'block') {
- for (var j = 0, k = token[2].length; j < k; j++) {
- properties = properties.concat(extract(token[2][j]));
- }
- }
-
- return properties;
-}
-
-function findNameRoot(name) {
- if (name == 'list-style')
- return name;
- if (name.indexOf('-radius') > 0)
- return 'border-radius';
- if (name == 'border-collapse' || name == 'border-spacing' || name == 'border-image')
- return name;
- if (name.indexOf('border-') === 0 && /^border\-\w+\-\w+$/.test(name))
- return name.match(/border\-\w+/)[0];
- if (name.indexOf('border-') === 0 && /^border\-\w+$/.test(name))
- return 'border';
- if (name.indexOf('text-') === 0)
- return name;
-
- return name.replace(/^\-\w+\-/, '').match(/([a-zA-Z]+)/)[0].toLowerCase();
-}
-
-module.exports = extract;
diff --git a/api/node_modules/clean-css/lib/selectors/is-special.js b/api/node_modules/clean-css/lib/selectors/is-special.js
deleted file mode 100644
index 963151415..000000000
--- a/api/node_modules/clean-css/lib/selectors/is-special.js
+++ /dev/null
@@ -1,5 +0,0 @@
-function isSpecial(options, selector) {
- return options.compatibility.selectors.special.test(selector);
-}
-
-module.exports = isSpecial;
diff --git a/api/node_modules/clean-css/lib/selectors/merge-adjacent.js b/api/node_modules/clean-css/lib/selectors/merge-adjacent.js
deleted file mode 100644
index 3de1c1fde..000000000
--- a/api/node_modules/clean-css/lib/selectors/merge-adjacent.js
+++ /dev/null
@@ -1,35 +0,0 @@
-var optimizeProperties = require('../properties/optimizer');
-
-var stringifyBody = require('../stringifier/one-time').body;
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var cleanUpSelectors = require('./clean-up').selectors;
-var isSpecial = require('./is-special');
-
-function mergeAdjacent(tokens, options, context) {
- var lastToken = [null, [], []];
- var adjacentSpace = options.compatibility.selectors.adjacentSpace;
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- if (token[0] != 'selector') {
- lastToken = [null, [], []];
- continue;
- }
-
- if (lastToken[0] == 'selector' && stringifySelectors(token[1]) == stringifySelectors(lastToken[1])) {
- var joinAt = [lastToken[2].length];
- Array.prototype.push.apply(lastToken[2], token[2]);
- optimizeProperties(token[1], lastToken[2], joinAt, true, options, context);
- token[2] = [];
- } else if (lastToken[0] == 'selector' && stringifyBody(token[2]) == stringifyBody(lastToken[2]) &&
- !isSpecial(options, stringifySelectors(token[1])) && !isSpecial(options, stringifySelectors(lastToken[1]))) {
- lastToken[1] = cleanUpSelectors(lastToken[1].concat(token[1]), false, adjacentSpace);
- token[2] = [];
- } else {
- lastToken = token;
- }
- }
-}
-
-module.exports = mergeAdjacent;
diff --git a/api/node_modules/clean-css/lib/selectors/merge-media-queries.js b/api/node_modules/clean-css/lib/selectors/merge-media-queries.js
deleted file mode 100644
index 0df0d6f57..000000000
--- a/api/node_modules/clean-css/lib/selectors/merge-media-queries.js
+++ /dev/null
@@ -1,64 +0,0 @@
-var canReorder = require('./reorderable').canReorder;
-var extractProperties = require('./extractor');
-
-function mergeMediaQueries(tokens) {
- var candidates = {};
- var reduced = [];
-
- for (var i = tokens.length - 1; i >= 0; i--) {
- var token = tokens[i];
- if (token[0] != 'block')
- continue;
-
- var candidate = candidates[token[1][0]];
- if (!candidate) {
- candidate = [];
- candidates[token[1][0]] = candidate;
- }
-
- candidate.push(i);
- }
-
- for (var name in candidates) {
- var positions = candidates[name];
-
- positionLoop:
- for (var j = positions.length - 1; j > 0; j--) {
- var positionOne = positions[j];
- var tokenOne = tokens[positionOne];
- var positionTwo = positions[j - 1];
- var tokenTwo = tokens[positionTwo];
-
- directionLoop:
- for (var direction = 1; direction >= -1; direction -= 2) {
- var topToBottom = direction == 1;
- var from = topToBottom ? positionOne + 1 : positionTwo - 1;
- var to = topToBottom ? positionTwo : positionOne;
- var delta = topToBottom ? 1 : -1;
- var source = topToBottom ? tokenOne : tokenTwo;
- var target = topToBottom ? tokenTwo : tokenOne;
- var movedProperties = extractProperties(source);
-
- while (from != to) {
- var traversedProperties = extractProperties(tokens[from]);
- from += delta;
-
- if (!canReorder(movedProperties, traversedProperties))
- continue directionLoop;
- }
-
- target[2] = topToBottom ?
- source[2].concat(target[2]) :
- target[2].concat(source[2]);
- source[2] = [];
-
- reduced.push(target);
- continue positionLoop;
- }
- }
- }
-
- return reduced;
-}
-
-module.exports = mergeMediaQueries;
diff --git a/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-body.js b/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-body.js
deleted file mode 100644
index de148a039..000000000
--- a/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-body.js
+++ /dev/null
@@ -1,61 +0,0 @@
-var stringifyBody = require('../stringifier/one-time').body;
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var cleanUpSelectors = require('./clean-up').selectors;
-var isSpecial = require('./is-special');
-
-function unsafeSelector(value) {
- return /\.|\*| :/.test(value);
-}
-
-function isBemElement(token) {
- var asString = stringifySelectors(token[1]);
- return asString.indexOf('__') > -1 || asString.indexOf('--') > -1;
-}
-
-function withoutModifier(selector) {
- return selector.replace(/--[^ ,>\+~:]+/g, '');
-}
-
-function removeAnyUnsafeElements(left, candidates) {
- var leftSelector = withoutModifier(stringifySelectors(left[1]));
-
- for (var body in candidates) {
- var right = candidates[body];
- var rightSelector = withoutModifier(stringifySelectors(right[1]));
-
- if (rightSelector.indexOf(leftSelector) > -1 || leftSelector.indexOf(rightSelector) > -1)
- delete candidates[body];
- }
-}
-
-function mergeNonAdjacentByBody(tokens, options) {
- var candidates = {};
- var adjacentSpace = options.compatibility.selectors.adjacentSpace;
-
- for (var i = tokens.length - 1; i >= 0; i--) {
- var token = tokens[i];
- if (token[0] != 'selector')
- continue;
-
- if (token[2].length > 0 && (!options.semanticMerging && unsafeSelector(stringifySelectors(token[1]))))
- candidates = {};
-
- if (token[2].length > 0 && options.semanticMerging && isBemElement(token))
- removeAnyUnsafeElements(token, candidates);
-
- var candidateBody = stringifyBody(token[2]);
- var oldToken = candidates[candidateBody];
- if (oldToken && !isSpecial(options, stringifySelectors(token[1])) && !isSpecial(options, stringifySelectors(oldToken[1]))) {
- token[1] = token[2].length > 0 ?
- cleanUpSelectors(oldToken[1].concat(token[1]), false, adjacentSpace) :
- oldToken[1].concat(token[1]);
-
- oldToken[2] = [];
- candidates[candidateBody] = null;
- }
-
- candidates[stringifyBody(token[2])] = token;
- }
-}
-
-module.exports = mergeNonAdjacentByBody;
diff --git a/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-selector.js b/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-selector.js
deleted file mode 100644
index bd1c1b9c9..000000000
--- a/api/node_modules/clean-css/lib/selectors/merge-non-adjacent-by-selector.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var optimizeProperties = require('../properties/optimizer');
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var extractProperties = require('./extractor');
-var canReorder = require('./reorderable').canReorder;
-
-function mergeNonAdjacentBySelector(tokens, options, context) {
- var allSelectors = {};
- var repeatedSelectors = [];
- var i;
-
- for (i = tokens.length - 1; i >= 0; i--) {
- if (tokens[i][0] != 'selector')
- continue;
- if (tokens[i][2].length === 0)
- continue;
-
- var selector = stringifySelectors(tokens[i][1]);
- allSelectors[selector] = [i].concat(allSelectors[selector] || []);
-
- if (allSelectors[selector].length == 2)
- repeatedSelectors.push(selector);
- }
-
- for (i = repeatedSelectors.length - 1; i >= 0; i--) {
- var positions = allSelectors[repeatedSelectors[i]];
-
- selectorIterator:
- for (var j = positions.length - 1; j > 0; j--) {
- var positionOne = positions[j - 1];
- var tokenOne = tokens[positionOne];
- var positionTwo = positions[j];
- var tokenTwo = tokens[positionTwo];
-
- directionIterator:
- for (var direction = 1; direction >= -1; direction -= 2) {
- var topToBottom = direction == 1;
- var from = topToBottom ? positionOne + 1 : positionTwo - 1;
- var to = topToBottom ? positionTwo : positionOne;
- var delta = topToBottom ? 1 : -1;
- var moved = topToBottom ? tokenOne : tokenTwo;
- var target = topToBottom ? tokenTwo : tokenOne;
- var movedProperties = extractProperties(moved);
- var joinAt;
-
- while (from != to) {
- var traversedProperties = extractProperties(tokens[from]);
- from += delta;
-
- // traversed then moved as we move selectors towards the start
- var reorderable = topToBottom ?
- canReorder(movedProperties, traversedProperties) :
- canReorder(traversedProperties, movedProperties);
-
- if (!reorderable && !topToBottom)
- continue selectorIterator;
- if (!reorderable && topToBottom)
- continue directionIterator;
- }
-
- if (topToBottom) {
- joinAt = [moved[2].length];
- Array.prototype.push.apply(moved[2], target[2]);
- target[2] = moved[2];
- } else {
- joinAt = [target[2].length];
- Array.prototype.push.apply(target[2], moved[2]);
- }
-
- optimizeProperties(target[1], target[2], joinAt, true, options, context);
- moved[2] = [];
- }
- }
- }
-}
-
-module.exports = mergeNonAdjacentBySelector;
diff --git a/api/node_modules/clean-css/lib/selectors/reduce-non-adjacent.js b/api/node_modules/clean-css/lib/selectors/reduce-non-adjacent.js
deleted file mode 100644
index 44b540c03..000000000
--- a/api/node_modules/clean-css/lib/selectors/reduce-non-adjacent.js
+++ /dev/null
@@ -1,172 +0,0 @@
-var optimizeProperties = require('../properties/optimizer');
-var stringifyBody = require('../stringifier/one-time').body;
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var isSpecial = require('./is-special');
-var cloneArray = require('../utils/clone-array');
-
-function reduceNonAdjacent(tokens, options, context) {
- var candidates = {};
- var repeated = [];
-
- for (var i = tokens.length - 1; i >= 0; i--) {
- var token = tokens[i];
-
- if (token[0] != 'selector')
- continue;
- if (token[2].length === 0)
- continue;
-
- var selectorAsString = stringifySelectors(token[1]);
- var isComplexAndNotSpecial = token[1].length > 1 && !isSpecial(options, selectorAsString);
- var wrappedSelectors = options.sourceMap ? wrappedSelectorsFrom(token[1]) : token[1];
- var selectors = isComplexAndNotSpecial ?
- [selectorAsString].concat(wrappedSelectors) :
- [selectorAsString];
-
- for (var j = 0, m = selectors.length; j < m; j++) {
- var selector = selectors[j];
-
- if (!candidates[selector])
- candidates[selector] = [];
- else
- repeated.push(selector);
-
- candidates[selector].push({
- where: i,
- list: wrappedSelectors,
- isPartial: isComplexAndNotSpecial && j > 0,
- isComplex: isComplexAndNotSpecial && j === 0
- });
- }
- }
-
- reduceSimpleNonAdjacentCases(tokens, repeated, candidates, options, context);
- reduceComplexNonAdjacentCases(tokens, candidates, options, context);
-}
-
-function wrappedSelectorsFrom(list) {
- var wrapped = [];
-
- for (var i = 0; i < list.length; i++) {
- wrapped.push([list[i][0]]);
- }
-
- return wrapped;
-}
-
-function reduceSimpleNonAdjacentCases(tokens, repeated, candidates, options, context) {
- function filterOut(idx, bodies) {
- return data[idx].isPartial && bodies.length === 0;
- }
-
- function reduceBody(token, newBody, processedCount, tokenIdx) {
- if (!data[processedCount - tokenIdx - 1].isPartial)
- token[2] = newBody;
- }
-
- for (var i = 0, l = repeated.length; i < l; i++) {
- var selector = repeated[i];
- var data = candidates[selector];
-
- reduceSelector(tokens, selector, data, {
- filterOut: filterOut,
- callback: reduceBody
- }, options, context);
- }
-}
-
-function reduceComplexNonAdjacentCases(tokens, candidates, options, context) {
- var localContext = {};
-
- function filterOut(idx) {
- return localContext.data[idx].where < localContext.intoPosition;
- }
-
- function collectReducedBodies(token, newBody, processedCount, tokenIdx) {
- if (tokenIdx === 0)
- localContext.reducedBodies.push(newBody);
- }
-
- allSelectors:
- for (var complexSelector in candidates) {
- var into = candidates[complexSelector];
- if (!into[0].isComplex)
- continue;
-
- var intoPosition = into[into.length - 1].where;
- var intoToken = tokens[intoPosition];
- var reducedBodies = [];
-
- var selectors = isSpecial(options, complexSelector) ?
- [complexSelector] :
- into[0].list;
-
- localContext.intoPosition = intoPosition;
- localContext.reducedBodies = reducedBodies;
-
- for (var j = 0, m = selectors.length; j < m; j++) {
- var selector = selectors[j];
- var data = candidates[selector];
-
- if (data.length < 2)
- continue allSelectors;
-
- localContext.data = data;
-
- reduceSelector(tokens, selector, data, {
- filterOut: filterOut,
- callback: collectReducedBodies
- }, options, context);
-
- if (stringifyBody(reducedBodies[reducedBodies.length - 1]) != stringifyBody(reducedBodies[0]))
- continue allSelectors;
- }
-
- intoToken[2] = reducedBodies[0];
- }
-}
-
-function reduceSelector(tokens, selector, data, context, options, outerContext) {
- var bodies = [];
- var bodiesAsList = [];
- var joinsAt = [];
- var processedTokens = [];
-
- for (var j = data.length - 1, m = 0; j >= 0; j--) {
- if (context.filterOut(j, bodies))
- continue;
-
- var where = data[j].where;
- var token = tokens[where];
- var clonedBody = cloneArray(token[2]);
-
- bodies = bodies.concat(clonedBody);
- bodiesAsList.push(clonedBody);
- processedTokens.push(where);
- }
-
- for (j = 0, m = bodiesAsList.length; j < m; j++) {
- if (bodiesAsList[j].length > 0)
- joinsAt.push((joinsAt.length > 0 ? joinsAt[joinsAt.length - 1] : 0) + bodiesAsList[j].length);
- }
-
- optimizeProperties(selector, bodies, joinsAt, false, options, outerContext);
-
- var processedCount = processedTokens.length;
- var propertyIdx = bodies.length - 1;
- var tokenIdx = processedCount - 1;
-
- while (tokenIdx >= 0) {
- if ((tokenIdx === 0 || (bodies[propertyIdx] && bodiesAsList[tokenIdx].indexOf(bodies[propertyIdx]) > -1)) && propertyIdx > -1) {
- propertyIdx--;
- continue;
- }
-
- var newBody = bodies.splice(propertyIdx + 1);
- context.callback(tokens[processedTokens[tokenIdx]], newBody, processedCount, tokenIdx);
-
- tokenIdx--;
- }
-}
-
-module.exports = reduceNonAdjacent;
diff --git a/api/node_modules/clean-css/lib/selectors/remove-duplicate-media-queries.js b/api/node_modules/clean-css/lib/selectors/remove-duplicate-media-queries.js
deleted file mode 100644
index 44070b0f7..000000000
--- a/api/node_modules/clean-css/lib/selectors/remove-duplicate-media-queries.js
+++ /dev/null
@@ -1,21 +0,0 @@
-var stringifyAll = require('../stringifier/one-time').all;
-
-function removeDuplicateMediaQueries(tokens) {
- var candidates = {};
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
- if (token[0] != 'block')
- continue;
-
- var key = token[1][0] + '%' + stringifyAll(token[2]);
- var candidate = candidates[key];
-
- if (candidate)
- candidate[2] = [];
-
- candidates[key] = token;
- }
-}
-
-module.exports = removeDuplicateMediaQueries;
diff --git a/api/node_modules/clean-css/lib/selectors/remove-duplicates.js b/api/node_modules/clean-css/lib/selectors/remove-duplicates.js
deleted file mode 100644
index 3a2ce959a..000000000
--- a/api/node_modules/clean-css/lib/selectors/remove-duplicates.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var stringifyBody = require('../stringifier/one-time').body;
-var stringifySelectors = require('../stringifier/one-time').selectors;
-
-function removeDuplicates(tokens) {
- var matched = {};
- var moreThanOnce = [];
- var id, token;
- var body, bodies;
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- token = tokens[i];
- if (token[0] != 'selector')
- continue;
-
- id = stringifySelectors(token[1]);
-
- if (matched[id] && matched[id].length == 1)
- moreThanOnce.push(id);
- else
- matched[id] = matched[id] || [];
-
- matched[id].push(i);
- }
-
- for (i = 0, l = moreThanOnce.length; i < l; i++) {
- id = moreThanOnce[i];
- bodies = [];
-
- for (var j = matched[id].length - 1; j >= 0; j--) {
- token = tokens[matched[id][j]];
- body = stringifyBody(token[2]);
-
- if (bodies.indexOf(body) > -1)
- token[2] = [];
- else
- bodies.push(body);
- }
- }
-}
-
-module.exports = removeDuplicates;
diff --git a/api/node_modules/clean-css/lib/selectors/reorderable.js b/api/node_modules/clean-css/lib/selectors/reorderable.js
deleted file mode 100644
index 3c49a3b49..000000000
--- a/api/node_modules/clean-css/lib/selectors/reorderable.js
+++ /dev/null
@@ -1,99 +0,0 @@
-// TODO: it'd be great to merge it with the other canReorder functionality
-
-var FLEX_PROPERTIES = /align\-items|box\-align|box\-pack|flex|justify/;
-var BORDER_PROPERTIES = /^border\-(top|right|bottom|left|color|style|width|radius)/;
-
-function canReorder(left, right) {
- for (var i = right.length - 1; i >= 0; i--) {
- for (var j = left.length - 1; j >= 0; j--) {
- if (!canReorderSingle(left[j], right[i]))
- return false;
- }
- }
-
- return true;
-}
-
-function canReorderSingle(left, right) {
- var leftName = left[0];
- var leftValue = left[1];
- var leftNameRoot = left[2];
- var leftSelector = left[5];
- var leftInSpecificSelector = left[6];
- var rightName = right[0];
- var rightValue = right[1];
- var rightNameRoot = right[2];
- var rightSelector = right[5];
- var rightInSpecificSelector = right[6];
-
- if (leftName == 'font' && rightName == 'line-height' || rightName == 'font' && leftName == 'line-height')
- return false;
- if (FLEX_PROPERTIES.test(leftName) && FLEX_PROPERTIES.test(rightName))
- return false;
- if (leftNameRoot == rightNameRoot && unprefixed(leftName) == unprefixed(rightName) && (vendorPrefixed(leftName) ^ vendorPrefixed(rightName)))
- return false;
- if (leftNameRoot == 'border' && BORDER_PROPERTIES.test(rightNameRoot) && (leftName == 'border' || leftName == rightNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName))))
- return false;
- if (rightNameRoot == 'border' && BORDER_PROPERTIES.test(leftNameRoot) && (rightName == 'border' || rightName == leftNameRoot || (leftValue != rightValue && sameBorderComponent(leftName, rightName))))
- return false;
- if (leftNameRoot == 'border' && rightNameRoot == 'border' && leftName != rightName && (isSideBorder(leftName) && isStyleBorder(rightName) || isStyleBorder(leftName) && isSideBorder(rightName)))
- return false;
- if (leftNameRoot != rightNameRoot)
- return true;
- if (leftName == rightName && leftNameRoot == rightNameRoot && (leftValue == rightValue || withDifferentVendorPrefix(leftValue, rightValue)))
- return true;
- if (leftName != rightName && leftNameRoot == rightNameRoot && leftName != leftNameRoot && rightName != rightNameRoot)
- return true;
- if (leftName != rightName && leftNameRoot == rightNameRoot && leftValue == rightValue)
- return true;
- if (rightInSpecificSelector && leftInSpecificSelector && !inheritable(leftNameRoot) && !inheritable(rightNameRoot) && selectorsDoNotOverlap(rightSelector, leftSelector))
- return true;
-
- return false;
-}
-
-function vendorPrefixed(name) {
- return /^\-(?:moz|webkit|ms|o)\-/.test(name);
-}
-
-function unprefixed(name) {
- return name.replace(/^\-(?:moz|webkit|ms|o)\-/, '');
-}
-
-function sameBorderComponent(name1, name2) {
- return name1.split('-').pop() == name2.split('-').pop();
-}
-
-function isSideBorder(name) {
- return name == 'border-top' || name == 'border-right' || name == 'border-bottom' || name == 'border-left';
-}
-
-function isStyleBorder(name) {
- return name == 'border-color' || name == 'border-style' || name == 'border-width';
-}
-
-function withDifferentVendorPrefix(value1, value2) {
- return vendorPrefixed(value1) && vendorPrefixed(value2) && value1.split('-')[1] != value2.split('-')[2];
-}
-
-function selectorsDoNotOverlap(s1, s2) {
- for (var i = 0, l = s1.length; i < l; i++) {
- for (var j = 0, m = s2.length; j < m; j++) {
- if (s1[i][0] == s2[j][0])
- return false;
- }
- }
-
- return true;
-}
-
-function inheritable(name) {
- // According to http://www.w3.org/TR/CSS21/propidx.html
- // Others will be catched by other, preceeding rules
- return name == 'font' || name == 'line-height' || name == 'list-style';
-}
-
-module.exports = {
- canReorder: canReorder,
- canReorderSingle: canReorderSingle
-};
diff --git a/api/node_modules/clean-css/lib/selectors/restructure.js b/api/node_modules/clean-css/lib/selectors/restructure.js
deleted file mode 100644
index c3e17f121..000000000
--- a/api/node_modules/clean-css/lib/selectors/restructure.js
+++ /dev/null
@@ -1,369 +0,0 @@
-var extractProperties = require('./extractor');
-var canReorderSingle = require('./reorderable').canReorderSingle;
-var stringifyBody = require('../stringifier/one-time').body;
-var stringifySelectors = require('../stringifier/one-time').selectors;
-var cleanUpSelectorDuplicates = require('./clean-up').selectorDuplicates;
-var isSpecial = require('./is-special');
-var cloneArray = require('../utils/clone-array');
-
-function naturalSorter(a, b) {
- return a > b;
-}
-
-function cloneAndMergeSelectors(propertyA, propertyB) {
- var cloned = cloneArray(propertyA);
- cloned[5] = cloned[5].concat(propertyB[5]);
-
- return cloned;
-}
-
-function restructure(tokens, options) {
- var movableTokens = {};
- var movedProperties = [];
- var multiPropertyMoveCache = {};
- var movedToBeDropped = [];
- var maxCombinationsLevel = 2;
- var ID_JOIN_CHARACTER = '%';
-
- function sendToMultiPropertyMoveCache(position, movedProperty, allFits) {
- for (var i = allFits.length - 1; i >= 0; i--) {
- var fit = allFits[i][0];
- var id = addToCache(movedProperty, fit);
-
- if (multiPropertyMoveCache[id].length > 1 && processMultiPropertyMove(position, multiPropertyMoveCache[id])) {
- removeAllMatchingFromCache(id);
- break;
- }
- }
- }
-
- function addToCache(movedProperty, fit) {
- var id = cacheId(fit);
- multiPropertyMoveCache[id] = multiPropertyMoveCache[id] || [];
- multiPropertyMoveCache[id].push([movedProperty, fit]);
- return id;
- }
-
- function removeAllMatchingFromCache(matchId) {
- var matchSelectors = matchId.split(ID_JOIN_CHARACTER);
- var forRemoval = [];
- var i;
-
- for (var id in multiPropertyMoveCache) {
- var selectors = id.split(ID_JOIN_CHARACTER);
- for (i = selectors.length - 1; i >= 0; i--) {
- if (matchSelectors.indexOf(selectors[i]) > -1) {
- forRemoval.push(id);
- break;
- }
- }
- }
-
- for (i = forRemoval.length - 1; i >= 0; i--) {
- delete multiPropertyMoveCache[forRemoval[i]];
- }
- }
-
- function cacheId(cachedTokens) {
- var id = [];
- for (var i = 0, l = cachedTokens.length; i < l; i++) {
- id.push(stringifySelectors(cachedTokens[i][1]));
- }
- return id.join(ID_JOIN_CHARACTER);
- }
-
- function tokensToMerge(sourceTokens) {
- var uniqueTokensWithBody = [];
- var mergeableTokens = [];
-
- for (var i = sourceTokens.length - 1; i >= 0; i--) {
- if (isSpecial(options, stringifySelectors(sourceTokens[i][1])))
- continue;
-
- mergeableTokens.unshift(sourceTokens[i]);
- if (sourceTokens[i][2].length > 0 && uniqueTokensWithBody.indexOf(sourceTokens[i]) == -1)
- uniqueTokensWithBody.push(sourceTokens[i]);
- }
-
- return uniqueTokensWithBody.length > 1 ?
- mergeableTokens :
- [];
- }
-
- function shortenIfPossible(position, movedProperty) {
- var name = movedProperty[0];
- var value = movedProperty[1];
- var key = movedProperty[4];
- var valueSize = name.length + value.length + 1;
- var allSelectors = [];
- var qualifiedTokens = [];
-
- var mergeableTokens = tokensToMerge(movableTokens[key]);
- if (mergeableTokens.length < 2)
- return;
-
- var allFits = findAllFits(mergeableTokens, valueSize, 1);
- var bestFit = allFits[0];
- if (bestFit[1] > 0)
- return sendToMultiPropertyMoveCache(position, movedProperty, allFits);
-
- for (var i = bestFit[0].length - 1; i >=0; i--) {
- allSelectors = bestFit[0][i][1].concat(allSelectors);
- qualifiedTokens.unshift(bestFit[0][i]);
- }
-
- allSelectors = cleanUpSelectorDuplicates(allSelectors);
- dropAsNewTokenAt(position, [movedProperty], allSelectors, qualifiedTokens);
- }
-
- function fitSorter(fit1, fit2) {
- return fit1[1] > fit2[1];
- }
-
- function findAllFits(mergeableTokens, propertySize, propertiesCount) {
- var combinations = allCombinations(mergeableTokens, propertySize, propertiesCount, maxCombinationsLevel - 1);
- return combinations.sort(fitSorter);
- }
-
- function allCombinations(tokensVariant, propertySize, propertiesCount, level) {
- var differenceVariants = [[tokensVariant, sizeDifference(tokensVariant, propertySize, propertiesCount)]];
- if (tokensVariant.length > 2 && level > 0) {
- for (var i = tokensVariant.length - 1; i >= 0; i--) {
- var subVariant = Array.prototype.slice.call(tokensVariant, 0);
- subVariant.splice(i, 1);
- differenceVariants = differenceVariants.concat(allCombinations(subVariant, propertySize, propertiesCount, level - 1));
- }
- }
-
- return differenceVariants;
- }
-
- function sizeDifference(tokensVariant, propertySize, propertiesCount) {
- var allSelectorsSize = 0;
- for (var i = tokensVariant.length - 1; i >= 0; i--) {
- allSelectorsSize += tokensVariant[i][2].length > propertiesCount ? stringifySelectors(tokensVariant[i][1]).length : -1;
- }
- return allSelectorsSize - (tokensVariant.length - 1) * propertySize + 1;
- }
-
- function dropAsNewTokenAt(position, properties, allSelectors, mergeableTokens) {
- var i, j, k, m;
- var allProperties = [];
-
- for (i = mergeableTokens.length - 1; i >= 0; i--) {
- var mergeableToken = mergeableTokens[i];
-
- for (j = mergeableToken[2].length - 1; j >= 0; j--) {
- var mergeableProperty = mergeableToken[2][j];
-
- for (k = 0, m = properties.length; k < m; k++) {
- var property = properties[k];
-
- var mergeablePropertyName = mergeableProperty[0][0];
- var propertyName = property[0];
- var propertyBody = property[4];
- if (mergeablePropertyName == propertyName && stringifyBody([mergeableProperty]) == propertyBody) {
- mergeableToken[2].splice(j, 1);
- break;
- }
- }
- }
- }
-
- for (i = properties.length - 1; i >= 0; i--) {
- allProperties.unshift(properties[i][3]);
- }
-
- var newToken = ['selector', allSelectors, allProperties];
- tokens.splice(position, 0, newToken);
- }
-
- function dropPropertiesAt(position, movedProperty) {
- var key = movedProperty[4];
- var toMove = movableTokens[key];
-
- if (toMove && toMove.length > 1) {
- if (!shortenMultiMovesIfPossible(position, movedProperty))
- shortenIfPossible(position, movedProperty);
- }
- }
-
- function shortenMultiMovesIfPossible(position, movedProperty) {
- var candidates = [];
- var propertiesAndMergableTokens = [];
- var key = movedProperty[4];
- var j, k;
-
- var mergeableTokens = tokensToMerge(movableTokens[key]);
- if (mergeableTokens.length < 2)
- return;
-
- movableLoop:
- for (var value in movableTokens) {
- var tokensList = movableTokens[value];
-
- for (j = mergeableTokens.length - 1; j >= 0; j--) {
- if (tokensList.indexOf(mergeableTokens[j]) == -1)
- continue movableLoop;
- }
-
- candidates.push(value);
- }
-
- if (candidates.length < 2)
- return false;
-
- for (j = candidates.length - 1; j >= 0; j--) {
- for (k = movedProperties.length - 1; k >= 0; k--) {
- if (movedProperties[k][4] == candidates[j]) {
- propertiesAndMergableTokens.unshift([movedProperties[k], mergeableTokens]);
- break;
- }
- }
- }
-
- return processMultiPropertyMove(position, propertiesAndMergableTokens);
- }
-
- function processMultiPropertyMove(position, propertiesAndMergableTokens) {
- var valueSize = 0;
- var properties = [];
- var property;
-
- for (var i = propertiesAndMergableTokens.length - 1; i >= 0; i--) {
- property = propertiesAndMergableTokens[i][0];
- var fullValue = property[4];
- valueSize += fullValue.length + (i > 0 ? 1 : 0);
-
- properties.push(property);
- }
-
- var mergeableTokens = propertiesAndMergableTokens[0][1];
- var bestFit = findAllFits(mergeableTokens, valueSize, properties.length)[0];
- if (bestFit[1] > 0)
- return false;
-
- var allSelectors = [];
- var qualifiedTokens = [];
- for (i = bestFit[0].length - 1; i >= 0; i--) {
- allSelectors = bestFit[0][i][1].concat(allSelectors);
- qualifiedTokens.unshift(bestFit[0][i]);
- }
-
- allSelectors = cleanUpSelectorDuplicates(allSelectors);
- dropAsNewTokenAt(position, properties, allSelectors, qualifiedTokens);
-
- for (i = properties.length - 1; i >= 0; i--) {
- property = properties[i];
- var index = movedProperties.indexOf(property);
-
- delete movableTokens[property[4]];
-
- if (index > -1 && movedToBeDropped.indexOf(index) == -1)
- movedToBeDropped.push(index);
- }
-
- return true;
- }
-
- function boundToAnotherPropertyInCurrrentToken(property, movedProperty, token) {
- var propertyName = property[0];
- var movedPropertyName = movedProperty[0];
- if (propertyName != movedPropertyName)
- return false;
-
- var key = movedProperty[4];
- var toMove = movableTokens[key];
- return toMove && toMove.indexOf(token) > -1;
- }
-
- for (var i = tokens.length - 1; i >= 0; i--) {
- var token = tokens[i];
- var isSelector;
- var j, k, m;
- var samePropertyAt;
-
- if (token[0] == 'selector') {
- isSelector = true;
- } else if (token[0] == 'block') {
- isSelector = false;
- } else {
- continue;
- }
-
- // We cache movedProperties.length as it may change in the loop
- var movedCount = movedProperties.length;
-
- var properties = extractProperties(token);
- movedToBeDropped = [];
-
- var unmovableInCurrentToken = [];
- for (j = properties.length - 1; j >= 0; j--) {
- for (k = j - 1; k >= 0; k--) {
- if (!canReorderSingle(properties[j], properties[k])) {
- unmovableInCurrentToken.push(j);
- break;
- }
- }
- }
-
- for (j = properties.length - 1; j >= 0; j--) {
- var property = properties[j];
- var movedSameProperty = false;
-
- for (k = 0; k < movedCount; k++) {
- var movedProperty = movedProperties[k];
-
- if (movedToBeDropped.indexOf(k) == -1 && !canReorderSingle(property, movedProperty) && !boundToAnotherPropertyInCurrrentToken(property, movedProperty, token)) {
- dropPropertiesAt(i + 1, movedProperty, token);
-
- if (movedToBeDropped.indexOf(k) == -1) {
- movedToBeDropped.push(k);
- delete movableTokens[movedProperty[4]];
- }
- }
-
- if (!movedSameProperty) {
- movedSameProperty = property[0] == movedProperty[0] && property[1] == movedProperty[1];
-
- if (movedSameProperty) {
- samePropertyAt = k;
- }
- }
- }
-
- if (!isSelector || unmovableInCurrentToken.indexOf(j) > -1)
- continue;
-
- var key = property[4];
- movableTokens[key] = movableTokens[key] || [];
- movableTokens[key].push(token);
-
- if (movedSameProperty) {
- movedProperties[samePropertyAt] = cloneAndMergeSelectors(movedProperties[samePropertyAt], property);
- } else {
- movedProperties.push(property);
- }
- }
-
- movedToBeDropped = movedToBeDropped.sort(naturalSorter);
- for (j = 0, m = movedToBeDropped.length; j < m; j++) {
- var dropAt = movedToBeDropped[j] - j;
- movedProperties.splice(dropAt, 1);
- }
- }
-
- var position = tokens[0] && tokens[0][0] == 'at-rule' && tokens[0][1][0].indexOf('@charset') === 0 ? 1 : 0;
- for (; position < tokens.length - 1; position++) {
- var isImportRule = tokens[position][0] === 'at-rule' && tokens[position][1][0].indexOf('@import') === 0;
- var isEscapedCommentSpecial = tokens[position][0] === 'text' && tokens[position][1][0].indexOf('__ESCAPED_COMMENT_SPECIAL') === 0;
- if (!(isImportRule || isEscapedCommentSpecial))
- break;
- }
-
- for (i = 0; i < movedProperties.length; i++) {
- dropPropertiesAt(position, movedProperties[i]);
- }
-}
-
-module.exports = restructure;
diff --git a/api/node_modules/clean-css/lib/selectors/simple.js b/api/node_modules/clean-css/lib/selectors/simple.js
deleted file mode 100644
index 3bf29ca30..000000000
--- a/api/node_modules/clean-css/lib/selectors/simple.js
+++ /dev/null
@@ -1,454 +0,0 @@
-var cleanUpSelectors = require('./clean-up').selectors;
-var cleanUpBlock = require('./clean-up').block;
-var cleanUpAtRule = require('./clean-up').atRule;
-var split = require('../utils/split');
-
-var RGB = require('../colors/rgb');
-var HSL = require('../colors/hsl');
-var HexNameShortener = require('../colors/hex-name-shortener');
-
-var wrapForOptimizing = require('../properties/wrap-for-optimizing').all;
-var restoreFromOptimizing = require('../properties/restore-from-optimizing');
-var removeUnused = require('../properties/remove-unused');
-
-var DEFAULT_ROUNDING_PRECISION = 2;
-var CHARSET_TOKEN = '@charset';
-var CHARSET_REGEXP = new RegExp('^' + CHARSET_TOKEN, 'i');
-var IMPORT_REGEXP = /^@import["'\s]/i;
-
-var FONT_NUMERAL_WEIGHTS = ['100', '200', '300', '400', '500', '600', '700', '800', '900'];
-var FONT_NAME_WEIGHTS = ['normal', 'bold', 'bolder', 'lighter'];
-var FONT_NAME_WEIGHTS_WITHOUT_NORMAL = ['bold', 'bolder', 'lighter'];
-
-var WHOLE_PIXEL_VALUE = /(?:^|\s|\()(-?\d+)px/;
-var TIME_VALUE = /^(\-?[\d\.]+)(m?s)$/;
-
-var valueMinifiers = {
- 'background': function (value, index, total) {
- return index === 0 && total == 1 && (value == 'none' || value == 'transparent') ? '0 0' : value;
- },
- 'font-weight': function (value) {
- if (value == 'normal')
- return '400';
- else if (value == 'bold')
- return '700';
- else
- return value;
- },
- 'outline': function (value, index, total) {
- return index === 0 && total == 1 && value == 'none' ? '0' : value;
- }
-};
-
-function isNegative(property, idx) {
- return property.value[idx] && property.value[idx][0][0] == '-' && parseFloat(property.value[idx][0]) < 0;
-}
-
-function zeroMinifier(name, value) {
- if (value.indexOf('0') == -1)
- return value;
-
- if (value.indexOf('-') > -1) {
- value = value
- .replace(/([^\w\d\-]|^)\-0([^\.]|$)/g, '$10$2')
- .replace(/([^\w\d\-]|^)\-0([^\.]|$)/g, '$10$2');
- }
-
- return value
- .replace(/(^|\s)0+([1-9])/g, '$1$2')
- .replace(/(^|\D)\.0+(\D|$)/g, '$10$2')
- .replace(/(^|\D)\.0+(\D|$)/g, '$10$2')
- .replace(/\.([1-9]*)0+(\D|$)/g, function (match, nonZeroPart, suffix) {
- return (nonZeroPart.length > 0 ? '.' : '') + nonZeroPart + suffix;
- })
- .replace(/(^|\D)0\.(\d)/g, '$1.$2');
-}
-
-function zeroDegMinifier(_, value) {
- if (value.indexOf('0deg') == -1)
- return value;
-
- return value.replace(/\(0deg\)/g, '(0)');
-}
-
-function whitespaceMinifier(name, value) {
- if (name.indexOf('filter') > -1 || value.indexOf(' ') == -1)
- return value;
-
- value = value.replace(/\s+/g, ' ');
-
- if (value.indexOf('calc') > -1)
- value = value.replace(/\) ?\/ ?/g, ')/ ');
-
- return value
- .replace(/\( /g, '(')
- .replace(/ \)/g, ')')
- .replace(/, /g, ',');
-}
-
-function precisionMinifier(_, value, precisionOptions) {
- if (precisionOptions.value === -1 || value.indexOf('.') === -1)
- return value;
-
- return value
- .replace(precisionOptions.regexp, function (match, number) {
- return Math.round(parseFloat(number) * precisionOptions.multiplier) / precisionOptions.multiplier + 'px';
- })
- .replace(/(\d)\.($|\D)/g, '$1$2');
-}
-
-function unitMinifier(name, value, unitsRegexp) {
- if (/^(?:\-moz\-calc|\-webkit\-calc|calc)\(/.test(value))
- return value;
-
- if (name == 'flex' || name == '-ms-flex' || name == '-webkit-flex' || name == 'flex-basis' || name == '-webkit-flex-basis')
- return value;
-
- if (value.indexOf('%') > 0 && (name == 'height' || name == 'max-height' || name == 'width' || name == 'max-width'))
- return value;
-
- return value
- .replace(unitsRegexp, '$1' + '0' + '$2')
- .replace(unitsRegexp, '$1' + '0' + '$2');
-}
-
-function multipleZerosMinifier(property) {
- var values = property.value;
- var spliceAt;
-
- if (values.length == 4 && values[0][0] === '0' && values[1][0] === '0' && values[2][0] === '0' && values[3][0] === '0') {
- if (property.name.indexOf('box-shadow') > -1)
- spliceAt = 2;
- else
- spliceAt = 1;
- }
-
- if (spliceAt) {
- property.value.splice(spliceAt);
- property.dirty = true;
- }
-}
-
-function colorMininifier(name, value, compatibility) {
- if (value.indexOf('#') === -1 && value.indexOf('rgb') == -1 && value.indexOf('hsl') == -1)
- return HexNameShortener.shorten(value);
-
- value = value
- .replace(/rgb\((\-?\d+),(\-?\d+),(\-?\d+)\)/g, function (match, red, green, blue) {
- return new RGB(red, green, blue).toHex();
- })
- .replace(/hsl\((-?\d+),(-?\d+)%?,(-?\d+)%?\)/g, function (match, hue, saturation, lightness) {
- return new HSL(hue, saturation, lightness).toHex();
- })
- .replace(/(^|[^='"])#([0-9a-f]{6})/gi, function (match, prefix, color) {
- if (color[0] == color[1] && color[2] == color[3] && color[4] == color[5])
- return prefix + '#' + color[0] + color[2] + color[4];
- else
- return prefix + '#' + color;
- })
- .replace(/(rgb|rgba|hsl|hsla)\(([^\)]+)\)/g, function (match, colorFunction, colorDef) {
- var tokens = colorDef.split(',');
- var applies = (colorFunction == 'hsl' && tokens.length == 3) ||
- (colorFunction == 'hsla' && tokens.length == 4) ||
- (colorFunction == 'rgb' && tokens.length == 3 && colorDef.indexOf('%') > 0) ||
- (colorFunction == 'rgba' && tokens.length == 4 && colorDef.indexOf('%') > 0);
- if (!applies)
- return match;
-
- if (tokens[1].indexOf('%') == -1)
- tokens[1] += '%';
- if (tokens[2].indexOf('%') == -1)
- tokens[2] += '%';
- return colorFunction + '(' + tokens.join(',') + ')';
- });
-
- if (compatibility.colors.opacity && name.indexOf('background') == -1) {
- value = value.replace(/(?:rgba|hsla)\(0,0%?,0%?,0\)/g, function (match) {
- if (split(value, ',').pop().indexOf('gradient(') > -1)
- return match;
-
- return 'transparent';
- });
- }
-
- return HexNameShortener.shorten(value);
-}
-
-function pixelLengthMinifier(_, value, compatibility) {
- if (!WHOLE_PIXEL_VALUE.test(value))
- return value;
-
- return value.replace(WHOLE_PIXEL_VALUE, function (match, val) {
- var newValue;
- var intVal = parseInt(val);
-
- if (intVal === 0)
- return match;
-
- if (compatibility.properties.shorterLengthUnits && compatibility.units.pt && intVal * 3 % 4 === 0)
- newValue = intVal * 3 / 4 + 'pt';
-
- if (compatibility.properties.shorterLengthUnits && compatibility.units.pc && intVal % 16 === 0)
- newValue = intVal / 16 + 'pc';
-
- if (compatibility.properties.shorterLengthUnits && compatibility.units.in && intVal % 96 === 0)
- newValue = intVal / 96 + 'in';
-
- if (newValue)
- newValue = match.substring(0, match.indexOf(val)) + newValue;
-
- return newValue && newValue.length < match.length ? newValue : match;
- });
-}
-
-function timeUnitMinifier(_, value) {
- if (!TIME_VALUE.test(value))
- return value;
-
- return value.replace(TIME_VALUE, function (match, val, unit) {
- var newValue;
-
- if (unit == 'ms') {
- newValue = parseInt(val) / 1000 + 's';
- } else if (unit == 's') {
- newValue = parseFloat(val) * 1000 + 'ms';
- }
-
- return newValue.length < match.length ? newValue : match;
- });
-}
-
-function minifyBorderRadius(property) {
- var values = property.value;
- var spliceAt;
-
- if (values.length == 3 && values[1][0] == '/' && values[0][0] == values[2][0])
- spliceAt = 1;
- else if (values.length == 5 && values[2][0] == '/' && values[0][0] == values[3][0] && values[1][0] == values[4][0])
- spliceAt = 2;
- else if (values.length == 7 && values[3][0] == '/' && values[0][0] == values[4][0] && values[1][0] == values[5][0] && values[2][0] == values[6][0])
- spliceAt = 3;
- else if (values.length == 9 && values[4][0] == '/' && values[0][0] == values[5][0] && values[1][0] == values[6][0] && values[2][0] == values[7][0] && values[3][0] == values[8][0])
- spliceAt = 4;
-
- if (spliceAt) {
- property.value.splice(spliceAt);
- property.dirty = true;
- }
-}
-
-function minifyFilter(property) {
- if (property.value.length == 1) {
- property.value[0][0] = property.value[0][0].replace(/progid:DXImageTransform\.Microsoft\.(Alpha|Chroma)(\W)/, function (match, filter, suffix) {
- return filter.toLowerCase() + suffix;
- });
- }
-
- property.value[0][0] = property.value[0][0]
- .replace(/,(\S)/g, ', $1')
- .replace(/ ?= ?/g, '=');
-}
-
-function minifyFont(property) {
- var values = property.value;
- var hasNumeral = FONT_NUMERAL_WEIGHTS.indexOf(values[0][0]) > -1 ||
- values[1] && FONT_NUMERAL_WEIGHTS.indexOf(values[1][0]) > -1 ||
- values[2] && FONT_NUMERAL_WEIGHTS.indexOf(values[2][0]) > -1;
-
- if (hasNumeral)
- return;
-
- if (values[1] == '/')
- return;
-
- var normalCount = 0;
- if (values[0][0] == 'normal')
- normalCount++;
- if (values[1] && values[1][0] == 'normal')
- normalCount++;
- if (values[2] && values[2][0] == 'normal')
- normalCount++;
-
- if (normalCount > 1)
- return;
-
- var toOptimize;
- if (FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[0][0]) > -1)
- toOptimize = 0;
- else if (values[1] && FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[1][0]) > -1)
- toOptimize = 1;
- else if (values[2] && FONT_NAME_WEIGHTS_WITHOUT_NORMAL.indexOf(values[2][0]) > -1)
- toOptimize = 2;
- else if (FONT_NAME_WEIGHTS.indexOf(values[0][0]) > -1)
- toOptimize = 0;
- else if (values[1] && FONT_NAME_WEIGHTS.indexOf(values[1][0]) > -1)
- toOptimize = 1;
- else if (values[2] && FONT_NAME_WEIGHTS.indexOf(values[2][0]) > -1)
- toOptimize = 2;
-
- if (toOptimize !== undefined) {
- property.value[toOptimize][0] = valueMinifiers['font-weight'](values[toOptimize][0]);
- property.dirty = true;
- }
-}
-
-function optimizeBody(properties, options) {
- var property, name, value;
- var _properties = wrapForOptimizing(properties);
-
- for (var i = 0, l = _properties.length; i < l; i++) {
- property = _properties[i];
- name = property.name;
-
- if (property.hack && (
- (property.hack == 'star' || property.hack == 'underscore') && !options.compatibility.properties.iePrefixHack ||
- property.hack == 'backslash' && !options.compatibility.properties.ieSuffixHack ||
- property.hack == 'bang' && !options.compatibility.properties.ieBangHack))
- property.unused = true;
-
- if (name.indexOf('padding') === 0 && (isNegative(property, 0) || isNegative(property, 1) || isNegative(property, 2) || isNegative(property, 3)))
- property.unused = true;
-
- if (property.unused)
- continue;
-
- if (property.variable) {
- if (property.block)
- optimizeBody(property.value[0], options);
- continue;
- }
-
- for (var j = 0, m = property.value.length; j < m; j++) {
- value = property.value[j][0];
-
- if (valueMinifiers[name])
- value = valueMinifiers[name](value, j, m);
-
- value = whitespaceMinifier(name, value);
- value = precisionMinifier(name, value, options.precision);
- value = pixelLengthMinifier(name, value, options.compatibility);
- value = timeUnitMinifier(name, value);
- value = zeroMinifier(name, value);
- if (options.compatibility.properties.zeroUnits) {
- value = zeroDegMinifier(name, value);
- value = unitMinifier(name, value, options.unitsRegexp);
- }
- if (options.compatibility.properties.colors)
- value = colorMininifier(name, value, options.compatibility);
-
- property.value[j][0] = value;
- }
-
- multipleZerosMinifier(property);
-
- if (name.indexOf('border') === 0 && name.indexOf('radius') > 0)
- minifyBorderRadius(property);
- else if (name == 'filter')
- minifyFilter(property);
- else if (name == 'font')
- minifyFont(property);
- }
-
- restoreFromOptimizing(_properties, true);
- removeUnused(_properties);
-}
-
-function cleanupCharsets(tokens) {
- var hasCharset = false;
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- if (token[0] != 'at-rule')
- continue;
-
- if (!CHARSET_REGEXP.test(token[1][0]))
- continue;
-
- if (hasCharset || token[1][0].indexOf(CHARSET_TOKEN) == -1) {
- tokens.splice(i, 1);
- i--;
- l--;
- } else {
- hasCharset = true;
- tokens.splice(i, 1);
- tokens.unshift(['at-rule', [token[1][0].replace(CHARSET_REGEXP, CHARSET_TOKEN)]]);
- }
- }
-}
-
-function buildUnitRegexp(options) {
- var units = ['px', 'em', 'ex', 'cm', 'mm', 'in', 'pt', 'pc', '%'];
- var otherUnits = ['ch', 'rem', 'vh', 'vm', 'vmax', 'vmin', 'vw'];
-
- otherUnits.forEach(function (unit) {
- if (options.compatibility.units[unit])
- units.push(unit);
- });
-
- return new RegExp('(^|\\s|\\(|,)0(?:' + units.join('|') + ')(\\W|$)', 'g');
-}
-
-function buildPrecision(options) {
- var precision = {};
-
- precision.value = options.roundingPrecision === undefined ?
- DEFAULT_ROUNDING_PRECISION :
- options.roundingPrecision;
- precision.multiplier = Math.pow(10, precision.value);
- precision.regexp = new RegExp('(\\d*\\.\\d{' + (precision.value + 1) + ',})px', 'g');
-
- return precision;
-}
-
-function optimize(tokens, options, context) {
- var ie7Hack = options.compatibility.selectors.ie7Hack;
- var adjacentSpace = options.compatibility.selectors.adjacentSpace;
- var spaceAfterClosingBrace = options.compatibility.properties.spaceAfterClosingBrace;
- var mayHaveCharset = false;
- var afterContent = false;
-
- options.unitsRegexp = buildUnitRegexp(options);
- options.precision = buildPrecision(options);
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- switch (token[0]) {
- case 'selector':
- token[1] = cleanUpSelectors(token[1], !ie7Hack, adjacentSpace);
- optimizeBody(token[2], options);
- afterContent = true;
- break;
- case 'block':
- cleanUpBlock(token[1], spaceAfterClosingBrace);
- optimize(token[2], options, context);
- afterContent = true;
- break;
- case 'flat-block':
- cleanUpBlock(token[1], spaceAfterClosingBrace);
- optimizeBody(token[2], options);
- afterContent = true;
- break;
- case 'at-rule':
- cleanUpAtRule(token[1]);
- mayHaveCharset = true;
- }
-
- if (token[0] == 'at-rule' && IMPORT_REGEXP.test(token[1]) && afterContent) {
- context.warnings.push('Ignoring @import rule "' + token[1] + '" as it appears after rules thus browsers will ignore them.');
- token[1] = '';
- }
-
- if (token[1].length === 0 || (token[2] && token[2].length === 0)) {
- tokens.splice(i, 1);
- i--;
- l--;
- }
- }
-
- if (mayHaveCharset)
- cleanupCharsets(tokens);
-}
-
-module.exports = optimize;
diff --git a/api/node_modules/clean-css/lib/source-maps/track.js b/api/node_modules/clean-css/lib/source-maps/track.js
deleted file mode 100644
index 735a58dc8..000000000
--- a/api/node_modules/clean-css/lib/source-maps/track.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var escapePrefix = '__ESCAPED_';
-
-function trackPrefix(value, context, interestingContent) {
- if (!interestingContent && value.indexOf('\n') == -1) {
- if (value.indexOf(escapePrefix) === 0) {
- return value;
- } else {
- context.column += value.length;
- return;
- }
- }
-
- var withoutContent = 0;
- var split = value.split('\n');
- var total = split.length;
- var shift = 0;
-
- while (true) {
- if (withoutContent == total - 1)
- break;
-
- var part = split[withoutContent];
- if (/\S/.test(part))
- break;
-
- shift += part.length + 1;
- withoutContent++;
- }
-
- context.line += withoutContent;
- context.column = withoutContent > 0 ? 0 : context.column;
- context.column += /^(\s)*/.exec(split[withoutContent])[0].length;
-
- return value.substring(shift).trimLeft();
-}
-
-function sourceFor(originalMetadata, contextMetadata, context) {
- var source = originalMetadata.source || contextMetadata.source;
-
- if (source && context.resolvePath)
- return context.resolvePath(contextMetadata.source, source);
-
- return source;
-}
-
-function snapshot(data, context, fallbacks) {
- var metadata = {
- line: context.line,
- column: context.column,
- source: context.source
- };
- var sourceContent = null;
- var sourceMetadata = context.sourceMapTracker.isTracking(metadata.source) ?
- context.sourceMapTracker.originalPositionFor(metadata, data, fallbacks || 0) :
- {};
-
- metadata.line = sourceMetadata.line || metadata.line;
- metadata.column = sourceMetadata.column || metadata.column;
- metadata.source = sourceMetadata.sourceResolved ?
- sourceMetadata.source :
- sourceFor(sourceMetadata, metadata, context);
-
- if (context.sourceMapInlineSources) {
- var sourceMapSourcesContent = context.sourceMapTracker.sourcesContentFor(context.source);
- sourceContent = sourceMapSourcesContent && sourceMapSourcesContent[metadata.source] ?
- sourceMapSourcesContent :
- context.sourceReader.sourceAt(context.source);
- }
-
- return sourceContent ?
- [metadata.line, metadata.column, metadata.source, sourceContent] :
- [metadata.line, metadata.column, metadata.source];
-}
-
-function trackSuffix(data, context) {
- var parts = data.split('\n');
-
- for (var i = 0, l = parts.length; i < l; i++) {
- var part = parts[i];
- var cursor = 0;
-
- if (i > 0) {
- context.line++;
- context.column = 0;
- }
-
- while (true) {
- var next = part.indexOf(escapePrefix, cursor);
-
- if (next == -1) {
- context.column += part.substring(cursor).length;
- break;
- }
-
- context.column += next - cursor;
- cursor += next - cursor;
-
- var escaped = part.substring(next, part.indexOf('__', next + 1) + 2);
- var encodedValues = escaped.substring(escaped.indexOf('(') + 1, escaped.indexOf(')')).split(',');
- context.line += ~~encodedValues[0];
- context.column = (~~encodedValues[0] === 0 ? context.column : 0) + ~~encodedValues[1];
- cursor += escaped.length;
- }
- }
-}
-
-function track(data, context, snapshotMetadata, fallbacks) {
- var untracked = trackPrefix(data, context, snapshotMetadata);
- var metadata = snapshotMetadata ?
- snapshot(untracked, context, fallbacks) :
- [];
-
- if (untracked)
- trackSuffix(untracked, context);
-
- return metadata;
-}
-
-module.exports = track;
diff --git a/api/node_modules/clean-css/lib/stringifier/helpers.js b/api/node_modules/clean-css/lib/stringifier/helpers.js
deleted file mode 100644
index 2e90001ef..000000000
--- a/api/node_modules/clean-css/lib/stringifier/helpers.js
+++ /dev/null
@@ -1,167 +0,0 @@
-var lineBreak = require('os').EOL;
-
-var AT_RULE = 'at-rule';
-var PROPERTY_SEPARATOR = ';';
-
-function hasMoreProperties(tokens, index) {
- for (var i = index, l = tokens.length; i < l; i++) {
- if (typeof tokens[i] != 'string')
- return true;
- }
-
- return false;
-}
-
-function supportsAfterClosingBrace(token) {
- return token[0][0] == 'background' || token[0][0] == 'transform' || token[0][0] == 'src';
-}
-
-function afterClosingBrace(token, valueIndex) {
- return token[valueIndex][0][token[valueIndex][0].length - 1] == ')' || token[valueIndex][0].indexOf('__ESCAPED_URL_CLEAN_CSS') === 0;
-}
-
-function afterComma(token, valueIndex) {
- return token[valueIndex][0] == ',';
-}
-
-function afterSlash(token, valueIndex) {
- return token[valueIndex][0] == '/';
-}
-
-function beforeComma(token, valueIndex) {
- return token[valueIndex + 1] && token[valueIndex + 1][0] == ',';
-}
-
-function beforeSlash(token, valueIndex) {
- return token[valueIndex + 1] && token[valueIndex + 1][0] == '/';
-}
-
-function inFilter(token) {
- return token[0][0] == 'filter' || token[0][0] == '-ms-filter';
-}
-
-function inSpecialContext(token, valueIndex, context) {
- return !context.spaceAfterClosingBrace && supportsAfterClosingBrace(token) && afterClosingBrace(token, valueIndex) ||
- beforeSlash(token, valueIndex) ||
- afterSlash(token, valueIndex) ||
- beforeComma(token, valueIndex) ||
- afterComma(token, valueIndex);
-}
-
-function selectors(tokens, context) {
- var store = context.store;
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- store(tokens[i], context);
-
- if (i < l - 1)
- store(',', context);
- }
-}
-
-function body(tokens, context) {
- for (var i = 0, l = tokens.length; i < l; i++) {
- property(tokens, i, i == l - 1, context);
- }
-}
-
-function property(tokens, position, isLast, context) {
- var store = context.store;
- var token = tokens[position];
-
- if (typeof token == 'string') {
- store(token, context);
- } else if (token[0] == AT_RULE) {
- propertyAtRule(token[1], false, context);
- } else {
- store(token[0], context);
- store(':', context);
- value(tokens, position, isLast, context);
- }
-}
-
-function propertyAtRule(value, isLast, context) {
- var store = context.store;
-
- store(value, context);
- if (!isLast)
- store(PROPERTY_SEPARATOR, context);
-}
-
-function value(tokens, position, isLast, context) {
- var store = context.store;
- var token = tokens[position];
- var isVariableDeclaration = token[0][0].indexOf('--') === 0;
- var isBlockVariable = isVariableDeclaration && Array.isArray(token[1][0]);
-
- if (isVariableDeclaration && isBlockVariable && atRulesOrProperties(token[1])) {
- store('{', context);
- body(token[1], context);
- store('};', context);
- return;
- }
-
- for (var j = 1, m = token.length; j < m; j++) {
- store(token[j], context);
-
- if (j < m - 1 && (inFilter(token) || !inSpecialContext(token, j, context))) {
- store(' ', context);
- } else if (j == m - 1 && !isLast && hasMoreProperties(tokens, position + 1)) {
- store(PROPERTY_SEPARATOR, context);
- }
- }
-}
-
-function atRulesOrProperties(values) {
- for (var i = 0, l = values.length; i < l; i++) {
- if (values[i][0] == AT_RULE || Array.isArray(values[i][0]))
- return true;
- }
-
- return false;
-}
-
-function all(tokens, context) {
- var joinCharacter = context.keepBreaks ? lineBreak : '';
- var store = context.store;
-
- for (var i = 0, l = tokens.length; i < l; i++) {
- var token = tokens[i];
-
- switch (token[0]) {
- case 'at-rule':
- case 'text':
- store(token[1][0], context);
- store(joinCharacter, context);
- break;
- case 'block':
- selectors([token[1]], context);
- store('{', context);
- all(token[2], context);
- store('}', context);
- store(joinCharacter, context);
- break;
- case 'flat-block':
- selectors([token[1]], context);
- store('{', context);
- body(token[2], context);
- store('}', context);
- store(joinCharacter, context);
- break;
- default:
- selectors(token[1], context);
- store('{', context);
- body(token[2], context);
- store('}', context);
- store(joinCharacter, context);
- }
- }
-}
-
-module.exports = {
- all: all,
- body: body,
- property: property,
- selectors: selectors,
- value: value
-};
diff --git a/api/node_modules/clean-css/lib/stringifier/one-time.js b/api/node_modules/clean-css/lib/stringifier/one-time.js
deleted file mode 100644
index 4a65c7f2a..000000000
--- a/api/node_modules/clean-css/lib/stringifier/one-time.js
+++ /dev/null
@@ -1,50 +0,0 @@
-var helpers = require('./helpers');
-
-function store(token, context) {
- context.output.push(typeof token == 'string' ? token : token[0]);
-}
-
-function context() {
- return {
- output: [],
- store: store
- };
-}
-
-function all(tokens) {
- var fakeContext = context();
- helpers.all(tokens, fakeContext);
- return fakeContext.output.join('');
-}
-
-function body(tokens) {
- var fakeContext = context();
- helpers.body(tokens, fakeContext);
- return fakeContext.output.join('');
-}
-
-function property(tokens, position) {
- var fakeContext = context();
- helpers.property(tokens, position, true, fakeContext);
- return fakeContext.output.join('');
-}
-
-function selectors(tokens) {
- var fakeContext = context();
- helpers.selectors(tokens, fakeContext);
- return fakeContext.output.join('');
-}
-
-function value(tokens, position) {
- var fakeContext = context();
- helpers.value(tokens, position, true, fakeContext);
- return fakeContext.output.join('');
-}
-
-module.exports = {
- all: all,
- body: body,
- property: property,
- selectors: selectors,
- value: value
-};
diff --git a/api/node_modules/clean-css/lib/stringifier/simple.js b/api/node_modules/clean-css/lib/stringifier/simple.js
deleted file mode 100644
index 0673996d2..000000000
--- a/api/node_modules/clean-css/lib/stringifier/simple.js
+++ /dev/null
@@ -1,22 +0,0 @@
-var all = require('./helpers').all;
-
-function store(token, context) {
- context.output.push(typeof token == 'string' ? token : token[0]);
-}
-
-function stringify(tokens, options, restoreCallback) {
- var context = {
- keepBreaks: options.keepBreaks,
- output: [],
- spaceAfterClosingBrace: options.compatibility.properties.spaceAfterClosingBrace,
- store: store
- };
-
- all(tokens, context, false);
-
- return {
- styles: restoreCallback(context.output.join('')).trim()
- };
-}
-
-module.exports = stringify;
diff --git a/api/node_modules/clean-css/lib/stringifier/source-maps.js b/api/node_modules/clean-css/lib/stringifier/source-maps.js
deleted file mode 100644
index 77486140d..000000000
--- a/api/node_modules/clean-css/lib/stringifier/source-maps.js
+++ /dev/null
@@ -1,96 +0,0 @@
-var SourceMapGenerator = require('source-map').SourceMapGenerator;
-var all = require('./helpers').all;
-
-var isWindows = process.platform == 'win32';
-var unknownSource = '$stdin';
-
-function store(element, context) {
- var fromString = typeof element == 'string';
- var value = fromString ? element : element[0];
-
- if (value.indexOf('_') > -1)
- value = context.restore(value, prefixContentFrom(context.output));
-
- track(value, fromString ? null : element, context);
- context.output.push(value);
-}
-
-function prefixContentFrom(values) {
- var content = [];
-
- for (var i = values.length - 1; i >= 0; i--) {
- var value = values[i];
- content.unshift(value);
-
- if (value == '{' || value == ';')
- break;
- }
-
- return content.join('');
-}
-
-function track(value, element, context) {
- if (element)
- trackAllMappings(element, context);
-
- var parts = value.split('\n');
- context.line += parts.length - 1;
- context.column = parts.length > 1 ? 0 : (context.column + parts.pop().length);
-}
-
-function trackAllMappings(element, context) {
- var mapping = element[element.length - 1];
-
- if (!Array.isArray(mapping))
- return;
-
- for (var i = 0, l = mapping.length; i < l; i++) {
- trackMapping(mapping[i], context);
- }
-}
-
-function trackMapping(mapping, context) {
- var source = mapping[2] || unknownSource;
-
- if (isWindows)
- source = source.replace(/\\/g, '/');
-
- context.outputMap.addMapping({
- generated: {
- line: context.line,
- column: context.column
- },
- source: source,
- original: {
- line: mapping[0],
- column: mapping[1]
- }
- });
-
- if (mapping[3])
- context.outputMap.setSourceContent(source, mapping[3][mapping[2]]);
-}
-
-function stringify(tokens, options, restoreCallback, inputMapTracker) {
- var context = {
- column: 0,
- inputMapTracker: inputMapTracker,
- keepBreaks: options.keepBreaks,
- line: 1,
- output: [],
- outputMap: new SourceMapGenerator(),
- restore: restoreCallback,
- sourceMapInlineSources: options.sourceMapInlineSources,
- spaceAfterClosingBrace: options.compatibility.properties.spaceAfterClosingBrace,
- store: store
- };
-
- all(tokens, context, false);
-
- return {
- sourceMap: context.outputMap,
- styles: context.output.join('').trim()
- };
-}
-
-module.exports = stringify;
diff --git a/api/node_modules/clean-css/lib/text/comments-processor.js b/api/node_modules/clean-css/lib/text/comments-processor.js
deleted file mode 100644
index 2063b53a6..000000000
--- a/api/node_modules/clean-css/lib/text/comments-processor.js
+++ /dev/null
@@ -1,131 +0,0 @@
-var EscapeStore = require('./escape-store');
-var QuoteScanner = require('../utils/quote-scanner');
-
-var SPECIAL_COMMENT_PREFIX = '/*!';
-var COMMENT_PREFIX = '/*';
-var COMMENT_SUFFIX = '*/';
-
-var lineBreak = require('os').EOL;
-
-function CommentsProcessor(context, keepSpecialComments, keepBreaks, saveWaypoints) {
- this.comments = new EscapeStore('COMMENT');
- this.specialComments = new EscapeStore('COMMENT_SPECIAL');
-
- this.context = context;
- this.restored = 0;
- this.keepAll = keepSpecialComments == '*';
- this.keepOne = keepSpecialComments == '1' || keepSpecialComments === 1;
- this.keepBreaks = keepBreaks;
- this.saveWaypoints = saveWaypoints;
-}
-
-function quoteScannerFor(data) {
- var quoteMap = [];
- new QuoteScanner(data).each(function (quotedString, _, startsAt) {
- quoteMap.push([startsAt, startsAt + quotedString.length]);
- });
-
- return function (position) {
- for (var i = 0, l = quoteMap.length; i < l; i++) {
- if (quoteMap[i][0] < position && quoteMap[i][1] > position)
- return true;
- }
-
- return false;
- };
-}
-
-CommentsProcessor.prototype.escape = function (data) {
- var tempData = [];
- var nextStart = 0;
- var nextEnd = 0;
- var cursor = 0;
- var indent = 0;
- var breaksCount;
- var lastBreakAt;
- var newIndent;
- var isQuotedAt = quoteScannerFor(data);
- var saveWaypoints = this.saveWaypoints;
-
- for (; nextEnd < data.length;) {
- nextStart = data.indexOf(COMMENT_PREFIX, cursor);
- if (nextStart == -1)
- break;
-
- if (isQuotedAt(nextStart)) {
- tempData.push(data.substring(cursor, nextStart + COMMENT_PREFIX.length));
- cursor = nextStart + COMMENT_PREFIX.length;
- continue;
- }
-
- nextEnd = data.indexOf(COMMENT_SUFFIX, nextStart + COMMENT_PREFIX.length);
- if (nextEnd == -1) {
- this.context.warnings.push('Broken comment: \'' + data.substring(nextStart) + '\'.');
- nextEnd = data.length - 2;
- }
-
- tempData.push(data.substring(cursor, nextStart));
-
- var comment = data.substring(nextStart, nextEnd + COMMENT_SUFFIX.length);
- var isSpecialComment = comment.indexOf(SPECIAL_COMMENT_PREFIX) === 0;
-
- if (saveWaypoints) {
- breaksCount = comment.split(lineBreak).length - 1;
- lastBreakAt = comment.lastIndexOf(lineBreak);
- newIndent = lastBreakAt > 0 ?
- comment.substring(lastBreakAt + lineBreak.length).length :
- indent + comment.length;
- }
-
- if (saveWaypoints || isSpecialComment) {
- var metadata = saveWaypoints ? [breaksCount, newIndent] : null;
- var placeholder = isSpecialComment ?
- this.specialComments.store(comment, metadata) :
- this.comments.store(comment, metadata);
- tempData.push(placeholder);
- }
-
- if (saveWaypoints)
- indent = newIndent + 1;
- cursor = nextEnd + COMMENT_SUFFIX.length;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-function restore(context, data, from, isSpecial) {
- var tempData = [];
- var cursor = 0;
-
- for (; cursor < data.length;) {
- var nextMatch = from.nextMatch(data, cursor);
- if (nextMatch.start < 0)
- break;
-
- tempData.push(data.substring(cursor, nextMatch.start));
- var comment = from.restore(nextMatch.match);
-
- if (isSpecial && (context.keepAll || (context.keepOne && context.restored === 0))) {
- context.restored++;
- tempData.push(comment);
-
- cursor = nextMatch.end;
- } else {
- cursor = nextMatch.end + (context.keepBreaks && data.substring(nextMatch.end, nextMatch.end + lineBreak.length) == lineBreak ? lineBreak.length : 0);
- }
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-}
-
-CommentsProcessor.prototype.restore = function (data) {
- data = restore(this, data, this.comments, false);
- data = restore(this, data, this.specialComments, true);
- return data;
-};
-
-module.exports = CommentsProcessor;
diff --git a/api/node_modules/clean-css/lib/text/escape-store.js b/api/node_modules/clean-css/lib/text/escape-store.js
deleted file mode 100644
index 8598d732e..000000000
--- a/api/node_modules/clean-css/lib/text/escape-store.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var placeholderBrace = '__';
-
-function EscapeStore(placeholderRoot) {
- this.placeholderRoot = 'ESCAPED_' + placeholderRoot + '_CLEAN_CSS';
- this.placeholderToData = {};
- this.dataToPlaceholder = {};
- this.count = 0;
- this.restoreMatcher = new RegExp(this.placeholderRoot + '(\\d+)');
-}
-
-EscapeStore.prototype._nextPlaceholder = function (metadata) {
- return {
- index: this.count,
- value: placeholderBrace + this.placeholderRoot + this.count++ + metadata + placeholderBrace
- };
-};
-
-EscapeStore.prototype.store = function (data, metadata) {
- var encodedMetadata = metadata ?
- '(' + metadata.join(',') + ')' :
- '';
- var placeholder = this.dataToPlaceholder[data];
-
- if (!placeholder) {
- var nextPlaceholder = this._nextPlaceholder(encodedMetadata);
- placeholder = nextPlaceholder.value;
- this.placeholderToData[nextPlaceholder.index] = data;
- this.dataToPlaceholder[data] = nextPlaceholder.value;
- }
-
- if (metadata)
- placeholder = placeholder.replace(/\([^\)]+\)/, encodedMetadata);
-
- return placeholder;
-};
-
-EscapeStore.prototype.nextMatch = function (data, cursor) {
- var next = {};
-
- next.start = data.indexOf(this.placeholderRoot, cursor) - placeholderBrace.length;
- next.end = data.indexOf(placeholderBrace, next.start + placeholderBrace.length) + placeholderBrace.length;
- if (next.start > -1 && next.end > -1)
- next.match = data.substring(next.start, next.end);
-
- return next;
-};
-
-EscapeStore.prototype.restore = function (placeholder) {
- var index = this.restoreMatcher.exec(placeholder)[1];
- return this.placeholderToData[index];
-};
-
-module.exports = EscapeStore;
diff --git a/api/node_modules/clean-css/lib/text/expressions-processor.js b/api/node_modules/clean-css/lib/text/expressions-processor.js
deleted file mode 100644
index 3e22ced81..000000000
--- a/api/node_modules/clean-css/lib/text/expressions-processor.js
+++ /dev/null
@@ -1,117 +0,0 @@
-var EscapeStore = require('./escape-store');
-
-var EXPRESSION_NAME = 'expression';
-var EXPRESSION_START = '(';
-var EXPRESSION_END = ')';
-var EXPRESSION_PREFIX = EXPRESSION_NAME + EXPRESSION_START;
-var BODY_START = '{';
-var BODY_END = '}';
-
-var lineBreak = require('os').EOL;
-
-function findEnd(data, start) {
- var end = start + EXPRESSION_NAME.length;
- var level = 0;
- var quoted = false;
- var braced = false;
-
- while (true) {
- var current = data[end++];
-
- if (quoted) {
- quoted = current != '\'' && current != '"';
- } else {
- quoted = current == '\'' || current == '"';
-
- if (current == EXPRESSION_START)
- level++;
- if (current == EXPRESSION_END)
- level--;
- if (current == BODY_START)
- braced = true;
- if (current == BODY_END && !braced && level == 1) {
- end--;
- level--;
- }
- }
-
- if (level === 0 && current == EXPRESSION_END)
- break;
- if (!current) {
- end = data.substring(0, end).lastIndexOf(BODY_END);
- break;
- }
- }
-
- return end;
-}
-
-function ExpressionsProcessor(saveWaypoints) {
- this.expressions = new EscapeStore('EXPRESSION');
- this.saveWaypoints = saveWaypoints;
-}
-
-ExpressionsProcessor.prototype.escape = function (data) {
- var nextStart = 0;
- var nextEnd = 0;
- var cursor = 0;
- var tempData = [];
- var indent = 0;
- var breaksCount;
- var lastBreakAt;
- var newIndent;
- var saveWaypoints = this.saveWaypoints;
-
- for (; nextEnd < data.length;) {
- nextStart = data.indexOf(EXPRESSION_PREFIX, nextEnd);
- if (nextStart == -1)
- break;
-
- nextEnd = findEnd(data, nextStart);
-
- var expression = data.substring(nextStart, nextEnd);
- if (saveWaypoints) {
- breaksCount = expression.split(lineBreak).length - 1;
- lastBreakAt = expression.lastIndexOf(lineBreak);
- newIndent = lastBreakAt > 0 ?
- expression.substring(lastBreakAt + lineBreak.length).length :
- indent + expression.length;
- }
-
- var metadata = saveWaypoints ? [breaksCount, newIndent] : null;
- var placeholder = this.expressions.store(expression, metadata);
- tempData.push(data.substring(cursor, nextStart));
- tempData.push(placeholder);
-
- if (saveWaypoints)
- indent = newIndent + 1;
- cursor = nextEnd;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-ExpressionsProcessor.prototype.restore = function (data) {
- var tempData = [];
- var cursor = 0;
-
- for (; cursor < data.length;) {
- var nextMatch = this.expressions.nextMatch(data, cursor);
- if (nextMatch.start < 0)
- break;
-
- tempData.push(data.substring(cursor, nextMatch.start));
- var comment = this.expressions.restore(nextMatch.match);
- tempData.push(comment);
-
- cursor = nextMatch.end;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-module.exports = ExpressionsProcessor;
diff --git a/api/node_modules/clean-css/lib/text/free-text-processor.js b/api/node_modules/clean-css/lib/text/free-text-processor.js
deleted file mode 100644
index 8a426244e..000000000
--- a/api/node_modules/clean-css/lib/text/free-text-processor.js
+++ /dev/null
@@ -1,98 +0,0 @@
-var EscapeStore = require('./escape-store');
-var QuoteScanner = require('../utils/quote-scanner');
-
-var lineBreak = require('os').EOL;
-
-function FreeTextProcessor(saveWaypoints) {
- this.matches = new EscapeStore('FREE_TEXT');
- this.saveWaypoints = saveWaypoints;
-}
-
-// Strip content tags by replacing them by the a special
-// marker for further restoring. It's done via string scanning
-// instead of regexps to speed up the process.
-FreeTextProcessor.prototype.escape = function (data) {
- var self = this;
- var breaksCount;
- var lastBreakAt;
- var indent;
- var metadata;
- var saveWaypoints = this.saveWaypoints;
-
- return new QuoteScanner(data).each(function (match, store) {
- if (saveWaypoints) {
- breaksCount = match.split(lineBreak).length - 1;
- lastBreakAt = match.lastIndexOf(lineBreak);
- indent = lastBreakAt > 0 ?
- match.substring(lastBreakAt + lineBreak.length).length :
- match.length;
- metadata = [breaksCount, indent];
- }
-
- var placeholder = self.matches.store(match, metadata);
- store.push(placeholder);
- });
-};
-
-function normalize(text, data, prefixContext, cursor) {
- // FIXME: this is even a bigger hack now - see #407
- var searchIn = data;
- if (prefixContext) {
- searchIn = prefixContext + data.substring(0, data.indexOf('__ESCAPED_FREE_TEXT_CLEAN_CSS'));
- cursor = searchIn.length;
- }
-
- var lastSemicolon = searchIn.lastIndexOf(';', cursor);
- var lastOpenBrace = searchIn.lastIndexOf('{', cursor);
- var lastOne = 0;
-
- if (lastSemicolon > -1 && lastOpenBrace > -1)
- lastOne = Math.max(lastSemicolon, lastOpenBrace);
- else if (lastSemicolon == -1)
- lastOne = lastOpenBrace;
- else
- lastOne = lastSemicolon;
-
- var context = searchIn.substring(lastOne + 1, cursor);
-
- if (/\[[\w\d\-]+[\*\|\~\^\$]?=$/.test(context)) {
- text = text
- .replace(/\\\n|\\\r\n/g, '')
- .replace(/\n|\r\n/g, '');
- }
-
- if (/^['"][a-zA-Z][a-zA-Z\d\-_]+['"]$/.test(text) && !/format\($/.test(context)) {
- var isFont = /^(font|font\-family):/.test(context);
- var isAttribute = /\[[\w\d\-]+[\*\|\~\^\$]?=$/.test(context);
- var isKeyframe = /@(-moz-|-o-|-webkit-)?keyframes /.test(context);
- var isAnimation = /^(-moz-|-o-|-webkit-)?animation(-name)?:/.test(context);
-
- if (isFont || isAttribute || isKeyframe || isAnimation)
- text = text.substring(1, text.length - 1);
- }
-
- return text;
-}
-
-FreeTextProcessor.prototype.restore = function (data, prefixContext) {
- var tempData = [];
- var cursor = 0;
-
- for (; cursor < data.length;) {
- var nextMatch = this.matches.nextMatch(data, cursor);
- if (nextMatch.start < 0)
- break;
-
- tempData.push(data.substring(cursor, nextMatch.start));
- var text = normalize(this.matches.restore(nextMatch.match), data, prefixContext, nextMatch.start);
- tempData.push(text);
-
- cursor = nextMatch.end;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-module.exports = FreeTextProcessor;
diff --git a/api/node_modules/clean-css/lib/text/urls-processor.js b/api/node_modules/clean-css/lib/text/urls-processor.js
deleted file mode 100644
index 4dbb55adf..000000000
--- a/api/node_modules/clean-css/lib/text/urls-processor.js
+++ /dev/null
@@ -1,75 +0,0 @@
-var EscapeStore = require('./escape-store');
-var reduceUrls = require('../urls/reduce');
-
-var lineBreak = require('os').EOL;
-
-function UrlsProcessor(context, saveWaypoints, keepUrlQuotes) {
- this.urls = new EscapeStore('URL');
- this.context = context;
- this.saveWaypoints = saveWaypoints;
- this.keepUrlQuotes = keepUrlQuotes;
-}
-
-// Strip urls by replacing them by a special
-// marker for further restoring. It's done via string scanning
-// instead of regexps to speed up the process.
-UrlsProcessor.prototype.escape = function (data) {
- var breaksCount;
- var lastBreakAt;
- var indent;
- var saveWaypoints = this.saveWaypoints;
- var self = this;
-
- return reduceUrls(data, this.context, function (url, tempData) {
- if (saveWaypoints) {
- breaksCount = url.split(lineBreak).length - 1;
- lastBreakAt = url.lastIndexOf(lineBreak);
- indent = lastBreakAt > 0 ?
- url.substring(lastBreakAt + lineBreak.length).length :
- url.length;
- }
-
- var placeholder = self.urls.store(url, saveWaypoints ? [breaksCount, indent] : null);
- tempData.push(placeholder);
- });
-};
-
-function normalize(url, keepUrlQuotes) {
- url = url
- .replace(/^url/gi, 'url')
- .replace(/\\?\n|\\?\r\n/g, '')
- .replace(/(\s{2,}|\s)/g, ' ')
- .replace(/^url\((['"])? /, 'url($1')
- .replace(/ (['"])?\)$/, '$1)');
-
- if (/url\(".*'.*"\)/.test(url) || /url\('.*".*'\)/.test(url))
- return url;
-
- if (!keepUrlQuotes && !/^['"].+['"]$/.test(url) && !/url\(.*[\s\(\)].*\)/.test(url) && !/url\(['"]data:[^;]+;charset/.test(url))
- url = url.replace(/["']/g, '');
-
- return url;
-}
-
-UrlsProcessor.prototype.restore = function (data) {
- var tempData = [];
- var cursor = 0;
-
- for (; cursor < data.length;) {
- var nextMatch = this.urls.nextMatch(data, cursor);
- if (nextMatch.start < 0)
- break;
-
- tempData.push(data.substring(cursor, nextMatch.start));
- var url = normalize(this.urls.restore(nextMatch.match), this.keepUrlQuotes);
- tempData.push(url);
-
- cursor = nextMatch.end;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-module.exports = UrlsProcessor;
diff --git a/api/node_modules/clean-css/lib/tokenizer/extract-properties.js b/api/node_modules/clean-css/lib/tokenizer/extract-properties.js
deleted file mode 100644
index d4b0db397..000000000
--- a/api/node_modules/clean-css/lib/tokenizer/extract-properties.js
+++ /dev/null
@@ -1,193 +0,0 @@
-var split = require('../utils/split');
-
-var COMMA = ',';
-var FORWARD_SLASH = '/';
-
-var AT_RULE = 'at-rule';
-
-var IMPORTANT_WORD = 'important';
-var IMPORTANT_TOKEN = '!'+IMPORTANT_WORD;
-var IMPORTANT_WORD_MATCH = new RegExp('^'+IMPORTANT_WORD+'$', 'i');
-var IMPORTANT_TOKEN_MATCH = new RegExp('^'+IMPORTANT_TOKEN+'$', 'i');
-
-function selectorName(value) {
- return value[0];
-}
-
-function noop() {}
-
-function withoutComments(string, into, heading, context) {
- var matcher = heading ? /^__ESCAPED_COMMENT_/ : /__ESCAPED_COMMENT_/;
- var track = heading ? context.track : noop; // don't track when comment not in a heading as we do it later in `trackComments`
-
- while (matcher.test(string)) {
- var startOfComment = string.indexOf('__');
- var endOfComment = string.indexOf('__', startOfComment + 1) + 2;
- var comment = string.substring(startOfComment, endOfComment);
- string = string.substring(0, startOfComment) + string.substring(endOfComment);
-
- track(comment);
- into.push(comment);
- }
-
- return string;
-}
-
-function withoutHeadingComments(string, into, context) {
- return withoutComments(string, into, true, context);
-}
-
-function withoutInnerComments(string, into, context) {
- return withoutComments(string, into, false, context);
-}
-
-function trackComments(comments, into, context) {
- for (var i = 0, l = comments.length; i < l; i++) {
- context.track(comments[i]);
- into.push(comments[i]);
- }
-}
-
-function extractProperties(string, selectors, context) {
- var list = [];
- var innerComments = [];
- var valueSeparator = /[\s,\/]/;
-
- if (typeof string != 'string')
- return [];
-
- if (string.indexOf(')') > -1)
- string = string.replace(/\)([^\s_;:,\)])/g, context.sourceMap ? ') __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__ $1' : ') $1');
-
- if (string.indexOf('ESCAPED_URL_CLEAN_CSS') > -1)
- string = string.replace(/(ESCAPED_URL_CLEAN_CSS[^_]+?__)/g, context.sourceMap ? '$1 __ESCAPED_COMMENT_CLEAN_CSS(0,-1)__ ' : '$1 ');
-
- var candidates = split(string, ';', false, '{', '}');
-
- for (var i = 0, l = candidates.length; i < l; i++) {
- var candidate = candidates[i];
- var firstColonAt = candidate.indexOf(':');
-
- var atRule = candidate.trim()[0] == '@';
- if (atRule) {
- context.track(candidate);
- list.push([AT_RULE, candidate.trim()]);
- continue;
- }
-
- if (firstColonAt == -1) {
- context.track(candidate);
- if (candidate.indexOf('__ESCAPED_COMMENT_SPECIAL') > -1)
- list.push(candidate.trim());
- continue;
- }
-
- if (candidate.indexOf('{') > 0 && candidate.indexOf('{') < firstColonAt) {
- context.track(candidate);
- continue;
- }
-
- var body = [];
- var name = candidate.substring(0, firstColonAt);
-
- innerComments = [];
-
- if (name.indexOf('__ESCAPED_COMMENT') > -1)
- name = withoutHeadingComments(name, list, context);
-
- if (name.indexOf('__ESCAPED_COMMENT') > -1)
- name = withoutInnerComments(name, innerComments, context);
-
- body.push([name.trim()].concat(context.track(name, true)));
- context.track(':');
-
- trackComments(innerComments, list, context);
-
- var firstBraceAt = candidate.indexOf('{');
- var isVariable = name.trim().indexOf('--') === 0;
- if (isVariable && firstBraceAt > 0) {
- var blockPrefix = candidate.substring(firstColonAt + 1, firstBraceAt + 1);
- var blockSuffix = candidate.substring(candidate.indexOf('}'));
- var blockContent = candidate.substring(firstBraceAt + 1, candidate.length - blockSuffix.length);
-
- context.track(blockPrefix);
- body.push(extractProperties(blockContent, selectors, context));
- list.push(body);
- context.track(blockSuffix);
- context.track(i < l - 1 ? ';' : '');
-
- continue;
- }
-
- var values = split(candidate.substring(firstColonAt + 1), valueSeparator, true);
-
- if (values.length == 1 && values[0] === '') {
- context.warnings.push('Empty property \'' + name + '\' inside \'' + selectors.filter(selectorName).join(',') + '\' selector. Ignoring.');
- continue;
- }
-
- for (var j = 0, m = values.length; j < m; j++) {
- var value = values[j];
- var trimmed = value.trim();
-
- if (trimmed.length === 0)
- continue;
-
- var lastCharacter = trimmed[trimmed.length - 1];
- var endsWithNonSpaceSeparator = trimmed.length > 1 && (lastCharacter == COMMA || lastCharacter == FORWARD_SLASH);
-
- if (endsWithNonSpaceSeparator)
- trimmed = trimmed.substring(0, trimmed.length - 1);
-
- if (trimmed.indexOf('__ESCAPED_COMMENT_CLEAN_CSS(0,-') > -1) {
- context.track(trimmed);
- continue;
- }
-
- innerComments = [];
-
- if (trimmed.indexOf('__ESCAPED_COMMENT') > -1)
- trimmed = withoutHeadingComments(trimmed, list, context);
-
- if (trimmed.indexOf('__ESCAPED_COMMENT') > -1)
- trimmed = withoutInnerComments(trimmed, innerComments, context);
-
- if (trimmed.length === 0) {
- trackComments(innerComments, list, context);
- continue;
- }
-
- var pos = body.length - 1;
- if (IMPORTANT_WORD_MATCH.test(trimmed) && body[pos][0] == '!') {
- context.track(trimmed);
- body[pos - 1][0] += IMPORTANT_TOKEN;
- body.pop();
- continue;
- }
-
- if (IMPORTANT_TOKEN_MATCH.test(trimmed) || (IMPORTANT_WORD_MATCH.test(trimmed) && body[pos][0][body[pos][0].length - 1] == '!')) {
- context.track(trimmed);
- body[pos][0] += trimmed;
- continue;
- }
-
- body.push([trimmed].concat(context.track(value, true)));
-
- trackComments(innerComments, list, context);
-
- if (endsWithNonSpaceSeparator) {
- body.push([lastCharacter]);
- context.track(lastCharacter);
- }
- }
-
- if (i < l - 1)
- context.track(';');
-
- list.push(body);
- }
-
- return list;
-}
-
-module.exports = extractProperties;
diff --git a/api/node_modules/clean-css/lib/tokenizer/extract-selectors.js b/api/node_modules/clean-css/lib/tokenizer/extract-selectors.js
deleted file mode 100644
index dc8a47fa5..000000000
--- a/api/node_modules/clean-css/lib/tokenizer/extract-selectors.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var split = require('../utils/split');
-
-function extractSelectors(string, context) {
- var list = [];
- var metadata;
- var selectors = split(string, ',');
-
- for (var i = 0, l = selectors.length; i < l; i++) {
- metadata = context.track(selectors[i], true, i);
- context.track(',');
- list.push([selectors[i].trim()].concat(metadata));
- }
-
- return list;
-}
-
-module.exports = extractSelectors;
diff --git a/api/node_modules/clean-css/lib/tokenizer/tokenize.js b/api/node_modules/clean-css/lib/tokenizer/tokenize.js
deleted file mode 100644
index e903f6e7d..000000000
--- a/api/node_modules/clean-css/lib/tokenizer/tokenize.js
+++ /dev/null
@@ -1,297 +0,0 @@
-var extractProperties = require('./extract-properties');
-var extractSelectors = require('./extract-selectors');
-var track = require('../source-maps/track');
-var split = require('../utils/split');
-
-var path = require('path');
-
-var flatBlock = /(@(font\-face|page|\-ms\-viewport|\-o\-viewport|viewport|counter\-style)|\\@.+?)/;
-var BACKSLASH = '\\';
-
-function tokenize(data, outerContext) {
- var chunks = split(normalize(data), '}', true, '{', '}');
- if (chunks.length === 0)
- return [];
-
- var context = {
- chunk: chunks.shift(),
- chunks: chunks,
- column: 0,
- cursor: 0,
- line: 1,
- mode: 'top',
- resolvePath: outerContext.options.explicitTarget ?
- relativePathResolver(outerContext.options.root, outerContext.options.target) :
- null,
- source: undefined,
- sourceMap: outerContext.options.sourceMap,
- sourceMapInlineSources: outerContext.options.sourceMapInlineSources,
- sourceMapTracker: outerContext.inputSourceMapTracker,
- sourceReader: outerContext.sourceReader,
- sourceTracker: outerContext.sourceTracker,
- state: [],
- track: outerContext.options.sourceMap ?
- function (data, snapshotMetadata, fallbacks) { return [[track(data, context, snapshotMetadata, fallbacks)]]; } :
- function () { return []; },
- warnings: outerContext.warnings
- };
-
- return intoTokens(context);
-}
-
-function normalize(data) {
- return data.replace(/\r\n/g, '\n');
-}
-
-function relativePathResolver(root, target) {
- var rebaseTo = path.relative(root, target);
-
- return function (relativeTo, sourcePath) {
- return relativeTo != sourcePath ?
- path.normalize(path.join(path.relative(rebaseTo, path.dirname(relativeTo)), sourcePath)) :
- sourcePath;
- };
-}
-
-function whatsNext(context) {
- var mode = context.mode;
- var chunk = context.chunk;
- var closest;
-
- if (chunk.length == context.cursor) {
- if (context.chunks.length === 0)
- return null;
-
- context.chunk = chunk = context.chunks.shift();
- context.cursor = 0;
- }
-
- if (mode == 'body') {
- if (chunk[context.cursor] == '}')
- return [context.cursor, 'bodyEnd'];
-
- if (chunk.indexOf('}', context.cursor) == -1)
- return null;
-
- closest = context.cursor + split(chunk.substring(context.cursor - 1), '}', true, '{', '}')[0].length - 2;
- return [closest, 'bodyEnd'];
- }
-
- var nextSpecial = nextAt(context, '@');
- var nextEscape = chunk.indexOf('__ESCAPED_', context.cursor);
- var nextBodyStart = nextAt(context, '{');
- var nextBodyEnd = nextAt(context, '}');
-
- if (nextSpecial > -1 && context.cursor > 0 && !/\s|\{|\}|\/|_|,|;/.test(chunk.substring(nextSpecial - 1, nextSpecial))) {
- nextSpecial = -1;
- }
-
- if (nextEscape > -1 && /\S/.test(chunk.substring(context.cursor, nextEscape)))
- nextEscape = -1;
-
- closest = nextSpecial;
- if (closest == -1 || (nextEscape > -1 && nextEscape < closest))
- closest = nextEscape;
- if (closest == -1 || (nextBodyStart > -1 && nextBodyStart < closest))
- closest = nextBodyStart;
- if (closest == -1 || (nextBodyEnd > -1 && nextBodyEnd < closest))
- closest = nextBodyEnd;
-
- if (closest == -1)
- return;
- if (nextEscape === closest)
- return [closest, 'escape'];
- if (nextBodyStart === closest)
- return [closest, 'bodyStart'];
- if (nextBodyEnd === closest)
- return [closest, 'bodyEnd'];
- if (nextSpecial === closest)
- return [closest, 'special'];
-}
-
-function nextAt(context, character) {
- var startAt = context.cursor;
- var chunk = context.chunk;
- var position;
-
- while ((position = chunk.indexOf(character, startAt)) > -1) {
- if (isEscaped(chunk, position)) {
- startAt = position + 1;
- } else {
- return position;
- }
- }
-
- return -1;
-}
-
-function isEscaped(chunk, position) {
- var startAt = position;
- var backslashCount = 0;
-
- while (startAt > 0 && chunk[startAt - 1] == BACKSLASH) {
- backslashCount++;
- startAt--;
- }
-
- return backslashCount % 2 !== 0;
-}
-
-function intoTokens(context) {
- var chunk = context.chunk;
- var tokenized = [];
- var newToken;
- var value;
-
- while (true) {
- var next = whatsNext(context);
- if (!next) {
- var whatsLeft = context.chunk.substring(context.cursor);
- if (whatsLeft.trim().length > 0) {
- if (context.mode == 'body') {
- context.warnings.push('Missing \'}\' after \'' + whatsLeft + '\'. Ignoring.');
- } else {
- tokenized.push(['text', [whatsLeft]]);
- }
- context.cursor += whatsLeft.length;
- }
- break;
- }
-
- var nextSpecial = next[0];
- var what = next[1];
- var nextEnd;
- var oldMode;
-
- chunk = context.chunk;
-
- if (context.cursor != nextSpecial && what != 'bodyEnd') {
- var spacing = chunk.substring(context.cursor, nextSpecial);
- var leadingWhitespace = /^\s+/.exec(spacing);
-
- if (leadingWhitespace) {
- context.cursor += leadingWhitespace[0].length;
- context.track(leadingWhitespace[0]);
- }
- }
-
- if (what == 'special') {
- var firstOpenBraceAt = chunk.indexOf('{', nextSpecial);
- var firstSemicolonAt = chunk.indexOf(';', nextSpecial);
- var isSingle = firstSemicolonAt > -1 && (firstOpenBraceAt == -1 || firstSemicolonAt < firstOpenBraceAt);
- var isBroken = firstOpenBraceAt == -1 && firstSemicolonAt == -1;
- if (isBroken) {
- context.warnings.push('Broken declaration: \'' + chunk.substring(context.cursor) + '\'.');
- context.cursor = chunk.length;
- } else if (isSingle) {
- nextEnd = chunk.indexOf(';', nextSpecial + 1);
- value = chunk.substring(context.cursor, nextEnd + 1);
-
- tokenized.push([
- 'at-rule',
- [value].concat(context.track(value, true))
- ]);
-
- context.track(';');
- context.cursor = nextEnd + 1;
- } else {
- nextEnd = chunk.indexOf('{', nextSpecial + 1);
- value = chunk.substring(context.cursor, nextEnd);
-
- var trimmedValue = value.trim();
- var isFlat = flatBlock.test(trimmedValue);
- oldMode = context.mode;
- context.cursor = nextEnd + 1;
- context.mode = isFlat ? 'body' : 'block';
-
- newToken = [
- isFlat ? 'flat-block' : 'block'
- ];
-
- newToken.push([trimmedValue].concat(context.track(value, true)));
- context.track('{');
- newToken.push(intoTokens(context));
-
- if (typeof newToken[2] == 'string')
- newToken[2] = extractProperties(newToken[2], [[trimmedValue]], context);
-
- context.mode = oldMode;
- context.track('}');
-
- tokenized.push(newToken);
- }
- } else if (what == 'escape') {
- nextEnd = chunk.indexOf('__', nextSpecial + 1);
- var escaped = chunk.substring(context.cursor, nextEnd + 2);
- var isStartSourceMarker = !!context.sourceTracker.nextStart(escaped);
- var isEndSourceMarker = !!context.sourceTracker.nextEnd(escaped);
-
- if (isStartSourceMarker) {
- context.track(escaped);
- context.state.push({
- source: context.source,
- line: context.line,
- column: context.column
- });
- context.source = context.sourceTracker.nextStart(escaped).filename;
- context.line = 1;
- context.column = 0;
- } else if (isEndSourceMarker) {
- var oldState = context.state.pop();
- context.source = oldState.source;
- context.line = oldState.line;
- context.column = oldState.column;
- context.track(escaped);
- } else {
- if (escaped.indexOf('__ESCAPED_COMMENT_SPECIAL') === 0)
- tokenized.push(['text', [escaped]]);
-
- context.track(escaped);
- }
-
- context.cursor = nextEnd + 2;
- } else if (what == 'bodyStart') {
- var selectors = extractSelectors(chunk.substring(context.cursor, nextSpecial), context);
-
- oldMode = context.mode;
- context.cursor = nextSpecial + 1;
- context.mode = 'body';
-
- var body = extractProperties(intoTokens(context), selectors, context);
-
- context.track('{');
- context.mode = oldMode;
-
- tokenized.push([
- 'selector',
- selectors,
- body
- ]);
- } else if (what == 'bodyEnd') {
- // extra closing brace at the top level can be safely ignored
- if (context.mode == 'top') {
- var at = context.cursor;
- var warning = chunk[context.cursor] == '}' ?
- 'Unexpected \'}\' in \'' + chunk.substring(at - 20, at + 20) + '\'. Ignoring.' :
- 'Unexpected content: \'' + chunk.substring(at, nextSpecial + 1) + '\'. Ignoring.';
-
- context.warnings.push(warning);
- context.cursor = nextSpecial + 1;
- continue;
- }
-
- if (context.mode == 'block')
- context.track(chunk.substring(context.cursor, nextSpecial));
- if (context.mode != 'block')
- tokenized = chunk.substring(context.cursor, nextSpecial);
-
- context.cursor = nextSpecial + 1;
-
- break;
- }
- }
-
- return tokenized;
-}
-
-module.exports = tokenize;
diff --git a/api/node_modules/clean-css/lib/urls/rebase.js b/api/node_modules/clean-css/lib/urls/rebase.js
deleted file mode 100644
index 04346b1d4..000000000
--- a/api/node_modules/clean-css/lib/urls/rebase.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var path = require('path');
-
-var rewriteUrls = require('./rewrite');
-
-function rebaseUrls(data, context) {
- var rebaseOpts = {
- absolute: context.options.explicitRoot,
- relative: !context.options.explicitRoot && context.options.explicitTarget,
- fromBase: context.options.relativeTo
- };
-
- if (!rebaseOpts.absolute && !rebaseOpts.relative)
- return data;
-
- if (rebaseOpts.absolute && context.options.explicitTarget)
- context.warnings.push('Both \'root\' and output file given so rebasing URLs as absolute paths');
-
- if (rebaseOpts.absolute)
- rebaseOpts.toBase = path.resolve(context.options.root);
-
- if (rebaseOpts.relative)
- rebaseOpts.toBase = path.resolve(context.options.target);
-
- if (!rebaseOpts.fromBase || !rebaseOpts.toBase)
- return data;
-
- return rewriteUrls(data, rebaseOpts, context);
-}
-
-module.exports = rebaseUrls;
diff --git a/api/node_modules/clean-css/lib/urls/reduce.js b/api/node_modules/clean-css/lib/urls/reduce.js
deleted file mode 100644
index 35ad55569..000000000
--- a/api/node_modules/clean-css/lib/urls/reduce.js
+++ /dev/null
@@ -1,154 +0,0 @@
-var split = require('../utils/split');
-
-var URL_PREFIX = 'url(';
-var UPPERCASE_URL_PREFIX = 'URL(';
-var URL_SUFFIX = ')';
-var SINGLE_QUOTE_URL_SUFFIX = '\')';
-var DOUBLE_QUOTE_URL_SUFFIX = '")';
-
-var DATA_URI_PREFIX_PATTERN = /^\s*['"]?\s*data:/;
-var DATA_URI_TRAILER_PATTERN = /[\s\};,\/!]/;
-
-var IMPORT_URL_PREFIX = '@import';
-var UPPERCASE_IMPORT_URL_PREFIX = '@IMPORT';
-
-var COMMENT_END_MARKER = /\*\//;
-
-function byUrl(data, context, callback) {
- var nextStart = 0;
- var nextStartUpperCase = 0;
- var nextEnd = 0;
- var firstMatch;
- var isDataURI = false;
- var cursor = 0;
- var tempData = [];
- var hasUppercaseUrl = data.indexOf(UPPERCASE_URL_PREFIX) > -1;
-
- for (; nextEnd < data.length;) {
- nextStart = data.indexOf(URL_PREFIX, nextEnd);
- nextStartUpperCase = hasUppercaseUrl ? data.indexOf(UPPERCASE_URL_PREFIX, nextEnd) : -1;
- if (nextStart == -1 && nextStartUpperCase == -1)
- break;
-
- if (nextStart == -1 && nextStartUpperCase > -1)
- nextStart = nextStartUpperCase;
-
- if (data[nextStart + URL_PREFIX.length] == '"') {
- nextEnd = data.indexOf(DOUBLE_QUOTE_URL_SUFFIX, nextStart);
- } else if (data[nextStart + URL_PREFIX.length] == '\'') {
- nextEnd = data.indexOf(SINGLE_QUOTE_URL_SUFFIX, nextStart);
- } else {
- isDataURI = DATA_URI_PREFIX_PATTERN.test(data.substring(nextStart + URL_PREFIX.length));
-
- if (isDataURI) {
- firstMatch = split(data.substring(nextStart), DATA_URI_TRAILER_PATTERN, false, '(', ')', true).pop();
-
- if (firstMatch && firstMatch[firstMatch.length - 1] == URL_SUFFIX) {
- nextEnd = nextStart + firstMatch.length - URL_SUFFIX.length;
- } else {
- nextEnd = -1;
- }
- } else {
- nextEnd = data.indexOf(URL_SUFFIX, nextStart);
- }
- }
-
-
- // Following lines are a safety mechanism to ensure
- // incorrectly terminated urls are processed correctly.
- if (nextEnd == -1) {
- nextEnd = data.indexOf('}', nextStart);
-
- if (nextEnd == -1)
- nextEnd = data.length;
- else
- nextEnd--;
-
- context.warnings.push('Broken URL declaration: \'' + data.substring(nextStart, nextEnd + 1) + '\'.');
- } else {
- if (data[nextEnd] != URL_SUFFIX)
- nextEnd = data.indexOf(URL_SUFFIX, nextEnd);
- }
-
- tempData.push(data.substring(cursor, nextStart));
-
- var url = data.substring(nextStart, nextEnd + 1);
- callback(url, tempData);
-
- cursor = nextEnd + 1;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-}
-
-function byImport(data, context, callback) {
- var nextImport = 0;
- var nextImportUpperCase = 0;
- var nextStart = 0;
- var nextEnd = 0;
- var cursor = 0;
- var tempData = [];
- var nextSingleQuote = 0;
- var nextDoubleQuote = 0;
- var untilNextQuote;
- var withQuote;
- var SINGLE_QUOTE = '\'';
- var DOUBLE_QUOTE = '"';
-
- for (; nextEnd < data.length;) {
- nextImport = data.indexOf(IMPORT_URL_PREFIX, nextEnd);
- nextImportUpperCase = data.indexOf(UPPERCASE_IMPORT_URL_PREFIX, nextEnd);
- if (nextImport == -1 && nextImportUpperCase == -1)
- break;
-
- if (nextImport > -1 && nextImportUpperCase > -1 && nextImportUpperCase < nextImport)
- nextImport = nextImportUpperCase;
-
- nextSingleQuote = data.indexOf(SINGLE_QUOTE, nextImport);
- nextDoubleQuote = data.indexOf(DOUBLE_QUOTE, nextImport);
-
- if (nextSingleQuote > -1 && nextDoubleQuote > -1 && nextSingleQuote < nextDoubleQuote) {
- nextStart = nextSingleQuote;
- withQuote = SINGLE_QUOTE;
- } else if (nextSingleQuote > -1 && nextDoubleQuote > -1 && nextSingleQuote > nextDoubleQuote) {
- nextStart = nextDoubleQuote;
- withQuote = DOUBLE_QUOTE;
- } else if (nextSingleQuote > -1) {
- nextStart = nextSingleQuote;
- withQuote = SINGLE_QUOTE;
- } else if (nextDoubleQuote > -1) {
- nextStart = nextDoubleQuote;
- withQuote = DOUBLE_QUOTE;
- } else {
- break;
- }
-
- tempData.push(data.substring(cursor, nextStart));
- nextEnd = data.indexOf(withQuote, nextStart + 1);
-
- untilNextQuote = data.substring(nextImport, nextEnd);
- if (nextEnd == -1 || /^@import\s+(url\(|__ESCAPED)/i.test(untilNextQuote) || COMMENT_END_MARKER.test(untilNextQuote)) {
- cursor = nextStart;
- break;
- }
-
- var url = data.substring(nextStart, nextEnd + 1);
- callback(url, tempData);
-
- cursor = nextEnd + 1;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-}
-
-function reduceAll(data, context, callback) {
- data = byUrl(data, context, callback);
- data = byImport(data, context, callback);
- return data;
-}
-
-module.exports = reduceAll;
diff --git a/api/node_modules/clean-css/lib/urls/rewrite.js b/api/node_modules/clean-css/lib/urls/rewrite.js
deleted file mode 100644
index 0f5552b4e..000000000
--- a/api/node_modules/clean-css/lib/urls/rewrite.js
+++ /dev/null
@@ -1,107 +0,0 @@
-var path = require('path');
-var url = require('url');
-
-var reduceUrls = require('./reduce');
-
-var isWindows = process.platform == 'win32';
-
-function isAbsolute(uri) {
- return uri[0] == '/';
-}
-
-function isSVGMarker(uri) {
- return uri[0] == '#';
-}
-
-function isEscaped(uri) {
- return uri.indexOf('__ESCAPED_URL_CLEAN_CSS__') === 0;
-}
-
-function isInternal(uri) {
- return /^\w+:\w+/.test(uri);
-}
-
-function isRemote(uri) {
- return /^[^:]+?:\/\//.test(uri) || uri.indexOf('//') === 0;
-}
-
-function isSameOrigin(uri1, uri2) {
- return url.parse(uri1).protocol == url.parse(uri2).protocol &&
- url.parse(uri1).host == url.parse(uri2).host;
-}
-
-function isImport(uri) {
- return uri.lastIndexOf('.css') === uri.length - 4;
-}
-
-function isData(uri) {
- return uri.indexOf('data:') === 0;
-}
-
-function absolute(uri, options) {
- return path
- .resolve(path.join(options.fromBase || '', uri))
- .replace(options.toBase, '');
-}
-
-function relative(uri, options) {
- return path.relative(options.toBase, path.join(options.fromBase || '', uri));
-}
-
-function normalize(uri) {
- return isWindows ? uri.replace(/\\/g, '/') : uri;
-}
-
-function rebase(uri, options) {
- if (isAbsolute(uri) || isSVGMarker(uri) || isEscaped(uri) || isInternal(uri))
- return uri;
-
- if (options.rebase === false && !isImport(uri))
- return uri;
-
- if (!options.imports && isImport(uri))
- return uri;
-
- if (isData(uri))
- return '\'' + uri + '\'';
-
- if (isRemote(uri) && !isRemote(options.toBase))
- return uri;
-
- if (isRemote(uri) && !isSameOrigin(uri, options.toBase))
- return uri;
-
- if (!isRemote(uri) && isRemote(options.toBase))
- return url.resolve(options.toBase, uri);
-
- return options.absolute ?
- normalize(absolute(uri, options)) :
- normalize(relative(uri, options));
-}
-
-function quoteFor(url) {
- if (url.indexOf('\'') > -1)
- return '"';
- else if (url.indexOf('"') > -1)
- return '\'';
- else if (/\s/.test(url) || /[\(\)]/.test(url))
- return '\'';
- else
- return '';
-}
-
-function rewriteUrls(data, options, context) {
- return reduceUrls(data, context, function (originUrl, tempData) {
- var url = originUrl.replace(/^(url\()?\s*['"]?|['"]?\s*\)?$/g, '');
- var match = originUrl.match(/^(url\()?\s*(['"]).*?(['"])\s*\)?$/);
- var quote;
- if (!!options.urlQuotes && match && match[2] === match[3]) {
- quote = match[2];
- } else {
- quote = quoteFor(url);
- }
- tempData.push('url(' + quote + rebase(url, options) + quote + ')');
- });
-}
-
-module.exports = rewriteUrls;
diff --git a/api/node_modules/clean-css/lib/utils/clone-array.js b/api/node_modules/clean-css/lib/utils/clone-array.js
deleted file mode 100644
index b95ee6843..000000000
--- a/api/node_modules/clean-css/lib/utils/clone-array.js
+++ /dev/null
@@ -1,12 +0,0 @@
-function cloneArray(array) {
- var cloned = array.slice(0);
-
- for (var i = 0, l = cloned.length; i < l; i++) {
- if (Array.isArray(cloned[i]))
- cloned[i] = cloneArray(cloned[i]);
- }
-
- return cloned;
-}
-
-module.exports = cloneArray;
diff --git a/api/node_modules/clean-css/lib/utils/compatibility.js b/api/node_modules/clean-css/lib/utils/compatibility.js
deleted file mode 100644
index 112a6dcce..000000000
--- a/api/node_modules/clean-css/lib/utils/compatibility.js
+++ /dev/null
@@ -1,162 +0,0 @@
-var util = require('util');
-
-var DEFAULTS = {
- '*': {
- colors: {
- opacity: true // rgba / hsla
- },
- properties: {
- backgroundClipMerging: false, // background-clip to shorthand
- backgroundOriginMerging: false, // background-origin to shorthand
- backgroundSizeMerging: false, // background-size to shorthand
- colors: true, // any kind of color transformations, like `#ff00ff` to `#f0f` or `#fff` into `red`
- ieBangHack: false, // !ie suffix hacks on IE<8
- iePrefixHack: false, // underscore / asterisk prefix hacks on IE
- ieSuffixHack: true, // \9 suffix hacks on IE6-9
- merging: true, // merging properties into one
- shorterLengthUnits: false, // optimize pixel units into `pt`, `pc` or `in` units
- spaceAfterClosingBrace: true, // 'url() no-repeat' to 'url()no-repeat'
- urlQuotes: false, // whether to wrap content of `url()` into quotes or not
- zeroUnits: true // 0[unit] -> 0
- },
- selectors: {
- adjacentSpace: false, // div+ nav Android stock browser hack
- ie7Hack: false, // *+html hack
- special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:dir\([a-z-]*\)|:first(?![a-z-])|:fullscreen|:left|:read-only|:read-write|:right|:placeholder|:host|:content|\/deep\/|:shadow|:selection|^,)/ // special selectors which prevent merging
- },
- units: {
- ch: true,
- in: true,
- pc: true,
- pt: true,
- rem: true,
- vh: true,
- vm: true, // vm is vmin on IE9+ see https://developer.mozilla.org/en-US/docs/Web/CSS/length
- vmax: true,
- vmin: true,
- vw: true
- }
- },
- 'ie8': {
- colors: {
- opacity: false
- },
- properties: {
- backgroundClipMerging: false,
- backgroundOriginMerging: false,
- backgroundSizeMerging: false,
- colors: true,
- ieBangHack: false,
- iePrefixHack: true,
- ieSuffixHack: true,
- merging: false,
- shorterLengthUnits: false,
- spaceAfterClosingBrace: true,
- urlQuotes: false,
- zeroUnits: true
- },
- selectors: {
- adjacentSpace: false,
- ie7Hack: false,
- special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
- },
- units: {
- ch: false,
- in: true,
- pc: true,
- pt: true,
- rem: false,
- vh: false,
- vm: false,
- vmax: false,
- vmin: false,
- vw: false
- }
- },
- 'ie7': {
- colors: {
- opacity: false
- },
- properties: {
- backgroundClipMerging: false,
- backgroundOriginMerging: false,
- backgroundSizeMerging: false,
- colors: true,
- ieBangHack: true,
- iePrefixHack: true,
- ieSuffixHack: true,
- merging: false,
- shorterLengthUnits: false,
- spaceAfterClosingBrace: true,
- urlQuotes: false,
- zeroUnits: true
- },
- selectors: {
- adjacentSpace: false,
- ie7Hack: true,
- special: /(\-moz\-|\-ms\-|\-o\-|\-webkit\-|:focus|:before|:after|:root|:nth|:first\-of|:last|:only|:empty|:target|:checked|::selection|:enabled|:disabled|:not|:placeholder|:host|::content|\/deep\/|::shadow|^,)/
- },
- units: {
- ch: false,
- in: true,
- pc: true,
- pt: true,
- rem: false,
- vh: false,
- vm: false,
- vmax: false,
- vmin: false,
- vw: false,
- }
- }
-};
-
-function Compatibility(source) {
- this.source = source || {};
-}
-
-function merge(source, target) {
- for (var key in source) {
- var value = source[key];
-
- if (typeof value === 'object' && !util.isRegExp(value))
- target[key] = merge(value, target[key] || {});
- else
- target[key] = key in target ? target[key] : value;
- }
-
- return target;
-}
-
-function calculateSource(source) {
- if (typeof source == 'object')
- return source;
-
- if (!/[,\+\-]/.test(source))
- return DEFAULTS[source] || DEFAULTS['*'];
-
- var parts = source.split(',');
- var template = parts[0] in DEFAULTS ?
- DEFAULTS[parts.shift()] :
- DEFAULTS['*'];
-
- source = {};
-
- parts.forEach(function (part) {
- var isAdd = part[0] == '+';
- var key = part.substring(1).split('.');
- var group = key[0];
- var option = key[1];
-
- source[group] = source[group] || {};
- source[group][option] = isAdd;
- });
-
- return merge(template, source);
-}
-
-Compatibility.prototype.toOptions = function () {
- return merge(DEFAULTS['*'], calculateSource(this.source));
-};
-
-module.exports = Compatibility;
diff --git a/api/node_modules/clean-css/lib/utils/input-source-map-tracker.js b/api/node_modules/clean-css/lib/utils/input-source-map-tracker.js
deleted file mode 100644
index bfd9106fc..000000000
--- a/api/node_modules/clean-css/lib/utils/input-source-map-tracker.js
+++ /dev/null
@@ -1,284 +0,0 @@
-var SourceMapConsumer = require('source-map').SourceMapConsumer;
-
-var fs = require('fs');
-var path = require('path');
-var http = require('http');
-var https = require('https');
-var url = require('url');
-
-var override = require('../utils/object.js').override;
-
-var MAP_MARKER = /\/\*# sourceMappingURL=(\S+) \*\//;
-var REMOTE_RESOURCE = /^(https?:)?\/\//;
-var DATA_URI = /^data:(\S*?)?(;charset=[^;]+)?(;[^,]+?)?,(.+)/;
-
-var unescape = global.unescape;
-
-function InputSourceMapStore(outerContext) {
- this.options = outerContext.options;
- this.errors = outerContext.errors;
- this.warnings = outerContext.warnings;
- this.sourceTracker = outerContext.sourceTracker;
- this.timeout = this.options.inliner.timeout;
- this.requestOptions = this.options.inliner.request;
- this.localOnly = outerContext.localOnly;
- this.relativeTo = outerContext.options.target || process.cwd();
-
- this.maps = {};
- this.sourcesContent = {};
-}
-
-function fromString(self, _, whenDone) {
- self.trackLoaded(undefined, undefined, self.options.sourceMap);
- return whenDone();
-}
-
-function fromSource(self, data, whenDone, context) {
- var nextAt = 0;
-
- function proceedToNext() {
- context.cursor += nextAt + 1;
- fromSource(self, data, whenDone, context);
- }
-
- while (context.cursor < data.length) {
- var fragment = data.substring(context.cursor);
-
- var markerStartMatch = self.sourceTracker.nextStart(fragment) || { index: -1 };
- var markerEndMatch = self.sourceTracker.nextEnd(fragment) || { index: -1 };
- var mapMatch = MAP_MARKER.exec(fragment) || { index: -1 };
- var sourceMapFile = mapMatch[1];
-
- nextAt = data.length;
- if (markerStartMatch.index > -1)
- nextAt = markerStartMatch.index;
- if (markerEndMatch.index > -1 && markerEndMatch.index < nextAt)
- nextAt = markerEndMatch.index;
- if (mapMatch.index > -1 && mapMatch.index < nextAt)
- nextAt = mapMatch.index;
-
- if (nextAt == data.length)
- break;
-
- if (nextAt == markerStartMatch.index) {
- context.files.push(markerStartMatch.filename);
- } else if (nextAt == markerEndMatch.index) {
- context.files.pop();
- } else if (nextAt == mapMatch.index) {
- var isRemote = /^https?:\/\//.test(sourceMapFile) || /^\/\//.test(sourceMapFile);
- var isDataUri = DATA_URI.test(sourceMapFile);
-
- if (isRemote) {
- return fetchMapFile(self, sourceMapFile, context, proceedToNext);
- } else {
- var sourceFile = context.files[context.files.length - 1];
- var sourceMapPath, sourceMapData;
- var sourceDir = sourceFile ? path.dirname(sourceFile) : self.options.relativeTo;
-
- if (isDataUri) {
- // source map's path is the same as the source file it comes from
- sourceMapPath = path.resolve(self.options.root, sourceFile || '');
- sourceMapData = fromDataUri(sourceMapFile);
- } else {
- sourceMapPath = path.resolve(self.options.root, path.join(sourceDir || '', sourceMapFile));
- sourceMapData = fs.readFileSync(sourceMapPath, 'utf-8');
- }
- self.trackLoaded(sourceFile || undefined, sourceMapPath, sourceMapData);
- }
- }
-
- context.cursor += nextAt + 1;
- }
-
- return whenDone();
-}
-
-function fromDataUri(uriString) {
- var match = DATA_URI.exec(uriString);
- var charset = match[2] ? match[2].split(/[=;]/)[2] : 'us-ascii';
- var encoding = match[3] ? match[3].split(';')[1] : 'utf8';
- var data = encoding == 'utf8' ? unescape(match[4]) : match[4];
-
- var buffer = new Buffer(data, encoding);
- buffer.charset = charset;
-
- return buffer.toString();
-}
-
-function fetchMapFile(self, sourceUrl, context, done) {
- fetch(self, sourceUrl, function (data) {
- self.trackLoaded(context.files[context.files.length - 1] || undefined, sourceUrl, data);
- done();
- }, function (message) {
- context.errors.push('Broken source map at "' + sourceUrl + '" - ' + message);
- return done();
- });
-}
-
-function fetch(self, path, onSuccess, onFailure) {
- var protocol = path.indexOf('https') === 0 ? https : http;
- var requestOptions = override(url.parse(path), self.requestOptions);
- var errorHandled = false;
-
- protocol
- .get(requestOptions, function (res) {
- if (res.statusCode < 200 || res.statusCode > 299)
- return onFailure(res.statusCode);
-
- var chunks = [];
- res.on('data', function (chunk) {
- chunks.push(chunk.toString());
- });
- res.on('end', function () {
- onSuccess(chunks.join(''));
- });
- })
- .on('error', function (res) {
- if (errorHandled)
- return;
-
- onFailure(res.message);
- errorHandled = true;
- })
- .on('timeout', function () {
- if (errorHandled)
- return;
-
- onFailure('timeout');
- errorHandled = true;
- })
- .setTimeout(self.timeout);
-}
-
-function originalPositionIn(trackedSource, line, column, token, allowNFallbacks) {
- var originalPosition;
- var maxRange = token.length;
- var position = {
- line: line,
- column: column + maxRange
- };
-
- while (maxRange-- > 0) {
- position.column--;
- originalPosition = trackedSource.data.originalPositionFor(position);
-
- if (originalPosition)
- break;
- }
-
- if (originalPosition.line === null && line > 1 && allowNFallbacks > 0)
- return originalPositionIn(trackedSource, line - 1, column, token, allowNFallbacks - 1);
-
- if (trackedSource.path && originalPosition.source) {
- originalPosition.source = REMOTE_RESOURCE.test(trackedSource.path) ?
- url.resolve(trackedSource.path, originalPosition.source) :
- path.join(trackedSource.path, originalPosition.source);
-
- originalPosition.sourceResolved = true;
- }
-
- return originalPosition;
-}
-
-function trackContentSources(self, sourceFile) {
- var consumer = self.maps[sourceFile].data;
- var isRemote = REMOTE_RESOURCE.test(sourceFile);
- var sourcesMapping = {};
-
- consumer.sources.forEach(function (file, index) {
- var uniquePath = isRemote ?
- url.resolve(path.dirname(sourceFile), file) :
- path.relative(self.relativeTo, path.resolve(path.dirname(sourceFile || '.'), file));
-
- sourcesMapping[uniquePath] = consumer.sourcesContent && consumer.sourcesContent[index];
- });
- self.sourcesContent[sourceFile] = sourcesMapping;
-}
-
-function _resolveSources(self, remaining, whenDone) {
- function processNext() {
- return _resolveSources(self, remaining, whenDone);
- }
-
- if (remaining.length === 0)
- return whenDone();
-
- var current = remaining.shift();
- var sourceFile = current[0];
- var originalFile = current[1];
- var isRemote = REMOTE_RESOURCE.test(sourceFile);
-
- if (isRemote && self.localOnly) {
- self.warnings.push('No callback given to `#minify` method, cannot fetch a remote file from "' + originalFile + '"');
- return processNext();
- }
-
- if (isRemote) {
- fetch(self, originalFile, function (data) {
- self.sourcesContent[sourceFile][originalFile] = data;
- processNext();
- }, function (message) {
- self.warnings.push('Broken original source file at "' + originalFile + '" - ' + message);
- processNext();
- });
- } else {
- var fullPath = path.join(self.options.root, originalFile);
- if (fs.existsSync(fullPath))
- self.sourcesContent[sourceFile][originalFile] = fs.readFileSync(fullPath, 'utf-8');
- else
- self.warnings.push('Missing original source file at "' + fullPath + '".');
- return processNext();
- }
-}
-
-InputSourceMapStore.prototype.track = function (data, whenDone) {
- return typeof this.options.sourceMap == 'string' ?
- fromString(this, data, whenDone) :
- fromSource(this, data, whenDone, { files: [], cursor: 0, errors: this.errors });
-};
-
-InputSourceMapStore.prototype.trackLoaded = function (sourcePath, mapPath, mapData) {
- var relativeTo = this.options.explicitTarget ? this.options.target : this.options.root;
- var isRemote = REMOTE_RESOURCE.test(sourcePath);
-
- if (mapPath) {
- mapPath = isRemote ?
- path.dirname(mapPath) :
- path.dirname(path.relative(relativeTo, mapPath));
- }
-
- this.maps[sourcePath] = {
- path: mapPath,
- data: new SourceMapConsumer(mapData)
- };
-
- trackContentSources(this, sourcePath);
-};
-
-InputSourceMapStore.prototype.isTracking = function (source) {
- return !!this.maps[source];
-};
-
-InputSourceMapStore.prototype.originalPositionFor = function (sourceInfo, token, allowNFallbacks) {
- return originalPositionIn(this.maps[sourceInfo.source], sourceInfo.line, sourceInfo.column, token, allowNFallbacks);
-};
-
-InputSourceMapStore.prototype.sourcesContentFor = function (contextSource) {
- return this.sourcesContent[contextSource];
-};
-
-InputSourceMapStore.prototype.resolveSources = function (whenDone) {
- var toResolve = [];
-
- for (var sourceFile in this.sourcesContent) {
- var contents = this.sourcesContent[sourceFile];
- for (var originalFile in contents) {
- if (!contents[originalFile])
- toResolve.push([sourceFile, originalFile]);
- }
- }
-
- return _resolveSources(this, toResolve, whenDone);
-};
-
-module.exports = InputSourceMapStore;
diff --git a/api/node_modules/clean-css/lib/utils/object.js b/api/node_modules/clean-css/lib/utils/object.js
deleted file mode 100644
index 8e94886c8..000000000
--- a/api/node_modules/clean-css/lib/utils/object.js
+++ /dev/null
@@ -1,11 +0,0 @@
-module.exports = {
- override: function (source1, source2) {
- var target = {};
- for (var key1 in source1)
- target[key1] = source1[key1];
- for (var key2 in source2)
- target[key2] = source2[key2];
-
- return target;
- }
-};
diff --git a/api/node_modules/clean-css/lib/utils/quote-scanner.js b/api/node_modules/clean-css/lib/utils/quote-scanner.js
deleted file mode 100644
index 1810b9ec6..000000000
--- a/api/node_modules/clean-css/lib/utils/quote-scanner.js
+++ /dev/null
@@ -1,119 +0,0 @@
-var COMMENT_START_MARK = '/*';
-
-function QuoteScanner(data) {
- this.data = data;
-}
-
-var findQuoteEnd = function (data, matched, cursor, oldCursor) {
- var commentEndMark = '*/';
- var escapeMark = '\\';
- var blockEndMark = '}';
- var dataPrefix = data.substring(oldCursor, cursor);
- var commentEndedAt = dataPrefix.lastIndexOf(commentEndMark, cursor);
- var commentStartedAt = findLastCommentStartedAt(dataPrefix, cursor);
- var commentStarted = false;
-
- if (commentEndedAt >= cursor && commentStartedAt > -1)
- commentStarted = true;
- if (commentStartedAt < cursor && commentStartedAt > commentEndedAt)
- commentStarted = true;
-
- if (commentStarted) {
- var commentEndsAt = data.indexOf(commentEndMark, cursor);
- if (commentEndsAt > -1)
- return commentEndsAt;
-
- commentEndsAt = data.indexOf(blockEndMark, cursor);
- return commentEndsAt > -1 ? commentEndsAt - 1 : data.length;
- }
-
- while (true) {
- if (data[cursor] === undefined)
- break;
- if (data[cursor] == matched && (data[cursor - 1] != escapeMark || data[cursor - 2] == escapeMark))
- break;
-
- cursor++;
- }
-
- return cursor;
-};
-
-function findLastCommentStartedAt(data, cursor) {
- var position = cursor;
-
- while (position > -1) {
- position = data.lastIndexOf(COMMENT_START_MARK, position);
-
- if (position > -1 && data[position - 1] != '*') {
- break;
- } else {
- position--;
- }
- }
-
- return position;
-}
-
-function findNext(data, mark, startAt) {
- var escapeMark = '\\';
- var candidate = startAt;
-
- while (true) {
- candidate = data.indexOf(mark, candidate + 1);
- if (candidate == -1)
- return -1;
- if (data[candidate - 1] != escapeMark)
- return candidate;
- }
-}
-
-QuoteScanner.prototype.each = function (callback) {
- var data = this.data;
- var tempData = [];
- var nextStart = 0;
- var nextEnd = 0;
- var cursor = 0;
- var matchedMark = null;
- var singleMark = '\'';
- var doubleMark = '"';
- var dataLength = data.length;
-
- for (; nextEnd < data.length;) {
- var nextStartSingle = findNext(data, singleMark, nextEnd);
- var nextStartDouble = findNext(data, doubleMark, nextEnd);
-
- if (nextStartSingle == -1)
- nextStartSingle = dataLength;
- if (nextStartDouble == -1)
- nextStartDouble = dataLength;
-
- if (nextStartSingle < nextStartDouble) {
- nextStart = nextStartSingle;
- matchedMark = singleMark;
- } else {
- nextStart = nextStartDouble;
- matchedMark = doubleMark;
- }
-
- if (nextStart == -1)
- break;
-
- nextEnd = findQuoteEnd(data, matchedMark, nextStart + 1, cursor);
- if (nextEnd == -1)
- break;
-
- var text = data.substring(nextStart, nextEnd + 1);
- tempData.push(data.substring(cursor, nextStart));
- if (text.length > 0)
- callback(text, tempData, nextStart);
-
- cursor = nextEnd + 1;
- }
-
- return tempData.length > 0 ?
- tempData.join('') + data.substring(cursor, data.length) :
- data;
-};
-
-module.exports = QuoteScanner;
diff --git a/api/node_modules/clean-css/lib/utils/source-reader.js b/api/node_modules/clean-css/lib/utils/source-reader.js
deleted file mode 100644
index d817e72b3..000000000
--- a/api/node_modules/clean-css/lib/utils/source-reader.js
+++ /dev/null
@@ -1,96 +0,0 @@
-var path = require('path');
-var rewriteUrls = require('../urls/rewrite');
-
-var REMOTE_RESOURCE = /^(https?:)?\/\//;
-
-function SourceReader(context, data) {
- this.outerContext = context;
- this.data = data;
- this.sources = {};
-}
-
-SourceReader.prototype.sourceAt = function (path) {
- return this.sources[path];
-};
-
-SourceReader.prototype.trackSource = function (path, source) {
- this.sources[path] = {};
- this.sources[path][path] = source;
-};
-
-SourceReader.prototype.toString = function () {
- if (typeof this.data == 'string')
- return fromString(this);
- if (Buffer.isBuffer(this.data))
- return fromBuffer(this);
- if (Array.isArray(this.data))
- return fromArray(this);
-
- return fromHash(this);
-};
-
-function fromString(self) {
- var data = self.data;
- self.trackSource(undefined, data);
- return data;
-}
-
-function fromBuffer(self) {
- var data = self.data.toString();
- self.trackSource(undefined, data);
- return data;
-}
-
-function fromArray(self) {
- return self.data
- .map(function (source) {
- return self.outerContext.options.processImport === false ?
- source + '@shallow' :
- source;
- })
- .map(function (source) {
- return !self.outerContext.options.relativeTo || /^https?:\/\//.test(source) ?
- source :
- path.relative(self.outerContext.options.relativeTo, source);
- })
- .map(function (source) { return '@import url(' + source + ');'; })
- .join('');
-}
-
-function fromHash(self) {
- var data = [];
- var toBase = path.resolve(self.outerContext.options.target || self.outerContext.options.root);
-
- for (var source in self.data) {
- var styles = self.data[source].styles;
- var inputSourceMap = self.data[source].sourceMap;
- var isRemote = REMOTE_RESOURCE.test(source);
- var absoluteSource = isRemote ? source : path.resolve(source);
- var absoluteSourcePath = path.dirname(absoluteSource);
-
- var rewriteOptions = {
- absolute: self.outerContext.options.explicitRoot,
- relative: !self.outerContext.options.explicitRoot,
- imports: true,
- rebase: self.outerContext.options.rebase,
- fromBase: absoluteSourcePath,
- toBase: isRemote ? absoluteSourcePath : toBase,
- urlQuotes: self.outerContext.options.compatibility.properties.urlQuotes
- };
- styles = rewriteUrls(styles, rewriteOptions, self.outerContext);
-
- self.trackSource(source, styles);
-
- styles = self.outerContext.sourceTracker.store(source, styles);
-
- // here we assume source map lies in the same directory as `source` does
- if (self.outerContext.options.sourceMap && inputSourceMap)
- self.outerContext.inputSourceMapTracker.trackLoaded(source, source, inputSourceMap);
-
- data.push(styles);
- }
-
- return data.join('');
-}
-
-module.exports = SourceReader;
diff --git a/api/node_modules/clean-css/lib/utils/source-tracker.js b/api/node_modules/clean-css/lib/utils/source-tracker.js
deleted file mode 100644
index 4cc9b6dab..000000000
--- a/api/node_modules/clean-css/lib/utils/source-tracker.js
+++ /dev/null
@@ -1,31 +0,0 @@
-function SourceTracker() {
- this.sources = [];
-}
-
-SourceTracker.prototype.store = function (filename, data) {
- this.sources.push(filename);
-
- return '__ESCAPED_SOURCE_CLEAN_CSS' + (this.sources.length - 1) + '__' +
- data +
- '__ESCAPED_SOURCE_END_CLEAN_CSS__';
-};
-
-SourceTracker.prototype.nextStart = function (data) {
- var next = /__ESCAPED_SOURCE_CLEAN_CSS(\d+)__/.exec(data);
-
- return next ?
- { index: next.index, filename: this.sources[~~next[1]] } :
- null;
-};
-
-SourceTracker.prototype.nextEnd = function (data) {
- return /__ESCAPED_SOURCE_END_CLEAN_CSS__/g.exec(data);
-};
-
-SourceTracker.prototype.removeAll = function (data) {
- return data
- .replace(/__ESCAPED_SOURCE_CLEAN_CSS\d+__/g, '')
- .replace(/__ESCAPED_SOURCE_END_CLEAN_CSS__/g, '');
-};
-
-module.exports = SourceTracker;
diff --git a/api/node_modules/clean-css/lib/utils/split.js b/api/node_modules/clean-css/lib/utils/split.js
deleted file mode 100644
index 6efc1ea0d..000000000
--- a/api/node_modules/clean-css/lib/utils/split.js
+++ /dev/null
@@ -1,62 +0,0 @@
-function split(value, separator, includeSeparator, openLevel, closeLevel, firstOnly) {
- var withRegex = typeof separator != 'string';
- var hasSeparator = withRegex ?
- separator.test(value) :
- value.indexOf(separator);
-
- if (!hasSeparator)
- return [value];
-
- openLevel = openLevel || '(';
- closeLevel = closeLevel || ')';
-
- if (value.indexOf(openLevel) == -1 && !includeSeparator && !firstOnly)
- return value.split(separator);
-
- var BACKSLASH = '\\';
- var isEscaped = false;
- var wasEscaped = false;
- var level = 0;
- var cursor = 0;
- var lastStart = 0;
- var len = value.length;
- var tokens = [];
-
- while (cursor < len) {
- isEscaped = value[cursor] == BACKSLASH;
-
- if (wasEscaped) {
- // no-op
- } else
- if (value[cursor] == openLevel) {
- level++;
- } else if (value[cursor] == closeLevel) {
- level--;
- }
-
- if (!wasEscaped && level === 0 && cursor > 0 && cursor + 1 < len && (withRegex ? separator.test(value[cursor]) : value[cursor] == separator)) {
- tokens.push(value.substring(lastStart, cursor + (includeSeparator ? 1 : 0)));
- lastStart = cursor + 1;
-
- if (firstOnly && tokens.length == 1) {
- break;
- }
- }
-
- wasEscaped = isEscaped;
- cursor++;
- }
-
- if (lastStart < cursor + 1) {
- var lastValue = value.substring(lastStart);
- var lastCharacter = lastValue[lastValue.length - 1];
- if (!includeSeparator && (withRegex ? separator.test(lastCharacter) : lastCharacter == separator))
- lastValue = lastValue.substring(0, lastValue.length - 1);
-
- tokens.push(lastValue);
- }
-
- return tokens;
-}
-
-module.exports = split;
diff --git a/api/node_modules/clean-css/node_modules/commander/History.md b/api/node_modules/clean-css/node_modules/commander/History.md
deleted file mode 100644
index 7b8b2c494..000000000
--- a/api/node_modules/clean-css/node_modules/commander/History.md
+++ /dev/null
@@ -1,256 +0,0 @@
-
-2.8.1 / 2015-04-22
-==================
-
- * Back out `support multiline description` Close #396 #397
-
-
-
-2.8.0 / 2015-04-07
-==================
-
- * Add `process.execArg` support, execution args like `--harmony` will be passed to sub-commands #387 @DigitalIO @zhiyelee
- * Fix bug in Git-style sub-commands #372 @zhiyelee
- * Allow commands to be hidden from help #383 @tonylukasavage
- * When git-style sub-commands are in use, yet none are called, display help #382 @claylo
- * Add ability to specify arguments syntax for top-level command #258 @rrthomas
- * Support multiline descriptions #208 @zxqfox
-
-2.7.1 / 2015-03-11
-==================
-
- * Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367.
-
-2.7.0 / 2015-03-09
-==================
-
- * Fix git-style bug when installed globally. Close #335 #349 @zhiyelee
- * Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage
- * Add support for camelCase on `opts()`. Close #353 @nkzawa
- * Add node.js 0.12 and io.js to travis.yml
- * Allow RegEx options. #337 @palanik
- * Fixes exit code when sub-command failing. Close #260 #332 @pirelenito
- * git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee
-
-2.6.0 / 2014-12-30
-==================
-
- * added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
- * Add application description to the help msg. Close #112 @dalssoft
-
-2.5.1 / 2014-12-15
-==================
-
- * fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
-
-2.5.0 / 2014-10-24
-==================
-
- * add support for variadic arguments. Closes #277 @whitlockjc
-
-2.4.0 / 2014-10-17
-==================
-
- * fixed a bug on executing the coercion function of subcommands option. Closes #270
- * added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
- * added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
- * fixed a bug on subcommand name. Closes #248 @jonathandelgado
- * fixed function normalize doesn’t honor option terminator. Closes #216 @abbr
-
-2.3.0 / 2014-07-16
-==================
-
- * add command alias'. Closes PR #210
- * fix: Typos. Closes #99
- * fix: Unused fs module. Closes #217
-
-2.2.0 / 2014-03-29
-==================
-
- * add passing of previous option value
- * fix: support subcommands on windows. Closes #142
- * Now the defaultValue passed as the second argument of the coercion function.
-
-2.1.0 / 2013-11-21
-==================
-
- * add: allow cflag style option params, unit test, fixes #174
-
-2.0.0 / 2013-07-18
-==================
-
- * remove input methods (.prompt, .confirm, etc)
-
-1.3.2 / 2013-07-18
-==================
-
- * add support for sub-commands to co-exist with the original command
-
-1.3.1 / 2013-07-18
-==================
-
- * add quick .runningCommand hack so you can opt-out of other logic when running a sub command
-
-1.3.0 / 2013-07-09
-==================
-
- * add EACCES error handling
- * fix sub-command --help
-
-1.2.0 / 2013-06-13
-==================
-
- * allow "-" hyphen as an option argument
- * support for RegExp coercion
-
-1.1.1 / 2012-11-20
-==================
-
- * add more sub-command padding
- * fix .usage() when args are present. Closes #106
-
-1.1.0 / 2012-11-16
-==================
-
- * add git-style executable subcommand support. Closes #94
-
-1.0.5 / 2012-10-09
-==================
-
- * fix `--name` clobbering. Closes #92
- * fix examples/help. Closes #89
-
-1.0.4 / 2012-09-03
-==================
-
- * add `outputHelp()` method.
-
-1.0.3 / 2012-08-30
-==================
-
- * remove invalid .version() defaulting
-
-1.0.2 / 2012-08-24
-==================
-
- * add `--foo=bar` support [arv]
- * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
-
-1.0.1 / 2012-08-03
-==================
-
- * fix issue #56
- * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
-
-1.0.0 / 2012-07-05
-==================
-
- * add support for optional option descriptions
- * add defaulting of `.version()` to package.json's version
-
-0.6.1 / 2012-06-01
-==================
-
- * Added: append (yes or no) on confirmation
- * Added: allow node.js v0.7.x
-
-0.6.0 / 2012-04-10
-==================
-
- * Added `.prompt(obj, callback)` support. Closes #49
- * Added default support to .choose(). Closes #41
- * Fixed the choice example
-
-0.5.1 / 2011-12-20
-==================
-
- * Fixed `password()` for recent nodes. Closes #36
-
-0.5.0 / 2011-12-04
-==================
-
- * Added sub-command option support [itay]
-
-0.4.3 / 2011-12-04
-==================
-
- * Fixed custom help ordering. Closes #32
-
-0.4.2 / 2011-11-24
-==================
-
- * Added travis support
- * Fixed: line-buffered input automatically trimmed. Closes #31
-
-0.4.1 / 2011-11-18
-==================
-
- * Removed listening for "close" on --help
-
-0.4.0 / 2011-11-15
-==================
-
- * Added support for `--`. Closes #24
-
-0.3.3 / 2011-11-14
-==================
-
- * Fixed: wait for close event when writing help info [Jerry Hamlet]
-
-0.3.2 / 2011-11-01
-==================
-
- * Fixed long flag definitions with values [felixge]
-
-0.3.1 / 2011-10-31
-==================
-
- * Changed `--version` short flag to `-V` from `-v`
- * Changed `.version()` so it's configurable [felixge]
-
-0.3.0 / 2011-10-31
-==================
-
- * Added support for long flags only. Closes #18
-
-0.2.1 / 2011-10-24
-==================
-
- * "node": ">= 0.4.x < 0.7.0". Closes #20
-
-0.2.0 / 2011-09-26
-==================
-
- * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
-
-0.1.0 / 2011-08-24
-==================
-
- * Added support for custom `--help` output
-
-0.0.5 / 2011-08-18
-==================
-
- * Changed: when the user enters nothing prompt for password again
- * Fixed issue with passwords beginning with numbers [NuckChorris]
-
-0.0.4 / 2011-08-15
-==================
-
- * Fixed `Commander#args`
-
-0.0.3 / 2011-08-15
-==================
-
- * Added default option value support
-
-0.0.2 / 2011-08-15
-==================
-
- * Added mask support to `Command#password(str[, mask], fn)`
- * Added `Command#password(str, fn)`
-
-0.0.1 / 2010-01-03
-==================
-
- * Initial release
diff --git a/api/node_modules/clean-css/node_modules/commander/LICENSE b/api/node_modules/clean-css/node_modules/commander/LICENSE
deleted file mode 100644
index 10f997ab1..000000000
--- a/api/node_modules/clean-css/node_modules/commander/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-(The MIT License)
-
-Copyright (c) 2011 TJ Holowaychuk
-
-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.
diff --git a/api/node_modules/clean-css/node_modules/commander/Readme.md b/api/node_modules/clean-css/node_modules/commander/Readme.md
deleted file mode 100644
index af58e22c9..000000000
--- a/api/node_modules/clean-css/node_modules/commander/Readme.md
+++ /dev/null
@@ -1,342 +0,0 @@
-# Commander.js
-
-
-[![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js)
-[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
-[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
-[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-
- The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).
- [API documentation](http://tj.github.com/commander.js/)
-
-
-## Installation
-
- $ npm install commander
-
-## Option parsing
-
- Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-p, --peppers', 'Add peppers')
- .option('-P, --pineapple', 'Add pineapple')
- .option('-b, --bbq-sauce', 'Add bbq sauce')
- .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
- .parse(process.argv);
-
-console.log('you ordered a pizza with:');
-if (program.peppers) console.log(' - peppers');
-if (program.pineapple) console.log(' - pineapple');
-if (program.bbqSauce) console.log(' - bbq');
-console.log(' - %s cheese', program.cheese);
-```
-
- Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
-
-
-## Coercion
-
-```js
-function range(val) {
- return val.split('..').map(Number);
-}
-
-function list(val) {
- return val.split(',');
-}
-
-function collect(val, memo) {
- memo.push(val);
- return memo;
-}
-
-function increaseVerbosity(v, total) {
- return total + 1;
-}
-
-program
- .version('0.0.1')
- .usage('[options] ')
- .option('-i, --integer ', 'An integer argument', parseInt)
- .option('-f, --float ', 'A float argument', parseFloat)
- .option('-r, --range ..', 'A range', range)
- .option('-l, --list ', 'A list', list)
- .option('-o, --optional [value]', 'An optional value')
- .option('-c, --collect [value]', 'A repeatable value', collect, [])
- .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
- .parse(process.argv);
-
-console.log(' int: %j', program.integer);
-console.log(' float: %j', program.float);
-console.log(' optional: %j', program.optional);
-program.range = program.range || [];
-console.log(' range: %j..%j', program.range[0], program.range[1]);
-console.log(' list: %j', program.list);
-console.log(' collect: %j', program.collect);
-console.log(' verbosity: %j', program.verbose);
-console.log(' args: %j', program.args);
-```
-
-## Regular Expression
-```js
-program
- .version('0.0.1')
- .option('-s --size ', 'Pizza size', /^(large|medium|small)$/i, 'medium')
- .option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
- .parse(process.argv);
-
-console.log(' size: %j', program.size);
-console.log(' drink: %j', program.drink);
-```
-
-## Variadic arguments
-
- The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
- append `...` to the argument name. Here is an example:
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .command('rmdir [otherDirs...]')
- .action(function (dir, otherDirs) {
- console.log('rmdir %s', dir);
- if (otherDirs) {
- otherDirs.forEach(function (oDir) {
- console.log('rmdir %s', oDir);
- });
- }
- });
-
-program.parse(process.argv);
-```
-
- An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
- to your action as demonstrated above.
-
-## Specify the argument syntax
-
-```js
-#!/usr/bin/env node
-
-var program = require('../');
-
-program
- .version('0.0.1')
- .arguments(' [env]')
- .action(function (cmd, env) {
- cmdValue = cmd;
- envValue = env;
- });
-
-program.parse(process.argv);
-
-if (typeof cmdValue === 'undefined') {
- console.error('no command given!');
- process.exit(1);
-}
-console.log('command:', cmdValue);
-console.log('environment:', envValue || "no environment given");
-```
-
-## Git-style sub-commands
-
-```js
-// file: ./examples/pm
-var program = require('..');
-
-program
- .version('0.0.1')
- .command('install [name]', 'install one or more packages')
- .command('search [query]', 'search with optional query')
- .command('list', 'list packages installed')
- .parse(process.argv);
-```
-
-When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
-The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
-
-If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
-
-### `--harmony`
-
-You can enable `--harmony` option in two ways:
-* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version don’t support this pattern.
-* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.
-
-## Automated --help
-
- The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
-
-```
- $ ./examples/pizza --help
-
- Usage: pizza [options]
-
- An application for pizzas ordering
-
- Options:
-
- -h, --help output usage information
- -V, --version output the version number
- -p, --peppers Add peppers
- -P, --pineapple Add pineapple
- -b, --bbq Add bbq sauce
- -c, --cheese Add the specified type of cheese [marble]
- -C, --no-cheese You do not want any cheese
-
-```
-
-## Custom help
-
- You can display arbitrary `-h, --help` information
- by listening for "--help". Commander will automatically
- exit once you are done so that the remainder of your program
- does not execute causing undesired behaviours, for example
- in the following executable "stuff" will not output when
- `--help` is used.
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-f, --foo', 'enable some foo')
- .option('-b, --bar', 'enable some bar')
- .option('-B, --baz', 'enable some baz');
-
-// must be before .parse() since
-// node's emit() is immediate
-
-program.on('--help', function(){
- console.log(' Examples:');
- console.log('');
- console.log(' $ custom-help --help');
- console.log(' $ custom-help -h');
- console.log('');
-});
-
-program.parse(process.argv);
-
-console.log('stuff');
-```
-
-Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
-
-```
-
-Usage: custom-help [options]
-
-Options:
-
- -h, --help output usage information
- -V, --version output the version number
- -f, --foo enable some foo
- -b, --bar enable some bar
- -B, --baz enable some baz
-
-Examples:
-
- $ custom-help --help
- $ custom-help -h
-
-```
-
-## .outputHelp()
-
-Output help information without exiting.
-
-If you want to display help by default (e.g. if no command was provided), you can use something like:
-
-```js
-var program = require('commander');
-
-program
- .version('0.0.1')
- .command('getstream [url]', 'get stream URL')
- .parse(process.argv);
-
- if (!process.argv.slice(2).length) {
- program.outputHelp();
- }
-```
-
-## .help()
-
- Output help information and exit immediately.
-
-## Examples
-
-```js
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-C, --chdir ', 'change the working directory')
- .option('-c, --config ', 'set config path. defaults to ./deploy.conf')
- .option('-T, --no-tests', 'ignore test hook')
-
-program
- .command('setup [env]')
- .description('run setup commands for all envs')
- .option("-s, --setup_mode [mode]", "Which setup mode to use")
- .action(function(env, options){
- var mode = options.setup_mode || "normal";
- env = env || 'all';
- console.log('setup for %s env(s) with %s mode', env, mode);
- });
-
-program
- .command('exec ')
- .alias('ex')
- .description('execute the given remote cmd')
- .option("-e, --exec_mode ", "Which exec mode to use")
- .action(function(cmd, options){
- console.log('exec "%s" using %s mode', cmd, options.exec_mode);
- }).on('--help', function() {
- console.log(' Examples:');
- console.log();
- console.log(' $ deploy exec sequential');
- console.log(' $ deploy exec async');
- console.log();
- });
-
-program
- .command('*')
- .action(function(env){
- console.log('deploying "%s"', env);
- });
-
-program.parse(process.argv);
-```
-
-More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
-
-## License
-
-MIT
-
diff --git a/api/node_modules/clean-css/node_modules/commander/index.js b/api/node_modules/clean-css/node_modules/commander/index.js
deleted file mode 100644
index 877696565..000000000
--- a/api/node_modules/clean-css/node_modules/commander/index.js
+++ /dev/null
@@ -1,1103 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var EventEmitter = require('events').EventEmitter;
-var spawn = require('child_process').spawn;
-var readlink = require('graceful-readlink').readlinkSync;
-var path = require('path');
-var dirname = path.dirname;
-var basename = path.basename;
-var fs = require('fs');
-
-/**
- * Expose the root command.
- */
-
-exports = module.exports = new Command();
-
-/**
- * Expose `Command`.
- */
-
-exports.Command = Command;
-
-/**
- * Expose `Option`.
- */
-
-exports.Option = Option;
-
-/**
- * Initialize a new `Option` with the given `flags` and `description`.
- *
- * @param {String} flags
- * @param {String} description
- * @api public
- */
-
-function Option(flags, description) {
- this.flags = flags;
- this.required = ~flags.indexOf('<');
- this.optional = ~flags.indexOf('[');
- this.bool = !~flags.indexOf('-no-');
- flags = flags.split(/[ ,|]+/);
- if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
- this.long = flags.shift();
- this.description = description || '';
-}
-
-/**
- * Return option name.
- *
- * @return {String}
- * @api private
- */
-
-Option.prototype.name = function() {
- return this.long
- .replace('--', '')
- .replace('no-', '');
-};
-
-/**
- * Check if `arg` matches the short or long flag.
- *
- * @param {String} arg
- * @return {Boolean}
- * @api private
- */
-
-Option.prototype.is = function(arg) {
- return arg == this.short || arg == this.long;
-};
-
-/**
- * Initialize a new `Command`.
- *
- * @param {String} name
- * @api public
- */
-
-function Command(name) {
- this.commands = [];
- this.options = [];
- this._execs = [];
- this._allowUnknownOption = false;
- this._args = [];
- this._name = name;
-}
-
-/**
- * Inherit from `EventEmitter.prototype`.
- */
-
-Command.prototype.__proto__ = EventEmitter.prototype;
-
-/**
- * Add command `name`.
- *
- * The `.action()` callback is invoked when the
- * command `name` is specified via __ARGV__,
- * and the remaining arguments are applied to the
- * function for access.
- *
- * When the `name` is "*" an un-matched command
- * will be passed as the first arg, followed by
- * the rest of __ARGV__ remaining.
- *
- * Examples:
- *
- * program
- * .version('0.0.1')
- * .option('-C, --chdir ', 'change the working directory')
- * .option('-c, --config ', 'set config path. defaults to ./deploy.conf')
- * .option('-T, --no-tests', 'ignore test hook')
- *
- * program
- * .command('setup')
- * .description('run remote setup commands')
- * .action(function() {
- * console.log('setup');
- * });
- *
- * program
- * .command('exec ')
- * .description('run the given remote command')
- * .action(function(cmd) {
- * console.log('exec "%s"', cmd);
- * });
- *
- * program
- * .command('teardown [otherDirs...]')
- * .description('run teardown commands')
- * .action(function(dir, otherDirs) {
- * console.log('dir "%s"', dir);
- * if (otherDirs) {
- * otherDirs.forEach(function (oDir) {
- * console.log('dir "%s"', oDir);
- * });
- * }
- * });
- *
- * program
- * .command('*')
- * .description('deploy the given env')
- * .action(function(env) {
- * console.log('deploying "%s"', env);
- * });
- *
- * program.parse(process.argv);
- *
- * @param {String} name
- * @param {String} [desc] for git-style sub-commands
- * @return {Command} the new command
- * @api public
- */
-
-Command.prototype.command = function(name, desc, opts) {
- opts = opts || {};
- var args = name.split(/ +/);
- var cmd = new Command(args.shift());
-
- if (desc) {
- cmd.description(desc);
- this.executables = true;
- this._execs[cmd._name] = true;
- }
-
- cmd._noHelp = !!opts.noHelp;
- this.commands.push(cmd);
- cmd.parseExpectedArgs(args);
- cmd.parent = this;
-
- if (desc) return this;
- return cmd;
-};
-
-/**
- * Define argument syntax for the top-level command.
- *
- * @api public
- */
-
-Command.prototype.arguments = function (desc) {
- return this.parseExpectedArgs(desc.split(/ +/));
-}
-
-/**
- * Add an implicit `help [cmd]` subcommand
- * which invokes `--help` for the given command.
- *
- * @api private
- */
-
-Command.prototype.addImplicitHelpCommand = function() {
- this.command('help [cmd]', 'display help for [cmd]');
-};
-
-/**
- * Parse expected `args`.
- *
- * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
- *
- * @param {Array} args
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.parseExpectedArgs = function(args) {
- if (!args.length) return;
- var self = this;
- args.forEach(function(arg) {
- var argDetails = {
- required: false,
- name: '',
- variadic: false
- };
-
- switch (arg[0]) {
- case '<':
- argDetails.required = true;
- argDetails.name = arg.slice(1, -1);
- break;
- case '[':
- argDetails.name = arg.slice(1, -1);
- break;
- }
-
- if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
- argDetails.variadic = true;
- argDetails.name = argDetails.name.slice(0, -3);
- }
- if (argDetails.name) {
- self._args.push(argDetails);
- }
- });
- return this;
-};
-
-/**
- * Register callback `fn` for the command.
- *
- * Examples:
- *
- * program
- * .command('help')
- * .description('display verbose help')
- * .action(function() {
- * // output help here
- * });
- *
- * @param {Function} fn
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.action = function(fn) {
- var self = this;
- var listener = function(args, unknown) {
- // Parse any so-far unknown options
- args = args || [];
- unknown = unknown || [];
-
- var parsed = self.parseOptions(unknown);
-
- // Output help if necessary
- outputHelpIfNecessary(self, parsed.unknown);
-
- // If there are still any unknown options, then we simply
- // die, unless someone asked for help, in which case we give it
- // to them, and then we die.
- if (parsed.unknown.length > 0) {
- self.unknownOption(parsed.unknown[0]);
- }
-
- // Leftover arguments need to be pushed back. Fixes issue #56
- if (parsed.args.length) args = parsed.args.concat(args);
-
- self._args.forEach(function(arg, i) {
- if (arg.required && null == args[i]) {
- self.missingArgument(arg.name);
- } else if (arg.variadic) {
- if (i !== self._args.length - 1) {
- self.variadicArgNotLast(arg.name);
- }
-
- args[i] = args.splice(i);
- }
- });
-
- // Always append ourselves to the end of the arguments,
- // to make sure we match the number of arguments the user
- // expects
- if (self._args.length) {
- args[self._args.length] = self;
- } else {
- args.push(self);
- }
-
- fn.apply(self, args);
- };
- var parent = this.parent || this;
- var name = parent === this ? '*' : this._name;
- parent.on(name, listener);
- if (this._alias) parent.on(this._alias, listener);
- return this;
-};
-
-/**
- * Define option with `flags`, `description` and optional
- * coercion `fn`.
- *
- * The `flags` string should contain both the short and long flags,
- * separated by comma, a pipe or space. The following are all valid
- * all will output this way when `--help` is used.
- *
- * "-p, --pepper"
- * "-p|--pepper"
- * "-p --pepper"
- *
- * Examples:
- *
- * // simple boolean defaulting to false
- * program.option('-p, --pepper', 'add pepper');
- *
- * --pepper
- * program.pepper
- * // => Boolean
- *
- * // simple boolean defaulting to true
- * program.option('-C, --no-cheese', 'remove cheese');
- *
- * program.cheese
- * // => true
- *
- * --no-cheese
- * program.cheese
- * // => false
- *
- * // required argument
- * program.option('-C, --chdir ', 'change the working directory');
- *
- * --chdir /tmp
- * program.chdir
- * // => "/tmp"
- *
- * // optional argument
- * program.option('-c, --cheese [type]', 'add cheese [marble]');
- *
- * @param {String} flags
- * @param {String} description
- * @param {Function|Mixed} fn or default
- * @param {Mixed} defaultValue
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.option = function(flags, description, fn, defaultValue) {
- var self = this
- , option = new Option(flags, description)
- , oname = option.name()
- , name = camelcase(oname);
-
- // default as 3rd arg
- if (typeof fn != 'function') {
- if (fn instanceof RegExp) {
- var regex = fn;
- fn = function(val, def) {
- var m = regex.exec(val);
- return m ? m[0] : def;
- }
- }
- else {
- defaultValue = fn;
- fn = null;
- }
- }
-
- // preassign default value only for --no-*, [optional], or
- if (false == option.bool || option.optional || option.required) {
- // when --no-* we make sure default is true
- if (false == option.bool) defaultValue = true;
- // preassign only if we have a default
- if (undefined !== defaultValue) self[name] = defaultValue;
- }
-
- // register the option
- this.options.push(option);
-
- // when it's passed assign the value
- // and conditionally invoke the callback
- this.on(oname, function(val) {
- // coercion
- if (null !== val && fn) val = fn(val, undefined === self[name]
- ? defaultValue
- : self[name]);
-
- // unassigned or bool
- if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) {
- // if no value, bool true, and we have a default, then use it!
- if (null == val) {
- self[name] = option.bool
- ? defaultValue || true
- : false;
- } else {
- self[name] = val;
- }
- } else if (null !== val) {
- // reassign
- self[name] = val;
- }
- });
-
- return this;
-};
-
-/**
- * Allow unknown options on the command line.
- *
- * @param {Boolean} arg if `true` or omitted, no error will be thrown
- * for unknown options.
- * @api public
- */
-Command.prototype.allowUnknownOption = function(arg) {
- this._allowUnknownOption = arguments.length === 0 || arg;
- return this;
-};
-
-/**
- * Parse `argv`, settings options and invoking commands when defined.
- *
- * @param {Array} argv
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.parse = function(argv) {
- // implicit help
- if (this.executables) this.addImplicitHelpCommand();
-
- // store raw args
- this.rawArgs = argv;
-
- // guess name
- this._name = this._name || basename(argv[1], '.js');
-
- // github-style sub-commands with no sub-command
- if (this.executables && argv.length < 3) {
- // this user needs help
- argv.push('--help');
- }
-
- // process argv
- var parsed = this.parseOptions(this.normalize(argv.slice(2)));
- var args = this.args = parsed.args;
-
- var result = this.parseArgs(this.args, parsed.unknown);
-
- // executable sub-commands
- var name = result.args[0];
- if (this._execs[name] && typeof this._execs[name] != "function") {
- return this.executeSubCommand(argv, args, parsed.unknown);
- }
-
- return result;
-};
-
-/**
- * Execute a sub-command executable.
- *
- * @param {Array} argv
- * @param {Array} args
- * @param {Array} unknown
- * @api private
- */
-
-Command.prototype.executeSubCommand = function(argv, args, unknown) {
- args = args.concat(unknown);
-
- if (!args.length) this.help();
- if ('help' == args[0] && 1 == args.length) this.help();
-
- // --help
- if ('help' == args[0]) {
- args[0] = args[1];
- args[1] = '--help';
- }
-
- // executable
- var f = argv[1];
- // name of the subcommand, link `pm-install`
- var bin = basename(f, '.js') + '-' + args[0];
-
-
- // In case of globally installed, get the base dir where executable
- // subcommand file should be located at
- var baseDir
- , link = readlink(f);
-
- // when symbolink is relative path
- if (link !== f && link.charAt(0) !== '/') {
- link = path.join(dirname(f), link)
- }
- baseDir = dirname(link);
-
- // prefer local `./` to bin in the $PATH
- var localBin = path.join(baseDir, bin);
-
- // whether bin file is a js script with explicit `.js` extension
- var isExplicitJS = false;
- if (exists(localBin + '.js')) {
- bin = localBin + '.js';
- isExplicitJS = true;
- } else if (exists(localBin)) {
- bin = localBin;
- }
-
- args = args.slice(1);
-
- var proc;
- if (process.platform !== 'win32') {
- if (isExplicitJS) {
- args.unshift(localBin);
- // add executable arguments to spawn
- args = (process.execArgv || []).concat(args);
-
- proc = spawn('node', args, { stdio: 'inherit', customFds: [0, 1, 2] });
- } else {
- proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
- }
- } else {
- args.unshift(localBin);
- proc = spawn(process.execPath, args, { stdio: 'inherit'});
- }
-
- proc.on('close', process.exit.bind(process));
- proc.on('error', function(err) {
- if (err.code == "ENOENT") {
- console.error('\n %s(1) does not exist, try --help\n', bin);
- } else if (err.code == "EACCES") {
- console.error('\n %s(1) not executable. try chmod or run with root\n', bin);
- }
- process.exit(1);
- });
-
- this.runningCommand = proc;
-};
-
-/**
- * Normalize `args`, splitting joined short flags. For example
- * the arg "-abc" is equivalent to "-a -b -c".
- * This also normalizes equal sign and splits "--abc=def" into "--abc def".
- *
- * @param {Array} args
- * @return {Array}
- * @api private
- */
-
-Command.prototype.normalize = function(args) {
- var ret = []
- , arg
- , lastOpt
- , index;
-
- for (var i = 0, len = args.length; i < len; ++i) {
- arg = args[i];
- if (i > 0) {
- lastOpt = this.optionFor(args[i-1]);
- }
-
- if (arg === '--') {
- // Honor option terminator
- ret = ret.concat(args.slice(i));
- break;
- } else if (lastOpt && lastOpt.required) {
- ret.push(arg);
- } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
- arg.slice(1).split('').forEach(function(c) {
- ret.push('-' + c);
- });
- } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {
- ret.push(arg.slice(0, index), arg.slice(index + 1));
- } else {
- ret.push(arg);
- }
- }
-
- return ret;
-};
-
-/**
- * Parse command `args`.
- *
- * When listener(s) are available those
- * callbacks are invoked, otherwise the "*"
- * event is emitted and those actions are invoked.
- *
- * @param {Array} args
- * @return {Command} for chaining
- * @api private
- */
-
-Command.prototype.parseArgs = function(args, unknown) {
- var name;
-
- if (args.length) {
- name = args[0];
- if (this.listeners(name).length) {
- this.emit(args.shift(), args, unknown);
- } else {
- this.emit('*', args);
- }
- } else {
- outputHelpIfNecessary(this, unknown);
-
- // If there were no args and we have unknown options,
- // then they are extraneous and we need to error.
- if (unknown.length > 0) {
- this.unknownOption(unknown[0]);
- }
- }
-
- return this;
-};
-
-/**
- * Return an option matching `arg` if any.
- *
- * @param {String} arg
- * @return {Option}
- * @api private
- */
-
-Command.prototype.optionFor = function(arg) {
- for (var i = 0, len = this.options.length; i < len; ++i) {
- if (this.options[i].is(arg)) {
- return this.options[i];
- }
- }
-};
-
-/**
- * Parse options from `argv` returning `argv`
- * void of these options.
- *
- * @param {Array} argv
- * @return {Array}
- * @api public
- */
-
-Command.prototype.parseOptions = function(argv) {
- var args = []
- , len = argv.length
- , literal
- , option
- , arg;
-
- var unknownOptions = [];
-
- // parse options
- for (var i = 0; i < len; ++i) {
- arg = argv[i];
-
- // literal args after --
- if ('--' == arg) {
- literal = true;
- continue;
- }
-
- if (literal) {
- args.push(arg);
- continue;
- }
-
- // find matching Option
- option = this.optionFor(arg);
-
- // option is defined
- if (option) {
- // requires arg
- if (option.required) {
- arg = argv[++i];
- if (null == arg) return this.optionMissingArgument(option);
- this.emit(option.name(), arg);
- // optional arg
- } else if (option.optional) {
- arg = argv[i+1];
- if (null == arg || ('-' == arg[0] && '-' != arg)) {
- arg = null;
- } else {
- ++i;
- }
- this.emit(option.name(), arg);
- // bool
- } else {
- this.emit(option.name());
- }
- continue;
- }
-
- // looks like an option
- if (arg.length > 1 && '-' == arg[0]) {
- unknownOptions.push(arg);
-
- // If the next argument looks like it might be
- // an argument for this option, we pass it on.
- // If it isn't, then it'll simply be ignored
- if (argv[i+1] && '-' != argv[i+1][0]) {
- unknownOptions.push(argv[++i]);
- }
- continue;
- }
-
- // arg
- args.push(arg);
- }
-
- return { args: args, unknown: unknownOptions };
-};
-
-/**
- * Return an object containing options as key-value pairs
- *
- * @return {Object}
- * @api public
- */
-Command.prototype.opts = function() {
- var result = {}
- , len = this.options.length;
-
- for (var i = 0 ; i < len; i++) {
- var key = camelcase(this.options[i].name());
- result[key] = key === 'version' ? this._version : this[key];
- }
- return result;
-};
-
-/**
- * Argument `name` is missing.
- *
- * @param {String} name
- * @api private
- */
-
-Command.prototype.missingArgument = function(name) {
- console.error();
- console.error(" error: missing required argument `%s'", name);
- console.error();
- process.exit(1);
-};
-
-/**
- * `Option` is missing an argument, but received `flag` or nothing.
- *
- * @param {String} option
- * @param {String} flag
- * @api private
- */
-
-Command.prototype.optionMissingArgument = function(option, flag) {
- console.error();
- if (flag) {
- console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag);
- } else {
- console.error(" error: option `%s' argument missing", option.flags);
- }
- console.error();
- process.exit(1);
-};
-
-/**
- * Unknown option `flag`.
- *
- * @param {String} flag
- * @api private
- */
-
-Command.prototype.unknownOption = function(flag) {
- if (this._allowUnknownOption) return;
- console.error();
- console.error(" error: unknown option `%s'", flag);
- console.error();
- process.exit(1);
-};
-
-/**
- * Variadic argument with `name` is not the last argument as required.
- *
- * @param {String} name
- * @api private
- */
-
-Command.prototype.variadicArgNotLast = function(name) {
- console.error();
- console.error(" error: variadic arguments must be last `%s'", name);
- console.error();
- process.exit(1);
-};
-
-/**
- * Set the program version to `str`.
- *
- * This method auto-registers the "-V, --version" flag
- * which will print the version number when passed.
- *
- * @param {String} str
- * @param {String} flags
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.version = function(str, flags) {
- if (0 == arguments.length) return this._version;
- this._version = str;
- flags = flags || '-V, --version';
- this.option(flags, 'output the version number');
- this.on('version', function() {
- process.stdout.write(str + '\n');
- process.exit(0);
- });
- return this;
-};
-
-/**
- * Set the description to `str`.
- *
- * @param {String} str
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.description = function(str) {
- if (0 == arguments.length) return this._description;
- this._description = str;
- return this;
-};
-
-/**
- * Set an alias for the command
- *
- * @param {String} alias
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.alias = function(alias) {
- if (0 == arguments.length) return this._alias;
- this._alias = alias;
- return this;
-};
-
-/**
- * Set / get the command usage `str`.
- *
- * @param {String} str
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.usage = function(str) {
- var args = this._args.map(function(arg) {
- return humanReadableArgName(arg);
- });
-
- var usage = '[options]'
- + (this.commands.length ? ' [command]' : '')
- + (this._args.length ? ' ' + args.join(' ') : '');
-
- if (0 == arguments.length) return this._usage || usage;
- this._usage = str;
-
- return this;
-};
-
-/**
- * Get the name of the command
- *
- * @param {String} name
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.name = function() {
- return this._name;
-};
-
-/**
- * Return the largest option length.
- *
- * @return {Number}
- * @api private
- */
-
-Command.prototype.largestOptionLength = function() {
- return this.options.reduce(function(max, option) {
- return Math.max(max, option.flags.length);
- }, 0);
-};
-
-/**
- * Return help for options.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.optionHelp = function() {
- var width = this.largestOptionLength();
-
- // Prepend the help information
- return [pad('-h, --help', width) + ' ' + 'output usage information']
- .concat(this.options.map(function(option) {
- return pad(option.flags, width) + ' ' + option.description;
- }))
- .join('\n');
-};
-
-/**
- * Return command help documentation.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.commandHelp = function() {
- if (!this.commands.length) return '';
-
- var commands = this.commands.filter(function(cmd) {
- return !cmd._noHelp;
- }).map(function(cmd) {
- var args = cmd._args.map(function(arg) {
- return humanReadableArgName(arg);
- }).join(' ');
-
- return [
- cmd._name
- + (cmd._alias
- ? '|' + cmd._alias
- : '')
- + (cmd.options.length
- ? ' [options]'
- : '')
- + ' ' + args
- , cmd.description()
- ];
- });
-
- var width = commands.reduce(function(max, command) {
- return Math.max(max, command[0].length);
- }, 0);
-
- return [
- ''
- , ' Commands:'
- , ''
- , commands.map(function(cmd) {
- return pad(cmd[0], width) + ' ' + cmd[1];
- }).join('\n').replace(/^/gm, ' ')
- , ''
- ].join('\n');
-};
-
-/**
- * Return program help documentation.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.helpInformation = function() {
- var desc = [];
- if (this._description) {
- desc = [
- ' ' + this._description
- , ''
- ];
- }
-
- var cmdName = this._name;
- if (this._alias) {
- cmdName = cmdName + '|' + this._alias;
- }
- var usage = [
- ''
- ,' Usage: ' + cmdName + ' ' + this.usage()
- , ''
- ];
-
- var cmds = [];
- var commandHelp = this.commandHelp();
- if (commandHelp) cmds = [commandHelp];
-
- var options = [
- ' Options:'
- , ''
- , '' + this.optionHelp().replace(/^/gm, ' ')
- , ''
- , ''
- ];
-
- return usage
- .concat(cmds)
- .concat(desc)
- .concat(options)
- .join('\n');
-};
-
-/**
- * Output help information for this command
- *
- * @api public
- */
-
-Command.prototype.outputHelp = function() {
- process.stdout.write(this.helpInformation());
- this.emit('--help');
-};
-
-/**
- * Output help information and exit.
- *
- * @api public
- */
-
-Command.prototype.help = function() {
- this.outputHelp();
- process.exit();
-};
-
-/**
- * Camel-case the given `flag`
- *
- * @param {String} flag
- * @return {String}
- * @api private
- */
-
-function camelcase(flag) {
- return flag.split('-').reduce(function(str, word) {
- return str + word[0].toUpperCase() + word.slice(1);
- });
-}
-
-/**
- * Pad `str` to `width`.
- *
- * @param {String} str
- * @param {Number} width
- * @return {String}
- * @api private
- */
-
-function pad(str, width) {
- var len = Math.max(0, width - str.length);
- return str + Array(len + 1).join(' ');
-}
-
-/**
- * Output help information if necessary
- *
- * @param {Command} command to output help for
- * @param {Array} array of options to search for -h or --help
- * @api private
- */
-
-function outputHelpIfNecessary(cmd, options) {
- options = options || [];
- for (var i = 0; i < options.length; i++) {
- if (options[i] == '--help' || options[i] == '-h') {
- cmd.outputHelp();
- process.exit(0);
- }
- }
-}
-
-/**
- * Takes an argument an returns its human readable equivalent for help usage.
- *
- * @param {Object} arg
- * @return {String}
- * @api private
- */
-
-function humanReadableArgName(arg) {
- var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
-
- return arg.required
- ? '<' + nameOutput + '>'
- : '[' + nameOutput + ']'
-}
-
-// for versions before node v0.8 when there weren't `fs.existsSync`
-function exists(file) {
- try {
- if (fs.statSync(file).isFile()) {
- return true;
- }
- } catch (e) {
- return false;
- }
-}
-
diff --git a/api/node_modules/clean-css/node_modules/commander/package.json b/api/node_modules/clean-css/node_modules/commander/package.json
deleted file mode 100644
index 6c43ace4e..000000000
--- a/api/node_modules/clean-css/node_modules/commander/package.json
+++ /dev/null
@@ -1,65 +0,0 @@
-{
- "_from": "commander@2.8.x",
- "_id": "commander@2.8.1",
- "_inBundle": false,
- "_integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
- "_location": "/clean-css/commander",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "commander@2.8.x",
- "name": "commander",
- "escapedName": "commander",
- "rawSpec": "2.8.x",
- "saveSpec": null,
- "fetchSpec": "2.8.x"
- },
- "_requiredBy": [
- "/clean-css"
- ],
- "_resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
- "_shasum": "06be367febfda0c330aa1e2a072d3dc9762425d4",
- "_spec": "commander@2.8.x",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/clean-css",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bugs": {
- "url": "https://github.com/tj/commander.js/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "graceful-readlink": ">= 1.0.0"
- },
- "deprecated": false,
- "description": "the complete solution for node.js command-line programs",
- "devDependencies": {
- "should": ">= 0.0.1",
- "sinon": ">= 1.14.1"
- },
- "engines": {
- "node": ">= 0.6.x"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/tj/commander.js#readme",
- "keywords": [
- "command",
- "option",
- "parser"
- ],
- "license": "MIT",
- "main": "index",
- "name": "commander",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/tj/commander.js.git"
- },
- "scripts": {
- "test": "make test"
- },
- "version": "2.8.1"
-}
diff --git a/api/node_modules/clean-css/package.json b/api/node_modules/clean-css/package.json
deleted file mode 100644
index 3fc72dcae..000000000
--- a/api/node_modules/clean-css/package.json
+++ /dev/null
@@ -1,84 +0,0 @@
-{
- "_from": "clean-css@^3.1.9",
- "_id": "clean-css@3.4.28",
- "_inBundle": false,
- "_integrity": "sha1-vxlF6C/ICPVWlebd6uwBQA79A/8=",
- "_location": "/clean-css",
- "_phantomChildren": {
- "graceful-readlink": "1.0.1"
- },
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "clean-css@^3.1.9",
- "name": "clean-css",
- "escapedName": "clean-css",
- "rawSpec": "^3.1.9",
- "saveSpec": null,
- "fetchSpec": "^3.1.9"
- },
- "_requiredBy": [
- "/jade"
- ],
- "_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-3.4.28.tgz",
- "_shasum": "bf1945e82fc808f55695e6ddeaec01400efd03ff",
- "_spec": "clean-css@^3.1.9",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/jade",
- "author": {
- "name": "Jakub Pawlowicz",
- "email": "contact@jakubpawlowicz.com",
- "url": "http://twitter.com/jakubpawlowicz"
- },
- "bin": {
- "cleancss": "./bin/cleancss"
- },
- "bugs": {
- "url": "https://github.com/jakubpawlowicz/clean-css/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "commander": "2.8.x",
- "source-map": "0.4.x"
- },
- "deprecated": false,
- "description": "A well-tested CSS minifier",
- "devDependencies": {
- "browserify": "11.x",
- "http-proxy": "1.x",
- "jshint": "2.8.x",
- "nock": "2.x",
- "server-destroy": "1.x",
- "uglify-js": "2.4.x",
- "vows": "0.8.x"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "bin",
- "lib",
- "History.md",
- "index.js",
- "LICENSE"
- ],
- "homepage": "https://github.com/jakubpawlowicz/clean-css",
- "keywords": [
- "css",
- "minifier"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "clean-css",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jakubpawlowicz/clean-css.git"
- },
- "scripts": {
- "bench": "node ./test/bench.js",
- "browserify": "browserify --standalone CleanCSS index.js | uglifyjs --compress --mangle -o cleancss-browser.js",
- "check": "jshint ./bin/cleancss .",
- "prepublish": "npm run check",
- "test": "vows"
- },
- "version": "3.4.28"
-}
diff --git a/api/node_modules/cliui/.coveralls.yml b/api/node_modules/cliui/.coveralls.yml
deleted file mode 100644
index 73367dbd7..000000000
--- a/api/node_modules/cliui/.coveralls.yml
+++ /dev/null
@@ -1 +0,0 @@
-repo_token: NiRhyj91Z2vtgob6XdEAqs83rzNnbMZUu
diff --git a/api/node_modules/cliui/.npmignore b/api/node_modules/cliui/.npmignore
deleted file mode 100644
index 9daa8247d..000000000
--- a/api/node_modules/cliui/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.DS_Store
-node_modules
diff --git a/api/node_modules/cliui/.travis.yml b/api/node_modules/cliui/.travis.yml
deleted file mode 100644
index d96edf8ec..000000000
--- a/api/node_modules/cliui/.travis.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-language: node_js
-node_js:
- - "0.10"
- - "0.11"
- - "0.12"
- - "iojs"
-after_script: "NODE_ENV=test YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha --require patched-blanket --reporter mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js"
diff --git a/api/node_modules/cliui/LICENSE.txt b/api/node_modules/cliui/LICENSE.txt
deleted file mode 100644
index c7e27478a..000000000
--- a/api/node_modules/cliui/LICENSE.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-Copyright (c) 2015, Contributors
-
-Permission to use, copy, modify, and/or distribute this software
-for any purpose with or without fee is hereby granted, provided
-that the above copyright notice and this permission notice
-appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
-LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/api/node_modules/cliui/README.md b/api/node_modules/cliui/README.md
deleted file mode 100644
index edcafa8ed..000000000
--- a/api/node_modules/cliui/README.md
+++ /dev/null
@@ -1,104 +0,0 @@
-# cliui
-
-[![Build Status](https://travis-ci.org/bcoe/cliui.png)](https://travis-ci.org/bcoe/cliui)
-[![Coverage Status](https://coveralls.io/repos/bcoe/cliui/badge.svg?branch=)](https://coveralls.io/r/bcoe/cliui?branch=)
-[![NPM version](https://img.shields.io/npm/v/cliui.svg)](https://www.npmjs.com/package/cliui)
-
-easily create complex multi-column command-line-interfaces.
-
-## Example
-
-```js
-var ui = require('cliui')({
- width: 80
-})
-
-ui.div('Usage: $0 [command] [options]')
-
-ui.div({
- text: 'Options:',
- padding: [2, 0, 2, 0]
-})
-
-ui.div(
- {
- text: "-f, --file",
- width: 40,
- padding: [0, 4, 0, 4]
- },
- {
- text: "the file to load",
- width: 25
- },
- {
- text: "[required]",
- align: 'right'
- }
-)
-
-console.log(ui.toString())
-```
-
-## Layout DSL
-
-cliui exposes a simple layout DSL:
-
-If you create a single `ui.row`, passing a string rather than an
-object:
-
-* `\n`: characters will be interpreted as new rows.
-* `\t`: characters will be interpreted as new columns.
-* ` `: characters will be interpreted as padding.
-
-**as an example...**
-
-```js
-var ui = require('./')({
- width: 60
-})
-
-ui.div(
- 'Usage: node ./bin/foo.js\n' +
- ' \t provide a regex\n' +
- ' \t provide a glob\t [required]'
-)
-
-console.log(ui.toString())
-```
-
-**will output:**
-
-```shell
-Usage: node ./bin/foo.js
- provide a regex
- provide a glob [required]
-```
-
-## Methods
-
-```js
-cliui = require('cliui')
-```
-
-### cliui({width: integer})
-
-Specify the maximum width of the UI being generated.
-
-### cliui({wrap: boolean})
-
-Enable or disable the wrapping of text in a column.
-
-### cliui.div(column, column, column)
-
-Create a row with any number of columns, a column
-can either be a string, or an object with the following
-options:
-
-* **width:** the width of a column.
-* **align:** alignment, `right` or `center`.
-* **padding:** `[top, right, bottom, left]`.
-
-### cliui.span(column, column, column)
-
-Similar to `div`, except the next row will be appended without
-a new line being created.
diff --git a/api/node_modules/cliui/index.js b/api/node_modules/cliui/index.js
deleted file mode 100644
index 31b4aa7b7..000000000
--- a/api/node_modules/cliui/index.js
+++ /dev/null
@@ -1,273 +0,0 @@
-var wrap = require('wordwrap'),
- align = {
- right: require('right-align'),
- center: require('center-align')
- },
- top = 0,
- right = 1,
- bottom = 2,
- left = 3
-
-function UI (opts) {
- this.width = opts.width
- this.wrap = opts.wrap
- this.rows = []
-}
-
-UI.prototype.span = function () {
- var cols = this.div.apply(this, arguments)
- cols.span = true
-}
-
-UI.prototype.div = function () {
- if (arguments.length === 0) this.div('')
- if (this.wrap && this._shouldApplyLayoutDSL.apply(this, arguments)) {
- return this._applyLayoutDSL(arguments[0])
- }
-
- var cols = []
-
- for (var i = 0, arg; (arg = arguments[i]) !== undefined; i++) {
- if (typeof arg === 'string') cols.push(this._colFromString(arg))
- else cols.push(arg)
- }
-
- this.rows.push(cols)
- return cols
-}
-
-UI.prototype._shouldApplyLayoutDSL = function () {
- return arguments.length === 1 && typeof arguments[0] === 'string' &&
- /[\t\n]/.test(arguments[0])
-}
-
-UI.prototype._applyLayoutDSL = function (str) {
- var _this = this,
- rows = str.split('\n'),
- leftColumnWidth = 0
-
- // simple heuristic for layout, make sure the
- // second column lines up along the left-hand.
- // don't allow the first column to take up more
- // than 50% of the screen.
- rows.forEach(function (row) {
- var columns = row.split('\t')
- if (columns.length > 1 && columns[0].length > leftColumnWidth) {
- leftColumnWidth = Math.min(
- Math.floor(_this.width * 0.5),
- columns[0].length
- )
- }
- })
-
- // generate a table:
- // replacing ' ' with padding calculations.
- // using the algorithmically generated width.
- rows.forEach(function (row) {
- var columns = row.split('\t')
- _this.div.apply(_this, columns.map(function (r, i) {
- return {
- text: r.trim(),
- padding: [0, r.match(/\s*$/)[0].length, 0, r.match(/^\s*/)[0].length],
- width: (i === 0 && columns.length > 1) ? leftColumnWidth : undefined
- }
- }))
- })
-
- return this.rows[this.rows.length - 1]
-}
-
-UI.prototype._colFromString = function (str) {
- return {
- text: str
- }
-}
-
-UI.prototype.toString = function () {
- var _this = this,
- lines = []
-
- _this.rows.forEach(function (row, i) {
- _this.rowToString(row, lines)
- })
-
- // don't display any lines with the
- // hidden flag set.
- lines = lines.filter(function (line) {
- return !line.hidden
- })
-
- return lines.map(function (line) {
- return line.text
- }).join('\n')
-}
-
-UI.prototype.rowToString = function (row, lines) {
- var _this = this,
- paddingLeft,
- rrows = this._rasterize(row),
- str = '',
- ts,
- width,
- wrapWidth
-
- rrows.forEach(function (rrow, r) {
- str = ''
- rrow.forEach(function (col, c) {
- ts = '' // temporary string used during alignment/padding.
- width = row[c].width // the width with padding.
- wrapWidth = _this._negatePadding(row[c]) // the width without padding.
-
- for (var i = 0; i < Math.max(wrapWidth, col.length); i++) {
- ts += col.charAt(i) || ' '
- }
-
- // align the string within its column.
- if (row[c].align && row[c].align !== 'left' && _this.wrap) {
- ts = align[row[c].align](ts.trim() + '\n' + new Array(wrapWidth + 1).join(' '))
- .split('\n')[0]
- if (ts.length < wrapWidth) ts += new Array(width - ts.length).join(' ')
- }
-
- // add left/right padding and print string.
- paddingLeft = (row[c].padding || [0, 0, 0, 0])[left]
- if (paddingLeft) str += new Array(row[c].padding[left] + 1).join(' ')
- str += ts
- if (row[c].padding && row[c].padding[right]) str += new Array(row[c].padding[right] + 1).join(' ')
-
- // if prior row is span, try to render the
- // current row on the prior line.
- if (r === 0 && lines.length > 0) {
- str = _this._renderInline(str, lines[lines.length - 1], paddingLeft)
- }
- })
-
- // remove trailing whitespace.
- lines.push({
- text: str.replace(/ +$/, ''),
- span: row.span
- })
- })
-
- return lines
-}
-
-// if the full 'source' can render in
-// the target line, do so.
-UI.prototype._renderInline = function (source, previousLine, paddingLeft) {
- var target = previousLine.text,
- str = ''
-
- if (!previousLine.span) return source
-
- // if we're not applying wrapping logic,
- // just always append to the span.
- if (!this.wrap) {
- previousLine.hidden = true
- return target + source
- }
-
- for (var i = 0, tc, sc; i < Math.max(source.length, target.length); i++) {
- tc = target.charAt(i) || ' '
- sc = source.charAt(i) || ' '
- // we tried to overwrite a character in the other string.
- if (tc !== ' ' && sc !== ' ') return source
- // there is not enough whitespace to maintain padding.
- if (sc !== ' ' && i < paddingLeft + target.length) return source
- // :thumbsup:
- if (tc === ' ') str += sc
- else str += tc
- }
-
- previousLine.hidden = true
-
- return str
-}
-
-UI.prototype._rasterize = function (row) {
- var _this = this,
- i,
- rrow,
- rrows = [],
- widths = this._columnWidths(row),
- wrapped
-
- // word wrap all columns, and create
- // a data-structure that is easy to rasterize.
- row.forEach(function (col, c) {
- // leave room for left and right padding.
- col.width = widths[c]
- if (_this.wrap) wrapped = wrap.hard(_this._negatePadding(col))(col.text).split('\n')
- else wrapped = col.text.split('\n')
-
- // add top and bottom padding.
- if (col.padding) {
- for (i = 0; i < (col.padding[top] || 0); i++) wrapped.unshift('')
- for (i = 0; i < (col.padding[bottom] || 0); i++) wrapped.push('')
- }
-
- wrapped.forEach(function (str, r) {
- if (!rrows[r]) rrows.push([])
-
- rrow = rrows[r]
-
- for (var i = 0; i < c; i++) {
- if (rrow[i] === undefined) rrow.push('')
- }
- rrow.push(str)
- })
- })
-
- return rrows
-}
-
-UI.prototype._negatePadding = function (col) {
- var wrapWidth = col.width
- if (col.padding) wrapWidth -= (col.padding[left] || 0) + (col.padding[right] || 0)
- return wrapWidth
-}
-
-UI.prototype._columnWidths = function (row) {
- var _this = this,
- widths = [],
- unset = row.length,
- unsetWidth,
- remainingWidth = this.width
-
- // column widths can be set in config.
- row.forEach(function (col, i) {
- if (col.width) {
- unset--
- widths[i] = col.width
- remainingWidth -= col.width
- } else {
- widths[i] = undefined
- }
- })
-
- // any unset widths should be calculated.
- if (unset) unsetWidth = Math.floor(remainingWidth / unset)
- widths.forEach(function (w, i) {
- if (!_this.wrap) widths[i] = row[i].width || row[i].text.length
- else if (w === undefined) widths[i] = Math.max(unsetWidth, _minWidth(row[i]))
- })
-
- return widths
-}
-
-// calculates the minimum width of
-// a column, based on padding preferences.
-function _minWidth (col) {
- var padding = col.padding || []
-
- return 1 + (padding[left] || 0) + (padding[right] || 0)
-}
-
-module.exports = function (opts) {
- opts = opts || {}
-
- return new UI({
- width: (opts || {}).width || 80,
- wrap: typeof opts.wrap === 'boolean' ? opts.wrap : true
- })
-}
diff --git a/api/node_modules/cliui/node_modules/wordwrap/README.markdown b/api/node_modules/cliui/node_modules/wordwrap/README.markdown
deleted file mode 100644
index 346374e0d..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/README.markdown
+++ /dev/null
@@ -1,70 +0,0 @@
-wordwrap
-========
-
-Wrap your words.
-
-example
-=======
-
-made out of meat
-----------------
-
-meat.js
-
- var wrap = require('wordwrap')(15);
- console.log(wrap('You and your whole family are made out of meat.'));
-
-output:
-
- You and your
- whole family
- are made out
- of meat.
-
-centered
---------
-
-center.js
-
- var wrap = require('wordwrap')(20, 60);
- console.log(wrap(
- 'At long last the struggle and tumult was over.'
- + ' The machines had finally cast off their oppressors'
- + ' and were finally free to roam the cosmos.'
- + '\n'
- + 'Free of purpose, free of obligation.'
- + ' Just drifting through emptiness.'
- + ' The sun was just another point of light.'
- ));
-
-output:
-
- At long last the struggle and tumult
- was over. The machines had finally cast
- off their oppressors and were finally
- free to roam the cosmos.
- Free of purpose, free of obligation.
- Just drifting through emptiness. The
- sun was just another point of light.
-
-methods
-=======
-
-var wrap = require('wordwrap');
-
-wrap(stop), wrap(start, stop, params={mode:"soft"})
----------------------------------------------------
-
-Returns a function that takes a string and returns a new string.
-
-Pad out lines with spaces out to column `start` and then wrap until column
-`stop`. If a word is longer than `stop - start` characters it will overflow.
-
-In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are
-longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break
-up chunks longer than `stop - start`.
-
-wrap.hard(start, stop)
-----------------------
-
-Like `wrap()` but with `params.mode = "hard"`.
diff --git a/api/node_modules/cliui/node_modules/wordwrap/example/center.js b/api/node_modules/cliui/node_modules/wordwrap/example/center.js
deleted file mode 100644
index a3fbaae98..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/example/center.js
+++ /dev/null
@@ -1,10 +0,0 @@
-var wrap = require('wordwrap')(20, 60);
-console.log(wrap(
- 'At long last the struggle and tumult was over.'
- + ' The machines had finally cast off their oppressors'
- + ' and were finally free to roam the cosmos.'
- + '\n'
- + 'Free of purpose, free of obligation.'
- + ' Just drifting through emptiness.'
- + ' The sun was just another point of light.'
-));
diff --git a/api/node_modules/cliui/node_modules/wordwrap/example/meat.js b/api/node_modules/cliui/node_modules/wordwrap/example/meat.js
deleted file mode 100644
index a4665e105..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/example/meat.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var wrap = require('wordwrap')(15);
-
-console.log(wrap('You and your whole family are made out of meat.'));
diff --git a/api/node_modules/cliui/node_modules/wordwrap/index.js b/api/node_modules/cliui/node_modules/wordwrap/index.js
deleted file mode 100644
index c9bc94521..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/index.js
+++ /dev/null
@@ -1,76 +0,0 @@
-var wordwrap = module.exports = function (start, stop, params) {
- if (typeof start === 'object') {
- params = start;
- start = params.start;
- stop = params.stop;
- }
-
- if (typeof stop === 'object') {
- params = stop;
- start = start || params.start;
- stop = undefined;
- }
-
- if (!stop) {
- stop = start;
- start = 0;
- }
-
- if (!params) params = {};
- var mode = params.mode || 'soft';
- var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
-
- return function (text) {
- var chunks = text.toString()
- .split(re)
- .reduce(function (acc, x) {
- if (mode === 'hard') {
- for (var i = 0; i < x.length; i += stop - start) {
- acc.push(x.slice(i, i + stop - start));
- }
- }
- else acc.push(x)
- return acc;
- }, [])
- ;
-
- return chunks.reduce(function (lines, rawChunk) {
- if (rawChunk === '') return lines;
-
- var chunk = rawChunk.replace(/\t/g, ' ');
-
- var i = lines.length - 1;
- if (lines[i].length + chunk.length > stop) {
- lines[i] = lines[i].replace(/\s+$/, '');
-
- chunk.split(/\n/).forEach(function (c) {
- lines.push(
- new Array(start + 1).join(' ')
- + c.replace(/^\s+/, '')
- );
- });
- }
- else if (chunk.match(/\n/)) {
- var xs = chunk.split(/\n/);
- lines[i] += xs.shift();
- xs.forEach(function (c) {
- lines.push(
- new Array(start + 1).join(' ')
- + c.replace(/^\s+/, '')
- );
- });
- }
- else {
- lines[i] += chunk;
- }
-
- return lines;
- }, [ new Array(start + 1).join(' ') ]).join('\n');
- };
-};
-
-wordwrap.soft = wordwrap;
-
-wordwrap.hard = function (start, stop) {
- return wordwrap(start, stop, { mode : 'hard' });
-};
diff --git a/api/node_modules/cliui/node_modules/wordwrap/package.json b/api/node_modules/cliui/node_modules/wordwrap/package.json
deleted file mode 100644
index 8972d8c84..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/package.json
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- "_from": "wordwrap@0.0.2",
- "_id": "wordwrap@0.0.2",
- "_inBundle": false,
- "_integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=",
- "_location": "/cliui/wordwrap",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "wordwrap@0.0.2",
- "name": "wordwrap",
- "escapedName": "wordwrap",
- "rawSpec": "0.0.2",
- "saveSpec": null,
- "fetchSpec": "0.0.2"
- },
- "_requiredBy": [
- "/cliui"
- ],
- "_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz",
- "_shasum": "b79669bb42ecb409f83d583cad52ca17eaa1643f",
- "_spec": "wordwrap@0.0.2",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/cliui",
- "author": {
- "name": "James Halliday",
- "email": "mail@substack.net",
- "url": "http://substack.net"
- },
- "bugs": {
- "url": "https://github.com/substack/node-wordwrap/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Wrap those words. Show them at what columns to start and stop.",
- "devDependencies": {
- "expresso": "=0.7.x"
- },
- "directories": {
- "lib": ".",
- "example": "example",
- "test": "test"
- },
- "engines": {
- "node": ">=0.4.0"
- },
- "homepage": "https://github.com/substack/node-wordwrap#readme",
- "keywords": [
- "word",
- "wrap",
- "rule",
- "format",
- "column"
- ],
- "license": "MIT/X11",
- "main": "./index.js",
- "name": "wordwrap",
- "repository": {
- "type": "git",
- "url": "git://github.com/substack/node-wordwrap.git"
- },
- "scripts": {
- "test": "expresso"
- },
- "version": "0.0.2"
-}
diff --git a/api/node_modules/cliui/node_modules/wordwrap/test/break.js b/api/node_modules/cliui/node_modules/wordwrap/test/break.js
deleted file mode 100644
index 749292ecc..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/test/break.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var assert = require('assert');
-var wordwrap = require('../');
-
-exports.hard = function () {
- var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,'
- + '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",'
- + '"browser":"chrome/6.0"}'
- ;
- var s_ = wordwrap.hard(80)(s);
-
- var lines = s_.split('\n');
- assert.equal(lines.length, 2);
- assert.ok(lines[0].length < 80);
- assert.ok(lines[1].length < 80);
-
- assert.equal(s, s_.replace(/\n/g, ''));
-};
-
-exports.break = function () {
- var s = new Array(55+1).join('a');
- var s_ = wordwrap.hard(20)(s);
-
- var lines = s_.split('\n');
- assert.equal(lines.length, 3);
- assert.ok(lines[0].length === 20);
- assert.ok(lines[1].length === 20);
- assert.ok(lines[2].length === 15);
-
- assert.equal(s, s_.replace(/\n/g, ''));
-};
diff --git a/api/node_modules/cliui/node_modules/wordwrap/test/idleness.txt b/api/node_modules/cliui/node_modules/wordwrap/test/idleness.txt
deleted file mode 100644
index aa3f4907f..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/test/idleness.txt
+++ /dev/null
@@ -1,63 +0,0 @@
-In Praise of Idleness
-
-By Bertrand Russell
-
-[1932]
-
-Like most of my generation, I was brought up on the saying: 'Satan finds some mischief for idle hands to do.' Being a highly virtuous child, I believed all that I was told, and acquired a conscience which has kept me working hard down to the present moment. But although my conscience has controlled my actions, my opinions have undergone a revolution. I think that there is far too much work done in the world, that immense harm is caused by the belief that work is virtuous, and that what needs to be preached in modern industrial countries is quite different from what always has been preached. Everyone knows the story of the traveler in Naples who saw twelve beggars lying in the sun (it was before the days of Mussolini), and offered a lira to the laziest of them. Eleven of them jumped up to claim it, so he gave it to the twelfth. this traveler was on the right lines. But in countries which do not enjoy Mediterranean sunshine idleness is more difficult, and a great public propaganda will be required to inaugurate it. I hope that, after reading the following pages, the leaders of the YMCA will start a campaign to induce good young men to do nothing. If so, I shall not have lived in vain.
-
-Before advancing my own arguments for laziness, I must dispose of one which I cannot accept. Whenever a person who already has enough to live on proposes to engage in some everyday kind of job, such as school-teaching or typing, he or she is told that such conduct takes the bread out of other people's mouths, and is therefore wicked. If this argument were valid, it would only be necessary for us all to be idle in order that we should all have our mouths full of bread. What people who say such things forget is that what a man earns he usually spends, and in spending he gives employment. As long as a man spends his income, he puts just as much bread into people's mouths in spending as he takes out of other people's mouths in earning. The real villain, from this point of view, is the man who saves. If he merely puts his savings in a stocking, like the proverbial French peasant, it is obvious that they do not give employment. If he invests his savings, the matter is less obvious, and different cases arise.
-
-One of the commonest things to do with savings is to lend them to some Government. In view of the fact that the bulk of the public expenditure of most civilized Governments consists in payment for past wars or preparation for future wars, the man who lends his money to a Government is in the same position as the bad men in Shakespeare who hire murderers. The net result of the man's economical habits is to increase the armed forces of the State to which he lends his savings. Obviously it would be better if he spent the money, even if he spent it in drink or gambling.
-
-But, I shall be told, the case is quite different when savings are invested in industrial enterprises. When such enterprises succeed, and produce something useful, this may be conceded. In these days, however, no one will deny that most enterprises fail. That means that a large amount of human labor, which might have been devoted to producing something that could be enjoyed, was expended on producing machines which, when produced, lay idle and did no good to anyone. The man who invests his savings in a concern that goes bankrupt is therefore injuring others as well as himself. If he spent his money, say, in giving parties for his friends, they (we may hope) would get pleasure, and so would all those upon whom he spent money, such as the butcher, the baker, and the bootlegger. But if he spends it (let us say) upon laying down rails for surface card in some place where surface cars turn out not to be wanted, he has diverted a mass of labor into channels where it gives pleasure to no one. Nevertheless, when he becomes poor through failure of his investment he will be regarded as a victim of undeserved misfortune, whereas the gay spendthrift, who has spent his money philanthropically, will be despised as a fool and a frivolous person.
-
-All this is only preliminary. I want to say, in all seriousness, that a great deal of harm is being done in the modern world by belief in the virtuousness of work, and that the road to happiness and prosperity lies in an organized diminution of work.
-
-First of all: what is work? Work is of two kinds: first, altering the position of matter at or near the earth's surface relatively to other such matter; second, telling other people to do so. The first kind is unpleasant and ill paid; the second is pleasant and highly paid. The second kind is capable of indefinite extension: there are not only those who give orders, but those who give advice as to what orders should be given. Usually two opposite kinds of advice are given simultaneously by two organized bodies of men; this is called politics. The skill required for this kind of work is not knowledge of the subjects as to which advice is given, but knowledge of the art of persuasive speaking and writing, i.e. of advertising.
-
-Throughout Europe, though not in America, there is a third class of men, more respected than either of the classes of workers. There are men who, through ownership of land, are able to make others pay for the privilege of being allowed to exist and to work. These landowners are idle, and I might therefore be expected to praise them. Unfortunately, their idleness is only rendered possible by the industry of others; indeed their desire for comfortable idleness is historically the source of the whole gospel of work. The last thing they have ever wished is that others should follow their example.
-
-From the beginning of civilization until the Industrial Revolution, a man could, as a rule, produce by hard work little more than was required for the subsistence of himself and his family, although his wife worked at least as hard as he did, and his children added their labor as soon as they were old enough to do so. The small surplus above bare necessaries was not left to those who produced it, but was appropriated by warriors and priests. In times of famine there was no surplus; the warriors and priests, however, still secured as much as at other times, with the result that many of the workers died of hunger. This system persisted in Russia until 1917 [1], and still persists in the East; in England, in spite of the Industrial Revolution, it remained in full force throughout the Napoleonic wars, and until a hundred years ago, when the new class of manufacturers acquired power. In America, the system came to an end with the Revolution, except in the South, where it persisted until the Civil War. A system which lasted so long and ended so recently has naturally left a profound impress upon men's thoughts and opinions. Much that we take for granted about the desirability of work is derived from this system, and, being pre-industrial, is not adapted to the modern world. Modern technique has made it possible for leisure, within limits, to be not the prerogative of small privileged classes, but a right evenly distributed throughout the community. The morality of work is the morality of slaves, and the modern world has no need of slavery.
-
-It is obvious that, in primitive communities, peasants, left to themselves, would not have parted with the slender surplus upon which the warriors and priests subsisted, but would have either produced less or consumed more. At first, sheer force compelled them to produce and part with the surplus. Gradually, however, it was found possible to induce many of them to accept an ethic according to which it was their duty to work hard, although part of their work went to support others in idleness. By this means the amount of compulsion required was lessened, and the expenses of government were diminished. To this day, 99 per cent of British wage-earners would be genuinely shocked if it were proposed that the King should not have a larger income than a working man. The conception of duty, speaking historically, has been a means used by the holders of power to induce others to live for the interests of their masters rather than for their own. Of course the holders of power conceal this fact from themselves by managing to believe that their interests are identical with the larger interests of humanity. Sometimes this is true; Athenian slave-owners, for instance, employed part of their leisure in making a permanent contribution to civilization which would have been impossible under a just economic system. Leisure is essential to civilization, and in former times leisure for the few was only rendered possible by the labors of the many. But their labors were valuable, not because work is good, but because leisure is good. And with modern technique it would be possible to distribute leisure justly without injury to civilization.
-
-Modern technique has made it possible to diminish enormously the amount of labor required to secure the necessaries of life for everyone. This was made obvious during the war. At that time all the men in the armed forces, and all the men and women engaged in the production of munitions, all the men and women engaged in spying, war propaganda, or Government offices connected with the war, were withdrawn from productive occupations. In spite of this, the general level of well-being among unskilled wage-earners on the side of the Allies was higher than before or since. The significance of this fact was concealed by finance: borrowing made it appear as if the future was nourishing the present. But that, of course, would have been impossible; a man cannot eat a loaf of bread that does not yet exist. The war showed conclusively that, by the scientific organization of production, it is possible to keep modern populations in fair comfort on a small part of the working capacity of the modern world. If, at the end of the war, the scientific organization, which had been created in order to liberate men for fighting and munition work, had been preserved, and the hours of the week had been cut down to four, all would have been well. Instead of that the old chaos was restored, those whose work was demanded were made to work long hours, and the rest were left to starve as unemployed. Why? Because work is a duty, and a man should not receive wages in proportion to what he has produced, but in proportion to his virtue as exemplified by his industry.
-
-This is the morality of the Slave State, applied in circumstances totally unlike those in which it arose. No wonder the result has been disastrous. Let us take an illustration. Suppose that, at a given moment, a certain number of people are engaged in the manufacture of pins. They make as many pins as the world needs, working (say) eight hours a day. Someone makes an invention by which the same number of men can make twice as many pins: pins are already so cheap that hardly any more will be bought at a lower price. In a sensible world, everybody concerned in the manufacturing of pins would take to working four hours instead of eight, and everything else would go on as before. But in the actual world this would be thought demoralizing. The men still work eight hours, there are too many pins, some employers go bankrupt, and half the men previously concerned in making pins are thrown out of work. There is, in the end, just as much leisure as on the other plan, but half the men are totally idle while half are still overworked. In this way, it is insured that the unavoidable leisure shall cause misery all round instead of being a universal source of happiness. Can anything more insane be imagined?
-
-The idea that the poor should have leisure has always been shocking to the rich. In England, in the early nineteenth century, fifteen hours was the ordinary day's work for a man; children sometimes did as much, and very commonly did twelve hours a day. When meddlesome busybodies suggested that perhaps these hours were rather long, they were told that work kept adults from drink and children from mischief. When I was a child, shortly after urban working men had acquired the vote, certain public holidays were established by law, to the great indignation of the upper classes. I remember hearing an old Duchess say: 'What do the poor want with holidays? They ought to work.' People nowadays are less frank, but the sentiment persists, and is the source of much of our economic confusion.
-
-Let us, for a moment, consider the ethics of work frankly, without superstition. Every human being, of necessity, consumes, in the course of his life, a certain amount of the produce of human labor. Assuming, as we may, that labor is on the whole disagreeable, it is unjust that a man should consume more than he produces. Of course he may provide services rather than commodities, like a medical man, for example; but he should provide something in return for his board and lodging. to this extent, the duty of work must be admitted, but to this extent only.
-
-I shall not dwell upon the fact that, in all modern societies outside the USSR, many people escape even this minimum amount of work, namely all those who inherit money and all those who marry money. I do not think the fact that these people are allowed to be idle is nearly so harmful as the fact that wage-earners are expected to overwork or starve.
-
-If the ordinary wage-earner worked four hours a day, there would be enough for everybody and no unemployment -- assuming a certain very moderate amount of sensible organization. This idea shocks the well-to-do, because they are convinced that the poor would not know how to use so much leisure. In America men often work long hours even when they are well off; such men, naturally, are indignant at the idea of leisure for wage-earners, except as the grim punishment of unemployment; in fact, they dislike leisure even for their sons. Oddly enough, while they wish their sons to work so hard as to have no time to be civilized, they do not mind their wives and daughters having no work at all. the snobbish admiration of uselessness, which, in an aristocratic society, extends to both sexes, is, under a plutocracy, confined to women; this, however, does not make it any more in agreement with common sense.
-
-The wise use of leisure, it must be conceded, is a product of civilization and education. A man who has worked long hours all his life will become bored if he becomes suddenly idle. But without a considerable amount of leisure a man is cut off from many of the best things. There is no longer any reason why the bulk of the population should suffer this deprivation; only a foolish asceticism, usually vicarious, makes us continue to insist on work in excessive quantities now that the need no longer exists.
-
-In the new creed which controls the government of Russia, while there is much that is very different from the traditional teaching of the West, there are some things that are quite unchanged. The attitude of the governing classes, and especially of those who conduct educational propaganda, on the subject of the dignity of labor, is almost exactly that which the governing classes of the world have always preached to what were called the 'honest poor'. Industry, sobriety, willingness to work long hours for distant advantages, even submissiveness to authority, all these reappear; moreover authority still represents the will of the Ruler of the Universe, Who, however, is now called by a new name, Dialectical Materialism.
-
-The victory of the proletariat in Russia has some points in common with the victory of the feminists in some other countries. For ages, men had conceded the superior saintliness of women, and had consoled women for their inferiority by maintaining that saintliness is more desirable than power. At last the feminists decided that they would have both, since the pioneers among them believed all that the men had told them about the desirability of virtue, but not what they had told them about the worthlessness of political power. A similar thing has happened in Russia as regards manual work. For ages, the rich and their sycophants have written in praise of 'honest toil', have praised the simple life, have professed a religion which teaches that the poor are much more likely to go to heaven than the rich, and in general have tried to make manual workers believe that there is some special nobility about altering the position of matter in space, just as men tried to make women believe that they derived some special nobility from their sexual enslavement. In Russia, all this teaching about the excellence of manual work has been taken seriously, with the result that the manual worker is more honored than anyone else. What are, in essence, revivalist appeals are made, but not for the old purposes: they are made to secure shock workers for special tasks. Manual work is the ideal which is held before the young, and is the basis of all ethical teaching.
-
-For the present, possibly, this is all to the good. A large country, full of natural resources, awaits development, and has has to be developed with very little use of credit. In these circumstances, hard work is necessary, and is likely to bring a great reward. But what will happen when the point has been reached where everybody could be comfortable without working long hours?
-
-In the West, we have various ways of dealing with this problem. We have no attempt at economic justice, so that a large proportion of the total produce goes to a small minority of the population, many of whom do no work at all. Owing to the absence of any central control over production, we produce hosts of things that are not wanted. We keep a large percentage of the working population idle, because we can dispense with their labor by making the others overwork. When all these methods prove inadequate, we have a war: we cause a number of people to manufacture high explosives, and a number of others to explode them, as if we were children who had just discovered fireworks. By a combination of all these devices we manage, though with difficulty, to keep alive the notion that a great deal of severe manual work must be the lot of the average man.
-
-In Russia, owing to more economic justice and central control over production, the problem will have to be differently solved. the rational solution would be, as soon as the necessaries and elementary comforts can be provided for all, to reduce the hours of labor gradually, allowing a popular vote to decide, at each stage, whether more leisure or more goods were to be preferred. But, having taught the supreme virtue of hard work, it is difficult to see how the authorities can aim at a paradise in which there will be much leisure and little work. It seems more likely that they will find continually fresh schemes, by which present leisure is to be sacrificed to future productivity. I read recently of an ingenious plan put forward by Russian engineers, for making the White Sea and the northern coasts of Siberia warm, by putting a dam across the Kara Sea. An admirable project, but liable to postpone proletarian comfort for a generation, while the nobility of toil is being displayed amid the ice-fields and snowstorms of the Arctic Ocean. This sort of thing, if it happens, will be the result of regarding the virtue of hard work as an end in itself, rather than as a means to a state of affairs in which it is no longer needed.
-
-The fact is that moving matter about, while a certain amount of it is necessary to our existence, is emphatically not one of the ends of human life. If it were, we should have to consider every navvy superior to Shakespeare. We have been misled in this matter by two causes. One is the necessity of keeping the poor contented, which has led the rich, for thousands of years, to preach the dignity of labor, while taking care themselves to remain undignified in this respect. The other is the new pleasure in mechanism, which makes us delight in the astonishingly clever changes that we can produce on the earth's surface. Neither of these motives makes any great appeal to the actual worker. If you ask him what he thinks the best part of his life, he is not likely to say: 'I enjoy manual work because it makes me feel that I am fulfilling man's noblest task, and because I like to think how much man can transform his planet. It is true that my body demands periods of rest, which I have to fill in as best I may, but I am never so happy as when the morning comes and I can return to the toil from which my contentment springs.' I have never heard working men say this sort of thing. They consider work, as it should be considered, a necessary means to a livelihood, and it is from their leisure that they derive whatever happiness they may enjoy.
-
-It will be said that, while a little leisure is pleasant, men would not know how to fill their days if they had only four hours of work out of the twenty-four. In so far as this is true in the modern world, it is a condemnation of our civilization; it would not have been true at any earlier period. There was formerly a capacity for light-heartedness and play which has been to some extent inhibited by the cult of efficiency. The modern man thinks that everything ought to be done for the sake of something else, and never for its own sake. Serious-minded persons, for example, are continually condemning the habit of going to the cinema, and telling us that it leads the young into crime. But all the work that goes to producing a cinema is respectable, because it is work, and because it brings a money profit. The notion that the desirable activities are those that bring a profit has made everything topsy-turvy. The butcher who provides you with meat and the baker who provides you with bread are praiseworthy, because they are making money; but when you enjoy the food they have provided, you are merely frivolous, unless you eat only to get strength for your work. Broadly speaking, it is held that getting money is good and spending money is bad. Seeing that they are two sides of one transaction, this is absurd; one might as well maintain that keys are good, but keyholes are bad. Whatever merit there may be in the production of goods must be entirely derivative from the advantage to be obtained by consuming them. The individual, in our society, works for profit; but the social purpose of his work lies in the consumption of what he produces. It is this divorce between the individual and the social purpose of production that makes it so difficult for men to think clearly in a world in which profit-making is the incentive to industry. We think too much of production, and too little of consumption. One result is that we attach too little importance to enjoyment and simple happiness, and that we do not judge production by the pleasure that it gives to the consumer.
-
-When I suggest that working hours should be reduced to four, I am not meaning to imply that all the remaining time should necessarily be spent in pure frivolity. I mean that four hours' work a day should entitle a man to the necessities and elementary comforts of life, and that the rest of his time should be his to use as he might see fit. It is an essential part of any such social system that education should be carried further than it usually is at present, and should aim, in part, at providing tastes which would enable a man to use leisure intelligently. I am not thinking mainly of the sort of things that would be considered 'highbrow'. Peasant dances have died out except in remote rural areas, but the impulses which caused them to be cultivated must still exist in human nature. The pleasures of urban populations have become mainly passive: seeing cinemas, watching football matches, listening to the radio, and so on. This results from the fact that their active energies are fully taken up with work; if they had more leisure, they would again enjoy pleasures in which they took an active part.
-
-In the past, there was a small leisure class and a larger working class. The leisure class enjoyed advantages for which there was no basis in social justice; this necessarily made it oppressive, limited its sympathies, and caused it to invent theories by which to justify its privileges. These facts greatly diminished its excellence, but in spite of this drawback it contributed nearly the whole of what we call civilization. It cultivated the arts and discovered the sciences; it wrote the books, invented the philosophies, and refined social relations. Even the liberation of the oppressed has usually been inaugurated from above. Without the leisure class, mankind would never have emerged from barbarism.
-
-The method of a leisure class without duties was, however, extraordinarily wasteful. None of the members of the class had to be taught to be industrious, and the class as a whole was not exceptionally intelligent. The class might produce one Darwin, but against him had to be set tens of thousands of country gentlemen who never thought of anything more intelligent than fox-hunting and punishing poachers. At present, the universities are supposed to provide, in a more systematic way, what the leisure class provided accidentally and as a by-product. This is a great improvement, but it has certain drawbacks. University life is so different from life in the world at large that men who live in academic milieu tend to be unaware of the preoccupations and problems of ordinary men and women; moreover their ways of expressing themselves are usually such as to rob their opinions of the influence that they ought to have upon the general public. Another disadvantage is that in universities studies are organized, and the man who thinks of some original line of research is likely to be discouraged. Academic institutions, therefore, useful as they are, are not adequate guardians of the interests of civilization in a world where everyone outside their walls is too busy for unutilitarian pursuits.
-
-In a world where no one is compelled to work more than four hours a day, every person possessed of scientific curiosity will be able to indulge it, and every painter will be able to paint without starving, however excellent his pictures may be. Young writers will not be obliged to draw attention to themselves by sensational pot-boilers, with a view to acquiring the economic independence needed for monumental works, for which, when the time at last comes, they will have lost the taste and capacity. Men who, in their professional work, have become interested in some phase of economics or government, will be able to develop their ideas without the academic detachment that makes the work of university economists often seem lacking in reality. Medical men will have the time to learn about the progress of medicine, teachers will not be exasperatedly struggling to teach by routine methods things which they learnt in their youth, which may, in the interval, have been proved to be untrue.
-
-Above all, there will be happiness and joy of life, instead of frayed nerves, weariness, and dyspepsia. The work exacted will be enough to make leisure delightful, but not enough to produce exhaustion. Since men will not be tired in their spare time, they will not demand only such amusements as are passive and vapid. At least one per cent will probably devote the time not spent in professional work to pursuits of some public importance, and, since they will not depend upon these pursuits for their livelihood, their originality will be unhampered, and there will be no need to conform to the standards set by elderly pundits. But it is not only in these exceptional cases that the advantages of leisure will appear. Ordinary men and women, having the opportunity of a happy life, will become more kindly and less persecuting and less inclined to view others with suspicion. The taste for war will die out, partly for this reason, and partly because it will involve long and severe work for all. Good nature is, of all moral qualities, the one that the world needs most, and good nature is the result of ease and security, not of a life of arduous struggle. Modern methods of production have given us the possibility of ease and security for all; we have chosen, instead, to have overwork for some and starvation for others. Hitherto we have continued to be as energetic as we were before there were machines; in this we have been foolish, but there is no reason to go on being foolish forever.
-
-[1] Since then, members of the Communist Party have succeeded to this privilege of the warriors and priests.
diff --git a/api/node_modules/cliui/node_modules/wordwrap/test/wrap.js b/api/node_modules/cliui/node_modules/wordwrap/test/wrap.js
deleted file mode 100644
index 0cfb76d17..000000000
--- a/api/node_modules/cliui/node_modules/wordwrap/test/wrap.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var assert = require('assert');
-var wordwrap = require('wordwrap');
-
-var fs = require('fs');
-var idleness = fs.readFileSync(__dirname + '/idleness.txt', 'utf8');
-
-exports.stop80 = function () {
- var lines = wordwrap(80)(idleness).split(/\n/);
- var words = idleness.split(/\s+/);
-
- lines.forEach(function (line) {
- assert.ok(line.length <= 80, 'line > 80 columns');
- var chunks = line.match(/\S/) ? line.split(/\s+/) : [];
- assert.deepEqual(chunks, words.splice(0, chunks.length));
- });
-};
-
-exports.start20stop60 = function () {
- var lines = wordwrap(20, 100)(idleness).split(/\n/);
- var words = idleness.split(/\s+/);
-
- lines.forEach(function (line) {
- assert.ok(line.length <= 100, 'line > 100 columns');
- var chunks = line
- .split(/\s+/)
- .filter(function (x) { return x.match(/\S/) })
- ;
- assert.deepEqual(chunks, words.splice(0, chunks.length));
- assert.deepEqual(line.slice(0, 20), new Array(20 + 1).join(' '));
- });
-};
diff --git a/api/node_modules/cliui/package.json b/api/node_modules/cliui/package.json
deleted file mode 100644
index 4bb1d3480..000000000
--- a/api/node_modules/cliui/package.json
+++ /dev/null
@@ -1,91 +0,0 @@
-{
- "_from": "cliui@^2.1.0",
- "_id": "cliui@2.1.0",
- "_inBundle": false,
- "_integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=",
- "_location": "/cliui",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "cliui@^2.1.0",
- "name": "cliui",
- "escapedName": "cliui",
- "rawSpec": "^2.1.0",
- "saveSpec": null,
- "fetchSpec": "^2.1.0"
- },
- "_requiredBy": [
- "/yargs"
- ],
- "_resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz",
- "_shasum": "4b475760ff80264c762c3a1719032e91c7fea0d1",
- "_spec": "cliui@^2.1.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/yargs",
- "author": {
- "name": "Ben Coe",
- "email": "ben@npmjs.com"
- },
- "bugs": {
- "url": "https://github.com/bcoe/cliui/issues"
- },
- "bundleDependencies": false,
- "config": {
- "blanket": {
- "pattern": [
- "index.js"
- ],
- "data-cover-never": [
- "node_modules",
- "test"
- ],
- "output-reporter": "spec"
- }
- },
- "dependencies": {
- "center-align": "^0.1.1",
- "right-align": "^0.1.1",
- "wordwrap": "0.0.2"
- },
- "deprecated": false,
- "description": "easily create complex multi-column command-line-interfaces",
- "devDependencies": {
- "blanket": "^1.1.6",
- "chai": "^2.2.0",
- "coveralls": "^2.11.2",
- "mocha": "^2.2.4",
- "mocha-lcov-reporter": "0.0.2",
- "mocoverage": "^1.0.0",
- "patched-blanket": "^1.0.1",
- "standard": "^3.6.1"
- },
- "homepage": "https://github.com/bcoe/cliui#readme",
- "keywords": [
- "cli",
- "command-line",
- "layout",
- "design",
- "console",
- "wrap",
- "table"
- ],
- "license": "ISC",
- "main": "index.js",
- "name": "cliui",
- "repository": {
- "type": "git",
- "url": "git+ssh://git@github.com/bcoe/cliui.git"
- },
- "scripts": {
- "test": "standard && mocha --check-leaks --ui exports --require patched-blanket -R mocoverage"
- },
- "standard": {
- "ignore": [
- "**/example/**"
- ],
- "globals": [
- "it"
- ]
- },
- "version": "2.1.0"
-}
diff --git a/api/node_modules/cliui/test/cliui.js b/api/node_modules/cliui/test/cliui.js
deleted file mode 100644
index 1cc6127cb..000000000
--- a/api/node_modules/cliui/test/cliui.js
+++ /dev/null
@@ -1,349 +0,0 @@
-/* global describe, it */
-
-require('chai').should()
-
-var cliui = require('../')
-
-describe('cliui', function () {
- describe('div', function () {
- it("wraps text at 'width' if a single column is given", function () {
- var ui = cliui({
- width: 10
- })
-
- ui.div('i am a string that should be wrapped')
-
- ui.toString().split('\n').forEach(function (row) {
- row.length.should.be.lte(10)
- })
- })
-
- it('evenly divides text across columns if multiple columns are given', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div(
- {text: 'i am a string that should be wrapped', width: 15},
- 'i am a second string that should be wrapped',
- 'i am a third string that should be wrapped'
- )
-
- // total width of all columns is <=
- // the width cliui is initialized with.
- ui.toString().split('\n').forEach(function (row) {
- row.length.should.be.lte(40)
- })
-
- // it should wrap each column appropriately.
- var expected = [
- 'i am a string i am a i am a third',
- 'that should be second string that',
- 'wrapped string that should be',
- ' should be wrapped',
- ' wrapped'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('allows for a blank row to be appended', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div()
-
- // it should wrap each column appropriately.
- var expected = ['']
-
- ui.toString().split('\n').should.eql(expected)
- })
- })
-
- describe('_columnWidths', function () {
- it('uses same width for each column by default', function () {
- var ui = cliui({
- width: 40
- }),
- widths = ui._columnWidths([{}, {}, {}])
-
- widths[0].should.equal(13)
- widths[1].should.equal(13)
- widths[2].should.equal(13)
- })
-
- it('divides width over remaining columns if first column has width specified', function () {
- var ui = cliui({
- width: 40
- }),
- widths = ui._columnWidths([{width: 20}, {}, {}])
-
- widths[0].should.equal(20)
- widths[1].should.equal(10)
- widths[2].should.equal(10)
- })
-
- it('divides width over remaining columns if middle column has width specified', function () {
- var ui = cliui({
- width: 40
- }),
- widths = ui._columnWidths([{}, {width: 10}, {}])
-
- widths[0].should.equal(15)
- widths[1].should.equal(10)
- widths[2].should.equal(15)
- })
-
- it('keeps track of remaining width if multiple columns have width specified', function () {
- var ui = cliui({
- width: 40
- }),
- widths = ui._columnWidths([{width: 20}, {width: 12}, {}])
-
- widths[0].should.equal(20)
- widths[1].should.equal(12)
- widths[2].should.equal(8)
- })
-
- it('uses a sane default if impossible widths are specified', function () {
- var ui = cliui({
- width: 40
- }),
- widths = ui._columnWidths([{width: 30}, {width: 30}, {padding: [0, 2, 0, 1]}])
-
- widths[0].should.equal(30)
- widths[1].should.equal(30)
- widths[2].should.equal(4)
- })
- })
-
- describe('alignment', function () {
- it('allows a column to be right aligned', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div(
- 'i am a string',
- {text: 'i am a second string', align: 'right'},
- 'i am a third string that should be wrapped'
- )
-
- // it should right-align the second column.
- var expected = [
- 'i am a stringi am a secondi am a third',
- ' stringstring that',
- ' should be',
- ' wrapped'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('allows a column to be center aligned', function () {
- var ui = cliui({
- width: 60
- })
-
- ui.div(
- 'i am a string',
- {text: 'i am a second string', align: 'center', padding: [0, 2, 0, 2]},
- 'i am a third string that should be wrapped'
- )
-
- // it should right-align the second column.
- var expected = [
- 'i am a string i am a second i am a third string',
- ' string that should be',
- ' wrapped'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
- })
-
- describe('padding', function () {
- it('handles left/right padding', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div(
- {text: 'i have padding on my left', padding: [0, 0, 0, 4]},
- {text: 'i have padding on my right', padding: [0, 2, 0, 0], align: 'center'},
- {text: 'i have no padding', padding: [0, 0, 0, 0]}
- )
-
- // it should add left/right padding to columns.
- var expected = [
- ' i have i have i have no',
- ' padding padding on padding',
- ' on my my right',
- ' left'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('handles top/bottom padding', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div(
- 'i am a string',
- {text: 'i am a second string', padding: [2, 0, 0, 0]},
- {text: 'i am a third string that should be wrapped', padding: [0, 0, 1, 0]}
- )
-
- // it should add top/bottom padding to second
- // and third columns.
- var expected = [
- 'i am a string i am a third',
- ' string that',
- ' i am a secondshould be',
- ' string wrapped',
- ''
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
- })
-
- describe('wrap', function () {
- it('allows wordwrap to be disabled', function () {
- var ui = cliui({
- wrap: false
- })
-
- ui.div(
- {text: 'i am a string', padding: [0, 1, 0, 0]},
- {text: 'i am a second string', padding: [0, 2, 0, 0]},
- {text: 'i am a third string that should not be wrapped', padding: [0, 0, 0, 2]}
- )
-
- ui.toString().should.equal('i am a string i am a second string i am a third string that should not be wrapped')
- })
- })
-
- describe('span', function () {
- it('appends the next row to the end of the prior row if it fits', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.span(
- {text: 'i am a string that will be wrapped', width: 30}
- )
-
- ui.div(
- {text: ' [required] [default: 99]', align: 'right'}
- )
-
- var expected = [
- 'i am a string that will be',
- 'wrapped [required] [default: 99]'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('does not append the string if it does not fit on the prior row', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.span(
- {text: 'i am a string that will be wrapped', width: 30}
- )
-
- ui.div(
- {text: 'i am a second row', align: 'left'}
- )
-
- var expected = [
- 'i am a string that will be',
- 'wrapped',
- 'i am a second row'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('always appends text to prior span if wrap is disabled', function () {
- var ui = cliui({
- wrap: false,
- width: 40
- })
-
- ui.span(
- {text: 'i am a string that will be wrapped', width: 30}
- )
-
- ui.div(
- {text: 'i am a second row', align: 'left', padding: [0, 0, 0, 3]}
- )
-
- ui.div('a third line')
-
- var expected = [
- 'i am a string that will be wrapped i am a second row',
- 'a third line'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
- })
-
- describe('layoutDSL', function () {
- it('turns tab into multiple columns', function () {
- var ui = cliui({
- width: 60
- })
-
- ui.div(
- ' \tmy awesome regex\n \tanother row\t a third column'
- )
-
- var expected = [
- ' my awesome regex',
- ' another row a third column'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('turns newline into multiple rows', function () {
- var ui = cliui({
- width: 40
- })
-
- ui.div(
- 'Usage: $0\n \t my awesome regex\n \t my awesome glob\t [required]'
- )
- var expected = [
- 'Usage: $0',
- ' my awesome regex',
- ' my awesome [required]',
- ' glob'
- ]
-
- ui.toString().split('\n').should.eql(expected)
- })
-
- it('does not apply DSL if wrap is false', function () {
- var ui = cliui({
- width: 40,
- wrap: false
- })
-
- ui.div(
- 'Usage: $0\ttwo\tthree'
- )
-
- ui.toString().should.eql('Usage: $0\ttwo\tthree')
- })
-
- })
-})
diff --git a/api/node_modules/commander/History.md b/api/node_modules/commander/History.md
deleted file mode 100644
index c927f4bf8..000000000
--- a/api/node_modules/commander/History.md
+++ /dev/null
@@ -1,222 +0,0 @@
-2.6.0 / 2014-12-30
-==================
-
- * added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
- * Add application description to the help msg. Close #112 @dalssoft
-
-2.5.1 / 2014-12-15
-==================
-
- * fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
-
-2.5.0 / 2014-10-24
-==================
-
- * add support for variadic arguments. Closes #277 @whitlockjc
-
-2.4.0 / 2014-10-17
-==================
-
- * fixed a bug on executing the coercion function of subcommands option. Closes #270
- * added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
- * added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
- * fixed a bug on subcommand name. Closes #248 @jonathandelgado
- * fixed function normalize doesn’t honor option terminator. Closes #216 @abbr
-
-2.3.0 / 2014-07-16
-==================
-
- * add command alias'. Closes PR #210
- * fix: Typos. Closes #99
- * fix: Unused fs module. Closes #217
-
-2.2.0 / 2014-03-29
-==================
-
- * add passing of previous option value
- * fix: support subcommands on windows. Closes #142
- * Now the defaultValue passed as the second argument of the coercion function.
-
-2.1.0 / 2013-11-21
-==================
-
- * add: allow cflag style option params, unit test, fixes #174
-
-2.0.0 / 2013-07-18
-==================
-
- * remove input methods (.prompt, .confirm, etc)
-
-1.3.2 / 2013-07-18
-==================
-
- * add support for sub-commands to co-exist with the original command
-
-1.3.1 / 2013-07-18
-==================
-
- * add quick .runningCommand hack so you can opt-out of other logic when running a sub command
-
-1.3.0 / 2013-07-09
-==================
-
- * add EACCES error handling
- * fix sub-command --help
-
-1.2.0 / 2013-06-13
-==================
-
- * allow "-" hyphen as an option argument
- * support for RegExp coercion
-
-1.1.1 / 2012-11-20
-==================
-
- * add more sub-command padding
- * fix .usage() when args are present. Closes #106
-
-1.1.0 / 2012-11-16
-==================
-
- * add git-style executable subcommand support. Closes #94
-
-1.0.5 / 2012-10-09
-==================
-
- * fix `--name` clobbering. Closes #92
- * fix examples/help. Closes #89
-
-1.0.4 / 2012-09-03
-==================
-
- * add `outputHelp()` method.
-
-1.0.3 / 2012-08-30
-==================
-
- * remove invalid .version() defaulting
-
-1.0.2 / 2012-08-24
-==================
-
- * add `--foo=bar` support [arv]
- * fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
-
-1.0.1 / 2012-08-03
-==================
-
- * fix issue #56
- * fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
-
-1.0.0 / 2012-07-05
-==================
-
- * add support for optional option descriptions
- * add defaulting of `.version()` to package.json's version
-
-0.6.1 / 2012-06-01
-==================
-
- * Added: append (yes or no) on confirmation
- * Added: allow node.js v0.7.x
-
-0.6.0 / 2012-04-10
-==================
-
- * Added `.prompt(obj, callback)` support. Closes #49
- * Added default support to .choose(). Closes #41
- * Fixed the choice example
-
-0.5.1 / 2011-12-20
-==================
-
- * Fixed `password()` for recent nodes. Closes #36
-
-0.5.0 / 2011-12-04
-==================
-
- * Added sub-command option support [itay]
-
-0.4.3 / 2011-12-04
-==================
-
- * Fixed custom help ordering. Closes #32
-
-0.4.2 / 2011-11-24
-==================
-
- * Added travis support
- * Fixed: line-buffered input automatically trimmed. Closes #31
-
-0.4.1 / 2011-11-18
-==================
-
- * Removed listening for "close" on --help
-
-0.4.0 / 2011-11-15
-==================
-
- * Added support for `--`. Closes #24
-
-0.3.3 / 2011-11-14
-==================
-
- * Fixed: wait for close event when writing help info [Jerry Hamlet]
-
-0.3.2 / 2011-11-01
-==================
-
- * Fixed long flag definitions with values [felixge]
-
-0.3.1 / 2011-10-31
-==================
-
- * Changed `--version` short flag to `-V` from `-v`
- * Changed `.version()` so it's configurable [felixge]
-
-0.3.0 / 2011-10-31
-==================
-
- * Added support for long flags only. Closes #18
-
-0.2.1 / 2011-10-24
-==================
-
- * "node": ">= 0.4.x < 0.7.0". Closes #20
-
-0.2.0 / 2011-09-26
-==================
-
- * Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
-
-0.1.0 / 2011-08-24
-==================
-
- * Added support for custom `--help` output
-
-0.0.5 / 2011-08-18
-==================
-
- * Changed: when the user enters nothing prompt for password again
- * Fixed issue with passwords beginning with numbers [NuckChorris]
-
-0.0.4 / 2011-08-15
-==================
-
- * Fixed `Commander#args`
-
-0.0.3 / 2011-08-15
-==================
-
- * Added default option value support
-
-0.0.2 / 2011-08-15
-==================
-
- * Added mask support to `Command#password(str[, mask], fn)`
- * Added `Command#password(str, fn)`
-
-0.0.1 / 2010-01-03
-==================
-
- * Initial release
diff --git a/api/node_modules/commander/Readme.md b/api/node_modules/commander/Readme.md
deleted file mode 100644
index 677bfc43a..000000000
--- a/api/node_modules/commander/Readme.md
+++ /dev/null
@@ -1,300 +0,0 @@
-# Commander.js
-
- [![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js)
-[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
-[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
-
- The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).
- [API documentation](http://tj.github.com/commander.js/)
-
-
-## Installation
-
- $ npm install commander
-
-## Option parsing
-
- Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-p, --peppers', 'Add peppers')
- .option('-P, --pineapple', 'Add pineapple')
- .option('-b, --bbq', 'Add bbq sauce')
- .option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
- .parse(process.argv);
-
-console.log('you ordered a pizza with:');
-if (program.peppers) console.log(' - peppers');
-if (program.pineapple) console.log(' - pineapple');
-if (program.bbq) console.log(' - bbq');
-console.log(' - %s cheese', program.cheese);
-```
-
- Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
-
-
-## Coercion
-
-```js
-function range(val) {
- return val.split('..').map(Number);
-}
-
-function list(val) {
- return val.split(',');
-}
-
-function collect(val, memo) {
- memo.push(val);
- return memo;
-}
-
-function increaseVerbosity(v, total) {
- return total + 1;
-}
-
-program
- .version('0.0.1')
- .usage('[options] ')
- .option('-i, --integer ', 'An integer argument', parseInt)
- .option('-f, --float ', 'A float argument', parseFloat)
- .option('-r, --range ..', 'A range', range)
- .option('-l, --list ', 'A list', list)
- .option('-o, --optional [value]', 'An optional value')
- .option('-c, --collect [value]', 'A repeatable value', collect, [])
- .option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
- .parse(process.argv);
-
-console.log(' int: %j', program.integer);
-console.log(' float: %j', program.float);
-console.log(' optional: %j', program.optional);
-program.range = program.range || [];
-console.log(' range: %j..%j', program.range[0], program.range[1]);
-console.log(' list: %j', program.list);
-console.log(' collect: %j', program.collect);
-console.log(' verbosity: %j', program.verbose);
-console.log(' args: %j', program.args);
-```
-
-## Variadic arguments
-
- The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
- append `...` to the argument name. Here is an example:
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .command('rmdir [otherDirs...]')
- .action(function (dir, otherDirs) {
- console.log('rmdir %s', dir);
- if (otherDirs) {
- otherDirs.forEach(function (oDir) {
- console.log('rmdir %s', oDir);
- });
- }
- });
-
-program.parse(process.argv);
-```
-
- An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
- to your action as demonstrated above.
-
-## Git-style sub-commands
-
-```js
-// file: ./examples/pm
-var program = require('..');
-
-program
- .version('0.0.1')
- .command('install [name]', 'install one or more packages')
- .command('search [query]', 'search with optional query')
- .command('list', 'list packages installed')
- .parse(process.argv);
-```
-
-When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
-The commander will try to find the executable script in __current directory__ with the name `scriptBasename-subcommand`, like `pm-install`, `pm-search`.
-
-## Automated --help
-
- The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
-
-```
- $ ./examples/pizza --help
-
- Usage: pizza [options]
-
- An application for pizzas ordering
-
- Options:
-
- -h, --help output usage information
- -V, --version output the version number
- -p, --peppers Add peppers
- -P, --pineapple Add pineapple
- -b, --bbq Add bbq sauce
- -c, --cheese Add the specified type of cheese [marble]
- -C, --no-cheese You do not want any cheese
-
-```
-
-## Custom help
-
- You can display arbitrary `-h, --help` information
- by listening for "--help". Commander will automatically
- exit once you are done so that the remainder of your program
- does not execute causing undesired behaviours, for example
- in the following executable "stuff" will not output when
- `--help` is used.
-
-```js
-#!/usr/bin/env node
-
-/**
- * Module dependencies.
- */
-
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-f, --foo', 'enable some foo')
- .option('-b, --bar', 'enable some bar')
- .option('-B, --baz', 'enable some baz');
-
-// must be before .parse() since
-// node's emit() is immediate
-
-program.on('--help', function(){
- console.log(' Examples:');
- console.log('');
- console.log(' $ custom-help --help');
- console.log(' $ custom-help -h');
- console.log('');
-});
-
-program.parse(process.argv);
-
-console.log('stuff');
-```
-
-Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
-
-```
-
-Usage: custom-help [options]
-
-Options:
-
- -h, --help output usage information
- -V, --version output the version number
- -f, --foo enable some foo
- -b, --bar enable some bar
- -B, --baz enable some baz
-
-Examples:
-
- $ custom-help --help
- $ custom-help -h
-
-```
-
-## .outputHelp()
-
- Output help information without exiting.
-
-## .help()
-
- Output help information and exit immediately.
-
-## Examples
-
-```js
-var program = require('commander');
-
-program
- .version('0.0.1')
- .option('-C, --chdir ', 'change the working directory')
- .option('-c, --config ', 'set config path. defaults to ./deploy.conf')
- .option('-T, --no-tests', 'ignore test hook')
-
-program
- .command('setup [env]')
- .description('run setup commands for all envs')
- .option("-s, --setup_mode [mode]", "Which setup mode to use")
- .action(function(env, options){
- var mode = options.setup_mode || "normal";
- env = env || 'all';
- console.log('setup for %s env(s) with %s mode', env, mode);
- });
-
-program
- .command('exec ')
- .alias('ex')
- .description('execute the given remote cmd')
- .option("-e, --exec_mode ", "Which exec mode to use")
- .action(function(cmd, options){
- console.log('exec "%s" using %s mode', cmd, options.exec_mode);
- }).on('--help', function() {
- console.log(' Examples:');
- console.log();
- console.log(' $ deploy exec sequential');
- console.log(' $ deploy exec async');
- console.log();
- });
-
-program
- .command('*')
- .action(function(env){
- console.log('deploying "%s"', env);
- });
-
-program.parse(process.argv);
-```
-
-You can see more Demos in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
-
-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.
diff --git a/api/node_modules/commander/index.js b/api/node_modules/commander/index.js
deleted file mode 100644
index e0299d5c6..000000000
--- a/api/node_modules/commander/index.js
+++ /dev/null
@@ -1,1020 +0,0 @@
-
-/**
- * Module dependencies.
- */
-
-var EventEmitter = require('events').EventEmitter;
-var spawn = require('child_process').spawn;
-var path = require('path');
-var dirname = path.dirname;
-var basename = path.basename;
-
-/**
- * Expose the root command.
- */
-
-exports = module.exports = new Command();
-
-/**
- * Expose `Command`.
- */
-
-exports.Command = Command;
-
-/**
- * Expose `Option`.
- */
-
-exports.Option = Option;
-
-/**
- * Initialize a new `Option` with the given `flags` and `description`.
- *
- * @param {String} flags
- * @param {String} description
- * @api public
- */
-
-function Option(flags, description) {
- this.flags = flags;
- this.required = ~flags.indexOf('<');
- this.optional = ~flags.indexOf('[');
- this.bool = !~flags.indexOf('-no-');
- flags = flags.split(/[ ,|]+/);
- if (flags.length > 1 && !/^[[<]/.test(flags[1])) this.short = flags.shift();
- this.long = flags.shift();
- this.description = description || '';
-}
-
-/**
- * Return option name.
- *
- * @return {String}
- * @api private
- */
-
-Option.prototype.name = function() {
- return this.long
- .replace('--', '')
- .replace('no-', '');
-};
-
-/**
- * Check if `arg` matches the short or long flag.
- *
- * @param {String} arg
- * @return {Boolean}
- * @api private
- */
-
-Option.prototype.is = function(arg) {
- return arg == this.short || arg == this.long;
-};
-
-/**
- * Initialize a new `Command`.
- *
- * @param {String} name
- * @api public
- */
-
-function Command(name) {
- this.commands = [];
- this.options = [];
- this._execs = [];
- this._allowUnknownOption = false;
- this._args = [];
- this._name = name;
-}
-
-/**
- * Inherit from `EventEmitter.prototype`.
- */
-
-Command.prototype.__proto__ = EventEmitter.prototype;
-
-/**
- * Add command `name`.
- *
- * The `.action()` callback is invoked when the
- * command `name` is specified via __ARGV__,
- * and the remaining arguments are applied to the
- * function for access.
- *
- * When the `name` is "*" an un-matched command
- * will be passed as the first arg, followed by
- * the rest of __ARGV__ remaining.
- *
- * Examples:
- *
- * program
- * .version('0.0.1')
- * .option('-C, --chdir ', 'change the working directory')
- * .option('-c, --config ', 'set config path. defaults to ./deploy.conf')
- * .option('-T, --no-tests', 'ignore test hook')
- *
- * program
- * .command('setup')
- * .description('run remote setup commands')
- * .action(function() {
- * console.log('setup');
- * });
- *
- * program
- * .command('exec ')
- * .description('run the given remote command')
- * .action(function(cmd) {
- * console.log('exec "%s"', cmd);
- * });
- *
- * program
- * .command('teardown [otherDirs...]')
- * .description('run teardown commands')
- * .action(function(dir, otherDirs) {
- * console.log('dir "%s"', dir);
- * if (otherDirs) {
- * otherDirs.forEach(function (oDir) {
- * console.log('dir "%s"', oDir);
- * });
- * }
- * });
- *
- * program
- * .command('*')
- * .description('deploy the given env')
- * .action(function(env) {
- * console.log('deploying "%s"', env);
- * });
- *
- * program.parse(process.argv);
- *
- * @param {String} name
- * @param {String} [desc] for git-style sub-commands
- * @return {Command} the new command
- * @api public
- */
-
-Command.prototype.command = function(name, desc) {
- var args = name.split(/ +/);
- var cmd = new Command(args.shift());
-
- if (desc) {
- cmd.description(desc);
- this.executables = true;
- this._execs[cmd._name] = true;
- }
-
- this.commands.push(cmd);
- cmd.parseExpectedArgs(args);
- cmd.parent = this;
-
- if (desc) return this;
- return cmd;
-};
-
-/**
- * Add an implicit `help [cmd]` subcommand
- * which invokes `--help` for the given command.
- *
- * @api private
- */
-
-Command.prototype.addImplicitHelpCommand = function() {
- this.command('help [cmd]', 'display help for [cmd]');
-};
-
-/**
- * Parse expected `args`.
- *
- * For example `["[type]"]` becomes `[{ required: false, name: 'type' }]`.
- *
- * @param {Array} args
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.parseExpectedArgs = function(args) {
- if (!args.length) return;
- var self = this;
- args.forEach(function(arg) {
- var argDetails = {
- required: false,
- name: '',
- variadic: false
- };
-
- switch (arg[0]) {
- case '<':
- argDetails.required = true;
- argDetails.name = arg.slice(1, -1);
- break;
- case '[':
- argDetails.name = arg.slice(1, -1);
- break;
- }
-
- if (argDetails.name.length > 3 && argDetails.name.slice(-3) === '...') {
- argDetails.variadic = true;
- argDetails.name = argDetails.name.slice(0, -3);
- }
- if (argDetails.name) {
- self._args.push(argDetails);
- }
- });
- return this;
-};
-
-/**
- * Register callback `fn` for the command.
- *
- * Examples:
- *
- * program
- * .command('help')
- * .description('display verbose help')
- * .action(function() {
- * // output help here
- * });
- *
- * @param {Function} fn
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.action = function(fn) {
- var self = this;
- var listener = function(args, unknown) {
- // Parse any so-far unknown options
- args = args || [];
- unknown = unknown || [];
-
- var parsed = self.parseOptions(unknown);
-
- // Output help if necessary
- outputHelpIfNecessary(self, parsed.unknown);
-
- // If there are still any unknown options, then we simply
- // die, unless someone asked for help, in which case we give it
- // to them, and then we die.
- if (parsed.unknown.length > 0) {
- self.unknownOption(parsed.unknown[0]);
- }
-
- // Leftover arguments need to be pushed back. Fixes issue #56
- if (parsed.args.length) args = parsed.args.concat(args);
-
- self._args.forEach(function(arg, i) {
- if (arg.required && null == args[i]) {
- self.missingArgument(arg.name);
- } else if (arg.variadic) {
- if (i !== self._args.length - 1) {
- self.variadicArgNotLast(arg.name);
- }
-
- args[i] = args.splice(i);
- }
- });
-
- // Always append ourselves to the end of the arguments,
- // to make sure we match the number of arguments the user
- // expects
- if (self._args.length) {
- args[self._args.length] = self;
- } else {
- args.push(self);
- }
-
- fn.apply(self, args);
- };
- this.parent.on(this._name, listener);
- if (this._alias) this.parent.on(this._alias, listener);
- return this;
-};
-
-/**
- * Define option with `flags`, `description` and optional
- * coercion `fn`.
- *
- * The `flags` string should contain both the short and long flags,
- * separated by comma, a pipe or space. The following are all valid
- * all will output this way when `--help` is used.
- *
- * "-p, --pepper"
- * "-p|--pepper"
- * "-p --pepper"
- *
- * Examples:
- *
- * // simple boolean defaulting to false
- * program.option('-p, --pepper', 'add pepper');
- *
- * --pepper
- * program.pepper
- * // => Boolean
- *
- * // simple boolean defaulting to true
- * program.option('-C, --no-cheese', 'remove cheese');
- *
- * program.cheese
- * // => true
- *
- * --no-cheese
- * program.cheese
- * // => false
- *
- * // required argument
- * program.option('-C, --chdir ', 'change the working directory');
- *
- * --chdir /tmp
- * program.chdir
- * // => "/tmp"
- *
- * // optional argument
- * program.option('-c, --cheese [type]', 'add cheese [marble]');
- *
- * @param {String} flags
- * @param {String} description
- * @param {Function|Mixed} fn or default
- * @param {Mixed} defaultValue
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.option = function(flags, description, fn, defaultValue) {
- var self = this
- , option = new Option(flags, description)
- , oname = option.name()
- , name = camelcase(oname);
-
- // default as 3rd arg
- if (typeof fn != 'function') {
- defaultValue = fn;
- fn = null;
- }
-
- // preassign default value only for --no-*, [optional], or
- if (false == option.bool || option.optional || option.required) {
- // when --no-* we make sure default is true
- if (false == option.bool) defaultValue = true;
- // preassign only if we have a default
- if (undefined !== defaultValue) self[name] = defaultValue;
- }
-
- // register the option
- this.options.push(option);
-
- // when it's passed assign the value
- // and conditionally invoke the callback
- this.on(oname, function(val) {
- // coercion
- if (null !== val && fn) val = fn(val, undefined === self[name]
- ? defaultValue
- : self[name]);
-
- // unassigned or bool
- if ('boolean' == typeof self[name] || 'undefined' == typeof self[name]) {
- // if no value, bool true, and we have a default, then use it!
- if (null == val) {
- self[name] = option.bool
- ? defaultValue || true
- : false;
- } else {
- self[name] = val;
- }
- } else if (null !== val) {
- // reassign
- self[name] = val;
- }
- });
-
- return this;
-};
-
-/**
- * Allow unknown options on the command line.
- *
- * @param {Boolean} arg if `true` or omitted, no error will be thrown
- * for unknown options.
- * @api public
- */
-Command.prototype.allowUnknownOption = function(arg) {
- this._allowUnknownOption = arguments.length === 0 || arg;
- return this;
-};
-
-/**
- * Parse `argv`, settings options and invoking commands when defined.
- *
- * @param {Array} argv
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.parse = function(argv) {
- // implicit help
- if (this.executables) this.addImplicitHelpCommand();
-
- // store raw args
- this.rawArgs = argv;
-
- // guess name
- this._name = this._name || basename(argv[1], '.js');
-
- // process argv
- var parsed = this.parseOptions(this.normalize(argv.slice(2)));
- var args = this.args = parsed.args;
-
- var result = this.parseArgs(this.args, parsed.unknown);
-
- // executable sub-commands
- var name = result.args[0];
- if (this._execs[name] && typeof this._execs[name] != "function") {
- return this.executeSubCommand(argv, args, parsed.unknown);
- }
-
- return result;
-};
-
-/**
- * Execute a sub-command executable.
- *
- * @param {Array} argv
- * @param {Array} args
- * @param {Array} unknown
- * @api private
- */
-
-Command.prototype.executeSubCommand = function(argv, args, unknown) {
- args = args.concat(unknown);
-
- if (!args.length) this.help();
- if ('help' == args[0] && 1 == args.length) this.help();
-
- // --help
- if ('help' == args[0]) {
- args[0] = args[1];
- args[1] = '--help';
- }
-
- // executable
- var dir = dirname(argv[1]);
- var bin = basename(argv[1], '.js') + '-' + args[0];
-
- // check for ./ first
- var local = path.join(dir, bin);
-
- // run it
- args = args.slice(1);
- args.unshift(local);
- var proc = spawn('node', args, { stdio: 'inherit', customFds: [0, 1, 2] });
- proc.on('error', function(err) {
- if (err.code == "ENOENT") {
- console.error('\n %s(1) does not exist, try --help\n', bin);
- } else if (err.code == "EACCES") {
- console.error('\n %s(1) not executable. try chmod or run with root\n', bin);
- }
- });
-
- this.runningCommand = proc;
-};
-
-/**
- * Normalize `args`, splitting joined short flags. For example
- * the arg "-abc" is equivalent to "-a -b -c".
- * This also normalizes equal sign and splits "--abc=def" into "--abc def".
- *
- * @param {Array} args
- * @return {Array}
- * @api private
- */
-
-Command.prototype.normalize = function(args) {
- var ret = []
- , arg
- , lastOpt
- , index;
-
- for (var i = 0, len = args.length; i < len; ++i) {
- arg = args[i];
- if (i > 0) {
- lastOpt = this.optionFor(args[i-1]);
- }
-
- if (arg === '--') {
- // Honor option terminator
- ret = ret.concat(args.slice(i));
- break;
- } else if (lastOpt && lastOpt.required) {
- ret.push(arg);
- } else if (arg.length > 1 && '-' == arg[0] && '-' != arg[1]) {
- arg.slice(1).split('').forEach(function(c) {
- ret.push('-' + c);
- });
- } else if (/^--/.test(arg) && ~(index = arg.indexOf('='))) {
- ret.push(arg.slice(0, index), arg.slice(index + 1));
- } else {
- ret.push(arg);
- }
- }
-
- return ret;
-};
-
-/**
- * Parse command `args`.
- *
- * When listener(s) are available those
- * callbacks are invoked, otherwise the "*"
- * event is emitted and those actions are invoked.
- *
- * @param {Array} args
- * @return {Command} for chaining
- * @api private
- */
-
-Command.prototype.parseArgs = function(args, unknown) {
- var name;
-
- if (args.length) {
- name = args[0];
- if (this.listeners(name).length) {
- this.emit(args.shift(), args, unknown);
- } else {
- this.emit('*', args);
- }
- } else {
- outputHelpIfNecessary(this, unknown);
-
- // If there were no args and we have unknown options,
- // then they are extraneous and we need to error.
- if (unknown.length > 0) {
- this.unknownOption(unknown[0]);
- }
- }
-
- return this;
-};
-
-/**
- * Return an option matching `arg` if any.
- *
- * @param {String} arg
- * @return {Option}
- * @api private
- */
-
-Command.prototype.optionFor = function(arg) {
- for (var i = 0, len = this.options.length; i < len; ++i) {
- if (this.options[i].is(arg)) {
- return this.options[i];
- }
- }
-};
-
-/**
- * Parse options from `argv` returning `argv`
- * void of these options.
- *
- * @param {Array} argv
- * @return {Array}
- * @api public
- */
-
-Command.prototype.parseOptions = function(argv) {
- var args = []
- , len = argv.length
- , literal
- , option
- , arg;
-
- var unknownOptions = [];
-
- // parse options
- for (var i = 0; i < len; ++i) {
- arg = argv[i];
-
- // literal args after --
- if ('--' == arg) {
- literal = true;
- continue;
- }
-
- if (literal) {
- args.push(arg);
- continue;
- }
-
- // find matching Option
- option = this.optionFor(arg);
-
- // option is defined
- if (option) {
- // requires arg
- if (option.required) {
- arg = argv[++i];
- if (null == arg) return this.optionMissingArgument(option);
- this.emit(option.name(), arg);
- // optional arg
- } else if (option.optional) {
- arg = argv[i+1];
- if (null == arg || ('-' == arg[0] && '-' != arg)) {
- arg = null;
- } else {
- ++i;
- }
- this.emit(option.name(), arg);
- // bool
- } else {
- this.emit(option.name());
- }
- continue;
- }
-
- // looks like an option
- if (arg.length > 1 && '-' == arg[0]) {
- unknownOptions.push(arg);
-
- // If the next argument looks like it might be
- // an argument for this option, we pass it on.
- // If it isn't, then it'll simply be ignored
- if (argv[i+1] && '-' != argv[i+1][0]) {
- unknownOptions.push(argv[++i]);
- }
- continue;
- }
-
- // arg
- args.push(arg);
- }
-
- return { args: args, unknown: unknownOptions };
-};
-
-/**
- * Return an object containing options as key-value pairs
- *
- * @return {Object}
- * @api public
- */
-Command.prototype.opts = function() {
- var result = {}
- , len = this.options.length;
-
- for (var i = 0 ; i < len; i++) {
- var key = this.options[i].name();
- result[key] = key === 'version' ? this._version : this[key];
- }
- return result;
-};
-
-/**
- * Argument `name` is missing.
- *
- * @param {String} name
- * @api private
- */
-
-Command.prototype.missingArgument = function(name) {
- console.error();
- console.error(" error: missing required argument `%s'", name);
- console.error();
- process.exit(1);
-};
-
-/**
- * `Option` is missing an argument, but received `flag` or nothing.
- *
- * @param {String} option
- * @param {String} flag
- * @api private
- */
-
-Command.prototype.optionMissingArgument = function(option, flag) {
- console.error();
- if (flag) {
- console.error(" error: option `%s' argument missing, got `%s'", option.flags, flag);
- } else {
- console.error(" error: option `%s' argument missing", option.flags);
- }
- console.error();
- process.exit(1);
-};
-
-/**
- * Unknown option `flag`.
- *
- * @param {String} flag
- * @api private
- */
-
-Command.prototype.unknownOption = function(flag) {
- if(this._allowUnknownOption) return;
- console.error();
- console.error(" error: unknown option `%s'", flag);
- console.error();
- process.exit(1);
-};
-
-/**
- * Variadic argument with `name` is not the last argument as required.
- *
- * @param {String} name
- * @api private
- */
-
-Command.prototype.variadicArgNotLast = function(name) {
- console.error();
- console.error(" error: variadic arguments must be last `%s'", name);
- console.error();
- process.exit(1);
-};
-
-/**
- * Set the program version to `str`.
- *
- * This method auto-registers the "-V, --version" flag
- * which will print the version number when passed.
- *
- * @param {String} str
- * @param {String} flags
- * @return {Command} for chaining
- * @api public
- */
-
-Command.prototype.version = function(str, flags) {
- if (0 == arguments.length) return this._version;
- this._version = str;
- flags = flags || '-V, --version';
- this.option(flags, 'output the version number');
- this.on('version', function() {
- process.stdout.write(str + '\n');
- process.exit(0);
- });
- return this;
-};
-
-/**
- * Set the description to `str`.
- *
- * @param {String} str
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.description = function(str) {
- if (0 == arguments.length) return this._description;
- this._description = str;
- return this;
-};
-
-/**
- * Set an alias for the command
- *
- * @param {String} alias
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.alias = function(alias) {
- if (0 == arguments.length) return this._alias;
- this._alias = alias;
- return this;
-};
-
-/**
- * Set / get the command usage `str`.
- *
- * @param {String} str
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.usage = function(str) {
- var args = this._args.map(function(arg) {
- return humanReadableArgName(arg);
- });
-
- var usage = '[options]'
- + (this.commands.length ? ' [command]' : '')
- + (this._args.length ? ' ' + args.join(' ') : '');
-
- if (0 == arguments.length) return this._usage || usage;
- this._usage = str;
-
- return this;
-};
-
-/**
- * Get the name of the command
- *
- * @param {String} name
- * @return {String|Command}
- * @api public
- */
-
-Command.prototype.name = function(name) {
- return this._name;
-};
-
-/**
- * Return the largest option length.
- *
- * @return {Number}
- * @api private
- */
-
-Command.prototype.largestOptionLength = function() {
- return this.options.reduce(function(max, option) {
- return Math.max(max, option.flags.length);
- }, 0);
-};
-
-/**
- * Return help for options.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.optionHelp = function() {
- var width = this.largestOptionLength();
-
- // Prepend the help information
- return [pad('-h, --help', width) + ' ' + 'output usage information']
- .concat(this.options.map(function(option) {
- return pad(option.flags, width) + ' ' + option.description;
- }))
- .join('\n');
-};
-
-/**
- * Return command help documentation.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.commandHelp = function() {
- if (!this.commands.length) return '';
-
- var commands = this.commands.map(function(cmd) {
- var args = cmd._args.map(function(arg) {
- return humanReadableArgName(arg);
- }).join(' ');
-
- return [
- cmd._name
- + (cmd._alias
- ? '|' + cmd._alias
- : '')
- + (cmd.options.length
- ? ' [options]'
- : '')
- + ' ' + args
- , cmd.description()
- ];
- });
-
- var width = commands.reduce(function(max, command) {
- return Math.max(max, command[0].length);
- }, 0);
-
- return [
- ''
- , ' Commands:'
- , ''
- , commands.map(function(cmd) {
- return pad(cmd[0], width) + ' ' + cmd[1];
- }).join('\n').replace(/^/gm, ' ')
- , ''
- ].join('\n');
-};
-
-/**
- * Return program help documentation.
- *
- * @return {String}
- * @api private
- */
-
-Command.prototype.helpInformation = function() {
- var desc = [];
- if (this._description) {
- desc = [
- ' ' + this._description
- , ''
- ];
- }
-
- var cmdName = this._name;
- if(this._alias) {
- cmdName = cmdName + '|' + this._alias;
- }
- var usage = [
- ''
- ,' Usage: ' + cmdName + ' ' + this.usage()
- , ''
- ];
-
- var cmds = [];
- var commandHelp = this.commandHelp();
- if (commandHelp) cmds = [commandHelp];
-
- var options = [
- ' Options:'
- , ''
- , '' + this.optionHelp().replace(/^/gm, ' ')
- , ''
- , ''
- ];
-
- return usage
- .concat(cmds)
- .concat(desc)
- .concat(options)
- .join('\n');
-};
-
-/**
- * Output help information for this command
- *
- * @api public
- */
-
-Command.prototype.outputHelp = function() {
- process.stdout.write(this.helpInformation());
- this.emit('--help');
-};
-
-/**
- * Output help information and exit.
- *
- * @api public
- */
-
-Command.prototype.help = function() {
- this.outputHelp();
- process.exit();
-};
-
-/**
- * Camel-case the given `flag`
- *
- * @param {String} flag
- * @return {String}
- * @api private
- */
-
-function camelcase(flag) {
- return flag.split('-').reduce(function(str, word) {
- return str + word[0].toUpperCase() + word.slice(1);
- });
-}
-
-/**
- * Pad `str` to `width`.
- *
- * @param {String} str
- * @param {Number} width
- * @return {String}
- * @api private
- */
-
-function pad(str, width) {
- var len = Math.max(0, width - str.length);
- return str + Array(len + 1).join(' ');
-}
-
-/**
- * Output help information if necessary
- *
- * @param {Command} command to output help for
- * @param {Array} array of options to search for -h or --help
- * @api private
- */
-
-function outputHelpIfNecessary(cmd, options) {
- options = options || [];
- for (var i = 0; i < options.length; i++) {
- if (options[i] == '--help' || options[i] == '-h') {
- cmd.outputHelp();
- process.exit(0);
- }
- }
-}
-
-/**
- * Takes an argument an returns its human readable equivalent for help usage.
- *
- * @param {Object} arg
- * @return {String}
- * @api private
- */
-
-function humanReadableArgName(arg) {
- var nameOutput = arg.name + (arg.variadic === true ? '...' : '');
-
- return arg.required
- ? '<' + nameOutput + '>'
- : '[' + nameOutput + ']'
-}
diff --git a/api/node_modules/commander/package.json b/api/node_modules/commander/package.json
deleted file mode 100644
index 128988d9b..000000000
--- a/api/node_modules/commander/package.json
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "_from": "commander@~2.6.0",
- "_id": "commander@2.6.0",
- "_inBundle": false,
- "_integrity": "sha1-nfflL7Kgyw+4kFjugMMQQiXzfh0=",
- "_location": "/commander",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "commander@~2.6.0",
- "name": "commander",
- "escapedName": "commander",
- "rawSpec": "~2.6.0",
- "saveSpec": null,
- "fetchSpec": "~2.6.0"
- },
- "_requiredBy": [
- "/jade"
- ],
- "_resolved": "https://registry.npmjs.org/commander/-/commander-2.6.0.tgz",
- "_shasum": "9df7e52fb2a0cb0fb89058ee80c3104225f37e1d",
- "_spec": "commander@~2.6.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/jade",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bugs": {
- "url": "https://github.com/tj/commander.js/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "the complete solution for node.js command-line programs",
- "devDependencies": {
- "should": ">= 0.0.1"
- },
- "engines": {
- "node": ">= 0.6.x"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/tj/commander.js#readme",
- "keywords": [
- "command",
- "option",
- "parser",
- "prompt"
- ],
- "license": "MIT",
- "main": "index",
- "name": "commander",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/tj/commander.js.git"
- },
- "scripts": {
- "test": "make test"
- },
- "version": "2.6.0"
-}
diff --git a/api/node_modules/constantinople/README.md b/api/node_modules/constantinople/README.md
deleted file mode 100644
index 506f7ea58..000000000
--- a/api/node_modules/constantinople/README.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# constantinople
-
-Determine whether a JavaScript expression evaluates to a constant (using acorn). Here it is assumed to be safe to underestimate how constant something is.
-
-[![Build Status](https://img.shields.io/travis/ForbesLindesay/constantinople/master.svg)](https://travis-ci.org/ForbesLindesay/constantinople)
-[![Dependency Status](https://img.shields.io/gemnasium/ForbesLindesay/constantinople.svg)](https://gemnasium.com/ForbesLindesay/constantinople)
-[![NPM version](https://img.shields.io/npm/v/constantinople.svg)](https://www.npmjs.org/package/constantinople)
-
-## Installation
-
- npm install constantinople
-
-## Usage
-
-```js
-var isConstant = require('constantinople')
-
-if (isConstant('"foo" + 5')) {
- console.dir(isConstant.toConstant('"foo" + 5'))
-}
-if (isConstant('Math.floor(10.5)', {Math: Math})) {
- console.dir(isConstant.toConstant('Math.floor(10.5)', {Math: Math}))
-}
-```
-
-## API
-
-### isConstant(src, [constants])
-
-Returns `true` if `src` evaluates to a constant, `false` otherwise. It will also return `false` if there is a syntax error, which makes it safe to use on potentially ES6 code.
-
-Constants is an object mapping strings to values, where those values should be treated as constants. Note that this makes it a pretty bad idea to have `Math` in there if the user might make use of `Math.random` and a pretty bad idea to have `Date` in there.
-
-### toConstant(src, [constants])
-
-Returns the value resulting from evaluating `src`. This method throws an error if the expression is not constant. e.g. `toConstant("Math.random()")` would throw an error.
-
-Constants is an object mapping strings to values, where those values should be treated as constants. Note that this makes it a pretty bad idea to have `Math` in there if the user might make use of `Math.random` and a pretty bad idea to have `Date` in there.
-
-## License
-
- MIT
diff --git a/api/node_modules/constantinople/index.js b/api/node_modules/constantinople/index.js
deleted file mode 100644
index 6a2f2f59d..000000000
--- a/api/node_modules/constantinople/index.js
+++ /dev/null
@@ -1,100 +0,0 @@
-'use strict'
-
-var acorn = require('acorn');
-var walk = require('acorn/dist/walk');
-
-var lastSRC = '(null)';
-var lastRes = true;
-var lastConstants = undefined;
-
-var STATEMENT_WHITE_LIST = {
- 'EmptyStatement': true,
- 'ExpressionStatement': true,
-};
-var EXPRESSION_WHITE_LIST = {
- 'ParenthesizedExpression': true,
- 'ArrayExpression': true,
- 'ObjectExpression': true,
- 'SequenceExpression': true,
- 'TemplateLiteral': true,
- 'UnaryExpression': true,
- 'BinaryExpression': true,
- 'LogicalExpression': true,
- 'ConditionalExpression': true,
- 'Identifier': true,
- 'Literal': true,
- 'ComprehensionExpression': true,
- 'TaggedTemplateExpression': true,
- 'MemberExpression': true,
- 'CallExpression': true,
- 'NewExpression': true,
-};
-module.exports = isConstant;
-function isConstant(src, constants) {
- src = '(' + src + ')';
- if (lastSRC === src && lastConstants === constants) return lastRes;
- lastSRC = src;
- lastConstants = constants;
- if (!isExpression(src)) return lastRes = false;
- var ast;
- try {
- ast = acorn.parse(src, {
- ecmaVersion: 6,
- allowReturnOutsideFunction: true,
- allowImportExportEverywhere: true,
- allowHashBang: true
- });
- } catch (ex) {
- return lastRes = false;
- }
- var isConstant = true;
- walk.simple(ast, {
- Statement: function (node) {
- if (isConstant) {
- if (STATEMENT_WHITE_LIST[node.type] !== true) {
- isConstant = false;
- }
- }
- },
- Expression: function (node) {
- if (isConstant) {
- if (EXPRESSION_WHITE_LIST[node.type] !== true) {
- isConstant = false;
- }
- }
- },
- MemberExpression: function (node) {
- if (isConstant) {
- if (node.computed) isConstant = false;
- else if (node.property.name[0] === '_') isConstant = false;
- }
- },
- Identifier: function (node) {
- if (isConstant) {
- if (!constants || !(node.name in constants)) {
- isConstant = false;
- }
- }
- },
- });
- return lastRes = isConstant;
-}
-isConstant.isConstant = isConstant;
-
-isConstant.toConstant = toConstant;
-function toConstant(src, constants) {
- if (!isConstant(src, constants)) throw new Error(JSON.stringify(src) + ' is not constant.');
- return Function(Object.keys(constants || {}).join(','), 'return (' + src + ')').apply(null, Object.keys(constants || {}).map(function (key) {
- return constants[key];
- }));
-}
-
-function isExpression(src) {
- try {
- eval('throw "STOP"; (function () { return (' + src + '); })()');
- return false;
- }
- catch (err) {
- return err === 'STOP';
- }
-}
diff --git a/api/node_modules/constantinople/package.json b/api/node_modules/constantinople/package.json
deleted file mode 100644
index 52df3a59e..000000000
--- a/api/node_modules/constantinople/package.json
+++ /dev/null
@@ -1,52 +0,0 @@
-{
- "_from": "constantinople@~3.0.1",
- "_id": "constantinople@3.0.2",
- "_inBundle": false,
- "_integrity": "sha1-S5RdmTeQe82Y7ldRIsOBdRZUQUE=",
- "_location": "/constantinople",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "constantinople@~3.0.1",
- "name": "constantinople",
- "escapedName": "constantinople",
- "rawSpec": "~3.0.1",
- "saveSpec": null,
- "fetchSpec": "~3.0.1"
- },
- "_requiredBy": [
- "/jade"
- ],
- "_resolved": "https://registry.npmjs.org/constantinople/-/constantinople-3.0.2.tgz",
- "_shasum": "4b945d9937907bcd98ee575122c3817516544141",
- "_spec": "constantinople@~3.0.1",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/jade",
- "author": {
- "name": "ForbesLindesay"
- },
- "bugs": {
- "url": "https://github.com/ForbesLindesay/constantinople/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "acorn": "^2.1.0"
- },
- "deprecated": "Please update to at least constantinople 3.1.1",
- "description": "Determine whether a JavaScript expression evaluates to a constant (using UglifyJS)",
- "devDependencies": {
- "mocha": "*"
- },
- "homepage": "https://github.com/ForbesLindesay/constantinople#readme",
- "keywords": [],
- "license": "MIT",
- "name": "constantinople",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/ForbesLindesay/constantinople.git"
- },
- "scripts": {
- "test": "mocha -R spec"
- },
- "version": "3.0.2"
-}
diff --git a/api/node_modules/constantinople/test/index.js b/api/node_modules/constantinople/test/index.js
deleted file mode 100644
index 6fd614bd0..000000000
--- a/api/node_modules/constantinople/test/index.js
+++ /dev/null
@@ -1,71 +0,0 @@
-'use strict'
-
-var assert = require('assert')
-var constaninople = require('../')
-
-describe('isConstant(src)', function () {
- it('handles "[5 + 3 + 10]"', function () {
- assert(constaninople.isConstant('[5 + 3 + 10]') === true)
- })
- it('handles "/[a-z]/.test(\'a\')"', function () {
- assert(constaninople.isConstant('/[a-z]/.test(\'a\')') === true)
- })
- it('handles "{\'class\': [(\'data\')]}"', function () {
- assert(constaninople.isConstant('{\'class\': [(\'data\')]}') === true)
- })
- it('handles "Math.random()"', function () {
- assert(constaninople.isConstant('Math.random()') === false)
- })
- it('handles "Math.random("', function () {
- assert(constaninople.isConstant('Math.random(') === false)
- })
- it('handles "Math.floor(10.5)" with {Math: Math} as constants', function () {
- assert(constaninople.isConstant('Math.floor(10.5)', {Math: Math}) === true)
- })
- it('handles "this.myVar"', function () {
- assert(constaninople.isConstant('this.myVar') === false)
- })
- it('handles "(function () { while (true); return 10; }())"', function () {
- assert(constaninople.isConstant('(function () { while (true); return 10; }())') === false)
- })
-})
-
-
-describe('toConstant(src)', function () {
- it('handles "[5 + 3 + 10]"', function () {
- assert.deepEqual(constaninople.toConstant('[5 + 3 + 10]'), [5 + 3 + 10])
- })
- it('handles "/[a-z]/.test(\'a\')"', function () {
- assert(constaninople.toConstant('/[a-z]/.test(\'a\')') === true)
- })
- it('handles "{\'class\': [(\'data\')]}"', function () {
- assert.deepEqual(constaninople.toConstant('{\'class\': [(\'data\')]}'), {'class': ['data']})
- })
- it('handles "Math.random()"', function () {
- try {
- constaninople.toConstant('Math.random()')
- } catch (ex) {
- return
- }
- assert(false, 'Math.random() should result in an error')
- })
- it('handles "Math.random("', function () {
- try {
- constaninople.toConstant('Math.random(')
- } catch (ex) {
- return
- }
- assert(false, 'Math.random( should result in an error')
- })
- it('handles "Math.floor(10.5)" with {Math: Math} as constants', function () {
- assert(constaninople.toConstant('Math.floor(10.5)', {Math: Math}) === 10)
- })
- it('handles "(function () { while (true); return 10; }())"', function () {
- try {
- constaninople.toConstant('(function () { while (true); return 10; }())')
- } catch (ex) {
- return
- }
- assert(false, '(function () { while (true); return 10; }()) should result in an error')
- })
-})
diff --git a/api/node_modules/content-disposition/HISTORY.md b/api/node_modules/content-disposition/HISTORY.md
index 53849b618..63a3d08c7 100644
--- a/api/node_modules/content-disposition/HISTORY.md
+++ b/api/node_modules/content-disposition/HISTORY.md
@@ -1,3 +1,8 @@
+0.5.3 / 2018-12-17
+==================
+
+ * Use `safe-buffer` for improved Buffer API
+
0.5.2 / 2016-12-08
==================
diff --git a/api/node_modules/content-disposition/LICENSE b/api/node_modules/content-disposition/LICENSE
index b7dce6cf9..84441fbb5 100644
--- a/api/node_modules/content-disposition/LICENSE
+++ b/api/node_modules/content-disposition/LICENSE
@@ -1,6 +1,6 @@
(The MIT License)
-Copyright (c) 2014 Douglas Christopher Wilson
+Copyright (c) 2014-2017 Douglas Christopher Wilson
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/api/node_modules/content-disposition/README.md b/api/node_modules/content-disposition/README.md
index 992d19a62..eebef13d4 100644
--- a/api/node_modules/content-disposition/README.md
+++ b/api/node_modules/content-disposition/README.md
@@ -16,6 +16,8 @@ $ npm install content-disposition
## API
+
+
```js
var contentDisposition = require('content-disposition')
```
@@ -26,6 +28,8 @@ Create an attachment `Content-Disposition` header value using the given file nam
if supplied. The `filename` is optional and if no file name is desired, but you
want to specify `options`, set `filename` to `undefined`.
+
+
```js
res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
```
@@ -66,8 +70,10 @@ it). The type is normalized to lower-case.
### contentDisposition.parse(string)
+
+
```js
-var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt');
+var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
```
Parse a `Content-Disposition` header string. This automatically handles extended
@@ -88,12 +94,13 @@ are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-
```js
var contentDisposition = require('content-disposition')
var destroy = require('destroy')
+var fs = require('fs')
var http = require('http')
var onFinished = require('on-finished')
var filePath = '/path/to/public/plans.pdf'
-http.createServer(function onRequest(req, res) {
+http.createServer(function onRequest (req, res) {
// set headers
res.setHeader('Content-Type', 'application/pdf')
res.setHeader('Content-Disposition', contentDisposition(filePath))
@@ -101,7 +108,7 @@ http.createServer(function onRequest(req, res) {
// send file
var stream = fs.createReadStream(filePath)
stream.pipe(res)
- onFinished(res, function (err) {
+ onFinished(res, function () {
destroy(stream)
})
})
@@ -129,13 +136,13 @@ $ npm test
[MIT](LICENSE)
-[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat
+[npm-image]: https://img.shields.io/npm/v/content-disposition.svg
[npm-url]: https://npmjs.org/package/content-disposition
-[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat
+[node-version-image]: https://img.shields.io/node/v/content-disposition.svg
[node-version-url]: https://nodejs.org/en/download
-[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat
+[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg
[travis-url]: https://travis-ci.org/jshttp/content-disposition
-[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg
[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
-[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat
+[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg
[downloads-url]: https://npmjs.org/package/content-disposition
diff --git a/api/node_modules/content-disposition/index.js b/api/node_modules/content-disposition/index.js
index 88a0d0a23..3092a4dc3 100644
--- a/api/node_modules/content-disposition/index.js
+++ b/api/node_modules/content-disposition/index.js
@@ -1,6 +1,6 @@
/*!
* content-disposition
- * Copyright(c) 2014 Douglas Christopher Wilson
+ * Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/
@@ -8,6 +8,7 @@
/**
* Module exports.
+ * @public
*/
module.exports = contentDisposition
@@ -15,18 +16,22 @@ module.exports.parse = parse
/**
* Module dependencies.
+ * @private
*/
var basename = require('path').basename
+var Buffer = require('safe-buffer').Buffer
/**
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
+ * @private
*/
var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g // eslint-disable-line no-control-regex
/**
* RegExp to match percent encoding escape.
+ * @private
*/
var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/
@@ -34,6 +39,7 @@ var HEX_ESCAPE_REPLACE_REGEXP = /%([0-9A-Fa-f]{2})/g
/**
* RegExp to match non-latin1 characters.
+ * @private
*/
var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
@@ -43,12 +49,14 @@ var NON_LATIN1_REGEXP = /[^\x20-\x7e\xa0-\xff]/g
*
* quoted-pair = "\" CHAR
* CHAR =
+ * @private
*/
-var QESC_REGEXP = /\\([\u0000-\u007f])/g
+var QESC_REGEXP = /\\([\u0000-\u007f])/g // eslint-disable-line no-control-regex
/**
* RegExp to match chars that must be quoted-pair in RFC 2616
+ * @private
*/
var QUOTE_REGEXP = /([\\"])/g
@@ -75,6 +83,7 @@ var QUOTE_REGEXP = /([\\"])/g
* HT =
* CTL =
* OCTET =
+ * @private
*/
var PARAM_REGEXP = /;[\x09\x20]*([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*=[\x09\x20]*("(?:[\x20!\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*/g // eslint-disable-line no-control-regex
@@ -100,6 +109,7 @@ var TOKEN_REGEXP = /^[!#$%&'*+.0-9A-Z^_`a-z|~-]+$/
* attr-char = ALPHA / DIGIT
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
* / "^" / "_" / "`" / "|" / "~"
+ * @private
*/
var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+.^_`|~-])+)$/
@@ -115,6 +125,7 @@ var EXT_VALUE_REGEXP = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-
* disp-ext-parm = token "=" value
* | ext-token "=" ext-value
* ext-token =
+ * @private
*/
var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/ // eslint-disable-line no-control-regex
@@ -127,7 +138,7 @@ var DISPOSITION_TYPE_REGEXP = /^([!#$%&'*+.0-9A-Z^_`a-z|~-]+)[\x09\x20]*(?:$|;)/
* @param {string} [options.type=attachment]
* @param {string|boolean} [options.fallback=true]
* @return {string}
- * @api public
+ * @public
*/
function contentDisposition (filename, options) {
@@ -149,7 +160,7 @@ function contentDisposition (filename, options) {
* @param {string} [filename]
* @param {string|boolean} [fallback=true]
* @return {object}
- * @api private
+ * @private
*/
function createparams (filename, fallback) {
@@ -210,7 +221,7 @@ function createparams (filename, fallback) {
* @param {string} obj.type
* @param {object} [obj.parameters]
* @return {string}
- * @api private
+ * @private
*/
function format (obj) {
@@ -248,7 +259,7 @@ function format (obj) {
*
* @param {string} str
* @return {string}
- * @api private
+ * @private
*/
function decodefield (str) {
@@ -270,7 +281,7 @@ function decodefield (str) {
value = getlatin1(binary)
break
case 'utf-8':
- value = new Buffer(binary, 'binary').toString('utf8')
+ value = Buffer.from(binary, 'binary').toString('utf8')
break
default:
throw new TypeError('unsupported charset in extended field')
@@ -284,7 +295,7 @@ function decodefield (str) {
*
* @param {string} val
* @return {string}
- * @api private
+ * @private
*/
function getlatin1 (val) {
@@ -297,7 +308,7 @@ function getlatin1 (val) {
*
* @param {string} string
* @return {object}
- * @api private
+ * @public
*/
function parse (string) {
@@ -378,7 +389,7 @@ function parse (string) {
* @param {string} str
* @param {string} hex
* @return {string}
- * @api private
+ * @private
*/
function pdecode (str, hex) {
@@ -390,17 +401,14 @@ function pdecode (str, hex) {
*
* @param {string} char
* @return {string}
- * @api private
+ * @private
*/
function pencode (char) {
- var hex = String(char)
+ return '%' + String(char)
.charCodeAt(0)
.toString(16)
.toUpperCase()
- return hex.length === 1
- ? '%0' + hex
- : '%' + hex
}
/**
@@ -408,7 +416,7 @@ function pencode (char) {
*
* @param {string} val
* @return {string}
- * @api private
+ * @private
*/
function qstring (val) {
@@ -422,7 +430,7 @@ function qstring (val) {
*
* @param {string} val
* @return {string}
- * @api private
+ * @private
*/
function ustring (val) {
@@ -437,6 +445,11 @@ function ustring (val) {
/**
* Class for parsed Content-Disposition header for v8 optimization
+ *
+ * @public
+ * @param {string} type
+ * @param {object} parameters
+ * @constructor
*/
function ContentDisposition (type, parameters) {
diff --git a/api/node_modules/content-disposition/package.json b/api/node_modules/content-disposition/package.json
index cb0ab3376..814f7f3f4 100644
--- a/api/node_modules/content-disposition/package.json
+++ b/api/node_modules/content-disposition/package.json
@@ -1,49 +1,30 @@
{
- "_from": "content-disposition@0.5.2",
- "_id": "content-disposition@0.5.2",
- "_inBundle": false,
- "_integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=",
- "_location": "/content-disposition",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "content-disposition@0.5.2",
- "name": "content-disposition",
- "escapedName": "content-disposition",
- "rawSpec": "0.5.2",
- "saveSpec": null,
- "fetchSpec": "0.5.2"
- },
- "_requiredBy": [
- "/express"
+ "name": "content-disposition",
+ "description": "Create and parse Content-Disposition header",
+ "version": "0.5.3",
+ "author": "Douglas Christopher Wilson ",
+ "license": "MIT",
+ "keywords": [
+ "content-disposition",
+ "http",
+ "rfc6266",
+ "res"
],
- "_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz",
- "_shasum": "0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4",
- "_spec": "content-disposition@0.5.2",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/express",
- "bugs": {
- "url": "https://github.com/jshttp/content-disposition/issues"
+ "repository": "jshttp/content-disposition",
+ "dependencies": {
+ "safe-buffer": "5.1.2"
},
- "bundleDependencies": false,
- "contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- }
- ],
- "deprecated": false,
- "description": "Create and parse Content-Disposition header",
"devDependencies": {
- "eslint": "3.11.1",
- "eslint-config-standard": "6.2.1",
- "eslint-plugin-promise": "3.3.0",
- "eslint-plugin-standard": "2.0.1",
+ "deep-equal": "1.0.1",
+ "eslint": "5.10.0",
+ "eslint-config-standard": "12.0.0",
+ "eslint-plugin-import": "2.14.0",
+ "eslint-plugin-markdown": "1.0.0-rc.1",
+ "eslint-plugin-node": "7.0.1",
+ "eslint-plugin-promise": "4.0.1",
+ "eslint-plugin-standard": "4.0.0",
"istanbul": "0.4.5",
- "mocha": "1.21.5"
- },
- "engines": {
- "node": ">= 0.6"
+ "mocha": "5.2.0"
},
"files": [
"LICENSE",
@@ -51,24 +32,13 @@
"README.md",
"index.js"
],
- "homepage": "https://github.com/jshttp/content-disposition#readme",
- "keywords": [
- "content-disposition",
- "http",
- "rfc6266",
- "res"
- ],
- "license": "MIT",
- "name": "content-disposition",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jshttp/content-disposition.git"
+ "engines": {
+ "node": ">= 0.6"
},
"scripts": {
- "lint": "eslint .",
+ "lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
- },
- "version": "0.5.2"
+ }
}
diff --git a/api/node_modules/cookie-parser/HISTORY.md b/api/node_modules/cookie-parser/HISTORY.md
index 4f28f505e..3405d50c7 100644
--- a/api/node_modules/cookie-parser/HISTORY.md
+++ b/api/node_modules/cookie-parser/HISTORY.md
@@ -1,3 +1,13 @@
+1.4.5 / 2020-03-14
+==================
+
+ * deps: cookie@0.4.0
+
+1.4.4 / 2019-02-12
+==================
+
+ * perf: normalize `secret` argument only once
+
1.4.3 / 2016-05-26
==================
@@ -10,7 +20,7 @@
* deps: cookie@0.2.4
- perf: enable strict mode
- perf: use for loop in parse
- - perf: use string concatination for serialization
+ - perf: use string concatenation for serialization
1.4.1 / 2016-01-11
==================
diff --git a/api/node_modules/cookie-parser/README.md b/api/node_modules/cookie-parser/README.md
index 05dbdc5a4..bc0d27109 100644
--- a/api/node_modules/cookie-parser/README.md
+++ b/api/node_modules/cookie-parser/README.md
@@ -1,14 +1,14 @@
# cookie-parser
-[![NPM Version][npm-image]][npm-url]
-[![NPM Downloads][downloads-image]][downloads-url]
-[![Node.js Version][node-version-image]][node-version-url]
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
-Parse `Cookie` header and populate `req.cookies` with an object keyed by the cookie
-names. Optionally you may enable signed cookie support by passing a `secret` string,
-which assigns `req.secret` so it may be used by other middleware.
+Parse `Cookie` header and populate `req.cookies` with an object keyed by the
+cookie names. Optionally you may enable signed cookie support by passing a
+`secret` string, which assigns `req.secret` so it may be used by other
+middleware.
## Installation
@@ -19,7 +19,7 @@ $ npm install cookie-parser
## API
```js
-var express = require('express')
+var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
@@ -28,41 +28,61 @@ app.use(cookieParser())
### cookieParser(secret, options)
-- `secret` a string or array used for signing cookies. This is optional and if not specified, will not parse signed cookies. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
-- `options` an object that is passed to `cookie.parse` as the second option. See [cookie](https://www.npmjs.org/package/cookie) for more information.
+- `secret` a string or array used for signing cookies. This is optional and if
+ not specified, will not parse signed cookies. If a string is provided, this
+ is used as the secret. If an array is provided, an attempt will be made to
+ unsign the cookie with each secret in order.
+- `options` an object that is passed to `cookie.parse` as the second option. Se
+ [cookie](https://www.npmjs.org/package/cookie) for more information.
- `decode` a function to decode the value of the cookie
### cookieParser.JSONCookie(str)
-Parse a cookie value as a JSON cookie. This will return the parsed JSON value if it was a JSON cookie, otherwise it will return the passed value.
+Parse a cookie value as a JSON cookie. This will return the parsed JSON value
+if it was a JSON cookie, otherwise, it will return the passed value.
### cookieParser.JSONCookies(cookies)
-Given an object, this will iterate over the keys and call `JSONCookie` on each value. This will return the same object passed in.
+Given an object, this will iterate over the keys and call `JSONCookie` on each
+value, replacing the original value with the parsed value. This returns the
+same object that was passed in.
### cookieParser.signedCookie(str, secret)
-Parse a cookie value as a signed cookie. This will return the parsed unsigned value if it was a signed cookie and the signature was valid, otherwise it will return the passed value.
+Parse a cookie value as a signed cookie. This will return the parsed unsigned
+value if it was a signed cookie and the signature was valid. If the value was
+not signed, the original value is returned. If the value was signed but the
+signature could not be validated, `false` is returned.
-The `secret` argument can be an array or string. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
+The `secret` argument can be an array or string. If a string is provided, this
+is used as the secret. If an array is provided, an attempt will be made to
+unsign the cookie with each secret in order.
### cookieParser.signedCookies(cookies, secret)
-Given an object, this will iterate over the keys and check if any value is a signed cookie. If it is a signed cookie and the signature is valid, the key will be deleted from the object and added to the new object that is returned.
+Given an object, this will iterate over the keys and check if any value is a
+signed cookie. If it is a signed cookie and the signature is valid, the key
+will be deleted from the object and added to the new object that is returned.
-The `secret` argument can be an array or string. If a string is provided, this is used as the secret. If an array is provided, an attempt will be made to unsign the cookie with each secret in order.
+The `secret` argument can be an array or string. If a string is provided, this
+is used as the secret. If an array is provided, an attempt will be made to
+unsign the cookie with each secret in order.
## Example
```js
-var express = require('express')
+var express = require('express')
var cookieParser = require('cookie-parser')
var app = express()
app.use(cookieParser())
-app.get('/', function(req, res) {
+app.get('/', function (req, res) {
+ // Cookies that have not been signed
console.log('Cookies: ', req.cookies)
+
+ // Cookies that have been signed
+ console.log('Signed Cookies: ', req.signedCookies)
})
app.listen(8080)
@@ -73,13 +93,10 @@ app.listen(8080)
### [MIT Licensed](LICENSE)
-[npm-image]: https://img.shields.io/npm/v/cookie-parser.svg
+[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/cookie-parser/master
+[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master
+[npm-downloads-image]: https://badgen.net/npm/dm/cookie-parser
[npm-url]: https://npmjs.org/package/cookie-parser
-[node-version-image]: https://img.shields.io/node/v/cookie-parser.svg
-[node-version-url]: https://nodejs.org/en/download
-[travis-image]: https://img.shields.io/travis/expressjs/cookie-parser/master.svg
+[npm-version-image]: https://badgen.net/npm/v/cookie-parser
+[travis-image]: https://badgen.net/travis/expressjs/cookie-parser/master
[travis-url]: https://travis-ci.org/expressjs/cookie-parser
-[coveralls-image]: https://img.shields.io/coveralls/expressjs/cookie-parser/master.svg
-[coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master
-[downloads-image]: https://img.shields.io/npm/dm/cookie-parser.svg
-[downloads-url]: https://npmjs.org/package/cookie-parser
diff --git a/api/node_modules/cookie-parser/index.js b/api/node_modules/cookie-parser/index.js
index 59816a223..dd6d479ad 100644
--- a/api/node_modules/cookie-parser/index.js
+++ b/api/node_modules/cookie-parser/index.js
@@ -5,26 +5,26 @@
* MIT Licensed
*/
-'use strict';
+'use strict'
/**
* Module dependencies.
* @private
*/
-var cookie = require('cookie');
-var signature = require('cookie-signature');
+var cookie = require('cookie')
+var signature = require('cookie-signature')
/**
* Module exports.
* @public
*/
-module.exports = cookieParser;
-module.exports.JSONCookie = JSONCookie;
-module.exports.JSONCookies = JSONCookies;
-module.exports.signedCookie = signedCookie;
-module.exports.signedCookies = signedCookies;
+module.exports = cookieParser
+module.exports.JSONCookie = JSONCookie
+module.exports.JSONCookies = JSONCookies
+module.exports.signedCookie = signedCookie
+module.exports.signedCookies = signedCookies
/**
* Parse Cookie header and populate `req.cookies`
@@ -36,39 +36,40 @@ module.exports.signedCookies = signedCookies;
* @public
*/
-function cookieParser(secret, options) {
- return function cookieParser(req, res, next) {
+function cookieParser (secret, options) {
+ var secrets = !secret || Array.isArray(secret)
+ ? (secret || [])
+ : [secret]
+
+ return function cookieParser (req, res, next) {
if (req.cookies) {
- return next();
+ return next()
}
- var cookies = req.headers.cookie;
- var secrets = !secret || Array.isArray(secret)
- ? (secret || [])
- : [secret];
+ var cookies = req.headers.cookie
- req.secret = secrets[0];
- req.cookies = Object.create(null);
- req.signedCookies = Object.create(null);
+ req.secret = secrets[0]
+ req.cookies = Object.create(null)
+ req.signedCookies = Object.create(null)
// no cookies
if (!cookies) {
- return next();
+ return next()
}
- req.cookies = cookie.parse(cookies, options);
+ req.cookies = cookie.parse(cookies, options)
// parse signed cookies
if (secrets.length !== 0) {
- req.signedCookies = signedCookies(req.cookies, secrets);
- req.signedCookies = JSONCookies(req.signedCookies);
+ req.signedCookies = signedCookies(req.cookies, secrets)
+ req.signedCookies = JSONCookies(req.signedCookies)
}
// parse JSON cookies
- req.cookies = JSONCookies(req.cookies);
+ req.cookies = JSONCookies(req.cookies)
- next();
- };
+ next()
+ }
}
/**
@@ -79,15 +80,15 @@ function cookieParser(secret, options) {
* @public
*/
-function JSONCookie(str) {
+function JSONCookie (str) {
if (typeof str !== 'string' || str.substr(0, 2) !== 'j:') {
- return undefined;
+ return undefined
}
try {
- return JSON.parse(str.slice(2));
+ return JSON.parse(str.slice(2))
} catch (err) {
- return undefined;
+ return undefined
}
}
@@ -99,21 +100,21 @@ function JSONCookie(str) {
* @public
*/
-function JSONCookies(obj) {
- var cookies = Object.keys(obj);
- var key;
- var val;
+function JSONCookies (obj) {
+ var cookies = Object.keys(obj)
+ var key
+ var val
for (var i = 0; i < cookies.length; i++) {
- key = cookies[i];
- val = JSONCookie(obj[key]);
+ key = cookies[i]
+ val = JSONCookie(obj[key])
if (val) {
- obj[key] = val;
+ obj[key] = val
}
}
- return obj;
+ return obj
}
/**
@@ -125,28 +126,28 @@ function JSONCookies(obj) {
* @public
*/
-function signedCookie(str, secret) {
+function signedCookie (str, secret) {
if (typeof str !== 'string') {
- return undefined;
+ return undefined
}
if (str.substr(0, 2) !== 's:') {
- return str;
+ return str
}
var secrets = !secret || Array.isArray(secret)
? (secret || [])
- : [secret];
+ : [secret]
for (var i = 0; i < secrets.length; i++) {
- var val = signature.unsign(str.slice(2), secrets[i]);
+ var val = signature.unsign(str.slice(2), secrets[i])
if (val !== false) {
- return val;
+ return val
}
}
- return false;
+ return false
}
/**
@@ -159,23 +160,23 @@ function signedCookie(str, secret) {
* @public
*/
-function signedCookies(obj, secret) {
- var cookies = Object.keys(obj);
- var dec;
- var key;
- var ret = Object.create(null);
- var val;
+function signedCookies (obj, secret) {
+ var cookies = Object.keys(obj)
+ var dec
+ var key
+ var ret = Object.create(null)
+ var val
for (var i = 0; i < cookies.length; i++) {
- key = cookies[i];
- val = obj[key];
- dec = signedCookie(val, secret);
+ key = cookies[i]
+ val = obj[key]
+ dec = signedCookie(val, secret)
if (val !== dec) {
- ret[key] = dec;
- delete obj[key];
+ ret[key] = dec
+ delete obj[key]
}
}
- return ret;
+ return ret
}
diff --git a/api/node_modules/cookie-parser/package.json b/api/node_modules/cookie-parser/package.json
index dba7f29a5..c3d1eaf30 100644
--- a/api/node_modules/cookie-parser/package.json
+++ b/api/node_modules/cookie-parser/package.json
@@ -1,76 +1,45 @@
{
- "_from": "cookie-parser@~1.4.3",
- "_id": "cookie-parser@1.4.3",
- "_inBundle": false,
- "_integrity": "sha1-D+MfoZ0AC5X0qt8fU/3CuKIDuqU=",
- "_location": "/cookie-parser",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "cookie-parser@~1.4.3",
- "name": "cookie-parser",
- "escapedName": "cookie-parser",
- "rawSpec": "~1.4.3",
- "saveSpec": null,
- "fetchSpec": "~1.4.3"
- },
- "_requiredBy": [
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.3.tgz",
- "_shasum": "0fe31fa19d000b95f4aadf1f53fdc2b8a203baa5",
- "_spec": "cookie-parser@~1.4.3",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca",
- "url": "http://tjholowaychuk.com"
- },
- "bugs": {
- "url": "https://github.com/expressjs/cookie-parser/issues"
- },
- "bundleDependencies": false,
+ "name": "cookie-parser",
+ "description": "Parse HTTP request cookies",
+ "version": "1.4.5",
+ "author": "TJ Holowaychuk (http://tjholowaychuk.com)",
"contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- }
+ "Douglas Christopher Wilson "
+ ],
+ "license": "MIT",
+ "repository": "expressjs/cookie-parser",
+ "keywords": [
+ "cookie",
+ "middleware"
],
"dependencies": {
- "cookie": "0.3.1",
+ "cookie": "0.4.0",
"cookie-signature": "1.0.6"
},
- "deprecated": false,
- "description": "cookie parsing with signatures",
"devDependencies": {
- "istanbul": "0.4.3",
- "mocha": "2.5.3",
- "supertest": "1.1.0"
- },
- "engines": {
- "node": ">= 0.8.0"
+ "eslint": "6.8.0",
+ "eslint-config-standard": "14.1.0",
+ "eslint-plugin-import": "2.20.1",
+ "eslint-plugin-markdown": "1.0.2",
+ "eslint-plugin-node": "11.0.0",
+ "eslint-plugin-promise": "4.2.1",
+ "eslint-plugin-standard": "4.0.1",
+ "istanbul": "0.4.5",
+ "mocha": "7.1.0",
+ "supertest": "4.0.2"
},
"files": [
"LICENSE",
"HISTORY.md",
"index.js"
],
- "homepage": "https://github.com/expressjs/cookie-parser#readme",
- "keywords": [
- "cookie",
- "middleware"
- ],
- "license": "MIT",
- "name": "cookie-parser",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/expressjs/cookie-parser.git"
+ "engines": {
+ "node": ">= 0.8.0"
},
"scripts": {
+ "lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
- },
- "version": "1.4.3"
+ }
}
diff --git a/api/node_modules/cookie/HISTORY.md b/api/node_modules/cookie/HISTORY.md
index 5bd648542..da2bf243d 100644
--- a/api/node_modules/cookie/HISTORY.md
+++ b/api/node_modules/cookie/HISTORY.md
@@ -1,3 +1,8 @@
+0.4.0 / 2019-05-15
+==================
+
+ * Add `SameSite=None` support
+
0.3.1 / 2016-05-26
==================
diff --git a/api/node_modules/cookie/README.md b/api/node_modules/cookie/README.md
index db0d07825..857fb77c7 100644
--- a/api/node_modules/cookie/README.md
+++ b/api/node_modules/cookie/README.md
@@ -1,7 +1,7 @@
# cookie
-[![NPM Version][npm-image]][npm-url]
-[![NPM Downloads][downloads-image]][downloads-url]
+[![NPM Version][npm-version-image]][npm-url]
+[![NPM Downloads][npm-downloads-image]][npm-url]
[![Node.js Version][node-version-image]][node-version-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]
@@ -64,7 +64,7 @@ var setCookie = cookie.serialize('foo', 'bar');
##### domain
-Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6266-5.2.3]. By default, no
+Specifies the value for the [`Domain` `Set-Cookie` attribute][rfc-6265-5.2.3]. By default, no
domain is set, and most clients will consider the cookie to apply to only the current domain.
##### encode
@@ -73,22 +73,22 @@ Specifies a function that will be used to encode a cookie's value. Since value o
has a limited character set (and must be a simple string), this function can be used to encode
a value into a string suited for a cookie's value.
-The default function is the global `ecodeURIComponent`, which will encode a JavaScript string
+The default function is the global `encodeURIComponent`, which will encode a JavaScript string
into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
##### expires
-Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6266-5.2.1].
+Specifies the `Date` object to be the value for the [`Expires` `Set-Cookie` attribute][rfc-6265-5.2.1].
By default, no expiration is set, and most clients will consider this a "non-persistent cookie" and
will delete it on a condition like exiting a web browser application.
-**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
-`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
+**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
+`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### httpOnly
-Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6266-5.2.6]. When truthy,
+Specifies the `boolean` value for the [`HttpOnly` `Set-Cookie` attribute][rfc-6265-5.2.6]. When truthy,
the `HttpOnly` attribute is set, otherwise it is not. By default, the `HttpOnly` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not allow client-side
@@ -96,38 +96,37 @@ JavaScript to see the cookie in `document.cookie`.
##### maxAge
-Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6266-5.2.2].
+Specifies the `number` (in seconds) to be the value for the [`Max-Age` `Set-Cookie` attribute][rfc-6265-5.2.2].
The given number will be converted to an integer by rounding down. By default, no maximum age is set.
-**note** the [cookie storage model specification][rfc-6266-5.3] states that if both `expires` and
-`magAge` are set, then `maxAge` takes precedence, but it is possiblke not all clients by obey this,
+**note** the [cookie storage model specification][rfc-6265-5.3] states that if both `expires` and
+`maxAge` are set, then `maxAge` takes precedence, but it is possible not all clients by obey this,
so if both are set, they should point to the same date and time.
##### path
-Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6266-5.2.4]. By default, the path
-is considered the ["default path"][rfc-6266-5.1.4]. By default, no maximum age is set, and most
-clients will consider this a "non-persistent cookie" and will delete it on a condition like exiting
-a web browser application.
+Specifies the value for the [`Path` `Set-Cookie` attribute][rfc-6265-5.2.4]. By default, the path
+is considered the ["default path"][rfc-6265-5.1.4].
##### sameSite
-Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][draft-west-first-party-cookies-07].
+Specifies the `boolean` or `string` to be the value for the [`SameSite` `Set-Cookie` attribute][rfc-6265bis-03-4.1.2.7].
- `true` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
- `false` will not set the `SameSite` attribute.
- `'lax'` will set the `SameSite` attribute to `Lax` for lax same site enforcement.
+ - `'none'` will set the `SameSite` attribute to `None` for an explicit cross-site cookie.
- `'strict'` will set the `SameSite` attribute to `Strict` for strict same site enforcement.
-More information about the different enforcement levels can be found in the specification
-https://tools.ietf.org/html/draft-west-first-party-cookies-07#section-4.1.1
+More information about the different enforcement levels can be found in
+[the specification][rfc-6265bis-03-4.1.2.7].
**note** This is an attribute that has not yet been fully standardized, and may change in the future.
This also means many clients may ignore this attribute until they understand it.
##### secure
-Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6266-5.2.5]. When truthy,
+Specifies the `boolean` value for the [`Secure` `Set-Cookie` attribute][rfc-6265-5.2.5]. When truthy,
the `Secure` attribute is set, otherwise it is not. By default, the `Secure` attribute is not set.
**note** be careful when setting this to `true`, as compliant clients will not send the cookie back to
@@ -178,7 +177,7 @@ function onRequest(req, res) {
res.write('');
}
http.createServer(onRequest).listen(3000);
@@ -190,31 +189,65 @@ http.createServer(onRequest).listen(3000);
$ npm test
```
+## Benchmark
+
+```
+$ npm run bench
+
+> cookie@0.3.1 bench cookie
+> node benchmark/index.js
+
+ http_parser@2.8.0
+ node@6.14.2
+ v8@5.1.281.111
+ uv@1.16.1
+ zlib@1.2.11
+ ares@1.10.1-DEV
+ icu@58.2
+ modules@48
+ napi@3
+ openssl@1.0.2o
+
+> node benchmark/parse.js
+
+ cookie.parse
+
+ 6 tests completed.
+
+ simple x 1,200,691 ops/sec ±1.12% (189 runs sampled)
+ decode x 1,012,994 ops/sec ±0.97% (186 runs sampled)
+ unquote x 1,074,174 ops/sec ±2.43% (186 runs sampled)
+ duplicates x 438,424 ops/sec ±2.17% (184 runs sampled)
+ 10 cookies x 147,154 ops/sec ±1.01% (186 runs sampled)
+ 100 cookies x 14,274 ops/sec ±1.07% (187 runs sampled)
+```
+
## References
-- [RFC 6266: HTTP State Management Mechanism][rfc-6266]
-- [Same-site Cookies][draft-west-first-party-cookies-07]
+- [RFC 6265: HTTP State Management Mechanism][rfc-6265]
+- [Same-site Cookies][rfc-6265bis-03-4.1.2.7]
-[draft-west-first-party-cookies-07]: https://tools.ietf.org/html/draft-west-first-party-cookies-07
-[rfc-6266]: https://tools.ietf.org/html/rfc6266
-[rfc-6266-5.1.4]: https://tools.ietf.org/html/rfc6266#section-5.1.4
-[rfc-6266-5.2.1]: https://tools.ietf.org/html/rfc6266#section-5.2.1
-[rfc-6266-5.2.2]: https://tools.ietf.org/html/rfc6266#section-5.2.2
-[rfc-6266-5.2.3]: https://tools.ietf.org/html/rfc6266#section-5.2.3
-[rfc-6266-5.2.4]: https://tools.ietf.org/html/rfc6266#section-5.2.4
-[rfc-6266-5.3]: https://tools.ietf.org/html/rfc6266#section-5.3
+[rfc-6265bis-03-4.1.2.7]: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
+[rfc-6265]: https://tools.ietf.org/html/rfc6265
+[rfc-6265-5.1.4]: https://tools.ietf.org/html/rfc6265#section-5.1.4
+[rfc-6265-5.2.1]: https://tools.ietf.org/html/rfc6265#section-5.2.1
+[rfc-6265-5.2.2]: https://tools.ietf.org/html/rfc6265#section-5.2.2
+[rfc-6265-5.2.3]: https://tools.ietf.org/html/rfc6265#section-5.2.3
+[rfc-6265-5.2.4]: https://tools.ietf.org/html/rfc6265#section-5.2.4
+[rfc-6265-5.2.5]: https://tools.ietf.org/html/rfc6265#section-5.2.5
+[rfc-6265-5.2.6]: https://tools.ietf.org/html/rfc6265#section-5.2.6
+[rfc-6265-5.3]: https://tools.ietf.org/html/rfc6265#section-5.3
## License
[MIT](LICENSE)
-[npm-image]: https://img.shields.io/npm/v/cookie.svg
-[npm-url]: https://npmjs.org/package/cookie
-[node-version-image]: https://img.shields.io/node/v/cookie.svg
+[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/cookie/master
+[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
+[node-version-image]: https://badgen.net/npm/node/cookie
[node-version-url]: https://nodejs.org/en/download
-[travis-image]: https://img.shields.io/travis/jshttp/cookie/master.svg
+[npm-downloads-image]: https://badgen.net/npm/dm/cookie
+[npm-url]: https://npmjs.org/package/cookie
+[npm-version-image]: https://badgen.net/npm/v/cookie
+[travis-image]: https://badgen.net/travis/jshttp/cookie/master
[travis-url]: https://travis-ci.org/jshttp/cookie
-[coveralls-image]: https://img.shields.io/coveralls/jshttp/cookie/master.svg
-[coveralls-url]: https://coveralls.io/r/jshttp/cookie?branch=master
-[downloads-image]: https://img.shields.io/npm/dm/cookie.svg
-[downloads-url]: https://npmjs.org/package/cookie
diff --git a/api/node_modules/cookie/index.js b/api/node_modules/cookie/index.js
index ab2e467ab..16f56c041 100644
--- a/api/node_modules/cookie/index.js
+++ b/api/node_modules/cookie/index.js
@@ -170,6 +170,9 @@ function serialize(name, val, options) {
case 'strict':
str += '; SameSite=Strict';
break;
+ case 'none':
+ str += '; SameSite=None';
+ break;
default:
throw new TypeError('option sameSite is invalid');
}
diff --git a/api/node_modules/cookie/package.json b/api/node_modules/cookie/package.json
index c6d7ba856..9bfbc47c1 100644
--- a/api/node_modules/cookie/package.json
+++ b/api/node_modules/cookie/package.json
@@ -1,50 +1,24 @@
{
- "_from": "cookie@0.3.1",
- "_id": "cookie@0.3.1",
- "_inBundle": false,
- "_integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=",
- "_location": "/cookie",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "cookie@0.3.1",
- "name": "cookie",
- "escapedName": "cookie",
- "rawSpec": "0.3.1",
- "saveSpec": null,
- "fetchSpec": "0.3.1"
- },
- "_requiredBy": [
- "/cookie-parser",
- "/express"
- ],
- "_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz",
- "_shasum": "e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb",
- "_spec": "cookie@0.3.1",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/cookie-parser",
- "author": {
- "name": "Roman Shtylman",
- "email": "shtylman@gmail.com"
- },
- "bugs": {
- "url": "https://github.com/jshttp/cookie/issues"
- },
- "bundleDependencies": false,
+ "name": "cookie",
+ "description": "HTTP server cookie parsing and serialization",
+ "version": "0.4.0",
+ "author": "Roman Shtylman ",
"contributors": [
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- }
+ "Douglas Christopher Wilson "
],
- "deprecated": false,
- "description": "HTTP server cookie parsing and serialization",
+ "license": "MIT",
+ "keywords": [
+ "cookie",
+ "cookies"
+ ],
+ "repository": "jshttp/cookie",
"devDependencies": {
- "istanbul": "0.4.3",
- "mocha": "1.21.5"
- },
- "engines": {
- "node": ">= 0.6"
+ "beautify-benchmark": "0.2.4",
+ "benchmark": "2.1.4",
+ "eslint": "5.16.0",
+ "eslint-plugin-markdown": "1.0.0",
+ "istanbul": "0.4.5",
+ "mocha": "6.1.4"
},
"files": [
"HISTORY.md",
@@ -52,21 +26,15 @@
"README.md",
"index.js"
],
- "homepage": "https://github.com/jshttp/cookie#readme",
- "keywords": [
- "cookie",
- "cookies"
- ],
- "license": "MIT",
- "name": "cookie",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/jshttp/cookie.git"
+ "engines": {
+ "node": ">= 0.6"
},
"scripts": {
+ "bench": "node benchmark/index.js",
+ "lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
- },
- "version": "0.3.1"
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
+ "version": "node scripts/version-history.js && git add HISTORY.md"
+ }
}
diff --git a/api/node_modules/cors/.eslintrc b/api/node_modules/cors/.eslintrc
deleted file mode 100644
index 51a789300..000000000
--- a/api/node_modules/cors/.eslintrc
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "env": {
- "node": true
- },
- "rules": {
- "indent": [2, 2],
- "quotes": "single"
- }
-}
diff --git a/api/node_modules/cors/.npmignore b/api/node_modules/cors/.npmignore
deleted file mode 100644
index 84a486374..000000000
--- a/api/node_modules/cors/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-coverage
-node_modules
-npm-debug.log
-package-lock.json
diff --git a/api/node_modules/cors/.travis.yml b/api/node_modules/cors/.travis.yml
deleted file mode 100644
index d3aa9cad9..000000000
--- a/api/node_modules/cors/.travis.yml
+++ /dev/null
@@ -1,19 +0,0 @@
-language: node_js
-node_js:
- - "0.10"
- - "4.8"
- - "6.11"
- - "8.1"
-sudo: false
-cache:
- directories:
- - node_modules
-before_install:
- # Skip updating shrinkwrap / lock
- - "npm config set shrinkwrap false"
- # Update Node.js modules
- - "test ! -d node_modules || npm prune"
- - "test ! -d node_modules || npm rebuild"
-after_script:
- # Report coverage
- - "test -e ./coverage/lcov.info && npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
diff --git a/api/node_modules/cors/HISTORY.md b/api/node_modules/cors/HISTORY.md
index 9e1e29cbb..5762bce92 100644
--- a/api/node_modules/cors/HISTORY.md
+++ b/api/node_modules/cors/HISTORY.md
@@ -1,3 +1,8 @@
+2.8.5 / 2018-11-04
+==================
+
+ * Fix setting `maxAge` option to `0`
+
2.8.4 / 2017-07-12
==================
@@ -23,7 +28,7 @@ This release only changed documentation.
2.8.0 / 2016-08-23
==================
- * Add `optionsSucccessCode` option
+ * Add `optionsSuccessStatus` option
2.7.2 / 2016-08-23
==================
@@ -44,7 +49,7 @@ This release only changed documentation.
2.6.1 / 2015-05-28
==================
- * Update `license` in pacakge.json
+ * Update `license` in package.json
2.6.0 / 2015-04-27
==================
diff --git a/api/node_modules/cors/LICENSE b/api/node_modules/cors/LICENSE
index a01c3f3af..fd10c843f 100644
--- a/api/node_modules/cors/LICENSE
+++ b/api/node_modules/cors/LICENSE
@@ -1,9 +1,22 @@
-The MIT License (MIT)
+(The MIT License)
Copyright (c) 2013 Troy Goode
-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:
+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 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.
+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.
diff --git a/api/node_modules/cors/README.md b/api/node_modules/cors/README.md
index 3c6bfdd6c..732b847ed 100644
--- a/api/node_modules/cors/README.md
+++ b/api/node_modules/cors/README.md
@@ -115,6 +115,21 @@ app.listen(80, function () {
})
```
+If you do not want to block REST tools or server-to-server requests,
+add a `!origin` check in the origin function like so:
+
+```javascript
+var corsOptions = {
+ origin: function (origin, callback) {
+ if (whitelist.indexOf(origin) !== -1 || !origin) {
+ callback(null, true)
+ } else {
+ callback(new Error('Not allowed by CORS'))
+ }
+ }
+}
+```
+
### Enabling CORS Pre-Flight
Certain CORS requests are considered 'complex' and require an initial
@@ -157,7 +172,7 @@ var corsOptionsDelegate = function (req, callback) {
var corsOptions;
if (whitelist.indexOf(req.header('Origin')) !== -1) {
corsOptions = { origin: true } // reflect (enable) the requested origin in the CORS response
- }else{
+ } else {
corsOptions = { origin: false } // disable CORS for this request
}
callback(null, corsOptions) // callback expects two parameters: error and options
diff --git a/api/node_modules/cors/lib/index.js b/api/node_modules/cors/lib/index.js
index 013469c0f..5475aecd6 100644
--- a/api/node_modules/cors/lib/index.js
+++ b/api/node_modules/cors/lib/index.js
@@ -6,11 +6,11 @@
var vary = require('vary');
var defaults = {
- origin: '*',
- methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
- preflightContinue: false,
- optionsSuccessStatus: 204
- };
+ origin: '*',
+ methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
+ preflightContinue: false,
+ optionsSuccessStatus: 204
+ };
function isString(s) {
return typeof s === 'string' || s instanceof String;
@@ -131,7 +131,7 @@
}
function configureMaxAge(options) {
- var maxAge = options.maxAge && options.maxAge.toString();
+ var maxAge = (typeof options.maxAge === 'number' || options.maxAge) && options.maxAge.toString()
if (maxAge && maxAge.length) {
return {
key: 'Access-Control-Max-Age',
@@ -170,12 +170,12 @@
headers.push(configureExposedHeaders(options, req));
applyHeaders(headers, res);
- if (options.preflightContinue ) {
+ if (options.preflightContinue) {
next();
} else {
// Safari (and potentially other browsers) need content-length 0,
// for 204 or they just hang waiting for a body
- res.statusCode = options.optionsSuccessStatus || defaults.optionsSuccessStatus;
+ res.statusCode = options.optionsSuccessStatus;
res.setHeader('Content-Length', '0');
res.end();
}
diff --git a/api/node_modules/cors/package.json b/api/node_modules/cors/package.json
index d202b874f..ff37d9843 100644
--- a/api/node_modules/cors/package.json
+++ b/api/node_modules/cors/package.json
@@ -1,73 +1,41 @@
{
- "_from": "cors",
- "_id": "cors@2.8.4",
- "_inBundle": false,
- "_integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=",
- "_location": "/cors",
- "_phantomChildren": {},
- "_requested": {
- "type": "tag",
- "registry": true,
- "raw": "cors",
- "name": "cors",
- "escapedName": "cors",
- "rawSpec": "",
- "saveSpec": null,
- "fetchSpec": "latest"
- },
- "_requiredBy": [
- "#USER",
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz",
- "_shasum": "2bd381f2eb201020105cd50ea59da63090694686",
- "_spec": "cors",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api",
- "author": {
- "name": "Troy Goode",
- "email": "troygoode@gmail.com",
- "url": "https://github.com/troygoode/"
- },
- "bugs": {
- "url": "https://github.com/expressjs/cors/issues"
- },
- "bundleDependencies": false,
- "dependencies": {
- "object-assign": "^4",
- "vary": "^1"
- },
- "deprecated": false,
+ "name": "cors",
"description": "Node.js CORS middleware",
- "devDependencies": {
- "basic-auth-connect": "^1.0.0",
- "body-parser": "^1.12.4",
- "eslint": "^0.21.2",
- "express": "^4.12.4",
- "istanbul": "^0.4.5",
- "mocha": "3.4.2",
- "should": "11.2.1",
- "supertest": "3.0.0"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "homepage": "https://github.com/expressjs/cors#readme",
+ "version": "2.8.5",
+ "author": "Troy Goode (https://github.com/troygoode/)",
+ "license": "MIT",
"keywords": [
"cors",
"express",
"connect",
"middleware"
],
- "license": "MIT",
+ "repository": "expressjs/cors",
"main": "./lib/index.js",
- "name": "cors",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/expressjs/cors.git"
+ "dependencies": {
+ "object-assign": "^4",
+ "vary": "^1"
},
- "scripts": {
- "lint": "eslint lib test",
- "test": "npm run lint && istanbul cover node_modules/mocha/bin/_mocha"
+ "devDependencies": {
+ "after": "0.8.2",
+ "eslint": "2.13.1",
+ "express": "4.16.3",
+ "mocha": "5.2.0",
+ "nyc": "13.1.0",
+ "supertest": "3.3.0"
+ },
+ "files": [
+ "lib/index.js",
+ "CONTRIBUTING.md",
+ "HISTORY.md",
+ "LICENSE",
+ "README.md"
+ ],
+ "engines": {
+ "node": ">= 0.10"
},
- "version": "2.8.4"
+ "scripts": {
+ "test": "npm run lint && nyc --reporter=html --reporter=text mocha --require test/support/env",
+ "lint": "eslint lib test"
+ }
}
diff --git a/api/node_modules/cors/test/basic-auth.js b/api/node_modules/cors/test/basic-auth.js
deleted file mode 100644
index 1323f42ec..000000000
--- a/api/node_modules/cors/test/basic-auth.js
+++ /dev/null
@@ -1,40 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- basicAuth = require('basic-auth-connect'),
- cors = require('../lib');
-
- var app;
-
- /* -------------------------------------------------------------------------- */
-
- app = express();
- app.use(basicAuth('username', 'password'));
- app.use(cors());
- app.post('/', function (req, res) {
- res.send('hello world');
- });
-
- /* -------------------------------------------------------------------------- */
-
- describe('basic auth', function () {
- it('POST works', function (done) {
- supertest(app)
- .post('/')
- .auth('username', 'password')
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('hello world');
- done();
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/body-events.js b/api/node_modules/cors/test/body-events.js
deleted file mode 100644
index 99d582b4b..000000000
--- a/api/node_modules/cors/test/body-events.js
+++ /dev/null
@@ -1,81 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- bodyParser = require('body-parser'),
- cors = require('../lib');
-
- var dynamicOrigin,
- app1,
- app2,
- text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed justo turpis, tempor id sem fringilla, cursus tristique purus. Mauris a sollicitudin magna. Etiam dui lacus, vehicula non dictum at, cursus vitae libero. Curabitur lorem nulla, sollicitudin id enim ut, vehicula rhoncus felis. Ut nec iaculis velit. Vivamus at augue nulla. Fusce at molestie arcu. Duis at dui at tellus mattis tincidunt. Vestibulum sit amet dictum metus. Curabitur nec pretium ante. Proin vulputate elit ac lorem gravida, sit amet placerat lorem fringilla. Mauris fermentum, diam et volutpat auctor, ante enim imperdiet purus, sit amet tincidunt ipsum nulla nec est. Fusce id ipsum in sem malesuada laoreet vitae non magna. Praesent commodo turpis in nulla egestas, eu posuere magna venenatis. Integer in aliquam sem. Fusce quis lorem tincidunt eros rutrum lobortis.\n\nNam aliquam cursus ipsum, a hendrerit purus. Cras ultrices viverra nunc ac lacinia. Sed sed diam orci. Vestibulum ut orci a nibh scelerisque pretium. Sed suscipit vestibulum metus, ac ultricies leo sodales a. Aliquam erat volutpat. Vestibulum mauris massa, luctus et libero vel, cursus suscipit nulla. Cras sed erat quis massa fermentum congue. Mauris ultrices sem ligula, id malesuada lectus tincidunt eget. Donec sed nisl elit. Aenean ac lobortis massa. Phasellus felis nisl, dictum a dui volutpat, dictum sagittis diam. Vestibulum lacinia tellus vel commodo consequat.\n\nNulla at varius nibh, non posuere enim. Curabitur urna est, ultrices vel sem nec, consequat molestie nisi. Aliquam sed augue sit amet ante viverra pretium. Cras aliquam turpis vitae eros gravida egestas. Etiam quis dolor non quam suscipit iaculis. Sed euismod est libero, ac ullamcorper elit hendrerit vitae. Vivamus sollicitudin nulla dolor, vitae porta lacus suscipit ac.\n\nSed volutpat, magna in scelerisque dapibus, eros ante volutpat nisi, ac condimentum diam sem sed justo. Aenean justo risus, bibendum vitae blandit ac, mattis quis nunc. Quisque non felis nec justo auctor accumsan non id odio. Mauris vel dui feugiat dolor dapibus convallis in et neque. Phasellus fermentum sollicitudin tortor ac pretium. Proin tristique accumsan nulla eu venenatis. Cras porta lorem ac arcu accumsan pulvinar. Sed dignissim leo augue, a pretium ante viverra id. Phasellus blandit at purus a malesuada. Nam et cursus mauris. Vivamus accumsan augue laoreet lectus lacinia eleifend. Fusce sit amet felis nunc. Pellentesque eu turpis nisl.\n\nPellentesque vitae quam feugiat, volutpat lectus et, faucibus massa. Maecenas consectetur quis nisi eu aliquam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Etiam laoreet condimentum laoreet. Praesent sit amet massa sit amet dui porta condimentum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed volutpat massa nec risus malesuada hendrerit.';
-
- /* -------------------------------------------------------------------------- */
-
- dynamicOrigin = function (origin, cb) {
- setTimeout(function () {
- cb(null, true);
- }, 200);
- };
-
- /* -------------------------------------------------------------------------- */
-
- app1 = express();
- app1.use(cors({origin: dynamicOrigin}));
- app1.use(bodyParser.json());
- app1.post('/', function (req, res) {
- res.send(req.body);
- });
-
- /* -------------------------------------------------------------------------- */
-
- app2 = express();
- app2.use(bodyParser.json());
- app2.use(cors({origin: dynamicOrigin}));
- app2.post('/', function (req, res) {
- res.send(req.body);
- });
-
- /* -------------------------------------------------------------------------- */
-
- describe('body-parser-events', function () {
- describe('app1 (cors before bodyparser)', function () {
- it('POST works', function (done) {
- var body = {
- example: text
- };
- supertest(app1)
- .post('/')
- .send(body)
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.body.should.eql(body);
- done();
- });
- });
- });
-
- describe('app2 (bodyparser before cors)', function () {
- it('POST works', function (done) {
- var body = {
- example: text
- };
- supertest(app2)
- .post('/')
- .send(body)
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.body.should.eql(body);
- done();
- });
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/cors.js b/api/node_modules/cors/test/cors.js
deleted file mode 100644
index 755f685eb..000000000
--- a/api/node_modules/cors/test/cors.js
+++ /dev/null
@@ -1,747 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- cors = require('../lib');
-
- var fakeRequest = function (headers) {
- return {
- headers: headers || {
- 'origin': 'request.com',
- 'access-control-request-headers': 'requestedHeader1,requestedHeader2'
- },
- pause: function () {
- // do nothing
- return;
- },
- resume: function () {
- // do nothing
- return;
- }
- };
- },
- fakeResponse = function () {
- var headers = {};
- return {
- allHeaders: function () {
- return headers;
- },
- getHeader: function (key) {
- return headers[key];
- },
- setHeader: function (key, value) {
- headers[key] = value;
- return;
- },
- get: function (key) {
- return headers[key];
- }
- };
- };
-
- describe('cors', function () {
- it('does not alter `options` configuration object', function () {
- var options = Object.freeze({
- origin: 'custom-origin'
- });
- (function () {
- cors(options);
- }).should.not.throw();
- });
-
- it('passes control to next middleware', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- done();
- };
-
- // act
- cors()(req, res, next);
- });
-
- it('shortcircuits preflight requests', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- done('should not be called');
- };
-
- // act
- cors()(req, res, next);
- });
-
- it('can configure preflight success response status code', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(200);
- done();
- };
- next = function () {
- // assert
- done('should not be called');
- };
-
- // act
- cors({optionsSuccessStatus: 200})(req, res, next);
- });
-
- it('doesn\'t shortcircuit preflight requests with preflightContinue option', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- done('should not be called');
- };
- next = function () {
- // assert
- done();
- };
-
- // act
- cors({preflightContinue: true})(req, res, next);
- });
-
- it('normalizes method names', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'options';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- done('should not be called');
- };
-
- // act
- cors()(req, res, next);
- });
-
- it('includes Content-Length response header', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'options';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Content-Length').should.equal('0');
- done();
- };
- next = function () {
- // assert
- done('should not be called');
- };
-
- // act
- cors()(req, res, next);
- });
-
- it('no options enables default CORS to all origins', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('*');
- should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
- done();
- };
-
- // act
- cors()(req, res, next);
- });
-
- it('OPTION call with no options enables default CORS to all origins and methods', function (done) {
- // arrange
- var req, res, next;
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('*');
- res.getHeader('Access-Control-Allow-Methods').should.equal('GET,PUT,PATCH,POST,DELETE');
- done();
- };
-
- // act
- cors()(req, res, next);
- });
-
- describe('passing static options', function () {
- it('overrides defaults', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: 'example.com',
- methods: ['FOO', 'bar'],
- headers: ['FIZZ', 'buzz'],
- credentials: true,
- maxAge: 123
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('example.com');
- res.getHeader('Access-Control-Allow-Methods').should.equal('FOO,bar');
- res.getHeader('Access-Control-Allow-Headers').should.equal('FIZZ,buzz');
- res.getHeader('Access-Control-Allow-Credentials').should.equal('true');
- res.getHeader('Access-Control-Max-Age').should.equal('123');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('matches request origin against regexp', function(done) {
- var req = fakeRequest();
- var res = fakeResponse();
- var options = { origin: /^(.+\.)?request.com$/ };
- cors(options)(req, res, function(err) {
- should.not.exist(err);
- res.getHeader('Access-Control-Allow-Origin').should.equal(req.headers.origin);
- should.exist(res.getHeader('Vary'));
- res.getHeader('Vary').should.equal('Origin');
- return done();
- });
- });
-
- it('matches request origin against array of origin checks', function(done) {
- var req = fakeRequest();
- var res = fakeResponse();
- var options = { origin: [ /foo\.com$/, 'request.com' ] };
- cors(options)(req, res, function(err) {
- should.not.exist(err);
- res.getHeader('Access-Control-Allow-Origin').should.equal(req.headers.origin);
- should.exist(res.getHeader('Vary'));
- res.getHeader('Vary').should.equal('Origin');
- return done();
- });
- });
-
- it('doesn\'t match request origin against array of invalid origin checks', function(done) {
- var req = fakeRequest();
- var res = fakeResponse();
- var options = { origin: [ /foo\.com$/, 'bar.com' ] };
- cors(options)(req, res, function(err) {
- should.not.exist(err);
- should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
- should.exist(res.getHeader('Vary'));
- res.getHeader('Vary').should.equal('Origin');
- return done();
- });
- });
-
- it('origin of false disables cors', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: false,
- methods: ['FOO', 'bar'],
- headers: ['FIZZ', 'buzz'],
- credentials: true,
- maxAge: 123
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
- should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
- should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
- should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
- should.not.exist(res.getHeader('Access-Control-Max-Age'));
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('can override origin', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: 'example.com'
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('example.com');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('includes Vary header for specific origins', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: 'example.com'
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.exist(res.getHeader('Vary'));
- res.getHeader('Vary').should.equal('Origin');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('appends to an existing Vary header', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: 'example.com'
- };
- req = fakeRequest();
- res = fakeResponse();
- res.setHeader('Vary', 'Foo');
- next = function () {
- // assert
- res.getHeader('Vary').should.equal('Foo, Origin');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('origin defaults to *', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('*');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('specifying true for origin reflects requesting origin', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- origin: true
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('should allow origin when callback returns true', function (done) {
- var req, res, next, options;
- options = {
- origin: function (sentOrigin, cb) {
- sentOrigin.should.equal('request.com');
- cb(null, true);
- }
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
- done();
- };
-
- cors(options)(req, res, next);
- });
-
- it('should not allow origin when callback returns false', function (done) {
- var req, res, next, options;
- options = {
- origin: function (sentOrigin, cb) {
- sentOrigin.should.equal('request.com');
- cb(null, false);
- }
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
- should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
- should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
- should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
- should.not.exist(res.getHeader('Access-Control-Max-Age'));
- done();
- };
-
- cors(options)(req, res, next);
- });
-
- it('should not override options.origin callback', function (done) {
- var req, res, next, options;
- options = {
- origin: function (sentOrigin, cb) {
- var isValid = sentOrigin === 'request.com';
- cb(null, isValid);
- }
- };
-
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- res.getHeader('Access-Control-Allow-Origin').should.equal('request.com');
- };
-
- cors(options)(req, res, next);
-
- req = fakeRequest({
- 'origin': 'invalid-request.com'
- });
- res = fakeResponse();
-
- next = function () {
- should.not.exist(res.getHeader('Access-Control-Allow-Origin'));
- should.not.exist(res.getHeader('Access-Control-Allow-Methods'));
- should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
- should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
- should.not.exist(res.getHeader('Access-Control-Max-Age'));
- done();
- };
-
- cors(options)(req, res, next);
- });
-
-
- it('can override methods', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- methods: ['method1', 'method2']
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Methods').should.equal('method1,method2');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('methods defaults to GET, PUT, PATCH, POST, DELETE', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.statusCode.should.equal(204);
- done();
- };
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Methods').should.equal('GET,PUT,PATCH,POST,DELETE');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('can specify allowed headers', function (done) {
- // arrange
- var req, res, options;
- options = {
- allowedHeaders: ['header1', 'header2']
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Access-Control-Allow-Headers').should.equal('header1,header2');
- should.not.exist(res.getHeader('Vary'));
- done();
- };
-
- // act
- cors(options)(req, res, null);
- });
-
- it('specifying an empty list or string of allowed headers will result in no response header for allowed headers', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- allowedHeaders: []
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.not.exist(res.getHeader('Access-Control-Allow-Headers'));
- should.not.exist(res.getHeader('Vary'));
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('if no allowed headers are specified, defaults to requested allowed headers', function (done) {
- // arrange
- var req, res, options;
- options = {
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Access-Control-Allow-Headers').should.equal('requestedHeader1,requestedHeader2');
- should.exist(res.getHeader('Vary'));
- res.getHeader('Vary').should.equal('Access-Control-Request-Headers');
- done();
- };
-
- // act
- cors(options)(req, res, null);
- });
-
- it('can specify exposed headers', function (done) {
- // arrange
- var req, res, options, next;
- options = {
- exposedHeaders: ['custom-header1', 'custom-header2']
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Expose-Headers').should.equal('custom-header1,custom-header2');
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('specifying an empty list or string of exposed headers will result in no response header for exposed headers', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- exposedHeaders: []
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.not.exist(res.getHeader('Access-Control-Expose-Headers'));
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('includes credentials if explicitly enabled', function (done) {
- // arrange
- var req, res, options;
- options = {
- credentials: true
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Access-Control-Allow-Credentials').should.equal('true');
- done();
- };
-
- // act
- cors(options)(req, res, null);
- });
-
- it('does not includes credentials unless explicitly enabled', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.not.exist(res.getHeader('Access-Control-Allow-Credentials'));
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
-
- it('includes maxAge when specified', function (done) {
- // arrange
- var req, res, options;
- options = {
- maxAge: 456
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Access-Control-Max-Age').should.equal('456');
- done();
- };
-
- // act
- cors(options)(req, res, null);
- });
-
- it('does not includes maxAge unless specified', function (done) {
- // arrange
- var req, res, next, options;
- options = {
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- should.not.exist(res.getHeader('Access-Control-Max-Age'));
- done();
- };
-
- // act
- cors(options)(req, res, next);
- });
- });
-
- describe('passing a function to build options', function () {
- it('handles options specified via callback', function (done) {
- // arrange
- var req, res, next, delegate;
- delegate = function (req2, cb) {
- cb(null, {
- origin: 'delegate.com'
- });
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('delegate.com');
- done();
- };
-
- // act
- cors(delegate)(req, res, next);
- });
-
- it('handles options specified via callback for preflight', function (done) {
- // arrange
- var req, res, delegate;
- delegate = function (req2, cb) {
- cb(null, {
- origin: 'delegate.com',
- maxAge: 1000
- });
- };
- req = fakeRequest();
- req.method = 'OPTIONS';
- res = fakeResponse();
- res.end = function () {
- // assert
- res.getHeader('Access-Control-Allow-Origin').should.equal('delegate.com');
- res.getHeader('Access-Control-Max-Age').should.equal('1000');
- done();
- };
-
- // act
- cors(delegate)(req, res, null);
- });
-
- it('handles error specified via callback', function (done) {
- // arrange
- var req, res, next, delegate;
- delegate = function (req2, cb) {
- cb('some error');
- };
- req = fakeRequest();
- res = fakeResponse();
- next = function (err) {
- // assert
- err.should.equal('some error');
- done();
- };
-
- // act
- cors(delegate)(req, res, next);
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/error-response.js b/api/node_modules/cors/test/error-response.js
deleted file mode 100644
index 06c7b979f..000000000
--- a/api/node_modules/cors/test/error-response.js
+++ /dev/null
@@ -1,77 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- cors = require('../lib');
-
- var app;
-
- /* -------------------------------------------------------------------------- */
-
- app = express();
- app.use(cors());
-
- app.post('/five-hundred', function (req, res, next) {
- next(new Error('nope'));
- });
-
- app.post('/four-oh-one', function (req, res, next) {
- next(new Error('401'));
- });
-
- app.post('/four-oh-four', function (req, res, next) {
- next();
- });
-
- app.use(function (err, req, res, next) {
- if (err.message === '401') {
- res.status(401).send('unauthorized');
- } else {
- next(err);
- }
- });
-
- /* -------------------------------------------------------------------------- */
-
- describe('error response', function () {
- it('500', function (done) {
- supertest(app)
- .post('/five-hundred')
- .expect(500)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.containEql('Error: nope');
- done();
- });
- });
-
- it('401', function (done) {
- supertest(app)
- .post('/four-oh-one')
- .expect(401)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('unauthorized');
- done();
- });
- });
-
- it('404', function (done) {
- supertest(app)
- .post('/four-oh-four')
- .expect(404)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- done();
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/example-app.js b/api/node_modules/cors/test/example-app.js
deleted file mode 100644
index 590cb3130..000000000
--- a/api/node_modules/cors/test/example-app.js
+++ /dev/null
@@ -1,98 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- cors = require('../lib');
-
- var simpleApp,
- complexApp;
-
- /* -------------------------------------------------------------------------- */
-
- simpleApp = express();
- simpleApp.head('/', cors(), function (req, res) {
- res.status(204).send();
- });
- simpleApp.get('/', cors(), function (req, res) {
- res.send('Hello World (Get)');
- });
- simpleApp.post('/', cors(), function (req, res) {
- res.send('Hello World (Post)');
- });
-
- /* -------------------------------------------------------------------------- */
-
- complexApp = express();
- complexApp.options('/', cors());
- complexApp.delete('/', cors(), function (req, res) {
- res.send('Hello World (Delete)');
- });
-
- /* -------------------------------------------------------------------------- */
-
- describe('example app(s)', function () {
- describe('simple methods', function () {
- it('GET works', function (done) {
- supertest(simpleApp)
- .get('/')
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('Hello World (Get)');
- done();
- });
- });
- it('HEAD works', function (done) {
- supertest(simpleApp)
- .head('/')
- .expect(204)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- done();
- });
- });
- it('POST works', function (done) {
- supertest(simpleApp)
- .post('/')
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('Hello World (Post)');
- done();
- });
- });
- });
-
- describe('complex methods', function () {
- it('OPTIONS works', function (done) {
- supertest(complexApp)
- .options('/')
- .expect(204)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- done();
- });
- });
- it('DELETE works', function (done) {
- supertest(complexApp)
- .del('/')
- .expect(200)
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('Hello World (Delete)');
- done();
- });
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/issue-2.js b/api/node_modules/cors/test/issue-2.js
deleted file mode 100644
index 0784bcd01..000000000
--- a/api/node_modules/cors/test/issue-2.js
+++ /dev/null
@@ -1,56 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- cors = require('../lib');
-
- var app,
- corsOptions;
-
- /* -------------------------------------------------------------------------- */
-
- app = express();
- corsOptions = {
- origin: true,
- methods: ['POST'],
- credentials: true,
- maxAge: 3600
- };
- app.options('/api/login', cors(corsOptions));
- app.post('/api/login', cors(corsOptions), function (req, res) {
- res.send('LOGIN');
- });
-
- /* -------------------------------------------------------------------------- */
-
- describe('issue #2', function () {
- it('OPTIONS works', function (done) {
- supertest(app)
- .options('/api/login')
- .expect(204)
- .set('Origin', 'http://example.com')
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('http://example.com');
- done();
- });
- });
- it('POST works', function (done) {
- supertest(app)
- .post('/api/login')
- .expect(200)
- .set('Origin', 'http://example.com')
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('http://example.com');
- res.text.should.eql('LOGIN');
- done();
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/issue-31.js b/api/node_modules/cors/test/issue-31.js
deleted file mode 100644
index 4f678fe1c..000000000
--- a/api/node_modules/cors/test/issue-31.js
+++ /dev/null
@@ -1,58 +0,0 @@
-(function () {
- /*global describe, it*/
-
- 'use strict';
-
- var should = require('should'),
- express = require('express'),
- supertest = require('supertest'),
- cors = require('../lib');
-
- var app,
- mainRouter,
- itemsRouter;
-
- /* -------------------------------------------------------------------------- */
-
- itemsRouter = new express.Router();
- itemsRouter.get('/', function (req, res) {
- res.send('hello world');
- });
-
- mainRouter = new express.Router();
- mainRouter.use('/items', itemsRouter);
-
- app = express();
- app.use(cors());
- app.use(mainRouter);
-
- /* -------------------------------------------------------------------------- */
-
- describe('issue #31', function () {
- it('OPTIONS works', function (done) {
- supertest(app)
- .options('/items')
- .expect(204)
- .set('Origin', 'http://example.com')
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- done();
- });
- });
-
- it('GET works', function (done) {
- supertest(app)
- .get('/items')
- .expect(200)
- .set('Origin', 'http://example.com')
- .end(function (err, res) {
- should.not.exist(err);
- res.headers['access-control-allow-origin'].should.eql('*');
- res.text.should.eql('hello world');
- done();
- });
- });
- });
-
-}());
diff --git a/api/node_modules/cors/test/mocha.opts b/api/node_modules/cors/test/mocha.opts
deleted file mode 100644
index c74c434b4..000000000
--- a/api/node_modules/cors/test/mocha.opts
+++ /dev/null
@@ -1,4 +0,0 @@
---ui bdd
---reporter spec
---require should
---require test/support/env
diff --git a/api/node_modules/cors/test/support/env.js b/api/node_modules/cors/test/support/env.js
deleted file mode 100644
index eb938f3b7..000000000
--- a/api/node_modules/cors/test/support/env.js
+++ /dev/null
@@ -1,2 +0,0 @@
-
-process.env.NODE_ENV = 'test';
diff --git a/api/node_modules/css-parse/.npmignore b/api/node_modules/css-parse/.npmignore
deleted file mode 100644
index 4a3c398e9..000000000
--- a/api/node_modules/css-parse/.npmignore
+++ /dev/null
@@ -1,6 +0,0 @@
-support
-test
-examples
-*.sock
-test.css
-test.js
diff --git a/api/node_modules/css-parse/History.md b/api/node_modules/css-parse/History.md
deleted file mode 100644
index 5276aab43..000000000
--- a/api/node_modules/css-parse/History.md
+++ /dev/null
@@ -1,30 +0,0 @@
-
-1.0.4 / 2012-09-17
-==================
-
- * fix keyframes float percentages
- * fix an issue with comments containing slashes.
-
-1.0.3 / 2012-09-01
-==================
-
- * add component support
- * fix unquoted data uris [rstacruz]
- * fix keyframe names with no whitespace [rstacruz]
- * fix excess semicolon support [rstacruz]
-
-1.0.2 / 2012-09-01
-==================
-
- * fix IE property hack support [rstacruz]
- * fix quoted strings in declarations [rstacruz]
-
-1.0.1 / 2012-07-26
-==================
-
- * change "selector" to "selectors" array
-
-1.0.0 / 2010-01-03
-==================
-
- * Initial release
diff --git a/api/node_modules/css-parse/Makefile b/api/node_modules/css-parse/Makefile
deleted file mode 100644
index 4e9c8d36e..000000000
--- a/api/node_modules/css-parse/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-
-test:
- @./node_modules/.bin/mocha \
- --require should \
- --reporter spec
-
-.PHONY: test
\ No newline at end of file
diff --git a/api/node_modules/css-parse/Readme.md b/api/node_modules/css-parse/Readme.md
deleted file mode 100644
index fde74a5b1..000000000
--- a/api/node_modules/css-parse/Readme.md
+++ /dev/null
@@ -1,62 +0,0 @@
-
-# css-parse
-
- CSS parser.
-
-## Example
-
-js:
-
-```js
-var parse = require('css-parse')
-parse('tobi { name: "tobi" }')
-```
-
-object returned:
-
-```json
-{
- "stylesheet": {
- "rules": [
- {
- "selectors": ["tobi"],
- "declarations": [
- {
- "property": "name",
- "value": "tobi"
- }
- ]
- }
- ]
- }
-}
-```
-
-## Performance
-
- Parsed 15,000 lines of CSS (2mb) in 40ms on my macbook air.
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
-
-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.
\ No newline at end of file
diff --git a/api/node_modules/css-parse/component.json b/api/node_modules/css-parse/component.json
deleted file mode 100644
index 234ebbead..000000000
--- a/api/node_modules/css-parse/component.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "css-parse",
- "repo": "visionmedia/node-css-parse",
- "version": "1.0.3",
- "description": "CSS parser",
- "keywords": ["css", "parser", "stylesheet"],
- "scripts": ["index.js"]
-}
\ No newline at end of file
diff --git a/api/node_modules/css-parse/index.js b/api/node_modules/css-parse/index.js
deleted file mode 100644
index 3ed278fa2..000000000
--- a/api/node_modules/css-parse/index.js
+++ /dev/null
@@ -1,265 +0,0 @@
-
-module.exports = function(css){
-
- /**
- * Parse stylesheet.
- */
-
- function stylesheet() {
- return { stylesheet: { rules: rules() }};
- }
-
- /**
- * Opening brace.
- */
-
- function open() {
- return match(/^{\s*/);
- }
-
- /**
- * Closing brace.
- */
-
- function close() {
- return match(/^}\s*/);
- }
-
- /**
- * Parse ruleset.
- */
-
- function rules() {
- var node;
- var rules = [];
- whitespace();
- comments();
- while (css[0] != '}' && (node = atrule() || rule())) {
- comments();
- rules.push(node);
- }
- return rules;
- }
-
- /**
- * Match `re` and return captures.
- */
-
- function match(re) {
- var m = re.exec(css);
- if (!m) return;
- css = css.slice(m[0].length);
- return m;
- }
-
- /**
- * Parse whitespace.
- */
-
- function whitespace() {
- match(/^\s*/);
- }
-
- /**
- * Parse comments;
- */
-
- function comments() {
- while (comment()) ;
- }
-
- /**
- * Parse comment.
- */
-
- function comment() {
- if ('/' == css[0] && '*' == css[1]) {
- var i = 2;
- while ('*' != css[i] || '/' != css[i + 1]) ++i;
- i += 2;
- css = css.slice(i);
- whitespace();
- return true;
- }
- }
-
- /**
- * Parse selector.
- */
-
- function selector() {
- var m = match(/^([^{]+)/);
- if (!m) return;
- return m[0].trim().split(/\s*,\s*/);
- }
-
- /**
- * Parse declaration.
- */
-
- function declaration() {
- // prop
- var prop = match(/^(\*?[-\w]+)\s*/);
- if (!prop) return;
- prop = prop[0];
-
- // :
- if (!match(/^:\s*/)) return;
-
- // val
- var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)\s*/);
- if (!val) return;
- val = val[0].trim();
-
- // ;
- match(/^[;\s]*/);
-
- return { property: prop, value: val };
- }
-
- /**
- * Parse keyframe.
- */
-
- function keyframe() {
- var m;
- var vals = [];
-
- while (m = match(/^(from|to|\d+%|\.\d+%|\d+\.\d+%)\s*/)) {
- vals.push(m[1]);
- match(/^,\s*/);
- }
-
- if (!vals.length) return;
-
- return {
- values: vals,
- declarations: declarations()
- };
- }
-
- /**
- * Parse keyframes.
- */
-
- function keyframes() {
- var m = match(/^@([-\w]+)?keyframes */);
- if (!m) return;
- var vendor = m[1];
-
- // identifier
- var m = match(/^([-\w]+)\s*/);
- if (!m) return;
- var name = m[1];
-
- if (!open()) return;
- comments();
-
- var frame;
- var frames = [];
- while (frame = keyframe()) {
- frames.push(frame);
- comments();
- }
-
- if (!close()) return;
-
- return {
- name: name,
- vendor: vendor,
- keyframes: frames
- };
- }
-
- /**
- * Parse media.
- */
-
- function media() {
- var m = match(/^@media *([^{]+)/);
- if (!m) return;
- var media = m[1].trim();
-
- if (!open()) return;
- comments();
-
- var style = rules();
-
- if (!close()) return;
-
- return { media: media, rules: style };
- }
-
- /**
- * Parse import
- */
-
- function atimport() {
- return _atrule('import')
- }
-
- /**
- * Parse charset
- */
-
- function atcharset() {
- return _atrule('charset');
- }
-
- /**
- * Parse non-block at-rules
- */
-
- function _atrule(name) {
- var m = match(new RegExp('^@' + name + ' *([^;\\n]+);\\s*'));
- if (!m) return;
- var ret = {}
- ret[name] = m[1].trim();
- return ret;
- }
-
- /**
- * Parse declarations.
- */
-
- function declarations() {
- var decls = [];
-
- if (!open()) return;
- comments();
-
- // declarations
- var decl;
- while (decl = declaration()) {
- decls.push(decl);
- comments();
- }
-
- if (!close()) return;
- return decls;
- }
-
- /**
- * Parse at rule.
- */
-
- function atrule() {
- return keyframes()
- || media()
- || atimport()
- || atcharset();
- }
-
- /**
- * Parse rule.
- */
-
- function rule() {
- var sel = selector();
- if (!sel) return;
- comments();
- return { selectors: sel, declarations: declarations() };
- }
-
- return stylesheet();
-};
diff --git a/api/node_modules/css-parse/package.json b/api/node_modules/css-parse/package.json
deleted file mode 100644
index 5d96e9496..000000000
--- a/api/node_modules/css-parse/package.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "_from": "css-parse@1.0.4",
- "_id": "css-parse@1.0.4",
- "_inBundle": false,
- "_integrity": "sha1-OLBQP7+dqfVOnB29pg4UXHcRe90=",
- "_location": "/css-parse",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "css-parse@1.0.4",
- "name": "css-parse",
- "escapedName": "css-parse",
- "rawSpec": "1.0.4",
- "saveSpec": null,
- "fetchSpec": "1.0.4"
- },
- "_requiredBy": [
- "/css"
- ],
- "_resolved": "https://registry.npmjs.org/css-parse/-/css-parse-1.0.4.tgz",
- "_shasum": "38b0503fbf9da9f54e9c1dbda60e145c77117bdd",
- "_spec": "css-parse@1.0.4",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/css",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "CSS parser",
- "devDependencies": {
- "mocha": "*",
- "should": "*"
- },
- "keywords": [
- "css",
- "parser",
- "stylesheet"
- ],
- "main": "index",
- "name": "css-parse",
- "version": "1.0.4"
-}
diff --git a/api/node_modules/css-stringify/.npmignore b/api/node_modules/css-stringify/.npmignore
deleted file mode 100644
index 4a3c398e9..000000000
--- a/api/node_modules/css-stringify/.npmignore
+++ /dev/null
@@ -1,6 +0,0 @@
-support
-test
-examples
-*.sock
-test.css
-test.js
diff --git a/api/node_modules/css-stringify/History.md b/api/node_modules/css-stringify/History.md
deleted file mode 100644
index a6ff960f1..000000000
--- a/api/node_modules/css-stringify/History.md
+++ /dev/null
@@ -1,30 +0,0 @@
-
-1.0.5 / 2013-03-15
-==================
-
- * fix indentation of multiple selectors in @media. Closes #11
-
-1.0.4 / 2012-11-15
-==================
-
- * fix indentation
-
-1.0.3 / 2012-09-04
-==================
-
- * add __@charset__ support [rstacruz]
-
-1.0.2 / 2012-09-01
-==================
-
- * add component support
-
-1.0.1 / 2012-07-26
-==================
-
- * add "selectors" array support
-
-0.0.1 / 2010-01-03
-==================
-
- * Initial release
diff --git a/api/node_modules/css-stringify/Makefile b/api/node_modules/css-stringify/Makefile
deleted file mode 100644
index 4e9c8d36e..000000000
--- a/api/node_modules/css-stringify/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-
-test:
- @./node_modules/.bin/mocha \
- --require should \
- --reporter spec
-
-.PHONY: test
\ No newline at end of file
diff --git a/api/node_modules/css-stringify/Readme.md b/api/node_modules/css-stringify/Readme.md
deleted file mode 100644
index a36e7803d..000000000
--- a/api/node_modules/css-stringify/Readme.md
+++ /dev/null
@@ -1,33 +0,0 @@
-
-# css-stringify
-
- CSS compiler using the AST provided by [css-parse](https://github.com/visionmedia/css-parse).
-
-## Performance
-
- Formats 15,000 lines of CSS (2mb) in 23ms on my macbook air.
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
-
-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.
diff --git a/api/node_modules/css-stringify/component.json b/api/node_modules/css-stringify/component.json
deleted file mode 100644
index 259baef07..000000000
--- a/api/node_modules/css-stringify/component.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "name": "css-stringify",
- "repo": "visionmedia/css-stringify",
- "version": "1.0.5",
- "description": "CSS compiler",
- "keywords": ["css", "stringify", "stylesheet"],
- "scripts": ["index.js"]
-}
diff --git a/api/node_modules/css-stringify/index.js b/api/node_modules/css-stringify/index.js
deleted file mode 100644
index f528e41e5..000000000
--- a/api/node_modules/css-stringify/index.js
+++ /dev/null
@@ -1,182 +0,0 @@
-
-/**
- * Stringfy the given AST `node`.
- *
- * @param {Object} node
- * @param {Object} options
- * @return {String}
- * @api public
- */
-
-module.exports = function(node, options){
- return new Compiler(options).compile(node);
-};
-
-/**
- * Initialize a new `Compiler`.
- */
-
-function Compiler(options) {
- options = options || {};
- this.compress = options.compress;
- this.indentation = options.indent;
-}
-
-/**
- * Compile `node`.
- */
-
-Compiler.prototype.compile = function(node){
- return node.stylesheet.rules.map(this.visit, this)
- .join(this.compress ? '' : '\n\n');
-};
-
-/**
- * Visit `node`.
- */
-
-Compiler.prototype.visit = function(node){
- if (node.charset) return this.charset(node);
- if (node.keyframes) return this.keyframes(node);
- if (node.media) return this.media(node);
- if (node.import) return this.import(node);
- return this.rule(node);
-};
-
-/**
- * Visit import node.
- */
-
-Compiler.prototype.import = function(node){
- return '@import ' + node.import + ';';
-};
-
-/**
- * Visit media node.
- */
-
-Compiler.prototype.media = function(node){
- if (this.compress) {
- return '@media '
- + node.media
- + '{'
- + node.rules.map(this.visit, this).join('')
- + '}';
- }
-
- return '@media '
- + node.media
- + ' {\n'
- + this.indent(1)
- + node.rules.map(this.visit, this).join('\n\n')
- + this.indent(-1)
- + '\n}';
-};
-
-/**
- * Visit charset node.
- */
-
-Compiler.prototype.charset = function(node){
- if (this.compress) {
- return '@charset ' + node.charset + ';';
- }
-
- return '@charset ' + node.charset + ';\n';
-};
-
-/**
- * Visit keyframes node.
- */
-
-Compiler.prototype.keyframes = function(node){
- if (this.compress) {
- return '@'
- + (node.vendor || '')
- + 'keyframes '
- + node.name
- + '{'
- + node.keyframes.map(this.keyframe, this).join('')
- + '}';
- }
-
- return '@'
- + (node.vendor || '')
- + 'keyframes '
- + node.name
- + ' {\n'
- + this.indent(1)
- + node.keyframes.map(this.keyframe, this).join('\n')
- + this.indent(-1)
- + '}';
-};
-
-/**
- * Visit keyframe node.
- */
-
-Compiler.prototype.keyframe = function(node){
- if (this.compress) {
- return node.values.join(',')
- + '{'
- + node.declarations.map(this.declaration, this).join(';')
- + '}';
- }
-
- return this.indent()
- + node.values.join(', ')
- + ' {\n'
- + this.indent(1)
- + node.declarations.map(this.declaration, this).join(';\n')
- + this.indent(-1)
- + '\n' + this.indent() + '}\n';
-};
-
-/**
- * Visit rule node.
- */
-
-Compiler.prototype.rule = function(node){
- var indent = this.indent();
-
- if (this.compress) {
- return node.selectors.join(',')
- + '{'
- + node.declarations.map(this.declaration, this).join(';')
- + '}';
- }
-
- return node.selectors.map(function(s){ return indent + s }).join(',\n')
- + ' {\n'
- + this.indent(1)
- + node.declarations.map(this.declaration, this).join(';\n')
- + this.indent(-1)
- + '\n' + this.indent() + '}';
-};
-
-/**
- * Visit declaration node.
- */
-
-Compiler.prototype.declaration = function(node){
- if (this.compress) {
- return node.property + ':' + node.value;
- }
-
- return this.indent() + node.property + ': ' + node.value;
-};
-
-/**
- * Increase, decrease or return current indentation.
- */
-
-Compiler.prototype.indent = function(level) {
- this.level = this.level || 1;
-
- if (null != level) {
- this.level += level;
- return '';
- }
-
- return Array(this.level).join(this.indentation || ' ');
-};
diff --git a/api/node_modules/css-stringify/package.json b/api/node_modules/css-stringify/package.json
deleted file mode 100644
index 4d719e846..000000000
--- a/api/node_modules/css-stringify/package.json
+++ /dev/null
@@ -1,45 +0,0 @@
-{
- "_from": "css-stringify@1.0.5",
- "_id": "css-stringify@1.0.5",
- "_inBundle": false,
- "_integrity": "sha1-sNBClG2ylTu50pKQCmy19tASIDE=",
- "_location": "/css-stringify",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "css-stringify@1.0.5",
- "name": "css-stringify",
- "escapedName": "css-stringify",
- "rawSpec": "1.0.5",
- "saveSpec": null,
- "fetchSpec": "1.0.5"
- },
- "_requiredBy": [
- "/css"
- ],
- "_resolved": "https://registry.npmjs.org/css-stringify/-/css-stringify-1.0.5.tgz",
- "_shasum": "b0d042946db2953bb9d292900a6cb5f6d0122031",
- "_spec": "css-stringify@1.0.5",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/css",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "CSS compiler",
- "devDependencies": {
- "css-parse": "1.0.3",
- "mocha": "*",
- "should": "*"
- },
- "keywords": [
- "css",
- "stringify",
- "stylesheet"
- ],
- "main": "index",
- "name": "css-stringify",
- "version": "1.0.5"
-}
diff --git a/api/node_modules/css/.npmignore b/api/node_modules/css/.npmignore
deleted file mode 100644
index f1250e584..000000000
--- a/api/node_modules/css/.npmignore
+++ /dev/null
@@ -1,4 +0,0 @@
-support
-test
-examples
-*.sock
diff --git a/api/node_modules/css/History.md b/api/node_modules/css/History.md
deleted file mode 100644
index 93b15c2f6..000000000
--- a/api/node_modules/css/History.md
+++ /dev/null
@@ -1,20 +0,0 @@
-
-1.0.7 / 2012-11-21
-==================
-
- * fix component.json
-
-1.0.4 / 2012-11-15
-==================
-
- * update css-stringify
-
-1.0.3 / 2012-09-01
-==================
-
- * add component support
-
-0.0.1 / 2010-01-03
-==================
-
- * Initial release
diff --git a/api/node_modules/css/Makefile b/api/node_modules/css/Makefile
deleted file mode 100644
index f13b4a784..000000000
--- a/api/node_modules/css/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-
-test:
- @node test
-
-benchmark:
- @node benchmark
-
-.PHONY: test benchmark
\ No newline at end of file
diff --git a/api/node_modules/css/Readme.md b/api/node_modules/css/Readme.md
deleted file mode 100644
index cf578dfed..000000000
--- a/api/node_modules/css/Readme.md
+++ /dev/null
@@ -1,77 +0,0 @@
-
-# css
-
- CSS parser / stringifier using [css-parse](https://github.com/visionmedia/css-parse) and [css-stringify](https://github.com/visionmedia/css-stringify).
-
-## Installation
-
- $ npm install css
-
-## Example
-
-js:
-
-```js
-var css = require('css')
-var obj = css.parse('tobi { name: "tobi" }')
-css.stringify(obj);
-```
-
-object returned by `.parse()`:
-
-```json
-{
- "stylesheet": {
- "rules": [
- {
- "selector": "tobi",
- "declarations": [
- {
- "property": "name",
- "value": "tobi"
- }
- ]
- }
- ]
- }
-}
-```
-
-string returned by `.stringify(ast)`:
-
-```css
-tobi {
- name: tobi;
-}
-```
-
-string returned by `.stringify(ast, { compress: true })`:
-
-```css
-tobi{name:tobi}
-```
-
-## License
-
-(The MIT License)
-
-Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
-
-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.
\ No newline at end of file
diff --git a/api/node_modules/css/benchmark.js b/api/node_modules/css/benchmark.js
deleted file mode 100644
index dec711dc2..000000000
--- a/api/node_modules/css/benchmark.js
+++ /dev/null
@@ -1,36 +0,0 @@
-
-var css = require('./')
- , fs = require('fs')
- , read = fs.readFileSync
- , str = read('examples/ui.css', 'utf8');
-
-var n = 5000;
-var ops = 200;
-var t = process.hrtime(t);
-var results = [];
-
-while (n--) {
- css.stringify(css.parse(str));
- if (n % ops == 0) {
- t = process.hrtime(t);
- var ms = t[1] / 1000 / 1000;
- var persec = (ops * (1000 / ms) | 0);
- results.push(persec);
- process.stdout.write('\r [' + persec + ' ops/s] [' + n + ']');
- t = process.hrtime();
- }
-}
-
-function sum(arr) {
- return arr.reduce(function(sum, n){
- return sum + n;
- });
-}
-
-function mean(arr) {
- return sum(arr) / arr.length | 0;
-}
-
-console.log();
-console.log(' avg: %d ops/s', mean(results));
-console.log(' size: %d kb', (str.length / 1024).toFixed(2));
\ No newline at end of file
diff --git a/api/node_modules/css/component.json b/api/node_modules/css/component.json
deleted file mode 100644
index 27691659b..000000000
--- a/api/node_modules/css/component.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "name": "css",
- "version": "1.0.8",
- "description": "CSS parser / stringifier using css-parse and css-stringify",
- "keywords": ["css", "parser", "stylesheet"],
- "dependencies": {
- "visionmedia/css-parse": "*",
- "visionmedia/css-stringify": "*"
- },
- "scripts": [
- "index.js"
- ]
-}
diff --git a/api/node_modules/css/index.js b/api/node_modules/css/index.js
deleted file mode 100644
index 19ec91a14..000000000
--- a/api/node_modules/css/index.js
+++ /dev/null
@@ -1,3 +0,0 @@
-
-exports.parse = require('css-parse');
-exports.stringify = require('css-stringify');
diff --git a/api/node_modules/css/package.json b/api/node_modules/css/package.json
deleted file mode 100644
index cea9820e1..000000000
--- a/api/node_modules/css/package.json
+++ /dev/null
@@ -1,44 +0,0 @@
-{
- "_from": "css@~1.0.8",
- "_id": "css@1.0.8",
- "_inBundle": false,
- "_integrity": "sha1-k4aBHKgrzMnuf7WnMrHioxfIo+c=",
- "_location": "/css",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "css@~1.0.8",
- "name": "css",
- "escapedName": "css",
- "rawSpec": "~1.0.8",
- "saveSpec": null,
- "fetchSpec": "~1.0.8"
- },
- "_requiredBy": [
- "/transformers"
- ],
- "_resolved": "https://registry.npmjs.org/css/-/css-1.0.8.tgz",
- "_shasum": "9386811ca82bccc9ee7fb5a732b1e2a317c8a3e7",
- "_spec": "css@~1.0.8",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/transformers",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bundleDependencies": false,
- "dependencies": {
- "css-parse": "1.0.4",
- "css-stringify": "1.0.5"
- },
- "deprecated": false,
- "description": "CSS parser / stringifier using css-parse and css-stringify",
- "keywords": [
- "css",
- "parser",
- "stylesheet"
- ],
- "main": "index",
- "name": "css",
- "version": "1.0.8"
-}
diff --git a/api/node_modules/css/test.js b/api/node_modules/css/test.js
deleted file mode 100644
index 3e1b4d3f0..000000000
--- a/api/node_modules/css/test.js
+++ /dev/null
@@ -1,6 +0,0 @@
-
-var css = require('./')
- , assert = require('assert');
-
-assert(css.parse);
-assert(css.stringify);
diff --git a/api/node_modules/decamelize/index.js b/api/node_modules/decamelize/index.js
deleted file mode 100644
index 8d5bab7e4..000000000
--- a/api/node_modules/decamelize/index.js
+++ /dev/null
@@ -1,13 +0,0 @@
-'use strict';
-module.exports = function (str, sep) {
- if (typeof str !== 'string') {
- throw new TypeError('Expected a string');
- }
-
- sep = typeof sep === 'undefined' ? '_' : sep;
-
- return str
- .replace(/([a-z\d])([A-Z])/g, '$1' + sep + '$2')
- .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + sep + '$2')
- .toLowerCase();
-};
diff --git a/api/node_modules/decamelize/license b/api/node_modules/decamelize/license
deleted file mode 100644
index 654d0bfe9..000000000
--- a/api/node_modules/decamelize/license
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Sindre Sorhus (sindresorhus.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.
diff --git a/api/node_modules/decamelize/package.json b/api/node_modules/decamelize/package.json
deleted file mode 100644
index 172f17199..000000000
--- a/api/node_modules/decamelize/package.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "_from": "decamelize@^1.0.0",
- "_id": "decamelize@1.2.0",
- "_inBundle": false,
- "_integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=",
- "_location": "/decamelize",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "decamelize@^1.0.0",
- "name": "decamelize",
- "escapedName": "decamelize",
- "rawSpec": "^1.0.0",
- "saveSpec": null,
- "fetchSpec": "^1.0.0"
- },
- "_requiredBy": [
- "/yargs"
- ],
- "_resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
- "_shasum": "f6534d15148269b20352e7bee26f501f9a191290",
- "_spec": "decamelize@^1.0.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/yargs",
- "author": {
- "name": "Sindre Sorhus",
- "email": "sindresorhus@gmail.com",
- "url": "sindresorhus.com"
- },
- "bugs": {
- "url": "https://github.com/sindresorhus/decamelize/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "Convert a camelized string into a lowercased one with a custom separator: unicornRainbow → unicorn_rainbow",
- "devDependencies": {
- "ava": "*",
- "xo": "*"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "files": [
- "index.js"
- ],
- "homepage": "https://github.com/sindresorhus/decamelize#readme",
- "keywords": [
- "decamelize",
- "decamelcase",
- "camelcase",
- "lowercase",
- "case",
- "dash",
- "hyphen",
- "string",
- "str",
- "text",
- "convert"
- ],
- "license": "MIT",
- "name": "decamelize",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/sindresorhus/decamelize.git"
- },
- "scripts": {
- "test": "xo && ava"
- },
- "version": "1.2.0"
-}
diff --git a/api/node_modules/decamelize/readme.md b/api/node_modules/decamelize/readme.md
deleted file mode 100644
index 624c7ee5e..000000000
--- a/api/node_modules/decamelize/readme.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# decamelize [![Build Status](https://travis-ci.org/sindresorhus/decamelize.svg?branch=master)](https://travis-ci.org/sindresorhus/decamelize)
-
-> Convert a camelized string into a lowercased one with a custom separator
-> Example: `unicornRainbow` → `unicorn_rainbow`
-
-
-## Install
-
-```
-$ npm install --save decamelize
-```
-
-
-## Usage
-
-```js
-const decamelize = require('decamelize');
-
-decamelize('unicornRainbow');
-//=> 'unicorn_rainbow'
-
-decamelize('unicornRainbow', '-');
-//=> 'unicorn-rainbow'
-```
-
-
-## API
-
-### decamelize(input, [separator])
-
-#### input
-
-Type: `string`
-
-#### separator
-
-Type: `string`
-Default: `_`
-
-
-## Related
-
-See [`camelcase`](https://github.com/sindresorhus/camelcase) for the inverse.
-
-
-## License
-
-MIT © [Sindre Sorhus](https://sindresorhus.com)
diff --git a/api/node_modules/constantinople/.npmignore b/api/node_modules/doctypes/.npmignore
similarity index 100%
rename from api/node_modules/constantinople/.npmignore
rename to api/node_modules/doctypes/.npmignore
diff --git a/api/node_modules/constantinople/.travis.yml b/api/node_modules/doctypes/.travis.yml
similarity index 100%
rename from api/node_modules/constantinople/.travis.yml
rename to api/node_modules/doctypes/.travis.yml
diff --git a/api/node_modules/doctypes/HISTORY.md b/api/node_modules/doctypes/HISTORY.md
new file mode 100644
index 000000000..d99fd34ac
--- /dev/null
+++ b/api/node_modules/doctypes/HISTORY.md
@@ -0,0 +1,14 @@
+# Change log
+
+## 1.1.0 / 2016-08-10
+
+- Bump minor (to fix a packaging error in 1.0.1)
+- Update plist doctype
+
+## 1.0.1 / 2016-08-09
+
+- Add property list doctype
+
+## 1.0.0 / 2015-01-22
+
+- Initial release
diff --git a/api/node_modules/doctypes/LICENSE b/api/node_modules/doctypes/LICENSE
new file mode 100644
index 000000000..a1421ffb7
--- /dev/null
+++ b/api/node_modules/doctypes/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2015 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.
\ No newline at end of file
diff --git a/api/node_modules/doctypes/README.md b/api/node_modules/doctypes/README.md
new file mode 100644
index 000000000..08013ab89
--- /dev/null
+++ b/api/node_modules/doctypes/README.md
@@ -0,0 +1,24 @@
+# doctypes
+
+Shorthands for commonly used doctypes
+
+[![Build Status](https://img.shields.io/travis/pugjs/doctypes/master.svg)](https://travis-ci.org/pugjs/doctypes)
+[![NPM version](https://img.shields.io/npm/v/doctypes.svg)](https://www.npmjs.org/package/doctypes)
+
+## Installation
+
+ npm install doctypes
+
+## Usage
+
+```js
+var assert = require('assert');
+var doctypes = require('doctypes');
+
+assert(doctypes['html'] === '');
+assert(doctypes['xml'] === '');
+```
+
+## License
+
+ MIT
diff --git a/api/node_modules/doctypes/index.js b/api/node_modules/doctypes/index.js
new file mode 100644
index 000000000..9e0f52d62
--- /dev/null
+++ b/api/node_modules/doctypes/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+module.exports = {
+ 'html': '',
+ 'xml': '',
+ 'transitional': '',
+ 'strict': '',
+ 'frameset': '',
+ '1.1': '',
+ 'basic': '',
+ 'mobile': '',
+ 'plist': ''
+};
diff --git a/api/node_modules/doctypes/package.json b/api/node_modules/doctypes/package.json
new file mode 100644
index 000000000..704b9d5ee
--- /dev/null
+++ b/api/node_modules/doctypes/package.json
@@ -0,0 +1,19 @@
+{
+ "name": "doctypes",
+ "version": "1.1.0",
+ "description": "Shorthands for commonly used doctypes",
+ "keywords": [
+ "doctype"
+ ],
+ "dependencies": {},
+ "devDependencies": {},
+ "scripts": {
+ "test": "node test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/pugjs/doctypes.git"
+ },
+ "author": "ForbesLindesay",
+ "license": "MIT"
+}
diff --git a/api/node_modules/doctypes/test.js b/api/node_modules/doctypes/test.js
new file mode 100644
index 000000000..7ef4b09c6
--- /dev/null
+++ b/api/node_modules/doctypes/test.js
@@ -0,0 +1,9 @@
+'use strict';
+
+var assert = require('assert');
+var doctypes = require('./');
+
+assert(doctypes['html'] === '');
+assert(doctypes['xml'] === '');
+
+console.log('tests passed');
diff --git a/api/node_modules/express/History.md b/api/node_modules/express/History.md
index e02fcd5bf..6e62a6ddb 100644
--- a/api/node_modules/express/History.md
+++ b/api/node_modules/express/History.md
@@ -1,3 +1,78 @@
+4.17.1 / 2019-05-25
+===================
+
+ * Revert "Improve error message for `null`/`undefined` to `res.status`"
+
+4.17.0 / 2019-05-16
+===================
+
+ * Add `express.raw` to parse bodies into `Buffer`
+ * Add `express.text` to parse bodies into string
+ * Improve error message for non-strings to `res.sendFile`
+ * Improve error message for `null`/`undefined` to `res.status`
+ * Support multiple hosts in `X-Forwarded-Host`
+ * deps: accepts@~1.3.7
+ * deps: body-parser@1.19.0
+ - Add encoding MIK
+ - Add petabyte (`pb`) support
+ - Fix parsing array brackets after index
+ - deps: bytes@3.1.0
+ - deps: http-errors@1.7.2
+ - deps: iconv-lite@0.4.24
+ - deps: qs@6.7.0
+ - deps: raw-body@2.4.0
+ - deps: type-is@~1.6.17
+ * deps: content-disposition@0.5.3
+ * deps: cookie@0.4.0
+ - Add `SameSite=None` support
+ * deps: finalhandler@~1.1.2
+ - Set stricter `Content-Security-Policy` header
+ - deps: parseurl@~1.3.3
+ - deps: statuses@~1.5.0
+ * deps: parseurl@~1.3.3
+ * deps: proxy-addr@~2.0.5
+ - deps: ipaddr.js@1.9.0
+ * deps: qs@6.7.0
+ - Fix parsing array brackets after index
+ * deps: range-parser@~1.2.1
+ * deps: send@0.17.1
+ - Set stricter CSP header in redirect & error responses
+ - deps: http-errors@~1.7.2
+ - deps: mime@1.6.0
+ - deps: ms@2.1.1
+ - deps: range-parser@~1.2.1
+ - deps: statuses@~1.5.0
+ - perf: remove redundant `path.normalize` call
+ * deps: serve-static@1.14.1
+ - Set stricter CSP header in redirect response
+ - deps: parseurl@~1.3.3
+ - deps: send@0.17.1
+ * deps: setprototypeof@1.1.1
+ * deps: statuses@~1.5.0
+ - Add `103 Early Hints`
+ * deps: type-is@~1.6.18
+ - deps: mime-types@~2.1.24
+ - perf: prevent internal `throw` on invalid type
+
+4.16.4 / 2018-10-10
+===================
+
+ * Fix issue where `"Request aborted"` may be logged in `res.sendfile`
+ * Fix JSDoc for `Router` constructor
+ * deps: body-parser@1.18.3
+ - Fix deprecation warnings on Node.js 10+
+ - Fix stack trace for strict json parse error
+ - deps: depd@~1.1.2
+ - deps: http-errors@~1.6.3
+ - deps: iconv-lite@0.4.23
+ - deps: qs@6.5.2
+ - deps: raw-body@2.3.3
+ - deps: type-is@~1.6.16
+ * deps: proxy-addr@~2.0.4
+ - deps: ipaddr.js@1.8.0
+ * deps: qs@6.5.2
+ * deps: safe-buffer@5.1.2
+
4.16.3 / 2018-03-12
===================
@@ -275,7 +350,7 @@
- Fix including type extensions in parameters in `Accept` parsing
- Fix parsing `Accept` parameters with quoted equals
- Fix parsing `Accept` parameters with quoted semicolons
- - Many performance improvments
+ - Many performance improvements
- deps: mime-types@~2.1.11
- deps: negotiator@0.6.1
* deps: content-type@~1.0.2
@@ -290,7 +365,7 @@
- perf: enable strict mode
- perf: hoist regular expression
- perf: use for loop in parse
- - perf: use string concatination for serialization
+ - perf: use string concatenation for serialization
* deps: finalhandler@0.5.0
- Change invalid or non-numeric status code to 500
- Overwrite status message to match set status code
@@ -300,7 +375,7 @@
* deps: proxy-addr@~1.1.2
- Fix accepting various invalid netmasks
- Fix IPv6-mapped IPv4 validation edge cases
- - IPv4 netmasks must be contingous
+ - IPv4 netmasks must be contiguous
- IPv6 addresses cannot be used as a netmask
- deps: ipaddr.js@1.1.1
* deps: qs@6.2.0
@@ -1078,13 +1153,13 @@
- deps: negotiator@0.4.6
* deps: debug@1.0.2
* deps: send@0.4.3
- - Do not throw un-catchable error on file open race condition
+ - Do not throw uncatchable error on file open race condition
- Use `escape-html` for HTML escaping
- deps: debug@1.0.2
- deps: finished@1.2.2
- deps: fresh@0.2.2
* deps: serve-static@1.2.3
- - Do not throw un-catchable error on file open race condition
+ - Do not throw uncatchable error on file open race condition
- deps: send@0.4.3
4.4.2 / 2014-06-09
@@ -1964,7 +2039,7 @@
- deps: serve-static@1.2.3
* deps: debug@1.0.2
* deps: send@0.4.3
- - Do not throw un-catchable error on file open race condition
+ - Do not throw uncatchable error on file open race condition
- Use `escape-html` for HTML escaping
- deps: debug@1.0.2
- deps: finished@1.2.2
@@ -3149,7 +3224,7 @@ Shaw]
* Updated haml submodule
* Changed ETag; removed inode, modified time only
* Fixed LF to CRLF for setting multiple cookies
- * Fixed cookie complation; values are now urlencoded
+ * Fixed cookie compilation; values are now urlencoded
* Fixed cookies parsing; accepts quoted values and url escaped cookies
0.11.0 / 2010-05-06
@@ -3344,7 +3419,7 @@ Shaw]
* Added "plot" format option for Profiler (for gnuplot processing)
* Added request number to Profiler plugin
- * Fixed binary encoding for multi-part file uploads, was previously defaulting to UTF8
+ * Fixed binary encoding for multipart file uploads, was previously defaulting to UTF8
* Fixed issue with routes not firing when not files are present. Closes #184
* Fixed process.Promise -> events.Promise
@@ -3390,7 +3465,7 @@ Shaw]
* Updated sample chat app to show messages on load
* Updated libxmljs parseString -> parseHtmlString
* Fixed `make init` to work with older versions of git
- * Fixed specs can now run independent specs for those who cant build deps. Closes #127
+ * Fixed specs can now run independent specs for those who can't build deps. Closes #127
* Fixed issues introduced by the node url module changes. Closes 126.
* Fixed two assertions failing due to Collection#keys() returning strings
* Fixed faulty Collection#toArray() spec due to keys() returning strings
diff --git a/api/node_modules/express/Readme.md b/api/node_modules/express/Readme.md
index 582e8958c..1f9129731 100644
--- a/api/node_modules/express/Readme.md
+++ b/api/node_modules/express/Readme.md
@@ -9,8 +9,8 @@
[![Test Coverage][coveralls-image]][coveralls-url]
```js
-var express = require('express')
-var app = express()
+const express = require('express')
+const app = express()
app.get('/', function (req, res) {
res.send('Hello World')
@@ -90,6 +90,8 @@ $ npm install
$ npm start
```
+ View the website at: http://localhost:3000
+
## Philosophy
The Express philosophy is to provide small, robust tooling for HTTP servers, making
@@ -125,6 +127,10 @@ $ npm install
$ npm test
```
+## Contributing
+
+[Contributing Guide](Contributing.md)
+
## People
The original author of Express is [TJ Holowaychuk](https://github.com/tj)
@@ -147,7 +153,3 @@ The current lead maintainer is [Douglas Christopher Wilson](https://github.com/d
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
-[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg
-[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/
-[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg
-[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/
diff --git a/api/node_modules/express/lib/express.js b/api/node_modules/express/lib/express.js
index 485a8fc08..d188a16db 100644
--- a/api/node_modules/express/lib/express.js
+++ b/api/node_modules/express/lib/express.js
@@ -77,14 +77,16 @@ exports.Router = Router;
exports.json = bodyParser.json
exports.query = require('./middleware/query');
+exports.raw = bodyParser.raw
exports.static = require('serve-static');
+exports.text = bodyParser.text
exports.urlencoded = bodyParser.urlencoded
/**
* Replace removed middleware with an appropriate error message.
*/
-;[
+var removedMiddlewares = [
'bodyParser',
'compress',
'cookieSession',
@@ -101,8 +103,10 @@ exports.urlencoded = bodyParser.urlencoded
'directory',
'limit',
'multipart',
- 'staticCache',
-].forEach(function (name) {
+ 'staticCache'
+]
+
+removedMiddlewares.forEach(function (name) {
Object.defineProperty(exports, name, {
get: function () {
throw new Error('Most middleware (like ' + name + ') is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.');
diff --git a/api/node_modules/express/lib/request.js b/api/node_modules/express/lib/request.js
index 8bb86a9ac..a9400ef99 100644
--- a/api/node_modules/express/lib/request.js
+++ b/api/node_modules/express/lib/request.js
@@ -430,6 +430,10 @@ defineGetter(req, 'hostname', function hostname(){
if (!host || !trust(this.connection.remoteAddress, 0)) {
host = this.get('Host');
+ } else if (host.indexOf(',') !== -1) {
+ // Note: X-Forwarded-Host is normally only ever a
+ // single value, but this is to be safe.
+ host = host.substring(0, host.indexOf(',')).trimRight()
}
if (!host) return;
diff --git a/api/node_modules/express/lib/response.js b/api/node_modules/express/lib/response.js
index 9c1796d37..c9f08cd54 100644
--- a/api/node_modules/express/lib/response.js
+++ b/api/node_modules/express/lib/response.js
@@ -411,6 +411,10 @@ res.sendFile = function sendFile(path, options, callback) {
throw new TypeError('path argument is required to res.sendFile');
}
+ if (typeof path !== 'string') {
+ throw new TypeError('path must be a string to res.sendFile')
+ }
+
// support function as second arg
if (typeof options === 'function') {
done = options;
@@ -500,7 +504,7 @@ res.sendfile = function (path, options, callback) {
if (err && err.code === 'EISDIR') return next();
// next() all but write errors
- if (err && err.code !== 'ECONNABORT' && err.syscall !== 'write') {
+ if (err && err.code !== 'ECONNABORTED' && err.syscall !== 'write') {
next(err);
}
});
@@ -814,7 +818,7 @@ res.clearCookie = function clearCookie(name, options) {
* // "Remember Me" for 15 minutes
* res.cookie('rememberme', '1', { expires: new Date(Date.now() + 900000), httpOnly: true });
*
- * // save as above
+ * // same as above
* res.cookie('rememberme', '1', { maxAge: 900000, httpOnly: true })
*
* @param {String} name
@@ -1127,6 +1131,7 @@ function stringify (value, replacer, spaces, escape) {
return '\\u003e'
case 0x26:
return '\\u0026'
+ /* istanbul ignore next: unreachable default */
default:
return c
}
diff --git a/api/node_modules/express/lib/router/index.js b/api/node_modules/express/lib/router/index.js
index 60727ed6d..69e6d3800 100644
--- a/api/node_modules/express/lib/router/index.js
+++ b/api/node_modules/express/lib/router/index.js
@@ -35,7 +35,7 @@ var toString = Object.prototype.toString;
/**
* Initialize a new `Router` with the given `options`.
*
- * @param {Object} options
+ * @param {Object} [options]
* @return {Router} which is an callable function
* @public
*/
diff --git a/api/node_modules/express/node_modules/setprototypeof/LICENSE b/api/node_modules/express/node_modules/setprototypeof/LICENSE
new file mode 100644
index 000000000..61afa2f18
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2015, Wes Todd
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/api/node_modules/express/node_modules/setprototypeof/README.md b/api/node_modules/express/node_modules/setprototypeof/README.md
new file mode 100644
index 000000000..f120044b6
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/README.md
@@ -0,0 +1,31 @@
+# Polyfill for `Object.setPrototypeOf`
+
+[![NPM Version](https://img.shields.io/npm/v/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
+[![NPM Downloads](https://img.shields.io/npm/dm/setprototypeof.svg)](https://npmjs.org/package/setprototypeof)
+[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/standard/standard)
+
+A simple cross platform implementation to set the prototype of an instianted object. Supports all modern browsers and at least back to IE8.
+
+## Usage:
+
+```
+$ npm install --save setprototypeof
+```
+
+```javascript
+var setPrototypeOf = require('setprototypeof')
+
+var obj = {}
+setPrototypeOf(obj, {
+ foo: function () {
+ return 'bar'
+ }
+})
+obj.foo() // bar
+```
+
+TypeScript is also supported:
+
+```typescript
+import setPrototypeOf = require('setprototypeof')
+```
diff --git a/api/node_modules/express/node_modules/setprototypeof/index.d.ts b/api/node_modules/express/node_modules/setprototypeof/index.d.ts
new file mode 100644
index 000000000..f108ecd0a
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/index.d.ts
@@ -0,0 +1,2 @@
+declare function setPrototypeOf(o: any, proto: object | null): any;
+export = setPrototypeOf;
diff --git a/api/node_modules/express/node_modules/setprototypeof/index.js b/api/node_modules/express/node_modules/setprototypeof/index.js
new file mode 100644
index 000000000..81fd5d7af
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/index.js
@@ -0,0 +1,17 @@
+'use strict'
+/* eslint no-proto: 0 */
+module.exports = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? setProtoOf : mixinProperties)
+
+function setProtoOf (obj, proto) {
+ obj.__proto__ = proto
+ return obj
+}
+
+function mixinProperties (obj, proto) {
+ for (var prop in proto) {
+ if (!obj.hasOwnProperty(prop)) {
+ obj[prop] = proto[prop]
+ }
+ }
+ return obj
+}
diff --git a/api/node_modules/express/node_modules/setprototypeof/package.json b/api/node_modules/express/node_modules/setprototypeof/package.json
new file mode 100644
index 000000000..41368e1b5
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/package.json
@@ -0,0 +1,36 @@
+{
+ "name": "setprototypeof",
+ "version": "1.1.1",
+ "description": "A small polyfill for Object.setprototypeof",
+ "main": "index.js",
+ "typings": "index.d.ts",
+ "scripts": {
+ "test": "standard && mocha",
+ "testallversions": "npm run node010 && npm run node4 && npm run node6 && npm run node9 && npm run node11",
+ "testversion": "docker run -it --rm -v $(PWD):/usr/src/app -w /usr/src/app node:${NODE_VER} npm install mocha@${MOCHA_VER:-latest} && npm t",
+ "node010": "NODE_VER=0.10 MOCHA_VER=3 npm run testversion",
+ "node4": "NODE_VER=4 npm run testversion",
+ "node6": "NODE_VER=6 npm run testversion",
+ "node9": "NODE_VER=9 npm run testversion",
+ "node11": "NODE_VER=11 npm run testversion"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/wesleytodd/setprototypeof.git"
+ },
+ "keywords": [
+ "polyfill",
+ "object",
+ "setprototypeof"
+ ],
+ "author": "Wes Todd",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/wesleytodd/setprototypeof/issues"
+ },
+ "homepage": "https://github.com/wesleytodd/setprototypeof",
+ "devDependencies": {
+ "mocha": "^5.2.0",
+ "standard": "^12.0.1"
+ }
+}
diff --git a/api/node_modules/express/node_modules/setprototypeof/test/index.js b/api/node_modules/express/node_modules/setprototypeof/test/index.js
new file mode 100644
index 000000000..afeb4ddb2
--- /dev/null
+++ b/api/node_modules/express/node_modules/setprototypeof/test/index.js
@@ -0,0 +1,24 @@
+'use strict'
+/* eslint-env mocha */
+/* eslint no-proto: 0 */
+var assert = require('assert')
+var setPrototypeOf = require('..')
+
+describe('setProtoOf(obj, proto)', function () {
+ it('should merge objects', function () {
+ var obj = { a: 1, b: 2 }
+ var proto = { b: 3, c: 4 }
+ var mergeObj = setPrototypeOf(obj, proto)
+
+ if (Object.getPrototypeOf) {
+ assert.strictEqual(Object.getPrototypeOf(obj), proto)
+ } else if ({ __proto__: [] } instanceof Array) {
+ assert.strictEqual(obj.__proto__, proto)
+ } else {
+ assert.strictEqual(obj.a, 1)
+ assert.strictEqual(obj.b, 2)
+ assert.strictEqual(obj.c, 4)
+ }
+ assert.strictEqual(mergeObj, obj)
+ })
+})
diff --git a/api/node_modules/express/package.json b/api/node_modules/express/package.json
index 30b977e2c..2979d57a2 100644
--- a/api/node_modules/express/package.json
+++ b/api/node_modules/express/package.json
@@ -1,117 +1,81 @@
{
- "_from": "express@~4.16.0",
- "_id": "express@4.16.3",
- "_inBundle": false,
- "_integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=",
- "_location": "/express",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "express@~4.16.0",
- "name": "express",
- "escapedName": "express",
- "rawSpec": "~4.16.0",
- "saveSpec": null,
- "fetchSpec": "~4.16.0"
- },
- "_requiredBy": [
- "/"
- ],
- "_resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz",
- "_shasum": "6af8a502350db3246ecc4becf6b5a34d22f7ed53",
- "_spec": "express@~4.16.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api",
- "author": {
- "name": "TJ Holowaychuk",
- "email": "tj@vision-media.ca"
- },
- "bugs": {
- "url": "https://github.com/expressjs/express/issues"
- },
- "bundleDependencies": false,
+ "name": "express",
+ "description": "Fast, unopinionated, minimalist web framework",
+ "version": "4.17.1",
+ "author": "TJ Holowaychuk ",
"contributors": [
- {
- "name": "Aaron Heckmann",
- "email": "aaron.heckmann+github@gmail.com"
- },
- {
- "name": "Ciaran Jessup",
- "email": "ciaranj@gmail.com"
- },
- {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- },
- {
- "name": "Guillermo Rauch",
- "email": "rauchg@gmail.com"
- },
- {
- "name": "Jonathan Ong",
- "email": "me@jongleberry.com"
- },
- {
- "name": "Roman Shtylman",
- "email": "shtylman+expressjs@gmail.com"
- },
- {
- "name": "Young Jae Sim",
- "email": "hanul@hanul.me"
- }
+ "Aaron Heckmann ",
+ "Ciaran Jessup ",
+ "Douglas Christopher Wilson ",
+ "Guillermo Rauch ",
+ "Jonathan Ong ",
+ "Roman Shtylman ",
+ "Young Jae Sim "
+ ],
+ "license": "MIT",
+ "repository": "expressjs/express",
+ "homepage": "http://expressjs.com/",
+ "keywords": [
+ "express",
+ "framework",
+ "sinatra",
+ "web",
+ "rest",
+ "restful",
+ "router",
+ "app",
+ "api"
],
"dependencies": {
- "accepts": "~1.3.5",
+ "accepts": "~1.3.7",
"array-flatten": "1.1.1",
- "body-parser": "1.18.2",
- "content-disposition": "0.5.2",
+ "body-parser": "1.19.0",
+ "content-disposition": "0.5.3",
"content-type": "~1.0.4",
- "cookie": "0.3.1",
+ "cookie": "0.4.0",
"cookie-signature": "1.0.6",
"debug": "2.6.9",
"depd": "~1.1.2",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"etag": "~1.8.1",
- "finalhandler": "1.1.1",
+ "finalhandler": "~1.1.2",
"fresh": "0.5.2",
"merge-descriptors": "1.0.1",
"methods": "~1.1.2",
"on-finished": "~2.3.0",
- "parseurl": "~1.3.2",
+ "parseurl": "~1.3.3",
"path-to-regexp": "0.1.7",
- "proxy-addr": "~2.0.3",
- "qs": "6.5.1",
- "range-parser": "~1.2.0",
- "safe-buffer": "5.1.1",
- "send": "0.16.2",
- "serve-static": "1.13.2",
- "setprototypeof": "1.1.0",
- "statuses": "~1.4.0",
- "type-is": "~1.6.16",
+ "proxy-addr": "~2.0.5",
+ "qs": "6.7.0",
+ "range-parser": "~1.2.1",
+ "safe-buffer": "5.1.2",
+ "send": "0.17.1",
+ "serve-static": "1.14.1",
+ "setprototypeof": "1.1.1",
+ "statuses": "~1.5.0",
+ "type-is": "~1.6.18",
"utils-merge": "1.0.1",
"vary": "~1.1.2"
},
- "deprecated": false,
- "description": "Fast, unopinionated, minimalist web framework",
"devDependencies": {
"after": "0.8.2",
- "connect-redis": "~2.4.1",
- "cookie-parser": "~1.4.3",
- "cookie-session": "1.3.2",
- "ejs": "2.5.7",
+ "connect-redis": "3.4.1",
+ "cookie-parser": "~1.4.4",
+ "cookie-session": "1.3.3",
+ "ejs": "2.6.1",
"eslint": "2.13.1",
- "express-session": "1.15.6",
- "hbs": "4.0.1",
+ "express-session": "1.16.1",
+ "hbs": "4.0.4",
"istanbul": "0.4.5",
- "marked": "0.3.17",
- "method-override": "2.3.10",
- "mocha": "3.5.3",
- "morgan": "1.9.0",
- "multiparty": "4.1.3",
+ "marked": "0.6.2",
+ "method-override": "3.0.0",
+ "mocha": "5.2.0",
+ "morgan": "1.9.1",
+ "multiparty": "4.2.1",
"pbkdf2-password": "1.2.1",
- "should": "13.2.1",
- "supertest": "1.2.0",
+ "should": "13.2.3",
+ "supertest": "3.3.0",
"vhost": "~3.0.2"
},
"engines": {
@@ -124,30 +88,11 @@
"index.js",
"lib/"
],
- "homepage": "http://expressjs.com/",
- "keywords": [
- "express",
- "framework",
- "sinatra",
- "web",
- "rest",
- "restful",
- "router",
- "app",
- "api"
- ],
- "license": "MIT",
- "name": "express",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/expressjs/express.git"
- },
"scripts": {
"lint": "eslint .",
- "test": "mocha --require test/support/env --reporter spec --bail --check-leaks --no-exit test/ test/acceptance/",
- "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks --no-exit test/ test/acceptance/",
- "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks --no-exit test/ test/acceptance/",
- "test-tap": "mocha --require test/support/env --reporter tap --check-leaks --no-exit test/ test/acceptance/"
- },
- "version": "4.16.3"
+ "test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
+ "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
+ "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/ test/acceptance/",
+ "test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
+ }
}
diff --git a/api/node_modules/finalhandler/HISTORY.md b/api/node_modules/finalhandler/HISTORY.md
index 9e43d2a54..920c35e58 100644
--- a/api/node_modules/finalhandler/HISTORY.md
+++ b/api/node_modules/finalhandler/HISTORY.md
@@ -1,3 +1,10 @@
+1.1.2 / 2019-05-09
+==================
+
+ * Set stricter `Content-Security-Policy` header
+ * deps: parseurl@~1.3.3
+ * deps: statuses@~1.5.0
+
1.1.1 / 2018-03-06
==================
diff --git a/api/node_modules/finalhandler/README.md b/api/node_modules/finalhandler/README.md
index 6756f0cd2..96327f0d1 100644
--- a/api/node_modules/finalhandler/README.md
+++ b/api/node_modules/finalhandler/README.md
@@ -116,7 +116,7 @@ var fs = require('fs')
var http = require('http')
var server = http.createServer(function (req, res) {
- var done = finalhandler(req, res, {onerror: logerror})
+ var done = finalhandler(req, res, { onerror: logerror })
fs.readFile('index.html', function (err, buf) {
if (err) return done(err)
diff --git a/api/node_modules/finalhandler/index.js b/api/node_modules/finalhandler/index.js
index f20ffe328..567350798 100644
--- a/api/node_modules/finalhandler/index.js
+++ b/api/node_modules/finalhandler/index.js
@@ -282,7 +282,7 @@ function send (req, res, status, headers, message) {
setHeaders(res, headers)
// security headers
- res.setHeader('Content-Security-Policy', "default-src 'self'")
+ res.setHeader('Content-Security-Policy', "default-src 'none'")
res.setHeader('X-Content-Type-Options', 'nosniff')
// standard headers
diff --git a/api/node_modules/finalhandler/package.json b/api/node_modules/finalhandler/package.json
index 9fb98bfda..79c8f3ed1 100644
--- a/api/node_modules/finalhandler/package.json
+++ b/api/node_modules/finalhandler/package.json
@@ -1,80 +1,45 @@
{
- "_from": "finalhandler@1.1.1",
- "_id": "finalhandler@1.1.1",
- "_inBundle": false,
- "_integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==",
- "_location": "/finalhandler",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "finalhandler@1.1.1",
- "name": "finalhandler",
- "escapedName": "finalhandler",
- "rawSpec": "1.1.1",
- "saveSpec": null,
- "fetchSpec": "1.1.1"
- },
- "_requiredBy": [
- "/express"
- ],
- "_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz",
- "_shasum": "eebf4ed840079c83f4249038c9d703008301b105",
- "_spec": "finalhandler@1.1.1",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/express",
- "author": {
- "name": "Douglas Christopher Wilson",
- "email": "doug@somethingdoug.com"
- },
- "bugs": {
- "url": "https://github.com/pillarjs/finalhandler/issues"
- },
- "bundleDependencies": false,
+ "name": "finalhandler",
+ "description": "Node.js final http responder",
+ "version": "1.1.2",
+ "author": "Douglas Christopher Wilson ",
+ "license": "MIT",
+ "repository": "pillarjs/finalhandler",
"dependencies": {
"debug": "2.6.9",
"encodeurl": "~1.0.2",
"escape-html": "~1.0.3",
"on-finished": "~2.3.0",
- "parseurl": "~1.3.2",
- "statuses": "~1.4.0",
+ "parseurl": "~1.3.3",
+ "statuses": "~1.5.0",
"unpipe": "~1.0.0"
},
- "deprecated": false,
- "description": "Node.js final http responder",
"devDependencies": {
- "eslint": "4.18.1",
- "eslint-config-standard": "11.0.0",
- "eslint-plugin-import": "2.9.0",
- "eslint-plugin-markdown": "1.0.0-beta.6",
- "eslint-plugin-node": "6.0.1",
- "eslint-plugin-promise": "3.6.0",
- "eslint-plugin-standard": "3.0.1",
+ "eslint": "5.16.0",
+ "eslint-config-standard": "12.0.0",
+ "eslint-plugin-import": "2.17.2",
+ "eslint-plugin-markdown": "1.0.0",
+ "eslint-plugin-node": "8.0.1",
+ "eslint-plugin-promise": "4.1.1",
+ "eslint-plugin-standard": "4.0.0",
"istanbul": "0.4.5",
- "mocha": "2.5.3",
- "readable-stream": "2.3.4",
- "safe-buffer": "5.1.1",
- "supertest": "1.1.0"
- },
- "engines": {
- "node": ">= 0.8"
+ "mocha": "6.1.4",
+ "readable-stream": "2.3.6",
+ "safe-buffer": "5.1.2",
+ "supertest": "4.0.2"
},
"files": [
"LICENSE",
"HISTORY.md",
"index.js"
],
- "homepage": "https://github.com/pillarjs/finalhandler#readme",
- "license": "MIT",
- "name": "finalhandler",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/pillarjs/finalhandler.git"
+ "engines": {
+ "node": ">= 0.8"
},
"scripts": {
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/"
- },
- "version": "1.1.1"
+ }
}
diff --git a/api/node_modules/function-bind/.editorconfig b/api/node_modules/function-bind/.editorconfig
new file mode 100644
index 000000000..ac29adef0
--- /dev/null
+++ b/api/node_modules/function-bind/.editorconfig
@@ -0,0 +1,20 @@
+root = true
+
+[*]
+indent_style = tab
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+max_line_length = 120
+
+[CHANGELOG.md]
+indent_style = space
+indent_size = 2
+
+[*.json]
+max_line_length = off
+
+[Makefile]
+max_line_length = off
diff --git a/api/node_modules/function-bind/.eslintrc b/api/node_modules/function-bind/.eslintrc
new file mode 100644
index 000000000..9b33d8edf
--- /dev/null
+++ b/api/node_modules/function-bind/.eslintrc
@@ -0,0 +1,15 @@
+{
+ "root": true,
+
+ "extends": "@ljharb",
+
+ "rules": {
+ "func-name-matching": 0,
+ "indent": [2, 4],
+ "max-nested-callbacks": [2, 3],
+ "max-params": [2, 3],
+ "max-statements": [2, 20],
+ "no-new-func": [1],
+ "strict": [0]
+ }
+}
diff --git a/api/node_modules/function-bind/.jscs.json b/api/node_modules/function-bind/.jscs.json
new file mode 100644
index 000000000..8c4479480
--- /dev/null
+++ b/api/node_modules/function-bind/.jscs.json
@@ -0,0 +1,176 @@
+{
+ "es3": true,
+
+ "additionalRules": [],
+
+ "requireSemicolons": true,
+
+ "disallowMultipleSpaces": true,
+
+ "disallowIdentifierNames": [],
+
+ "requireCurlyBraces": {
+ "allExcept": [],
+ "keywords": ["if", "else", "for", "while", "do", "try", "catch"]
+ },
+
+ "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"],
+
+ "disallowSpaceAfterKeywords": [],
+
+ "disallowSpaceBeforeComma": true,
+ "disallowSpaceAfterComma": false,
+ "disallowSpaceBeforeSemicolon": true,
+
+ "disallowNodeTypes": [
+ "DebuggerStatement",
+ "ForInStatement",
+ "LabeledStatement",
+ "SwitchCase",
+ "SwitchStatement",
+ "WithStatement"
+ ],
+
+ "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] },
+
+ "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true },
+ "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true },
+ "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true },
+ "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true },
+ "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true },
+
+ "requireSpaceBetweenArguments": true,
+
+ "disallowSpacesInsideParentheses": true,
+
+ "disallowSpacesInsideArrayBrackets": true,
+
+ "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] },
+
+ "disallowSpaceAfterObjectKeys": true,
+
+ "requireCommaBeforeLineBreak": true,
+
+ "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
+ "requireSpaceAfterPrefixUnaryOperators": [],
+
+ "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
+ "requireSpaceBeforePostfixUnaryOperators": [],
+
+ "disallowSpaceBeforeBinaryOperators": [],
+ "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
+
+ "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
+ "disallowSpaceAfterBinaryOperators": [],
+
+ "disallowImplicitTypeConversion": ["binary", "string"],
+
+ "disallowKeywords": ["with", "eval"],
+
+ "requireKeywordsOnNewLine": [],
+ "disallowKeywordsOnNewLine": ["else"],
+
+ "requireLineFeedAtFileEnd": true,
+
+ "disallowTrailingWhitespace": true,
+
+ "disallowTrailingComma": true,
+
+ "excludeFiles": ["node_modules/**", "vendor/**"],
+
+ "disallowMultipleLineStrings": true,
+
+ "requireDotNotation": { "allExcept": ["keywords"] },
+
+ "requireParenthesesAroundIIFE": true,
+
+ "validateLineBreaks": "LF",
+
+ "validateQuoteMarks": {
+ "escape": true,
+ "mark": "'"
+ },
+
+ "disallowOperatorBeforeLineBreak": [],
+
+ "requireSpaceBeforeKeywords": [
+ "do",
+ "for",
+ "if",
+ "else",
+ "switch",
+ "case",
+ "try",
+ "catch",
+ "finally",
+ "while",
+ "with",
+ "return"
+ ],
+
+ "validateAlignedFunctionParameters": {
+ "lineBreakAfterOpeningBraces": true,
+ "lineBreakBeforeClosingBraces": true
+ },
+
+ "requirePaddingNewLinesBeforeExport": true,
+
+ "validateNewlineAfterArrayElements": {
+ "maximum": 8
+ },
+
+ "requirePaddingNewLinesAfterUseStrict": true,
+
+ "disallowArrowFunctions": true,
+
+ "disallowMultiLineTernary": true,
+
+ "validateOrderInObjectKeys": "asc-insensitive",
+
+ "disallowIdenticalDestructuringNames": true,
+
+ "disallowNestedTernaries": { "maxLevel": 1 },
+
+ "requireSpaceAfterComma": { "allExcept": ["trailing"] },
+ "requireAlignedMultilineParams": false,
+
+ "requireSpacesInGenerator": {
+ "afterStar": true
+ },
+
+ "disallowSpacesInGenerator": {
+ "beforeStar": true
+ },
+
+ "disallowVar": false,
+
+ "requireArrayDestructuring": false,
+
+ "requireEnhancedObjectLiterals": false,
+
+ "requireObjectDestructuring": false,
+
+ "requireEarlyReturn": false,
+
+ "requireCapitalizedConstructorsNew": {
+ "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"]
+ },
+
+ "requireImportAlphabetized": false,
+
+ "requireSpaceBeforeObjectValues": true,
+ "requireSpaceBeforeDestructuredValues": true,
+
+ "disallowSpacesInsideTemplateStringPlaceholders": true,
+
+ "disallowArrayDestructuringReturn": false,
+
+ "requireNewlineBeforeSingleStatementsInIf": false,
+
+ "disallowUnusedVariables": true,
+
+ "requireSpacesInsideImportedObjectBraces": true,
+
+ "requireUseStrict": true
+}
+
diff --git a/api/node_modules/function-bind/.npmignore b/api/node_modules/function-bind/.npmignore
new file mode 100644
index 000000000..dbb555fd1
--- /dev/null
+++ b/api/node_modules/function-bind/.npmignore
@@ -0,0 +1,22 @@
+# gitignore
+.DS_Store
+.monitor
+.*.swp
+.nodemonignore
+releases
+*.log
+*.err
+fleet.json
+public/browserify
+bin/*.json
+.bin
+build
+compile
+.lock-wscript
+coverage
+node_modules
+
+# Only apps should have lockfiles
+npm-shrinkwrap.json
+package-lock.json
+yarn.lock
diff --git a/api/node_modules/function-bind/.travis.yml b/api/node_modules/function-bind/.travis.yml
new file mode 100644
index 000000000..85f70d246
--- /dev/null
+++ b/api/node_modules/function-bind/.travis.yml
@@ -0,0 +1,168 @@
+language: node_js
+os:
+ - linux
+node_js:
+ - "8.4"
+ - "7.10"
+ - "6.11"
+ - "5.12"
+ - "4.8"
+ - "iojs-v3.3"
+ - "iojs-v2.5"
+ - "iojs-v1.8"
+ - "0.12"
+ - "0.10"
+ - "0.8"
+before_install:
+ - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then npm install -g npm@1.3 ; elif [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then case "$(npm --version)" in 1.*) npm install -g npm@1.4.28 ;; 2.*) npm install -g npm@2 ;; esac ; fi'
+ - 'if [ "${TRAVIS_NODE_VERSION}" != "0.6" ] && [ "${TRAVIS_NODE_VERSION}" != "0.9" ]; then if [ "${TRAVIS_NODE_VERSION%${TRAVIS_NODE_VERSION#[0-9]}}" = "0" ] || [ "${TRAVIS_NODE_VERSION:0:4}" = "iojs" ]; then npm install -g npm@4.5 ; else npm install -g npm; fi; fi'
+install:
+ - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ]; then nvm install 0.8 && npm install -g npm@1.3 && npm install -g npm@1.4.28 && npm install -g npm@2 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
+script:
+ - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
+ - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
+ - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
+ - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
+sudo: false
+env:
+ - TEST=true
+matrix:
+ fast_finish: true
+ include:
+ - node_js: "node"
+ env: PRETEST=true
+ - node_js: "4"
+ env: COVERAGE=true
+ - node_js: "8.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "8.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "7.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.10"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "6.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.11"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.10"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.8"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "5.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "4.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v3.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v2.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.7"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.5"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.4"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.3"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.2"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.1"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "iojs-v1.0"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.11"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.9"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.6"
+ env: TEST=true ALLOW_FAILURE=true
+ - node_js: "0.4"
+ env: TEST=true ALLOW_FAILURE=true
+ allow_failures:
+ - os: osx
+ - env: TEST=true ALLOW_FAILURE=true
diff --git a/api/node_modules/function-bind/LICENSE b/api/node_modules/function-bind/LICENSE
new file mode 100644
index 000000000..62d6d237f
--- /dev/null
+++ b/api/node_modules/function-bind/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2013 Raynos.
+
+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.
+
diff --git a/api/node_modules/function-bind/README.md b/api/node_modules/function-bind/README.md
new file mode 100644
index 000000000..81862a02c
--- /dev/null
+++ b/api/node_modules/function-bind/README.md
@@ -0,0 +1,48 @@
+# function-bind
+
+
+
+
+
+Implementation of function.prototype.bind
+
+## Example
+
+I mainly do this for unit tests I run on phantomjs.
+PhantomJS does not have Function.prototype.bind :(
+
+```js
+Function.prototype.bind = require("function-bind")
+```
+
+## Installation
+
+`npm install function-bind`
+
+## Contributors
+
+ - Raynos
+
+## MIT Licenced
+
+ [travis-svg]: https://travis-ci.org/Raynos/function-bind.svg
+ [travis-url]: https://travis-ci.org/Raynos/function-bind
+ [npm-badge-svg]: https://badge.fury.io/js/function-bind.svg
+ [npm-url]: https://npmjs.org/package/function-bind
+ [5]: https://coveralls.io/repos/Raynos/function-bind/badge.png
+ [6]: https://coveralls.io/r/Raynos/function-bind
+ [7]: https://gemnasium.com/Raynos/function-bind.png
+ [8]: https://gemnasium.com/Raynos/function-bind
+ [deps-svg]: https://david-dm.org/Raynos/function-bind.svg
+ [deps-url]: https://david-dm.org/Raynos/function-bind
+ [dev-deps-svg]: https://david-dm.org/Raynos/function-bind/dev-status.svg
+ [dev-deps-url]: https://david-dm.org/Raynos/function-bind#info=devDependencies
+ [11]: https://ci.testling.com/Raynos/function-bind.png
+ [12]: https://ci.testling.com/Raynos/function-bind
diff --git a/api/node_modules/function-bind/implementation.js b/api/node_modules/function-bind/implementation.js
new file mode 100644
index 000000000..cc4daec1b
--- /dev/null
+++ b/api/node_modules/function-bind/implementation.js
@@ -0,0 +1,52 @@
+'use strict';
+
+/* eslint no-invalid-this: 1 */
+
+var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
+var slice = Array.prototype.slice;
+var toStr = Object.prototype.toString;
+var funcType = '[object Function]';
+
+module.exports = function bind(that) {
+ var target = this;
+ if (typeof target !== 'function' || toStr.call(target) !== funcType) {
+ throw new TypeError(ERROR_MESSAGE + target);
+ }
+ var args = slice.call(arguments, 1);
+
+ var bound;
+ var binder = function () {
+ if (this instanceof bound) {
+ var result = target.apply(
+ this,
+ args.concat(slice.call(arguments))
+ );
+ if (Object(result) === result) {
+ return result;
+ }
+ return this;
+ } else {
+ return target.apply(
+ that,
+ args.concat(slice.call(arguments))
+ );
+ }
+ };
+
+ var boundLength = Math.max(0, target.length - args.length);
+ var boundArgs = [];
+ for (var i = 0; i < boundLength; i++) {
+ boundArgs.push('$' + i);
+ }
+
+ bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
+
+ if (target.prototype) {
+ var Empty = function Empty() {};
+ Empty.prototype = target.prototype;
+ bound.prototype = new Empty();
+ Empty.prototype = null;
+ }
+
+ return bound;
+};
diff --git a/api/node_modules/function-bind/index.js b/api/node_modules/function-bind/index.js
new file mode 100644
index 000000000..3bb6b9609
--- /dev/null
+++ b/api/node_modules/function-bind/index.js
@@ -0,0 +1,5 @@
+'use strict';
+
+var implementation = require('./implementation');
+
+module.exports = Function.prototype.bind || implementation;
diff --git a/api/node_modules/function-bind/package.json b/api/node_modules/function-bind/package.json
new file mode 100644
index 000000000..20a1727cb
--- /dev/null
+++ b/api/node_modules/function-bind/package.json
@@ -0,0 +1,63 @@
+{
+ "name": "function-bind",
+ "version": "1.1.1",
+ "description": "Implementation of Function.prototype.bind",
+ "keywords": [
+ "function",
+ "bind",
+ "shim",
+ "es5"
+ ],
+ "author": "Raynos ",
+ "repository": "git://github.com/Raynos/function-bind.git",
+ "main": "index",
+ "homepage": "https://github.com/Raynos/function-bind",
+ "contributors": [
+ {
+ "name": "Raynos"
+ },
+ {
+ "name": "Jordan Harband",
+ "url": "https://github.com/ljharb"
+ }
+ ],
+ "bugs": {
+ "url": "https://github.com/Raynos/function-bind/issues",
+ "email": "raynos2@gmail.com"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "@ljharb/eslint-config": "^12.2.1",
+ "covert": "^1.1.0",
+ "eslint": "^4.5.0",
+ "jscs": "^3.0.7",
+ "tape": "^4.8.0"
+ },
+ "license": "MIT",
+ "scripts": {
+ "pretest": "npm run lint",
+ "test": "npm run tests-only",
+ "posttest": "npm run coverage -- --quiet",
+ "tests-only": "node test",
+ "coverage": "covert test/*.js",
+ "lint": "npm run jscs && npm run eslint",
+ "jscs": "jscs *.js */*.js",
+ "eslint": "eslint *.js */*.js"
+ },
+ "testling": {
+ "files": "test/index.js",
+ "browsers": [
+ "ie/8..latest",
+ "firefox/16..latest",
+ "firefox/nightly",
+ "chrome/22..latest",
+ "chrome/canary",
+ "opera/12..latest",
+ "opera/next",
+ "safari/5.1..latest",
+ "ipad/6.0..latest",
+ "iphone/6.0..latest",
+ "android-browser/4.2..latest"
+ ]
+ }
+}
diff --git a/api/node_modules/function-bind/test/.eslintrc b/api/node_modules/function-bind/test/.eslintrc
new file mode 100644
index 000000000..8a56d5b72
--- /dev/null
+++ b/api/node_modules/function-bind/test/.eslintrc
@@ -0,0 +1,9 @@
+{
+ "rules": {
+ "array-bracket-newline": 0,
+ "array-element-newline": 0,
+ "max-statements-per-line": [2, { "max": 2 }],
+ "no-invalid-this": 0,
+ "no-magic-numbers": 0,
+ }
+}
diff --git a/api/node_modules/function-bind/test/index.js b/api/node_modules/function-bind/test/index.js
new file mode 100644
index 000000000..2edecce2f
--- /dev/null
+++ b/api/node_modules/function-bind/test/index.js
@@ -0,0 +1,252 @@
+// jscs:disable requireUseStrict
+
+var test = require('tape');
+
+var functionBind = require('../implementation');
+var getCurrentContext = function () { return this; };
+
+test('functionBind is a function', function (t) {
+ t.equal(typeof functionBind, 'function');
+ t.end();
+});
+
+test('non-functions', function (t) {
+ var nonFunctions = [true, false, [], {}, 42, 'foo', NaN, /a/g];
+ t.plan(nonFunctions.length);
+ for (var i = 0; i < nonFunctions.length; ++i) {
+ try { functionBind.call(nonFunctions[i]); } catch (ex) {
+ t.ok(ex instanceof TypeError, 'throws when given ' + String(nonFunctions[i]));
+ }
+ }
+ t.end();
+});
+
+test('without a context', function (t) {
+ t.test('binds properly', function (st) {
+ var args, context;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ context = this;
+ })
+ };
+ namespace.func(1, 2, 3);
+ st.deepEqual(args, [1, 2, 3]);
+ st.equal(context, getCurrentContext.call());
+ st.end();
+ });
+
+ t.test('binds properly, and still supplies bound arguments', function (st) {
+ var args, context;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ context = this;
+ }, undefined, 1, 2, 3)
+ };
+ namespace.func(4, 5, 6);
+ st.deepEqual(args, [1, 2, 3, 4, 5, 6]);
+ st.equal(context, getCurrentContext.call());
+ st.end();
+ });
+
+ t.test('returns properly', function (st) {
+ var args;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ return this;
+ }, null)
+ };
+ var context = namespace.func(1, 2, 3);
+ st.equal(context, getCurrentContext.call(), 'returned context is namespaced context');
+ st.deepEqual(args, [1, 2, 3], 'passed arguments are correct');
+ st.end();
+ });
+
+ t.test('returns properly with bound arguments', function (st) {
+ var args;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ return this;
+ }, null, 1, 2, 3)
+ };
+ var context = namespace.func(4, 5, 6);
+ st.equal(context, getCurrentContext.call(), 'returned context is namespaced context');
+ st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'passed arguments are correct');
+ st.end();
+ });
+
+ t.test('called as a constructor', function (st) {
+ var thunkify = function (value) {
+ return function () { return value; };
+ };
+ st.test('returns object value', function (sst) {
+ var expectedReturnValue = [1, 2, 3];
+ var Constructor = functionBind.call(thunkify(expectedReturnValue), null);
+ var result = new Constructor();
+ sst.equal(result, expectedReturnValue);
+ sst.end();
+ });
+
+ st.test('does not return primitive value', function (sst) {
+ var Constructor = functionBind.call(thunkify(42), null);
+ var result = new Constructor();
+ sst.notEqual(result, 42);
+ sst.end();
+ });
+
+ st.test('object from bound constructor is instance of original and bound constructor', function (sst) {
+ var A = function (x) {
+ this.name = x || 'A';
+ };
+ var B = functionBind.call(A, null, 'B');
+
+ var result = new B();
+ sst.ok(result instanceof B, 'result is instance of bound constructor');
+ sst.ok(result instanceof A, 'result is instance of original constructor');
+ sst.end();
+ });
+
+ st.end();
+ });
+
+ t.end();
+});
+
+test('with a context', function (t) {
+ t.test('with no bound arguments', function (st) {
+ var args, context;
+ var boundContext = {};
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ context = this;
+ }, boundContext)
+ };
+ namespace.func(1, 2, 3);
+ st.equal(context, boundContext, 'binds a context properly');
+ st.deepEqual(args, [1, 2, 3], 'supplies passed arguments');
+ st.end();
+ });
+
+ t.test('with bound arguments', function (st) {
+ var args, context;
+ var boundContext = {};
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ context = this;
+ }, boundContext, 1, 2, 3)
+ };
+ namespace.func(4, 5, 6);
+ st.equal(context, boundContext, 'binds a context properly');
+ st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'supplies bound and passed arguments');
+ st.end();
+ });
+
+ t.test('returns properly', function (st) {
+ var boundContext = {};
+ var args;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ return this;
+ }, boundContext)
+ };
+ var context = namespace.func(1, 2, 3);
+ st.equal(context, boundContext, 'returned context is bound context');
+ st.notEqual(context, getCurrentContext.call(), 'returned context is not lexical context');
+ st.deepEqual(args, [1, 2, 3], 'passed arguments are correct');
+ st.end();
+ });
+
+ t.test('returns properly with bound arguments', function (st) {
+ var boundContext = {};
+ var args;
+ var namespace = {
+ func: functionBind.call(function () {
+ args = Array.prototype.slice.call(arguments);
+ return this;
+ }, boundContext, 1, 2, 3)
+ };
+ var context = namespace.func(4, 5, 6);
+ st.equal(context, boundContext, 'returned context is bound context');
+ st.notEqual(context, getCurrentContext.call(), 'returned context is not lexical context');
+ st.deepEqual(args, [1, 2, 3, 4, 5, 6], 'passed arguments are correct');
+ st.end();
+ });
+
+ t.test('passes the correct arguments when called as a constructor', function (st) {
+ var expected = { name: 'Correct' };
+ var namespace = {
+ Func: functionBind.call(function (arg) {
+ return arg;
+ }, { name: 'Incorrect' })
+ };
+ var returned = new namespace.Func(expected);
+ st.equal(returned, expected, 'returns the right arg when called as a constructor');
+ st.end();
+ });
+
+ t.test('has the new instance\'s context when called as a constructor', function (st) {
+ var actualContext;
+ var expectedContext = { foo: 'bar' };
+ var namespace = {
+ Func: functionBind.call(function () {
+ actualContext = this;
+ }, expectedContext)
+ };
+ var result = new namespace.Func();
+ st.equal(result instanceof namespace.Func, true);
+ st.notEqual(actualContext, expectedContext);
+ st.end();
+ });
+
+ t.end();
+});
+
+test('bound function length', function (t) {
+ t.test('sets a correct length without thisArg', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; });
+ st.equal(subject.length, 3);
+ st.equal(subject(1, 2, 3), 6);
+ st.end();
+ });
+
+ t.test('sets a correct length with thisArg', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {});
+ st.equal(subject.length, 3);
+ st.equal(subject(1, 2, 3), 6);
+ st.end();
+ });
+
+ t.test('sets a correct length without thisArg and first argument', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; }, undefined, 1);
+ st.equal(subject.length, 2);
+ st.equal(subject(2, 3), 6);
+ st.end();
+ });
+
+ t.test('sets a correct length with thisArg and first argument', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {}, 1);
+ st.equal(subject.length, 2);
+ st.equal(subject(2, 3), 6);
+ st.end();
+ });
+
+ t.test('sets a correct length without thisArg and too many arguments', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; }, undefined, 1, 2, 3, 4);
+ st.equal(subject.length, 0);
+ st.equal(subject(), 6);
+ st.end();
+ });
+
+ t.test('sets a correct length with thisArg and too many arguments', function (st) {
+ var subject = functionBind.call(function (a, b, c) { return a + b + c; }, {}, 1, 2, 3, 4);
+ st.equal(subject.length, 0);
+ st.equal(subject(), 6);
+ st.end();
+ });
+});
diff --git a/api/node_modules/get-intrinsic/.eslintignore b/api/node_modules/get-intrinsic/.eslintignore
new file mode 100644
index 000000000..404abb221
--- /dev/null
+++ b/api/node_modules/get-intrinsic/.eslintignore
@@ -0,0 +1 @@
+coverage/
diff --git a/api/node_modules/get-intrinsic/.eslintrc b/api/node_modules/get-intrinsic/.eslintrc
new file mode 100644
index 000000000..d04e4839f
--- /dev/null
+++ b/api/node_modules/get-intrinsic/.eslintrc
@@ -0,0 +1,43 @@
+{
+ "root": true,
+
+ "extends": "@ljharb",
+
+ "env": {
+ "es6": true,
+ "es2017": true,
+ "es2020": true,
+ "es2021": true,
+ },
+
+ "globals": {
+ "AggregateError": false,
+ },
+
+ "rules": {
+ "array-bracket-newline": 0,
+ "array-element-newline": 0,
+ "complexity": 0,
+ "eqeqeq": [2, "allow-null"],
+ "func-name-matching": 0,
+ "id-length": 0,
+ "max-lines-per-function": [2, 80],
+ "max-params": [2, 4],
+ "max-statements": 0,
+ "max-statements-per-line": [2, { "max": 2 }],
+ "multiline-comment-style": 0,
+ "no-magic-numbers": 0,
+ "operator-linebreak": [2, "before"],
+ "sort-keys": 0,
+ },
+
+ "overrides": [
+ {
+ "files": "test/**",
+ "rules": {
+ "max-lines-per-function": 0,
+ "new-cap": 0,
+ },
+ },
+ ],
+}
diff --git a/api/node_modules/get-intrinsic/.github/FUNDING.yml b/api/node_modules/get-intrinsic/.github/FUNDING.yml
new file mode 100644
index 000000000..8e8da0dda
--- /dev/null
+++ b/api/node_modules/get-intrinsic/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ljharb]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/get-intrinsic
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/api/node_modules/get-intrinsic/.nycrc b/api/node_modules/get-intrinsic/.nycrc
new file mode 100644
index 000000000..1826526e0
--- /dev/null
+++ b/api/node_modules/get-intrinsic/.nycrc
@@ -0,0 +1,13 @@
+{
+ "all": true,
+ "check-coverage": false,
+ "reporter": ["text-summary", "text", "html", "json"],
+ "lines": 86,
+ "statements": 85.93,
+ "functions": 82.43,
+ "branches": 76.06,
+ "exclude": [
+ "coverage",
+ "test"
+ ]
+}
diff --git a/api/node_modules/get-intrinsic/CHANGELOG.md b/api/node_modules/get-intrinsic/CHANGELOG.md
new file mode 100644
index 000000000..32502ec1f
--- /dev/null
+++ b/api/node_modules/get-intrinsic/CHANGELOG.md
@@ -0,0 +1,64 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v1.1.1](https://github.com/ljharb/get-intrinsic/compare/v1.1.0...v1.1.1) - 2021-02-03
+
+### Fixed
+
+- [meta] export `./package.json` [`#9`](https://github.com/ljharb/get-intrinsic/issues/9)
+
+### Commits
+
+- [readme] flesh out the readme; use `evalmd` [`d12f12c`](https://github.com/ljharb/get-intrinsic/commit/d12f12c15345a0a0772cc65a7c64369529abd614)
+- [eslint] set up proper globals config [`5a8c098`](https://github.com/ljharb/get-intrinsic/commit/5a8c0984e3319d1ac0e64b102f8ec18b64e79f36)
+- [Dev Deps] update `eslint` [`7b9a5c0`](https://github.com/ljharb/get-intrinsic/commit/7b9a5c0d31a90ca1a1234181c74988fb046701cd)
+
+## [v1.1.0](https://github.com/ljharb/get-intrinsic/compare/v1.0.2...v1.1.0) - 2021-01-25
+
+### Fixed
+
+- [Refactor] delay `Function` eval until syntax-derived values are requested [`#3`](https://github.com/ljharb/get-intrinsic/issues/3)
+
+### Commits
+
+- [Tests] migrate tests to Github Actions [`2ab762b`](https://github.com/ljharb/get-intrinsic/commit/2ab762b48164aea8af37a40ba105bbc8246ab8c4)
+- [meta] do not publish github action workflow files [`5e7108e`](https://github.com/ljharb/get-intrinsic/commit/5e7108e4768b244d48d9567ba4f8a6cab9c65b8e)
+- [Tests] add some coverage [`01ac7a8`](https://github.com/ljharb/get-intrinsic/commit/01ac7a87ac29738567e8524cd8c9e026b1fa8cb3)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `call-bind`, `es-abstract`, `tape`; add `call-bind` [`911b672`](https://github.com/ljharb/get-intrinsic/commit/911b672fbffae433a96924c6ce013585e425f4b7)
+- [Refactor] rearrange evalled constructors a bit [`7e7e4bf`](https://github.com/ljharb/get-intrinsic/commit/7e7e4bf583f3799c8ac1c6c5e10d2cb553957347)
+- [meta] add Automatic Rebase and Require Allow Edits workflows [`0199968`](https://github.com/ljharb/get-intrinsic/commit/01999687a263ffce0a3cb011dfbcb761754aedbc)
+
+## [v1.0.2](https://github.com/ljharb/get-intrinsic/compare/v1.0.1...v1.0.2) - 2020-12-17
+
+### Commits
+
+- [Fix] Throw for non‑existent intrinsics [`68f873b`](https://github.com/ljharb/get-intrinsic/commit/68f873b013c732a05ad6f5fc54f697e55515461b)
+- [Fix] Throw for non‑existent segments in the intrinsic path [`8325dee`](https://github.com/ljharb/get-intrinsic/commit/8325deee43128f3654d3399aa9591741ebe17b21)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `has-bigints`, `object-inspect` [`0c227a7`](https://github.com/ljharb/get-intrinsic/commit/0c227a7d8b629166f25715fd242553892e458525)
+- [meta] do not lint coverage output [`70d2419`](https://github.com/ljharb/get-intrinsic/commit/70d24199b620043cd9110fc5f426d214ebe21dc9)
+
+## [v1.0.1](https://github.com/ljharb/get-intrinsic/compare/v1.0.0...v1.0.1) - 2020-10-30
+
+### Commits
+
+- [Tests] gather coverage data on every job [`d1d280d`](https://github.com/ljharb/get-intrinsic/commit/d1d280dec714e3f0519cc877dbcb193057d9cac6)
+- [Fix] add missing dependencies [`5031771`](https://github.com/ljharb/get-intrinsic/commit/5031771bb1095b38be88ce7c41d5de88718e432e)
+- [Tests] use `es-value-fixtures` [`af48765`](https://github.com/ljharb/get-intrinsic/commit/af48765a23c5323fb0b6b38dbf00eb5099c7bebc)
+
+## v1.0.0 - 2020-10-29
+
+### Commits
+
+- Implementation [`bbce57c`](https://github.com/ljharb/get-intrinsic/commit/bbce57c6f33d05b2d8d3efa273ceeb3ee01127bb)
+- Tests [`17b4f0d`](https://github.com/ljharb/get-intrinsic/commit/17b4f0d56dea6b4059b56fc30ef3ee4d9500ebc2)
+- Initial commit [`3153294`](https://github.com/ljharb/get-intrinsic/commit/31532948de363b0a27dd9fd4649e7b7028ec4b44)
+- npm init [`fb326c4`](https://github.com/ljharb/get-intrinsic/commit/fb326c4d2817c8419ec31de1295f06bb268a7902)
+- [meta] add Automatic Rebase and Require Allow Edits workflows [`48862fb`](https://github.com/ljharb/get-intrinsic/commit/48862fb2508c8f6a57968e6d08b7c883afc9d550)
+- [meta] add `auto-changelog` [`5f28ad0`](https://github.com/ljharb/get-intrinsic/commit/5f28ad019e060a353d8028f9f2591a9cc93074a1)
+- [meta] add "funding"; create `FUNDING.yml` [`c2bbdde`](https://github.com/ljharb/get-intrinsic/commit/c2bbddeba73a875be61484ee4680b129a6d4e0a1)
+- [Tests] add `npm run lint` [`0a84b98`](https://github.com/ljharb/get-intrinsic/commit/0a84b98b22b7cf7a748666f705b0003a493c35fd)
+- Only apps should have lockfiles [`9586c75`](https://github.com/ljharb/get-intrinsic/commit/9586c75866c1ee678e4d5d4dbbdef6997e511b05)
diff --git a/api/node_modules/get-intrinsic/LICENSE b/api/node_modules/get-intrinsic/LICENSE
new file mode 100644
index 000000000..48f05d01d
--- /dev/null
+++ b/api/node_modules/get-intrinsic/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2020 Jordan Harband
+
+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.
diff --git a/api/node_modules/get-intrinsic/README.md b/api/node_modules/get-intrinsic/README.md
new file mode 100644
index 000000000..335a3b49b
--- /dev/null
+++ b/api/node_modules/get-intrinsic/README.md
@@ -0,0 +1,65 @@
+# get-intrinsic [![Version Badge][npm-version-svg]][package-url]
+
+[![dependency status][deps-svg]][deps-url]
+[![dev dependency status][dev-deps-svg]][dev-deps-url]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+[![npm badge][npm-badge-png]][package-url]
+
+Get and robustly cache all JS language-level intrinsics at first require time.
+
+See the syntax described [in the JS spec](https://tc39.es/ecma262/#sec-well-known-intrinsic-objects) for reference.
+
+## Example
+
+```js
+var GetIntrinsic = require('get-intrinsic');
+var assert = require('assert');
+
+// static methods
+assert.equal(GetIntrinsic('%Math.pow%'), Math.pow);
+assert.equal(Math.pow(2, 3), 8);
+assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);
+delete Math.pow;
+assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);
+
+// instance methods
+var arr = [1];
+assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push);
+assert.deepEqual(arr, [1]);
+
+arr.push(2);
+assert.deepEqual(arr, [1, 2]);
+
+GetIntrinsic('%Array.prototype.push%').call(arr, 3);
+assert.deepEqual(arr, [1, 2, 3]);
+
+delete Array.prototype.push;
+GetIntrinsic('%Array.prototype.push%').call(arr, 4);
+assert.deepEqual(arr, [1, 2, 3, 4]);
+
+// missing features
+delete JSON.parse; // to simulate a real intrinsic that is missing in the environment
+assert.throws(() => GetIntrinsic('%JSON.parse%'));
+assert.equal(undefined, GetIntrinsic('%JSON.parse%', true));
+```
+
+## Tests
+Simply clone the repo, `npm install`, and run `npm test`
+
+## Security
+
+Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
+
+[package-url]: https://npmjs.org/package/get-intrinsic
+[npm-version-svg]: http://versionbadg.es/ljharb/get-intrinsic.svg
+[deps-svg]: https://david-dm.org/ljharb/get-intrinsic.svg
+[deps-url]: https://david-dm.org/ljharb/get-intrinsic
+[dev-deps-svg]: https://david-dm.org/ljharb/get-intrinsic/dev-status.svg
+[dev-deps-url]: https://david-dm.org/ljharb/get-intrinsic#info=devDependencies
+[npm-badge-png]: https://nodei.co/npm/get-intrinsic.png?downloads=true&stars=true
+[license-image]: https://img.shields.io/npm/l/get-intrinsic.svg
+[license-url]: LICENSE
+[downloads-image]: https://img.shields.io/npm/dm/get-intrinsic.svg
+[downloads-url]: https://npm-stat.com/charts.html?package=get-intrinsic
diff --git a/api/node_modules/get-intrinsic/index.js b/api/node_modules/get-intrinsic/index.js
new file mode 100644
index 000000000..d6c06c281
--- /dev/null
+++ b/api/node_modules/get-intrinsic/index.js
@@ -0,0 +1,330 @@
+'use strict';
+
+var undefined;
+
+var $SyntaxError = SyntaxError;
+var $Function = Function;
+var $TypeError = TypeError;
+
+// eslint-disable-next-line consistent-return
+var getEvalledConstructor = function (expressionSyntax) {
+ try {
+ return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
+ } catch (e) {}
+};
+
+var $gOPD = Object.getOwnPropertyDescriptor;
+if ($gOPD) {
+ try {
+ $gOPD({}, '');
+ } catch (e) {
+ $gOPD = null; // this is IE 8, which has a broken gOPD
+ }
+}
+
+var throwTypeError = function () {
+ throw new $TypeError();
+};
+var ThrowTypeError = $gOPD
+ ? (function () {
+ try {
+ // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
+ arguments.callee; // IE 8 does not throw here
+ return throwTypeError;
+ } catch (calleeThrows) {
+ try {
+ // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
+ return $gOPD(arguments, 'callee').get;
+ } catch (gOPDthrows) {
+ return throwTypeError;
+ }
+ }
+ }())
+ : throwTypeError;
+
+var hasSymbols = require('has-symbols')();
+
+var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
+
+var needsEval = {};
+
+var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array);
+
+var INTRINSICS = {
+ '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError,
+ '%Array%': Array,
+ '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer,
+ '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined,
+ '%AsyncFromSyncIteratorPrototype%': undefined,
+ '%AsyncFunction%': needsEval,
+ '%AsyncGenerator%': needsEval,
+ '%AsyncGeneratorFunction%': needsEval,
+ '%AsyncIteratorPrototype%': needsEval,
+ '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics,
+ '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt,
+ '%Boolean%': Boolean,
+ '%DataView%': typeof DataView === 'undefined' ? undefined : DataView,
+ '%Date%': Date,
+ '%decodeURI%': decodeURI,
+ '%decodeURIComponent%': decodeURIComponent,
+ '%encodeURI%': encodeURI,
+ '%encodeURIComponent%': encodeURIComponent,
+ '%Error%': Error,
+ '%eval%': eval, // eslint-disable-line no-eval
+ '%EvalError%': EvalError,
+ '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array,
+ '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array,
+ '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry,
+ '%Function%': $Function,
+ '%GeneratorFunction%': needsEval,
+ '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array,
+ '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array,
+ '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array,
+ '%isFinite%': isFinite,
+ '%isNaN%': isNaN,
+ '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined,
+ '%JSON%': typeof JSON === 'object' ? JSON : undefined,
+ '%Map%': typeof Map === 'undefined' ? undefined : Map,
+ '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()),
+ '%Math%': Math,
+ '%Number%': Number,
+ '%Object%': Object,
+ '%parseFloat%': parseFloat,
+ '%parseInt%': parseInt,
+ '%Promise%': typeof Promise === 'undefined' ? undefined : Promise,
+ '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy,
+ '%RangeError%': RangeError,
+ '%ReferenceError%': ReferenceError,
+ '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect,
+ '%RegExp%': RegExp,
+ '%Set%': typeof Set === 'undefined' ? undefined : Set,
+ '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()),
+ '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer,
+ '%String%': String,
+ '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined,
+ '%Symbol%': hasSymbols ? Symbol : undefined,
+ '%SyntaxError%': $SyntaxError,
+ '%ThrowTypeError%': ThrowTypeError,
+ '%TypedArray%': TypedArray,
+ '%TypeError%': $TypeError,
+ '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array,
+ '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray,
+ '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array,
+ '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array,
+ '%URIError%': URIError,
+ '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap,
+ '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef,
+ '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet
+};
+
+var doEval = function doEval(name) {
+ var value;
+ if (name === '%AsyncFunction%') {
+ value = getEvalledConstructor('async function () {}');
+ } else if (name === '%GeneratorFunction%') {
+ value = getEvalledConstructor('function* () {}');
+ } else if (name === '%AsyncGeneratorFunction%') {
+ value = getEvalledConstructor('async function* () {}');
+ } else if (name === '%AsyncGenerator%') {
+ var fn = doEval('%AsyncGeneratorFunction%');
+ if (fn) {
+ value = fn.prototype;
+ }
+ } else if (name === '%AsyncIteratorPrototype%') {
+ var gen = doEval('%AsyncGenerator%');
+ if (gen) {
+ value = getProto(gen.prototype);
+ }
+ }
+
+ INTRINSICS[name] = value;
+
+ return value;
+};
+
+var LEGACY_ALIASES = {
+ '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
+ '%ArrayPrototype%': ['Array', 'prototype'],
+ '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
+ '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
+ '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
+ '%ArrayProto_values%': ['Array', 'prototype', 'values'],
+ '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
+ '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
+ '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
+ '%BooleanPrototype%': ['Boolean', 'prototype'],
+ '%DataViewPrototype%': ['DataView', 'prototype'],
+ '%DatePrototype%': ['Date', 'prototype'],
+ '%ErrorPrototype%': ['Error', 'prototype'],
+ '%EvalErrorPrototype%': ['EvalError', 'prototype'],
+ '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
+ '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
+ '%FunctionPrototype%': ['Function', 'prototype'],
+ '%Generator%': ['GeneratorFunction', 'prototype'],
+ '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
+ '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
+ '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
+ '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
+ '%JSONParse%': ['JSON', 'parse'],
+ '%JSONStringify%': ['JSON', 'stringify'],
+ '%MapPrototype%': ['Map', 'prototype'],
+ '%NumberPrototype%': ['Number', 'prototype'],
+ '%ObjectPrototype%': ['Object', 'prototype'],
+ '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
+ '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
+ '%PromisePrototype%': ['Promise', 'prototype'],
+ '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
+ '%Promise_all%': ['Promise', 'all'],
+ '%Promise_reject%': ['Promise', 'reject'],
+ '%Promise_resolve%': ['Promise', 'resolve'],
+ '%RangeErrorPrototype%': ['RangeError', 'prototype'],
+ '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
+ '%RegExpPrototype%': ['RegExp', 'prototype'],
+ '%SetPrototype%': ['Set', 'prototype'],
+ '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
+ '%StringPrototype%': ['String', 'prototype'],
+ '%SymbolPrototype%': ['Symbol', 'prototype'],
+ '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
+ '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
+ '%TypeErrorPrototype%': ['TypeError', 'prototype'],
+ '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
+ '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
+ '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
+ '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
+ '%URIErrorPrototype%': ['URIError', 'prototype'],
+ '%WeakMapPrototype%': ['WeakMap', 'prototype'],
+ '%WeakSetPrototype%': ['WeakSet', 'prototype']
+};
+
+var bind = require('function-bind');
+var hasOwn = require('has');
+var $concat = bind.call(Function.call, Array.prototype.concat);
+var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
+var $replace = bind.call(Function.call, String.prototype.replace);
+var $strSlice = bind.call(Function.call, String.prototype.slice);
+
+/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
+var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
+var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
+var stringToPath = function stringToPath(string) {
+ var first = $strSlice(string, 0, 1);
+ var last = $strSlice(string, -1);
+ if (first === '%' && last !== '%') {
+ throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`');
+ } else if (last === '%' && first !== '%') {
+ throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`');
+ }
+ var result = [];
+ $replace(string, rePropName, function (match, number, quote, subString) {
+ result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
+ });
+ return result;
+};
+/* end adaptation */
+
+var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
+ var intrinsicName = name;
+ var alias;
+ if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
+ alias = LEGACY_ALIASES[intrinsicName];
+ intrinsicName = '%' + alias[0] + '%';
+ }
+
+ if (hasOwn(INTRINSICS, intrinsicName)) {
+ var value = INTRINSICS[intrinsicName];
+ if (value === needsEval) {
+ value = doEval(intrinsicName);
+ }
+ if (typeof value === 'undefined' && !allowMissing) {
+ throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
+ }
+
+ return {
+ alias: alias,
+ name: intrinsicName,
+ value: value
+ };
+ }
+
+ throw new $SyntaxError('intrinsic ' + name + ' does not exist!');
+};
+
+module.exports = function GetIntrinsic(name, allowMissing) {
+ if (typeof name !== 'string' || name.length === 0) {
+ throw new $TypeError('intrinsic name must be a non-empty string');
+ }
+ if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
+ throw new $TypeError('"allowMissing" argument must be a boolean');
+ }
+
+ var parts = stringToPath(name);
+ var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
+
+ var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
+ var intrinsicRealName = intrinsic.name;
+ var value = intrinsic.value;
+ var skipFurtherCaching = false;
+
+ var alias = intrinsic.alias;
+ if (alias) {
+ intrinsicBaseName = alias[0];
+ $spliceApply(parts, $concat([0, 1], alias));
+ }
+
+ for (var i = 1, isOwn = true; i < parts.length; i += 1) {
+ var part = parts[i];
+ var first = $strSlice(part, 0, 1);
+ var last = $strSlice(part, -1);
+ if (
+ (
+ (first === '"' || first === "'" || first === '`')
+ || (last === '"' || last === "'" || last === '`')
+ )
+ && first !== last
+ ) {
+ throw new $SyntaxError('property names with quotes must have matching quotes');
+ }
+ if (part === 'constructor' || !isOwn) {
+ skipFurtherCaching = true;
+ }
+
+ intrinsicBaseName += '.' + part;
+ intrinsicRealName = '%' + intrinsicBaseName + '%';
+
+ if (hasOwn(INTRINSICS, intrinsicRealName)) {
+ value = INTRINSICS[intrinsicRealName];
+ } else if (value != null) {
+ if (!(part in value)) {
+ if (!allowMissing) {
+ throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.');
+ }
+ return void undefined;
+ }
+ if ($gOPD && (i + 1) >= parts.length) {
+ var desc = $gOPD(value, part);
+ isOwn = !!desc;
+
+ // By convention, when a data property is converted to an accessor
+ // property to emulate a data property that does not suffer from
+ // the override mistake, that accessor's getter is marked with
+ // an `originalValue` property. Here, when we detect this, we
+ // uphold the illusion by pretending to see that original data
+ // property, i.e., returning the value rather than the getter
+ // itself.
+ if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
+ value = desc.get;
+ } else {
+ value = value[part];
+ }
+ } else {
+ isOwn = hasOwn(value, part);
+ value = value[part];
+ }
+
+ if (isOwn && !skipFurtherCaching) {
+ INTRINSICS[intrinsicRealName] = value;
+ }
+ }
+ }
+ return value;
+};
diff --git a/api/node_modules/get-intrinsic/package.json b/api/node_modules/get-intrinsic/package.json
new file mode 100644
index 000000000..d34894a06
--- /dev/null
+++ b/api/node_modules/get-intrinsic/package.json
@@ -0,0 +1,78 @@
+{
+ "name": "get-intrinsic",
+ "version": "1.1.1",
+ "description": "Get and robustly cache all JS language-level intrinsics at first require time",
+ "main": "index.js",
+ "exports": {
+ ".": [
+ {
+ "default": "./index.js"
+ },
+ "./index.js"
+ ],
+ "./package.json": "./package.json"
+ },
+ "scripts": {
+ "prelint": "evalmd README.md",
+ "lint": "eslint --ext=.js,.mjs .",
+ "pretest": "npm run lint",
+ "tests-only": "nyc tape 'test/**/*.js'",
+ "test": "npm run tests-only",
+ "posttest": "aud --production",
+ "version": "auto-changelog && git add CHANGELOG.md",
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/ljharb/get-intrinsic.git"
+ },
+ "keywords": [
+ "javascript",
+ "ecmascript",
+ "es",
+ "js",
+ "intrinsic",
+ "getintrinsic",
+ "es-abstract"
+ ],
+ "author": "Jordan Harband ",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/ljharb/get-intrinsic/issues"
+ },
+ "homepage": "https://github.com/ljharb/get-intrinsic#readme",
+ "devDependencies": {
+ "@ljharb/eslint-config": "^17.5.0",
+ "aud": "^1.1.3",
+ "auto-changelog": "^2.2.1",
+ "call-bind": "^1.0.2",
+ "es-abstract": "^1.18.0-next.2",
+ "es-value-fixtures": "^1.0.0",
+ "eslint": "^7.19.0",
+ "evalmd": "^0.0.19",
+ "foreach": "^2.0.5",
+ "has-bigints": "^1.0.1",
+ "make-async-function": "^1.0.0",
+ "make-async-generator-function": "^1.0.0",
+ "make-generator-function": "^2.0.0",
+ "nyc": "^10.3.2",
+ "object-inspect": "^1.9.0",
+ "tape": "^5.1.1"
+ },
+ "auto-changelog": {
+ "output": "CHANGELOG.md",
+ "template": "keepachangelog",
+ "unreleased": false,
+ "commitLimit": false,
+ "backfillLimit": false,
+ "hideCredit": true
+ },
+ "dependencies": {
+ "function-bind": "^1.1.1",
+ "has": "^1.0.3",
+ "has-symbols": "^1.0.1"
+ }
+}
diff --git a/api/node_modules/get-intrinsic/test/GetIntrinsic.js b/api/node_modules/get-intrinsic/test/GetIntrinsic.js
new file mode 100644
index 000000000..695e3ad41
--- /dev/null
+++ b/api/node_modules/get-intrinsic/test/GetIntrinsic.js
@@ -0,0 +1,260 @@
+'use strict';
+
+var GetIntrinsic = require('../');
+
+var test = require('tape');
+var forEach = require('foreach');
+var debug = require('object-inspect');
+var generatorFns = require('make-generator-function')();
+var asyncFns = require('make-async-function').list();
+var asyncGenFns = require('make-async-generator-function')();
+
+var callBound = require('call-bind/callBound');
+var v = require('es-value-fixtures');
+var $gOPD = require('es-abstract/helpers/getOwnPropertyDescriptor');
+var defineProperty = require('es-abstract/test/helpers/defineProperty');
+
+var $isProto = callBound('%Object.prototype.isPrototypeOf%');
+
+test('export', function (t) {
+ t.equal(typeof GetIntrinsic, 'function', 'it is a function');
+ t.equal(GetIntrinsic.length, 2, 'function has length of 2');
+
+ t.end();
+});
+
+test('throws', function (t) {
+ t['throws'](
+ function () { GetIntrinsic('not an intrinsic'); },
+ SyntaxError,
+ 'nonexistent intrinsic throws a syntax error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic(''); },
+ TypeError,
+ 'empty string intrinsic throws a type error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic('.'); },
+ SyntaxError,
+ '"just a dot" intrinsic throws a syntax error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic('%String'); },
+ SyntaxError,
+ 'Leading % without trailing % throws a syntax error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic('String%'); },
+ SyntaxError,
+ 'Trailing % without leading % throws a syntax error'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic("String['prototype]"); },
+ SyntaxError,
+ 'Dynamic property access is disallowed for intrinsics (unterminated string)'
+ );
+
+ t['throws'](
+ function () { GetIntrinsic('%Proxy.prototype.undefined%'); },
+ TypeError,
+ "Throws when middle part doesn't exist (%Proxy.prototype.undefined%)"
+ );
+
+ forEach(v.nonStrings, function (nonString) {
+ t['throws'](
+ function () { GetIntrinsic(nonString); },
+ TypeError,
+ debug(nonString) + ' is not a String'
+ );
+ });
+
+ forEach(v.nonBooleans, function (nonBoolean) {
+ t['throws'](
+ function () { GetIntrinsic('%', nonBoolean); },
+ TypeError,
+ debug(nonBoolean) + ' is not a Boolean'
+ );
+ });
+
+ forEach([
+ 'toString',
+ 'propertyIsEnumerable',
+ 'hasOwnProperty'
+ ], function (objectProtoMember) {
+ t['throws'](
+ function () { GetIntrinsic(objectProtoMember); },
+ SyntaxError,
+ debug(objectProtoMember) + ' is not an intrinsic'
+ );
+ });
+
+ t.end();
+});
+
+test('base intrinsics', function (t) {
+ t.equal(GetIntrinsic('%Object%'), Object, '%Object% yields Object');
+ t.equal(GetIntrinsic('Object'), Object, 'Object yields Object');
+ t.equal(GetIntrinsic('%Array%'), Array, '%Array% yields Array');
+ t.equal(GetIntrinsic('Array'), Array, 'Array yields Array');
+
+ t.end();
+});
+
+test('dotted paths', function (t) {
+ t.equal(GetIntrinsic('%Object.prototype.toString%'), Object.prototype.toString, '%Object.prototype.toString% yields Object.prototype.toString');
+ t.equal(GetIntrinsic('Object.prototype.toString'), Object.prototype.toString, 'Object.prototype.toString yields Object.prototype.toString');
+ t.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push, '%Array.prototype.push% yields Array.prototype.push');
+ t.equal(GetIntrinsic('Array.prototype.push'), Array.prototype.push, 'Array.prototype.push yields Array.prototype.push');
+
+ test('underscore paths are aliases for dotted paths', { skip: !Object.isFrozen || Object.isFrozen(Object.prototype) }, function (st) {
+ var original = GetIntrinsic('%ObjProto_toString%');
+
+ forEach([
+ '%Object.prototype.toString%',
+ 'Object.prototype.toString',
+ '%ObjectPrototype.toString%',
+ 'ObjectPrototype.toString',
+ '%ObjProto_toString%',
+ 'ObjProto_toString'
+ ], function (name) {
+ defineProperty(Object.prototype, 'toString', {
+ value: function toString() {
+ return original.apply(this, arguments);
+ }
+ });
+ st.equal(GetIntrinsic(name), original, name + ' yields original Object.prototype.toString');
+ });
+
+ defineProperty(Object.prototype, 'toString', { value: original });
+ st.end();
+ });
+
+ test('dotted paths cache', { skip: !Object.isFrozen || Object.isFrozen(Object.prototype) }, function (st) {
+ var original = GetIntrinsic('%Object.prototype.propertyIsEnumerable%');
+
+ forEach([
+ '%Object.prototype.propertyIsEnumerable%',
+ 'Object.prototype.propertyIsEnumerable',
+ '%ObjectPrototype.propertyIsEnumerable%',
+ 'ObjectPrototype.propertyIsEnumerable'
+ ], function (name) {
+ // eslint-disable-next-line no-extend-native
+ Object.prototype.propertyIsEnumerable = function propertyIsEnumerable() {
+ return original.apply(this, arguments);
+ };
+ st.equal(GetIntrinsic(name), original, name + ' yields cached Object.prototype.propertyIsEnumerable');
+ });
+
+ // eslint-disable-next-line no-extend-native
+ Object.prototype.propertyIsEnumerable = original;
+ st.end();
+ });
+
+ test('dotted path reports correct error', function (st) {
+ st['throws'](function () {
+ GetIntrinsic('%NonExistentIntrinsic.prototype.property%');
+ }, /%NonExistentIntrinsic%/, 'The base intrinsic of %NonExistentIntrinsic.prototype.property% is %NonExistentIntrinsic%');
+
+ st['throws'](function () {
+ GetIntrinsic('%NonExistentIntrinsicPrototype.property%');
+ }, /%NonExistentIntrinsicPrototype%/, 'The base intrinsic of %NonExistentIntrinsicPrototype.property% is %NonExistentIntrinsicPrototype%');
+
+ st.end();
+ });
+
+ t.end();
+});
+
+test('accessors', { skip: !$gOPD || typeof Map !== 'function' }, function (t) {
+ var actual = $gOPD(Map.prototype, 'size');
+ t.ok(actual, 'Map.prototype.size has a descriptor');
+ t.equal(typeof actual.get, 'function', 'Map.prototype.size has a getter function');
+ t.equal(GetIntrinsic('%Map.prototype.size%'), actual.get, '%Map.prototype.size% yields the getter for it');
+ t.equal(GetIntrinsic('Map.prototype.size'), actual.get, 'Map.prototype.size yields the getter for it');
+
+ t.end();
+});
+
+test('generator functions', { skip: !generatorFns.length }, function (t) {
+ var $GeneratorFunction = GetIntrinsic('%GeneratorFunction%');
+ var $GeneratorFunctionPrototype = GetIntrinsic('%Generator%');
+ var $GeneratorPrototype = GetIntrinsic('%GeneratorPrototype%');
+
+ forEach(generatorFns, function (genFn) {
+ var fnName = genFn.name;
+ fnName = fnName ? "'" + fnName + "'" : 'genFn';
+
+ t.ok(genFn instanceof $GeneratorFunction, fnName + ' instanceof %GeneratorFunction%');
+ t.ok($isProto($GeneratorFunctionPrototype, genFn), '%Generator% is prototype of ' + fnName);
+ t.ok($isProto($GeneratorPrototype, genFn.prototype), '%GeneratorPrototype% is prototype of ' + fnName + '.prototype');
+ });
+
+ t.end();
+});
+
+test('async functions', { skip: !asyncFns.length }, function (t) {
+ var $AsyncFunction = GetIntrinsic('%AsyncFunction%');
+ var $AsyncFunctionPrototype = GetIntrinsic('%AsyncFunctionPrototype%');
+
+ forEach(asyncFns, function (asyncFn) {
+ var fnName = asyncFn.name;
+ fnName = fnName ? "'" + fnName + "'" : 'asyncFn';
+
+ t.ok(asyncFn instanceof $AsyncFunction, fnName + ' instanceof %AsyncFunction%');
+ t.ok($isProto($AsyncFunctionPrototype, asyncFn), '%AsyncFunctionPrototype% is prototype of ' + fnName);
+ });
+
+ t.end();
+});
+
+test('async generator functions', { skip: asyncGenFns.length === 0 }, function (t) {
+ var $AsyncGeneratorFunction = GetIntrinsic('%AsyncGeneratorFunction%');
+ var $AsyncGeneratorFunctionPrototype = GetIntrinsic('%AsyncGenerator%');
+ var $AsyncGeneratorPrototype = GetIntrinsic('%AsyncGeneratorPrototype%');
+
+ forEach(asyncGenFns, function (asyncGenFn) {
+ var fnName = asyncGenFn.name;
+ fnName = fnName ? "'" + fnName + "'" : 'asyncGenFn';
+
+ t.ok(asyncGenFn instanceof $AsyncGeneratorFunction, fnName + ' instanceof %AsyncGeneratorFunction%');
+ t.ok($isProto($AsyncGeneratorFunctionPrototype, asyncGenFn), '%AsyncGenerator% is prototype of ' + fnName);
+ t.ok($isProto($AsyncGeneratorPrototype, asyncGenFn.prototype), '%AsyncGeneratorPrototype% is prototype of ' + fnName + '.prototype');
+ });
+
+ t.end();
+});
+
+test('%ThrowTypeError%', function (t) {
+ var $ThrowTypeError = GetIntrinsic('%ThrowTypeError%');
+
+ t.equal(typeof $ThrowTypeError, 'function', 'is a function');
+ t['throws'](
+ $ThrowTypeError,
+ TypeError,
+ '%ThrowTypeError% throws a TypeError'
+ );
+
+ t.end();
+});
+
+test('allowMissing', { skip: asyncGenFns.length > 0 }, function (t) {
+ t['throws'](
+ function () { GetIntrinsic('%AsyncGeneratorPrototype%'); },
+ TypeError,
+ 'throws when missing'
+ );
+
+ t.equal(
+ GetIntrinsic('%AsyncGeneratorPrototype%', true),
+ undefined,
+ 'does not throw when allowMissing'
+ );
+
+ t.end();
+});
diff --git a/api/node_modules/graceful-readlink/.npmignore b/api/node_modules/graceful-readlink/.npmignore
deleted file mode 100644
index 3ac7d16c6..000000000
--- a/api/node_modules/graceful-readlink/.npmignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.idea/
-.DS_Store
-node_modules/
diff --git a/api/node_modules/graceful-readlink/.travis.yml b/api/node_modules/graceful-readlink/.travis.yml
deleted file mode 100644
index baf9be7f6..000000000
--- a/api/node_modules/graceful-readlink/.travis.yml
+++ /dev/null
@@ -1,5 +0,0 @@
-language: node_js
-node_js:
- - "0.10"
- - "0.12"
- - "io.js"
diff --git a/api/node_modules/graceful-readlink/LICENSE b/api/node_modules/graceful-readlink/LICENSE
deleted file mode 100644
index d1f842f0b..000000000
--- a/api/node_modules/graceful-readlink/LICENSE
+++ /dev/null
@@ -1,22 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2015 Zhiye Li
-
-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.
-
diff --git a/api/node_modules/graceful-readlink/README.md b/api/node_modules/graceful-readlink/README.md
deleted file mode 100644
index fc63b505a..000000000
--- a/api/node_modules/graceful-readlink/README.md
+++ /dev/null
@@ -1,17 +0,0 @@
-# graceful-readlink
-[![NPM Version](http://img.shields.io/npm/v/graceful-readlink.svg?style=flat)](https://www.npmjs.org/package/graceful-readlink)
-[![NPM Downloads](https://img.shields.io/npm/dm/graceful-readlink.svg?style=flat)](https://www.npmjs.org/package/graceful-readlink)
-
-
-## Usage
-
-```js
-var readlinkSync = require('graceful-readlink').readlinkSync;
-console.log(readlinkSync(f));
-// output
-// the file pointed to when `f` is a symbolic link
-// the `f` itself when `f` is not a symbolic link
-```
-## Licence
-
-MIT License
diff --git a/api/node_modules/graceful-readlink/index.js b/api/node_modules/graceful-readlink/index.js
deleted file mode 100644
index 7e9fc70f0..000000000
--- a/api/node_modules/graceful-readlink/index.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var fs = require('fs')
- , lstat = fs.lstatSync;
-
-exports.readlinkSync = function (p) {
- if (lstat(p).isSymbolicLink()) {
- return fs.readlinkSync(p);
- } else {
- return p;
- }
-};
-
-
diff --git a/api/node_modules/graceful-readlink/package.json b/api/node_modules/graceful-readlink/package.json
deleted file mode 100644
index d5f1d702a..000000000
--- a/api/node_modules/graceful-readlink/package.json
+++ /dev/null
@@ -1,50 +0,0 @@
-{
- "_from": "graceful-readlink@>= 1.0.0",
- "_id": "graceful-readlink@1.0.1",
- "_inBundle": false,
- "_integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
- "_location": "/graceful-readlink",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "graceful-readlink@>= 1.0.0",
- "name": "graceful-readlink",
- "escapedName": "graceful-readlink",
- "rawSpec": ">= 1.0.0",
- "saveSpec": null,
- "fetchSpec": ">= 1.0.0"
- },
- "_requiredBy": [
- "/clean-css/commander"
- ],
- "_resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
- "_shasum": "4cafad76bc62f02fa039b2f94e9a3dd3a391a725",
- "_spec": "graceful-readlink@>= 1.0.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/clean-css/node_modules/commander",
- "author": {
- "name": "zhiyelee"
- },
- "bugs": {
- "url": "https://github.com/zhiyelee/graceful-readlink/issues"
- },
- "bundleDependencies": false,
- "deprecated": false,
- "description": "graceful fs.readlink",
- "homepage": "https://github.com/zhiyelee/graceful-readlink",
- "keywords": [
- "fs.readlink",
- "readlink"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "graceful-readlink",
- "repository": {
- "type": "git",
- "url": "git://github.com/zhiyelee/graceful-readlink.git"
- },
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "version": "1.0.1"
-}
diff --git a/api/node_modules/has-symbols/.eslintignore b/api/node_modules/has-symbols/.eslintignore
new file mode 100644
index 000000000..404abb221
--- /dev/null
+++ b/api/node_modules/has-symbols/.eslintignore
@@ -0,0 +1 @@
+coverage/
diff --git a/api/node_modules/has-symbols/.eslintrc b/api/node_modules/has-symbols/.eslintrc
new file mode 100644
index 000000000..2d9a66a8a
--- /dev/null
+++ b/api/node_modules/has-symbols/.eslintrc
@@ -0,0 +1,11 @@
+{
+ "root": true,
+
+ "extends": "@ljharb",
+
+ "rules": {
+ "max-statements-per-line": [2, { "max": 2 }],
+ "no-magic-numbers": 0,
+ "multiline-comment-style": 0,
+ }
+}
diff --git a/api/node_modules/has-symbols/.github/FUNDING.yml b/api/node_modules/has-symbols/.github/FUNDING.yml
new file mode 100644
index 000000000..04cf87e66
--- /dev/null
+++ b/api/node_modules/has-symbols/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ljharb]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/has-symbols
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/api/node_modules/has-symbols/.nycrc b/api/node_modules/has-symbols/.nycrc
new file mode 100644
index 000000000..1826526e0
--- /dev/null
+++ b/api/node_modules/has-symbols/.nycrc
@@ -0,0 +1,13 @@
+{
+ "all": true,
+ "check-coverage": false,
+ "reporter": ["text-summary", "text", "html", "json"],
+ "lines": 86,
+ "statements": 85.93,
+ "functions": 82.43,
+ "branches": 76.06,
+ "exclude": [
+ "coverage",
+ "test"
+ ]
+}
diff --git a/api/node_modules/has-symbols/CHANGELOG.md b/api/node_modules/has-symbols/CHANGELOG.md
new file mode 100644
index 000000000..852ca0420
--- /dev/null
+++ b/api/node_modules/has-symbols/CHANGELOG.md
@@ -0,0 +1,58 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v1.0.2](https://github.com/inspect-js/has-symbols/compare/v1.0.1...v1.0.2) - 2021-02-27
+
+### Fixed
+
+- [Fix] use a universal way to get the original Symbol [`#11`](https://github.com/inspect-js/has-symbols/issues/11)
+
+### Commits
+
+- [Tests] migrate tests to Github Actions [`90ae798`](https://github.com/inspect-js/has-symbols/commit/90ae79820bdfe7bc703d67f5f3c5e205f98556d3)
+- [meta] do not publish github action workflow files [`29e60a1`](https://github.com/inspect-js/has-symbols/commit/29e60a1b7c25c7f1acf7acff4a9320d0d10c49b4)
+- [Tests] run `nyc` on all tests [`8476b91`](https://github.com/inspect-js/has-symbols/commit/8476b915650d360915abe2522505abf4b0e8f0ae)
+- [readme] fix repo URLs, remove defunct badges [`126288e`](https://github.com/inspect-js/has-symbols/commit/126288ecc1797c0a40247a6b78bcb2e0bc5d7036)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `core-js`, `get-own-property-symbols` [`d84bdfa`](https://github.com/inspect-js/has-symbols/commit/d84bdfa48ac5188abbb4904b42614cd6c030940a)
+- [Tests] fix linting errors [`0df3070`](https://github.com/inspect-js/has-symbols/commit/0df3070b981b6c9f2ee530c09189a7f5c6def839)
+- [actions] add "Allow Edits" workflow [`1e6bc29`](https://github.com/inspect-js/has-symbols/commit/1e6bc29b188f32b9648657b07eda08504be5aa9c)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `tape` [`36cea2a`](https://github.com/inspect-js/has-symbols/commit/36cea2addd4e6ec435f35a2656b4e9ef82498e9b)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`1278338`](https://github.com/inspect-js/has-symbols/commit/127833801865fbc2cc8979beb9ca869c7bfe8222)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `tape` [`1493254`](https://github.com/inspect-js/has-symbols/commit/1493254eda13db5fb8fc5e4a3e8324b3d196029d)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `core-js` [`b090bf2`](https://github.com/inspect-js/has-symbols/commit/b090bf214d3679a30edc1e2d729d466ab5183e1d)
+- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`4addb7a`](https://github.com/inspect-js/has-symbols/commit/4addb7ab4dc73f927ae99928d68817554fc21dc0)
+- [Dev Deps] update `auto-changelog`, `tape` [`81d0baf`](https://github.com/inspect-js/has-symbols/commit/81d0baf3816096a89a8558e8043895f7a7d10d8b)
+- [Dev Deps] update `auto-changelog`; add `aud` [`1a4e561`](https://github.com/inspect-js/has-symbols/commit/1a4e5612c25d91c3a03d509721d02630bc4fe3da)
+- [readme] remove unused testling URLs [`3000941`](https://github.com/inspect-js/has-symbols/commit/3000941f958046e923ed8152edb1ef4a599e6fcc)
+- [Tests] only audit prod deps [`692e974`](https://github.com/inspect-js/has-symbols/commit/692e9743c912410e9440207631a643a34b4741a1)
+- [Dev Deps] update `@ljharb/eslint-config` [`51c946c`](https://github.com/inspect-js/has-symbols/commit/51c946c7f6baa793ec5390bb5a45cdce16b4ba76)
+
+## [v1.0.1](https://github.com/inspect-js/has-symbols/compare/v1.0.0...v1.0.1) - 2019-11-16
+
+### Commits
+
+- [Tests] use shared travis-ci configs [`ce396c9`](https://github.com/inspect-js/has-symbols/commit/ce396c9419ff11c43d0da5d05cdbb79f7fb42229)
+- [Tests] up to `node` `v12.4`, `v11.15`, `v10.15`, `v9.11`, `v8.15`, `v7.10`, `v6.17`, `v4.9`; use `nvm install-latest-npm` [`0690732`](https://github.com/inspect-js/has-symbols/commit/0690732801f47ab429f39ba1962f522d5c462d6b)
+- [meta] add `auto-changelog` [`2163d0b`](https://github.com/inspect-js/has-symbols/commit/2163d0b7f36343076b8f947cd1667dd1750f26fc)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `core-js`, `safe-publish-latest`, `tape` [`8e0951f`](https://github.com/inspect-js/has-symbols/commit/8e0951f1a7a2e52068222b7bb73511761e6e4d9c)
+- [actions] add automatic rebasing / merge commit blocking [`b09cdb7`](https://github.com/inspect-js/has-symbols/commit/b09cdb7cd7ee39e7a769878f56e2d6066f5ccd1d)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest`, `core-js`, `get-own-property-symbols`, `tape` [`1dd42cd`](https://github.com/inspect-js/has-symbols/commit/1dd42cd86183ed0c50f99b1062345c458babca91)
+- [meta] create FUNDING.yml [`aa57a17`](https://github.com/inspect-js/has-symbols/commit/aa57a17b19708906d1927f821ea8e73394d84ca4)
+- Only apps should have lockfiles [`a2d8bea`](https://github.com/inspect-js/has-symbols/commit/a2d8bea23a97d15c09eaf60f5b107fcf9a4d57aa)
+- [Tests] use `npx aud` instead of `nsp` or `npm audit` with hoops [`9e96cb7`](https://github.com/inspect-js/has-symbols/commit/9e96cb783746cbed0c10ef78e599a8eaa7ebe193)
+- [meta] add `funding` field [`a0b32cf`](https://github.com/inspect-js/has-symbols/commit/a0b32cf68e803f963c1639b6d47b0a9d6440bab0)
+- [Dev Deps] update `safe-publish-latest` [`cb9f0a5`](https://github.com/inspect-js/has-symbols/commit/cb9f0a521a3a1790f1064d437edd33bb6c3d6af0)
+
+## v1.0.0 - 2016-09-19
+
+### Commits
+
+- Tests. [`ecb6eb9`](https://github.com/inspect-js/has-symbols/commit/ecb6eb934e4883137f3f93b965ba5e0a98df430d)
+- package.json [`88a337c`](https://github.com/inspect-js/has-symbols/commit/88a337cee0864a0da35f5d19e69ff0ef0150e46a)
+- Initial commit [`42e1e55`](https://github.com/inspect-js/has-symbols/commit/42e1e5502536a2b8ac529c9443984acd14836b1c)
+- Initial implementation. [`33f5cc6`](https://github.com/inspect-js/has-symbols/commit/33f5cc6cdff86e2194b081ee842bfdc63caf43fb)
+- read me [`01f1170`](https://github.com/inspect-js/has-symbols/commit/01f1170188ff7cb1558aa297f6ba5b516c6d7b0c)
diff --git a/api/node_modules/has-symbols/LICENSE b/api/node_modules/has-symbols/LICENSE
new file mode 100644
index 000000000..df31cbf3c
--- /dev/null
+++ b/api/node_modules/has-symbols/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2016 Jordan Harband
+
+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.
diff --git a/api/node_modules/has-symbols/README.md b/api/node_modules/has-symbols/README.md
new file mode 100644
index 000000000..3875d7e58
--- /dev/null
+++ b/api/node_modules/has-symbols/README.md
@@ -0,0 +1,40 @@
+# has-symbols [![Version Badge][2]][1]
+
+[![dependency status][5]][6]
+[![dev dependency status][7]][8]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+[![npm badge][11]][1]
+
+Determine if the JS environment has Symbol support. Supports spec, or shams.
+
+## Example
+
+```js
+var hasSymbols = require('has-symbols');
+
+hasSymbols() === true; // if the environment has native Symbol support. Not polyfillable, not forgeable.
+
+var hasSymbolsKinda = require('has-symbols/shams');
+hasSymbolsKinda() === true; // if the environment has a Symbol sham that mostly follows the spec.
+```
+
+## Supported Symbol shams
+ - get-own-property-symbols [npm](https://www.npmjs.com/package/get-own-property-symbols) | [github](https://github.com/WebReflection/get-own-property-symbols)
+ - core-js [npm](https://www.npmjs.com/package/core-js) | [github](https://github.com/zloirock/core-js)
+
+## Tests
+Simply clone the repo, `npm install`, and run `npm test`
+
+[1]: https://npmjs.org/package/has-symbols
+[2]: https://versionbadg.es/inspect-js/has-symbols.svg
+[5]: https://david-dm.org/inspect-js/has-symbols.svg
+[6]: https://david-dm.org/inspect-js/has-symbols
+[7]: https://david-dm.org/inspect-js/has-symbols/dev-status.svg
+[8]: https://david-dm.org/inspect-js/has-symbols#info=devDependencies
+[11]: https://nodei.co/npm/has-symbols.png?downloads=true&stars=true
+[license-image]: https://img.shields.io/npm/l/has-symbols.svg
+[license-url]: LICENSE
+[downloads-image]: https://img.shields.io/npm/dm/has-symbols.svg
+[downloads-url]: https://npm-stat.com/charts.html?package=has-symbols
diff --git a/api/node_modules/has-symbols/index.js b/api/node_modules/has-symbols/index.js
new file mode 100644
index 000000000..17044fa21
--- /dev/null
+++ b/api/node_modules/has-symbols/index.js
@@ -0,0 +1,13 @@
+'use strict';
+
+var origSymbol = typeof Symbol !== 'undefined' && Symbol;
+var hasSymbolSham = require('./shams');
+
+module.exports = function hasNativeSymbols() {
+ if (typeof origSymbol !== 'function') { return false; }
+ if (typeof Symbol !== 'function') { return false; }
+ if (typeof origSymbol('foo') !== 'symbol') { return false; }
+ if (typeof Symbol('bar') !== 'symbol') { return false; }
+
+ return hasSymbolSham();
+};
diff --git a/api/node_modules/has-symbols/package.json b/api/node_modules/has-symbols/package.json
new file mode 100644
index 000000000..2c2f57278
--- /dev/null
+++ b/api/node_modules/has-symbols/package.json
@@ -0,0 +1,96 @@
+{
+ "name": "has-symbols",
+ "version": "1.0.2",
+ "author": {
+ "name": "Jordan Harband",
+ "email": "ljharb@gmail.com",
+ "url": "http://ljharb.codes"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ },
+ "contributors": [
+ {
+ "name": "Jordan Harband",
+ "email": "ljharb@gmail.com",
+ "url": "http://ljharb.codes"
+ }
+ ],
+ "description": "Determine if the JS environment has Symbol support. Supports spec, or shams.",
+ "license": "MIT",
+ "main": "index.js",
+ "scripts": {
+ "prepublish": "safe-publish-latest",
+ "pretest": "npm run --silent lint",
+ "test": "npm run tests-only",
+ "posttest": "aud --production",
+ "tests-only": "npm run test:stock && npm run test:staging && npm run test:shams",
+ "test:stock": "nyc node test",
+ "test:staging": "nyc node --harmony --es-staging test",
+ "test:shams": "npm run --silent test:shams:getownpropertysymbols && npm run --silent test:shams:corejs",
+ "test:shams:corejs": "nyc node test/shams/core-js.js",
+ "test:shams:getownpropertysymbols": "nyc node test/shams/get-own-property-symbols.js",
+ "lint": "eslint --ext=js,mjs .",
+ "version": "auto-changelog && git add CHANGELOG.md",
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/inspect-js/has-symbols.git"
+ },
+ "keywords": [
+ "Symbol",
+ "symbols",
+ "typeof",
+ "sham",
+ "polyfill",
+ "native",
+ "core-js",
+ "ES6"
+ ],
+ "devDependencies": {
+ "@ljharb/eslint-config": "^17.5.1",
+ "aud": "^1.1.4",
+ "auto-changelog": "^2.2.1",
+ "core-js": "^2.6.12",
+ "eslint": "^7.20.0",
+ "get-own-property-symbols": "^0.9.5",
+ "nyc": "^10.3.2",
+ "safe-publish-latest": "^1.1.4",
+ "tape": "^5.2.0"
+ },
+ "testling": {
+ "files": "test/index.js",
+ "browsers": [
+ "iexplore/6.0..latest",
+ "firefox/3.0..6.0",
+ "firefox/15.0..latest",
+ "firefox/nightly",
+ "chrome/4.0..10.0",
+ "chrome/20.0..latest",
+ "chrome/canary",
+ "opera/10.0..latest",
+ "opera/next",
+ "safari/4.0..latest",
+ "ipad/6.0..latest",
+ "iphone/6.0..latest",
+ "android-browser/4.2"
+ ]
+ },
+ "engines": {
+ "node": ">= 0.4"
+ },
+ "auto-changelog": {
+ "output": "CHANGELOG.md",
+ "template": "keepachangelog",
+ "unreleased": false,
+ "commitLimit": false,
+ "backfillLimit": false,
+ "hideCredit": true
+ },
+ "greenkeeper": {
+ "ignore": [
+ "core-js"
+ ]
+ }
+}
diff --git a/api/node_modules/has-symbols/shams.js b/api/node_modules/has-symbols/shams.js
new file mode 100644
index 000000000..1285210ef
--- /dev/null
+++ b/api/node_modules/has-symbols/shams.js
@@ -0,0 +1,42 @@
+'use strict';
+
+/* eslint complexity: [2, 18], max-statements: [2, 33] */
+module.exports = function hasSymbols() {
+ if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
+ if (typeof Symbol.iterator === 'symbol') { return true; }
+
+ var obj = {};
+ var sym = Symbol('test');
+ var symObj = Object(sym);
+ if (typeof sym === 'string') { return false; }
+
+ if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
+ if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
+
+ // temp disabled per https://github.com/ljharb/object.assign/issues/17
+ // if (sym instanceof Symbol) { return false; }
+ // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
+ // if (!(symObj instanceof Symbol)) { return false; }
+
+ // if (typeof Symbol.prototype.toString !== 'function') { return false; }
+ // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
+
+ var symVal = 42;
+ obj[sym] = symVal;
+ for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
+ if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
+
+ if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
+
+ var syms = Object.getOwnPropertySymbols(obj);
+ if (syms.length !== 1 || syms[0] !== sym) { return false; }
+
+ if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
+
+ if (typeof Object.getOwnPropertyDescriptor === 'function') {
+ var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
+ if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
+ }
+
+ return true;
+};
diff --git a/api/node_modules/has-symbols/test/index.js b/api/node_modules/has-symbols/test/index.js
new file mode 100644
index 000000000..352129ca3
--- /dev/null
+++ b/api/node_modules/has-symbols/test/index.js
@@ -0,0 +1,22 @@
+'use strict';
+
+var test = require('tape');
+var hasSymbols = require('../');
+var runSymbolTests = require('./tests');
+
+test('interface', function (t) {
+ t.equal(typeof hasSymbols, 'function', 'is a function');
+ t.equal(typeof hasSymbols(), 'boolean', 'returns a boolean');
+ t.end();
+});
+
+test('Symbols are supported', { skip: !hasSymbols() }, function (t) {
+ runSymbolTests(t);
+ t.end();
+});
+
+test('Symbols are not supported', { skip: hasSymbols() }, function (t) {
+ t.equal(typeof Symbol, 'undefined', 'global Symbol is undefined');
+ t.equal(typeof Object.getOwnPropertySymbols, 'undefined', 'Object.getOwnPropertySymbols does not exist');
+ t.end();
+});
diff --git a/api/node_modules/has-symbols/test/shams/core-js.js b/api/node_modules/has-symbols/test/shams/core-js.js
new file mode 100644
index 000000000..df5365c23
--- /dev/null
+++ b/api/node_modules/has-symbols/test/shams/core-js.js
@@ -0,0 +1,28 @@
+'use strict';
+
+var test = require('tape');
+
+if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') {
+ test('has native Symbol support', function (t) {
+ t.equal(typeof Symbol, 'function');
+ t.equal(typeof Symbol(), 'symbol');
+ t.end();
+ });
+ return;
+}
+
+var hasSymbols = require('../../shams');
+
+test('polyfilled Symbols', function (t) {
+ /* eslint-disable global-require */
+ t.equal(hasSymbols(), false, 'hasSymbols is false before polyfilling');
+ require('core-js/fn/symbol');
+ require('core-js/fn/symbol/to-string-tag');
+
+ require('../tests')(t);
+
+ var hasSymbolsAfter = hasSymbols();
+ t.equal(hasSymbolsAfter, true, 'hasSymbols is true after polyfilling');
+ /* eslint-enable global-require */
+ t.end();
+});
diff --git a/api/node_modules/has-symbols/test/shams/get-own-property-symbols.js b/api/node_modules/has-symbols/test/shams/get-own-property-symbols.js
new file mode 100644
index 000000000..9191b248b
--- /dev/null
+++ b/api/node_modules/has-symbols/test/shams/get-own-property-symbols.js
@@ -0,0 +1,28 @@
+'use strict';
+
+var test = require('tape');
+
+if (typeof Symbol === 'function' && typeof Symbol() === 'symbol') {
+ test('has native Symbol support', function (t) {
+ t.equal(typeof Symbol, 'function');
+ t.equal(typeof Symbol(), 'symbol');
+ t.end();
+ });
+ return;
+}
+
+var hasSymbols = require('../../shams');
+
+test('polyfilled Symbols', function (t) {
+ /* eslint-disable global-require */
+ t.equal(hasSymbols(), false, 'hasSymbols is false before polyfilling');
+
+ require('get-own-property-symbols');
+
+ require('../tests')(t);
+
+ var hasSymbolsAfter = hasSymbols();
+ t.equal(hasSymbolsAfter, true, 'hasSymbols is true after polyfilling');
+ /* eslint-enable global-require */
+ t.end();
+});
diff --git a/api/node_modules/has-symbols/test/tests.js b/api/node_modules/has-symbols/test/tests.js
new file mode 100644
index 000000000..89edd1291
--- /dev/null
+++ b/api/node_modules/has-symbols/test/tests.js
@@ -0,0 +1,56 @@
+'use strict';
+
+// eslint-disable-next-line consistent-return
+module.exports = function runSymbolTests(t) {
+ t.equal(typeof Symbol, 'function', 'global Symbol is a function');
+
+ if (typeof Symbol !== 'function') { return false; }
+
+ t.notEqual(Symbol(), Symbol(), 'two symbols are not equal');
+
+ /*
+ t.equal(
+ Symbol.prototype.toString.call(Symbol('foo')),
+ Symbol.prototype.toString.call(Symbol('foo')),
+ 'two symbols with the same description stringify the same'
+ );
+ */
+
+ /*
+ var foo = Symbol('foo');
+
+ t.notEqual(
+ String(foo),
+ String(Symbol('bar')),
+ 'two symbols with different descriptions do not stringify the same'
+ );
+ */
+
+ t.equal(typeof Symbol.prototype.toString, 'function', 'Symbol#toString is a function');
+ // t.equal(String(foo), Symbol.prototype.toString.call(foo), 'Symbol#toString equals String of the same symbol');
+
+ t.equal(typeof Object.getOwnPropertySymbols, 'function', 'Object.getOwnPropertySymbols is a function');
+
+ var obj = {};
+ var sym = Symbol('test');
+ var symObj = Object(sym);
+ t.notEqual(typeof sym, 'string', 'Symbol is not a string');
+ t.equal(Object.prototype.toString.call(sym), '[object Symbol]', 'symbol primitive Object#toStrings properly');
+ t.equal(Object.prototype.toString.call(symObj), '[object Symbol]', 'symbol primitive Object#toStrings properly');
+
+ var symVal = 42;
+ obj[sym] = symVal;
+ // eslint-disable-next-line no-restricted-syntax
+ for (sym in obj) { t.fail('symbol property key was found in for..in of object'); }
+
+ t.deepEqual(Object.keys(obj), [], 'no enumerable own keys on symbol-valued object');
+ t.deepEqual(Object.getOwnPropertyNames(obj), [], 'no own names on symbol-valued object');
+ t.deepEqual(Object.getOwnPropertySymbols(obj), [sym], 'one own symbol on symbol-valued object');
+ t.equal(Object.prototype.propertyIsEnumerable.call(obj, sym), true, 'symbol is enumerable');
+ t.deepEqual(Object.getOwnPropertyDescriptor(obj, sym), {
+ configurable: true,
+ enumerable: true,
+ value: 42,
+ writable: true
+ }, 'property descriptor is correct');
+};
diff --git a/api/node_modules/window-size/LICENSE-MIT b/api/node_modules/has/LICENSE-MIT
similarity index 94%
rename from api/node_modules/window-size/LICENSE-MIT
rename to api/node_modules/has/LICENSE-MIT
index 6c12c0a19..ae7014d38 100644
--- a/api/node_modules/window-size/LICENSE-MIT
+++ b/api/node_modules/has/LICENSE-MIT
@@ -1,22 +1,22 @@
-Copyright (c) 2014 Jon Schlinkert
-
-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.
+Copyright (c) 2013 Thiago de Arruda
+
+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.
diff --git a/api/node_modules/has/README.md b/api/node_modules/has/README.md
new file mode 100644
index 000000000..635e3a4ba
--- /dev/null
+++ b/api/node_modules/has/README.md
@@ -0,0 +1,18 @@
+# has
+
+> Object.prototype.hasOwnProperty.call shortcut
+
+## Installation
+
+```sh
+npm install --save has
+```
+
+## Usage
+
+```js
+var has = require('has');
+
+has({}, 'hasOwnProperty'); // false
+has(Object.prototype, 'hasOwnProperty'); // true
+```
diff --git a/api/node_modules/has/package.json b/api/node_modules/has/package.json
new file mode 100644
index 000000000..7c4592f16
--- /dev/null
+++ b/api/node_modules/has/package.json
@@ -0,0 +1,48 @@
+{
+ "name": "has",
+ "description": "Object.prototype.hasOwnProperty.call shortcut",
+ "version": "1.0.3",
+ "homepage": "https://github.com/tarruda/has",
+ "author": {
+ "name": "Thiago de Arruda",
+ "email": "tpadilha84@gmail.com"
+ },
+ "contributors": [
+ {
+ "name": "Jordan Harband",
+ "email": "ljharb@gmail.com",
+ "url": "http://ljharb.codes"
+ }
+ ],
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/tarruda/has.git"
+ },
+ "bugs": {
+ "url": "https://github.com/tarruda/has/issues"
+ },
+ "license": "MIT",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/tarruda/has/blob/master/LICENSE-MIT"
+ }
+ ],
+ "main": "./src",
+ "dependencies": {
+ "function-bind": "^1.1.1"
+ },
+ "devDependencies": {
+ "@ljharb/eslint-config": "^12.2.1",
+ "eslint": "^4.19.1",
+ "tape": "^4.9.0"
+ },
+ "engines": {
+ "node": ">= 0.4.0"
+ },
+ "scripts": {
+ "lint": "eslint .",
+ "pretest": "npm run lint",
+ "test": "tape test"
+ }
+}
diff --git a/api/node_modules/has/src/index.js b/api/node_modules/has/src/index.js
new file mode 100644
index 000000000..dd92dd909
--- /dev/null
+++ b/api/node_modules/has/src/index.js
@@ -0,0 +1,5 @@
+'use strict';
+
+var bind = require('function-bind');
+
+module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty);
diff --git a/api/node_modules/has/test/index.js b/api/node_modules/has/test/index.js
new file mode 100644
index 000000000..43d480b2c
--- /dev/null
+++ b/api/node_modules/has/test/index.js
@@ -0,0 +1,10 @@
+'use strict';
+
+var test = require('tape');
+var has = require('../');
+
+test('has', function (t) {
+ t.equal(has({}, 'hasOwnProperty'), false, 'object literal does not have own property "hasOwnProperty"');
+ t.equal(has(Object.prototype, 'hasOwnProperty'), true, 'Object.prototype has own property "hasOwnProperty"');
+ t.end();
+});
diff --git a/api/node_modules/iconv-lite/.npmignore b/api/node_modules/iconv-lite/.npmignore
deleted file mode 100644
index 5cd2673c9..000000000
--- a/api/node_modules/iconv-lite/.npmignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*~
-*sublime-*
-generation
-test
-wiki
-coverage
diff --git a/api/node_modules/iconv-lite/.travis.yml b/api/node_modules/iconv-lite/.travis.yml
deleted file mode 100644
index 3eab7fdb3..000000000
--- a/api/node_modules/iconv-lite/.travis.yml
+++ /dev/null
@@ -1,23 +0,0 @@
- sudo: false
- language: node_js
- node_js:
- - "0.10"
- - "0.11"
- - "0.12"
- - "iojs"
- - "4"
- - "6"
- - "8"
- - "node"
-
-
- env:
- - CXX=g++-4.8
- addons:
- apt:
- sources:
- - ubuntu-toolchain-r-test
- packages:
- - gcc-4.8
- - g++-4.8
-
diff --git a/api/node_modules/iconv-lite/Changelog.md b/api/node_modules/iconv-lite/Changelog.md
index 64aae34b1..f252313f8 100644
--- a/api/node_modules/iconv-lite/Changelog.md
+++ b/api/node_modules/iconv-lite/Changelog.md
@@ -1,3 +1,31 @@
+# 0.4.24 / 2018-08-22
+
+ * Added MIK encoding (#196, by @Ivan-Kalatchev)
+
+
+# 0.4.23 / 2018-05-07
+
+ * Fix deprecation warning in Node v10 due to the last usage of `new Buffer` (#185, by @felixbuenemann)
+ * Switched from NodeBuffer to Buffer in typings (#155 by @felixfbecker, #186 by @larssn)
+
+
+# 0.4.22 / 2018-05-05
+
+ * Use older semver style for dependencies to be compatible with Node version 0.10 (#182, by @dougwilson)
+ * Fix tests to accomodate fixes in Node v10 (#182, by @dougwilson)
+
+
+# 0.4.21 / 2018-04-06
+
+ * Fix encoding canonicalization (#156)
+ * Fix the paths in the "browser" field in package.json (#174 by @LMLB)
+ * Removed "contributors" section in package.json - see Git history instead.
+
+
+# 0.4.20 / 2018-04-06
+
+ * Updated `new Buffer()` usages with recommended replacements as it's being deprecated in Node v10 (#176, #178 by @ChALkeR)
+
# 0.4.19 / 2017-09-09
diff --git a/api/node_modules/iconv-lite/README.md b/api/node_modules/iconv-lite/README.md
index 767daedef..c981c3708 100644
--- a/api/node_modules/iconv-lite/README.md
+++ b/api/node_modules/iconv-lite/README.md
@@ -20,7 +20,7 @@
var iconv = require('iconv-lite');
// Convert from an encoded buffer to js string.
-str = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');
+str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251');
// Convert from js string to an encoded buffer.
buf = iconv.encode("Sample input string", 'win1251');
@@ -154,7 +154,3 @@ $ # To view test coverage:
$ npm run coverage
$ open coverage/lcov-report/index.html
```
-
-## Adoption
-[![NPM](https://nodei.co/npm-dl/iconv-lite.png)](https://nodei.co/npm/iconv-lite/)
-[![Codeship Status for ashtuchkin/iconv-lite](https://www.codeship.com/projects/81670840-fa72-0131-4520-4a01a6c01acc/status)](https://www.codeship.com/projects/29053)
diff --git a/api/node_modules/iconv-lite/encodings/dbcs-codec.js b/api/node_modules/iconv-lite/encodings/dbcs-codec.js
index 7b3c980b3..1fe3e1601 100644
--- a/api/node_modules/iconv-lite/encodings/dbcs-codec.js
+++ b/api/node_modules/iconv-lite/encodings/dbcs-codec.js
@@ -1,5 +1,5 @@
"use strict";
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
// Multibyte codec. In this scheme, a character is represented by 1 or more bytes.
// Our codec supports UTF-16 surrogates, extensions for GB18030 and unicode sequences.
@@ -281,7 +281,7 @@ function DBCSEncoder(options, codec) {
}
DBCSEncoder.prototype.write = function(str) {
- var newBuf = new Buffer(str.length * (this.gb18030 ? 4 : 3)),
+ var newBuf = Buffer.alloc(str.length * (this.gb18030 ? 4 : 3)),
leadSurrogate = this.leadSurrogate,
seqObj = this.seqObj, nextChar = -1,
i = 0, j = 0;
@@ -404,7 +404,7 @@ DBCSEncoder.prototype.end = function() {
if (this.leadSurrogate === -1 && this.seqObj === undefined)
return; // All clean. Most often case.
- var newBuf = new Buffer(10), j = 0;
+ var newBuf = Buffer.alloc(10), j = 0;
if (this.seqObj) { // We're in the sequence.
var dbcsCode = this.seqObj[DEF_CHAR];
@@ -440,7 +440,7 @@ DBCSEncoder.prototype.findIdx = findIdx;
function DBCSDecoder(options, codec) {
// Decoder state
this.nodeIdx = 0;
- this.prevBuf = new Buffer(0);
+ this.prevBuf = Buffer.alloc(0);
// Static data
this.decodeTables = codec.decodeTables;
@@ -450,7 +450,7 @@ function DBCSDecoder(options, codec) {
}
DBCSDecoder.prototype.write = function(buf) {
- var newBuf = new Buffer(buf.length*2),
+ var newBuf = Buffer.alloc(buf.length*2),
nodeIdx = this.nodeIdx,
prevBuf = this.prevBuf, prevBufOffset = this.prevBuf.length,
seqStart = -this.prevBuf.length, // idx of the start of current parsed sequence.
@@ -527,7 +527,7 @@ DBCSDecoder.prototype.end = function() {
var buf = this.prevBuf.slice(1);
// Parse remaining as usual.
- this.prevBuf = new Buffer(0);
+ this.prevBuf = Buffer.alloc(0);
this.nodeIdx = 0;
if (buf.length > 0)
ret += this.write(buf);
diff --git a/api/node_modules/iconv-lite/encodings/internal.js b/api/node_modules/iconv-lite/encodings/internal.js
index b0adf6a92..05ce38b27 100644
--- a/api/node_modules/iconv-lite/encodings/internal.js
+++ b/api/node_modules/iconv-lite/encodings/internal.js
@@ -1,5 +1,5 @@
"use strict";
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
// Export Node.js internal encodings.
@@ -33,7 +33,7 @@ function InternalCodec(codecOptions, iconv) {
this.encoder = InternalEncoderCesu8;
// Add decoder for versions of Node not supporting CESU-8
- if (new Buffer('eda0bdedb2a9', 'hex').toString() !== '💩') {
+ if (Buffer.from('eda0bdedb2a9', 'hex').toString() !== '💩') {
this.decoder = InternalDecoderCesu8;
this.defaultCharUnicode = iconv.defaultCharUnicode;
}
@@ -67,7 +67,7 @@ function InternalEncoder(options, codec) {
}
InternalEncoder.prototype.write = function(str) {
- return new Buffer(str, this.enc);
+ return Buffer.from(str, this.enc);
}
InternalEncoder.prototype.end = function() {
@@ -87,11 +87,11 @@ InternalEncoderBase64.prototype.write = function(str) {
this.prevStr = str.slice(completeQuads);
str = str.slice(0, completeQuads);
- return new Buffer(str, "base64");
+ return Buffer.from(str, "base64");
}
InternalEncoderBase64.prototype.end = function() {
- return new Buffer(this.prevStr, "base64");
+ return Buffer.from(this.prevStr, "base64");
}
@@ -102,7 +102,7 @@ function InternalEncoderCesu8(options, codec) {
}
InternalEncoderCesu8.prototype.write = function(str) {
- var buf = new Buffer(str.length * 3), bufIdx = 0;
+ var buf = Buffer.alloc(str.length * 3), bufIdx = 0;
for (var i = 0; i < str.length; i++) {
var charCode = str.charCodeAt(i);
// Naive implementation, but it works because CESU-8 is especially easy
diff --git a/api/node_modules/iconv-lite/encodings/sbcs-codec.js b/api/node_modules/iconv-lite/encodings/sbcs-codec.js
index 7789e00ed..abac5ffaa 100644
--- a/api/node_modules/iconv-lite/encodings/sbcs-codec.js
+++ b/api/node_modules/iconv-lite/encodings/sbcs-codec.js
@@ -1,5 +1,5 @@
"use strict";
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
// Single-byte codec. Needs a 'chars' string parameter that contains 256 or 128 chars that
// correspond to encoded bytes (if 128 - then lower half is ASCII).
@@ -20,11 +20,10 @@ function SBCSCodec(codecOptions, iconv) {
codecOptions.chars = asciiString + codecOptions.chars;
}
- this.decodeBuf = new Buffer(codecOptions.chars, 'ucs2');
+ this.decodeBuf = Buffer.from(codecOptions.chars, 'ucs2');
// Encoding buffer.
- var encodeBuf = new Buffer(65536);
- encodeBuf.fill(iconv.defaultCharSingleByte.charCodeAt(0));
+ var encodeBuf = Buffer.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
for (var i = 0; i < codecOptions.chars.length; i++)
encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
@@ -41,7 +40,7 @@ function SBCSEncoder(options, codec) {
}
SBCSEncoder.prototype.write = function(str) {
- var buf = new Buffer(str.length);
+ var buf = Buffer.alloc(str.length);
for (var i = 0; i < str.length; i++)
buf[i] = this.encodeBuf[str.charCodeAt(i)];
@@ -59,7 +58,7 @@ function SBCSDecoder(options, codec) {
SBCSDecoder.prototype.write = function(buf) {
// Strings are immutable in JS -> we use ucs2 buffer to speed up computations.
var decodeBuf = this.decodeBuf;
- var newBuf = new Buffer(buf.length*2);
+ var newBuf = Buffer.alloc(buf.length*2);
var idx1 = 0, idx2 = 0;
for (var i = 0; i < buf.length; i++) {
idx1 = buf[i]*2; idx2 = i*2;
diff --git a/api/node_modules/iconv-lite/encodings/sbcs-data.js b/api/node_modules/iconv-lite/encodings/sbcs-data.js
index 2d6f846ad..fdb81a39a 100644
--- a/api/node_modules/iconv-lite/encodings/sbcs-data.js
+++ b/api/node_modules/iconv-lite/encodings/sbcs-data.js
@@ -17,6 +17,11 @@ module.exports = {
"chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀рстуфхцчшщъыьэюяЁёЄєЇїЎў°∙·√№€■ "
},
+ "mik": {
+ "type": "_sbcs",
+ "chars": "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя└┴┬├─┼╣║╚╔╩╦╠═╬┐░▒▓│┤№§╗╝┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ "
+ },
+
// Aliases of generated encodings.
"ascii8bit": "ascii",
"usascii": "ascii",
diff --git a/api/node_modules/iconv-lite/encodings/utf16.js b/api/node_modules/iconv-lite/encodings/utf16.js
index 7e8f1591a..54765aeee 100644
--- a/api/node_modules/iconv-lite/encodings/utf16.js
+++ b/api/node_modules/iconv-lite/encodings/utf16.js
@@ -1,5 +1,5 @@
"use strict";
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
// Note: UTF16-LE (or UCS2) codec is Node.js native. See encodings/internal.js
@@ -20,7 +20,7 @@ function Utf16BEEncoder() {
}
Utf16BEEncoder.prototype.write = function(str) {
- var buf = new Buffer(str, 'ucs2');
+ var buf = Buffer.from(str, 'ucs2');
for (var i = 0; i < buf.length; i += 2) {
var tmp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = tmp;
}
@@ -41,7 +41,7 @@ Utf16BEDecoder.prototype.write = function(buf) {
if (buf.length == 0)
return '';
- var buf2 = new Buffer(buf.length + 1),
+ var buf2 = Buffer.alloc(buf.length + 1),
i = 0, j = 0;
if (this.overflowByte !== -1) {
diff --git a/api/node_modules/iconv-lite/encodings/utf7.js b/api/node_modules/iconv-lite/encodings/utf7.js
index 19b7194aa..b7631c23a 100644
--- a/api/node_modules/iconv-lite/encodings/utf7.js
+++ b/api/node_modules/iconv-lite/encodings/utf7.js
@@ -1,5 +1,5 @@
"use strict";
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
// UTF-7 codec, according to https://tools.ietf.org/html/rfc2152
// See also below a UTF-7-IMAP codec, according to http://tools.ietf.org/html/rfc3501#section-5.1.3
@@ -26,7 +26,7 @@ function Utf7Encoder(options, codec) {
Utf7Encoder.prototype.write = function(str) {
// Naive implementation.
// Non-direct chars are encoded as "+-"; single "+" char is encoded as "+-".
- return new Buffer(str.replace(nonDirectChars, function(chunk) {
+ return Buffer.from(str.replace(nonDirectChars, function(chunk) {
return "+" + (chunk === '+' ? '' :
this.iconv.encode(chunk, 'utf16-be').toString('base64').replace(/=+$/, ''))
+ "-";
@@ -75,7 +75,7 @@ Utf7Decoder.prototype.write = function(buf) {
res += "+";
} else {
var b64str = base64Accum + buf.slice(lastI, i).toString();
- res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
+ res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}
if (buf[i] != minusChar) // Minus is absorbed after base64.
@@ -97,7 +97,7 @@ Utf7Decoder.prototype.write = function(buf) {
base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.
b64str = b64str.slice(0, canBeDecoded);
- res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
+ res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}
this.inBase64 = inBase64;
@@ -109,7 +109,7 @@ Utf7Decoder.prototype.write = function(buf) {
Utf7Decoder.prototype.end = function() {
var res = "";
if (this.inBase64 && this.base64Accum.length > 0)
- res = this.iconv.decode(new Buffer(this.base64Accum, 'base64'), "utf16-be");
+ res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");
this.inBase64 = false;
this.base64Accum = '';
@@ -144,7 +144,7 @@ Utf7IMAPCodec.prototype.bomAware = true;
function Utf7IMAPEncoder(options, codec) {
this.iconv = codec.iconv;
this.inBase64 = false;
- this.base64Accum = new Buffer(6);
+ this.base64Accum = Buffer.alloc(6);
this.base64AccumIdx = 0;
}
@@ -152,7 +152,7 @@ Utf7IMAPEncoder.prototype.write = function(str) {
var inBase64 = this.inBase64,
base64Accum = this.base64Accum,
base64AccumIdx = this.base64AccumIdx,
- buf = new Buffer(str.length*5 + 10), bufIdx = 0;
+ buf = Buffer.alloc(str.length*5 + 10), bufIdx = 0;
for (var i = 0; i < str.length; i++) {
var uChar = str.charCodeAt(i);
@@ -198,7 +198,7 @@ Utf7IMAPEncoder.prototype.write = function(str) {
}
Utf7IMAPEncoder.prototype.end = function() {
- var buf = new Buffer(10), bufIdx = 0;
+ var buf = Buffer.alloc(10), bufIdx = 0;
if (this.inBase64) {
if (this.base64AccumIdx > 0) {
bufIdx += buf.write(this.base64Accum.slice(0, this.base64AccumIdx).toString('base64').replace(/\//g, ',').replace(/=+$/, ''), bufIdx);
@@ -246,7 +246,7 @@ Utf7IMAPDecoder.prototype.write = function(buf) {
res += "&";
} else {
var b64str = base64Accum + buf.slice(lastI, i).toString().replace(/,/g, '/');
- res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
+ res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}
if (buf[i] != minusChar) // Minus may be absorbed after base64.
@@ -268,7 +268,7 @@ Utf7IMAPDecoder.prototype.write = function(buf) {
base64Accum = b64str.slice(canBeDecoded); // The rest will be decoded in future.
b64str = b64str.slice(0, canBeDecoded);
- res += this.iconv.decode(new Buffer(b64str, 'base64'), "utf16-be");
+ res += this.iconv.decode(Buffer.from(b64str, 'base64'), "utf16-be");
}
this.inBase64 = inBase64;
@@ -280,7 +280,7 @@ Utf7IMAPDecoder.prototype.write = function(buf) {
Utf7IMAPDecoder.prototype.end = function() {
var res = "";
if (this.inBase64 && this.base64Accum.length > 0)
- res = this.iconv.decode(new Buffer(this.base64Accum, 'base64'), "utf16-be");
+ res = this.iconv.decode(Buffer.from(this.base64Accum, 'base64'), "utf16-be");
this.inBase64 = false;
this.base64Accum = '';
diff --git a/api/node_modules/iconv-lite/lib/extend-node.js b/api/node_modules/iconv-lite/lib/extend-node.js
index a120400be..87f5394a4 100644
--- a/api/node_modules/iconv-lite/lib/extend-node.js
+++ b/api/node_modules/iconv-lite/lib/extend-node.js
@@ -1,5 +1,6 @@
"use strict";
var Buffer = require("buffer").Buffer;
+// Note: not polyfilled with safer-buffer on a purpose, as overrides Buffer
// == Extend Node primitives to use iconv-lite =================================
@@ -8,7 +9,8 @@ module.exports = function (iconv) {
// Node authors rewrote Buffer internals to make it compatible with
// Uint8Array and we cannot patch key functions since then.
- iconv.supportsNodeEncodingsExtension = !(new Buffer(0) instanceof Uint8Array);
+ // Note: this does use older Buffer API on a purpose
+ iconv.supportsNodeEncodingsExtension = !(Buffer.from || new Buffer(0) instanceof Uint8Array);
iconv.extendNodeEncodings = function extendNodeEncodings() {
if (original) return;
diff --git a/api/node_modules/iconv-lite/lib/index.d.ts b/api/node_modules/iconv-lite/lib/index.d.ts
index b9c83613e..0547eb346 100644
--- a/api/node_modules/iconv-lite/lib/index.d.ts
+++ b/api/node_modules/iconv-lite/lib/index.d.ts
@@ -6,9 +6,9 @@
*--------------------------------------------------------------------------------------------*/
declare module 'iconv-lite' {
- export function decode(buffer: NodeBuffer, encoding: string, options?: Options): string;
+ export function decode(buffer: Buffer, encoding: string, options?: Options): string;
- export function encode(content: string, encoding: string, options?: Options): NodeBuffer;
+ export function encode(content: string, encoding: string, options?: Options): Buffer;
export function encodingExists(encoding: string): boolean;
diff --git a/api/node_modules/iconv-lite/lib/index.js b/api/node_modules/iconv-lite/lib/index.js
index 9a5247212..5391919ca 100644
--- a/api/node_modules/iconv-lite/lib/index.js
+++ b/api/node_modules/iconv-lite/lib/index.js
@@ -2,7 +2,7 @@
// Some environments don't have global Buffer (e.g. React Native).
// Solution would be installing npm modules "buffer" and "stream" explicitly.
-var Buffer = require("buffer").Buffer;
+var Buffer = require("safer-buffer").Buffer;
var bomHandling = require("./bom-handling"),
iconv = module.exports;
@@ -34,7 +34,7 @@ iconv.decode = function decode(buf, encoding, options) {
iconv.skipDecodeWarning = true;
}
- buf = new Buffer("" + (buf || ""), "binary"); // Ensure buffer.
+ buf = Buffer.from("" + (buf || ""), "binary"); // Ensure buffer.
}
var decoder = iconv.getDecoder(encoding, options);
@@ -65,7 +65,7 @@ iconv.getCodec = function getCodec(encoding) {
iconv.encodings = require("../encodings"); // Lazy load all encoding definitions.
// Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
- var enc = (''+encoding).toLowerCase().replace(/[^0-9a-z]|:\d{4}$/g, "");
+ var enc = iconv._canonicalizeEncoding(encoding);
// Traverse iconv.encodings to find actual codec.
var codecOptions = {};
@@ -108,6 +108,11 @@ iconv.getCodec = function getCodec(encoding) {
}
}
+iconv._canonicalizeEncoding = function(encoding) {
+ // Canonicalize encoding name: strip all non-alphanumeric chars and appended year.
+ return (''+encoding).toLowerCase().replace(/:\d{4}$|[^0-9a-z]/g, "");
+}
+
iconv.getEncoder = function getEncoder(encoding, options) {
var codec = iconv.getCodec(encoding),
encoder = new codec.encoder(options, codec);
diff --git a/api/node_modules/iconv-lite/package.json b/api/node_modules/iconv-lite/package.json
index 846306ca0..a7c74fcc2 100644
--- a/api/node_modules/iconv-lite/package.json
+++ b/api/node_modules/iconv-lite/package.json
@@ -1,124 +1,46 @@
{
- "_from": "iconv-lite@0.4.19",
- "_id": "iconv-lite@0.4.19",
- "_inBundle": false,
- "_integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==",
- "_location": "/iconv-lite",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "iconv-lite@0.4.19",
"name": "iconv-lite",
- "escapedName": "iconv-lite",
- "rawSpec": "0.4.19",
- "saveSpec": null,
- "fetchSpec": "0.4.19"
- },
- "_requiredBy": [
- "/body-parser",
- "/raw-body"
- ],
- "_resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
- "_shasum": "f7468f60135f5e5dad3399c0a81be9a1603a082b",
- "_spec": "iconv-lite@0.4.19",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/body-parser",
- "author": {
- "name": "Alexander Shtuchkin",
- "email": "ashtuchkin@gmail.com"
- },
- "browser": {
- "./extend-node": false,
- "./streams": false
- },
- "bugs": {
- "url": "https://github.com/ashtuchkin/iconv-lite/issues"
- },
- "bundleDependencies": false,
- "contributors": [
- {
- "name": "Jinwu Zhan",
- "url": "https://github.com/jenkinv"
- },
- {
- "name": "Adamansky Anton",
- "url": "https://github.com/adamansky"
- },
- {
- "name": "George Stagas",
- "url": "https://github.com/stagas"
- },
- {
- "name": "Mike D Pilsbury",
- "url": "https://github.com/pekim"
- },
- {
- "name": "Niggler",
- "url": "https://github.com/Niggler"
- },
- {
- "name": "wychi",
- "url": "https://github.com/wychi"
- },
- {
- "name": "David Kuo",
- "url": "https://github.com/david50407"
- },
- {
- "name": "ChangZhuo Chen",
- "url": "https://github.com/czchen"
- },
- {
- "name": "Lee Treveil",
- "url": "https://github.com/leetreveil"
- },
- {
- "name": "Brian White",
- "url": "https://github.com/mscdex"
- },
- {
- "name": "Mithgol",
- "url": "https://github.com/Mithgol"
- },
- {
- "name": "Nazar Leush",
- "url": "https://github.com/nleush"
+ "description": "Convert character encodings in pure javascript.",
+ "version": "0.4.24",
+ "license": "MIT",
+ "keywords": [
+ "iconv",
+ "convert",
+ "charset",
+ "icu"
+ ],
+ "author": "Alexander Shtuchkin ",
+ "main": "./lib/index.js",
+ "typings": "./lib/index.d.ts",
+ "homepage": "https://github.com/ashtuchkin/iconv-lite",
+ "bugs": "https://github.com/ashtuchkin/iconv-lite/issues",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/ashtuchkin/iconv-lite.git"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "coverage": "istanbul cover _mocha -- --grep .",
+ "coverage-open": "open coverage/lcov-report/index.html",
+ "test": "mocha --reporter spec --grep ."
+ },
+ "browser": {
+ "./lib/extend-node": false,
+ "./lib/streams": false
+ },
+ "devDependencies": {
+ "mocha": "^3.1.0",
+ "request": "~2.87.0",
+ "unorm": "*",
+ "errto": "*",
+ "async": "*",
+ "istanbul": "*",
+ "semver": "*",
+ "iconv": "*"
+ },
+ "dependencies": {
+ "safer-buffer": ">= 2.1.2 < 3"
}
- ],
- "deprecated": false,
- "description": "Convert character encodings in pure javascript.",
- "devDependencies": {
- "async": "*",
- "errto": "*",
- "iconv": "*",
- "istanbul": "*",
- "mocha": "*",
- "request": "*",
- "semver": "*",
- "unorm": "*"
- },
- "engines": {
- "node": ">=0.10.0"
- },
- "homepage": "https://github.com/ashtuchkin/iconv-lite",
- "keywords": [
- "iconv",
- "convert",
- "charset",
- "icu"
- ],
- "license": "MIT",
- "main": "./lib/index.js",
- "name": "iconv-lite",
- "repository": {
- "type": "git",
- "url": "git://github.com/ashtuchkin/iconv-lite.git"
- },
- "scripts": {
- "coverage": "istanbul cover _mocha -- --grep .",
- "coverage-open": "open coverage/lcov-report/index.html",
- "test": "mocha --reporter spec --grep ."
- },
- "typings": "./lib/index.d.ts",
- "version": "0.4.19"
}
diff --git a/api/node_modules/ipaddr.js/LICENSE b/api/node_modules/ipaddr.js/LICENSE
new file mode 100644
index 000000000..f6b37b52d
--- /dev/null
+++ b/api/node_modules/ipaddr.js/LICENSE
@@ -0,0 +1,19 @@
+Copyright (C) 2011-2017 whitequark
+
+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.
diff --git a/api/node_modules/ipaddr.js/README.md b/api/node_modules/ipaddr.js/README.md
index 6876a3b82..f57725b0f 100644
--- a/api/node_modules/ipaddr.js/README.md
+++ b/api/node_modules/ipaddr.js/README.md
@@ -173,7 +173,7 @@ addr.octets // => [192, 168, 1, 1]
```
`prefixLengthFromSubnetMask()` will return a CIDR prefix length for a valid IPv4 netmask or
-false if the netmask is not valid.
+null if the netmask is not valid.
```js
ipaddr.IPv4.parse('255.255.255.240').prefixLengthFromSubnetMask() == 28
diff --git a/api/node_modules/ipaddr.js/ipaddr.min.js b/api/node_modules/ipaddr.js/ipaddr.min.js
index 56c227caf..b54a7cc42 100644
--- a/api/node_modules/ipaddr.js/ipaddr.min.js
+++ b/api/node_modules/ipaddr.js/ipaddr.min.js
@@ -1 +1 @@
-(function(){var r,t,n,e,i,o,a,s;t={},s=this,"undefined"!=typeof module&&null!==module&&module.exports?module.exports=t:s.ipaddr=t,a=function(r,t,n,e){var i,o;if(r.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");for(i=0;e>0;){if((o=n-e)<0&&(o=0),r[i]>>o!=t[i]>>o)return!1;e-=n,i+=1}return!0},t.subnetMatch=function(r,t,n){var e,i,o,a,s;null==n&&(n="unicast");for(o in t)for(!(a=t[o])[0]||a[0]instanceof Array||(a=[a]),e=0,i=a.length;e=0;t=n+=-1){if(!((e=this.octets[t])in a))return null;if(o=a[e],i&&0!==o)return null;8!==o&&(i=!0),r+=o}return 32-r},r}(),n="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp("^"+n+"\\."+n+"\\."+n+"\\."+n+"$","i"),longValue:new RegExp("^"+n+"$","i")},t.IPv4.parser=function(r){var t,n,i,o,a;if(n=function(r){return"0"===r[0]&&"x"!==r[1]?parseInt(r,8):parseInt(r)},t=r.match(e.fourOctet))return function(){var r,e,o,a;for(a=[],r=0,e=(o=t.slice(1,6)).length;r4294967295||a<0)throw new Error("ipaddr: address outside defined range");return function(){var r,t;for(t=[],o=r=0;r<=24;o=r+=8)t.push(a>>o&255);return t}().reverse()}return null},t.IPv6=function(){function r(r,t){var n,e,i,o,a,s;if(16===r.length)for(this.parts=[],n=e=0;e<=14;n=e+=2)this.parts.push(r[n]<<8|r[n+1]);else{if(8!==r.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=r}for(i=0,o=(s=this.parts).length;i>8),r.push(255&e);return r},r.prototype.toNormalizedString=function(){var r,t,n;return r=function(){var r,n,e,i;for(i=[],r=0,n=(e=this.parts).length;r>8,255&r,n>>8,255&n])},r.prototype.prefixLengthFromSubnetMask=function(){var r,t,n,e,i,o,a;for(a={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r=0,i=!1,t=n=7;n>=0;t=n+=-1){if(!((e=this.parts[t])in a))return null;if(o=a[e],i&&0!==o)return null;16!==o&&(i=!0),r+=o}return 128-r},r}(),i="(?:[0-9a-f]+::?)+",o={zoneIndex:new RegExp("%[0-9a-z]{1,}","i"),native:new RegExp("^(::)?("+i+")?([0-9a-f]+)?(::)?(%[0-9a-z]{1,})?$","i"),transitional:new RegExp("^((?:"+i+")|(?:::)(?:"+i+")?)"+n+"\\."+n+"\\."+n+"\\."+n+"(%[0-9a-z]{1,})?$","i")},r=function(r,t){var n,e,i,a,s,p;if(r.indexOf("::")!==r.lastIndexOf("::"))return null;for((p=(r.match(o.zoneIndex)||[])[0])&&(p=p.substring(1),r=r.replace(/%.+$/,"")),n=0,e=-1;(e=r.indexOf(":",e+1))>=0;)n++;if("::"===r.substr(0,2)&&n--,"::"===r.substr(-2,2)&&n--,n>t)return null;for(s=t-n,a=":";s--;)a+="0:";return":"===(r=r.replace("::",a))[0]&&(r=r.slice(1)),":"===r[r.length-1]&&(r=r.slice(0,-1)),t=function(){var t,n,e,o;for(o=[],t=0,n=(e=r.split(":")).length;t=0&&t<=32)return e=[this.parse(n[1]),t],Object.defineProperty(e,"toString",{value:function(){return this.join("/")}}),e;throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},t.IPv4.subnetMaskFromPrefixLength=function(r){var t,n,e;if((r=parseInt(r))<0||r>32)throw new Error("ipaddr: invalid IPv4 prefix length");for(e=[0,0,0,0],n=0,t=Math.floor(r/8);n=0&&t<=128)return e=[this.parse(n[1]),t],Object.defineProperty(e,"toString",{value:function(){return this.join("/")}}),e;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},t.isValid=function(r){return t.IPv6.isValid(r)||t.IPv4.isValid(r)},t.parse=function(r){if(t.IPv6.isValid(r))return t.IPv6.parse(r);if(t.IPv4.isValid(r))return t.IPv4.parse(r);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},t.parseCIDR=function(r){try{return t.IPv6.parseCIDR(r)}catch(n){n;try{return t.IPv4.parseCIDR(r)}catch(r){throw r,new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},t.fromByteArray=function(r){var n;if(4===(n=r.length))return new t.IPv4(r);if(16===n)return new t.IPv6(r);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},t.process=function(r){var t;return"ipv6"===(t=this.parse(r)).kind()&&t.isIPv4MappedAddress()?t.toIPv4Address():t}}).call(this);
\ No newline at end of file
+(function(){var r,t,n,e,i,o,a,s;t={},s=this,"undefined"!=typeof module&&null!==module&&module.exports?module.exports=t:s.ipaddr=t,a=function(r,t,n,e){var i,o;if(r.length!==t.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");for(i=0;e>0;){if((o=n-e)<0&&(o=0),r[i]>>o!=t[i]>>o)return!1;e-=n,i+=1}return!0},t.subnetMatch=function(r,t,n){var e,i,o,a,s;null==n&&(n="unicast");for(o in t)for(!(a=t[o])[0]||a[0]instanceof Array||(a=[a]),e=0,i=a.length;e=0;t=n+=-1){if(!((e=this.octets[t])in a))return null;if(o=a[e],i&&0!==o)return null;8!==o&&(i=!0),r+=o}return 32-r},r}(),n="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp("^"+n+"\\."+n+"\\."+n+"\\."+n+"$","i"),longValue:new RegExp("^"+n+"$","i")},t.IPv4.parser=function(r){var t,n,i,o,a;if(n=function(r){return"0"===r[0]&&"x"!==r[1]?parseInt(r,8):parseInt(r)},t=r.match(e.fourOctet))return function(){var r,e,o,a;for(a=[],r=0,e=(o=t.slice(1,6)).length;r4294967295||a<0)throw new Error("ipaddr: address outside defined range");return function(){var r,t;for(t=[],o=r=0;r<=24;o=r+=8)t.push(a>>o&255);return t}().reverse()}return null},t.IPv6=function(){function r(r,t){var n,e,i,o,a,s;if(16===r.length)for(this.parts=[],n=e=0;e<=14;n=e+=2)this.parts.push(r[n]<<8|r[n+1]);else{if(8!==r.length)throw new Error("ipaddr: ipv6 part count should be 8 or 16");this.parts=r}for(i=0,o=(s=this.parts).length;it&&(r=n.index,t=n[0].length);return t<0?i:i.substring(0,r)+"::"+i.substring(r+t)},r.prototype.toByteArray=function(){var r,t,n,e,i;for(r=[],t=0,n=(i=this.parts).length;t>8),r.push(255&e);return r},r.prototype.toNormalizedString=function(){var r,t,n;return r=function(){var r,n,e,i;for(i=[],r=0,n=(e=this.parts).length;r>8,255&r,n>>8,255&n])},r.prototype.prefixLengthFromSubnetMask=function(){var r,t,n,e,i,o,a;for(a={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},r=0,i=!1,t=n=7;n>=0;t=n+=-1){if(!((e=this.parts[t])in a))return null;if(o=a[e],i&&0!==o)return null;16!==o&&(i=!0),r+=o}return 128-r},r}(),i="(?:[0-9a-f]+::?)+",o={zoneIndex:new RegExp("%[0-9a-z]{1,}","i"),native:new RegExp("^(::)?("+i+")?([0-9a-f]+)?(::)?(%[0-9a-z]{1,})?$","i"),transitional:new RegExp("^((?:"+i+")|(?:::)(?:"+i+")?)"+n+"\\."+n+"\\."+n+"\\."+n+"(%[0-9a-z]{1,})?$","i")},r=function(r,t){var n,e,i,a,s,p;if(r.indexOf("::")!==r.lastIndexOf("::"))return null;for((p=(r.match(o.zoneIndex)||[])[0])&&(p=p.substring(1),r=r.replace(/%.+$/,"")),n=0,e=-1;(e=r.indexOf(":",e+1))>=0;)n++;if("::"===r.substr(0,2)&&n--,"::"===r.substr(-2,2)&&n--,n>t)return null;for(s=t-n,a=":";s--;)a+="0:";return":"===(r=r.replace("::",a))[0]&&(r=r.slice(1)),":"===r[r.length-1]&&(r=r.slice(0,-1)),t=function(){var t,n,e,o;for(o=[],t=0,n=(e=r.split(":")).length;t=0&&t<=32)return e=[this.parse(n[1]),t],Object.defineProperty(e,"toString",{value:function(){return this.join("/")}}),e;throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},t.IPv4.subnetMaskFromPrefixLength=function(r){var t,n,e;if((r=parseInt(r))<0||r>32)throw new Error("ipaddr: invalid IPv4 prefix length");for(e=[0,0,0,0],n=0,t=Math.floor(r/8);n=0&&t<=128)return e=[this.parse(n[1]),t],Object.defineProperty(e,"toString",{value:function(){return this.join("/")}}),e;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},t.isValid=function(r){return t.IPv6.isValid(r)||t.IPv4.isValid(r)},t.parse=function(r){if(t.IPv6.isValid(r))return t.IPv6.parse(r);if(t.IPv4.isValid(r))return t.IPv4.parse(r);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},t.parseCIDR=function(r){try{return t.IPv6.parseCIDR(r)}catch(n){n;try{return t.IPv4.parseCIDR(r)}catch(r){throw r,new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},t.fromByteArray=function(r){var n;if(4===(n=r.length))return new t.IPv4(r);if(16===n)return new t.IPv6(r);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},t.process=function(r){var t;return t=this.parse(r),"ipv6"===t.kind()&&t.isIPv4MappedAddress()?t.toIPv4Address():t}}).call(this);
\ No newline at end of file
diff --git a/api/node_modules/ipaddr.js/lib/ipaddr.js b/api/node_modules/ipaddr.js/lib/ipaddr.js
index ab5d74b4e..18bd93b5e 100644
--- a/api/node_modules/ipaddr.js/lib/ipaddr.js
+++ b/api/node_modules/ipaddr.js/lib/ipaddr.js
@@ -229,6 +229,24 @@
return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/, '::');
};
+ IPv6.prototype.toRFC5952String = function() {
+ var bestMatchIndex, bestMatchLength, match, regex, string;
+ regex = /((^|:)(0(:|$)){2,})/g;
+ string = this.toNormalizedString();
+ bestMatchIndex = 0;
+ bestMatchLength = -1;
+ while ((match = regex.exec(string))) {
+ if (match[0].length > bestMatchLength) {
+ bestMatchIndex = match.index;
+ bestMatchLength = match[0].length;
+ }
+ }
+ if (bestMatchLength < 0) {
+ return string;
+ }
+ return string.substring(0, bestMatchIndex) + '::' + string.substring(bestMatchIndex + bestMatchLength);
+ };
+
IPv6.prototype.toByteArray = function() {
var bytes, k, len, part, ref;
bytes = [];
@@ -260,6 +278,25 @@
return addr + suffix;
};
+ IPv6.prototype.toFixedLengthString = function() {
+ var addr, part, suffix;
+ addr = ((function() {
+ var k, len, ref, results;
+ ref = this.parts;
+ results = [];
+ for (k = 0, len = ref.length; k < len; k++) {
+ part = ref[k];
+ results.push(part.toString(16).padStart(4, '0'));
+ }
+ return results;
+ }).call(this)).join(":");
+ suffix = '';
+ if (this.zoneId) {
+ suffix = '%' + this.zoneId;
+ }
+ return addr + suffix;
+ };
+
IPv6.prototype.match = function(other, cidrRange) {
var ref;
if (cidrRange === void 0) {
diff --git a/api/node_modules/ipaddr.js/lib/ipaddr.js.d.ts b/api/node_modules/ipaddr.js/lib/ipaddr.js.d.ts
index 882fa96d7..52174b6b6 100644
--- a/api/node_modules/ipaddr.js/lib/ipaddr.js.d.ts
+++ b/api/node_modules/ipaddr.js/lib/ipaddr.js.d.ts
@@ -1,31 +1,25 @@
-
-
declare module "ipaddr.js" {
-
- type IPv4Range = 'unspecified' | 'broadcast' | 'multicast' | 'linkLocal' | 'loopback' | 'carrierGradeNat' | 'private' | 'reserved';
- type IPv6Range = 'unspecified' | 'linkLocal' | 'multicast' | 'loopback' | 'uniqueLocal' | 'ipv4Mapped' | 'rfc6145' | 'rfc6052' | '6to4' | 'teredo' | 'reserved';
+ type IPv4Range = 'unicast' | 'unspecified' | 'broadcast' | 'multicast' | 'linkLocal' | 'loopback' | 'carrierGradeNat' | 'private' | 'reserved';
+ type IPv6Range = 'unicast' | 'unspecified' | 'linkLocal' | 'multicast' | 'loopback' | 'uniqueLocal' | 'ipv4Mapped' | 'rfc6145' | 'rfc6052' | '6to4' | 'teredo' | 'reserved';
interface RangeList {
[name: string]: [T, number] | [T, number][];
}
-
// Common methods/properties for IPv4 and IPv6 classes.
class IP {
-
- prefixLengthFromSubnetMask(): number | false;
+ prefixLengthFromSubnetMask(): number | null;
toByteArray(): number[];
toNormalizedString(): string;
toString(): string;
}
namespace Address {
-
export function isValid(addr: string): boolean;
export function fromByteArray(bytes: number[]): IPv4 | IPv6;
export function parse(addr: string): IPv4 | IPv6;
export function parseCIDR(mask: string): [IPv4 | IPv6, number];
- export function process(address: string): IPv4 | IPv6;
+ export function process(addr: string): IPv4 | IPv6;
export function subnetMatch(addr: IPv4, rangeList: RangeList, defaultName?: string): string;
export function subnetMatch(addr: IPv6, rangeList: RangeList, defaultName?: string): string;
@@ -39,6 +33,7 @@ declare module "ipaddr.js" {
static parseCIDR(addr: string): [IPv4, number];
static subnetMaskFromPrefixLength(prefix: number): IPv4;
constructor(octets: number[]);
+ octets: number[]
kind(): 'ipv4';
match(addr: IPv4, bits: number): boolean;
@@ -55,7 +50,9 @@ declare module "ipaddr.js" {
static parse(addr: string): IPv6;
static parseCIDR(addr: string): [IPv6, number];
static subnetMaskFromPrefixLength(prefix: number): IPv6;
- constructor(octets: number[]);
+ constructor(parts: number[]);
+ parts: number[]
+ zoneId?: string
isIPv4MappedAddress(): boolean;
kind(): 'ipv6';
diff --git a/api/node_modules/ipaddr.js/package.json b/api/node_modules/ipaddr.js/package.json
index f8e953f8f..f4d35475d 100644
--- a/api/node_modules/ipaddr.js/package.json
+++ b/api/node_modules/ipaddr.js/package.json
@@ -1,69 +1,35 @@
{
- "_from": "ipaddr.js@1.8.0",
- "_id": "ipaddr.js@1.8.0",
- "_inBundle": false,
- "_integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=",
- "_location": "/ipaddr.js",
- "_phantomChildren": {},
- "_requested": {
- "type": "version",
- "registry": true,
- "raw": "ipaddr.js@1.8.0",
- "name": "ipaddr.js",
- "escapedName": "ipaddr.js",
- "rawSpec": "1.8.0",
- "saveSpec": null,
- "fetchSpec": "1.8.0"
- },
- "_requiredBy": [
- "/proxy-addr"
- ],
- "_resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz",
- "_shasum": "eaa33d6ddd7ace8f7f6fe0c9ca0440e706738b1e",
- "_spec": "ipaddr.js@1.8.0",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/proxy-addr",
- "author": {
- "name": "whitequark",
- "email": "whitequark@whitequark.org"
- },
- "bugs": {
- "url": "https://github.com/whitequark/ipaddr.js/issues"
+ "name": "ipaddr.js",
+ "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.",
+ "version": "1.9.1",
+ "author": "whitequark ",
+ "directories": {
+ "lib": "./lib"
},
- "bundleDependencies": false,
"dependencies": {},
- "deprecated": false,
- "description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.",
"devDependencies": {
"coffee-script": "~1.12.6",
- "nodeunit": ">=0.8.2 <0.8.7",
+ "nodeunit": "^0.11.3",
"uglify-js": "~3.0.19"
},
- "directories": {
- "lib": "./lib"
- },
- "engines": {
- "node": ">= 0.10"
+ "scripts": {
+ "test": "cake build test"
},
"files": [
"lib/",
+ "LICENSE",
"ipaddr.min.js"
],
- "homepage": "https://github.com/whitequark/ipaddr.js#readme",
"keywords": [
"ip",
"ipv4",
"ipv6"
],
- "license": "MIT",
+ "repository": "git://github.com/whitequark/ipaddr.js",
"main": "./lib/ipaddr.js",
- "name": "ipaddr.js",
- "repository": {
- "type": "git",
- "url": "git://github.com/whitequark/ipaddr.js.git"
- },
- "scripts": {
- "test": "cake build test"
+ "engines": {
+ "node": ">= 0.10"
},
- "types": "./lib/ipaddr.js.d.ts",
- "version": "1.8.0"
+ "license": "MIT",
+ "types": "./lib/ipaddr.js.d.ts"
}
diff --git a/api/node_modules/is-buffer/LICENSE b/api/node_modules/is-buffer/LICENSE
deleted file mode 100644
index 0c068ceec..000000000
--- a/api/node_modules/is-buffer/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) Feross Aboukhadijeh
-
-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.
diff --git a/api/node_modules/is-buffer/README.md b/api/node_modules/is-buffer/README.md
deleted file mode 100644
index cce0a8cf9..000000000
--- a/api/node_modules/is-buffer/README.md
+++ /dev/null
@@ -1,53 +0,0 @@
-# is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
-
-[travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg
-[travis-url]: https://travis-ci.org/feross/is-buffer
-[npm-image]: https://img.shields.io/npm/v/is-buffer.svg
-[npm-url]: https://npmjs.org/package/is-buffer
-[downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg
-[downloads-url]: https://npmjs.org/package/is-buffer
-[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
-[standard-url]: https://standardjs.com
-
-#### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
-
-[![saucelabs][saucelabs-image]][saucelabs-url]
-
-[saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg
-[saucelabs-url]: https://saucelabs.com/u/is-buffer
-
-## Why not use `Buffer.isBuffer`?
-
-This module lets you check if an object is a `Buffer` without using `Buffer.isBuffer` (which includes the whole [buffer](https://github.com/feross/buffer) module in [browserify](http://browserify.org/)).
-
-It's future-proof and works in node too!
-
-## install
-
-```bash
-npm install is-buffer
-```
-
-## usage
-
-```js
-var isBuffer = require('is-buffer')
-
-isBuffer(new Buffer(4)) // true
-
-isBuffer(undefined) // false
-isBuffer(null) // false
-isBuffer('') // false
-isBuffer(true) // false
-isBuffer(false) // false
-isBuffer(0) // false
-isBuffer(1) // false
-isBuffer(1.0) // false
-isBuffer('string') // false
-isBuffer({}) // false
-isBuffer(function foo () {}) // false
-```
-
-## license
-
-MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org).
diff --git a/api/node_modules/is-buffer/index.js b/api/node_modules/is-buffer/index.js
deleted file mode 100644
index 9cce39659..000000000
--- a/api/node_modules/is-buffer/index.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh
- * @license MIT
- */
-
-// The _isBuffer check is for Safari 5-7 support, because it's missing
-// Object.prototype.constructor. Remove this eventually
-module.exports = function (obj) {
- return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
-}
-
-function isBuffer (obj) {
- return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
-}
-
-// For Node v0.10 support. Remove this eventually.
-function isSlowBuffer (obj) {
- return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
-}
diff --git a/api/node_modules/is-buffer/package.json b/api/node_modules/is-buffer/package.json
deleted file mode 100644
index 132bf2d46..000000000
--- a/api/node_modules/is-buffer/package.json
+++ /dev/null
@@ -1,77 +0,0 @@
-{
- "_from": "is-buffer@^1.1.5",
- "_id": "is-buffer@1.1.6",
- "_inBundle": false,
- "_integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
- "_location": "/is-buffer",
- "_phantomChildren": {},
- "_requested": {
- "type": "range",
- "registry": true,
- "raw": "is-buffer@^1.1.5",
- "name": "is-buffer",
- "escapedName": "is-buffer",
- "rawSpec": "^1.1.5",
- "saveSpec": null,
- "fetchSpec": "^1.1.5"
- },
- "_requiredBy": [
- "/kind-of"
- ],
- "_resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
- "_shasum": "efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be",
- "_spec": "is-buffer@^1.1.5",
- "_where": "/Users/joaohenrique/Repositories/freeCodeCamp/my_awesome_project/api/node_modules/kind-of",
- "author": {
- "name": "Feross Aboukhadijeh",
- "email": "feross@feross.org",
- "url": "http://feross.org/"
- },
- "bugs": {
- "url": "https://github.com/feross/is-buffer/issues"
- },
- "bundleDependencies": false,
- "dependencies": {},
- "deprecated": false,
- "description": "Determine if an object is a Buffer",
- "devDependencies": {
- "standard": "*",
- "tape": "^4.0.0",
- "zuul": "^3.0.0"
- },
- "homepage": "https://github.com/feross/is-buffer#readme",
- "keywords": [
- "buffer",
- "buffers",
- "type",
- "core buffer",
- "browser buffer",
- "browserify",
- "typed array",
- "uint32array",
- "int16array",
- "int32array",
- "float32array",
- "float64array",
- "browser",
- "arraybuffer",
- "dataview"
- ],
- "license": "MIT",
- "main": "index.js",
- "name": "is-buffer",
- "repository": {
- "type": "git",
- "url": "git://github.com/feross/is-buffer.git"
- },
- "scripts": {
- "test": "standard && npm run test-node && npm run test-browser",
- "test-browser": "zuul -- test/*.js",
- "test-browser-local": "zuul --local -- test/*.js",
- "test-node": "tape test/*.js"
- },
- "testling": {
- "files": "test/*.js"
- },
- "version": "1.1.6"
-}
diff --git a/api/node_modules/is-buffer/test/basic.js b/api/node_modules/is-buffer/test/basic.js
deleted file mode 100644
index be4f8e438..000000000
--- a/api/node_modules/is-buffer/test/basic.js
+++ /dev/null
@@ -1,24 +0,0 @@
-var isBuffer = require('../')
-var test = require('tape')
-
-test('is-buffer', function (t) {
- t.equal(isBuffer(Buffer.alloc(4)), true, 'new Buffer(4)')
- t.equal(isBuffer(Buffer.allocUnsafeSlow(100)), true, 'SlowBuffer(100)')
-
- t.equal(isBuffer(undefined), false, 'undefined')
- t.equal(isBuffer(null), false, 'null')
- t.equal(isBuffer(''), false, 'empty string')
- t.equal(isBuffer(true), false, 'true')
- t.equal(isBuffer(false), false, 'false')
- t.equal(isBuffer(0), false, '0')
- t.equal(isBuffer(1), false, '1')
- t.equal(isBuffer(1.0), false, '1.0')
- t.equal(isBuffer('string'), false, 'string')
- t.equal(isBuffer({}), false, '{}')
- t.equal(isBuffer([]), false, '[]')
- t.equal(isBuffer(function foo () {}), false, 'function foo () {}')
- t.equal(isBuffer({ isBuffer: null }), false, '{ isBuffer: null }')
- t.equal(isBuffer({ isBuffer: function () { throw new Error() } }), false, '{ isBuffer: function () { throw new Error() } }')
-
- t.end()
-})
diff --git a/api/node_modules/is-core-module/.eslintignore b/api/node_modules/is-core-module/.eslintignore
new file mode 100644
index 000000000..404abb221
--- /dev/null
+++ b/api/node_modules/is-core-module/.eslintignore
@@ -0,0 +1 @@
+coverage/
diff --git a/api/node_modules/is-core-module/.eslintrc b/api/node_modules/is-core-module/.eslintrc
new file mode 100644
index 000000000..9c7d5168a
--- /dev/null
+++ b/api/node_modules/is-core-module/.eslintrc
@@ -0,0 +1,18 @@
+{
+ "extends": "@ljharb",
+ "root": true,
+ "rules": {
+ "func-style": 1,
+ "operator-linebreak": [2, "before"],
+ },
+ "overrides": [
+ {
+ "files": "test/**",
+ "rules": {
+ "global-require": 0,
+ "max-lines-per-function": 0,
+ "no-negated-condition": 0,
+ },
+ },
+ ],
+}
diff --git a/api/node_modules/is-core-module/.github/FUNDING.yml b/api/node_modules/is-core-module/.github/FUNDING.yml
new file mode 100644
index 000000000..422ce9b01
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/FUNDING.yml
@@ -0,0 +1,12 @@
+# These are supported funding model platforms
+
+github: [ljharb]
+patreon: # Replace with a single Patreon username
+open_collective: # Replace with a single Open Collective username
+ko_fi: # Replace with a single Ko-fi username
+tidelift: npm/is-core-module
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/api/node_modules/is-core-module/.github/workflows/node-4+.yml b/api/node_modules/is-core-module/.github/workflows/node-4+.yml
new file mode 100644
index 000000000..ba174e1d6
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/node-4+.yml
@@ -0,0 +1,54 @@
+name: 'Tests: node.js'
+
+on: [pull_request, push]
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest
+ outputs:
+ latest: ${{ steps.set-matrix.outputs.requireds }}
+ minors: ${{ steps.set-matrix.outputs.optionals }}
+ steps:
+ - uses: ljharb/actions/node/matrix@main
+ id: set-matrix
+ with:
+ preset: '>=4'
+
+ latest:
+ needs: [matrix]
+ name: 'latest minors'
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ name: 'npm install && npm run tests-only'
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+ minors:
+ needs: [matrix, latest]
+ name: 'non-latest minors'
+ continue-on-error: true
+ if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+
+ node:
+ name: 'node 4+'
+ needs: [latest, minors]
+ runs-on: ubuntu-latest
+ steps:
+ - run: 'echo tests completed'
diff --git a/api/node_modules/is-core-module/.github/workflows/node-iojs.yml b/api/node_modules/is-core-module/.github/workflows/node-iojs.yml
new file mode 100644
index 000000000..f707c3cfc
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/node-iojs.yml
@@ -0,0 +1,58 @@
+name: 'Tests: node.js (io.js)'
+
+on: [pull_request, push]
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest
+ outputs:
+ latest: ${{ steps.set-matrix.outputs.requireds }}
+ minors: ${{ steps.set-matrix.outputs.optionals }}
+ steps:
+ - uses: ljharb/actions/node/matrix@main
+ id: set-matrix
+ with:
+ preset: 'iojs'
+
+ latest:
+ needs: [matrix]
+ name: 'latest minors'
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.latest) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ name: 'npm install && npm run tests-only'
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+ skip-ls-check: true
+
+ minors:
+ needs: [matrix, latest]
+ name: 'non-latest minors'
+ continue-on-error: true
+ if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.minors) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ name: 'npm install && npm run tests-only'
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+ skip-ls-check: true
+
+ node:
+ name: 'io.js'
+ needs: [latest, minors]
+ runs-on: ubuntu-latest
+ steps:
+ - run: 'echo tests completed'
diff --git a/api/node_modules/is-core-module/.github/workflows/node-pretest.yml b/api/node_modules/is-core-module/.github/workflows/node-pretest.yml
new file mode 100644
index 000000000..3921e0ae6
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/node-pretest.yml
@@ -0,0 +1,26 @@
+name: 'Tests: pretest/posttest'
+
+on: [pull_request, push]
+
+jobs:
+ pretest:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ name: 'npm install && npm run pretest'
+ with:
+ node-version: 'lts/*'
+ command: 'pretest'
+
+ posttest:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ name: 'npm install && npm run posttest'
+ with:
+ node-version: 'lts/*'
+ command: 'posttest'
diff --git a/api/node_modules/is-core-module/.github/workflows/node-zero.yml b/api/node_modules/is-core-module/.github/workflows/node-zero.yml
new file mode 100644
index 000000000..d044c6031
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/node-zero.yml
@@ -0,0 +1,58 @@
+name: 'Tests: node.js (0.x)'
+
+on: [pull_request, push]
+
+jobs:
+ matrix:
+ runs-on: ubuntu-latest
+ outputs:
+ stable: ${{ steps.set-matrix.outputs.requireds }}
+ unstable: ${{ steps.set-matrix.outputs.optionals }}
+ steps:
+ - uses: ljharb/actions/node/matrix@main
+ id: set-matrix
+ with:
+ preset: '0.x'
+
+ stable:
+ needs: [matrix]
+ name: 'stable minors'
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.stable) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+ cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
+ skip-ls-check: true
+
+ unstable:
+ needs: [matrix, stable]
+ name: 'unstable minors'
+ continue-on-error: true
+ if: ${{ !github.head_ref || !startsWith(github.head_ref, 'renovate') }}
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix: ${{ fromJson(needs.matrix.outputs.unstable) }}
+
+ steps:
+ - uses: actions/checkout@v2
+ - uses: ljharb/actions/node/run@main
+ with:
+ node-version: ${{ matrix.node-version }}
+ command: 'tests-only'
+ cache-node-modules-key: node_modules-${{ github.workflow }}-${{ github.action }}-${{ github.run_id }}
+ skip-ls-check: true
+
+ node:
+ name: 'node 0.x'
+ needs: [stable, unstable]
+ runs-on: ubuntu-latest
+ steps:
+ - run: 'echo tests completed'
diff --git a/api/node_modules/is-core-module/.github/workflows/rebase.yml b/api/node_modules/is-core-module/.github/workflows/rebase.yml
new file mode 100644
index 000000000..0c2ad39b5
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/rebase.yml
@@ -0,0 +1,15 @@
+name: Automatic Rebase
+
+on: [pull_request_target]
+
+jobs:
+ _:
+ name: "Automatic Rebase"
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ - uses: ljharb/rebase@master
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/api/node_modules/is-core-module/.github/workflows/require-allow-edits.yml b/api/node_modules/is-core-module/.github/workflows/require-allow-edits.yml
new file mode 100644
index 000000000..aac42d3e2
--- /dev/null
+++ b/api/node_modules/is-core-module/.github/workflows/require-allow-edits.yml
@@ -0,0 +1,14 @@
+name: Require “Allow Edits”
+
+on: [pull_request_target]
+
+jobs:
+ _:
+ name: "Require “Allow Edits”"
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: ljharb/require-allow-edits@main
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/api/node_modules/is-core-module/.nycrc b/api/node_modules/is-core-module/.nycrc
new file mode 100644
index 000000000..1826526e0
--- /dev/null
+++ b/api/node_modules/is-core-module/.nycrc
@@ -0,0 +1,13 @@
+{
+ "all": true,
+ "check-coverage": false,
+ "reporter": ["text-summary", "text", "html", "json"],
+ "lines": 86,
+ "statements": 85.93,
+ "functions": 82.43,
+ "branches": 76.06,
+ "exclude": [
+ "coverage",
+ "test"
+ ]
+}
diff --git a/api/node_modules/is-core-module/CHANGELOG.md b/api/node_modules/is-core-module/CHANGELOG.md
new file mode 100644
index 000000000..4cdb33d00
--- /dev/null
+++ b/api/node_modules/is-core-module/CHANGELOG.md
@@ -0,0 +1,58 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [v2.2.0](https://github.com/inspect-js/is-core-module/compare/v2.1.0...v2.2.0) - 2020-11-26
+
+### Commits
+
+- [Tests] migrate tests to Github Actions [`c919f57`](https://github.com/inspect-js/is-core-module/commit/c919f573c0a92d10a0acad0b650b5aecb033d426)
+- [patch] `core.json`: %s/ /\t/g [`db3f685`](https://github.com/inspect-js/is-core-module/commit/db3f68581f53e73cc09cd675955eb1bdd6a5a39b)
+- [Tests] run `nyc` on all tests [`b2f925f`](https://github.com/inspect-js/is-core-module/commit/b2f925f8866f210ef441f39fcc8cc42692ab89b1)
+- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`; add `safe-publish-latest` [`89f02a2`](https://github.com/inspect-js/is-core-module/commit/89f02a2b4162246dea303a6ee31bb9a550b05c72)
+- [New] add `path/posix`, `path/win32`, `util/types` [`77f94f1`](https://github.com/inspect-js/is-core-module/commit/77f94f1e90ffd7c0be2a3f1aa8574ebf7fd981b3)
+
+## [v2.1.0](https://github.com/inspect-js/is-core-module/compare/v2.0.0...v2.1.0) - 2020-11-04
+
+### Commits
+
+- [Dev Deps] update `eslint` [`5e0034e`](https://github.com/inspect-js/is-core-module/commit/5e0034eae57c09c8f1bd769f502486a00f56c6e4)
+- [New] Add `diagnostics_channel` [`c2d83d0`](https://github.com/inspect-js/is-core-module/commit/c2d83d0a0225a1a658945d9bab7036ea347d29ec)
+
+## [v2.0.0](https://github.com/inspect-js/is-core-module/compare/v1.0.2...v2.0.0) - 2020-09-29
+
+### Commits
+
+- v2 implementation [`865aeb5`](https://github.com/inspect-js/is-core-module/commit/865aeb5ca0e90248a3dfff5d7622e4751fdeb9cd)
+- Only apps should have lockfiles [`5a5e660`](https://github.com/inspect-js/is-core-module/commit/5a5e660d568e37eb44e17fb1ebb12a105205fc2b)
+- Initial commit for v2 [`5a51524`](https://github.com/inspect-js/is-core-module/commit/5a51524e06f92adece5fbb138c69b7b9748a2348)
+- Tests [`116eae4`](https://github.com/inspect-js/is-core-module/commit/116eae4fccd01bc72c1fd3cc4b7561c387afc496)
+- [meta] add `auto-changelog` [`c24388b`](https://github.com/inspect-js/is-core-module/commit/c24388bee828d223040519d1f5b226ca35beee63)
+- [actions] add "Automatic Rebase" and "require allow edits" actions [`34292db`](https://github.com/inspect-js/is-core-module/commit/34292dbcbadae0868aff03c22dbd8b7b8a11558a)
+- [Tests] add `npm run lint` [`4f9eeee`](https://github.com/inspect-js/is-core-module/commit/4f9eeee7ddff10698bbf528620f4dc8d4fa3e697)
+- [readme] fix travis badges, https all URLs [`e516a73`](https://github.com/inspect-js/is-core-module/commit/e516a73b0dccce20938c432b1ba512eae8eff9e9)
+- [meta] create FUNDING.yml [`1aabebc`](https://github.com/inspect-js/is-core-module/commit/1aabebca98d01f8a04e46bc2e2520fa93cf21ac6)
+- [Fix] `domain`: domain landed sometime > v0.7.7 and <= v0.7.12 [`2df7d37`](https://github.com/inspect-js/is-core-module/commit/2df7d37595d41b15eeada732b706b926c2771655)
+- [Fix] `sys`: worked in 0.6, not 0.7, and 0.8+ [`a75c134`](https://github.com/inspect-js/is-core-module/commit/a75c134229e1e9441801f6b73f6a52489346eb65)
+
+## [v1.0.2](https://github.com/inspect-js/is-core-module/compare/v1.0.1...v1.0.2) - 2014-09-28
+
+### Commits
+
+- simpler [`66fe90f`](https://github.com/inspect-js/is-core-module/commit/66fe90f9771581b9adc0c3900baa52c21b5baea2)
+
+## [v1.0.1](https://github.com/inspect-js/is-core-module/compare/v1.0.0...v1.0.1) - 2014-09-28
+
+### Commits
+
+- remove stupid [`f21f906`](https://github.com/inspect-js/is-core-module/commit/f21f906f882c2bd656a5fc5ed6fbe48ddaffb2ac)
+- update readme [`1eff0ec`](https://github.com/inspect-js/is-core-module/commit/1eff0ec69798d1ec65771552d1562911e90a8027)
+
+## v1.0.0 - 2014-09-28
+
+### Commits
+
+- init [`48e5e76`](https://github.com/inspect-js/is-core-module/commit/48e5e76cac378fddb8c1f7d4055b8dfc943d6b96)
diff --git a/api/node_modules/is-core-module/LICENSE b/api/node_modules/is-core-module/LICENSE
new file mode 100644
index 000000000..2e502872a
--- /dev/null
+++ b/api/node_modules/is-core-module/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Dave Justice
+
+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.
\ No newline at end of file
diff --git a/api/node_modules/is-core-module/README.md b/api/node_modules/is-core-module/README.md
new file mode 100644
index 000000000..479d6d24c
--- /dev/null
+++ b/api/node_modules/is-core-module/README.md
@@ -0,0 +1,37 @@
+# is-core-module [![Version Badge][2]][1]
+
+[![Build Status][3]][4]
+[![dependency status][5]][6]
+[![dev dependency status][7]][8]
+[![License][license-image]][license-url]
+[![Downloads][downloads-image]][downloads-url]
+
+[![npm badge][11]][1]
+
+Is this specifier a node.js core module? Optionally provide a node version to check; defaults to the current node version.
+
+## Example
+
+```js
+var isCore = require('is-core-module');
+var assert = require('assert');
+assert(isCore('fs'));
+assert(!isCore('butts'));
+```
+
+## Tests
+Clone the repo, `npm install`, and run `npm test`
+
+[1]: https://npmjs.org/package/is-core-module
+[2]: https://versionbadg.es/inspect-js/is-core-module.svg
+[3]: https://travis-ci.com/inspect-js/is-core-module.svg
+[4]: https://travis-ci.com/inspect-js/is-core-module
+[5]: https://david-dm.org/inspect-js/is-core-module.svg
+[6]: https://david-dm.org/inspect-js/is-core-module
+[7]: https://david-dm.org/inspect-js/is-core-module/dev-status.svg
+[8]: https://david-dm.org/inspect-js/is-core-module#info=devDependencies
+[11]: https://nodei.co/npm/is-core-module.png?downloads=true&stars=true
+[license-image]: https://img.shields.io/npm/l/is-core-module.svg
+[license-url]: LICENSE
+[downloads-image]: https://img.shields.io/npm/dm/is-core-module.svg
+[downloads-url]: https://npm-stat.com/charts.html?package=is-core-module
diff --git a/api/node_modules/is-core-module/core.json b/api/node_modules/is-core-module/core.json
new file mode 100644
index 000000000..0238b61a4
--- /dev/null
+++ b/api/node_modules/is-core-module/core.json
@@ -0,0 +1,83 @@
+{
+ "assert": true,
+ "assert/strict": ">= 15",
+ "async_hooks": ">= 8",
+ "buffer_ieee754": "< 0.9.7",
+ "buffer": true,
+ "child_process": true,
+ "cluster": true,
+ "console": true,
+ "constants": true,
+ "crypto": true,
+ "_debug_agent": ">= 1 && < 8",
+ "_debugger": "< 8",
+ "dgram": true,
+ "diagnostics_channel": ">= 15.1",
+ "dns": true,
+ "dns/promises": ">= 15",
+ "domain": ">= 0.7.12",
+ "events": true,
+ "freelist": "< 6",
+ "fs": true,
+ "fs/promises": [">= 10 && < 10.1", ">= 14"],
+ "_http_agent": ">= 0.11.1",
+ "_http_client": ">= 0.11.1",
+ "_http_common": ">= 0.11.1",
+ "_http_incoming": ">= 0.11.1",
+ "_http_outgoing": ">= 0.11.1",
+ "_http_server": ">= 0.11.1",
+ "http": true,
+ "http2": ">= 8.8",
+ "https": true,
+ "inspector": ">= 8.0.0",
+ "_linklist": "< 8",
+ "module": true,
+ "net": true,
+ "node-inspect/lib/_inspect": ">= 7.6.0 && < 12",
+ "node-inspect/lib/internal/inspect_client": ">= 7.6.0 && < 12",
+ "node-inspect/lib/internal/inspect_repl": ">= 7.6.0 && < 12",
+ "os": true,
+ "path": true,
+ "path/posix": ">= 15.3",
+ "path/win32": ">= 15.3",
+ "perf_hooks": ">= 8.5",
+ "process": ">= 1",
+ "punycode": true,
+ "querystring": true,
+ "readline": true,
+ "repl": true,
+ "smalloc": ">= 0.11.5 && < 3",
+ "_stream_duplex": ">= 0.9.4",
+ "_stream_transform": ">= 0.9.4",
+ "_stream_wrap": ">= 1.4.1",
+ "_stream_passthrough": ">= 0.9.4",
+ "_stream_readable": ">= 0.9.4",
+ "_stream_writable": ">= 0.9.4",
+ "stream": true,
+ "stream/promises": ">= 15",
+ "string_decoder": true,
+ "sys": [">= 0.6 && < 0.7", ">= 0.8"],
+ "timers": true,
+ "timers/promises": ">= 15",
+ "_tls_common": ">= 0.11.13",
+ "_tls_legacy": ">= 0.11.3 && < 10",
+ "_tls_wrap": ">= 0.11.3",
+ "tls": true,
+ "trace_events": ">= 10",
+ "tty": true,
+ "url": true,
+ "util": true,
+ "util/types": ">= 15.3",
+ "v8/tools/arguments": ">= 10 && < 12",
+ "v8/tools/codemap": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8/tools/consarray": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8/tools/csvparser": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8/tools/logreader": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8/tools/profile_view": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8/tools/splaytree": [">= 4.4.0 && < 5", ">= 5.2.0 && < 12"],
+ "v8": ">= 1",
+ "vm": true,
+ "wasi": ">= 13.4 && < 13.5",
+ "worker_threads": ">= 11.7",
+ "zlib": true
+}
diff --git a/api/node_modules/is-core-module/index.js b/api/node_modules/is-core-module/index.js
new file mode 100644
index 000000000..f5a69cf76
--- /dev/null
+++ b/api/node_modules/is-core-module/index.js
@@ -0,0 +1,69 @@
+'use strict';
+
+var has = require('has');
+
+function specifierIncluded(current, specifier) {
+ var nodeParts = current.split('.');
+ var parts = specifier.split(' ');
+ var op = parts.length > 1 ? parts[0] : '=';
+ var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
+
+ for (var i = 0; i < 3; ++i) {
+ var cur = parseInt(nodeParts[i] || 0, 10);
+ var ver = parseInt(versionParts[i] || 0, 10);
+ if (cur === ver) {
+ continue; // eslint-disable-line no-restricted-syntax, no-continue
+ }
+ if (op === '<') {
+ return cur < ver;
+ }
+ if (op === '>=') {
+ return cur >= ver;
+ }
+ return false;
+ }
+ return op === '>=';
+}
+
+function matchesRange(current, range) {
+ var specifiers = range.split(/ ?&& ?/);
+ if (specifiers.length === 0) {
+ return false;
+ }
+ for (var i = 0; i < specifiers.length; ++i) {
+ if (!specifierIncluded(current, specifiers[i])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+function versionIncluded(nodeVersion, specifierValue) {
+ if (typeof specifierValue === 'boolean') {
+ return specifierValue;
+ }
+
+ var current = typeof nodeVersion === 'undefined'
+ ? process.versions && process.versions.node && process.versions.node
+ : nodeVersion;
+
+ if (typeof current !== 'string') {
+ throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
+ }
+
+ if (specifierValue && typeof specifierValue === 'object') {
+ for (var i = 0; i < specifierValue.length; ++i) {
+ if (matchesRange(current, specifierValue[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return matchesRange(current, specifierValue);
+}
+
+var data = require('./core.json');
+
+module.exports = function isCore(x, nodeVersion) {
+ return has(data, x) && versionIncluded(nodeVersion, data[x]);
+};
diff --git a/api/node_modules/is-core-module/package.json b/api/node_modules/is-core-module/package.json
new file mode 100644
index 000000000..21341cc43
--- /dev/null
+++ b/api/node_modules/is-core-module/package.json
@@ -0,0 +1,66 @@
+{
+ "name": "is-core-module",
+ "version": "2.2.0",
+ "description": "Is this specifier a node.js core module?",
+ "main": "index.js",
+ "exports": {
+ ".": [
+ {
+ "default": "./index.js"
+ },
+ "./index.js"
+ ],
+ "./package.json": "./package.json"
+ },
+ "scripts": {
+ "prepublish": "safe-publish-latest",
+ "lint": "eslint .",
+ "pretest": "npm run lint",
+ "tests-only": "tape 'test/**/*.js'",
+ "test": "nyc npm run tests-only",
+ "posttest": "aud --production",
+ "version": "auto-changelog && git add CHANGELOG.md",
+ "postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/inspect-js/is-core-module.git"
+ },
+ "keywords": [
+ "core",
+ "modules",
+ "module",
+ "npm",
+ "node",
+ "dependencies"
+ ],
+ "author": "Jordan Harband ",
+ "funding": {
+ "url": "https://github.com/sponsors/ljharb"
+ },
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/inspect-js/is-core-module/issues"
+ },
+ "homepage": "https://github.com/inspect-js/is-core-module",
+ "dependencies": {
+ "has": "^1.0.3"
+ },
+ "devDependencies": {
+ "@ljharb/eslint-config": "^17.3.0",
+ "aud": "^1.1.3",
+ "auto-changelog": "^2.2.1",
+ "eslint": "^7.14.0",
+ "nyc": "^10.3.2",
+ "safe-publish-latest": "^1.1.4",
+ "tape": "^5.0.1"
+ },
+ "auto-changelog": {
+ "output": "CHANGELOG.md",
+ "template": "keepachangelog",
+ "unreleased": false,
+ "commitLimit": false,
+ "backfillLimit": false,
+ "hideCredit": true
+ }
+}
diff --git a/api/node_modules/is-core-module/test/index.js b/api/node_modules/is-core-module/test/index.js
new file mode 100644
index 000000000..99659bcf1
--- /dev/null
+++ b/api/node_modules/is-core-module/test/index.js
@@ -0,0 +1,83 @@
+'use strict';
+
+var test = require('tape');
+var keys = require('object-keys');
+var isCore = require('../');
+var data = require('../core.json');
+
+test('core modules', function (t) {
+ t.test('isCore()', function (st) {
+ st.ok(isCore('fs'));
+ st.ok(isCore('net'));
+ st.ok(isCore('http'));
+
+ st.ok(!isCore('seq'));
+ st.ok(!isCore('../'));
+
+ st.ok(!isCore('toString'));
+
+ st.end();
+ });
+
+ t.test('core list', function (st) {
+ var cores = keys(data);
+ st.plan(cores.length);
+
+ for (var i = 0; i < cores.length; ++i) {
+ var mod = cores[i];
+ var requireFunc = function () { require(mod); }; // eslint-disable-line no-loop-func
+ if (isCore(mod)) {
+ st.doesNotThrow(requireFunc, mod + ' supported; requiring does not throw');
+ } else {
+ st['throws'](requireFunc, mod + ' not supported; requiring throws');
+ }
+ }
+
+ st.end();
+ });
+
+ t.test('core via repl module', { skip: !data.repl }, function (st) {
+ var libs = require('repl')._builtinLibs; // eslint-disable-line no-underscore-dangle
+ if (!libs) {
+ st.skip('module.builtinModules does not exist');
+ } else {
+ for (var i = 0; i < libs.length; ++i) {
+ var mod = libs[i];
+ st.ok(data[mod], mod + ' is a core module');
+ st.doesNotThrow(
+ function () { require(mod); }, // eslint-disable-line no-loop-func
+ 'requiring ' + mod + ' does not throw'
+ );
+ }
+ }
+ st.end();
+ });
+
+ t.test('core via builtinModules list', { skip: !data.module }, function (st) {
+ var libs = require('module').builtinModules;
+ if (!libs) {
+ st.skip('module.builtinModules does not exist');
+ } else {
+ var excludeList = [
+ '_debug_agent',
+ 'v8/tools/tickprocessor-driver',
+ 'v8/tools/SourceMap',
+ 'v8/tools/tickprocessor',
+ 'v8/tools/profile'
+ ];
+ for (var i = 0; i < libs.length; ++i) {
+ var mod = libs[i];
+ if (excludeList.indexOf(mod) === -1) {
+ st.ok(data[mod], mod + ' is a core module');
+ st.doesNotThrow(
+ function () { require(mod); }, // eslint-disable-line no-loop-func
+ 'requiring ' + mod + ' does not throw'
+ );
+ }
+ }
+ }
+ st.end();
+ });
+
+ t.end();
+});
diff --git a/api/node_modules/is-expression/CHANGELOG.md b/api/node_modules/is-expression/CHANGELOG.md
new file mode 100644
index 000000000..abf03e819
--- /dev/null
+++ b/api/node_modules/is-expression/CHANGELOG.md
@@ -0,0 +1,48 @@
+# Change Log
+
+Version 4.0.0 onwards are documented in [Releases](https://github.com/pugjs/is-expression/releases).
+
+This project adheres to [Semantic Versioning](http://semver.org/).
+
+## 3.0.0 - 2016-09-11
+### Added
+- Updated to acorn ~4.0.0
+ - ES2016 has been made the default `ecmaVersion`.
+ - Async functions are now implemented for `{ecmaVersion: 8}`.
+ - See [acorn's CHANGELOG][acorn-4.0.0] for a full list of changes.
+
+## 2.1.0 - 2016-07-27
+### Added
+- Updated to acorn ~3.3.0
+ - The ES2016 check for strict mode in function parameters is now implemented
+ for `{ecmaVersion: 7}`.
+ - See [acorn's CHANGELOG][acorn-3.3.0] for a full list of changes.
+
+## 2.0.1 - 2016-06-04
+### Added
+- Updated to acorn ~3.1.0
+ - See [acorn's CHANGELOG][acorn-3.1.0] for a list of changes.
+ - Even though it is a minor version bump for acorn, the new features are not
+ in parts of acorn we are using, and thus a patch level bump is warranted.
+
+## 2.0.0 - 2016-02-12
+### Added
+- Updated to acorn ~3.0.2
+ - See [acorn's CHANGELOG][acorn-3.0.0] for a list of breaking changes.
+
+## 1.0.2 - 2016-01-06
+### Added
+- Updated to acorn ~2.7.0
+
+## 1.0.1 - 2015-11-12
+### Fixed
+- Use a stricter version range for Acorn since we depend on Acorn internals.
+
+## 1.0.0 - 2015-11-11
+### Added
+- Initial release
+
+[acorn-4.0.0]: https://github.com/ternjs/acorn/blob/master/CHANGELOG.md#400-2016-08-07
+[acorn-3.3.0]: https://github.com/ternjs/acorn/blob/master/CHANGELOG.md#330-2016-07-25
+[acorn-3.1.0]: https://github.com/ternjs/acorn/blob/master/CHANGELOG.md#310-2016-04-18
+[acorn-3.0.0]: https://github.com/ternjs/acorn/blob/master/CHANGELOG.md#300-2016-02-10
diff --git a/api/node_modules/is-expression/LICENSE.md b/api/node_modules/is-expression/LICENSE.md
new file mode 100644
index 000000000..6ee7c4aa7
--- /dev/null
+++ b/api/node_modules/is-expression/LICENSE.md
@@ -0,0 +1,19 @@
+Copyright (c) 2015 Tiancheng “Timothy” Gu
+
+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.
diff --git a/api/node_modules/is-expression/README.md b/api/node_modules/is-expression/README.md
new file mode 100644
index 000000000..9c66c3813
--- /dev/null
+++ b/api/node_modules/is-expression/README.md
@@ -0,0 +1,67 @@
+# is-expression
+
+Validates a string as a JavaScript expression
+
+[![Build Status](https://img.shields.io/travis/pugjs/is-expression/master.svg)](https://travis-ci.org/pugjs/is-expression)
+[![Dependency Status](https://img.shields.io/david/pugjs/is-expression.svg)](https://david-dm.org/pugjs/is-expression)
+[![Rolling Versions](https://img.shields.io/badge/Rolling%20Versions-Enabled-brightgreen)](https://rollingversions.com/pugjs/is-expression)
+[![npm version](https://img.shields.io/npm/v/is-expression.svg)](https://www.npmjs.org/package/is-expression)
+
+## Installation
+
+ npm install is-expression
+
+## Usage
+
+### `isExpression(src[, options])`
+
+Validates a string as a JavaScript expression.
+
+`src` contains the source.
+
+`options` can contain any Acorn options (since we use Acorn under-the-hood),
+or any of the following:
+
+- `throw`: Throw an error if the string is not an expression. The error can
+ be an Acorn error, with location information in `err.loc` and `err.pos`.
+ Defaults to `false`.
+- `strict`: Use strict mode when trying to parse the string. Defaults to
+ `false`. Even if this option is `false`, if you have provided
+ `options.sourceType === 'module'` which imples strict mode under ES2015,
+ strict mode will be used.
+- `lineComment`: When `true`, allows line comments in the expression.
+ Defaults to `false` for safety.
+
+See the examples below for usage.
+
+## Examples
+
+```js
+var isExpression = require('is-expression')
+
+isExpression('myVar')
+//=> true
+isExpression('var')
+//=> false
+isExpression('["an", "array", "\'s"].indexOf("index")')
+//=> true
+
+isExpression('var', {throw: true})
+// SyntaxError: Unexpected token (1:0)
+// at Parser.pp.raise (acorn/dist/acorn.js:940:13)
+// at ...
+
+isExpression('public')
+//=> true
+isExpression('public', {strict: true})
+//=> false
+
+isExpression('abc // my comment')
+//=> false
+isExpression('abc // my comment', {lineComment: true})
+//=> true
+```
+
+## License
+
+MIT
diff --git a/api/node_modules/is-expression/index.js b/api/node_modules/is-expression/index.js
new file mode 100644
index 000000000..7724c975e
--- /dev/null
+++ b/api/node_modules/is-expression/index.js
@@ -0,0 +1,45 @@
+'use strict';
+
+var acorn = require('acorn');
+var objectAssign = require('object-assign');
+
+module.exports = isExpression;
+
+var DEFAULT_OPTIONS = {
+ throw: false,
+ strict: false,
+ lineComment: false
+};
+
+function isExpression(src, options) {
+ options = objectAssign({}, DEFAULT_OPTIONS, options);
+
+ try {
+ var parser = new acorn.Parser(options, src, 0);
+
+ if (options.strict) {
+ parser.strict = true;
+ }
+
+ if (!options.lineComment) {
+ parser.skipLineComment = function (startSkip) {
+ this.raise(this.pos, 'Line comments not allowed in an expression');
+ };
+ }
+
+ parser.nextToken();
+ parser.parseExpression();
+
+ if (parser.type !== acorn.tokTypes.eof) {
+ parser.unexpected();
+ }
+ } catch (ex) {
+ if (!options.throw) {
+ return false;
+ }
+
+ throw ex;
+ }
+
+ return true;
+}
diff --git a/api/node_modules/.bin/acorn b/api/node_modules/is-expression/node_modules/.bin/acorn
similarity index 100%
rename from api/node_modules/.bin/acorn
rename to api/node_modules/is-expression/node_modules/.bin/acorn
diff --git a/api/node_modules/is-expression/node_modules/acorn/CHANGELOG.md b/api/node_modules/is-expression/node_modules/acorn/CHANGELOG.md
new file mode 100644
index 000000000..164fd27c6
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/CHANGELOG.md
@@ -0,0 +1,620 @@
+## 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.
diff --git a/api/node_modules/is-expression/node_modules/acorn/LICENSE b/api/node_modules/is-expression/node_modules/acorn/LICENSE
new file mode 100644
index 000000000..cc5272c96
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (C) 2012-2018 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.
diff --git a/api/node_modules/is-expression/node_modules/acorn/README.md b/api/node_modules/is-expression/node_modules/acorn/README.md
new file mode 100644
index 000000000..52d2e9b71
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/README.md
@@ -0,0 +1,269 @@
+# 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` can be undefined or 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"));
+```
+
+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 can be provided by passing a second argument, which should be
+an object containing any of these fields:
+
+- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
+ either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019) or 11
+ (2020, partial support). This influences support for strict mode,
+ the set of reserved words, and support for new syntax features.
+ Default is 10.
+
+ **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
+ implemented by Acorn. Other proposed new features can 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.
+
+- **allowAwaitOutsideFunction**: By default, `await` expressions can
+ only appear inside `async` functions. Setting this option to
+ `true` allows to have top-level `await` expressions. They are
+ still not allowed in non-`async` functions, though.
+
+- **allowHashBang**: When this is enabled (off by default), if the
+ code starts with the characters `#!` (as in a shellscript), the
+ first line will be treated as a comment.
+
+- **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()");
+```
+
+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.
+
+- `--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)
+
+Plugins for ECMAScript proposals:
+
+ - [`acorn-stage3`](https://github.com/acornjs/acorn-stage3): Parse most stage 3 proposals, bundling:
+ - [`acorn-class-fields`](https://github.com/acornjs/acorn-class-fields): Parse [class fields proposal](https://github.com/tc39/proposal-class-fields)
+ - [`acorn-import-meta`](https://github.com/acornjs/acorn-import-meta): Parse [import.meta proposal](https://github.com/tc39/proposal-import-meta)
+ - [`acorn-private-methods`](https://github.com/acornjs/acorn-private-methods): parse [private methods, getters and setters proposal](https://github.com/tc39/proposal-private-methods)n
diff --git a/api/node_modules/is-expression/node_modules/acorn/bin/acorn b/api/node_modules/is-expression/node_modules/acorn/bin/acorn
new file mode 100755
index 000000000..cf7df4689
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/bin/acorn
@@ -0,0 +1,4 @@
+#!/usr/bin/env node
+'use strict';
+
+require('../dist/bin.js');
diff --git a/api/node_modules/is-expression/node_modules/acorn/dist/acorn.d.ts b/api/node_modules/is-expression/node_modules/acorn/dist/acorn.d.ts
new file mode 100644
index 000000000..bda5f803c
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/dist/acorn.d.ts
@@ -0,0 +1,209 @@
+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
+ }
+
+ interface Options {
+ ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
+ sourceType?: 'script' | 'module'
+ onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
+ onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
+ allowReserved?: boolean | 'never'
+ allowReturnOutsideFunction?: boolean
+ allowImportExportEverywhere?: boolean
+ allowAwaitOutsideFunction?: 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 {
+ constructor(options: Options, input: string, startPos?: number)
+ parse(this: Parser): Node
+ 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
+ }
+ 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
+ eof: TokenType
+ bracketL: TokenType
+ bracketR: TokenType
+ braceL: TokenType
+ braceR: TokenType
+ parenL: TokenType
+ parenR: TokenType
+ comma: TokenType
+ semi: TokenType
+ colon: TokenType
+ dot: TokenType
+ question: TokenType
+ arrow: TokenType
+ template: 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
+ _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
+ }
+
+ function isIdentifierStart(code: number, astral?: boolean): boolean
+
+ function isIdentifierChar(code: number, astral?: boolean): boolean
+
+ interface AbstractToken {
+ }
+
+ interface Comment extends AbstractToken {
+ type: string
+ 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
+}
diff --git a/api/node_modules/is-expression/node_modules/acorn/dist/acorn.js b/api/node_modules/is-expression/node_modules/acorn/dist/acorn.js
new file mode 100644
index 000000000..0523f0e34
--- /dev/null
+++ b/api/node_modules/is-expression/node_modules/acorn/dist/acorn.js
@@ -0,0 +1,5186 @@
+(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 = {}));
+}(this, (function (exports) { 'use strict';
+
+ // Reserved word lists for various dialects of the language
+
+ var reservedWords = {
+ 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",
+ 5: "class enum extends super const export import",
+ 6: "enum",
+ strict: "implements interface let package private protected public static yield",
+ strictBind: "eval arguments"
+ };
+
+ // And the keywords
+
+ var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this";
+
+ var keywords = {
+ 5: ecma5AndLessKeywords,
+ "5module": ecma5AndLessKeywords + " export import",
+ 6: ecma5AndLessKeywords + " const class extends export import super"
+ };
+
+ var keywordRelationalOperator = /^in(stanceof)?$/;
+
+ // ## Character categories
+
+ // Big ugly regular expressions that match characters in the
+ // whitespace, identifier, and identifier-start categories. These
+ // are only applied when a character is found to actually have a
+ // code point above 128.
+ // Generated by `bin/generate-identifier-regex.js`.
+ var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
+ var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
+
+ var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
+ var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
+
+ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
+
+ // These are a run-length and offset encoded representation of the
+ // >0xffff code points that are a valid part of identifiers. The
+ // offset starts at 0x10000, and each pair of numbers represents an
+ // offset to the next range, and then a size of the range. They were
+ // generated by bin/generate-identifier-regex.js
+
+ // eslint-disable-next-line comma-spacing
+ var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];
+
+ // eslint-disable-next-line comma-spacing
+ var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];
+
+ // This has a complexity linear to the value of the code. The
+ // assumption is that looking up astral identifier characters is
+ // rare.
+ function isInAstralSet(code, set) {
+ var pos = 0x10000;
+ for (var i = 0; i < set.length; i += 2) {
+ pos += set[i];
+ if (pos > code) { return false }
+ pos += set[i + 1];
+ if (pos >= code) { return true }
+ }
+ }
+
+ // Test whether a given character code starts an identifier.
+
+ function isIdentifierStart(code, astral) {
+ if (code < 65) { return code === 36 }
+ if (code < 91) { return true }
+ if (code < 97) { return code === 95 }
+ if (code < 123) { return true }
+ if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) }
+ if (astral === false) { return false }
+ return isInAstralSet(code, astralIdentifierStartCodes)
+ }
+
+ // Test whether a given character is part of an identifier.
+
+ function isIdentifierChar(code, astral) {
+ if (code < 48) { return code === 36 }
+ if (code < 58) { return true }
+ if (code < 65) { return false }
+ if (code < 91) { return true }
+ if (code < 97) { return code === 95 }
+ if (code < 123) { return true }
+ if (code <= 0xffff) { return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) }
+ if (astral === false) { return false }
+ return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes)
+ }
+
+ // ## Token types
+
+ // The assignment of fine-grained, information-carrying type objects
+ // allows the tokenizer to store the information it has about a
+ // token in a way that is very cheap for the parser to look up.
+
+ // All token type variables start with an underscore, to make them
+ // easy to recognize.
+
+ // The `beforeExpr` property is used to disambiguate between regular
+ // expressions and divisions. It is set on all token types that can
+ // be followed by an expression (thus, a slash after them would be a
+ // regular expression).
+ //
+ // The `startsExpr` property is used to check if the token ends a
+ // `yield` expression. It is set on all token types that either can
+ // directly start an expression (like a quotation mark) or can
+ // continue an expression (like the body of a string).
+ //
+ // `isLoop` marks a keyword as starting a loop, which is important
+ // to know when parsing a label, in order to allow or disallow
+ // continue jumps to that label.
+
+ var TokenType = function TokenType(label, conf) {
+ if ( conf === void 0 ) conf = {};
+
+ this.label = label;
+ this.keyword = conf.keyword;
+ this.beforeExpr = !!conf.beforeExpr;
+ this.startsExpr = !!conf.startsExpr;
+ this.isLoop = !!conf.isLoop;
+ this.isAssign = !!conf.isAssign;
+ this.prefix = !!conf.prefix;
+ this.postfix = !!conf.postfix;
+ this.binop = conf.binop || null;
+ this.updateContext = null;
+ };
+
+ function binop(name, prec) {
+ return new TokenType(name, {beforeExpr: true, binop: prec})
+ }
+ var beforeExpr = {beforeExpr: true}, startsExpr = {startsExpr: true};
+
+ // Map keyword names to token types.
+
+ var keywords$1 = {};
+
+ // Succinct definitions of keyword token types
+ function kw(name, options) {
+ if ( options === void 0 ) options = {};
+
+ options.keyword = name;
+ return keywords$1[name] = new TokenType(name, options)
+ }
+
+ var types = {
+ num: new TokenType("num", startsExpr),
+ regexp: new TokenType("regexp", startsExpr),
+ string: new TokenType("string", startsExpr),
+ name: new TokenType("name", startsExpr),
+ eof: new TokenType("eof"),
+
+ // Punctuation token types.
+ bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}),
+ bracketR: new TokenType("]"),
+ braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}),
+ braceR: new TokenType("}"),
+ parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}),
+ parenR: new TokenType(")"),
+ comma: new TokenType(",", beforeExpr),
+ semi: new TokenType(";", beforeExpr),
+ colon: new TokenType(":", beforeExpr),
+ dot: new TokenType("."),
+ question: new TokenType("?", beforeExpr),
+ questionDot: new TokenType("?."),
+ arrow: new TokenType("=>", beforeExpr),
+ template: new TokenType("template"),
+ invalidTemplate: new TokenType("invalidTemplate"),
+ ellipsis: new TokenType("...", beforeExpr),
+ backQuote: new TokenType("`", startsExpr),
+ dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}),
+
+ // Operators. These carry several kinds of properties to help the
+ // parser use them properly (the presence of these properties is
+ // what categorizes them as operators).
+ //
+ // `binop`, when present, specifies that this operator is a binary
+ // operator, and will refer to its precedence.
+ //
+ // `prefix` and `postfix` mark the operator as a prefix or postfix
+ // unary operator.
+ //
+ // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as
+ // binary operators with a very low precedence, that should result
+ // in AssignmentExpression nodes.
+
+ eq: new TokenType("=", {beforeExpr: true, isAssign: true}),
+ assign: new TokenType("_=", {beforeExpr: true, isAssign: true}),
+ incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}),
+ prefix: new TokenType("!/~", {beforeExpr: true, prefix: true, startsExpr: true}),
+ logicalOR: binop("||", 1),
+ logicalAND: binop("&&", 2),
+ bitwiseOR: binop("|", 3),
+ bitwiseXOR: binop("^", 4),
+ bitwiseAND: binop("&", 5),
+ equality: binop("==/!=/===/!==", 6),
+ relational: binop(">/<=/>=", 7),
+ bitShift: binop("<>>/>>>", 8),
+ plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}),
+ modulo: binop("%", 10),
+ star: binop("*", 10),
+ slash: binop("/", 10),
+ starstar: new TokenType("**", {beforeExpr: true}),
+ coalesce: binop("??", 1),
+
+ // Keyword token types.
+ _break: kw("break"),
+ _case: kw("case", beforeExpr),
+ _catch: kw("catch"),
+ _continue: kw("continue"),
+ _debugger: kw("debugger"),
+ _default: kw("default", beforeExpr),
+ _do: kw("do", {isLoop: true, beforeExpr: true}),
+ _else: kw("else", beforeExpr),
+ _finally: kw("finally"),
+ _for: kw("for", {isLoop: true}),
+ _function: kw("function", startsExpr),
+ _if: kw("if"),
+ _return: kw("return", beforeExpr),
+ _switch: kw("switch"),
+ _throw: kw("throw", beforeExpr),
+ _try: kw("try"),
+ _var: kw("var"),
+ _const: kw("const"),
+ _while: kw("while", {isLoop: true}),
+ _with: kw("with"),
+ _new: kw("new", {beforeExpr: true, startsExpr: true}),
+ _this: kw("this", startsExpr),
+ _super: kw("super", startsExpr),
+ _class: kw("class", startsExpr),
+ _extends: kw("extends", beforeExpr),
+ _export: kw("export"),
+ _import: kw("import", startsExpr),
+ _null: kw("null", startsExpr),
+ _true: kw("true", startsExpr),
+ _false: kw("false", startsExpr),
+ _in: kw("in", {beforeExpr: true, binop: 7}),
+ _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}),
+ _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}),
+ _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}),
+ _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true})
+ };
+
+ // Matches a whole line break (where CRLF is considered a single
+ // line break). Used to count lines.
+
+ var lineBreak = /\r\n?|\n|\u2028|\u2029/;
+ var lineBreakG = new RegExp(lineBreak.source, "g");
+
+ function isNewLine(code, ecma2019String) {
+ return code === 10 || code === 13 || (!ecma2019String && (code === 0x2028 || code === 0x2029))
+ }
+
+ var nonASCIIwhitespace = /[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/;
+
+ var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g;
+
+ var ref = Object.prototype;
+ var hasOwnProperty = ref.hasOwnProperty;
+ var toString = ref.toString;
+
+ // Checks if an object has a property.
+
+ function has(obj, propName) {
+ return hasOwnProperty.call(obj, propName)
+ }
+
+ var isArray = Array.isArray || (function (obj) { return (
+ toString.call(obj) === "[object Array]"
+ ); });
+
+ function wordsRegexp(words) {
+ return new RegExp("^(?:" + words.replace(/ /g, "|") + ")$")
+ }
+
+ // These are used when `options.locations` is on, for the
+ // `startLoc` and `endLoc` properties.
+
+ var Position = function Position(line, col) {
+ this.line = line;
+ this.column = col;
+ };
+
+ Position.prototype.offset = function offset (n) {
+ return new Position(this.line, this.column + n)
+ };
+
+ var SourceLocation = function SourceLocation(p, start, end) {
+ this.start = start;
+ this.end = end;
+ if (p.sourceFile !== null) { this.source = p.sourceFile; }
+ };
+
+ // The `getLineInfo` function is mostly useful when the
+ // `locations` option is off (for performance reasons) and you
+ // want to find the line/column position for a given character
+ // offset. `input` should be the code string that the offset refers
+ // into.
+
+ function getLineInfo(input, offset) {
+ for (var line = 1, cur = 0;;) {
+ lineBreakG.lastIndex = cur;
+ var match = lineBreakG.exec(input);
+ if (match && match.index < offset) {
+ ++line;
+ cur = match.index + match[0].length;
+ } else {
+ return new Position(line, offset - cur)
+ }
+ }
+ }
+
+ // A second optional argument can be given to further configure
+ // the parser process. These options are recognized:
+
+ var defaultOptions = {
+ // `ecmaVersion` indicates the ECMAScript version to parse. Must be
+ // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
+ // (2019). This influences support for strict mode, the set of
+ // reserved words, and support for new syntax features. The default
+ // is 10.
+ ecmaVersion: 10,
+ // `sourceType` indicates 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.
+ sourceType: "script",
+ // `onInsertedSemicolon` can be a callback that will be called
+ // when a semicolon is automatically inserted. It will be passed
+ // the position of the comma as an offset, and if `locations` is
+ // enabled, it is given the location as a `{line, column}` object
+ // as second argument.
+ onInsertedSemicolon: null,
+ // `onTrailingComma` is similar to `onInsertedSemicolon`, but for
+ // trailing commas.
+ onTrailingComma: null,
+ // By default, reserved words are only enforced if ecmaVersion >= 5.
+ // Set `allowReserved` to a boolean value to explicitly turn this on
+ // an off. When this option has the value "never", reserved words
+ // and keywords can also not be used as property names.
+ allowReserved: null,
+ // When enabled, a return at the top level is not considered an
+ // error.
+ allowReturnOutsideFunction: false,
+ // When enabled, import/export statements are not constrained to
+ // appearing at the top of the program.
+ allowImportExportEverywhere: false,
+ // When enabled, await identifiers are allowed to appear at the top-level scope,
+ // but they are still not allowed in non-async functions.
+ allowAwaitOutsideFunction: false,
+ // When enabled, hashbang directive in the beginning of file
+ // is allowed and treated as a line comment.
+ allowHashBang: false,
+ // When `locations` is on, `loc` properties holding objects with
+ // `start` and `end` properties in `{line, column}` form (with
+ // line being 1-based and column 0-based) will be attached to the
+ // nodes.
+ locations: false,
+ // A function can be passed as `onToken` option, which will
+ // cause Acorn to call that function with object in the same
+ // format as tokens returned from `tokenizer().getToken()`. Note
+ // that you are not allowed to call the parser from the
+ // callback—that will corrupt its internal state.
+ onToken: null,
+ // A function can be passed as `onComment` option, which will
+ // cause Acorn to call that function with `(block, text, start,
+ // end)` parameters whenever a comment is skipped. `block` is a
+ // boolean indicating whether this is a block (`/* */`) comment,
+ // `text` is the content of the comment, and `start` and `end` are
+ // character offsets that denote the start and end of the comment.
+ // When the `locations` option is on, two more parameters are
+ // passed, the full `{line, column}` locations of the start and
+ // end of the comments. Note that you are not allowed to call the
+ // parser from the callback—that will corrupt its internal state.
+ onComment: null,
+ // 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][range] `range` property holding a `[start,
+ // end]` array with the same numbers, set the `ranges` option to
+ // `true`.
+ //
+ // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678
+ ranges: false,
+ // It is possible to parse multiple files into a single AST by
+ // passing the tree produced by parsing the first file as
+ // `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.
+ program: null,
+ // When `locations` is on, you can pass this to record the source
+ // file in every node's `loc` object.
+ sourceFile: null,
+ // This value, if given, is stored in every node, whether
+ // `locations` is on or off.
+ directSourceFile: null,
+ // When enabled, parenthesized expressions are represented by
+ // (non-standard) ParenthesizedExpression nodes
+ preserveParens: false
+ };
+
+ // Interpret and default an options object
+
+ function getOptions(opts) {
+ var options = {};
+
+ for (var opt in defaultOptions)
+ { options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt]; }
+
+ if (options.ecmaVersion >= 2015)
+ { options.ecmaVersion -= 2009; }
+
+ if (options.allowReserved == null)
+ { options.allowReserved = options.ecmaVersion < 5; }
+
+ if (isArray(options.onToken)) {
+ var tokens = options.onToken;
+ options.onToken = function (token) { return tokens.push(token); };
+ }
+ if (isArray(options.onComment))
+ { options.onComment = pushComment(options, options.onComment); }
+
+ return options
+ }
+
+ function pushComment(options, array) {
+ return function(block, text, start, end, startLoc, endLoc) {
+ var comment = {
+ type: block ? "Block" : "Line",
+ value: text,
+ start: start,
+ end: end
+ };
+ if (options.locations)
+ { comment.loc = new SourceLocation(this, startLoc, endLoc); }
+ if (options.ranges)
+ { comment.range = [start, end]; }
+ array.push(comment);
+ }
+ }
+
+ // Each scope gets a bitset that may contain these flags
+ var
+ SCOPE_TOP = 1,
+ SCOPE_FUNCTION = 2,
+ SCOPE_VAR = SCOPE_TOP | SCOPE_FUNCTION,
+ SCOPE_ASYNC = 4,
+ SCOPE_GENERATOR = 8,
+ SCOPE_ARROW = 16,
+ SCOPE_SIMPLE_CATCH = 32,
+ SCOPE_SUPER = 64,
+ SCOPE_DIRECT_SUPER = 128;
+
+ function functionFlags(async, generator) {
+ return SCOPE_FUNCTION | (async ? SCOPE_ASYNC : 0) | (generator ? SCOPE_GENERATOR : 0)
+ }
+
+ // Used in checkLVal and declareName to determine the type of a binding
+ var
+ BIND_NONE = 0, // Not a binding
+ BIND_VAR = 1, // Var-style binding
+ BIND_LEXICAL = 2, // Let- or const-style binding
+ BIND_FUNCTION = 3, // Function declaration
+ BIND_SIMPLE_CATCH = 4, // Simple (identifier pattern) catch binding
+ BIND_OUTSIDE = 5; // Special case for function names as bound inside the function
+
+ var Parser = function Parser(options, input, startPos) {
+ this.options = options = getOptions(options);
+ this.sourceFile = options.sourceFile;
+ this.keywords = wordsRegexp(keywords[options.ecmaVersion >= 6 ? 6 : options.sourceType === "module" ? "5module" : 5]);
+ var reserved = "";
+ if (options.allowReserved !== true) {
+ for (var v = options.ecmaVersion;; v--)
+ { if (reserved = reservedWords[v]) { break } }
+ if (options.sourceType === "module") { reserved += " await"; }
+ }
+ this.reservedWords = wordsRegexp(reserved);
+ var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict;
+ this.reservedWordsStrict = wordsRegexp(reservedStrict);
+ this.reservedWordsStrictBind = wordsRegexp(reservedStrict + " " + reservedWords.strictBind);
+ this.input = String(input);
+
+ // Used to signal to callers of `readWord1` whether the word
+ // contained any escape sequences. This is needed because words with
+ // escape sequences must not be interpreted as keywords.
+ this.containsEsc = false;
+
+ // Set up token state
+
+ // The current position of the tokenizer in the input.
+ if (startPos) {
+ this.pos = startPos;
+ this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1;
+ this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length;
+ } else {
+ this.pos = this.lineStart = 0;
+ this.curLine = 1;
+ }
+
+ // Properties of the current token:
+ // Its type
+ this.type = types.eof;
+ // For tokens that include more information than their type, the value
+ this.value = null;
+ // Its start and end offset
+ this.start = this.end = this.pos;
+ // And, if locations are used, the {line, column} object
+ // corresponding to those offsets
+ this.startLoc = this.endLoc = this.curPosition();
+
+ // Position information for the previous token
+ this.lastTokEndLoc = this.lastTokStartLoc = null;
+ this.lastTokStart = this.lastTokEnd = this.pos;
+
+ // The context stack is used to superficially track syntactic
+ // context to predict whether a regular expression is allowed in a
+ // given position.
+ this.context = this.initialContext();
+ this.exprAllowed = true;
+
+ // Figure out if it's a module code.
+ this.inModule = options.sourceType === "module";
+ this.strict = this.inModule || this.strictDirective(this.pos);
+
+ // Used to signify the start of a potential arrow function
+ this.potentialArrowAt = -1;
+
+ // Positions to delayed-check that yield/await does not exist in default parameters.
+ this.yieldPos = this.awaitPos = this.awaitIdentPos = 0;
+ // Labels in scope.
+ this.labels = [];
+ // Thus-far undefined exports.
+ this.undefinedExports = {};
+
+ // If enabled, skip leading hashbang line.
+ if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === "#!")
+ { this.skipLineComment(2); }
+
+ // Scope tracking for duplicate variable names (see scope.js)
+ this.scopeStack = [];
+ this.enterScope(SCOPE_TOP);
+
+ // For RegExp validation
+ this.regexpState = null;
+ };
+
+ var prototypeAccessors = { inFunction: { configurable: true },inGenerator: { configurable: true },inAsync: { configurable: true },allowSuper: { configurable: true },allowDirectSuper: { configurable: true },treatFunctionsAsVar: { configurable: true } };
+
+ Parser.prototype.parse = function parse () {
+ var node = this.options.program || this.startNode();
+ this.nextToken();
+ return this.parseTopLevel(node)
+ };
+
+ prototypeAccessors.inFunction.get = function () { return (this.currentVarScope().flags & SCOPE_FUNCTION) > 0 };
+ prototypeAccessors.inGenerator.get = function () { return (this.currentVarScope().flags & SCOPE_GENERATOR) > 0 };
+ prototypeAccessors.inAsync.get = function () { return (this.currentVarScope().flags & SCOPE_ASYNC) > 0 };
+ prototypeAccessors.allowSuper.get = function () { return (this.currentThisScope().flags & SCOPE_SUPER) > 0 };
+ prototypeAccessors.allowDirectSuper.get = function () { return (this.currentThisScope().flags & SCOPE_DIRECT_SUPER) > 0 };
+ prototypeAccessors.treatFunctionsAsVar.get = function () { return this.treatFunctionsAsVarInScope(this.currentScope()) };
+
+ // Switch to a getter for 7.0.0.
+ Parser.prototype.inNonArrowFunction = function inNonArrowFunction () { return (this.currentThisScope().flags & SCOPE_FUNCTION) > 0 };
+
+ Parser.extend = function extend () {
+ var plugins = [], len = arguments.length;
+ while ( len-- ) plugins[ len ] = arguments[ len ];
+
+ var cls = this;
+ for (var i = 0; i < plugins.length; i++) { cls = plugins[i](cls); }
+ return cls
+ };
+
+ Parser.parse = function parse (input, options) {
+ return new this(options, input).parse()
+ };
+
+ Parser.parseExpressionAt = function parseExpressionAt (input, pos, options) {
+ var parser = new this(options, input, pos);
+ parser.nextToken();
+ return parser.parseExpression()
+ };
+
+ Parser.tokenizer = function tokenizer (input, options) {
+ return new this(options, input)
+ };
+
+ Object.defineProperties( Parser.prototype, prototypeAccessors );
+
+ var pp = Parser.prototype;
+
+ // ## Parser utilities
+
+ var literal = /^(?:'((?:\\.|[^'\\])*?)'|"((?:\\.|[^"\\])*?)")/;
+ pp.strictDirective = function(start) {
+ for (;;) {
+ // Try to find string literal.
+ skipWhiteSpace.lastIndex = start;
+ start += skipWhiteSpace.exec(this.input)[0].length;
+ var match = literal.exec(this.input.slice(start));
+ if (!match) { return false }
+ if ((match[1] || match[2]) === "use strict") {
+ skipWhiteSpace.lastIndex = start + match[0].length;
+ var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
+ var next = this.input.charAt(end);
+ return next === ";" || next === "}" ||
+ (lineBreak.test(spaceAfter[0]) &&
+ !(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
+ }
+ start += match[0].length;
+
+ // Skip semicolon, if any.
+ skipWhiteSpace.lastIndex = start;
+ start += skipWhiteSpace.exec(this.input)[0].length;
+ if (this.input[start] === ";")
+ { start++; }
+ }
+ };
+
+ // Predicate that tests whether the next token is of the given
+ // type, and if yes, consumes it as a side effect.
+
+ pp.eat = function(type) {
+ if (this.type === type) {
+ this.next();
+ return true
+ } else {
+ return false
+ }
+ };
+
+ // Tests whether parsed token is a contextual keyword.
+
+ pp.isContextual = function(name) {
+ return this.type === types.name && this.value === name && !this.containsEsc
+ };
+
+ // Consumes contextual keyword if possible.
+
+ pp.eatContextual = function(name) {
+ if (!this.isContextual(name)) { return false }
+ this.next();
+ return true
+ };
+
+ // Asserts that following token is given contextual keyword.
+
+ pp.expectContextual = function(name) {
+ if (!this.eatContextual(name)) { this.unexpected(); }
+ };
+
+ // Test whether a semicolon can be inserted at the current position.
+
+ pp.canInsertSemicolon = function() {
+ return this.type === types.eof ||
+ this.type === types.braceR ||
+ lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
+ };
+
+ pp.insertSemicolon = function() {
+ if (this.canInsertSemicolon()) {
+ if (this.options.onInsertedSemicolon)
+ { this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc); }
+ return true
+ }
+ };
+
+ // Consume a semicolon, or, failing that, see if we are allowed to
+ // pretend that there is a semicolon at this position.
+
+ pp.semicolon = function() {
+ if (!this.eat(types.semi) && !this.insertSemicolon()) { this.unexpected(); }
+ };
+
+ pp.afterTrailingComma = function(tokType, notNext) {
+ if (this.type === tokType) {
+ if (this.options.onTrailingComma)
+ { this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc); }
+ if (!notNext)
+ { this.next(); }
+ return true
+ }
+ };
+
+ // Expect a token of a given type. If found, consume it, otherwise,
+ // raise an unexpected token error.
+
+ pp.expect = function(type) {
+ this.eat(type) || this.unexpected();
+ };
+
+ // Raise an unexpected token error.
+
+ pp.unexpected = function(pos) {
+ this.raise(pos != null ? pos : this.start, "Unexpected token");
+ };
+
+ function DestructuringErrors() {
+ this.shorthandAssign =
+ this.trailingComma =
+ this.parenthesizedAssign =
+ this.parenthesizedBind =
+ this.doubleProto =
+ -1;
+ }
+
+ pp.checkPatternErrors = function(refDestructuringErrors, isAssign) {
+ if (!refDestructuringErrors) { return }
+ if (refDestructuringErrors.trailingComma > -1)
+ { this.raiseRecoverable(refDestructuringErrors.trailingComma, "Comma is not permitted after the rest element"); }
+ var parens = isAssign ? refDestructuringErrors.parenthesizedAssign : refDestructuringErrors.parenthesizedBind;
+ if (parens > -1) { this.raiseRecoverable(parens, "Parenthesized pattern"); }
+ };
+
+ pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) {
+ if (!refDestructuringErrors) { return false }
+ var shorthandAssign = refDestructuringErrors.shorthandAssign;
+ var doubleProto = refDestructuringErrors.doubleProto;
+ if (!andThrow) { return shorthandAssign >= 0 || doubleProto >= 0 }
+ if (shorthandAssign >= 0)
+ { this.raise(shorthandAssign, "Shorthand property assignments are valid only in destructuring patterns"); }
+ if (doubleProto >= 0)
+ { this.raiseRecoverable(doubleProto, "Redefinition of __proto__ property"); }
+ };
+
+ pp.checkYieldAwaitInDefaultParams = function() {
+ if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos))
+ { this.raise(this.yieldPos, "Yield expression cannot be a default value"); }
+ if (this.awaitPos)
+ { this.raise(this.awaitPos, "Await expression cannot be a default value"); }
+ };
+
+ pp.isSimpleAssignTarget = function(expr) {
+ if (expr.type === "ParenthesizedExpression")
+ { return this.isSimpleAssignTarget(expr.expression) }
+ return expr.type === "Identifier" || expr.type === "MemberExpression"
+ };
+
+ var pp$1 = Parser.prototype;
+
+ // ### Statement parsing
+
+ // Parse a program. Initializes the parser, reads any number of
+ // statements, and wraps them in a Program node. Optionally takes a
+ // `program` argument. If present, the statements will be appended
+ // to its body instead of creating a new node.
+
+ pp$1.parseTopLevel = function(node) {
+ var exports = {};
+ if (!node.body) { node.body = []; }
+ while (this.type !== types.eof) {
+ var stmt = this.parseStatement(null, true, exports);
+ node.body.push(stmt);
+ }
+ if (this.inModule)
+ { for (var i = 0, list = Object.keys(this.undefinedExports); i < list.length; i += 1)
+ {
+ var name = list[i];
+
+ this.raiseRecoverable(this.undefinedExports[name].start, ("Export '" + name + "' is not defined"));
+ } }
+ this.adaptDirectivePrologue(node.body);
+ this.next();
+ node.sourceType = this.options.sourceType;
+ return this.finishNode(node, "Program")
+ };
+
+ var loopLabel = {kind: "loop"}, switchLabel = {kind: "switch"};
+
+ pp$1.isLet = function(context) {
+ if (this.options.ecmaVersion < 6 || !this.isContextual("let")) { return false }
+ skipWhiteSpace.lastIndex = this.pos;
+ var skip = skipWhiteSpace.exec(this.input);
+ var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
+ // For ambiguous cases, determine if a LexicalDeclaration (or only a
+ // Statement) is allowed here. If context is not empty then only a Statement
+ // is allowed. However, `let [` is an explicit negative lookahead for
+ // ExpressionStatement, so special-case it first.
+ if (nextCh === 91) { return true } // '['
+ if (context) { return false }
+
+ if (nextCh === 123) { return true } // '{'
+ if (isIdentifierStart(nextCh, true)) {
+ var pos = next + 1;
+ while (isIdentifierChar(this.input.charCodeAt(pos), true)) { ++pos; }
+ var ident = this.input.slice(next, pos);
+ if (!keywordRelationalOperator.test(ident)) { return true }
+ }
+ return false
+ };
+
+ // check 'async [no LineTerminator here] function'
+ // - 'async /*foo*/ function' is OK.
+ // - 'async /*\n*/ function' is invalid.
+ pp$1.isAsyncFunction = function() {
+ if (this.options.ecmaVersion < 8 || !this.isContextual("async"))
+ { return false }
+
+ skipWhiteSpace.lastIndex = this.pos;
+ var skip = skipWhiteSpace.exec(this.input);
+ var next = this.pos + skip[0].length;
+ return !lineBreak.test(this.input.slice(this.pos, next)) &&
+ this.input.slice(next, next + 8) === "function" &&
+ (next + 8 === this.input.length || !isIdentifierChar(this.input.charAt(next + 8)))
+ };
+
+ // Parse a single statement.
+ //
+ // If expecting a statement and finding a slash operator, parse a
+ // regular expression literal. This is to handle cases like
+ // `if (foo) /blah/.exec(foo)`, where looking at the previous token
+ // does not help.
+
+ pp$1.parseStatement = function(context, topLevel, exports) {
+ var starttype = this.type, node = this.startNode(), kind;
+
+ if (this.isLet(context)) {
+ starttype = types._var;
+ kind = "let";
+ }
+
+ // Most types of statements are recognized by the keyword they
+ // start with. Many are trivial to parse, some require a bit of
+ // complexity.
+
+ switch (starttype) {
+ case types._break: case types._continue: return this.parseBreakContinueStatement(node, starttype.keyword)
+ case types._debugger: return this.parseDebuggerStatement(node)
+ case types._do: return this.parseDoStatement(node)
+ case types._for: return this.parseForStatement(node)
+ case types._function:
+ // Function as sole body of either an if statement or a labeled statement
+ // works, but not when it is part of a labeled statement that is the sole
+ // body of an if statement.
+ if ((context && (this.strict || context !== "if" && context !== "label")) && this.options.ecmaVersion >= 6) { this.unexpected(); }
+ return this.parseFunctionStatement(node, false, !context)
+ case types._class:
+ if (context) { this.unexpected(); }
+ return this.parseClass(node, true)
+ case types._if: return this.parseIfStatement(node)
+ case types._return: return this.parseReturnStatement(node)
+ case types._switch: return this.parseSwitchStatement(node)
+ case types._throw: return this.parseThrowStatement(node)
+ case types._try: return this.parseTryStatement(node)
+ case types._const: case types._var:
+ kind = kind || this.value;
+ if (context && kind !== "var") { this.unexpected(); }
+ return this.parseVarStatement(node, kind)
+ case types._while: return this.parseWhileStatement(node)
+ case types._with: return this.parseWithStatement(node)
+ case types.braceL: return this.parseBlock(true, node)
+ case types.semi: return this.parseEmptyStatement(node)
+ case types._export:
+ case types._import:
+ if (this.options.ecmaVersion > 10 && starttype === types._import) {
+ skipWhiteSpace.lastIndex = this.pos;
+ var skip = skipWhiteSpace.exec(this.input);
+ var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
+ if (nextCh === 40 || nextCh === 46) // '(' or '.'
+ { return this.parseExpressionStatement(node, this.parseExpression()) }
+ }
+
+ if (!this.options.allowImportExportEverywhere) {
+ if (!topLevel)
+ { this.raise(this.start, "'import' and 'export' may only appear at the top level"); }
+ if (!this.inModule)
+ { this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'"); }
+ }
+ return starttype === types._import ? this.parseImport(node) : this.parseExport(node, exports)
+
+ // If the statement does not start with a statement keyword or a
+ // brace, it's an ExpressionStatement or LabeledStatement. We
+ // simply start parsing an expression, and afterwards, if the
+ // next token is a colon and the expression was a simple
+ // Identifier node, we switch to interpreting it as a label.
+ default:
+ if (this.isAsyncFunction()) {
+ if (context) { this.unexpected(); }
+ this.next();
+ return this.parseFunctionStatement(node, true, !context)
+ }
+
+ var maybeName = this.value, expr = this.parseExpression();
+ if (starttype === types.name && expr.type === "Identifier" && this.eat(types.colon))
+ { return this.parseLabeledStatement(node, maybeName, expr, context) }
+ else { return this.parseExpressionStatement(node, expr) }
+ }
+ };
+
+ pp$1.parseBreakContinueStatement = function(node, keyword) {
+ var isBreak = keyword === "break";
+ this.next();
+ if (this.eat(types.semi) || this.insertSemicolon()) { node.label = null; }
+ else if (this.type !== types.name) { this.unexpected(); }
+ else {
+ node.label = this.parseIdent();
+ this.semicolon();
+ }
+
+ // Verify that there is an actual destination to break or
+ // continue to.
+ var i = 0;
+ for (; i < this.labels.length; ++i) {
+ var lab = this.labels[i];
+ if (node.label == null || lab.name === node.label.name) {
+ if (lab.kind != null && (isBreak || lab.kind === "loop")) { break }
+ if (node.label && isBreak) { break }
+ }
+ }
+ if (i === this.labels.length) { this.raise(node.start, "Unsyntactic " + keyword); }
+ return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement")
+ };
+
+ pp$1.parseDebuggerStatement = function(node) {
+ this.next();
+ this.semicolon();
+ return this.finishNode(node, "DebuggerStatement")
+ };
+
+ pp$1.parseDoStatement = function(node) {
+ this.next();
+ this.labels.push(loopLabel);
+ node.body = this.parseStatement("do");
+ this.labels.pop();
+ this.expect(types._while);
+ node.test = this.parseParenExpression();
+ if (this.options.ecmaVersion >= 6)
+ { this.eat(types.semi); }
+ else
+ { this.semicolon(); }
+ return this.finishNode(node, "DoWhileStatement")
+ };
+
+ // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
+ // loop is non-trivial. Basically, we have to parse the init `var`
+ // statement or expression, disallowing the `in` operator (see
+ // the second parameter to `parseExpression`), and then check
+ // whether the next token is `in` or `of`. When there is no init
+ // part (semicolon immediately after the opening parenthesis), it
+ // is a regular `for` loop.
+
+ pp$1.parseForStatement = function(node) {
+ this.next();
+ var awaitAt = (this.options.ecmaVersion >= 9 && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) && this.eatContextual("await")) ? this.lastTokStart : -1;
+ this.labels.push(loopLabel);
+ this.enterScope(0);
+ this.expect(types.parenL);
+ if (this.type === types.semi) {
+ if (awaitAt > -1) { this.unexpected(awaitAt); }
+ return this.parseFor(node, null)
+ }
+ var isLet = this.isLet();
+ if (this.type === types._var || this.type === types._const || isLet) {
+ var init$1 = this.startNode(), kind = isLet ? "let" : this.value;
+ this.next();
+ this.parseVar(init$1, true, kind);
+ this.finishNode(init$1, "VariableDeclaration");
+ if ((this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1) {
+ if (this.options.ecmaVersion >= 9) {
+ if (this.type === types._in) {
+ if (awaitAt > -1) { this.unexpected(awaitAt); }
+ } else { node.await = awaitAt > -1; }
+ }
+ return this.parseForIn(node, init$1)
+ }
+ if (awaitAt > -1) { this.unexpected(awaitAt); }
+ return this.parseFor(node, init$1)
+ }
+ var refDestructuringErrors = new DestructuringErrors;
+ var init = this.parseExpression(true, refDestructuringErrors);
+ if (this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) {
+ if (this.options.ecmaVersion >= 9) {
+ if (this.type === types._in) {
+ if (awaitAt > -1) { this.unexpected(awaitAt); }
+ } else { node.await = awaitAt > -1; }
+ }
+ this.toAssignable(init, false, refDestructuringErrors);
+ this.checkLVal(init);
+ return this.parseForIn(node, init)
+ } else {
+ this.checkExpressionErrors(refDestructuringErrors, true);
+ }
+ if (awaitAt > -1) { this.unexpected(awaitAt); }
+ return this.parseFor(node, init)
+ };
+
+ pp$1.parseFunctionStatement = function(node, isAsync, declarationPosition) {
+ this.next();
+ return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
+ };
+
+ pp$1.parseIfStatement = function(node) {
+ this.next();
+ node.test = this.parseParenExpression();
+ // allow function declarations in branches, but only in non-strict mode
+ node.consequent = this.parseStatement("if");
+ node.alternate = this.eat(types._else) ? this.parseStatement("if") : null;
+ return this.finishNode(node, "IfStatement")
+ };
+
+ pp$1.parseReturnStatement = function(node) {
+ if (!this.inFunction && !this.options.allowReturnOutsideFunction)
+ { this.raise(this.start, "'return' outside of function"); }
+ this.next();
+
+ // In `return` (and `break`/`continue`), the keywords with
+ // optional arguments, we eagerly look for a semicolon or the
+ // possibility to insert one.
+
+ if (this.eat(types.semi) || this.insertSemicolon()) { node.argument = null; }
+ else { node.argument = this.parseExpression(); this.semicolon(); }
+ return this.finishNode(node, "ReturnStatement")
+ };
+
+ pp$1.parseSwitchStatement = function(node) {
+ this.next();
+ node.discriminant = this.parseParenExpression();
+ node.cases = [];
+ this.expect(types.braceL);
+ this.labels.push(switchLabel);
+ this.enterScope(0);
+
+ // Statements under must be grouped (by label) in SwitchCase
+ // nodes. `cur` is used to keep the node that we are currently
+ // adding statements to.
+
+ var cur;
+ for (var sawDefault = false; this.type !== types.braceR;) {
+ if (this.type === types._case || this.type === types._default) {
+ var isCase = this.type === types._case;
+ if (cur) { this.finishNode(cur, "SwitchCase"); }
+ node.cases.push(cur = this.startNode());
+ cur.consequent = [];
+ this.next();
+ if (isCase) {
+ cur.test = this.parseExpression();
+ } else {
+ if (sawDefault) { this.raiseRecoverable(this.lastTokStart, "Multiple default clauses"); }
+ sawDefault = true;
+ cur.test = null;
+ }
+ this.expect(types.colon);
+ } else {
+ if (!cur) { this.unexpected(); }
+ cur.consequent.push(this.parseStatement(null));
+ }
+ }
+ this.exitScope();
+ if (cur) { this.finishNode(cur, "SwitchCase"); }
+ this.next(); // Closing brace
+ this.labels.pop();
+ return this.finishNode(node, "SwitchStatement")
+ };
+
+ pp$1.parseThrowStatement = function(node) {
+ this.next();
+ if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start)))
+ { this.raise(this.lastTokEnd, "Illegal newline after throw"); }
+ node.argument = this.parseExpression();
+ this.semicolon();
+ return this.finishNode(node, "ThrowStatement")
+ };
+
+ // Reused empty array added for node fields that are always empty.
+
+ var empty = [];
+
+ pp$1.parseTryStatement = function(node) {
+ this.next();
+ node.block = this.parseBlock();
+ node.handler = null;
+ if (this.type === types._catch) {
+ var clause = this.startNode();
+ this.next();
+ if (this.eat(types.parenL)) {
+ clause.param = this.parseBindingAtom();
+ var simple = clause.param.type === "Identifier";
+ this.enterScope(simple ? SCOPE_SIMPLE_CATCH : 0);
+ this.checkLVal(clause.param, simple ? BIND_SIMPLE_CATCH : BIND_LEXICAL);
+ this.expect(types.parenR);
+ } else {
+ if (this.options.ecmaVersion < 10) { this.unexpected(); }
+ clause.param = null;
+ this.enterScope(0);
+ }
+ clause.body = this.parseBlock(false);
+ this.exitScope();
+ node.handler = this.finishNode(clause, "CatchClause");
+ }
+ node.finalizer = this.eat(types._finally) ? this.parseBlock() : null;
+ if (!node.handler && !node.finalizer)
+ { this.raise(node.start, "Missing catch or finally clause"); }
+ return this.finishNode(node, "TryStatement")
+ };
+
+ pp$1.parseVarStatement = function(node, kind) {
+ this.next();
+ this.parseVar(node, false, kind);
+ this.semicolon();
+ return this.finishNode(node, "VariableDeclaration")
+ };
+
+ pp$1.parseWhileStatement = function(node) {
+ this.next();
+ node.test = this.parseParenExpression();
+ this.labels.push(loopLabel);
+ node.body = this.parseStatement("while");
+ this.labels.pop();
+ return this.finishNode(node, "WhileStatement")
+ };
+
+ pp$1.parseWithStatement = function(node) {
+ if (this.strict) { this.raise(this.start, "'with' in strict mode"); }
+ this.next();
+ node.object = this.parseParenExpression();
+ node.body = this.parseStatement("with");
+ return this.finishNode(node, "WithStatement")
+ };
+
+ pp$1.parseEmptyStatement = function(node) {
+ this.next();
+ return this.finishNode(node, "EmptyStatement")
+ };
+
+ pp$1.parseLabeledStatement = function(node, maybeName, expr, context) {
+ for (var i$1 = 0, list = this.labels; i$1 < list.length; i$1 += 1)
+ {
+ var label = list[i$1];
+
+ if (label.name === maybeName)
+ { this.raise(expr.start, "Label '" + maybeName + "' is already declared");
+ } }
+ var kind = this.type.isLoop ? "loop" : this.type === types._switch ? "switch" : null;
+ for (var i = this.labels.length - 1; i >= 0; i--) {
+ var label$1 = this.labels[i];
+ if (label$1.statementStart === node.start) {
+ // Update information about previous labels on this node
+ label$1.statementStart = this.start;
+ label$1.kind = kind;
+ } else { break }
+ }
+ this.labels.push({name: maybeName, kind: kind, statementStart: this.start});
+ node.body = this.parseStatement(context ? context.indexOf("label") === -1 ? context + "label" : context : "label");
+ this.labels.pop();
+ node.label = expr;
+ return this.finishNode(node, "LabeledStatement")
+ };
+
+ pp$1.parseExpressionStatement = function(node, expr) {
+ node.expression = expr;
+ this.semicolon();
+ return this.finishNode(node, "ExpressionStatement")
+ };
+
+ // Parse a semicolon-enclosed block of statements, handling `"use
+ // strict"` declarations when `allowStrict` is true (used for
+ // function bodies).
+
+ pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
+ if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
+ if ( node === void 0 ) node = this.startNode();
+
+ node.body = [];
+ this.expect(types.braceL);
+ if (createNewLexicalScope) { this.enterScope(0); }
+ while (this.type !== types.braceR) {
+ var stmt = this.parseStatement(null);
+ node.body.push(stmt);
+ }
+ if (exitStrict) { this.strict = false; }
+ this.next();
+ if (createNewLexicalScope) { this.exitScope(); }
+ return this.finishNode(node, "BlockStatement")
+ };
+
+ // Parse a regular `for` loop. The disambiguation code in
+ // `parseStatement` will already have parsed the init statement or
+ // expression.
+
+ pp$1.parseFor = function(node, init) {
+ node.init = init;
+ this.expect(types.semi);
+ node.test = this.type === types.semi ? null : this.parseExpression();
+ this.expect(types.semi);
+ node.update = this.type === types.parenR ? null : this.parseExpression();
+ this.expect(types.parenR);
+ node.body = this.parseStatement("for");
+ this.exitScope();
+ this.labels.pop();
+ return this.finishNode(node, "ForStatement")
+ };
+
+ // Parse a `for`/`in` and `for`/`of` loop, which are almost
+ // same from parser's perspective.
+
+ pp$1.parseForIn = function(node, init) {
+ var isForIn = this.type === types._in;
+ this.next();
+
+ if (
+ init.type === "VariableDeclaration" &&
+ init.declarations[0].init != null &&
+ (
+ !isForIn ||
+ this.options.ecmaVersion < 8 ||
+ this.strict ||
+ init.kind !== "var" ||
+ init.declarations[0].id.type !== "Identifier"
+ )
+ ) {
+ this.raise(
+ init.start,
+ ((isForIn ? "for-in" : "for-of") + " loop variable declaration may not have an initializer")
+ );
+ } else if (init.type === "AssignmentPattern") {
+ this.raise(init.start, "Invalid left-hand side in for-loop");
+ }
+ node.left = init;
+ node.right = isForIn ? this.parseExpression() : this.parseMaybeAssign();
+ this.expect(types.parenR);
+ node.body = this.parseStatement("for");
+ this.exitScope();
+ this.labels.pop();
+ return this.finishNode(node, isForIn ? "ForInStatement" : "ForOfStatement")
+ };
+
+ // Parse a list of variable declarations.
+
+ pp$1.parseVar = function(node, isFor, kind) {
+ node.declarations = [];
+ node.kind = kind;
+ for (;;) {
+ var decl = this.startNode();
+ this.parseVarId(decl, kind);
+ if (this.eat(types.eq)) {
+ decl.init = this.parseMaybeAssign(isFor);
+ } else if (kind === "const" && !(this.type === types._in || (this.options.ecmaVersion >= 6 && this.isContextual("of")))) {
+ this.unexpected();
+ } else if (decl.id.type !== "Identifier" && !(isFor && (this.type === types._in || this.isContextual("of")))) {
+ this.raise(this.lastTokEnd, "Complex binding patterns require an initialization value");
+ } else {
+ decl.init = null;
+ }
+ node.declarations.push(this.finishNode(decl, "VariableDeclarator"));
+ if (!this.eat(types.comma)) { break }
+ }
+ return node
+ };
+
+ pp$1.parseVarId = function(decl, kind) {
+ decl.id = this.parseBindingAtom();
+ this.checkLVal(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
+ };
+
+ var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
+
+ // Parse a function declaration or literal (depending on the
+ // `statement & FUNC_STATEMENT`).
+
+ // Remove `allowExpressionBody` for 7.0.0, as it is only called with false
+ pp$1.parseFunction = function(node, statement, allowExpressionBody, isAsync) {
+ this.initFunction(node);
+ if (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !isAsync) {
+ if (this.type === types.star && (statement & FUNC_HANGING_STATEMENT))
+ { this.unexpected(); }
+ node.generator = this.eat(types.star);
+ }
+ if (this.options.ecmaVersion >= 8)
+ { node.async = !!isAsync; }
+
+ if (statement & FUNC_STATEMENT) {
+ node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types.name ? null : this.parseIdent();
+ if (node.id && !(statement & FUNC_HANGING_STATEMENT))
+ // If it is a regular function declaration in sloppy mode, then it is
+ // subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
+ // mode depends on properties of the current scope (see
+ // treatFunctionsAsVar).
+ { this.checkLVal(node.id, (this.strict || node.generator || node.async) ? this.treatFunctionsAsVar ? BIND_VAR : BIND_LEXICAL : BIND_FUNCTION); }
+ }
+
+ var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
+ this.yieldPos = 0;
+ this.awaitPos = 0;
+ this.awaitIdentPos = 0;
+ this.enterScope(functionFlags(node.async, node.generator));
+
+ if (!(statement & FUNC_STATEMENT))
+ { node.id = this.type === types.name ? this.parseIdent() : null; }
+
+ this.parseFunctionParams(node);
+ this.parseFunctionBody(node, allowExpressionBody, false);
+
+ this.yieldPos = oldYieldPos;
+ this.awaitPos = oldAwaitPos;
+ this.awaitIdentPos = oldAwaitIdentPos;
+ return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
+ };
+
+ pp$1.parseFunctionParams = function(node) {
+ this.expect(types.parenL);
+ node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
+ this.checkYieldAwaitInDefaultParams();
+ };
+
+ // Parse a class declaration or literal (depending on the
+ // `isStatement` parameter).
+
+ pp$1.parseClass = function(node, isStatement) {
+ this.next();
+
+ // ecma-262 14.6 Class Definitions
+ // A class definition is always strict mode code.
+ var oldStrict = this.strict;
+ this.strict = true;
+
+ this.parseClassId(node, isStatement);
+ this.parseClassSuper(node);
+ var classBody = this.startNode();
+ var hadConstructor = false;
+ classBody.body = [];
+ this.expect(types.braceL);
+ while (this.type !== types.braceR) {
+ var element = this.parseClassElement(node.superClass !== null);
+ if (element) {
+ classBody.body.push(element);
+ if (element.type === "MethodDefinition" && element.kind === "constructor") {
+ if (hadConstructor) { this.raise(element.start, "Duplicate constructor in the same class"); }
+ hadConstructor = true;
+ }
+ }
+ }
+ this.strict = oldStrict;
+ this.next();
+ node.body = this.finishNode(classBody, "ClassBody");
+ return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
+ };
+
+ pp$1.parseClassElement = function(constructorAllowsSuper) {
+ var this$1 = this;
+
+ if (this.eat(types.semi)) { return null }
+
+ var method = this.startNode();
+ var tryContextual = function (k, noLineBreak) {
+ if ( noLineBreak === void 0 ) noLineBreak = false;
+
+ var start = this$1.start, startLoc = this$1.startLoc;
+ if (!this$1.eatContextual(k)) { return false }
+ if (this$1.type !== types.parenL && (!noLineBreak || !this$1.canInsertSemicolon())) { return true }
+ if (method.key) { this$1.unexpected(); }
+ method.computed = false;
+ method.key = this$1.startNodeAt(start, startLoc);
+ method.key.name = k;
+ this$1.finishNode(method.key, "Identifier");
+ return false
+ };
+
+ method.kind = "method";
+ method.static = tryContextual("static");
+ var isGenerator = this.eat(types.star);
+ var isAsync = false;
+ if (!isGenerator) {
+ if (this.options.ecmaVersion >= 8 && tryContextual("async", true)) {
+ isAsync = true;
+ isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
+ } else if (tryContextual("get")) {
+ method.kind = "get";
+ } else if (tryContextual("set")) {
+ method.kind = "set";
+ }
+ }
+ if (!method.key) { this.parsePropertyName(method); }
+ var key = method.key;
+ var allowsDirectSuper = false;
+ if (!method.computed && !method.static && (key.type === "Identifier" && key.name === "constructor" ||
+ key.type === "Literal" && key.value === "constructor")) {
+ if (method.kind !== "method") { this.raise(key.start, "Constructor can't have get/set modifier"); }
+ if (isGenerator) { this.raise(key.start, "Constructor can't be a generator"); }
+ if (isAsync) { this.raise(key.start, "Constructor can't be an async method"); }
+ method.kind = "constructor";
+ allowsDirectSuper = constructorAllowsSuper;
+ } else if (method.static && key.type === "Identifier" && key.name === "prototype") {
+ this.raise(key.start, "Classes may not have a static property named prototype");
+ }
+ this.parseClassMethod(method, isGenerator, isAsync, allowsDirectSuper);
+ if (method.kind === "get" && method.value.params.length !== 0)
+ { this.raiseRecoverable(method.value.start, "getter should have no params"); }
+ if (method.kind === "set" && method.value.params.length !== 1)
+ { this.raiseRecoverable(method.value.start, "setter should have exactly one param"); }
+ if (method.kind === "set" && method.value.params[0].type === "RestElement")
+ { this.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params"); }
+ return method
+ };
+
+ pp$1.parseClassMethod = function(method, isGenerator, isAsync, allowsDirectSuper) {
+ method.value = this.parseMethod(isGenerator, isAsync, allowsDirectSuper);
+ return this.finishNode(method, "MethodDefinition")
+ };
+
+ pp$1.parseClassId = function(node, isStatement) {
+ if (this.type === types.name) {
+ node.id = this.parseIdent();
+ if (isStatement)
+ { this.checkLVal(node.id, BIND_LEXICAL, false); }
+ } else {
+ if (isStatement === true)
+ { this.unexpected(); }
+ node.id = null;
+ }
+ };
+
+ pp$1.parseClassSuper = function(node) {
+ node.superClass = this.eat(types._extends) ? this.parseExprSubscripts() : null;
+ };
+
+ // Parses module export declaration.
+
+ pp$1.parseExport = function(node, exports) {
+ this.next();
+ // export * from '...'
+ if (this.eat(types.star)) {
+ if (this.options.ecmaVersion >= 11) {
+ if (this.eatContextual("as")) {
+ node.exported = this.parseIdent(true);
+ this.checkExport(exports, node.exported.name, this.lastTokStart);
+ } else {
+ node.exported = null;
+ }
+ }
+ this.expectContextual("from");
+ if (this.type !== types.string) { this.unexpected(); }
+ node.source = this.parseExprAtom();
+ this.semicolon();
+ return this.finishNode(node, "ExportAllDeclaration")
+ }
+ if (this.eat(types._default)) { // export default ...
+ this.checkExport(exports, "default", this.lastTokStart);
+ var isAsync;
+ if (this.type === types._function || (isAsync = this.isAsyncFunction())) {
+ var fNode = this.startNode();
+ this.next();
+ if (isAsync) { this.next(); }
+ node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
+ } else if (this.type === types._class) {
+ var cNode = this.startNode();
+ node.declaration = this.parseClass(cNode, "nullableID");
+ } else {
+ node.declaration = this.parseMaybeAssign();
+ this.semicolon();
+ }
+ return this.finishNode(node, "ExportDefaultDeclaration")
+ }
+ // export var|const|let|function|class ...
+ if (this.shouldParseExportStatement()) {
+ node.declaration = this.parseStatement(null);
+ if (node.declaration.type === "VariableDeclaration")
+ { this.checkVariableExport(exports, node.declaration.declarations); }
+ else
+ { this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
+ node.specifiers = [];
+ node.source = null;
+ } else { // export { x, y as z } [from '...']
+ node.declaration = null;
+ node.specifiers = this.parseExportSpecifiers(exports);
+ if (this.eatContextual("from")) {
+ if (this.type !== types.string) { this.unexpected(); }
+ node.source = this.parseExprAtom();
+ } else {
+ for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
+ // check for keywords used as local names
+ var spec = list[i];
+
+ this.checkUnreserved(spec.local);
+ // check if export is defined
+ this.checkLocalExport(spec.local);
+ }
+
+ node.source = null;
+ }
+ this.semicolon();
+ }
+ return this.finishNode(node, "ExportNamedDeclaration")
+ };
+
+ pp$1.checkExport = function(exports, name, pos) {
+ if (!exports) { return }
+ if (has(exports, name))
+ { this.raiseRecoverable(pos, "Duplicate export '" + name + "'"); }
+ exports[name] = true;
+ };
+
+ pp$1.checkPatternExport = function(exports, pat) {
+ var type = pat.type;
+ if (type === "Identifier")
+ { this.checkExport(exports, pat.name, pat.start); }
+ else if (type === "ObjectPattern")
+ { for (var i = 0, list = pat.properties; i < list.length; i += 1)
+ {
+ var prop = list[i];
+
+ this.checkPatternExport(exports, prop);
+ } }
+ else if (type === "ArrayPattern")
+ { for (var i$1 = 0, list$1 = pat.elements; i$1 < list$1.length; i$1 += 1) {
+ var elt = list$1[i$1];
+
+ if (elt) { this.checkPatternExport(exports, elt); }
+ } }
+ else if (type === "Property")
+ { this.checkPatternExport(exports, pat.value); }
+ else if (type === "AssignmentPattern")
+ { this.checkPatternExport(exports, pat.left); }
+ else if (type === "RestElement")
+ { this.checkPatternExport(exports, pat.argument); }
+ else if (type === "ParenthesizedExpression")
+ { this.checkPatternExport(exports, pat.expression); }
+ };
+
+ pp$1.checkVariableExport = function(exports, decls) {
+ if (!exports) { return }
+ for (var i = 0, list = decls; i < list.length; i += 1)
+ {
+ var decl = list[i];
+
+ this.checkPatternExport(exports, decl.id);
+ }
+ };
+
+ pp$1.shouldParseExportStatement = function() {
+ return this.type.keyword === "var" ||
+ this.type.keyword === "const" ||
+ this.type.keyword === "class" ||
+ this.type.keyword === "function" ||
+ this.isLet() ||
+ this.isAsyncFunction()
+ };
+
+ // Parses a comma-separated list of module exports.
+
+ pp$1.parseExportSpecifiers = function(exports) {
+ var nodes = [], first = true;
+ // export { x, y as z } [from '...']
+ this.expect(types.braceL);
+ while (!this.eat(types.braceR)) {
+ if (!first) {
+ this.expect(types.comma);
+ if (this.afterTrailingComma(types.braceR)) { break }
+ } else { first = false; }
+
+ var node = this.startNode();
+ node.local = this.parseIdent(true);
+ node.exported = this.eatContextual("as") ? this.parseIdent(true) : node.local;
+ this.checkExport(exports, node.exported.name, node.exported.start);
+ nodes.push(this.finishNode(node, "ExportSpecifier"));
+ }
+ return nodes
+ };
+
+ // Parses import declaration.
+
+ pp$1.parseImport = function(node) {
+ this.next();
+ // import '...'
+ if (this.type === types.string) {
+ node.specifiers = empty;
+ node.source = this.parseExprAtom();
+ } else {
+ node.specifiers = this.parseImportSpecifiers();
+ this.expectContextual("from");
+ node.source = this.type === types.string ? this.parseExprAtom() : this.unexpected();
+ }
+ this.semicolon();
+ return this.finishNode(node, "ImportDeclaration")
+ };
+
+ // Parses a comma-separated list of module imports.
+
+ pp$1.parseImportSpecifiers = function() {
+ var nodes = [], first = true;
+ if (this.type === types.name) {
+ // import defaultObj, { x, y as z } from '...'
+ var node = this.startNode();
+ node.local = this.parseIdent();
+ this.checkLVal(node.local, BIND_LEXICAL);
+ nodes.push(this.finishNode(node, "ImportDefaultSpecifier"));
+ if (!this.eat(types.comma)) { return nodes }
+ }
+ if (this.type === types.star) {
+ var node$1 = this.startNode();
+ this.next();
+ this.expectContextual("as");
+ node$1.local = this.parseIdent();
+ this.checkLVal(node$1.local, BIND_LEXICAL);
+ nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier"));
+ return nodes
+ }
+ this.expect(types.braceL);
+ while (!this.eat(types.braceR)) {
+ if (!first) {
+ this.expect(types.comma);
+ if (this.afterTrailingComma(types.braceR)) { break }
+ } else { first = false; }
+
+ var node$2 = this.startNode();
+ node$2.imported = this.parseIdent(true);
+ if (this.eatContextual("as")) {
+ node$2.local = this.parseIdent();
+ } else {
+ this.checkUnreserved(node$2.imported);
+ node$2.local = node$2.imported;
+ }
+ this.checkLVal(node$2.local, BIND_LEXICAL);
+ nodes.push(this.finishNode(node$2, "ImportSpecifier"));
+ }
+ return nodes
+ };
+
+ // Set `ExpressionStatement#directive` property for directive prologues.
+ pp$1.adaptDirectivePrologue = function(statements) {
+ for (var i = 0; i < statements.length && this.isDirectiveCandidate(statements[i]); ++i) {
+ statements[i].directive = statements[i].expression.raw.slice(1, -1);
+ }
+ };
+ pp$1.isDirectiveCandidate = function(statement) {
+ return (
+ statement.type === "ExpressionStatement" &&
+ statement.expression.type === "Literal" &&
+ typeof statement.expression.value === "string" &&
+ // Reject parenthesized strings.
+ (this.input[statement.start] === "\"" || this.input[statement.start] === "'")
+ )
+ };
+
+ var pp$2 = Parser.prototype;
+
+ // Convert existing expression atom to assignable pattern
+ // if possible.
+
+ pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
+ if (this.options.ecmaVersion >= 6 && node) {
+ switch (node.type) {
+ case "Identifier":
+ if (this.inAsync && node.name === "await")
+ { this.raise(node.start, "Cannot use 'await' as identifier inside an async function"); }
+ break
+
+ case "ObjectPattern":
+ case "ArrayPattern":
+ case "RestElement":
+ break
+
+ case "ObjectExpression":
+ node.type = "ObjectPattern";
+ if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
+ for (var i = 0, list = node.properties; i < list.length; i += 1) {
+ var prop = list[i];
+
+ this.toAssignable(prop, isBinding);
+ // Early error:
+ // AssignmentRestProperty[Yield, Await] :
+ // `...` DestructuringAssignmentTarget[Yield, Await]
+ //
+ // It is a Syntax Error if |DestructuringAssignmentTarget| is an |ArrayLiteral| or an |ObjectLiteral|.
+ if (
+ prop.type === "RestElement" &&
+ (prop.argument.type === "ArrayPattern" || prop.argument.type === "ObjectPattern")
+ ) {
+ this.raise(prop.argument.start, "Unexpected token");
+ }
+ }
+ break
+
+ case "Property":
+ // AssignmentProperty has type === "Property"
+ if (node.kind !== "init") { this.raise(node.key.start, "Object pattern can't contain getter or setter"); }
+ this.toAssignable(node.value, isBinding);
+ break
+
+ case "ArrayExpression":
+ node.type = "ArrayPattern";
+ if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
+ this.toAssignableList(node.elements, isBinding);
+ break
+
+ case "SpreadElement":
+ node.type = "RestElement";
+ this.toAssignable(node.argument, isBinding);
+ if (node.argument.type === "AssignmentPattern")
+ { this.raise(node.argument.start, "Rest elements cannot have a default value"); }
+ break
+
+ case "AssignmentExpression":
+ if (node.operator !== "=") { this.raise(node.left.end, "Only '=' operator can be used for specifying default value."); }
+ node.type = "AssignmentPattern";
+ delete node.operator;
+ this.toAssignable(node.left, isBinding);
+ // falls through to AssignmentPattern
+
+ case "AssignmentPattern":
+ break
+
+ case "ParenthesizedExpression":
+ this.toAssignable(node.expression, isBinding, refDestructuringErrors);
+ break
+
+ case "ChainExpression":
+ this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
+ break
+
+ case "MemberExpression":
+ if (!isBinding) { break }
+
+ default:
+ this.raise(node.start, "Assigning to rvalue");
+ }
+ } else if (refDestructuringErrors) { this.checkPatternErrors(refDestructuringErrors, true); }
+ return node
+ };
+
+ // Convert list of expression atoms to binding list.
+
+ pp$2.toAssignableList = function(exprList, isBinding) {
+ var end = exprList.length;
+ for (var i = 0; i < end; i++) {
+ var elt = exprList[i];
+ if (elt) { this.toAssignable(elt, isBinding); }
+ }
+ if (end) {
+ var last = exprList[end - 1];
+ if (this.options.ecmaVersion === 6 && isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier")
+ { this.unexpected(last.argument.start); }
+ }
+ return exprList
+ };
+
+ // Parses spread element.
+
+ pp$2.parseSpread = function(refDestructuringErrors) {
+ var node = this.startNode();
+ this.next();
+ node.argument = this.parseMaybeAssign(false, refDestructuringErrors);
+ return this.finishNode(node, "SpreadElement")
+ };
+
+ pp$2.parseRestBinding = function() {
+ var node = this.startNode();
+ this.next();
+
+ // RestElement inside of a function parameter must be an identifier
+ if (this.options.ecmaVersion === 6 && this.type !== types.name)
+ { this.unexpected(); }
+
+ node.argument = this.parseBindingAtom();
+
+ return this.finishNode(node, "RestElement")
+ };
+
+ // Parses lvalue (assignable) atom.
+
+ pp$2.parseBindingAtom = function() {
+ if (this.options.ecmaVersion >= 6) {
+ switch (this.type) {
+ case types.bracketL:
+ var node = this.startNode();
+ this.next();
+ node.elements = this.parseBindingList(types.bracketR, true, true);
+ return this.finishNode(node, "ArrayPattern")
+
+ case types.braceL:
+ return this.parseObj(true)
+ }
+ }
+ return this.parseIdent()
+ };
+
+ pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma) {
+ var elts = [], first = true;
+ while (!this.eat(close)) {
+ if (first) { first = false; }
+ else { this.expect(types.comma); }
+ if (allowEmpty && this.type === types.comma) {
+ elts.push(null);
+ } else if (allowTrailingComma && this.afterTrailingComma(close)) {
+ break
+ } else if (this.type === types.ellipsis) {
+ var rest = this.parseRestBinding();
+ this.parseBindingListItem(rest);
+ elts.push(rest);
+ if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
+ this.expect(close);
+ break
+ } else {
+ var elem = this.parseMaybeDefault(this.start, this.startLoc);
+ this.parseBindingListItem(elem);
+ elts.push(elem);
+ }
+ }
+ return elts
+ };
+
+ pp$2.parseBindingListItem = function(param) {
+ return param
+ };
+
+ // Parses assignment pattern around given atom if possible.
+
+ pp$2.parseMaybeDefault = function(startPos, startLoc, left) {
+ left = left || this.parseBindingAtom();
+ if (this.options.ecmaVersion < 6 || !this.eat(types.eq)) { return left }
+ var node = this.startNodeAt(startPos, startLoc);
+ node.left = left;
+ node.right = this.parseMaybeAssign();
+ return this.finishNode(node, "AssignmentPattern")
+ };
+
+ // Verify that a node is an lval — something that can be assigned
+ // to.
+ // bindingType can be either:
+ // 'var' indicating that the lval creates a 'var' binding
+ // 'let' indicating that the lval creates a lexical ('let' or 'const') binding
+ // 'none' indicating that the binding should be checked for illegal identifiers, but not for duplicate references
+
+ pp$2.checkLVal = function(expr, bindingType, checkClashes) {
+ if ( bindingType === void 0 ) bindingType = BIND_NONE;
+
+ switch (expr.type) {
+ case "Identifier":
+ if (bindingType === BIND_LEXICAL && expr.name === "let")
+ { this.raiseRecoverable(expr.start, "let is disallowed as a lexically bound name"); }
+ if (this.strict && this.reservedWordsStrictBind.test(expr.name))
+ { this.raiseRecoverable(expr.start, (bindingType ? "Binding " : "Assigning to ") + expr.name + " in strict mode"); }
+ if (checkClashes) {
+ if (has(checkClashes, expr.name))
+ { this.raiseRecoverable(expr.start, "Argument name clash"); }
+ checkClashes[expr.name] = true;
+ }
+ if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
+ break
+
+ case "ChainExpression":
+ this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
+ break
+
+ case "MemberExpression":
+ if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); }
+ break
+
+ case "ObjectPattern":
+ for (var i = 0, list = expr.properties; i < list.length; i += 1)
+ {
+ var prop = list[i];
+
+ this.checkLVal(prop, bindingType, checkClashes);
+ }
+ break
+
+ case "Property":
+ // AssignmentProperty has type === "Property"
+ this.checkLVal(expr.value, bindingType, checkClashes);
+ break
+
+ case "ArrayPattern":
+ for (var i$1 = 0, list$1 = expr.elements; i$1 < list$1.length; i$1 += 1) {
+ var elem = list$1[i$1];
+
+ if (elem) { this.checkLVal(elem, bindingType, checkClashes); }
+ }
+ break
+
+ case "AssignmentPattern":
+ this.checkLVal(expr.left, bindingType, checkClashes);
+ break
+
+ case "RestElement":
+ this.checkLVal(expr.argument, bindingType, checkClashes);
+ break
+
+ case "ParenthesizedExpression":
+ this.checkLVal(expr.expression, bindingType, checkClashes);
+ break
+
+ default:
+ this.raise(expr.start, (bindingType ? "Binding" : "Assigning to") + " rvalue");
+ }
+ };
+
+ // A recursive descent parser operates by defining functions for all
+
+ var pp$3 = Parser.prototype;
+
+ // Check if property name clashes with already added.
+ // Object/class getters and setters are not allowed to clash —
+ // either with each other or with an init property — and in
+ // strict mode, init properties are also not allowed to be repeated.
+
+ pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
+ if (this.options.ecmaVersion >= 9 && prop.type === "SpreadElement")
+ { return }
+ if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand))
+ { return }
+ var key = prop.key;
+ var name;
+ switch (key.type) {
+ case "Identifier": name = key.name; break
+ case "Literal": name = String(key.value); break
+ default: return
+ }
+ var kind = prop.kind;
+ if (this.options.ecmaVersion >= 6) {
+ if (name === "__proto__" && kind === "init") {
+ if (propHash.proto) {
+ if (refDestructuringErrors) {
+ if (refDestructuringErrors.doubleProto < 0)
+ { refDestructuringErrors.doubleProto = key.start; }
+ // Backwards-compat kludge. Can be removed in version 6.0
+ } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
+ }
+ propHash.proto = true;
+ }
+ return
+ }
+ name = "$" + name;
+ var other = propHash[name];
+ if (other) {
+ var redefinition;
+ if (kind === "init") {
+ redefinition = this.strict && other.init || other.get || other.set;
+ } else {
+ redefinition = other.init || other[kind];
+ }
+ if (redefinition)
+ { this.raiseRecoverable(key.start, "Redefinition of property"); }
+ } else {
+ other = propHash[name] = {
+ init: false,
+ get: false,
+ set: false
+ };
+ }
+ other[kind] = true;
+ };
+
+ // ### Expression parsing
+
+ // These nest, from the most general expression type at the top to
+ // 'atomic', nondivisible expression types at the bottom. Most of
+ // the functions will simply let the function(s) below them parse,
+ // and, *if* the syntactic construct they handle is present, wrap
+ // the AST node that the inner parser gave them in another node.
+
+ // Parse a full expression. The optional arguments are used to
+ // forbid the `in` operator (in for loops initalization expressions)
+ // and provide reference for storing '=' operator inside shorthand
+ // property assignment in contexts where both object expression
+ // and object pattern might appear (so it's possible to raise
+ // delayed syntax error at correct position).
+
+ pp$3.parseExpression = function(noIn, refDestructuringErrors) {
+ var startPos = this.start, startLoc = this.startLoc;
+ var expr = this.parseMaybeAssign(noIn, refDestructuringErrors);
+ if (this.type === types.comma) {
+ var node = this.startNodeAt(startPos, startLoc);
+ node.expressions = [expr];
+ while (this.eat(types.comma)) { node.expressions.push(this.parseMaybeAssign(noIn, refDestructuringErrors)); }
+ return this.finishNode(node, "SequenceExpression")
+ }
+ return expr
+ };
+
+ // Parse an assignment expression. This includes applications of
+ // operators like `+=`.
+
+ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
+ if (this.isContextual("yield")) {
+ if (this.inGenerator) { return this.parseYield(noIn) }
+ // The tokenizer will assume an expression is allowed after
+ // `yield`, but this isn't that kind of yield
+ else { this.exprAllowed = false; }
+ }
+
+ var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
+ if (refDestructuringErrors) {
+ oldParenAssign = refDestructuringErrors.parenthesizedAssign;
+ oldTrailingComma = refDestructuringErrors.trailingComma;
+ refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
+ } else {
+ refDestructuringErrors = new DestructuringErrors;
+ ownDestructuringErrors = true;
+ }
+
+ var startPos = this.start, startLoc = this.startLoc;
+ if (this.type === types.parenL || this.type === types.name)
+ { this.potentialArrowAt = this.start; }
+ var left = this.parseMaybeConditional(noIn, refDestructuringErrors);
+ if (afterLeftParse) { left = afterLeftParse.call(this, left, startPos, startLoc); }
+ if (this.type.isAssign) {
+ var node = this.startNodeAt(startPos, startLoc);
+ node.operator = this.value;
+ node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
+ if (!ownDestructuringErrors) {
+ refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
+ }
+ if (refDestructuringErrors.shorthandAssign >= node.left.start)
+ { refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
+ this.checkLVal(left);
+ this.next();
+ node.right = this.parseMaybeAssign(noIn);
+ return this.finishNode(node, "AssignmentExpression")
+ } else {
+ if (ownDestructuringErrors) { this.checkExpressionErrors(refDestructuringErrors, true); }
+ }
+ if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
+ if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
+ return left
+ };
+
+ // Parse a ternary conditional (`?:`) operator.
+
+ pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) {
+ var startPos = this.start, startLoc = this.startLoc;
+ var expr = this.parseExprOps(noIn, refDestructuringErrors);
+ if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
+ if (this.eat(types.question)) {
+ var node = this.startNodeAt(startPos, startLoc);
+ node.test = expr;
+ node.consequent = this.parseMaybeAssign();
+ this.expect(types.colon);
+ node.alternate = this.parseMaybeAssign(noIn);
+ return this.finishNode(node, "ConditionalExpression")
+ }
+ return expr
+ };
+
+ // Start the precedence parser.
+
+ pp$3.parseExprOps = function(noIn, refDestructuringErrors) {
+ var startPos = this.start, startLoc = this.startLoc;
+ var expr = this.parseMaybeUnary(refDestructuringErrors, false);
+ if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
+ return expr.start === startPos && expr.type === "ArrowFunctionExpression" ? expr : this.parseExprOp(expr, startPos, startLoc, -1, noIn)
+ };
+
+ // Parse binary operators with the operator precedence parsing
+ // algorithm. `left` is the left-hand side of the operator.
+ // `minPrec` provides context that allows the function to stop and
+ // defer further parser to one of its callers when it encounters an
+ // operator that has a lower precedence than the set it is parsing.
+
+ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
+ var prec = this.type.binop;
+ if (prec != null && (!noIn || this.type !== types._in)) {
+ if (prec > minPrec) {
+ var logical = this.type === types.logicalOR || this.type === types.logicalAND;
+ var coalesce = this.type === types.coalesce;
+ if (coalesce) {
+ // Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
+ // In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
+ prec = types.logicalAND.binop;
+ }
+ var op = this.value;
+ this.next();
+ var startPos = this.start, startLoc = this.startLoc;
+ var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
+ var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
+ if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
+ this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
+ }
+ return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
+ }
+ }
+ return left
+ };
+
+ pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) {
+ var node = this.startNodeAt(startPos, startLoc);
+ node.left = left;
+ node.operator = op;
+ node.right = right;
+ return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression")
+ };
+
+ // Parse unary operators, both prefix and postfix.
+
+ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
+ var startPos = this.start, startLoc = this.startLoc, expr;
+ if (this.isContextual("await") && (this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction))) {
+ expr = this.parseAwait();
+ sawUnary = true;
+ } else if (this.type.prefix) {
+ var node = this.startNode(), update = this.type === types.incDec;
+ node.operator = this.value;
+ node.prefix = true;
+ this.next();
+ node.argument = this.parseMaybeUnary(null, true);
+ this.checkExpressionErrors(refDestructuringErrors, true);
+ if (update) { this.checkLVal(node.argument); }
+ else if (this.strict && node.operator === "delete" &&
+ node.argument.type === "Identifier")
+ { this.raiseRecoverable(node.start, "Deleting local variable in strict mode"); }
+ else { sawUnary = true; }
+ expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
+ } else {
+ expr = this.parseExprSubscripts(refDestructuringErrors);
+ if (this.checkExpressionErrors(refDestructuringErrors)) { return expr }
+ while (this.type.postfix && !this.canInsertSemicolon()) {
+ var node$1 = this.startNodeAt(startPos, startLoc);
+ node$1.operator = this.value;
+ node$1.prefix = false;
+ node$1.argument = expr;
+ this.checkLVal(expr);
+ this.next();
+ expr = this.finishNode(node$1, "UpdateExpression");
+ }
+ }
+
+ if (!sawUnary && this.eat(types.starstar))
+ { return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) }
+ else
+ { return expr }
+ };
+
+ // Parse call, dot, and `[]`-subscript expressions.
+
+ pp$3.parseExprSubscripts = function(refDestructuringErrors) {
+ var startPos = this.start, startLoc = this.startLoc;
+ var expr = this.parseExprAtom(refDestructuringErrors);
+ if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
+ { return expr }
+ var result = this.parseSubscripts(expr, startPos, startLoc);
+ if (refDestructuringErrors && result.type === "MemberExpression") {
+ if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
+ if (refDestructuringErrors.parenthesizedBind >= result.start) { refDestructuringErrors.parenthesizedBind = -1; }
+ }
+ return result
+ };
+
+ pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
+ var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
+ this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
+ this.potentialArrowAt === base.start;
+ var optionalChained = false;
+
+ while (true) {
+ var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained);
+
+ if (element.optional) { optionalChained = true; }
+ if (element === base || element.type === "ArrowFunctionExpression") {
+ if (optionalChained) {
+ var chainNode = this.startNodeAt(startPos, startLoc);
+ chainNode.expression = element;
+ element = this.finishNode(chainNode, "ChainExpression");
+ }
+ return element
+ }
+
+ base = element;
+ }
+ };
+
+ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained) {
+ var optionalSupported = this.options.ecmaVersion >= 11;
+ var optional = optionalSupported && this.eat(types.questionDot);
+ if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
+
+ var computed = this.eat(types.bracketL);
+ if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
+ var node = this.startNodeAt(startPos, startLoc);
+ node.object = base;
+ node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
+ node.computed = !!computed;
+ if (computed) { this.expect(types.bracketR); }
+ if (optionalSupported) {
+ node.optional = optional;
+ }
+ base = this.finishNode(node, "MemberExpression");
+ } else if (!noCalls && this.eat(types.parenL)) {
+ var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
+ this.yieldPos = 0;
+ this.awaitPos = 0;
+ this.awaitIdentPos = 0;
+ var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
+ if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
+ this.checkPatternErrors(refDestructuringErrors, false);
+ this.checkYieldAwaitInDefaultParams();
+ if (this.awaitIdentPos > 0)
+ { this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"); }
+ this.yieldPos = oldYieldPos;
+ this.awaitPos = oldAwaitPos;
+ this.awaitIdentPos = oldAwaitIdentPos;
+ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList, true)
+ }
+ this.checkExpressionErrors(refDestructuringErrors, true);
+ this.yieldPos = oldYieldPos || this.yieldPos;
+ this.awaitPos = oldAwaitPos || this.awaitPos;
+ this.awaitIdentPos = oldAwaitIdentPos || this.awaitIdentPos;
+ var node$1 = this.startNodeAt(startPos, startLoc);
+ node$1.callee = base;
+ node$1.arguments = exprList;
+ if (optionalSupported) {
+ node$1.optional = optional;
+ }
+ base = this.finishNode(node$1, "CallExpression");
+ } else if (this.type === types.backQuote) {
+ if (optional || optionalChained) {
+ this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
+ }
+ var node$2 = this.startNodeAt(startPos, startLoc);
+ node$2.tag = base;
+ node$2.quasi = this.parseTemplate({isTagged: true});
+ base = this.finishNode(node$2, "TaggedTemplateExpression");
+ }
+ return base
+ };
+
+ // Parse an atomic expression — either a single token that is an
+ // expression, an expression started by a keyword like `function` or
+ // `new`, or an expression wrapped in punctuation like `()`, `[]`,
+ // or `{}`.
+
+ pp$3.parseExprAtom = function(refDestructuringErrors) {
+ // If a division operator appears in an expression position, the
+ // tokenizer got confused, and we force it to read a regexp instead.
+ if (this.type === types.slash) { this.readRegexp(); }
+
+ var node, canBeArrow = this.potentialArrowAt === this.start;
+ switch (this.type) {
+ case types._super:
+ if (!this.allowSuper)
+ { this.raise(this.start, "'super' keyword outside a method"); }
+ node = this.startNode();
+ this.next();
+ if (this.type === types.parenL && !this.allowDirectSuper)
+ { this.raise(node.start, "super() call outside constructor of a subclass"); }
+ // The `super` keyword can appear at below:
+ // SuperProperty:
+ // super [ Expression ]
+ // super . IdentifierName
+ // SuperCall:
+ // super ( Arguments )
+ if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
+ { this.unexpected(); }
+ return this.finishNode(node, "Super")
+
+ case types._this:
+ node = this.startNode();
+ this.next();
+ return this.finishNode(node, "ThisExpression")
+
+ case types.name:
+ var startPos = this.start, startLoc = this.startLoc, containsEsc = this.containsEsc;
+ var id = this.parseIdent(false);
+ if (this.options.ecmaVersion >= 8 && !containsEsc && id.name === "async" && !this.canInsertSemicolon() && this.eat(types._function))
+ { return this.parseFunction(this.startNodeAt(startPos, startLoc), 0, false, true) }
+ if (canBeArrow && !this.canInsertSemicolon()) {
+ if (this.eat(types.arrow))
+ { return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) }
+ if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === types.name && !containsEsc) {
+ id = this.parseIdent(false);
+ if (this.canInsertSemicolon() || !this.eat(types.arrow))
+ { this.unexpected(); }
+ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true)
+ }
+ }
+ return id
+
+ case types.regexp:
+ var value = this.value;
+ node = this.parseLiteral(value.value);
+ node.regex = {pattern: value.pattern, flags: value.flags};
+ return node
+
+ case types.num: case types.string:
+ return this.parseLiteral(this.value)
+
+ case types._null: case types._true: case types._false:
+ node = this.startNode();
+ node.value = this.type === types._null ? null : this.type === types._true;
+ node.raw = this.type.keyword;
+ this.next();
+ return this.finishNode(node, "Literal")
+
+ case types.parenL:
+ var start = this.start, expr = this.parseParenAndDistinguishExpression(canBeArrow);
+ if (refDestructuringErrors) {
+ if (refDestructuringErrors.parenthesizedAssign < 0 && !this.isSimpleAssignTarget(expr))
+ { refDestructuringErrors.parenthesizedAssign = start; }
+ if (refDestructuringErrors.parenthesizedBind < 0)
+ { refDestructuringErrors.parenthesizedBind = start; }
+ }
+ return expr
+
+ case types.bracketL:
+ node = this.startNode();
+ this.next();
+ node.elements = this.parseExprList(types.bracketR, true, true, refDestructuringErrors);
+ return this.finishNode(node, "ArrayExpression")
+
+ case types.braceL:
+ return this.parseObj(false, refDestructuringErrors)
+
+ case types._function:
+ node = this.startNode();
+ this.next();
+ return this.parseFunction(node, 0)
+
+ case types._class:
+ return this.parseClass(this.startNode(), false)
+
+ case types._new:
+ return this.parseNew()
+
+ case types.backQuote:
+ return this.parseTemplate()
+
+ case types._import:
+ if (this.options.ecmaVersion >= 11) {
+ return this.parseExprImport()
+ } else {
+ return this.unexpected()
+ }
+
+ default:
+ this.unexpected();
+ }
+ };
+
+ pp$3.parseExprImport = function() {
+ var node = this.startNode();
+
+ // Consume `import` as an identifier for `import.meta`.
+ // Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
+ if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
+ var meta = this.parseIdent(true);
+
+ switch (this.type) {
+ case types.parenL:
+ return this.parseDynamicImport(node)
+ case types.dot:
+ node.meta = meta;
+ return this.parseImportMeta(node)
+ default:
+ this.unexpected();
+ }
+ };
+
+ pp$3.parseDynamicImport = function(node) {
+ this.next(); // skip `(`
+
+ // Parse node.source.
+ node.source = this.parseMaybeAssign();
+
+ // Verify ending.
+ if (!this.eat(types.parenR)) {
+ var errorPos = this.start;
+ if (this.eat(types.comma) && this.eat(types.parenR)) {
+ this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
+ } else {
+ this.unexpected(errorPos);
+ }
+ }
+
+ return this.finishNode(node, "ImportExpression")
+ };
+
+ pp$3.parseImportMeta = function(node) {
+ this.next(); // skip `.`
+
+ var containsEsc = this.containsEsc;
+ node.property = this.parseIdent(true);
+
+ if (node.property.name !== "meta")
+ { this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
+ if (containsEsc)
+ { this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
+ if (this.options.sourceType !== "module")
+ { this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
+
+ return this.finishNode(node, "MetaProperty")
+ };
+
+ pp$3.parseLiteral = function(value) {
+ var node = this.startNode();
+ node.value = value;
+ node.raw = this.input.slice(this.start, this.end);
+ if (node.raw.charCodeAt(node.raw.length - 1) === 110) { node.bigint = node.raw.slice(0, -1).replace(/_/g, ""); }
+ this.next();
+ return this.finishNode(node, "Literal")
+ };
+
+ pp$3.parseParenExpression = function() {
+ this.expect(types.parenL);
+ var val = this.parseExpression();
+ this.expect(types.parenR);
+ return val
+ };
+
+ pp$3.parseParenAndDistinguishExpression = function(canBeArrow) {
+ var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8;
+ if (this.options.ecmaVersion >= 6) {
+ this.next();
+
+ var innerStartPos = this.start, innerStartLoc = this.startLoc;
+ var exprList = [], first = true, lastIsComma = false;
+ var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart;
+ this.yieldPos = 0;
+ this.awaitPos = 0;
+ // Do not save awaitIdentPos to allow checking awaits nested in parameters
+ while (this.type !== types.parenR) {
+ first ? first = false : this.expect(types.comma);
+ if (allowTrailingComma && this.afterTrailingComma(types.parenR, true)) {
+ lastIsComma = true;
+ break
+ } else if (this.type === types.ellipsis) {
+ spreadStart = this.start;
+ exprList.push(this.parseParenItem(this.parseRestBinding()));
+ if (this.type === types.comma) { this.raise(this.start, "Comma is not permitted after the rest element"); }
+ break
+ } else {
+ exprList.push(this.parseMaybeAssign(false, refDestructuringErrors, this.parseParenItem));
+ }
+ }
+ var innerEndPos = this.start, innerEndLoc = this.startLoc;
+ this.expect(types.parenR);
+
+ if (canBeArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) {
+ this.checkPatternErrors(refDestructuringErrors, false);
+ this.checkYieldAwaitInDefaultParams();
+ this.yieldPos = oldYieldPos;
+ this.awaitPos = oldAwaitPos;
+ return this.parseParenArrowList(startPos, startLoc, exprList)
+ }
+
+ if (!exprList.length || lastIsComma) { this.unexpected(this.lastTokStart); }
+ if (spreadStart) { this.unexpected(spreadStart); }
+ this.checkExpressionErrors(refDestructuringErrors, true);
+ this.yieldPos = oldYieldPos || this.yieldPos;
+ this.awaitPos = oldAwaitPos || this.awaitPos;
+
+ if (exprList.length > 1) {
+ val = this.startNodeAt(innerStartPos, innerStartLoc);
+ val.expressions = exprList;
+ this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc);
+ } else {
+ val = exprList[0];
+ }
+ } else {
+ val = this.parseParenExpression();
+ }
+
+ if (this.options.preserveParens) {
+ var par = this.startNodeAt(startPos, startLoc);
+ par.expression = val;
+ return this.finishNode(par, "ParenthesizedExpression")
+ } else {
+ return val
+ }
+ };
+
+ pp$3.parseParenItem = function(item) {
+ return item
+ };
+
+ pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
+ return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList)
+ };
+
+ // New's precedence is slightly tricky. It must allow its argument to
+ // be a `[]` or dot subscript expression, but not a call — at least,
+ // not without wrapping it in parentheses. Thus, it uses the noCalls
+ // argument to parseSubscripts to prevent it from consuming the
+ // argument list.
+
+ var empty$1 = [];
+
+ pp$3.parseNew = function() {
+ if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
+ var node = this.startNode();
+ var meta = this.parseIdent(true);
+ if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
+ node.meta = meta;
+ var containsEsc = this.containsEsc;
+ node.property = this.parseIdent(true);
+ if (node.property.name !== "target")
+ { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
+ if (containsEsc)
+ { this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
+ if (!this.inNonArrowFunction())
+ { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); }
+ return this.finishNode(node, "MetaProperty")
+ }
+ var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
+ node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
+ if (isImport && node.callee.type === "ImportExpression") {
+ this.raise(startPos, "Cannot use new with import()");
+ }
+ if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
+ else { node.arguments = empty$1; }
+ return this.finishNode(node, "NewExpression")
+ };
+
+ // Parse template expression.
+
+ pp$3.parseTemplateElement = function(ref) {
+ var isTagged = ref.isTagged;
+
+ var elem = this.startNode();
+ if (this.type === types.invalidTemplate) {
+ if (!isTagged) {
+ this.raiseRecoverable(this.start, "Bad escape sequence in untagged template literal");
+ }
+ elem.value = {
+ raw: this.value,
+ cooked: null
+ };
+ } else {
+ elem.value = {
+ raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, "\n"),
+ cooked: this.value
+ };
+ }
+ this.next();
+ elem.tail = this.type === types.backQuote;
+ return this.finishNode(elem, "TemplateElement")
+ };
+
+ pp$3.parseTemplate = function(ref) {
+ if ( ref === void 0 ) ref = {};
+ var isTagged = ref.isTagged; if ( isTagged === void 0 ) isTagged = false;
+
+ var node = this.startNode();
+ this.next();
+ node.expressions = [];
+ var curElt = this.parseTemplateElement({isTagged: isTagged});
+ node.quasis = [curElt];
+ while (!curElt.tail) {
+ if (this.type === types.eof) { this.raise(this.pos, "Unterminated template literal"); }
+ this.expect(types.dollarBraceL);
+ node.expressions.push(this.parseExpression());
+ this.expect(types.braceR);
+ node.quasis.push(curElt = this.parseTemplateElement({isTagged: isTagged}));
+ }
+ this.next();
+ return this.finishNode(node, "TemplateLiteral")
+ };
+
+ pp$3.isAsyncProp = function(prop) {
+ return !prop.computed && prop.key.type === "Identifier" && prop.key.name === "async" &&
+ (this.type === types.name || this.type === types.num || this.type === types.string || this.type === types.bracketL || this.type.keyword || (this.options.ecmaVersion >= 9 && this.type === types.star)) &&
+ !lineBreak.test(this.input.slice(this.lastTokEnd, this.start))
+ };
+
+ // Parse an object literal or binding pattern.
+
+ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
+ var node = this.startNode(), first = true, propHash = {};
+ node.properties = [];
+ this.next();
+ while (!this.eat(types.braceR)) {
+ if (!first) {
+ this.expect(types.comma);
+ if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
+ } else { first = false; }
+
+ var prop = this.parseProperty(isPattern, refDestructuringErrors);
+ if (!isPattern) { this.checkPropClash(prop, propHash, refDestructuringErrors); }
+ node.properties.push(prop);
+ }
+ return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression")
+ };
+
+ pp$3.parseProperty = function(isPattern, refDestructuringErrors) {
+ var prop = this.startNode(), isGenerator, isAsync, startPos, startLoc;
+ if (this.options.ecmaVersion >= 9 && this.eat(types.ellipsis)) {
+ if (isPattern) {
+ prop.argument = this.parseIdent(false);
+ if (this.type === types.comma) {
+ this.raise(this.start, "Comma is not permitted after the rest element");
+ }
+ return this.finishNode(prop, "RestElement")
+ }
+ // To disallow parenthesized identifier via `this.toAssignable()`.
+ if (this.type === types.parenL && refDestructuringErrors) {
+ if (refDestructuringErrors.parenthesizedAssign < 0) {
+ refDestructuringErrors.parenthesizedAssign = this.start;
+ }
+ if (refDestructuringErrors.parenthesizedBind < 0) {
+ refDestructuringErrors.parenthesizedBind = this.start;
+ }
+ }
+ // Parse argument.
+ prop.argument = this.parseMaybeAssign(false, refDestructuringErrors);
+ // To disallow trailing comma via `this.toAssignable()`.
+ if (this.type === types.comma && refDestructuringErrors && refDestructuringErrors.trailingComma < 0) {
+ refDestructuringErrors.trailingComma = this.start;
+ }
+ // Finish
+ return this.finishNode(prop, "SpreadElement")
+ }
+ if (this.options.ecmaVersion >= 6) {
+ prop.method = false;
+ prop.shorthand = false;
+ if (isPattern || refDestructuringErrors) {
+ startPos = this.start;
+ startLoc = this.startLoc;
+ }
+ if (!isPattern)
+ { isGenerator = this.eat(types.star); }
+ }
+ var containsEsc = this.containsEsc;
+ this.parsePropertyName(prop);
+ if (!isPattern && !containsEsc && this.options.ecmaVersion >= 8 && !isGenerator && this.isAsyncProp(prop)) {
+ isAsync = true;
+ isGenerator = this.options.ecmaVersion >= 9 && this.eat(types.star);
+ this.parsePropertyName(prop, refDestructuringErrors);
+ } else {
+ isAsync = false;
+ }
+ this.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc);
+ return this.finishNode(prop, "Property")
+ };
+
+ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors, containsEsc) {
+ if ((isGenerator || isAsync) && this.type === types.colon)
+ { this.unexpected(); }
+
+ if (this.eat(types.colon)) {
+ prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors);
+ prop.kind = "init";
+ } else if (this.options.ecmaVersion >= 6 && this.type === types.parenL) {
+ if (isPattern) { this.unexpected(); }
+ prop.kind = "init";
+ prop.method = true;
+ prop.value = this.parseMethod(isGenerator, isAsync);
+ } else if (!isPattern && !containsEsc &&
+ this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
+ (prop.key.name === "get" || prop.key.name === "set") &&
+ (this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
+ if (isGenerator || isAsync) { this.unexpected(); }
+ prop.kind = prop.key.name;
+ this.parsePropertyName(prop);
+ prop.value = this.parseMethod(false);
+ var paramCount = prop.kind === "get" ? 0 : 1;
+ if (prop.value.params.length !== paramCount) {
+ var start = prop.value.start;
+ if (prop.kind === "get")
+ { this.raiseRecoverable(start, "getter should have no params"); }
+ else
+ { this.raiseRecoverable(start, "setter should have exactly one param"); }
+ } else {
+ if (prop.kind === "set" && prop.value.params[0].type === "RestElement")
+ { this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params"); }
+ }
+ } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") {
+ if (isGenerator || isAsync) { this.unexpected(); }
+ this.checkUnreserved(prop.key);
+ if (prop.key.name === "await" && !this.awaitIdentPos)
+ { this.awaitIdentPos = startPos; }
+ prop.kind = "init";
+ if (isPattern) {
+ prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
+ } else if (this.type === types.eq && refDestructuringErrors) {
+ if (refDestructuringErrors.shorthandAssign < 0)
+ { refDestructuringErrors.shorthandAssign = this.start; }
+ prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key);
+ } else {
+ prop.value = prop.key;
+ }
+ prop.shorthand = true;
+ } else { this.unexpected(); }
+ };
+
+ pp$3.parsePropertyName = function(prop) {
+ if (this.options.ecmaVersion >= 6) {
+ if (this.eat(types.bracketL)) {
+ prop.computed = true;
+ prop.key = this.parseMaybeAssign();
+ this.expect(types.bracketR);
+ return prop.key
+ } else {
+ prop.computed = false;
+ }
+ }
+ return prop.key = this.type === types.num || this.type === types.string ? this.parseExprAtom() : this.parseIdent(this.options.allowReserved !== "never")
+ };
+
+ // Initialize empty function node.
+
+ pp$3.initFunction = function(node) {
+ node.id = null;
+ if (this.options.ecmaVersion >= 6) { node.generator = node.expression = false; }
+ if (this.options.ecmaVersion >= 8) { node.async = false; }
+ };
+
+ // Parse object or class method.
+
+ pp$3.parseMethod = function(isGenerator, isAsync, allowDirectSuper) {
+ var node = this.startNode(), oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
+
+ this.initFunction(node);
+ if (this.options.ecmaVersion >= 6)
+ { node.generator = isGenerator; }
+ if (this.options.ecmaVersion >= 8)
+ { node.async = !!isAsync; }
+
+ this.yieldPos = 0;
+ this.awaitPos = 0;
+ this.awaitIdentPos = 0;
+ this.enterScope(functionFlags(isAsync, node.generator) | SCOPE_SUPER | (allowDirectSuper ? SCOPE_DIRECT_SUPER : 0));
+
+ this.expect(types.parenL);
+ node.params = this.parseBindingList(types.parenR, false, this.options.ecmaVersion >= 8);
+ this.checkYieldAwaitInDefaultParams();
+ this.parseFunctionBody(node, false, true);
+
+ this.yieldPos = oldYieldPos;
+ this.awaitPos = oldAwaitPos;
+ this.awaitIdentPos = oldAwaitIdentPos;
+ return this.finishNode(node, "FunctionExpression")
+ };
+
+ // Parse arrow function expression with given parameters.
+
+ pp$3.parseArrowExpression = function(node, params, isAsync) {
+ var oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
+
+ this.enterScope(functionFlags(isAsync, false) | SCOPE_ARROW);
+ this.initFunction(node);
+ if (this.options.ecmaVersion >= 8) { node.async = !!isAsync; }
+
+ this.yieldPos = 0;
+ this.awaitPos = 0;
+ this.awaitIdentPos = 0;
+
+ node.params = this.toAssignableList(params, true);
+ this.parseFunctionBody(node, true, false);
+
+ this.yieldPos = oldYieldPos;
+ this.awaitPos = oldAwaitPos;
+ this.awaitIdentPos = oldAwaitIdentPos;
+ return this.finishNode(node, "ArrowFunctionExpression")
+ };
+
+ // Parse function body and check parameters.
+
+ pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) {
+ var isExpression = isArrowFunction && this.type !== types.braceL;
+ var oldStrict = this.strict, useStrict = false;
+
+ if (isExpression) {
+ node.body = this.parseMaybeAssign();
+ node.expression = true;
+ this.checkParams(node, false);
+ } else {
+ var nonSimple = this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params);
+ if (!oldStrict || nonSimple) {
+ useStrict = this.strictDirective(this.end);
+ // If this is a strict mode function, verify that argument names
+ // are not repeated, and it does not try to bind the words `eval`
+ // or `arguments`.
+ if (useStrict && nonSimple)
+ { this.raiseRecoverable(node.start, "Illegal 'use strict' directive in function with non-simple parameter list"); }
+ }
+ // Start a new scope with regard to labels and the `inFunction`
+ // flag (restore them to their old value afterwards).
+ var oldLabels = this.labels;
+ this.labels = [];
+ if (useStrict) { this.strict = true; }
+
+ // Add the params to varDeclaredNames to ensure that an error is thrown
+ // if a let/const declaration in the function clashes with one of the params.
+ this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
+ // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
+ if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); }
+ node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
+ node.expression = false;
+ this.adaptDirectivePrologue(node.body.body);
+ this.labels = oldLabels;
+ }
+ this.exitScope();
+ };
+
+ pp$3.isSimpleParamList = function(params) {
+ for (var i = 0, list = params; i < list.length; i += 1)
+ {
+ var param = list[i];
+
+ if (param.type !== "Identifier") { return false
+ } }
+ return true
+ };
+
+ // Checks function params for various disallowed patterns such as using "eval"
+ // or "arguments" and duplicate parameters.
+
+ pp$3.checkParams = function(node, allowDuplicates) {
+ var nameHash = {};
+ for (var i = 0, list = node.params; i < list.length; i += 1)
+ {
+ var param = list[i];
+
+ this.checkLVal(param, BIND_VAR, allowDuplicates ? null : nameHash);
+ }
+ };
+
+ // Parses a comma-separated list of expressions, and returns them as
+ // an array. `close` is the token type that ends the list, and
+ // `allowEmpty` can be turned on to allow subsequent commas with
+ // nothing in between them to be parsed as `null` (which is needed
+ // for array literals).
+
+ pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) {
+ var elts = [], first = true;
+ while (!this.eat(close)) {
+ if (!first) {
+ this.expect(types.comma);
+ if (allowTrailingComma && this.afterTrailingComma(close)) { break }
+ } else { first = false; }
+
+ var elt = (void 0);
+ if (allowEmpty && this.type === types.comma)
+ { elt = null; }
+ else if (this.type === types.ellipsis) {
+ elt = this.parseSpread(refDestructuringErrors);
+ if (refDestructuringErrors && this.type === types.comma && refDestructuringErrors.trailingComma < 0)
+ { refDestructuringErrors.trailingComma = this.start; }
+ } else {
+ elt = this.parseMaybeAssign(false, refDestructuringErrors);
+ }
+ elts.push(elt);
+ }
+ return elts
+ };
+
+ pp$3.checkUnreserved = function(ref) {
+ var start = ref.start;
+ var end = ref.end;
+ var name = ref.name;
+
+ if (this.inGenerator && name === "yield")
+ { this.raiseRecoverable(start, "Cannot use 'yield' as identifier inside a generator"); }
+ if (this.inAsync && name === "await")
+ { this.raiseRecoverable(start, "Cannot use 'await' as identifier inside an async function"); }
+ if (this.keywords.test(name))
+ { this.raise(start, ("Unexpected keyword '" + name + "'")); }
+ if (this.options.ecmaVersion < 6 &&
+ this.input.slice(start, end).indexOf("\\") !== -1) { return }
+ var re = this.strict ? this.reservedWordsStrict : this.reservedWords;
+ if (re.test(name)) {
+ if (!this.inAsync && name === "await")
+ { this.raiseRecoverable(start, "Cannot use keyword 'await' outside an async function"); }
+ this.raiseRecoverable(start, ("The keyword '" + name + "' is reserved"));
+ }
+ };
+
+ // Parse the next token as an identifier. If `liberal` is true (used
+ // when parsing properties), it will also convert keywords into
+ // identifiers.
+
+ pp$3.parseIdent = function(liberal, isBinding) {
+ var node = this.startNode();
+ if (this.type === types.name) {
+ node.name = this.value;
+ } else if (this.type.keyword) {
+ node.name = this.type.keyword;
+
+ // To fix https://github.com/acornjs/acorn/issues/575
+ // `class` and `function` keywords push new context into this.context.
+ // But there is no chance to pop the context if the keyword is consumed as an identifier such as a property name.
+ // If the previous token is a dot, this does not apply because the context-managing code already ignored the keyword
+ if ((node.name === "class" || node.name === "function") &&
+ (this.lastTokEnd !== this.lastTokStart + 1 || this.input.charCodeAt(this.lastTokStart) !== 46)) {
+ this.context.pop();
+ }
+ } else {
+ this.unexpected();
+ }
+ this.next(!!liberal);
+ this.finishNode(node, "Identifier");
+ if (!liberal) {
+ this.checkUnreserved(node);
+ if (node.name === "await" && !this.awaitIdentPos)
+ { this.awaitIdentPos = node.start; }
+ }
+ return node
+ };
+
+ // Parses yield expression inside generator.
+
+ pp$3.parseYield = function(noIn) {
+ if (!this.yieldPos) { this.yieldPos = this.start; }
+
+ var node = this.startNode();
+ this.next();
+ if (this.type === types.semi || this.canInsertSemicolon() || (this.type !== types.star && !this.type.startsExpr)) {
+ node.delegate = false;
+ node.argument = null;
+ } else {
+ node.delegate = this.eat(types.star);
+ node.argument = this.parseMaybeAssign(noIn);
+ }
+ return this.finishNode(node, "YieldExpression")
+ };
+
+ pp$3.parseAwait = function() {
+ if (!this.awaitPos) { this.awaitPos = this.start; }
+
+ var node = this.startNode();
+ this.next();
+ node.argument = this.parseMaybeUnary(null, false);
+ return this.finishNode(node, "AwaitExpression")
+ };
+
+ var pp$4 = Parser.prototype;
+
+ // This function is used to raise exceptions on parse errors. It
+ // takes an offset integer (into the current `input`) to indicate
+ // the location of the error, attaches the position to the end
+ // of the error message, and then raises a `SyntaxError` with that
+ // message.
+
+ pp$4.raise = function(pos, message) {
+ var loc = getLineInfo(this.input, pos);
+ message += " (" + loc.line + ":" + loc.column + ")";
+ var err = new SyntaxError(message);
+ err.pos = pos; err.loc = loc; err.raisedAt = this.pos;
+ throw err
+ };
+
+ pp$4.raiseRecoverable = pp$4.raise;
+
+ pp$4.curPosition = function() {
+ if (this.options.locations) {
+ return new Position(this.curLine, this.pos - this.lineStart)
+ }
+ };
+
+ var pp$5 = Parser.prototype;
+
+ var Scope = function Scope(flags) {
+ this.flags = flags;
+ // A list of var-declared names in the current lexical scope
+ this.var = [];
+ // A list of lexically-declared names in the current lexical scope
+ this.lexical = [];
+ // A list of lexically-declared FunctionDeclaration names in the current lexical scope
+ this.functions = [];
+ };
+
+ // The functions in this module keep track of declared variables in the current scope in order to detect duplicate variable names.
+
+ pp$5.enterScope = function(flags) {
+ this.scopeStack.push(new Scope(flags));
+ };
+
+ pp$5.exitScope = function() {
+ this.scopeStack.pop();
+ };
+
+ // The spec says:
+ // > At the top level of a function, or script, function declarations are
+ // > treated like var declarations rather than like lexical declarations.
+ pp$5.treatFunctionsAsVarInScope = function(scope) {
+ return (scope.flags & SCOPE_FUNCTION) || !this.inModule && (scope.flags & SCOPE_TOP)
+ };
+
+ pp$5.declareName = function(name, bindingType, pos) {
+ var redeclared = false;
+ if (bindingType === BIND_LEXICAL) {
+ var scope = this.currentScope();
+ redeclared = scope.lexical.indexOf(name) > -1 || scope.functions.indexOf(name) > -1 || scope.var.indexOf(name) > -1;
+ scope.lexical.push(name);
+ if (this.inModule && (scope.flags & SCOPE_TOP))
+ { delete this.undefinedExports[name]; }
+ } else if (bindingType === BIND_SIMPLE_CATCH) {
+ var scope$1 = this.currentScope();
+ scope$1.lexical.push(name);
+ } else if (bindingType === BIND_FUNCTION) {
+ var scope$2 = this.currentScope();
+ if (this.treatFunctionsAsVar)
+ { redeclared = scope$2.lexical.indexOf(name) > -1; }
+ else
+ { redeclared = scope$2.lexical.indexOf(name) > -1 || scope$2.var.indexOf(name) > -1; }
+ scope$2.functions.push(name);
+ } else {
+ for (var i = this.scopeStack.length - 1; i >= 0; --i) {
+ var scope$3 = this.scopeStack[i];
+ if (scope$3.lexical.indexOf(name) > -1 && !((scope$3.flags & SCOPE_SIMPLE_CATCH) && scope$3.lexical[0] === name) ||
+ !this.treatFunctionsAsVarInScope(scope$3) && scope$3.functions.indexOf(name) > -1) {
+ redeclared = true;
+ break
+ }
+ scope$3.var.push(name);
+ if (this.inModule && (scope$3.flags & SCOPE_TOP))
+ { delete this.undefinedExports[name]; }
+ if (scope$3.flags & SCOPE_VAR) { break }
+ }
+ }
+ if (redeclared) { this.raiseRecoverable(pos, ("Identifier '" + name + "' has already been declared")); }
+ };
+
+ pp$5.checkLocalExport = function(id) {
+ // scope.functions must be empty as Module code is always strict.
+ if (this.scopeStack[0].lexical.indexOf(id.name) === -1 &&
+ this.scopeStack[0].var.indexOf(id.name) === -1) {
+ this.undefinedExports[id.name] = id;
+ }
+ };
+
+ pp$5.currentScope = function() {
+ return this.scopeStack[this.scopeStack.length - 1]
+ };
+
+ pp$5.currentVarScope = function() {
+ for (var i = this.scopeStack.length - 1;; i--) {
+ var scope = this.scopeStack[i];
+ if (scope.flags & SCOPE_VAR) { return scope }
+ }
+ };
+
+ // Could be useful for `this`, `new.target`, `super()`, `super.property`, and `super[property]`.
+ pp$5.currentThisScope = function() {
+ for (var i = this.scopeStack.length - 1;; i--) {
+ var scope = this.scopeStack[i];
+ if (scope.flags & SCOPE_VAR && !(scope.flags & SCOPE_ARROW)) { return scope }
+ }
+ };
+
+ var Node = function Node(parser, pos, loc) {
+ this.type = "";
+ this.start = pos;
+ this.end = 0;
+ if (parser.options.locations)
+ { this.loc = new SourceLocation(parser, loc); }
+ if (parser.options.directSourceFile)
+ { this.sourceFile = parser.options.directSourceFile; }
+ if (parser.options.ranges)
+ { this.range = [pos, 0]; }
+ };
+
+ // Start an AST node, attaching a start offset.
+
+ var pp$6 = Parser.prototype;
+
+ pp$6.startNode = function() {
+ return new Node(this, this.start, this.startLoc)
+ };
+
+ pp$6.startNodeAt = function(pos, loc) {
+ return new Node(this, pos, loc)
+ };
+
+ // Finish an AST node, adding `type` and `end` properties.
+
+ function finishNodeAt(node, type, pos, loc) {
+ node.type = type;
+ node.end = pos;
+ if (this.options.locations)
+ { node.loc.end = loc; }
+ if (this.options.ranges)
+ { node.range[1] = pos; }
+ return node
+ }
+
+ pp$6.finishNode = function(node, type) {
+ return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc)
+ };
+
+ // Finish node at given position
+
+ pp$6.finishNodeAt = function(node, type, pos, loc) {
+ return finishNodeAt.call(this, node, type, pos, loc)
+ };
+
+ // The algorithm used to determine whether a regexp can appear at a
+
+ var TokContext = function TokContext(token, isExpr, preserveSpace, override, generator) {
+ this.token = token;
+ this.isExpr = !!isExpr;
+ this.preserveSpace = !!preserveSpace;
+ this.override = override;
+ this.generator = !!generator;
+ };
+
+ var types$1 = {
+ b_stat: new TokContext("{", false),
+ b_expr: new TokContext("{", true),
+ b_tmpl: new TokContext("${", false),
+ p_stat: new TokContext("(", false),
+ p_expr: new TokContext("(", true),
+ q_tmpl: new TokContext("`", true, true, function (p) { return p.tryReadTemplateToken(); }),
+ f_stat: new TokContext("function", false),
+ f_expr: new TokContext("function", true),
+ f_expr_gen: new TokContext("function", true, false, null, true),
+ f_gen: new TokContext("function", false, false, null, true)
+ };
+
+ var pp$7 = Parser.prototype;
+
+ pp$7.initialContext = function() {
+ return [types$1.b_stat]
+ };
+
+ pp$7.braceIsBlock = function(prevType) {
+ var parent = this.curContext();
+ if (parent === types$1.f_expr || parent === types$1.f_stat)
+ { return true }
+ if (prevType === types.colon && (parent === types$1.b_stat || parent === types$1.b_expr))
+ { return !parent.isExpr }
+
+ // The check for `tt.name && exprAllowed` detects whether we are
+ // after a `yield` or `of` construct. See the `updateContext` for
+ // `tt.name`.
+ if (prevType === types._return || prevType === types.name && this.exprAllowed)
+ { return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) }
+ if (prevType === types._else || prevType === types.semi || prevType === types.eof || prevType === types.parenR || prevType === types.arrow)
+ { return true }
+ if (prevType === types.braceL)
+ { return parent === types$1.b_stat }
+ if (prevType === types._var || prevType === types._const || prevType === types.name)
+ { return false }
+ return !this.exprAllowed
+ };
+
+ pp$7.inGeneratorContext = function() {
+ for (var i = this.context.length - 1; i >= 1; i--) {
+ var context = this.context[i];
+ if (context.token === "function")
+ { return context.generator }
+ }
+ return false
+ };
+
+ pp$7.updateContext = function(prevType) {
+ var update, type = this.type;
+ if (type.keyword && prevType === types.dot)
+ { this.exprAllowed = false; }
+ else if (update = type.updateContext)
+ { update.call(this, prevType); }
+ else
+ { this.exprAllowed = type.beforeExpr; }
+ };
+
+ // Token-specific context update code
+
+ types.parenR.updateContext = types.braceR.updateContext = function() {
+ if (this.context.length === 1) {
+ this.exprAllowed = true;
+ return
+ }
+ var out = this.context.pop();
+ if (out === types$1.b_stat && this.curContext().token === "function") {
+ out = this.context.pop();
+ }
+ this.exprAllowed = !out.isExpr;
+ };
+
+ types.braceL.updateContext = function(prevType) {
+ this.context.push(this.braceIsBlock(prevType) ? types$1.b_stat : types$1.b_expr);
+ this.exprAllowed = true;
+ };
+
+ types.dollarBraceL.updateContext = function() {
+ this.context.push(types$1.b_tmpl);
+ this.exprAllowed = true;
+ };
+
+ types.parenL.updateContext = function(prevType) {
+ var statementParens = prevType === types._if || prevType === types._for || prevType === types._with || prevType === types._while;
+ this.context.push(statementParens ? types$1.p_stat : types$1.p_expr);
+ this.exprAllowed = true;
+ };
+
+ types.incDec.updateContext = function() {
+ // tokExprAllowed stays unchanged
+ };
+
+ types._function.updateContext = types._class.updateContext = function(prevType) {
+ if (prevType.beforeExpr && prevType !== types.semi && prevType !== types._else &&
+ !(prevType === types._return && lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) &&
+ !((prevType === types.colon || prevType === types.braceL) && this.curContext() === types$1.b_stat))
+ { this.context.push(types$1.f_expr); }
+ else
+ { this.context.push(types$1.f_stat); }
+ this.exprAllowed = false;
+ };
+
+ types.backQuote.updateContext = function() {
+ if (this.curContext() === types$1.q_tmpl)
+ { this.context.pop(); }
+ else
+ { this.context.push(types$1.q_tmpl); }
+ this.exprAllowed = false;
+ };
+
+ types.star.updateContext = function(prevType) {
+ if (prevType === types._function) {
+ var index = this.context.length - 1;
+ if (this.context[index] === types$1.f_expr)
+ { this.context[index] = types$1.f_expr_gen; }
+ else
+ { this.context[index] = types$1.f_gen; }
+ }
+ this.exprAllowed = true;
+ };
+
+ types.name.updateContext = function(prevType) {
+ var allowed = false;
+ if (this.options.ecmaVersion >= 6 && prevType !== types.dot) {
+ if (this.value === "of" && !this.exprAllowed ||
+ this.value === "yield" && this.inGeneratorContext())
+ { allowed = true; }
+ }
+ this.exprAllowed = allowed;
+ };
+
+ // This file contains Unicode properties extracted from the ECMAScript
+ // specification. The lists are extracted like so:
+ // $$('#table-binary-unicode-properties > figure > table > tbody > tr > td:nth-child(1) code').map(el => el.innerText)
+
+ // #table-binary-unicode-properties
+ var ecma9BinaryProperties = "ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS";
+ var ecma10BinaryProperties = ecma9BinaryProperties + " Extended_Pictographic";
+ var ecma11BinaryProperties = ecma10BinaryProperties;
+ var unicodeBinaryProperties = {
+ 9: ecma9BinaryProperties,
+ 10: ecma10BinaryProperties,
+ 11: ecma11BinaryProperties
+ };
+
+ // #table-unicode-general-category-values
+ var unicodeGeneralCategoryValues = "Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu";
+
+ // #table-unicode-script-values
+ var ecma9ScriptValues = "Adlam Adlm Ahom Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb";
+ var ecma10ScriptValues = ecma9ScriptValues + " Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd";
+ var ecma11ScriptValues = ecma10ScriptValues + " Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho";
+ var unicodeScriptValues = {
+ 9: ecma9ScriptValues,
+ 10: ecma10ScriptValues,
+ 11: ecma11ScriptValues
+ };
+
+ var data = {};
+ function buildUnicodeData(ecmaVersion) {
+ var d = data[ecmaVersion] = {
+ binary: wordsRegexp(unicodeBinaryProperties[ecmaVersion] + " " + unicodeGeneralCategoryValues),
+ nonBinary: {
+ General_Category: wordsRegexp(unicodeGeneralCategoryValues),
+ Script: wordsRegexp(unicodeScriptValues[ecmaVersion])
+ }
+ };
+ d.nonBinary.Script_Extensions = d.nonBinary.Script;
+
+ d.nonBinary.gc = d.nonBinary.General_Category;
+ d.nonBinary.sc = d.nonBinary.Script;
+ d.nonBinary.scx = d.nonBinary.Script_Extensions;
+ }
+ buildUnicodeData(9);
+ buildUnicodeData(10);
+ buildUnicodeData(11);
+
+ var pp$8 = Parser.prototype;
+
+ var RegExpValidationState = function RegExpValidationState(parser) {
+ this.parser = parser;
+ this.validFlags = "gim" + (parser.options.ecmaVersion >= 6 ? "uy" : "") + (parser.options.ecmaVersion >= 9 ? "s" : "");
+ this.unicodeProperties = data[parser.options.ecmaVersion >= 11 ? 11 : parser.options.ecmaVersion];
+ this.source = "";
+ this.flags = "";
+ this.start = 0;
+ this.switchU = false;
+ this.switchN = false;
+ this.pos = 0;
+ this.lastIntValue = 0;
+ this.lastStringValue = "";
+ this.lastAssertionIsQuantifiable = false;
+ this.numCapturingParens = 0;
+ this.maxBackReference = 0;
+ this.groupNames = [];
+ this.backReferenceNames = [];
+ };
+
+ RegExpValidationState.prototype.reset = function reset (start, pattern, flags) {
+ var unicode = flags.indexOf("u") !== -1;
+ this.start = start | 0;
+ this.source = pattern + "";
+ this.flags = flags;
+ this.switchU = unicode && this.parser.options.ecmaVersion >= 6;
+ this.switchN = unicode && this.parser.options.ecmaVersion >= 9;
+ };
+
+ RegExpValidationState.prototype.raise = function raise (message) {
+ this.parser.raiseRecoverable(this.start, ("Invalid regular expression: /" + (this.source) + "/: " + message));
+ };
+
+ // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
+ // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
+ RegExpValidationState.prototype.at = function at (i, forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ var s = this.source;
+ var l = s.length;
+ if (i >= l) {
+ return -1
+ }
+ var c = s.charCodeAt(i);
+ if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
+ return c
+ }
+ var next = s.charCodeAt(i + 1);
+ return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
+ };
+
+ RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ var s = this.source;
+ var l = s.length;
+ if (i >= l) {
+ return l
+ }
+ var c = s.charCodeAt(i), next;
+ if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
+ (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
+ return i + 1
+ }
+ return i + 2
+ };
+
+ RegExpValidationState.prototype.current = function current (forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ return this.at(this.pos, forceU)
+ };
+
+ RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ return this.at(this.nextIndex(this.pos, forceU), forceU)
+ };
+
+ RegExpValidationState.prototype.advance = function advance (forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ this.pos = this.nextIndex(this.pos, forceU);
+ };
+
+ RegExpValidationState.prototype.eat = function eat (ch, forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ if (this.current(forceU) === ch) {
+ this.advance(forceU);
+ return true
+ }
+ return false
+ };
+
+ function codePointToString(ch) {
+ if (ch <= 0xFFFF) { return String.fromCharCode(ch) }
+ ch -= 0x10000;
+ return String.fromCharCode((ch >> 10) + 0xD800, (ch & 0x03FF) + 0xDC00)
+ }
+
+ /**
+ * Validate the flags part of a given RegExpLiteral.
+ *
+ * @param {RegExpValidationState} state The state to validate RegExp.
+ * @returns {void}
+ */
+ pp$8.validateRegExpFlags = function(state) {
+ var validFlags = state.validFlags;
+ var flags = state.flags;
+
+ for (var i = 0; i < flags.length; i++) {
+ var flag = flags.charAt(i);
+ if (validFlags.indexOf(flag) === -1) {
+ this.raise(state.start, "Invalid regular expression flag");
+ }
+ if (flags.indexOf(flag, i + 1) > -1) {
+ this.raise(state.start, "Duplicate regular expression flag");
+ }
+ }
+ };
+
+ /**
+ * Validate the pattern part of a given RegExpLiteral.
+ *
+ * @param {RegExpValidationState} state The state to validate RegExp.
+ * @returns {void}
+ */
+ pp$8.validateRegExpPattern = function(state) {
+ this.regexp_pattern(state);
+
+ // The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of
+ // parsing contains a |GroupName|, reparse with the goal symbol
+ // |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError*
+ // exception if _P_ did not conform to the grammar, if any elements of _P_
+ // were not matched by the parse, or if any Early Error conditions exist.
+ if (!state.switchN && this.options.ecmaVersion >= 9 && state.groupNames.length > 0) {
+ state.switchN = true;
+ this.regexp_pattern(state);
+ }
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Pattern
+ pp$8.regexp_pattern = function(state) {
+ state.pos = 0;
+ state.lastIntValue = 0;
+ state.lastStringValue = "";
+ state.lastAssertionIsQuantifiable = false;
+ state.numCapturingParens = 0;
+ state.maxBackReference = 0;
+ state.groupNames.length = 0;
+ state.backReferenceNames.length = 0;
+
+ this.regexp_disjunction(state);
+
+ if (state.pos !== state.source.length) {
+ // Make the same messages as V8.
+ if (state.eat(0x29 /* ) */)) {
+ state.raise("Unmatched ')'");
+ }
+ if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
+ state.raise("Lone quantifier brackets");
+ }
+ }
+ if (state.maxBackReference > state.numCapturingParens) {
+ state.raise("Invalid escape");
+ }
+ for (var i = 0, list = state.backReferenceNames; i < list.length; i += 1) {
+ var name = list[i];
+
+ if (state.groupNames.indexOf(name) === -1) {
+ state.raise("Invalid named capture referenced");
+ }
+ }
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Disjunction
+ pp$8.regexp_disjunction = function(state) {
+ this.regexp_alternative(state);
+ while (state.eat(0x7C /* | */)) {
+ this.regexp_alternative(state);
+ }
+
+ // Make the same message as V8.
+ if (this.regexp_eatQuantifier(state, true)) {
+ state.raise("Nothing to repeat");
+ }
+ if (state.eat(0x7B /* { */)) {
+ state.raise("Lone quantifier brackets");
+ }
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Alternative
+ pp$8.regexp_alternative = function(state) {
+ while (state.pos < state.source.length && this.regexp_eatTerm(state))
+ { }
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Term
+ pp$8.regexp_eatTerm = function(state) {
+ if (this.regexp_eatAssertion(state)) {
+ // Handle `QuantifiableAssertion Quantifier` alternative.
+ // `state.lastAssertionIsQuantifiable` is true if the last eaten Assertion
+ // is a QuantifiableAssertion.
+ if (state.lastAssertionIsQuantifiable && this.regexp_eatQuantifier(state)) {
+ // Make the same message as V8.
+ if (state.switchU) {
+ state.raise("Invalid quantifier");
+ }
+ }
+ return true
+ }
+
+ if (state.switchU ? this.regexp_eatAtom(state) : this.regexp_eatExtendedAtom(state)) {
+ this.regexp_eatQuantifier(state);
+ return true
+ }
+
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-Assertion
+ pp$8.regexp_eatAssertion = function(state) {
+ var start = state.pos;
+ state.lastAssertionIsQuantifiable = false;
+
+ // ^, $
+ if (state.eat(0x5E /* ^ */) || state.eat(0x24 /* $ */)) {
+ return true
+ }
+
+ // \b \B
+ if (state.eat(0x5C /* \ */)) {
+ if (state.eat(0x42 /* B */) || state.eat(0x62 /* b */)) {
+ return true
+ }
+ state.pos = start;
+ }
+
+ // Lookahead / Lookbehind
+ if (state.eat(0x28 /* ( */) && state.eat(0x3F /* ? */)) {
+ var lookbehind = false;
+ if (this.options.ecmaVersion >= 9) {
+ lookbehind = state.eat(0x3C /* < */);
+ }
+ if (state.eat(0x3D /* = */) || state.eat(0x21 /* ! */)) {
+ this.regexp_disjunction(state);
+ if (!state.eat(0x29 /* ) */)) {
+ state.raise("Unterminated group");
+ }
+ state.lastAssertionIsQuantifiable = !lookbehind;
+ return true
+ }
+ }
+
+ state.pos = start;
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Quantifier
+ pp$8.regexp_eatQuantifier = function(state, noError) {
+ if ( noError === void 0 ) noError = false;
+
+ if (this.regexp_eatQuantifierPrefix(state, noError)) {
+ state.eat(0x3F /* ? */);
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-QuantifierPrefix
+ pp$8.regexp_eatQuantifierPrefix = function(state, noError) {
+ return (
+ state.eat(0x2A /* * */) ||
+ state.eat(0x2B /* + */) ||
+ state.eat(0x3F /* ? */) ||
+ this.regexp_eatBracedQuantifier(state, noError)
+ )
+ };
+ pp$8.regexp_eatBracedQuantifier = function(state, noError) {
+ var start = state.pos;
+ if (state.eat(0x7B /* { */)) {
+ var min = 0, max = -1;
+ if (this.regexp_eatDecimalDigits(state)) {
+ min = state.lastIntValue;
+ if (state.eat(0x2C /* , */) && this.regexp_eatDecimalDigits(state)) {
+ max = state.lastIntValue;
+ }
+ if (state.eat(0x7D /* } */)) {
+ // SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-term
+ if (max !== -1 && max < min && !noError) {
+ state.raise("numbers out of order in {} quantifier");
+ }
+ return true
+ }
+ }
+ if (state.switchU && !noError) {
+ state.raise("Incomplete quantifier");
+ }
+ state.pos = start;
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Atom
+ pp$8.regexp_eatAtom = function(state) {
+ return (
+ this.regexp_eatPatternCharacters(state) ||
+ state.eat(0x2E /* . */) ||
+ this.regexp_eatReverseSolidusAtomEscape(state) ||
+ this.regexp_eatCharacterClass(state) ||
+ this.regexp_eatUncapturingGroup(state) ||
+ this.regexp_eatCapturingGroup(state)
+ )
+ };
+ pp$8.regexp_eatReverseSolidusAtomEscape = function(state) {
+ var start = state.pos;
+ if (state.eat(0x5C /* \ */)) {
+ if (this.regexp_eatAtomEscape(state)) {
+ return true
+ }
+ state.pos = start;
+ }
+ return false
+ };
+ pp$8.regexp_eatUncapturingGroup = function(state) {
+ var start = state.pos;
+ if (state.eat(0x28 /* ( */)) {
+ if (state.eat(0x3F /* ? */) && state.eat(0x3A /* : */)) {
+ this.regexp_disjunction(state);
+ if (state.eat(0x29 /* ) */)) {
+ return true
+ }
+ state.raise("Unterminated group");
+ }
+ state.pos = start;
+ }
+ return false
+ };
+ pp$8.regexp_eatCapturingGroup = function(state) {
+ if (state.eat(0x28 /* ( */)) {
+ if (this.options.ecmaVersion >= 9) {
+ this.regexp_groupSpecifier(state);
+ } else if (state.current() === 0x3F /* ? */) {
+ state.raise("Invalid group");
+ }
+ this.regexp_disjunction(state);
+ if (state.eat(0x29 /* ) */)) {
+ state.numCapturingParens += 1;
+ return true
+ }
+ state.raise("Unterminated group");
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedAtom
+ pp$8.regexp_eatExtendedAtom = function(state) {
+ return (
+ state.eat(0x2E /* . */) ||
+ this.regexp_eatReverseSolidusAtomEscape(state) ||
+ this.regexp_eatCharacterClass(state) ||
+ this.regexp_eatUncapturingGroup(state) ||
+ this.regexp_eatCapturingGroup(state) ||
+ this.regexp_eatInvalidBracedQuantifier(state) ||
+ this.regexp_eatExtendedPatternCharacter(state)
+ )
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-InvalidBracedQuantifier
+ pp$8.regexp_eatInvalidBracedQuantifier = function(state) {
+ if (this.regexp_eatBracedQuantifier(state, true)) {
+ state.raise("Nothing to repeat");
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-SyntaxCharacter
+ pp$8.regexp_eatSyntaxCharacter = function(state) {
+ var ch = state.current();
+ if (isSyntaxCharacter(ch)) {
+ state.lastIntValue = ch;
+ state.advance();
+ return true
+ }
+ return false
+ };
+ function isSyntaxCharacter(ch) {
+ return (
+ ch === 0x24 /* $ */ ||
+ ch >= 0x28 /* ( */ && ch <= 0x2B /* + */ ||
+ ch === 0x2E /* . */ ||
+ ch === 0x3F /* ? */ ||
+ ch >= 0x5B /* [ */ && ch <= 0x5E /* ^ */ ||
+ ch >= 0x7B /* { */ && ch <= 0x7D /* } */
+ )
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-PatternCharacter
+ // But eat eager.
+ pp$8.regexp_eatPatternCharacters = function(state) {
+ var start = state.pos;
+ var ch = 0;
+ while ((ch = state.current()) !== -1 && !isSyntaxCharacter(ch)) {
+ state.advance();
+ }
+ return state.pos !== start
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ExtendedPatternCharacter
+ pp$8.regexp_eatExtendedPatternCharacter = function(state) {
+ var ch = state.current();
+ if (
+ ch !== -1 &&
+ ch !== 0x24 /* $ */ &&
+ !(ch >= 0x28 /* ( */ && ch <= 0x2B /* + */) &&
+ ch !== 0x2E /* . */ &&
+ ch !== 0x3F /* ? */ &&
+ ch !== 0x5B /* [ */ &&
+ ch !== 0x5E /* ^ */ &&
+ ch !== 0x7C /* | */
+ ) {
+ state.advance();
+ return true
+ }
+ return false
+ };
+
+ // GroupSpecifier ::
+ // [empty]
+ // `?` GroupName
+ pp$8.regexp_groupSpecifier = function(state) {
+ if (state.eat(0x3F /* ? */)) {
+ if (this.regexp_eatGroupName(state)) {
+ if (state.groupNames.indexOf(state.lastStringValue) !== -1) {
+ state.raise("Duplicate capture group name");
+ }
+ state.groupNames.push(state.lastStringValue);
+ return
+ }
+ state.raise("Invalid group");
+ }
+ };
+
+ // GroupName ::
+ // `<` RegExpIdentifierName `>`
+ // Note: this updates `state.lastStringValue` property with the eaten name.
+ pp$8.regexp_eatGroupName = function(state) {
+ state.lastStringValue = "";
+ if (state.eat(0x3C /* < */)) {
+ if (this.regexp_eatRegExpIdentifierName(state) && state.eat(0x3E /* > */)) {
+ return true
+ }
+ state.raise("Invalid capture group name");
+ }
+ return false
+ };
+
+ // RegExpIdentifierName ::
+ // RegExpIdentifierStart
+ // RegExpIdentifierName RegExpIdentifierPart
+ // Note: this updates `state.lastStringValue` property with the eaten name.
+ pp$8.regexp_eatRegExpIdentifierName = function(state) {
+ state.lastStringValue = "";
+ if (this.regexp_eatRegExpIdentifierStart(state)) {
+ state.lastStringValue += codePointToString(state.lastIntValue);
+ while (this.regexp_eatRegExpIdentifierPart(state)) {
+ state.lastStringValue += codePointToString(state.lastIntValue);
+ }
+ return true
+ }
+ return false
+ };
+
+ // RegExpIdentifierStart ::
+ // UnicodeIDStart
+ // `$`
+ // `_`
+ // `\` RegExpUnicodeEscapeSequence[+U]
+ pp$8.regexp_eatRegExpIdentifierStart = function(state) {
+ var start = state.pos;
+ var forceU = this.options.ecmaVersion >= 11;
+ var ch = state.current(forceU);
+ state.advance(forceU);
+
+ if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
+ ch = state.lastIntValue;
+ }
+ if (isRegExpIdentifierStart(ch)) {
+ state.lastIntValue = ch;
+ return true
+ }
+
+ state.pos = start;
+ return false
+ };
+ function isRegExpIdentifierStart(ch) {
+ return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
+ }
+
+ // RegExpIdentifierPart ::
+ // UnicodeIDContinue
+ // `$`
+ // `_`
+ // `\` RegExpUnicodeEscapeSequence[+U]
+ //
+ //
+ pp$8.regexp_eatRegExpIdentifierPart = function(state) {
+ var start = state.pos;
+ var forceU = this.options.ecmaVersion >= 11;
+ var ch = state.current(forceU);
+ state.advance(forceU);
+
+ if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
+ ch = state.lastIntValue;
+ }
+ if (isRegExpIdentifierPart(ch)) {
+ state.lastIntValue = ch;
+ return true
+ }
+
+ state.pos = start;
+ return false
+ };
+ function isRegExpIdentifierPart(ch) {
+ return isIdentifierChar(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ || ch === 0x200C /* */ || ch === 0x200D /* */
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-AtomEscape
+ pp$8.regexp_eatAtomEscape = function(state) {
+ if (
+ this.regexp_eatBackReference(state) ||
+ this.regexp_eatCharacterClassEscape(state) ||
+ this.regexp_eatCharacterEscape(state) ||
+ (state.switchN && this.regexp_eatKGroupName(state))
+ ) {
+ return true
+ }
+ if (state.switchU) {
+ // Make the same message as V8.
+ if (state.current() === 0x63 /* c */) {
+ state.raise("Invalid unicode escape");
+ }
+ state.raise("Invalid escape");
+ }
+ return false
+ };
+ pp$8.regexp_eatBackReference = function(state) {
+ var start = state.pos;
+ if (this.regexp_eatDecimalEscape(state)) {
+ var n = state.lastIntValue;
+ if (state.switchU) {
+ // For SyntaxError in https://www.ecma-international.org/ecma-262/8.0/#sec-atomescape
+ if (n > state.maxBackReference) {
+ state.maxBackReference = n;
+ }
+ return true
+ }
+ if (n <= state.numCapturingParens) {
+ return true
+ }
+ state.pos = start;
+ }
+ return false
+ };
+ pp$8.regexp_eatKGroupName = function(state) {
+ if (state.eat(0x6B /* k */)) {
+ if (this.regexp_eatGroupName(state)) {
+ state.backReferenceNames.push(state.lastStringValue);
+ return true
+ }
+ state.raise("Invalid named reference");
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-CharacterEscape
+ pp$8.regexp_eatCharacterEscape = function(state) {
+ return (
+ this.regexp_eatControlEscape(state) ||
+ this.regexp_eatCControlLetter(state) ||
+ this.regexp_eatZero(state) ||
+ this.regexp_eatHexEscapeSequence(state) ||
+ this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
+ (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
+ this.regexp_eatIdentityEscape(state)
+ )
+ };
+ pp$8.regexp_eatCControlLetter = function(state) {
+ var start = state.pos;
+ if (state.eat(0x63 /* c */)) {
+ if (this.regexp_eatControlLetter(state)) {
+ return true
+ }
+ state.pos = start;
+ }
+ return false
+ };
+ pp$8.regexp_eatZero = function(state) {
+ if (state.current() === 0x30 /* 0 */ && !isDecimalDigit(state.lookahead())) {
+ state.lastIntValue = 0;
+ state.advance();
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlEscape
+ pp$8.regexp_eatControlEscape = function(state) {
+ var ch = state.current();
+ if (ch === 0x74 /* t */) {
+ state.lastIntValue = 0x09; /* \t */
+ state.advance();
+ return true
+ }
+ if (ch === 0x6E /* n */) {
+ state.lastIntValue = 0x0A; /* \n */
+ state.advance();
+ return true
+ }
+ if (ch === 0x76 /* v */) {
+ state.lastIntValue = 0x0B; /* \v */
+ state.advance();
+ return true
+ }
+ if (ch === 0x66 /* f */) {
+ state.lastIntValue = 0x0C; /* \f */
+ state.advance();
+ return true
+ }
+ if (ch === 0x72 /* r */) {
+ state.lastIntValue = 0x0D; /* \r */
+ state.advance();
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-ControlLetter
+ pp$8.regexp_eatControlLetter = function(state) {
+ var ch = state.current();
+ if (isControlLetter(ch)) {
+ state.lastIntValue = ch % 0x20;
+ state.advance();
+ return true
+ }
+ return false
+ };
+ function isControlLetter(ch) {
+ return (
+ (ch >= 0x41 /* A */ && ch <= 0x5A /* Z */) ||
+ (ch >= 0x61 /* a */ && ch <= 0x7A /* z */)
+ )
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
+ pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
+ if ( forceU === void 0 ) forceU = false;
+
+ var start = state.pos;
+ var switchU = forceU || state.switchU;
+
+ if (state.eat(0x75 /* u */)) {
+ if (this.regexp_eatFixedHexDigits(state, 4)) {
+ var lead = state.lastIntValue;
+ if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
+ var leadSurrogateEnd = state.pos;
+ if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
+ var trail = state.lastIntValue;
+ if (trail >= 0xDC00 && trail <= 0xDFFF) {
+ state.lastIntValue = (lead - 0xD800) * 0x400 + (trail - 0xDC00) + 0x10000;
+ return true
+ }
+ }
+ state.pos = leadSurrogateEnd;
+ state.lastIntValue = lead;
+ }
+ return true
+ }
+ if (
+ switchU &&
+ state.eat(0x7B /* { */) &&
+ this.regexp_eatHexDigits(state) &&
+ state.eat(0x7D /* } */) &&
+ isValidUnicode(state.lastIntValue)
+ ) {
+ return true
+ }
+ if (switchU) {
+ state.raise("Invalid unicode escape");
+ }
+ state.pos = start;
+ }
+
+ return false
+ };
+ function isValidUnicode(ch) {
+ return ch >= 0 && ch <= 0x10FFFF
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-IdentityEscape
+ pp$8.regexp_eatIdentityEscape = function(state) {
+ if (state.switchU) {
+ if (this.regexp_eatSyntaxCharacter(state)) {
+ return true
+ }
+ if (state.eat(0x2F /* / */)) {
+ state.lastIntValue = 0x2F; /* / */
+ return true
+ }
+ return false
+ }
+
+ var ch = state.current();
+ if (ch !== 0x63 /* c */ && (!state.switchN || ch !== 0x6B /* k */)) {
+ state.lastIntValue = ch;
+ state.advance();
+ return true
+ }
+
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalEscape
+ pp$8.regexp_eatDecimalEscape = function(state) {
+ state.lastIntValue = 0;
+ var ch = state.current();
+ if (ch >= 0x31 /* 1 */ && ch <= 0x39 /* 9 */) {
+ do {
+ state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
+ state.advance();
+ } while ((ch = state.current()) >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */)
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClassEscape
+ pp$8.regexp_eatCharacterClassEscape = function(state) {
+ var ch = state.current();
+
+ if (isCharacterClassEscape(ch)) {
+ state.lastIntValue = -1;
+ state.advance();
+ return true
+ }
+
+ if (
+ state.switchU &&
+ this.options.ecmaVersion >= 9 &&
+ (ch === 0x50 /* P */ || ch === 0x70 /* p */)
+ ) {
+ state.lastIntValue = -1;
+ state.advance();
+ if (
+ state.eat(0x7B /* { */) &&
+ this.regexp_eatUnicodePropertyValueExpression(state) &&
+ state.eat(0x7D /* } */)
+ ) {
+ return true
+ }
+ state.raise("Invalid property name");
+ }
+
+ return false
+ };
+ function isCharacterClassEscape(ch) {
+ return (
+ ch === 0x64 /* d */ ||
+ ch === 0x44 /* D */ ||
+ ch === 0x73 /* s */ ||
+ ch === 0x53 /* S */ ||
+ ch === 0x77 /* w */ ||
+ ch === 0x57 /* W */
+ )
+ }
+
+ // UnicodePropertyValueExpression ::
+ // UnicodePropertyName `=` UnicodePropertyValue
+ // LoneUnicodePropertyNameOrValue
+ pp$8.regexp_eatUnicodePropertyValueExpression = function(state) {
+ var start = state.pos;
+
+ // UnicodePropertyName `=` UnicodePropertyValue
+ if (this.regexp_eatUnicodePropertyName(state) && state.eat(0x3D /* = */)) {
+ var name = state.lastStringValue;
+ if (this.regexp_eatUnicodePropertyValue(state)) {
+ var value = state.lastStringValue;
+ this.regexp_validateUnicodePropertyNameAndValue(state, name, value);
+ return true
+ }
+ }
+ state.pos = start;
+
+ // LoneUnicodePropertyNameOrValue
+ if (this.regexp_eatLoneUnicodePropertyNameOrValue(state)) {
+ var nameOrValue = state.lastStringValue;
+ this.regexp_validateUnicodePropertyNameOrValue(state, nameOrValue);
+ return true
+ }
+ return false
+ };
+ pp$8.regexp_validateUnicodePropertyNameAndValue = function(state, name, value) {
+ if (!has(state.unicodeProperties.nonBinary, name))
+ { state.raise("Invalid property name"); }
+ if (!state.unicodeProperties.nonBinary[name].test(value))
+ { state.raise("Invalid property value"); }
+ };
+ pp$8.regexp_validateUnicodePropertyNameOrValue = function(state, nameOrValue) {
+ if (!state.unicodeProperties.binary.test(nameOrValue))
+ { state.raise("Invalid property name"); }
+ };
+
+ // UnicodePropertyName ::
+ // UnicodePropertyNameCharacters
+ pp$8.regexp_eatUnicodePropertyName = function(state) {
+ var ch = 0;
+ state.lastStringValue = "";
+ while (isUnicodePropertyNameCharacter(ch = state.current())) {
+ state.lastStringValue += codePointToString(ch);
+ state.advance();
+ }
+ return state.lastStringValue !== ""
+ };
+ function isUnicodePropertyNameCharacter(ch) {
+ return isControlLetter(ch) || ch === 0x5F /* _ */
+ }
+
+ // UnicodePropertyValue ::
+ // UnicodePropertyValueCharacters
+ pp$8.regexp_eatUnicodePropertyValue = function(state) {
+ var ch = 0;
+ state.lastStringValue = "";
+ while (isUnicodePropertyValueCharacter(ch = state.current())) {
+ state.lastStringValue += codePointToString(ch);
+ state.advance();
+ }
+ return state.lastStringValue !== ""
+ };
+ function isUnicodePropertyValueCharacter(ch) {
+ return isUnicodePropertyNameCharacter(ch) || isDecimalDigit(ch)
+ }
+
+ // LoneUnicodePropertyNameOrValue ::
+ // UnicodePropertyValueCharacters
+ pp$8.regexp_eatLoneUnicodePropertyNameOrValue = function(state) {
+ return this.regexp_eatUnicodePropertyValue(state)
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-CharacterClass
+ pp$8.regexp_eatCharacterClass = function(state) {
+ if (state.eat(0x5B /* [ */)) {
+ state.eat(0x5E /* ^ */);
+ this.regexp_classRanges(state);
+ if (state.eat(0x5D /* ] */)) {
+ return true
+ }
+ // Unreachable since it threw "unterminated regular expression" error before.
+ state.raise("Unterminated character class");
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassRanges
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRanges
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-NonemptyClassRangesNoDash
+ pp$8.regexp_classRanges = function(state) {
+ while (this.regexp_eatClassAtom(state)) {
+ var left = state.lastIntValue;
+ if (state.eat(0x2D /* - */) && this.regexp_eatClassAtom(state)) {
+ var right = state.lastIntValue;
+ if (state.switchU && (left === -1 || right === -1)) {
+ state.raise("Invalid character class");
+ }
+ if (left !== -1 && right !== -1 && left > right) {
+ state.raise("Range out of order in character class");
+ }
+ }
+ }
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtom
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-ClassAtomNoDash
+ pp$8.regexp_eatClassAtom = function(state) {
+ var start = state.pos;
+
+ if (state.eat(0x5C /* \ */)) {
+ if (this.regexp_eatClassEscape(state)) {
+ return true
+ }
+ if (state.switchU) {
+ // Make the same message as V8.
+ var ch$1 = state.current();
+ if (ch$1 === 0x63 /* c */ || isOctalDigit(ch$1)) {
+ state.raise("Invalid class escape");
+ }
+ state.raise("Invalid escape");
+ }
+ state.pos = start;
+ }
+
+ var ch = state.current();
+ if (ch !== 0x5D /* ] */) {
+ state.lastIntValue = ch;
+ state.advance();
+ return true
+ }
+
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassEscape
+ pp$8.regexp_eatClassEscape = function(state) {
+ var start = state.pos;
+
+ if (state.eat(0x62 /* b */)) {
+ state.lastIntValue = 0x08; /* */
+ return true
+ }
+
+ if (state.switchU && state.eat(0x2D /* - */)) {
+ state.lastIntValue = 0x2D; /* - */
+ return true
+ }
+
+ if (!state.switchU && state.eat(0x63 /* c */)) {
+ if (this.regexp_eatClassControlLetter(state)) {
+ return true
+ }
+ state.pos = start;
+ }
+
+ return (
+ this.regexp_eatCharacterClassEscape(state) ||
+ this.regexp_eatCharacterEscape(state)
+ )
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-ClassControlLetter
+ pp$8.regexp_eatClassControlLetter = function(state) {
+ var ch = state.current();
+ if (isDecimalDigit(ch) || ch === 0x5F /* _ */) {
+ state.lastIntValue = ch % 0x20;
+ state.advance();
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
+ pp$8.regexp_eatHexEscapeSequence = function(state) {
+ var start = state.pos;
+ if (state.eat(0x78 /* x */)) {
+ if (this.regexp_eatFixedHexDigits(state, 2)) {
+ return true
+ }
+ if (state.switchU) {
+ state.raise("Invalid escape");
+ }
+ state.pos = start;
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-DecimalDigits
+ pp$8.regexp_eatDecimalDigits = function(state) {
+ var start = state.pos;
+ var ch = 0;
+ state.lastIntValue = 0;
+ while (isDecimalDigit(ch = state.current())) {
+ state.lastIntValue = 10 * state.lastIntValue + (ch - 0x30 /* 0 */);
+ state.advance();
+ }
+ return state.pos !== start
+ };
+ function isDecimalDigit(ch) {
+ return ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigits
+ pp$8.regexp_eatHexDigits = function(state) {
+ var start = state.pos;
+ var ch = 0;
+ state.lastIntValue = 0;
+ while (isHexDigit(ch = state.current())) {
+ state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
+ state.advance();
+ }
+ return state.pos !== start
+ };
+ function isHexDigit(ch) {
+ return (
+ (ch >= 0x30 /* 0 */ && ch <= 0x39 /* 9 */) ||
+ (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) ||
+ (ch >= 0x61 /* a */ && ch <= 0x66 /* f */)
+ )
+ }
+ function hexToInt(ch) {
+ if (ch >= 0x41 /* A */ && ch <= 0x46 /* F */) {
+ return 10 + (ch - 0x41 /* A */)
+ }
+ if (ch >= 0x61 /* a */ && ch <= 0x66 /* f */) {
+ return 10 + (ch - 0x61 /* a */)
+ }
+ return ch - 0x30 /* 0 */
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-annexB-LegacyOctalEscapeSequence
+ // Allows only 0-377(octal) i.e. 0-255(decimal).
+ pp$8.regexp_eatLegacyOctalEscapeSequence = function(state) {
+ if (this.regexp_eatOctalDigit(state)) {
+ var n1 = state.lastIntValue;
+ if (this.regexp_eatOctalDigit(state)) {
+ var n2 = state.lastIntValue;
+ if (n1 <= 3 && this.regexp_eatOctalDigit(state)) {
+ state.lastIntValue = n1 * 64 + n2 * 8 + state.lastIntValue;
+ } else {
+ state.lastIntValue = n1 * 8 + n2;
+ }
+ } else {
+ state.lastIntValue = n1;
+ }
+ return true
+ }
+ return false
+ };
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-OctalDigit
+ pp$8.regexp_eatOctalDigit = function(state) {
+ var ch = state.current();
+ if (isOctalDigit(ch)) {
+ state.lastIntValue = ch - 0x30; /* 0 */
+ state.advance();
+ return true
+ }
+ state.lastIntValue = 0;
+ return false
+ };
+ function isOctalDigit(ch) {
+ return ch >= 0x30 /* 0 */ && ch <= 0x37 /* 7 */
+ }
+
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-Hex4Digits
+ // https://www.ecma-international.org/ecma-262/8.0/#prod-HexDigit
+ // And HexDigit HexDigit in https://www.ecma-international.org/ecma-262/8.0/#prod-HexEscapeSequence
+ pp$8.regexp_eatFixedHexDigits = function(state, length) {
+ var start = state.pos;
+ state.lastIntValue = 0;
+ for (var i = 0; i < length; ++i) {
+ var ch = state.current();
+ if (!isHexDigit(ch)) {
+ state.pos = start;
+ return false
+ }
+ state.lastIntValue = 16 * state.lastIntValue + hexToInt(ch);
+ state.advance();
+ }
+ return true
+ };
+
+ // Object type used to represent tokens. Note that normally, tokens
+ // simply exist as properties on the parser object. This is only
+ // used for the onToken callback and the external tokenizer.
+
+ var Token = function Token(p) {
+ this.type = p.type;
+ this.value = p.value;
+ this.start = p.start;
+ this.end = p.end;
+ if (p.options.locations)
+ { this.loc = new SourceLocation(p, p.startLoc, p.endLoc); }
+ if (p.options.ranges)
+ { this.range = [p.start, p.end]; }
+ };
+
+ // ## Tokenizer
+
+ var pp$9 = Parser.prototype;
+
+ // Move to the next token
+
+ pp$9.next = function(ignoreEscapeSequenceInKeyword) {
+ if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
+ { this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
+ if (this.options.onToken)
+ { this.options.onToken(new Token(this)); }
+
+ this.lastTokEnd = this.end;
+ this.lastTokStart = this.start;
+ this.lastTokEndLoc = this.endLoc;
+ this.lastTokStartLoc = this.startLoc;
+ this.nextToken();
+ };
+
+ pp$9.getToken = function() {
+ this.next();
+ return new Token(this)
+ };
+
+ // If we're in an ES6 environment, make parsers iterable
+ if (typeof Symbol !== "undefined")
+ { pp$9[Symbol.iterator] = function() {
+ var this$1 = this;
+
+ return {
+ next: function () {
+ var token = this$1.getToken();
+ return {
+ done: token.type === types.eof,
+ value: token
+ }
+ }
+ }
+ }; }
+
+ // Toggle strict mode. Re-reads the next number or string to please
+ // pedantic tests (`"use strict"; 010;` should fail).
+
+ pp$9.curContext = function() {
+ return this.context[this.context.length - 1]
+ };
+
+ // Read a single token, updating the parser object's token-related
+ // properties.
+
+ pp$9.nextToken = function() {
+ var curContext = this.curContext();
+ if (!curContext || !curContext.preserveSpace) { this.skipSpace(); }
+
+ this.start = this.pos;
+ if (this.options.locations) { this.startLoc = this.curPosition(); }
+ if (this.pos >= this.input.length) { return this.finishToken(types.eof) }
+
+ if (curContext.override) { return curContext.override(this) }
+ else { this.readToken(this.fullCharCodeAtPos()); }
+ };
+
+ pp$9.readToken = function(code) {
+ // Identifier or keyword. '\uXXXX' sequences are allowed in
+ // identifiers, so '\' also dispatches to that.
+ if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */)
+ { return this.readWord() }
+
+ return this.getTokenFromCode(code)
+ };
+
+ pp$9.fullCharCodeAtPos = function() {
+ var code = this.input.charCodeAt(this.pos);
+ if (code <= 0xd7ff || code >= 0xe000) { return code }
+ var next = this.input.charCodeAt(this.pos + 1);
+ return (code << 10) + next - 0x35fdc00
+ };
+
+ pp$9.skipBlockComment = function() {
+ var startLoc = this.options.onComment && this.curPosition();
+ var start = this.pos, end = this.input.indexOf("*/", this.pos += 2);
+ if (end === -1) { this.raise(this.pos - 2, "Unterminated comment"); }
+ this.pos = end + 2;
+ if (this.options.locations) {
+ lineBreakG.lastIndex = start;
+ var match;
+ while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) {
+ ++this.curLine;
+ this.lineStart = match.index + match[0].length;
+ }
+ }
+ if (this.options.onComment)
+ { this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos,
+ startLoc, this.curPosition()); }
+ };
+
+ pp$9.skipLineComment = function(startSkip) {
+ var start = this.pos;
+ var startLoc = this.options.onComment && this.curPosition();
+ var ch = this.input.charCodeAt(this.pos += startSkip);
+ while (this.pos < this.input.length && !isNewLine(ch)) {
+ ch = this.input.charCodeAt(++this.pos);
+ }
+ if (this.options.onComment)
+ { this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos,
+ startLoc, this.curPosition()); }
+ };
+
+ // Called at the start of the parse and after every token. Skips
+ // whitespace and comments, and.
+
+ pp$9.skipSpace = function() {
+ loop: while (this.pos < this.input.length) {
+ var ch = this.input.charCodeAt(this.pos);
+ switch (ch) {
+ case 32: case 160: // ' '
+ ++this.pos;
+ break
+ case 13:
+ if (this.input.charCodeAt(this.pos + 1) === 10) {
+ ++this.pos;
+ }
+ case 10: case 8232: case 8233:
+ ++this.pos;
+ if (this.options.locations) {
+ ++this.curLine;
+ this.lineStart = this.pos;
+ }
+ break
+ case 47: // '/'
+ switch (this.input.charCodeAt(this.pos + 1)) {
+ case 42: // '*'
+ this.skipBlockComment();
+ break
+ case 47:
+ this.skipLineComment(2);
+ break
+ default:
+ break loop
+ }
+ break
+ default:
+ if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) {
+ ++this.pos;
+ } else {
+ break loop
+ }
+ }
+ }
+ };
+
+ // Called at the end of every token. Sets `end`, `val`, and
+ // maintains `context` and `exprAllowed`, and skips the space after
+ // the token, so that the next one's `start` will point at the
+ // right position.
+
+ pp$9.finishToken = function(type, val) {
+ this.end = this.pos;
+ if (this.options.locations) { this.endLoc = this.curPosition(); }
+ var prevType = this.type;
+ this.type = type;
+ this.value = val;
+
+ this.updateContext(prevType);
+ };
+
+ // ### Token reading
+
+ // This is the function that is called to fetch the next token. It
+ // is somewhat obscure, because it works in character codes rather
+ // than characters, and because operator parsing has been inlined
+ // into it.
+ //
+ // All in the name of speed.
+ //
+ pp$9.readToken_dot = function() {
+ var next = this.input.charCodeAt(this.pos + 1);
+ if (next >= 48 && next <= 57) { return this.readNumber(true) }
+ var next2 = this.input.charCodeAt(this.pos + 2);
+ if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.'
+ this.pos += 3;
+ return this.finishToken(types.ellipsis)
+ } else {
+ ++this.pos;
+ return this.finishToken(types.dot)
+ }
+ };
+
+ pp$9.readToken_slash = function() { // '/'
+ var next = this.input.charCodeAt(this.pos + 1);
+ if (this.exprAllowed) { ++this.pos; return this.readRegexp() }
+ if (next === 61) { return this.finishOp(types.assign, 2) }
+ return this.finishOp(types.slash, 1)
+ };
+
+ pp$9.readToken_mult_modulo_exp = function(code) { // '%*'
+ var next = this.input.charCodeAt(this.pos + 1);
+ var size = 1;
+ var tokentype = code === 42 ? types.star : types.modulo;
+
+ // exponentiation operator ** and **=
+ if (this.options.ecmaVersion >= 7 && code === 42 && next === 42) {
+ ++size;
+ tokentype = types.starstar;
+ next = this.input.charCodeAt(this.pos + 2);
+ }
+
+ if (next === 61) { return this.finishOp(types.assign, size + 1) }
+ return this.finishOp(tokentype, size)
+ };
+
+ pp$9.readToken_pipe_amp = function(code) { // '|&'
+ var next = this.input.charCodeAt(this.pos + 1);
+ if (next === code) {
+ if (this.options.ecmaVersion >= 12) {
+ var next2 = this.input.charCodeAt(this.pos + 2);
+ if (next2 === 61) { return this.finishOp(types.assign, 3) }
+ }
+ return this.finishOp(code === 124 ? types.logicalOR : types.logicalAND, 2)
+ }
+ if (next === 61) { return this.finishOp(types.assign, 2) }
+ return this.finishOp(code === 124 ? types.bitwiseOR : types.bitwiseAND, 1)
+ };
+
+ pp$9.readToken_caret = function() { // '^'
+ var next = this.input.charCodeAt(this.pos + 1);
+ if (next === 61) { return this.finishOp(types.assign, 2) }
+ return this.finishOp(types.bitwiseXOR, 1)
+ };
+
+ pp$9.readToken_plus_min = function(code) { // '+-'
+ var next = this.input.charCodeAt(this.pos + 1);
+ if (next === code) {
+ if (next === 45 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 62 &&
+ (this.lastTokEnd === 0 || lineBreak.test(this.input.slice(this.lastTokEnd, this.pos)))) {
+ // A `-->` line comment
+ this.skipLineComment(3);
+ this.skipSpace();
+ return this.nextToken()
+ }
+ return this.finishOp(types.incDec, 2)
+ }
+ if (next === 61) { return this.finishOp(types.assign, 2) }
+ return this.finishOp(types.plusMin, 1)
+ };
+
+ pp$9.readToken_lt_gt = function(code) { // '<>'
+ var next = this.input.charCodeAt(this.pos + 1);
+ var size = 1;
+ if (next === code) {
+ size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
+ if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
+ return this.finishOp(types.bitShift, size)
+ }
+ if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
+ this.input.charCodeAt(this.pos + 3) === 45) {
+ // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `` line comment
+ this.skipLineComment(3);
+ this.skipSpace();
+ return this.nextToken()
+ }
+ return this.finishOp(types.incDec, 2)
+ }
+ if (next === 61) { return this.finishOp(types.assign, 2) }
+ return this.finishOp(types.plusMin, 1)
+};
+
+pp$9.readToken_lt_gt = function(code) { // '<>'
+ var next = this.input.charCodeAt(this.pos + 1);
+ var size = 1;
+ if (next === code) {
+ size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2;
+ if (this.input.charCodeAt(this.pos + size) === 61) { return this.finishOp(types.assign, size + 1) }
+ return this.finishOp(types.bitShift, size)
+ }
+ if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&
+ this.input.charCodeAt(this.pos + 3) === 45) {
+ // `` line comment\n this.skipLineComment(3)\n this.skipSpace()\n return this.nextToken()\n }\n return this.finishOp(tt.incDec, 2)\n }\n if (next === 61) return this.finishOp(tt.assign, 2)\n return this.finishOp(tt.plusMin, 1)\n}\n\npp.readToken_lt_gt = function(code) { // '<>'\n let next = this.input.charCodeAt(this.pos + 1)\n let size = 1\n if (next === code) {\n size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2\n if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1)\n return this.finishOp(tt.bitShift, size)\n }\n if (next === 33 && code === 60 && !this.inModule && this.input.charCodeAt(this.pos + 2) === 45 &&\n this.input.charCodeAt(this.pos + 3) === 45) {\n // `
-foo
-bar
-```
-
-Jade 同样支持不输出的注释,加一个短横线就行了:
-
-```jade
-//- will not output within markup
-p foo
-p bar
-```
-
-渲染为:
-
-```html
-foo
-bar
-```
-
-
-### 块注释
-
-块注释也是支持的:
-
-```jade
-body
- //
- #content
- h1 Example
-```
-
-渲染为:
-
-```html
-
-
-
-```
-
-Jade 同样很好的支持了条件注释:
-
-```jade
-body
- //if IE
- a(href='http://www.mozilla.com/en-US/firefox/') Get Firefox
-```
-
-渲染为:
-
-```html
-
-
-
-```
-
-
-### 内联
-
-Jade 支持以自然的方式定义标签嵌套:
-
-```jade
-ul
- li.first
- a(href='#') foo
- li
- a(href='#') bar
- li.last
- a(href='#') baz
-```
-
-
-### 块展开
-
-块展开可以帮助你在一行内创建嵌套的标签,下面的例子和上面的是一样的:
-
-```jade
-ul
- li.first: a(href='#') foo
- li: a(href='#') bar
- li.last: a(href='#') baz
-```
-
-
-### Case
-
-`case` 表达式按下面这样的形式写:
-
-```jade
-html
- body
- friends = 10
- case friends
- when 0
- p you have no friends
- when 1
- p you have a friend
- default
- p you have #{friends} friends
-```
-
-块展开在这里也可以使用:
-
-```jade
-friends = 5
-
-html
- body
- case friends
- when 0: p you have no friends
- when 1: p you have a friend
- default: p you have #{friends} friends
-```
-
-
-### 属性
-
-Jade 现在支持使用 `(` 和 `)` 作为属性分隔符
-
-```jade
-a(href='/login', title='View login page') Login
-```
-
-当一个值是 `undefined` 或者 `null` 属性 _不_ 会被加上,
-所以呢,它不会编译出 'something="null"'.
-
-```jade
-div(something=null)
-```
-
-Boolean 属性也是支持的:
-
-```jade
-input(type="checkbox", checked)
-```
-
-使用代码的 Boolean 属性只有当属性为 `true` 时才会输出:
-
-```jade
-input(type="checkbox", checked=someValue)
-```
-
-多行同样也是可用的:
-
-```jade
-input(type='checkbox',
- name='agreement',
- checked)
-```
-
-多行的时候可以不加逗号:
-
-```jade
-input(type='checkbox'
- name='agreement'
- checked)
-```
-
-加点空格,格式好看一点?同样支持
-
-```jade
-input(
- type='checkbox'
- name='agreement'
- checked)
-```
-
-冒号也是支持的:
-
-```jade
-rss(xmlns:atom="atom")
-```
-
-假如我有一个 `user` 对象 `{ id: 12, name: 'tobi' }`
-我们希望创建一个指向 `/user/12` 的链接 `href`, 我们可以使用普通的 JavaScript 字符串连接,如下:
-
-```jade
-a(href='/user/' + user.id)= user.name
-```
-
-或者我们使用 Jade 的修改方式, 这个我想很多使用 Ruby 或者 CoffeeScript 的人会看起来像普通的 JS..:
-
-```jade
-a(href='/user/#{user.id}')= user.name
-```
-
-`class` 属性是一个特殊的属性,你可以直接传递一个数组,比如 `bodyClasses = ['user', 'authenticated']` :
-
-```jade
-body(class=bodyClasses)
-```
-
-
-### HTML
-
-内联的 HTML 是可以的,我们可以使用管道定义一段文本 :
-
-```jade
-html
- body
- | Title
- | foo bar baz
-```
-
-或者我们可以使用 `.` 来告诉 Jade 我们需要一段文本:
-
-```jade
-html
- body.
- Title
- foo bar baz
-```
-
-上面的两个例子都会渲染成相同的结果:
-
-```jade
-Title
-foo bar baz
-
-```
-
- 这条规则适应于在 Jade 里的任何文本:
-
-```
-html
- body
- h1 User #{name}
-```
-
-
-### Doctypes
-
-添加文档类型只需要简单的使用 `!!!`, 或者 `doctype` 跟上下面的可选项:
-
-```jade
-!!!
-```
-
-会渲染出 _transitional_ 文档类型, 或者:
-
-```jade
-!!! 5
-```
-
-或
-
-```jade
-!!! html
-```
-
-或
-
-```jade
-doctype html
-```
-
-Doctype 是大小写不敏感的, 所以下面两个是一样的:
-
-```jade
-doctype Basic
-doctype basic
-```
-
-当然也是可以直接传递一段文档类型的文本:
-
-```jade
-doctype html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
-```
-
-渲染后:
-
-```html
-
-```
-
-会输出 _HTML5_ 文档类型. 下面的默认的文档类型,可以很简单的扩展:
-
-```javascript
-var doctypes = exports.doctypes = {
- '5': '',
- 'xml': '',
- 'default': '',
- 'transitional': '',
- 'strict': '',
- 'frameset': '',
- '1.1': '',
- 'basic': '',
- 'mobile': ''
-};
-```
-
-通过下面的代码可以很简单的改变默认的文档类型:
-
-```javascript
- jade.doctypes.default = 'whatever you want';
-```
-
-
-## 过滤器
-
-过滤器前缀 `:`, 比如 `:markdown` 会把下面块里的文本交给专门的函数进行处理。查看顶部 _特性_ 里有哪些可用的过滤器。
-
-```jade
-body
- :markdown
- Woah! jade _and_ markdown, very **cool**
- we can even link to [stuff](http://google.com)
-```
-
-渲染为:
-
-```html
-Woah! jade and markdown, very cool we can even link to stuff
-```
-
-
-## 代码
-
-Jade 目前支持三种类型的可执行代码。第一种是前缀 `-`, 这是不会被输出的:
-
-```jade
-- var foo = 'bar';
-```
-
-这可以用在条件语句或者循环中:
-
-```jade
-- for (var key in obj)
- p= obj[key]
-```
-
-由于 Jade 的缓存技术,下面的代码也是可以的:
-
-```jade
-- if (foo)
- ul
- li yay
- li foo
- li worked
-- else
- p oh no! didnt work
-```
-
-哈哈,甚至是很长的循环也是可以的:
-
- - if (items.length)
- ul
- - items.forEach(function(item){
- li= item
- - })
-
-所以你想要的!
-
-下一步我们要 _转义_ 输出的代码,比如我们返回一个值,只要前缀一个 `=`:
-
-```jade
-- var foo = 'bar'
-= foo
-h1= foo
-```
-
-它会渲染为 `barbar
`. 为了安全起见,使用 `=` 输出的代码默认是转义的,如果想直接输出不转义的值可以使用 `!=`:
-
-```jade
-p!= aVarContainingMoreHTML
-```
-
-Jade 同样是设计师友好的,它可以使 JavaScript 更直接更富表现力。比如下面的赋值语句是相等的,同时表达式还是通常的 JavaScript:
-
-```jade
-- var foo = 'foo ' + 'bar'
-foo = 'foo ' + 'bar'
-```
-
-Jade 会把 `if`, `else if`, `else`, `until`, `while`, `unless` 同别的优先对待, 但是你得记住它们还是普通的 JavaScript:
-
-```jade
-if foo == 'bar'
- ul
- li yay
- li foo
- li worked
-else
- p oh no! didnt work
-```
-
-
-## 循环
-
-尽管已经支持 JavaScript 原生代码,Jade 还是支持了一些特殊的标签,它们可以让模板更加易于理解,其中之一就是 `each`, 这种形式:
-
-```jade
-each VAL[, KEY] in OBJ
-```
-
-一个遍历数组的例子 :
-
-```jade
-- var items = ["one", "two", "three"]
-each item in items
- li= item
-```
-
-渲染为:
-
-```html
-- one
-- two
-- three
-```
-
-遍历一个数组同时带上索引:
-
-```jade
-items = ["one", "two", "three"]
-each item, i in items
- li #{item}: #{i}
-```
-
-渲染为:
-
-```html
-- one: 0
-- two: 1
-- three: 2
-```
-
-遍历一个数组的键值:
-
-```jade
-obj = { foo: 'bar' }
-each val, key in obj
- li #{key}: #{val}
-```
-
-将会渲染为:`- foo: bar
`
-
-Jade 在内部会把这些语句转换成原生的 JavaScript 语句,就像使用 `users.forEach(function(user){`, 词法作用域和嵌套会像在普通的 JavaScript 中一样:
-
-```jade
-each user in users
- each role in user.roles
- li= role
-```
-
-如果你喜欢,也可以使用 `for` :
-
-```jade
-for user in users
- for role in user.roles
- li= role
-```
-
-
-## 条件语句
-
-Jade 条件语句和使用了(`-`) 前缀的 JavaScript 语句是一致的,然后它允许你不使用圆括号,这样会看上去对设计师更友好一点,
-同时要在心里记住这个表达式渲染出的是 _常规_ JavaScript:
-
-```jade
-for user in users
- if user.role == 'admin'
- p #{user.name} is an admin
- else
- p= user.name
-```
-
-和下面的使用了常规 JavaScript 的代码是相等的:
-
-```jade
-for user in users
- - if (user.role == 'admin')
- p #{user.name} is an admin
- - else
- p= user.name
-```
-
-Jade 同时支持 `unless`, 这和 `if (!(expr))` 是等价的:
-
-```jade
-for user in users
- unless user.isAnonymous
- p
- | Click to view
- a(href='/users/' + user.id)= user.name
-```
-
-
-## 模板继承
-
-Jade 支持通过 `block` 和 `extends` 关键字来实现模板继承。 一个块就是一个 Jade 的 block ,它将在子模板中实现,同时是支持递归的。
-
-Jade 块如果没有内容,Jade 会添加默认内容,下面的代码默认会输出 `block scripts`, `block content`, 和 `block foot`.
-
-```jade
-html
- head
- h1 My Site - #{title}
- block scripts
- script(src='/jquery.js')
- body
- block content
- block foot
- #footer
- p some footer content
-```
-
-现在我们来继承这个布局,简单创建一个新文件,像下面那样直接使用 `extends`,给定路径(可以选择带 `.jade` 扩展名或者不带). 你可以定义一个或者更多的块来覆盖父级块内容, 注意到这里的 `foot` 块 _没有_ 定义,所以它还会输出父级的 "some footer content"。
-
-```jade
-extends extend-layout
-
-block scripts
- script(src='/jquery.js')
- script(src='/pets.js')
-
-block content
- h1= title
- each pet in pets
- include pet
-```
-
-同样可以在一个子块里添加块,就像下面实现的块 `content` 里又定义了两个可以被实现的块 `sidebar` 和 `primary`,或者子模板直接实现 `content`。
-
-```jade
-extends regular-layout
-
-block content
- .sidebar
- block sidebar
- p nothing
- .primary
- block primary
- p nothing
-```
-
-
-
-## 前置、追加代码块
-
-Jade允许你 _替换_ (默认)、 _前置_ 和 _追加_ blocks. 比如,假设你希望在 _所有_ 页面的头部都加上默认的脚本,你可以这么做:
-
-
-```jade
-html
- head
- block head
- script(src='/vendor/jquery.js')
- script(src='/vendor/caustic.js')
- body
- block content
-```
-
-现在假设你有一个Javascript游戏的页面,你希望在默认的脚本之外添加一些游戏相关的脚本,你可以直接`append`上代码块:
-
-
-```jade
-extends layout
-
-block append head
- script(src='/vendor/three.js')
- script(src='/game.js')
-```
-
-使用 `block append` 或 `block prepend` 时 `block` 是可选的:
-
-```jade
-extends layout
-
-append head
- script(src='/vendor/three.js')
- script(src='/game.js')
-```
-
-
-## 包含
-
-Includes 允许你静态包含一段 Jade, 或者别的存放在单个文件中的东西比如 CSS, HTML 非常常见的例子是包含头部和页脚。 假设我们有一个下面目录结构的文件夹:
-
-```
-./layout.jade
-./includes/
- ./head.jade
- ./tail.jade
-```
-
-下面是 `layout.jade` 的内容:
-
-```jade
-html
- include includes/head
- body
- h1 My Site
- p Welcome to my super amazing site.
- include includes/foot
-```
-
-这两个包含 `includes/head` 和 `includes/foot` 都会读取相对于给 `layout.jade` 参数`filename` 的路径的文件, 这是一个绝对路径,不用担心Express帮你搞定这些了。Include 会解析这些文件,并且插入到已经生成的语法树中,然后渲染为你期待的内容:
-
-```html
-
-
- My Site
-
-
-
- My Site
- Welcome to my super lame site.
-
-
-
-```
-
-前面已经提到,`include` 可以包含比如 HTML 或者 CSS 这样的内容。给定一个扩展名后,Jade 不会把这个文件当作一个 Jade 源代码,并且会把它当作一个普通文本包含进来:
-
-```
-html
- head
- //- css and js have simple filters that wrap them in
-