docs:更新文档

This commit is contained in:
张益铭
2021-03-01 15:06:11 +08:00
parent 1542135ab0
commit 9064b372e8
5835 changed files with 904126 additions and 161722 deletions

125
node_modules/rollup-pluginutils/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,125 @@
# rollup-pluginutils changelog
## 2.8.2
*2019-09-13*
* Handle optional catch parameter in attachScopes ([#70](https://github.com/rollup/rollup-pluginutils/pulls/70))
## 2.8.1
*2019-06-04*
* Support serialization of many edge cases ([#64](https://github.com/rollup/rollup-pluginutils/issues/64))
## 2.8.0
*2019-05-30*
* Bundle updated micromatch dependency ([#60](https://github.com/rollup/rollup-pluginutils/issues/60))
## 2.7.1
*2019-05-17*
* Do not ignore files with a leading "." in createFilter ([#62](https://github.com/rollup/rollup-pluginutils/issues/62))
## 2.7.0
*2019-05-15*
* Add `resolve` option to createFilter ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
## 2.6.0
*2019-04-04*
* Add `extractAssignedNames` ([#59](https://github.com/rollup/rollup-pluginutils/issues/59))
* Provide dedicated TypeScript typings file ([#58](https://github.com/rollup/rollup-pluginutils/issues/58))
## 2.5.0
*2019-03-18*
* Generalize dataToEsm type ([#55](https://github.com/rollup/rollup-pluginutils/issues/55))
* Handle empty keys in dataToEsm ([#56](https://github.com/rollup/rollup-pluginutils/issues/56))
## 2.4.1
*2019-02-16*
* Remove unnecessary dependency
## 2.4.0
*2019-02-16*
Update dependencies to solve micromatch vulnerability ([#53](https://github.com/rollup/rollup-pluginutils/issues/53))
## 2.3.3
*2018-09-19*
* Revert micromatch update ([#43](https://github.com/rollup/rollup-pluginutils/issues/43))
## 2.3.2
*2018-09-18*
* Bumb micromatch dependency ([#36](https://github.com/rollup/rollup-pluginutils/issues/36))
* Bumb dependencies ([#41](https://github.com/rollup/rollup-pluginutils/issues/41))
* Split up tests ([#40](https://github.com/rollup/rollup-pluginutils/issues/40))
## 2.3.1
*2018-08-06*
* Fixed ObjectPattern scope in attachScopes to recognise { ...rest } syntax ([#37](https://github.com/rollup/rollup-pluginutils/issues/37))
## 2.3.0
*2018-05-21*
* Add option to not generate named exports ([#32](https://github.com/rollup/rollup-pluginutils/issues/32))
## 2.2.1
*2018-05-21*
* Support `null` serialization ([#34](https://github.com/rollup/rollup-pluginutils/issues/34))
## 2.2.0
*2018-05-11*
* Improve white-space handling in `dataToEsm` and add `prepare` script ([#31](https://github.com/rollup/rollup-pluginutils/issues/31))
## 2.1.1
*2018-05-09*
* Update dependencies
## 2.1.0
*2018-05-08*
* Add `dataToEsm` helper to create named exports from objects ([#29](https://github.com/rollup/rollup-pluginutils/issues/29))
* Support literal keys in object patterns ([#27](https://github.com/rollup/rollup-pluginutils/issues/27))
* Support function declarations without id in `attachScopes` ([#28](https://github.com/rollup/rollup-pluginutils/issues/28))
## 2.0.1
*2017-01-03*
* Don't add extension to file with trailing dot ([#14](https://github.com/rollup/rollup-pluginutils/issues/14))
## 2.0.0
*2017-01-03*
* Use `micromatch` instead of `minimatch` ([#19](https://github.com/rollup/rollup-pluginutils/issues/19))
* Allow `createFilter` to take regexes ([#5](https://github.com/rollup/rollup-pluginutils/issues/5))
## 1.5.2
*2016-08-29*
* Treat `arguments` as a reserved word ([#10](https://github.com/rollup/rollup-pluginutils/issues/10))
## 1.5.1
*2016-06-24*
* Add all declarators in a var declaration to scope, not just the first
## 1.5.0
*2016-06-07*
* Exclude IDs with null character (`\0`)
## 1.4.0
*2016-06-07*
* Workaround minimatch issue ([#6](https://github.com/rollup/rollup-pluginutils/pull/6))
* Exclude non-string IDs in `createFilter`
## 1.3.1
*2015-12-16*
* Build with Rollup directly, rather than via Gobble
## 1.3.0
*2015-12-16*
* Use correct path separator on Windows
## 1.2.0
*2015-11-02*
* Add `attachScopes` and `makeLegalIdentifier`
## 1.1.0
2015-10-24*
* Add `addExtension` function
## 1.0.1
*2015-10-24*
* Include dist files in package
## 1.0.0
*2015-10-24*
* First release

169
node_modules/rollup-pluginutils/README.md generated vendored Normal file
View File

@@ -0,0 +1,169 @@
# rollup-pluginutils
A set of functions commonly used by Rollup plugins.
## Installation
```bash
npm install --save rollup-pluginutils
```
## Usage
### addExtension
```js
import { addExtension } from 'rollup-pluginutils';
export default function myPlugin ( options = {} ) {
return {
resolveId ( code, id ) {
// only adds an extension if there isn't one already
id = addExtension( id ); // `foo` -> `foo.js`, `foo.js -> foo.js`
id = addExtension( id, '.myext' ); // `foo` -> `foo.myext`, `foo.js -> `foo.js`
}
};
}
```
### attachScopes
This function attaches `Scope` objects to the relevant nodes of an AST. Each `Scope` object has a `scope.contains(name)` method that returns `true` if a given name is defined in the current scope or a parent scope.
See [rollup-plugin-inject](https://github.com/rollup/rollup-plugin-inject) or [rollup-plugin-commonjs](https://github.com/rollup/rollup-plugin-commonjs) for an example of usage.
```js
import { attachScopes } from 'rollup-pluginutils';
import { walk } from 'estree-walker';
export default function myPlugin ( options = {} ) {
return {
transform ( code ) {
const ast = this.parse( code );
let scope = attachScopes( ast, 'scope' );
walk( ast, {
enter ( node ) {
if ( node.scope ) scope = node.scope;
if ( !scope.contains( 'foo' ) ) {
// `foo` is not defined, so if we encounter it,
// we assume it's a global
}
},
leave ( node ) {
if ( node.scope ) scope = scope.parent;
}
});
}
};
}
```
### createFilter
```js
import { createFilter } from 'rollup-pluginutils';
export default function myPlugin ( options = {} ) {
// `options.include` and `options.exclude` can each be a minimatch
// pattern, or an array of minimatch patterns, relative to process.cwd()
var filter = createFilter( options.include, options.exclude );
return {
transform ( code, id ) {
// if `options.include` is omitted or has zero length, filter
// will return `true` by default. Otherwise, an ID must match
// one or more of the minimatch patterns, and must not match
// any of the `options.exclude` patterns.
if ( !filter( id ) ) return;
// proceed with the transformation...
}
};
}
```
If you want to resolve the patterns against a directory other than
`process.cwd()`, you can additionally pass a `resolve` option:
```js
var filter = createFilter( options.include, options.exclude, {resolve: '/my/base/dir'} )
```
If `resolve` is a string, then this value will be used as the base directory.
Relative paths will be resolved against `process.cwd()` first. If `resolve` is
`false`, then the patterns will not be resolved against any directory. This can
be useful if you want to create a filter for virtual module names.
### makeLegalIdentifier
```js
import { makeLegalIdentifier } from 'rollup-pluginutils';
makeLegalIdentifier( 'foo-bar' ); // 'foo_bar'
makeLegalIdentifier( 'typeof' ); // '_typeof'
```
### dataToEsm
Helper for treeshakable data imports
```js
import { dataToEsm } from 'rollup-pluginutils';
const esModuleSource = dataToEsm({
custom: 'data',
to: ['treeshake']
}, {
compact: false,
indent: '\t',
preferConst: false,
objectShorthand: false,
namedExports: true
});
/*
Outputs the string ES module source:
export const custom = 'data';
export const to = ['treeshake'];
export default { custom, to };
*/
```
### extractAssignedNames
Extract the names of all assignment targets from patterns.
```js
import { extractAssignedNames } from 'rollup-pluginutils';
import { walk } from 'estree-walker';
export default function myPlugin ( options = {} ) {
return {
transform ( code ) {
const ast = this.parse( code );
walk( ast, {
enter ( node ) {
if ( node.type === 'VariableDeclarator' ) {
const declaredNames = extractAssignedNames(node.id);
// do something with the declared names
// e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z']
}
}
});
}
};
}
```
## License
MIT

3292
node_modules/rollup-pluginutils/dist/pluginutils.cjs.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

39
node_modules/rollup-pluginutils/dist/pluginutils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { Node } from 'estree-walker';
export interface AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void;
contains(name: string): boolean;
}
export interface DataToEsmOptions {
compact?: boolean;
indent?: string;
namedExports?: boolean;
objectShorthand?: boolean;
preferConst?: boolean;
}
export type AddExtension = (filename: string, ext?: string) => string;
export const addExtension: AddExtension;
export type AttachScopes = (ast: Node, propertyName?: string) => AttachedScope;
export const attachScopes: AttachScopes;
export type CreateFilter = (
include?: Array<string | RegExp> | string | RegExp | null,
exclude?: Array<string | RegExp> | string | RegExp | null,
options?: { resolve?: string | false | null }
) => (id: string | any) => boolean;
export const createFilter: CreateFilter;
export type MakeLegalIdentifier = (str: string) => string;
export const makeLegalIdentifier: MakeLegalIdentifier;
export type DataToEsm = (data: any, options?: DataToEsmOptions) => string;
export const dataToEsm: DataToEsm;
export type ExtractAssignedNames = (param: Node) => Array<string>;
export const extractAssignedNames: ExtractAssignedNames;

3280
node_modules/rollup-pluginutils/dist/pluginutils.es.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
# changelog
## 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

View File

@@ -0,0 +1,45 @@
# 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.
## 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

View File

@@ -0,0 +1,65 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.estreeWalker = {})));
}(this, (function (exports) { 'use strict';
function walk(ast, { enter, leave }) {
visit(ast, null, enter, leave);
}
let shouldSkip = false;
const context = { skip: () => shouldSkip = true };
const childKeys = {};
const toString = Object.prototype.toString;
function isArray(thing) {
return toString.call(thing) === '[object Array]';
}
function visit(node, parent, enter, leave, prop, index) {
if (!node) return;
if (enter) {
const _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call(context, node, parent, prop, index);
const skipped = shouldSkip;
shouldSkip = _shouldSkip;
if (skipped) return;
}
const keys = node.type && childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
const value = node[key];
if (isArray(value)) {
for (let j = 0; j < value.length; j += 1) {
value[j] && value[j].type && visit(value[j], node, enter, leave, key, j);
}
}
else if (value && value.type) {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
leave(node, parent, prop, index);
}
}
exports.walk = walk;
exports.childKeys = childKeys;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=estree-walker.umd.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"estree-walker.umd.js","sources":["../src/estree-walker.js"],"sourcesContent":["export function walk(ast, { enter, leave }) {\n\tvisit(ast, null, enter, leave);\n}\n\nlet shouldSkip = false;\nconst context = { skip: () => shouldSkip = true };\n\nexport const childKeys = {};\n\nconst toString = Object.prototype.toString;\n\nfunction isArray(thing) {\n\treturn toString.call(thing) === '[object Array]';\n}\n\nfunction visit(node, parent, enter, leave, prop, index) {\n\tif (!node) return;\n\n\tif (enter) {\n\t\tconst _shouldSkip = shouldSkip;\n\t\tshouldSkip = false;\n\t\tenter.call(context, node, parent, prop, index);\n\t\tconst skipped = shouldSkip;\n\t\tshouldSkip = _shouldSkip;\n\n\t\tif (skipped) return;\n\t}\n\n\tconst keys = node.type && childKeys[node.type] || (\n\t\tchildKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')\n\t);\n\n\tfor (let i = 0; i < keys.length; i += 1) {\n\t\tconst key = keys[i];\n\t\tconst value = node[key];\n\n\t\tif (isArray(value)) {\n\t\t\tfor (let j = 0; j < value.length; j += 1) {\n\t\t\t\tvalue[j] && value[j].type && visit(value[j], node, enter, leave, key, j);\n\t\t\t}\n\t\t}\n\n\t\telse if (value && value.type) {\n\t\t\tvisit(value, node, enter, leave, key, null);\n\t\t}\n\t}\n\n\tif (leave) {\n\t\tleave(node, parent, prop, index);\n\t}\n}\n"],"names":[],"mappings":";;;;;;CAAO,SAAS,IAAI,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;CAC5C,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;CAChC,CAAC;;CAED,IAAI,UAAU,GAAG,KAAK,CAAC;CACvB,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,GAAG,IAAI,EAAE,CAAC;;AAElD,AAAY,OAAC,SAAS,GAAG,EAAE,CAAC;;CAE5B,MAAM,QAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;;CAE3C,SAAS,OAAO,CAAC,KAAK,EAAE;CACxB,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,gBAAgB,CAAC;CAClD,CAAC;;CAED,SAAS,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;CACxD,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;;CAEnB,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,MAAM,WAAW,GAAG,UAAU,CAAC;CACjC,EAAE,UAAU,GAAG,KAAK,CAAC;CACrB,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACjD,EAAE,MAAM,OAAO,GAAG,UAAU,CAAC;CAC7B,EAAE,UAAU,GAAG,WAAW,CAAC;;CAE3B,EAAE,IAAI,OAAO,EAAE,OAAO;CACtB,EAAE;;CAEF,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;CAC/C,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC;CACvF,EAAE,CAAC;;CAEH,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC1C,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;CACtB,EAAE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;;CAE1B,EAAE,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;CACtB,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;CAC7C,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;CAC7E,IAAI;CACJ,GAAG;;CAEH,OAAO,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE;CAChC,GAAG,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;CAC/C,GAAG;CACH,EAAE;;CAEF,CAAC,IAAI,KAAK,EAAE;CACZ,EAAE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;CACnC,EAAE;CACF,CAAC;;;;;;;;;;;;;"}

View File

@@ -0,0 +1,27 @@
declare module "estree-walker" {
export interface Node {
start: number;
end: number;
type: string;
[propName: string]: any;
}
export type WalkerContext = {
skip: () => void;
};
export type WalkerListener = (
this: WalkerContext,
node: Node,
parent?: Node,
prop?: string,
index?: number
) => void;
export interface WalkerOptions {
enter?: WalkerListener;
leave?: WalkerListener;
}
export function walk(ast: Node, options: WalkerOptions): void;
}

View File

@@ -0,0 +1,65 @@
{
"_args": [
[
"estree-walker@0.6.1",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "estree-walker@0.6.1",
"_id": "estree-walker@0.6.1",
"_inBundle": false,
"_integrity": "sha1-UwSRQ/QMbrkYsjZx0f4yGfOhs2I=",
"_location": "/rollup-pluginutils/estree-walker",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "estree-walker@0.6.1",
"name": "estree-walker",
"escapedName": "estree-walker",
"rawSpec": "0.6.1",
"saveSpec": null,
"fetchSpec": "0.6.1"
},
"_requiredBy": [
"/rollup-pluginutils"
],
"_resolved": "http://192.168.250.101:4873/estree-walker/-/estree-walker-0.6.1.tgz",
"_spec": "0.6.1",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Rich Harris"
},
"bugs": {
"url": "https://github.com/Rich-Harris/estree-walker/issues"
},
"description": "Traverse an ESTree-compliant AST",
"devDependencies": {
"mocha": "^5.2.0",
"rollup": "^0.67.3"
},
"files": [
"src",
"dist",
"index.d.ts",
"README.md"
],
"homepage": "https://github.com/Rich-Harris/estree-walker#readme",
"license": "MIT",
"main": "dist/estree-walker.umd.js",
"module": "src/estree-walker.js",
"name": "estree-walker",
"repository": {
"type": "git",
"url": "git+https://github.com/Rich-Harris/estree-walker.git"
},
"scripts": {
"build": "rollup -c",
"prepublishOnly": "npm test",
"pretest": "npm run build",
"test": "mocha test/test.js"
},
"typings": "index.d.ts",
"version": "0.6.1"
}

View File

@@ -0,0 +1,51 @@
export function walk(ast, { enter, leave }) {
visit(ast, null, enter, leave);
}
let shouldSkip = false;
const context = { skip: () => shouldSkip = true };
export const childKeys = {};
const toString = Object.prototype.toString;
function isArray(thing) {
return toString.call(thing) === '[object Array]';
}
function visit(node, parent, enter, leave, prop, index) {
if (!node) return;
if (enter) {
const _shouldSkip = shouldSkip;
shouldSkip = false;
enter.call(context, node, parent, prop, index);
const skipped = shouldSkip;
shouldSkip = _shouldSkip;
if (skipped) return;
}
const keys = node.type && childKeys[node.type] || (
childKeys[node.type] = Object.keys(node).filter(key => typeof node[key] === 'object')
);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
const value = node[key];
if (isArray(value)) {
for (let j = 0; j < value.length; j += 1) {
value[j] && value[j].type && visit(value[j], node, enter, leave, key, j);
}
}
else if (value && value.type) {
visit(value, node, enter, leave, key, null);
}
}
if (leave) {
leave(node, parent, prop, index);
}
}

92
node_modules/rollup-pluginutils/package.json generated vendored Normal file
View File

@@ -0,0 +1,92 @@
{
"_args": [
[
"rollup-pluginutils@2.8.2",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "rollup-pluginutils@2.8.2",
"_id": "rollup-pluginutils@2.8.2",
"_inBundle": false,
"_integrity": "sha1-cvKvB0i1kjZNvTOJ5gDlqURKNR4=",
"_location": "/rollup-pluginutils",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "rollup-pluginutils@2.8.2",
"name": "rollup-pluginutils",
"escapedName": "rollup-pluginutils",
"rawSpec": "2.8.2",
"saveSpec": null,
"fetchSpec": "2.8.2"
},
"_requiredBy": [
"/rollup-plugin-vue"
],
"_resolved": "http://192.168.250.101:4873/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz",
"_spec": "2.8.2",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Rich Harris",
"email": "richard.a.harris@gmail.com"
},
"bugs": {
"url": "https://github.com/rollup/rollup-pluginutils/issues"
},
"dependencies": {
"estree-walker": "^0.6.1"
},
"description": "Functionality commonly needed by Rollup plugins",
"devDependencies": {
"@types/estree": "0.0.39",
"@types/jest": "^24.0.13",
"@types/micromatch": "^3.1.0",
"@types/node": "^12.0.4",
"husky": "^3.0.5",
"jest": "^24.8.0",
"lint-staged": "^9.2.5",
"micromatch": "^4.0.2",
"prettier": "^1.17.1",
"rollup": "^1.13.1",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.1",
"rollup-plugin-typescript": "^1.0.1",
"shx": "^0.3.2",
"ts-jest": "^24.0.2",
"tslint": "^5.17.0",
"typescript": "^3.5.1",
"typescript-eslint-parser": "^22.0.0"
},
"files": [
"src",
"dist",
"README.md"
],
"homepage": "https://github.com/rollup/rollup-pluginutils#readme",
"jsnext:main": "dist/pluginutils.es.js",
"keywords": [
"rollup",
"utils"
],
"license": "MIT",
"main": "dist/pluginutils.cjs.js",
"module": "dist/pluginutils.es.js",
"name": "rollup-pluginutils",
"repository": {
"type": "git",
"url": "git+https://github.com/rollup/rollup-pluginutils.git"
},
"scripts": {
"build": "rollup -c && shx cp src/pluginutils.d.ts dist/pluginutils.d.ts",
"lint": "npm run lint:nofix -- --fix",
"lint:nofix": "tslint --project .",
"prepare": "npm run build",
"prepublishOnly": "npm test",
"pretest": "npm run build",
"test": "jest"
},
"typings": "dist/pluginutils.d.ts",
"version": "2.8.2"
}

9
node_modules/rollup-pluginutils/src/addExtension.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
import { extname } from 'path';
import { AddExtension } from './pluginutils';
const addExtension: AddExtension = function addExtension(filename, ext = '.js') {
if (!extname(filename)) filename += ext;
return filename;
};
export { addExtension as default };

125
node_modules/rollup-pluginutils/src/attachScopes.ts generated vendored Normal file
View File

@@ -0,0 +1,125 @@
import { Node, walk } from 'estree-walker';
import extractAssignedNames from './extractAssignedNames';
import { AttachedScope, AttachScopes } from './pluginutils';
const blockDeclarations = {
const: true,
let: true
};
interface ScopeOptions {
parent?: AttachedScope;
block?: boolean;
params?: Array<Node>;
}
class Scope implements AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
constructor(options: ScopeOptions = {}) {
this.parent = options.parent;
this.isBlockScope = !!options.block;
this.declarations = Object.create(null);
if (options.params) {
options.params.forEach(param => {
extractAssignedNames(param).forEach(name => {
this.declarations[name] = true;
});
});
}
}
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void {
if (!isBlockDeclaration && this.isBlockScope) {
// it's a `var` or function node, and this
// is a block scope, so we need to go up
this.parent!.addDeclaration(node, isBlockDeclaration, isVar);
} else if (node.id) {
extractAssignedNames(node.id).forEach(name => {
this.declarations[name] = true;
});
}
}
contains(name: string): boolean {
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
}
}
const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'scope') {
let scope = new Scope();
walk(ast, {
enter(node, parent) {
// function foo () {...}
// class Foo {...}
if (/(Function|Class)Declaration/.test(node.type)) {
scope.addDeclaration(node, false, false);
}
// var foo = 1
if (node.type === 'VariableDeclaration') {
const kind: keyof typeof blockDeclarations = node.kind;
const isBlockDeclaration = blockDeclarations[kind];
node.declarations.forEach((declaration: Node) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}
let newScope: AttachedScope | undefined;
// create new function scope
if (/Function/.test(node.type)) {
newScope = new Scope({
parent: scope,
block: false,
params: node.params
});
// named function expressions - the name is considered
// part of the function's scope
if (node.type === 'FunctionExpression' && node.id) {
newScope.addDeclaration(node, false, false);
}
}
// create new block scope
if (node.type === 'BlockStatement' && !/Function/.test(parent!.type)) {
newScope = new Scope({
parent: scope,
block: true
});
}
// catch clause has its own block scope
if (node.type === 'CatchClause') {
newScope = new Scope({
parent: scope,
params: node.param ? [node.param] : [],
block: true
});
}
if (newScope) {
Object.defineProperty(node, propertyName, {
value: newScope,
configurable: true
});
scope = newScope;
}
},
leave(node) {
if (node[propertyName]) scope = scope.parent!;
}
});
return scope;
};
export { attachScopes as default };

52
node_modules/rollup-pluginutils/src/createFilter.ts generated vendored Normal file
View File

@@ -0,0 +1,52 @@
import mm from 'micromatch';
import { resolve, sep } from 'path';
import { CreateFilter } from './pluginutils';
import ensureArray from './utils/ensureArray';
function getMatcherString(id: string, resolutionBase: string | false | null | undefined) {
if (resolutionBase === false) {
return id;
}
return resolve(...(typeof resolutionBase === 'string' ? [resolutionBase, id] : [id]));
}
const createFilter: CreateFilter = function createFilter(include?, exclude?, options?) {
const resolutionBase = options && options.resolve;
const getMatcher = (id: string | RegExp) => {
return id instanceof RegExp
? id
: {
test: mm.matcher(
getMatcherString(id, resolutionBase)
.split(sep)
.join('/'),
{ dot: true }
)
};
};
const includeMatchers = ensureArray(include).map(getMatcher);
const excludeMatchers = ensureArray(exclude).map(getMatcher);
return function(id: string | any): boolean {
if (typeof id !== 'string') return false;
if (/\0/.test(id)) return false;
id = id.split(sep).join('/');
for (let i = 0; i < excludeMatchers.length; ++i) {
const matcher = excludeMatchers[i];
if (matcher.test(id)) return false;
}
for (let i = 0; i < includeMatchers.length; ++i) {
const matcher = includeMatchers[i];
if (matcher.test(id)) return true;
}
return !includeMatchers.length;
};
};
export { createFilter as default };

92
node_modules/rollup-pluginutils/src/dataToEsm.ts generated vendored Normal file
View File

@@ -0,0 +1,92 @@
import makeLegalIdentifier from './makeLegalIdentifier';
import { DataToEsm } from './pluginutils';
export type Indent = string | null | undefined;
function stringify(obj: any): string {
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, char => `\\u${('000' + char.charCodeAt(0).toString(16)).slice(-4)}`);
}
function serializeArray<T>(arr: Array<T>, indent: Indent, baseIndent: string): string {
let output = '[';
const separator = indent ? '\n' + baseIndent + indent : '';
for (let i = 0; i < arr.length; i++) {
const key = arr[i];
output += `${i > 0 ? ',' : ''}${separator}${serialize(key, indent, baseIndent + indent)}`;
}
return output + `${indent ? '\n' + baseIndent : ''}]`;
}
function serializeObject<T>(obj: { [key: string]: T }, indent: Indent, baseIndent: string): string {
let output = '{';
const separator = indent ? '\n' + baseIndent + indent : '';
const keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(
obj[key],
indent,
baseIndent + indent
)}`;
}
return output + `${indent ? '\n' + baseIndent : ''}}`;
}
function serialize(obj: any, indent: Indent, baseIndent: string): string {
if (obj === Infinity) return 'Infinity';
if (obj === -Infinity) return '-Infinity';
if (obj === 0 && 1/obj === -Infinity) return '-0';
if (obj instanceof Date) return 'new Date(' + obj.getTime() + ')';
if (obj instanceof RegExp) return obj.toString();
if (obj !== obj) return 'NaN';
if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
if (obj === null) return 'null';
if (typeof obj === 'object') return serializeObject(obj, indent, baseIndent);
return stringify(obj);
}
const dataToEsm: DataToEsm = function dataToEsm(data, options = {}) {
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
const _ = options.compact ? '' : ' ';
const n = options.compact ? '' : '\n';
const declarationType = options.preferConst ? 'const' : 'var';
if (
options.namedExports === false ||
typeof data !== 'object' ||
Array.isArray(data) ||
data instanceof Date ||
data instanceof RegExp ||
data === null
) {
const code = serialize(data, options.compact ? null : t, '');
const __ = _ || (/^[{[\-\/]/.test(code) ? '' : ' ');
return `export default${__}${code};`;
}
let namedExportCode = '';
const defaultExportRows = [];
const dataKeys = Object.keys(data);
for (let i = 0; i < dataKeys.length; i++) {
const key = dataKeys[i];
if (key === makeLegalIdentifier(key)) {
if (options.objectShorthand) defaultExportRows.push(key);
else defaultExportRows.push(`${key}:${_}${key}`);
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(
data[key],
options.compact ? null : t,
''
)};${n}`;
} else {
defaultExportRows.push(
`${stringify(key)}:${_}${serialize(data[key], options.compact ? null : t, '')}`
);
}
}
return (
namedExportCode + `export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`
);
};
export { dataToEsm as default };

View File

@@ -0,0 +1,46 @@
import { Node } from 'estree-walker';
interface Extractors {
[key: string]: (names: Array<string>, param: Node) => void;
}
const extractors: Extractors = {
ArrayPattern(names: Array<string>, param: Node) {
for (const element of param.elements) {
if (element) extractors[element.type](names, element);
}
},
AssignmentPattern(names: Array<string>, param: Node) {
extractors[param.left.type](names, param.left);
},
Identifier(names: Array<string>, param: Node) {
names.push(param.name);
},
MemberExpression() {},
ObjectPattern(names: Array<string>, param: Node) {
for (const prop of param.properties) {
if (prop.type === 'RestElement') {
extractors.RestElement(names, prop);
} else {
extractors[prop.value.type](names, prop.value);
}
}
},
RestElement(names: Array<string>, param: Node) {
extractors[param.argument.type](names, param.argument);
}
};
const extractAssignedNames = function extractAssignedNames(param: Node): Array<string> {
const names: Array<string> = [];
extractors[param.type](names, param);
return names;
};
export { extractAssignedNames as default };

6
node_modules/rollup-pluginutils/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export { default as addExtension } from './addExtension';
export { default as attachScopes } from './attachScopes';
export { default as createFilter } from './createFilter';
export { default as makeLegalIdentifier } from './makeLegalIdentifier';
export { default as dataToEsm } from './dataToEsm';
export { default as extractAssignedNames } from './extractAssignedNames';

View File

@@ -0,0 +1,21 @@
import { MakeLegalIdentifier } from './pluginutils';
const reservedWords =
'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
const builtins =
'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
const forbiddenIdentifiers = new Set<string>(`${reservedWords} ${builtins}`.split(' '));
forbiddenIdentifiers.add('');
export const makeLegalIdentifier: MakeLegalIdentifier = function makeLegalIdentifier(str) {
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, '_');
if (/\d/.test(str[0]) || forbiddenIdentifiers.has(str)) {
str = `_${str}`;
}
return str || '_';
};
export { makeLegalIdentifier as default };

39
node_modules/rollup-pluginutils/src/pluginutils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { Node } from 'estree-walker';
export interface AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void;
contains(name: string): boolean;
}
export interface DataToEsmOptions {
compact?: boolean;
indent?: string;
namedExports?: boolean;
objectShorthand?: boolean;
preferConst?: boolean;
}
export type AddExtension = (filename: string, ext?: string) => string;
export const addExtension: AddExtension;
export type AttachScopes = (ast: Node, propertyName?: string) => AttachedScope;
export const attachScopes: AttachScopes;
export type CreateFilter = (
include?: Array<string | RegExp> | string | RegExp | null,
exclude?: Array<string | RegExp> | string | RegExp | null,
options?: { resolve?: string | false | null }
) => (id: string | any) => boolean;
export const createFilter: CreateFilter;
export type MakeLegalIdentifier = (str: string) => string;
export const makeLegalIdentifier: MakeLegalIdentifier;
export type DataToEsm = (data: any, options?: DataToEsmOptions) => string;
export const dataToEsm: DataToEsm;
export type ExtractAssignedNames = (param: Node) => Array<string>;
export const extractAssignedNames: ExtractAssignedNames;

View File

@@ -0,0 +1,5 @@
export default function ensureArray<T>(thing: Array<T> | T | undefined | null): Array<T> {
if (Array.isArray(thing)) return thing;
if (thing == undefined) return [];
return [thing];
}