zsmj
3 years ago
commit
dd41bae746
11543 changed files with 1344061 additions and 0 deletions
@ -0,0 +1,11 @@
|
||||
{ |
||||
"plugins": ["@babel/syntax-dynamic-import"], |
||||
"presets": [ |
||||
[ |
||||
"@babel/preset-env", |
||||
{ |
||||
"modules": false |
||||
} |
||||
] |
||||
] |
||||
} |
@ -0,0 +1,13 @@
|
||||
/.vscode |
||||
/node_modules |
||||
.idea/ |
||||
/css/ |
||||
/src/css/ |
||||
/dist/**/*.js |
||||
/dist/**/*.css |
||||
constants/classes |
||||
/coverage |
||||
/unit.test.statistic.json |
||||
/allure |
||||
package-lock.json |
||||
yarn.lock |
@ -0,0 +1,5 @@
|
||||
# Default ignored files |
||||
/shelf/ |
||||
/workspace.xml |
||||
# Editor-based HTTP Client requests |
||||
/httpRequests/ |
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<module type="WEB_MODULE" version="4"> |
||||
<component name="NewModuleRootManager"> |
||||
<content url="file://$MODULE_DIR$"> |
||||
<excludeFolder url="file://$MODULE_DIR$/temp" /> |
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" /> |
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" /> |
||||
</content> |
||||
<orderEntry type="inheritedJdk" /> |
||||
<orderEntry type="sourceFolder" forTests="false" /> |
||||
</component> |
||||
</module> |
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project version="4"> |
||||
<component name="ProjectModuleManager"> |
||||
<modules> |
||||
<module fileurl="file://$PROJECT_DIR$/.idea/customtreedemo.iml" filepath="$PROJECT_DIR$/.idea/customtreedemo.iml" /> |
||||
</modules> |
||||
</component> |
||||
</project> |
@ -0,0 +1,7 @@
|
||||
# 🚀 Welcome to your new awesome project! |
||||
|
||||
## 这些组件你都看过没有? |
||||
|
||||
BI.BasicButton BI.NodeButton BI.Expander BI.Loader Events |
||||
|
||||
## 最普通的树 |
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html> |
||||
<html> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<title>Webpack App</title> |
||||
</head> |
||||
<body> |
||||
<div id="wrapper"></div> |
||||
</body> |
||||
|
||||
</html> |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-export-namespace-from", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("exportNamespaceFrom"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,24 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-export-namespace-from", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of export namespace from", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-export-namespace-from", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.3" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.3" |
||||
}, |
||||
"gitHead": "a7620bd266ae1345975767bbc7abf09034437017" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-json-strings |
||||
|
||||
> Allow parsing of the U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR in JS strings |
||||
|
||||
See our website [@babel/plugin-syntax-json-strings](https://babeljs.io/docs/en/next/babel-plugin-syntax-json-strings.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-json-strings |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-json-strings --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-json-strings", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("jsonStrings"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-json-strings", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of the U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR in JS strings", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-json-strings", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.0" |
||||
} |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-logical-assignment-operators |
||||
|
||||
> Allow parsing of the logical assignment operators |
||||
|
||||
See our website [@babel/plugin-syntax-logical-assignment-operators](https://babeljs.io/docs/en/next/babel-plugin-syntax-logical-assignment-operators.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-logical-assignment-operators |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-logical-assignment-operators --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-logical-assignment-operators", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("logicalAssignment"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,28 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-logical-assignment-operators", |
||||
"version": "7.10.4", |
||||
"description": "Allow parsing of the logical assignment operators", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-syntax-logical-assignment-operators" |
||||
}, |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.10.4" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.10.4" |
||||
}, |
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-nullish-coalescing-operator |
||||
|
||||
> Allow parsing of the nullish-coalescing operator |
||||
|
||||
See our website [@babel/plugin-syntax-nullish-coalescing-operator](https://babeljs.io/docs/en/next/babel-plugin-syntax-nullish-coalescing-operator.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-nullish-coalescing-operator |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-nullish-coalescing-operator --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-nullish-coalescing-operator", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("nullishCoalescingOperator"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-nullish-coalescing-operator", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of the nullish-coalescing operator", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-nullish-coalescing-operator", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.0" |
||||
} |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-numeric-separator |
||||
|
||||
> Allow parsing of Decimal, Binary, Hex and Octal literals that contain a Numeric Literal Separator |
||||
|
||||
See our website [@babel/plugin-syntax-numeric-separator](https://babeljs.io/docs/en/next/babel-plugin-syntax-numeric-separator.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-numeric-separator |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-numeric-separator --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-numeric-separator", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("numericSeparator"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,28 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-numeric-separator", |
||||
"version": "7.10.4", |
||||
"description": "Allow parsing of Decimal, Binary, Hex and Octal literals that contain a Numeric Literal Separator", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-syntax-numeric-separator" |
||||
}, |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.10.4" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.10.4" |
||||
}, |
||||
"gitHead": "7fd40d86a0d03ff0e9c3ea16b29689945433d4df" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-object-rest-spread |
||||
|
||||
> Allow parsing of object rest/spread |
||||
|
||||
See our website [@babel/plugin-syntax-object-rest-spread](https://babeljs.io/docs/en/next/babel-plugin-syntax-object-rest-spread.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-object-rest-spread |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-object-rest-spread --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-object-rest-spread", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("objectRestSpread"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-object-rest-spread", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of object rest/spread", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-object-rest-spread", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.0" |
||||
} |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-optional-catch-binding |
||||
|
||||
> Allow parsing of optional catch bindings |
||||
|
||||
See our website [@babel/plugin-syntax-optional-catch-binding](https://babeljs.io/docs/en/next/babel-plugin-syntax-optional-catch-binding.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-optional-catch-binding |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-optional-catch-binding --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-optional-catch-binding", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("optionalCatchBinding"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-optional-catch-binding", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of optional catch bindings", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-optional-catch-binding", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.0" |
||||
} |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-optional-chaining |
||||
|
||||
> Allow parsing of optional properties |
||||
|
||||
See our website [@babel/plugin-syntax-optional-chaining](https://babeljs.io/docs/en/next/babel-plugin-syntax-optional-chaining.html) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-optional-chaining |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-optional-chaining --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-optional-chaining", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("optionalChaining"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,23 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-optional-chaining", |
||||
"version": "7.8.3", |
||||
"description": "Allow parsing of optional properties", |
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-optional-chaining", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.8.0" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.8.0" |
||||
} |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-private-property-in-object |
||||
|
||||
> Allow parsing of '#foo in obj' brand checks |
||||
|
||||
See our website [@babel/plugin-syntax-private-property-in-object](https://babeljs.io/docs/en/babel-plugin-syntax-private-property-in-object) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-private-property-in-object |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-private-property-in-object --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-private-property-in-object", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("privateIn"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,32 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-private-property-in-object", |
||||
"version": "7.14.5", |
||||
"description": "Allow parsing of '#foo in obj' brand checks", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-syntax-private-property-in-object" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-syntax-private-property-in-object", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"exports": { |
||||
".": "./lib/index.js" |
||||
}, |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.14.5" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-syntax-top-level-await |
||||
|
||||
> Allow parsing of top-level await in modules |
||||
|
||||
See our website [@babel/plugin-syntax-top-level-await](https://babeljs.io/docs/en/babel-plugin-syntax-top-level-await) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-syntax-top-level-await |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-syntax-top-level-await --dev |
||||
``` |
@ -0,0 +1,22 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "syntax-top-level-await", |
||||
|
||||
manipulateOptions(opts, parserOpts) { |
||||
parserOpts.plugins.push("topLevelAwait"); |
||||
} |
||||
|
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,32 @@
|
||||
{ |
||||
"name": "@babel/plugin-syntax-top-level-await", |
||||
"version": "7.14.5", |
||||
"description": "Allow parsing of top-level await in modules", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-syntax-top-level-await" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-syntax-top-level-await", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.14.5" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "7.14.5" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-arrow-functions |
||||
|
||||
> Compile ES2015 arrow functions to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-arrow-functions](https://babeljs.io/docs/en/babel-plugin-transform-arrow-functions) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-arrow-functions |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-arrow-functions --dev |
||||
``` |
@ -0,0 +1,31 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
var _api$assumption; |
||||
|
||||
api.assertVersion(7); |
||||
const noNewArrows = (_api$assumption = api.assumption("noNewArrows")) != null ? _api$assumption : !options.spec; |
||||
return { |
||||
name: "transform-arrow-functions", |
||||
visitor: { |
||||
ArrowFunctionExpression(path) { |
||||
if (!path.isArrowFunctionExpression()) return; |
||||
path.arrowFunctionToExpression({ |
||||
allowInsertArrow: false, |
||||
noNewArrows, |
||||
specCompliant: !noNewArrows |
||||
}); |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,35 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-arrow-functions", |
||||
"version": "7.16.7", |
||||
"description": "Compile ES2015 arrow functions to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-arrow-functions" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-arrow-functions", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7", |
||||
"@babel/traverse": "^7.16.7", |
||||
"@babel/types": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-async-to-generator |
||||
|
||||
> Turn async functions into ES2015 generators |
||||
|
||||
See our website [@babel/plugin-transform-async-to-generator](https://babeljs.io/docs/en/babel-plugin-transform-async-to-generator) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-async-to-generator |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-async-to-generator --dev |
||||
``` |
@ -0,0 +1,62 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _helperRemapAsyncToGenerator = require("@babel/helper-remap-async-to-generator"); |
||||
|
||||
var _helperModuleImports = require("@babel/helper-module-imports"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
api.assertVersion(7); |
||||
const { |
||||
method, |
||||
module |
||||
} = options; |
||||
const noNewArrows = api.assumption("noNewArrows"); |
||||
const ignoreFunctionLength = api.assumption("ignoreFunctionLength"); |
||||
|
||||
if (method && module) { |
||||
return { |
||||
name: "transform-async-to-generator", |
||||
visitor: { |
||||
Function(path, state) { |
||||
if (!path.node.async || path.node.generator) return; |
||||
let wrapAsync = state.methodWrapper; |
||||
|
||||
if (wrapAsync) { |
||||
wrapAsync = _core.types.cloneNode(wrapAsync); |
||||
} else { |
||||
wrapAsync = state.methodWrapper = (0, _helperModuleImports.addNamed)(path, method, module); |
||||
} |
||||
|
||||
(0, _helperRemapAsyncToGenerator.default)(path, { |
||||
wrapAsync |
||||
}, noNewArrows, ignoreFunctionLength); |
||||
} |
||||
|
||||
} |
||||
}; |
||||
} |
||||
|
||||
return { |
||||
name: "transform-async-to-generator", |
||||
visitor: { |
||||
Function(path, state) { |
||||
if (!path.node.async || path.node.generator) return; |
||||
(0, _helperRemapAsyncToGenerator.default)(path, { |
||||
wrapAsync: state.addHelper("asyncToGenerator") |
||||
}, noNewArrows, ignoreFunctionLength); |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,35 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-async-to-generator", |
||||
"version": "7.16.8", |
||||
"description": "Turn async functions into ES2015 generators", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-async-to-generator" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-async-to-generator", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-module-imports": "^7.16.7", |
||||
"@babel/helper-plugin-utils": "^7.16.7", |
||||
"@babel/helper-remap-async-to-generator": "^7.16.8" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-block-scoped-functions |
||||
|
||||
> Babel plugin to ensure function declarations at the block level are block scoped |
||||
|
||||
See our website [@babel/plugin-transform-block-scoped-functions](https://babeljs.io/docs/en/babel-plugin-transform-block-scoped-functions) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-block-scoped-functions |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-block-scoped-functions --dev |
||||
``` |
@ -0,0 +1,56 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
|
||||
function statementList(key, path) { |
||||
const paths = path.get(key); |
||||
|
||||
for (const path of paths) { |
||||
const func = path.node; |
||||
if (!path.isFunctionDeclaration()) continue; |
||||
|
||||
const declar = _core.types.variableDeclaration("let", [_core.types.variableDeclarator(func.id, _core.types.toExpression(func))]); |
||||
|
||||
declar._blockHoist = 2; |
||||
func.id = null; |
||||
path.replaceWith(declar); |
||||
} |
||||
} |
||||
|
||||
return { |
||||
name: "transform-block-scoped-functions", |
||||
visitor: { |
||||
BlockStatement(path) { |
||||
const { |
||||
node, |
||||
parent |
||||
} = path; |
||||
|
||||
if (_core.types.isFunction(parent, { |
||||
body: node |
||||
}) || _core.types.isExportDeclaration(parent)) { |
||||
return; |
||||
} |
||||
|
||||
statementList("body", path); |
||||
}, |
||||
|
||||
SwitchCase(path) { |
||||
statementList("consequent", path); |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,33 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-block-scoped-functions", |
||||
"version": "7.16.7", |
||||
"description": "Babel plugin to ensure function declarations at the block level are block scoped", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-block-scoped-functions" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-block-scoped-functions", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-block-scoping |
||||
|
||||
> Compile ES2015 block scoping (const and let) to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-block-scoping](https://babeljs.io/docs/en/babel-plugin-transform-block-scoping) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-block-scoping |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-block-scoping --dev |
||||
``` |
@ -0,0 +1,763 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _tdz = require("./tdz"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
const DONE = new WeakSet(); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, opts) => { |
||||
api.assertVersion(7); |
||||
const { |
||||
throwIfClosureRequired = false, |
||||
tdz: tdzEnabled = false |
||||
} = opts; |
||||
|
||||
if (typeof throwIfClosureRequired !== "boolean") { |
||||
throw new Error(`.throwIfClosureRequired must be a boolean, or undefined`); |
||||
} |
||||
|
||||
if (typeof tdzEnabled !== "boolean") { |
||||
throw new Error(`.tdz must be a boolean, or undefined`); |
||||
} |
||||
|
||||
return { |
||||
name: "transform-block-scoping", |
||||
visitor: { |
||||
VariableDeclaration(path) { |
||||
const { |
||||
node, |
||||
parent, |
||||
scope |
||||
} = path; |
||||
if (!isBlockScoped(node)) return; |
||||
convertBlockScopedToVar(path, null, parent, scope, true); |
||||
|
||||
if (node._tdzThis) { |
||||
const nodes = [node]; |
||||
|
||||
for (let i = 0; i < node.declarations.length; i++) { |
||||
const decl = node.declarations[i]; |
||||
|
||||
const assign = _core.types.assignmentExpression("=", _core.types.cloneNode(decl.id), decl.init || scope.buildUndefinedNode()); |
||||
|
||||
assign._ignoreBlockScopingTDZ = true; |
||||
nodes.push(_core.types.expressionStatement(assign)); |
||||
decl.init = this.addHelper("temporalUndefined"); |
||||
} |
||||
|
||||
node._blockHoist = 2; |
||||
|
||||
if (path.isCompletionRecord()) { |
||||
nodes.push(_core.types.expressionStatement(scope.buildUndefinedNode())); |
||||
} |
||||
|
||||
path.replaceWithMultiple(nodes); |
||||
} |
||||
}, |
||||
|
||||
Loop(path, state) { |
||||
const { |
||||
parent, |
||||
scope |
||||
} = path; |
||||
path.ensureBlock(); |
||||
const blockScoping = new BlockScoping(path, path.get("body"), parent, scope, throwIfClosureRequired, tdzEnabled, state); |
||||
const replace = blockScoping.run(); |
||||
if (replace) path.replaceWith(replace); |
||||
}, |
||||
|
||||
CatchClause(path, state) { |
||||
const { |
||||
parent, |
||||
scope |
||||
} = path; |
||||
const blockScoping = new BlockScoping(null, path.get("body"), parent, scope, throwIfClosureRequired, tdzEnabled, state); |
||||
blockScoping.run(); |
||||
}, |
||||
|
||||
"BlockStatement|SwitchStatement|Program"(path, state) { |
||||
if (!ignoreBlock(path)) { |
||||
const blockScoping = new BlockScoping(null, path, path.parent, path.scope, throwIfClosureRequired, tdzEnabled, state); |
||||
blockScoping.run(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
||||
|
||||
function ignoreBlock(path) { |
||||
return _core.types.isLoop(path.parent) || _core.types.isCatchClause(path.parent); |
||||
} |
||||
|
||||
const buildRetCheck = (0, _core.template)(` |
||||
if (typeof RETURN === "object") return RETURN.v; |
||||
`);
|
||||
|
||||
function isBlockScoped(node) { |
||||
if (!_core.types.isVariableDeclaration(node)) return false; |
||||
if (node[_core.types.BLOCK_SCOPED_SYMBOL]) return true; |
||||
if (node.kind !== "let" && node.kind !== "const") return false; |
||||
return true; |
||||
} |
||||
|
||||
function isInLoop(path) { |
||||
const loopOrFunctionParent = path.find(path => path.isLoop() || path.isFunction()); |
||||
return loopOrFunctionParent == null ? void 0 : loopOrFunctionParent.isLoop(); |
||||
} |
||||
|
||||
function convertBlockScopedToVar(path, node, parent, scope, moveBindingsToParent = false) { |
||||
if (!node) { |
||||
node = path.node; |
||||
} |
||||
|
||||
if (isInLoop(path) && !_core.types.isFor(parent)) { |
||||
for (let i = 0; i < node.declarations.length; i++) { |
||||
const declar = node.declarations[i]; |
||||
declar.init = declar.init || scope.buildUndefinedNode(); |
||||
} |
||||
} |
||||
|
||||
node[_core.types.BLOCK_SCOPED_SYMBOL] = true; |
||||
node.kind = "var"; |
||||
|
||||
if (moveBindingsToParent) { |
||||
const parentScope = scope.getFunctionParent() || scope.getProgramParent(); |
||||
|
||||
for (const name of Object.keys(path.getBindingIdentifiers())) { |
||||
const binding = scope.getOwnBinding(name); |
||||
if (binding) binding.kind = "var"; |
||||
scope.moveBindingTo(name, parentScope); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function isVar(node) { |
||||
return _core.types.isVariableDeclaration(node, { |
||||
kind: "var" |
||||
}) && !isBlockScoped(node); |
||||
} |
||||
|
||||
const letReferenceBlockVisitor = _core.traverse.visitors.merge([{ |
||||
Loop: { |
||||
enter(path, state) { |
||||
state.loopDepth++; |
||||
}, |
||||
|
||||
exit(path, state) { |
||||
state.loopDepth--; |
||||
} |
||||
|
||||
}, |
||||
|
||||
FunctionParent(path, state) { |
||||
if (state.loopDepth > 0) { |
||||
path.traverse(letReferenceFunctionVisitor, state); |
||||
} else { |
||||
path.traverse(_tdz.visitor, state); |
||||
} |
||||
|
||||
return path.skip(); |
||||
} |
||||
|
||||
}, _tdz.visitor]); |
||||
|
||||
const letReferenceFunctionVisitor = _core.traverse.visitors.merge([{ |
||||
ReferencedIdentifier(path, state) { |
||||
const ref = state.letReferences.get(path.node.name); |
||||
if (!ref) return; |
||||
const localBinding = path.scope.getBindingIdentifier(path.node.name); |
||||
if (localBinding && localBinding !== ref) return; |
||||
state.closurify = true; |
||||
} |
||||
|
||||
}, _tdz.visitor]); |
||||
|
||||
const hoistVarDeclarationsVisitor = { |
||||
enter(path, self) { |
||||
if (path.isForStatement()) { |
||||
const { |
||||
node |
||||
} = path; |
||||
|
||||
if (isVar(node.init)) { |
||||
const nodes = self.pushDeclar(node.init); |
||||
|
||||
if (nodes.length === 1) { |
||||
node.init = nodes[0]; |
||||
} else { |
||||
node.init = _core.types.sequenceExpression(nodes); |
||||
} |
||||
} |
||||
} else if (path.isForInStatement() || path.isForOfStatement()) { |
||||
const { |
||||
node |
||||
} = path; |
||||
|
||||
if (isVar(node.left)) { |
||||
self.pushDeclar(node.left); |
||||
node.left = node.left.declarations[0].id; |
||||
} |
||||
} else if (isVar(path.node)) { |
||||
path.replaceWithMultiple(self.pushDeclar(path.node).map(expr => _core.types.expressionStatement(expr))); |
||||
} else if (path.isFunction()) { |
||||
return path.skip(); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
const loopLabelVisitor = { |
||||
LabeledStatement({ |
||||
node |
||||
}, state) { |
||||
state.innerLabels.push(node.label.name); |
||||
} |
||||
|
||||
}; |
||||
const continuationVisitor = { |
||||
enter(path, state) { |
||||
if (path.isAssignmentExpression() || path.isUpdateExpression()) { |
||||
for (const name of Object.keys(path.getBindingIdentifiers())) { |
||||
if (state.outsideReferences.get(name) !== path.scope.getBindingIdentifier(name)) { |
||||
continue; |
||||
} |
||||
|
||||
state.reassignments[name] = true; |
||||
} |
||||
} else if (path.isReturnStatement()) { |
||||
state.returnStatements.push(path); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
|
||||
function loopNodeTo(node) { |
||||
if (_core.types.isBreakStatement(node)) { |
||||
return "break"; |
||||
} else if (_core.types.isContinueStatement(node)) { |
||||
return "continue"; |
||||
} |
||||
} |
||||
|
||||
const loopVisitor = { |
||||
Loop(path, state) { |
||||
const oldIgnoreLabeless = state.ignoreLabeless; |
||||
state.ignoreLabeless = true; |
||||
path.traverse(loopVisitor, state); |
||||
state.ignoreLabeless = oldIgnoreLabeless; |
||||
path.skip(); |
||||
}, |
||||
|
||||
Function(path) { |
||||
path.skip(); |
||||
}, |
||||
|
||||
SwitchCase(path, state) { |
||||
const oldInSwitchCase = state.inSwitchCase; |
||||
state.inSwitchCase = true; |
||||
path.traverse(loopVisitor, state); |
||||
state.inSwitchCase = oldInSwitchCase; |
||||
path.skip(); |
||||
}, |
||||
|
||||
"BreakStatement|ContinueStatement|ReturnStatement"(path, state) { |
||||
const { |
||||
node, |
||||
scope |
||||
} = path; |
||||
if (node[this.LOOP_IGNORE]) return; |
||||
let replace; |
||||
let loopText = loopNodeTo(node); |
||||
|
||||
if (loopText) { |
||||
if (_core.types.isReturnStatement(node)) { |
||||
throw new Error("Internal error: unexpected return statement with `loopText`"); |
||||
} |
||||
|
||||
if (node.label) { |
||||
if (state.innerLabels.indexOf(node.label.name) >= 0) { |
||||
return; |
||||
} |
||||
|
||||
loopText = `${loopText}|${node.label.name}`; |
||||
} else { |
||||
if (state.ignoreLabeless) return; |
||||
if (_core.types.isBreakStatement(node) && state.inSwitchCase) return; |
||||
} |
||||
|
||||
state.hasBreakContinue = true; |
||||
state.map[loopText] = node; |
||||
replace = _core.types.stringLiteral(loopText); |
||||
} |
||||
|
||||
if (_core.types.isReturnStatement(node)) { |
||||
state.hasReturn = true; |
||||
replace = _core.types.objectExpression([_core.types.objectProperty(_core.types.identifier("v"), node.argument || scope.buildUndefinedNode())]); |
||||
} |
||||
|
||||
if (replace) { |
||||
replace = _core.types.returnStatement(replace); |
||||
replace[this.LOOP_IGNORE] = true; |
||||
path.skip(); |
||||
path.replaceWith(_core.types.inherits(replace, node)); |
||||
} |
||||
} |
||||
|
||||
}; |
||||
|
||||
function isStrict(path) { |
||||
return !!path.find(({ |
||||
node |
||||
}) => { |
||||
if (_core.types.isProgram(node)) { |
||||
if (node.sourceType === "module") return true; |
||||
} else if (!_core.types.isBlockStatement(node)) return false; |
||||
|
||||
return node.directives.some(directive => directive.value.value === "use strict"); |
||||
}); |
||||
} |
||||
|
||||
class BlockScoping { |
||||
constructor(loopPath, blockPath, parent, scope, throwIfClosureRequired, tdzEnabled, state) { |
||||
this.parent = void 0; |
||||
this.state = void 0; |
||||
this.scope = void 0; |
||||
this.throwIfClosureRequired = void 0; |
||||
this.tdzEnabled = void 0; |
||||
this.blockPath = void 0; |
||||
this.block = void 0; |
||||
this.outsideLetReferences = void 0; |
||||
this.hasLetReferences = void 0; |
||||
this.letReferences = void 0; |
||||
this.body = void 0; |
||||
this.loopParent = void 0; |
||||
this.loopLabel = void 0; |
||||
this.loopPath = void 0; |
||||
this.loop = void 0; |
||||
this.has = void 0; |
||||
this.parent = parent; |
||||
this.scope = scope; |
||||
this.state = state; |
||||
this.throwIfClosureRequired = throwIfClosureRequired; |
||||
this.tdzEnabled = tdzEnabled; |
||||
this.blockPath = blockPath; |
||||
this.block = blockPath.node; |
||||
this.outsideLetReferences = new Map(); |
||||
this.hasLetReferences = false; |
||||
this.letReferences = new Map(); |
||||
this.body = []; |
||||
|
||||
if (loopPath) { |
||||
this.loopParent = loopPath.parent; |
||||
this.loopLabel = _core.types.isLabeledStatement(this.loopParent) && this.loopParent.label; |
||||
this.loopPath = loopPath; |
||||
this.loop = loopPath.node; |
||||
} |
||||
} |
||||
|
||||
run() { |
||||
const block = this.block; |
||||
if (DONE.has(block)) return; |
||||
DONE.add(block); |
||||
const needsClosure = this.getLetReferences(); |
||||
this.checkConstants(); |
||||
|
||||
if (_core.types.isFunction(this.parent) || _core.types.isProgram(this.block)) { |
||||
this.updateScopeInfo(); |
||||
return; |
||||
} |
||||
|
||||
if (!this.hasLetReferences) return; |
||||
|
||||
if (needsClosure) { |
||||
this.wrapClosure(); |
||||
} else { |
||||
this.remap(); |
||||
} |
||||
|
||||
this.updateScopeInfo(needsClosure); |
||||
|
||||
if (this.loopLabel && !_core.types.isLabeledStatement(this.loopParent)) { |
||||
return _core.types.labeledStatement(this.loopLabel, this.loop); |
||||
} |
||||
} |
||||
|
||||
checkConstants() { |
||||
const scope = this.scope; |
||||
const state = this.state; |
||||
|
||||
for (const name of Object.keys(scope.bindings)) { |
||||
const binding = scope.bindings[name]; |
||||
if (binding.kind !== "const") continue; |
||||
|
||||
for (const violation of binding.constantViolations) { |
||||
const readOnlyError = state.addHelper("readOnlyError"); |
||||
|
||||
const throwNode = _core.types.callExpression(readOnlyError, [_core.types.stringLiteral(name)]); |
||||
|
||||
if (violation.isAssignmentExpression()) { |
||||
const { |
||||
operator |
||||
} = violation.node; |
||||
|
||||
if (operator === "=") { |
||||
violation.replaceWith(_core.types.sequenceExpression([violation.get("right").node, throwNode])); |
||||
} else if (["&&=", "||=", "??="].includes(operator)) { |
||||
violation.replaceWith(_core.types.logicalExpression(operator.slice(0, -1), violation.get("left").node, _core.types.sequenceExpression([violation.get("right").node, throwNode]))); |
||||
} else { |
||||
violation.replaceWith(_core.types.sequenceExpression([_core.types.binaryExpression(operator.slice(0, -1), violation.get("left").node, violation.get("right").node), throwNode])); |
||||
} |
||||
} else if (violation.isUpdateExpression()) { |
||||
violation.replaceWith(_core.types.sequenceExpression([_core.types.unaryExpression("+", violation.get("argument").node), throwNode])); |
||||
} else if (violation.isForXStatement()) { |
||||
violation.ensureBlock(); |
||||
violation.get("left").replaceWith(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(violation.scope.generateUidIdentifier(name))])); |
||||
violation.node.body.body.unshift(_core.types.expressionStatement(throwNode)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
updateScopeInfo(wrappedInClosure) { |
||||
const blockScope = this.blockPath.scope; |
||||
const parentScope = blockScope.getFunctionParent() || blockScope.getProgramParent(); |
||||
const letRefs = this.letReferences; |
||||
|
||||
for (const key of letRefs.keys()) { |
||||
const ref = letRefs.get(key); |
||||
const binding = blockScope.getBinding(ref.name); |
||||
if (!binding) continue; |
||||
|
||||
if (binding.kind === "let" || binding.kind === "const") { |
||||
binding.kind = "var"; |
||||
|
||||
if (wrappedInClosure) { |
||||
if (blockScope.hasOwnBinding(ref.name)) { |
||||
blockScope.removeBinding(ref.name); |
||||
} |
||||
} else { |
||||
blockScope.moveBindingTo(ref.name, parentScope); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
remap() { |
||||
const letRefs = this.letReferences; |
||||
const outsideLetRefs = this.outsideLetReferences; |
||||
const scope = this.scope; |
||||
const blockPathScope = this.blockPath.scope; |
||||
|
||||
for (const key of letRefs.keys()) { |
||||
const ref = letRefs.get(key); |
||||
|
||||
if (scope.parentHasBinding(key) || scope.hasGlobal(key)) { |
||||
const binding = scope.getOwnBinding(key); |
||||
|
||||
if (binding) { |
||||
const parentBinding = scope.parent.getOwnBinding(key); |
||||
|
||||
if (binding.kind === "hoisted" && !binding.path.node.async && !binding.path.node.generator && (!parentBinding || isVar(parentBinding.path.parent)) && !isStrict(binding.path.parentPath)) { |
||||
continue; |
||||
} |
||||
|
||||
scope.rename(ref.name); |
||||
} |
||||
|
||||
if (blockPathScope.hasOwnBinding(key)) { |
||||
blockPathScope.rename(ref.name); |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (const key of outsideLetRefs.keys()) { |
||||
const ref = letRefs.get(key); |
||||
|
||||
if (isInLoop(this.blockPath) && blockPathScope.hasOwnBinding(key)) { |
||||
blockPathScope.rename(ref.name); |
||||
} |
||||
} |
||||
} |
||||
|
||||
wrapClosure() { |
||||
if (this.throwIfClosureRequired) { |
||||
throw this.blockPath.buildCodeFrameError("Compiling let/const in this block would add a closure " + "(throwIfClosureRequired)."); |
||||
} |
||||
|
||||
const block = this.block; |
||||
const outsideRefs = this.outsideLetReferences; |
||||
|
||||
if (this.loop) { |
||||
for (const name of Array.from(outsideRefs.keys())) { |
||||
const id = outsideRefs.get(name); |
||||
|
||||
if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) { |
||||
outsideRefs.delete(id.name); |
||||
this.letReferences.delete(id.name); |
||||
this.scope.rename(id.name); |
||||
this.letReferences.set(id.name, id); |
||||
outsideRefs.set(id.name, id); |
||||
} |
||||
} |
||||
} |
||||
|
||||
this.has = this.checkLoop(); |
||||
this.hoistVarDeclarations(); |
||||
const args = Array.from(outsideRefs.values(), node => _core.types.cloneNode(node)); |
||||
const params = args.map(id => _core.types.cloneNode(id)); |
||||
const isSwitch = this.blockPath.isSwitchStatement(); |
||||
|
||||
const fn = _core.types.functionExpression(null, params, _core.types.blockStatement(isSwitch ? [block] : block.body)); |
||||
|
||||
this.addContinuations(fn); |
||||
|
||||
let call = _core.types.callExpression(_core.types.nullLiteral(), args); |
||||
|
||||
let basePath = ".callee"; |
||||
|
||||
const hasYield = _core.traverse.hasType(fn.body, "YieldExpression", _core.types.FUNCTION_TYPES); |
||||
|
||||
if (hasYield) { |
||||
fn.generator = true; |
||||
call = _core.types.yieldExpression(call, true); |
||||
basePath = ".argument" + basePath; |
||||
} |
||||
|
||||
const hasAsync = _core.traverse.hasType(fn.body, "AwaitExpression", _core.types.FUNCTION_TYPES); |
||||
|
||||
if (hasAsync) { |
||||
fn.async = true; |
||||
call = _core.types.awaitExpression(call); |
||||
basePath = ".argument" + basePath; |
||||
} |
||||
|
||||
let placeholderPath; |
||||
let index; |
||||
|
||||
if (this.has.hasReturn || this.has.hasBreakContinue) { |
||||
const ret = this.scope.generateUid("ret"); |
||||
this.body.push(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(ret), call)])); |
||||
placeholderPath = "declarations.0.init" + basePath; |
||||
index = this.body.length - 1; |
||||
this.buildHas(ret); |
||||
} else { |
||||
this.body.push(_core.types.expressionStatement(call)); |
||||
placeholderPath = "expression" + basePath; |
||||
index = this.body.length - 1; |
||||
} |
||||
|
||||
let callPath; |
||||
|
||||
if (isSwitch) { |
||||
const { |
||||
parentPath, |
||||
listKey, |
||||
key |
||||
} = this.blockPath; |
||||
this.blockPath.replaceWithMultiple(this.body); |
||||
callPath = parentPath.get(listKey)[key + index]; |
||||
} else { |
||||
block.body = this.body; |
||||
callPath = this.blockPath.get("body")[index]; |
||||
} |
||||
|
||||
const placeholder = callPath.get(placeholderPath); |
||||
let fnPath; |
||||
|
||||
if (this.loop) { |
||||
const loopId = this.scope.generateUid("loop"); |
||||
const p = this.loopPath.insertBefore(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(loopId), fn)])); |
||||
placeholder.replaceWith(_core.types.identifier(loopId)); |
||||
fnPath = p[0].get("declarations.0.init"); |
||||
} else { |
||||
placeholder.replaceWith(fn); |
||||
fnPath = placeholder; |
||||
} |
||||
|
||||
fnPath.unwrapFunctionEnvironment(); |
||||
} |
||||
|
||||
addContinuations(fn) { |
||||
const state = { |
||||
reassignments: {}, |
||||
returnStatements: [], |
||||
outsideReferences: this.outsideLetReferences |
||||
}; |
||||
this.scope.traverse(fn, continuationVisitor, state); |
||||
|
||||
for (let i = 0; i < fn.params.length; i++) { |
||||
const param = fn.params[i]; |
||||
if (!state.reassignments[param.name]) continue; |
||||
const paramName = param.name; |
||||
const newParamName = this.scope.generateUid(param.name); |
||||
fn.params[i] = _core.types.identifier(newParamName); |
||||
this.scope.rename(paramName, newParamName, fn); |
||||
state.returnStatements.forEach(returnStatement => { |
||||
returnStatement.insertBefore(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName)))); |
||||
}); |
||||
fn.body.body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.identifier(paramName), _core.types.identifier(newParamName)))); |
||||
} |
||||
} |
||||
|
||||
getLetReferences() { |
||||
const block = this.block; |
||||
const declarators = []; |
||||
|
||||
if (this.loop) { |
||||
const init = this.loop.left || this.loop.init; |
||||
|
||||
if (isBlockScoped(init)) { |
||||
declarators.push(init); |
||||
|
||||
const names = _core.types.getBindingIdentifiers(init); |
||||
|
||||
for (const name of Object.keys(names)) { |
||||
this.outsideLetReferences.set(name, names[name]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
const addDeclarationsFromChild = (path, node) => { |
||||
node = node || path.node; |
||||
|
||||
if (_core.types.isClassDeclaration(node) || _core.types.isFunctionDeclaration(node) || isBlockScoped(node)) { |
||||
if (isBlockScoped(node)) { |
||||
convertBlockScopedToVar(path, node, block, this.scope); |
||||
} |
||||
|
||||
if (node.declarations) { |
||||
for (let i = 0; i < node.declarations.length; i++) { |
||||
declarators.push(node.declarations[i]); |
||||
} |
||||
} else { |
||||
declarators.push(node); |
||||
} |
||||
} |
||||
|
||||
if (_core.types.isLabeledStatement(node)) { |
||||
addDeclarationsFromChild(path.get("body"), node.body); |
||||
} |
||||
}; |
||||
|
||||
if (block.body) { |
||||
const declarPaths = this.blockPath.get("body"); |
||||
|
||||
for (let i = 0; i < block.body.length; i++) { |
||||
addDeclarationsFromChild(declarPaths[i]); |
||||
} |
||||
} |
||||
|
||||
if (block.cases) { |
||||
const declarPaths = this.blockPath.get("cases"); |
||||
|
||||
for (let i = 0; i < block.cases.length; i++) { |
||||
const consequents = block.cases[i].consequent; |
||||
|
||||
for (let j = 0; j < consequents.length; j++) { |
||||
const declar = consequents[j]; |
||||
addDeclarationsFromChild(declarPaths[i], declar); |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (let i = 0; i < declarators.length; i++) { |
||||
const declar = declarators[i]; |
||||
|
||||
const keys = _core.types.getBindingIdentifiers(declar, false, true); |
||||
|
||||
for (const key of Object.keys(keys)) { |
||||
this.letReferences.set(key, keys[key]); |
||||
} |
||||
|
||||
this.hasLetReferences = true; |
||||
} |
||||
|
||||
if (!this.hasLetReferences) return; |
||||
const state = { |
||||
letReferences: this.letReferences, |
||||
closurify: false, |
||||
loopDepth: 0, |
||||
tdzEnabled: this.tdzEnabled, |
||||
addHelper: name => this.state.addHelper(name) |
||||
}; |
||||
|
||||
if (isInLoop(this.blockPath)) { |
||||
state.loopDepth++; |
||||
} |
||||
|
||||
this.blockPath.traverse(letReferenceBlockVisitor, state); |
||||
return state.closurify; |
||||
} |
||||
|
||||
checkLoop() { |
||||
const state = { |
||||
hasBreakContinue: false, |
||||
ignoreLabeless: false, |
||||
inSwitchCase: false, |
||||
innerLabels: [], |
||||
hasReturn: false, |
||||
isLoop: !!this.loop, |
||||
map: {}, |
||||
LOOP_IGNORE: Symbol() |
||||
}; |
||||
this.blockPath.traverse(loopLabelVisitor, state); |
||||
this.blockPath.traverse(loopVisitor, state); |
||||
return state; |
||||
} |
||||
|
||||
hoistVarDeclarations() { |
||||
this.blockPath.traverse(hoistVarDeclarationsVisitor, this); |
||||
} |
||||
|
||||
pushDeclar(node) { |
||||
const declars = []; |
||||
|
||||
const names = _core.types.getBindingIdentifiers(node); |
||||
|
||||
for (const name of Object.keys(names)) { |
||||
declars.push(_core.types.variableDeclarator(names[name])); |
||||
} |
||||
|
||||
this.body.push(_core.types.variableDeclaration(node.kind, declars)); |
||||
const replace = []; |
||||
|
||||
for (let i = 0; i < node.declarations.length; i++) { |
||||
const declar = node.declarations[i]; |
||||
if (!declar.init) continue; |
||||
|
||||
const expr = _core.types.assignmentExpression("=", _core.types.cloneNode(declar.id), _core.types.cloneNode(declar.init)); |
||||
|
||||
replace.push(_core.types.inherits(expr, declar)); |
||||
} |
||||
|
||||
return replace; |
||||
} |
||||
|
||||
buildHas(ret) { |
||||
const body = this.body; |
||||
const has = this.has; |
||||
|
||||
if (has.hasBreakContinue) { |
||||
for (const key of Object.keys(has.map)) { |
||||
body.push(_core.types.ifStatement(_core.types.binaryExpression("===", _core.types.identifier(ret), _core.types.stringLiteral(key)), has.map[key])); |
||||
} |
||||
} |
||||
|
||||
if (has.hasReturn) { |
||||
body.push(buildRetCheck({ |
||||
RETURN: _core.types.identifier(ret) |
||||
})); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,97 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.visitor = void 0; |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
function getTDZStatus(refPath, bindingPath) { |
||||
const executionStatus = bindingPath._guessExecutionStatusRelativeTo(refPath); |
||||
|
||||
if (executionStatus === "before") { |
||||
return "outside"; |
||||
} else if (executionStatus === "after") { |
||||
return "inside"; |
||||
} else { |
||||
return "maybe"; |
||||
} |
||||
} |
||||
|
||||
function buildTDZAssert(node, state) { |
||||
return _core.types.callExpression(state.addHelper("temporalRef"), [node, _core.types.stringLiteral(node.name)]); |
||||
} |
||||
|
||||
function isReference(node, scope, state) { |
||||
const declared = state.letReferences.get(node.name); |
||||
if (!declared) return false; |
||||
return scope.getBindingIdentifier(node.name) === declared; |
||||
} |
||||
|
||||
const visitedMaybeTDZNodes = new WeakSet(); |
||||
const visitor = { |
||||
ReferencedIdentifier(path, state) { |
||||
if (!state.tdzEnabled) return; |
||||
const { |
||||
node, |
||||
parent, |
||||
scope |
||||
} = path; |
||||
if (path.parentPath.isFor({ |
||||
left: node |
||||
})) return; |
||||
if (!isReference(node, scope, state)) return; |
||||
const bindingPath = scope.getBinding(node.name).path; |
||||
if (bindingPath.isFunctionDeclaration()) return; |
||||
const status = getTDZStatus(path, bindingPath); |
||||
if (status === "outside") return; |
||||
|
||||
if (status === "maybe") { |
||||
if (visitedMaybeTDZNodes.has(node)) { |
||||
return; |
||||
} |
||||
|
||||
visitedMaybeTDZNodes.add(node); |
||||
const assert = buildTDZAssert(node, state); |
||||
bindingPath.parent._tdzThis = true; |
||||
|
||||
if (path.parentPath.isUpdateExpression()) { |
||||
if (parent._ignoreBlockScopingTDZ) return; |
||||
path.parentPath.replaceWith(_core.types.sequenceExpression([assert, parent])); |
||||
} else { |
||||
path.replaceWith(assert); |
||||
} |
||||
} else if (status === "inside") { |
||||
path.replaceWith(_core.template.ast`${state.addHelper("tdz")}("${node.name}")`); |
||||
} |
||||
}, |
||||
|
||||
AssignmentExpression: { |
||||
exit(path, state) { |
||||
if (!state.tdzEnabled) return; |
||||
const { |
||||
node |
||||
} = path; |
||||
if (node._ignoreBlockScopingTDZ) return; |
||||
const nodes = []; |
||||
const ids = path.getBindingIdentifiers(); |
||||
|
||||
for (const name of Object.keys(ids)) { |
||||
const id = ids[name]; |
||||
|
||||
if (isReference(id, path.scope, state)) { |
||||
nodes.push(id); |
||||
} |
||||
} |
||||
|
||||
if (nodes.length) { |
||||
node._ignoreBlockScopingTDZ = true; |
||||
nodes.push(node); |
||||
path.replaceWithMultiple(nodes.map(n => _core.types.expressionStatement(n))); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
exports.visitor = visitor; |
@ -0,0 +1,34 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-block-scoping", |
||||
"version": "7.16.7", |
||||
"description": "Compile ES2015 block scoping (const and let) to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-block-scoping" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-block-scoping", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7", |
||||
"@babel/traverse": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-classes |
||||
|
||||
> Compile ES2015 classes to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-classes](https://babeljs.io/docs/en/babel-plugin-transform-classes) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-classes |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-classes --dev |
||||
``` |
@ -0,0 +1,88 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure"); |
||||
|
||||
var _helperFunctionName = require("@babel/helper-function-name"); |
||||
|
||||
var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _globals = require("globals"); |
||||
|
||||
var _transformClass = require("./transformClass"); |
||||
|
||||
const getBuiltinClasses = category => Object.keys(_globals[category]).filter(name => /^[A-Z]/.test(name)); |
||||
|
||||
const builtinClasses = new Set([...getBuiltinClasses("builtin"), ...getBuiltinClasses("browser")]); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
var _api$assumption, _api$assumption2, _api$assumption3, _api$assumption4; |
||||
|
||||
api.assertVersion(7); |
||||
const { |
||||
loose |
||||
} = options; |
||||
const setClassMethods = (_api$assumption = api.assumption("setClassMethods")) != null ? _api$assumption : options.loose; |
||||
const constantSuper = (_api$assumption2 = api.assumption("constantSuper")) != null ? _api$assumption2 : options.loose; |
||||
const superIsCallableConstructor = (_api$assumption3 = api.assumption("superIsCallableConstructor")) != null ? _api$assumption3 : options.loose; |
||||
const noClassCalls = (_api$assumption4 = api.assumption("noClassCalls")) != null ? _api$assumption4 : options.loose; |
||||
const VISITED = Symbol(); |
||||
return { |
||||
name: "transform-classes", |
||||
visitor: { |
||||
ExportDefaultDeclaration(path) { |
||||
if (!path.get("declaration").isClassDeclaration()) return; |
||||
(0, _helperSplitExportDeclaration.default)(path); |
||||
}, |
||||
|
||||
ClassDeclaration(path) { |
||||
const { |
||||
node |
||||
} = path; |
||||
const ref = node.id || path.scope.generateUidIdentifier("class"); |
||||
path.replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(ref, _core.types.toExpression(node))])); |
||||
}, |
||||
|
||||
ClassExpression(path, state) { |
||||
const { |
||||
node |
||||
} = path; |
||||
if (node[VISITED]) return; |
||||
const inferred = (0, _helperFunctionName.default)(path); |
||||
|
||||
if (inferred && inferred !== node) { |
||||
path.replaceWith(inferred); |
||||
return; |
||||
} |
||||
|
||||
node[VISITED] = true; |
||||
path.replaceWith((0, _transformClass.default)(path, state.file, builtinClasses, loose, { |
||||
setClassMethods, |
||||
constantSuper, |
||||
superIsCallableConstructor, |
||||
noClassCalls |
||||
})); |
||||
|
||||
if (path.isCallExpression()) { |
||||
(0, _helperAnnotateAsPure.default)(path); |
||||
const callee = path.get("callee"); |
||||
|
||||
if (callee.isArrowFunctionExpression()) { |
||||
callee.arrowFunctionToExpression(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,72 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = addCreateSuperHelper; |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
const helperIDs = new WeakMap(); |
||||
|
||||
function addCreateSuperHelper(file) { |
||||
if (helperIDs.has(file)) { |
||||
return (_core.types.cloneNode || _core.types.clone)(helperIDs.get(file)); |
||||
} |
||||
|
||||
try { |
||||
return file.addHelper("createSuper"); |
||||
} catch (_unused) {} |
||||
|
||||
const id = file.scope.generateUidIdentifier("createSuper"); |
||||
helperIDs.set(file, id); |
||||
const fn = helper({ |
||||
CREATE_SUPER: id, |
||||
GET_PROTOTYPE_OF: file.addHelper("getPrototypeOf"), |
||||
POSSIBLE_CONSTRUCTOR_RETURN: file.addHelper("possibleConstructorReturn") |
||||
}); |
||||
file.path.unshiftContainer("body", [fn]); |
||||
file.scope.registerDeclaration(file.path.get("body.0")); |
||||
return _core.types.cloneNode(id); |
||||
} |
||||
|
||||
const helper = _core.template.statement` |
||||
function CREATE_SUPER(Derived) { |
||||
function isNativeReflectConstruct() { |
||||
if (typeof Reflect === "undefined" || !Reflect.construct) return false; |
||||
|
||||
// core-js@3
|
||||
if (Reflect.construct.sham) return false; |
||||
|
||||
// Proxy can't be polyfilled. Every browser implemented
|
||||
// proxies before or at the same time as Reflect.construct,
|
||||
// so if they support Proxy they also support Reflect.construct.
|
||||
if (typeof Proxy === "function") return true; |
||||
|
||||
// Since Reflect.construct can't be properly polyfilled, some
|
||||
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
||||
// Those polyfills don't allow us to subclass built-ins, so we need to
|
||||
// use our fallback implementation.
|
||||
try { |
||||
// If the internal slots aren't set, this throws an error similar to
|
||||
// TypeError: this is not a Date object.
|
||||
Date.prototype.toString.call(Reflect.construct(Date, [], function() {})); |
||||
return true; |
||||
} catch (e) { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return function () { |
||||
var Super = GET_PROTOTYPE_OF(Derived), result; |
||||
if (isNativeReflectConstruct()) { |
||||
// NOTE: This doesn't work if this.__proto__.constructor has been modified.
|
||||
var NewTarget = GET_PROTOTYPE_OF(this).constructor; |
||||
result = Reflect.construct(Super, arguments, NewTarget); |
||||
} else { |
||||
result = Super.apply(this, arguments); |
||||
} |
||||
return POSSIBLE_CONSTRUCTOR_RETURN(this, result); |
||||
} |
||||
} |
||||
`;
|
@ -0,0 +1,622 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = transformClass; |
||||
|
||||
var _helperFunctionName = require("@babel/helper-function-name"); |
||||
|
||||
var _helperReplaceSupers = require("@babel/helper-replace-supers"); |
||||
|
||||
var _helperEnvironmentVisitor = require("@babel/helper-environment-visitor"); |
||||
|
||||
var _helperOptimiseCallExpression = require("@babel/helper-optimise-call-expression"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure"); |
||||
|
||||
var _inlineCreateSuperHelpers = require("./inline-createSuper-helpers"); |
||||
|
||||
function buildConstructor(classRef, constructorBody, node) { |
||||
const func = _core.types.functionDeclaration(_core.types.cloneNode(classRef), [], constructorBody); |
||||
|
||||
_core.types.inherits(func, node); |
||||
|
||||
return func; |
||||
} |
||||
|
||||
function transformClass(path, file, builtinClasses, isLoose, assumptions) { |
||||
const classState = { |
||||
parent: undefined, |
||||
scope: undefined, |
||||
node: undefined, |
||||
path: undefined, |
||||
file: undefined, |
||||
classId: undefined, |
||||
classRef: undefined, |
||||
superFnId: undefined, |
||||
superName: undefined, |
||||
superReturns: [], |
||||
isDerived: false, |
||||
extendsNative: false, |
||||
construct: undefined, |
||||
constructorBody: undefined, |
||||
userConstructor: undefined, |
||||
userConstructorPath: undefined, |
||||
hasConstructor: false, |
||||
staticPropBody: [], |
||||
body: [], |
||||
superThises: [], |
||||
pushedConstructor: false, |
||||
pushedInherits: false, |
||||
pushedCreateClass: false, |
||||
protoAlias: null, |
||||
isLoose: false, |
||||
dynamicKeys: new Map(), |
||||
methods: { |
||||
instance: { |
||||
hasComputed: false, |
||||
list: [], |
||||
map: new Map() |
||||
}, |
||||
static: { |
||||
hasComputed: false, |
||||
list: [], |
||||
map: new Map() |
||||
} |
||||
} |
||||
}; |
||||
|
||||
const setState = newState => { |
||||
Object.assign(classState, newState); |
||||
}; |
||||
|
||||
const findThisesVisitor = _core.traverse.visitors.merge([_helperEnvironmentVisitor.default, { |
||||
ThisExpression(path) { |
||||
classState.superThises.push(path); |
||||
} |
||||
|
||||
}]); |
||||
|
||||
function createClassHelper(args) { |
||||
return _core.types.callExpression(classState.file.addHelper("createClass"), args); |
||||
} |
||||
|
||||
function maybeCreateConstructor() { |
||||
let hasConstructor = false; |
||||
const paths = classState.path.get("body.body"); |
||||
|
||||
for (const path of paths) { |
||||
hasConstructor = path.equals("kind", "constructor"); |
||||
if (hasConstructor) break; |
||||
} |
||||
|
||||
if (hasConstructor) return; |
||||
let params, body; |
||||
|
||||
if (classState.isDerived) { |
||||
const constructor = _core.template.expression.ast` |
||||
(function () { |
||||
super(...arguments); |
||||
}) |
||||
`;
|
||||
params = constructor.params; |
||||
body = constructor.body; |
||||
} else { |
||||
params = []; |
||||
body = _core.types.blockStatement([]); |
||||
} |
||||
|
||||
classState.path.get("body").unshiftContainer("body", _core.types.classMethod("constructor", _core.types.identifier("constructor"), params, body)); |
||||
} |
||||
|
||||
function buildBody() { |
||||
maybeCreateConstructor(); |
||||
pushBody(); |
||||
verifyConstructor(); |
||||
|
||||
if (classState.userConstructor) { |
||||
const { |
||||
constructorBody, |
||||
userConstructor, |
||||
construct |
||||
} = classState; |
||||
constructorBody.body.push(...userConstructor.body.body); |
||||
|
||||
_core.types.inherits(construct, userConstructor); |
||||
|
||||
_core.types.inherits(constructorBody, userConstructor.body); |
||||
} |
||||
|
||||
pushDescriptors(); |
||||
} |
||||
|
||||
function pushBody() { |
||||
const classBodyPaths = classState.path.get("body.body"); |
||||
|
||||
for (const path of classBodyPaths) { |
||||
const node = path.node; |
||||
|
||||
if (path.isClassProperty()) { |
||||
throw path.buildCodeFrameError("Missing class properties transform."); |
||||
} |
||||
|
||||
if (node.decorators) { |
||||
throw path.buildCodeFrameError("Method has decorators, put the decorator plugin before the classes one."); |
||||
} |
||||
|
||||
if (_core.types.isClassMethod(node)) { |
||||
const isConstructor = node.kind === "constructor"; |
||||
const replaceSupers = new _helperReplaceSupers.default({ |
||||
methodPath: path, |
||||
objectRef: classState.classRef, |
||||
superRef: classState.superName, |
||||
constantSuper: assumptions.constantSuper, |
||||
file: classState.file, |
||||
refToPreserve: classState.classRef |
||||
}); |
||||
replaceSupers.replace(); |
||||
const superReturns = []; |
||||
path.traverse(_core.traverse.visitors.merge([_helperEnvironmentVisitor.default, { |
||||
ReturnStatement(path) { |
||||
if (!path.getFunctionParent().isArrowFunctionExpression()) { |
||||
superReturns.push(path); |
||||
} |
||||
} |
||||
|
||||
}])); |
||||
|
||||
if (isConstructor) { |
||||
pushConstructor(superReturns, node, path); |
||||
} else { |
||||
pushMethod(node, path); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
function pushDescriptors() { |
||||
pushInheritsToBody(); |
||||
const { |
||||
body |
||||
} = classState; |
||||
const props = { |
||||
instance: null, |
||||
static: null |
||||
}; |
||||
|
||||
for (const placement of ["static", "instance"]) { |
||||
if (classState.methods[placement].list.length) { |
||||
props[placement] = classState.methods[placement].list.map(desc => { |
||||
const obj = _core.types.objectExpression([_core.types.objectProperty(_core.types.identifier("key"), desc.key)]); |
||||
|
||||
for (const kind of ["get", "set", "value"]) { |
||||
if (desc[kind] != null) { |
||||
obj.properties.push(_core.types.objectProperty(_core.types.identifier(kind), desc[kind])); |
||||
} |
||||
} |
||||
|
||||
return obj; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
if (props.instance || props.static) { |
||||
let args = [_core.types.cloneNode(classState.classRef), props.instance ? _core.types.arrayExpression(props.instance) : _core.types.nullLiteral(), props.static ? _core.types.arrayExpression(props.static) : _core.types.nullLiteral()]; |
||||
let lastNonNullIndex = 0; |
||||
|
||||
for (let i = 0; i < args.length; i++) { |
||||
if (!_core.types.isNullLiteral(args[i])) lastNonNullIndex = i; |
||||
} |
||||
|
||||
args = args.slice(0, lastNonNullIndex + 1); |
||||
body.push(_core.types.expressionStatement(createClassHelper(args))); |
||||
classState.pushedCreateClass = true; |
||||
} |
||||
} |
||||
|
||||
function wrapSuperCall(bareSuper, superRef, thisRef, body) { |
||||
const bareSuperNode = bareSuper.node; |
||||
let call; |
||||
|
||||
if (assumptions.superIsCallableConstructor) { |
||||
bareSuperNode.arguments.unshift(_core.types.thisExpression()); |
||||
|
||||
if (bareSuperNode.arguments.length === 2 && _core.types.isSpreadElement(bareSuperNode.arguments[1]) && _core.types.isIdentifier(bareSuperNode.arguments[1].argument, { |
||||
name: "arguments" |
||||
})) { |
||||
bareSuperNode.arguments[1] = bareSuperNode.arguments[1].argument; |
||||
bareSuperNode.callee = _core.types.memberExpression(_core.types.cloneNode(superRef), _core.types.identifier("apply")); |
||||
} else { |
||||
bareSuperNode.callee = _core.types.memberExpression(_core.types.cloneNode(superRef), _core.types.identifier("call")); |
||||
} |
||||
|
||||
call = _core.types.logicalExpression("||", bareSuperNode, _core.types.thisExpression()); |
||||
} else { |
||||
call = (0, _helperOptimiseCallExpression.default)(_core.types.cloneNode(classState.superFnId), _core.types.thisExpression(), bareSuperNode.arguments, false); |
||||
} |
||||
|
||||
if (bareSuper.parentPath.isExpressionStatement() && bareSuper.parentPath.container === body.node.body && body.node.body.length - 1 === bareSuper.parentPath.key) { |
||||
if (classState.superThises.length) { |
||||
call = _core.types.assignmentExpression("=", thisRef(), call); |
||||
} |
||||
|
||||
bareSuper.parentPath.replaceWith(_core.types.returnStatement(call)); |
||||
} else { |
||||
bareSuper.replaceWith(_core.types.assignmentExpression("=", thisRef(), call)); |
||||
} |
||||
} |
||||
|
||||
function verifyConstructor() { |
||||
if (!classState.isDerived) return; |
||||
const path = classState.userConstructorPath; |
||||
const body = path.get("body"); |
||||
path.traverse(findThisesVisitor); |
||||
|
||||
let thisRef = function () { |
||||
const ref = path.scope.generateDeclaredUidIdentifier("this"); |
||||
|
||||
thisRef = () => _core.types.cloneNode(ref); |
||||
|
||||
return ref; |
||||
}; |
||||
|
||||
for (const thisPath of classState.superThises) { |
||||
const { |
||||
node, |
||||
parentPath |
||||
} = thisPath; |
||||
|
||||
if (parentPath.isMemberExpression({ |
||||
object: node |
||||
})) { |
||||
thisPath.replaceWith(thisRef()); |
||||
continue; |
||||
} |
||||
|
||||
thisPath.replaceWith(_core.types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()])); |
||||
} |
||||
|
||||
const bareSupers = new Set(); |
||||
path.traverse(_core.traverse.visitors.merge([_helperEnvironmentVisitor.default, { |
||||
Super(path) { |
||||
const { |
||||
node, |
||||
parentPath |
||||
} = path; |
||||
|
||||
if (parentPath.isCallExpression({ |
||||
callee: node |
||||
})) { |
||||
bareSupers.add(parentPath); |
||||
} |
||||
} |
||||
|
||||
}])); |
||||
let guaranteedSuperBeforeFinish = !!bareSupers.size; |
||||
|
||||
for (const bareSuper of bareSupers) { |
||||
wrapSuperCall(bareSuper, classState.superName, thisRef, body); |
||||
|
||||
if (guaranteedSuperBeforeFinish) { |
||||
bareSuper.find(function (parentPath) { |
||||
if (parentPath === path) { |
||||
return true; |
||||
} |
||||
|
||||
if (parentPath.isLoop() || parentPath.isConditional() || parentPath.isArrowFunctionExpression()) { |
||||
guaranteedSuperBeforeFinish = false; |
||||
return true; |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
let wrapReturn; |
||||
|
||||
if (classState.isLoose) { |
||||
wrapReturn = returnArg => { |
||||
const thisExpr = _core.types.callExpression(classState.file.addHelper("assertThisInitialized"), [thisRef()]); |
||||
|
||||
return returnArg ? _core.types.logicalExpression("||", returnArg, thisExpr) : thisExpr; |
||||
}; |
||||
} else { |
||||
wrapReturn = returnArg => _core.types.callExpression(classState.file.addHelper("possibleConstructorReturn"), [thisRef()].concat(returnArg || [])); |
||||
} |
||||
|
||||
const bodyPaths = body.get("body"); |
||||
|
||||
if (!bodyPaths.length || !bodyPaths.pop().isReturnStatement()) { |
||||
body.pushContainer("body", _core.types.returnStatement(guaranteedSuperBeforeFinish ? thisRef() : wrapReturn())); |
||||
} |
||||
|
||||
for (const returnPath of classState.superReturns) { |
||||
returnPath.get("argument").replaceWith(wrapReturn(returnPath.node.argument)); |
||||
} |
||||
} |
||||
|
||||
function pushMethod(node, path) { |
||||
const scope = path ? path.scope : classState.scope; |
||||
|
||||
if (node.kind === "method") { |
||||
if (processMethod(node, scope)) return; |
||||
} |
||||
|
||||
const placement = node.static ? "static" : "instance"; |
||||
const methods = classState.methods[placement]; |
||||
const descKey = node.kind === "method" ? "value" : node.kind; |
||||
const key = _core.types.isNumericLiteral(node.key) || _core.types.isBigIntLiteral(node.key) ? _core.types.stringLiteral(String(node.key.value)) : _core.types.toComputedKey(node); |
||||
|
||||
let fn = _core.types.toExpression(node); |
||||
|
||||
if (_core.types.isStringLiteral(key)) { |
||||
if (node.kind === "method") { |
||||
fn = (0, _helperFunctionName.default)({ |
||||
id: key, |
||||
node: node, |
||||
scope |
||||
}); |
||||
} |
||||
} else { |
||||
methods.hasComputed = true; |
||||
} |
||||
|
||||
let descriptor; |
||||
|
||||
if (!methods.hasComputed && methods.map.has(key.value)) { |
||||
descriptor = methods.map.get(key.value); |
||||
descriptor[descKey] = fn; |
||||
|
||||
if (descKey === "value") { |
||||
descriptor.get = null; |
||||
descriptor.set = null; |
||||
} else { |
||||
descriptor.value = null; |
||||
} |
||||
} else { |
||||
descriptor = { |
||||
key: key, |
||||
[descKey]: fn |
||||
}; |
||||
methods.list.push(descriptor); |
||||
|
||||
if (!methods.hasComputed) { |
||||
methods.map.set(key.value, descriptor); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function processMethod(node, scope) { |
||||
if (assumptions.setClassMethods && !node.decorators) { |
||||
let { |
||||
classRef |
||||
} = classState; |
||||
|
||||
if (!node.static) { |
||||
insertProtoAliasOnce(); |
||||
classRef = classState.protoAlias; |
||||
} |
||||
|
||||
const methodName = _core.types.memberExpression(_core.types.cloneNode(classRef), node.key, node.computed || _core.types.isLiteral(node.key)); |
||||
|
||||
let func = _core.types.functionExpression(null, node.params, node.body, node.generator, node.async); |
||||
|
||||
_core.types.inherits(func, node); |
||||
|
||||
const key = _core.types.toComputedKey(node, node.key); |
||||
|
||||
if (_core.types.isStringLiteral(key)) { |
||||
func = (0, _helperFunctionName.default)({ |
||||
node: func, |
||||
id: key, |
||||
scope |
||||
}); |
||||
} |
||||
|
||||
const expr = _core.types.expressionStatement(_core.types.assignmentExpression("=", methodName, func)); |
||||
|
||||
_core.types.inheritsComments(expr, node); |
||||
|
||||
classState.body.push(expr); |
||||
return true; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
function insertProtoAliasOnce() { |
||||
if (classState.protoAlias === null) { |
||||
setState({ |
||||
protoAlias: classState.scope.generateUidIdentifier("proto") |
||||
}); |
||||
|
||||
const classProto = _core.types.memberExpression(classState.classRef, _core.types.identifier("prototype")); |
||||
|
||||
const protoDeclaration = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(classState.protoAlias, classProto)]); |
||||
|
||||
classState.body.push(protoDeclaration); |
||||
} |
||||
} |
||||
|
||||
function pushConstructor(superReturns, method, path) { |
||||
setState({ |
||||
userConstructorPath: path, |
||||
userConstructor: method, |
||||
hasConstructor: true, |
||||
superReturns |
||||
}); |
||||
const { |
||||
construct |
||||
} = classState; |
||||
|
||||
_core.types.inheritsComments(construct, method); |
||||
|
||||
construct.params = method.params; |
||||
|
||||
_core.types.inherits(construct.body, method.body); |
||||
|
||||
construct.body.directives = method.body.directives; |
||||
pushConstructorToBody(); |
||||
} |
||||
|
||||
function pushConstructorToBody() { |
||||
if (classState.pushedConstructor) return; |
||||
classState.pushedConstructor = true; |
||||
|
||||
if (classState.hasInstanceDescriptors || classState.hasStaticDescriptors) { |
||||
pushDescriptors(); |
||||
} |
||||
|
||||
classState.body.push(classState.construct); |
||||
pushInheritsToBody(); |
||||
} |
||||
|
||||
function pushInheritsToBody() { |
||||
if (!classState.isDerived || classState.pushedInherits) return; |
||||
const superFnId = path.scope.generateUidIdentifier("super"); |
||||
setState({ |
||||
pushedInherits: true, |
||||
superFnId |
||||
}); |
||||
|
||||
if (!assumptions.superIsCallableConstructor) { |
||||
classState.body.unshift(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(superFnId, _core.types.callExpression((0, _inlineCreateSuperHelpers.default)(classState.file), [_core.types.cloneNode(classState.classRef)]))])); |
||||
} |
||||
|
||||
classState.body.unshift(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper(classState.isLoose ? "inheritsLoose" : "inherits"), [_core.types.cloneNode(classState.classRef), _core.types.cloneNode(classState.superName)]))); |
||||
} |
||||
|
||||
function extractDynamicKeys() { |
||||
const { |
||||
dynamicKeys, |
||||
node, |
||||
scope |
||||
} = classState; |
||||
|
||||
for (const elem of node.body.body) { |
||||
if (!_core.types.isClassMethod(elem) || !elem.computed) continue; |
||||
if (scope.isPure(elem.key, true)) continue; |
||||
const id = scope.generateUidIdentifierBasedOnNode(elem.key); |
||||
dynamicKeys.set(id.name, elem.key); |
||||
elem.key = id; |
||||
} |
||||
} |
||||
|
||||
function setupClosureParamsArgs() { |
||||
const { |
||||
superName, |
||||
dynamicKeys |
||||
} = classState; |
||||
const closureParams = []; |
||||
const closureArgs = []; |
||||
|
||||
if (classState.isDerived) { |
||||
let arg = _core.types.cloneNode(superName); |
||||
|
||||
if (classState.extendsNative) { |
||||
arg = _core.types.callExpression(classState.file.addHelper("wrapNativeSuper"), [arg]); |
||||
(0, _helperAnnotateAsPure.default)(arg); |
||||
} |
||||
|
||||
const param = classState.scope.generateUidIdentifierBasedOnNode(superName); |
||||
closureParams.push(param); |
||||
closureArgs.push(arg); |
||||
setState({ |
||||
superName: _core.types.cloneNode(param) |
||||
}); |
||||
} |
||||
|
||||
for (const [name, value] of dynamicKeys) { |
||||
closureParams.push(_core.types.identifier(name)); |
||||
closureArgs.push(value); |
||||
} |
||||
|
||||
return { |
||||
closureParams, |
||||
closureArgs |
||||
}; |
||||
} |
||||
|
||||
function classTransformer(path, file, builtinClasses, isLoose) { |
||||
setState({ |
||||
parent: path.parent, |
||||
scope: path.scope, |
||||
node: path.node, |
||||
path, |
||||
file, |
||||
isLoose |
||||
}); |
||||
setState({ |
||||
classId: classState.node.id, |
||||
classRef: classState.node.id ? _core.types.identifier(classState.node.id.name) : classState.scope.generateUidIdentifier("class"), |
||||
superName: classState.node.superClass, |
||||
isDerived: !!classState.node.superClass, |
||||
constructorBody: _core.types.blockStatement([]) |
||||
}); |
||||
setState({ |
||||
extendsNative: classState.isDerived && builtinClasses.has(classState.superName.name) && !classState.scope.hasBinding(classState.superName.name, true) |
||||
}); |
||||
const { |
||||
classRef, |
||||
node, |
||||
constructorBody |
||||
} = classState; |
||||
setState({ |
||||
construct: buildConstructor(classRef, constructorBody, node) |
||||
}); |
||||
extractDynamicKeys(); |
||||
const { |
||||
body |
||||
} = classState; |
||||
const { |
||||
closureParams, |
||||
closureArgs |
||||
} = setupClosureParamsArgs(); |
||||
buildBody(); |
||||
|
||||
if (!assumptions.noClassCalls) { |
||||
constructorBody.body.unshift(_core.types.expressionStatement(_core.types.callExpression(classState.file.addHelper("classCallCheck"), [_core.types.thisExpression(), _core.types.cloneNode(classState.classRef)]))); |
||||
} |
||||
|
||||
body.push(...classState.staticPropBody.map(fn => fn(_core.types.cloneNode(classState.classRef)))); |
||||
const isStrict = path.isInStrictMode(); |
||||
let constructorOnly = classState.classId && body.length === 1; |
||||
|
||||
if (constructorOnly && !isStrict) { |
||||
for (const param of classState.construct.params) { |
||||
if (!_core.types.isIdentifier(param)) { |
||||
constructorOnly = false; |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
const directives = constructorOnly ? body[0].body.directives : []; |
||||
|
||||
if (!isStrict) { |
||||
directives.push(_core.types.directive(_core.types.directiveLiteral("use strict"))); |
||||
} |
||||
|
||||
if (constructorOnly) { |
||||
const expr = _core.types.toExpression(body[0]); |
||||
|
||||
return classState.isLoose ? expr : createClassHelper([expr]); |
||||
} |
||||
|
||||
let returnArg = _core.types.cloneNode(classState.classRef); |
||||
|
||||
if (!classState.pushedCreateClass && !classState.isLoose) { |
||||
returnArg = createClassHelper([returnArg]); |
||||
} |
||||
|
||||
body.push(_core.types.returnStatement(returnArg)); |
||||
|
||||
const container = _core.types.arrowFunctionExpression(closureParams, _core.types.blockStatement(body, directives)); |
||||
|
||||
return _core.types.callExpression(container, closureArgs); |
||||
} |
||||
|
||||
return classTransformer(path, file, builtinClasses, isLoose); |
||||
} |
@ -0,0 +1,41 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-classes", |
||||
"version": "7.16.7", |
||||
"description": "Compile ES2015 classes to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-classes" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-classes", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"dependencies": { |
||||
"@babel/helper-annotate-as-pure": "^7.16.7", |
||||
"@babel/helper-environment-visitor": "^7.16.7", |
||||
"@babel/helper-function-name": "^7.16.7", |
||||
"@babel/helper-optimise-call-expression": "^7.16.7", |
||||
"@babel/helper-plugin-utils": "^7.16.7", |
||||
"@babel/helper-replace-supers": "^7.16.7", |
||||
"@babel/helper-split-export-declaration": "^7.16.7", |
||||
"globals": "^11.1.0" |
||||
}, |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7", |
||||
"@babel/traverse": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-computed-properties |
||||
|
||||
> Compile ES2015 computed properties to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-computed-properties](https://babeljs.io/docs/en/babel-plugin-transform-computed-properties) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-computed-properties |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-computed-properties --dev |
||||
``` |
@ -0,0 +1,171 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
var _api$assumption; |
||||
|
||||
api.assertVersion(7); |
||||
const setComputedProperties = (_api$assumption = api.assumption("setComputedProperties")) != null ? _api$assumption : options.loose; |
||||
const pushComputedProps = setComputedProperties ? pushComputedPropsLoose : pushComputedPropsSpec; |
||||
const buildMutatorMapAssign = (0, _core.template)(` |
||||
MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {}; |
||||
MUTATOR_MAP_REF[KEY].KIND = VALUE; |
||||
`);
|
||||
|
||||
function getValue(prop) { |
||||
if (_core.types.isObjectProperty(prop)) { |
||||
return prop.value; |
||||
} else if (_core.types.isObjectMethod(prop)) { |
||||
return _core.types.functionExpression(null, prop.params, prop.body, prop.generator, prop.async); |
||||
} |
||||
} |
||||
|
||||
function pushAssign(objId, prop, body) { |
||||
if (prop.kind === "get" && prop.kind === "set") { |
||||
pushMutatorDefine(objId, prop); |
||||
} else { |
||||
body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.cloneNode(objId), prop.key, prop.computed || _core.types.isLiteral(prop.key)), getValue(prop)))); |
||||
} |
||||
} |
||||
|
||||
function pushMutatorDefine({ |
||||
body, |
||||
getMutatorId, |
||||
scope |
||||
}, prop) { |
||||
let key = !prop.computed && _core.types.isIdentifier(prop.key) ? _core.types.stringLiteral(prop.key.name) : prop.key; |
||||
const maybeMemoise = scope.maybeGenerateMemoised(key); |
||||
|
||||
if (maybeMemoise) { |
||||
body.push(_core.types.expressionStatement(_core.types.assignmentExpression("=", maybeMemoise, key))); |
||||
key = maybeMemoise; |
||||
} |
||||
|
||||
body.push(...buildMutatorMapAssign({ |
||||
MUTATOR_MAP_REF: getMutatorId(), |
||||
KEY: _core.types.cloneNode(key), |
||||
VALUE: getValue(prop), |
||||
KIND: _core.types.identifier(prop.kind) |
||||
})); |
||||
} |
||||
|
||||
function pushComputedPropsLoose(info) { |
||||
for (const prop of info.computedProps) { |
||||
if (prop.kind === "get" || prop.kind === "set") { |
||||
pushMutatorDefine(info, prop); |
||||
} else { |
||||
pushAssign(_core.types.cloneNode(info.objId), prop, info.body); |
||||
} |
||||
} |
||||
} |
||||
|
||||
function pushComputedPropsSpec(info) { |
||||
const { |
||||
objId, |
||||
body, |
||||
computedProps, |
||||
state |
||||
} = info; |
||||
|
||||
for (const prop of computedProps) { |
||||
const key = _core.types.toComputedKey(prop); |
||||
|
||||
if (prop.kind === "get" || prop.kind === "set") { |
||||
pushMutatorDefine(info, prop); |
||||
} else { |
||||
if (computedProps.length === 1) { |
||||
return _core.types.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, getValue(prop)]); |
||||
} else { |
||||
body.push(_core.types.expressionStatement(_core.types.callExpression(state.addHelper("defineProperty"), [_core.types.cloneNode(objId), key, getValue(prop)]))); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
return { |
||||
name: "transform-computed-properties", |
||||
visitor: { |
||||
ObjectExpression: { |
||||
exit(path, state) { |
||||
const { |
||||
node, |
||||
parent, |
||||
scope |
||||
} = path; |
||||
let hasComputed = false; |
||||
|
||||
for (const prop of node.properties) { |
||||
hasComputed = prop.computed === true; |
||||
if (hasComputed) break; |
||||
} |
||||
|
||||
if (!hasComputed) return; |
||||
const initProps = []; |
||||
const computedProps = []; |
||||
let foundComputed = false; |
||||
|
||||
for (const prop of node.properties) { |
||||
if (prop.computed) { |
||||
foundComputed = true; |
||||
} |
||||
|
||||
if (foundComputed) { |
||||
computedProps.push(prop); |
||||
} else { |
||||
initProps.push(prop); |
||||
} |
||||
} |
||||
|
||||
const objId = scope.generateUidIdentifierBasedOnNode(parent); |
||||
|
||||
const initPropExpression = _core.types.objectExpression(initProps); |
||||
|
||||
const body = []; |
||||
body.push(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(objId, initPropExpression)])); |
||||
let mutatorRef; |
||||
|
||||
const getMutatorId = function () { |
||||
if (!mutatorRef) { |
||||
mutatorRef = scope.generateUidIdentifier("mutatorMap"); |
||||
body.push(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(mutatorRef, _core.types.objectExpression([]))])); |
||||
} |
||||
|
||||
return _core.types.cloneNode(mutatorRef); |
||||
}; |
||||
|
||||
const single = pushComputedProps({ |
||||
scope, |
||||
objId, |
||||
body, |
||||
computedProps, |
||||
initPropExpression, |
||||
getMutatorId, |
||||
state |
||||
}); |
||||
|
||||
if (mutatorRef) { |
||||
body.push(_core.types.expressionStatement(_core.types.callExpression(state.addHelper("defineEnumerableProperties"), [_core.types.cloneNode(objId), _core.types.cloneNode(mutatorRef)]))); |
||||
} |
||||
|
||||
if (single) { |
||||
path.replaceWith(single); |
||||
} else { |
||||
body.push(_core.types.expressionStatement(_core.types.cloneNode(objId))); |
||||
path.replaceWithMultiple(body); |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,33 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-computed-properties", |
||||
"version": "7.16.7", |
||||
"description": "Compile ES2015 computed properties to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-computed-properties" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-computed-properties", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-destructuring |
||||
|
||||
> Compile ES2015 destructuring to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-destructuring](https://babeljs.io/docs/en/babel-plugin-transform-destructuring) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-destructuring |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-destructuring --dev |
||||
``` |
@ -0,0 +1,590 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
var _api$assumption, _options$allowArrayLi, _api$assumption2; |
||||
|
||||
api.assertVersion(7); |
||||
const { |
||||
useBuiltIns = false |
||||
} = options; |
||||
const iterableIsArray = (_api$assumption = api.assumption("iterableIsArray")) != null ? _api$assumption : options.loose; |
||||
const arrayLikeIsIterable = (_options$allowArrayLi = options.allowArrayLike) != null ? _options$allowArrayLi : api.assumption("arrayLikeIsIterable"); |
||||
const objectRestNoSymbols = (_api$assumption2 = api.assumption("objectRestNoSymbols")) != null ? _api$assumption2 : options.loose; |
||||
|
||||
function getExtendsHelper(file) { |
||||
return useBuiltIns ? _core.types.memberExpression(_core.types.identifier("Object"), _core.types.identifier("assign")) : file.addHelper("extends"); |
||||
} |
||||
|
||||
function variableDeclarationHasPattern(node) { |
||||
for (const declar of node.declarations) { |
||||
if (_core.types.isPattern(declar.id)) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
function hasRest(pattern) { |
||||
for (const elem of pattern.elements) { |
||||
if (_core.types.isRestElement(elem)) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
function hasObjectRest(pattern) { |
||||
for (const elem of pattern.properties) { |
||||
if (_core.types.isRestElement(elem)) { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
|
||||
const STOP_TRAVERSAL = {}; |
||||
|
||||
const arrayUnpackVisitor = (node, ancestors, state) => { |
||||
if (!ancestors.length) { |
||||
return; |
||||
} |
||||
|
||||
if (_core.types.isIdentifier(node) && _core.types.isReferenced(node, ancestors[ancestors.length - 1]) && state.bindings[node.name]) { |
||||
state.deopt = true; |
||||
throw STOP_TRAVERSAL; |
||||
} |
||||
}; |
||||
|
||||
class DestructuringTransformer { |
||||
constructor(opts) { |
||||
this.blockHoist = void 0; |
||||
this.operator = void 0; |
||||
this.arrays = void 0; |
||||
this.nodes = void 0; |
||||
this.scope = void 0; |
||||
this.kind = void 0; |
||||
this.iterableIsArray = void 0; |
||||
this.arrayLikeIsIterable = void 0; |
||||
this.addHelper = void 0; |
||||
this.blockHoist = opts.blockHoist; |
||||
this.operator = opts.operator; |
||||
this.arrays = {}; |
||||
this.nodes = opts.nodes || []; |
||||
this.scope = opts.scope; |
||||
this.kind = opts.kind; |
||||
this.iterableIsArray = opts.iterableIsArray; |
||||
this.arrayLikeIsIterable = opts.arrayLikeIsIterable; |
||||
this.addHelper = opts.addHelper; |
||||
} |
||||
|
||||
buildVariableAssignment(id, init) { |
||||
let op = this.operator; |
||||
if (_core.types.isMemberExpression(id)) op = "="; |
||||
let node; |
||||
|
||||
if (op) { |
||||
node = _core.types.expressionStatement(_core.types.assignmentExpression(op, id, _core.types.cloneNode(init) || this.scope.buildUndefinedNode())); |
||||
} else { |
||||
let nodeInit; |
||||
|
||||
if (this.kind === "const" && init === null) { |
||||
nodeInit = this.scope.buildUndefinedNode(); |
||||
} else { |
||||
nodeInit = _core.types.cloneNode(init); |
||||
} |
||||
|
||||
node = _core.types.variableDeclaration(this.kind, [_core.types.variableDeclarator(id, nodeInit)]); |
||||
} |
||||
|
||||
node._blockHoist = this.blockHoist; |
||||
return node; |
||||
} |
||||
|
||||
buildVariableDeclaration(id, init) { |
||||
const declar = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.cloneNode(id), _core.types.cloneNode(init))]); |
||||
|
||||
declar._blockHoist = this.blockHoist; |
||||
return declar; |
||||
} |
||||
|
||||
push(id, _init) { |
||||
const init = _core.types.cloneNode(_init); |
||||
|
||||
if (_core.types.isObjectPattern(id)) { |
||||
this.pushObjectPattern(id, init); |
||||
} else if (_core.types.isArrayPattern(id)) { |
||||
this.pushArrayPattern(id, init); |
||||
} else if (_core.types.isAssignmentPattern(id)) { |
||||
this.pushAssignmentPattern(id, init); |
||||
} else { |
||||
this.nodes.push(this.buildVariableAssignment(id, init)); |
||||
} |
||||
} |
||||
|
||||
toArray(node, count) { |
||||
if (this.iterableIsArray || _core.types.isIdentifier(node) && this.arrays[node.name]) { |
||||
return node; |
||||
} else { |
||||
return this.scope.toArray(node, count, this.arrayLikeIsIterable); |
||||
} |
||||
} |
||||
|
||||
pushAssignmentPattern({ |
||||
left, |
||||
right |
||||
}, valueRef) { |
||||
if (valueRef === null) { |
||||
this.nodes.push(this.buildVariableAssignment(left, right)); |
||||
return; |
||||
} |
||||
|
||||
const tempId = this.scope.generateUidIdentifierBasedOnNode(valueRef); |
||||
this.nodes.push(this.buildVariableDeclaration(tempId, valueRef)); |
||||
|
||||
const tempConditional = _core.types.conditionalExpression(_core.types.binaryExpression("===", _core.types.cloneNode(tempId), this.scope.buildUndefinedNode()), right, _core.types.cloneNode(tempId)); |
||||
|
||||
if (_core.types.isPattern(left)) { |
||||
let patternId; |
||||
let node; |
||||
|
||||
if (this.kind === "const" || this.kind === "let") { |
||||
patternId = this.scope.generateUidIdentifier(tempId.name); |
||||
node = this.buildVariableDeclaration(patternId, tempConditional); |
||||
} else { |
||||
patternId = tempId; |
||||
node = _core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.cloneNode(tempId), tempConditional)); |
||||
} |
||||
|
||||
this.nodes.push(node); |
||||
this.push(left, patternId); |
||||
} else { |
||||
this.nodes.push(this.buildVariableAssignment(left, tempConditional)); |
||||
} |
||||
} |
||||
|
||||
pushObjectRest(pattern, objRef, spreadProp, spreadPropIndex) { |
||||
const keys = []; |
||||
let allLiteral = true; |
||||
let hasTemplateLiteral = false; |
||||
|
||||
for (let i = 0; i < pattern.properties.length; i++) { |
||||
const prop = pattern.properties[i]; |
||||
if (i >= spreadPropIndex) break; |
||||
if (_core.types.isRestElement(prop)) continue; |
||||
const key = prop.key; |
||||
|
||||
if (_core.types.isIdentifier(key) && !prop.computed) { |
||||
keys.push(_core.types.stringLiteral(key.name)); |
||||
} else if (_core.types.isTemplateLiteral(key)) { |
||||
keys.push(_core.types.cloneNode(key)); |
||||
hasTemplateLiteral = true; |
||||
} else if (_core.types.isLiteral(key)) { |
||||
keys.push(_core.types.stringLiteral(String(key.value))); |
||||
} else { |
||||
keys.push(_core.types.cloneNode(key)); |
||||
allLiteral = false; |
||||
} |
||||
} |
||||
|
||||
let value; |
||||
|
||||
if (keys.length === 0) { |
||||
value = _core.types.callExpression(getExtendsHelper(this), [_core.types.objectExpression([]), _core.types.cloneNode(objRef)]); |
||||
} else { |
||||
let keyExpression = _core.types.arrayExpression(keys); |
||||
|
||||
if (!allLiteral) { |
||||
keyExpression = _core.types.callExpression(_core.types.memberExpression(keyExpression, _core.types.identifier("map")), [this.addHelper("toPropertyKey")]); |
||||
} else if (!hasTemplateLiteral && !_core.types.isProgram(this.scope.block)) { |
||||
const program = this.scope.path.findParent(path => path.isProgram()); |
||||
const id = this.scope.generateUidIdentifier("excluded"); |
||||
program.scope.push({ |
||||
id, |
||||
init: keyExpression, |
||||
kind: "const" |
||||
}); |
||||
keyExpression = _core.types.cloneNode(id); |
||||
} |
||||
|
||||
value = _core.types.callExpression(this.addHelper(`objectWithoutProperties${objectRestNoSymbols ? "Loose" : ""}`), [_core.types.cloneNode(objRef), keyExpression]); |
||||
} |
||||
|
||||
this.nodes.push(this.buildVariableAssignment(spreadProp.argument, value)); |
||||
} |
||||
|
||||
pushObjectProperty(prop, propRef) { |
||||
if (_core.types.isLiteral(prop.key)) prop.computed = true; |
||||
const pattern = prop.value; |
||||
|
||||
const objRef = _core.types.memberExpression(_core.types.cloneNode(propRef), prop.key, prop.computed); |
||||
|
||||
if (_core.types.isPattern(pattern)) { |
||||
this.push(pattern, objRef); |
||||
} else { |
||||
this.nodes.push(this.buildVariableAssignment(pattern, objRef)); |
||||
} |
||||
} |
||||
|
||||
pushObjectPattern(pattern, objRef) { |
||||
if (!pattern.properties.length) { |
||||
this.nodes.push(_core.types.expressionStatement(_core.types.callExpression(this.addHelper("objectDestructuringEmpty"), [objRef]))); |
||||
} |
||||
|
||||
if (pattern.properties.length > 1 && !this.scope.isStatic(objRef)) { |
||||
const temp = this.scope.generateUidIdentifierBasedOnNode(objRef); |
||||
this.nodes.push(this.buildVariableDeclaration(temp, objRef)); |
||||
objRef = temp; |
||||
} |
||||
|
||||
if (hasObjectRest(pattern)) { |
||||
let copiedPattern; |
||||
|
||||
for (let i = 0; i < pattern.properties.length; i++) { |
||||
const prop = pattern.properties[i]; |
||||
|
||||
if (_core.types.isRestElement(prop)) { |
||||
break; |
||||
} |
||||
|
||||
const key = prop.key; |
||||
|
||||
if (prop.computed && !this.scope.isPure(key)) { |
||||
const name = this.scope.generateUidIdentifierBasedOnNode(key); |
||||
this.nodes.push(this.buildVariableDeclaration(name, key)); |
||||
|
||||
if (!copiedPattern) { |
||||
copiedPattern = pattern = Object.assign({}, pattern, { |
||||
properties: pattern.properties.slice() |
||||
}); |
||||
} |
||||
|
||||
copiedPattern.properties[i] = Object.assign({}, copiedPattern.properties[i], { |
||||
key: name |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
for (let i = 0; i < pattern.properties.length; i++) { |
||||
const prop = pattern.properties[i]; |
||||
|
||||
if (_core.types.isRestElement(prop)) { |
||||
this.pushObjectRest(pattern, objRef, prop, i); |
||||
} else { |
||||
this.pushObjectProperty(prop, objRef); |
||||
} |
||||
} |
||||
} |
||||
|
||||
canUnpackArrayPattern(pattern, arr) { |
||||
if (!_core.types.isArrayExpression(arr)) return false; |
||||
if (pattern.elements.length > arr.elements.length) return; |
||||
|
||||
if (pattern.elements.length < arr.elements.length && !hasRest(pattern)) { |
||||
return false; |
||||
} |
||||
|
||||
for (const elem of pattern.elements) { |
||||
if (!elem) return false; |
||||
if (_core.types.isMemberExpression(elem)) return false; |
||||
} |
||||
|
||||
for (const elem of arr.elements) { |
||||
if (_core.types.isSpreadElement(elem)) return false; |
||||
if (_core.types.isCallExpression(elem)) return false; |
||||
if (_core.types.isMemberExpression(elem)) return false; |
||||
} |
||||
|
||||
const bindings = _core.types.getBindingIdentifiers(pattern); |
||||
|
||||
const state = { |
||||
deopt: false, |
||||
bindings |
||||
}; |
||||
|
||||
try { |
||||
_core.types.traverse(arr, arrayUnpackVisitor, state); |
||||
} catch (e) { |
||||
if (e !== STOP_TRAVERSAL) throw e; |
||||
} |
||||
|
||||
return !state.deopt; |
||||
} |
||||
|
||||
pushUnpackedArrayPattern(pattern, arr) { |
||||
for (let i = 0; i < pattern.elements.length; i++) { |
||||
const elem = pattern.elements[i]; |
||||
|
||||
if (_core.types.isRestElement(elem)) { |
||||
this.push(elem.argument, _core.types.arrayExpression(arr.elements.slice(i))); |
||||
} else { |
||||
this.push(elem, arr.elements[i]); |
||||
} |
||||
} |
||||
} |
||||
|
||||
pushArrayPattern(pattern, arrayRef) { |
||||
if (!pattern.elements) return; |
||||
|
||||
if (this.canUnpackArrayPattern(pattern, arrayRef)) { |
||||
return this.pushUnpackedArrayPattern(pattern, arrayRef); |
||||
} |
||||
|
||||
const count = !hasRest(pattern) && pattern.elements.length; |
||||
const toArray = this.toArray(arrayRef, count); |
||||
|
||||
if (_core.types.isIdentifier(toArray)) { |
||||
arrayRef = toArray; |
||||
} else { |
||||
arrayRef = this.scope.generateUidIdentifierBasedOnNode(arrayRef); |
||||
this.arrays[arrayRef.name] = true; |
||||
this.nodes.push(this.buildVariableDeclaration(arrayRef, toArray)); |
||||
} |
||||
|
||||
for (let i = 0; i < pattern.elements.length; i++) { |
||||
let elem = pattern.elements[i]; |
||||
if (!elem) continue; |
||||
let elemRef; |
||||
|
||||
if (_core.types.isRestElement(elem)) { |
||||
elemRef = this.toArray(arrayRef); |
||||
elemRef = _core.types.callExpression(_core.types.memberExpression(elemRef, _core.types.identifier("slice")), [_core.types.numericLiteral(i)]); |
||||
elem = elem.argument; |
||||
} else { |
||||
elemRef = _core.types.memberExpression(arrayRef, _core.types.numericLiteral(i), true); |
||||
} |
||||
|
||||
this.push(elem, elemRef); |
||||
} |
||||
} |
||||
|
||||
init(pattern, ref) { |
||||
if (!_core.types.isArrayExpression(ref) && !_core.types.isMemberExpression(ref)) { |
||||
const memo = this.scope.maybeGenerateMemoised(ref, true); |
||||
|
||||
if (memo) { |
||||
this.nodes.push(this.buildVariableDeclaration(memo, _core.types.cloneNode(ref))); |
||||
ref = memo; |
||||
} |
||||
} |
||||
|
||||
this.push(pattern, ref); |
||||
return this.nodes; |
||||
} |
||||
|
||||
} |
||||
|
||||
return { |
||||
name: "transform-destructuring", |
||||
visitor: { |
||||
ExportNamedDeclaration(path) { |
||||
const declaration = path.get("declaration"); |
||||
if (!declaration.isVariableDeclaration()) return; |
||||
if (!variableDeclarationHasPattern(declaration.node)) return; |
||||
const specifiers = []; |
||||
|
||||
for (const name of Object.keys(path.getOuterBindingIdentifiers(path))) { |
||||
specifiers.push(_core.types.exportSpecifier(_core.types.identifier(name), _core.types.identifier(name))); |
||||
} |
||||
|
||||
path.replaceWith(declaration.node); |
||||
path.insertAfter(_core.types.exportNamedDeclaration(null, specifiers)); |
||||
}, |
||||
|
||||
ForXStatement(path) { |
||||
const { |
||||
node, |
||||
scope |
||||
} = path; |
||||
const left = node.left; |
||||
|
||||
if (_core.types.isPattern(left)) { |
||||
const temp = scope.generateUidIdentifier("ref"); |
||||
node.left = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(temp)]); |
||||
path.ensureBlock(); |
||||
|
||||
if (node.body.body.length === 0 && path.isCompletionRecord()) { |
||||
node.body.body.unshift(_core.types.expressionStatement(scope.buildUndefinedNode())); |
||||
} |
||||
|
||||
node.body.body.unshift(_core.types.expressionStatement(_core.types.assignmentExpression("=", left, temp))); |
||||
return; |
||||
} |
||||
|
||||
if (!_core.types.isVariableDeclaration(left)) return; |
||||
const pattern = left.declarations[0].id; |
||||
if (!_core.types.isPattern(pattern)) return; |
||||
const key = scope.generateUidIdentifier("ref"); |
||||
node.left = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(key, null)]); |
||||
const nodes = []; |
||||
const destructuring = new DestructuringTransformer({ |
||||
kind: left.kind, |
||||
scope: scope, |
||||
nodes: nodes, |
||||
iterableIsArray, |
||||
arrayLikeIsIterable, |
||||
addHelper: name => this.addHelper(name) |
||||
}); |
||||
destructuring.init(pattern, key); |
||||
path.ensureBlock(); |
||||
const block = node.body; |
||||
block.body = nodes.concat(block.body); |
||||
}, |
||||
|
||||
CatchClause({ |
||||
node, |
||||
scope |
||||
}) { |
||||
const pattern = node.param; |
||||
if (!_core.types.isPattern(pattern)) return; |
||||
const ref = scope.generateUidIdentifier("ref"); |
||||
node.param = ref; |
||||
const nodes = []; |
||||
const destructuring = new DestructuringTransformer({ |
||||
kind: "let", |
||||
scope: scope, |
||||
nodes: nodes, |
||||
iterableIsArray, |
||||
arrayLikeIsIterable, |
||||
addHelper: name => this.addHelper(name) |
||||
}); |
||||
destructuring.init(pattern, ref); |
||||
node.body.body = nodes.concat(node.body.body); |
||||
}, |
||||
|
||||
AssignmentExpression(path) { |
||||
const { |
||||
node, |
||||
scope |
||||
} = path; |
||||
if (!_core.types.isPattern(node.left)) return; |
||||
const nodes = []; |
||||
const destructuring = new DestructuringTransformer({ |
||||
operator: node.operator, |
||||
scope: scope, |
||||
nodes: nodes, |
||||
iterableIsArray, |
||||
arrayLikeIsIterable, |
||||
addHelper: name => this.addHelper(name) |
||||
}); |
||||
let ref; |
||||
|
||||
if (path.isCompletionRecord() || !path.parentPath.isExpressionStatement()) { |
||||
ref = scope.generateUidIdentifierBasedOnNode(node.right, "ref"); |
||||
nodes.push(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(ref, node.right)])); |
||||
|
||||
if (_core.types.isArrayExpression(node.right)) { |
||||
destructuring.arrays[ref.name] = true; |
||||
} |
||||
} |
||||
|
||||
destructuring.init(node.left, ref || node.right); |
||||
|
||||
if (ref) { |
||||
if (path.parentPath.isArrowFunctionExpression()) { |
||||
path.replaceWith(_core.types.blockStatement([])); |
||||
nodes.push(_core.types.returnStatement(_core.types.cloneNode(ref))); |
||||
} else { |
||||
nodes.push(_core.types.expressionStatement(_core.types.cloneNode(ref))); |
||||
} |
||||
} |
||||
|
||||
path.replaceWithMultiple(nodes); |
||||
path.scope.crawl(); |
||||
}, |
||||
|
||||
VariableDeclaration(path) { |
||||
const { |
||||
node, |
||||
scope, |
||||
parent |
||||
} = path; |
||||
if (_core.types.isForXStatement(parent)) return; |
||||
if (!parent || !path.container) return; |
||||
if (!variableDeclarationHasPattern(node)) return; |
||||
const nodeKind = node.kind; |
||||
const nodeLoc = node.loc; |
||||
const nodes = []; |
||||
let declar; |
||||
|
||||
for (let i = 0; i < node.declarations.length; i++) { |
||||
declar = node.declarations[i]; |
||||
const patternId = declar.init; |
||||
const pattern = declar.id; |
||||
const destructuring = new DestructuringTransformer({ |
||||
blockHoist: node._blockHoist, |
||||
nodes: nodes, |
||||
scope: scope, |
||||
kind: node.kind, |
||||
iterableIsArray, |
||||
arrayLikeIsIterable, |
||||
addHelper: name => this.addHelper(name) |
||||
}); |
||||
|
||||
if (_core.types.isPattern(pattern)) { |
||||
destructuring.init(pattern, patternId); |
||||
|
||||
if (+i !== node.declarations.length - 1) { |
||||
_core.types.inherits(nodes[nodes.length - 1], declar); |
||||
} |
||||
} else { |
||||
nodes.push(_core.types.inherits(destructuring.buildVariableAssignment(declar.id, _core.types.cloneNode(declar.init)), declar)); |
||||
} |
||||
} |
||||
|
||||
let tail = null; |
||||
const nodesOut = []; |
||||
|
||||
for (const node of nodes) { |
||||
if (tail !== null && _core.types.isVariableDeclaration(node)) { |
||||
tail.declarations.push(...node.declarations); |
||||
} else { |
||||
node.kind = nodeKind; |
||||
|
||||
if (!node.loc) { |
||||
node.loc = nodeLoc; |
||||
} |
||||
|
||||
nodesOut.push(node); |
||||
tail = _core.types.isVariableDeclaration(node) ? node : null; |
||||
} |
||||
} |
||||
|
||||
for (const nodeOut of nodesOut) { |
||||
if (!nodeOut.declarations) continue; |
||||
|
||||
for (const declaration of nodeOut.declarations) { |
||||
const { |
||||
name |
||||
} = declaration.id; |
||||
|
||||
if (scope.bindings[name]) { |
||||
scope.bindings[name].kind = nodeOut.kind; |
||||
} |
||||
} |
||||
} |
||||
|
||||
if (nodesOut.length === 1) { |
||||
path.replaceWith(nodesOut[0]); |
||||
} else { |
||||
path.replaceWithMultiple(nodesOut); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,34 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-destructuring", |
||||
"version": "7.17.3", |
||||
"description": "Compile ES2015 destructuring to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-destructuring" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-destructuring", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.17.3", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7", |
||||
"@babel/traverse": "^7.17.3" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-dotall-regex |
||||
|
||||
> Compile regular expressions using the `s` (`dotAll`) flag to ES5. |
||||
|
||||
See our website [@babel/plugin-transform-dotall-regex](https://babeljs.io/docs/en/babel-plugin-transform-dotall-regex) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-dotall-regex |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-dotall-regex --dev |
||||
``` |
@ -0,0 +1,20 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperCreateRegexpFeaturesPlugin = require("@babel/helper-create-regexp-features-plugin"); |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return (0, _helperCreateRegexpFeaturesPlugin.createRegExpFeaturePlugin)({ |
||||
name: "transform-dotall-regex", |
||||
feature: "dotAllFlag" |
||||
}); |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,39 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-dotall-regex", |
||||
"version": "7.16.7", |
||||
"description": "Compile regular expressions using the `s` (`dotAll`) flag to ES5.", |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-dotall-regex", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin", |
||||
"regex", |
||||
"regexp", |
||||
"regular expressions", |
||||
"dotall" |
||||
], |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-dotall-regex" |
||||
}, |
||||
"bugs": "https://github.com/babel/babel/issues", |
||||
"dependencies": { |
||||
"@babel/helper-create-regexp-features-plugin": "^7.16.7", |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-duplicate-keys |
||||
|
||||
> Compile objects with duplicate keys to valid strict ES5 |
||||
|
||||
See our website [@babel/plugin-transform-duplicate-keys](https://babeljs.io/docs/en/babel-plugin-transform-duplicate-keys) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-duplicate-keys |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-duplicate-keys --dev |
||||
``` |
@ -0,0 +1,74 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
function getName(key) { |
||||
if (_core.types.isIdentifier(key)) { |
||||
return key.name; |
||||
} |
||||
|
||||
return key.value.toString(); |
||||
} |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "transform-duplicate-keys", |
||||
visitor: { |
||||
ObjectExpression(path) { |
||||
const { |
||||
node |
||||
} = path; |
||||
const plainProps = node.properties.filter(prop => !_core.types.isSpreadElement(prop) && !prop.computed); |
||||
const alreadySeenData = Object.create(null); |
||||
const alreadySeenGetters = Object.create(null); |
||||
const alreadySeenSetters = Object.create(null); |
||||
|
||||
for (const prop of plainProps) { |
||||
const name = getName(prop.key); |
||||
let isDuplicate = false; |
||||
|
||||
switch (prop.kind) { |
||||
case "get": |
||||
if (alreadySeenData[name] || alreadySeenGetters[name]) { |
||||
isDuplicate = true; |
||||
} |
||||
|
||||
alreadySeenGetters[name] = true; |
||||
break; |
||||
|
||||
case "set": |
||||
if (alreadySeenData[name] || alreadySeenSetters[name]) { |
||||
isDuplicate = true; |
||||
} |
||||
|
||||
alreadySeenSetters[name] = true; |
||||
break; |
||||
|
||||
default: |
||||
if (alreadySeenData[name] || alreadySeenGetters[name] || alreadySeenSetters[name]) { |
||||
isDuplicate = true; |
||||
} |
||||
|
||||
alreadySeenData[name] = true; |
||||
} |
||||
|
||||
if (isDuplicate) { |
||||
prop.computed = true; |
||||
prop.key = _core.types.stringLiteral(name); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,33 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-duplicate-keys", |
||||
"version": "7.16.7", |
||||
"description": "Compile objects with duplicate keys to valid strict ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-duplicate-keys" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-duplicate-keys", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-exponentiation-operator |
||||
|
||||
> Compile exponentiation operator to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-exponentiation-operator](https://babeljs.io/docs/en/babel-plugin-transform-exponentiation-operator) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-exponentiation-operator |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-exponentiation-operator --dev |
||||
``` |
@ -0,0 +1,29 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _helperBuilderBinaryAssignmentOperatorVisitor = require("@babel/helper-builder-binary-assignment-operator-visitor"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
return { |
||||
name: "transform-exponentiation-operator", |
||||
visitor: (0, _helperBuilderBinaryAssignmentOperatorVisitor.default)({ |
||||
operator: "**", |
||||
|
||||
build(left, right) { |
||||
return _core.types.callExpression(_core.types.memberExpression(_core.types.identifier("Math"), _core.types.identifier("pow")), [left, right]); |
||||
} |
||||
|
||||
}) |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,34 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-exponentiation-operator", |
||||
"version": "7.16.7", |
||||
"description": "Compile exponentiation operator to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-exponentiation-operator" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-exponentiation-operator", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-builder-binary-assignment-operator-visitor": "^7.16.7", |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-for-of |
||||
|
||||
> Compile ES2015 for...of to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-for-of](https://babeljs.io/docs/en/babel-plugin-transform-for-of) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-for-of |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-for-of --dev |
||||
``` |
@ -0,0 +1,222 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
var _noHelperImplementation = require("./no-helper-implementation"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)((api, options) => { |
||||
var _options$assumeArray, _options$allowArrayLi, _api$assumption; |
||||
|
||||
api.assertVersion(7); |
||||
{ |
||||
const { |
||||
assumeArray, |
||||
allowArrayLike, |
||||
loose |
||||
} = options; |
||||
|
||||
if (loose === true && assumeArray === true) { |
||||
throw new Error(`The loose and assumeArray options cannot be used together in @babel/plugin-transform-for-of`); |
||||
} |
||||
|
||||
if (assumeArray === true && allowArrayLike === true) { |
||||
throw new Error(`The assumeArray and allowArrayLike options cannot be used together in @babel/plugin-transform-for-of`); |
||||
} |
||||
|
||||
if (allowArrayLike && /^7\.\d\./.test(api.version)) { |
||||
throw new Error(`The allowArrayLike is only supported when using @babel/core@^7.10.0`); |
||||
} |
||||
} |
||||
const iterableIsArray = (_options$assumeArray = options.assumeArray) != null ? _options$assumeArray : !options.loose && api.assumption("iterableIsArray"); |
||||
const arrayLikeIsIterable = (_options$allowArrayLi = options.allowArrayLike) != null ? _options$allowArrayLi : api.assumption("arrayLikeIsIterable"); |
||||
const skipteratorClosing = (_api$assumption = api.assumption("skipForOfIteratorClosing")) != null ? _api$assumption : options.loose; |
||||
|
||||
if (iterableIsArray && arrayLikeIsIterable) { |
||||
throw new Error(`The "iterableIsArray" and "arrayLikeIsIterable" assumptions are not compatible.`); |
||||
} |
||||
|
||||
if (iterableIsArray) { |
||||
return { |
||||
name: "transform-for-of", |
||||
visitor: { |
||||
ForOfStatement(path) { |
||||
const { |
||||
scope |
||||
} = path; |
||||
const { |
||||
left, |
||||
right, |
||||
await: isAwait |
||||
} = path.node; |
||||
|
||||
if (isAwait) { |
||||
return; |
||||
} |
||||
|
||||
const i = scope.generateUidIdentifier("i"); |
||||
let array = scope.maybeGenerateMemoised(right, true); |
||||
const inits = [_core.types.variableDeclarator(i, _core.types.numericLiteral(0))]; |
||||
|
||||
if (array) { |
||||
inits.push(_core.types.variableDeclarator(array, right)); |
||||
} else { |
||||
array = right; |
||||
} |
||||
|
||||
const item = _core.types.memberExpression(_core.types.cloneNode(array), _core.types.cloneNode(i), true); |
||||
|
||||
let assignment; |
||||
|
||||
if (_core.types.isVariableDeclaration(left)) { |
||||
assignment = left; |
||||
assignment.declarations[0].init = item; |
||||
} else { |
||||
assignment = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, item)); |
||||
} |
||||
|
||||
let blockBody; |
||||
const body = path.get("body"); |
||||
|
||||
if (body.isBlockStatement() && Object.keys(path.getBindingIdentifiers()).some(id => body.scope.hasOwnBinding(id))) { |
||||
blockBody = _core.types.blockStatement([assignment, body.node]); |
||||
} else { |
||||
blockBody = _core.types.toBlock(body.node); |
||||
blockBody.body.unshift(assignment); |
||||
} |
||||
|
||||
path.replaceWith(_core.types.forStatement(_core.types.variableDeclaration("let", inits), _core.types.binaryExpression("<", _core.types.cloneNode(i), _core.types.memberExpression(_core.types.cloneNode(array), _core.types.identifier("length"))), _core.types.updateExpression("++", _core.types.cloneNode(i)), blockBody)); |
||||
} |
||||
|
||||
} |
||||
}; |
||||
} |
||||
|
||||
const buildForOfArray = (0, _core.template)` |
||||
for (var KEY = 0, NAME = ARR; KEY < NAME.length; KEY++) BODY; |
||||
`;
|
||||
const buildForOfNoIteratorClosing = _core.template.statements` |
||||
for (var ITERATOR_HELPER = CREATE_ITERATOR_HELPER(OBJECT, ARRAY_LIKE_IS_ITERABLE), STEP_KEY; |
||||
!(STEP_KEY = ITERATOR_HELPER()).done;) BODY; |
||||
`;
|
||||
const buildForOf = _core.template.statements` |
||||
var ITERATOR_HELPER = CREATE_ITERATOR_HELPER(OBJECT, ARRAY_LIKE_IS_ITERABLE), STEP_KEY; |
||||
try { |
||||
for (ITERATOR_HELPER.s(); !(STEP_KEY = ITERATOR_HELPER.n()).done;) BODY; |
||||
} catch (err) { |
||||
ITERATOR_HELPER.e(err); |
||||
} finally { |
||||
ITERATOR_HELPER.f(); |
||||
} |
||||
`;
|
||||
const builder = skipteratorClosing ? { |
||||
build: buildForOfNoIteratorClosing, |
||||
helper: "createForOfIteratorHelperLoose", |
||||
getContainer: nodes => nodes |
||||
} : { |
||||
build: buildForOf, |
||||
helper: "createForOfIteratorHelper", |
||||
getContainer: nodes => nodes[1].block.body |
||||
}; |
||||
|
||||
function _ForOfStatementArray(path) { |
||||
const { |
||||
node, |
||||
scope |
||||
} = path; |
||||
const right = scope.generateUidIdentifierBasedOnNode(node.right, "arr"); |
||||
const iterationKey = scope.generateUidIdentifier("i"); |
||||
const loop = buildForOfArray({ |
||||
BODY: node.body, |
||||
KEY: iterationKey, |
||||
NAME: right, |
||||
ARR: node.right |
||||
}); |
||||
|
||||
_core.types.inherits(loop, node); |
||||
|
||||
_core.types.ensureBlock(loop); |
||||
|
||||
const iterationValue = _core.types.memberExpression(_core.types.cloneNode(right), _core.types.cloneNode(iterationKey), true); |
||||
|
||||
const left = node.left; |
||||
|
||||
if (_core.types.isVariableDeclaration(left)) { |
||||
left.declarations[0].init = iterationValue; |
||||
loop.body.body.unshift(left); |
||||
} else { |
||||
loop.body.body.unshift(_core.types.expressionStatement(_core.types.assignmentExpression("=", left, iterationValue))); |
||||
} |
||||
|
||||
return loop; |
||||
} |
||||
|
||||
return { |
||||
name: "transform-for-of", |
||||
visitor: { |
||||
ForOfStatement(path, state) { |
||||
const right = path.get("right"); |
||||
|
||||
if (right.isArrayExpression() || right.isGenericType("Array") || _core.types.isArrayTypeAnnotation(right.getTypeAnnotation())) { |
||||
path.replaceWith(_ForOfStatementArray(path)); |
||||
return; |
||||
} |
||||
|
||||
if (!state.availableHelper(builder.helper)) { |
||||
(0, _noHelperImplementation.default)(skipteratorClosing, path, state); |
||||
return; |
||||
} |
||||
|
||||
const { |
||||
node, |
||||
parent, |
||||
scope |
||||
} = path; |
||||
const left = node.left; |
||||
let declar; |
||||
const stepKey = scope.generateUid("step"); |
||||
|
||||
const stepValue = _core.types.memberExpression(_core.types.identifier(stepKey), _core.types.identifier("value")); |
||||
|
||||
if (_core.types.isVariableDeclaration(left)) { |
||||
declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]); |
||||
} else { |
||||
declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue)); |
||||
} |
||||
|
||||
path.ensureBlock(); |
||||
node.body.body.unshift(declar); |
||||
const nodes = builder.build({ |
||||
CREATE_ITERATOR_HELPER: state.addHelper(builder.helper), |
||||
ITERATOR_HELPER: scope.generateUidIdentifier("iterator"), |
||||
ARRAY_LIKE_IS_ITERABLE: arrayLikeIsIterable ? _core.types.booleanLiteral(true) : null, |
||||
STEP_KEY: _core.types.identifier(stepKey), |
||||
OBJECT: node.right, |
||||
BODY: node.body |
||||
}); |
||||
const container = builder.getContainer(nodes); |
||||
|
||||
_core.types.inherits(container[0], node); |
||||
|
||||
_core.types.inherits(container[0].body, node.body); |
||||
|
||||
if (_core.types.isLabeledStatement(parent)) { |
||||
container[0] = _core.types.labeledStatement(parent.label, container[0]); |
||||
path.parentPath.replaceWithMultiple(nodes); |
||||
path.skip(); |
||||
} else { |
||||
path.replaceWithMultiple(nodes); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,174 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = transformWithoutHelper; |
||||
|
||||
var _core = require("@babel/core"); |
||||
|
||||
function transformWithoutHelper(loose, path, state) { |
||||
const pushComputedProps = loose ? pushComputedPropsLoose : pushComputedPropsSpec; |
||||
const { |
||||
node |
||||
} = path; |
||||
const build = pushComputedProps(path, state); |
||||
const declar = build.declar; |
||||
const loop = build.loop; |
||||
const block = loop.body; |
||||
path.ensureBlock(); |
||||
|
||||
if (declar) { |
||||
block.body.push(declar); |
||||
} |
||||
|
||||
block.body.push(...node.body.body); |
||||
|
||||
_core.types.inherits(loop, node); |
||||
|
||||
_core.types.inherits(loop.body, node.body); |
||||
|
||||
if (build.replaceParent) { |
||||
path.parentPath.replaceWithMultiple(build.node); |
||||
path.remove(); |
||||
} else { |
||||
path.replaceWithMultiple(build.node); |
||||
} |
||||
} |
||||
|
||||
const buildForOfLoose = (0, _core.template)(` |
||||
for (var LOOP_OBJECT = OBJECT, |
||||
IS_ARRAY = Array.isArray(LOOP_OBJECT), |
||||
INDEX = 0, |
||||
LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) { |
||||
INTERMEDIATE; |
||||
if (IS_ARRAY) { |
||||
if (INDEX >= LOOP_OBJECT.length) break; |
||||
ID = LOOP_OBJECT[INDEX++]; |
||||
} else { |
||||
INDEX = LOOP_OBJECT.next(); |
||||
if (INDEX.done) break; |
||||
ID = INDEX.value; |
||||
} |
||||
} |
||||
`);
|
||||
const buildForOf = (0, _core.template)(` |
||||
var ITERATOR_COMPLETION = true; |
||||
var ITERATOR_HAD_ERROR_KEY = false; |
||||
var ITERATOR_ERROR_KEY = undefined; |
||||
try { |
||||
for ( |
||||
var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY; |
||||
!(ITERATOR_COMPLETION = (STEP_KEY = ITERATOR_KEY.next()).done); |
||||
ITERATOR_COMPLETION = true |
||||
) {} |
||||
} catch (err) { |
||||
ITERATOR_HAD_ERROR_KEY = true; |
||||
ITERATOR_ERROR_KEY = err; |
||||
} finally { |
||||
try { |
||||
if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) { |
||||
ITERATOR_KEY.return(); |
||||
} |
||||
} finally { |
||||
if (ITERATOR_HAD_ERROR_KEY) { |
||||
throw ITERATOR_ERROR_KEY; |
||||
} |
||||
} |
||||
} |
||||
`);
|
||||
|
||||
function pushComputedPropsLoose(path, file) { |
||||
const { |
||||
node, |
||||
scope, |
||||
parent |
||||
} = path; |
||||
const { |
||||
left |
||||
} = node; |
||||
let declar, id, intermediate; |
||||
|
||||
if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) { |
||||
id = left; |
||||
intermediate = null; |
||||
} else if (_core.types.isVariableDeclaration(left)) { |
||||
id = scope.generateUidIdentifier("ref"); |
||||
declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, _core.types.identifier(id.name))]); |
||||
intermediate = _core.types.variableDeclaration("var", [_core.types.variableDeclarator(_core.types.identifier(id.name))]); |
||||
} else { |
||||
throw file.buildCodeFrameError(left, `Unknown node type ${left.type} in ForStatement`); |
||||
} |
||||
|
||||
const iteratorKey = scope.generateUidIdentifier("iterator"); |
||||
const isArrayKey = scope.generateUidIdentifier("isArray"); |
||||
const loop = buildForOfLoose({ |
||||
LOOP_OBJECT: iteratorKey, |
||||
IS_ARRAY: isArrayKey, |
||||
OBJECT: node.right, |
||||
INDEX: scope.generateUidIdentifier("i"), |
||||
ID: id, |
||||
INTERMEDIATE: intermediate |
||||
}); |
||||
|
||||
const isLabeledParent = _core.types.isLabeledStatement(parent); |
||||
|
||||
let labeled; |
||||
|
||||
if (isLabeledParent) { |
||||
labeled = _core.types.labeledStatement(parent.label, loop); |
||||
} |
||||
|
||||
return { |
||||
replaceParent: isLabeledParent, |
||||
declar: declar, |
||||
node: labeled || loop, |
||||
loop: loop |
||||
}; |
||||
} |
||||
|
||||
function pushComputedPropsSpec(path, file) { |
||||
const { |
||||
node, |
||||
scope, |
||||
parent |
||||
} = path; |
||||
const left = node.left; |
||||
let declar; |
||||
const stepKey = scope.generateUid("step"); |
||||
|
||||
const stepValue = _core.types.memberExpression(_core.types.identifier(stepKey), _core.types.identifier("value")); |
||||
|
||||
if (_core.types.isIdentifier(left) || _core.types.isPattern(left) || _core.types.isMemberExpression(left)) { |
||||
declar = _core.types.expressionStatement(_core.types.assignmentExpression("=", left, stepValue)); |
||||
} else if (_core.types.isVariableDeclaration(left)) { |
||||
declar = _core.types.variableDeclaration(left.kind, [_core.types.variableDeclarator(left.declarations[0].id, stepValue)]); |
||||
} else { |
||||
throw file.buildCodeFrameError(left, `Unknown node type ${left.type} in ForStatement`); |
||||
} |
||||
|
||||
const template = buildForOf({ |
||||
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"), |
||||
ITERATOR_COMPLETION: scope.generateUidIdentifier("iteratorNormalCompletion"), |
||||
ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"), |
||||
ITERATOR_KEY: scope.generateUidIdentifier("iterator"), |
||||
STEP_KEY: _core.types.identifier(stepKey), |
||||
OBJECT: node.right |
||||
}); |
||||
|
||||
const isLabeledParent = _core.types.isLabeledStatement(parent); |
||||
|
||||
const tryBody = template[3].block.body; |
||||
const loop = tryBody[0]; |
||||
|
||||
if (isLabeledParent) { |
||||
tryBody[0] = _core.types.labeledStatement(parent.label, loop); |
||||
} |
||||
|
||||
return { |
||||
replaceParent: isLabeledParent, |
||||
declar: declar, |
||||
loop: loop, |
||||
node: template |
||||
}; |
||||
} |
@ -0,0 +1,33 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-for-of", |
||||
"version": "7.16.7", |
||||
"description": "Compile ES2015 for...of to ES5", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-for-of" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-for-of", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-function-name |
||||
|
||||
> Apply ES2015 function.name semantics to all functions |
||||
|
||||
See our website [@babel/plugin-transform-function-name](https://babeljs.io/docs/en/babel-plugin-transform-function-name) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-function-name |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-function-name --dev |
||||
``` |
@ -0,0 +1,43 @@
|
||||
"use strict"; |
||||
|
||||
Object.defineProperty(exports, "__esModule", { |
||||
value: true |
||||
}); |
||||
exports.default = void 0; |
||||
|
||||
var _helperCompilationTargets = require("@babel/helper-compilation-targets"); |
||||
|
||||
var _helperPluginUtils = require("@babel/helper-plugin-utils"); |
||||
|
||||
var _helperFunctionName = require("@babel/helper-function-name"); |
||||
|
||||
var _default = (0, _helperPluginUtils.declare)(api => { |
||||
api.assertVersion(7); |
||||
const supportUnicodeId = !(0, _helperCompilationTargets.isRequired)("transform-unicode-escapes", api.targets()); |
||||
return { |
||||
name: "transform-function-name", |
||||
visitor: { |
||||
FunctionExpression: { |
||||
exit(path) { |
||||
if (path.key !== "value" && !path.parentPath.isObjectProperty()) { |
||||
const replacement = (0, _helperFunctionName.default)(path); |
||||
if (replacement) path.replaceWith(replacement); |
||||
} |
||||
} |
||||
|
||||
}, |
||||
|
||||
ObjectProperty(path) { |
||||
const value = path.get("value"); |
||||
|
||||
if (value.isFunction()) { |
||||
const newNode = (0, _helperFunctionName.default)(value, false, supportUnicodeId); |
||||
if (newNode) value.replaceWith(newNode); |
||||
} |
||||
} |
||||
|
||||
} |
||||
}; |
||||
}); |
||||
|
||||
exports.default = _default; |
@ -0,0 +1,35 @@
|
||||
{ |
||||
"name": "@babel/plugin-transform-function-name", |
||||
"version": "7.16.7", |
||||
"description": "Apply ES2015 function.name semantics to all functions", |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "https://github.com/babel/babel.git", |
||||
"directory": "packages/babel-plugin-transform-function-name" |
||||
}, |
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-function-name", |
||||
"license": "MIT", |
||||
"publishConfig": { |
||||
"access": "public" |
||||
}, |
||||
"main": "./lib/index.js", |
||||
"keywords": [ |
||||
"babel-plugin" |
||||
], |
||||
"dependencies": { |
||||
"@babel/helper-compilation-targets": "^7.16.7", |
||||
"@babel/helper-function-name": "^7.16.7", |
||||
"@babel/helper-plugin-utils": "^7.16.7" |
||||
}, |
||||
"peerDependencies": { |
||||
"@babel/core": "^7.0.0-0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/core": "^7.16.7", |
||||
"@babel/helper-plugin-test-runner": "^7.16.7" |
||||
}, |
||||
"engines": { |
||||
"node": ">=6.9.0" |
||||
}, |
||||
"author": "The Babel Team (https://babel.dev/team)" |
||||
} |
@ -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 @@
|
||||
# @babel/plugin-transform-literals |
||||
|
||||
> Compile ES2015 unicode string and number literals to ES5 |
||||
|
||||
See our website [@babel/plugin-transform-literals](https://babeljs.io/docs/en/babel-plugin-transform-literals) for more information. |
||||
|
||||
## Install |
||||
|
||||
Using npm: |
||||
|
||||
```sh |
||||
npm install --save-dev @babel/plugin-transform-literals |
||||
``` |
||||
|
||||
or using yarn: |
||||
|
||||
```sh |
||||
yarn add @babel/plugin-transform-literals --dev |
||||
``` |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue