$
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+19
@@ -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
|
||||
```
|
||||
+88
@@ -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 = false
|
||||
} = options;
|
||||
const setClassMethods = (_api$assumption = api.assumption("setClassMethods")) != null ? _api$assumption : loose;
|
||||
const constantSuper = (_api$assumption2 = api.assumption("constantSuper")) != null ? _api$assumption2 : loose;
|
||||
const superIsCallableConstructor = (_api$assumption3 = api.assumption("superIsCallableConstructor")) != null ? _api$assumption3 : loose;
|
||||
const noClassCalls = (_api$assumption4 = api.assumption("noClassCalls")) != null ? _api$assumption4 : loose;
|
||||
const VISITED = new WeakSet();
|
||||
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 (VISITED.has(node)) return;
|
||||
const inferred = (0, _helperFunctionName.default)(path);
|
||||
|
||||
if (inferred && inferred !== node) {
|
||||
path.replaceWith(inferred);
|
||||
return;
|
||||
}
|
||||
|
||||
VISITED.add(node);
|
||||
const [replacedPath] = path.replaceWith((0, _transformClass.default)(path, state.file, builtinClasses, loose, {
|
||||
setClassMethods,
|
||||
constantSuper,
|
||||
superIsCallableConstructor,
|
||||
noClassCalls
|
||||
}));
|
||||
|
||||
if (replacedPath.isCallExpression()) {
|
||||
(0, _helperAnnotateAsPure.default)(replacedPath);
|
||||
const callee = replacedPath.get("callee");
|
||||
|
||||
if (callee.isArrowFunctionExpression()) {
|
||||
callee.arrowFunctionToExpression();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
||||
+72
@@ -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);
|
||||
}
|
||||
}
|
||||
`;
|
||||
+628
File diff suppressed because it is too large
Load Diff
+1563
File diff suppressed because it is too large
Load Diff
+2
@@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
module.exports = require('./globals.json');
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
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.
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "globals",
|
||||
"version": "11.12.0",
|
||||
"description": "Global identifiers from different JavaScript environments",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/globals",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"globals.json"
|
||||
],
|
||||
"keywords": [
|
||||
"globals",
|
||||
"global",
|
||||
"identifiers",
|
||||
"variables",
|
||||
"vars",
|
||||
"jshint",
|
||||
"eslint",
|
||||
"environments"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "0.21.0",
|
||||
"xo": "0.18.0"
|
||||
},
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"get-browser-globals.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
# globals [](https://travis-ci.org/sindresorhus/globals)
|
||||
|
||||
> Global identifiers from different JavaScript environments
|
||||
|
||||
Extracted from [JSHint](https://github.com/jshint/jshint/blob/3a8efa979dbb157bfb5c10b5826603a55a33b9ad/src/vars.js) and [ESLint](https://github.com/eslint/eslint/blob/b648406218f8a2d7302b98f5565e23199f44eb31/conf/environments.json) and merged.
|
||||
|
||||
It's just a [JSON file](globals.json), so use it in whatever environment you like.
|
||||
|
||||
**This module [no longer accepts](https://github.com/sindresorhus/globals/issues/82) new environments. If you need it for ESLint, just [create a plugin](http://eslint.org/docs/developer-guide/working-with-plugins#environments-in-plugins).**
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install globals
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const globals = require('globals');
|
||||
|
||||
console.log(globals.browser);
|
||||
/*
|
||||
{
|
||||
addEventListener: false,
|
||||
applicationCache: false,
|
||||
ArrayBuffer: false,
|
||||
atob: false,
|
||||
...
|
||||
}
|
||||
*/
|
||||
```
|
||||
|
||||
Each global is given a value of `true` or `false`. A value of `true` indicates that the variable may be overwritten. A value of `false` indicates that the variable should be considered read-only. This information is used by static analysis tools to flag incorrect behavior. We assume all variables should be `false` unless we hear otherwise.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@babel/plugin-transform-classes",
|
||||
"version": "7.18.9",
|
||||
"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.18.6",
|
||||
"@babel/helper-environment-visitor": "^7.18.9",
|
||||
"@babel/helper-function-name": "^7.18.9",
|
||||
"@babel/helper-optimise-call-expression": "^7.18.6",
|
||||
"@babel/helper-plugin-utils": "^7.18.9",
|
||||
"@babel/helper-replace-supers": "^7.18.9",
|
||||
"@babel/helper-split-export-declaration": "^7.18.6",
|
||||
"globals": "^11.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"babel-plugin"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.9",
|
||||
"@babel/helper-plugin-test-runner": "^7.18.6",
|
||||
"@babel/traverse": "^7.18.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"type": "commonjs"
|
||||
}
|
||||
Reference in New Issue
Block a user