Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/@rollup/plugin-replace/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/@rollup/plugin-replace/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/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.
|
||||
240
Frontend-Learner/node_modules/@rollup/plugin-replace/README.md
generated
vendored
Normal file
240
Frontend-Learner/node_modules/@rollup/plugin-replace/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-replace
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-replace
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-replace
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-replace
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/plugin-replace
|
||||
|
||||
🍣 A Rollup plugin which replaces targeted strings in files while bundling.
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```console
|
||||
npm install @rollup/plugin-replace --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
||||
|
||||
```js
|
||||
import replace from '@rollup/plugin-replace';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
dir: 'output',
|
||||
format: 'cjs'
|
||||
},
|
||||
plugins: [
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify('production'),
|
||||
__buildDate__: () => JSON.stringify(new Date()),
|
||||
__buildVersion: 15
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
Then call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).
|
||||
|
||||
The configuration above will replace every instance of `process.env.NODE_ENV` with `"production"` and `__buildDate__` with the result of the given function in any file included in the build.
|
||||
|
||||
_Note: Values must be either primitives (e.g. string, number) or `function` that returns a string. For complex values, use `JSON.stringify`. To replace a target with a value that will be evaluated as a string, set the value to a quoted string (e.g. `"test"`) or use `JSON.stringify` to preprocess the target string safely._
|
||||
|
||||
Typically, `@rollup/plugin-replace` should be placed in `plugins` _before_ other plugins so that they may apply optimizations, such as dead code removal.
|
||||
|
||||
## Options
|
||||
|
||||
In addition to the properties and values specified for replacement, users may also specify the options below.
|
||||
|
||||
### `delimiters`
|
||||
|
||||
Type: `Array[String, String]`<br>
|
||||
Default: `['(?<![_$a-zA-Z0-9\\xA0-\\uFFFF])', '(?![_$a-zA-Z0-9\\xA0-\\uFFFF])(?!\\.)']`
|
||||
|
||||
Specifies the boundaries around which strings will be replaced. By default, delimiters match JavaScript identifier boundaries and also prevent replacements of instances with nested access. See [Word Boundaries](#word-boundaries) below for more information.
|
||||
For example, if you pass `typeof window` in `values` to-be-replaced, then you could expect the following scenarios:
|
||||
|
||||
- `typeof window` **will** be replaced
|
||||
- `typeof window.document` **will not** be replaced due to the `(?!\.)` boundary
|
||||
- `typeof windowSmth` **will not** be replaced due to identifier boundaries
|
||||
|
||||
Delimiters will be used to build a `Regexp`. To match special characters (any of `.*+?^${}()|[]\`), be sure to [escape](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping) them.
|
||||
|
||||
### `objectGuards`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
When replacing dot-separated object properties like `process.env.NODE_ENV`, will also replace `typeof process` object guard
|
||||
checks against the objects with the string `"object"`.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
replace({
|
||||
values: {
|
||||
'process.env.NODE_ENV': '"production"'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
// Input
|
||||
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
|
||||
console.log('production');
|
||||
}
|
||||
// Without `objectGuards`
|
||||
if (typeof process !== 'undefined' && 'production' === 'production') {
|
||||
console.log('production');
|
||||
}
|
||||
// With `objectGuards`
|
||||
if ('object' !== 'undefined' && 'production' === 'production') {
|
||||
console.log('production');
|
||||
}
|
||||
```
|
||||
|
||||
### `preventAssignment`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Prevents replacing strings where they are followed by a single equals sign. For example, where the plugin is called as follows:
|
||||
|
||||
```js
|
||||
replace({
|
||||
values: {
|
||||
'process.env.DEBUG': 'false'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Observe the following code:
|
||||
|
||||
```js
|
||||
// Input
|
||||
process.env.DEBUG = false;
|
||||
if (process.env.DEBUG == true) {
|
||||
//
|
||||
}
|
||||
// Without `preventAssignment`
|
||||
false = false; // this throws an error because false cannot be assigned to
|
||||
if (false == true) {
|
||||
//
|
||||
}
|
||||
// With `preventAssignment`
|
||||
process.env.DEBUG = false;
|
||||
if (false == true) {
|
||||
//
|
||||
}
|
||||
```
|
||||
|
||||
### `exclude`
|
||||
|
||||
Type: `String` | `Array[...String]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files in the build the plugin should _ignore_. By default no files are ignored.
|
||||
|
||||
### `include`
|
||||
|
||||
Type: `String` | `Array[...String]`<br>
|
||||
Default: `null`
|
||||
|
||||
A [picomatch pattern](https://github.com/micromatch/picomatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.
|
||||
|
||||
### `sourceMap` or `sourcemap`
|
||||
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Enables generating sourcemaps for the bundled code. For example, where the plugin is called as follows:
|
||||
|
||||
```js
|
||||
replace({
|
||||
sourcemap: true
|
||||
});
|
||||
```
|
||||
|
||||
### `values`
|
||||
|
||||
Type: `{ [key: String]: Replacement }`, where `Replacement` is either a string or a `function` that returns a string.
|
||||
Default: `{}`
|
||||
|
||||
To avoid mixing replacement strings with the other options, you can specify replacements in the `values` option. For example, the following signature:
|
||||
|
||||
```js
|
||||
replace({
|
||||
include: ['src/**/*.js'],
|
||||
changed: 'replaced'
|
||||
});
|
||||
```
|
||||
|
||||
Can be replaced with:
|
||||
|
||||
```js
|
||||
replace({
|
||||
include: ['src/**/*.js'],
|
||||
values: {
|
||||
changed: 'replaced'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
## Word Boundaries
|
||||
|
||||
By default, values will only match if they are surrounded by _word boundaries_ that respect JavaScript's rules for valid identifiers (including `$` and `_` as valid identifier characters).
|
||||
|
||||
Consider the following options and build file:
|
||||
|
||||
```js
|
||||
module.exports = {
|
||||
...
|
||||
plugins: [replace({ changed: 'replaced' })]
|
||||
};
|
||||
```
|
||||
|
||||
```js
|
||||
// file.js
|
||||
console.log('changed');
|
||||
console.log('unchanged');
|
||||
```
|
||||
|
||||
The result would be:
|
||||
|
||||
```js
|
||||
// file.js
|
||||
console.log('replaced');
|
||||
console.log('unchanged');
|
||||
```
|
||||
|
||||
To ignore word boundaries and replace every instance of the string, wherever it may be, specify empty strings as delimiters:
|
||||
|
||||
```js
|
||||
export default {
|
||||
...
|
||||
plugins: [
|
||||
replace({
|
||||
changed: 'replaced',
|
||||
delimiters: ['', '']
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
139
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/cjs/index.js
generated
vendored
Normal file
139
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/cjs/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var MagicString = require('magic-string');
|
||||
var pluginutils = require('@rollup/pluginutils');
|
||||
|
||||
function escape(str) {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function ensureFunction(functionOrValue) {
|
||||
if (typeof functionOrValue === 'function') { return functionOrValue; }
|
||||
return function () { return functionOrValue; };
|
||||
}
|
||||
|
||||
function longest(a, b) {
|
||||
return b.length - a.length;
|
||||
}
|
||||
|
||||
function getReplacements(options) {
|
||||
if (options.values) {
|
||||
return Object.assign({}, options.values);
|
||||
}
|
||||
var values = Object.assign({}, options);
|
||||
delete values.delimiters;
|
||||
delete values.include;
|
||||
delete values.exclude;
|
||||
delete values.sourcemap;
|
||||
delete values.sourceMap;
|
||||
delete values.objectGuards;
|
||||
delete values.preventAssignment;
|
||||
return values;
|
||||
}
|
||||
|
||||
function mapToFunctions(object) {
|
||||
return Object.keys(object).reduce(function (fns, key) {
|
||||
var functions = Object.assign({}, fns);
|
||||
functions[key] = ensureFunction(object[key]);
|
||||
return functions;
|
||||
}, {});
|
||||
}
|
||||
|
||||
var objKeyRegEx =
|
||||
/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)(\.([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))+$/;
|
||||
function expandTypeofReplacements(replacements) {
|
||||
Object.keys(replacements).forEach(function (key) {
|
||||
var objMatch = key.match(objKeyRegEx);
|
||||
if (!objMatch) { return; }
|
||||
var dotIndex = objMatch[1].length;
|
||||
do {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
replacements[("typeof " + (key.slice(0, dotIndex)))] = '"object"';
|
||||
dotIndex = key.indexOf('.', dotIndex + 1);
|
||||
} while (dotIndex !== -1);
|
||||
});
|
||||
}
|
||||
|
||||
function replace(options) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
var filter = pluginutils.createFilter(options.include, options.exclude);
|
||||
var delimiters = options.delimiters; if ( delimiters === void 0 ) delimiters = ['(?<![_$a-zA-Z0-9\\xA0-\\uFFFF])', '(?![_$a-zA-Z0-9\\xA0-\\uFFFF])(?!\\.)'];
|
||||
var preventAssignment = options.preventAssignment;
|
||||
var objectGuards = options.objectGuards;
|
||||
var replacements = getReplacements(options);
|
||||
if (objectGuards) { expandTypeofReplacements(replacements); }
|
||||
var functionValues = mapToFunctions(replacements);
|
||||
var keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
var lookbehind = preventAssignment ? '(?<!\\b(?:const|let|var)\\s*)' : '';
|
||||
var lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
var pattern = new RegExp(
|
||||
("" + lookbehind + (delimiters[0]) + "(" + (keys.join('|')) + ")" + (delimiters[1]) + lookahead),
|
||||
'g'
|
||||
);
|
||||
|
||||
return {
|
||||
name: 'replace',
|
||||
|
||||
buildStart: function buildStart() {
|
||||
if (![true, false].includes(preventAssignment)) {
|
||||
this.warn({
|
||||
message:
|
||||
"@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`."
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
renderChunk: function renderChunk(code, chunk) {
|
||||
var id = chunk.fileName;
|
||||
if (!keys.length) { return null; }
|
||||
if (!filter(id)) { return null; }
|
||||
return executeReplacement(code, id);
|
||||
},
|
||||
|
||||
transform: function transform(code, id) {
|
||||
if (!keys.length) { return null; }
|
||||
if (!filter(id)) { return null; }
|
||||
return executeReplacement(code, id);
|
||||
}
|
||||
};
|
||||
|
||||
function executeReplacement(code, id) {
|
||||
var magicString = new MagicString(code);
|
||||
if (!codeHasReplacements(code, id, magicString)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = { code: magicString.toString() };
|
||||
if (isSourceMapEnabled()) {
|
||||
result.map = magicString.generateMap({ hires: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function codeHasReplacements(code, id, magicString) {
|
||||
var result = false;
|
||||
var match;
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while ((match = pattern.exec(code))) {
|
||||
result = true;
|
||||
|
||||
var start = match.index;
|
||||
var end = start + match[0].length;
|
||||
var replacement = String(functionValues[match[1]](id));
|
||||
magicString.overwrite(start, end, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isSourceMapEnabled() {
|
||||
return options.sourceMap !== false && options.sourcemap !== false;
|
||||
}
|
||||
}
|
||||
|
||||
exports.default = replace;
|
||||
module.exports = Object.assign(exports.default, exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
134
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/es/index.js
generated
vendored
Normal file
134
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/es/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
import MagicString from 'magic-string';
|
||||
import { createFilter } from '@rollup/pluginutils';
|
||||
|
||||
function escape(str) {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function ensureFunction(functionOrValue) {
|
||||
if (typeof functionOrValue === 'function') { return functionOrValue; }
|
||||
return function () { return functionOrValue; };
|
||||
}
|
||||
|
||||
function longest(a, b) {
|
||||
return b.length - a.length;
|
||||
}
|
||||
|
||||
function getReplacements(options) {
|
||||
if (options.values) {
|
||||
return Object.assign({}, options.values);
|
||||
}
|
||||
var values = Object.assign({}, options);
|
||||
delete values.delimiters;
|
||||
delete values.include;
|
||||
delete values.exclude;
|
||||
delete values.sourcemap;
|
||||
delete values.sourceMap;
|
||||
delete values.objectGuards;
|
||||
delete values.preventAssignment;
|
||||
return values;
|
||||
}
|
||||
|
||||
function mapToFunctions(object) {
|
||||
return Object.keys(object).reduce(function (fns, key) {
|
||||
var functions = Object.assign({}, fns);
|
||||
functions[key] = ensureFunction(object[key]);
|
||||
return functions;
|
||||
}, {});
|
||||
}
|
||||
|
||||
var objKeyRegEx =
|
||||
/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)(\.([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))+$/;
|
||||
function expandTypeofReplacements(replacements) {
|
||||
Object.keys(replacements).forEach(function (key) {
|
||||
var objMatch = key.match(objKeyRegEx);
|
||||
if (!objMatch) { return; }
|
||||
var dotIndex = objMatch[1].length;
|
||||
do {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
replacements[("typeof " + (key.slice(0, dotIndex)))] = '"object"';
|
||||
dotIndex = key.indexOf('.', dotIndex + 1);
|
||||
} while (dotIndex !== -1);
|
||||
});
|
||||
}
|
||||
|
||||
function replace(options) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
var filter = createFilter(options.include, options.exclude);
|
||||
var delimiters = options.delimiters; if ( delimiters === void 0 ) delimiters = ['(?<![_$a-zA-Z0-9\\xA0-\\uFFFF])', '(?![_$a-zA-Z0-9\\xA0-\\uFFFF])(?!\\.)'];
|
||||
var preventAssignment = options.preventAssignment;
|
||||
var objectGuards = options.objectGuards;
|
||||
var replacements = getReplacements(options);
|
||||
if (objectGuards) { expandTypeofReplacements(replacements); }
|
||||
var functionValues = mapToFunctions(replacements);
|
||||
var keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
var lookbehind = preventAssignment ? '(?<!\\b(?:const|let|var)\\s*)' : '';
|
||||
var lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
var pattern = new RegExp(
|
||||
("" + lookbehind + (delimiters[0]) + "(" + (keys.join('|')) + ")" + (delimiters[1]) + lookahead),
|
||||
'g'
|
||||
);
|
||||
|
||||
return {
|
||||
name: 'replace',
|
||||
|
||||
buildStart: function buildStart() {
|
||||
if (![true, false].includes(preventAssignment)) {
|
||||
this.warn({
|
||||
message:
|
||||
"@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`."
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
renderChunk: function renderChunk(code, chunk) {
|
||||
var id = chunk.fileName;
|
||||
if (!keys.length) { return null; }
|
||||
if (!filter(id)) { return null; }
|
||||
return executeReplacement(code, id);
|
||||
},
|
||||
|
||||
transform: function transform(code, id) {
|
||||
if (!keys.length) { return null; }
|
||||
if (!filter(id)) { return null; }
|
||||
return executeReplacement(code, id);
|
||||
}
|
||||
};
|
||||
|
||||
function executeReplacement(code, id) {
|
||||
var magicString = new MagicString(code);
|
||||
if (!codeHasReplacements(code, id, magicString)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = { code: magicString.toString() };
|
||||
if (isSourceMapEnabled()) {
|
||||
result.map = magicString.generateMap({ hires: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function codeHasReplacements(code, id, magicString) {
|
||||
var result = false;
|
||||
var match;
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while ((match = pattern.exec(code))) {
|
||||
result = true;
|
||||
|
||||
var start = match.index;
|
||||
var end = start + match[0].length;
|
||||
var replacement = String(functionValues[match[1]](id));
|
||||
magicString.overwrite(start, end, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isSourceMapEnabled() {
|
||||
return options.sourceMap !== false && options.sourcemap !== false;
|
||||
}
|
||||
}
|
||||
|
||||
export { replace as default };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/es/package.json
generated
vendored
Normal file
1
Frontend-Learner/node_modules/@rollup/plugin-replace/dist/es/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
{"type":"module"}
|
||||
84
Frontend-Learner/node_modules/@rollup/plugin-replace/package.json
generated
vendored
Normal file
84
Frontend-Learner/node_modules/@rollup/plugin-replace/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
{
|
||||
"name": "@rollup/plugin-replace",
|
||||
"version": "6.0.3",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Replace strings in files while bundling",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/replace"
|
||||
},
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/replace#readme",
|
||||
"bugs": "https://github.com/rollup/plugins/issues",
|
||||
"main": "dist/cjs/index.js",
|
||||
"module": "dist/es/index.js",
|
||||
"exports": {
|
||||
"types": "./types/index.d.ts",
|
||||
"import": "./dist/es/index.js",
|
||||
"default": "./dist/cjs/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"!dist/**/*.map",
|
||||
"src",
|
||||
"types",
|
||||
"README.md"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"replace",
|
||||
"es2015",
|
||||
"npm",
|
||||
"modules"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.0.1",
|
||||
"magic-string": "^0.30.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-buble": "^1.0.0",
|
||||
"del-cli": "^5.0.0",
|
||||
"locate-character": "^2.0.5",
|
||||
"rollup": "^4.0.0-24",
|
||||
"source-map": "^0.7.4",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"types": "./types/index.d.ts",
|
||||
"ava": {
|
||||
"workerThreads": false,
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm build && pnpm lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
|
||||
"prebuild": "del-cli dist",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build",
|
||||
"release": "pnpm --workspace-root package:release $(pwd)",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
||||
}
|
||||
}
|
||||
131
Frontend-Learner/node_modules/@rollup/plugin-replace/src/index.js
generated
vendored
Normal file
131
Frontend-Learner/node_modules/@rollup/plugin-replace/src/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
import MagicString from 'magic-string';
|
||||
import { createFilter } from '@rollup/pluginutils';
|
||||
|
||||
function escape(str) {
|
||||
return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
||||
}
|
||||
|
||||
function ensureFunction(functionOrValue) {
|
||||
if (typeof functionOrValue === 'function') return functionOrValue;
|
||||
return () => functionOrValue;
|
||||
}
|
||||
|
||||
function longest(a, b) {
|
||||
return b.length - a.length;
|
||||
}
|
||||
|
||||
function getReplacements(options) {
|
||||
if (options.values) {
|
||||
return Object.assign({}, options.values);
|
||||
}
|
||||
const values = Object.assign({}, options);
|
||||
delete values.delimiters;
|
||||
delete values.include;
|
||||
delete values.exclude;
|
||||
delete values.sourcemap;
|
||||
delete values.sourceMap;
|
||||
delete values.objectGuards;
|
||||
delete values.preventAssignment;
|
||||
return values;
|
||||
}
|
||||
|
||||
function mapToFunctions(object) {
|
||||
return Object.keys(object).reduce((fns, key) => {
|
||||
const functions = Object.assign({}, fns);
|
||||
functions[key] = ensureFunction(object[key]);
|
||||
return functions;
|
||||
}, {});
|
||||
}
|
||||
|
||||
const objKeyRegEx =
|
||||
/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)(\.([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))+$/;
|
||||
function expandTypeofReplacements(replacements) {
|
||||
Object.keys(replacements).forEach((key) => {
|
||||
const objMatch = key.match(objKeyRegEx);
|
||||
if (!objMatch) return;
|
||||
let dotIndex = objMatch[1].length;
|
||||
do {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
replacements[`typeof ${key.slice(0, dotIndex)}`] = '"object"';
|
||||
dotIndex = key.indexOf('.', dotIndex + 1);
|
||||
} while (dotIndex !== -1);
|
||||
});
|
||||
}
|
||||
|
||||
export default function replace(options = {}) {
|
||||
const filter = createFilter(options.include, options.exclude);
|
||||
const {
|
||||
delimiters = ['(?<![_$a-zA-Z0-9\\xA0-\\uFFFF])', '(?![_$a-zA-Z0-9\\xA0-\\uFFFF])(?!\\.)'],
|
||||
preventAssignment,
|
||||
objectGuards
|
||||
} = options;
|
||||
const replacements = getReplacements(options);
|
||||
if (objectGuards) expandTypeofReplacements(replacements);
|
||||
const functionValues = mapToFunctions(replacements);
|
||||
const keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
const lookbehind = preventAssignment ? '(?<!\\b(?:const|let|var)\\s*)' : '';
|
||||
const lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
const pattern = new RegExp(
|
||||
`${lookbehind}${delimiters[0]}(${keys.join('|')})${delimiters[1]}${lookahead}`,
|
||||
'g'
|
||||
);
|
||||
|
||||
return {
|
||||
name: 'replace',
|
||||
|
||||
buildStart() {
|
||||
if (![true, false].includes(preventAssignment)) {
|
||||
this.warn({
|
||||
message:
|
||||
"@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`."
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
renderChunk(code, chunk) {
|
||||
const id = chunk.fileName;
|
||||
if (!keys.length) return null;
|
||||
if (!filter(id)) return null;
|
||||
return executeReplacement(code, id);
|
||||
},
|
||||
|
||||
transform(code, id) {
|
||||
if (!keys.length) return null;
|
||||
if (!filter(id)) return null;
|
||||
return executeReplacement(code, id);
|
||||
}
|
||||
};
|
||||
|
||||
function executeReplacement(code, id) {
|
||||
const magicString = new MagicString(code);
|
||||
if (!codeHasReplacements(code, id, magicString)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = { code: magicString.toString() };
|
||||
if (isSourceMapEnabled()) {
|
||||
result.map = magicString.generateMap({ hires: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function codeHasReplacements(code, id, magicString) {
|
||||
let result = false;
|
||||
let match;
|
||||
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while ((match = pattern.exec(code))) {
|
||||
result = true;
|
||||
|
||||
const start = match.index;
|
||||
const end = start + match[0].length;
|
||||
const replacement = String(functionValues[match[1]](id));
|
||||
magicString.overwrite(start, end, replacement);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isSourceMapEnabled() {
|
||||
return options.sourceMap !== false && options.sourcemap !== false;
|
||||
}
|
||||
}
|
||||
57
Frontend-Learner/node_modules/@rollup/plugin-replace/types/index.d.ts
generated
vendored
Normal file
57
Frontend-Learner/node_modules/@rollup/plugin-replace/types/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import type { FilterPattern } from '@rollup/pluginutils';
|
||||
import type { Plugin } from 'rollup';
|
||||
|
||||
type Replacement = string | ((id: string) => string);
|
||||
|
||||
export interface RollupReplaceOptions {
|
||||
/**
|
||||
* All other options are treated as `string: replacement` replacers,
|
||||
* or `string: (id) => replacement` functions.
|
||||
*/
|
||||
[str: string]:
|
||||
| Replacement
|
||||
| RollupReplaceOptions['include']
|
||||
| RollupReplaceOptions['values']
|
||||
| RollupReplaceOptions['objectGuards']
|
||||
| RollupReplaceOptions['preventAssignment'];
|
||||
|
||||
/**
|
||||
* A picomatch pattern, or array of patterns, of files that should be
|
||||
* processed by this plugin (if omitted, all files are included by default)
|
||||
*/
|
||||
include?: FilterPattern;
|
||||
/**
|
||||
* Files that should be excluded, if `include` is otherwise too permissive.
|
||||
*/
|
||||
exclude?: FilterPattern;
|
||||
/**
|
||||
* If false, skips source map generation. This will improve performance.
|
||||
* @default true
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
/**
|
||||
* To replace every occurrence of `<@foo@>` instead of every occurrence
|
||||
* of `foo`, supply delimiters
|
||||
*/
|
||||
delimiters?: [string, string];
|
||||
/**
|
||||
* When replacing dot-separated object properties like `process.env.NODE_ENV`,
|
||||
* will also replace `typeof process` object guard checks against the objects
|
||||
* with the string `"object"`.
|
||||
*/
|
||||
objectGuards?: boolean;
|
||||
/**
|
||||
* Prevents replacing strings where they are followed by a single equals
|
||||
* sign.
|
||||
*/
|
||||
preventAssignment?: boolean;
|
||||
/**
|
||||
* You can separate values to replace from other options.
|
||||
*/
|
||||
values?: { [str: string]: Replacement };
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace strings in files while bundling them.
|
||||
*/
|
||||
export default function replace(options?: RollupReplaceOptions): Plugin;
|
||||
Loading…
Add table
Add a link
Reference in a new issue