mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-09-09 14:24:06 +07:00
Improve code quality and write tests
This commit is contained in:
22
node_modules/@babel/helper-replace-supers/LICENSE
generated
vendored
Normal file
22
node_modules/@babel/helper-replace-supers/LICENSE
generated
vendored
Normal file
@ -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
node_modules/@babel/helper-replace-supers/README.md
generated
vendored
Normal file
19
node_modules/@babel/helper-replace-supers/README.md
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
# @babel/helper-replace-supers
|
||||
|
||||
> Helper function to replace supers
|
||||
|
||||
See our website [@babel/helper-replace-supers](https://babeljs.io/docs/en/next/babel-helper-replace-supers.html) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/helper-replace-supers
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/helper-replace-supers --dev
|
||||
```
|
241
node_modules/@babel/helper-replace-supers/lib/index.js
generated
vendored
Normal file
241
node_modules/@babel/helper-replace-supers/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,241 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = exports.environmentVisitor = void 0;
|
||||
|
||||
function _traverse() {
|
||||
const data = _interopRequireDefault(require("@babel/traverse"));
|
||||
|
||||
_traverse = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _helperMemberExpressionToFunctions() {
|
||||
const data = _interopRequireDefault(require("@babel/helper-member-expression-to-functions"));
|
||||
|
||||
_helperMemberExpressionToFunctions = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _helperOptimiseCallExpression() {
|
||||
const data = _interopRequireDefault(require("@babel/helper-optimise-call-expression"));
|
||||
|
||||
_helperOptimiseCallExpression = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function t() {
|
||||
const data = _interopRequireWildcard(require("@babel/types"));
|
||||
|
||||
t = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function getPrototypeOfExpression(objectRef, isStatic, file, isPrivateMethod) {
|
||||
objectRef = t().cloneNode(objectRef);
|
||||
const targetRef = isStatic || isPrivateMethod ? objectRef : t().memberExpression(objectRef, t().identifier("prototype"));
|
||||
return t().callExpression(file.addHelper("getPrototypeOf"), [targetRef]);
|
||||
}
|
||||
|
||||
function skipAllButComputedKey(path) {
|
||||
if (!path.node.computed) {
|
||||
path.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
const keys = t().VISITOR_KEYS[path.type];
|
||||
|
||||
for (const key of keys) {
|
||||
if (key !== "key") path.skipKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
const environmentVisitor = {
|
||||
TypeAnnotation(path) {
|
||||
path.skip();
|
||||
},
|
||||
|
||||
Function(path) {
|
||||
if (path.isMethod()) return;
|
||||
if (path.isArrowFunctionExpression()) return;
|
||||
path.skip();
|
||||
},
|
||||
|
||||
"Method|ClassProperty|ClassPrivateProperty"(path) {
|
||||
skipAllButComputedKey(path);
|
||||
}
|
||||
|
||||
};
|
||||
exports.environmentVisitor = environmentVisitor;
|
||||
|
||||
const visitor = _traverse().default.visitors.merge([environmentVisitor, {
|
||||
Super(path, state) {
|
||||
const {
|
||||
node,
|
||||
parentPath
|
||||
} = path;
|
||||
if (!parentPath.isMemberExpression({
|
||||
object: node
|
||||
})) return;
|
||||
state.handle(parentPath);
|
||||
}
|
||||
|
||||
}]);
|
||||
|
||||
const specHandlers = {
|
||||
memoise(superMember, count) {
|
||||
const {
|
||||
scope,
|
||||
node
|
||||
} = superMember;
|
||||
const {
|
||||
computed,
|
||||
property
|
||||
} = node;
|
||||
|
||||
if (!computed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const memo = scope.maybeGenerateMemoised(property);
|
||||
|
||||
if (!memo) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.memoiser.set(property, memo, count);
|
||||
},
|
||||
|
||||
prop(superMember) {
|
||||
const {
|
||||
computed,
|
||||
property
|
||||
} = superMember.node;
|
||||
|
||||
if (this.memoiser.has(property)) {
|
||||
return t().cloneNode(this.memoiser.get(property));
|
||||
}
|
||||
|
||||
if (computed) {
|
||||
return t().cloneNode(property);
|
||||
}
|
||||
|
||||
return t().stringLiteral(property.name);
|
||||
},
|
||||
|
||||
get(superMember) {
|
||||
return t().callExpression(this.file.addHelper("get"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), t().thisExpression()]);
|
||||
},
|
||||
|
||||
set(superMember, value) {
|
||||
return t().callExpression(this.file.addHelper("set"), [getPrototypeOfExpression(this.getObjectRef(), this.isStatic, this.file, this.isPrivateMethod), this.prop(superMember), value, t().thisExpression(), t().booleanLiteral(superMember.isInStrictMode())]);
|
||||
},
|
||||
|
||||
destructureSet(superMember) {
|
||||
throw superMember.buildCodeFrameError(`Destructuring to a super field is not supported yet.`);
|
||||
},
|
||||
|
||||
call(superMember, args) {
|
||||
return (0, _helperOptimiseCallExpression().default)(this.get(superMember), t().thisExpression(), args);
|
||||
}
|
||||
|
||||
};
|
||||
const looseHandlers = Object.assign({}, specHandlers, {
|
||||
prop(superMember) {
|
||||
const {
|
||||
property
|
||||
} = superMember.node;
|
||||
|
||||
if (this.memoiser.has(property)) {
|
||||
return t().cloneNode(this.memoiser.get(property));
|
||||
}
|
||||
|
||||
return t().cloneNode(property);
|
||||
},
|
||||
|
||||
get(superMember) {
|
||||
const {
|
||||
isStatic,
|
||||
superRef
|
||||
} = this;
|
||||
const {
|
||||
computed
|
||||
} = superMember.node;
|
||||
const prop = this.prop(superMember);
|
||||
let object;
|
||||
|
||||
if (isStatic) {
|
||||
object = superRef ? t().cloneNode(superRef) : t().memberExpression(t().identifier("Function"), t().identifier("prototype"));
|
||||
} else {
|
||||
object = superRef ? t().memberExpression(t().cloneNode(superRef), t().identifier("prototype")) : t().memberExpression(t().identifier("Object"), t().identifier("prototype"));
|
||||
}
|
||||
|
||||
return t().memberExpression(object, prop, computed);
|
||||
},
|
||||
|
||||
set(superMember, value) {
|
||||
const {
|
||||
computed
|
||||
} = superMember.node;
|
||||
const prop = this.prop(superMember);
|
||||
return t().assignmentExpression("=", t().memberExpression(t().thisExpression(), prop, computed), value);
|
||||
},
|
||||
|
||||
destructureSet(superMember) {
|
||||
const {
|
||||
computed
|
||||
} = superMember.node;
|
||||
const prop = this.prop(superMember);
|
||||
return t().memberExpression(t().thisExpression(), prop, computed);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
class ReplaceSupers {
|
||||
constructor(opts) {
|
||||
const path = opts.methodPath;
|
||||
this.methodPath = path;
|
||||
this.isStatic = path.isObjectMethod() || path.node.static;
|
||||
this.isPrivateMethod = path.isPrivate() && path.isMethod();
|
||||
this.file = opts.file;
|
||||
this.superRef = opts.superRef;
|
||||
this.isLoose = opts.isLoose;
|
||||
this.opts = opts;
|
||||
}
|
||||
|
||||
getObjectRef() {
|
||||
return t().cloneNode(this.opts.objectRef || this.opts.getObjectRef());
|
||||
}
|
||||
|
||||
replace() {
|
||||
const handler = this.isLoose ? looseHandlers : specHandlers;
|
||||
(0, _helperMemberExpressionToFunctions().default)(this.methodPath, visitor, Object.assign({
|
||||
file: this.file,
|
||||
isStatic: this.isStatic,
|
||||
isPrivateMethod: this.isPrivateMethod,
|
||||
getObjectRef: this.getObjectRef.bind(this),
|
||||
superRef: this.superRef
|
||||
}, handler));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = ReplaceSupers;
|
51
node_modules/@babel/helper-replace-supers/package.json
generated
vendored
Normal file
51
node_modules/@babel/helper-replace-supers/package.json
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@babel/helper-replace-supers@7.5.5",
|
||||
"E:\\python\\setup-php"
|
||||
]
|
||||
],
|
||||
"_from": "@babel/helper-replace-supers@7.5.5",
|
||||
"_id": "@babel/helper-replace-supers@7.5.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-XvRFWrNnlsow2u7jXDuH4jDDctkxbS7gXssrP4q2nUD606ukXHRvydj346wmNg+zAgpFx4MWf4+usfC93bElJg==",
|
||||
"_location": "/@babel/helper-replace-supers",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@babel/helper-replace-supers@7.5.5",
|
||||
"name": "@babel/helper-replace-supers",
|
||||
"escapedName": "@babel%2fhelper-replace-supers",
|
||||
"scope": "@babel",
|
||||
"rawSpec": "7.5.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "7.5.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@babel/plugin-transform-classes",
|
||||
"/@babel/plugin-transform-object-super"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.5.5.tgz",
|
||||
"_spec": "7.5.5",
|
||||
"_where": "E:\\python\\setup-php",
|
||||
"dependencies": {
|
||||
"@babel/helper-member-expression-to-functions": "^7.5.5",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/traverse": "^7.5.5",
|
||||
"@babel/types": "^7.5.5"
|
||||
},
|
||||
"description": "Helper function to replace supers",
|
||||
"gitHead": "0407f034f09381b95e9cabefbf6b176c76485a43",
|
||||
"license": "MIT",
|
||||
"main": "lib/index.js",
|
||||
"name": "@babel/helper-replace-supers",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers"
|
||||
},
|
||||
"version": "7.5.5"
|
||||
}
|
Reference in New Issue
Block a user