initial commit
This commit is contained in:
96
node_modules/@rollup/plugin-inject/README.md
generated
vendored
Normal file
96
node_modules/@rollup/plugin-inject/README.md
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
[npm]: https://img.shields.io/npm/v/@rollup/plugin-inject
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/plugin-inject
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/plugin-inject
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/plugin-inject
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/plugin-inject
|
||||
|
||||
🍣 A Rollup plugin which scans modules for global variables and injects `import` statements where necessary.
|
||||
|
||||
## 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-inject --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Create a `rollup.config.js` [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:
|
||||
|
||||
```js
|
||||
import inject from '@rollup/plugin-inject';
|
||||
|
||||
export default {
|
||||
input: 'src/index.js',
|
||||
output: {
|
||||
dir: 'output',
|
||||
format: 'cjs'
|
||||
},
|
||||
plugins: [
|
||||
inject({
|
||||
Promise: ['es6-promise', 'Promise']
|
||||
})
|
||||
]
|
||||
};
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
This configuration above will scan all your files for global Promise usage and plugin will add import to desired module (`import { Promise } from 'es6-promise'` in this case).
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
{
|
||||
// import { Promise } from 'es6-promise'
|
||||
Promise: [ 'es6-promise', 'Promise' ],
|
||||
|
||||
// import { Promise as P } from 'es6-promise'
|
||||
P: [ 'es6-promise', 'Promise' ],
|
||||
|
||||
// import $ from 'jquery'
|
||||
$: 'jquery',
|
||||
|
||||
// import * as fs from 'fs'
|
||||
fs: [ 'fs', '*' ],
|
||||
|
||||
// use a local module instead of a third-party one
|
||||
'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
||||
}
|
||||
```
|
||||
|
||||
Typically, `@rollup/plugin-inject` 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 injecting, users may also specify the options below.
|
||||
|
||||
### `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.
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
218
node_modules/@rollup/plugin-inject/dist/cjs/index.js
generated
vendored
Normal file
218
node_modules/@rollup/plugin-inject/dist/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var path = require('path');
|
||||
var pluginutils = require('@rollup/pluginutils');
|
||||
var estreeWalker = require('estree-walker');
|
||||
var MagicString = require('magic-string');
|
||||
|
||||
var escape = function (str) { return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); };
|
||||
|
||||
var isReference = function (node, parent) {
|
||||
if (node.type === 'MemberExpression') {
|
||||
return !node.computed && isReference(node.object, node);
|
||||
}
|
||||
|
||||
if (node.type === 'Identifier') {
|
||||
// TODO is this right?
|
||||
if (parent.type === 'MemberExpression') { return parent.computed || node === parent.object; }
|
||||
|
||||
// disregard the `bar` in { bar: foo }
|
||||
if (parent.type === 'Property' && node !== parent.value) { return false; }
|
||||
|
||||
// disregard the `bar` in `class Foo { bar () {...} }`
|
||||
if (parent.type === 'MethodDefinition') { return false; }
|
||||
|
||||
// disregard the `bar` in `export { foo as bar }`
|
||||
if (parent.type === 'ExportSpecifier' && node !== parent.local) { return false; }
|
||||
|
||||
// disregard the `bar` in `import { bar as foo }`
|
||||
if (parent.type === 'ImportSpecifier' && node === parent.imported) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
var flatten = function (startNode) {
|
||||
var parts = [];
|
||||
var node = startNode;
|
||||
|
||||
while (node.type === 'MemberExpression') {
|
||||
parts.unshift(node.property.name);
|
||||
node = node.object;
|
||||
}
|
||||
|
||||
var name = node.name;
|
||||
parts.unshift(name);
|
||||
|
||||
return { name: name, keypath: parts.join('.') };
|
||||
};
|
||||
|
||||
function inject(options) {
|
||||
if (!options) { throw new Error('Missing options'); }
|
||||
|
||||
var filter = pluginutils.createFilter(options.include, options.exclude);
|
||||
|
||||
var modules = options.modules;
|
||||
|
||||
if (!modules) {
|
||||
modules = Object.assign({}, options);
|
||||
delete modules.include;
|
||||
delete modules.exclude;
|
||||
delete modules.sourceMap;
|
||||
delete modules.sourcemap;
|
||||
}
|
||||
|
||||
var modulesMap = new Map(Object.entries(modules));
|
||||
|
||||
// Fix paths on Windows
|
||||
if (path.sep !== '/') {
|
||||
modulesMap.forEach(function (mod, key) {
|
||||
modulesMap.set(
|
||||
key,
|
||||
Array.isArray(mod) ? [mod[0].split(path.sep).join('/'), mod[1]] : mod.split(path.sep).join('/')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
var firstpass = new RegExp(("(?:" + (Array.from(modulesMap.keys()).map(escape).join('|')) + ")"), 'g');
|
||||
var sourceMap = options.sourceMap !== false && options.sourcemap !== false;
|
||||
|
||||
return {
|
||||
name: 'inject',
|
||||
|
||||
transform: function transform(code, id) {
|
||||
if (!filter(id)) { return null; }
|
||||
if (code.search(firstpass) === -1) { return null; }
|
||||
|
||||
if (path.sep !== '/') { id = id.split(path.sep).join('/'); } // eslint-disable-line no-param-reassign
|
||||
|
||||
var ast = null;
|
||||
try {
|
||||
ast = this.parse(code);
|
||||
} catch (err) {
|
||||
this.warn({
|
||||
code: 'PARSE_ERROR',
|
||||
message: ("rollup-plugin-inject: failed to parse " + id + ". Consider restricting the plugin to particular files via options.include")
|
||||
});
|
||||
}
|
||||
if (!ast) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var imports = new Set();
|
||||
ast.body.forEach(function (node) {
|
||||
if (node.type === 'ImportDeclaration') {
|
||||
node.specifiers.forEach(function (specifier) {
|
||||
imports.add(specifier.local.name);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// analyse scopes
|
||||
var scope = pluginutils.attachScopes(ast, 'scope');
|
||||
|
||||
var magicString = new MagicString(code);
|
||||
|
||||
var newImports = new Map();
|
||||
|
||||
function handleReference(node, name, keypath) {
|
||||
var mod = modulesMap.get(keypath);
|
||||
if (mod && !imports.has(name) && !scope.contains(name)) {
|
||||
if (typeof mod === 'string') { mod = [mod, 'default']; }
|
||||
|
||||
// prevent module from importing itself
|
||||
if (mod[0] === id) { return false; }
|
||||
|
||||
var hash = keypath + ":" + (mod[0]) + ":" + (mod[1]);
|
||||
|
||||
var importLocalName =
|
||||
name === keypath ? name : pluginutils.makeLegalIdentifier(("$inject_" + keypath));
|
||||
|
||||
if (!newImports.has(hash)) {
|
||||
// escape apostrophes and backslashes for use in single-quoted string literal
|
||||
var modName = mod[0].replace(/[''\\]/g, '\\$&');
|
||||
if (mod[1] === '*') {
|
||||
newImports.set(hash, ("import * as " + importLocalName + " from '" + modName + "';"));
|
||||
} else {
|
||||
newImports.set(hash, ("import { " + (mod[1]) + " as " + importLocalName + " } from '" + modName + "';"));
|
||||
}
|
||||
}
|
||||
|
||||
if (name !== keypath) {
|
||||
magicString.overwrite(node.start, node.end, importLocalName, {
|
||||
storeName: true
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
estreeWalker.walk(ast, {
|
||||
enter: function enter(node, parent) {
|
||||
if (sourceMap) {
|
||||
magicString.addSourcemapLocation(node.start);
|
||||
magicString.addSourcemapLocation(node.end);
|
||||
}
|
||||
|
||||
if (node.scope) {
|
||||
scope = node.scope; // eslint-disable-line prefer-destructuring
|
||||
}
|
||||
|
||||
// special case – shorthand properties. because node.key === node.value,
|
||||
// we can't differentiate once we've descended into the node
|
||||
if (node.type === 'Property' && node.shorthand && node.value.type === 'Identifier') {
|
||||
var ref = node.key;
|
||||
var name = ref.name;
|
||||
handleReference(node, name, name);
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isReference(node, parent)) {
|
||||
var ref$1 = flatten(node);
|
||||
var name$1 = ref$1.name;
|
||||
var keypath = ref$1.keypath;
|
||||
var handled = handleReference(node, name$1, keypath);
|
||||
if (handled) {
|
||||
this.skip();
|
||||
}
|
||||
}
|
||||
},
|
||||
leave: function leave(node) {
|
||||
if (node.scope) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (newImports.size === 0) {
|
||||
return {
|
||||
code: code,
|
||||
ast: ast,
|
||||
map: sourceMap ? magicString.generateMap({ hires: true }) : null
|
||||
};
|
||||
}
|
||||
var importBlock = Array.from(newImports.values()).join('\n\n');
|
||||
|
||||
magicString.prepend((importBlock + "\n\n"));
|
||||
|
||||
return {
|
||||
code: magicString.toString(),
|
||||
map: sourceMap ? magicString.generateMap({ hires: true }) : null
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
exports.default = inject;
|
||||
module.exports = Object.assign(exports.default, exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
213
node_modules/@rollup/plugin-inject/dist/es/index.js
generated
vendored
Normal file
213
node_modules/@rollup/plugin-inject/dist/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
import { sep } from 'path';
|
||||
import { createFilter, attachScopes, makeLegalIdentifier } from '@rollup/pluginutils';
|
||||
import { walk } from 'estree-walker';
|
||||
import MagicString from 'magic-string';
|
||||
|
||||
var escape = function (str) { return str.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&'); };
|
||||
|
||||
var isReference = function (node, parent) {
|
||||
if (node.type === 'MemberExpression') {
|
||||
return !node.computed && isReference(node.object, node);
|
||||
}
|
||||
|
||||
if (node.type === 'Identifier') {
|
||||
// TODO is this right?
|
||||
if (parent.type === 'MemberExpression') { return parent.computed || node === parent.object; }
|
||||
|
||||
// disregard the `bar` in { bar: foo }
|
||||
if (parent.type === 'Property' && node !== parent.value) { return false; }
|
||||
|
||||
// disregard the `bar` in `class Foo { bar () {...} }`
|
||||
if (parent.type === 'MethodDefinition') { return false; }
|
||||
|
||||
// disregard the `bar` in `export { foo as bar }`
|
||||
if (parent.type === 'ExportSpecifier' && node !== parent.local) { return false; }
|
||||
|
||||
// disregard the `bar` in `import { bar as foo }`
|
||||
if (parent.type === 'ImportSpecifier' && node === parent.imported) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
var flatten = function (startNode) {
|
||||
var parts = [];
|
||||
var node = startNode;
|
||||
|
||||
while (node.type === 'MemberExpression') {
|
||||
parts.unshift(node.property.name);
|
||||
node = node.object;
|
||||
}
|
||||
|
||||
var name = node.name;
|
||||
parts.unshift(name);
|
||||
|
||||
return { name: name, keypath: parts.join('.') };
|
||||
};
|
||||
|
||||
function inject(options) {
|
||||
if (!options) { throw new Error('Missing options'); }
|
||||
|
||||
var filter = createFilter(options.include, options.exclude);
|
||||
|
||||
var modules = options.modules;
|
||||
|
||||
if (!modules) {
|
||||
modules = Object.assign({}, options);
|
||||
delete modules.include;
|
||||
delete modules.exclude;
|
||||
delete modules.sourceMap;
|
||||
delete modules.sourcemap;
|
||||
}
|
||||
|
||||
var modulesMap = new Map(Object.entries(modules));
|
||||
|
||||
// Fix paths on Windows
|
||||
if (sep !== '/') {
|
||||
modulesMap.forEach(function (mod, key) {
|
||||
modulesMap.set(
|
||||
key,
|
||||
Array.isArray(mod) ? [mod[0].split(sep).join('/'), mod[1]] : mod.split(sep).join('/')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
var firstpass = new RegExp(("(?:" + (Array.from(modulesMap.keys()).map(escape).join('|')) + ")"), 'g');
|
||||
var sourceMap = options.sourceMap !== false && options.sourcemap !== false;
|
||||
|
||||
return {
|
||||
name: 'inject',
|
||||
|
||||
transform: function transform(code, id) {
|
||||
if (!filter(id)) { return null; }
|
||||
if (code.search(firstpass) === -1) { return null; }
|
||||
|
||||
if (sep !== '/') { id = id.split(sep).join('/'); } // eslint-disable-line no-param-reassign
|
||||
|
||||
var ast = null;
|
||||
try {
|
||||
ast = this.parse(code);
|
||||
} catch (err) {
|
||||
this.warn({
|
||||
code: 'PARSE_ERROR',
|
||||
message: ("rollup-plugin-inject: failed to parse " + id + ". Consider restricting the plugin to particular files via options.include")
|
||||
});
|
||||
}
|
||||
if (!ast) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var imports = new Set();
|
||||
ast.body.forEach(function (node) {
|
||||
if (node.type === 'ImportDeclaration') {
|
||||
node.specifiers.forEach(function (specifier) {
|
||||
imports.add(specifier.local.name);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// analyse scopes
|
||||
var scope = attachScopes(ast, 'scope');
|
||||
|
||||
var magicString = new MagicString(code);
|
||||
|
||||
var newImports = new Map();
|
||||
|
||||
function handleReference(node, name, keypath) {
|
||||
var mod = modulesMap.get(keypath);
|
||||
if (mod && !imports.has(name) && !scope.contains(name)) {
|
||||
if (typeof mod === 'string') { mod = [mod, 'default']; }
|
||||
|
||||
// prevent module from importing itself
|
||||
if (mod[0] === id) { return false; }
|
||||
|
||||
var hash = keypath + ":" + (mod[0]) + ":" + (mod[1]);
|
||||
|
||||
var importLocalName =
|
||||
name === keypath ? name : makeLegalIdentifier(("$inject_" + keypath));
|
||||
|
||||
if (!newImports.has(hash)) {
|
||||
// escape apostrophes and backslashes for use in single-quoted string literal
|
||||
var modName = mod[0].replace(/[''\\]/g, '\\$&');
|
||||
if (mod[1] === '*') {
|
||||
newImports.set(hash, ("import * as " + importLocalName + " from '" + modName + "';"));
|
||||
} else {
|
||||
newImports.set(hash, ("import { " + (mod[1]) + " as " + importLocalName + " } from '" + modName + "';"));
|
||||
}
|
||||
}
|
||||
|
||||
if (name !== keypath) {
|
||||
magicString.overwrite(node.start, node.end, importLocalName, {
|
||||
storeName: true
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
walk(ast, {
|
||||
enter: function enter(node, parent) {
|
||||
if (sourceMap) {
|
||||
magicString.addSourcemapLocation(node.start);
|
||||
magicString.addSourcemapLocation(node.end);
|
||||
}
|
||||
|
||||
if (node.scope) {
|
||||
scope = node.scope; // eslint-disable-line prefer-destructuring
|
||||
}
|
||||
|
||||
// special case – shorthand properties. because node.key === node.value,
|
||||
// we can't differentiate once we've descended into the node
|
||||
if (node.type === 'Property' && node.shorthand && node.value.type === 'Identifier') {
|
||||
var ref = node.key;
|
||||
var name = ref.name;
|
||||
handleReference(node, name, name);
|
||||
this.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isReference(node, parent)) {
|
||||
var ref$1 = flatten(node);
|
||||
var name$1 = ref$1.name;
|
||||
var keypath = ref$1.keypath;
|
||||
var handled = handleReference(node, name$1, keypath);
|
||||
if (handled) {
|
||||
this.skip();
|
||||
}
|
||||
}
|
||||
},
|
||||
leave: function leave(node) {
|
||||
if (node.scope) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (newImports.size === 0) {
|
||||
return {
|
||||
code: code,
|
||||
ast: ast,
|
||||
map: sourceMap ? magicString.generateMap({ hires: true }) : null
|
||||
};
|
||||
}
|
||||
var importBlock = Array.from(newImports.values()).join('\n\n');
|
||||
|
||||
magicString.prepend((importBlock + "\n\n"));
|
||||
|
||||
return {
|
||||
code: magicString.toString(),
|
||||
map: sourceMap ? magicString.generateMap({ hires: true }) : null
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { inject as default };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@rollup/plugin-inject/dist/es/package.json
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/dist/es/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
92
node_modules/@rollup/plugin-inject/node_modules/estree-walker/CHANGELOG.md
generated
vendored
Normal file
92
node_modules/@rollup/plugin-inject/node_modules/estree-walker/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
# changelog
|
||||
|
||||
## 2.0.2
|
||||
|
||||
* Internal tidying up (change test runner, convert to JS)
|
||||
|
||||
## 2.0.1
|
||||
|
||||
* Robustify `this.remove()`, pass current index to walker functions ([#18](https://github.com/Rich-Harris/estree-walker/pull/18))
|
||||
|
||||
## 2.0.0
|
||||
|
||||
* Add an `asyncWalk` export ([#20](https://github.com/Rich-Harris/estree-walker/pull/20))
|
||||
* Internal rewrite
|
||||
|
||||
## 1.0.1
|
||||
|
||||
* Relax node type to `BaseNode` ([#17](https://github.com/Rich-Harris/estree-walker/pull/17))
|
||||
|
||||
## 1.0.0
|
||||
|
||||
* Don't cache child keys
|
||||
|
||||
## 0.9.0
|
||||
|
||||
* Add `this.remove()` method
|
||||
|
||||
## 0.8.1
|
||||
|
||||
* Fix pkg.files
|
||||
|
||||
## 0.8.0
|
||||
|
||||
* Adopt `estree` types
|
||||
|
||||
## 0.7.0
|
||||
|
||||
* Add a `this.replace(node)` method
|
||||
|
||||
## 0.6.1
|
||||
|
||||
* Only traverse nodes that exist and have a type ([#9](https://github.com/Rich-Harris/estree-walker/pull/9))
|
||||
* Only cache keys for nodes with a type ([#8](https://github.com/Rich-Harris/estree-walker/pull/8))
|
||||
|
||||
## 0.6.0
|
||||
|
||||
* Fix walker context type
|
||||
* Update deps, remove unncessary Bublé transformation
|
||||
|
||||
## 0.5.2
|
||||
|
||||
* Add types to package
|
||||
|
||||
## 0.5.1
|
||||
|
||||
* Prevent context corruption when `walk()` is called during a walk
|
||||
|
||||
## 0.5.0
|
||||
|
||||
* Export `childKeys`, for manually fixing in case of malformed ASTs
|
||||
|
||||
## 0.4.0
|
||||
|
||||
* Add TypeScript typings ([#3](https://github.com/Rich-Harris/estree-walker/pull/3))
|
||||
|
||||
## 0.3.1
|
||||
|
||||
* Include `pkg.repository` ([#2](https://github.com/Rich-Harris/estree-walker/pull/2))
|
||||
|
||||
## 0.3.0
|
||||
|
||||
* More predictable ordering
|
||||
|
||||
## 0.2.1
|
||||
|
||||
* Keep `context` shape
|
||||
|
||||
## 0.2.0
|
||||
|
||||
* Add ES6 build
|
||||
|
||||
## 0.1.3
|
||||
|
||||
* npm snafu
|
||||
|
||||
## 0.1.2
|
||||
|
||||
* Pass current prop and index to `enter`/`leave` callbacks
|
||||
|
||||
## 0.1.1
|
||||
|
||||
* First release
|
||||
7
node_modules/@rollup/plugin-inject/node_modules/estree-walker/LICENSE
generated
vendored
Normal file
7
node_modules/@rollup/plugin-inject/node_modules/estree-walker/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/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.
|
||||
48
node_modules/@rollup/plugin-inject/node_modules/estree-walker/README.md
generated
vendored
Normal file
48
node_modules/@rollup/plugin-inject/node_modules/estree-walker/README.md
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# estree-walker
|
||||
|
||||
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i estree-walker
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var walk = require( 'estree-walker' ).walk;
|
||||
var acorn = require( 'acorn' );
|
||||
|
||||
ast = acorn.parse( sourceCode, options ); // https://github.com/acornjs/acorn
|
||||
|
||||
walk( ast, {
|
||||
enter: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
},
|
||||
leave: function ( node, parent, prop, index ) {
|
||||
// some code happens
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
|
||||
|
||||
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
|
||||
|
||||
Call `this.remove()` in either `enter` or `leave` to remove the current node.
|
||||
|
||||
## Why not use estraverse?
|
||||
|
||||
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
|
||||
|
||||
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
|
||||
|
||||
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
333
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/esm/estree-walker.js
generated
vendored
Normal file
333
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/esm/estree-walker.js
generated
vendored
Normal file
@@ -0,0 +1,333 @@
|
||||
// @ts-check
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
}} WalkerContext */
|
||||
|
||||
class WalkerBase {
|
||||
constructor() {
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {BaseNode | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => void} SyncHandler */
|
||||
|
||||
class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} enter
|
||||
* @param {SyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => Promise<void>} AsyncHandler */
|
||||
|
||||
class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} enter
|
||||
* @param {AsyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
async visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
||||
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
function walk(ast, { enter, leave }) {
|
||||
const instance = new SyncWalker(enter, leave);
|
||||
return instance.visit(ast, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
async function asyncWalk(ast, { enter, leave }) {
|
||||
const instance = new AsyncWalker(enter, leave);
|
||||
return await instance.visit(ast, null);
|
||||
}
|
||||
|
||||
export { asyncWalk, walk };
|
||||
1
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/esm/package.json
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
344
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/umd/estree-walker.js
generated
vendored
Normal file
344
node_modules/@rollup/plugin-inject/node_modules/estree-walker/dist/umd/estree-walker.js
generated
vendored
Normal file
@@ -0,0 +1,344 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = global || self, factory(global.estreeWalker = {}));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
// @ts-check
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
}} WalkerContext */
|
||||
|
||||
class WalkerBase {
|
||||
constructor() {
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {BaseNode | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => void} SyncHandler */
|
||||
|
||||
class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} enter
|
||||
* @param {SyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => Promise<void>} AsyncHandler */
|
||||
|
||||
class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} enter
|
||||
* @param {AsyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
async visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-check
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
||||
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
function walk(ast, { enter, leave }) {
|
||||
const instance = new SyncWalker(enter, leave);
|
||||
return instance.visit(ast, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
async function asyncWalk(ast, { enter, leave }) {
|
||||
const instance = new AsyncWalker(enter, leave);
|
||||
return await instance.visit(ast, null);
|
||||
}
|
||||
|
||||
exports.asyncWalk = asyncWalk;
|
||||
exports.walk = walk;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
37
node_modules/@rollup/plugin-inject/node_modules/estree-walker/package.json
generated
vendored
Normal file
37
node_modules/@rollup/plugin-inject/node_modules/estree-walker/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "estree-walker",
|
||||
"description": "Traverse an ESTree-compliant AST",
|
||||
"version": "2.0.2",
|
||||
"private": false,
|
||||
"author": "Rich Harris",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Rich-Harris/estree-walker"
|
||||
},
|
||||
"type": "commonjs",
|
||||
"main": "./dist/umd/estree-walker.js",
|
||||
"module": "./dist/esm/estree-walker.js",
|
||||
"exports": {
|
||||
"require": "./dist/umd/estree-walker.js",
|
||||
"import": "./dist/esm/estree-walker.js"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"prepublishOnly": "npm run build && npm test",
|
||||
"build": "tsc && rollup -c",
|
||||
"test": "uvu test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/estree": "0.0.42",
|
||||
"rollup": "^2.10.9",
|
||||
"typescript": "^3.7.5",
|
||||
"uvu": "^0.5.1"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"types",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
118
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/async.js
generated
vendored
Normal file
118
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/async.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
// @ts-check
|
||||
import { WalkerBase } from './walker.js';
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => Promise<void>} AsyncHandler */
|
||||
|
||||
export class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} enter
|
||||
* @param {AsyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {AsyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
async visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!(await this.visit(value[i], node, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
await this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
35
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/index.js
generated
vendored
Normal file
35
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// @ts-check
|
||||
import { SyncWalker } from './sync.js';
|
||||
import { AsyncWalker } from './async.js';
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
||||
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
export function walk(ast, { enter, leave }) {
|
||||
const instance = new SyncWalker(enter, leave);
|
||||
return instance.visit(ast, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
export async function asyncWalk(ast, { enter, leave }) {
|
||||
const instance = new AsyncWalker(enter, leave);
|
||||
return await instance.visit(ast, null);
|
||||
}
|
||||
1
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/package.json
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type": "module"}
|
||||
118
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/sync.js
generated
vendored
Normal file
118
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/sync.js
generated
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
// @ts-check
|
||||
import { WalkerBase } from './walker.js';
|
||||
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
||||
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => void} SyncHandler */
|
||||
|
||||
export class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} enter
|
||||
* @param {SyncHandler} leave
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {SyncHandler} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
for (const key in node) {
|
||||
const value = node[key];
|
||||
|
||||
if (typeof value !== "object") {
|
||||
continue;
|
||||
} else if (Array.isArray(value)) {
|
||||
for (let i = 0; i < value.length; i += 1) {
|
||||
if (value[i] !== null && typeof value[i].type === 'string') {
|
||||
if (!this.visit(value[i], node, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
61
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/walker.js
generated
vendored
Normal file
61
node_modules/@rollup/plugin-inject/node_modules/estree-walker/src/walker.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// @ts-check
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
}} WalkerContext */
|
||||
|
||||
export class WalkerBase {
|
||||
constructor() {
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {BaseNode | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
53
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/async.d.ts
generated
vendored
Normal file
53
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker').WalkerContext} WalkerContext */
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => Promise<void>} AsyncHandler */
|
||||
export class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} enter
|
||||
* @param {AsyncHandler} leave
|
||||
*/
|
||||
constructor(enter: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>, leave: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>);
|
||||
/** @type {AsyncHandler} */
|
||||
enter: AsyncHandler;
|
||||
/** @type {AsyncHandler} */
|
||||
leave: AsyncHandler;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
visit(node: import("estree").BaseNode, parent: import("estree").BaseNode, prop?: string, index?: number): Promise<import("estree").BaseNode>;
|
||||
should_skip: any;
|
||||
should_remove: any;
|
||||
replacement: any;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
export type AsyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
56
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
56
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./sync.js').SyncHandler} SyncHandler */
|
||||
/** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
export function walk(ast: import("estree").BaseNode, { enter, leave }: {
|
||||
enter?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
leave?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
}): import("estree").BaseNode;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<BaseNode>}
|
||||
*/
|
||||
export function asyncWalk(ast: import("estree").BaseNode, { enter, leave }: {
|
||||
enter?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
leave?: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
}): Promise<import("estree").BaseNode>;
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type SyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
export type AsyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => Promise<void>;
|
||||
53
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/sync.d.ts
generated
vendored
Normal file
53
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef { import('./walker.js').WalkerContext} WalkerContext */
|
||||
/** @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: BaseNode,
|
||||
* parent: BaseNode,
|
||||
* key: string,
|
||||
* index: number
|
||||
* ) => void} SyncHandler */
|
||||
export class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} enter
|
||||
* @param {SyncHandler} leave
|
||||
*/
|
||||
constructor(enter: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void, leave: (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void);
|
||||
/** @type {SyncHandler} */
|
||||
enter: SyncHandler;
|
||||
/** @type {SyncHandler} */
|
||||
leave: SyncHandler;
|
||||
/**
|
||||
*
|
||||
* @param {BaseNode} node
|
||||
* @param {BaseNode} parent
|
||||
* @param {string} [prop]
|
||||
* @param {number} [index]
|
||||
* @returns {BaseNode}
|
||||
*/
|
||||
visit(node: import("estree").BaseNode, parent: import("estree").BaseNode, prop?: string, index?: number): import("estree").BaseNode;
|
||||
should_skip: any;
|
||||
should_remove: any;
|
||||
replacement: any;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
export type SyncHandler = (this: {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
}, node: import("estree").BaseNode, parent: import("estree").BaseNode, key: string, index: number) => void;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
345
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/tsconfig.tsbuildinfo
generated
vendored
Normal file
345
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/tsconfig.tsbuildinfo
generated
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
{
|
||||
"program": {
|
||||
"fileInfos": {
|
||||
"../node_modules/typescript/lib/lib.es5.d.ts": {
|
||||
"version": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea",
|
||||
"signature": "fc43680ad3a1a4ec8c7b8d908af1ec9ddff87845346de5f02c735c9171fa98ea"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.d.ts": {
|
||||
"version": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96",
|
||||
"signature": "7994d44005046d1413ea31d046577cdda33b8b2470f30281fd9c8b3c99fe2d96"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2016.d.ts": {
|
||||
"version": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1",
|
||||
"signature": "5f217838d25704474d9ef93774f04164889169ca31475fe423a9de6758f058d1"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.d.ts": {
|
||||
"version": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743",
|
||||
"signature": "459097c7bdd88fc5731367e56591e4f465f2c9de81a35427a7bd473165c34743"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.dom.d.ts": {
|
||||
"version": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de",
|
||||
"signature": "d93de5e8a7275cb9d47481410e13b3b1debb997e216490954b5d106e37e086de"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.dom.iterable.d.ts": {
|
||||
"version": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf",
|
||||
"signature": "8329c3401aa8708426c7760f14219170f69a2cb77e4519758cec6f5027270faf"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts": {
|
||||
"version": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b",
|
||||
"signature": "fe4e59403e34c7ff747abe4ff6abbc7718229556d7c1a5b93473fb53156c913b"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.scripthost.d.ts": {
|
||||
"version": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9",
|
||||
"signature": "b9faa17292f17d2ad75e34fac77dd63a6403af1dba02d39cd0cbb9ffdf3de8b9"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.core.d.ts": {
|
||||
"version": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6",
|
||||
"signature": "734ddc145e147fbcd55f07d034f50ccff1086f5a880107665ec326fb368876f6"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.collection.d.ts": {
|
||||
"version": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8",
|
||||
"signature": "4a0862a21f4700de873db3b916f70e41570e2f558da77d2087c9490f5a0615d8"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.generator.d.ts": {
|
||||
"version": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122",
|
||||
"signature": "765e0e9c9d74cf4d031ca8b0bdb269a853e7d81eda6354c8510218d03db12122"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts": {
|
||||
"version": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210",
|
||||
"signature": "285958e7699f1babd76d595830207f18d719662a0c30fac7baca7df7162a9210"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.promise.d.ts": {
|
||||
"version": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca",
|
||||
"signature": "d4deaafbb18680e3143e8b471acd650ed6f72a408a33137f0a0dd104fbe7f8ca"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts": {
|
||||
"version": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe",
|
||||
"signature": "5e72f949a89717db444e3bd9433468890068bb21a5638d8ab15a1359e05e54fe"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts": {
|
||||
"version": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976",
|
||||
"signature": "f5b242136ae9bfb1cc99a5971cccc44e99947ae6b5ef6fd8aa54b5ade553b976"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts": {
|
||||
"version": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230",
|
||||
"signature": "9ae2860252d6b5f16e2026d8a2c2069db7b2a3295e98b6031d01337b96437230"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts": {
|
||||
"version": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303",
|
||||
"signature": "3e0a459888f32b42138d5a39f706ff2d55d500ab1031e0988b5568b0f67c2303"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts": {
|
||||
"version": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0",
|
||||
"signature": "3f96f1e570aedbd97bf818c246727151e873125d0512e4ae904330286c721bc0"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.object.d.ts": {
|
||||
"version": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408",
|
||||
"signature": "c2d60b2e558d44384e4704b00e6b3d154334721a911f094d3133c35f0917b408"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts": {
|
||||
"version": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f",
|
||||
"signature": "b8667586a618c5cf64523d4e500ae39e781428abfb28f3de441fc66b56144b6f"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.string.d.ts": {
|
||||
"version": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c",
|
||||
"signature": "21df2e0059f14dcb4c3a0e125859f6b6ff01332ee24b0065a741d121250bc71c"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.intl.d.ts": {
|
||||
"version": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6",
|
||||
"signature": "c1759cb171c7619af0d2234f2f8fb2a871ee88e956e2ed91bb61778e41f272c6"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts": {
|
||||
"version": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46",
|
||||
"signature": "28569d59e07d4378cb3d54979c4c60f9f06305c9bb6999ffe6cab758957adc46"
|
||||
},
|
||||
"../node_modules/typescript/lib/lib.es2017.full.d.ts": {
|
||||
"version": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594",
|
||||
"signature": "873c09f1c309389742d98b7b67419a8e0a5fa6f10ce59fd5149ecd31a2818594"
|
||||
},
|
||||
"../node_modules/@types/estree/index.d.ts": {
|
||||
"version": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644",
|
||||
"signature": "c2efad8a2f2d7fb931ff15c7959fb45340e74684cd665ddf0cbf9b3977be1644"
|
||||
},
|
||||
"../src/walker.js": {
|
||||
"version": "4cc9d0e334d83a4cebeeac502de37a1aeeb953f6d4145a886d9eecea1f2142a7",
|
||||
"signature": "075872468ccc19c83b03fd717fc9305b5f8ec09592210cf60279cb13eca2bd70"
|
||||
},
|
||||
"../src/async.js": {
|
||||
"version": "904efd145090ac40c3c98f29cc928332898a62ab642dd5921db2ae249bfe014a",
|
||||
"signature": "da428f781d6dc6dfd4f4afd0dd5f25a780897dc8b57e5b30462491b7d08f32c0"
|
||||
},
|
||||
"../src/sync.js": {
|
||||
"version": "85bb22b85042f0a3717d8fac2fc8f62af16894652be34d1e08eb3e63785535f5",
|
||||
"signature": "5b131a727db18c956611a5e33d08217df96d0f2e0f26d98b804d1ec2407e59ae"
|
||||
},
|
||||
"../src/index.js": {
|
||||
"version": "99128f4c6cb79cb1e3abf3f2ba96faedd2b820aab4fd7f743aab0b8d710a73af",
|
||||
"signature": "c52be5c79280bfcfcf359c084c6f2f70f405b0ad14dde96b6703dbc5ef2261f5"
|
||||
}
|
||||
},
|
||||
"options": {
|
||||
"allowJs": true,
|
||||
"target": 4,
|
||||
"module": 99,
|
||||
"types": [
|
||||
"estree"
|
||||
],
|
||||
"declaration": true,
|
||||
"declarationDir": "./",
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "./",
|
||||
"newLine": 1,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"incremental": true,
|
||||
"configFilePath": "../tsconfig.json"
|
||||
},
|
||||
"referencedMap": {
|
||||
"../src/walker.js": [
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/async.js": [
|
||||
"../src/walker.js",
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/sync.js": [
|
||||
"../src/walker.js",
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/index.js": [
|
||||
"../src/sync.js",
|
||||
"../src/async.js",
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
]
|
||||
},
|
||||
"exportedModulesMap": {
|
||||
"../src/walker.js": [
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/async.js": [
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/sync.js": [
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
],
|
||||
"../src/index.js": [
|
||||
"../node_modules/@types/estree/index.d.ts"
|
||||
]
|
||||
},
|
||||
"semanticDiagnosticsPerFile": [
|
||||
"../node_modules/typescript/lib/lib.es5.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2016.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.d.ts",
|
||||
"../node_modules/typescript/lib/lib.dom.d.ts",
|
||||
"../node_modules/typescript/lib/lib.dom.iterable.d.ts",
|
||||
"../node_modules/typescript/lib/lib.webworker.importscripts.d.ts",
|
||||
"../node_modules/typescript/lib/lib.scripthost.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.core.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.collection.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.generator.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.iterable.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.promise.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.proxy.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.reflect.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.symbol.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2016.array.include.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.object.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.string.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.intl.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts",
|
||||
"../node_modules/typescript/lib/lib.es2017.full.d.ts",
|
||||
"../node_modules/@types/estree/index.d.ts",
|
||||
"../src/walker.js",
|
||||
[
|
||||
"../src/async.js",
|
||||
[
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 864,
|
||||
"length": 12,
|
||||
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 907,
|
||||
"length": 14,
|
||||
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 954,
|
||||
"length": 12,
|
||||
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 991,
|
||||
"length": 24,
|
||||
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 1021,
|
||||
"length": 26,
|
||||
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 1053,
|
||||
"length": 23,
|
||||
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/async.js",
|
||||
"start": 1643,
|
||||
"length": 9,
|
||||
"code": 7053,
|
||||
"category": 1,
|
||||
"messageText": {
|
||||
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
|
||||
"category": 1,
|
||||
"code": 7053,
|
||||
"next": [
|
||||
{
|
||||
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
|
||||
"category": 1,
|
||||
"code": 7054
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
[
|
||||
"../src/sync.js",
|
||||
[
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 837,
|
||||
"length": 12,
|
||||
"messageText": "'_should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 880,
|
||||
"length": 14,
|
||||
"messageText": "'_should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 927,
|
||||
"length": 12,
|
||||
"messageText": "'_replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 964,
|
||||
"length": 24,
|
||||
"messageText": "'should_skip' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 994,
|
||||
"length": 26,
|
||||
"messageText": "'should_remove' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 1026,
|
||||
"length": 23,
|
||||
"messageText": "'replacement' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.",
|
||||
"category": 1,
|
||||
"code": 7022
|
||||
},
|
||||
{
|
||||
"file": "../src/sync.js",
|
||||
"start": 1610,
|
||||
"length": 9,
|
||||
"code": 7053,
|
||||
"category": 1,
|
||||
"messageText": {
|
||||
"messageText": "Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'BaseNode'.",
|
||||
"category": 1,
|
||||
"code": 7053,
|
||||
"next": [
|
||||
{
|
||||
"messageText": "No index signature with a parameter of type 'string' was found on type 'BaseNode'.",
|
||||
"category": 1,
|
||||
"code": 7054
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
],
|
||||
"../src/index.js"
|
||||
]
|
||||
},
|
||||
"version": "3.7.5"
|
||||
}
|
||||
37
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/walker.d.ts
generated
vendored
Normal file
37
node_modules/@rollup/plugin-inject/node_modules/estree-walker/types/walker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
/** @typedef { import('estree').BaseNode} BaseNode */
|
||||
/** @typedef {{
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
}} WalkerContext */
|
||||
export class WalkerBase {
|
||||
/** @type {boolean} */
|
||||
should_skip: boolean;
|
||||
/** @type {boolean} */
|
||||
should_remove: boolean;
|
||||
/** @type {BaseNode | null} */
|
||||
replacement: BaseNode | null;
|
||||
/** @type {WalkerContext} */
|
||||
context: WalkerContext;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
* @param {BaseNode} node
|
||||
*/
|
||||
replace(parent: any, prop: string, index: number, node: import("estree").BaseNode): void;
|
||||
/**
|
||||
*
|
||||
* @param {any} parent
|
||||
* @param {string} prop
|
||||
* @param {number} index
|
||||
*/
|
||||
remove(parent: any, prop: string, index: number): void;
|
||||
}
|
||||
export type BaseNode = import("estree").BaseNode;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: import("estree").BaseNode) => void;
|
||||
};
|
||||
7
node_modules/@rollup/plugin-inject/node_modules/magic-string/LICENSE
generated
vendored
Normal file
7
node_modules/@rollup/plugin-inject/node_modules/magic-string/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2018 Rich Harris
|
||||
|
||||
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.
|
||||
289
node_modules/@rollup/plugin-inject/node_modules/magic-string/README.md
generated
vendored
Normal file
289
node_modules/@rollup/plugin-inject/node_modules/magic-string/README.md
generated
vendored
Normal file
@@ -0,0 +1,289 @@
|
||||
# magic-string
|
||||
|
||||
<a href="https://travis-ci.org/Rich-Harris/magic-string">
|
||||
<img src="http://img.shields.io/travis/Rich-Harris/magic-string.svg"
|
||||
alt="build status">
|
||||
</a>
|
||||
<a href="https://npmjs.org/package/magic-string">
|
||||
<img src="https://img.shields.io/npm/v/magic-string.svg"
|
||||
alt="npm version">
|
||||
</a>
|
||||
<a href="https://github.com/Rich-Harris/magic-string/blob/master/LICENSE.md">
|
||||
<img src="https://img.shields.io/npm/l/magic-string.svg"
|
||||
alt="license">
|
||||
</a>
|
||||
|
||||
Suppose you have some source code. You want to make some light modifications to it - replacing a few characters here and there, wrapping it with a header and footer, etc - and ideally you'd like to generate a [source map](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/) at the end of it. You've thought about using something like [recast](https://github.com/benjamn/recast) (which allows you to generate an AST from some JavaScript, manipulate it, and reprint it with a sourcemap without losing your comments and formatting), but it seems like overkill for your needs (or maybe the source code isn't JavaScript).
|
||||
|
||||
Your requirements are, frankly, rather niche. But they're requirements that I also have, and for which I made magic-string. It's a small, fast utility for manipulating strings and generating sourcemaps.
|
||||
|
||||
## Installation
|
||||
|
||||
magic-string works in both node.js and browser environments. For node, install with npm:
|
||||
|
||||
```bash
|
||||
npm i magic-string
|
||||
```
|
||||
|
||||
To use in browser, grab the [magic-string.umd.js](https://unpkg.com/magic-string/dist/magic-string.umd.js) file and add it to your page:
|
||||
|
||||
```html
|
||||
<script src='magic-string.umd.js'></script>
|
||||
```
|
||||
|
||||
(It also works with various module systems, if you prefer that sort of thing - it has a dependency on [vlq](https://github.com/Rich-Harris/vlq).)
|
||||
|
||||
## Usage
|
||||
|
||||
These examples assume you're in node.js, or something similar:
|
||||
|
||||
```js
|
||||
import MagicString from 'magic-string';
|
||||
import fs from 'fs'
|
||||
|
||||
const s = new MagicString('problems = 99');
|
||||
|
||||
s.update(0, 8, 'answer');
|
||||
s.toString(); // 'answer = 99'
|
||||
|
||||
s.update(11, 13, '42'); // character indices always refer to the original string
|
||||
s.toString(); // 'answer = 42'
|
||||
|
||||
s.prepend('var ').append(';'); // most methods are chainable
|
||||
s.toString(); // 'var answer = 42;'
|
||||
|
||||
const map = s.generateMap({
|
||||
source: 'source.js',
|
||||
file: 'converted.js.map',
|
||||
includeContent: true
|
||||
}); // generates a v3 sourcemap
|
||||
|
||||
fs.writeFileSync('converted.js', s.toString());
|
||||
fs.writeFileSync('converted.js.map', map.toString());
|
||||
```
|
||||
|
||||
You can pass an options argument:
|
||||
|
||||
```js
|
||||
const s = new MagicString(someCode, {
|
||||
// both these options will be used if you later
|
||||
// call `bundle.addSource( s )` - see below
|
||||
filename: 'foo.js',
|
||||
indentExclusionRanges: [/*...*/]
|
||||
});
|
||||
```
|
||||
|
||||
## Methods
|
||||
|
||||
### s.addSourcemapLocation( index )
|
||||
|
||||
Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is `false` (see below).
|
||||
|
||||
### s.append( content )
|
||||
|
||||
Appends the specified content to the end of the string. Returns `this`.
|
||||
|
||||
### s.appendLeft( index, content )
|
||||
|
||||
Appends the specified `content` at the `index` in the original string. If a range *ending* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependLeft(...)`.
|
||||
|
||||
### s.appendRight( index, content )
|
||||
|
||||
Appends the specified `content` at the `index` in the original string. If a range *starting* with `index` is subsequently moved, the insert will be moved with it. Returns `this`. See also `s.prependRight(...)`.
|
||||
|
||||
### s.clone()
|
||||
|
||||
Does what you'd expect.
|
||||
|
||||
### s.generateDecodedMap( options )
|
||||
|
||||
Generates a sourcemap object with raw mappings in array form, rather than encoded as a string. See `generateMap` documentation below for options details. Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
||||
|
||||
### s.generateMap( options )
|
||||
|
||||
Generates a [version 3 sourcemap](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit). All options are, well, optional:
|
||||
|
||||
* `file` - the filename where you plan to write the sourcemap
|
||||
* `source` - the filename of the file containing the original source
|
||||
* `includeContent` - whether to include the original content in the map's `sourcesContent` array
|
||||
* `hires` - whether the mapping should be high-resolution. Hi-res mappings map every single character, meaning (for example) your devtools will always be able to pinpoint the exact location of function calls and so on. With lo-res mappings, devtools may only be able to identify the correct line - but they're quicker to generate and less bulky. If sourcemap locations have been specified with `s.addSourceMapLocation()`, they will be used here.
|
||||
|
||||
The returned sourcemap has two (non-enumerable) methods attached for convenience:
|
||||
|
||||
* `toString` - returns the equivalent of `JSON.stringify(map)`
|
||||
* `toUrl` - returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
||||
|
||||
```js
|
||||
code += '\n//# sourceMappingURL=' + map.toUrl();
|
||||
```
|
||||
|
||||
### s.hasChanged()
|
||||
|
||||
Indicates if the string has been changed.
|
||||
|
||||
### s.indent( prefix[, options] )
|
||||
|
||||
Prefixes each line of the string with `prefix`. If `prefix` is not supplied, the indentation will be guessed from the original content, falling back to a single tab character. Returns `this`.
|
||||
|
||||
The `options` argument can have an `exclude` property, which is an array of `[start, end]` character ranges. These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
|
||||
|
||||
### s.insertLeft( index, content )
|
||||
|
||||
**DEPRECATED** since 0.17 – use `s.appendLeft(...)` instead
|
||||
|
||||
### s.insertRight( index, content )
|
||||
|
||||
**DEPRECATED** since 0.17 – use `s.prependRight(...)` instead
|
||||
|
||||
### s.isEmpty()
|
||||
|
||||
Returns true if the resulting source is empty (disregarding white space).
|
||||
|
||||
### s.locate( index )
|
||||
|
||||
**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30)
|
||||
|
||||
### s.locateOrigin( index )
|
||||
|
||||
**DEPRECATED** since 0.10 – see [#30](https://github.com/Rich-Harris/magic-string/pull/30)
|
||||
|
||||
### s.move( start, end, index )
|
||||
|
||||
Moves the characters from `start` and `end` to `index`. Returns `this`.
|
||||
|
||||
### s.overwrite( start, end, content[, options] )
|
||||
|
||||
Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in that range. The same restrictions as `s.remove()` apply. Returns `this`.
|
||||
|
||||
The fourth argument is optional. It can have a `storeName` property — if `true`, the original name will be stored for later inclusion in a sourcemap's `names` array — and a `contentOnly` property which determines whether only the content is overwritten, or anything that was appended/prepended to the range as well.
|
||||
|
||||
It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
||||
|
||||
### s.prepend( content )
|
||||
|
||||
Prepends the string with the specified content. Returns `this`.
|
||||
|
||||
### s.prependLeft ( index, content )
|
||||
|
||||
Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||||
|
||||
### s.prependRight ( index, content )
|
||||
|
||||
Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||||
|
||||
### s.replace( regexpOrString, substitution )
|
||||
|
||||
String replacement with RegExp or string. When using a RegExp, replacer function is also supported. Returns `this`.
|
||||
|
||||
```ts
|
||||
import MagicString from 'magic-string'
|
||||
|
||||
const s = new MagicString(source)
|
||||
|
||||
s.replace('foo', 'bar')
|
||||
s.replace(/foo/g, 'bar')
|
||||
s.replace(/(\w)(\d+)/g, (_, $1, $2) => $1.toUpperCase() + $2)
|
||||
```
|
||||
|
||||
The differences from [`String.replace`]((https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace)):
|
||||
- It will always match against the **original string**
|
||||
- It mutates the magic string state (use `.clone()` to be immutable)
|
||||
|
||||
### s.replaceAll( regexpOrString, substitution )
|
||||
|
||||
Same as `s.replace`, but replace all matched strings instead of just one.
|
||||
If `substitution` is a regex, then it must have the global (`g`) flag set, or a `TypeError` is thrown. Matches the behavior of the bultin [`String.property.replaceAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll).
|
||||
|
||||
### s.remove( start, end )
|
||||
|
||||
Removes the characters from `start` to `end` (of the original string, **not** the generated string). Removing the same content twice, or making removals that partially overlap, will cause an error. Returns `this`.
|
||||
|
||||
### s.slice( start, end )
|
||||
|
||||
Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string. Throws error if the indices are for characters that were already removed.
|
||||
|
||||
### s.snip( start, end )
|
||||
|
||||
Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
||||
|
||||
### s.toString()
|
||||
|
||||
Returns the generated string.
|
||||
|
||||
### s.trim([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end. Returns `this`.
|
||||
|
||||
### s.trimStart([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start. Returns `this`.
|
||||
|
||||
### s.trimEnd([ charType ])
|
||||
|
||||
Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end. Returns `this`.
|
||||
|
||||
### s.trimLines()
|
||||
|
||||
Removes empty lines from the start and end. Returns `this`.
|
||||
|
||||
### s.update( start, end, content[, options] )
|
||||
|
||||
Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply. Returns `this`.
|
||||
|
||||
The fourth argument is optional. It can have a `storeName` property — if `true`, the original name will be stored for later inclusion in a sourcemap's `names` array — and an `overwrite` property which defaults to `false` and determines whether anything that was appended/prepended to the range will be overwritten along with the original content.
|
||||
|
||||
`s.update(start, end, content)` is equivalent to `s.overwrite(start, end, content, { contentOnly: true })`.
|
||||
|
||||
## Bundling
|
||||
|
||||
To concatenate several sources, use `MagicString.Bundle`:
|
||||
|
||||
```js
|
||||
const bundle = new MagicString.Bundle();
|
||||
|
||||
bundle.addSource({
|
||||
filename: 'foo.js',
|
||||
content: new MagicString('var answer = 42;')
|
||||
});
|
||||
|
||||
bundle.addSource({
|
||||
filename: 'bar.js',
|
||||
content: new MagicString('console.log( answer )')
|
||||
});
|
||||
|
||||
// Advanced: a source can include an `indentExclusionRanges` property
|
||||
// alongside `filename` and `content`. This will be passed to `s.indent()`
|
||||
// - see documentation above
|
||||
|
||||
bundle.indent() // optionally, pass an indent string, otherwise it will be guessed
|
||||
.prepend('(function () {\n')
|
||||
.append('}());');
|
||||
|
||||
bundle.toString();
|
||||
// (function () {
|
||||
// var answer = 42;
|
||||
// console.log( answer );
|
||||
// }());
|
||||
|
||||
// options are as per `s.generateMap()` above
|
||||
const map = bundle.generateMap({
|
||||
file: 'bundle.js',
|
||||
includeContent: true,
|
||||
hires: true
|
||||
});
|
||||
```
|
||||
|
||||
As an alternative syntax, if you a) don't have `filename` or `indentExclusionRanges` options, or b) passed those in when you used `new MagicString(...)`, you can simply pass the `MagicString` instance itself:
|
||||
|
||||
```js
|
||||
const bundle = new MagicString.Bundle();
|
||||
const source = new MagicString(someCode, {
|
||||
filename: 'foo.js'
|
||||
});
|
||||
|
||||
bundle.addSource(source);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
1431
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.cjs.js
generated
vendored
Normal file
1431
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.cjs.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.cjs.js.map
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.cjs.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1425
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.es.mjs
generated
vendored
Normal file
1425
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.es.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.es.mjs.map
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.es.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1523
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.umd.js
generated
vendored
Normal file
1523
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.umd.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.umd.js.map
generated
vendored
Normal file
1
node_modules/@rollup/plugin-inject/node_modules/magic-string/dist/magic-string.umd.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
250
node_modules/@rollup/plugin-inject/node_modules/magic-string/index.d.ts
generated
vendored
Normal file
250
node_modules/@rollup/plugin-inject/node_modules/magic-string/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
export interface BundleOptions {
|
||||
intro?: string;
|
||||
separator?: string;
|
||||
}
|
||||
|
||||
export interface SourceMapOptions {
|
||||
/**
|
||||
* Whether the mapping should be high-resolution.
|
||||
* Hi-res mappings map every single character, meaning (for example) your devtools will always
|
||||
* be able to pinpoint the exact location of function calls and so on.
|
||||
* With lo-res mappings, devtools may only be able to identify the correct
|
||||
* line - but they're quicker to generate and less bulky.
|
||||
* If sourcemap locations have been specified with s.addSourceMapLocation(), they will be used here.
|
||||
*/
|
||||
hires?: boolean;
|
||||
/**
|
||||
* The filename where you plan to write the sourcemap.
|
||||
*/
|
||||
file?: string;
|
||||
/**
|
||||
* The filename of the file containing the original source.
|
||||
*/
|
||||
source?: string;
|
||||
/**
|
||||
* Whether to include the original content in the map's sourcesContent array.
|
||||
*/
|
||||
includeContent?: boolean;
|
||||
}
|
||||
|
||||
export type SourceMapSegment =
|
||||
| [number]
|
||||
| [number, number, number, number]
|
||||
| [number, number, number, number, number];
|
||||
|
||||
export interface DecodedSourceMap {
|
||||
file: string;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
names: string[];
|
||||
mappings: SourceMapSegment[][];
|
||||
}
|
||||
|
||||
export class SourceMap {
|
||||
constructor(properties: DecodedSourceMap);
|
||||
|
||||
version: number;
|
||||
file: string;
|
||||
sources: string[];
|
||||
sourcesContent: string[];
|
||||
names: string[];
|
||||
mappings: string;
|
||||
|
||||
/**
|
||||
* Returns the equivalent of `JSON.stringify(map)`
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
|
||||
* `generateMap(options?: SourceMapOptions): SourceMap;`
|
||||
*/
|
||||
toUrl(): string;
|
||||
}
|
||||
|
||||
export class Bundle {
|
||||
constructor(options?: BundleOptions);
|
||||
addSource(source: MagicString | { filename?: string, content: MagicString }): Bundle;
|
||||
append(str: string, options?: BundleOptions): Bundle;
|
||||
clone(): Bundle;
|
||||
generateMap(options?: SourceMapOptions): SourceMap;
|
||||
generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
|
||||
getIndentString(): string;
|
||||
indent(indentStr?: string): Bundle;
|
||||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||||
prepend(str: string): Bundle;
|
||||
toString(): string;
|
||||
trimLines(): Bundle;
|
||||
trim(charType?: string): Bundle;
|
||||
trimStart(charType?: string): Bundle;
|
||||
trimEnd(charType?: string): Bundle;
|
||||
isEmpty(): boolean;
|
||||
length(): number;
|
||||
}
|
||||
|
||||
export type ExclusionRange = [ number, number ];
|
||||
|
||||
export interface MagicStringOptions {
|
||||
filename?: string,
|
||||
indentExclusionRanges?: ExclusionRange | Array<ExclusionRange>;
|
||||
}
|
||||
|
||||
export interface IndentOptions {
|
||||
exclude?: ExclusionRange | Array<ExclusionRange>;
|
||||
indentStart?: boolean;
|
||||
}
|
||||
|
||||
export interface OverwriteOptions {
|
||||
storeName?: boolean;
|
||||
contentOnly?: boolean;
|
||||
}
|
||||
|
||||
export interface UpdateOptions {
|
||||
storeName?: boolean;
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
export default class MagicString {
|
||||
constructor(str: string, options?: MagicStringOptions);
|
||||
/**
|
||||
* Adds the specified character index (with respect to the original string) to sourcemap mappings, if `hires` is false.
|
||||
*/
|
||||
addSourcemapLocation(char: number): void;
|
||||
/**
|
||||
* Appends the specified content to the end of the string.
|
||||
*/
|
||||
append(content: string): MagicString;
|
||||
/**
|
||||
* Appends the specified content at the index in the original string.
|
||||
* If a range *ending* with index is subsequently moved, the insert will be moved with it.
|
||||
* See also `s.prependLeft(...)`.
|
||||
*/
|
||||
appendLeft(index: number, content: string): MagicString;
|
||||
/**
|
||||
* Appends the specified content at the index in the original string.
|
||||
* If a range *starting* with index is subsequently moved, the insert will be moved with it.
|
||||
* See also `s.prependRight(...)`.
|
||||
*/
|
||||
appendRight(index: number, content: string): MagicString;
|
||||
/**
|
||||
* Does what you'd expect.
|
||||
*/
|
||||
clone(): MagicString;
|
||||
/**
|
||||
* Generates a version 3 sourcemap.
|
||||
*/
|
||||
generateMap(options?: SourceMapOptions): SourceMap;
|
||||
/**
|
||||
* Generates a sourcemap object with raw mappings in array form, rather than encoded as a string.
|
||||
* Useful if you need to manipulate the sourcemap further, but most of the time you will use `generateMap` instead.
|
||||
*/
|
||||
generateDecodedMap(options?: SourceMapOptions): DecodedSourceMap;
|
||||
getIndentString(): string;
|
||||
|
||||
/**
|
||||
* Prefixes each line of the string with prefix.
|
||||
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
||||
*/
|
||||
indent(options?: IndentOptions): MagicString;
|
||||
/**
|
||||
* Prefixes each line of the string with prefix.
|
||||
* If prefix is not supplied, the indentation will be guessed from the original content, falling back to a single tab character.
|
||||
*
|
||||
* The options argument can have an exclude property, which is an array of [start, end] character ranges.
|
||||
* These ranges will be excluded from the indentation - useful for (e.g.) multiline strings.
|
||||
*/
|
||||
indent(indentStr?: string, options?: IndentOptions): MagicString;
|
||||
indentExclusionRanges: ExclusionRange | Array<ExclusionRange>;
|
||||
|
||||
/**
|
||||
* Moves the characters from `start and `end` to `index`.
|
||||
*/
|
||||
move(start: number, end: number, index: number): MagicString;
|
||||
/**
|
||||
* Replaces the characters from `start` to `end` with `content`, along with the appended/prepended content in
|
||||
* that range. The same restrictions as `s.remove()` apply.
|
||||
*
|
||||
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
||||
* for later inclusion in a sourcemap's names array — and a contentOnly property which determines whether only
|
||||
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
||||
*
|
||||
* It may be preferred to use `s.update(...)` instead if you wish to avoid overwriting the appended/prepended content.
|
||||
*/
|
||||
overwrite(start: number, end: number, content: string, options?: boolean | OverwriteOptions): MagicString;
|
||||
/**
|
||||
* Replaces the characters from `start` to `end` with `content`. The same restrictions as `s.remove()` apply.
|
||||
*
|
||||
* The fourth argument is optional. It can have a storeName property — if true, the original name will be stored
|
||||
* for later inclusion in a sourcemap's names array — and an overwrite property which determines whether only
|
||||
* the content is overwritten, or anything that was appended/prepended to the range as well.
|
||||
*/
|
||||
update(start: number, end: number, content: string, options?: boolean | UpdateOptions): MagicString;
|
||||
/**
|
||||
* Prepends the string with the specified content.
|
||||
*/
|
||||
prepend(content: string): MagicString;
|
||||
/**
|
||||
* Same as `s.appendLeft(...)`, except that the inserted content will go *before* any previous appends or prepends at index
|
||||
*/
|
||||
prependLeft(index: number, content: string): MagicString;
|
||||
/**
|
||||
* Same as `s.appendRight(...)`, except that the inserted content will go *before* any previous appends or prepends at `index`
|
||||
*/
|
||||
prependRight(index: number, content: string): MagicString;
|
||||
/**
|
||||
* Removes the characters from `start` to `end` (of the original string, **not** the generated string).
|
||||
* Removing the same content twice, or making removals that partially overlap, will cause an error.
|
||||
*/
|
||||
remove(start: number, end: number): MagicString;
|
||||
/**
|
||||
* Returns the content of the generated string that corresponds to the slice between `start` and `end` of the original string.
|
||||
* Throws error if the indices are for characters that were already removed.
|
||||
*/
|
||||
slice(start: number, end: number): string;
|
||||
/**
|
||||
* Returns a clone of `s`, with all content before the `start` and `end` characters of the original string removed.
|
||||
*/
|
||||
snip(start: number, end: number): MagicString;
|
||||
/**
|
||||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start and end.
|
||||
*/
|
||||
trim(charType?: string): MagicString;
|
||||
/**
|
||||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the start.
|
||||
*/
|
||||
trimStart(charType?: string): MagicString;
|
||||
/**
|
||||
* Trims content matching `charType` (defaults to `\s`, i.e. whitespace) from the end.
|
||||
*/
|
||||
trimEnd(charType?: string): MagicString;
|
||||
/**
|
||||
* Removes empty lines from the start and end.
|
||||
*/
|
||||
trimLines(): MagicString;
|
||||
/**
|
||||
* String replacement with RegExp or string.
|
||||
*/
|
||||
replace(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): MagicString;
|
||||
/**
|
||||
* Same as `s.replace`, but replace all matched strings instead of just one.
|
||||
*/
|
||||
replaceAll(regex: RegExp | string, replacement: string | ((substring: string, ...args: any[]) => string)): MagicString;
|
||||
|
||||
lastChar(): string;
|
||||
lastLine(): string;
|
||||
/**
|
||||
* Returns true if the resulting source is empty (disregarding white space).
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
length(): number;
|
||||
|
||||
/**
|
||||
* Indicates if the string has been changed.
|
||||
*/
|
||||
hasChanged(): boolean;
|
||||
|
||||
original: string;
|
||||
/**
|
||||
* Returns the generated string.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
64
node_modules/@rollup/plugin-inject/node_modules/magic-string/package.json
generated
vendored
Normal file
64
node_modules/@rollup/plugin-inject/node_modules/magic-string/package.json
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"name": "magic-string",
|
||||
"version": "0.27.0",
|
||||
"description": "Modify strings, generate sourcemaps",
|
||||
"keywords": [
|
||||
"string",
|
||||
"string manipulation",
|
||||
"sourcemap",
|
||||
"templating",
|
||||
"transpilation"
|
||||
],
|
||||
"repository": "https://github.com/rich-harris/magic-string",
|
||||
"license": "MIT",
|
||||
"author": "Rich Harris",
|
||||
"main": "./dist/magic-string.cjs.js",
|
||||
"module": "./dist/magic-string.es.mjs",
|
||||
"jsnext:main": "./dist/magic-string.es.mjs",
|
||||
"types": "./index.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": "./dist/magic-string.es.mjs",
|
||||
"require": "./dist/magic-string.cjs.js",
|
||||
"types": "./index.d.ts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/*",
|
||||
"index.d.ts",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
||||
"format": "prettier --single-quote --print-width 100 --use-tabs --write src/*.js src/**/*.js",
|
||||
"lint": "eslint src test",
|
||||
"prepare": "npm run build",
|
||||
"prepublishOnly": "rm -rf dist && npm test",
|
||||
"release": "bumpp -x \"npm run changelog\" --all --commit --tag --push && npm publish",
|
||||
"pretest": "npm run lint && npm run build",
|
||||
"test": "mocha",
|
||||
"bench": "npm run build && node benchmark/index.mjs",
|
||||
"watch": "rollup -cw"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-node-resolve": "^14.1.0",
|
||||
"@rollup/plugin-replace": "^4.0.0",
|
||||
"benchmark": "^2.1.4",
|
||||
"bumpp": "^8.2.1",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"eslint": "^8.23.1",
|
||||
"mocha": "^10.0.0",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup": "^2.79.1",
|
||||
"source-map-js": "^1.0.2",
|
||||
"source-map-support": "^0.5.21"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.13"
|
||||
}
|
||||
}
|
||||
85
node_modules/@rollup/plugin-inject/package.json
generated
vendored
Normal file
85
node_modules/@rollup/plugin-inject/package.json
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"name": "@rollup/plugin-inject",
|
||||
"version": "5.0.3",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "Scan modules for global variables and injects `import` statements where necessary",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/inject"
|
||||
},
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/inject#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"
|
||||
},
|
||||
"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",
|
||||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build",
|
||||
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"!dist/**/*.map",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"inject",
|
||||
"es2015",
|
||||
"npm",
|
||||
"modules"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"rollup": "^1.20.0||^2.0.0||^3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"rollup": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@rollup/pluginutils": "^5.0.1",
|
||||
"estree-walker": "^2.0.2",
|
||||
"magic-string": "^0.27.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-buble": "^1.0.0",
|
||||
"del-cli": "^5.0.0",
|
||||
"locate-character": "^2.0.5",
|
||||
"rollup": "^3.2.3",
|
||||
"source-map": "^0.7.4",
|
||||
"typescript": "^4.8.3"
|
||||
},
|
||||
"types": "./types/index.d.ts",
|
||||
"ava": {
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
42
node_modules/@rollup/plugin-inject/types/index.d.ts
generated
vendored
Normal file
42
node_modules/@rollup/plugin-inject/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import type { Plugin } from 'rollup';
|
||||
|
||||
type Injectment = string | [string, string];
|
||||
|
||||
export interface RollupInjectOptions {
|
||||
/**
|
||||
* All other options are treated as `string: injectment` injectrs,
|
||||
* or `string: (id) => injectment` functions.
|
||||
*/
|
||||
[str: string]:
|
||||
| Injectment
|
||||
| RollupInjectOptions['include']
|
||||
| RollupInjectOptions['sourceMap']
|
||||
| RollupInjectOptions['modules'];
|
||||
|
||||
/**
|
||||
* 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?: string | RegExp | ReadonlyArray<string | RegExp> | null;
|
||||
|
||||
/**
|
||||
* Files that should be excluded, if `include` is otherwise too permissive.
|
||||
*/
|
||||
exclude?: string | RegExp | ReadonlyArray<string | RegExp> | null;
|
||||
|
||||
/**
|
||||
* If false, skips source map generation. This will improve performance.
|
||||
* @default true
|
||||
*/
|
||||
sourceMap?: boolean;
|
||||
|
||||
/**
|
||||
* You can separate values to inject from other options.
|
||||
*/
|
||||
modules?: { [str: string]: Injectment };
|
||||
}
|
||||
|
||||
/**
|
||||
* inject strings in files while bundling them.
|
||||
*/
|
||||
export default function inject(options?: RollupInjectOptions): Plugin;
|
||||
Reference in New Issue
Block a user