monaxys
2 years ago
4240 changed files with 1021074 additions and 0 deletions
@ -0,0 +1,3 @@
@@ -0,0 +1,3 @@
|
||||
{ |
||||
"recommendations": ["Vue.volar"] |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
a[data-v-53358646]{color:#42b983}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50;margin-top:60px} |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 4.2 KiB |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8" /> |
||||
<link rel="icon" href="/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
||||
<title>Vite App</title> |
||||
<script type="module" crossorigin src="/assets/index.5d696174.js"></script> |
||||
<link rel="stylesheet" href="/assets/index.c8be967f.css"> |
||||
</head> |
||||
<body> |
||||
<div id="app"></div> |
||||
|
||||
</body> |
||||
</html> |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8" /> |
||||
<link rel="icon" href="/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
||||
<title>webtpl</title> |
||||
</head> |
||||
<body> |
||||
<div id="app"></div> |
||||
<script type="module" src="/src/main.js"></script> |
||||
</body> |
||||
</html> |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../acorn/bin/acorn |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../esbuild/bin/esbuild |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../nanoid/bin/nanoid.cjs |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../@babel/parser/bin/babel-parser.js |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../resolve/bin/resolve |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../rollup/dist/bin/rollup |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../sass/sass.js |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../terser/bin/terser |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
../vite/bin/vite.js |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
{ |
||||
"hash": "4df88986", |
||||
"browserHash": "9b2ac2cc", |
||||
"optimized": { |
||||
"vue": { |
||||
"src": "../../vue/dist/vue.runtime.esm-bundler.js", |
||||
"file": "vue.js", |
||||
"fileHash": "0ce642ec", |
||||
"needsInterop": false |
||||
} |
||||
}, |
||||
"chunks": {} |
||||
} |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
{"type":"module"} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,22 @@
@@ -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. |
@ -0,0 +1,19 @@
@@ -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 @babel/helper-validator-identifier |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/helper-validator-identifier |
||||
``` |
@ -0,0 +1,84 @@
@@ -0,0 +1,84 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.isIdentifierChar = isIdentifierChar; |
||||
exports.isIdentifierName = isIdentifierName; |
||||
exports.isIdentifierStart = isIdentifierStart; |
||||
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\u0870-\u0887\u0889-\u088e\u08a0-\u08c9\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\u0c5d\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cdd\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-\u1711\u171f-\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-\u1b4c\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-\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-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ca\ua7d0\ua7d1\ua7d3\ua7d5-\ua7d9\ua7f2-\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\u0898-\u089f\u08ca-\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\u0c3c\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-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u180f-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf-\u1ace\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-\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, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 68, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 8, 70, 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, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 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, 38, 6, 186, 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, 19, 72, 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, 2637, 96, 16, 1070, 4050, 582, 8634, 568, 8, 30, 18, 78, 18, 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, 8936, 3, 2, 6, 2, 1, 2, 290, 46, 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, 1845, 30, 482, 44, 11, 6, 17, 0, 322, 29, 19, 43, 1269, 6, 2, 3, 2, 1, 2, 14, 2, 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, 42719, 33, 4152, 8, 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, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 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, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 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, 357, 0, 62, 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; i < name.length; i++) { |
||||
let cp = name.charCodeAt(i); |
||||
|
||||
if ((cp & 0xfc00) === 0xd800 && i + 1 < name.length) { |
||||
const trail = name.charCodeAt(++i); |
||||
|
||||
if ((trail & 0xfc00) === 0xdc00) { |
||||
cp = 0x10000 + ((cp & 0x3ff) << 10) + (trail & 0x3ff); |
||||
} |
||||
} |
||||
|
||||
if (isFirst) { |
||||
isFirst = false; |
||||
|
||||
if (!isIdentifierStart(cp)) { |
||||
return false; |
||||
} |
||||
} else if (!isIdentifierChar(cp)) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return !isFirst; |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
Object.defineProperty(exports, "isIdentifierChar", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _identifier.isIdentifierChar; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isIdentifierName", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _identifier.isIdentifierName; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isIdentifierStart", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _identifier.isIdentifierStart; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isKeyword", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _keyword.isKeyword; |
||||
} |
||||
}); |
||||
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; |
||||
} |
||||
}); |
||||
|
||||
var _identifier = require("./identifier"); |
||||
|
||||
var _keyword = require("./keyword"); |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.isKeyword = isKeyword; |
||||
exports.isReservedWord = isReservedWord; |
||||
exports.isStrictBindOnlyReservedWord = isStrictBindOnlyReservedWord; |
||||
exports.isStrictBindReservedWord = isStrictBindReservedWord; |
||||
exports.isStrictReservedWord = isStrictReservedWord; |
||||
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); |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
{ |
||||
"name": "@babel/helper-validator-identifier", |
||||
"version": "7.16.7", |
||||
"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", |
||||
"./package.json": "./package.json" |
||||
}, |
||||
"devDependencies": { |
||||
"@unicode/unicode-14.0.0": "^1.2.1", |
||||
"charcodes": "^0.2.0" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
"use strict"; |
||||
|
||||
// Always use the latest available version of Unicode!
|
||||
// https://tc39.github.io/ecma262/#sec-conformance
|
||||
const version = "14.0.0"; |
||||
|
||||
const start = require("@unicode/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/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) + ";" |
||||
); |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
Copyright (C) 2012-2014 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. |
@ -0,0 +1,19 @@
@@ -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 |
||||
``` |
@ -0,0 +1,15 @@
@@ -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, " ")); |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
{ |
||||
"name": "@babel/parser", |
||||
"version": "7.18.5", |
||||
"description": "A JavaScript parser", |
||||
"author": "The Babel Team (https://babel.dev/team)", |
||||
"homepage": "https://babel.dev/docs/en/next/babel-parser", |
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A+parser+%28babylon%29%22+is%3Aopen", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"keywords": [ |
||||
"babel", |
||||
"javascript", |
||||
"parser", |
||||
"tc39", |
||||
"ecmascript", |
||||
"@babel/parser" |
||||
], |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-parser" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"types": "./typings/babel-parser.d.ts", |
||||
"files": [ |
||||
"bin", |
||||
"lib", |
||||
"typings" |
||||
], |
||||
"engines": { |
||||
"node": ">=6.0.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/code-frame": "^7.16.7", |
||||
"@babel/helper-check-duplicate-nodes": "^7.18.4", |
||||
"@babel/helper-fixtures": "^7.17.10", |
||||
"@babel/helper-validator-identifier": "^7.16.7", |
||||
"charcodes": "^0.2.0" |
||||
}, |
||||
"bin": "./bin/babel-parser.js" |
||||
} |
@ -0,0 +1,214 @@
@@ -0,0 +1,214 @@
|
||||
// Type definitions for @babel/parser
|
||||
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Avi Vahl <https://github.com/AviVahl>
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
/** |
||||
* Parse the provided code as an entire ECMAScript program. |
||||
*/ |
||||
export function parse( |
||||
input: string, |
||||
options?: ParserOptions |
||||
): ParseResult<import("@babel/types").File>; |
||||
|
||||
/** |
||||
* Parse the provided code as a single expression. |
||||
*/ |
||||
export function parseExpression( |
||||
input: string, |
||||
options?: ParserOptions |
||||
): ParseResult<import("@babel/types").Expression>; |
||||
|
||||
export interface ParserOptions { |
||||
/** |
||||
* 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. |
||||
*/ |
||||
allowImportExportEverywhere?: boolean; |
||||
|
||||
/** |
||||
* By default, await use is not allowed outside of an async function. |
||||
* Set this to true to accept such code. |
||||
*/ |
||||
allowAwaitOutsideFunction?: boolean; |
||||
|
||||
/** |
||||
* By default, a return statement at the top level raises an error. |
||||
* Set this to true to accept such code. |
||||
*/ |
||||
allowReturnOutsideFunction?: boolean; |
||||
|
||||
allowSuperOutsideMethod?: boolean; |
||||
|
||||
/** |
||||
* By default, exported identifiers must refer to a declared variable. |
||||
* Set this to true to allow export statements to reference undeclared variables. |
||||
*/ |
||||
allowUndeclaredExports?: boolean; |
||||
|
||||
/** |
||||
* By default, Babel attaches comments to adjacent AST nodes. |
||||
* When this option is set to false, comments are not attached. |
||||
* It can provide up to 30% performance improvement when the input code has many comments. |
||||
* @babel/eslint-parser will set it for you. |
||||
* It is not recommended to use attachComment: false with Babel transform, |
||||
* as doing so removes all the comments in output code, and renders annotations such as |
||||
* /* istanbul ignore next *\/ nonfunctional. |
||||
*/ |
||||
attachComment?: boolean; |
||||
|
||||
/** |
||||
* By default, Babel always throws an error when it finds some invalid code. |
||||
* When this option is set to true, it will store the parsing error and |
||||
* try to continue parsing the invalid input file. |
||||
*/ |
||||
errorRecovery?: boolean; |
||||
|
||||
/** |
||||
* Indicate the mode the code should be parsed in. |
||||
* Can be one of "script", "module", or "unambiguous". Defaults to "script". |
||||
* "unambiguous" will make @babel/parser attempt to guess, based on the presence |
||||
* of ES6 import or export statements. |
||||
* Files with ES6 imports and exports are considered "module" and are otherwise "script". |
||||
*/ |
||||
sourceType?: "script" | "module" | "unambiguous"; |
||||
|
||||
/** |
||||
* Correlate output AST nodes with their source filename. |
||||
* Useful when generating code and source maps from the ASTs of multiple input files. |
||||
*/ |
||||
sourceFilename?: string; |
||||
|
||||
/** |
||||
* By default, the first line of code parsed is treated as line 1. |
||||
* You can provide a line number to alternatively start with. |
||||
* Useful for integration with other source tools. |
||||
*/ |
||||
startLine?: number; |
||||
|
||||
/** |
||||
* By default, the parsed code is treated as if it starts from line 1, column 0. |
||||
* You can provide a column number to alternatively start with. |
||||
* Useful for integration with other source tools. |
||||
*/ |
||||
startColumn?: number; |
||||
|
||||
/** |
||||
* Array containing the plugins that you want to enable. |
||||
*/ |
||||
plugins?: ParserPlugin[]; |
||||
|
||||
/** |
||||
* Should the parser work in strict mode. |
||||
* Defaults to true if sourceType === 'module'. Otherwise, false. |
||||
*/ |
||||
strictMode?: boolean; |
||||
|
||||
/** |
||||
* Adds a ranges property to each node: [node.start, node.end] |
||||
*/ |
||||
ranges?: boolean; |
||||
|
||||
/** |
||||
* Adds all parsed tokens to a tokens property on the File node. |
||||
*/ |
||||
tokens?: boolean; |
||||
|
||||
/** |
||||
* By default, the parser adds information about parentheses by setting |
||||
* `extra.parenthesized` to `true` as needed. |
||||
* When this option is `true` the parser creates `ParenthesizedExpression` |
||||
* AST nodes instead of using the `extra` property. |
||||
*/ |
||||
createParenthesizedExpressions?: boolean; |
||||
} |
||||
|
||||
export type ParserPlugin = |
||||
| "asyncDoExpressions" |
||||
| "asyncGenerators" |
||||
| "bigInt" |
||||
| "classPrivateMethods" |
||||
| "classPrivateProperties" |
||||
| "classProperties" |
||||
| "classStaticBlock" // Enabled by default
|
||||
| "decimal" |
||||
| "decorators" |
||||
| "decorators-legacy" |
||||
| "decoratorAutoAccessors" |
||||
| "destructuringPrivate" |
||||
| "doExpressions" |
||||
| "dynamicImport" |
||||
| "estree" |
||||
| "exportDefaultFrom" |
||||
| "exportNamespaceFrom" // deprecated
|
||||
| "flow" |
||||
| "flowComments" |
||||
| "functionBind" |
||||
| "functionSent" |
||||
| "importMeta" |
||||
| "jsx" |
||||
| "logicalAssignment" |
||||
| "importAssertions" |
||||
| "moduleBlocks" |
||||
| "moduleStringNames" |
||||
| "nullishCoalescingOperator" |
||||
| "numericSeparator" |
||||
| "objectRestSpread" |
||||
| "optionalCatchBinding" |
||||
| "optionalChaining" |
||||
| "partialApplication" |
||||
| "pipelineOperator" |
||||
| "placeholders" |
||||
| "privateIn" // Enabled by default
|
||||
| "regexpUnicodeSets" |
||||
| "throwExpressions" |
||||
| "topLevelAwait" |
||||
| "typescript" |
||||
| "v8intrinsic" |
||||
| ParserPluginWithOptions; |
||||
|
||||
export type ParserPluginWithOptions = |
||||
| ["decorators", DecoratorsPluginOptions] |
||||
| ["pipelineOperator", PipelineOperatorPluginOptions] |
||||
| ["recordAndTuple", RecordAndTuplePluginOptions] |
||||
| ["flow", FlowPluginOptions] |
||||
| ["typescript", TypeScriptPluginOptions]; |
||||
|
||||
export interface DecoratorsPluginOptions { |
||||
decoratorsBeforeExport?: boolean; |
||||
} |
||||
|
||||
export interface PipelineOperatorPluginOptions { |
||||
proposal: "minimal" | "fsharp" | "hack" | "smart"; |
||||
topicToken?: "%" | "#" | "@@" | "^^" | "^"; |
||||
} |
||||
|
||||
export interface RecordAndTuplePluginOptions { |
||||
syntaxType: "bar" | "hash"; |
||||
} |
||||
|
||||
export interface FlowPluginOptions { |
||||
all?: boolean; |
||||
enums?: boolean; |
||||
} |
||||
|
||||
export interface TypeScriptPluginOptions { |
||||
dts?: boolean; |
||||
disallowAmbiguousJSXLike?: boolean; |
||||
} |
||||
|
||||
export const tokTypes: { |
||||
// todo(flow->ts) real token type
|
||||
[name: string]: any; |
||||
}; |
||||
|
||||
export interface ParseError { |
||||
code: string; |
||||
reasonCode: string; |
||||
} |
||||
|
||||
type ParseResult<Result> = Result & { |
||||
errors: ParseError[]; |
||||
}; |
@ -0,0 +1,22 @@
@@ -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. |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
# @babel/standalone |
||||
|
||||
> Standalone build of Babel for use in non-Node.js environments. |
||||
|
||||
See our website [@babel/standalone](https://babeljs.io/docs/en/babel-standalone) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20standalone%22+is%3Aopen) associated with this package. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/standalone |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/standalone --dev |
||||
``` |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,137 @@
@@ -0,0 +1,137 @@
|
||||
{ |
||||
"name": "@babel/standalone", |
||||
"version": "7.18.5", |
||||
"description": "Standalone build of Babel for use in non-Node.js environments.", |
||||
"main": "./babel.js", |
||||
"files": [ |
||||
"babel.js", |
||||
"babel.min.js" |
||||
], |
||||
"devDependencies": { |
||||
"@babel/core": "^7.18.5", |
||||
"@babel/plugin-external-helpers": "^7.17.12", |
||||
"@babel/plugin-proposal-async-generator-functions": "^7.17.12", |
||||
"@babel/plugin-proposal-class-properties": "^7.17.12", |
||||
"@babel/plugin-proposal-class-static-block": "^7.18.0", |
||||
"@babel/plugin-proposal-decorators": "^7.18.2", |
||||
"@babel/plugin-proposal-destructuring-private": "^7.18.0", |
||||
"@babel/plugin-proposal-do-expressions": "^7.16.7", |
||||
"@babel/plugin-proposal-dynamic-import": "^7.16.7", |
||||
"@babel/plugin-proposal-export-default-from": "^7.17.12", |
||||
"@babel/plugin-proposal-export-namespace-from": "^7.17.12", |
||||
"@babel/plugin-proposal-function-bind": "^7.16.7", |
||||
"@babel/plugin-proposal-function-sent": "^7.18.2", |
||||
"@babel/plugin-proposal-json-strings": "^7.17.12", |
||||
"@babel/plugin-proposal-logical-assignment-operators": "^7.17.12", |
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.17.12", |
||||
"@babel/plugin-proposal-numeric-separator": "^7.16.7", |
||||
"@babel/plugin-proposal-object-rest-spread": "^7.18.0", |
||||
"@babel/plugin-proposal-optional-catch-binding": "^7.16.7", |
||||
"@babel/plugin-proposal-optional-chaining": "^7.17.12", |
||||
"@babel/plugin-proposal-pipeline-operator": "^7.18.2", |
||||
"@babel/plugin-proposal-private-methods": "^7.17.12", |
||||
"@babel/plugin-proposal-private-property-in-object": "^7.17.12", |
||||
"@babel/plugin-proposal-throw-expressions": "^7.16.7", |
||||
"@babel/plugin-proposal-unicode-property-regex": "^7.17.12", |
||||
"@babel/plugin-syntax-async-generators": "^7.8.4", |
||||
"@babel/plugin-syntax-class-properties": "^7.12.13", |
||||
"@babel/plugin-syntax-class-static-block": "^7.14.5", |
||||
"@babel/plugin-syntax-decimal": "^7.16.7", |
||||
"@babel/plugin-syntax-decorators": "^7.17.12", |
||||
"@babel/plugin-syntax-destructuring-private": "^7.18.0", |
||||
"@babel/plugin-syntax-do-expressions": "^7.16.7", |
||||
"@babel/plugin-syntax-export-default-from": "^7.16.7", |
||||
"@babel/plugin-syntax-flow": "^7.17.12", |
||||
"@babel/plugin-syntax-function-bind": "^7.16.7", |
||||
"@babel/plugin-syntax-function-sent": "^7.16.7", |
||||
"@babel/plugin-syntax-import-assertions": "^7.17.12", |
||||
"@babel/plugin-syntax-import-meta": "^7.10.4", |
||||
"@babel/plugin-syntax-jsx": "^7.17.12", |
||||
"@babel/plugin-syntax-module-blocks": "^7.16.7", |
||||
"@babel/plugin-syntax-object-rest-spread": "^7.8.3", |
||||
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3", |
||||
"@babel/plugin-syntax-pipeline-operator": "^7.17.12", |
||||
"@babel/plugin-syntax-record-and-tuple": "^7.17.12", |
||||
"@babel/plugin-syntax-top-level-await": "^7.14.5", |
||||
"@babel/plugin-syntax-typescript": "^7.17.12", |
||||
"@babel/plugin-transform-arrow-functions": "^7.17.12", |
||||
"@babel/plugin-transform-async-to-generator": "^7.17.12", |
||||
"@babel/plugin-transform-block-scoped-functions": "^7.16.7", |
||||
"@babel/plugin-transform-block-scoping": "^7.18.4", |
||||
"@babel/plugin-transform-classes": "^7.18.4", |
||||
"@babel/plugin-transform-computed-properties": "^7.17.12", |
||||
"@babel/plugin-transform-destructuring": "^7.18.0", |
||||
"@babel/plugin-transform-dotall-regex": "^7.16.7", |
||||
"@babel/plugin-transform-duplicate-keys": "^7.17.12", |
||||
"@babel/plugin-transform-exponentiation-operator": "^7.16.7", |
||||
"@babel/plugin-transform-flow-comments": "^7.17.12", |
||||
"@babel/plugin-transform-flow-strip-types": "^7.17.12", |
||||
"@babel/plugin-transform-for-of": "^7.18.1", |
||||
"@babel/plugin-transform-function-name": "^7.16.7", |
||||
"@babel/plugin-transform-instanceof": "^7.17.12", |
||||
"@babel/plugin-transform-jscript": "^7.17.12", |
||||
"@babel/plugin-transform-literals": "^7.17.12", |
||||
"@babel/plugin-transform-member-expression-literals": "^7.16.7", |
||||
"@babel/plugin-transform-modules-amd": "^7.18.0", |
||||
"@babel/plugin-transform-modules-commonjs": "^7.18.2", |
||||
"@babel/plugin-transform-modules-systemjs": "^7.18.5", |
||||
"@babel/plugin-transform-modules-umd": "^7.18.0", |
||||
"@babel/plugin-transform-named-capturing-groups-regex": "^7.17.12", |
||||
"@babel/plugin-transform-new-target": "^7.18.5", |
||||
"@babel/plugin-transform-object-assign": "^7.16.7", |
||||
"@babel/plugin-transform-object-set-prototype-of-to-assign": "^7.16.7", |
||||
"@babel/plugin-transform-object-super": "^7.16.7", |
||||
"@babel/plugin-transform-parameters": "^7.17.12", |
||||
"@babel/plugin-transform-property-literals": "^7.16.7", |
||||
"@babel/plugin-transform-property-mutators": "^7.17.12", |
||||
"@babel/plugin-transform-proto-to-assign": "^7.18.0", |
||||
"@babel/plugin-transform-react-constant-elements": "^7.17.12", |
||||
"@babel/plugin-transform-react-display-name": "^7.16.7", |
||||
"@babel/plugin-transform-react-inline-elements": "^7.16.7", |
||||
"@babel/plugin-transform-react-jsx": "^7.17.12", |
||||
"@babel/plugin-transform-react-jsx-compat": "^7.16.7", |
||||
"@babel/plugin-transform-react-jsx-development": "^7.16.7", |
||||
"@babel/plugin-transform-react-jsx-self": "^7.17.12", |
||||
"@babel/plugin-transform-react-jsx-source": "^7.16.7", |
||||
"@babel/plugin-transform-regenerator": "^7.18.0", |
||||
"@babel/plugin-transform-reserved-words": "^7.17.12", |
||||
"@babel/plugin-transform-runtime": "^7.18.5", |
||||
"@babel/plugin-transform-shorthand-properties": "^7.16.7", |
||||
"@babel/plugin-transform-spread": "^7.17.12", |
||||
"@babel/plugin-transform-sticky-regex": "^7.16.7", |
||||
"@babel/plugin-transform-strict-mode": "^7.16.7", |
||||
"@babel/plugin-transform-template-literals": "^7.18.2", |
||||
"@babel/plugin-transform-typeof-symbol": "^7.17.12", |
||||
"@babel/plugin-transform-typescript": "^7.18.4", |
||||
"@babel/plugin-transform-unicode-escapes": "^7.16.7", |
||||
"@babel/plugin-transform-unicode-regex": "^7.16.7", |
||||
"@babel/preset-env": "^7.18.2", |
||||
"@babel/preset-flow": "^7.17.12", |
||||
"@babel/preset-react": "^7.17.12", |
||||
"@babel/preset-typescript": "^7.17.12" |
||||
}, |
||||
"keywords": [ |
||||
"babel", |
||||
"babeljs", |
||||
"6to5", |
||||
"transpile", |
||||
"transpiler" |
||||
], |
||||
"author": "The Babel Team (https://babel.dev/team)", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"bugs": { |
||||
"url": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20standalone%22+is%3Aopen" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-standalone", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-standalone" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
} |
||||
} |
@ -0,0 +1,22 @@
@@ -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. |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
# @babel/types |
||||
|
||||
> Babel Types is a Lodash-esque utility library for AST nodes |
||||
|
||||
See our website [@babel/types](https://babeljs.io/docs/en/babel-types) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20types%22+is%3Aopen) associated with this package. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/types |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/types --dev |
||||
``` |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = assertNode; |
||||
|
||||
var _isNode = require("../validators/isNode"); |
||||
|
||||
function assertNode(node) { |
||||
if (!(0, _isNode.default)(node)) { |
||||
var _node$type; |
||||
|
||||
const type = (_node$type = node == null ? void 0 : node.type) != null ? _node$type : JSON.stringify(node); |
||||
throw new TypeError(`Not a valid node of type "${type}"`); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = createFlowUnionType; |
||||
|
||||
var _generated = require("../generated"); |
||||
|
||||
var _removeTypeDuplicates = require("../../modifications/flow/removeTypeDuplicates"); |
||||
|
||||
function createFlowUnionType(types) { |
||||
const flattened = (0, _removeTypeDuplicates.default)(types); |
||||
|
||||
if (flattened.length === 1) { |
||||
return flattened[0]; |
||||
} else { |
||||
return (0, _generated.unionTypeAnnotation)(flattened); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _generated = require("../generated"); |
||||
|
||||
var _default = createTypeAnnotationBasedOnTypeof; |
||||
exports.default = _default; |
||||
|
||||
function createTypeAnnotationBasedOnTypeof(type) { |
||||
switch (type) { |
||||
case "string": |
||||
return (0, _generated.stringTypeAnnotation)(); |
||||
|
||||
case "number": |
||||
return (0, _generated.numberTypeAnnotation)(); |
||||
|
||||
case "undefined": |
||||
return (0, _generated.voidTypeAnnotation)(); |
||||
|
||||
case "boolean": |
||||
return (0, _generated.booleanTypeAnnotation)(); |
||||
|
||||
case "function": |
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Function")); |
||||
|
||||
case "object": |
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Object")); |
||||
|
||||
case "symbol": |
||||
return (0, _generated.genericTypeAnnotation)((0, _generated.identifier)("Symbol")); |
||||
|
||||
case "bigint": |
||||
return (0, _generated.anyTypeAnnotation)(); |
||||
} |
||||
|
||||
throw new Error("Invalid typeof value: " + type); |
||||
} |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = buildChildren; |
||||
|
||||
var _generated = require("../../validators/generated"); |
||||
|
||||
var _cleanJSXElementLiteralChild = require("../../utils/react/cleanJSXElementLiteralChild"); |
||||
|
||||
function buildChildren(node) { |
||||
const elements = []; |
||||
|
||||
for (let i = 0; i < node.children.length; i++) { |
||||
let child = node.children[i]; |
||||
|
||||
if ((0, _generated.isJSXText)(child)) { |
||||
(0, _cleanJSXElementLiteralChild.default)(child, elements); |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isJSXExpressionContainer)(child)) child = child.expression; |
||||
if ((0, _generated.isJSXEmptyExpression)(child)) continue; |
||||
elements.push(child); |
||||
} |
||||
|
||||
return elements; |
||||
} |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = createTSUnionType; |
||||
|
||||
var _generated = require("../generated"); |
||||
|
||||
var _removeTypeDuplicates = require("../../modifications/typescript/removeTypeDuplicates"); |
||||
|
||||
function createTSUnionType(typeAnnotations) { |
||||
const types = typeAnnotations.map(type => type.typeAnnotation); |
||||
const flattened = (0, _removeTypeDuplicates.default)(types); |
||||
|
||||
if (flattened.length === 1) { |
||||
return flattened[0]; |
||||
} else { |
||||
return (0, _generated.tsUnionType)(flattened); |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = validateNode; |
||||
|
||||
var _validate = require("../validators/validate"); |
||||
|
||||
var _ = require(".."); |
||||
|
||||
function validateNode(node) { |
||||
const keys = _.BUILDER_KEYS[node.type]; |
||||
|
||||
for (const key of keys) { |
||||
(0, _validate.default)(node, key, node[key]); |
||||
} |
||||
|
||||
return node; |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = clone; |
||||
|
||||
var _cloneNode = require("./cloneNode"); |
||||
|
||||
function clone(node) { |
||||
return (0, _cloneNode.default)(node, false); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = cloneDeep; |
||||
|
||||
var _cloneNode = require("./cloneNode"); |
||||
|
||||
function cloneDeep(node) { |
||||
return (0, _cloneNode.default)(node); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = cloneDeepWithoutLoc; |
||||
|
||||
var _cloneNode = require("./cloneNode"); |
||||
|
||||
function cloneDeepWithoutLoc(node) { |
||||
return (0, _cloneNode.default)(node, true, true); |
||||
} |
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = cloneNode; |
||||
|
||||
var _definitions = require("../definitions"); |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
const has = Function.call.bind(Object.prototype.hasOwnProperty); |
||||
|
||||
function cloneIfNode(obj, deep, withoutLoc, commentsCache) { |
||||
if (obj && typeof obj.type === "string") { |
||||
return cloneNodeInternal(obj, deep, withoutLoc, commentsCache); |
||||
} |
||||
|
||||
return obj; |
||||
} |
||||
|
||||
function cloneIfNodeOrArray(obj, deep, withoutLoc, commentsCache) { |
||||
if (Array.isArray(obj)) { |
||||
return obj.map(node => cloneIfNode(node, deep, withoutLoc, commentsCache)); |
||||
} |
||||
|
||||
return cloneIfNode(obj, deep, withoutLoc, commentsCache); |
||||
} |
||||
|
||||
function cloneNode(node, deep = true, withoutLoc = false) { |
||||
return cloneNodeInternal(node, deep, withoutLoc, new Map()); |
||||
} |
||||
|
||||
function cloneNodeInternal(node, deep = true, withoutLoc = false, commentsCache) { |
||||
if (!node) return node; |
||||
const { |
||||
type |
||||
} = node; |
||||
const newNode = { |
||||
type: node.type |
||||
}; |
||||
|
||||
if ((0, _generated.isIdentifier)(node)) { |
||||
newNode.name = node.name; |
||||
|
||||
if (has(node, "optional") && typeof node.optional === "boolean") { |
||||
newNode.optional = node.optional; |
||||
} |
||||
|
||||
if (has(node, "typeAnnotation")) { |
||||
newNode.typeAnnotation = deep ? cloneIfNodeOrArray(node.typeAnnotation, true, withoutLoc, commentsCache) : node.typeAnnotation; |
||||
} |
||||
} else if (!has(_definitions.NODE_FIELDS, type)) { |
||||
throw new Error(`Unknown node type: "${type}"`); |
||||
} else { |
||||
for (const field of Object.keys(_definitions.NODE_FIELDS[type])) { |
||||
if (has(node, field)) { |
||||
if (deep) { |
||||
newNode[field] = (0, _generated.isFile)(node) && field === "comments" ? maybeCloneComments(node.comments, deep, withoutLoc, commentsCache) : cloneIfNodeOrArray(node[field], true, withoutLoc, commentsCache); |
||||
} else { |
||||
newNode[field] = node[field]; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (has(node, "loc")) { |
||||
if (withoutLoc) { |
||||
newNode.loc = null; |
||||
} else { |
||||
newNode.loc = node.loc; |
||||
} |
||||
} |
||||
|
||||
if (has(node, "leadingComments")) { |
||||
newNode.leadingComments = maybeCloneComments(node.leadingComments, deep, withoutLoc, commentsCache); |
||||
} |
||||
|
||||
if (has(node, "innerComments")) { |
||||
newNode.innerComments = maybeCloneComments(node.innerComments, deep, withoutLoc, commentsCache); |
||||
} |
||||
|
||||
if (has(node, "trailingComments")) { |
||||
newNode.trailingComments = maybeCloneComments(node.trailingComments, deep, withoutLoc, commentsCache); |
||||
} |
||||
|
||||
if (has(node, "extra")) { |
||||
newNode.extra = Object.assign({}, node.extra); |
||||
} |
||||
|
||||
return newNode; |
||||
} |
||||
|
||||
function maybeCloneComments(comments, deep, withoutLoc, commentsCache) { |
||||
if (!comments || !deep) { |
||||
return comments; |
||||
} |
||||
|
||||
return comments.map(comment => { |
||||
const cache = commentsCache.get(comment); |
||||
if (cache) return cache; |
||||
const { |
||||
type, |
||||
value, |
||||
loc |
||||
} = comment; |
||||
const ret = { |
||||
type, |
||||
value, |
||||
loc |
||||
}; |
||||
|
||||
if (withoutLoc) { |
||||
ret.loc = null; |
||||
} |
||||
|
||||
commentsCache.set(comment, ret); |
||||
return ret; |
||||
}); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = cloneWithoutLoc; |
||||
|
||||
var _cloneNode = require("./cloneNode"); |
||||
|
||||
function cloneWithoutLoc(node) { |
||||
return (0, _cloneNode.default)(node, false, true); |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = addComment; |
||||
|
||||
var _addComments = require("./addComments"); |
||||
|
||||
function addComment(node, type, content, line) { |
||||
return (0, _addComments.default)(node, type, [{ |
||||
type: line ? "CommentLine" : "CommentBlock", |
||||
value: content |
||||
}]); |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = addComments; |
||||
|
||||
function addComments(node, type, comments) { |
||||
if (!comments || !node) return node; |
||||
const key = `${type}Comments`; |
||||
|
||||
if (node[key]) { |
||||
if (type === "leading") { |
||||
node[key] = comments.concat(node[key]); |
||||
} else { |
||||
node[key].push(...comments); |
||||
} |
||||
} else { |
||||
node[key] = comments; |
||||
} |
||||
|
||||
return node; |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = inheritInnerComments; |
||||
|
||||
var _inherit = require("../utils/inherit"); |
||||
|
||||
function inheritInnerComments(child, parent) { |
||||
(0, _inherit.default)("innerComments", child, parent); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = inheritLeadingComments; |
||||
|
||||
var _inherit = require("../utils/inherit"); |
||||
|
||||
function inheritLeadingComments(child, parent) { |
||||
(0, _inherit.default)("leadingComments", child, parent); |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = inheritTrailingComments; |
||||
|
||||
var _inherit = require("../utils/inherit"); |
||||
|
||||
function inheritTrailingComments(child, parent) { |
||||
(0, _inherit.default)("trailingComments", child, parent); |
||||
} |
@ -0,0 +1,19 @@
@@ -0,0 +1,19 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = inheritsComments; |
||||
|
||||
var _inheritTrailingComments = require("./inheritTrailingComments"); |
||||
|
||||
var _inheritLeadingComments = require("./inheritLeadingComments"); |
||||
|
||||
var _inheritInnerComments = require("./inheritInnerComments"); |
||||
|
||||
function inheritsComments(child, parent) { |
||||
(0, _inheritTrailingComments.default)(child, parent); |
||||
(0, _inheritLeadingComments.default)(child, parent); |
||||
(0, _inheritInnerComments.default)(child, parent); |
||||
return child; |
||||
} |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = removeComments; |
||||
|
||||
var _constants = require("../constants"); |
||||
|
||||
function removeComments(node) { |
||||
_constants.COMMENT_KEYS.forEach(key => { |
||||
node[key] = null; |
||||
}); |
||||
|
||||
return node; |
||||
} |
@ -0,0 +1,107 @@
@@ -0,0 +1,107 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.WHILE_TYPES = exports.USERWHITESPACABLE_TYPES = exports.UNARYLIKE_TYPES = exports.TYPESCRIPT_TYPES = exports.TSTYPE_TYPES = exports.TSTYPEELEMENT_TYPES = exports.TSENTITYNAME_TYPES = exports.TSBASETYPE_TYPES = exports.TERMINATORLESS_TYPES = exports.STATEMENT_TYPES = exports.STANDARDIZED_TYPES = exports.SCOPABLE_TYPES = exports.PUREISH_TYPES = exports.PROPERTY_TYPES = exports.PRIVATE_TYPES = exports.PATTERN_TYPES = exports.PATTERNLIKE_TYPES = exports.OBJECTMEMBER_TYPES = exports.MODULESPECIFIER_TYPES = exports.MODULEDECLARATION_TYPES = exports.MISCELLANEOUS_TYPES = exports.METHOD_TYPES = exports.LVAL_TYPES = exports.LOOP_TYPES = exports.LITERAL_TYPES = exports.JSX_TYPES = exports.IMMUTABLE_TYPES = exports.FUNCTION_TYPES = exports.FUNCTIONPARENT_TYPES = exports.FOR_TYPES = exports.FORXSTATEMENT_TYPES = exports.FLOW_TYPES = exports.FLOWTYPE_TYPES = exports.FLOWPREDICATE_TYPES = exports.FLOWDECLARATION_TYPES = exports.FLOWBASEANNOTATION_TYPES = exports.EXPRESSION_TYPES = exports.EXPRESSIONWRAPPER_TYPES = exports.EXPORTDECLARATION_TYPES = exports.ENUMMEMBER_TYPES = exports.ENUMBODY_TYPES = exports.DECLARATION_TYPES = exports.CONDITIONAL_TYPES = exports.COMPLETIONSTATEMENT_TYPES = exports.CLASS_TYPES = exports.BLOCK_TYPES = exports.BLOCKPARENT_TYPES = exports.BINARY_TYPES = exports.ACCESSOR_TYPES = void 0; |
||||
|
||||
var _definitions = require("../../definitions"); |
||||
|
||||
const STANDARDIZED_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Standardized"]; |
||||
exports.STANDARDIZED_TYPES = STANDARDIZED_TYPES; |
||||
const EXPRESSION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Expression"]; |
||||
exports.EXPRESSION_TYPES = EXPRESSION_TYPES; |
||||
const BINARY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Binary"]; |
||||
exports.BINARY_TYPES = BINARY_TYPES; |
||||
const SCOPABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Scopable"]; |
||||
exports.SCOPABLE_TYPES = SCOPABLE_TYPES; |
||||
const BLOCKPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["BlockParent"]; |
||||
exports.BLOCKPARENT_TYPES = BLOCKPARENT_TYPES; |
||||
const BLOCK_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Block"]; |
||||
exports.BLOCK_TYPES = BLOCK_TYPES; |
||||
const STATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Statement"]; |
||||
exports.STATEMENT_TYPES = STATEMENT_TYPES; |
||||
const TERMINATORLESS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Terminatorless"]; |
||||
exports.TERMINATORLESS_TYPES = TERMINATORLESS_TYPES; |
||||
const COMPLETIONSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["CompletionStatement"]; |
||||
exports.COMPLETIONSTATEMENT_TYPES = COMPLETIONSTATEMENT_TYPES; |
||||
const CONDITIONAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Conditional"]; |
||||
exports.CONDITIONAL_TYPES = CONDITIONAL_TYPES; |
||||
const LOOP_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Loop"]; |
||||
exports.LOOP_TYPES = LOOP_TYPES; |
||||
const WHILE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["While"]; |
||||
exports.WHILE_TYPES = WHILE_TYPES; |
||||
const EXPRESSIONWRAPPER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExpressionWrapper"]; |
||||
exports.EXPRESSIONWRAPPER_TYPES = EXPRESSIONWRAPPER_TYPES; |
||||
const FOR_TYPES = _definitions.FLIPPED_ALIAS_KEYS["For"]; |
||||
exports.FOR_TYPES = FOR_TYPES; |
||||
const FORXSTATEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ForXStatement"]; |
||||
exports.FORXSTATEMENT_TYPES = FORXSTATEMENT_TYPES; |
||||
const FUNCTION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Function"]; |
||||
exports.FUNCTION_TYPES = FUNCTION_TYPES; |
||||
const FUNCTIONPARENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FunctionParent"]; |
||||
exports.FUNCTIONPARENT_TYPES = FUNCTIONPARENT_TYPES; |
||||
const PUREISH_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pureish"]; |
||||
exports.PUREISH_TYPES = PUREISH_TYPES; |
||||
const DECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Declaration"]; |
||||
exports.DECLARATION_TYPES = DECLARATION_TYPES; |
||||
const PATTERNLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["PatternLike"]; |
||||
exports.PATTERNLIKE_TYPES = PATTERNLIKE_TYPES; |
||||
const LVAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["LVal"]; |
||||
exports.LVAL_TYPES = LVAL_TYPES; |
||||
const TSENTITYNAME_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSEntityName"]; |
||||
exports.TSENTITYNAME_TYPES = TSENTITYNAME_TYPES; |
||||
const LITERAL_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Literal"]; |
||||
exports.LITERAL_TYPES = LITERAL_TYPES; |
||||
const IMMUTABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Immutable"]; |
||||
exports.IMMUTABLE_TYPES = IMMUTABLE_TYPES; |
||||
const USERWHITESPACABLE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UserWhitespacable"]; |
||||
exports.USERWHITESPACABLE_TYPES = USERWHITESPACABLE_TYPES; |
||||
const METHOD_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Method"]; |
||||
exports.METHOD_TYPES = METHOD_TYPES; |
||||
const OBJECTMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ObjectMember"]; |
||||
exports.OBJECTMEMBER_TYPES = OBJECTMEMBER_TYPES; |
||||
const PROPERTY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Property"]; |
||||
exports.PROPERTY_TYPES = PROPERTY_TYPES; |
||||
const UNARYLIKE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["UnaryLike"]; |
||||
exports.UNARYLIKE_TYPES = UNARYLIKE_TYPES; |
||||
const PATTERN_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Pattern"]; |
||||
exports.PATTERN_TYPES = PATTERN_TYPES; |
||||
const CLASS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Class"]; |
||||
exports.CLASS_TYPES = CLASS_TYPES; |
||||
const MODULEDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleDeclaration"]; |
||||
exports.MODULEDECLARATION_TYPES = MODULEDECLARATION_TYPES; |
||||
const EXPORTDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ExportDeclaration"]; |
||||
exports.EXPORTDECLARATION_TYPES = EXPORTDECLARATION_TYPES; |
||||
const MODULESPECIFIER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["ModuleSpecifier"]; |
||||
exports.MODULESPECIFIER_TYPES = MODULESPECIFIER_TYPES; |
||||
const ACCESSOR_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Accessor"]; |
||||
exports.ACCESSOR_TYPES = ACCESSOR_TYPES; |
||||
const PRIVATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Private"]; |
||||
exports.PRIVATE_TYPES = PRIVATE_TYPES; |
||||
const FLOW_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Flow"]; |
||||
exports.FLOW_TYPES = FLOW_TYPES; |
||||
const FLOWTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowType"]; |
||||
exports.FLOWTYPE_TYPES = FLOWTYPE_TYPES; |
||||
const FLOWBASEANNOTATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowBaseAnnotation"]; |
||||
exports.FLOWBASEANNOTATION_TYPES = FLOWBASEANNOTATION_TYPES; |
||||
const FLOWDECLARATION_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowDeclaration"]; |
||||
exports.FLOWDECLARATION_TYPES = FLOWDECLARATION_TYPES; |
||||
const FLOWPREDICATE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["FlowPredicate"]; |
||||
exports.FLOWPREDICATE_TYPES = FLOWPREDICATE_TYPES; |
||||
const ENUMBODY_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumBody"]; |
||||
exports.ENUMBODY_TYPES = ENUMBODY_TYPES; |
||||
const ENUMMEMBER_TYPES = _definitions.FLIPPED_ALIAS_KEYS["EnumMember"]; |
||||
exports.ENUMMEMBER_TYPES = ENUMMEMBER_TYPES; |
||||
const JSX_TYPES = _definitions.FLIPPED_ALIAS_KEYS["JSX"]; |
||||
exports.JSX_TYPES = JSX_TYPES; |
||||
const MISCELLANEOUS_TYPES = _definitions.FLIPPED_ALIAS_KEYS["Miscellaneous"]; |
||||
exports.MISCELLANEOUS_TYPES = MISCELLANEOUS_TYPES; |
||||
const TYPESCRIPT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TypeScript"]; |
||||
exports.TYPESCRIPT_TYPES = TYPESCRIPT_TYPES; |
||||
const TSTYPEELEMENT_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSTypeElement"]; |
||||
exports.TSTYPEELEMENT_TYPES = TSTYPEELEMENT_TYPES; |
||||
const TSTYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSType"]; |
||||
exports.TSTYPE_TYPES = TSTYPE_TYPES; |
||||
const TSBASETYPE_TYPES = _definitions.FLIPPED_ALIAS_KEYS["TSBaseType"]; |
||||
exports.TSBASETYPE_TYPES = TSBASETYPE_TYPES; |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.UPDATE_OPERATORS = exports.UNARY_OPERATORS = exports.STRING_UNARY_OPERATORS = exports.STATEMENT_OR_BLOCK_KEYS = exports.NUMBER_UNARY_OPERATORS = exports.NUMBER_BINARY_OPERATORS = exports.NOT_LOCAL_BINDING = exports.LOGICAL_OPERATORS = exports.INHERIT_KEYS = exports.FOR_INIT_KEYS = exports.FLATTENABLE_KEYS = exports.EQUALITY_BINARY_OPERATORS = exports.COMPARISON_BINARY_OPERATORS = exports.COMMENT_KEYS = exports.BOOLEAN_UNARY_OPERATORS = exports.BOOLEAN_NUMBER_BINARY_OPERATORS = exports.BOOLEAN_BINARY_OPERATORS = exports.BLOCK_SCOPED_SYMBOL = exports.BINARY_OPERATORS = exports.ASSIGNMENT_OPERATORS = void 0; |
||||
const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"]; |
||||
exports.STATEMENT_OR_BLOCK_KEYS = STATEMENT_OR_BLOCK_KEYS; |
||||
const FLATTENABLE_KEYS = ["body", "expressions"]; |
||||
exports.FLATTENABLE_KEYS = FLATTENABLE_KEYS; |
||||
const FOR_INIT_KEYS = ["left", "init"]; |
||||
exports.FOR_INIT_KEYS = FOR_INIT_KEYS; |
||||
const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"]; |
||||
exports.COMMENT_KEYS = COMMENT_KEYS; |
||||
const LOGICAL_OPERATORS = ["||", "&&", "??"]; |
||||
exports.LOGICAL_OPERATORS = LOGICAL_OPERATORS; |
||||
const UPDATE_OPERATORS = ["++", "--"]; |
||||
exports.UPDATE_OPERATORS = UPDATE_OPERATORS; |
||||
const BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="]; |
||||
exports.BOOLEAN_NUMBER_BINARY_OPERATORS = BOOLEAN_NUMBER_BINARY_OPERATORS; |
||||
const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="]; |
||||
exports.EQUALITY_BINARY_OPERATORS = EQUALITY_BINARY_OPERATORS; |
||||
const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"]; |
||||
exports.COMPARISON_BINARY_OPERATORS = COMPARISON_BINARY_OPERATORS; |
||||
const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS]; |
||||
exports.BOOLEAN_BINARY_OPERATORS = BOOLEAN_BINARY_OPERATORS; |
||||
const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"]; |
||||
exports.NUMBER_BINARY_OPERATORS = NUMBER_BINARY_OPERATORS; |
||||
const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS, "|>"]; |
||||
exports.BINARY_OPERATORS = BINARY_OPERATORS; |
||||
const ASSIGNMENT_OPERATORS = ["=", "+=", ...NUMBER_BINARY_OPERATORS.map(op => op + "="), ...LOGICAL_OPERATORS.map(op => op + "=")]; |
||||
exports.ASSIGNMENT_OPERATORS = ASSIGNMENT_OPERATORS; |
||||
const BOOLEAN_UNARY_OPERATORS = ["delete", "!"]; |
||||
exports.BOOLEAN_UNARY_OPERATORS = BOOLEAN_UNARY_OPERATORS; |
||||
const NUMBER_UNARY_OPERATORS = ["+", "-", "~"]; |
||||
exports.NUMBER_UNARY_OPERATORS = NUMBER_UNARY_OPERATORS; |
||||
const STRING_UNARY_OPERATORS = ["typeof"]; |
||||
exports.STRING_UNARY_OPERATORS = STRING_UNARY_OPERATORS; |
||||
const UNARY_OPERATORS = ["void", "throw", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS]; |
||||
exports.UNARY_OPERATORS = UNARY_OPERATORS; |
||||
const INHERIT_KEYS = { |
||||
optional: ["typeAnnotation", "typeParameters", "returnType"], |
||||
force: ["start", "loc", "end"] |
||||
}; |
||||
exports.INHERIT_KEYS = INHERIT_KEYS; |
||||
const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped"); |
||||
exports.BLOCK_SCOPED_SYMBOL = BLOCK_SCOPED_SYMBOL; |
||||
const NOT_LOCAL_BINDING = Symbol.for("should not be considered a local binding"); |
||||
exports.NOT_LOCAL_BINDING = NOT_LOCAL_BINDING; |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = ensureBlock; |
||||
|
||||
var _toBlock = require("./toBlock"); |
||||
|
||||
function ensureBlock(node, key = "body") { |
||||
return node[key] = (0, _toBlock.default)(node[key], node); |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = gatherSequenceExpressions; |
||||
|
||||
var _getBindingIdentifiers = require("../retrievers/getBindingIdentifiers"); |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _generated2 = require("../builders/generated"); |
||||
|
||||
var _cloneNode = require("../clone/cloneNode"); |
||||
|
||||
function gatherSequenceExpressions(nodes, scope, declars) { |
||||
const exprs = []; |
||||
let ensureLastUndefined = true; |
||||
|
||||
for (const node of nodes) { |
||||
if (!(0, _generated.isEmptyStatement)(node)) { |
||||
ensureLastUndefined = false; |
||||
} |
||||
|
||||
if ((0, _generated.isExpression)(node)) { |
||||
exprs.push(node); |
||||
} else if ((0, _generated.isExpressionStatement)(node)) { |
||||
exprs.push(node.expression); |
||||
} else if ((0, _generated.isVariableDeclaration)(node)) { |
||||
if (node.kind !== "var") return; |
||||
|
||||
for (const declar of node.declarations) { |
||||
const bindings = (0, _getBindingIdentifiers.default)(declar); |
||||
|
||||
for (const key of Object.keys(bindings)) { |
||||
declars.push({ |
||||
kind: node.kind, |
||||
id: (0, _cloneNode.default)(bindings[key]) |
||||
}); |
||||
} |
||||
|
||||
if (declar.init) { |
||||
exprs.push((0, _generated2.assignmentExpression)("=", declar.id, declar.init)); |
||||
} |
||||
} |
||||
|
||||
ensureLastUndefined = true; |
||||
} else if ((0, _generated.isIfStatement)(node)) { |
||||
const consequent = node.consequent ? gatherSequenceExpressions([node.consequent], scope, declars) : scope.buildUndefinedNode(); |
||||
const alternate = node.alternate ? gatherSequenceExpressions([node.alternate], scope, declars) : scope.buildUndefinedNode(); |
||||
if (!consequent || !alternate) return; |
||||
exprs.push((0, _generated2.conditionalExpression)(node.test, consequent, alternate)); |
||||
} else if ((0, _generated.isBlockStatement)(node)) { |
||||
const body = gatherSequenceExpressions(node.body, scope, declars); |
||||
if (!body) return; |
||||
exprs.push(body); |
||||
} else if ((0, _generated.isEmptyStatement)(node)) { |
||||
if (nodes.indexOf(node) === 0) { |
||||
ensureLastUndefined = true; |
||||
} |
||||
} else { |
||||
return; |
||||
} |
||||
} |
||||
|
||||
if (ensureLastUndefined) { |
||||
exprs.push(scope.buildUndefinedNode()); |
||||
} |
||||
|
||||
if (exprs.length === 1) { |
||||
return exprs[0]; |
||||
} else { |
||||
return (0, _generated2.sequenceExpression)(exprs); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toBindingIdentifierName; |
||||
|
||||
var _toIdentifier = require("./toIdentifier"); |
||||
|
||||
function toBindingIdentifierName(name) { |
||||
name = (0, _toIdentifier.default)(name); |
||||
if (name === "eval" || name === "arguments") name = "_" + name; |
||||
return name; |
||||
} |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toBlock; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _generated2 = require("../builders/generated"); |
||||
|
||||
function toBlock(node, parent) { |
||||
if ((0, _generated.isBlockStatement)(node)) { |
||||
return node; |
||||
} |
||||
|
||||
let blockNodes = []; |
||||
|
||||
if ((0, _generated.isEmptyStatement)(node)) { |
||||
blockNodes = []; |
||||
} else { |
||||
if (!(0, _generated.isStatement)(node)) { |
||||
if ((0, _generated.isFunction)(parent)) { |
||||
node = (0, _generated2.returnStatement)(node); |
||||
} else { |
||||
node = (0, _generated2.expressionStatement)(node); |
||||
} |
||||
} |
||||
|
||||
blockNodes = [node]; |
||||
} |
||||
|
||||
return (0, _generated2.blockStatement)(blockNodes); |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toComputedKey; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _generated2 = require("../builders/generated"); |
||||
|
||||
function toComputedKey(node, key = node.key || node.property) { |
||||
if (!node.computed && (0, _generated.isIdentifier)(key)) key = (0, _generated2.stringLiteral)(key.name); |
||||
return key; |
||||
} |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _default = toExpression; |
||||
exports.default = _default; |
||||
|
||||
function toExpression(node) { |
||||
if ((0, _generated.isExpressionStatement)(node)) { |
||||
node = node.expression; |
||||
} |
||||
|
||||
if ((0, _generated.isExpression)(node)) { |
||||
return node; |
||||
} |
||||
|
||||
if ((0, _generated.isClass)(node)) { |
||||
node.type = "ClassExpression"; |
||||
} else if ((0, _generated.isFunction)(node)) { |
||||
node.type = "FunctionExpression"; |
||||
} |
||||
|
||||
if (!(0, _generated.isExpression)(node)) { |
||||
throw new Error(`cannot turn ${node.type} to an expression`); |
||||
} |
||||
|
||||
return node; |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toIdentifier; |
||||
|
||||
var _isValidIdentifier = require("../validators/isValidIdentifier"); |
||||
|
||||
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier"); |
||||
|
||||
function toIdentifier(input) { |
||||
input = input + ""; |
||||
let name = ""; |
||||
|
||||
for (const c of input) { |
||||
name += (0, _helperValidatorIdentifier.isIdentifierChar)(c.codePointAt(0)) ? c : "-"; |
||||
} |
||||
|
||||
name = name.replace(/^[-0-9]+/, ""); |
||||
name = name.replace(/[-\s]+(.)?/g, function (match, c) { |
||||
return c ? c.toUpperCase() : ""; |
||||
}); |
||||
|
||||
if (!(0, _isValidIdentifier.default)(name)) { |
||||
name = `_${name}`; |
||||
} |
||||
|
||||
return name || "_"; |
||||
} |
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toKeyAlias; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _cloneNode = require("../clone/cloneNode"); |
||||
|
||||
var _removePropertiesDeep = require("../modifications/removePropertiesDeep"); |
||||
|
||||
function toKeyAlias(node, key = node.key) { |
||||
let alias; |
||||
|
||||
if (node.kind === "method") { |
||||
return toKeyAlias.increment() + ""; |
||||
} else if ((0, _generated.isIdentifier)(key)) { |
||||
alias = key.name; |
||||
} else if ((0, _generated.isStringLiteral)(key)) { |
||||
alias = JSON.stringify(key.value); |
||||
} else { |
||||
alias = JSON.stringify((0, _removePropertiesDeep.default)((0, _cloneNode.default)(key))); |
||||
} |
||||
|
||||
if (node.computed) { |
||||
alias = `[${alias}]`; |
||||
} |
||||
|
||||
if (node.static) { |
||||
alias = `static:${alias}`; |
||||
} |
||||
|
||||
return alias; |
||||
} |
||||
|
||||
toKeyAlias.uid = 0; |
||||
|
||||
toKeyAlias.increment = function () { |
||||
if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) { |
||||
return toKeyAlias.uid = 0; |
||||
} else { |
||||
return toKeyAlias.uid++; |
||||
} |
||||
}; |
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = toSequenceExpression; |
||||
|
||||
var _gatherSequenceExpressions = require("./gatherSequenceExpressions"); |
||||
|
||||
function toSequenceExpression(nodes, scope) { |
||||
if (!(nodes != null && nodes.length)) return; |
||||
const declars = []; |
||||
const result = (0, _gatherSequenceExpressions.default)(nodes, scope, declars); |
||||
if (!result) return; |
||||
|
||||
for (const declar of declars) { |
||||
scope.push(declar); |
||||
} |
||||
|
||||
return result; |
||||
} |
@ -0,0 +1,47 @@
@@ -0,0 +1,47 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
var _generated2 = require("../builders/generated"); |
||||
|
||||
var _default = toStatement; |
||||
exports.default = _default; |
||||
|
||||
function toStatement(node, ignore) { |
||||
if ((0, _generated.isStatement)(node)) { |
||||
return node; |
||||
} |
||||
|
||||
let mustHaveId = false; |
||||
let newType; |
||||
|
||||
if ((0, _generated.isClass)(node)) { |
||||
mustHaveId = true; |
||||
newType = "ClassDeclaration"; |
||||
} else if ((0, _generated.isFunction)(node)) { |
||||
mustHaveId = true; |
||||
newType = "FunctionDeclaration"; |
||||
} else if ((0, _generated.isAssignmentExpression)(node)) { |
||||
return (0, _generated2.expressionStatement)(node); |
||||
} |
||||
|
||||
if (mustHaveId && !node.id) { |
||||
newType = false; |
||||
} |
||||
|
||||
if (!newType) { |
||||
if (ignore) { |
||||
return false; |
||||
} else { |
||||
throw new Error(`cannot turn ${node.type} to a statement`); |
||||
} |
||||
} |
||||
|
||||
node.type = newType; |
||||
return node; |
||||
} |
@ -0,0 +1,99 @@
@@ -0,0 +1,99 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _isValidIdentifier = require("../validators/isValidIdentifier"); |
||||
|
||||
var _generated = require("../builders/generated"); |
||||
|
||||
var _default = valueToNode; |
||||
exports.default = _default; |
||||
const objectToString = Function.call.bind(Object.prototype.toString); |
||||
|
||||
function isRegExp(value) { |
||||
return objectToString(value) === "[object RegExp]"; |
||||
} |
||||
|
||||
function isPlainObject(value) { |
||||
if (typeof value !== "object" || value === null || Object.prototype.toString.call(value) !== "[object Object]") { |
||||
return false; |
||||
} |
||||
|
||||
const proto = Object.getPrototypeOf(value); |
||||
return proto === null || Object.getPrototypeOf(proto) === null; |
||||
} |
||||
|
||||
function valueToNode(value) { |
||||
if (value === undefined) { |
||||
return (0, _generated.identifier)("undefined"); |
||||
} |
||||
|
||||
if (value === true || value === false) { |
||||
return (0, _generated.booleanLiteral)(value); |
||||
} |
||||
|
||||
if (value === null) { |
||||
return (0, _generated.nullLiteral)(); |
||||
} |
||||
|
||||
if (typeof value === "string") { |
||||
return (0, _generated.stringLiteral)(value); |
||||
} |
||||
|
||||
if (typeof value === "number") { |
||||
let result; |
||||
|
||||
if (Number.isFinite(value)) { |
||||
result = (0, _generated.numericLiteral)(Math.abs(value)); |
||||
} else { |
||||
let numerator; |
||||
|
||||
if (Number.isNaN(value)) { |
||||
numerator = (0, _generated.numericLiteral)(0); |
||||
} else { |
||||
numerator = (0, _generated.numericLiteral)(1); |
||||
} |
||||
|
||||
result = (0, _generated.binaryExpression)("/", numerator, (0, _generated.numericLiteral)(0)); |
||||
} |
||||
|
||||
if (value < 0 || Object.is(value, -0)) { |
||||
result = (0, _generated.unaryExpression)("-", result); |
||||
} |
||||
|
||||
return result; |
||||
} |
||||
|
||||
if (isRegExp(value)) { |
||||
const pattern = value.source; |
||||
const flags = value.toString().match(/\/([a-z]+|)$/)[1]; |
||||
return (0, _generated.regExpLiteral)(pattern, flags); |
||||
} |
||||
|
||||
if (Array.isArray(value)) { |
||||
return (0, _generated.arrayExpression)(value.map(valueToNode)); |
||||
} |
||||
|
||||
if (isPlainObject(value)) { |
||||
const props = []; |
||||
|
||||
for (const key of Object.keys(value)) { |
||||
let nodeKey; |
||||
|
||||
if ((0, _isValidIdentifier.default)(key)) { |
||||
nodeKey = (0, _generated.identifier)(key); |
||||
} else { |
||||
nodeKey = (0, _generated.stringLiteral)(key); |
||||
} |
||||
|
||||
props.push((0, _generated.objectProperty)(nodeKey, valueToNode(value[key]))); |
||||
} |
||||
|
||||
return (0, _generated.objectExpression)(props); |
||||
} |
||||
|
||||
throw new Error("don't know how to turn this value into a node"); |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,133 @@
@@ -0,0 +1,133 @@
|
||||
"use strict"; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
(0, _utils.default)("ArgumentPlaceholder", {}); |
||||
(0, _utils.default)("BindExpression", { |
||||
visitor: ["object", "callee"], |
||||
aliases: ["Expression"], |
||||
fields: !process.env.BABEL_TYPES_8_BREAKING ? { |
||||
object: { |
||||
validate: Object.assign(() => {}, { |
||||
oneOfNodeTypes: ["Expression"] |
||||
}) |
||||
}, |
||||
callee: { |
||||
validate: Object.assign(() => {}, { |
||||
oneOfNodeTypes: ["Expression"] |
||||
}) |
||||
} |
||||
} : { |
||||
object: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
}, |
||||
callee: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("ImportAttribute", { |
||||
visitor: ["key", "value"], |
||||
fields: { |
||||
key: { |
||||
validate: (0, _utils.assertNodeType)("Identifier", "StringLiteral") |
||||
}, |
||||
value: { |
||||
validate: (0, _utils.assertNodeType)("StringLiteral") |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("Decorator", { |
||||
visitor: ["expression"], |
||||
fields: { |
||||
expression: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("DoExpression", { |
||||
visitor: ["body"], |
||||
builder: ["body", "async"], |
||||
aliases: ["Expression"], |
||||
fields: { |
||||
body: { |
||||
validate: (0, _utils.assertNodeType)("BlockStatement") |
||||
}, |
||||
async: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
default: false |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("ExportDefaultSpecifier", { |
||||
visitor: ["exported"], |
||||
aliases: ["ModuleSpecifier"], |
||||
fields: { |
||||
exported: { |
||||
validate: (0, _utils.assertNodeType)("Identifier") |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("RecordExpression", { |
||||
visitor: ["properties"], |
||||
aliases: ["Expression"], |
||||
fields: { |
||||
properties: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("ObjectProperty", "SpreadElement"))) |
||||
} |
||||
} |
||||
}); |
||||
(0, _utils.default)("TupleExpression", { |
||||
fields: { |
||||
elements: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Expression", "SpreadElement"))), |
||||
default: [] |
||||
} |
||||
}, |
||||
visitor: ["elements"], |
||||
aliases: ["Expression"] |
||||
}); |
||||
(0, _utils.default)("DecimalLiteral", { |
||||
builder: ["value"], |
||||
fields: { |
||||
value: { |
||||
validate: (0, _utils.assertValueType)("string") |
||||
} |
||||
}, |
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"] |
||||
}); |
||||
(0, _utils.default)("ModuleExpression", { |
||||
visitor: ["body"], |
||||
fields: { |
||||
body: { |
||||
validate: (0, _utils.assertNodeType)("Program") |
||||
} |
||||
}, |
||||
aliases: ["Expression"] |
||||
}); |
||||
(0, _utils.default)("TopicReference", { |
||||
aliases: ["Expression"] |
||||
}); |
||||
(0, _utils.default)("PipelineTopicExpression", { |
||||
builder: ["expression"], |
||||
visitor: ["expression"], |
||||
fields: { |
||||
expression: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
}, |
||||
aliases: ["Expression"] |
||||
}); |
||||
(0, _utils.default)("PipelineBareFunction", { |
||||
builder: ["callee"], |
||||
visitor: ["callee"], |
||||
fields: { |
||||
callee: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
}, |
||||
aliases: ["Expression"] |
||||
}); |
||||
(0, _utils.default)("PipelinePrimaryTopicReference", { |
||||
aliases: ["Expression"] |
||||
}); |
@ -0,0 +1,486 @@
@@ -0,0 +1,486 @@
|
||||
"use strict"; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
const defineType = (0, _utils.defineAliasedType)("Flow"); |
||||
|
||||
const defineInterfaceishType = (name, typeParameterType = "TypeParameterDeclaration") => { |
||||
defineType(name, { |
||||
builder: ["id", "typeParameters", "extends", "body"], |
||||
visitor: ["id", "typeParameters", "extends", "mixins", "implements", "body"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)(typeParameterType), |
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
||||
mixins: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
||||
implements: (0, _utils.validateOptional)((0, _utils.arrayOfType)("ClassImplements")), |
||||
body: (0, _utils.validateType)("ObjectTypeAnnotation") |
||||
} |
||||
}); |
||||
}; |
||||
|
||||
defineType("AnyTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("ArrayTypeAnnotation", { |
||||
visitor: ["elementType"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
elementType: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("BooleanTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("BooleanLiteralTypeAnnotation", { |
||||
builder: ["value"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("NullLiteralTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("ClassImplements", { |
||||
visitor: ["id", "typeParameters"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineInterfaceishType("DeclareClass"); |
||||
defineType("DeclareFunction", { |
||||
visitor: ["id"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
predicate: (0, _utils.validateOptionalType)("DeclaredPredicate") |
||||
} |
||||
}); |
||||
defineInterfaceishType("DeclareInterface"); |
||||
defineType("DeclareModule", { |
||||
builder: ["id", "body", "kind"], |
||||
visitor: ["id", "body"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
||||
body: (0, _utils.validateType)("BlockStatement"), |
||||
kind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("CommonJS", "ES")) |
||||
} |
||||
}); |
||||
defineType("DeclareModuleExports", { |
||||
visitor: ["typeAnnotation"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation") |
||||
} |
||||
}); |
||||
defineType("DeclareTypeAlias", { |
||||
visitor: ["id", "typeParameters", "right"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
||||
right: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("DeclareOpaqueType", { |
||||
visitor: ["id", "typeParameters", "supertype"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
||||
supertype: (0, _utils.validateOptionalType)("FlowType"), |
||||
impltype: (0, _utils.validateOptionalType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("DeclareVariable", { |
||||
visitor: ["id"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier") |
||||
} |
||||
}); |
||||
defineType("DeclareExportDeclaration", { |
||||
visitor: ["declaration", "specifiers", "source"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
declaration: (0, _utils.validateOptionalType)("Flow"), |
||||
specifiers: (0, _utils.validateOptional)((0, _utils.arrayOfType)(["ExportSpecifier", "ExportNamespaceSpecifier"])), |
||||
source: (0, _utils.validateOptionalType)("StringLiteral"), |
||||
default: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("DeclareExportAllDeclaration", { |
||||
visitor: ["source"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
source: (0, _utils.validateType)("StringLiteral"), |
||||
exportKind: (0, _utils.validateOptional)((0, _utils.assertOneOf)("type", "value")) |
||||
} |
||||
}); |
||||
defineType("DeclaredPredicate", { |
||||
visitor: ["value"], |
||||
aliases: ["FlowPredicate"], |
||||
fields: { |
||||
value: (0, _utils.validateType)("Flow") |
||||
} |
||||
}); |
||||
defineType("ExistsTypeAnnotation", { |
||||
aliases: ["FlowType"] |
||||
}); |
||||
defineType("FunctionTypeAnnotation", { |
||||
visitor: ["typeParameters", "params", "rest", "returnType"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FunctionTypeParam")), |
||||
rest: (0, _utils.validateOptionalType)("FunctionTypeParam"), |
||||
this: (0, _utils.validateOptionalType)("FunctionTypeParam"), |
||||
returnType: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("FunctionTypeParam", { |
||||
visitor: ["name", "typeAnnotation"], |
||||
fields: { |
||||
name: (0, _utils.validateOptionalType)("Identifier"), |
||||
typeAnnotation: (0, _utils.validateType)("FlowType"), |
||||
optional: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("GenericTypeAnnotation", { |
||||
visitor: ["id", "typeParameters"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("InferredPredicate", { |
||||
aliases: ["FlowPredicate"] |
||||
}); |
||||
defineType("InterfaceExtends", { |
||||
visitor: ["id", "typeParameters"], |
||||
fields: { |
||||
id: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineInterfaceishType("InterfaceDeclaration"); |
||||
defineType("InterfaceTypeAnnotation", { |
||||
visitor: ["extends", "body"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("InterfaceExtends")), |
||||
body: (0, _utils.validateType)("ObjectTypeAnnotation") |
||||
} |
||||
}); |
||||
defineType("IntersectionTypeAnnotation", { |
||||
visitor: ["types"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
||||
} |
||||
}); |
||||
defineType("MixedTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("EmptyTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("NullableTypeAnnotation", { |
||||
visitor: ["typeAnnotation"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("NumberLiteralTypeAnnotation", { |
||||
builder: ["value"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("number")) |
||||
} |
||||
}); |
||||
defineType("NumberTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("ObjectTypeAnnotation", { |
||||
visitor: ["properties", "indexers", "callProperties", "internalSlots"], |
||||
aliases: ["FlowType"], |
||||
builder: ["properties", "indexers", "callProperties", "internalSlots", "exact"], |
||||
fields: { |
||||
properties: (0, _utils.validate)((0, _utils.arrayOfType)(["ObjectTypeProperty", "ObjectTypeSpreadProperty"])), |
||||
indexers: { |
||||
validate: (0, _utils.arrayOfType)("ObjectTypeIndexer"), |
||||
optional: true, |
||||
default: [] |
||||
}, |
||||
callProperties: { |
||||
validate: (0, _utils.arrayOfType)("ObjectTypeCallProperty"), |
||||
optional: true, |
||||
default: [] |
||||
}, |
||||
internalSlots: { |
||||
validate: (0, _utils.arrayOfType)("ObjectTypeInternalSlot"), |
||||
optional: true, |
||||
default: [] |
||||
}, |
||||
exact: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
default: false |
||||
}, |
||||
inexact: (0, _utils.validateOptional)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("ObjectTypeInternalSlot", { |
||||
visitor: ["id", "value", "optional", "static", "method"], |
||||
aliases: ["UserWhitespacable"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
value: (0, _utils.validateType)("FlowType"), |
||||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("ObjectTypeCallProperty", { |
||||
visitor: ["value"], |
||||
aliases: ["UserWhitespacable"], |
||||
fields: { |
||||
value: (0, _utils.validateType)("FlowType"), |
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("ObjectTypeIndexer", { |
||||
visitor: ["id", "key", "value", "variance"], |
||||
aliases: ["UserWhitespacable"], |
||||
fields: { |
||||
id: (0, _utils.validateOptionalType)("Identifier"), |
||||
key: (0, _utils.validateType)("FlowType"), |
||||
value: (0, _utils.validateType)("FlowType"), |
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
variance: (0, _utils.validateOptionalType)("Variance") |
||||
} |
||||
}); |
||||
defineType("ObjectTypeProperty", { |
||||
visitor: ["key", "value", "variance"], |
||||
aliases: ["UserWhitespacable"], |
||||
fields: { |
||||
key: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
||||
value: (0, _utils.validateType)("FlowType"), |
||||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("init", "get", "set")), |
||||
static: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
proto: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
variance: (0, _utils.validateOptionalType)("Variance"), |
||||
method: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("ObjectTypeSpreadProperty", { |
||||
visitor: ["argument"], |
||||
aliases: ["UserWhitespacable"], |
||||
fields: { |
||||
argument: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("OpaqueType", { |
||||
visitor: ["id", "typeParameters", "supertype", "impltype"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
||||
supertype: (0, _utils.validateOptionalType)("FlowType"), |
||||
impltype: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("QualifiedTypeIdentifier", { |
||||
visitor: ["id", "qualification"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
qualification: (0, _utils.validateType)(["Identifier", "QualifiedTypeIdentifier"]) |
||||
} |
||||
}); |
||||
defineType("StringLiteralTypeAnnotation", { |
||||
builder: ["value"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
value: (0, _utils.validate)((0, _utils.assertValueType)("string")) |
||||
} |
||||
}); |
||||
defineType("StringTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("SymbolTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("ThisTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("TupleTypeAnnotation", { |
||||
visitor: ["types"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
||||
} |
||||
}); |
||||
defineType("TypeofTypeAnnotation", { |
||||
visitor: ["argument"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
argument: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("TypeAlias", { |
||||
visitor: ["id", "typeParameters", "right"], |
||||
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TypeParameterDeclaration"), |
||||
right: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("TypeAnnotation", { |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("TypeCastExpression", { |
||||
visitor: ["expression", "typeAnnotation"], |
||||
aliases: ["ExpressionWrapper", "Expression"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("Expression"), |
||||
typeAnnotation: (0, _utils.validateType)("TypeAnnotation") |
||||
} |
||||
}); |
||||
defineType("TypeParameter", { |
||||
visitor: ["bound", "default", "variance"], |
||||
fields: { |
||||
name: (0, _utils.validate)((0, _utils.assertValueType)("string")), |
||||
bound: (0, _utils.validateOptionalType)("TypeAnnotation"), |
||||
default: (0, _utils.validateOptionalType)("FlowType"), |
||||
variance: (0, _utils.validateOptionalType)("Variance") |
||||
} |
||||
}); |
||||
defineType("TypeParameterDeclaration", { |
||||
visitor: ["params"], |
||||
fields: { |
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("TypeParameter")) |
||||
} |
||||
}); |
||||
defineType("TypeParameterInstantiation", { |
||||
visitor: ["params"], |
||||
fields: { |
||||
params: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
||||
} |
||||
}); |
||||
defineType("UnionTypeAnnotation", { |
||||
visitor: ["types"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
types: (0, _utils.validate)((0, _utils.arrayOfType)("FlowType")) |
||||
} |
||||
}); |
||||
defineType("Variance", { |
||||
builder: ["kind"], |
||||
fields: { |
||||
kind: (0, _utils.validate)((0, _utils.assertOneOf)("minus", "plus")) |
||||
} |
||||
}); |
||||
defineType("VoidTypeAnnotation", { |
||||
aliases: ["FlowType", "FlowBaseAnnotation"] |
||||
}); |
||||
defineType("EnumDeclaration", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "body"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
body: (0, _utils.validateType)(["EnumBooleanBody", "EnumNumberBody", "EnumStringBody", "EnumSymbolBody"]) |
||||
} |
||||
}); |
||||
defineType("EnumBooleanBody", { |
||||
aliases: ["EnumBody"], |
||||
visitor: ["members"], |
||||
fields: { |
||||
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
members: (0, _utils.validateArrayOfType)("EnumBooleanMember"), |
||||
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("EnumNumberBody", { |
||||
aliases: ["EnumBody"], |
||||
visitor: ["members"], |
||||
fields: { |
||||
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
members: (0, _utils.validateArrayOfType)("EnumNumberMember"), |
||||
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("EnumStringBody", { |
||||
aliases: ["EnumBody"], |
||||
visitor: ["members"], |
||||
fields: { |
||||
explicitType: (0, _utils.validate)((0, _utils.assertValueType)("boolean")), |
||||
members: (0, _utils.validateArrayOfType)(["EnumStringMember", "EnumDefaultedMember"]), |
||||
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("EnumSymbolBody", { |
||||
aliases: ["EnumBody"], |
||||
visitor: ["members"], |
||||
fields: { |
||||
members: (0, _utils.validateArrayOfType)("EnumDefaultedMember"), |
||||
hasUnknownMembers: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
||||
defineType("EnumBooleanMember", { |
||||
aliases: ["EnumMember"], |
||||
visitor: ["id"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
init: (0, _utils.validateType)("BooleanLiteral") |
||||
} |
||||
}); |
||||
defineType("EnumNumberMember", { |
||||
aliases: ["EnumMember"], |
||||
visitor: ["id", "init"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
init: (0, _utils.validateType)("NumericLiteral") |
||||
} |
||||
}); |
||||
defineType("EnumStringMember", { |
||||
aliases: ["EnumMember"], |
||||
visitor: ["id", "init"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
init: (0, _utils.validateType)("StringLiteral") |
||||
} |
||||
}); |
||||
defineType("EnumDefaultedMember", { |
||||
aliases: ["EnumMember"], |
||||
visitor: ["id"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier") |
||||
} |
||||
}); |
||||
defineType("IndexedAccessType", { |
||||
visitor: ["objectType", "indexType"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
objectType: (0, _utils.validateType)("FlowType"), |
||||
indexType: (0, _utils.validateType)("FlowType") |
||||
} |
||||
}); |
||||
defineType("OptionalIndexedAccessType", { |
||||
visitor: ["objectType", "indexType"], |
||||
aliases: ["FlowType"], |
||||
fields: { |
||||
objectType: (0, _utils.validateType)("FlowType"), |
||||
indexType: (0, _utils.validateType)("FlowType"), |
||||
optional: (0, _utils.validate)((0, _utils.assertValueType)("boolean")) |
||||
} |
||||
}); |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
Object.defineProperty(exports, "ALIAS_KEYS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.ALIAS_KEYS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "BUILDER_KEYS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.BUILDER_KEYS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "DEPRECATED_KEYS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.DEPRECATED_KEYS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "FLIPPED_ALIAS_KEYS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.FLIPPED_ALIAS_KEYS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "NODE_FIELDS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.NODE_FIELDS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "NODE_PARENT_VALIDATIONS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.NODE_PARENT_VALIDATIONS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "PLACEHOLDERS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _placeholders.PLACEHOLDERS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "PLACEHOLDERS_ALIAS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _placeholders.PLACEHOLDERS_ALIAS; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "PLACEHOLDERS_FLIPPED_ALIAS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _placeholders.PLACEHOLDERS_FLIPPED_ALIAS; |
||||
} |
||||
}); |
||||
exports.TYPES = void 0; |
||||
Object.defineProperty(exports, "VISITOR_KEYS", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _utils.VISITOR_KEYS; |
||||
} |
||||
}); |
||||
|
||||
var _toFastProperties = require("to-fast-properties"); |
||||
|
||||
require("./core"); |
||||
|
||||
require("./flow"); |
||||
|
||||
require("./jsx"); |
||||
|
||||
require("./misc"); |
||||
|
||||
require("./experimental"); |
||||
|
||||
require("./typescript"); |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
var _placeholders = require("./placeholders"); |
||||
|
||||
_toFastProperties(_utils.VISITOR_KEYS); |
||||
|
||||
_toFastProperties(_utils.ALIAS_KEYS); |
||||
|
||||
_toFastProperties(_utils.FLIPPED_ALIAS_KEYS); |
||||
|
||||
_toFastProperties(_utils.NODE_FIELDS); |
||||
|
||||
_toFastProperties(_utils.BUILDER_KEYS); |
||||
|
||||
_toFastProperties(_utils.DEPRECATED_KEYS); |
||||
|
||||
_toFastProperties(_placeholders.PLACEHOLDERS_ALIAS); |
||||
|
||||
_toFastProperties(_placeholders.PLACEHOLDERS_FLIPPED_ALIAS); |
||||
|
||||
const TYPES = [].concat(Object.keys(_utils.VISITOR_KEYS), Object.keys(_utils.FLIPPED_ALIAS_KEYS), Object.keys(_utils.DEPRECATED_KEYS)); |
||||
exports.TYPES = TYPES; |
@ -0,0 +1,157 @@
@@ -0,0 +1,157 @@
|
||||
"use strict"; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
const defineType = (0, _utils.defineAliasedType)("JSX"); |
||||
defineType("JSXAttribute", { |
||||
visitor: ["name", "value"], |
||||
aliases: ["Immutable"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXNamespacedName") |
||||
}, |
||||
value: { |
||||
optional: true, |
||||
validate: (0, _utils.assertNodeType)("JSXElement", "JSXFragment", "StringLiteral", "JSXExpressionContainer") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXClosingElement", { |
||||
visitor: ["name"], |
||||
aliases: ["Immutable"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXElement", { |
||||
builder: ["openingElement", "closingElement", "children", "selfClosing"], |
||||
visitor: ["openingElement", "children", "closingElement"], |
||||
aliases: ["Immutable", "Expression"], |
||||
fields: Object.assign({ |
||||
openingElement: { |
||||
validate: (0, _utils.assertNodeType)("JSXOpeningElement") |
||||
}, |
||||
closingElement: { |
||||
optional: true, |
||||
validate: (0, _utils.assertNodeType)("JSXClosingElement") |
||||
}, |
||||
children: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) |
||||
} |
||||
}, { |
||||
selfClosing: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
optional: true |
||||
} |
||||
}) |
||||
}); |
||||
defineType("JSXEmptyExpression", {}); |
||||
defineType("JSXExpressionContainer", { |
||||
visitor: ["expression"], |
||||
aliases: ["Immutable"], |
||||
fields: { |
||||
expression: { |
||||
validate: (0, _utils.assertNodeType)("Expression", "JSXEmptyExpression") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXSpreadChild", { |
||||
visitor: ["expression"], |
||||
aliases: ["Immutable"], |
||||
fields: { |
||||
expression: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXIdentifier", { |
||||
builder: ["name"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertValueType)("string") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXMemberExpression", { |
||||
visitor: ["object", "property"], |
||||
fields: { |
||||
object: { |
||||
validate: (0, _utils.assertNodeType)("JSXMemberExpression", "JSXIdentifier") |
||||
}, |
||||
property: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXNamespacedName", { |
||||
visitor: ["namespace", "name"], |
||||
fields: { |
||||
namespace: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
||||
}, |
||||
name: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXOpeningElement", { |
||||
builder: ["name", "attributes", "selfClosing"], |
||||
visitor: ["name", "attributes"], |
||||
aliases: ["Immutable"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertNodeType)("JSXIdentifier", "JSXMemberExpression", "JSXNamespacedName") |
||||
}, |
||||
selfClosing: { |
||||
default: false |
||||
}, |
||||
attributes: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXAttribute", "JSXSpreadAttribute"))) |
||||
}, |
||||
typeParameters: { |
||||
validate: (0, _utils.assertNodeType)("TypeParameterInstantiation", "TSTypeParameterInstantiation"), |
||||
optional: true |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXSpreadAttribute", { |
||||
visitor: ["argument"], |
||||
fields: { |
||||
argument: { |
||||
validate: (0, _utils.assertNodeType)("Expression") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXText", { |
||||
aliases: ["Immutable"], |
||||
builder: ["value"], |
||||
fields: { |
||||
value: { |
||||
validate: (0, _utils.assertValueType)("string") |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXFragment", { |
||||
builder: ["openingFragment", "closingFragment", "children"], |
||||
visitor: ["openingFragment", "children", "closingFragment"], |
||||
aliases: ["Immutable", "Expression"], |
||||
fields: { |
||||
openingFragment: { |
||||
validate: (0, _utils.assertNodeType)("JSXOpeningFragment") |
||||
}, |
||||
closingFragment: { |
||||
validate: (0, _utils.assertNodeType)("JSXClosingFragment") |
||||
}, |
||||
children: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement", "JSXFragment"))) |
||||
} |
||||
} |
||||
}); |
||||
defineType("JSXOpeningFragment", { |
||||
aliases: ["Immutable"] |
||||
}); |
||||
defineType("JSXClosingFragment", { |
||||
aliases: ["Immutable"] |
||||
}); |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
"use strict"; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
var _placeholders = require("./placeholders"); |
||||
|
||||
const defineType = (0, _utils.defineAliasedType)("Miscellaneous"); |
||||
{ |
||||
defineType("Noop", { |
||||
visitor: [] |
||||
}); |
||||
} |
||||
defineType("Placeholder", { |
||||
visitor: [], |
||||
builder: ["expectedNode", "name"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertNodeType)("Identifier") |
||||
}, |
||||
expectedNode: { |
||||
validate: (0, _utils.assertOneOf)(..._placeholders.PLACEHOLDERS) |
||||
} |
||||
} |
||||
}); |
||||
defineType("V8IntrinsicIdentifier", { |
||||
builder: ["name"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertValueType)("string") |
||||
} |
||||
} |
||||
}); |
@ -0,0 +1,33 @@
@@ -0,0 +1,33 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.PLACEHOLDERS_FLIPPED_ALIAS = exports.PLACEHOLDERS_ALIAS = exports.PLACEHOLDERS = void 0; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
const PLACEHOLDERS = ["Identifier", "StringLiteral", "Expression", "Statement", "Declaration", "BlockStatement", "ClassBody", "Pattern"]; |
||||
exports.PLACEHOLDERS = PLACEHOLDERS; |
||||
const PLACEHOLDERS_ALIAS = { |
||||
Declaration: ["Statement"], |
||||
Pattern: ["PatternLike", "LVal"] |
||||
}; |
||||
exports.PLACEHOLDERS_ALIAS = PLACEHOLDERS_ALIAS; |
||||
|
||||
for (const type of PLACEHOLDERS) { |
||||
const alias = _utils.ALIAS_KEYS[type]; |
||||
if (alias != null && alias.length) PLACEHOLDERS_ALIAS[type] = alias; |
||||
} |
||||
|
||||
const PLACEHOLDERS_FLIPPED_ALIAS = {}; |
||||
exports.PLACEHOLDERS_FLIPPED_ALIAS = PLACEHOLDERS_FLIPPED_ALIAS; |
||||
Object.keys(PLACEHOLDERS_ALIAS).forEach(type => { |
||||
PLACEHOLDERS_ALIAS[type].forEach(alias => { |
||||
if (!Object.hasOwnProperty.call(PLACEHOLDERS_FLIPPED_ALIAS, alias)) { |
||||
PLACEHOLDERS_FLIPPED_ALIAS[alias] = []; |
||||
} |
||||
|
||||
PLACEHOLDERS_FLIPPED_ALIAS[alias].push(type); |
||||
}); |
||||
}); |
@ -0,0 +1,487 @@
@@ -0,0 +1,487 @@
|
||||
"use strict"; |
||||
|
||||
var _utils = require("./utils"); |
||||
|
||||
var _core = require("./core"); |
||||
|
||||
var _is = require("../validators/is"); |
||||
|
||||
const defineType = (0, _utils.defineAliasedType)("TypeScript"); |
||||
const bool = (0, _utils.assertValueType)("boolean"); |
||||
const tSFunctionTypeAnnotationCommon = { |
||||
returnType: { |
||||
validate: (0, _utils.assertNodeType)("TSTypeAnnotation", "Noop"), |
||||
optional: true |
||||
}, |
||||
typeParameters: { |
||||
validate: (0, _utils.assertNodeType)("TSTypeParameterDeclaration", "Noop"), |
||||
optional: true |
||||
} |
||||
}; |
||||
defineType("TSParameterProperty", { |
||||
aliases: ["LVal"], |
||||
visitor: ["parameter"], |
||||
fields: { |
||||
accessibility: { |
||||
validate: (0, _utils.assertOneOf)("public", "private", "protected"), |
||||
optional: true |
||||
}, |
||||
readonly: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
optional: true |
||||
}, |
||||
parameter: { |
||||
validate: (0, _utils.assertNodeType)("Identifier", "AssignmentPattern") |
||||
}, |
||||
override: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
optional: true |
||||
}, |
||||
decorators: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("Decorator"))), |
||||
optional: true |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSDeclareFunction", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "typeParameters", "params", "returnType"], |
||||
fields: Object.assign({}, _core.functionDeclarationCommon, tSFunctionTypeAnnotationCommon) |
||||
}); |
||||
defineType("TSDeclareMethod", { |
||||
visitor: ["decorators", "key", "typeParameters", "params", "returnType"], |
||||
fields: Object.assign({}, _core.classMethodOrDeclareMethodCommon, tSFunctionTypeAnnotationCommon) |
||||
}); |
||||
defineType("TSQualifiedName", { |
||||
aliases: ["TSEntityName"], |
||||
visitor: ["left", "right"], |
||||
fields: { |
||||
left: (0, _utils.validateType)("TSEntityName"), |
||||
right: (0, _utils.validateType)("Identifier") |
||||
} |
||||
}); |
||||
const signatureDeclarationCommon = { |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
||||
["parameters"]: (0, _utils.validateArrayOfType)(["Identifier", "RestElement"]), |
||||
["typeAnnotation"]: (0, _utils.validateOptionalType)("TSTypeAnnotation") |
||||
}; |
||||
const callConstructSignatureDeclaration = { |
||||
aliases: ["TSTypeElement"], |
||||
visitor: ["typeParameters", "parameters", "typeAnnotation"], |
||||
fields: signatureDeclarationCommon |
||||
}; |
||||
defineType("TSCallSignatureDeclaration", callConstructSignatureDeclaration); |
||||
defineType("TSConstructSignatureDeclaration", callConstructSignatureDeclaration); |
||||
const namedTypeElementCommon = { |
||||
key: (0, _utils.validateType)("Expression"), |
||||
computed: (0, _utils.validate)(bool), |
||||
optional: (0, _utils.validateOptional)(bool) |
||||
}; |
||||
defineType("TSPropertySignature", { |
||||
aliases: ["TSTypeElement"], |
||||
visitor: ["key", "typeAnnotation", "initializer"], |
||||
fields: Object.assign({}, namedTypeElementCommon, { |
||||
readonly: (0, _utils.validateOptional)(bool), |
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), |
||||
initializer: (0, _utils.validateOptionalType)("Expression"), |
||||
kind: { |
||||
validate: (0, _utils.assertOneOf)("get", "set") |
||||
} |
||||
}) |
||||
}); |
||||
defineType("TSMethodSignature", { |
||||
aliases: ["TSTypeElement"], |
||||
visitor: ["key", "typeParameters", "parameters", "typeAnnotation"], |
||||
fields: Object.assign({}, signatureDeclarationCommon, namedTypeElementCommon, { |
||||
kind: { |
||||
validate: (0, _utils.assertOneOf)("method", "get", "set") |
||||
} |
||||
}) |
||||
}); |
||||
defineType("TSIndexSignature", { |
||||
aliases: ["TSTypeElement"], |
||||
visitor: ["parameters", "typeAnnotation"], |
||||
fields: { |
||||
readonly: (0, _utils.validateOptional)(bool), |
||||
static: (0, _utils.validateOptional)(bool), |
||||
parameters: (0, _utils.validateArrayOfType)("Identifier"), |
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation") |
||||
} |
||||
}); |
||||
const tsKeywordTypes = ["TSAnyKeyword", "TSBooleanKeyword", "TSBigIntKeyword", "TSIntrinsicKeyword", "TSNeverKeyword", "TSNullKeyword", "TSNumberKeyword", "TSObjectKeyword", "TSStringKeyword", "TSSymbolKeyword", "TSUndefinedKeyword", "TSUnknownKeyword", "TSVoidKeyword"]; |
||||
|
||||
for (const type of tsKeywordTypes) { |
||||
defineType(type, { |
||||
aliases: ["TSType", "TSBaseType"], |
||||
visitor: [], |
||||
fields: {} |
||||
}); |
||||
} |
||||
|
||||
defineType("TSThisType", { |
||||
aliases: ["TSType", "TSBaseType"], |
||||
visitor: [], |
||||
fields: {} |
||||
}); |
||||
const fnOrCtrBase = { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeParameters", "parameters", "typeAnnotation"] |
||||
}; |
||||
defineType("TSFunctionType", Object.assign({}, fnOrCtrBase, { |
||||
fields: signatureDeclarationCommon |
||||
})); |
||||
defineType("TSConstructorType", Object.assign({}, fnOrCtrBase, { |
||||
fields: Object.assign({}, signatureDeclarationCommon, { |
||||
abstract: (0, _utils.validateOptional)(bool) |
||||
}) |
||||
})); |
||||
defineType("TSTypeReference", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeName", "typeParameters"], |
||||
fields: { |
||||
typeName: (0, _utils.validateType)("TSEntityName"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("TSTypePredicate", { |
||||
aliases: ["TSType"], |
||||
visitor: ["parameterName", "typeAnnotation"], |
||||
builder: ["parameterName", "typeAnnotation", "asserts"], |
||||
fields: { |
||||
parameterName: (0, _utils.validateType)(["Identifier", "TSThisType"]), |
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSTypeAnnotation"), |
||||
asserts: (0, _utils.validateOptional)(bool) |
||||
} |
||||
}); |
||||
defineType("TSTypeQuery", { |
||||
aliases: ["TSType"], |
||||
visitor: ["exprName", "typeParameters"], |
||||
fields: { |
||||
exprName: (0, _utils.validateType)(["TSEntityName", "TSImportType"]), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("TSTypeLiteral", { |
||||
aliases: ["TSType"], |
||||
visitor: ["members"], |
||||
fields: { |
||||
members: (0, _utils.validateArrayOfType)("TSTypeElement") |
||||
} |
||||
}); |
||||
defineType("TSArrayType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["elementType"], |
||||
fields: { |
||||
elementType: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSTupleType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["elementTypes"], |
||||
fields: { |
||||
elementTypes: (0, _utils.validateArrayOfType)(["TSType", "TSNamedTupleMember"]) |
||||
} |
||||
}); |
||||
defineType("TSOptionalType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSRestType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSNamedTupleMember", { |
||||
visitor: ["label", "elementType"], |
||||
builder: ["label", "elementType", "optional"], |
||||
fields: { |
||||
label: (0, _utils.validateType)("Identifier"), |
||||
optional: { |
||||
validate: bool, |
||||
default: false |
||||
}, |
||||
elementType: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
const unionOrIntersection = { |
||||
aliases: ["TSType"], |
||||
visitor: ["types"], |
||||
fields: { |
||||
types: (0, _utils.validateArrayOfType)("TSType") |
||||
} |
||||
}; |
||||
defineType("TSUnionType", unionOrIntersection); |
||||
defineType("TSIntersectionType", unionOrIntersection); |
||||
defineType("TSConditionalType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["checkType", "extendsType", "trueType", "falseType"], |
||||
fields: { |
||||
checkType: (0, _utils.validateType)("TSType"), |
||||
extendsType: (0, _utils.validateType)("TSType"), |
||||
trueType: (0, _utils.validateType)("TSType"), |
||||
falseType: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSInferType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeParameter"], |
||||
fields: { |
||||
typeParameter: (0, _utils.validateType)("TSTypeParameter") |
||||
} |
||||
}); |
||||
defineType("TSParenthesizedType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSTypeOperator", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
operator: (0, _utils.validate)((0, _utils.assertValueType)("string")), |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSIndexedAccessType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["objectType", "indexType"], |
||||
fields: { |
||||
objectType: (0, _utils.validateType)("TSType"), |
||||
indexType: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSMappedType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["typeParameter", "typeAnnotation", "nameType"], |
||||
fields: { |
||||
readonly: (0, _utils.validateOptional)(bool), |
||||
typeParameter: (0, _utils.validateType)("TSTypeParameter"), |
||||
optional: (0, _utils.validateOptional)(bool), |
||||
typeAnnotation: (0, _utils.validateOptionalType)("TSType"), |
||||
nameType: (0, _utils.validateOptionalType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSLiteralType", { |
||||
aliases: ["TSType", "TSBaseType"], |
||||
visitor: ["literal"], |
||||
fields: { |
||||
literal: { |
||||
validate: function () { |
||||
const unaryExpression = (0, _utils.assertNodeType)("NumericLiteral", "BigIntLiteral"); |
||||
const unaryOperator = (0, _utils.assertOneOf)("-"); |
||||
const literal = (0, _utils.assertNodeType)("NumericLiteral", "StringLiteral", "BooleanLiteral", "BigIntLiteral"); |
||||
|
||||
function validator(parent, key, node) { |
||||
if ((0, _is.default)("UnaryExpression", node)) { |
||||
unaryOperator(node, "operator", node.operator); |
||||
unaryExpression(node, "argument", node.argument); |
||||
} else { |
||||
literal(parent, key, node); |
||||
} |
||||
} |
||||
|
||||
validator.oneOfNodeTypes = ["NumericLiteral", "StringLiteral", "BooleanLiteral", "BigIntLiteral", "UnaryExpression"]; |
||||
return validator; |
||||
}() |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSExpressionWithTypeArguments", { |
||||
aliases: ["TSType"], |
||||
visitor: ["expression", "typeParameters"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("TSEntityName"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("TSInterfaceDeclaration", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "typeParameters", "extends", "body"], |
||||
fields: { |
||||
declare: (0, _utils.validateOptional)(bool), |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
||||
extends: (0, _utils.validateOptional)((0, _utils.arrayOfType)("TSExpressionWithTypeArguments")), |
||||
body: (0, _utils.validateType)("TSInterfaceBody") |
||||
} |
||||
}); |
||||
defineType("TSInterfaceBody", { |
||||
visitor: ["body"], |
||||
fields: { |
||||
body: (0, _utils.validateArrayOfType)("TSTypeElement") |
||||
} |
||||
}); |
||||
defineType("TSTypeAliasDeclaration", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "typeParameters", "typeAnnotation"], |
||||
fields: { |
||||
declare: (0, _utils.validateOptional)(bool), |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterDeclaration"), |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSInstantiationExpression", { |
||||
aliases: ["Expression"], |
||||
visitor: ["expression", "typeParameters"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("Expression"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("TSAsExpression", { |
||||
aliases: ["Expression", "LVal", "PatternLike"], |
||||
visitor: ["expression", "typeAnnotation"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("Expression"), |
||||
typeAnnotation: (0, _utils.validateType)("TSType") |
||||
} |
||||
}); |
||||
defineType("TSTypeAssertion", { |
||||
aliases: ["Expression", "LVal", "PatternLike"], |
||||
visitor: ["typeAnnotation", "expression"], |
||||
fields: { |
||||
typeAnnotation: (0, _utils.validateType)("TSType"), |
||||
expression: (0, _utils.validateType)("Expression") |
||||
} |
||||
}); |
||||
defineType("TSEnumDeclaration", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "members"], |
||||
fields: { |
||||
declare: (0, _utils.validateOptional)(bool), |
||||
const: (0, _utils.validateOptional)(bool), |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
members: (0, _utils.validateArrayOfType)("TSEnumMember"), |
||||
initializer: (0, _utils.validateOptionalType)("Expression") |
||||
} |
||||
}); |
||||
defineType("TSEnumMember", { |
||||
visitor: ["id", "initializer"], |
||||
fields: { |
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
||||
initializer: (0, _utils.validateOptionalType)("Expression") |
||||
} |
||||
}); |
||||
defineType("TSModuleDeclaration", { |
||||
aliases: ["Statement", "Declaration"], |
||||
visitor: ["id", "body"], |
||||
fields: { |
||||
declare: (0, _utils.validateOptional)(bool), |
||||
global: (0, _utils.validateOptional)(bool), |
||||
id: (0, _utils.validateType)(["Identifier", "StringLiteral"]), |
||||
body: (0, _utils.validateType)(["TSModuleBlock", "TSModuleDeclaration"]) |
||||
} |
||||
}); |
||||
defineType("TSModuleBlock", { |
||||
aliases: ["Scopable", "Block", "BlockParent"], |
||||
visitor: ["body"], |
||||
fields: { |
||||
body: (0, _utils.validateArrayOfType)("Statement") |
||||
} |
||||
}); |
||||
defineType("TSImportType", { |
||||
aliases: ["TSType"], |
||||
visitor: ["argument", "qualifier", "typeParameters"], |
||||
fields: { |
||||
argument: (0, _utils.validateType)("StringLiteral"), |
||||
qualifier: (0, _utils.validateOptionalType)("TSEntityName"), |
||||
typeParameters: (0, _utils.validateOptionalType)("TSTypeParameterInstantiation") |
||||
} |
||||
}); |
||||
defineType("TSImportEqualsDeclaration", { |
||||
aliases: ["Statement"], |
||||
visitor: ["id", "moduleReference"], |
||||
fields: { |
||||
isExport: (0, _utils.validate)(bool), |
||||
id: (0, _utils.validateType)("Identifier"), |
||||
moduleReference: (0, _utils.validateType)(["TSEntityName", "TSExternalModuleReference"]), |
||||
importKind: { |
||||
validate: (0, _utils.assertOneOf)("type", "value"), |
||||
optional: true |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSExternalModuleReference", { |
||||
visitor: ["expression"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("StringLiteral") |
||||
} |
||||
}); |
||||
defineType("TSNonNullExpression", { |
||||
aliases: ["Expression", "LVal", "PatternLike"], |
||||
visitor: ["expression"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("Expression") |
||||
} |
||||
}); |
||||
defineType("TSExportAssignment", { |
||||
aliases: ["Statement"], |
||||
visitor: ["expression"], |
||||
fields: { |
||||
expression: (0, _utils.validateType)("Expression") |
||||
} |
||||
}); |
||||
defineType("TSNamespaceExportDeclaration", { |
||||
aliases: ["Statement"], |
||||
visitor: ["id"], |
||||
fields: { |
||||
id: (0, _utils.validateType)("Identifier") |
||||
} |
||||
}); |
||||
defineType("TSTypeAnnotation", { |
||||
visitor: ["typeAnnotation"], |
||||
fields: { |
||||
typeAnnotation: { |
||||
validate: (0, _utils.assertNodeType)("TSType") |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSTypeParameterInstantiation", { |
||||
visitor: ["params"], |
||||
fields: { |
||||
params: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSType"))) |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSTypeParameterDeclaration", { |
||||
visitor: ["params"], |
||||
fields: { |
||||
params: { |
||||
validate: (0, _utils.chain)((0, _utils.assertValueType)("array"), (0, _utils.assertEach)((0, _utils.assertNodeType)("TSTypeParameter"))) |
||||
} |
||||
} |
||||
}); |
||||
defineType("TSTypeParameter", { |
||||
builder: ["constraint", "default", "name"], |
||||
visitor: ["constraint", "default"], |
||||
fields: { |
||||
name: { |
||||
validate: (0, _utils.assertValueType)("string") |
||||
}, |
||||
in: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
optional: true |
||||
}, |
||||
out: { |
||||
validate: (0, _utils.assertValueType)("boolean"), |
||||
optional: true |
||||
}, |
||||
constraint: { |
||||
validate: (0, _utils.assertNodeType)("TSType"), |
||||
optional: true |
||||
}, |
||||
default: { |
||||
validate: (0, _utils.assertNodeType)("TSType"), |
||||
optional: true |
||||
} |
||||
} |
||||
}); |
@ -0,0 +1,343 @@
@@ -0,0 +1,343 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.VISITOR_KEYS = exports.NODE_PARENT_VALIDATIONS = exports.NODE_FIELDS = exports.FLIPPED_ALIAS_KEYS = exports.DEPRECATED_KEYS = exports.BUILDER_KEYS = exports.ALIAS_KEYS = void 0; |
||||
exports.arrayOf = arrayOf; |
||||
exports.arrayOfType = arrayOfType; |
||||
exports.assertEach = assertEach; |
||||
exports.assertNodeOrValueType = assertNodeOrValueType; |
||||
exports.assertNodeType = assertNodeType; |
||||
exports.assertOneOf = assertOneOf; |
||||
exports.assertOptionalChainStart = assertOptionalChainStart; |
||||
exports.assertShape = assertShape; |
||||
exports.assertValueType = assertValueType; |
||||
exports.chain = chain; |
||||
exports.default = defineType; |
||||
exports.defineAliasedType = defineAliasedType; |
||||
exports.typeIs = typeIs; |
||||
exports.validate = validate; |
||||
exports.validateArrayOfType = validateArrayOfType; |
||||
exports.validateOptional = validateOptional; |
||||
exports.validateOptionalType = validateOptionalType; |
||||
exports.validateType = validateType; |
||||
|
||||
var _is = require("../validators/is"); |
||||
|
||||
var _validate = require("../validators/validate"); |
||||
|
||||
const VISITOR_KEYS = {}; |
||||
exports.VISITOR_KEYS = VISITOR_KEYS; |
||||
const ALIAS_KEYS = {}; |
||||
exports.ALIAS_KEYS = ALIAS_KEYS; |
||||
const FLIPPED_ALIAS_KEYS = {}; |
||||
exports.FLIPPED_ALIAS_KEYS = FLIPPED_ALIAS_KEYS; |
||||
const NODE_FIELDS = {}; |
||||
exports.NODE_FIELDS = NODE_FIELDS; |
||||
const BUILDER_KEYS = {}; |
||||
exports.BUILDER_KEYS = BUILDER_KEYS; |
||||
const DEPRECATED_KEYS = {}; |
||||
exports.DEPRECATED_KEYS = DEPRECATED_KEYS; |
||||
const NODE_PARENT_VALIDATIONS = {}; |
||||
exports.NODE_PARENT_VALIDATIONS = NODE_PARENT_VALIDATIONS; |
||||
|
||||
function getType(val) { |
||||
if (Array.isArray(val)) { |
||||
return "array"; |
||||
} else if (val === null) { |
||||
return "null"; |
||||
} else { |
||||
return typeof val; |
||||
} |
||||
} |
||||
|
||||
function validate(validate) { |
||||
return { |
||||
validate |
||||
}; |
||||
} |
||||
|
||||
function typeIs(typeName) { |
||||
return typeof typeName === "string" ? assertNodeType(typeName) : assertNodeType(...typeName); |
||||
} |
||||
|
||||
function validateType(typeName) { |
||||
return validate(typeIs(typeName)); |
||||
} |
||||
|
||||
function validateOptional(validate) { |
||||
return { |
||||
validate, |
||||
optional: true |
||||
}; |
||||
} |
||||
|
||||
function validateOptionalType(typeName) { |
||||
return { |
||||
validate: typeIs(typeName), |
||||
optional: true |
||||
}; |
||||
} |
||||
|
||||
function arrayOf(elementType) { |
||||
return chain(assertValueType("array"), assertEach(elementType)); |
||||
} |
||||
|
||||
function arrayOfType(typeName) { |
||||
return arrayOf(typeIs(typeName)); |
||||
} |
||||
|
||||
function validateArrayOfType(typeName) { |
||||
return validate(arrayOfType(typeName)); |
||||
} |
||||
|
||||
function assertEach(callback) { |
||||
function validator(node, key, val) { |
||||
if (!Array.isArray(val)) return; |
||||
|
||||
for (let i = 0; i < val.length; i++) { |
||||
const subkey = `${key}[${i}]`; |
||||
const v = val[i]; |
||||
callback(node, subkey, v); |
||||
if (process.env.BABEL_TYPES_8_BREAKING) (0, _validate.validateChild)(node, subkey, v); |
||||
} |
||||
} |
||||
|
||||
validator.each = callback; |
||||
return validator; |
||||
} |
||||
|
||||
function assertOneOf(...values) { |
||||
function validate(node, key, val) { |
||||
if (values.indexOf(val) < 0) { |
||||
throw new TypeError(`Property ${key} expected value to be one of ${JSON.stringify(values)} but got ${JSON.stringify(val)}`); |
||||
} |
||||
} |
||||
|
||||
validate.oneOf = values; |
||||
return validate; |
||||
} |
||||
|
||||
function assertNodeType(...types) { |
||||
function validate(node, key, val) { |
||||
for (const type of types) { |
||||
if ((0, _is.default)(type, val)) { |
||||
(0, _validate.validateChild)(node, key, val); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`); |
||||
} |
||||
|
||||
validate.oneOfNodeTypes = types; |
||||
return validate; |
||||
} |
||||
|
||||
function assertNodeOrValueType(...types) { |
||||
function validate(node, key, val) { |
||||
for (const type of types) { |
||||
if (getType(val) === type || (0, _is.default)(type, val)) { |
||||
(0, _validate.validateChild)(node, key, val); |
||||
return; |
||||
} |
||||
} |
||||
|
||||
throw new TypeError(`Property ${key} of ${node.type} expected node to be of a type ${JSON.stringify(types)} but instead got ${JSON.stringify(val == null ? void 0 : val.type)}`); |
||||
} |
||||
|
||||
validate.oneOfNodeOrValueTypes = types; |
||||
return validate; |
||||
} |
||||
|
||||
function assertValueType(type) { |
||||
function validate(node, key, val) { |
||||
const valid = getType(val) === type; |
||||
|
||||
if (!valid) { |
||||
throw new TypeError(`Property ${key} expected type of ${type} but got ${getType(val)}`); |
||||
} |
||||
} |
||||
|
||||
validate.type = type; |
||||
return validate; |
||||
} |
||||
|
||||
function assertShape(shape) { |
||||
function validate(node, key, val) { |
||||
const errors = []; |
||||
|
||||
for (const property of Object.keys(shape)) { |
||||
try { |
||||
(0, _validate.validateField)(node, property, val[property], shape[property]); |
||||
} catch (error) { |
||||
if (error instanceof TypeError) { |
||||
errors.push(error.message); |
||||
continue; |
||||
} |
||||
|
||||
throw error; |
||||
} |
||||
} |
||||
|
||||
if (errors.length) { |
||||
throw new TypeError(`Property ${key} of ${node.type} expected to have the following:\n${errors.join("\n")}`); |
||||
} |
||||
} |
||||
|
||||
validate.shapeOf = shape; |
||||
return validate; |
||||
} |
||||
|
||||
function assertOptionalChainStart() { |
||||
function validate(node) { |
||||
var _current; |
||||
|
||||
let current = node; |
||||
|
||||
while (node) { |
||||
const { |
||||
type |
||||
} = current; |
||||
|
||||
if (type === "OptionalCallExpression") { |
||||
if (current.optional) return; |
||||
current = current.callee; |
||||
continue; |
||||
} |
||||
|
||||
if (type === "OptionalMemberExpression") { |
||||
if (current.optional) return; |
||||
current = current.object; |
||||
continue; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
|
||||
throw new TypeError(`Non-optional ${node.type} must chain from an optional OptionalMemberExpression or OptionalCallExpression. Found chain from ${(_current = current) == null ? void 0 : _current.type}`); |
||||
} |
||||
|
||||
return validate; |
||||
} |
||||
|
||||
function chain(...fns) { |
||||
function validate(...args) { |
||||
for (const fn of fns) { |
||||
fn(...args); |
||||
} |
||||
} |
||||
|
||||
validate.chainOf = fns; |
||||
|
||||
if (fns.length >= 2 && "type" in fns[0] && fns[0].type === "array" && !("each" in fns[1])) { |
||||
throw new Error(`An assertValueType("array") validator can only be followed by an assertEach(...) validator.`); |
||||
} |
||||
|
||||
return validate; |
||||
} |
||||
|
||||
const validTypeOpts = ["aliases", "builder", "deprecatedAlias", "fields", "inherits", "visitor", "validate"]; |
||||
const validFieldKeys = ["default", "optional", "validate"]; |
||||
|
||||
function defineAliasedType(...aliases) { |
||||
return (type, opts = {}) => { |
||||
let defined = opts.aliases; |
||||
|
||||
if (!defined) { |
||||
var _store$opts$inherits$, _defined; |
||||
|
||||
if (opts.inherits) defined = (_store$opts$inherits$ = store[opts.inherits].aliases) == null ? void 0 : _store$opts$inherits$.slice(); |
||||
(_defined = defined) != null ? _defined : defined = []; |
||||
opts.aliases = defined; |
||||
} |
||||
|
||||
const additional = aliases.filter(a => !defined.includes(a)); |
||||
defined.unshift(...additional); |
||||
return defineType(type, opts); |
||||
}; |
||||
} |
||||
|
||||
function defineType(type, opts = {}) { |
||||
const inherits = opts.inherits && store[opts.inherits] || {}; |
||||
let fields = opts.fields; |
||||
|
||||
if (!fields) { |
||||
fields = {}; |
||||
|
||||
if (inherits.fields) { |
||||
const keys = Object.getOwnPropertyNames(inherits.fields); |
||||
|
||||
for (const key of keys) { |
||||
const field = inherits.fields[key]; |
||||
const def = field.default; |
||||
|
||||
if (Array.isArray(def) ? def.length > 0 : def && typeof def === "object") { |
||||
throw new Error("field defaults can only be primitives or empty arrays currently"); |
||||
} |
||||
|
||||
fields[key] = { |
||||
default: Array.isArray(def) ? [] : def, |
||||
optional: field.optional, |
||||
validate: field.validate |
||||
}; |
||||
} |
||||
} |
||||
} |
||||
|
||||
const visitor = opts.visitor || inherits.visitor || []; |
||||
const aliases = opts.aliases || inherits.aliases || []; |
||||
const builder = opts.builder || inherits.builder || opts.visitor || []; |
||||
|
||||
for (const k of Object.keys(opts)) { |
||||
if (validTypeOpts.indexOf(k) === -1) { |
||||
throw new Error(`Unknown type option "${k}" on ${type}`); |
||||
} |
||||
} |
||||
|
||||
if (opts.deprecatedAlias) { |
||||
DEPRECATED_KEYS[opts.deprecatedAlias] = type; |
||||
} |
||||
|
||||
for (const key of visitor.concat(builder)) { |
||||
fields[key] = fields[key] || {}; |
||||
} |
||||
|
||||
for (const key of Object.keys(fields)) { |
||||
const field = fields[key]; |
||||
|
||||
if (field.default !== undefined && builder.indexOf(key) === -1) { |
||||
field.optional = true; |
||||
} |
||||
|
||||
if (field.default === undefined) { |
||||
field.default = null; |
||||
} else if (!field.validate && field.default != null) { |
||||
field.validate = assertValueType(getType(field.default)); |
||||
} |
||||
|
||||
for (const k of Object.keys(field)) { |
||||
if (validFieldKeys.indexOf(k) === -1) { |
||||
throw new Error(`Unknown field key "${k}" on ${type}.${key}`); |
||||
} |
||||
} |
||||
} |
||||
|
||||
VISITOR_KEYS[type] = opts.visitor = visitor; |
||||
BUILDER_KEYS[type] = opts.builder = builder; |
||||
NODE_FIELDS[type] = opts.fields = fields; |
||||
ALIAS_KEYS[type] = opts.aliases = aliases; |
||||
aliases.forEach(alias => { |
||||
FLIPPED_ALIAS_KEYS[alias] = FLIPPED_ALIAS_KEYS[alias] || []; |
||||
FLIPPED_ALIAS_KEYS[alias].push(type); |
||||
}); |
||||
|
||||
if (opts.validate) { |
||||
NODE_PARENT_VALIDATIONS[type] = opts.validate; |
||||
} |
||||
|
||||
store[type] = opts; |
||||
} |
||||
|
||||
const store = {}; |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,647 @@
@@ -0,0 +1,647 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
var _exportNames = { |
||||
react: true, |
||||
assertNode: true, |
||||
createTypeAnnotationBasedOnTypeof: true, |
||||
createUnionTypeAnnotation: true, |
||||
createFlowUnionType: true, |
||||
createTSUnionType: true, |
||||
cloneNode: true, |
||||
clone: true, |
||||
cloneDeep: true, |
||||
cloneDeepWithoutLoc: true, |
||||
cloneWithoutLoc: true, |
||||
addComment: true, |
||||
addComments: true, |
||||
inheritInnerComments: true, |
||||
inheritLeadingComments: true, |
||||
inheritsComments: true, |
||||
inheritTrailingComments: true, |
||||
removeComments: true, |
||||
ensureBlock: true, |
||||
toBindingIdentifierName: true, |
||||
toBlock: true, |
||||
toComputedKey: true, |
||||
toExpression: true, |
||||
toIdentifier: true, |
||||
toKeyAlias: true, |
||||
toSequenceExpression: true, |
||||
toStatement: true, |
||||
valueToNode: true, |
||||
appendToMemberExpression: true, |
||||
inherits: true, |
||||
prependToMemberExpression: true, |
||||
removeProperties: true, |
||||
removePropertiesDeep: true, |
||||
removeTypeDuplicates: true, |
||||
getBindingIdentifiers: true, |
||||
getOuterBindingIdentifiers: true, |
||||
traverse: true, |
||||
traverseFast: true, |
||||
shallowEqual: true, |
||||
is: true, |
||||
isBinding: true, |
||||
isBlockScoped: true, |
||||
isImmutable: true, |
||||
isLet: true, |
||||
isNode: true, |
||||
isNodesEquivalent: true, |
||||
isPlaceholderType: true, |
||||
isReferenced: true, |
||||
isScope: true, |
||||
isSpecifierDefault: true, |
||||
isType: true, |
||||
isValidES3Identifier: true, |
||||
isValidIdentifier: true, |
||||
isVar: true, |
||||
matchesPattern: true, |
||||
validate: true, |
||||
buildMatchMemberExpression: true |
||||
}; |
||||
Object.defineProperty(exports, "addComment", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _addComment.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "addComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _addComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "appendToMemberExpression", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _appendToMemberExpression.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "assertNode", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _assertNode.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "buildMatchMemberExpression", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _buildMatchMemberExpression.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "clone", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _clone.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "cloneDeep", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _cloneDeep.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "cloneDeepWithoutLoc", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _cloneDeepWithoutLoc.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "cloneNode", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _cloneNode.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "cloneWithoutLoc", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _cloneWithoutLoc.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "createFlowUnionType", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _createFlowUnionType.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "createTSUnionType", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _createTSUnionType.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "createTypeAnnotationBasedOnTypeof", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _createTypeAnnotationBasedOnTypeof.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "createUnionTypeAnnotation", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _createFlowUnionType.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "ensureBlock", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _ensureBlock.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "getBindingIdentifiers", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _getBindingIdentifiers.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "getOuterBindingIdentifiers", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _getOuterBindingIdentifiers.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "inheritInnerComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _inheritInnerComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "inheritLeadingComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _inheritLeadingComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "inheritTrailingComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _inheritTrailingComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "inherits", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _inherits.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "inheritsComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _inheritsComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "is", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _is.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isBinding", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isBinding.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isBlockScoped", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isBlockScoped.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isImmutable", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isImmutable.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isLet", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isLet.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isNode", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isNode.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isNodesEquivalent", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isNodesEquivalent.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isPlaceholderType", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isPlaceholderType.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isReferenced", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isReferenced.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isScope", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isScope.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isSpecifierDefault", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isSpecifierDefault.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isType", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isType.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isValidES3Identifier", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isValidES3Identifier.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isValidIdentifier", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isValidIdentifier.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "isVar", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _isVar.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "matchesPattern", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _matchesPattern.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "prependToMemberExpression", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _prependToMemberExpression.default; |
||||
} |
||||
}); |
||||
exports.react = void 0; |
||||
Object.defineProperty(exports, "removeComments", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _removeComments.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "removeProperties", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _removeProperties.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "removePropertiesDeep", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _removePropertiesDeep.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "removeTypeDuplicates", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _removeTypeDuplicates.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "shallowEqual", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _shallowEqual.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toBindingIdentifierName", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toBindingIdentifierName.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toBlock", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toBlock.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toComputedKey", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toComputedKey.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toExpression", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toExpression.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toIdentifier", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toIdentifier.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toKeyAlias", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toKeyAlias.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toSequenceExpression", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toSequenceExpression.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "toStatement", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _toStatement.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "traverse", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _traverse.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "traverseFast", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _traverseFast.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "validate", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _validate.default; |
||||
} |
||||
}); |
||||
Object.defineProperty(exports, "valueToNode", { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _valueToNode.default; |
||||
} |
||||
}); |
||||
|
||||
var _isReactComponent = require("./validators/react/isReactComponent"); |
||||
|
||||
var _isCompatTag = require("./validators/react/isCompatTag"); |
||||
|
||||
var _buildChildren = require("./builders/react/buildChildren"); |
||||
|
||||
var _assertNode = require("./asserts/assertNode"); |
||||
|
||||
var _generated = require("./asserts/generated"); |
||||
|
||||
Object.keys(_generated).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _generated[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _generated[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _createTypeAnnotationBasedOnTypeof = require("./builders/flow/createTypeAnnotationBasedOnTypeof"); |
||||
|
||||
var _createFlowUnionType = require("./builders/flow/createFlowUnionType"); |
||||
|
||||
var _createTSUnionType = require("./builders/typescript/createTSUnionType"); |
||||
|
||||
var _generated2 = require("./builders/generated"); |
||||
|
||||
Object.keys(_generated2).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _generated2[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _generated2[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _uppercase = require("./builders/generated/uppercase"); |
||||
|
||||
Object.keys(_uppercase).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _uppercase[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _uppercase[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _cloneNode = require("./clone/cloneNode"); |
||||
|
||||
var _clone = require("./clone/clone"); |
||||
|
||||
var _cloneDeep = require("./clone/cloneDeep"); |
||||
|
||||
var _cloneDeepWithoutLoc = require("./clone/cloneDeepWithoutLoc"); |
||||
|
||||
var _cloneWithoutLoc = require("./clone/cloneWithoutLoc"); |
||||
|
||||
var _addComment = require("./comments/addComment"); |
||||
|
||||
var _addComments = require("./comments/addComments"); |
||||
|
||||
var _inheritInnerComments = require("./comments/inheritInnerComments"); |
||||
|
||||
var _inheritLeadingComments = require("./comments/inheritLeadingComments"); |
||||
|
||||
var _inheritsComments = require("./comments/inheritsComments"); |
||||
|
||||
var _inheritTrailingComments = require("./comments/inheritTrailingComments"); |
||||
|
||||
var _removeComments = require("./comments/removeComments"); |
||||
|
||||
var _generated3 = require("./constants/generated"); |
||||
|
||||
Object.keys(_generated3).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _generated3[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _generated3[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _constants = require("./constants"); |
||||
|
||||
Object.keys(_constants).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _constants[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _constants[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _ensureBlock = require("./converters/ensureBlock"); |
||||
|
||||
var _toBindingIdentifierName = require("./converters/toBindingIdentifierName"); |
||||
|
||||
var _toBlock = require("./converters/toBlock"); |
||||
|
||||
var _toComputedKey = require("./converters/toComputedKey"); |
||||
|
||||
var _toExpression = require("./converters/toExpression"); |
||||
|
||||
var _toIdentifier = require("./converters/toIdentifier"); |
||||
|
||||
var _toKeyAlias = require("./converters/toKeyAlias"); |
||||
|
||||
var _toSequenceExpression = require("./converters/toSequenceExpression"); |
||||
|
||||
var _toStatement = require("./converters/toStatement"); |
||||
|
||||
var _valueToNode = require("./converters/valueToNode"); |
||||
|
||||
var _definitions = require("./definitions"); |
||||
|
||||
Object.keys(_definitions).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _definitions[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _definitions[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _appendToMemberExpression = require("./modifications/appendToMemberExpression"); |
||||
|
||||
var _inherits = require("./modifications/inherits"); |
||||
|
||||
var _prependToMemberExpression = require("./modifications/prependToMemberExpression"); |
||||
|
||||
var _removeProperties = require("./modifications/removeProperties"); |
||||
|
||||
var _removePropertiesDeep = require("./modifications/removePropertiesDeep"); |
||||
|
||||
var _removeTypeDuplicates = require("./modifications/flow/removeTypeDuplicates"); |
||||
|
||||
var _getBindingIdentifiers = require("./retrievers/getBindingIdentifiers"); |
||||
|
||||
var _getOuterBindingIdentifiers = require("./retrievers/getOuterBindingIdentifiers"); |
||||
|
||||
var _traverse = require("./traverse/traverse"); |
||||
|
||||
Object.keys(_traverse).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _traverse[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _traverse[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _traverseFast = require("./traverse/traverseFast"); |
||||
|
||||
var _shallowEqual = require("./utils/shallowEqual"); |
||||
|
||||
var _is = require("./validators/is"); |
||||
|
||||
var _isBinding = require("./validators/isBinding"); |
||||
|
||||
var _isBlockScoped = require("./validators/isBlockScoped"); |
||||
|
||||
var _isImmutable = require("./validators/isImmutable"); |
||||
|
||||
var _isLet = require("./validators/isLet"); |
||||
|
||||
var _isNode = require("./validators/isNode"); |
||||
|
||||
var _isNodesEquivalent = require("./validators/isNodesEquivalent"); |
||||
|
||||
var _isPlaceholderType = require("./validators/isPlaceholderType"); |
||||
|
||||
var _isReferenced = require("./validators/isReferenced"); |
||||
|
||||
var _isScope = require("./validators/isScope"); |
||||
|
||||
var _isSpecifierDefault = require("./validators/isSpecifierDefault"); |
||||
|
||||
var _isType = require("./validators/isType"); |
||||
|
||||
var _isValidES3Identifier = require("./validators/isValidES3Identifier"); |
||||
|
||||
var _isValidIdentifier = require("./validators/isValidIdentifier"); |
||||
|
||||
var _isVar = require("./validators/isVar"); |
||||
|
||||
var _matchesPattern = require("./validators/matchesPattern"); |
||||
|
||||
var _validate = require("./validators/validate"); |
||||
|
||||
var _buildMatchMemberExpression = require("./validators/buildMatchMemberExpression"); |
||||
|
||||
var _generated4 = require("./validators/generated"); |
||||
|
||||
Object.keys(_generated4).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _generated4[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _generated4[key]; |
||||
} |
||||
}); |
||||
}); |
||||
|
||||
var _generated5 = require("./ast-types/generated"); |
||||
|
||||
Object.keys(_generated5).forEach(function (key) { |
||||
if (key === "default" || key === "__esModule") return; |
||||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; |
||||
if (key in exports && exports[key] === _generated5[key]) return; |
||||
Object.defineProperty(exports, key, { |
||||
enumerable: true, |
||||
get: function () { |
||||
return _generated5[key]; |
||||
} |
||||
}); |
||||
}); |
||||
const react = { |
||||
isReactComponent: _isReactComponent.default, |
||||
isCompatTag: _isCompatTag.default, |
||||
buildChildren: _buildChildren.default |
||||
}; |
||||
exports.react = react; |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = appendToMemberExpression; |
||||
|
||||
var _generated = require("../builders/generated"); |
||||
|
||||
function appendToMemberExpression(member, append, computed = false) { |
||||
member.object = (0, _generated.memberExpression)(member.object, member.property, member.computed); |
||||
member.property = append; |
||||
member.computed = !!computed; |
||||
return member; |
||||
} |
@ -0,0 +1,78 @@
@@ -0,0 +1,78 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = removeTypeDuplicates; |
||||
|
||||
var _generated = require("../../validators/generated"); |
||||
|
||||
function getQualifiedName(node) { |
||||
return (0, _generated.isIdentifier)(node) ? node.name : `${node.id.name}.${getQualifiedName(node.qualification)}`; |
||||
} |
||||
|
||||
function removeTypeDuplicates(nodes) { |
||||
const generics = {}; |
||||
const bases = {}; |
||||
const typeGroups = new Set(); |
||||
const types = []; |
||||
|
||||
for (let i = 0; i < nodes.length; i++) { |
||||
const node = nodes[i]; |
||||
if (!node) continue; |
||||
|
||||
if (types.indexOf(node) >= 0) { |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isAnyTypeAnnotation)(node)) { |
||||
return [node]; |
||||
} |
||||
|
||||
if ((0, _generated.isFlowBaseAnnotation)(node)) { |
||||
bases[node.type] = node; |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isUnionTypeAnnotation)(node)) { |
||||
if (!typeGroups.has(node.types)) { |
||||
nodes = nodes.concat(node.types); |
||||
typeGroups.add(node.types); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isGenericTypeAnnotation)(node)) { |
||||
const name = getQualifiedName(node.id); |
||||
|
||||
if (generics[name]) { |
||||
let existing = generics[name]; |
||||
|
||||
if (existing.typeParameters) { |
||||
if (node.typeParameters) { |
||||
existing.typeParameters.params = removeTypeDuplicates(existing.typeParameters.params.concat(node.typeParameters.params)); |
||||
} |
||||
} else { |
||||
existing = node.typeParameters; |
||||
} |
||||
} else { |
||||
generics[name] = node; |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
types.push(node); |
||||
} |
||||
|
||||
for (const type of Object.keys(bases)) { |
||||
types.push(bases[type]); |
||||
} |
||||
|
||||
for (const name of Object.keys(generics)) { |
||||
types.push(generics[name]); |
||||
} |
||||
|
||||
return types; |
||||
} |
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = inherits; |
||||
|
||||
var _constants = require("../constants"); |
||||
|
||||
var _inheritsComments = require("../comments/inheritsComments"); |
||||
|
||||
function inherits(child, parent) { |
||||
if (!child || !parent) return child; |
||||
|
||||
for (const key of _constants.INHERIT_KEYS.optional) { |
||||
if (child[key] == null) { |
||||
child[key] = parent[key]; |
||||
} |
||||
} |
||||
|
||||
for (const key of Object.keys(parent)) { |
||||
if (key[0] === "_" && key !== "__clone") child[key] = parent[key]; |
||||
} |
||||
|
||||
for (const key of _constants.INHERIT_KEYS.force) { |
||||
child[key] = parent[key]; |
||||
} |
||||
|
||||
(0, _inheritsComments.default)(child, parent); |
||||
return child; |
||||
} |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = prependToMemberExpression; |
||||
|
||||
var _generated = require("../builders/generated"); |
||||
|
||||
function prependToMemberExpression(member, prepend) { |
||||
member.object = (0, _generated.memberExpression)(prepend, member.object); |
||||
return member; |
||||
} |
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = removeProperties; |
||||
|
||||
var _constants = require("../constants"); |
||||
|
||||
const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"]; |
||||
|
||||
const CLEAR_KEYS_PLUS_COMMENTS = _constants.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS); |
||||
|
||||
function removeProperties(node, opts = {}) { |
||||
const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS; |
||||
|
||||
for (const key of map) { |
||||
if (node[key] != null) node[key] = undefined; |
||||
} |
||||
|
||||
for (const key of Object.keys(node)) { |
||||
if (key[0] === "_" && node[key] != null) node[key] = undefined; |
||||
} |
||||
|
||||
const symbols = Object.getOwnPropertySymbols(node); |
||||
|
||||
for (const sym of symbols) { |
||||
node[sym] = null; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = removePropertiesDeep; |
||||
|
||||
var _traverseFast = require("../traverse/traverseFast"); |
||||
|
||||
var _removeProperties = require("./removeProperties"); |
||||
|
||||
function removePropertiesDeep(tree, opts) { |
||||
(0, _traverseFast.default)(tree, _removeProperties.default, opts); |
||||
return tree; |
||||
} |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = removeTypeDuplicates; |
||||
|
||||
var _generated = require("../../validators/generated"); |
||||
|
||||
function removeTypeDuplicates(nodes) { |
||||
const generics = {}; |
||||
const bases = {}; |
||||
const typeGroups = new Set(); |
||||
const types = []; |
||||
|
||||
for (let i = 0; i < nodes.length; i++) { |
||||
const node = nodes[i]; |
||||
if (!node) continue; |
||||
|
||||
if (types.indexOf(node) >= 0) { |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isTSAnyKeyword)(node)) { |
||||
return [node]; |
||||
} |
||||
|
||||
if ((0, _generated.isTSBaseType)(node)) { |
||||
bases[node.type] = node; |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isTSUnionType)(node)) { |
||||
if (!typeGroups.has(node.types)) { |
||||
nodes.push(...node.types); |
||||
typeGroups.add(node.types); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
types.push(node); |
||||
} |
||||
|
||||
for (const type of Object.keys(bases)) { |
||||
types.push(bases[type]); |
||||
} |
||||
|
||||
for (const name of Object.keys(generics)) { |
||||
types.push(generics[name]); |
||||
} |
||||
|
||||
return types; |
||||
} |
@ -0,0 +1,104 @@
@@ -0,0 +1,104 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = getBindingIdentifiers; |
||||
|
||||
var _generated = require("../validators/generated"); |
||||
|
||||
function getBindingIdentifiers(node, duplicates, outerOnly) { |
||||
let search = [].concat(node); |
||||
const ids = Object.create(null); |
||||
|
||||
while (search.length) { |
||||
const id = search.shift(); |
||||
if (!id) continue; |
||||
const keys = getBindingIdentifiers.keys[id.type]; |
||||
|
||||
if ((0, _generated.isIdentifier)(id)) { |
||||
if (duplicates) { |
||||
const _ids = ids[id.name] = ids[id.name] || []; |
||||
|
||||
_ids.push(id); |
||||
} else { |
||||
ids[id.name] = id; |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isExportDeclaration)(id) && !(0, _generated.isExportAllDeclaration)(id)) { |
||||
if ((0, _generated.isDeclaration)(id.declaration)) { |
||||
search.push(id.declaration); |
||||
} |
||||
|
||||
continue; |
||||
} |
||||
|
||||
if (outerOnly) { |
||||
if ((0, _generated.isFunctionDeclaration)(id)) { |
||||
search.push(id.id); |
||||
continue; |
||||
} |
||||
|
||||
if ((0, _generated.isFunctionExpression)(id)) { |
||||
continue; |
||||
} |
||||
} |
||||
|
||||
if (keys) { |
||||
for (let i = 0; i < keys.length; i++) { |
||||
const key = keys[i]; |
||||
|
||||
if (id[key]) { |
||||
search = search.concat(id[key]); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return ids; |
||||
} |
||||
|
||||
getBindingIdentifiers.keys = { |
||||
DeclareClass: ["id"], |
||||
DeclareFunction: ["id"], |
||||
DeclareModule: ["id"], |
||||
DeclareVariable: ["id"], |
||||
DeclareInterface: ["id"], |
||||
DeclareTypeAlias: ["id"], |
||||
DeclareOpaqueType: ["id"], |
||||
InterfaceDeclaration: ["id"], |
||||
TypeAlias: ["id"], |
||||
OpaqueType: ["id"], |
||||
CatchClause: ["param"], |
||||
LabeledStatement: ["label"], |
||||
UnaryExpression: ["argument"], |
||||
AssignmentExpression: ["left"], |
||||
ImportSpecifier: ["local"], |
||||
ImportNamespaceSpecifier: ["local"], |
||||
ImportDefaultSpecifier: ["local"], |
||||
ImportDeclaration: ["specifiers"], |
||||
ExportSpecifier: ["exported"], |
||||
ExportNamespaceSpecifier: ["exported"], |
||||
ExportDefaultSpecifier: ["exported"], |
||||
FunctionDeclaration: ["id", "params"], |
||||
FunctionExpression: ["id", "params"], |
||||
ArrowFunctionExpression: ["params"], |
||||
ObjectMethod: ["params"], |
||||
ClassMethod: ["params"], |
||||
ClassPrivateMethod: ["params"], |
||||
ForInStatement: ["left"], |
||||
ForOfStatement: ["left"], |
||||
ClassDeclaration: ["id"], |
||||
ClassExpression: ["id"], |
||||
RestElement: ["argument"], |
||||
UpdateExpression: ["argument"], |
||||
ObjectProperty: ["value"], |
||||
AssignmentPattern: ["left"], |
||||
ArrayPattern: ["elements"], |
||||
ObjectPattern: ["properties"], |
||||
VariableDeclaration: ["declarations"], |
||||
VariableDeclarator: ["id"] |
||||
}; |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue