mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
22
web/node_modules/@babel/plugin-transform-react-constant-elements/LICENSE
generated
vendored
Normal file
22
web/node_modules/@babel/plugin-transform-react-constant-elements/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
web/node_modules/@babel/plugin-transform-react-constant-elements/README.md
generated
vendored
Normal file
19
web/node_modules/@babel/plugin-transform-react-constant-elements/README.md
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# @babel/plugin-transform-react-constant-elements
|
||||
|
||||
> Treat React JSX elements as value types and hoist them to the highest scope
|
||||
|
||||
See our website [@babel/plugin-transform-react-constant-elements](https://babeljs.io/docs/en/babel-plugin-transform-react-constant-elements) for more information.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/plugin-transform-react-constant-elements
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/plugin-transform-react-constant-elements --dev
|
||||
```
|
187
web/node_modules/@babel/plugin-transform-react-constant-elements/lib/index.js
generated
vendored
Normal file
187
web/node_modules/@babel/plugin-transform-react-constant-elements/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,187 @@
|
|||
"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) => {
|
||||
api.assertVersion(7);
|
||||
const {
|
||||
allowMutablePropsOnTags
|
||||
} = options;
|
||||
|
||||
if (allowMutablePropsOnTags != null && !Array.isArray(allowMutablePropsOnTags)) {
|
||||
throw new Error(".allowMutablePropsOnTags must be an array, null, or undefined.");
|
||||
}
|
||||
|
||||
const HOISTED = new WeakMap();
|
||||
|
||||
function declares(node, scope) {
|
||||
if (_core.types.isJSXIdentifier(node, {
|
||||
name: "this"
|
||||
}) || _core.types.isJSXIdentifier(node, {
|
||||
name: "arguments"
|
||||
}) || _core.types.isJSXIdentifier(node, {
|
||||
name: "super"
|
||||
}) || _core.types.isJSXIdentifier(node, {
|
||||
name: "new"
|
||||
})) {
|
||||
const {
|
||||
path
|
||||
} = scope;
|
||||
return path.isFunctionParent() && !path.isArrowFunctionExpression();
|
||||
}
|
||||
|
||||
return scope.hasOwnBinding(node.name);
|
||||
}
|
||||
|
||||
function isHoistingScope({
|
||||
path
|
||||
}) {
|
||||
return path.isFunctionParent() || path.isLoop() || path.isProgram();
|
||||
}
|
||||
|
||||
function getHoistingScope(scope) {
|
||||
while (!isHoistingScope(scope)) scope = scope.parent;
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
const analyzer = {
|
||||
enter(path, state) {
|
||||
const stop = () => {
|
||||
state.isImmutable = false;
|
||||
path.stop();
|
||||
};
|
||||
|
||||
if (path.isJSXClosingElement()) {
|
||||
path.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.isJSXIdentifier({
|
||||
name: "ref"
|
||||
}) && path.parentPath.isJSXAttribute({
|
||||
name: path.node
|
||||
})) {
|
||||
return stop();
|
||||
}
|
||||
|
||||
if (path.isJSXIdentifier() || path.isJSXMemberExpression() || path.isJSXNamespacedName()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.isIdentifier()) {
|
||||
const binding = path.scope.getBinding(path.node.name);
|
||||
if (binding && binding.constant) return;
|
||||
}
|
||||
|
||||
if (!path.isImmutable()) {
|
||||
if (path.isPure()) {
|
||||
const expressionResult = path.evaluate();
|
||||
|
||||
if (expressionResult.confident) {
|
||||
const {
|
||||
value
|
||||
} = expressionResult;
|
||||
const isMutable = !state.mutablePropsAllowed && value && typeof value === "object" || typeof value === "function";
|
||||
|
||||
if (!isMutable) {
|
||||
path.skip();
|
||||
return;
|
||||
}
|
||||
} else if (_core.types.isIdentifier(expressionResult.deopt)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
stop();
|
||||
}
|
||||
},
|
||||
|
||||
ReferencedIdentifier(path, state) {
|
||||
const {
|
||||
node
|
||||
} = path;
|
||||
let {
|
||||
scope
|
||||
} = path;
|
||||
|
||||
while (scope) {
|
||||
if (scope === state.targetScope) return;
|
||||
if (declares(node, scope)) break;
|
||||
scope = scope.parent;
|
||||
}
|
||||
|
||||
state.targetScope = getHoistingScope(scope);
|
||||
}
|
||||
|
||||
};
|
||||
return {
|
||||
name: "transform-react-constant-elements",
|
||||
visitor: {
|
||||
JSXElement(path) {
|
||||
var _jsxScope;
|
||||
|
||||
if (HOISTED.has(path.node)) return;
|
||||
HOISTED.set(path.node, path.scope);
|
||||
const name = path.node.openingElement.name;
|
||||
let mutablePropsAllowed = false;
|
||||
|
||||
if (allowMutablePropsOnTags != null) {
|
||||
let lastSegment = name;
|
||||
|
||||
while (_core.types.isJSXMemberExpression(lastSegment)) {
|
||||
lastSegment = lastSegment.property;
|
||||
}
|
||||
|
||||
const elementName = lastSegment.name;
|
||||
mutablePropsAllowed = allowMutablePropsOnTags.includes(elementName);
|
||||
}
|
||||
|
||||
const state = {
|
||||
isImmutable: true,
|
||||
mutablePropsAllowed,
|
||||
targetScope: path.scope.getProgramParent()
|
||||
};
|
||||
path.traverse(analyzer, state);
|
||||
if (!state.isImmutable) return;
|
||||
const {
|
||||
targetScope
|
||||
} = state;
|
||||
HOISTED.set(path.node, targetScope);
|
||||
let jsxScope;
|
||||
let current = path;
|
||||
|
||||
while (!jsxScope && current.parentPath.isJSX()) {
|
||||
current = current.parentPath;
|
||||
jsxScope = HOISTED.get(current.node);
|
||||
}
|
||||
|
||||
(_jsxScope = jsxScope) != null ? _jsxScope : jsxScope = getHoistingScope(path.scope);
|
||||
if (targetScope === jsxScope) return;
|
||||
const id = path.scope.generateUidBasedOnNode(name);
|
||||
targetScope.push({
|
||||
id: _core.types.identifier(id)
|
||||
});
|
||||
let replacement = _core.template.expression.ast`
|
||||
${_core.types.identifier(id)} || (${_core.types.identifier(id)} = ${path.node})
|
||||
`;
|
||||
|
||||
if (path.parentPath.isJSXElement() || path.parentPath.isJSXAttribute()) {
|
||||
replacement = _core.types.jsxExpressionContainer(replacement);
|
||||
}
|
||||
|
||||
path.replaceWith(replacement);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
exports.default = _default;
|
33
web/node_modules/@babel/plugin-transform-react-constant-elements/package.json
generated
vendored
Normal file
33
web/node_modules/@babel/plugin-transform-react-constant-elements/package.json
generated
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "@babel/plugin-transform-react-constant-elements",
|
||||
"version": "7.14.5",
|
||||
"description": "Treat React JSX elements as value types and hoist them to the highest scope",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-plugin-transform-react-constant-elements"
|
||||
},
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-react-constant-elements",
|
||||
"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",
|
||||
"@babel/helper-plugin-test-runner": "7.14.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"author": "The Babel Team (https://babel.dev/team)"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue