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
124
web/node_modules/@rollup/plugin-replace/CHANGELOG.md
generated
vendored
Executable file
124
web/node_modules/@rollup/plugin-replace/CHANGELOG.md
generated
vendored
Executable file
|
@ -0,0 +1,124 @@
|
|||
# @rollup/plugin-replace ChangeLog
|
||||
|
||||
## v2.4.2
|
||||
|
||||
_2021-03-26_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: document the `values` option (#814)
|
||||
|
||||
## v2.4.1
|
||||
|
||||
_2021-02-22_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: add missing types for new `preventAssignment` option (#813)
|
||||
|
||||
## v2.4.0
|
||||
|
||||
_2021-02-22_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: prevent accidental replacement within assignment (#798)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: clarify replacement. fixes #737 (#785)
|
||||
|
||||
## v2.3.4
|
||||
|
||||
_2020-10-27_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: describe process.env.NODE_ENV case (#589)
|
||||
- chore: update dependencies (53e2b73)
|
||||
- docs: linting update in readme (aef7dbc)
|
||||
|
||||
## v2.3.3
|
||||
|
||||
_2020-06-05_
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: clarify options for allowed replacement values (#422)
|
||||
|
||||
## v2.3.2
|
||||
|
||||
_2020-04-19_
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: add rollup 2 to peer range (3e0d775)
|
||||
|
||||
## v2.3.1
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: update dependencies (aca4a94)
|
||||
|
||||
## 2.3.0
|
||||
|
||||
_2019-12-21_
|
||||
|
||||
- feat(replace): allow plugin to operate as an output plugin (#55)
|
||||
|
||||
## 2.2.1
|
||||
|
||||
_2019-11-06_
|
||||
|
||||
- Move `typescript` to `devDependencies`
|
||||
|
||||
## 2.2.0
|
||||
|
||||
_2019-04-10_
|
||||
|
||||
- Add index.d.ts typings file ([#31](https://github.com/rollup/rollup-plugin-replace/pull/31))
|
||||
|
||||
## 2.1.1
|
||||
|
||||
_2019-03-18_
|
||||
|
||||
- Update rollup-pluginutils ([#29](https://github.com/rollup/rollup-plugin-replace/pull/29))
|
||||
- Update dependencies ([#30](https://github.com/rollup/rollup-plugin-replace/pull/30))
|
||||
|
||||
## 2.1.0
|
||||
|
||||
_2018-10-07_
|
||||
|
||||
- Do not mutate values passed as option ([#22](https://github.com/rollup/rollup-plugin-replace/pull/22))
|
||||
- Update dependencies and improve tests ([#26](https://github.com/rollup/rollup-plugin-replace/pull/26))
|
||||
|
||||
## 2.0.0
|
||||
|
||||
- Only match on word boundaries, unless delimiters are empty strings ([#10](https://github.com/rollup/rollup-plugin-replace/pull/10))
|
||||
|
||||
## 1.2.1
|
||||
|
||||
- Match longest keys first ([#8](https://github.com/rollup/rollup-plugin-replace/pull/8))
|
||||
- Escape keys ([#9](https://github.com/rollup/rollup-plugin-replace/pull/9))
|
||||
|
||||
## 1.2.0
|
||||
|
||||
- Allow replacement to be a function that takes a module ID ([#1](https://github.com/rollup/rollup-plugin-replace/issues/1))
|
||||
|
||||
## 1.1.1
|
||||
|
||||
- Return a `name`
|
||||
|
||||
## 1.1.0
|
||||
|
||||
- Generate sourcemaps by default
|
||||
|
||||
## 1.0.1
|
||||
|
||||
- Include correct files in package
|
||||
|
||||
## 1.0.0
|
||||
|
||||
- First release
|
21
web/node_modules/@rollup/plugin-replace/LICENSE
generated
vendored
Normal file
21
web/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.
|
187
web/node_modules/@rollup/plugin-replace/README.md
generated
vendored
Normal file
187
web/node_modules/@rollup/plugin-replace/README.md
generated
vendored
Normal file
|
@ -0,0 +1,187 @@
|
|||
[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 (v8.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: `['\b', '\b']`
|
||||
|
||||
Specifies the boundaries around which strings will be replaced. By default, delimiters are [word boundaries](https://www.regular-expressions.info/wordboundaries.html). See [Word Boundaries](#word-boundaries) below for more information.
|
||||
|
||||
### `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 [minimatch pattern](https://github.com/isaacs/minimatch), 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 [minimatch pattern](https://github.com/isaacs/minimatch), or array of patterns, which specifies the files in the build the plugin should operate on. By default all files are targeted.
|
||||
|
||||
### `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_.
|
||||
|
||||
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)
|
120
web/node_modules/@rollup/plugin-replace/dist/rollup-plugin-replace.cjs.js
generated
vendored
Normal file
120
web/node_modules/@rollup/plugin-replace/dist/rollup-plugin-replace.cjs.js
generated
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
'use strict';
|
||||
|
||||
var MagicString = require('magic-string');
|
||||
var pluginutils = require('@rollup/pluginutils');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
|
||||
|
||||
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;
|
||||
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;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function replace(options) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
var filter = pluginutils.createFilter(options.include, options.exclude);
|
||||
var delimiters = options.delimiters;
|
||||
var preventAssignment = options.preventAssignment;
|
||||
var functionValues = mapToFunctions(getReplacements(options));
|
||||
var keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
var lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
var pattern = delimiters
|
||||
? new RegExp(
|
||||
((escape(delimiters[0])) + "(" + (keys.join('|')) + ")" + (escape(delimiters[1])) + lookahead),
|
||||
'g'
|
||||
)
|
||||
: new RegExp(("\\b(" + (keys.join('|')) + ")\\b" + 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__default['default'](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;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = replace;
|
114
web/node_modules/@rollup/plugin-replace/dist/rollup-plugin-replace.es.js
generated
vendored
Normal file
114
web/node_modules/@rollup/plugin-replace/dist/rollup-plugin-replace.es.js
generated
vendored
Normal file
|
@ -0,0 +1,114 @@
|
|||
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;
|
||||
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;
|
||||
}, {});
|
||||
}
|
||||
|
||||
function replace(options) {
|
||||
if ( options === void 0 ) options = {};
|
||||
|
||||
var filter = createFilter(options.include, options.exclude);
|
||||
var delimiters = options.delimiters;
|
||||
var preventAssignment = options.preventAssignment;
|
||||
var functionValues = mapToFunctions(getReplacements(options));
|
||||
var keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
var lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
var pattern = delimiters
|
||||
? new RegExp(
|
||||
((escape(delimiters[0])) + "(" + (keys.join('|')) + ")" + (escape(delimiters[1])) + lookahead),
|
||||
'g'
|
||||
)
|
||||
: new RegExp(("\\b(" + (keys.join('|')) + ")\\b" + 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 default replace;
|
73
web/node_modules/@rollup/plugin-replace/package.json
generated
vendored
Normal file
73
web/node_modules/@rollup/plugin-replace/package.json
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"name": "@rollup/plugin-replace",
|
||||
"version": "2.4.2",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Replace strings in files while bundling",
|
||||
"license": "MIT",
|
||||
"repository": "rollup/plugins",
|
||||
"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/rollup-plugin-replace.cjs.js",
|
||||
"module": "dist/rollup-plugin-replace.es.js",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"ci:coverage": "nyc pnpm run test && nyc report --reporter=text-lcov > coverage.lcov",
|
||||
"ci:lint": "pnpm run build && pnpm run lint",
|
||||
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
|
||||
"ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
|
||||
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
|
||||
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write README.md",
|
||||
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
|
||||
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "pnpm run build",
|
||||
"prepublishOnly": "pnpm run lint && pnpm run test",
|
||||
"pretest": "pnpm run build",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
"types",
|
||||
"README.md"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"replace",
|
||||
"es2015",
|
||||
"npm",
|
||||
"modules"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0 || ^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^3.1.0",
|
||||
"magic-string": "^0.25.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-buble": "^0.21.3",
|
||||
"del-cli": "^3.0.1",
|
||||
"locate-character": "^2.0.5",
|
||||
"rollup": "^2.23.0",
|
||||
"source-map": "^0.7.3",
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"ava": {
|
||||
"babel": {
|
||||
"compileEnhancements": false
|
||||
},
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
}
|
||||
}
|
109
web/node_modules/@rollup/plugin-replace/src/index.js
generated
vendored
Executable file
109
web/node_modules/@rollup/plugin-replace/src/index.js
generated
vendored
Executable file
|
@ -0,0 +1,109 @@
|
|||
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;
|
||||
return values;
|
||||
}
|
||||
|
||||
function mapToFunctions(object) {
|
||||
return Object.keys(object).reduce((fns, key) => {
|
||||
const functions = Object.assign({}, fns);
|
||||
functions[key] = ensureFunction(object[key]);
|
||||
return functions;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export default function replace(options = {}) {
|
||||
const filter = createFilter(options.include, options.exclude);
|
||||
const { delimiters, preventAssignment } = options;
|
||||
const functionValues = mapToFunctions(getReplacements(options));
|
||||
const keys = Object.keys(functionValues).sort(longest).map(escape);
|
||||
const lookahead = preventAssignment ? '(?!\\s*=[^=])' : '';
|
||||
const pattern = delimiters
|
||||
? new RegExp(
|
||||
`${escape(delimiters[0])}(${keys.join('|')})${escape(delimiters[1])}${lookahead}`,
|
||||
'g'
|
||||
)
|
||||
: new RegExp(`\\b(${keys.join('|')})\\b${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;
|
||||
}
|
||||
}
|
45
web/node_modules/@rollup/plugin-replace/types/index.d.ts
generated
vendored
Executable file
45
web/node_modules/@rollup/plugin-replace/types/index.d.ts
generated
vendored
Executable file
|
@ -0,0 +1,45 @@
|
|||
import { FilterPattern } from '@rollup/pluginutils';
|
||||
import { 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['preventAssignment'];
|
||||
|
||||
/**
|
||||
* A minimatch 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;
|
||||
/**
|
||||
* To replace every occurrence of `<@foo@>` instead of every occurrence
|
||||
* of `foo`, supply delimiters
|
||||
*/
|
||||
delimiters?: [string, string];
|
||||
/**
|
||||
* 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