Commit cf9f5af3 authored by Rosanny Sihombing's avatar Rosanny Sihombing
Browse files

restructuring the project

1 merge request!151Mlab 667
Showing with 0 additions and 787 deletions
+0 -787
# has-flag [![Build Status](https://travis-ci.org/sindresorhus/has-flag.svg?branch=master)](https://travis-ci.org/sindresorhus/has-flag)
> Check if [`argv`](https://nodejs.org/docs/latest/api/process.html#process_process_argv) has a specific flag
Correctly stops looking after an `--` argument terminator.
## Install
```
$ npm install has-flag
```
## Usage
```js
// foo.js
const hasFlag = require('has-flag');
hasFlag('unicorn');
//=> true
hasFlag('--unicorn');
//=> true
hasFlag('f');
//=> true
hasFlag('-f');
//=> true
hasFlag('foo=bar');
//=> true
hasFlag('foo');
//=> false
hasFlag('rainbow');
//=> false
```
```
$ node foo.js -f --unicorn --foo=bar -- --rainbow
```
## API
### hasFlag(flag, [argv])
Returns a boolean for whether the flag exists.
#### flag
Type: `string`
CLI flag to look for. The `--` prefix is optional.
#### argv
Type: `string[]`<br>
Default: `process.argv`
CLI arguments.
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
'use strict';
module.exports = {
stdout: false,
stderr: false
};
'use strict';
const os = require('os');
const hasFlag = require('has-flag');
const env = process.env;
let forceColor;
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
forceColor = false;
} else if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
forceColor = true;
}
if ('FORCE_COLOR' in env) {
forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
}
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
}
function supportsColor(stream) {
if (forceColor === false) {
return 0;
}
if (hasFlag('color=16m') ||
hasFlag('color=full') ||
hasFlag('color=truecolor')) {
return 3;
}
if (hasFlag('color=256')) {
return 2;
}
if (stream && !stream.isTTY && forceColor !== true) {
return 0;
}
const min = forceColor ? 1 : 0;
if (process.platform === 'win32') {
// Node.js 7.5.0 is the first version of Node.js to include a patch to
// libuv that enables 256 color output on Windows. Anything earlier and it
// won't work. However, here we target Node.js 8 at minimum as it is an LTS
// release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
// release that supports 256 colors. Windows 10 build 14931 is the first release
// that supports 16m/TrueColor.
const osRelease = os.release().split('.');
if (
Number(process.versions.node.split('.')[0]) >= 8 &&
Number(osRelease[0]) >= 10 &&
Number(osRelease[2]) >= 10586
) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ('CI' in env) {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
return 1;
}
return min;
}
if ('TEAMCITY_VERSION' in env) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if (env.COLORTERM === 'truecolor') {
return 3;
}
if ('TERM_PROGRAM' in env) {
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
switch (env.TERM_PROGRAM) {
case 'iTerm.app':
return version >= 3 ? 3 : 2;
case 'Apple_Terminal':
return 2;
// No default
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ('COLORTERM' in env) {
return 1;
}
if (env.TERM === 'dumb') {
return min;
}
return min;
}
function getSupportLevel(stream) {
const level = supportsColor(stream);
return translateLevel(level);
}
module.exports = {
supportsColor: getSupportLevel,
stdout: getSupportLevel(process.stdout),
stderr: getSupportLevel(process.stderr)
};
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "supports-color",
"version": "5.5.0",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": "chalk/supports-color",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"browser.js"
],
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect",
"truecolor",
"16m"
],
"dependencies": {
"has-flag": "^3.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"import-fresh": "^2.0.0",
"xo": "^0.20.0"
},
"browser": "browser.js"
}
# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
> Detect whether a terminal supports color
## Install
```
$ npm install supports-color
```
## Usage
```js
const supportsColor = require('supports-color');
if (supportsColor.stdout) {
console.log('Terminal stdout supports color');
}
if (supportsColor.stdout.has256) {
console.log('Terminal stdout supports 256 colors');
}
if (supportsColor.stderr.has16m) {
console.log('Terminal stderr supports 16 million colors (truecolor)');
}
```
## API
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
- `.level = 2` and `.has256 = true`: 256 color support
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
## Info
It obeys the `--color` and `--no-color` CLI flags.
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add the environment variable `FORCE_COLOR=1` to forcefully enable color or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
## License
MIT
{
"name": "@babel/highlight",
"version": "7.18.6",
"description": "Syntax highlight JavaScript strings for output in terminals.",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-highlight",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-highlight"
},
"main": "./lib/index.js",
"dependencies": {
"@babel/helper-validator-identifier": "^7.18.6",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
},
"devDependencies": {
"@types/chalk": "^2.0.0",
"strip-ansi": "^4.0.0"
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression
> Rename destructuring parameter to workaround https://bugs.webkit.org/show_bug.cgi?id=220517
See our website [@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression](https://babeljs.io/docs/en/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression
```
or using yarn:
```sh
yarn add @babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression --dev
```
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helperPluginUtils = require('@babel/helper-plugin-utils');
function shouldTransform(path) {
const {
node
} = path;
const functionId = node.id;
if (!functionId) return false;
const name = functionId.name;
const paramNameBinding = path.scope.getOwnBinding(name);
if (paramNameBinding === undefined) {
return false;
}
if (paramNameBinding.kind !== "param") {
return false;
}
if (paramNameBinding.identifier === paramNameBinding.path.node) {
return false;
}
return name;
}
var index = helperPluginUtils.declare(api => {
api.assertVersion("^7.16.0");
return {
name: "plugin-bugfix-safari-id-destructuring-collision-in-function-expression",
visitor: {
FunctionExpression(path) {
const name = shouldTransform(path);
if (name) {
const {
scope
} = path;
const newParamName = scope.generateUid(name);
scope.rename(name, newParamName);
}
}
}
};
});
exports["default"] = index;
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import type { FunctionExpression } from \"@babel/types\";\nimport type { NodePath } from \"@babel/traverse\";\n\n/**\n * Check whether a function expression can be affected by\n * https://bugs.webkit.org/show_bug.cgi?id=220517\n * @param path The function expression NodePath\n * @returns the name of function id if it should be transformed, otherwise returns false\n */\nexport function shouldTransform(\n path: NodePath<FunctionExpression>,\n): string | false {\n const { node } = path;\n const functionId = node.id;\n if (!functionId) return false;\n\n const name = functionId.name;\n // On collision, `getOwnBinding` returns the param binding\n // with the id binding be registered as constant violation\n const paramNameBinding = path.scope.getOwnBinding(name);\n if (paramNameBinding === undefined) {\n // Case 1: the function id is injected by babel-helper-name-function, which\n // assigns `NOT_LOCAL_BINDING` to the `functionId` and thus not registering id\n // in scope tracking\n // Case 2: the function id is injected by a third party plugin which does not update the\n // scope info\n return false;\n }\n if (paramNameBinding.kind !== \"param\") {\n // the function id does not reproduce in params\n return false;\n }\n\n if (paramNameBinding.identifier === paramNameBinding.path.node) {\n // the param binding is a simple parameter\n // e.g. (function a(a) {})\n return false;\n }\n\n return name;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport { shouldTransform } from \"./util\";\n\nexport default declare(api => {\n api.assertVersion(\"^7.16.0\");\n\n return {\n name: \"plugin-bugfix-safari-id-destructuring-collision-in-function-expression\",\n\n visitor: {\n FunctionExpression(path) {\n const name = shouldTransform(path);\n if (name) {\n // Now we have (function a([a]) {})\n const { scope } = path;\n // invariant: path.node.id is always an Identifier here\n const newParamName = scope.generateUid(name);\n scope.rename(name, newParamName);\n }\n },\n },\n };\n});\n"],"names":["shouldTransform","path","node","functionId","id","name","paramNameBinding","scope","getOwnBinding","undefined","kind","identifier","declare","api","assertVersion","visitor","FunctionExpression","newParamName","generateUid","rename"],"mappings":";;;;;;AASO,SAASA,eAAT,CACLC,IADK,EAEW;EAChB,MAAM;AAAEC,IAAAA,IAAAA;AAAF,GAAA,GAAWD,IAAjB,CAAA;AACA,EAAA,MAAME,UAAU,GAAGD,IAAI,CAACE,EAAxB,CAAA;AACA,EAAA,IAAI,CAACD,UAAL,EAAiB,OAAO,KAAP,CAAA;AAEjB,EAAA,MAAME,IAAI,GAAGF,UAAU,CAACE,IAAxB,CAAA;EAGA,MAAMC,gBAAgB,GAAGL,IAAI,CAACM,KAAL,CAAWC,aAAX,CAAyBH,IAAzB,CAAzB,CAAA;;EACA,IAAIC,gBAAgB,KAAKG,SAAzB,EAAoC;AAMlC,IAAA,OAAO,KAAP,CAAA;AACD,GAAA;;AACD,EAAA,IAAIH,gBAAgB,CAACI,IAAjB,KAA0B,OAA9B,EAAuC;AAErC,IAAA,OAAO,KAAP,CAAA;AACD,GAAA;;EAED,IAAIJ,gBAAgB,CAACK,UAAjB,KAAgCL,gBAAgB,CAACL,IAAjB,CAAsBC,IAA1D,EAAgE;AAG9D,IAAA,OAAO,KAAP,CAAA;AACD,GAAA;;AAED,EAAA,OAAOG,IAAP,CAAA;AACD;;ACrCD,YAAeO,yBAAO,CAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAJ,CAAkB,SAAlB,CAAA,CAAA;EAEA,OAAO;AACLT,IAAAA,IAAI,EAAE,wEADD;AAGLU,IAAAA,OAAO,EAAE;MACPC,kBAAkB,CAACf,IAAD,EAAO;AACvB,QAAA,MAAMI,IAAI,GAAGL,eAAe,CAACC,IAAD,CAA5B,CAAA;;AACA,QAAA,IAAII,IAAJ,EAAU;UAER,MAAM;AAAEE,YAAAA,KAAAA;AAAF,WAAA,GAAYN,IAAlB,CAAA;AAEA,UAAA,MAAMgB,YAAY,GAAGV,KAAK,CAACW,WAAN,CAAkBb,IAAlB,CAArB,CAAA;AACAE,UAAAA,KAAK,CAACY,MAAN,CAAad,IAAb,EAAmBY,YAAnB,CAAA,CAAA;AACD,SAAA;AACF,OAAA;;AAVM,KAAA;GAHX,CAAA;AAgBD,CAnBqB,CAAtB;;;;"}
\ No newline at end of file
{
"name": "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression",
"version": "7.18.6",
"description": "Rename destructuring parameter to workaround https://bugs.webkit.org/show_bug.cgi?id=220517",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"keywords": [
"babel-plugin",
"bugfix"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.18.6"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-function-name": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
> Transform optional chaining operators to workaround https://crbug.com/v8/11558
See our website [@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining](https://babeljs.io/docs/en/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining
```
or using yarn:
```sh
yarn add @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining --dev
```
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helperPluginUtils = require('@babel/helper-plugin-utils');
var pluginProposalOptionalChaining = require('@babel/plugin-proposal-optional-chaining');
var helperSkipTransparentExpressionWrappers = require('@babel/helper-skip-transparent-expression-wrappers');
var core = require('@babel/core');
function matchAffectedArguments(argumentNodes) {
const spreadIndex = argumentNodes.findIndex(node => core.types.isSpreadElement(node));
return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;
}
function shouldTransform(path) {
let optionalPath = path;
const chains = [];
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
const {
node
} = optionalPath;
chains.push(node);
if (optionalPath.isOptionalMemberExpression()) {
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("object"));
} else if (optionalPath.isOptionalCallExpression()) {
optionalPath = helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers(optionalPath.get("callee"));
}
}
for (let i = 0; i < chains.length; i++) {
const node = chains[i];
if (core.types.isOptionalCallExpression(node) && matchAffectedArguments(node.arguments)) {
if (node.optional) {
return true;
}
const callee = chains[i + 1];
if (core.types.isOptionalMemberExpression(callee, {
optional: true
})) {
return true;
}
}
}
return false;
}
var index = helperPluginUtils.declare(api => {
var _api$assumption, _api$assumption2;
api.assertVersion(7);
const noDocumentAll = (_api$assumption = api.assumption("noDocumentAll")) != null ? _api$assumption : false;
const pureGetters = (_api$assumption2 = api.assumption("pureGetters")) != null ? _api$assumption2 : false;
return {
name: "bugfix-v8-spread-parameters-in-optional-chaining",
visitor: {
"OptionalCallExpression|OptionalMemberExpression"(path) {
if (shouldTransform(path)) {
pluginProposalOptionalChaining.transform(path, {
noDocumentAll,
pureGetters
});
}
}
}
};
});
exports["default"] = index;
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sources":["../src/util.ts","../src/index.ts"],"sourcesContent":["import { skipTransparentExprWrappers } from \"@babel/helper-skip-transparent-expression-wrappers\";\nimport type { NodePath } from \"@babel/traverse\";\nimport { types as t } from \"@babel/core\";\n// https://crbug.com/v8/11558\n\n// check if there is a spread element followed by another argument.\n// (...[], 0) or (...[], ...[])\n\nfunction matchAffectedArguments(argumentNodes: t.CallExpression[\"arguments\"]) {\n const spreadIndex = argumentNodes.findIndex(node => t.isSpreadElement(node));\n return spreadIndex >= 0 && spreadIndex !== argumentNodes.length - 1;\n}\n\n/**\n * Check whether the optional chain is affected by https://crbug.com/v8/11558.\n * This routine MUST not manipulate NodePath\n *\n * @export\n * @param {(NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>)} path\n * @returns {boolean}\n */\nexport function shouldTransform(\n path: NodePath<t.OptionalMemberExpression | t.OptionalCallExpression>,\n): boolean {\n let optionalPath: NodePath<t.Expression> = path;\n const chains = [];\n while (\n optionalPath.isOptionalMemberExpression() ||\n optionalPath.isOptionalCallExpression()\n ) {\n const { node } = optionalPath;\n chains.push(node);\n\n if (optionalPath.isOptionalMemberExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"object\"));\n } else if (optionalPath.isOptionalCallExpression()) {\n optionalPath = skipTransparentExprWrappers(optionalPath.get(\"callee\"));\n }\n }\n for (let i = 0; i < chains.length; i++) {\n const node = chains[i];\n if (\n t.isOptionalCallExpression(node) &&\n matchAffectedArguments(node.arguments)\n ) {\n // f?.(...[], 0)\n if (node.optional) {\n return true;\n }\n // o?.m(...[], 0)\n // when node.optional is false, chains[i + 1] is always well defined\n const callee = chains[i + 1];\n if (t.isOptionalMemberExpression(callee, { optional: true })) {\n return true;\n }\n }\n }\n return false;\n}\n","import { declare } from \"@babel/helper-plugin-utils\";\nimport { transform } from \"@babel/plugin-proposal-optional-chaining\";\nimport { shouldTransform } from \"./util\";\nimport type { NodePath } from \"@babel/traverse\";\nimport type * as t from \"@babel/types\";\n\nexport default declare(api => {\n api.assertVersion(7);\n\n const noDocumentAll = (api.assumption(\"noDocumentAll\") ?? false) as boolean;\n const pureGetters = (api.assumption(\"pureGetters\") ?? false) as boolean;\n\n return {\n name: \"bugfix-v8-spread-parameters-in-optional-chaining\",\n\n visitor: {\n \"OptionalCallExpression|OptionalMemberExpression\"(\n path: NodePath<t.OptionalCallExpression | t.OptionalMemberExpression>,\n ) {\n if (shouldTransform(path)) {\n transform(path, { noDocumentAll, pureGetters });\n }\n },\n },\n };\n});\n"],"names":["matchAffectedArguments","argumentNodes","spreadIndex","findIndex","node","t","isSpreadElement","length","shouldTransform","path","optionalPath","chains","isOptionalMemberExpression","isOptionalCallExpression","push","skipTransparentExprWrappers","get","i","arguments","optional","callee","declare","api","assertVersion","noDocumentAll","assumption","pureGetters","name","visitor","transform"],"mappings":";;;;;;;;;AAQA,SAASA,sBAAT,CAAgCC,aAAhC,EAA8E;AAC5E,EAAA,MAAMC,WAAW,GAAGD,aAAa,CAACE,SAAd,CAAwBC,IAAI,IAAIC,UAAC,CAACC,eAAF,CAAkBF,IAAlB,CAAhC,CAApB,CAAA;EACA,OAAOF,WAAW,IAAI,CAAf,IAAoBA,WAAW,KAAKD,aAAa,CAACM,MAAd,GAAuB,CAAlE,CAAA;AACD,CAAA;;AAUM,SAASC,eAAT,CACLC,IADK,EAEI;EACT,IAAIC,YAAoC,GAAGD,IAA3C,CAAA;EACA,MAAME,MAAM,GAAG,EAAf,CAAA;;EACA,OACED,YAAY,CAACE,0BAAb,EAAA,IACAF,YAAY,CAACG,wBAAb,EAFF,EAGE;IACA,MAAM;AAAET,MAAAA,IAAAA;AAAF,KAAA,GAAWM,YAAjB,CAAA;IACAC,MAAM,CAACG,IAAP,CAAYV,IAAZ,CAAA,CAAA;;AAEA,IAAA,IAAIM,YAAY,CAACE,0BAAb,EAAJ,EAA+C;MAC7CF,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C,CAAA;AACD,KAFD,MAEO,IAAIN,YAAY,CAACG,wBAAb,EAAJ,EAA6C;MAClDH,YAAY,GAAGK,mEAA2B,CAACL,YAAY,CAACM,GAAb,CAAiB,QAAjB,CAAD,CAA1C,CAAA;AACD,KAAA;AACF,GAAA;;AACD,EAAA,KAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGN,MAAM,CAACJ,MAA3B,EAAmCU,CAAC,EAApC,EAAwC;AACtC,IAAA,MAAMb,IAAI,GAAGO,MAAM,CAACM,CAAD,CAAnB,CAAA;;AACA,IAAA,IACEZ,UAAC,CAACQ,wBAAF,CAA2BT,IAA3B,CAAA,IACAJ,sBAAsB,CAACI,IAAI,CAACc,SAAN,CAFxB,EAGE;MAEA,IAAId,IAAI,CAACe,QAAT,EAAmB;AACjB,QAAA,OAAO,IAAP,CAAA;AACD,OAAA;;AAGD,MAAA,MAAMC,MAAM,GAAGT,MAAM,CAACM,CAAC,GAAG,CAAL,CAArB,CAAA;;AACA,MAAA,IAAIZ,UAAC,CAACO,0BAAF,CAA6BQ,MAA7B,EAAqC;AAAED,QAAAA,QAAQ,EAAE,IAAA;AAAZ,OAArC,CAAJ,EAA8D;AAC5D,QAAA,OAAO,IAAP,CAAA;AACD,OAAA;AACF,KAAA;AACF,GAAA;;AACD,EAAA,OAAO,KAAP,CAAA;AACD;;ACpDD,YAAeE,yBAAO,CAACC,GAAG,IAAI;AAAA,EAAA,IAAA,eAAA,EAAA,gBAAA,CAAA;;EAC5BA,GAAG,CAACC,aAAJ,CAAkB,CAAlB,CAAA,CAAA;EAEA,MAAMC,aAAa,sBAAIF,GAAG,CAACG,UAAJ,CAAe,eAAf,CAAJ,KAAA,IAAA,GAAA,eAAA,GAAuC,KAA1D,CAAA;EACA,MAAMC,WAAW,uBAAIJ,GAAG,CAACG,UAAJ,CAAe,aAAf,CAAJ,KAAA,IAAA,GAAA,gBAAA,GAAqC,KAAtD,CAAA;EAEA,OAAO;AACLE,IAAAA,IAAI,EAAE,kDADD;AAGLC,IAAAA,OAAO,EAAE;AACP,MAAA,iDAAA,CACEnB,IADF,EAEE;AACA,QAAA,IAAID,eAAe,CAACC,IAAD,CAAnB,EAA2B;UACzBoB,wCAAS,CAACpB,IAAD,EAAO;YAAEe,aAAF;AAAiBE,YAAAA,WAAAA;AAAjB,WAAP,CAAT,CAAA;AACD,SAAA;AACF,OAAA;;AAPM,KAAA;GAHX,CAAA;AAaD,CAnBqB,CAAtB;;;;"}
\ No newline at end of file
{
"name": "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining",
"version": "7.18.6",
"description": "Transform optional chaining operators to workaround https://crbug.com/v8/11558",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining"
},
"homepage": "https://babel.dev/docs/en/next/babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./package.json": "./package.json"
},
"keywords": [
"babel-plugin",
"bugfix"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.18.6",
"@babel/helper-skip-transparent-expression-wrappers": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.18.6"
},
"peerDependencies": {
"@babel/core": "^7.13.0"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@babel/helper-plugin-test-runner": "^7.18.6",
"@babel/traverse": "^7.18.6"
},
"engines": {
"node": ">=6.9.0"
},
"author": "The Babel Team (https://babel.dev/team)",
"type": "commonjs"
}
\ No newline at end of file
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.
# @babel/plugin-proposal-async-generator-functions
> Turn async generator functions into ES2015 generators
See our website [@babel/plugin-proposal-async-generator-functions](https://babeljs.io/docs/en/babel-plugin-proposal-async-generator-functions) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-async-generator-functions
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-async-generator-functions --dev
```
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _core = require("@babel/core");
const buildForAwait = (0, _core.template)(`
async function wrapper() {
var ITERATOR_ABRUPT_COMPLETION = false;
var ITERATOR_HAD_ERROR_KEY = false;
var ITERATOR_ERROR_KEY;
try {
for (
var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY;
ITERATOR_ABRUPT_COMPLETION = !(STEP_KEY = await ITERATOR_KEY.next()).done;
ITERATOR_ABRUPT_COMPLETION = false
) {
}
} catch (err) {
ITERATOR_HAD_ERROR_KEY = true;
ITERATOR_ERROR_KEY = err;
} finally {
try {
if (ITERATOR_ABRUPT_COMPLETION && ITERATOR_KEY.return != null) {
await ITERATOR_KEY.return();
}
} finally {
if (ITERATOR_HAD_ERROR_KEY) {
throw ITERATOR_ERROR_KEY;
}
}
}
}
`);
function _default(path, {
getAsyncIterator
}) {
const {
node,
scope,
parent
} = path;
const stepKey = scope.generateUidIdentifier("step");
const stepValue = _core.types.memberExpression(stepKey, _core.types.identifier("value"));
const left = node.left;
let declar;
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)]);
}
let template = buildForAwait({
ITERATOR_HAD_ERROR_KEY: scope.generateUidIdentifier("didIteratorError"),
ITERATOR_ABRUPT_COMPLETION: scope.generateUidIdentifier("iteratorAbruptCompletion"),
ITERATOR_ERROR_KEY: scope.generateUidIdentifier("iteratorError"),
ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
GET_ITERATOR: getAsyncIterator,
OBJECT: node.right,
STEP_KEY: _core.types.cloneNode(stepKey)
});
template = template.body.body;
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,
node: template,
declar,
loop
};
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment