initial commit
This commit is contained in:
7
node_modules/@vercel/nft/LICENSE
generated
vendored
Normal file
7
node_modules/@vercel/nft/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright 2019 Vercel, Inc.
|
||||
|
||||
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.
|
||||
389
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/CHANGELOG.md
generated
vendored
Executable file
389
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/CHANGELOG.md
generated
vendored
Executable file
@@ -0,0 +1,389 @@
|
||||
# @rollup/pluginutils ChangeLog
|
||||
|
||||
## v4.2.1
|
||||
|
||||
_2022-04-13_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: fix path normalisation for createFilter on absolute and * paths (#1161)
|
||||
|
||||
## v4.2.0
|
||||
|
||||
_2022-03-07_
|
||||
|
||||
### Features
|
||||
|
||||
- feat: support bigint and symbol in dataToEsm (#1047)
|
||||
|
||||
## v4.1.2
|
||||
|
||||
_2021-12-13_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: correct minimatch to picomatch in TSDoc (#1057)
|
||||
|
||||
## v4.1.1
|
||||
|
||||
_2021-07-16_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: remove extraneous peer dependency requirement (#845)
|
||||
|
||||
## v4.1.0
|
||||
|
||||
_2020-10-27_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: attach scope object to for-loop (#616)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: normalizePath (#550)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: improve readability of attachScopes test (#551)
|
||||
|
||||
## v4.0.0
|
||||
|
||||
_2020-08-13_
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- fix!: don't add cwd to absolute or patterns that start with a glob (#517)
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add native node es modules support (#419)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: Correct minimatch to picomatch (#525)
|
||||
- chore: update dependencies (9f56d37)
|
||||
- refactor: replace micromatch with picomatch. (#306)
|
||||
- chore: Don't bundle micromatch (#220)
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.1.0
|
||||
|
||||
_2020-06-05_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Features
|
||||
|
||||
- feat: add native node es modules support (#419)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: replace micromatch with picomatch. (#306)
|
||||
- chore: Don't bundle micromatch (#220)
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.10
|
||||
|
||||
_2020-05-02_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- refactor: replace micromatch with picomatch. (#306)
|
||||
- chore: Don't bundle micromatch (#220)
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.9
|
||||
|
||||
_2020-04-12_
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: support Rollup v2
|
||||
|
||||
## v3.0.8
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: add missing typescript devDep (238b140)
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.7
|
||||
|
||||
_2020-02-01_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
### Updates
|
||||
|
||||
- chore: Use readonly arrays, add TSDoc (#187)
|
||||
- chore: Use typechecking (2ae08eb)
|
||||
|
||||
## v3.0.6
|
||||
|
||||
_2020-01-27_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: resolve relative paths starting with "./" (#180)
|
||||
|
||||
## v3.0.5
|
||||
|
||||
_2020-01-25_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: bring back named exports (#176)
|
||||
|
||||
## v3.0.4
|
||||
|
||||
_2020-01-10_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: keep for(const..) out of scope (#151)
|
||||
|
||||
## v3.0.3
|
||||
|
||||
_2020-01-07_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: createFilter Windows regression (#141)
|
||||
|
||||
### Updates
|
||||
|
||||
- test: fix windows path failure (0a0de65)
|
||||
- chore: fix test script (5eae320)
|
||||
|
||||
## v3.0.2
|
||||
|
||||
_2020-01-04_
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- fix: makeLegalIdentifier - potentially unsafe input for blacklisted identifier (#116)
|
||||
|
||||
### Updates
|
||||
|
||||
- docs: Fix documented type of createFilter's include/exclude (#123)
|
||||
- chore: update minor linting correction (bcbf9d2)
|
||||
|
||||
## 3.0.1
|
||||
|
||||
- fix: Escape glob characters in folder (#84)
|
||||
|
||||
## 3.0.0
|
||||
|
||||
_2019-11-25_
|
||||
|
||||
- **Breaking:** Minimum compatible Rollup version is 1.20.0
|
||||
- **Breaking:** Minimum supported Node version is 8.0.0
|
||||
- Published as @rollup/plugins-image
|
||||
|
||||
## 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
|
||||
255
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/README.md
generated
vendored
Executable file
255
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/README.md
generated
vendored
Executable file
@@ -0,0 +1,255 @@
|
||||
[npm]: https://img.shields.io/npm/v/@rollup/pluginutils
|
||||
[npm-url]: https://www.npmjs.com/package/@rollup/pluginutils
|
||||
[size]: https://packagephobia.now.sh/badge?p=@rollup/pluginutils
|
||||
[size-url]: https://packagephobia.now.sh/result?p=@rollup/pluginutils
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![size][size]][size-url]
|
||||
[](https://liberamanifesto.com)
|
||||
|
||||
# @rollup/pluginutils
|
||||
|
||||
A set of utility functions commonly used by 🍣 Rollup plugins.
|
||||
|
||||
## Requirements
|
||||
|
||||
This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```console
|
||||
npm install @rollup/pluginutils --save-dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import utils from '@rollup/pluginutils';
|
||||
//...
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
Available utility functions are listed below:
|
||||
|
||||
_Note: Parameter names immediately followed by a `?` indicate that the parameter is optional._
|
||||
|
||||
### addExtension
|
||||
|
||||
Adds an extension to a module ID if one does not exist.
|
||||
|
||||
Parameters: `(filename: String, ext?: String)`<br>
|
||||
Returns: `String`
|
||||
|
||||
```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
|
||||
|
||||
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.
|
||||
|
||||
Parameters: `(ast: Node, propertyName?: String)`<br>
|
||||
Returns: `Object`
|
||||
|
||||
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
|
||||
|
||||
Constructs a filter function which can be used to determine whether or not certain modules should be operated upon.
|
||||
|
||||
Parameters: `(include?: <picomatch>, exclude?: <picomatch>, options?: Object)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### `include` and `exclude`
|
||||
|
||||
Type: `String | RegExp | Array[...String|RegExp]`<br>
|
||||
|
||||
A valid [`picomatch`](https://github.com/micromatch/picomatch#globbing-features) pattern, or array of patterns. 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 `picomatch` patterns, and must not match any of the `options.exclude` patterns.
|
||||
|
||||
Note that `picomatch` patterns are very similar to [`minimatch`](https://github.com/isaacs/minimatch#readme) patterns, and in most use cases, they are interchangeable. If you have more specific pattern matching needs, you can view [this comparison table](https://github.com/micromatch/picomatch#library-comparisons) to learn more about where the libraries differ.
|
||||
|
||||
#### `options`
|
||||
|
||||
##### `resolve`
|
||||
|
||||
Type: `String | Boolean | null`
|
||||
|
||||
Optionally resolves the patterns against a directory other than `process.cwd()`. If a `String` is specified, then the value will be used as the base directory. Relative paths will be resolved against `process.cwd()` first. If `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.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { createFilter } from '@rollup/pluginutils';
|
||||
|
||||
export default function myPlugin(options = {}) {
|
||||
// assume that the myPlugin accepts options of `options.include` and `options.exclude`
|
||||
var filter = createFilter(options.include, options.exclude, {
|
||||
resolve: '/my/base/dir'
|
||||
});
|
||||
|
||||
return {
|
||||
transform(code, id) {
|
||||
if (!filter(id)) return;
|
||||
|
||||
// proceed with the transformation...
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### dataToEsm
|
||||
|
||||
Transforms objects into tree-shakable ES Module imports.
|
||||
|
||||
Parameters: `(data: Object)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### `data`
|
||||
|
||||
Type: `Object`
|
||||
|
||||
An object to transform into an ES module.
|
||||
|
||||
#### Usage
|
||||
|
||||
```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
|
||||
|
||||
Extracts the names of all assignment targets based upon specified patterns.
|
||||
|
||||
Parameters: `(param: Node)`<br>
|
||||
Returns: `Array[...String]`
|
||||
|
||||
#### `param`
|
||||
|
||||
Type: `Node`
|
||||
|
||||
An `acorn` AST Node.
|
||||
|
||||
#### Usage
|
||||
|
||||
```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']
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### makeLegalIdentifier
|
||||
|
||||
Constructs a bundle-safe identifier from a `String`.
|
||||
|
||||
Parameters: `(str: String)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { makeLegalIdentifier } from '@rollup/pluginutils';
|
||||
|
||||
makeLegalIdentifier('foo-bar'); // 'foo_bar'
|
||||
makeLegalIdentifier('typeof'); // '_typeof'
|
||||
```
|
||||
|
||||
### normalizePath
|
||||
|
||||
Converts path separators to forward slash.
|
||||
|
||||
Parameters: `(filename: String)`<br>
|
||||
Returns: `String`
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
import { normalizePath } from '@rollup/pluginutils';
|
||||
|
||||
normalizePath('foo\\bar'); // 'foo/bar'
|
||||
normalizePath('foo/bar'); // 'foo/bar'
|
||||
```
|
||||
|
||||
## Meta
|
||||
|
||||
[CONTRIBUTING](/.github/CONTRIBUTING.md)
|
||||
|
||||
[LICENSE (MIT)](/LICENSE)
|
||||
475
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/cjs/index.js
generated
vendored
Normal file
475
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/cjs/index.js
generated
vendored
Normal file
@@ -0,0 +1,475 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var path = require('path');
|
||||
var pm = require('picomatch');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
var pm__default = /*#__PURE__*/_interopDefaultLegacy(pm);
|
||||
|
||||
const addExtension = function addExtension(filename, ext = '.js') {
|
||||
let result = `${filename}`;
|
||||
if (!path.extname(filename))
|
||||
result += ext;
|
||||
return result;
|
||||
};
|
||||
|
||||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); }
|
||||
__init() {this.should_skip = false;}
|
||||
__init2() {this.should_remove = false;}
|
||||
__init3() {this.replacement = null;}
|
||||
|
||||
__init4() {this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};}
|
||||
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (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;
|
||||
|
||||
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, enter, leave, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
function walk(ast, walker) {
|
||||
const instance = new SyncWalkerClass(walker);
|
||||
return instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
const extractors = {
|
||||
ArrayPattern(names, param) {
|
||||
for (const element of param.elements) {
|
||||
if (element)
|
||||
extractors[element.type](names, element);
|
||||
}
|
||||
},
|
||||
AssignmentPattern(names, param) {
|
||||
extractors[param.left.type](names, param.left);
|
||||
},
|
||||
Identifier(names, param) {
|
||||
names.push(param.name);
|
||||
},
|
||||
MemberExpression() { },
|
||||
ObjectPattern(names, param) {
|
||||
for (const prop of param.properties) {
|
||||
// @ts-ignore Typescript reports that this is not a valid type
|
||||
if (prop.type === 'RestElement') {
|
||||
extractors.RestElement(names, prop);
|
||||
}
|
||||
else {
|
||||
extractors[prop.value.type](names, prop.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
RestElement(names, param) {
|
||||
extractors[param.argument.type](names, param.argument);
|
||||
}
|
||||
};
|
||||
const extractAssignedNames = function extractAssignedNames(param) {
|
||||
const names = [];
|
||||
extractors[param.type](names, param);
|
||||
return names;
|
||||
};
|
||||
|
||||
const blockDeclarations = {
|
||||
const: true,
|
||||
let: true
|
||||
};
|
||||
class Scope {
|
||||
constructor(options = {}) {
|
||||
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, isBlockDeclaration, isVar) {
|
||||
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) {
|
||||
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
||||
}
|
||||
}
|
||||
const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
||||
let scope = new Scope();
|
||||
walk(ast, {
|
||||
enter(n, parent) {
|
||||
const node = n;
|
||||
// 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 } = node;
|
||||
const isBlockDeclaration = blockDeclarations[kind];
|
||||
node.declarations.forEach((declaration) => {
|
||||
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
||||
});
|
||||
}
|
||||
let newScope;
|
||||
// create new function scope
|
||||
if (/Function/.test(node.type)) {
|
||||
const func = node;
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: false,
|
||||
params: func.params
|
||||
});
|
||||
// named function expressions - the name is considered
|
||||
// part of the function's scope
|
||||
if (func.type === 'FunctionExpression' && func.id) {
|
||||
newScope.addDeclaration(func, false, false);
|
||||
}
|
||||
}
|
||||
// create new for scope
|
||||
if (/For(In|Of)?Statement/.test(node.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: true
|
||||
});
|
||||
}
|
||||
// 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(n) {
|
||||
const node = n;
|
||||
if (node[propertyName])
|
||||
scope = scope.parent;
|
||||
}
|
||||
});
|
||||
return scope;
|
||||
};
|
||||
|
||||
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
||||
function isArray(arg) {
|
||||
return Array.isArray(arg);
|
||||
}
|
||||
function ensureArray(thing) {
|
||||
if (isArray(thing))
|
||||
return thing;
|
||||
if (thing == null)
|
||||
return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
const normalizePath = function normalizePath(filename) {
|
||||
return filename.split(path.win32.sep).join(path.posix.sep);
|
||||
};
|
||||
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false || path.isAbsolute(id) || id.startsWith('*')) {
|
||||
return normalizePath(id);
|
||||
}
|
||||
// resolve('') is valid and will default to process.cwd()
|
||||
const basePath = normalizePath(path.resolve(resolutionBase || ''))
|
||||
// escape all possible (posix + win) path characters that might interfere with regex
|
||||
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
||||
// Note that we use posix.join because:
|
||||
// 1. the basePath has been normalized to use /
|
||||
// 2. the incoming glob (id) matcher, also uses /
|
||||
// otherwise Node will force backslash (\) on windows
|
||||
return path.posix.join(basePath, normalizePath(id));
|
||||
}
|
||||
const createFilter = function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp
|
||||
? id
|
||||
: {
|
||||
test: (what) => {
|
||||
// this refactor is a tad overly verbose but makes for easy debugging
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
const fn = pm__default["default"](pattern, { dot: true });
|
||||
const result = fn(what);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
const includeMatchers = ensureArray(include).map(getMatcher);
|
||||
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
||||
return function result(id) {
|
||||
if (typeof id !== 'string')
|
||||
return false;
|
||||
if (/\0/.test(id))
|
||||
return false;
|
||||
const pathId = normalizePath(id);
|
||||
for (let i = 0; i < excludeMatchers.length; ++i) {
|
||||
const matcher = excludeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < includeMatchers.length; ++i) {
|
||||
const matcher = includeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
};
|
||||
|
||||
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(`${reservedWords} ${builtins}`.split(' '));
|
||||
forbiddenIdentifiers.add('');
|
||||
const makeLegalIdentifier = function makeLegalIdentifier(str) {
|
||||
let identifier = str
|
||||
.replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
|
||||
.replace(/[^$_a-zA-Z0-9]/g, '_');
|
||||
if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
return identifier || '_';
|
||||
};
|
||||
|
||||
function stringify(obj) {
|
||||
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
||||
}
|
||||
function serializeArray(arr, indent, baseIndent) {
|
||||
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(obj, indent, baseIndent) {
|
||||
let output = '{';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
const entries = Object.entries(obj);
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [key, value] = entries[i];
|
||||
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
||||
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(value, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}}`;
|
||||
}
|
||||
function serialize(obj, indent, baseIndent) {
|
||||
if (typeof obj === 'object' && obj !== null) {
|
||||
if (Array.isArray(obj))
|
||||
return serializeArray(obj, indent, baseIndent);
|
||||
if (obj instanceof Date)
|
||||
return `new Date(${obj.getTime()})`;
|
||||
if (obj instanceof RegExp)
|
||||
return obj.toString();
|
||||
return serializeObject(obj, indent, baseIndent);
|
||||
}
|
||||
if (typeof obj === 'number') {
|
||||
if (obj === Infinity)
|
||||
return 'Infinity';
|
||||
if (obj === -Infinity)
|
||||
return '-Infinity';
|
||||
if (obj === 0)
|
||||
return 1 / obj === Infinity ? '0' : '-0';
|
||||
if (obj !== obj)
|
||||
return 'NaN'; // eslint-disable-line no-self-compare
|
||||
}
|
||||
if (typeof obj === 'symbol') {
|
||||
const key = Symbol.keyFor(obj);
|
||||
if (key !== undefined)
|
||||
return `Symbol.for(${stringify(key)})`;
|
||||
}
|
||||
if (typeof obj === 'bigint')
|
||||
return `${obj}n`;
|
||||
return stringify(obj);
|
||||
}
|
||||
const 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 magic = _ || (/^[{[\-\/]/.test(code) ? '' : ' '); // eslint-disable-line no-useless-escape
|
||||
return `export default${magic}${code};`;
|
||||
}
|
||||
let namedExportCode = '';
|
||||
const defaultExportRows = [];
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === makeLegalIdentifier(key)) {
|
||||
if (options.objectShorthand)
|
||||
defaultExportRows.push(key);
|
||||
else
|
||||
defaultExportRows.push(`${key}:${_}${key}`);
|
||||
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`;
|
||||
}
|
||||
else {
|
||||
defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`);
|
||||
}
|
||||
}
|
||||
return `${namedExportCode}export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
||||
};
|
||||
|
||||
// TODO: remove this in next major
|
||||
var index = {
|
||||
addExtension,
|
||||
attachScopes,
|
||||
createFilter,
|
||||
dataToEsm,
|
||||
extractAssignedNames,
|
||||
makeLegalIdentifier,
|
||||
normalizePath
|
||||
};
|
||||
|
||||
exports.addExtension = addExtension;
|
||||
exports.attachScopes = attachScopes;
|
||||
exports.createFilter = createFilter;
|
||||
exports.dataToEsm = dataToEsm;
|
||||
exports["default"] = index;
|
||||
exports.extractAssignedNames = extractAssignedNames;
|
||||
exports.makeLegalIdentifier = makeLegalIdentifier;
|
||||
exports.normalizePath = normalizePath;
|
||||
460
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/es/index.js
generated
vendored
Normal file
460
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,460 @@
|
||||
import { extname, win32, posix, isAbsolute, resolve } from 'path';
|
||||
import pm from 'picomatch';
|
||||
|
||||
const addExtension = function addExtension(filename, ext = '.js') {
|
||||
let result = `${filename}`;
|
||||
if (!extname(filename))
|
||||
result += ext;
|
||||
return result;
|
||||
};
|
||||
|
||||
class WalkerBase {constructor() { WalkerBase.prototype.__init.call(this);WalkerBase.prototype.__init2.call(this);WalkerBase.prototype.__init3.call(this);WalkerBase.prototype.__init4.call(this); }
|
||||
__init() {this.should_skip = false;}
|
||||
__init2() {this.should_remove = false;}
|
||||
__init3() {this.replacement = null;}
|
||||
|
||||
__init4() {this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};}
|
||||
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remove(parent, prop, index) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SyncWalkerClass extends WalkerBase {
|
||||
|
||||
|
||||
|
||||
constructor(walker) {
|
||||
super();
|
||||
this.enter = walker.enter;
|
||||
this.leave = walker.leave;
|
||||
}
|
||||
|
||||
visit(
|
||||
node,
|
||||
parent,
|
||||
enter,
|
||||
leave,
|
||||
prop,
|
||||
index
|
||||
) {
|
||||
if (node) {
|
||||
if (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;
|
||||
|
||||
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, enter, leave, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (value !== null && typeof value.type === "string") {
|
||||
this.visit(value, node, enter, leave, key, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
function walk(ast, walker) {
|
||||
const instance = new SyncWalkerClass(walker);
|
||||
return instance.visit(ast, null, walker.enter, walker.leave);
|
||||
}
|
||||
|
||||
const extractors = {
|
||||
ArrayPattern(names, param) {
|
||||
for (const element of param.elements) {
|
||||
if (element)
|
||||
extractors[element.type](names, element);
|
||||
}
|
||||
},
|
||||
AssignmentPattern(names, param) {
|
||||
extractors[param.left.type](names, param.left);
|
||||
},
|
||||
Identifier(names, param) {
|
||||
names.push(param.name);
|
||||
},
|
||||
MemberExpression() { },
|
||||
ObjectPattern(names, param) {
|
||||
for (const prop of param.properties) {
|
||||
// @ts-ignore Typescript reports that this is not a valid type
|
||||
if (prop.type === 'RestElement') {
|
||||
extractors.RestElement(names, prop);
|
||||
}
|
||||
else {
|
||||
extractors[prop.value.type](names, prop.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
RestElement(names, param) {
|
||||
extractors[param.argument.type](names, param.argument);
|
||||
}
|
||||
};
|
||||
const extractAssignedNames = function extractAssignedNames(param) {
|
||||
const names = [];
|
||||
extractors[param.type](names, param);
|
||||
return names;
|
||||
};
|
||||
|
||||
const blockDeclarations = {
|
||||
const: true,
|
||||
let: true
|
||||
};
|
||||
class Scope {
|
||||
constructor(options = {}) {
|
||||
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, isBlockDeclaration, isVar) {
|
||||
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) {
|
||||
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
||||
}
|
||||
}
|
||||
const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
||||
let scope = new Scope();
|
||||
walk(ast, {
|
||||
enter(n, parent) {
|
||||
const node = n;
|
||||
// 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 } = node;
|
||||
const isBlockDeclaration = blockDeclarations[kind];
|
||||
node.declarations.forEach((declaration) => {
|
||||
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
||||
});
|
||||
}
|
||||
let newScope;
|
||||
// create new function scope
|
||||
if (/Function/.test(node.type)) {
|
||||
const func = node;
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: false,
|
||||
params: func.params
|
||||
});
|
||||
// named function expressions - the name is considered
|
||||
// part of the function's scope
|
||||
if (func.type === 'FunctionExpression' && func.id) {
|
||||
newScope.addDeclaration(func, false, false);
|
||||
}
|
||||
}
|
||||
// create new for scope
|
||||
if (/For(In|Of)?Statement/.test(node.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: true
|
||||
});
|
||||
}
|
||||
// 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(n) {
|
||||
const node = n;
|
||||
if (node[propertyName])
|
||||
scope = scope.parent;
|
||||
}
|
||||
});
|
||||
return scope;
|
||||
};
|
||||
|
||||
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
||||
function isArray(arg) {
|
||||
return Array.isArray(arg);
|
||||
}
|
||||
function ensureArray(thing) {
|
||||
if (isArray(thing))
|
||||
return thing;
|
||||
if (thing == null)
|
||||
return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
const normalizePath = function normalizePath(filename) {
|
||||
return filename.split(win32.sep).join(posix.sep);
|
||||
};
|
||||
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false || isAbsolute(id) || id.startsWith('*')) {
|
||||
return normalizePath(id);
|
||||
}
|
||||
// resolve('') is valid and will default to process.cwd()
|
||||
const basePath = normalizePath(resolve(resolutionBase || ''))
|
||||
// escape all possible (posix + win) path characters that might interfere with regex
|
||||
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
||||
// Note that we use posix.join because:
|
||||
// 1. the basePath has been normalized to use /
|
||||
// 2. the incoming glob (id) matcher, also uses /
|
||||
// otherwise Node will force backslash (\) on windows
|
||||
return posix.join(basePath, normalizePath(id));
|
||||
}
|
||||
const createFilter = function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp
|
||||
? id
|
||||
: {
|
||||
test: (what) => {
|
||||
// this refactor is a tad overly verbose but makes for easy debugging
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
const fn = pm(pattern, { dot: true });
|
||||
const result = fn(what);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
const includeMatchers = ensureArray(include).map(getMatcher);
|
||||
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
||||
return function result(id) {
|
||||
if (typeof id !== 'string')
|
||||
return false;
|
||||
if (/\0/.test(id))
|
||||
return false;
|
||||
const pathId = normalizePath(id);
|
||||
for (let i = 0; i < excludeMatchers.length; ++i) {
|
||||
const matcher = excludeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return false;
|
||||
}
|
||||
for (let i = 0; i < includeMatchers.length; ++i) {
|
||||
const matcher = includeMatchers[i];
|
||||
if (matcher.test(pathId))
|
||||
return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
};
|
||||
|
||||
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(`${reservedWords} ${builtins}`.split(' '));
|
||||
forbiddenIdentifiers.add('');
|
||||
const makeLegalIdentifier = function makeLegalIdentifier(str) {
|
||||
let identifier = str
|
||||
.replace(/-(\w)/g, (_, letter) => letter.toUpperCase())
|
||||
.replace(/[^$_a-zA-Z0-9]/g, '_');
|
||||
if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) {
|
||||
identifier = `_${identifier}`;
|
||||
}
|
||||
return identifier || '_';
|
||||
};
|
||||
|
||||
function stringify(obj) {
|
||||
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
|
||||
}
|
||||
function serializeArray(arr, indent, baseIndent) {
|
||||
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(obj, indent, baseIndent) {
|
||||
let output = '{';
|
||||
const separator = indent ? `\n${baseIndent}${indent}` : '';
|
||||
const entries = Object.entries(obj);
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [key, value] = entries[i];
|
||||
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
||||
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(value, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return `${output}${indent ? `\n${baseIndent}` : ''}}`;
|
||||
}
|
||||
function serialize(obj, indent, baseIndent) {
|
||||
if (typeof obj === 'object' && obj !== null) {
|
||||
if (Array.isArray(obj))
|
||||
return serializeArray(obj, indent, baseIndent);
|
||||
if (obj instanceof Date)
|
||||
return `new Date(${obj.getTime()})`;
|
||||
if (obj instanceof RegExp)
|
||||
return obj.toString();
|
||||
return serializeObject(obj, indent, baseIndent);
|
||||
}
|
||||
if (typeof obj === 'number') {
|
||||
if (obj === Infinity)
|
||||
return 'Infinity';
|
||||
if (obj === -Infinity)
|
||||
return '-Infinity';
|
||||
if (obj === 0)
|
||||
return 1 / obj === Infinity ? '0' : '-0';
|
||||
if (obj !== obj)
|
||||
return 'NaN'; // eslint-disable-line no-self-compare
|
||||
}
|
||||
if (typeof obj === 'symbol') {
|
||||
const key = Symbol.keyFor(obj);
|
||||
if (key !== undefined)
|
||||
return `Symbol.for(${stringify(key)})`;
|
||||
}
|
||||
if (typeof obj === 'bigint')
|
||||
return `${obj}n`;
|
||||
return stringify(obj);
|
||||
}
|
||||
const 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 magic = _ || (/^[{[\-\/]/.test(code) ? '' : ' '); // eslint-disable-line no-useless-escape
|
||||
return `export default${magic}${code};`;
|
||||
}
|
||||
let namedExportCode = '';
|
||||
const defaultExportRows = [];
|
||||
for (const [key, value] of Object.entries(data)) {
|
||||
if (key === makeLegalIdentifier(key)) {
|
||||
if (options.objectShorthand)
|
||||
defaultExportRows.push(key);
|
||||
else
|
||||
defaultExportRows.push(`${key}:${_}${key}`);
|
||||
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, '')};${n}`;
|
||||
}
|
||||
else {
|
||||
defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, '')}`);
|
||||
}
|
||||
}
|
||||
return `${namedExportCode}export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
||||
};
|
||||
|
||||
// TODO: remove this in next major
|
||||
var index = {
|
||||
addExtension,
|
||||
attachScopes,
|
||||
createFilter,
|
||||
dataToEsm,
|
||||
extractAssignedNames,
|
||||
makeLegalIdentifier,
|
||||
normalizePath
|
||||
};
|
||||
|
||||
export { addExtension, attachScopes, createFilter, dataToEsm, index as default, extractAssignedNames, makeLegalIdentifier, normalizePath };
|
||||
1
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/es/package.json
generated
vendored
Normal file
1
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/dist/es/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
92
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/package.json
generated
vendored
Normal file
92
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "@rollup/pluginutils",
|
||||
"version": "4.2.1",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"description": "A set of utility functions commonly used by Rollup plugins",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "rollup/plugins",
|
||||
"directory": "packages/pluginutils"
|
||||
},
|
||||
"author": "Rich Harris <richard.a.harris@gmail.com>",
|
||||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/pluginutils#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rollup/plugins/issues"
|
||||
},
|
||||
"main": "./dist/cjs/index.js",
|
||||
"module": "./dist/es/index.js",
|
||||
"type": "commonjs",
|
||||
"exports": {
|
||||
"require": "./dist/cjs/index.js",
|
||||
"import": "./dist/es/index.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.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",
|
||||
"prebuild": "del-cli dist",
|
||||
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
|
||||
"prerelease": "pnpm build",
|
||||
"pretest": "pnpm build -- --sourcemap",
|
||||
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
|
||||
"test": "ava",
|
||||
"test:ts": "tsc --noEmit"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"keywords": [
|
||||
"rollup",
|
||||
"plugin",
|
||||
"utils"
|
||||
],
|
||||
"dependencies": {
|
||||
"estree-walker": "^2.0.1",
|
||||
"picomatch": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^14.0.0",
|
||||
"@rollup/plugin-node-resolve": "^8.4.0",
|
||||
"@rollup/plugin-typescript": "^5.0.2",
|
||||
"@types/estree": "0.0.45",
|
||||
"@types/node": "^14.0.26",
|
||||
"@types/picomatch": "^2.2.1",
|
||||
"acorn": "^8.0.4",
|
||||
"rollup": "^2.67.3",
|
||||
"typescript": "^4.1.2"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"ava": {
|
||||
"babel": {
|
||||
"compileEnhancements": false
|
||||
},
|
||||
"extensions": [
|
||||
"ts"
|
||||
],
|
||||
"require": [
|
||||
"ts-node/register"
|
||||
],
|
||||
"files": [
|
||||
"!**/fixtures/**",
|
||||
"!**/helpers/**",
|
||||
"!**/recipes/**",
|
||||
"!**/types.ts"
|
||||
]
|
||||
},
|
||||
"nyc": {
|
||||
"extension": [
|
||||
".js",
|
||||
".ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
93
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/types/index.d.ts
generated
vendored
Executable file
93
node_modules/@vercel/nft/node_modules/@rollup/pluginutils/types/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,93 @@
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
import { BaseNode } from 'estree';
|
||||
|
||||
export interface AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: { [key: string]: boolean };
|
||||
addDeclaration(node: BaseNode, isBlockDeclaration: boolean, isVar: boolean): void;
|
||||
contains(name: string): boolean;
|
||||
}
|
||||
|
||||
export interface DataToEsmOptions {
|
||||
compact?: boolean;
|
||||
indent?: string;
|
||||
namedExports?: boolean;
|
||||
objectShorthand?: boolean;
|
||||
preferConst?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A valid `picomatch` glob pattern, or array of patterns.
|
||||
*/
|
||||
export type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
||||
|
||||
/**
|
||||
* Adds an extension to a module ID if one does not exist.
|
||||
*/
|
||||
export function addExtension(filename: string, ext?: string): string;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export function attachScopes(ast: BaseNode, propertyName?: string): AttachedScope;
|
||||
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `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.
|
||||
*/
|
||||
export function createFilter(
|
||||
include?: FilterPattern,
|
||||
exclude?: FilterPattern,
|
||||
options?: { resolve?: string | false | null }
|
||||
): (id: string | unknown) => boolean;
|
||||
|
||||
/**
|
||||
* Transforms objects into tree-shakable ES Module imports.
|
||||
* @param data An object to transform into an ES module.
|
||||
*/
|
||||
export function dataToEsm(data: unknown, options?: DataToEsmOptions): string;
|
||||
|
||||
/**
|
||||
* Extracts the names of all assignment targets based upon specified patterns.
|
||||
* @param param An `acorn` AST Node.
|
||||
*/
|
||||
export function extractAssignedNames(param: BaseNode): string[];
|
||||
|
||||
/**
|
||||
* Constructs a bundle-safe identifier from a `string`.
|
||||
*/
|
||||
export function makeLegalIdentifier(str: string): string;
|
||||
|
||||
/**
|
||||
* Converts path separators to forward slash.
|
||||
*/
|
||||
export function normalizePath(filename: string): string;
|
||||
|
||||
export type AddExtension = typeof addExtension;
|
||||
export type AttachScopes = typeof attachScopes;
|
||||
export type CreateFilter = typeof createFilter;
|
||||
export type ExtractAssignedNames = typeof extractAssignedNames;
|
||||
export type MakeLegalIdentifier = typeof makeLegalIdentifier;
|
||||
export type NormalizePath = typeof normalizePath;
|
||||
export type DataToEsm = typeof dataToEsm;
|
||||
|
||||
declare const defaultExport: {
|
||||
addExtension: AddExtension;
|
||||
attachScopes: AttachScopes;
|
||||
createFilter: CreateFilter;
|
||||
dataToEsm: DataToEsm;
|
||||
extractAssignedNames: ExtractAssignedNames;
|
||||
makeLegalIdentifier: MakeLegalIdentifier;
|
||||
normalizePath: NormalizePath;
|
||||
};
|
||||
export default defaultExport;
|
||||
21
node_modules/@vercel/nft/node_modules/brace-expansion/LICENSE
generated
vendored
Normal file
21
node_modules/@vercel/nft/node_modules/brace-expansion/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
||||
129
node_modules/@vercel/nft/node_modules/brace-expansion/README.md
generated
vendored
Normal file
129
node_modules/@vercel/nft/node_modules/brace-expansion/README.md
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
# brace-expansion
|
||||
|
||||
[Brace expansion](https://www.gnu.org/software/bash/manual/html_node/Brace-Expansion.html),
|
||||
as known from sh/bash, in JavaScript.
|
||||
|
||||
[](http://travis-ci.org/juliangruber/brace-expansion)
|
||||
[](https://www.npmjs.org/package/brace-expansion)
|
||||
[](https://greenkeeper.io/)
|
||||
|
||||
[](https://ci.testling.com/juliangruber/brace-expansion)
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
|
||||
expand('file-{a,b,c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('-v{,,}')
|
||||
// => ['-v', '-v', '-v']
|
||||
|
||||
expand('file{0..2}.jpg')
|
||||
// => ['file0.jpg', 'file1.jpg', 'file2.jpg']
|
||||
|
||||
expand('file-{a..c}.jpg')
|
||||
// => ['file-a.jpg', 'file-b.jpg', 'file-c.jpg']
|
||||
|
||||
expand('file{2..0}.jpg')
|
||||
// => ['file2.jpg', 'file1.jpg', 'file0.jpg']
|
||||
|
||||
expand('file{0..4..2}.jpg')
|
||||
// => ['file0.jpg', 'file2.jpg', 'file4.jpg']
|
||||
|
||||
expand('file-{a..e..2}.jpg')
|
||||
// => ['file-a.jpg', 'file-c.jpg', 'file-e.jpg']
|
||||
|
||||
expand('file{00..10..5}.jpg')
|
||||
// => ['file00.jpg', 'file05.jpg', 'file10.jpg']
|
||||
|
||||
expand('{{A..C},{a..c}}')
|
||||
// => ['A', 'B', 'C', 'a', 'b', 'c']
|
||||
|
||||
expand('ppp{,config,oe{,conf}}')
|
||||
// => ['ppp', 'pppconfig', 'pppoe', 'pppoeconf']
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var expand = require('brace-expansion');
|
||||
```
|
||||
|
||||
### var expanded = expand(str)
|
||||
|
||||
Return an array of all possible and valid expansions of `str`. If none are
|
||||
found, `[str]` is returned.
|
||||
|
||||
Valid expansions are:
|
||||
|
||||
```js
|
||||
/^(.*,)+(.+)?$/
|
||||
// {a,b,...}
|
||||
```
|
||||
|
||||
A comma separated list of options, like `{a,b}` or `{a,{b,c}}` or `{,a,}`.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
A numeric sequence from `x` to `y` inclusive, with optional increment.
|
||||
If `x` or `y` start with a leading `0`, all the numbers will be padded
|
||||
to have equal length. Negative numbers and backwards iteration work too.
|
||||
|
||||
```js
|
||||
/^-?\d+\.\.-?\d+(\.\.-?\d+)?$/
|
||||
// {x..y[..incr]}
|
||||
```
|
||||
|
||||
An alphabetic sequence from `x` to `y` inclusive, with optional increment.
|
||||
`x` and `y` must be exactly one character, and if given, `incr` must be a
|
||||
number.
|
||||
|
||||
For compatibility reasons, the string `${` is not eligible for brace expansion.
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```bash
|
||||
npm install brace-expansion
|
||||
```
|
||||
|
||||
## Contributors
|
||||
|
||||
- [Julian Gruber](https://github.com/juliangruber)
|
||||
- [Isaac Z. Schlueter](https://github.com/isaacs)
|
||||
|
||||
## Sponsors
|
||||
|
||||
This module is proudly supported by my [Sponsors](https://github.com/juliangruber/sponsors)!
|
||||
|
||||
Do you want to support modules like this to improve their quality, stability and weigh in on new features? Then please consider donating to my [Patreon](https://www.patreon.com/juliangruber). Not sure how much of my modules you're using? Try [feross/thanks](https://github.com/feross/thanks)!
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
||||
201
node_modules/@vercel/nft/node_modules/brace-expansion/index.js
generated
vendored
Normal file
201
node_modules/@vercel/nft/node_modules/brace-expansion/index.js
generated
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
var concatMap = require('concat-map');
|
||||
var balanced = require('balanced-match');
|
||||
|
||||
module.exports = expandTop;
|
||||
|
||||
var escSlash = '\0SLASH'+Math.random()+'\0';
|
||||
var escOpen = '\0OPEN'+Math.random()+'\0';
|
||||
var escClose = '\0CLOSE'+Math.random()+'\0';
|
||||
var escComma = '\0COMMA'+Math.random()+'\0';
|
||||
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
||||
|
||||
function numeric(str) {
|
||||
return parseInt(str, 10) == str
|
||||
? parseInt(str, 10)
|
||||
: str.charCodeAt(0);
|
||||
}
|
||||
|
||||
function escapeBraces(str) {
|
||||
return str.split('\\\\').join(escSlash)
|
||||
.split('\\{').join(escOpen)
|
||||
.split('\\}').join(escClose)
|
||||
.split('\\,').join(escComma)
|
||||
.split('\\.').join(escPeriod);
|
||||
}
|
||||
|
||||
function unescapeBraces(str) {
|
||||
return str.split(escSlash).join('\\')
|
||||
.split(escOpen).join('{')
|
||||
.split(escClose).join('}')
|
||||
.split(escComma).join(',')
|
||||
.split(escPeriod).join('.');
|
||||
}
|
||||
|
||||
|
||||
// Basically just str.split(","), but handling cases
|
||||
// where we have nested braced sections, which should be
|
||||
// treated as individual members, like {a,{b,c},d}
|
||||
function parseCommaParts(str) {
|
||||
if (!str)
|
||||
return [''];
|
||||
|
||||
var parts = [];
|
||||
var m = balanced('{', '}', str);
|
||||
|
||||
if (!m)
|
||||
return str.split(',');
|
||||
|
||||
var pre = m.pre;
|
||||
var body = m.body;
|
||||
var post = m.post;
|
||||
var p = pre.split(',');
|
||||
|
||||
p[p.length-1] += '{' + body + '}';
|
||||
var postParts = parseCommaParts(post);
|
||||
if (post.length) {
|
||||
p[p.length-1] += postParts.shift();
|
||||
p.push.apply(p, postParts);
|
||||
}
|
||||
|
||||
parts.push.apply(parts, p);
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
function expandTop(str) {
|
||||
if (!str)
|
||||
return [];
|
||||
|
||||
// I don't know why Bash 4.3 does this, but it does.
|
||||
// Anything starting with {} will have the first two bytes preserved
|
||||
// but *only* at the top level, so {},a}b will not expand to anything,
|
||||
// but a{},b}c will be expanded to [a}c,abc].
|
||||
// One could argue that this is a bug in Bash, but since the goal of
|
||||
// this module is to match Bash's rules, we escape a leading {}
|
||||
if (str.substr(0, 2) === '{}') {
|
||||
str = '\\{\\}' + str.substr(2);
|
||||
}
|
||||
|
||||
return expand(escapeBraces(str), true).map(unescapeBraces);
|
||||
}
|
||||
|
||||
function identity(e) {
|
||||
return e;
|
||||
}
|
||||
|
||||
function embrace(str) {
|
||||
return '{' + str + '}';
|
||||
}
|
||||
function isPadded(el) {
|
||||
return /^-?0\d/.test(el);
|
||||
}
|
||||
|
||||
function lte(i, y) {
|
||||
return i <= y;
|
||||
}
|
||||
function gte(i, y) {
|
||||
return i >= y;
|
||||
}
|
||||
|
||||
function expand(str, isTop) {
|
||||
var expansions = [];
|
||||
|
||||
var m = balanced('{', '}', str);
|
||||
if (!m || /\$$/.test(m.pre)) return [str];
|
||||
|
||||
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
||||
var isSequence = isNumericSequence || isAlphaSequence;
|
||||
var isOptions = m.body.indexOf(',') >= 0;
|
||||
if (!isSequence && !isOptions) {
|
||||
// {a},b}
|
||||
if (m.post.match(/,.*\}/)) {
|
||||
str = m.pre + '{' + m.body + escClose + m.post;
|
||||
return expand(str);
|
||||
}
|
||||
return [str];
|
||||
}
|
||||
|
||||
var n;
|
||||
if (isSequence) {
|
||||
n = m.body.split(/\.\./);
|
||||
} else {
|
||||
n = parseCommaParts(m.body);
|
||||
if (n.length === 1) {
|
||||
// x{{a,b}}y ==> x{a}y x{b}y
|
||||
n = expand(n[0], false).map(embrace);
|
||||
if (n.length === 1) {
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
return post.map(function(p) {
|
||||
return m.pre + n[0] + p;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// at this point, n is the parts, and we know it's not a comma set
|
||||
// with a single entry.
|
||||
|
||||
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
||||
var pre = m.pre;
|
||||
var post = m.post.length
|
||||
? expand(m.post, false)
|
||||
: [''];
|
||||
|
||||
var N;
|
||||
|
||||
if (isSequence) {
|
||||
var x = numeric(n[0]);
|
||||
var y = numeric(n[1]);
|
||||
var width = Math.max(n[0].length, n[1].length)
|
||||
var incr = n.length == 3
|
||||
? Math.abs(numeric(n[2]))
|
||||
: 1;
|
||||
var test = lte;
|
||||
var reverse = y < x;
|
||||
if (reverse) {
|
||||
incr *= -1;
|
||||
test = gte;
|
||||
}
|
||||
var pad = n.some(isPadded);
|
||||
|
||||
N = [];
|
||||
|
||||
for (var i = x; test(i, y); i += incr) {
|
||||
var c;
|
||||
if (isAlphaSequence) {
|
||||
c = String.fromCharCode(i);
|
||||
if (c === '\\')
|
||||
c = '';
|
||||
} else {
|
||||
c = String(i);
|
||||
if (pad) {
|
||||
var need = width - c.length;
|
||||
if (need > 0) {
|
||||
var z = new Array(need + 1).join('0');
|
||||
if (i < 0)
|
||||
c = '-' + z + c.slice(1);
|
||||
else
|
||||
c = z + c;
|
||||
}
|
||||
}
|
||||
}
|
||||
N.push(c);
|
||||
}
|
||||
} else {
|
||||
N = concatMap(n, function(el) { return expand(el, false) });
|
||||
}
|
||||
|
||||
for (var j = 0; j < N.length; j++) {
|
||||
for (var k = 0; k < post.length; k++) {
|
||||
var expansion = pre + N[j] + post[k];
|
||||
if (!isTop || isSequence || expansion)
|
||||
expansions.push(expansion);
|
||||
}
|
||||
}
|
||||
|
||||
return expansions;
|
||||
}
|
||||
|
||||
47
node_modules/@vercel/nft/node_modules/brace-expansion/package.json
generated
vendored
Normal file
47
node_modules/@vercel/nft/node_modules/brace-expansion/package.json
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "brace-expansion",
|
||||
"description": "Brace expansion as known from sh/bash",
|
||||
"version": "1.1.11",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/brace-expansion.git"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/brace-expansion",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "tape test/*.js",
|
||||
"gentest": "bash test/generate.sh",
|
||||
"bench": "matcha test/perf/bench.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"matcha": "^0.7.0",
|
||||
"tape": "^4.6.0"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/20..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/25..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
}
|
||||
}
|
||||
92
node_modules/@vercel/nft/node_modules/estree-walker/CHANGELOG.md
generated
vendored
Normal file
92
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/LICENSE
generated
vendored
Normal file
7
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/README.md
generated
vendored
Normal file
48
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/dist/esm/estree-walker.js
generated
vendored
Normal file
333
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/dist/esm/package.json
generated
vendored
Normal file
1
node_modules/@vercel/nft/node_modules/estree-walker/dist/esm/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type":"module"}
|
||||
344
node_modules/@vercel/nft/node_modules/estree-walker/dist/umd/estree-walker.js
generated
vendored
Normal file
344
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/package.json
generated
vendored
Normal file
37
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/src/async.js
generated
vendored
Normal file
118
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/src/index.js
generated
vendored
Normal file
35
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/src/package.json
generated
vendored
Normal file
1
node_modules/@vercel/nft/node_modules/estree-walker/src/package.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"type": "module"}
|
||||
118
node_modules/@vercel/nft/node_modules/estree-walker/src/sync.js
generated
vendored
Normal file
118
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/src/walker.js
generated
vendored
Normal file
61
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/types/async.d.ts
generated
vendored
Normal file
53
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
56
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/types/sync.d.ts
generated
vendored
Normal file
53
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/types/tsconfig.tsbuildinfo
generated
vendored
Normal file
345
node_modules/@vercel/nft/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/@vercel/nft/node_modules/estree-walker/types/walker.d.ts
generated
vendored
Normal file
37
node_modules/@vercel/nft/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;
|
||||
};
|
||||
21
node_modules/@vercel/nft/node_modules/glob/LICENSE
generated
vendored
Normal file
21
node_modules/@vercel/nft/node_modules/glob/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
## Glob Logo
|
||||
|
||||
Glob's logo created by Tanya Brassie <http://tanyabrassie.com/>, licensed
|
||||
under a Creative Commons Attribution-ShareAlike 4.0 International License
|
||||
https://creativecommons.org/licenses/by-sa/4.0/
|
||||
378
node_modules/@vercel/nft/node_modules/glob/README.md
generated
vendored
Normal file
378
node_modules/@vercel/nft/node_modules/glob/README.md
generated
vendored
Normal file
@@ -0,0 +1,378 @@
|
||||
# Glob
|
||||
|
||||
Match files using the patterns the shell uses, like stars and stuff.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-glob/) [](https://ci.appveyor.com/project/isaacs/node-glob) [](https://coveralls.io/github/isaacs/node-glob?branch=master)
|
||||
|
||||
This is a glob implementation in JavaScript. It uses the `minimatch`
|
||||
library to do its matching.
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Install with npm
|
||||
|
||||
```
|
||||
npm i glob
|
||||
```
|
||||
|
||||
```javascript
|
||||
var glob = require("glob")
|
||||
|
||||
// options is optional
|
||||
glob("**/*.js", options, function (er, files) {
|
||||
// files is an array of filenames.
|
||||
// If the `nonull` option is set, and nothing
|
||||
// was found, then files is ["**/*.js"]
|
||||
// er is an error object or null.
|
||||
})
|
||||
```
|
||||
|
||||
## Glob Primer
|
||||
|
||||
"Globs" are the patterns you type when you do stuff like `ls *.js` on
|
||||
the command line, or put `build/*` in a `.gitignore` file.
|
||||
|
||||
Before parsing the path part patterns, braced sections are expanded
|
||||
into a set. Braced sections start with `{` and end with `}`, with any
|
||||
number of comma-delimited sections within. Braced sections may contain
|
||||
slash characters, so `a{/b/c,bcd}` would expand into `a/b/c` and `abcd`.
|
||||
|
||||
The following characters have special magic meaning when used in a
|
||||
path portion:
|
||||
|
||||
* `*` Matches 0 or more characters in a single path portion
|
||||
* `?` Matches 1 character
|
||||
* `[...]` Matches a range of characters, similar to a RegExp range.
|
||||
If the first character of the range is `!` or `^` then it matches
|
||||
any character not in the range.
|
||||
* `!(pattern|pattern|pattern)` Matches anything that does not match
|
||||
any of the patterns provided.
|
||||
* `?(pattern|pattern|pattern)` Matches zero or one occurrence of the
|
||||
patterns provided.
|
||||
* `+(pattern|pattern|pattern)` Matches one or more occurrences of the
|
||||
patterns provided.
|
||||
* `*(a|b|c)` Matches zero or more occurrences of the patterns provided
|
||||
* `@(pattern|pat*|pat?erN)` Matches exactly one of the patterns
|
||||
provided
|
||||
* `**` If a "globstar" is alone in a path portion, then it matches
|
||||
zero or more directories and subdirectories searching for matches.
|
||||
It does not crawl symlinked directories.
|
||||
|
||||
### Dots
|
||||
|
||||
If a file or directory path portion has a `.` as the first character,
|
||||
then it will not match any glob pattern unless that pattern's
|
||||
corresponding path part also has a `.` as its first character.
|
||||
|
||||
For example, the pattern `a/.*/c` would match the file at `a/.b/c`.
|
||||
However the pattern `a/*/c` would not, because `*` does not start with
|
||||
a dot character.
|
||||
|
||||
You can make glob treat dots as normal characters by setting
|
||||
`dot:true` in the options.
|
||||
|
||||
### Basename Matching
|
||||
|
||||
If you set `matchBase:true` in the options, and the pattern has no
|
||||
slashes in it, then it will seek for any file anywhere in the tree
|
||||
with a matching basename. For example, `*.js` would match
|
||||
`test/simple/basic.js`.
|
||||
|
||||
### Empty Sets
|
||||
|
||||
If no matching files are found, then an empty array is returned. This
|
||||
differs from the shell, where the pattern itself is returned. For
|
||||
example:
|
||||
|
||||
$ echo a*s*d*f
|
||||
a*s*d*f
|
||||
|
||||
To get the bash-style behavior, set the `nonull:true` in the options.
|
||||
|
||||
### See Also:
|
||||
|
||||
* `man sh`
|
||||
* `man bash` (Search for "Pattern Matching")
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
* [minimatch documentation](https://github.com/isaacs/minimatch)
|
||||
|
||||
## glob.hasMagic(pattern, [options])
|
||||
|
||||
Returns `true` if there are any special characters in the pattern, and
|
||||
`false` otherwise.
|
||||
|
||||
Note that the options affect the results. If `noext:true` is set in
|
||||
the options object, then `+(a|b)` will not be considered a magic
|
||||
pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`
|
||||
then that is considered magical, unless `nobrace:true` is set in the
|
||||
options.
|
||||
|
||||
## glob(pattern, [options], cb)
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}`
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform an asynchronous glob search.
|
||||
|
||||
## glob.sync(pattern, [options])
|
||||
|
||||
* `pattern` `{String}` Pattern to be matched
|
||||
* `options` `{Object}`
|
||||
* return: `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Perform a synchronous glob search.
|
||||
|
||||
## Class: glob.Glob
|
||||
|
||||
Create a Glob object by instantiating the `glob.Glob` class.
|
||||
|
||||
```javascript
|
||||
var Glob = require("glob").Glob
|
||||
var mg = new Glob(pattern, options, cb)
|
||||
```
|
||||
|
||||
It's an EventEmitter, and starts walking the filesystem to find matches
|
||||
immediately.
|
||||
|
||||
### new glob.Glob(pattern, [options], [cb])
|
||||
|
||||
* `pattern` `{String}` pattern to search for
|
||||
* `options` `{Object}`
|
||||
* `cb` `{Function}` Called when an error occurs, or matches are found
|
||||
* `err` `{Error | null}`
|
||||
* `matches` `{Array<String>}` filenames found matching the pattern
|
||||
|
||||
Note that if the `sync` flag is set in the options, then matches will
|
||||
be immediately available on the `g.found` member.
|
||||
|
||||
### Properties
|
||||
|
||||
* `minimatch` The minimatch object that the glob uses.
|
||||
* `options` The options object passed in.
|
||||
* `aborted` Boolean which is set to true when calling `abort()`. There
|
||||
is no way at this time to continue a glob search after aborting, but
|
||||
you can re-use the statCache to avoid having to duplicate syscalls.
|
||||
* `cache` Convenience object. Each field has the following possible
|
||||
values:
|
||||
* `false` - Path does not exist
|
||||
* `true` - Path exists
|
||||
* `'FILE'` - Path exists, and is not a directory
|
||||
* `'DIR'` - Path exists, and is a directory
|
||||
* `[file, entries, ...]` - Path exists, is a directory, and the
|
||||
array value is the results of `fs.readdir`
|
||||
* `statCache` Cache of `fs.stat` results, to prevent statting the same
|
||||
path multiple times.
|
||||
* `symlinks` A record of which paths are symbolic links, which is
|
||||
relevant in resolving `**` patterns.
|
||||
* `realpathCache` An optional object which is passed to `fs.realpath`
|
||||
to minimize unnecessary syscalls. It is stored on the instantiated
|
||||
Glob object, and may be re-used.
|
||||
|
||||
### Events
|
||||
|
||||
* `end` When the matching is finished, this is emitted with all the
|
||||
matches found. If the `nonull` option is set, and no match was found,
|
||||
then the `matches` list contains the original pattern. The matches
|
||||
are sorted, unless the `nosort` flag is set.
|
||||
* `match` Every time a match is found, this is emitted with the specific
|
||||
thing that matched. It is not deduplicated or resolved to a realpath.
|
||||
* `error` Emitted when an unexpected error is encountered, or whenever
|
||||
any fs error occurs if `options.strict` is set.
|
||||
* `abort` When `abort()` is called, this event is raised.
|
||||
|
||||
### Methods
|
||||
|
||||
* `pause` Temporarily stop the search
|
||||
* `resume` Resume the search
|
||||
* `abort` Stop the search forever
|
||||
|
||||
### Options
|
||||
|
||||
All the options that can be passed to Minimatch can also be passed to
|
||||
Glob to change pattern matching behavior. Also, some have been added,
|
||||
or have glob-specific ramifications.
|
||||
|
||||
All options are false by default, unless otherwise noted.
|
||||
|
||||
All options are added to the Glob object, as well.
|
||||
|
||||
If you are running many `glob` operations, you can pass a Glob object
|
||||
as the `options` argument to a subsequent operation to shortcut some
|
||||
`stat` and `readdir` calls. At the very least, you may pass in shared
|
||||
`symlinks`, `statCache`, `realpathCache`, and `cache` options, so that
|
||||
parallel glob operations will be sped up by sharing information about
|
||||
the filesystem.
|
||||
|
||||
* `cwd` The current working directory in which to search. Defaults
|
||||
to `process.cwd()`.
|
||||
* `root` The place where patterns starting with `/` will be mounted
|
||||
onto. Defaults to `path.resolve(options.cwd, "/")` (`/` on Unix
|
||||
systems, and `C:\` or some such on Windows.)
|
||||
* `dot` Include `.dot` files in normal matches and `globstar` matches.
|
||||
Note that an explicit dot in a portion of the pattern will always
|
||||
match dot files.
|
||||
* `nomount` By default, a pattern starting with a forward-slash will be
|
||||
"mounted" onto the root setting, so that a valid filesystem path is
|
||||
returned. Set this flag to disable that behavior.
|
||||
* `mark` Add a `/` character to directory matches. Note that this
|
||||
requires additional stat calls.
|
||||
* `nosort` Don't sort the results.
|
||||
* `stat` Set to true to stat *all* results. This reduces performance
|
||||
somewhat, and is completely unnecessary, unless `readdir` is presumed
|
||||
to be an untrustworthy indicator of file existence.
|
||||
* `silent` When an unusual error is encountered when attempting to
|
||||
read a directory, a warning will be printed to stderr. Set the
|
||||
`silent` option to true to suppress these warnings.
|
||||
* `strict` When an unusual error is encountered when attempting to
|
||||
read a directory, the process will just continue on in search of
|
||||
other matches. Set the `strict` option to raise an error in these
|
||||
cases.
|
||||
* `cache` See `cache` property above. Pass in a previously generated
|
||||
cache object to save some fs calls.
|
||||
* `statCache` A cache of results of filesystem information, to prevent
|
||||
unnecessary stat calls. While it should not normally be necessary
|
||||
to set this, you may pass the statCache from one glob() call to the
|
||||
options object of another, if you know that the filesystem will not
|
||||
change between calls. (See "Race Conditions" below.)
|
||||
* `symlinks` A cache of known symbolic links. You may pass in a
|
||||
previously generated `symlinks` object to save `lstat` calls when
|
||||
resolving `**` matches.
|
||||
* `sync` DEPRECATED: use `glob.sync(pattern, opts)` instead.
|
||||
* `nounique` In some cases, brace-expanded patterns can result in the
|
||||
same file showing up multiple times in the result set. By default,
|
||||
this implementation prevents duplicates in the result set. Set this
|
||||
flag to disable that behavior.
|
||||
* `nonull` Set to never return an empty set, instead returning a set
|
||||
containing the pattern itself. This is the default in glob(3).
|
||||
* `debug` Set to enable debug logging in minimatch and glob.
|
||||
* `nobrace` Do not expand `{a,b}` and `{1..3}` brace sets.
|
||||
* `noglobstar` Do not match `**` against multiple filenames. (Ie,
|
||||
treat it as a normal `*` instead.)
|
||||
* `noext` Do not match `+(a|b)` "extglob" patterns.
|
||||
* `nocase` Perform a case-insensitive match. Note: on
|
||||
case-insensitive filesystems, non-magic patterns will match by
|
||||
default, since `stat` and `readdir` will not raise errors.
|
||||
* `matchBase` Perform a basename-only match if the pattern does not
|
||||
contain any slash characters. That is, `*.js` would be treated as
|
||||
equivalent to `**/*.js`, matching all js files in all directories.
|
||||
* `nodir` Do not match directories, only files. (Note: to match
|
||||
*only* directories, simply put a `/` at the end of the pattern.)
|
||||
* `ignore` Add a pattern or an array of glob patterns to exclude matches.
|
||||
Note: `ignore` patterns are *always* in `dot:true` mode, regardless
|
||||
of any other settings.
|
||||
* `follow` Follow symlinked directories when expanding `**` patterns.
|
||||
Note that this can result in a lot of duplicate references in the
|
||||
presence of cyclic links.
|
||||
* `realpath` Set to true to call `fs.realpath` on all of the results.
|
||||
In the case of a symlink that cannot be resolved, the full absolute
|
||||
path to the matched entry is returned (though it will usually be a
|
||||
broken symlink)
|
||||
* `absolute` Set to true to always receive absolute paths for matched
|
||||
files. Unlike `realpath`, this also affects the values returned in
|
||||
the `match` event.
|
||||
* `fs` File-system object with Node's `fs` API. By default, the built-in
|
||||
`fs` module will be used. Set to a volume provided by a library like
|
||||
`memfs` to avoid using the "real" file-system.
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between node-glob and other
|
||||
implementations, and are intentional.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.3, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
Note that symlinked directories are not crawled as part of a `**`,
|
||||
though their contents may match against subsequent portions of the
|
||||
pattern. This prevents infinite loops and duplicates and the like.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then glob returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`glob.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
|
||||
### Comments and Negation
|
||||
|
||||
Previously, this module let you mark a pattern as a "comment" if it
|
||||
started with a `#` character, or a "negated" pattern if it started
|
||||
with a `!` character.
|
||||
|
||||
These options were deprecated in version 5, and removed in version 6.
|
||||
|
||||
To specify things that should not match, use the `ignore` option.
|
||||
|
||||
## Windows
|
||||
|
||||
**Please only use forward-slashes in glob expressions.**
|
||||
|
||||
Though windows uses either `/` or `\` as its path separator, only `/`
|
||||
characters are used by this glob implementation. You must use
|
||||
forward-slashes **only** in glob expressions. Back-slashes will always
|
||||
be interpreted as escape characters, not path separators.
|
||||
|
||||
Results from absolute patterns such as `/foo/*` are mounted onto the
|
||||
root setting using `path.join`. On windows, this will by default result
|
||||
in `/foo/*` matching `C:\foo\bar.txt`.
|
||||
|
||||
## Race Conditions
|
||||
|
||||
Glob searching, by its very nature, is susceptible to race conditions,
|
||||
since it relies on directory walking and such.
|
||||
|
||||
As a result, it is possible that a file that exists when glob looks for
|
||||
it may have been deleted or modified by the time it returns the result.
|
||||
|
||||
As part of its internal implementation, this program caches all stat
|
||||
and readdir calls that it makes, in order to cut down on system
|
||||
overhead. However, this also makes it even more susceptible to races,
|
||||
especially if the cache or statCache objects are reused between glob
|
||||
calls.
|
||||
|
||||
Users are thus advised not to use a glob result as a guarantee of
|
||||
filesystem state in the face of rapid changes. For the vast majority
|
||||
of operations, this is never a problem.
|
||||
|
||||
## Glob Logo
|
||||
Glob's logo was created by [Tanya Brassie](http://tanyabrassie.com/). Logo files can be found [here](https://github.com/isaacs/node-glob/tree/master/logo).
|
||||
|
||||
The logo is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
|
||||
|
||||
## Contributing
|
||||
|
||||
Any change to behavior (including bugfixes) must come with a test.
|
||||
|
||||
Patches that fail tests or reduce performance will be rejected.
|
||||
|
||||
```
|
||||
# to run tests
|
||||
npm test
|
||||
|
||||
# to re-generate test fixtures
|
||||
npm run test-regen
|
||||
|
||||
# to benchmark against bash/zsh
|
||||
npm run bench
|
||||
|
||||
# to profile javascript
|
||||
npm run prof
|
||||
```
|
||||
|
||||

|
||||
238
node_modules/@vercel/nft/node_modules/glob/common.js
generated
vendored
Normal file
238
node_modules/@vercel/nft/node_modules/glob/common.js
generated
vendored
Normal file
@@ -0,0 +1,238 @@
|
||||
exports.setopts = setopts
|
||||
exports.ownProp = ownProp
|
||||
exports.makeAbs = makeAbs
|
||||
exports.finish = finish
|
||||
exports.mark = mark
|
||||
exports.isIgnored = isIgnored
|
||||
exports.childrenIgnored = childrenIgnored
|
||||
|
||||
function ownProp (obj, field) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, field)
|
||||
}
|
||||
|
||||
var fs = require("fs")
|
||||
var path = require("path")
|
||||
var minimatch = require("minimatch")
|
||||
var isAbsolute = require("path-is-absolute")
|
||||
var Minimatch = minimatch.Minimatch
|
||||
|
||||
function alphasort (a, b) {
|
||||
return a.localeCompare(b, 'en')
|
||||
}
|
||||
|
||||
function setupIgnores (self, options) {
|
||||
self.ignore = options.ignore || []
|
||||
|
||||
if (!Array.isArray(self.ignore))
|
||||
self.ignore = [self.ignore]
|
||||
|
||||
if (self.ignore.length) {
|
||||
self.ignore = self.ignore.map(ignoreMap)
|
||||
}
|
||||
}
|
||||
|
||||
// ignore patterns are always in dot:true mode.
|
||||
function ignoreMap (pattern) {
|
||||
var gmatcher = null
|
||||
if (pattern.slice(-3) === '/**') {
|
||||
var gpattern = pattern.replace(/(\/\*\*)+$/, '')
|
||||
gmatcher = new Minimatch(gpattern, { dot: true })
|
||||
}
|
||||
|
||||
return {
|
||||
matcher: new Minimatch(pattern, { dot: true }),
|
||||
gmatcher: gmatcher
|
||||
}
|
||||
}
|
||||
|
||||
function setopts (self, pattern, options) {
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
// base-matching: just use globstar for that.
|
||||
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
||||
if (options.noglobstar) {
|
||||
throw new Error("base matching requires globstar")
|
||||
}
|
||||
pattern = "**/" + pattern
|
||||
}
|
||||
|
||||
self.silent = !!options.silent
|
||||
self.pattern = pattern
|
||||
self.strict = options.strict !== false
|
||||
self.realpath = !!options.realpath
|
||||
self.realpathCache = options.realpathCache || Object.create(null)
|
||||
self.follow = !!options.follow
|
||||
self.dot = !!options.dot
|
||||
self.mark = !!options.mark
|
||||
self.nodir = !!options.nodir
|
||||
if (self.nodir)
|
||||
self.mark = true
|
||||
self.sync = !!options.sync
|
||||
self.nounique = !!options.nounique
|
||||
self.nonull = !!options.nonull
|
||||
self.nosort = !!options.nosort
|
||||
self.nocase = !!options.nocase
|
||||
self.stat = !!options.stat
|
||||
self.noprocess = !!options.noprocess
|
||||
self.absolute = !!options.absolute
|
||||
self.fs = options.fs || fs
|
||||
|
||||
self.maxLength = options.maxLength || Infinity
|
||||
self.cache = options.cache || Object.create(null)
|
||||
self.statCache = options.statCache || Object.create(null)
|
||||
self.symlinks = options.symlinks || Object.create(null)
|
||||
|
||||
setupIgnores(self, options)
|
||||
|
||||
self.changedCwd = false
|
||||
var cwd = process.cwd()
|
||||
if (!ownProp(options, "cwd"))
|
||||
self.cwd = cwd
|
||||
else {
|
||||
self.cwd = path.resolve(options.cwd)
|
||||
self.changedCwd = self.cwd !== cwd
|
||||
}
|
||||
|
||||
self.root = options.root || path.resolve(self.cwd, "/")
|
||||
self.root = path.resolve(self.root)
|
||||
if (process.platform === "win32")
|
||||
self.root = self.root.replace(/\\/g, "/")
|
||||
|
||||
// TODO: is an absolute `cwd` supposed to be resolved against `root`?
|
||||
// e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
|
||||
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd)
|
||||
if (process.platform === "win32")
|
||||
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/")
|
||||
self.nomount = !!options.nomount
|
||||
|
||||
// disable comments and negation in Minimatch.
|
||||
// Note that they are not supported in Glob itself anyway.
|
||||
options.nonegate = true
|
||||
options.nocomment = true
|
||||
// always treat \ in patterns as escapes, not path separators
|
||||
options.allowWindowsEscape = false
|
||||
|
||||
self.minimatch = new Minimatch(pattern, options)
|
||||
self.options = self.minimatch.options
|
||||
}
|
||||
|
||||
function finish (self) {
|
||||
var nou = self.nounique
|
||||
var all = nou ? [] : Object.create(null)
|
||||
|
||||
for (var i = 0, l = self.matches.length; i < l; i ++) {
|
||||
var matches = self.matches[i]
|
||||
if (!matches || Object.keys(matches).length === 0) {
|
||||
if (self.nonull) {
|
||||
// do like the shell, and spit out the literal glob
|
||||
var literal = self.minimatch.globSet[i]
|
||||
if (nou)
|
||||
all.push(literal)
|
||||
else
|
||||
all[literal] = true
|
||||
}
|
||||
} else {
|
||||
// had matches
|
||||
var m = Object.keys(matches)
|
||||
if (nou)
|
||||
all.push.apply(all, m)
|
||||
else
|
||||
m.forEach(function (m) {
|
||||
all[m] = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (!nou)
|
||||
all = Object.keys(all)
|
||||
|
||||
if (!self.nosort)
|
||||
all = all.sort(alphasort)
|
||||
|
||||
// at *some* point we statted all of these
|
||||
if (self.mark) {
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
all[i] = self._mark(all[i])
|
||||
}
|
||||
if (self.nodir) {
|
||||
all = all.filter(function (e) {
|
||||
var notDir = !(/\/$/.test(e))
|
||||
var c = self.cache[e] || self.cache[makeAbs(self, e)]
|
||||
if (notDir && c)
|
||||
notDir = c !== 'DIR' && !Array.isArray(c)
|
||||
return notDir
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (self.ignore.length)
|
||||
all = all.filter(function(m) {
|
||||
return !isIgnored(self, m)
|
||||
})
|
||||
|
||||
self.found = all
|
||||
}
|
||||
|
||||
function mark (self, p) {
|
||||
var abs = makeAbs(self, p)
|
||||
var c = self.cache[abs]
|
||||
var m = p
|
||||
if (c) {
|
||||
var isDir = c === 'DIR' || Array.isArray(c)
|
||||
var slash = p.slice(-1) === '/'
|
||||
|
||||
if (isDir && !slash)
|
||||
m += '/'
|
||||
else if (!isDir && slash)
|
||||
m = m.slice(0, -1)
|
||||
|
||||
if (m !== p) {
|
||||
var mabs = makeAbs(self, m)
|
||||
self.statCache[mabs] = self.statCache[abs]
|
||||
self.cache[mabs] = self.cache[abs]
|
||||
}
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
// lotta situps...
|
||||
function makeAbs (self, f) {
|
||||
var abs = f
|
||||
if (f.charAt(0) === '/') {
|
||||
abs = path.join(self.root, f)
|
||||
} else if (isAbsolute(f) || f === '') {
|
||||
abs = f
|
||||
} else if (self.changedCwd) {
|
||||
abs = path.resolve(self.cwd, f)
|
||||
} else {
|
||||
abs = path.resolve(f)
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
abs = abs.replace(/\\/g, '/')
|
||||
|
||||
return abs
|
||||
}
|
||||
|
||||
|
||||
// Return true, if pattern ends with globstar '**', for the accompanying parent directory.
|
||||
// Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
|
||||
function isIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
|
||||
function childrenIgnored (self, path) {
|
||||
if (!self.ignore.length)
|
||||
return false
|
||||
|
||||
return self.ignore.some(function(item) {
|
||||
return !!(item.gmatcher && item.gmatcher.match(path))
|
||||
})
|
||||
}
|
||||
790
node_modules/@vercel/nft/node_modules/glob/glob.js
generated
vendored
Normal file
790
node_modules/@vercel/nft/node_modules/glob/glob.js
generated
vendored
Normal file
@@ -0,0 +1,790 @@
|
||||
// Approach:
|
||||
//
|
||||
// 1. Get the minimatch set
|
||||
// 2. For each pattern in the set, PROCESS(pattern, false)
|
||||
// 3. Store matches per-set, then uniq them
|
||||
//
|
||||
// PROCESS(pattern, inGlobStar)
|
||||
// Get the first [n] items from pattern that are all strings
|
||||
// Join these together. This is PREFIX.
|
||||
// If there is no more remaining, then stat(PREFIX) and
|
||||
// add to matches if it succeeds. END.
|
||||
//
|
||||
// If inGlobStar and PREFIX is symlink and points to dir
|
||||
// set ENTRIES = []
|
||||
// else readdir(PREFIX) as ENTRIES
|
||||
// If fail, END
|
||||
//
|
||||
// with ENTRIES
|
||||
// If pattern[n] is GLOBSTAR
|
||||
// // handle the case where the globstar match is empty
|
||||
// // by pruning it out, and testing the resulting pattern
|
||||
// PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
|
||||
// // handle other cases.
|
||||
// for ENTRY in ENTRIES (not dotfiles)
|
||||
// // attach globstar + tail onto the entry
|
||||
// // Mark that this entry is a globstar match
|
||||
// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
|
||||
//
|
||||
// else // not globstar
|
||||
// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
|
||||
// Test ENTRY against pattern[n]
|
||||
// If fails, continue
|
||||
// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
|
||||
//
|
||||
// Caveat:
|
||||
// Cache all stats and readdirs results to minimize syscall. Since all
|
||||
// we ever care about is existence and directory-ness, we can just keep
|
||||
// `true` for files, and [children,...] for directories, or `false` for
|
||||
// things that don't exist.
|
||||
|
||||
module.exports = glob
|
||||
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var inherits = require('inherits')
|
||||
var EE = require('events').EventEmitter
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var globSync = require('./sync.js')
|
||||
var common = require('./common.js')
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var inflight = require('inflight')
|
||||
var util = require('util')
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
var once = require('once')
|
||||
|
||||
function glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') cb = options, options = {}
|
||||
if (!options) options = {}
|
||||
|
||||
if (options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return globSync(pattern, options)
|
||||
}
|
||||
|
||||
return new Glob(pattern, options, cb)
|
||||
}
|
||||
|
||||
glob.sync = globSync
|
||||
var GlobSync = glob.GlobSync = globSync.GlobSync
|
||||
|
||||
// old api surface
|
||||
glob.glob = glob
|
||||
|
||||
function extend (origin, add) {
|
||||
if (add === null || typeof add !== 'object') {
|
||||
return origin
|
||||
}
|
||||
|
||||
var keys = Object.keys(add)
|
||||
var i = keys.length
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]]
|
||||
}
|
||||
return origin
|
||||
}
|
||||
|
||||
glob.hasMagic = function (pattern, options_) {
|
||||
var options = extend({}, options_)
|
||||
options.noprocess = true
|
||||
|
||||
var g = new Glob(pattern, options)
|
||||
var set = g.minimatch.set
|
||||
|
||||
if (!pattern)
|
||||
return false
|
||||
|
||||
if (set.length > 1)
|
||||
return true
|
||||
|
||||
for (var j = 0; j < set[0].length; j++) {
|
||||
if (typeof set[0][j] !== 'string')
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
glob.Glob = Glob
|
||||
inherits(Glob, EE)
|
||||
function Glob (pattern, options, cb) {
|
||||
if (typeof options === 'function') {
|
||||
cb = options
|
||||
options = null
|
||||
}
|
||||
|
||||
if (options && options.sync) {
|
||||
if (cb)
|
||||
throw new TypeError('callback provided to sync glob')
|
||||
return new GlobSync(pattern, options)
|
||||
}
|
||||
|
||||
if (!(this instanceof Glob))
|
||||
return new Glob(pattern, options, cb)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
this._didRealPath = false
|
||||
|
||||
// process each pattern in the minimatch set
|
||||
var n = this.minimatch.set.length
|
||||
|
||||
// The matches are stored as {<filename>: true,...} so that
|
||||
// duplicates are automagically pruned.
|
||||
// Later, we do an Object.keys() on these.
|
||||
// Keep them as a list so we can fill in when nonull is set.
|
||||
this.matches = new Array(n)
|
||||
|
||||
if (typeof cb === 'function') {
|
||||
cb = once(cb)
|
||||
this.on('error', cb)
|
||||
this.on('end', function (matches) {
|
||||
cb(null, matches)
|
||||
})
|
||||
}
|
||||
|
||||
var self = this
|
||||
this._processing = 0
|
||||
|
||||
this._emitQueue = []
|
||||
this._processQueue = []
|
||||
this.paused = false
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
if (n === 0)
|
||||
return done()
|
||||
|
||||
var sync = true
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false, done)
|
||||
}
|
||||
sync = false
|
||||
|
||||
function done () {
|
||||
--self._processing
|
||||
if (self._processing <= 0) {
|
||||
if (sync) {
|
||||
process.nextTick(function () {
|
||||
self._finish()
|
||||
})
|
||||
} else {
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._finish = function () {
|
||||
assert(this instanceof Glob)
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (this.realpath && !this._didRealpath)
|
||||
return this._realpath()
|
||||
|
||||
common.finish(this)
|
||||
this.emit('end', this.found)
|
||||
}
|
||||
|
||||
Glob.prototype._realpath = function () {
|
||||
if (this._didRealpath)
|
||||
return
|
||||
|
||||
this._didRealpath = true
|
||||
|
||||
var n = this.matches.length
|
||||
if (n === 0)
|
||||
return this._finish()
|
||||
|
||||
var self = this
|
||||
for (var i = 0; i < this.matches.length; i++)
|
||||
this._realpathSet(i, next)
|
||||
|
||||
function next () {
|
||||
if (--n === 0)
|
||||
self._finish()
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._realpathSet = function (index, cb) {
|
||||
var matchset = this.matches[index]
|
||||
if (!matchset)
|
||||
return cb()
|
||||
|
||||
var found = Object.keys(matchset)
|
||||
var self = this
|
||||
var n = found.length
|
||||
|
||||
if (n === 0)
|
||||
return cb()
|
||||
|
||||
var set = this.matches[index] = Object.create(null)
|
||||
found.forEach(function (p, i) {
|
||||
// If there's a problem with the stat, then it means that
|
||||
// one or more of the links in the realpath couldn't be
|
||||
// resolved. just return the abs value in that case.
|
||||
p = self._makeAbs(p)
|
||||
rp.realpath(p, self.realpathCache, function (er, real) {
|
||||
if (!er)
|
||||
set[real] = true
|
||||
else if (er.syscall === 'stat')
|
||||
set[p] = true
|
||||
else
|
||||
self.emit('error', er) // srsly wtf right here
|
||||
|
||||
if (--n === 0) {
|
||||
self.matches[index] = set
|
||||
cb()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
Glob.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
|
||||
Glob.prototype.abort = function () {
|
||||
this.aborted = true
|
||||
this.emit('abort')
|
||||
}
|
||||
|
||||
Glob.prototype.pause = function () {
|
||||
if (!this.paused) {
|
||||
this.paused = true
|
||||
this.emit('pause')
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype.resume = function () {
|
||||
if (this.paused) {
|
||||
this.emit('resume')
|
||||
this.paused = false
|
||||
if (this._emitQueue.length) {
|
||||
var eq = this._emitQueue.slice(0)
|
||||
this._emitQueue.length = 0
|
||||
for (var i = 0; i < eq.length; i ++) {
|
||||
var e = eq[i]
|
||||
this._emitMatch(e[0], e[1])
|
||||
}
|
||||
}
|
||||
if (this._processQueue.length) {
|
||||
var pq = this._processQueue.slice(0)
|
||||
this._processQueue.length = 0
|
||||
for (var i = 0; i < pq.length; i ++) {
|
||||
var p = pq[i]
|
||||
this._processing--
|
||||
this._process(p[0], p[1], p[2], p[3])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
|
||||
assert(this instanceof Glob)
|
||||
assert(typeof cb === 'function')
|
||||
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
this._processing++
|
||||
if (this.paused) {
|
||||
this._processQueue.push([pattern, index, inGlobStar, cb])
|
||||
return
|
||||
}
|
||||
|
||||
//console.error('PROCESS %d', this._processing, pattern)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// see if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index, cb)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) ||
|
||||
isAbsolute(pattern.map(function (p) {
|
||||
return typeof p === 'string' ? p : '[*]'
|
||||
}).join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip _processing
|
||||
if (childrenIgnored(this, read))
|
||||
return cb()
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb)
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
//console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return cb()
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return cb()
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix) {
|
||||
if (prefix !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
this._process([e].concat(remain), index, inGlobStar, cb)
|
||||
}
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._emitMatch = function (index, e) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
if (this.paused) {
|
||||
this._emitQueue.push([index, e])
|
||||
return
|
||||
}
|
||||
|
||||
var abs = isAbsolute(e) ? e : this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute)
|
||||
e = abs
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
var st = this.statCache[abs]
|
||||
if (st)
|
||||
this.emit('stat', e, st)
|
||||
|
||||
this.emit('match', e)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirInGlobStar = function (abs, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false, cb)
|
||||
|
||||
var lstatkey = 'lstat\0' + abs
|
||||
var self = this
|
||||
var lstatcb = inflight(lstatkey, lstatcb_)
|
||||
|
||||
if (lstatcb)
|
||||
self.fs.lstat(abs, lstatcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (er && er.code === 'ENOENT')
|
||||
return cb()
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
self.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory()) {
|
||||
self.cache[abs] = 'FILE'
|
||||
cb()
|
||||
} else
|
||||
self._readdir(abs, false, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdir = function (abs, inGlobStar, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb)
|
||||
if (!cb)
|
||||
return
|
||||
|
||||
//console.error('RD %j %j', +inGlobStar, abs)
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs, cb)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return cb()
|
||||
|
||||
if (Array.isArray(c))
|
||||
return cb(null, c)
|
||||
}
|
||||
|
||||
var self = this
|
||||
self.fs.readdir(abs, readdirCb(this, abs, cb))
|
||||
}
|
||||
|
||||
function readdirCb (self, abs, cb) {
|
||||
return function (er, entries) {
|
||||
if (er)
|
||||
self._readdirError(abs, er, cb)
|
||||
else
|
||||
self._readdirEntries(abs, entries, cb)
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._readdirEntries = function (abs, entries, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
return cb(null, entries)
|
||||
}
|
||||
|
||||
Glob.prototype._readdirError = function (f, er, cb) {
|
||||
if (this.aborted)
|
||||
return
|
||||
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
this.emit('error', error)
|
||||
this.abort()
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict) {
|
||||
this.emit('error', er)
|
||||
// If the error is handled, then we abort
|
||||
// if not, we threw out of here
|
||||
this.abort()
|
||||
}
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
|
||||
return cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
|
||||
var self = this
|
||||
this._readdir(abs, inGlobStar, function (er, entries) {
|
||||
self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
|
||||
//console.error('pgs2', prefix, remain[0], entries)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return cb()
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false, cb)
|
||||
|
||||
var isSym = this.symlinks[abs]
|
||||
var len = entries.length
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return cb()
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true, cb)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true, cb)
|
||||
}
|
||||
|
||||
cb()
|
||||
}
|
||||
|
||||
Glob.prototype._processSimple = function (prefix, index, cb) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var self = this
|
||||
this._stat(prefix, function (er, exists) {
|
||||
self._processSimple2(prefix, index, er, exists, cb)
|
||||
})
|
||||
}
|
||||
Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
|
||||
|
||||
//console.error('ps2', prefix, exists)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return cb()
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
cb()
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
Glob.prototype._stat = function (f, cb) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return cb()
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return cb(null, c)
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (stat !== undefined) {
|
||||
if (stat === false)
|
||||
return cb(null, stat)
|
||||
else {
|
||||
var type = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
if (needDir && type === 'FILE')
|
||||
return cb()
|
||||
else
|
||||
return cb(null, type, stat)
|
||||
}
|
||||
}
|
||||
|
||||
var self = this
|
||||
var statcb = inflight('stat\0' + abs, lstatcb_)
|
||||
if (statcb)
|
||||
self.fs.lstat(abs, statcb)
|
||||
|
||||
function lstatcb_ (er, lstat) {
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
// If it's a symlink, then treat it as the target, unless
|
||||
// the target does not exist, then treat it as a file.
|
||||
return self.fs.stat(abs, function (er, stat) {
|
||||
if (er)
|
||||
self._stat2(f, abs, null, lstat, cb)
|
||||
else
|
||||
self._stat2(f, abs, er, stat, cb)
|
||||
})
|
||||
} else {
|
||||
self._stat2(f, abs, er, lstat, cb)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return cb()
|
||||
}
|
||||
|
||||
var needDir = f.slice(-1) === '/'
|
||||
this.statCache[abs] = stat
|
||||
|
||||
if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
|
||||
return cb(null, false, stat)
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return cb()
|
||||
|
||||
return cb(null, c, stat)
|
||||
}
|
||||
55
node_modules/@vercel/nft/node_modules/glob/package.json
generated
vendored
Normal file
55
node_modules/@vercel/nft/node_modules/glob/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"name": "glob",
|
||||
"description": "a little globber",
|
||||
"version": "7.2.3",
|
||||
"publishConfig": {
|
||||
"tag": "v7-legacy"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/node-glob.git"
|
||||
},
|
||||
"main": "glob.js",
|
||||
"files": [
|
||||
"glob.js",
|
||||
"sync.js",
|
||||
"common.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"memfs": "^3.2.0",
|
||||
"mkdirp": "0",
|
||||
"rimraf": "^2.2.8",
|
||||
"tap": "^15.0.6",
|
||||
"tick": "0.0.6"
|
||||
},
|
||||
"tap": {
|
||||
"before": "test/00-setup.js",
|
||||
"after": "test/zz-cleanup.js",
|
||||
"jobs": 1
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "npm run benchclean",
|
||||
"profclean": "rm -f v8.log profile.txt",
|
||||
"test": "tap",
|
||||
"test-regen": "npm run profclean && TEST_REGEN=1 node test/00-setup.js",
|
||||
"bench": "bash benchmark.sh",
|
||||
"prof": "bash prof.sh && cat profile.txt",
|
||||
"benchclean": "node benchclean.js"
|
||||
},
|
||||
"license": "ISC",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
}
|
||||
486
node_modules/@vercel/nft/node_modules/glob/sync.js
generated
vendored
Normal file
486
node_modules/@vercel/nft/node_modules/glob/sync.js
generated
vendored
Normal file
@@ -0,0 +1,486 @@
|
||||
module.exports = globSync
|
||||
globSync.GlobSync = GlobSync
|
||||
|
||||
var rp = require('fs.realpath')
|
||||
var minimatch = require('minimatch')
|
||||
var Minimatch = minimatch.Minimatch
|
||||
var Glob = require('./glob.js').Glob
|
||||
var util = require('util')
|
||||
var path = require('path')
|
||||
var assert = require('assert')
|
||||
var isAbsolute = require('path-is-absolute')
|
||||
var common = require('./common.js')
|
||||
var setopts = common.setopts
|
||||
var ownProp = common.ownProp
|
||||
var childrenIgnored = common.childrenIgnored
|
||||
var isIgnored = common.isIgnored
|
||||
|
||||
function globSync (pattern, options) {
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
return new GlobSync(pattern, options).found
|
||||
}
|
||||
|
||||
function GlobSync (pattern, options) {
|
||||
if (!pattern)
|
||||
throw new Error('must provide pattern')
|
||||
|
||||
if (typeof options === 'function' || arguments.length === 3)
|
||||
throw new TypeError('callback provided to sync glob\n'+
|
||||
'See: https://github.com/isaacs/node-glob/issues/167')
|
||||
|
||||
if (!(this instanceof GlobSync))
|
||||
return new GlobSync(pattern, options)
|
||||
|
||||
setopts(this, pattern, options)
|
||||
|
||||
if (this.noprocess)
|
||||
return this
|
||||
|
||||
var n = this.minimatch.set.length
|
||||
this.matches = new Array(n)
|
||||
for (var i = 0; i < n; i ++) {
|
||||
this._process(this.minimatch.set[i], i, false)
|
||||
}
|
||||
this._finish()
|
||||
}
|
||||
|
||||
GlobSync.prototype._finish = function () {
|
||||
assert.ok(this instanceof GlobSync)
|
||||
if (this.realpath) {
|
||||
var self = this
|
||||
this.matches.forEach(function (matchset, index) {
|
||||
var set = self.matches[index] = Object.create(null)
|
||||
for (var p in matchset) {
|
||||
try {
|
||||
p = self._makeAbs(p)
|
||||
var real = rp.realpathSync(p, self.realpathCache)
|
||||
set[real] = true
|
||||
} catch (er) {
|
||||
if (er.syscall === 'stat')
|
||||
set[self._makeAbs(p)] = true
|
||||
else
|
||||
throw er
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
common.finish(this)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._process = function (pattern, index, inGlobStar) {
|
||||
assert.ok(this instanceof GlobSync)
|
||||
|
||||
// Get the first [n] parts of pattern that are all strings.
|
||||
var n = 0
|
||||
while (typeof pattern[n] === 'string') {
|
||||
n ++
|
||||
}
|
||||
// now n is the index of the first one that is *not* a string.
|
||||
|
||||
// See if there's anything else
|
||||
var prefix
|
||||
switch (n) {
|
||||
// if not, then this is rather simple
|
||||
case pattern.length:
|
||||
this._processSimple(pattern.join('/'), index)
|
||||
return
|
||||
|
||||
case 0:
|
||||
// pattern *starts* with some non-trivial item.
|
||||
// going to readdir(cwd), but not include the prefix in matches.
|
||||
prefix = null
|
||||
break
|
||||
|
||||
default:
|
||||
// pattern has some string bits in the front.
|
||||
// whatever it starts with, whether that's 'absolute' like /foo/bar,
|
||||
// or 'relative' like '../baz'
|
||||
prefix = pattern.slice(0, n).join('/')
|
||||
break
|
||||
}
|
||||
|
||||
var remain = pattern.slice(n)
|
||||
|
||||
// get the list of entries.
|
||||
var read
|
||||
if (prefix === null)
|
||||
read = '.'
|
||||
else if (isAbsolute(prefix) ||
|
||||
isAbsolute(pattern.map(function (p) {
|
||||
return typeof p === 'string' ? p : '[*]'
|
||||
}).join('/'))) {
|
||||
if (!prefix || !isAbsolute(prefix))
|
||||
prefix = '/' + prefix
|
||||
read = prefix
|
||||
} else
|
||||
read = prefix
|
||||
|
||||
var abs = this._makeAbs(read)
|
||||
|
||||
//if ignored, skip processing
|
||||
if (childrenIgnored(this, read))
|
||||
return
|
||||
|
||||
var isGlobStar = remain[0] === minimatch.GLOBSTAR
|
||||
if (isGlobStar)
|
||||
this._processGlobStar(prefix, read, abs, remain, index, inGlobStar)
|
||||
else
|
||||
this._processReaddir(prefix, read, abs, remain, index, inGlobStar)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// if the abs isn't a dir, then nothing can match!
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// It will only match dot entries if it starts with a dot, or if
|
||||
// dot is set. Stuff like @(.foo|.bar) isn't allowed.
|
||||
var pn = remain[0]
|
||||
var negate = !!this.minimatch.negate
|
||||
var rawGlob = pn._glob
|
||||
var dotOk = this.dot || rawGlob.charAt(0) === '.'
|
||||
|
||||
var matchedEntries = []
|
||||
for (var i = 0; i < entries.length; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) !== '.' || dotOk) {
|
||||
var m
|
||||
if (negate && !prefix) {
|
||||
m = !e.match(pn)
|
||||
} else {
|
||||
m = e.match(pn)
|
||||
}
|
||||
if (m)
|
||||
matchedEntries.push(e)
|
||||
}
|
||||
}
|
||||
|
||||
var len = matchedEntries.length
|
||||
// If there are no matched entries, then nothing matches.
|
||||
if (len === 0)
|
||||
return
|
||||
|
||||
// if this is the last remaining pattern bit, then no need for
|
||||
// an additional stat *unless* the user has specified mark or
|
||||
// stat explicitly. We know they exist, since readdir returned
|
||||
// them.
|
||||
|
||||
if (remain.length === 1 && !this.mark && !this.stat) {
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
if (prefix) {
|
||||
if (prefix.slice(-1) !== '/')
|
||||
e = prefix + '/' + e
|
||||
else
|
||||
e = prefix + e
|
||||
}
|
||||
|
||||
if (e.charAt(0) === '/' && !this.nomount) {
|
||||
e = path.join(this.root, e)
|
||||
}
|
||||
this._emitMatch(index, e)
|
||||
}
|
||||
// This was the last one, and no stats were needed
|
||||
return
|
||||
}
|
||||
|
||||
// now test all matched entries as stand-ins for that part
|
||||
// of the pattern.
|
||||
remain.shift()
|
||||
for (var i = 0; i < len; i ++) {
|
||||
var e = matchedEntries[i]
|
||||
var newPattern
|
||||
if (prefix)
|
||||
newPattern = [prefix, e]
|
||||
else
|
||||
newPattern = [e]
|
||||
this._process(newPattern.concat(remain), index, inGlobStar)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._emitMatch = function (index, e) {
|
||||
if (isIgnored(this, e))
|
||||
return
|
||||
|
||||
var abs = this._makeAbs(e)
|
||||
|
||||
if (this.mark)
|
||||
e = this._mark(e)
|
||||
|
||||
if (this.absolute) {
|
||||
e = abs
|
||||
}
|
||||
|
||||
if (this.matches[index][e])
|
||||
return
|
||||
|
||||
if (this.nodir) {
|
||||
var c = this.cache[abs]
|
||||
if (c === 'DIR' || Array.isArray(c))
|
||||
return
|
||||
}
|
||||
|
||||
this.matches[index][e] = true
|
||||
|
||||
if (this.stat)
|
||||
this._stat(e)
|
||||
}
|
||||
|
||||
|
||||
GlobSync.prototype._readdirInGlobStar = function (abs) {
|
||||
// follow all symlinked directories forever
|
||||
// just proceed as if this is a non-globstar situation
|
||||
if (this.follow)
|
||||
return this._readdir(abs, false)
|
||||
|
||||
var entries
|
||||
var lstat
|
||||
var stat
|
||||
try {
|
||||
lstat = this.fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er.code === 'ENOENT') {
|
||||
// lstat failed, doesn't exist
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
var isSym = lstat && lstat.isSymbolicLink()
|
||||
this.symlinks[abs] = isSym
|
||||
|
||||
// If it's not a symlink or a dir, then it's definitely a regular file.
|
||||
// don't bother doing a readdir in that case.
|
||||
if (!isSym && lstat && !lstat.isDirectory())
|
||||
this.cache[abs] = 'FILE'
|
||||
else
|
||||
entries = this._readdir(abs, false)
|
||||
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdir = function (abs, inGlobStar) {
|
||||
var entries
|
||||
|
||||
if (inGlobStar && !ownProp(this.symlinks, abs))
|
||||
return this._readdirInGlobStar(abs)
|
||||
|
||||
if (ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
if (!c || c === 'FILE')
|
||||
return null
|
||||
|
||||
if (Array.isArray(c))
|
||||
return c
|
||||
}
|
||||
|
||||
try {
|
||||
return this._readdirEntries(abs, this.fs.readdirSync(abs))
|
||||
} catch (er) {
|
||||
this._readdirError(abs, er)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirEntries = function (abs, entries) {
|
||||
// if we haven't asked to stat everything, then just
|
||||
// assume that everything in there exists, so we can avoid
|
||||
// having to stat it a second time.
|
||||
if (!this.mark && !this.stat) {
|
||||
for (var i = 0; i < entries.length; i ++) {
|
||||
var e = entries[i]
|
||||
if (abs === '/')
|
||||
e = abs + e
|
||||
else
|
||||
e = abs + '/' + e
|
||||
this.cache[e] = true
|
||||
}
|
||||
}
|
||||
|
||||
this.cache[abs] = entries
|
||||
|
||||
// mark and cache dir-ness
|
||||
return entries
|
||||
}
|
||||
|
||||
GlobSync.prototype._readdirError = function (f, er) {
|
||||
// handle errors, and cache the information
|
||||
switch (er.code) {
|
||||
case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
|
||||
case 'ENOTDIR': // totally normal. means it *does* exist.
|
||||
var abs = this._makeAbs(f)
|
||||
this.cache[abs] = 'FILE'
|
||||
if (abs === this.cwdAbs) {
|
||||
var error = new Error(er.code + ' invalid cwd ' + this.cwd)
|
||||
error.path = this.cwd
|
||||
error.code = er.code
|
||||
throw error
|
||||
}
|
||||
break
|
||||
|
||||
case 'ENOENT': // not terribly unusual
|
||||
case 'ELOOP':
|
||||
case 'ENAMETOOLONG':
|
||||
case 'UNKNOWN':
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
break
|
||||
|
||||
default: // some unusual error. Treat as failure.
|
||||
this.cache[this._makeAbs(f)] = false
|
||||
if (this.strict)
|
||||
throw er
|
||||
if (!this.silent)
|
||||
console.error('glob error', er)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
|
||||
|
||||
var entries = this._readdir(abs, inGlobStar)
|
||||
|
||||
// no entries means not a dir, so it can never have matches
|
||||
// foo.txt/** doesn't match foo.txt
|
||||
if (!entries)
|
||||
return
|
||||
|
||||
// test without the globstar, and with every child both below
|
||||
// and replacing the globstar.
|
||||
var remainWithoutGlobStar = remain.slice(1)
|
||||
var gspref = prefix ? [ prefix ] : []
|
||||
var noGlobStar = gspref.concat(remainWithoutGlobStar)
|
||||
|
||||
// the noGlobStar pattern exits the inGlobStar state
|
||||
this._process(noGlobStar, index, false)
|
||||
|
||||
var len = entries.length
|
||||
var isSym = this.symlinks[abs]
|
||||
|
||||
// If it's a symlink, and we're in a globstar, then stop
|
||||
if (isSym && inGlobStar)
|
||||
return
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
var e = entries[i]
|
||||
if (e.charAt(0) === '.' && !this.dot)
|
||||
continue
|
||||
|
||||
// these two cases enter the inGlobStar state
|
||||
var instead = gspref.concat(entries[i], remainWithoutGlobStar)
|
||||
this._process(instead, index, true)
|
||||
|
||||
var below = gspref.concat(entries[i], remain)
|
||||
this._process(below, index, true)
|
||||
}
|
||||
}
|
||||
|
||||
GlobSync.prototype._processSimple = function (prefix, index) {
|
||||
// XXX review this. Shouldn't it be doing the mounting etc
|
||||
// before doing stat? kinda weird?
|
||||
var exists = this._stat(prefix)
|
||||
|
||||
if (!this.matches[index])
|
||||
this.matches[index] = Object.create(null)
|
||||
|
||||
// If it doesn't exist, then just mark the lack of results
|
||||
if (!exists)
|
||||
return
|
||||
|
||||
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
||||
var trail = /[\/\\]$/.test(prefix)
|
||||
if (prefix.charAt(0) === '/') {
|
||||
prefix = path.join(this.root, prefix)
|
||||
} else {
|
||||
prefix = path.resolve(this.root, prefix)
|
||||
if (trail)
|
||||
prefix += '/'
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'win32')
|
||||
prefix = prefix.replace(/\\/g, '/')
|
||||
|
||||
// Mark this as a match
|
||||
this._emitMatch(index, prefix)
|
||||
}
|
||||
|
||||
// Returns either 'DIR', 'FILE', or false
|
||||
GlobSync.prototype._stat = function (f) {
|
||||
var abs = this._makeAbs(f)
|
||||
var needDir = f.slice(-1) === '/'
|
||||
|
||||
if (f.length > this.maxLength)
|
||||
return false
|
||||
|
||||
if (!this.stat && ownProp(this.cache, abs)) {
|
||||
var c = this.cache[abs]
|
||||
|
||||
if (Array.isArray(c))
|
||||
c = 'DIR'
|
||||
|
||||
// It exists, but maybe not how we need it
|
||||
if (!needDir || c === 'DIR')
|
||||
return c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
// otherwise we have to stat, because maybe c=true
|
||||
// if we know it exists, but not what it is.
|
||||
}
|
||||
|
||||
var exists
|
||||
var stat = this.statCache[abs]
|
||||
if (!stat) {
|
||||
var lstat
|
||||
try {
|
||||
lstat = this.fs.lstatSync(abs)
|
||||
} catch (er) {
|
||||
if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
|
||||
this.statCache[abs] = false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (lstat && lstat.isSymbolicLink()) {
|
||||
try {
|
||||
stat = this.fs.statSync(abs)
|
||||
} catch (er) {
|
||||
stat = lstat
|
||||
}
|
||||
} else {
|
||||
stat = lstat
|
||||
}
|
||||
}
|
||||
|
||||
this.statCache[abs] = stat
|
||||
|
||||
var c = true
|
||||
if (stat)
|
||||
c = stat.isDirectory() ? 'DIR' : 'FILE'
|
||||
|
||||
this.cache[abs] = this.cache[abs] || c
|
||||
|
||||
if (needDir && c === 'FILE')
|
||||
return false
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
GlobSync.prototype._mark = function (p) {
|
||||
return common.mark(this, p)
|
||||
}
|
||||
|
||||
GlobSync.prototype._makeAbs = function (f) {
|
||||
return common.makeAbs(this, f)
|
||||
}
|
||||
15
node_modules/@vercel/nft/node_modules/minimatch/LICENSE
generated
vendored
Normal file
15
node_modules/@vercel/nft/node_modules/minimatch/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
230
node_modules/@vercel/nft/node_modules/minimatch/README.md
generated
vendored
Normal file
230
node_modules/@vercel/nft/node_modules/minimatch/README.md
generated
vendored
Normal file
@@ -0,0 +1,230 @@
|
||||
# minimatch
|
||||
|
||||
A minimal matching utility.
|
||||
|
||||
[](http://travis-ci.org/isaacs/minimatch)
|
||||
|
||||
|
||||
This is the matching library used internally by npm.
|
||||
|
||||
It works by converting glob expressions into JavaScript `RegExp`
|
||||
objects.
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var minimatch = require("minimatch")
|
||||
|
||||
minimatch("bar.foo", "*.foo") // true!
|
||||
minimatch("bar.foo", "*.bar") // false!
|
||||
minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy!
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
Supports these glob features:
|
||||
|
||||
* Brace Expansion
|
||||
* Extended glob matching
|
||||
* "Globstar" `**` matching
|
||||
|
||||
See:
|
||||
|
||||
* `man sh`
|
||||
* `man bash`
|
||||
* `man 3 fnmatch`
|
||||
* `man 5 gitignore`
|
||||
|
||||
## Minimatch Class
|
||||
|
||||
Create a minimatch object by instantiating the `minimatch.Minimatch` class.
|
||||
|
||||
```javascript
|
||||
var Minimatch = require("minimatch").Minimatch
|
||||
var mm = new Minimatch(pattern, options)
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
* `pattern` The original pattern the minimatch object represents.
|
||||
* `options` The options supplied to the constructor.
|
||||
* `set` A 2-dimensional array of regexp or string expressions.
|
||||
Each row in the
|
||||
array corresponds to a brace-expanded pattern. Each item in the row
|
||||
corresponds to a single path-part. For example, the pattern
|
||||
`{a,b/c}/d` would expand to a set of patterns like:
|
||||
|
||||
[ [ a, d ]
|
||||
, [ b, c, d ] ]
|
||||
|
||||
If a portion of the pattern doesn't have any "magic" in it
|
||||
(that is, it's something like `"foo"` rather than `fo*o?`), then it
|
||||
will be left as a string rather than converted to a regular
|
||||
expression.
|
||||
|
||||
* `regexp` Created by the `makeRe` method. A single regular expression
|
||||
expressing the entire pattern. This is useful in cases where you wish
|
||||
to use the pattern somewhat like `fnmatch(3)` with `FNM_PATH` enabled.
|
||||
* `negate` True if the pattern is negated.
|
||||
* `comment` True if the pattern is a comment.
|
||||
* `empty` True if the pattern is `""`.
|
||||
|
||||
### Methods
|
||||
|
||||
* `makeRe` Generate the `regexp` member if necessary, and return it.
|
||||
Will return `false` if the pattern is invalid.
|
||||
* `match(fname)` Return true if the filename matches the pattern, or
|
||||
false otherwise.
|
||||
* `matchOne(fileArray, patternArray, partial)` Take a `/`-split
|
||||
filename, and match it against a single row in the `regExpSet`. This
|
||||
method is mainly for internal use, but is exposed so that it can be
|
||||
used by a glob-walker that needs to avoid excessive filesystem calls.
|
||||
|
||||
All other methods are internal, and will be called as necessary.
|
||||
|
||||
### minimatch(path, pattern, options)
|
||||
|
||||
Main export. Tests a path against the pattern using the options.
|
||||
|
||||
```javascript
|
||||
var isJS = minimatch(file, "*.js", { matchBase: true })
|
||||
```
|
||||
|
||||
### minimatch.filter(pattern, options)
|
||||
|
||||
Returns a function that tests its
|
||||
supplied argument, suitable for use with `Array.filter`. Example:
|
||||
|
||||
```javascript
|
||||
var javascripts = fileList.filter(minimatch.filter("*.js", {matchBase: true}))
|
||||
```
|
||||
|
||||
### minimatch.match(list, pattern, options)
|
||||
|
||||
Match against the list of
|
||||
files, in the style of fnmatch or glob. If nothing is matched, and
|
||||
options.nonull is set, then return a list containing the pattern itself.
|
||||
|
||||
```javascript
|
||||
var javascripts = minimatch.match(fileList, "*.js", {matchBase: true}))
|
||||
```
|
||||
|
||||
### minimatch.makeRe(pattern, options)
|
||||
|
||||
Make a regular expression object from the pattern.
|
||||
|
||||
## Options
|
||||
|
||||
All options are `false` by default.
|
||||
|
||||
### debug
|
||||
|
||||
Dump a ton of stuff to stderr.
|
||||
|
||||
### nobrace
|
||||
|
||||
Do not expand `{a,b}` and `{1..3}` brace sets.
|
||||
|
||||
### noglobstar
|
||||
|
||||
Disable `**` matching against multiple folder names.
|
||||
|
||||
### dot
|
||||
|
||||
Allow patterns to match filenames starting with a period, even if
|
||||
the pattern does not explicitly have a period in that spot.
|
||||
|
||||
Note that by default, `a/**/b` will **not** match `a/.d/b`, unless `dot`
|
||||
is set.
|
||||
|
||||
### noext
|
||||
|
||||
Disable "extglob" style patterns like `+(a|b)`.
|
||||
|
||||
### nocase
|
||||
|
||||
Perform a case-insensitive match.
|
||||
|
||||
### nonull
|
||||
|
||||
When a match is not found by `minimatch.match`, return a list containing
|
||||
the pattern itself if this option is set. When not set, an empty list
|
||||
is returned if there are no matches.
|
||||
|
||||
### matchBase
|
||||
|
||||
If set, then patterns without slashes will be matched
|
||||
against the basename of the path if it contains slashes. For example,
|
||||
`a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
|
||||
|
||||
### nocomment
|
||||
|
||||
Suppress the behavior of treating `#` at the start of a pattern as a
|
||||
comment.
|
||||
|
||||
### nonegate
|
||||
|
||||
Suppress the behavior of treating a leading `!` character as negation.
|
||||
|
||||
### flipNegate
|
||||
|
||||
Returns from negate expressions the same as if they were not negated.
|
||||
(Ie, true on a hit, false on a miss.)
|
||||
|
||||
### partial
|
||||
|
||||
Compare a partial path to a pattern. As long as the parts of the path that
|
||||
are present are not contradicted by the pattern, it will be treated as a
|
||||
match. This is useful in applications where you're walking through a
|
||||
folder structure, and don't yet have the full path, but want to ensure that
|
||||
you do not walk down paths that can never be a match.
|
||||
|
||||
For example,
|
||||
|
||||
```js
|
||||
minimatch('/a/b', '/a/*/c/d', { partial: true }) // true, might be /a/b/c/d
|
||||
minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d
|
||||
minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
|
||||
```
|
||||
|
||||
### allowWindowsEscape
|
||||
|
||||
Windows path separator `\` is by default converted to `/`, which
|
||||
prohibits the usage of `\` as a escape character. This flag skips that
|
||||
behavior and allows using the escape character.
|
||||
|
||||
## Comparisons to other fnmatch/glob implementations
|
||||
|
||||
While strict compliance with the existing standards is a worthwhile
|
||||
goal, some discrepancies exist between minimatch and other
|
||||
implementations, and are intentional.
|
||||
|
||||
If the pattern starts with a `!` character, then it is negated. Set the
|
||||
`nonegate` flag to suppress this behavior, and treat leading `!`
|
||||
characters normally. This is perhaps relevant if you wish to start the
|
||||
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
|
||||
characters at the start of a pattern will negate the pattern multiple
|
||||
times.
|
||||
|
||||
If a pattern starts with `#`, then it is treated as a comment, and
|
||||
will not match anything. Use `\#` to match a literal `#` at the
|
||||
start of a line, or set the `nocomment` flag to suppress this behavior.
|
||||
|
||||
The double-star character `**` is supported by default, unless the
|
||||
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
||||
and bash 4.1, where `**` only has special significance if it is the only
|
||||
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
||||
`a/**b` will not.
|
||||
|
||||
If an escaped pattern has no matches, and the `nonull` flag is set,
|
||||
then minimatch.match returns the pattern as-provided, rather than
|
||||
interpreting the character escapes. For example,
|
||||
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
||||
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
||||
that it does not resolve escaped pattern characters.
|
||||
|
||||
If brace expansion is not disabled, then it is performed before any
|
||||
other interpretation of the glob pattern. Thus, a pattern like
|
||||
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
||||
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
||||
checked for validity. Since those two are valid, matching proceeds.
|
||||
947
node_modules/@vercel/nft/node_modules/minimatch/minimatch.js
generated
vendored
Normal file
947
node_modules/@vercel/nft/node_modules/minimatch/minimatch.js
generated
vendored
Normal file
@@ -0,0 +1,947 @@
|
||||
module.exports = minimatch
|
||||
minimatch.Minimatch = Minimatch
|
||||
|
||||
var path = (function () { try { return require('path') } catch (e) {}}()) || {
|
||||
sep: '/'
|
||||
}
|
||||
minimatch.sep = path.sep
|
||||
|
||||
var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
|
||||
var expand = require('brace-expansion')
|
||||
|
||||
var plTypes = {
|
||||
'!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
|
||||
'?': { open: '(?:', close: ')?' },
|
||||
'+': { open: '(?:', close: ')+' },
|
||||
'*': { open: '(?:', close: ')*' },
|
||||
'@': { open: '(?:', close: ')' }
|
||||
}
|
||||
|
||||
// any single thing other than /
|
||||
// don't need to escape / when using new RegExp()
|
||||
var qmark = '[^/]'
|
||||
|
||||
// * => any number of characters
|
||||
var star = qmark + '*?'
|
||||
|
||||
// ** when dots are allowed. Anything goes, except .. and .
|
||||
// not (^ or / followed by one or two dots followed by $ or /),
|
||||
// followed by anything, any number of times.
|
||||
var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
|
||||
|
||||
// not a ^ or / followed by a dot,
|
||||
// followed by anything, any number of times.
|
||||
var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
|
||||
|
||||
// characters that need to be escaped in RegExp.
|
||||
var reSpecials = charSet('().*{}+?[]^$\\!')
|
||||
|
||||
// "abc" -> { a:true, b:true, c:true }
|
||||
function charSet (s) {
|
||||
return s.split('').reduce(function (set, c) {
|
||||
set[c] = true
|
||||
return set
|
||||
}, {})
|
||||
}
|
||||
|
||||
// normalizes slashes.
|
||||
var slashSplit = /\/+/
|
||||
|
||||
minimatch.filter = filter
|
||||
function filter (pattern, options) {
|
||||
options = options || {}
|
||||
return function (p, i, list) {
|
||||
return minimatch(p, pattern, options)
|
||||
}
|
||||
}
|
||||
|
||||
function ext (a, b) {
|
||||
b = b || {}
|
||||
var t = {}
|
||||
Object.keys(a).forEach(function (k) {
|
||||
t[k] = a[k]
|
||||
})
|
||||
Object.keys(b).forEach(function (k) {
|
||||
t[k] = b[k]
|
||||
})
|
||||
return t
|
||||
}
|
||||
|
||||
minimatch.defaults = function (def) {
|
||||
if (!def || typeof def !== 'object' || !Object.keys(def).length) {
|
||||
return minimatch
|
||||
}
|
||||
|
||||
var orig = minimatch
|
||||
|
||||
var m = function minimatch (p, pattern, options) {
|
||||
return orig(p, pattern, ext(def, options))
|
||||
}
|
||||
|
||||
m.Minimatch = function Minimatch (pattern, options) {
|
||||
return new orig.Minimatch(pattern, ext(def, options))
|
||||
}
|
||||
m.Minimatch.defaults = function defaults (options) {
|
||||
return orig.defaults(ext(def, options)).Minimatch
|
||||
}
|
||||
|
||||
m.filter = function filter (pattern, options) {
|
||||
return orig.filter(pattern, ext(def, options))
|
||||
}
|
||||
|
||||
m.defaults = function defaults (options) {
|
||||
return orig.defaults(ext(def, options))
|
||||
}
|
||||
|
||||
m.makeRe = function makeRe (pattern, options) {
|
||||
return orig.makeRe(pattern, ext(def, options))
|
||||
}
|
||||
|
||||
m.braceExpand = function braceExpand (pattern, options) {
|
||||
return orig.braceExpand(pattern, ext(def, options))
|
||||
}
|
||||
|
||||
m.match = function (list, pattern, options) {
|
||||
return orig.match(list, pattern, ext(def, options))
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
|
||||
Minimatch.defaults = function (def) {
|
||||
return minimatch.defaults(def).Minimatch
|
||||
}
|
||||
|
||||
function minimatch (p, pattern, options) {
|
||||
assertValidPattern(pattern)
|
||||
|
||||
if (!options) options = {}
|
||||
|
||||
// shortcut: comments match nothing.
|
||||
if (!options.nocomment && pattern.charAt(0) === '#') {
|
||||
return false
|
||||
}
|
||||
|
||||
return new Minimatch(pattern, options).match(p)
|
||||
}
|
||||
|
||||
function Minimatch (pattern, options) {
|
||||
if (!(this instanceof Minimatch)) {
|
||||
return new Minimatch(pattern, options)
|
||||
}
|
||||
|
||||
assertValidPattern(pattern)
|
||||
|
||||
if (!options) options = {}
|
||||
|
||||
pattern = pattern.trim()
|
||||
|
||||
// windows support: need to use /, not \
|
||||
if (!options.allowWindowsEscape && path.sep !== '/') {
|
||||
pattern = pattern.split(path.sep).join('/')
|
||||
}
|
||||
|
||||
this.options = options
|
||||
this.set = []
|
||||
this.pattern = pattern
|
||||
this.regexp = null
|
||||
this.negate = false
|
||||
this.comment = false
|
||||
this.empty = false
|
||||
this.partial = !!options.partial
|
||||
|
||||
// make the set of regexps etc.
|
||||
this.make()
|
||||
}
|
||||
|
||||
Minimatch.prototype.debug = function () {}
|
||||
|
||||
Minimatch.prototype.make = make
|
||||
function make () {
|
||||
var pattern = this.pattern
|
||||
var options = this.options
|
||||
|
||||
// empty patterns and comments match nothing.
|
||||
if (!options.nocomment && pattern.charAt(0) === '#') {
|
||||
this.comment = true
|
||||
return
|
||||
}
|
||||
if (!pattern) {
|
||||
this.empty = true
|
||||
return
|
||||
}
|
||||
|
||||
// step 1: figure out negation, etc.
|
||||
this.parseNegate()
|
||||
|
||||
// step 2: expand braces
|
||||
var set = this.globSet = this.braceExpand()
|
||||
|
||||
if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
|
||||
|
||||
this.debug(this.pattern, set)
|
||||
|
||||
// step 3: now we have a set, so turn each one into a series of path-portion
|
||||
// matching patterns.
|
||||
// These will be regexps, except in the case of "**", which is
|
||||
// set to the GLOBSTAR object for globstar behavior,
|
||||
// and will not contain any / characters
|
||||
set = this.globParts = set.map(function (s) {
|
||||
return s.split(slashSplit)
|
||||
})
|
||||
|
||||
this.debug(this.pattern, set)
|
||||
|
||||
// glob --> regexps
|
||||
set = set.map(function (s, si, set) {
|
||||
return s.map(this.parse, this)
|
||||
}, this)
|
||||
|
||||
this.debug(this.pattern, set)
|
||||
|
||||
// filter out everything that didn't compile properly.
|
||||
set = set.filter(function (s) {
|
||||
return s.indexOf(false) === -1
|
||||
})
|
||||
|
||||
this.debug(this.pattern, set)
|
||||
|
||||
this.set = set
|
||||
}
|
||||
|
||||
Minimatch.prototype.parseNegate = parseNegate
|
||||
function parseNegate () {
|
||||
var pattern = this.pattern
|
||||
var negate = false
|
||||
var options = this.options
|
||||
var negateOffset = 0
|
||||
|
||||
if (options.nonegate) return
|
||||
|
||||
for (var i = 0, l = pattern.length
|
||||
; i < l && pattern.charAt(i) === '!'
|
||||
; i++) {
|
||||
negate = !negate
|
||||
negateOffset++
|
||||
}
|
||||
|
||||
if (negateOffset) this.pattern = pattern.substr(negateOffset)
|
||||
this.negate = negate
|
||||
}
|
||||
|
||||
// Brace expansion:
|
||||
// a{b,c}d -> abd acd
|
||||
// a{b,}c -> abc ac
|
||||
// a{0..3}d -> a0d a1d a2d a3d
|
||||
// a{b,c{d,e}f}g -> abg acdfg acefg
|
||||
// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
|
||||
//
|
||||
// Invalid sets are not expanded.
|
||||
// a{2..}b -> a{2..}b
|
||||
// a{b}c -> a{b}c
|
||||
minimatch.braceExpand = function (pattern, options) {
|
||||
return braceExpand(pattern, options)
|
||||
}
|
||||
|
||||
Minimatch.prototype.braceExpand = braceExpand
|
||||
|
||||
function braceExpand (pattern, options) {
|
||||
if (!options) {
|
||||
if (this instanceof Minimatch) {
|
||||
options = this.options
|
||||
} else {
|
||||
options = {}
|
||||
}
|
||||
}
|
||||
|
||||
pattern = typeof pattern === 'undefined'
|
||||
? this.pattern : pattern
|
||||
|
||||
assertValidPattern(pattern)
|
||||
|
||||
// Thanks to Yeting Li <https://github.com/yetingli> for
|
||||
// improving this regexp to avoid a ReDOS vulnerability.
|
||||
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
||||
// shortcut. no need to expand.
|
||||
return [pattern]
|
||||
}
|
||||
|
||||
return expand(pattern)
|
||||
}
|
||||
|
||||
var MAX_PATTERN_LENGTH = 1024 * 64
|
||||
var assertValidPattern = function (pattern) {
|
||||
if (typeof pattern !== 'string') {
|
||||
throw new TypeError('invalid pattern')
|
||||
}
|
||||
|
||||
if (pattern.length > MAX_PATTERN_LENGTH) {
|
||||
throw new TypeError('pattern is too long')
|
||||
}
|
||||
}
|
||||
|
||||
// parse a component of the expanded set.
|
||||
// At this point, no pattern may contain "/" in it
|
||||
// so we're going to return a 2d array, where each entry is the full
|
||||
// pattern, split on '/', and then turned into a regular expression.
|
||||
// A regexp is made at the end which joins each array with an
|
||||
// escaped /, and another full one which joins each regexp with |.
|
||||
//
|
||||
// Following the lead of Bash 4.1, note that "**" only has special meaning
|
||||
// when it is the *only* thing in a path portion. Otherwise, any series
|
||||
// of * is equivalent to a single *. Globstar behavior is enabled by
|
||||
// default, and can be disabled by setting options.noglobstar.
|
||||
Minimatch.prototype.parse = parse
|
||||
var SUBPARSE = {}
|
||||
function parse (pattern, isSub) {
|
||||
assertValidPattern(pattern)
|
||||
|
||||
var options = this.options
|
||||
|
||||
// shortcuts
|
||||
if (pattern === '**') {
|
||||
if (!options.noglobstar)
|
||||
return GLOBSTAR
|
||||
else
|
||||
pattern = '*'
|
||||
}
|
||||
if (pattern === '') return ''
|
||||
|
||||
var re = ''
|
||||
var hasMagic = !!options.nocase
|
||||
var escaping = false
|
||||
// ? => one single character
|
||||
var patternListStack = []
|
||||
var negativeLists = []
|
||||
var stateChar
|
||||
var inClass = false
|
||||
var reClassStart = -1
|
||||
var classStart = -1
|
||||
// . and .. never match anything that doesn't start with .,
|
||||
// even when options.dot is set.
|
||||
var patternStart = pattern.charAt(0) === '.' ? '' // anything
|
||||
// not (start or / followed by . or .. followed by / or end)
|
||||
: options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
|
||||
: '(?!\\.)'
|
||||
var self = this
|
||||
|
||||
function clearStateChar () {
|
||||
if (stateChar) {
|
||||
// we had some state-tracking character
|
||||
// that wasn't consumed by this pass.
|
||||
switch (stateChar) {
|
||||
case '*':
|
||||
re += star
|
||||
hasMagic = true
|
||||
break
|
||||
case '?':
|
||||
re += qmark
|
||||
hasMagic = true
|
||||
break
|
||||
default:
|
||||
re += '\\' + stateChar
|
||||
break
|
||||
}
|
||||
self.debug('clearStateChar %j %j', stateChar, re)
|
||||
stateChar = false
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0, len = pattern.length, c
|
||||
; (i < len) && (c = pattern.charAt(i))
|
||||
; i++) {
|
||||
this.debug('%s\t%s %s %j', pattern, i, re, c)
|
||||
|
||||
// skip over any that are escaped.
|
||||
if (escaping && reSpecials[c]) {
|
||||
re += '\\' + c
|
||||
escaping = false
|
||||
continue
|
||||
}
|
||||
|
||||
switch (c) {
|
||||
/* istanbul ignore next */
|
||||
case '/': {
|
||||
// completely not allowed, even escaped.
|
||||
// Should already be path-split by now.
|
||||
return false
|
||||
}
|
||||
|
||||
case '\\':
|
||||
clearStateChar()
|
||||
escaping = true
|
||||
continue
|
||||
|
||||
// the various stateChar values
|
||||
// for the "extglob" stuff.
|
||||
case '?':
|
||||
case '*':
|
||||
case '+':
|
||||
case '@':
|
||||
case '!':
|
||||
this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
|
||||
|
||||
// all of those are literals inside a class, except that
|
||||
// the glob [!a] means [^a] in regexp
|
||||
if (inClass) {
|
||||
this.debug(' in class')
|
||||
if (c === '!' && i === classStart + 1) c = '^'
|
||||
re += c
|
||||
continue
|
||||
}
|
||||
|
||||
// if we already have a stateChar, then it means
|
||||
// that there was something like ** or +? in there.
|
||||
// Handle the stateChar, then proceed with this one.
|
||||
self.debug('call clearStateChar %j', stateChar)
|
||||
clearStateChar()
|
||||
stateChar = c
|
||||
// if extglob is disabled, then +(asdf|foo) isn't a thing.
|
||||
// just clear the statechar *now*, rather than even diving into
|
||||
// the patternList stuff.
|
||||
if (options.noext) clearStateChar()
|
||||
continue
|
||||
|
||||
case '(':
|
||||
if (inClass) {
|
||||
re += '('
|
||||
continue
|
||||
}
|
||||
|
||||
if (!stateChar) {
|
||||
re += '\\('
|
||||
continue
|
||||
}
|
||||
|
||||
patternListStack.push({
|
||||
type: stateChar,
|
||||
start: i - 1,
|
||||
reStart: re.length,
|
||||
open: plTypes[stateChar].open,
|
||||
close: plTypes[stateChar].close
|
||||
})
|
||||
// negation is (?:(?!js)[^/]*)
|
||||
re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
|
||||
this.debug('plType %j %j', stateChar, re)
|
||||
stateChar = false
|
||||
continue
|
||||
|
||||
case ')':
|
||||
if (inClass || !patternListStack.length) {
|
||||
re += '\\)'
|
||||
continue
|
||||
}
|
||||
|
||||
clearStateChar()
|
||||
hasMagic = true
|
||||
var pl = patternListStack.pop()
|
||||
// negation is (?:(?!js)[^/]*)
|
||||
// The others are (?:<pattern>)<type>
|
||||
re += pl.close
|
||||
if (pl.type === '!') {
|
||||
negativeLists.push(pl)
|
||||
}
|
||||
pl.reEnd = re.length
|
||||
continue
|
||||
|
||||
case '|':
|
||||
if (inClass || !patternListStack.length || escaping) {
|
||||
re += '\\|'
|
||||
escaping = false
|
||||
continue
|
||||
}
|
||||
|
||||
clearStateChar()
|
||||
re += '|'
|
||||
continue
|
||||
|
||||
// these are mostly the same in regexp and glob
|
||||
case '[':
|
||||
// swallow any state-tracking char before the [
|
||||
clearStateChar()
|
||||
|
||||
if (inClass) {
|
||||
re += '\\' + c
|
||||
continue
|
||||
}
|
||||
|
||||
inClass = true
|
||||
classStart = i
|
||||
reClassStart = re.length
|
||||
re += c
|
||||
continue
|
||||
|
||||
case ']':
|
||||
// a right bracket shall lose its special
|
||||
// meaning and represent itself in
|
||||
// a bracket expression if it occurs
|
||||
// first in the list. -- POSIX.2 2.8.3.2
|
||||
if (i === classStart + 1 || !inClass) {
|
||||
re += '\\' + c
|
||||
escaping = false
|
||||
continue
|
||||
}
|
||||
|
||||
// handle the case where we left a class open.
|
||||
// "[z-a]" is valid, equivalent to "\[z-a\]"
|
||||
// split where the last [ was, make sure we don't have
|
||||
// an invalid re. if so, re-walk the contents of the
|
||||
// would-be class to re-translate any characters that
|
||||
// were passed through as-is
|
||||
// TODO: It would probably be faster to determine this
|
||||
// without a try/catch and a new RegExp, but it's tricky
|
||||
// to do safely. For now, this is safe and works.
|
||||
var cs = pattern.substring(classStart + 1, i)
|
||||
try {
|
||||
RegExp('[' + cs + ']')
|
||||
} catch (er) {
|
||||
// not a valid class!
|
||||
var sp = this.parse(cs, SUBPARSE)
|
||||
re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
|
||||
hasMagic = hasMagic || sp[1]
|
||||
inClass = false
|
||||
continue
|
||||
}
|
||||
|
||||
// finish up the class.
|
||||
hasMagic = true
|
||||
inClass = false
|
||||
re += c
|
||||
continue
|
||||
|
||||
default:
|
||||
// swallow any state char that wasn't consumed
|
||||
clearStateChar()
|
||||
|
||||
if (escaping) {
|
||||
// no need
|
||||
escaping = false
|
||||
} else if (reSpecials[c]
|
||||
&& !(c === '^' && inClass)) {
|
||||
re += '\\'
|
||||
}
|
||||
|
||||
re += c
|
||||
|
||||
} // switch
|
||||
} // for
|
||||
|
||||
// handle the case where we left a class open.
|
||||
// "[abc" is valid, equivalent to "\[abc"
|
||||
if (inClass) {
|
||||
// split where the last [ was, and escape it
|
||||
// this is a huge pita. We now have to re-walk
|
||||
// the contents of the would-be class to re-translate
|
||||
// any characters that were passed through as-is
|
||||
cs = pattern.substr(classStart + 1)
|
||||
sp = this.parse(cs, SUBPARSE)
|
||||
re = re.substr(0, reClassStart) + '\\[' + sp[0]
|
||||
hasMagic = hasMagic || sp[1]
|
||||
}
|
||||
|
||||
// handle the case where we had a +( thing at the *end*
|
||||
// of the pattern.
|
||||
// each pattern list stack adds 3 chars, and we need to go through
|
||||
// and escape any | chars that were passed through as-is for the regexp.
|
||||
// Go through and escape them, taking care not to double-escape any
|
||||
// | chars that were already escaped.
|
||||
for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
|
||||
var tail = re.slice(pl.reStart + pl.open.length)
|
||||
this.debug('setting tail', re, pl)
|
||||
// maybe some even number of \, then maybe 1 \, followed by a |
|
||||
tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
|
||||
if (!$2) {
|
||||
// the | isn't already escaped, so escape it.
|
||||
$2 = '\\'
|
||||
}
|
||||
|
||||
// need to escape all those slashes *again*, without escaping the
|
||||
// one that we need for escaping the | character. As it works out,
|
||||
// escaping an even number of slashes can be done by simply repeating
|
||||
// it exactly after itself. That's why this trick works.
|
||||
//
|
||||
// I am sorry that you have to see this.
|
||||
return $1 + $1 + $2 + '|'
|
||||
})
|
||||
|
||||
this.debug('tail=%j\n %s', tail, tail, pl, re)
|
||||
var t = pl.type === '*' ? star
|
||||
: pl.type === '?' ? qmark
|
||||
: '\\' + pl.type
|
||||
|
||||
hasMagic = true
|
||||
re = re.slice(0, pl.reStart) + t + '\\(' + tail
|
||||
}
|
||||
|
||||
// handle trailing things that only matter at the very end.
|
||||
clearStateChar()
|
||||
if (escaping) {
|
||||
// trailing \\
|
||||
re += '\\\\'
|
||||
}
|
||||
|
||||
// only need to apply the nodot start if the re starts with
|
||||
// something that could conceivably capture a dot
|
||||
var addPatternStart = false
|
||||
switch (re.charAt(0)) {
|
||||
case '[': case '.': case '(': addPatternStart = true
|
||||
}
|
||||
|
||||
// Hack to work around lack of negative lookbehind in JS
|
||||
// A pattern like: *.!(x).!(y|z) needs to ensure that a name
|
||||
// like 'a.xyz.yz' doesn't match. So, the first negative
|
||||
// lookahead, has to look ALL the way ahead, to the end of
|
||||
// the pattern.
|
||||
for (var n = negativeLists.length - 1; n > -1; n--) {
|
||||
var nl = negativeLists[n]
|
||||
|
||||
var nlBefore = re.slice(0, nl.reStart)
|
||||
var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
|
||||
var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
|
||||
var nlAfter = re.slice(nl.reEnd)
|
||||
|
||||
nlLast += nlAfter
|
||||
|
||||
// Handle nested stuff like *(*.js|!(*.json)), where open parens
|
||||
// mean that we should *not* include the ) in the bit that is considered
|
||||
// "after" the negated section.
|
||||
var openParensBefore = nlBefore.split('(').length - 1
|
||||
var cleanAfter = nlAfter
|
||||
for (i = 0; i < openParensBefore; i++) {
|
||||
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
|
||||
}
|
||||
nlAfter = cleanAfter
|
||||
|
||||
var dollar = ''
|
||||
if (nlAfter === '' && isSub !== SUBPARSE) {
|
||||
dollar = '$'
|
||||
}
|
||||
var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
|
||||
re = newRe
|
||||
}
|
||||
|
||||
// if the re is not "" at this point, then we need to make sure
|
||||
// it doesn't match against an empty path part.
|
||||
// Otherwise a/* will match a/, which it should not.
|
||||
if (re !== '' && hasMagic) {
|
||||
re = '(?=.)' + re
|
||||
}
|
||||
|
||||
if (addPatternStart) {
|
||||
re = patternStart + re
|
||||
}
|
||||
|
||||
// parsing just a piece of a larger pattern.
|
||||
if (isSub === SUBPARSE) {
|
||||
return [re, hasMagic]
|
||||
}
|
||||
|
||||
// skip the regexp for non-magical patterns
|
||||
// unescape anything in it, though, so that it'll be
|
||||
// an exact match against a file etc.
|
||||
if (!hasMagic) {
|
||||
return globUnescape(pattern)
|
||||
}
|
||||
|
||||
var flags = options.nocase ? 'i' : ''
|
||||
try {
|
||||
var regExp = new RegExp('^' + re + '$', flags)
|
||||
} catch (er) /* istanbul ignore next - should be impossible */ {
|
||||
// If it was an invalid regular expression, then it can't match
|
||||
// anything. This trick looks for a character after the end of
|
||||
// the string, which is of course impossible, except in multi-line
|
||||
// mode, but it's not a /m regex.
|
||||
return new RegExp('$.')
|
||||
}
|
||||
|
||||
regExp._glob = pattern
|
||||
regExp._src = re
|
||||
|
||||
return regExp
|
||||
}
|
||||
|
||||
minimatch.makeRe = function (pattern, options) {
|
||||
return new Minimatch(pattern, options || {}).makeRe()
|
||||
}
|
||||
|
||||
Minimatch.prototype.makeRe = makeRe
|
||||
function makeRe () {
|
||||
if (this.regexp || this.regexp === false) return this.regexp
|
||||
|
||||
// at this point, this.set is a 2d array of partial
|
||||
// pattern strings, or "**".
|
||||
//
|
||||
// It's better to use .match(). This function shouldn't
|
||||
// be used, really, but it's pretty convenient sometimes,
|
||||
// when you just want to work with a regex.
|
||||
var set = this.set
|
||||
|
||||
if (!set.length) {
|
||||
this.regexp = false
|
||||
return this.regexp
|
||||
}
|
||||
var options = this.options
|
||||
|
||||
var twoStar = options.noglobstar ? star
|
||||
: options.dot ? twoStarDot
|
||||
: twoStarNoDot
|
||||
var flags = options.nocase ? 'i' : ''
|
||||
|
||||
var re = set.map(function (pattern) {
|
||||
return pattern.map(function (p) {
|
||||
return (p === GLOBSTAR) ? twoStar
|
||||
: (typeof p === 'string') ? regExpEscape(p)
|
||||
: p._src
|
||||
}).join('\\\/')
|
||||
}).join('|')
|
||||
|
||||
// must match entire pattern
|
||||
// ending in a * or ** will make it less strict.
|
||||
re = '^(?:' + re + ')$'
|
||||
|
||||
// can match anything, as long as it's not this.
|
||||
if (this.negate) re = '^(?!' + re + ').*$'
|
||||
|
||||
try {
|
||||
this.regexp = new RegExp(re, flags)
|
||||
} catch (ex) /* istanbul ignore next - should be impossible */ {
|
||||
this.regexp = false
|
||||
}
|
||||
return this.regexp
|
||||
}
|
||||
|
||||
minimatch.match = function (list, pattern, options) {
|
||||
options = options || {}
|
||||
var mm = new Minimatch(pattern, options)
|
||||
list = list.filter(function (f) {
|
||||
return mm.match(f)
|
||||
})
|
||||
if (mm.options.nonull && !list.length) {
|
||||
list.push(pattern)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
Minimatch.prototype.match = function match (f, partial) {
|
||||
if (typeof partial === 'undefined') partial = this.partial
|
||||
this.debug('match', f, this.pattern)
|
||||
// short-circuit in the case of busted things.
|
||||
// comments, etc.
|
||||
if (this.comment) return false
|
||||
if (this.empty) return f === ''
|
||||
|
||||
if (f === '/' && partial) return true
|
||||
|
||||
var options = this.options
|
||||
|
||||
// windows: need to use /, not \
|
||||
if (path.sep !== '/') {
|
||||
f = f.split(path.sep).join('/')
|
||||
}
|
||||
|
||||
// treat the test path as a set of pathparts.
|
||||
f = f.split(slashSplit)
|
||||
this.debug(this.pattern, 'split', f)
|
||||
|
||||
// just ONE of the pattern sets in this.set needs to match
|
||||
// in order for it to be valid. If negating, then just one
|
||||
// match means that we have failed.
|
||||
// Either way, return on the first hit.
|
||||
|
||||
var set = this.set
|
||||
this.debug(this.pattern, 'set', set)
|
||||
|
||||
// Find the basename of the path by looking for the last non-empty segment
|
||||
var filename
|
||||
var i
|
||||
for (i = f.length - 1; i >= 0; i--) {
|
||||
filename = f[i]
|
||||
if (filename) break
|
||||
}
|
||||
|
||||
for (i = 0; i < set.length; i++) {
|
||||
var pattern = set[i]
|
||||
var file = f
|
||||
if (options.matchBase && pattern.length === 1) {
|
||||
file = [filename]
|
||||
}
|
||||
var hit = this.matchOne(file, pattern, partial)
|
||||
if (hit) {
|
||||
if (options.flipNegate) return true
|
||||
return !this.negate
|
||||
}
|
||||
}
|
||||
|
||||
// didn't get any hits. this is success if it's a negative
|
||||
// pattern, failure otherwise.
|
||||
if (options.flipNegate) return false
|
||||
return this.negate
|
||||
}
|
||||
|
||||
// set partial to true to test if, for example,
|
||||
// "/a/b" matches the start of "/*/b/*/d"
|
||||
// Partial means, if you run out of file before you run
|
||||
// out of pattern, then that's fine, as long as all
|
||||
// the parts match.
|
||||
Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
||||
var options = this.options
|
||||
|
||||
this.debug('matchOne',
|
||||
{ 'this': this, file: file, pattern: pattern })
|
||||
|
||||
this.debug('matchOne', file.length, pattern.length)
|
||||
|
||||
for (var fi = 0,
|
||||
pi = 0,
|
||||
fl = file.length,
|
||||
pl = pattern.length
|
||||
; (fi < fl) && (pi < pl)
|
||||
; fi++, pi++) {
|
||||
this.debug('matchOne loop')
|
||||
var p = pattern[pi]
|
||||
var f = file[fi]
|
||||
|
||||
this.debug(pattern, p, f)
|
||||
|
||||
// should be impossible.
|
||||
// some invalid regexp stuff in the set.
|
||||
/* istanbul ignore if */
|
||||
if (p === false) return false
|
||||
|
||||
if (p === GLOBSTAR) {
|
||||
this.debug('GLOBSTAR', [pattern, p, f])
|
||||
|
||||
// "**"
|
||||
// a/**/b/**/c would match the following:
|
||||
// a/b/x/y/z/c
|
||||
// a/x/y/z/b/c
|
||||
// a/b/x/b/x/c
|
||||
// a/b/c
|
||||
// To do this, take the rest of the pattern after
|
||||
// the **, and see if it would match the file remainder.
|
||||
// If so, return success.
|
||||
// If not, the ** "swallows" a segment, and try again.
|
||||
// This is recursively awful.
|
||||
//
|
||||
// a/**/b/**/c matching a/b/x/y/z/c
|
||||
// - a matches a
|
||||
// - doublestar
|
||||
// - matchOne(b/x/y/z/c, b/**/c)
|
||||
// - b matches b
|
||||
// - doublestar
|
||||
// - matchOne(x/y/z/c, c) -> no
|
||||
// - matchOne(y/z/c, c) -> no
|
||||
// - matchOne(z/c, c) -> no
|
||||
// - matchOne(c, c) yes, hit
|
||||
var fr = fi
|
||||
var pr = pi + 1
|
||||
if (pr === pl) {
|
||||
this.debug('** at the end')
|
||||
// a ** at the end will just swallow the rest.
|
||||
// We have found a match.
|
||||
// however, it will not swallow /.x, unless
|
||||
// options.dot is set.
|
||||
// . and .. are *never* matched by **, for explosively
|
||||
// exponential reasons.
|
||||
for (; fi < fl; fi++) {
|
||||
if (file[fi] === '.' || file[fi] === '..' ||
|
||||
(!options.dot && file[fi].charAt(0) === '.')) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// ok, let's see if we can swallow whatever we can.
|
||||
while (fr < fl) {
|
||||
var swallowee = file[fr]
|
||||
|
||||
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
|
||||
|
||||
// XXX remove this slice. Just pass the start index.
|
||||
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
||||
this.debug('globstar found match!', fr, fl, swallowee)
|
||||
// found a match.
|
||||
return true
|
||||
} else {
|
||||
// can't swallow "." or ".." ever.
|
||||
// can only swallow ".foo" when explicitly asked.
|
||||
if (swallowee === '.' || swallowee === '..' ||
|
||||
(!options.dot && swallowee.charAt(0) === '.')) {
|
||||
this.debug('dot detected!', file, fr, pattern, pr)
|
||||
break
|
||||
}
|
||||
|
||||
// ** swallows a segment, and continue.
|
||||
this.debug('globstar swallow a segment, and continue')
|
||||
fr++
|
||||
}
|
||||
}
|
||||
|
||||
// no match was found.
|
||||
// However, in partial mode, we can't say this is necessarily over.
|
||||
// If there's more *pattern* left, then
|
||||
/* istanbul ignore if */
|
||||
if (partial) {
|
||||
// ran out of file
|
||||
this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
|
||||
if (fr === fl) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// something other than **
|
||||
// non-magic patterns just have to match exactly
|
||||
// patterns with magic have been turned into regexps.
|
||||
var hit
|
||||
if (typeof p === 'string') {
|
||||
hit = f === p
|
||||
this.debug('string match', p, f, hit)
|
||||
} else {
|
||||
hit = f.match(p)
|
||||
this.debug('pattern match', p, f, hit)
|
||||
}
|
||||
|
||||
if (!hit) return false
|
||||
}
|
||||
|
||||
// Note: ending in / means that we'll get a final ""
|
||||
// at the end of the pattern. This can only match a
|
||||
// corresponding "" at the end of the file.
|
||||
// If the file ends in /, then it can only match a
|
||||
// a pattern that ends in /, unless the pattern just
|
||||
// doesn't have any more for it. But, a/b/ should *not*
|
||||
// match "a/b/*", even though "" matches against the
|
||||
// [^/]*? pattern, except in partial mode, where it might
|
||||
// simply not be reached yet.
|
||||
// However, a/b/ should still satisfy a/*
|
||||
|
||||
// now either we fell off the end of the pattern, or we're done.
|
||||
if (fi === fl && pi === pl) {
|
||||
// ran out of pattern and filename at the same time.
|
||||
// an exact hit!
|
||||
return true
|
||||
} else if (fi === fl) {
|
||||
// ran out of file, but still had pattern left.
|
||||
// this is ok if we're doing the match as part of
|
||||
// a glob fs traversal.
|
||||
return partial
|
||||
} else /* istanbul ignore else */ if (pi === pl) {
|
||||
// ran out of pattern, still have file left.
|
||||
// this is only acceptable if we're on the very last
|
||||
// empty segment of a file with a trailing slash.
|
||||
// a/* should match a/b/
|
||||
return (fi === fl - 1) && (file[fi] === '')
|
||||
}
|
||||
|
||||
// should be unreachable.
|
||||
/* istanbul ignore next */
|
||||
throw new Error('wtf?')
|
||||
}
|
||||
|
||||
// replace stuff like \* with *
|
||||
function globUnescape (s) {
|
||||
return s.replace(/\\(.)/g, '$1')
|
||||
}
|
||||
|
||||
function regExpEscape (s) {
|
||||
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
|
||||
}
|
||||
33
node_modules/@vercel/nft/node_modules/minimatch/package.json
generated
vendored
Normal file
33
node_modules/@vercel/nft/node_modules/minimatch/package.json
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
|
||||
"name": "minimatch",
|
||||
"description": "a glob matcher in javascript",
|
||||
"version": "3.1.2",
|
||||
"publishConfig": {
|
||||
"tag": "v3-legacy"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/minimatch.git"
|
||||
},
|
||||
"main": "minimatch.js",
|
||||
"scripts": {
|
||||
"test": "tap",
|
||||
"preversion": "npm test",
|
||||
"postversion": "npm publish",
|
||||
"postpublish": "git push origin --all; git push origin --tags"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^15.1.6"
|
||||
},
|
||||
"license": "ISC",
|
||||
"files": [
|
||||
"minimatch.js"
|
||||
]
|
||||
}
|
||||
8
node_modules/@vercel/nft/out/analyze.d.ts
generated
vendored
Normal file
8
node_modules/@vercel/nft/out/analyze.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Job } from './node-file-trace';
|
||||
export interface AnalyzeResult {
|
||||
assets: Set<string>;
|
||||
deps: Set<string>;
|
||||
imports: Set<string>;
|
||||
isESM: boolean;
|
||||
}
|
||||
export default function analyze(id: string, code: string, job: Job): Promise<AnalyzeResult>;
|
||||
887
node_modules/@vercel/nft/out/analyze.js
generated
vendored
Normal file
887
node_modules/@vercel/nft/out/analyze.js
generated
vendored
Normal file
@@ -0,0 +1,887 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const estree_walker_1 = require("estree-walker");
|
||||
const pluginutils_1 = require("@rollup/pluginutils");
|
||||
const static_eval_1 = require("./utils/static-eval");
|
||||
const acorn_1 = require("acorn");
|
||||
const bindings_1 = __importDefault(require("bindings"));
|
||||
const ast_helpers_1 = require("./utils/ast-helpers");
|
||||
const glob_1 = __importDefault(require("glob"));
|
||||
const get_package_base_1 = require("./utils/get-package-base");
|
||||
const binary_locators_1 = require("./utils/binary-locators");
|
||||
const interop_require_1 = require("./utils/interop-require");
|
||||
const special_cases_1 = __importDefault(require("./utils/special-cases"));
|
||||
const resolve_dependency_js_1 = __importDefault(require("./resolve-dependency.js"));
|
||||
//@ts-ignore
|
||||
const node_gyp_build_1 = __importDefault(require("node-gyp-build"));
|
||||
//@ts-ignore
|
||||
const node_pre_gyp_1 = __importDefault(require("@mapbox/node-pre-gyp"));
|
||||
const url_1 = require("url");
|
||||
// Note: these should be deprecated over time as they ship in Acorn core
|
||||
const acorn = acorn_1.Parser.extend(
|
||||
//require("acorn-class-fields"),
|
||||
//require("acorn-static-class-features"),
|
||||
//require("acorn-private-class-elements")
|
||||
);
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const wrappers_1 = require("./utils/wrappers");
|
||||
const resolve_from_1 = __importDefault(require("resolve-from"));
|
||||
const staticProcess = {
|
||||
cwd: () => {
|
||||
return cwd;
|
||||
},
|
||||
env: {
|
||||
NODE_ENV: static_eval_1.UNKNOWN,
|
||||
[static_eval_1.UNKNOWN]: true
|
||||
},
|
||||
[static_eval_1.UNKNOWN]: true
|
||||
};
|
||||
// unique symbol value to identify express instance in static analysis
|
||||
const EXPRESS_SET = Symbol();
|
||||
const EXPRESS_ENGINE = Symbol();
|
||||
const NBIND_INIT = Symbol();
|
||||
const SET_ROOT_DIR = Symbol();
|
||||
const PKG_INFO = Symbol();
|
||||
const FS_FN = Symbol();
|
||||
const FS_DIR_FN = Symbol();
|
||||
const BINDINGS = Symbol();
|
||||
const NODE_GYP_BUILD = Symbol();
|
||||
const fsSymbols = {
|
||||
access: FS_FN,
|
||||
accessSync: FS_FN,
|
||||
createReadStream: FS_FN,
|
||||
exists: FS_FN,
|
||||
existsSync: FS_FN,
|
||||
fstat: FS_FN,
|
||||
fstatSync: FS_FN,
|
||||
lstat: FS_FN,
|
||||
lstatSync: FS_FN,
|
||||
open: FS_FN,
|
||||
readdir: FS_DIR_FN,
|
||||
readdirSync: FS_DIR_FN,
|
||||
readFile: FS_FN,
|
||||
readFileSync: FS_FN,
|
||||
stat: FS_FN,
|
||||
statSync: FS_FN
|
||||
};
|
||||
const fsExtraSymbols = {
|
||||
...fsSymbols,
|
||||
pathExists: FS_FN,
|
||||
pathExistsSync: FS_FN,
|
||||
readJson: FS_FN,
|
||||
readJSON: FS_FN,
|
||||
readJsonSync: FS_FN,
|
||||
readJSONSync: FS_FN,
|
||||
};
|
||||
const staticModules = Object.assign(Object.create(null), {
|
||||
bindings: {
|
||||
default: BINDINGS
|
||||
},
|
||||
express: {
|
||||
default: function () {
|
||||
return {
|
||||
[static_eval_1.UNKNOWN]: true,
|
||||
set: EXPRESS_SET,
|
||||
engine: EXPRESS_ENGINE
|
||||
};
|
||||
}
|
||||
},
|
||||
fs: {
|
||||
default: fsSymbols,
|
||||
...fsSymbols
|
||||
},
|
||||
'fs-extra': {
|
||||
default: fsExtraSymbols,
|
||||
...fsExtraSymbols
|
||||
},
|
||||
'graceful-fs': {
|
||||
default: fsSymbols,
|
||||
...fsSymbols
|
||||
},
|
||||
process: {
|
||||
default: staticProcess,
|
||||
...staticProcess
|
||||
},
|
||||
// populated below
|
||||
path: {
|
||||
default: {}
|
||||
},
|
||||
os: {
|
||||
default: os_1.default,
|
||||
...os_1.default
|
||||
},
|
||||
'@mapbox/node-pre-gyp': {
|
||||
default: node_pre_gyp_1.default,
|
||||
...node_pre_gyp_1.default
|
||||
},
|
||||
'node-pre-gyp': binary_locators_1.pregyp,
|
||||
'node-pre-gyp/lib/pre-binding': binary_locators_1.pregyp,
|
||||
'node-pre-gyp/lib/pre-binding.js': binary_locators_1.pregyp,
|
||||
'node-gyp-build': {
|
||||
default: NODE_GYP_BUILD
|
||||
},
|
||||
'nbind': {
|
||||
init: NBIND_INIT,
|
||||
default: {
|
||||
init: NBIND_INIT
|
||||
}
|
||||
},
|
||||
'resolve-from': {
|
||||
default: resolve_from_1.default
|
||||
},
|
||||
'strong-globalize': {
|
||||
default: {
|
||||
SetRootDir: SET_ROOT_DIR
|
||||
},
|
||||
SetRootDir: SET_ROOT_DIR
|
||||
},
|
||||
'pkginfo': {
|
||||
default: PKG_INFO
|
||||
}
|
||||
});
|
||||
const globalBindings = {
|
||||
// Support for require calls generated from `import` statements by babel
|
||||
_interopRequireDefault: interop_require_1.normalizeDefaultRequire,
|
||||
_interopRequireWildcard: interop_require_1.normalizeWildcardRequire,
|
||||
// Support for require calls generated from `import` statements by tsc
|
||||
__importDefault: interop_require_1.normalizeDefaultRequire,
|
||||
__importStar: interop_require_1.normalizeWildcardRequire,
|
||||
MONGOOSE_DRIVER_PATH: undefined,
|
||||
URL: url_1.URL,
|
||||
Object: {
|
||||
assign: Object.assign
|
||||
}
|
||||
};
|
||||
globalBindings.global = globalBindings.GLOBAL = globalBindings.globalThis = globalBindings;
|
||||
// call expression triggers
|
||||
const TRIGGER = Symbol();
|
||||
binary_locators_1.pregyp.find[TRIGGER] = true;
|
||||
const staticPath = staticModules.path;
|
||||
Object.keys(path_1.default).forEach(name => {
|
||||
const pathFn = path_1.default[name];
|
||||
if (typeof pathFn === 'function') {
|
||||
const fn = function mockPath() {
|
||||
return pathFn.apply(mockPath, arguments);
|
||||
};
|
||||
fn[TRIGGER] = true;
|
||||
staticPath[name] = staticPath.default[name] = fn;
|
||||
}
|
||||
else {
|
||||
staticPath[name] = staticPath.default[name] = pathFn;
|
||||
}
|
||||
});
|
||||
// overload path.resolve to support custom cwd
|
||||
staticPath.resolve = staticPath.default.resolve = function (...args) {
|
||||
return path_1.default.resolve.apply(this, [cwd, ...args]);
|
||||
};
|
||||
staticPath.resolve[TRIGGER] = true;
|
||||
const excludeAssetExtensions = new Set(['.h', '.cmake', '.c', '.cpp']);
|
||||
const excludeAssetFiles = new Set(['CHANGELOG.md', 'README.md', 'readme.md', 'changelog.md']);
|
||||
let cwd;
|
||||
const absoluteRegEx = /^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;
|
||||
function isAbsolutePathOrUrl(str) {
|
||||
if (str instanceof url_1.URL)
|
||||
return str.protocol === 'file:';
|
||||
if (typeof str === 'string') {
|
||||
if (str.startsWith('file:')) {
|
||||
try {
|
||||
new url_1.URL(str);
|
||||
return true;
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return absoluteRegEx.test(str);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const BOUND_REQUIRE = Symbol();
|
||||
const repeatGlobRegEx = /([\/\\]\*\*[\/\\]\*)+/g;
|
||||
;
|
||||
async function analyze(id, code, job) {
|
||||
const assets = new Set();
|
||||
const deps = new Set();
|
||||
const imports = new Set();
|
||||
const dir = path_1.default.dirname(id);
|
||||
// if (typeof options.production === 'boolean' && staticProcess.env.NODE_ENV === UNKNOWN)
|
||||
// staticProcess.env.NODE_ENV = options.production ? 'production' : 'dev';
|
||||
cwd = job.cwd;
|
||||
const pkgBase = (0, get_package_base_1.getPackageBase)(id);
|
||||
const emitAssetDirectory = (wildcardPath) => {
|
||||
if (!job.analysis.emitGlobs)
|
||||
return;
|
||||
const wildcardIndex = wildcardPath.indexOf(static_eval_1.WILDCARD);
|
||||
const dirIndex = wildcardIndex === -1 ? wildcardPath.length : wildcardPath.lastIndexOf(path_1.default.sep, wildcardIndex);
|
||||
const assetDirPath = wildcardPath.substring(0, dirIndex);
|
||||
const patternPath = wildcardPath.slice(dirIndex);
|
||||
const wildcardPattern = patternPath.replace(static_eval_1.wildcardRegEx, (_match, index) => {
|
||||
return patternPath[index - 1] === path_1.default.sep ? '**/*' : '*';
|
||||
}).replace(repeatGlobRegEx, '/**/*') || '/**/*';
|
||||
if (job.ignoreFn(path_1.default.relative(job.base, assetDirPath + wildcardPattern)))
|
||||
return;
|
||||
assetEmissionPromises = assetEmissionPromises.then(async () => {
|
||||
if (job.log)
|
||||
console.log('Globbing ' + assetDirPath + wildcardPattern);
|
||||
const files = (await new Promise((resolve, reject) => (0, glob_1.default)(assetDirPath + wildcardPattern, { mark: true, ignore: assetDirPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))));
|
||||
files
|
||||
.filter(name => !excludeAssetExtensions.has(path_1.default.extname(name)) &&
|
||||
!excludeAssetFiles.has(path_1.default.basename(name)) &&
|
||||
!name.endsWith('/'))
|
||||
.forEach(file => assets.add(file));
|
||||
});
|
||||
};
|
||||
let assetEmissionPromises = Promise.resolve();
|
||||
// remove shebang
|
||||
code = code.replace(/^#![^\n\r]*[\r\n]/, '');
|
||||
let ast;
|
||||
let isESM = false;
|
||||
try {
|
||||
ast = acorn.parse(code, { ecmaVersion: 'latest', allowReturnOutsideFunction: true });
|
||||
isESM = false;
|
||||
}
|
||||
catch (e) {
|
||||
const isModule = e && e.message && e.message.includes('sourceType: module');
|
||||
if (!isModule) {
|
||||
job.warnings.add(new Error(`Failed to parse ${id} as script:\n${e && e.message}`));
|
||||
}
|
||||
}
|
||||
//@ts-ignore
|
||||
if (!ast) {
|
||||
try {
|
||||
ast = acorn.parse(code, { ecmaVersion: 'latest', sourceType: 'module', allowAwaitOutsideFunction: true });
|
||||
isESM = true;
|
||||
}
|
||||
catch (e) {
|
||||
job.warnings.add(new Error(`Failed to parse ${id} as module:\n${e && e.message}`));
|
||||
// Parser errors just skip analysis
|
||||
return { assets, deps, imports, isESM: false };
|
||||
}
|
||||
}
|
||||
const importMetaUrl = (0, url_1.pathToFileURL)(id).href;
|
||||
const knownBindings = Object.assign(Object.create(null), {
|
||||
__dirname: {
|
||||
shadowDepth: 0,
|
||||
value: { value: path_1.default.resolve(id, '..') }
|
||||
},
|
||||
__filename: {
|
||||
shadowDepth: 0,
|
||||
value: { value: id }
|
||||
},
|
||||
process: {
|
||||
shadowDepth: 0,
|
||||
value: { value: staticProcess }
|
||||
}
|
||||
});
|
||||
if (!isESM || job.mixedModules) {
|
||||
knownBindings.require = {
|
||||
shadowDepth: 0,
|
||||
value: {
|
||||
value: {
|
||||
[static_eval_1.FUNCTION](specifier) {
|
||||
deps.add(specifier);
|
||||
const m = staticModules[specifier.startsWith('node:') ? specifier.slice(5) : specifier];
|
||||
return m.default;
|
||||
},
|
||||
resolve(specifier) {
|
||||
return (0, resolve_dependency_js_1.default)(specifier, id, job);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
knownBindings.require.value.value.resolve[TRIGGER] = true;
|
||||
}
|
||||
function setKnownBinding(name, value) {
|
||||
// require is somewhat special in that we shadow it but don't
|
||||
// statically analyze it ("known unknown" of sorts)
|
||||
if (name === 'require')
|
||||
return;
|
||||
knownBindings[name] = {
|
||||
shadowDepth: 0,
|
||||
value: value
|
||||
};
|
||||
}
|
||||
function getKnownBinding(name) {
|
||||
const binding = knownBindings[name];
|
||||
if (binding) {
|
||||
if (binding.shadowDepth === 0) {
|
||||
return binding.value;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function hasKnownBindingValue(name) {
|
||||
const binding = knownBindings[name];
|
||||
return binding && binding.shadowDepth === 0;
|
||||
}
|
||||
if ((isESM || job.mixedModules) && isAst(ast)) {
|
||||
for (const decl of ast.body) {
|
||||
if (decl.type === 'ImportDeclaration') {
|
||||
const source = String(decl.source.value);
|
||||
deps.add(source);
|
||||
const staticModule = staticModules[source.startsWith('node:') ? source.slice(5) : source];
|
||||
if (staticModule) {
|
||||
for (const impt of decl.specifiers) {
|
||||
if (impt.type === 'ImportNamespaceSpecifier')
|
||||
setKnownBinding(impt.local.name, { value: staticModule });
|
||||
else if (impt.type === 'ImportDefaultSpecifier' && 'default' in staticModule)
|
||||
setKnownBinding(impt.local.name, { value: staticModule.default });
|
||||
else if (impt.type === 'ImportSpecifier' && impt.imported.name in staticModule)
|
||||
setKnownBinding(impt.local.name, { value: staticModule[impt.imported.name] });
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (decl.type === 'ExportNamedDeclaration' || decl.type === 'ExportAllDeclaration') {
|
||||
if (decl.source)
|
||||
deps.add(String(decl.source.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
async function computePureStaticValue(expr, computeBranches = true) {
|
||||
const vars = Object.create(null);
|
||||
Object.keys(globalBindings).forEach(name => {
|
||||
vars[name] = { value: globalBindings[name] };
|
||||
});
|
||||
Object.keys(knownBindings).forEach(name => {
|
||||
vars[name] = getKnownBinding(name);
|
||||
});
|
||||
vars['import.meta'] = { url: importMetaUrl };
|
||||
// evaluate returns undefined for non-statically-analyzable
|
||||
const result = await (0, static_eval_1.evaluate)(expr, vars, computeBranches);
|
||||
return result;
|
||||
}
|
||||
// statically determinable leaves are tracked, and inlined when the
|
||||
// greatest parent statically known leaf computation corresponds to an asset path
|
||||
let staticChildNode;
|
||||
let staticChildValue;
|
||||
// Express engine opt-out
|
||||
let definedExpressEngines = false;
|
||||
function emitWildcardRequire(wildcardRequire) {
|
||||
if (!job.analysis.emitGlobs || !wildcardRequire.startsWith('./') && !wildcardRequire.startsWith('../'))
|
||||
return;
|
||||
wildcardRequire = path_1.default.resolve(dir, wildcardRequire);
|
||||
const wildcardIndex = wildcardRequire.indexOf(static_eval_1.WILDCARD);
|
||||
const dirIndex = wildcardIndex === -1 ? wildcardRequire.length : wildcardRequire.lastIndexOf(path_1.default.sep, wildcardIndex);
|
||||
const wildcardDirPath = wildcardRequire.substring(0, dirIndex);
|
||||
const patternPath = wildcardRequire.slice(dirIndex);
|
||||
let wildcardPattern = patternPath.replace(static_eval_1.wildcardRegEx, (_match, index) => {
|
||||
return patternPath[index - 1] === path_1.default.sep ? '**/*' : '*';
|
||||
}) || '/**/*';
|
||||
if (!wildcardPattern.endsWith('*'))
|
||||
wildcardPattern += '?(' + (job.ts ? '.ts|.tsx|' : '') + '.js|.json|.node)';
|
||||
if (job.ignoreFn(path_1.default.relative(job.base, wildcardDirPath + wildcardPattern)))
|
||||
return;
|
||||
assetEmissionPromises = assetEmissionPromises.then(async () => {
|
||||
if (job.log)
|
||||
console.log('Globbing ' + wildcardDirPath + wildcardPattern);
|
||||
const files = (await new Promise((resolve, reject) => (0, glob_1.default)(wildcardDirPath + wildcardPattern, { mark: true, ignore: wildcardDirPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files))));
|
||||
files
|
||||
.filter(name => !excludeAssetExtensions.has(path_1.default.extname(name)) &&
|
||||
!excludeAssetFiles.has(path_1.default.basename(name)) &&
|
||||
!name.endsWith('/'))
|
||||
.forEach(file => deps.add(file));
|
||||
});
|
||||
}
|
||||
async function processRequireArg(expression, isImport = false) {
|
||||
if (expression.type === 'ConditionalExpression') {
|
||||
await processRequireArg(expression.consequent, isImport);
|
||||
await processRequireArg(expression.alternate, isImport);
|
||||
return;
|
||||
}
|
||||
if (expression.type === 'LogicalExpression') {
|
||||
await processRequireArg(expression.left, isImport);
|
||||
await processRequireArg(expression.right, isImport);
|
||||
return;
|
||||
}
|
||||
let computed = await computePureStaticValue(expression, true);
|
||||
if (!computed)
|
||||
return;
|
||||
if ('value' in computed && typeof computed.value === 'string') {
|
||||
if (!computed.wildcards)
|
||||
(isImport ? imports : deps).add(computed.value);
|
||||
else if (computed.wildcards.length >= 1)
|
||||
emitWildcardRequire(computed.value);
|
||||
}
|
||||
else {
|
||||
if ('then' in computed && typeof computed.then === 'string')
|
||||
(isImport ? imports : deps).add(computed.then);
|
||||
if ('else' in computed && typeof computed.else === 'string')
|
||||
(isImport ? imports : deps).add(computed.else);
|
||||
}
|
||||
}
|
||||
let scope = (0, pluginutils_1.attachScopes)(ast, 'scope');
|
||||
if (isAst(ast)) {
|
||||
(0, wrappers_1.handleWrappers)(ast);
|
||||
await (0, special_cases_1.default)({ id, ast, emitDependency: path => deps.add(path), emitAsset: path => assets.add(path), emitAssetDirectory, job });
|
||||
}
|
||||
async function backtrack(parent, context) {
|
||||
// computing a static expression outward
|
||||
// -> compute and backtrack
|
||||
// Note that `context` can be undefined in `leave()`
|
||||
if (!staticChildNode)
|
||||
throw new Error('Internal error: No staticChildNode for backtrack.');
|
||||
const curStaticValue = await computePureStaticValue(parent, true);
|
||||
if (curStaticValue) {
|
||||
if ('value' in curStaticValue && typeof curStaticValue.value !== 'symbol' ||
|
||||
'then' in curStaticValue && typeof curStaticValue.then !== 'symbol' && typeof curStaticValue.else !== 'symbol') {
|
||||
staticChildValue = curStaticValue;
|
||||
staticChildNode = parent;
|
||||
if (context)
|
||||
context.skip();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// no static value -> see if we should emit the asset if it exists
|
||||
await emitStaticChildAsset();
|
||||
}
|
||||
await (0, estree_walker_1.asyncWalk)(ast, {
|
||||
async enter(_node, _parent) {
|
||||
const node = _node;
|
||||
const parent = _parent;
|
||||
if (node.scope) {
|
||||
scope = node.scope;
|
||||
for (const id in node.scope.declarations) {
|
||||
if (id in knownBindings)
|
||||
knownBindings[id].shadowDepth++;
|
||||
}
|
||||
}
|
||||
// currently backtracking
|
||||
if (staticChildNode)
|
||||
return;
|
||||
if (!parent)
|
||||
return;
|
||||
if (node.type === 'Identifier') {
|
||||
if ((0, ast_helpers_1.isIdentifierRead)(node, parent) && job.analysis.computeFileReferences) {
|
||||
let binding;
|
||||
// detect asset leaf expression triggers (if not already)
|
||||
// __dirname, __filename
|
||||
if (typeof (binding = getKnownBinding(node.name)?.value) === 'string' && binding.match(absoluteRegEx) ||
|
||||
binding && (typeof binding === 'function' || typeof binding === 'object') && binding[TRIGGER]) {
|
||||
staticChildValue = { value: typeof binding === 'string' ? binding : undefined };
|
||||
staticChildNode = node;
|
||||
await backtrack(parent, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (job.analysis.computeFileReferences && node.type === 'MemberExpression' && node.object.type === 'MetaProperty' && node.object.meta.name === 'import' && node.object.property.name === 'meta' && (node.property.computed ? node.property.value : node.property.name) === 'url') {
|
||||
// import.meta.url leaf trigger
|
||||
staticChildValue = { value: importMetaUrl };
|
||||
staticChildNode = node;
|
||||
await backtrack(parent, this);
|
||||
}
|
||||
else if (node.type === 'ImportExpression') {
|
||||
await processRequireArg(node.source, true);
|
||||
return;
|
||||
}
|
||||
// Call expression cases and asset triggers
|
||||
// - fs triggers: fs.readFile(...)
|
||||
// - require.resolve()
|
||||
// - bindings()(...)
|
||||
// - nodegyp()
|
||||
// - etc.
|
||||
else if (node.type === 'CallExpression') {
|
||||
if ((!isESM || job.mixedModules) && node.callee.type === 'Identifier' && node.arguments.length) {
|
||||
if (node.callee.name === 'require' && knownBindings.require.shadowDepth === 0) {
|
||||
await processRequireArg(node.arguments[0]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if ((!isESM || job.mixedModules) &&
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
node.callee.object.name === 'module' &&
|
||||
'module' in knownBindings === false &&
|
||||
node.callee.property.type === 'Identifier' &&
|
||||
!node.callee.computed &&
|
||||
node.callee.property.name === 'require' &&
|
||||
node.arguments.length) {
|
||||
await processRequireArg(node.arguments[0]);
|
||||
return;
|
||||
}
|
||||
else if ((!isESM || job.mixedModules) &&
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
node.callee.object.name === 'require' &&
|
||||
knownBindings.require.shadowDepth === 0 &&
|
||||
node.callee.property.type === 'Identifier' &&
|
||||
!node.callee.computed &&
|
||||
node.callee.property.name === 'resolve' &&
|
||||
node.arguments.length) {
|
||||
await processRequireArg(node.arguments[0]);
|
||||
return;
|
||||
}
|
||||
const calleeValue = job.analysis.evaluatePureExpressions && await computePureStaticValue(node.callee, false);
|
||||
// if we have a direct pure static function,
|
||||
// and that function has a [TRIGGER] symbol -> trigger asset emission from it
|
||||
if (calleeValue && 'value' in calleeValue && typeof calleeValue.value === 'function' && calleeValue.value[TRIGGER] && job.analysis.computeFileReferences) {
|
||||
staticChildValue = await computePureStaticValue(node, true);
|
||||
// if it computes, then we start backtracking
|
||||
if (staticChildValue && parent) {
|
||||
staticChildNode = node;
|
||||
await backtrack(parent, this);
|
||||
}
|
||||
}
|
||||
// handle well-known function symbol cases
|
||||
else if (calleeValue && 'value' in calleeValue && typeof calleeValue.value === 'symbol') {
|
||||
switch (calleeValue.value) {
|
||||
// customRequireWrapper('...')
|
||||
case BOUND_REQUIRE:
|
||||
if (node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Literal' &&
|
||||
node.callee.type === 'Identifier' &&
|
||||
knownBindings.require.shadowDepth === 0) {
|
||||
await processRequireArg(node.arguments[0]);
|
||||
}
|
||||
break;
|
||||
// require('bindings')(...)
|
||||
case BINDINGS:
|
||||
if (node.arguments.length) {
|
||||
const arg = await computePureStaticValue(node.arguments[0], false);
|
||||
if (arg && 'value' in arg && arg.value) {
|
||||
let opts;
|
||||
if (typeof arg.value === 'object')
|
||||
opts = arg.value;
|
||||
else if (typeof arg.value === 'string')
|
||||
opts = { bindings: arg.value };
|
||||
if (!opts.path) {
|
||||
opts.path = true;
|
||||
}
|
||||
opts.module_root = pkgBase;
|
||||
let resolved;
|
||||
try {
|
||||
resolved = (0, bindings_1.default)(opts);
|
||||
}
|
||||
catch (e) { }
|
||||
if (resolved) {
|
||||
staticChildValue = { value: resolved };
|
||||
staticChildNode = node;
|
||||
await emitStaticChildAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NODE_GYP_BUILD:
|
||||
if (node.arguments.length === 1 && node.arguments[0].type === 'Identifier' &&
|
||||
node.arguments[0].name === '__dirname' && knownBindings.__dirname.shadowDepth === 0) {
|
||||
let resolved;
|
||||
try {
|
||||
// use installed version of node-gyp-build since resolving
|
||||
// binaries can differ among versions
|
||||
const nodeGypBuildPath = (0, resolve_from_1.default)(dir, 'node-gyp-build');
|
||||
resolved = require(nodeGypBuildPath).path(dir);
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
resolved = node_gyp_build_1.default.path(dir);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
if (resolved) {
|
||||
staticChildValue = { value: resolved };
|
||||
staticChildNode = node;
|
||||
await emitStaticChildAsset();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// nbind.init(...) -> require('./resolved.node')
|
||||
case NBIND_INIT:
|
||||
if (node.arguments.length) {
|
||||
const arg = await computePureStaticValue(node.arguments[0], false);
|
||||
if (arg && 'value' in arg && (typeof arg.value === 'string' || typeof arg.value === 'undefined')) {
|
||||
const bindingInfo = (0, binary_locators_1.nbind)(arg.value);
|
||||
if (bindingInfo && bindingInfo.path) {
|
||||
deps.add(path_1.default.relative(dir, bindingInfo.path).replace(/\\/g, '/'));
|
||||
return this.skip();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Express templates:
|
||||
// app.set("view engine", [name]) -> 'name' is a require
|
||||
case EXPRESS_SET:
|
||||
if (node.arguments.length === 2 &&
|
||||
node.arguments[0].type === 'Literal' &&
|
||||
node.arguments[0].value === 'view engine' &&
|
||||
!definedExpressEngines) {
|
||||
await processRequireArg(node.arguments[1]);
|
||||
return this.skip();
|
||||
}
|
||||
break;
|
||||
// app.engine('name', ...) causes opt-out of express dynamic require
|
||||
case EXPRESS_ENGINE:
|
||||
definedExpressEngines = true;
|
||||
break;
|
||||
case FS_FN:
|
||||
case FS_DIR_FN:
|
||||
if (node.arguments[0] && job.analysis.computeFileReferences) {
|
||||
staticChildValue = await computePureStaticValue(node.arguments[0], true);
|
||||
// if it computes, then we start backtracking
|
||||
if (staticChildValue) {
|
||||
staticChildNode = node.arguments[0];
|
||||
if (calleeValue.value === FS_DIR_FN && node.arguments[0].type === 'Identifier' && node.arguments[0].name === '__dirname') {
|
||||
// Special case `fs.readdirSync(__dirname)` to emit right away
|
||||
emitAssetDirectory(dir);
|
||||
}
|
||||
else {
|
||||
await backtrack(parent, this);
|
||||
}
|
||||
return this.skip();
|
||||
}
|
||||
}
|
||||
break;
|
||||
// strong globalize (emits intl folder)
|
||||
case SET_ROOT_DIR:
|
||||
if (node.arguments[0]) {
|
||||
const rootDir = await computePureStaticValue(node.arguments[0], false);
|
||||
if (rootDir && 'value' in rootDir && rootDir.value)
|
||||
emitAssetDirectory(rootDir.value + '/intl');
|
||||
return this.skip();
|
||||
}
|
||||
break;
|
||||
// pkginfo - require('pkginfo')(module) -> loads package.json
|
||||
case PKG_INFO:
|
||||
let pjsonPath = path_1.default.resolve(id, '../package.json');
|
||||
const rootPjson = path_1.default.resolve('/package.json');
|
||||
while (pjsonPath !== rootPjson && (await job.stat(pjsonPath) === null))
|
||||
pjsonPath = path_1.default.resolve(pjsonPath, '../../package.json');
|
||||
if (pjsonPath !== rootPjson)
|
||||
assets.add(pjsonPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.type === 'VariableDeclaration' && parent && !(0, ast_helpers_1.isVarLoop)(parent) && job.analysis.evaluatePureExpressions) {
|
||||
for (const decl of node.declarations) {
|
||||
if (!decl.init)
|
||||
continue;
|
||||
const computed = await computePureStaticValue(decl.init, true);
|
||||
if (computed) {
|
||||
// var known = ...;
|
||||
if (decl.id.type === 'Identifier') {
|
||||
setKnownBinding(decl.id.name, computed);
|
||||
}
|
||||
// var { known } = ...;
|
||||
else if (decl.id.type === 'ObjectPattern' && 'value' in computed) {
|
||||
for (const prop of decl.id.properties) {
|
||||
if (prop.type !== 'Property' ||
|
||||
prop.key.type !== 'Identifier' ||
|
||||
prop.value.type !== 'Identifier' ||
|
||||
typeof computed.value !== 'object' ||
|
||||
computed.value === null ||
|
||||
!(prop.key.name in computed.value))
|
||||
continue;
|
||||
setKnownBinding(prop.value.name, { value: computed.value[prop.key.name] });
|
||||
}
|
||||
}
|
||||
if (!('value' in computed) && isAbsolutePathOrUrl(computed.then) && isAbsolutePathOrUrl(computed.else)) {
|
||||
staticChildValue = computed;
|
||||
staticChildNode = decl.init;
|
||||
await emitStaticChildAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.type === 'AssignmentExpression' && parent && !(0, ast_helpers_1.isLoop)(parent) && job.analysis.evaluatePureExpressions) {
|
||||
if (!hasKnownBindingValue(node.left.name)) {
|
||||
const computed = await computePureStaticValue(node.right, false);
|
||||
if (computed && 'value' in computed) {
|
||||
// var known = ...
|
||||
if (node.left.type === 'Identifier') {
|
||||
setKnownBinding(node.left.name, computed);
|
||||
}
|
||||
// var { known } = ...
|
||||
else if (node.left.type === 'ObjectPattern') {
|
||||
for (const prop of node.left.properties) {
|
||||
if (prop.type !== 'Property' ||
|
||||
prop.key.type !== 'Identifier' ||
|
||||
prop.value.type !== 'Identifier' ||
|
||||
typeof computed.value !== 'object' ||
|
||||
computed.value === null ||
|
||||
!(prop.key.name in computed.value))
|
||||
continue;
|
||||
setKnownBinding(prop.value.name, { value: computed.value[prop.key.name] });
|
||||
}
|
||||
}
|
||||
if (isAbsolutePathOrUrl(computed.value)) {
|
||||
staticChildValue = computed;
|
||||
staticChildNode = node.right;
|
||||
await emitStaticChildAsset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Support require wrappers like function p (x) { ...; var y = require(x); ...; return y; }
|
||||
else if ((!isESM || job.mixedModules) &&
|
||||
(node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') &&
|
||||
(node.arguments || node.params)[0] && (node.arguments || node.params)[0].type === 'Identifier') {
|
||||
let fnName;
|
||||
let args;
|
||||
if ((node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression') &&
|
||||
parent &&
|
||||
parent.type === 'VariableDeclarator' &&
|
||||
parent.id.type === 'Identifier') {
|
||||
fnName = parent.id;
|
||||
args = node.arguments || node.params;
|
||||
}
|
||||
else if (node.id) {
|
||||
fnName = node.id;
|
||||
args = node.arguments || node.params;
|
||||
}
|
||||
if (fnName && node.body.body) {
|
||||
let requireDecl, returned = false;
|
||||
for (let i = 0; i < node.body.body.length; i++) {
|
||||
if (node.body.body[i].type === 'VariableDeclaration' && !requireDecl) {
|
||||
requireDecl = node.body.body[i].declarations.find((decl) => decl &&
|
||||
decl.id &&
|
||||
decl.id.type === 'Identifier' &&
|
||||
decl.init &&
|
||||
decl.init.type === 'CallExpression' &&
|
||||
decl.init.callee.type === 'Identifier' &&
|
||||
decl.init.callee.name === 'require' &&
|
||||
knownBindings.require.shadowDepth === 0 &&
|
||||
decl.init.arguments[0] &&
|
||||
decl.init.arguments[0].type === 'Identifier' &&
|
||||
decl.init.arguments[0].name === args[0].name);
|
||||
}
|
||||
if (requireDecl &&
|
||||
node.body.body[i].type === 'ReturnStatement' &&
|
||||
node.body.body[i].argument &&
|
||||
node.body.body[i].argument.type === 'Identifier' &&
|
||||
node.body.body[i].argument.name === requireDecl.id.name) {
|
||||
returned = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (returned)
|
||||
setKnownBinding(fnName.name, { value: BOUND_REQUIRE });
|
||||
}
|
||||
}
|
||||
},
|
||||
async leave(_node, _parent) {
|
||||
const node = _node;
|
||||
const parent = _parent;
|
||||
if (node.scope) {
|
||||
if (scope.parent) {
|
||||
scope = scope.parent;
|
||||
}
|
||||
for (const id in node.scope.declarations) {
|
||||
if (id in knownBindings) {
|
||||
if (knownBindings[id].shadowDepth > 0)
|
||||
knownBindings[id].shadowDepth--;
|
||||
else
|
||||
delete knownBindings[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (staticChildNode && parent)
|
||||
await backtrack(parent, this);
|
||||
}
|
||||
});
|
||||
await assetEmissionPromises;
|
||||
return { assets, deps, imports, isESM };
|
||||
async function emitAssetPath(assetPath) {
|
||||
// verify the asset file / directory exists
|
||||
const wildcardIndex = assetPath.indexOf(static_eval_1.WILDCARD);
|
||||
const dirIndex = wildcardIndex === -1 ? assetPath.length : assetPath.lastIndexOf(path_1.default.sep, wildcardIndex);
|
||||
const basePath = assetPath.substring(0, dirIndex);
|
||||
try {
|
||||
var stats = await job.stat(basePath);
|
||||
if (stats === null) {
|
||||
throw new Error('file not found');
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
if (wildcardIndex !== -1 && stats.isFile())
|
||||
return;
|
||||
if (stats.isFile()) {
|
||||
assets.add(assetPath);
|
||||
}
|
||||
else if (stats.isDirectory()) {
|
||||
if (validWildcard(assetPath))
|
||||
emitAssetDirectory(assetPath);
|
||||
}
|
||||
}
|
||||
function validWildcard(assetPath) {
|
||||
let wildcardSuffix = '';
|
||||
if (assetPath.endsWith(path_1.default.sep))
|
||||
wildcardSuffix = path_1.default.sep;
|
||||
else if (assetPath.endsWith(path_1.default.sep + static_eval_1.WILDCARD))
|
||||
wildcardSuffix = path_1.default.sep + static_eval_1.WILDCARD;
|
||||
else if (assetPath.endsWith(static_eval_1.WILDCARD))
|
||||
wildcardSuffix = static_eval_1.WILDCARD;
|
||||
// do not emit __dirname
|
||||
if (assetPath === dir + wildcardSuffix)
|
||||
return false;
|
||||
// do not emit cwd
|
||||
if (assetPath === cwd + wildcardSuffix)
|
||||
return false;
|
||||
// do not emit node_modules
|
||||
if (assetPath.endsWith(path_1.default.sep + 'node_modules' + wildcardSuffix))
|
||||
return false;
|
||||
// do not emit directories above __dirname
|
||||
if (dir.startsWith(assetPath.slice(0, assetPath.length - wildcardSuffix.length) + path_1.default.sep))
|
||||
return false;
|
||||
// do not emit asset directories higher than the node_modules base if a package
|
||||
if (pkgBase) {
|
||||
const nodeModulesBase = id.substring(0, id.indexOf(path_1.default.sep + 'node_modules')) + path_1.default.sep + 'node_modules' + path_1.default.sep;
|
||||
if (!assetPath.startsWith(nodeModulesBase)) {
|
||||
if (job.log)
|
||||
console.log('Skipping asset emission of ' + assetPath.replace(static_eval_1.wildcardRegEx, '*') + ' for ' + id + ' as it is outside the package base ' + pkgBase);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
function resolveAbsolutePathOrUrl(value) {
|
||||
return value instanceof url_1.URL ? (0, url_1.fileURLToPath)(value) : value.startsWith('file:') ? (0, url_1.fileURLToPath)(new url_1.URL(value)) : path_1.default.resolve(value);
|
||||
}
|
||||
async function emitStaticChildAsset() {
|
||||
if (!staticChildValue) {
|
||||
return;
|
||||
}
|
||||
if ('value' in staticChildValue && isAbsolutePathOrUrl(staticChildValue.value)) {
|
||||
try {
|
||||
const resolved = resolveAbsolutePathOrUrl(staticChildValue.value);
|
||||
await emitAssetPath(resolved);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
else if ('then' in staticChildValue && 'else' in staticChildValue && isAbsolutePathOrUrl(staticChildValue.then) && isAbsolutePathOrUrl(staticChildValue.else)) {
|
||||
let resolvedThen;
|
||||
try {
|
||||
resolvedThen = resolveAbsolutePathOrUrl(staticChildValue.then);
|
||||
}
|
||||
catch (e) { }
|
||||
let resolvedElse;
|
||||
try {
|
||||
resolvedElse = resolveAbsolutePathOrUrl(staticChildValue.else);
|
||||
}
|
||||
catch (e) { }
|
||||
if (resolvedThen)
|
||||
await emitAssetPath(resolvedThen);
|
||||
if (resolvedElse)
|
||||
await emitAssetPath(resolvedElse);
|
||||
}
|
||||
else if (staticChildNode && staticChildNode.type === 'ArrayExpression' && 'value' in staticChildValue && staticChildValue.value instanceof Array) {
|
||||
for (const value of staticChildValue.value) {
|
||||
try {
|
||||
const resolved = resolveAbsolutePathOrUrl(value);
|
||||
await emitAssetPath(resolved);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
staticChildNode = staticChildValue = undefined;
|
||||
}
|
||||
}
|
||||
exports.default = analyze;
|
||||
;
|
||||
function isAst(ast) {
|
||||
return 'body' in ast;
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/analyze.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/analyze.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@vercel/nft/out/cli.d.ts
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export {};
|
||||
95
node_modules/@vercel/nft/out/cli.js
generated
vendored
Executable file
95
node_modules/@vercel/nft/out/cli.js
generated
vendored
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env node
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = require("path");
|
||||
const graceful_fs_1 = require("graceful-fs");
|
||||
const { copyFile, mkdir } = graceful_fs_1.promises;
|
||||
const rimraf = require('rimraf');
|
||||
const node_file_trace_1 = require("./node-file-trace");
|
||||
function printStack(file, reasons, stdout, cwd) {
|
||||
stdout.push(file);
|
||||
const reason = reasons.get(file);
|
||||
if (!reason ||
|
||||
!reason.parents ||
|
||||
(reason.type.length === 1 && reason.type.includes('initial') && reason.parents.size === 0)) {
|
||||
return;
|
||||
}
|
||||
for (let parent of reason.parents) {
|
||||
printStack(parent, reasons, stdout, cwd);
|
||||
}
|
||||
}
|
||||
async function cli(action = process.argv[2], entrypoint = process.argv[3], exitpoint = process.argv[4], outputDir = 'dist', cwd = process.cwd()) {
|
||||
const opts = {
|
||||
ts: true,
|
||||
base: cwd,
|
||||
mixedModules: true,
|
||||
log: action == 'print' || action == 'build',
|
||||
};
|
||||
const { fileList, esmFileList, warnings, reasons } = await (0, node_file_trace_1.nodeFileTrace)([entrypoint], opts);
|
||||
const allFiles = [...fileList].concat([...esmFileList]).sort();
|
||||
const stdout = [];
|
||||
if (action === 'print') {
|
||||
stdout.push('FILELIST:');
|
||||
stdout.push(...allFiles);
|
||||
stdout.push('\n');
|
||||
if (warnings.size > 0) {
|
||||
stdout.push('WARNINGS:');
|
||||
for (var warning of warnings) {
|
||||
stdout.push(warning.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (action === 'build') {
|
||||
rimraf.sync((0, path_1.join)(cwd, outputDir));
|
||||
for (const f of allFiles) {
|
||||
const src = (0, path_1.join)(cwd, f);
|
||||
const dest = (0, path_1.join)(cwd, outputDir, f);
|
||||
const dir = (0, path_1.dirname)(dest);
|
||||
await mkdir(dir, { recursive: true });
|
||||
await copyFile(src, dest);
|
||||
}
|
||||
}
|
||||
else if (action === 'size') {
|
||||
const isSymbolicLink = (m) => (m & 61440) === 40960;
|
||||
let bytes = 0;
|
||||
for (const f of allFiles) {
|
||||
const lstat = (0, graceful_fs_1.lstatSync)(f);
|
||||
if (isSymbolicLink(lstat.mode)) {
|
||||
bytes += lstat.size;
|
||||
}
|
||||
else {
|
||||
const stat = (0, graceful_fs_1.statSync)(f);
|
||||
bytes += stat.size;
|
||||
}
|
||||
}
|
||||
stdout.push(`${bytes} bytes total`);
|
||||
}
|
||||
else if (action === 'why') {
|
||||
if (!exitpoint) {
|
||||
throw new Error('Expected additional argument for "why" action');
|
||||
}
|
||||
const normalizedExitPoint = ((0, path_1.isAbsolute)(exitpoint)
|
||||
? (0, path_1.relative)(cwd, exitpoint)
|
||||
: exitpoint).replace(/[/\\]/g, path_1.sep);
|
||||
printStack(normalizedExitPoint, reasons, stdout, cwd);
|
||||
}
|
||||
else {
|
||||
stdout.push(`△ nft ${require('../package.json').version}`);
|
||||
stdout.push('');
|
||||
stdout.push('Usage:');
|
||||
stdout.push('');
|
||||
stdout.push(` $ nft [command] <file>`);
|
||||
stdout.push('');
|
||||
stdout.push('Commands:');
|
||||
stdout.push('');
|
||||
stdout.push(' build [entrypoint] trace and copy to the dist directory');
|
||||
stdout.push(' print [entrypoint] trace and print to stdout');
|
||||
stdout.push(' size [entrypoint] trace and print size in bytes');
|
||||
stdout.push(' why [entrypoint] [file] trace and print stack why file was included');
|
||||
}
|
||||
return stdout.join('\n');
|
||||
}
|
||||
if (require.main === module) {
|
||||
cli().then(console.log).catch(console.error);
|
||||
}
|
||||
module.exports = cli;
|
||||
1
node_modules/@vercel/nft/out/cli.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/cli.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,+BAAgE;AAChE,6CAA4D;AAC5D,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,sBAAQ,CAAC;AACrC,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,uDAAkD;AAGlD,SAAS,UAAU,CAAC,IAAY,EAAE,OAA6B,EAAE,MAAgB,EAAE,GAAW;IAC5F,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAEjC,IACE,CAAC,MAAM;QACP,CAAC,MAAM,CAAC,OAAO;QACf,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,EAC1F;QACA,OAAO;KACR;IAED,KAAK,IAAI,MAAM,IAAI,MAAM,CAAC,OAAO,EAAE;QACjC,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;AACH,CAAC;AAED,KAAK,UAAU,GAAG,CAChB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EACxB,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAC5B,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAC3B,SAAS,GAAG,MAAM,EAClB,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAEnB,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,IAAI;QACR,IAAI,EAAE,GAAG;QACT,YAAY,EAAE,IAAI;QAClB,GAAG,EAAE,MAAM,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO;KAC5C,CAAC;IACF,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,+BAAa,EAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC;IAC7F,MAAM,QAAQ,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC/D,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,IAAI,MAAM,KAAK,OAAO,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACxB,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE;YACrB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzB,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE;gBAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;aACjC;SACF;KACF;SAAM,IAAI,MAAM,KAAK,OAAO,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,IAAA,WAAI,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;QAClC,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE;YACxB,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YACzB,MAAM,IAAI,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;YACrC,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;YAC1B,MAAM,KAAK,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtC,MAAM,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;SAC3B;KACF;SAAM,IAAI,MAAM,KAAK,MAAM,EAAE;QAC5B,MAAM,cAAc,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,KAAK,CAAC;QAC5D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE;YACxB,MAAM,KAAK,GAAG,IAAA,uBAAS,EAAC,CAAC,CAAC,CAAC;YAC3B,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAC9B,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC;aACrB;iBAAM;gBACL,MAAM,IAAI,GAAG,IAAA,sBAAQ,EAAC,CAAC,CAAC,CAAA;gBACxB,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC;aACpB;SACF;QACD,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,cAAc,CAAC,CAAA;KACpC;SAAM,IAAI,MAAM,KAAK,KAAK,EAAE;QAC3B,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;SAClE;QACD,MAAM,mBAAmB,GAAG,CAAC,IAAA,iBAAU,EAAC,SAAS,CAAC;YAChD,CAAC,CAAC,IAAA,eAAQ,EAAC,GAAG,EAAE,SAAS,CAAC;YAC1B,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,UAAG,CAAC,CAAC;QAEtC,UAAU,CAAC,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;KACvD;SAAM;QACL,MAAM,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3D,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,MAAM,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAC;QAChF,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;QACrE,MAAM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAC;KACxF;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3B,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;CAC9C;AAED,MAAM,CAAC,OAAO,GAAG,GAAG,CAAC"}
|
||||
23
node_modules/@vercel/nft/out/fs.d.ts
generated
vendored
Normal file
23
node_modules/@vercel/nft/out/fs.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/// <reference types="node" />
|
||||
import type { Stats } from "fs";
|
||||
export declare class CachedFileSystem {
|
||||
private fileCache;
|
||||
private statCache;
|
||||
private symlinkCache;
|
||||
private fileIOQueue;
|
||||
constructor({ cache, fileIOConcurrency, }: {
|
||||
cache?: {
|
||||
fileCache?: Map<string, Promise<string | null>>;
|
||||
statCache?: Map<string, Promise<Stats | null>>;
|
||||
symlinkCache?: Map<string, Promise<string | null>>;
|
||||
};
|
||||
fileIOConcurrency: number;
|
||||
});
|
||||
readlink(path: string): Promise<string | null>;
|
||||
readFile(path: string): Promise<string | null>;
|
||||
stat(path: string): Promise<Stats | null>;
|
||||
private _internalReadlink;
|
||||
private _internalReadFile;
|
||||
private _internalStat;
|
||||
private executeFileIO;
|
||||
}
|
||||
102
node_modules/@vercel/nft/out/fs.js
generated
vendored
Normal file
102
node_modules/@vercel/nft/out/fs.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CachedFileSystem = void 0;
|
||||
const path_1 = require("path");
|
||||
const graceful_fs_1 = __importDefault(require("graceful-fs"));
|
||||
const async_sema_1 = require("async-sema");
|
||||
const fsReadFile = graceful_fs_1.default.promises.readFile;
|
||||
const fsReadlink = graceful_fs_1.default.promises.readlink;
|
||||
const fsStat = graceful_fs_1.default.promises.stat;
|
||||
class CachedFileSystem {
|
||||
constructor({ cache, fileIOConcurrency, }) {
|
||||
this.fileIOQueue = new async_sema_1.Sema(fileIOConcurrency);
|
||||
this.fileCache = cache?.fileCache ?? new Map();
|
||||
this.statCache = cache?.statCache ?? new Map();
|
||||
this.symlinkCache = cache?.symlinkCache ?? new Map();
|
||||
if (cache) {
|
||||
cache.fileCache = this.fileCache;
|
||||
cache.statCache = this.statCache;
|
||||
cache.symlinkCache = this.symlinkCache;
|
||||
}
|
||||
}
|
||||
async readlink(path) {
|
||||
const cached = this.symlinkCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const readlinkPromise = this.executeFileIO(path, this._internalReadlink);
|
||||
this.symlinkCache.set(path, readlinkPromise);
|
||||
return readlinkPromise;
|
||||
}
|
||||
async readFile(path) {
|
||||
const cached = this.fileCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const readFilePromise = this.executeFileIO(path, this._internalReadFile);
|
||||
this.fileCache.set(path, readFilePromise);
|
||||
return readFilePromise;
|
||||
}
|
||||
async stat(path) {
|
||||
const cached = this.statCache.get(path);
|
||||
if (cached !== undefined)
|
||||
return cached;
|
||||
// This is not awaiting the response, so that the cache is instantly populated and
|
||||
// future calls serve the Promise from the cache
|
||||
const statPromise = this.executeFileIO(path, this._internalStat);
|
||||
this.statCache.set(path, statPromise);
|
||||
return statPromise;
|
||||
}
|
||||
async _internalReadlink(path) {
|
||||
try {
|
||||
const link = await fsReadlink(path);
|
||||
// also copy stat cache to symlink
|
||||
const stats = this.statCache.get(path);
|
||||
if (stats)
|
||||
this.statCache.set((0, path_1.resolve)(path, link), stats);
|
||||
return link;
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code !== "EINVAL" && e.code !== "ENOENT" && e.code !== "UNKNOWN")
|
||||
throw e;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
async _internalReadFile(path) {
|
||||
try {
|
||||
return (await fsReadFile(path)).toString();
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === "ENOENT" || e.code === "EISDIR") {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async _internalStat(path) {
|
||||
try {
|
||||
return await fsStat(path);
|
||||
}
|
||||
catch (e) {
|
||||
if (e.code === "ENOENT") {
|
||||
return null;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
async executeFileIO(path, fileIO) {
|
||||
await this.fileIOQueue.acquire();
|
||||
try {
|
||||
return fileIO.call(this, path);
|
||||
}
|
||||
finally {
|
||||
this.fileIOQueue.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.CachedFileSystem = CachedFileSystem;
|
||||
1
node_modules/@vercel/nft/out/fs.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/fs.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":";;;;;;AACA,+BAA+B;AAC/B,8DAA6B;AAC7B,2CAAkC;AAElC,MAAM,UAAU,GAAG,qBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACxC,MAAM,UAAU,GAAG,qBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;AACxC,MAAM,MAAM,GAAG,qBAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;AAEhC,MAAa,gBAAgB;IAM3B,YAAY,EACV,KAAK,EACL,iBAAiB,GAIlB;QACC,IAAI,CAAC,WAAW,GAAG,IAAI,iBAAI,CAAC,iBAAiB,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,IAAI,GAAG,EAAE,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,IAAI,GAAG,EAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,KAAK,EAAE,YAAY,IAAI,IAAI,GAAG,EAAE,CAAC;QAErD,IAAI,KAAK,EAAE;YACT,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YACjC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;YACjC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;SACxC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,kFAAkF;QAClF,gDAAgD;QAChD,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzE,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAE7C,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY;QACzB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,kFAAkF;QAClF,gDAAgD;QAChD,MAAM,eAAe,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAE1C,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,IAAY;QACrB,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,kFAAkF;QAClF,gDAAgD;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAEtC,OAAO,WAAW,CAAC;IACrB,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,IAAY;QAC1C,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC;YACpC,kCAAkC;YAClC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACvC,IAAI,KAAK;gBAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAA,cAAO,EAAC,IAAI,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;YAC1D,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;gBACpE,MAAM,CAAC,CAAC;YACV,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAEO,KAAK,CAAC,iBAAiB,CAAC,IAAY;QAC1C,IAAI;YACF,OAAO,CAAC,MAAM,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC5C;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBAC9C,OAAO,IAAI,CAAC;aACb;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,IAAY;QACtC,IAAI;YACF,OAAO,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;SAC3B;QAAC,OAAO,CAAM,EAAE;YACf,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,OAAO,IAAI,CAAC;aACb;YACD,MAAM,CAAC,CAAC;SACT;IACH,CAAC;IAEO,KAAK,CAAC,aAAa,CACzB,IAAY,EACZ,MAAyC;QAEzC,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAEjC,IAAI;YACF,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;SAChC;gBAAS;YACR,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;SAC5B;IACH,CAAC;CACF;AA1GD,4CA0GC"}
|
||||
2
node_modules/@vercel/nft/out/index.d.ts
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './types';
|
||||
export { nodeFileTrace } from './node-file-trace';
|
||||
20
node_modules/@vercel/nft/out/index.js
generated
vendored
Normal file
20
node_modules/@vercel/nft/out/index.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.nodeFileTrace = void 0;
|
||||
__exportStar(require("./types"), exports);
|
||||
var node_file_trace_1 = require("./node-file-trace");
|
||||
Object.defineProperty(exports, "nodeFileTrace", { enumerable: true, get: function () { return node_file_trace_1.nodeFileTrace; } });
|
||||
1
node_modules/@vercel/nft/out/index.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA"}
|
||||
39
node_modules/@vercel/nft/out/node-file-trace.d.ts
generated
vendored
Normal file
39
node_modules/@vercel/nft/out/node-file-trace.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { NodeFileTraceOptions, NodeFileTraceResult, NodeFileTraceReasons, NodeFileTraceReasonType } from './types';
|
||||
export declare function nodeFileTrace(files: string[], opts?: NodeFileTraceOptions): Promise<NodeFileTraceResult>;
|
||||
export declare class Job {
|
||||
ts: boolean;
|
||||
base: string;
|
||||
cwd: string;
|
||||
conditions: string[];
|
||||
exportsOnly: boolean;
|
||||
paths: Record<string, string>;
|
||||
ignoreFn: (path: string, parent?: string) => boolean;
|
||||
log: boolean;
|
||||
mixedModules: boolean;
|
||||
analysis: {
|
||||
emitGlobs?: boolean;
|
||||
computeFileReferences?: boolean;
|
||||
evaluatePureExpressions?: boolean;
|
||||
};
|
||||
private analysisCache;
|
||||
fileList: Set<string>;
|
||||
esmFileList: Set<string>;
|
||||
processed: Set<string>;
|
||||
warnings: Set<Error>;
|
||||
reasons: NodeFileTraceReasons;
|
||||
private cachedFileSystem;
|
||||
constructor({ base, processCwd, exports, conditions, exportsOnly, paths, ignore, log, mixedModules, ts, analysis, cache, fileIOConcurrency, }: NodeFileTraceOptions);
|
||||
readlink(path: string): Promise<string | null>;
|
||||
isFile(path: string): Promise<boolean>;
|
||||
isDir(path: string): Promise<boolean>;
|
||||
stat(path: string): Promise<import("fs").Stats | null>;
|
||||
private maybeEmitDep;
|
||||
resolve(id: string, parent: string, job: Job, cjsResolve: boolean): Promise<string | string[]>;
|
||||
readFile(path: string): Promise<Buffer | string | null>;
|
||||
realpath(path: string, parent?: string, seen?: Set<unknown>): Promise<string>;
|
||||
emitFile(path: string, reasonType: NodeFileTraceReasonType, parent?: string, isRealpath?: boolean): Promise<boolean>;
|
||||
getPjsonBoundary(path: string): Promise<string | undefined>;
|
||||
emitDependency(path: string, parent?: string): Promise<void>;
|
||||
}
|
||||
322
node_modules/@vercel/nft/out/node-file-trace.js
generated
vendored
Normal file
322
node_modules/@vercel/nft/out/node-file-trace.js
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Job = exports.nodeFileTrace = void 0;
|
||||
const path_1 = require("path");
|
||||
const analyze_1 = __importDefault(require("./analyze"));
|
||||
const resolve_dependency_1 = __importStar(require("./resolve-dependency"));
|
||||
const micromatch_1 = require("micromatch");
|
||||
const sharedlib_emit_1 = require("./utils/sharedlib-emit");
|
||||
const path_2 = require("path");
|
||||
const fs_1 = require("./fs");
|
||||
function inPath(path, parent) {
|
||||
const pathWithSep = (0, path_2.join)(parent, path_1.sep);
|
||||
return path.startsWith(pathWithSep) && path !== pathWithSep;
|
||||
}
|
||||
async function nodeFileTrace(files, opts = {}) {
|
||||
const job = new Job(opts);
|
||||
if (opts.readFile)
|
||||
job.readFile = opts.readFile;
|
||||
if (opts.stat)
|
||||
job.stat = opts.stat;
|
||||
if (opts.readlink)
|
||||
job.readlink = opts.readlink;
|
||||
if (opts.resolve)
|
||||
job.resolve = opts.resolve;
|
||||
job.ts = true;
|
||||
await Promise.all(files.map(async (file) => {
|
||||
const path = (0, path_1.resolve)(file);
|
||||
await job.emitFile(path, 'initial');
|
||||
return job.emitDependency(path);
|
||||
}));
|
||||
const result = {
|
||||
fileList: job.fileList,
|
||||
esmFileList: job.esmFileList,
|
||||
reasons: job.reasons,
|
||||
warnings: job.warnings
|
||||
};
|
||||
return result;
|
||||
}
|
||||
exports.nodeFileTrace = nodeFileTrace;
|
||||
;
|
||||
class Job {
|
||||
constructor({ base = process.cwd(), processCwd, exports, conditions = exports || ['node'], exportsOnly = false, paths = {}, ignore, log = false, mixedModules = false, ts = true, analysis = {}, cache,
|
||||
// we use a default of 1024 concurrency to balance
|
||||
// performance and memory usage for fs operations
|
||||
fileIOConcurrency = 1024, }) {
|
||||
this.reasons = new Map();
|
||||
this.maybeEmitDep = async (dep, path, cjsResolve) => {
|
||||
let resolved = '';
|
||||
let error;
|
||||
try {
|
||||
resolved = await this.resolve(dep, path, this, cjsResolve);
|
||||
}
|
||||
catch (e1) {
|
||||
error = e1;
|
||||
try {
|
||||
if (this.ts && dep.endsWith('.js') && e1 instanceof resolve_dependency_1.NotFoundError) {
|
||||
// TS with ESM relative import paths need full extensions
|
||||
// (we have to write import "./foo.js" instead of import "./foo")
|
||||
// See https://www.typescriptlang.org/docs/handbook/esm-node.html
|
||||
const depTS = dep.slice(0, -3) + '.ts';
|
||||
resolved = await this.resolve(depTS, path, this, cjsResolve);
|
||||
error = undefined;
|
||||
}
|
||||
}
|
||||
catch (e2) {
|
||||
error = e2;
|
||||
}
|
||||
}
|
||||
if (error) {
|
||||
this.warnings.add(new Error(`Failed to resolve dependency "${dep}":\n${error?.message}`));
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(resolved)) {
|
||||
for (const item of resolved) {
|
||||
// ignore builtins
|
||||
if (item.startsWith('node:'))
|
||||
return;
|
||||
await this.emitDependency(item, path);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// ignore builtins
|
||||
if (resolved.startsWith('node:'))
|
||||
return;
|
||||
await this.emitDependency(resolved, path);
|
||||
}
|
||||
};
|
||||
this.ts = ts;
|
||||
base = (0, path_1.resolve)(base);
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
if (typeof ignore === 'string')
|
||||
ignore = [ignore];
|
||||
if (typeof ignore === 'function') {
|
||||
const ig = ignore;
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
if (ig(path))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
else if (Array.isArray(ignore)) {
|
||||
const resolvedIgnores = ignore.map(ignore => (0, path_1.relative)(base, (0, path_1.resolve)(base || process.cwd(), ignore)));
|
||||
this.ignoreFn = (path) => {
|
||||
if (path.startsWith('..' + path_1.sep))
|
||||
return true;
|
||||
if ((0, micromatch_1.isMatch)(path, resolvedIgnores))
|
||||
return true;
|
||||
return false;
|
||||
};
|
||||
}
|
||||
this.base = base;
|
||||
this.cwd = (0, path_1.resolve)(processCwd || base);
|
||||
this.conditions = conditions;
|
||||
this.exportsOnly = exportsOnly;
|
||||
const resolvedPaths = {};
|
||||
for (const path of Object.keys(paths)) {
|
||||
const trailer = paths[path].endsWith('/');
|
||||
const resolvedPath = (0, path_1.resolve)(base, paths[path]);
|
||||
resolvedPaths[path] = resolvedPath + (trailer ? '/' : '');
|
||||
}
|
||||
this.paths = resolvedPaths;
|
||||
this.log = log;
|
||||
this.mixedModules = mixedModules;
|
||||
this.cachedFileSystem = new fs_1.CachedFileSystem({ cache, fileIOConcurrency });
|
||||
this.analysis = {};
|
||||
if (analysis !== false) {
|
||||
Object.assign(this.analysis, {
|
||||
// whether to glob any analysis like __dirname + '/dir/' or require('x/' + y)
|
||||
// that might output any file in a directory
|
||||
emitGlobs: true,
|
||||
// whether __filename and __dirname style
|
||||
// expressions should be analyzed as file references
|
||||
computeFileReferences: true,
|
||||
// evaluate known bindings to assist with glob and file reference analysis
|
||||
evaluatePureExpressions: true,
|
||||
}, analysis === true ? {} : analysis);
|
||||
}
|
||||
this.analysisCache = cache && cache.analysisCache || new Map();
|
||||
if (cache) {
|
||||
cache.analysisCache = this.analysisCache;
|
||||
}
|
||||
this.fileList = new Set();
|
||||
this.esmFileList = new Set();
|
||||
this.processed = new Set();
|
||||
this.warnings = new Set();
|
||||
}
|
||||
async readlink(path) {
|
||||
return this.cachedFileSystem.readlink(path);
|
||||
}
|
||||
async isFile(path) {
|
||||
const stats = await this.stat(path);
|
||||
if (stats)
|
||||
return stats.isFile();
|
||||
return false;
|
||||
}
|
||||
async isDir(path) {
|
||||
const stats = await this.stat(path);
|
||||
if (stats)
|
||||
return stats.isDirectory();
|
||||
return false;
|
||||
}
|
||||
async stat(path) {
|
||||
return this.cachedFileSystem.stat(path);
|
||||
}
|
||||
async resolve(id, parent, job, cjsResolve) {
|
||||
return (0, resolve_dependency_1.default)(id, parent, job, cjsResolve);
|
||||
}
|
||||
async readFile(path) {
|
||||
return this.cachedFileSystem.readFile(path);
|
||||
}
|
||||
async realpath(path, parent, seen = new Set()) {
|
||||
if (seen.has(path))
|
||||
throw new Error('Recursive symlink detected resolving ' + path);
|
||||
seen.add(path);
|
||||
const symlink = await this.readlink(path);
|
||||
// emit direct symlink paths only
|
||||
if (symlink) {
|
||||
const parentPath = (0, path_1.dirname)(path);
|
||||
const resolved = (0, path_1.resolve)(parentPath, symlink);
|
||||
const realParent = await this.realpath(parentPath, parent);
|
||||
if (inPath(path, realParent))
|
||||
await this.emitFile(path, 'resolve', parent, true);
|
||||
return this.realpath(resolved, parent, seen);
|
||||
}
|
||||
// keep backtracking for realpath, emitting folder symlinks within base
|
||||
if (!inPath(path, this.base))
|
||||
return path;
|
||||
return (0, path_2.join)(await this.realpath((0, path_1.dirname)(path), parent, seen), (0, path_1.basename)(path));
|
||||
}
|
||||
async emitFile(path, reasonType, parent, isRealpath = false) {
|
||||
if (!isRealpath) {
|
||||
path = await this.realpath(path, parent);
|
||||
}
|
||||
path = (0, path_1.relative)(this.base, path);
|
||||
if (parent) {
|
||||
parent = (0, path_1.relative)(this.base, parent);
|
||||
}
|
||||
let reasonEntry = this.reasons.get(path);
|
||||
if (!reasonEntry) {
|
||||
reasonEntry = {
|
||||
type: [reasonType],
|
||||
ignored: false,
|
||||
parents: new Set()
|
||||
};
|
||||
this.reasons.set(path, reasonEntry);
|
||||
}
|
||||
else if (!reasonEntry.type.includes(reasonType)) {
|
||||
reasonEntry.type.push(reasonType);
|
||||
}
|
||||
if (parent && this.ignoreFn(path, parent)) {
|
||||
if (!this.fileList.has(path) && reasonEntry) {
|
||||
reasonEntry.ignored = true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (parent) {
|
||||
reasonEntry.parents.add(parent);
|
||||
}
|
||||
this.fileList.add(path);
|
||||
return true;
|
||||
}
|
||||
async getPjsonBoundary(path) {
|
||||
const rootSeparatorIndex = path.indexOf(path_1.sep);
|
||||
let separatorIndex;
|
||||
while ((separatorIndex = path.lastIndexOf(path_1.sep)) > rootSeparatorIndex) {
|
||||
path = path.slice(0, separatorIndex);
|
||||
if (await this.isFile(path + path_1.sep + 'package.json'))
|
||||
return path;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async emitDependency(path, parent) {
|
||||
if (this.processed.has(path)) {
|
||||
if (parent) {
|
||||
await this.emitFile(path, 'dependency', parent);
|
||||
}
|
||||
return;
|
||||
}
|
||||
;
|
||||
this.processed.add(path);
|
||||
const emitted = await this.emitFile(path, 'dependency', parent);
|
||||
if (!emitted)
|
||||
return;
|
||||
if (path.endsWith('.json'))
|
||||
return;
|
||||
if (path.endsWith('.node'))
|
||||
return await (0, sharedlib_emit_1.sharedLibEmit)(path, this);
|
||||
// .js and .ts files can change behavior based on { "type": "module" }
|
||||
// in the nearest package.json so we must emit it too. We don't need to
|
||||
// emit for .cjs/.mjs/.cts/.mts files since their behavior does not
|
||||
// depend on package.json
|
||||
if (path.endsWith('.js') || path.endsWith('.ts')) {
|
||||
const pjsonBoundary = await this.getPjsonBoundary(path);
|
||||
if (pjsonBoundary)
|
||||
await this.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', path);
|
||||
}
|
||||
let analyzeResult;
|
||||
const cachedAnalysis = this.analysisCache.get(path);
|
||||
if (cachedAnalysis) {
|
||||
analyzeResult = cachedAnalysis;
|
||||
}
|
||||
else {
|
||||
const source = await this.readFile(path);
|
||||
if (source === null)
|
||||
throw new Error('File ' + path + ' does not exist.');
|
||||
// analyze should not have any side-effects e.g. calling `job.emitFile`
|
||||
// directly as this will not be included in the cachedAnalysis and won't
|
||||
// be emit for successive runs that leverage the cache
|
||||
analyzeResult = await (0, analyze_1.default)(path, source.toString(), this);
|
||||
this.analysisCache.set(path, analyzeResult);
|
||||
}
|
||||
const { deps, imports, assets, isESM } = analyzeResult;
|
||||
if (isESM) {
|
||||
this.esmFileList.add((0, path_1.relative)(this.base, path));
|
||||
}
|
||||
await Promise.all([
|
||||
...[...assets].map(async (asset) => {
|
||||
const ext = (0, path_1.extname)(asset);
|
||||
if (ext === '.js' || ext === '.mjs' || ext === '.node' || ext === '' ||
|
||||
this.ts && (ext === '.ts' || ext === '.tsx') && asset.startsWith(this.base) && asset.slice(this.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1)
|
||||
await this.emitDependency(asset, path);
|
||||
else
|
||||
await this.emitFile(asset, 'asset', path);
|
||||
}),
|
||||
...[...deps].map(async (dep) => this.maybeEmitDep(dep, path, !isESM)),
|
||||
...[...imports].map(async (dep) => this.maybeEmitDep(dep, path, false)),
|
||||
]);
|
||||
}
|
||||
}
|
||||
exports.Job = Job;
|
||||
1
node_modules/@vercel/nft/out/node-file-trace.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/node-file-trace.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
6
node_modules/@vercel/nft/out/resolve-dependency.d.ts
generated
vendored
Normal file
6
node_modules/@vercel/nft/out/resolve-dependency.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Job } from './node-file-trace';
|
||||
export default function resolveDependency(specifier: string, parent: string, job: Job, cjsResolve?: boolean): Promise<string | string[]>;
|
||||
export declare class NotFoundError extends Error {
|
||||
code: string;
|
||||
constructor(specifier: string, parent: string);
|
||||
}
|
||||
264
node_modules/@vercel/nft/out/resolve-dependency.js
generated
vendored
Normal file
264
node_modules/@vercel/nft/out/resolve-dependency.js
generated
vendored
Normal file
@@ -0,0 +1,264 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.NotFoundError = void 0;
|
||||
const path_1 = require("path");
|
||||
// node resolver
|
||||
// custom implementation to emit only needed package.json files for resolver
|
||||
// (package.json files are emitted as they are hit)
|
||||
async function resolveDependency(specifier, parent, job, cjsResolve = true) {
|
||||
let resolved;
|
||||
if ((0, path_1.isAbsolute)(specifier) || specifier === '.' || specifier === '..' || specifier.startsWith('./') || specifier.startsWith('../')) {
|
||||
const trailingSlash = specifier.endsWith('/');
|
||||
resolved = await resolvePath((0, path_1.resolve)(parent, '..', specifier) + (trailingSlash ? '/' : ''), parent, job);
|
||||
}
|
||||
else if (specifier[0] === '#') {
|
||||
resolved = await packageImportsResolve(specifier, parent, job, cjsResolve);
|
||||
}
|
||||
else {
|
||||
resolved = await resolvePackage(specifier, parent, job, cjsResolve);
|
||||
}
|
||||
if (Array.isArray(resolved)) {
|
||||
return Promise.all(resolved.map(resolved => job.realpath(resolved, parent)));
|
||||
}
|
||||
else if (resolved.startsWith('node:')) {
|
||||
return resolved;
|
||||
}
|
||||
else {
|
||||
return job.realpath(resolved, parent);
|
||||
}
|
||||
}
|
||||
exports.default = resolveDependency;
|
||||
;
|
||||
async function resolvePath(path, parent, job) {
|
||||
const result = await resolveFile(path, parent, job) || await resolveDir(path, parent, job);
|
||||
if (!result) {
|
||||
throw new NotFoundError(path, parent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
async function resolveFile(path, parent, job) {
|
||||
if (path.endsWith('/'))
|
||||
return undefined;
|
||||
path = await job.realpath(path, parent);
|
||||
if (await job.isFile(path))
|
||||
return path;
|
||||
if (job.ts && path.startsWith(job.base) && path.slice(job.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1 && await job.isFile(path + '.ts'))
|
||||
return path + '.ts';
|
||||
if (job.ts && path.startsWith(job.base) && path.slice(job.base.length).indexOf(path_1.sep + 'node_modules' + path_1.sep) === -1 && await job.isFile(path + '.tsx'))
|
||||
return path + '.tsx';
|
||||
if (await job.isFile(path + '.js'))
|
||||
return path + '.js';
|
||||
if (await job.isFile(path + '.json'))
|
||||
return path + '.json';
|
||||
if (await job.isFile(path + '.node'))
|
||||
return path + '.node';
|
||||
return undefined;
|
||||
}
|
||||
async function resolveDir(path, parent, job) {
|
||||
if (path.endsWith('/'))
|
||||
path = path.slice(0, -1);
|
||||
if (!await job.isDir(path))
|
||||
return;
|
||||
const pkgCfg = await getPkgCfg(path, job);
|
||||
if (pkgCfg && typeof pkgCfg.main === 'string') {
|
||||
const resolved = await resolveFile((0, path_1.resolve)(path, pkgCfg.main), parent, job) || await resolveFile((0, path_1.resolve)(path, pkgCfg.main, 'index'), parent, job);
|
||||
if (resolved) {
|
||||
await job.emitFile(path + path_1.sep + 'package.json', 'resolve', parent);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
return resolveFile((0, path_1.resolve)(path, 'index'), parent, job);
|
||||
}
|
||||
class NotFoundError extends Error {
|
||||
constructor(specifier, parent) {
|
||||
super("Cannot find module '" + specifier + "' loaded from " + parent);
|
||||
this.code = 'MODULE_NOT_FOUND';
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
const nodeBuiltins = new Set([...require("repl")._builtinLibs, "constants", "module", "timers", "console", "_stream_writable", "_stream_readable", "_stream_duplex", "process", "sys"]);
|
||||
function getPkgName(name) {
|
||||
const segments = name.split('/');
|
||||
if (name[0] === '@' && segments.length > 1)
|
||||
return segments.length > 1 ? segments.slice(0, 2).join('/') : null;
|
||||
return segments.length ? segments[0] : null;
|
||||
}
|
||||
async function getPkgCfg(pkgPath, job) {
|
||||
const pjsonSource = await job.readFile(pkgPath + path_1.sep + 'package.json');
|
||||
if (pjsonSource) {
|
||||
try {
|
||||
return JSON.parse(pjsonSource.toString());
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function getExportsTarget(exports, conditions, cjsResolve) {
|
||||
if (typeof exports === 'string') {
|
||||
return exports;
|
||||
}
|
||||
else if (exports === null) {
|
||||
return exports;
|
||||
}
|
||||
else if (Array.isArray(exports)) {
|
||||
for (const item of exports) {
|
||||
const target = getExportsTarget(item, conditions, cjsResolve);
|
||||
if (target === null || typeof target === 'string' && target.startsWith('./'))
|
||||
return target;
|
||||
}
|
||||
}
|
||||
else if (typeof exports === 'object') {
|
||||
for (const condition of Object.keys(exports)) {
|
||||
if (condition === 'default' ||
|
||||
condition === 'require' && cjsResolve ||
|
||||
condition === 'import' && !cjsResolve ||
|
||||
conditions.includes(condition)) {
|
||||
const target = getExportsTarget(exports[condition], conditions, cjsResolve);
|
||||
if (target !== undefined)
|
||||
return target;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function resolveExportsImports(pkgPath, obj, subpath, job, isImports, cjsResolve) {
|
||||
let matchObj;
|
||||
if (isImports) {
|
||||
if (!(typeof obj === 'object' && !Array.isArray(obj) && obj !== null))
|
||||
return undefined;
|
||||
matchObj = obj;
|
||||
}
|
||||
else if (typeof obj === 'string' || Array.isArray(obj) || obj === null ||
|
||||
typeof obj === 'object' && Object.keys(obj).length && Object.keys(obj)[0][0] !== '.') {
|
||||
matchObj = { '.': obj };
|
||||
}
|
||||
else {
|
||||
matchObj = obj;
|
||||
}
|
||||
if (subpath in matchObj) {
|
||||
const target = getExportsTarget(matchObj[subpath], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' && target.startsWith('./'))
|
||||
return pkgPath + target.slice(1);
|
||||
}
|
||||
for (const match of Object.keys(matchObj).sort((a, b) => b.length - a.length)) {
|
||||
if (match.endsWith('*') && subpath.startsWith(match.slice(0, -1))) {
|
||||
const target = getExportsTarget(matchObj[match], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' && target.startsWith('./'))
|
||||
return pkgPath + target.slice(1).replace(/\*/g, subpath.slice(match.length - 1));
|
||||
}
|
||||
if (!match.endsWith('/'))
|
||||
continue;
|
||||
if (subpath.startsWith(match)) {
|
||||
const target = getExportsTarget(matchObj[match], job.conditions, cjsResolve);
|
||||
if (typeof target === 'string' && target.endsWith('/') && target.startsWith('./'))
|
||||
return pkgPath + target.slice(1) + subpath.slice(match.length);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
async function packageImportsResolve(name, parent, job, cjsResolve) {
|
||||
if (name !== '#' && !name.startsWith('#/') && job.conditions) {
|
||||
const pjsonBoundary = await job.getPjsonBoundary(parent);
|
||||
if (pjsonBoundary) {
|
||||
const pkgCfg = await getPkgCfg(pjsonBoundary, job);
|
||||
const { imports: pkgImports } = pkgCfg || {};
|
||||
if (pkgCfg && pkgImports !== null && pkgImports !== undefined) {
|
||||
let importsResolved = resolveExportsImports(pjsonBoundary, pkgImports, name, job, true, cjsResolve);
|
||||
if (importsResolved) {
|
||||
if (cjsResolve)
|
||||
importsResolved = await resolveFile(importsResolved, parent, job) || await resolveDir(importsResolved, parent, job);
|
||||
else if (!await job.isFile(importsResolved))
|
||||
throw new NotFoundError(importsResolved, parent);
|
||||
if (importsResolved) {
|
||||
await job.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', parent);
|
||||
return importsResolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
async function resolvePackage(name, parent, job, cjsResolve) {
|
||||
let packageParent = parent;
|
||||
if (nodeBuiltins.has(name))
|
||||
return 'node:' + name;
|
||||
if (name.startsWith('node:'))
|
||||
return name;
|
||||
const pkgName = getPkgName(name) || '';
|
||||
// package own name resolution
|
||||
let selfResolved;
|
||||
if (job.conditions) {
|
||||
const pjsonBoundary = await job.getPjsonBoundary(parent);
|
||||
if (pjsonBoundary) {
|
||||
const pkgCfg = await getPkgCfg(pjsonBoundary, job);
|
||||
const { exports: pkgExports } = pkgCfg || {};
|
||||
if (pkgCfg && pkgCfg.name && pkgCfg.name === pkgName && pkgExports !== null && pkgExports !== undefined) {
|
||||
selfResolved = resolveExportsImports(pjsonBoundary, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve);
|
||||
if (selfResolved) {
|
||||
if (cjsResolve)
|
||||
selfResolved = await resolveFile(selfResolved, parent, job) || await resolveDir(selfResolved, parent, job);
|
||||
else if (!await job.isFile(selfResolved))
|
||||
throw new NotFoundError(selfResolved, parent);
|
||||
}
|
||||
if (selfResolved)
|
||||
await job.emitFile(pjsonBoundary + path_1.sep + 'package.json', 'resolve', parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
let separatorIndex;
|
||||
const rootSeparatorIndex = packageParent.indexOf(path_1.sep);
|
||||
while ((separatorIndex = packageParent.lastIndexOf(path_1.sep)) > rootSeparatorIndex) {
|
||||
packageParent = packageParent.slice(0, separatorIndex);
|
||||
const nodeModulesDir = packageParent + path_1.sep + 'node_modules';
|
||||
const stat = await job.stat(nodeModulesDir);
|
||||
if (!stat || !stat.isDirectory())
|
||||
continue;
|
||||
const pkgCfg = await getPkgCfg(nodeModulesDir + path_1.sep + pkgName, job);
|
||||
const { exports: pkgExports } = pkgCfg || {};
|
||||
if (job.conditions && pkgExports !== undefined && pkgExports !== null && !selfResolved) {
|
||||
let legacyResolved;
|
||||
if (!job.exportsOnly)
|
||||
legacyResolved = await resolveFile(nodeModulesDir + path_1.sep + name, parent, job) || await resolveDir(nodeModulesDir + path_1.sep + name, parent, job);
|
||||
let resolved = resolveExportsImports(nodeModulesDir + path_1.sep + pkgName, pkgExports, '.' + name.slice(pkgName.length), job, false, cjsResolve);
|
||||
if (resolved) {
|
||||
if (cjsResolve)
|
||||
resolved = await resolveFile(resolved, parent, job) || await resolveDir(resolved, parent, job);
|
||||
else if (!await job.isFile(resolved))
|
||||
throw new NotFoundError(resolved, parent);
|
||||
}
|
||||
if (resolved) {
|
||||
await job.emitFile(nodeModulesDir + path_1.sep + pkgName + path_1.sep + 'package.json', 'resolve', parent);
|
||||
if (legacyResolved && legacyResolved !== resolved)
|
||||
return [resolved, legacyResolved];
|
||||
return resolved;
|
||||
}
|
||||
if (legacyResolved)
|
||||
return legacyResolved;
|
||||
}
|
||||
else {
|
||||
const resolved = await resolveFile(nodeModulesDir + path_1.sep + name, parent, job) || await resolveDir(nodeModulesDir + path_1.sep + name, parent, job);
|
||||
if (resolved) {
|
||||
if (selfResolved && selfResolved !== resolved)
|
||||
return [resolved, selfResolved];
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (selfResolved)
|
||||
return selfResolved;
|
||||
if (Object.hasOwnProperty.call(job.paths, name)) {
|
||||
return job.paths[name];
|
||||
}
|
||||
for (const path of Object.keys(job.paths)) {
|
||||
if (path.endsWith('/') && name.startsWith(path)) {
|
||||
const pathTarget = job.paths[path] + name.slice(path.length);
|
||||
const resolved = await resolveFile(pathTarget, parent, job) || await resolveDir(pathTarget, parent, job);
|
||||
if (!resolved) {
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
throw new NotFoundError(name, parent);
|
||||
}
|
||||
1
node_modules/@vercel/nft/out/resolve-dependency.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/resolve-dependency.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
65
node_modules/@vercel/nft/out/types.d.ts
generated
vendored
Normal file
65
node_modules/@vercel/nft/out/types.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/// <reference types="node" />
|
||||
import { Job } from './node-file-trace';
|
||||
export interface Stats {
|
||||
isFile(): boolean;
|
||||
isDirectory(): boolean;
|
||||
isBlockDevice(): boolean;
|
||||
isCharacterDevice(): boolean;
|
||||
isSymbolicLink(): boolean;
|
||||
isFIFO(): boolean;
|
||||
isSocket(): boolean;
|
||||
dev: number;
|
||||
ino: number;
|
||||
mode: number;
|
||||
nlink: number;
|
||||
uid: number;
|
||||
gid: number;
|
||||
rdev: number;
|
||||
size: number;
|
||||
blksize: number;
|
||||
blocks: number;
|
||||
atimeMs: number;
|
||||
mtimeMs: number;
|
||||
ctimeMs: number;
|
||||
birthtimeMs: number;
|
||||
atime: Date;
|
||||
mtime: Date;
|
||||
ctime: Date;
|
||||
birthtime: Date;
|
||||
}
|
||||
export interface NodeFileTraceOptions {
|
||||
base?: string;
|
||||
processCwd?: string;
|
||||
exports?: string[];
|
||||
conditions?: string[];
|
||||
exportsOnly?: boolean;
|
||||
ignore?: string | string[] | ((path: string) => boolean);
|
||||
analysis?: boolean | {
|
||||
emitGlobs?: boolean;
|
||||
computeFileReferences?: boolean;
|
||||
evaluatePureExpressions?: boolean;
|
||||
};
|
||||
cache?: any;
|
||||
paths?: Record<string, string>;
|
||||
ts?: boolean;
|
||||
log?: boolean;
|
||||
mixedModules?: boolean;
|
||||
readFile?: (path: string) => Promise<Buffer | string | null>;
|
||||
stat?: (path: string) => Promise<Stats | null>;
|
||||
readlink?: (path: string) => Promise<string | null>;
|
||||
resolve?: (id: string, parent: string, job: Job, cjsResolve: boolean) => Promise<string | string[]>;
|
||||
fileIOConcurrency?: number;
|
||||
}
|
||||
export declare type NodeFileTraceReasonType = 'initial' | 'resolve' | 'dependency' | 'asset' | 'sharedlib';
|
||||
export interface NodeFileTraceReasons extends Map<string, {
|
||||
type: NodeFileTraceReasonType[];
|
||||
ignored: boolean;
|
||||
parents: Set<string>;
|
||||
}> {
|
||||
}
|
||||
export interface NodeFileTraceResult {
|
||||
fileList: Set<string>;
|
||||
esmFileList: Set<string>;
|
||||
reasons: NodeFileTraceReasons;
|
||||
warnings: Set<Error>;
|
||||
}
|
||||
2
node_modules/@vercel/nft/out/types.js
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
node_modules/@vercel/nft/out/types.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
||||
44
node_modules/@vercel/nft/out/utils/ast-helpers.js
generated
vendored
Normal file
44
node_modules/@vercel/nft/out/utils/ast-helpers.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isLoop = exports.isVarLoop = exports.isIdentifierRead = void 0;
|
||||
function isIdentifierRead(node, parent) {
|
||||
switch (parent.type) {
|
||||
case 'ObjectPattern':
|
||||
case 'ArrayPattern':
|
||||
// Note: default values not currently supported
|
||||
return false;
|
||||
// disregard `bar` in `bar = thing()`
|
||||
case 'AssignmentExpression':
|
||||
return parent.right === node;
|
||||
case 'MemberExpression':
|
||||
return parent.computed || node === parent.object;
|
||||
// disregard the `bar` in `{ bar: foo }`
|
||||
case 'Property':
|
||||
return node === parent.value;
|
||||
// disregard the `bar` in `class Foo { bar () {...} }`
|
||||
case 'MethodDefinition':
|
||||
return false;
|
||||
// disregard the `bar` in var bar = asdf
|
||||
case 'VariableDeclarator':
|
||||
return parent.id !== node;
|
||||
// disregard the `bar` in `export { foo as bar }`
|
||||
case 'ExportSpecifier':
|
||||
return false;
|
||||
// disregard the `bar` in `function (bar) {}`
|
||||
case 'FunctionExpression':
|
||||
case 'FunctionDeclaration':
|
||||
case 'ArrowFunctionExpression':
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.isIdentifierRead = isIdentifierRead;
|
||||
function isVarLoop(node) {
|
||||
return node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement';
|
||||
}
|
||||
exports.isVarLoop = isVarLoop;
|
||||
function isLoop(node) {
|
||||
return node.type === 'ForStatement' || node.type === 'ForInStatement' || node.type === 'ForOfStatement' || node.type === 'WhileStatement' || node.type === 'DoWhileStatement';
|
||||
}
|
||||
exports.isLoop = isLoop;
|
||||
1
node_modules/@vercel/nft/out/utils/ast-helpers.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/ast-helpers.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ast-helpers.js","sourceRoot":"","sources":["../../src/utils/ast-helpers.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,IAAU,EAAE,MAAY;IACvD,QAAQ,MAAM,CAAC,IAAI,EAAE;QACnB,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc;YACjB,+CAA+C;YAC/C,OAAO,KAAK,CAAC;QACf,qCAAqC;QACrC,KAAK,sBAAsB;YACzB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC;QAC/B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,QAAQ,IAAI,IAAI,KAAK,MAAM,CAAC,MAAM,CAAC;QACnD,wCAAwC;QACxC,KAAK,UAAU;YACb,OAAO,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC;QAC/B,sDAAsD;QACtD,KAAK,kBAAkB;YACrB,OAAO,KAAK,CAAC;QACf,wCAAwC;QACxC,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC;QAC5B,iDAAiD;QACjD,KAAK,iBAAiB;YACpB,OAAO,KAAK,CAAC;QACf,6CAA6C;QAC7C,KAAK,oBAAoB,CAAC;QAC1B,KAAK,qBAAqB,CAAC;QAC3B,KAAK,yBAAyB;YAC5B,OAAO,KAAK,CAAC;QACf;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC;AA/BD,4CA+BC;AAED,SAAgB,SAAS,CAAC,IAAU;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,CAAC;AAC1G,CAAC;AAFD,8BAEC;AAED,SAAgB,MAAM,CAAC,IAAU;IAC/B,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC;AAChL,CAAC;AAFD,wBAEC"}
|
||||
88
node_modules/@vercel/nft/out/utils/binary-locators.js
generated
vendored
Normal file
88
node_modules/@vercel/nft/out/utils/binary-locators.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.nbind = exports.pregyp = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const graceful_fs_1 = __importDefault(require("graceful-fs"));
|
||||
// pregyp
|
||||
const versioning = require("@mapbox/node-pre-gyp/lib/util/versioning.js");
|
||||
const napi = require("@mapbox/node-pre-gyp/lib/util/napi.js");
|
||||
const pregypFind = (package_json_path, opts) => {
|
||||
const package_json = JSON.parse(graceful_fs_1.default.readFileSync(package_json_path).toString());
|
||||
versioning.validate_config(package_json, opts);
|
||||
var napi_build_version;
|
||||
if (napi.get_napi_build_versions(package_json, opts)) {
|
||||
napi_build_version = napi.get_best_napi_build_version(package_json, opts);
|
||||
}
|
||||
opts = opts || {};
|
||||
if (!opts.module_root)
|
||||
opts.module_root = path_1.default.dirname(package_json_path);
|
||||
var meta = versioning.evaluate(package_json, opts, napi_build_version);
|
||||
return meta.module;
|
||||
};
|
||||
exports.pregyp = { default: { find: pregypFind }, find: pregypFind };
|
||||
// nbind
|
||||
// Adapted from nbind.js
|
||||
function makeModulePathList(root, name) {
|
||||
return ([
|
||||
[root, name],
|
||||
[root, "build", name],
|
||||
[root, "build", "Debug", name],
|
||||
[root, "build", "Release", name],
|
||||
[root, "out", "Debug", name],
|
||||
[root, "Debug", name],
|
||||
[root, "out", "Release", name],
|
||||
[root, "Release", name],
|
||||
[root, "build", "default", name],
|
||||
[
|
||||
root,
|
||||
process.env["NODE_BINDINGS_COMPILED_DIR"] || "compiled",
|
||||
process.versions.node,
|
||||
process.platform,
|
||||
process.arch,
|
||||
name
|
||||
]
|
||||
]);
|
||||
}
|
||||
function findCompiledModule(basePath, specList) {
|
||||
var resolvedList = [];
|
||||
var ext = path_1.default.extname(basePath);
|
||||
for (var _i = 0, specList_1 = specList; _i < specList_1.length; _i++) {
|
||||
var spec = specList_1[_i];
|
||||
if (ext == spec.ext) {
|
||||
try {
|
||||
spec.path = eval("require.resolve(basePath)");
|
||||
return spec;
|
||||
}
|
||||
catch (err) {
|
||||
resolvedList.push(basePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var _a = 0, specList_2 = specList; _a < specList_2.length; _a++) {
|
||||
var spec = specList_2[_a];
|
||||
for (var _b = 0, _c = makeModulePathList(basePath, spec.name); _b < _c.length; _b++) {
|
||||
var pathParts = _c[_b];
|
||||
var resolvedPath = path_1.default.resolve.apply(path_1.default, pathParts);
|
||||
try {
|
||||
spec.path = eval("require.resolve(resolvedPath)");
|
||||
}
|
||||
catch (err) {
|
||||
resolvedList.push(resolvedPath);
|
||||
continue;
|
||||
}
|
||||
return spec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function nbind(basePath = process.cwd()) {
|
||||
const found = findCompiledModule(basePath, [
|
||||
{ ext: ".node", name: "nbind.node", type: "node" },
|
||||
{ ext: ".js", name: "nbind.js", type: "emcc" }
|
||||
]);
|
||||
return found;
|
||||
}
|
||||
exports.nbind = nbind;
|
||||
1
node_modules/@vercel/nft/out/utils/binary-locators.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/binary-locators.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"binary-locators.js","sourceRoot":"","sources":["../../src/utils/binary-locators.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,8DAA6B;AAE7B,SAAS;AACT,MAAM,UAAU,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAC1E,MAAM,IAAI,GAAG,OAAO,CAAC,uCAAuC,CAAC,CAAC;AAC9D,MAAM,UAAU,GAAG,CAAC,iBAAyB,EAAE,IAAS,EAAE,EAAE;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,qBAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,UAAU,CAAC,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAC/C,IAAI,kBAAkB,CAAC;IACvB,IAAI,IAAI,CAAC,uBAAuB,CAAE,YAAY,EAAE,IAAI,CAAC,EAAE;QACrD,kBAAkB,GAAG,IAAI,CAAC,2BAA2B,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;KAC3E;IACD,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IAClB,IAAI,CAAC,IAAI,CAAC,WAAW;QAAE,IAAI,CAAC,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC1E,IAAI,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,YAAY,EAAC,IAAI,EAAC,kBAAkB,CAAC,CAAC;IACrE,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC,CAAC;AACW,QAAA,MAAM,GAAG,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAE1E,QAAQ;AACR,wBAAwB;AACxB,SAAS,kBAAkB,CAAC,IAAY,EAAE,IAAY;IACpD,OAAO,CAAC;QACN,CAAC,IAAI,EAAE,IAAI,CAAC;QACZ,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;QACrB,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;QAC9B,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC;QAChC,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;QAC5B,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;QACrB,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC;QAC9B,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC;QACvB,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC;QAChC;YACI,IAAI;YACJ,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,IAAI,UAAU;YACvD,OAAO,CAAC,QAAQ,CAAC,IAAI;YACrB,OAAO,CAAC,QAAQ;YAChB,OAAO,CAAC,IAAI;YACZ,IAAI;SACP;KACF,CAAC,CAAC;AACL,CAAC;AAGD,SAAS,kBAAkB,CAAC,QAAgB,EAAE,QAAgB;IAC5D,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,IAAI,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACjC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,QAAQ,EAAE,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;QACpE,IAAI,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC1B,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE;YACnB,IAAI;gBACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,2BAA2B,CAAC,CAAC;gBAC9C,OAAO,IAAI,CAAC;aACb;YACD,OAAO,GAAG,EAAE;gBACV,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aAC7B;SACF;KACF;IACD,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,UAAU,GAAG,QAAQ,EAAE,EAAE,GAAG,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;QACpE,IAAI,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;QAC1B,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,kBAAkB,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;YACnF,IAAI,SAAS,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YACvB,IAAI,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,KAAK,CAAC,cAAI,EAAE,SAAS,CAAC,CAAC;YACvD,IAAI;gBACF,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,+BAA+B,CAAC,CAAC;aACnD;YACD,OAAO,GAAG,EAAE;gBACV,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBAChC,SAAS;aACV;YACD,OAAO,IAAI,CAAC;SACb;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AACD,SAAgB,KAAK,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;IAC5C,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,EAAE;QACzC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE;QAClD,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;KAC/C,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAND,sBAMC"}
|
||||
32
node_modules/@vercel/nft/out/utils/get-package-base.js
generated
vendored
Normal file
32
node_modules/@vercel/nft/out/utils/get-package-base.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getPackageName = exports.getPackageBase = void 0;
|
||||
// returns the base-level package folder based on detecting "node_modules"
|
||||
// package name boundaries
|
||||
const pkgNameRegEx = /^(@[^\\\/]+[\\\/])?[^\\\/]+/;
|
||||
function getPackageBase(id) {
|
||||
const pkgIndex = id.lastIndexOf('node_modules');
|
||||
if (pkgIndex !== -1 &&
|
||||
(id[pkgIndex - 1] === '/' || id[pkgIndex - 1] === '\\') &&
|
||||
(id[pkgIndex + 12] === '/' || id[pkgIndex + 12] === '\\')) {
|
||||
const pkgNameMatch = id.slice(pkgIndex + 13).match(pkgNameRegEx);
|
||||
if (pkgNameMatch)
|
||||
return id.slice(0, pkgIndex + 13 + pkgNameMatch[0].length);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.getPackageBase = getPackageBase;
|
||||
function getPackageName(id) {
|
||||
const pkgIndex = id.lastIndexOf('node_modules');
|
||||
if (pkgIndex !== -1 &&
|
||||
(id[pkgIndex - 1] === '/' || id[pkgIndex - 1] === '\\') &&
|
||||
(id[pkgIndex + 12] === '/' || id[pkgIndex + 12] === '\\')) {
|
||||
const pkgNameMatch = id.slice(pkgIndex + 13).match(pkgNameRegEx);
|
||||
if (pkgNameMatch && pkgNameMatch.length > 0) {
|
||||
return pkgNameMatch[0].replace(/\\/g, '/');
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
exports.getPackageName = getPackageName;
|
||||
;
|
||||
1
node_modules/@vercel/nft/out/utils/get-package-base.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/get-package-base.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"get-package-base.js","sourceRoot":"","sources":["../../src/utils/get-package-base.ts"],"names":[],"mappings":";;;AAAA,0EAA0E;AAC1E,0BAA0B;AAC1B,MAAM,YAAY,GAAG,6BAA6B,CAAC;AAEnD,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAChD,IAAI,QAAQ,KAAK,CAAC,CAAC;QACf,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QACvD,CAAC,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,EAAE;QAC7D,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjE,IAAI,YAAY;YACd,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;KAC9D;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,wCAUC;AAED,SAAgB,cAAc,CAAC,EAAU;IACvC,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAChD,IAAI,QAAQ,KAAK,CAAC,CAAC;QACf,CAAC,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC;QACvD,CAAC,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,GAAG,IAAI,EAAE,CAAC,QAAQ,GAAG,EAAE,CAAC,KAAK,IAAI,CAAC,EAAE;QAC7D,MAAM,YAAY,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACjE,IAAI,YAAY,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3C,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAG,GAAG,CAAC,CAAC;SAC7C;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAXD,wCAWC;AAAA,CAAC"}
|
||||
25
node_modules/@vercel/nft/out/utils/interop-require.js
generated
vendored
Normal file
25
node_modules/@vercel/nft/out/utils/interop-require.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeWildcardRequire = exports.normalizeDefaultRequire = void 0;
|
||||
function normalizeDefaultRequire(obj) {
|
||||
if (obj && obj.__esModule)
|
||||
return obj;
|
||||
return { default: obj };
|
||||
}
|
||||
exports.normalizeDefaultRequire = normalizeDefaultRequire;
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function normalizeWildcardRequire(obj) {
|
||||
if (obj && obj.__esModule)
|
||||
return obj;
|
||||
// Note: This implements only value properties and doesn't preserve getters.
|
||||
// This follows the simpler helpers generated by TypeScript.
|
||||
const out = {};
|
||||
for (const key in obj) {
|
||||
if (!hasOwnProperty.call(obj, key))
|
||||
continue;
|
||||
out[key] = obj[key];
|
||||
}
|
||||
out['default'] = obj;
|
||||
return out;
|
||||
}
|
||||
exports.normalizeWildcardRequire = normalizeWildcardRequire;
|
||||
1
node_modules/@vercel/nft/out/utils/interop-require.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/interop-require.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"interop-require.js","sourceRoot":"","sources":["../../src/utils/interop-require.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;AAEb,SAAgB,uBAAuB,CAAC,GAAQ;IAC9C,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAC1B,CAAC;AAHD,0DAGC;AAED,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACvD,SAAgB,wBAAwB,CAAC,GAAQ;IAC/C,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU;QAAE,OAAO,GAAG,CAAC;IACtC,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,GAAG,GAA8B,EAAE,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;QACrB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC;YAAE,SAAS;QAC7C,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;KACrB;IACD,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC;IACrB,OAAO,GAAG,CAAC;AACb,CAAC;AAXD,4DAWC"}
|
||||
31
node_modules/@vercel/nft/out/utils/sharedlib-emit.js
generated
vendored
Normal file
31
node_modules/@vercel/nft/out/utils/sharedlib-emit.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sharedLibEmit = void 0;
|
||||
const os_1 = __importDefault(require("os"));
|
||||
const glob_1 = __importDefault(require("glob"));
|
||||
const get_package_base_1 = require("./get-package-base");
|
||||
let sharedlibGlob = '';
|
||||
switch (os_1.default.platform()) {
|
||||
case 'darwin':
|
||||
sharedlibGlob = '/**/*.@(dylib|so?(.*))';
|
||||
break;
|
||||
case 'win32':
|
||||
sharedlibGlob = '/**/*.dll';
|
||||
break;
|
||||
default:
|
||||
sharedlibGlob = '/**/*.so?(.*)';
|
||||
}
|
||||
// helper for emitting the associated shared libraries when a binary is emitted
|
||||
async function sharedLibEmit(path, job) {
|
||||
// console.log('Emitting shared libs for ' + path);
|
||||
const pkgPath = (0, get_package_base_1.getPackageBase)(path);
|
||||
if (!pkgPath)
|
||||
return;
|
||||
const files = await new Promise((resolve, reject) => (0, glob_1.default)(pkgPath + sharedlibGlob, { ignore: pkgPath + '/**/node_modules/**/*' }, (err, files) => err ? reject(err) : resolve(files)));
|
||||
await Promise.all(files.map(file => job.emitFile(file, 'sharedlib', path)));
|
||||
}
|
||||
exports.sharedLibEmit = sharedLibEmit;
|
||||
;
|
||||
1
node_modules/@vercel/nft/out/utils/sharedlib-emit.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/sharedlib-emit.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sharedlib-emit.js","sourceRoot":"","sources":["../../src/utils/sharedlib-emit.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,yDAAoD;AAGpD,IAAI,aAAa,GAAG,EAAE,CAAC;AACvB,QAAQ,YAAE,CAAC,QAAQ,EAAE,EAAE;IACrB,KAAK,QAAQ;QACX,aAAa,GAAG,wBAAwB,CAAC;QAC3C,MAAM;IACN,KAAK,OAAO;QACV,aAAa,GAAG,WAAW,CAAC;QAC9B,MAAM;IACN;QACE,aAAa,GAAG,eAAe,CAAC;CACnC;AAED,+EAA+E;AACxE,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,GAAQ;IACxD,mDAAmD;IACnD,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,IAAI,CAAC,CAAC;IACrC,IAAI,CAAC,OAAO;QACV,OAAO;IAET,MAAM,KAAK,GAAG,MAAM,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAC5D,IAAA,cAAI,EAAC,OAAO,GAAG,aAAa,EAAE,EAAE,MAAM,EAAE,OAAO,GAAG,uBAAuB,EAAE,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CACjI,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC;AAVD,sCAUC;AAAA,CAAC"}
|
||||
246
node_modules/@vercel/nft/out/utils/special-cases.js
generated
vendored
Normal file
246
node_modules/@vercel/nft/out/utils/special-cases.js
generated
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path_1 = require("path");
|
||||
const resolve_dependency_1 = __importDefault(require("../resolve-dependency"));
|
||||
const get_package_base_1 = require("./get-package-base");
|
||||
const graceful_fs_1 = require("graceful-fs");
|
||||
const specialCases = {
|
||||
'@generated/photon'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('@generated/photon/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'runtime/'));
|
||||
}
|
||||
},
|
||||
'argon2'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('argon2/argon2.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'build', 'Release'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'prebuilds'));
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), 'lib', 'binding'));
|
||||
}
|
||||
},
|
||||
'bull'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('bull/lib/commands/index.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id)));
|
||||
}
|
||||
},
|
||||
'camaro'({ id, emitAsset }) {
|
||||
if (id.endsWith('camaro/dist/camaro.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), 'camaro.wasm'));
|
||||
}
|
||||
},
|
||||
'esbuild'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('esbuild/lib/main.js')) {
|
||||
const file = (0, path_1.resolve)(id, '..', '..', 'package.json');
|
||||
const pkg = JSON.parse((0, graceful_fs_1.readFileSync)(file, 'utf8'));
|
||||
for (const dep of Object.keys(pkg.optionalDependencies || {})) {
|
||||
const dir = (0, path_1.resolve)(id, '..', '..', '..', dep);
|
||||
emitAssetDirectory(dir);
|
||||
}
|
||||
}
|
||||
},
|
||||
'google-gax'({ id, ast, emitAssetDirectory }) {
|
||||
if (id.endsWith('google-gax/build/src/grpc.js')) {
|
||||
// const googleProtoFilesDir = path.normalize(google_proto_files_1.getProtoPath('..'));
|
||||
// ->
|
||||
// const googleProtoFilesDir = resolve(__dirname, '../../../google-proto-files');
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'VariableDeclaration' &&
|
||||
statement.declarations[0].id.type === 'Identifier' &&
|
||||
statement.declarations[0].id.name === 'googleProtoFilesDir') {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '../../../google-proto-files'));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'oracledb'({ id, ast, emitAsset }) {
|
||||
if (id.endsWith('oracledb/lib/oracledb.js')) {
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'ForStatement' &&
|
||||
'body' in statement.body &&
|
||||
statement.body.body &&
|
||||
Array.isArray(statement.body.body) &&
|
||||
statement.body.body[0] &&
|
||||
statement.body.body[0].type === 'TryStatement' &&
|
||||
statement.body.body[0].block.body[0] &&
|
||||
statement.body.body[0].block.body[0].type === 'ExpressionStatement' &&
|
||||
statement.body.body[0].block.body[0].expression.type === 'AssignmentExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.operator === '=' &&
|
||||
statement.body.body[0].block.body[0].expression.left.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.left.name === 'oracledbCLib' &&
|
||||
statement.body.body[0].block.body[0].expression.right.type === 'CallExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.right.callee.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.callee.name === 'require' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments.length === 1 &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].type === 'MemberExpression' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].computed === true &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].object.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].object.name === 'binaryLocations' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].property.type === 'Identifier' &&
|
||||
statement.body.body[0].block.body[0].expression.right.arguments[0].property.name === 'i') {
|
||||
statement.body.body[0].block.body[0].expression.right.arguments = [{ type: 'Literal', value: '_' }];
|
||||
const version = global._unit ? '3.0.0' : JSON.parse((0, graceful_fs_1.readFileSync)(id.slice(0, -15) + 'package.json', 'utf8')).version;
|
||||
const useVersion = Number(version.slice(0, version.indexOf('.'))) >= 4;
|
||||
const binaryName = 'oracledb-' + (useVersion ? version : 'abi' + process.versions.modules) + '-' + process.platform + '-' + process.arch + '.node';
|
||||
emitAsset((0, path_1.resolve)(id, '../../build/Release/' + binaryName));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'phantomjs-prebuilt'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('phantomjs-prebuilt/lib/phantomjs.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)((0, path_1.dirname)(id), '..', 'bin'));
|
||||
}
|
||||
},
|
||||
'remark-prism'({ id, emitAssetDirectory }) {
|
||||
const file = 'remark-prism/src/highlight.js';
|
||||
if (id.endsWith(file)) {
|
||||
try {
|
||||
const node_modules = id.slice(0, -file.length);
|
||||
emitAssetDirectory((0, path_1.resolve)(node_modules, 'prismjs', 'components'));
|
||||
}
|
||||
catch (e) {
|
||||
// fail silently
|
||||
}
|
||||
}
|
||||
},
|
||||
'semver'({ id, emitAsset }) {
|
||||
if (id.endsWith('semver/index.js')) {
|
||||
// See https://github.com/npm/node-semver/blob/master/CHANGELOG.md#710
|
||||
emitAsset((0, path_1.resolve)(id.replace('index.js', 'preload.js')));
|
||||
}
|
||||
},
|
||||
'socket.io': async function ({ id, ast, job }) {
|
||||
if (id.endsWith('socket.io/lib/index.js')) {
|
||||
async function replaceResolvePathStatement(statement) {
|
||||
if (statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.right.type === 'CallExpression' &&
|
||||
statement.expression.right.callee.type === 'Identifier' &&
|
||||
statement.expression.right.callee.name === 'read' &&
|
||||
statement.expression.right.arguments.length >= 1 &&
|
||||
statement.expression.right.arguments[0].type === 'CallExpression' &&
|
||||
statement.expression.right.arguments[0].callee.type === 'Identifier' &&
|
||||
statement.expression.right.arguments[0].callee.name === 'resolvePath' &&
|
||||
statement.expression.right.arguments[0].arguments.length === 1 &&
|
||||
statement.expression.right.arguments[0].arguments[0].type === 'Literal') {
|
||||
const arg = statement.expression.right.arguments[0].arguments[0].value;
|
||||
let resolved;
|
||||
try {
|
||||
const dep = await (0, resolve_dependency_1.default)(String(arg), id, job);
|
||||
if (typeof dep === 'string') {
|
||||
resolved = dep;
|
||||
}
|
||||
else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
// The asset relocator will then pick up the AST rewriting from here
|
||||
const relResolved = '/' + (0, path_1.relative)((0, path_1.dirname)(id), resolved);
|
||||
statement.expression.right.arguments[0] = {
|
||||
type: 'BinaryExpression',
|
||||
// @ts-ignore Its okay if start is undefined
|
||||
start: statement.expression.right.arguments[0].start,
|
||||
// @ts-ignore Its okay if end is undefined
|
||||
end: statement.expression.right.arguments[0].end,
|
||||
operator: '+',
|
||||
left: {
|
||||
type: 'Identifier',
|
||||
name: '__dirname'
|
||||
},
|
||||
right: {
|
||||
type: 'Literal',
|
||||
value: relResolved,
|
||||
raw: JSON.stringify(relResolved)
|
||||
}
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
for (const statement of ast.body) {
|
||||
if (statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.left.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.object.type === 'Identifier' &&
|
||||
statement.expression.left.object.object.name === 'Server' &&
|
||||
statement.expression.left.object.property.type === 'Identifier' &&
|
||||
statement.expression.left.object.property.name === 'prototype' &&
|
||||
statement.expression.left.property.type === 'Identifier' &&
|
||||
statement.expression.left.property.name === 'serveClient' &&
|
||||
statement.expression.right.type === 'FunctionExpression') {
|
||||
for (const node of statement.expression.right.body.body) {
|
||||
if (node.type === 'IfStatement' && node.consequent && 'body' in node.consequent && node.consequent.body) {
|
||||
const ifBody = node.consequent.body;
|
||||
let replaced = false;
|
||||
if (Array.isArray(ifBody) && ifBody[0] && ifBody[0].type === 'ExpressionStatement') {
|
||||
replaced = await replaceResolvePathStatement(ifBody[0]);
|
||||
}
|
||||
if (Array.isArray(ifBody) && ifBody[1] && ifBody[1].type === 'TryStatement' && ifBody[1].block.body && ifBody[1].block.body[0]) {
|
||||
replaced = await replaceResolvePathStatement(ifBody[1].block.body[0]) || replaced;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'typescript'({ id, emitAssetDirectory }) {
|
||||
if (id.endsWith('typescript/lib/tsc.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)(id, '../'));
|
||||
}
|
||||
},
|
||||
'uglify-es'({ id, emitAsset }) {
|
||||
if (id.endsWith('uglify-es/tools/node.js')) {
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/utils.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/ast.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/parse.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/transform.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/scope.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/output.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/compress.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/sourcemap.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/mozilla-ast.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/propmangle.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../../lib/minify.js'));
|
||||
emitAsset((0, path_1.resolve)(id, '../exports.js'));
|
||||
}
|
||||
},
|
||||
'uglify-js'({ id, emitAsset, emitAssetDirectory }) {
|
||||
if (id.endsWith('uglify-js/tools/node.js')) {
|
||||
emitAssetDirectory((0, path_1.resolve)(id, '../../lib'));
|
||||
emitAsset((0, path_1.resolve)(id, '../exports.js'));
|
||||
}
|
||||
},
|
||||
'playwright-core'({ id, emitAsset }) {
|
||||
if (id.endsWith('playwright-core/index.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), 'browsers.json'));
|
||||
}
|
||||
},
|
||||
'geo-tz'({ id, emitAsset }) {
|
||||
if (id.endsWith('geo-tz/dist/geo-tz.js')) {
|
||||
emitAsset((0, path_1.resolve)((0, path_1.dirname)(id), '../data/geo.dat'));
|
||||
}
|
||||
},
|
||||
'pixelmatch'({ id, emitDependency }) {
|
||||
if (id.endsWith('pixelmatch/index.js')) {
|
||||
emitDependency((0, path_1.resolve)((0, path_1.dirname)(id), 'bin/pixelmatch'));
|
||||
}
|
||||
}
|
||||
};
|
||||
async function handleSpecialCases({ id, ast, emitDependency, emitAsset, emitAssetDirectory, job }) {
|
||||
const pkgName = (0, get_package_base_1.getPackageName)(id);
|
||||
const specialCase = specialCases[pkgName || ''];
|
||||
id = id.replace(/\\/g, '/');
|
||||
if (specialCase)
|
||||
await specialCase({ id, ast, emitDependency, emitAsset, emitAssetDirectory, job });
|
||||
}
|
||||
exports.default = handleSpecialCases;
|
||||
;
|
||||
1
node_modules/@vercel/nft/out/utils/special-cases.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/special-cases.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
562
node_modules/@vercel/nft/out/utils/static-eval.js
generated
vendored
Normal file
562
node_modules/@vercel/nft/out/utils/static-eval.js
generated
vendored
Normal file
@@ -0,0 +1,562 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.wildcardRegEx = exports.WILDCARD = exports.FUNCTION = exports.UNKNOWN = exports.evaluate = void 0;
|
||||
const url_1 = require("url");
|
||||
async function evaluate(ast, vars = {}, computeBranches = true) {
|
||||
const state = {
|
||||
computeBranches,
|
||||
vars
|
||||
};
|
||||
return walk(ast);
|
||||
// walk returns:
|
||||
// 1. Single known value: { value: value }
|
||||
// 2. Conditional value: { test, then, else }
|
||||
// 3. Unknown value: undefined
|
||||
function walk(node) {
|
||||
const visitor = visitors[node.type];
|
||||
if (visitor) {
|
||||
return visitor.call(state, node, walk);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
exports.evaluate = evaluate;
|
||||
;
|
||||
exports.UNKNOWN = Symbol();
|
||||
exports.FUNCTION = Symbol();
|
||||
exports.WILDCARD = '\x1a';
|
||||
exports.wildcardRegEx = /\x1a/g;
|
||||
function countWildcards(str) {
|
||||
exports.wildcardRegEx.lastIndex = 0;
|
||||
let cnt = 0;
|
||||
while (exports.wildcardRegEx.exec(str))
|
||||
cnt++;
|
||||
return cnt;
|
||||
}
|
||||
const visitors = {
|
||||
'ArrayExpression': async function ArrayExpression(node, walk) {
|
||||
const arr = [];
|
||||
for (let i = 0, l = node.elements.length; i < l; i++) {
|
||||
if (node.elements[i] === null) {
|
||||
arr.push(null);
|
||||
continue;
|
||||
}
|
||||
const x = await walk(node.elements[i]);
|
||||
if (!x)
|
||||
return;
|
||||
if ('value' in x === false)
|
||||
return;
|
||||
arr.push(x.value);
|
||||
}
|
||||
return { value: arr };
|
||||
},
|
||||
'ArrowFunctionExpression': async function (node, walk) {
|
||||
// () => val support only
|
||||
if (node.params.length === 0 && !node.generator && !node.async && node.expression) {
|
||||
const innerValue = await walk(node.body);
|
||||
if (!innerValue || !('value' in innerValue))
|
||||
return;
|
||||
return {
|
||||
value: {
|
||||
[exports.FUNCTION]: () => innerValue.value
|
||||
}
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
'BinaryExpression': async function BinaryExpression(node, walk) {
|
||||
const op = node.operator;
|
||||
let l = await walk(node.left);
|
||||
if (!l && op !== '+')
|
||||
return;
|
||||
let r = await walk(node.right);
|
||||
if (!l && !r)
|
||||
return;
|
||||
if (!l) {
|
||||
// UNKNOWN + 'str' -> wildcard string value
|
||||
if (this.computeBranches && r && 'value' in r && typeof r.value === 'string')
|
||||
return { value: exports.WILDCARD + r.value, wildcards: [node.left, ...r.wildcards || []] };
|
||||
return;
|
||||
}
|
||||
if (!r) {
|
||||
// 'str' + UKNOWN -> wildcard string value
|
||||
if (this.computeBranches && op === '+') {
|
||||
if (l && 'value' in l && typeof l.value === 'string')
|
||||
return { value: l.value + exports.WILDCARD, wildcards: [...l.wildcards || [], node.right] };
|
||||
}
|
||||
// A || UNKNOWN -> A if A is truthy
|
||||
if (!('test' in l) && op === '||' && l.value)
|
||||
return l;
|
||||
return;
|
||||
}
|
||||
if ('test' in l && 'value' in r) {
|
||||
const v = r.value;
|
||||
if (op === '==')
|
||||
return { test: l.test, then: l.then == v, else: l.else == v };
|
||||
if (op === '===')
|
||||
return { test: l.test, then: l.then === v, else: l.else === v };
|
||||
if (op === '!=')
|
||||
return { test: l.test, then: l.then != v, else: l.else != v };
|
||||
if (op === '!==')
|
||||
return { test: l.test, then: l.then !== v, else: l.else !== v };
|
||||
if (op === '+')
|
||||
return { test: l.test, then: l.then + v, else: l.else + v };
|
||||
if (op === '-')
|
||||
return { test: l.test, then: l.then - v, else: l.else - v };
|
||||
if (op === '*')
|
||||
return { test: l.test, then: l.then * v, else: l.else * v };
|
||||
if (op === '/')
|
||||
return { test: l.test, then: l.then / v, else: l.else / v };
|
||||
if (op === '%')
|
||||
return { test: l.test, then: l.then % v, else: l.else % v };
|
||||
if (op === '<')
|
||||
return { test: l.test, then: l.then < v, else: l.else < v };
|
||||
if (op === '<=')
|
||||
return { test: l.test, then: l.then <= v, else: l.else <= v };
|
||||
if (op === '>')
|
||||
return { test: l.test, then: l.then > v, else: l.else > v };
|
||||
if (op === '>=')
|
||||
return { test: l.test, then: l.then >= v, else: l.else >= v };
|
||||
if (op === '|')
|
||||
return { test: l.test, then: l.then | v, else: l.else | v };
|
||||
if (op === '&')
|
||||
return { test: l.test, then: l.then & v, else: l.else & v };
|
||||
if (op === '^')
|
||||
return { test: l.test, then: l.then ^ v, else: l.else ^ v };
|
||||
if (op === '&&')
|
||||
return { test: l.test, then: l.then && v, else: l.else && v };
|
||||
if (op === '||')
|
||||
return { test: l.test, then: l.then || v, else: l.else || v };
|
||||
}
|
||||
else if ('test' in r && 'value' in l) {
|
||||
const v = l.value;
|
||||
if (op === '==')
|
||||
return { test: r.test, then: v == r.then, else: v == r.else };
|
||||
if (op === '===')
|
||||
return { test: r.test, then: v === r.then, else: v === r.else };
|
||||
if (op === '!=')
|
||||
return { test: r.test, then: v != r.then, else: v != r.else };
|
||||
if (op === '!==')
|
||||
return { test: r.test, then: v !== r.then, else: v !== r.else };
|
||||
if (op === '+')
|
||||
return { test: r.test, then: v + r.then, else: v + r.else };
|
||||
if (op === '-')
|
||||
return { test: r.test, then: v - r.then, else: v - r.else };
|
||||
if (op === '*')
|
||||
return { test: r.test, then: v * r.then, else: v * r.else };
|
||||
if (op === '/')
|
||||
return { test: r.test, then: v / r.then, else: v / r.else };
|
||||
if (op === '%')
|
||||
return { test: r.test, then: v % r.then, else: v % r.else };
|
||||
if (op === '<')
|
||||
return { test: r.test, then: v < r.then, else: v < r.else };
|
||||
if (op === '<=')
|
||||
return { test: r.test, then: v <= r.then, else: v <= r.else };
|
||||
if (op === '>')
|
||||
return { test: r.test, then: v > r.then, else: v > r.else };
|
||||
if (op === '>=')
|
||||
return { test: r.test, then: v >= r.then, else: v >= r.else };
|
||||
if (op === '|')
|
||||
return { test: r.test, then: v | r.then, else: v | r.else };
|
||||
if (op === '&')
|
||||
return { test: r.test, then: v & r.then, else: v & r.else };
|
||||
if (op === '^')
|
||||
return { test: r.test, then: v ^ r.then, else: v ^ r.else };
|
||||
if (op === '&&')
|
||||
return { test: r.test, then: v && r.then, else: l && r.else };
|
||||
if (op === '||')
|
||||
return { test: r.test, then: v || r.then, else: l || r.else };
|
||||
}
|
||||
else if ('value' in l && 'value' in r) {
|
||||
if (op === '==')
|
||||
return { value: l.value == r.value };
|
||||
if (op === '===')
|
||||
return { value: l.value === r.value };
|
||||
if (op === '!=')
|
||||
return { value: l.value != r.value };
|
||||
if (op === '!==')
|
||||
return { value: l.value !== r.value };
|
||||
if (op === '+') {
|
||||
const val = { value: l.value + r.value };
|
||||
let wildcards = [];
|
||||
if ('wildcards' in l && l.wildcards) {
|
||||
wildcards = wildcards.concat(l.wildcards);
|
||||
}
|
||||
if ('wildcards' in r && r.wildcards) {
|
||||
wildcards = wildcards.concat(r.wildcards);
|
||||
}
|
||||
if (wildcards.length > 0) {
|
||||
val.wildcards = wildcards;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
if (op === '-')
|
||||
return { value: l.value - r.value };
|
||||
if (op === '*')
|
||||
return { value: l.value * r.value };
|
||||
if (op === '/')
|
||||
return { value: l.value / r.value };
|
||||
if (op === '%')
|
||||
return { value: l.value % r.value };
|
||||
if (op === '<')
|
||||
return { value: l.value < r.value };
|
||||
if (op === '<=')
|
||||
return { value: l.value <= r.value };
|
||||
if (op === '>')
|
||||
return { value: l.value > r.value };
|
||||
if (op === '>=')
|
||||
return { value: l.value >= r.value };
|
||||
if (op === '|')
|
||||
return { value: l.value | r.value };
|
||||
if (op === '&')
|
||||
return { value: l.value & r.value };
|
||||
if (op === '^')
|
||||
return { value: l.value ^ r.value };
|
||||
if (op === '&&')
|
||||
return { value: l.value && r.value };
|
||||
if (op === '||')
|
||||
return { value: l.value || r.value };
|
||||
}
|
||||
return;
|
||||
},
|
||||
'CallExpression': async function CallExpression(node, walk) {
|
||||
const callee = await walk(node.callee);
|
||||
if (!callee || 'test' in callee)
|
||||
return;
|
||||
let fn = callee.value;
|
||||
if (typeof fn === 'object' && fn !== null)
|
||||
fn = fn[exports.FUNCTION];
|
||||
if (typeof fn !== 'function')
|
||||
return;
|
||||
let ctx = null;
|
||||
if (node.callee.object) {
|
||||
ctx = await walk(node.callee.object);
|
||||
ctx = ctx && 'value' in ctx && ctx.value ? ctx.value : null;
|
||||
}
|
||||
// we allow one conditional argument to create a conditional expression
|
||||
let predicate;
|
||||
let args = [];
|
||||
let argsElse;
|
||||
let allWildcards = node.arguments.length > 0 && node.callee.property?.name !== 'concat';
|
||||
const wildcards = [];
|
||||
for (let i = 0, l = node.arguments.length; i < l; i++) {
|
||||
let x = await walk(node.arguments[i]);
|
||||
if (x) {
|
||||
allWildcards = false;
|
||||
if ('value' in x && typeof x.value === 'string' && x.wildcards)
|
||||
x.wildcards.forEach(w => wildcards.push(w));
|
||||
}
|
||||
else {
|
||||
if (!this.computeBranches)
|
||||
return;
|
||||
// this works because provided static functions
|
||||
// operate on known string inputs
|
||||
x = { value: exports.WILDCARD };
|
||||
wildcards.push(node.arguments[i]);
|
||||
}
|
||||
if ('test' in x) {
|
||||
if (wildcards.length)
|
||||
return;
|
||||
if (predicate)
|
||||
return;
|
||||
predicate = x.test;
|
||||
argsElse = args.concat([]);
|
||||
args.push(x.then);
|
||||
argsElse.push(x.else);
|
||||
}
|
||||
else {
|
||||
args.push(x.value);
|
||||
if (argsElse)
|
||||
argsElse.push(x.value);
|
||||
}
|
||||
}
|
||||
if (allWildcards)
|
||||
return;
|
||||
try {
|
||||
const result = await fn.apply(ctx, args);
|
||||
if (result === exports.UNKNOWN)
|
||||
return;
|
||||
if (!predicate) {
|
||||
if (wildcards.length) {
|
||||
if (typeof result !== 'string' || countWildcards(result) !== wildcards.length)
|
||||
return;
|
||||
return { value: result, wildcards };
|
||||
}
|
||||
return { value: result };
|
||||
}
|
||||
const resultElse = await fn.apply(ctx, argsElse);
|
||||
if (result === exports.UNKNOWN)
|
||||
return;
|
||||
return { test: predicate, then: result, else: resultElse };
|
||||
}
|
||||
catch (e) {
|
||||
return;
|
||||
}
|
||||
},
|
||||
'ConditionalExpression': async function ConditionalExpression(node, walk) {
|
||||
const val = await walk(node.test);
|
||||
if (val && 'value' in val)
|
||||
return val.value ? walk(node.consequent) : walk(node.alternate);
|
||||
if (!this.computeBranches)
|
||||
return;
|
||||
const thenValue = await walk(node.consequent);
|
||||
if (!thenValue || 'wildcards' in thenValue || 'test' in thenValue)
|
||||
return;
|
||||
const elseValue = await walk(node.alternate);
|
||||
if (!elseValue || 'wildcards' in elseValue || 'test' in elseValue)
|
||||
return;
|
||||
return {
|
||||
test: node.test,
|
||||
then: thenValue.value,
|
||||
else: elseValue.value
|
||||
};
|
||||
},
|
||||
'ExpressionStatement': async function ExpressionStatement(node, walk) {
|
||||
return walk(node.expression);
|
||||
},
|
||||
'Identifier': async function Identifier(node, _walk) {
|
||||
if (Object.hasOwnProperty.call(this.vars, node.name))
|
||||
return this.vars[node.name];
|
||||
return undefined;
|
||||
},
|
||||
'Literal': async function Literal(node, _walk) {
|
||||
return { value: node.value };
|
||||
},
|
||||
'MemberExpression': async function MemberExpression(node, walk) {
|
||||
const obj = await walk(node.object);
|
||||
if (!obj || 'test' in obj || typeof obj.value === 'function') {
|
||||
return undefined;
|
||||
}
|
||||
if (node.property.type === 'Identifier') {
|
||||
if (typeof obj.value === 'string' && node.property.name === 'concat') {
|
||||
return {
|
||||
value: {
|
||||
[exports.FUNCTION]: (...args) => obj.value.concat(args)
|
||||
}
|
||||
};
|
||||
}
|
||||
if (typeof obj.value === 'object' && obj.value !== null) {
|
||||
const objValue = obj.value;
|
||||
if (node.computed) {
|
||||
// See if we can compute the computed property
|
||||
const computedProp = await walk(node.property);
|
||||
if (computedProp && 'value' in computedProp && computedProp.value) {
|
||||
const val = objValue[computedProp.value];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
// Special case for empty object
|
||||
if (!objValue[exports.UNKNOWN] && Object.keys(obj).length === 0) {
|
||||
return { value: undefined };
|
||||
}
|
||||
}
|
||||
else if (node.property.name in objValue) {
|
||||
const val = objValue[node.property.name];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
else if (objValue[exports.UNKNOWN])
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
return { value: undefined };
|
||||
}
|
||||
}
|
||||
const prop = await walk(node.property);
|
||||
if (!prop || 'test' in prop)
|
||||
return undefined;
|
||||
if (typeof obj.value === 'object' && obj.value !== null) {
|
||||
//@ts-ignore
|
||||
if (prop.value in obj.value) {
|
||||
//@ts-ignore
|
||||
const val = obj.value[prop.value];
|
||||
if (val === exports.UNKNOWN)
|
||||
return undefined;
|
||||
return { value: val };
|
||||
}
|
||||
//@ts-ignore
|
||||
else if (obj.value[exports.UNKNOWN]) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return { value: undefined };
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
'MetaProperty': async function MetaProperty(node) {
|
||||
if (node.meta.name === 'import' && node.property.name === 'meta')
|
||||
return { value: this.vars['import.meta'] };
|
||||
return undefined;
|
||||
},
|
||||
'NewExpression': async function NewExpression(node, walk) {
|
||||
// new URL('./local', parent)
|
||||
const cls = await walk(node.callee);
|
||||
if (cls && 'value' in cls && cls.value === url_1.URL && node.arguments.length) {
|
||||
const arg = await walk(node.arguments[0]);
|
||||
if (!arg)
|
||||
return undefined;
|
||||
let parent = null;
|
||||
if (node.arguments[1]) {
|
||||
parent = await walk(node.arguments[1]);
|
||||
if (!parent || !('value' in parent))
|
||||
return undefined;
|
||||
}
|
||||
if ('value' in arg) {
|
||||
if (parent) {
|
||||
try {
|
||||
return { value: new url_1.URL(arg.value, parent.value) };
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return { value: new url_1.URL(arg.value) };
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const test = arg.test;
|
||||
if (parent) {
|
||||
try {
|
||||
return {
|
||||
test,
|
||||
then: new url_1.URL(arg.then, parent.value),
|
||||
else: new url_1.URL(arg.else, parent.value)
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
try {
|
||||
return {
|
||||
test,
|
||||
then: new url_1.URL(arg.then),
|
||||
else: new url_1.URL(arg.else)
|
||||
};
|
||||
}
|
||||
catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
'ObjectExpression': async function ObjectExpression(node, walk) {
|
||||
const obj = {};
|
||||
for (let i = 0; i < node.properties.length; i++) {
|
||||
const prop = node.properties[i];
|
||||
const keyValue = prop.computed ? walk(prop.key) : prop.key && { value: prop.key.name || prop.key.value };
|
||||
if (!keyValue || 'test' in keyValue)
|
||||
return;
|
||||
const value = await walk(prop.value);
|
||||
if (!value || 'test' in value)
|
||||
return;
|
||||
//@ts-ignore
|
||||
if (value.value === exports.UNKNOWN)
|
||||
return;
|
||||
//@ts-ignore
|
||||
obj[keyValue.value] = value.value;
|
||||
}
|
||||
return { value: obj };
|
||||
},
|
||||
'SequenceExpression': async function SequenceExpression(node, walk) {
|
||||
if ('expressions' in node && node.expressions.length === 2 && node.expressions[0].type === 'Literal' && node.expressions[0].value === 0 && node.expressions[1].type === 'MemberExpression') {
|
||||
const arg = await walk(node.expressions[1]);
|
||||
return arg;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
'TemplateLiteral': async function TemplateLiteral(node, walk) {
|
||||
let val = { value: '' };
|
||||
for (var i = 0; i < node.expressions.length; i++) {
|
||||
if ('value' in val) {
|
||||
val.value += node.quasis[i].value.cooked;
|
||||
}
|
||||
else {
|
||||
val.then += node.quasis[i].value.cooked;
|
||||
val.else += node.quasis[i].value.cooked;
|
||||
}
|
||||
let exprValue = await walk(node.expressions[i]);
|
||||
if (!exprValue) {
|
||||
if (!this.computeBranches)
|
||||
return undefined;
|
||||
exprValue = { value: exports.WILDCARD, wildcards: [node.expressions[i]] };
|
||||
}
|
||||
if ('value' in exprValue) {
|
||||
if ('value' in val) {
|
||||
val.value += exprValue.value;
|
||||
if (exprValue.wildcards)
|
||||
val.wildcards = [...val.wildcards || [], ...exprValue.wildcards];
|
||||
}
|
||||
else {
|
||||
if (exprValue.wildcards)
|
||||
return;
|
||||
val.then += exprValue.value;
|
||||
val.else += exprValue.value;
|
||||
}
|
||||
}
|
||||
else if ('value' in val) {
|
||||
if ('wildcards' in val) {
|
||||
// only support a single branch in a template
|
||||
return;
|
||||
}
|
||||
val = {
|
||||
test: exprValue.test,
|
||||
then: val.value + exprValue.then,
|
||||
else: val.value + exprValue.else
|
||||
};
|
||||
}
|
||||
else {
|
||||
// only support a single branch in a template
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ('value' in val) {
|
||||
val.value += node.quasis[i].value.cooked;
|
||||
}
|
||||
else {
|
||||
val.then += node.quasis[i].value.cooked;
|
||||
val.else += node.quasis[i].value.cooked;
|
||||
}
|
||||
return val;
|
||||
},
|
||||
'ThisExpression': async function ThisExpression(_node, _walk) {
|
||||
if (Object.hasOwnProperty.call(this.vars, 'this'))
|
||||
return this.vars['this'];
|
||||
return undefined;
|
||||
},
|
||||
'UnaryExpression': async function UnaryExpression(node, walk) {
|
||||
const val = await walk(node.argument);
|
||||
if (!val)
|
||||
return undefined;
|
||||
if ('value' in val && 'wildcards' in val === false) {
|
||||
if (node.operator === '+')
|
||||
return { value: +val.value };
|
||||
if (node.operator === '-')
|
||||
return { value: -val.value };
|
||||
if (node.operator === '~')
|
||||
return { value: ~val.value };
|
||||
if (node.operator === '!')
|
||||
return { value: !val.value };
|
||||
}
|
||||
else if ('test' in val && 'wildcards' in val === false) {
|
||||
if (node.operator === '+')
|
||||
return { test: val.test, then: +val.then, else: +val.else };
|
||||
if (node.operator === '-')
|
||||
return { test: val.test, then: -val.then, else: -val.else };
|
||||
if (node.operator === '~')
|
||||
return { test: val.test, then: ~val.then, else: ~val.else };
|
||||
if (node.operator === '!')
|
||||
return { test: val.test, then: !val.then, else: !val.else };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
visitors.LogicalExpression = visitors.BinaryExpression;
|
||||
1
node_modules/@vercel/nft/out/utils/static-eval.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/static-eval.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
node_modules/@vercel/nft/out/utils/types.js
generated
vendored
Normal file
2
node_modules/@vercel/nft/out/utils/types.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
1
node_modules/@vercel/nft/out/utils/types.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/types.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/utils/types.ts"],"names":[],"mappings":""}
|
||||
569
node_modules/@vercel/nft/out/utils/wrappers.js
generated
vendored
Normal file
569
node_modules/@vercel/nft/out/utils/wrappers.js
generated
vendored
Normal file
@@ -0,0 +1,569 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handleWrappers = void 0;
|
||||
const estree_walker_1 = require("estree-walker");
|
||||
function isUndefinedOrVoid(node) {
|
||||
return node.type === 'Identifier' && node.name === 'undefined' || node.type === 'UnaryExpression' && node.operator === 'void' && node.argument.type === 'Literal' && node.argument.value === 0;
|
||||
}
|
||||
// Wrapper detection pretransforms to enable static analysis
|
||||
function handleWrappers(ast) {
|
||||
// UglifyJS will convert function wrappers into !function(){}
|
||||
let wrapper;
|
||||
if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'UnaryExpression' &&
|
||||
ast.body[0].expression.operator === '!' &&
|
||||
ast.body[0].expression.argument.type === 'CallExpression' &&
|
||||
ast.body[0].expression.argument.callee.type === 'FunctionExpression' &&
|
||||
ast.body[0].expression.argument.arguments.length === 1)
|
||||
wrapper = ast.body[0].expression.argument;
|
||||
else if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'CallExpression' &&
|
||||
ast.body[0].expression.callee.type === 'FunctionExpression' &&
|
||||
(ast.body[0].expression.arguments.length === 1 || ast.body[0].expression.arguments.length === 0))
|
||||
wrapper = ast.body[0].expression;
|
||||
else if (ast.body.length === 1 &&
|
||||
ast.body[0].type === 'ExpressionStatement' &&
|
||||
ast.body[0].expression.type === 'AssignmentExpression' &&
|
||||
ast.body[0].expression.left.type === 'MemberExpression' &&
|
||||
ast.body[0].expression.left.object.type === 'Identifier' &&
|
||||
ast.body[0].expression.left.object.name === 'module' &&
|
||||
ast.body[0].expression.left.property.type === 'Identifier' &&
|
||||
ast.body[0].expression.left.property.name === 'exports' &&
|
||||
ast.body[0].expression.right.type === 'CallExpression' &&
|
||||
ast.body[0].expression.right.callee.type === 'FunctionExpression' &&
|
||||
ast.body[0].expression.right.arguments.length === 1)
|
||||
wrapper = ast.body[0].expression.right;
|
||||
if (wrapper) {
|
||||
let browserifyReturn;
|
||||
let webpackModuleObj;
|
||||
// When.js-style AMD wrapper:
|
||||
// (function (define) { 'use strict' define(function (require) { ... }) })
|
||||
// (typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); })
|
||||
// ->
|
||||
// (function (define) { 'use strict' define(function () { ... }) })
|
||||
// (typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); })
|
||||
if (wrapper.arguments[0] && wrapper.arguments[0].type === 'ConditionalExpression' &&
|
||||
wrapper.arguments[0].test.type === 'LogicalExpression' &&
|
||||
wrapper.arguments[0].test.operator === '&&' &&
|
||||
wrapper.arguments[0].test.left.type === 'BinaryExpression' &&
|
||||
wrapper.arguments[0].test.left.operator === '===' &&
|
||||
wrapper.arguments[0].test.left.left.type === 'UnaryExpression' &&
|
||||
wrapper.arguments[0].test.left.left.operator === 'typeof' &&
|
||||
'name' in wrapper.arguments[0].test.left.left.argument &&
|
||||
wrapper.arguments[0].test.left.left.argument.name === 'define' &&
|
||||
wrapper.arguments[0].test.left.right.type === 'Literal' &&
|
||||
wrapper.arguments[0].test.left.right.value === 'function' &&
|
||||
wrapper.arguments[0].test.right.type === 'MemberExpression' &&
|
||||
wrapper.arguments[0].test.right.object.type === 'Identifier' &&
|
||||
wrapper.arguments[0].test.right.property.type === 'Identifier' &&
|
||||
wrapper.arguments[0].test.right.property.name === 'amd' &&
|
||||
wrapper.arguments[0].test.right.computed === false &&
|
||||
wrapper.arguments[0].alternate.type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].alternate.params.length === 1 &&
|
||||
wrapper.arguments[0].alternate.params[0].type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body.length === 1 &&
|
||||
wrapper.arguments[0].alternate.body.body[0].type === 'ExpressionStatement' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.type === 'AssignmentExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.type === 'MemberExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.object.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.object.name === 'module' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.property.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.property.name === 'exports' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.left.computed === false &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.type === 'CallExpression' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.callee.type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.callee.name === wrapper.arguments[0].alternate.params[0].name &&
|
||||
'body' in wrapper.callee &&
|
||||
'body' in wrapper.callee.body &&
|
||||
Array.isArray(wrapper.callee.body.body) &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments.length === 1 &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments[0].type === 'Identifier' &&
|
||||
wrapper.arguments[0].alternate.body.body[0].expression.right.arguments[0].name === 'require') {
|
||||
let body = wrapper.callee.body.body;
|
||||
if (body[0].type === 'ExpressionStatement' &&
|
||||
body[0].expression.type === 'Literal' &&
|
||||
body[0].expression.value === 'use strict') {
|
||||
body = body.slice(1);
|
||||
}
|
||||
if (body.length === 1 &&
|
||||
body[0].type === 'ExpressionStatement' &&
|
||||
body[0].expression.type === 'CallExpression' &&
|
||||
body[0].expression.callee.type === 'Identifier' &&
|
||||
body[0].expression.callee.name === wrapper.arguments[0].test.right.object.name &&
|
||||
body[0].expression.arguments.length === 1 &&
|
||||
body[0].expression.arguments[0].type === 'FunctionExpression' &&
|
||||
body[0].expression.arguments[0].params.length === 1 &&
|
||||
body[0].expression.arguments[0].params[0].type === 'Identifier' &&
|
||||
body[0].expression.arguments[0].params[0].name === 'require') {
|
||||
const arg = body[0].expression.arguments[0];
|
||||
arg.params = [];
|
||||
try {
|
||||
// @ts-ignore If it doesn't exist thats ok
|
||||
delete arg.scope.declarations.require;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
// Browserify-style wrapper
|
||||
// (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugsnag = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({
|
||||
// 1:[function(require,module,exports){
|
||||
// ...code...
|
||||
// },{"external":undefined}], 2: ...
|
||||
// },{},[24])(24)
|
||||
// });
|
||||
// ->
|
||||
// (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bugsnag = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({
|
||||
// 1:[function(require,module,exports){
|
||||
// ...code...
|
||||
// },{"external":undefined}], 2: ...
|
||||
// },{
|
||||
// "external": { exports: require('external') }
|
||||
// },[24])(24)
|
||||
// });
|
||||
else if (wrapper.arguments[0] && wrapper.arguments[0].type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].params.length === 0 &&
|
||||
(wrapper.arguments[0].body.body.length === 1 ||
|
||||
wrapper.arguments[0].body.body.length === 2 &&
|
||||
wrapper.arguments[0].body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.arguments[0].body.body[0].declarations.length === 3 &&
|
||||
wrapper.arguments[0].body.body[0].declarations.every(decl => decl.init === null && decl.id.type === 'Identifier')) &&
|
||||
wrapper.arguments[0].body.body[wrapper.arguments[0].body.body.length - 1].type === 'ReturnStatement' &&
|
||||
(browserifyReturn = wrapper.arguments[0].body.body[wrapper.arguments[0].body.body.length - 1]) &&
|
||||
browserifyReturn.argument?.type === 'CallExpression' &&
|
||||
browserifyReturn.argument.arguments.length &&
|
||||
browserifyReturn.argument.arguments.every(arg => arg && arg.type === 'Literal' && typeof arg.value === 'number') &&
|
||||
browserifyReturn.argument.callee.type === 'CallExpression' &&
|
||||
(browserifyReturn.argument.callee.callee.type === 'FunctionExpression' ||
|
||||
browserifyReturn.argument.callee.callee.type === 'CallExpression' &&
|
||||
browserifyReturn.argument.callee.callee.callee.type === 'FunctionExpression' &&
|
||||
browserifyReturn.argument.callee.callee.arguments.length === 0) &&
|
||||
// (dont go deeper into browserify loader internals than this)
|
||||
browserifyReturn.argument.callee.arguments.length === 3 &&
|
||||
browserifyReturn.argument.callee.arguments[0].type === 'ObjectExpression' &&
|
||||
browserifyReturn.argument.callee.arguments[1].type === 'ObjectExpression' &&
|
||||
browserifyReturn.argument.callee.arguments[2].type === 'ArrayExpression') {
|
||||
const modules = browserifyReturn.argument.callee.arguments[0].properties;
|
||||
// verify modules is the expected data structure
|
||||
// in the process, extract external requires
|
||||
const externals = {};
|
||||
if (modules.every(m => {
|
||||
if (m.type !== 'Property' ||
|
||||
m.computed !== false ||
|
||||
m.key.type !== 'Literal' ||
|
||||
typeof m.key.value !== 'number' ||
|
||||
m.value.type !== 'ArrayExpression' ||
|
||||
m.value.elements.length !== 2 ||
|
||||
!m.value.elements[0] ||
|
||||
!m.value.elements[1] ||
|
||||
m.value.elements[0].type !== 'FunctionExpression' ||
|
||||
m.value.elements[1].type !== 'ObjectExpression') {
|
||||
return false;
|
||||
}
|
||||
// detect externals from undefined moduleMap values
|
||||
const moduleMap = m.value.elements[1].properties;
|
||||
for (const prop of moduleMap) {
|
||||
if (prop.type !== 'Property' ||
|
||||
(prop.value.type !== 'Identifier' && prop.value.type !== 'Literal' && !isUndefinedOrVoid(prop.value)) ||
|
||||
!(prop.key.type === 'Literal' && typeof prop.key.value === 'string' ||
|
||||
prop.key.type === 'Identifier') ||
|
||||
prop.computed) {
|
||||
return false;
|
||||
}
|
||||
if (isUndefinedOrVoid(prop.value)) {
|
||||
if (prop.key.type === 'Identifier') {
|
||||
externals[prop.key.name] = {
|
||||
type: 'Literal',
|
||||
// @ts-ignore start can be undefined
|
||||
start: prop.key.start,
|
||||
// @ts-ignore end can be undefined
|
||||
end: prop.key.end,
|
||||
value: prop.key.name,
|
||||
raw: JSON.stringify(prop.key.name)
|
||||
};
|
||||
}
|
||||
else if (prop.key.type === 'Literal') {
|
||||
externals[String(prop.key.value)] = prop.key;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
})) {
|
||||
// if we have externals, inline them into the browserify cache for webpack to pick up
|
||||
const externalIds = Object.keys(externals);
|
||||
const cache = browserifyReturn.argument.callee.arguments[1];
|
||||
cache.properties = externalIds.map(ext => {
|
||||
return {
|
||||
type: 'Property',
|
||||
method: false,
|
||||
shorthand: false,
|
||||
computed: false,
|
||||
kind: 'init',
|
||||
key: externals[ext],
|
||||
value: {
|
||||
type: 'ObjectExpression',
|
||||
properties: [{
|
||||
type: 'Property',
|
||||
kind: 'init',
|
||||
method: false,
|
||||
shorthand: false,
|
||||
computed: false,
|
||||
key: {
|
||||
type: 'Identifier',
|
||||
name: 'exports'
|
||||
},
|
||||
value: {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'Identifier',
|
||||
name: 'require'
|
||||
},
|
||||
arguments: [externals[ext]]
|
||||
}
|
||||
}]
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
// UMD wrapper
|
||||
// (function (factory) {
|
||||
// if (typeof module === "object" && typeof module.exports === "object") {
|
||||
// var v = factory(require, exports);
|
||||
// if (v !== undefined) module.exports = v;
|
||||
// }
|
||||
// else if (typeof define === "function" && define.amd) {
|
||||
// define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
|
||||
// }
|
||||
// })(function (require, exports) {
|
||||
// // ...
|
||||
// }
|
||||
// ->
|
||||
// (function (factory) {
|
||||
// if (typeof module === "object" && typeof module.exports === "object") {
|
||||
// var v = factory(require, exports);
|
||||
// if (v !== undefined) module.exports = v;
|
||||
// }
|
||||
// else if (typeof define === "function" && define.amd) {
|
||||
// define(["require", "exports", "./impl/format", "./impl/edit", "./impl/scanner", "./impl/parser"], factory);
|
||||
// }
|
||||
// })(function () {
|
||||
// // ...
|
||||
// }
|
||||
else if (wrapper.arguments[0] && wrapper.arguments[0].type === 'FunctionExpression' &&
|
||||
wrapper.arguments[0].params.length === 2 &&
|
||||
wrapper.arguments[0].params[0].type === 'Identifier' &&
|
||||
wrapper.arguments[0].params[1].type === 'Identifier' &&
|
||||
'body' in wrapper.callee &&
|
||||
'body' in wrapper.callee.body &&
|
||||
Array.isArray(wrapper.callee.body.body) &&
|
||||
wrapper.callee.body.body.length === 1) {
|
||||
const statement = wrapper.callee.body.body[0];
|
||||
if (statement.type === 'IfStatement' &&
|
||||
statement.test.type === 'LogicalExpression' &&
|
||||
statement.test.operator === '&&' &&
|
||||
statement.test.left.type === 'BinaryExpression' &&
|
||||
statement.test.left.left.type === 'UnaryExpression' &&
|
||||
statement.test.left.left.operator === 'typeof' &&
|
||||
statement.test.left.left.argument.type === 'Identifier' &&
|
||||
statement.test.left.left.argument.name === 'module' &&
|
||||
statement.test.left.right.type === 'Literal' &&
|
||||
statement.test.left.right.value === 'object' &&
|
||||
statement.test.right.type === 'BinaryExpression' &&
|
||||
statement.test.right.left.type === 'UnaryExpression' &&
|
||||
statement.test.right.left.operator === 'typeof' &&
|
||||
statement.test.right.left.argument.type === 'MemberExpression' &&
|
||||
statement.test.right.left.argument.object.type === 'Identifier' &&
|
||||
statement.test.right.left.argument.object.name === 'module' &&
|
||||
statement.test.right.left.argument.property.type === 'Identifier' &&
|
||||
statement.test.right.left.argument.property.name === 'exports' &&
|
||||
statement.test.right.right.type === 'Literal' &&
|
||||
statement.test.right.right.value === 'object' &&
|
||||
statement.consequent.type === 'BlockStatement' &&
|
||||
statement.consequent.body.length > 0) {
|
||||
let callSite;
|
||||
if (statement.consequent.body[0].type === 'VariableDeclaration' &&
|
||||
statement.consequent.body[0].declarations[0].init &&
|
||||
statement.consequent.body[0].declarations[0].init.type === 'CallExpression')
|
||||
callSite = statement.consequent.body[0].declarations[0].init;
|
||||
else if (statement.consequent.body[0].type === 'ExpressionStatement' &&
|
||||
statement.consequent.body[0].expression.type === 'CallExpression')
|
||||
callSite = statement.consequent.body[0].expression;
|
||||
else if (statement.consequent.body[0].type === 'ExpressionStatement' &&
|
||||
statement.consequent.body[0].expression.type === 'AssignmentExpression' &&
|
||||
statement.consequent.body[0].expression.operator === '=' &&
|
||||
statement.consequent.body[0].expression.right.type === 'CallExpression')
|
||||
callSite = statement.consequent.body[0].expression.right;
|
||||
if (callSite &&
|
||||
callSite.callee.type === 'Identifier' &&
|
||||
'params' in wrapper.callee &&
|
||||
wrapper.callee.params.length > 0 &&
|
||||
'name' in wrapper.callee.params[0] &&
|
||||
callSite.callee.name === wrapper.callee.params[0].name &&
|
||||
callSite.arguments.length === 2 &&
|
||||
callSite.arguments[0].type === 'Identifier' &&
|
||||
callSite.arguments[0].name === 'require' &&
|
||||
callSite.arguments[1].type === 'Identifier' &&
|
||||
callSite.arguments[1].name === 'exports') {
|
||||
const funcExpression = wrapper.arguments[0];
|
||||
funcExpression.params = [];
|
||||
try {
|
||||
// @ts-ignore If scope doesn't exist thats ok
|
||||
const scope = funcExpression.scope;
|
||||
delete scope.declarations.require;
|
||||
delete scope.declarations.exports;
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
// Webpack wrapper
|
||||
//
|
||||
// module.exports = (function(e) {
|
||||
// var t = {};
|
||||
// function r(n) { /*...*/ }
|
||||
// })([
|
||||
// function (e, t) {
|
||||
// e.exports = require("fs");
|
||||
// },
|
||||
// function(e, t, r) {
|
||||
// const n = r(0);
|
||||
// const ns = r.n(n);
|
||||
// ns.a.export;
|
||||
// }
|
||||
// ]);
|
||||
// ->
|
||||
// module.exports = (function(e) {
|
||||
// var t = {};
|
||||
// function r(n) { /*...*/ }
|
||||
// })([
|
||||
// function (e, t) {
|
||||
// e.exports = require("fs");
|
||||
// },
|
||||
// function(e, t, r) {
|
||||
// const n = require("fs");
|
||||
// const ns = Object.assign(a => n, { a: n });
|
||||
// }
|
||||
// ]);
|
||||
//
|
||||
// OR !(function (){})() | (function () {})() variants
|
||||
// OR { 0: function..., 'some-id': function () ... } registry variants
|
||||
// OR Webpack 5 non-runtime variant:
|
||||
//
|
||||
// (function() {
|
||||
// var exports = {};
|
||||
// exports.id = 223;
|
||||
// exports.ids = [223];
|
||||
// exports.modules = { ... };
|
||||
// var __webpack_require__ = require("../../webpack-runtime.js");
|
||||
// ...
|
||||
// })()
|
||||
//
|
||||
else if (wrapper.callee.type === 'FunctionExpression' &&
|
||||
wrapper.callee.body.body.length > 2 &&
|
||||
wrapper.callee.body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[0].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[0].declarations[0].type === 'VariableDeclarator' &&
|
||||
wrapper.callee.body.body[0].declarations[0].id.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init && (wrapper.callee.body.body[0].declarations[0].init.type === 'ObjectExpression' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init.properties.length === 0 ||
|
||||
wrapper.callee.body.body[0].declarations[0].init.type === 'CallExpression' &&
|
||||
wrapper.callee.body.body[0].declarations[0].init.arguments.length === 1) &&
|
||||
(wrapper.callee.body.body[1] &&
|
||||
wrapper.callee.body.body[1].type === 'FunctionDeclaration' &&
|
||||
wrapper.callee.body.body[1].params.length === 1 &&
|
||||
wrapper.callee.body.body[1].body.body.length >= 3 ||
|
||||
wrapper.callee.body.body[2] &&
|
||||
wrapper.callee.body.body[2].type === 'FunctionDeclaration' &&
|
||||
wrapper.callee.body.body[2].params.length === 1 &&
|
||||
wrapper.callee.body.body[2].body.body.length >= 3) && (wrapper.arguments[0] && (wrapper.arguments[0].type === 'ArrayExpression' &&
|
||||
(webpackModuleObj = wrapper.arguments[0]) &&
|
||||
wrapper.arguments[0].elements.length > 0 &&
|
||||
wrapper.arguments[0].elements.every(el => el && el.type === 'FunctionExpression') ||
|
||||
wrapper.arguments[0].type === 'ObjectExpression' &&
|
||||
(webpackModuleObj = wrapper.arguments[0]) &&
|
||||
wrapper.arguments[0].properties &&
|
||||
wrapper.arguments[0].properties.length > 0 &&
|
||||
wrapper.arguments[0].properties.every(prop => prop && prop.type === 'Property' && !prop.computed && prop.key && prop.key.type === 'Literal' && (typeof prop.key.value === 'string' || typeof prop.key.value === 'number') && prop.value && prop.value.type === 'FunctionExpression'))) ||
|
||||
wrapper.arguments.length === 0 &&
|
||||
wrapper.callee.type === 'FunctionExpression' &&
|
||||
wrapper.callee.params.length === 0 &&
|
||||
wrapper.callee.body.type === 'BlockStatement' &&
|
||||
wrapper.callee.body.body.length > 5 &&
|
||||
wrapper.callee.body.body[0].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[0].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[0].declarations[0].id.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[1].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[1].expression.type === 'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[2].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[2].expression.type === 'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[3].type === 'ExpressionStatement' &&
|
||||
wrapper.callee.body.body[3].expression.type === 'AssignmentExpression' &&
|
||||
wrapper.callee.body.body[3].expression.left.type === 'MemberExpression' &&
|
||||
wrapper.callee.body.body[3].expression.left.object.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[3].expression.left.object.name === wrapper.callee.body.body[0].declarations[0].id.name &&
|
||||
wrapper.callee.body.body[3].expression.left.property.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[3].expression.left.property.name === 'modules' &&
|
||||
wrapper.callee.body.body[3].expression.right.type === 'ObjectExpression' &&
|
||||
wrapper.callee.body.body[3].expression.right.properties.every(prop => prop && prop.type === 'Property' && !prop.computed && prop.key && prop.key.type === 'Literal' && (typeof prop.key.value === 'string' || typeof prop.key.value === 'number') && prop.value && prop.value.type === 'FunctionExpression') &&
|
||||
(webpackModuleObj = wrapper.callee.body.body[3].expression.right) &&
|
||||
(wrapper.callee.body.body[4].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[4].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[4].declarations[0].init &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.type === 'CallExpression' &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.callee.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[4].declarations[0].init.callee.name === 'require' ||
|
||||
wrapper.callee.body.body[5].type === 'VariableDeclaration' &&
|
||||
wrapper.callee.body.body[5].declarations.length === 1 &&
|
||||
wrapper.callee.body.body[5].declarations[0].init &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.type === 'CallExpression' &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.callee.type === 'Identifier' &&
|
||||
wrapper.callee.body.body[5].declarations[0].init.callee.name === 'require')) {
|
||||
const externalMap = new Map();
|
||||
let modules;
|
||||
if (webpackModuleObj.type === 'ArrayExpression')
|
||||
modules = webpackModuleObj.elements.filter(el => el?.type === 'FunctionExpression').map((el, i) => [String(i), el]);
|
||||
// Structure already checked in conditional above
|
||||
else
|
||||
modules = webpackModuleObj.properties.map(prop => [String(prop.key.value), prop.value]);
|
||||
for (const [k, m] of modules) {
|
||||
const statement = m.body.body.length === 1 ? m.body.body[0] :
|
||||
(m.body.body.length === 2 || m.body.body.length === 3 && m.body.body[2].type === 'EmptyStatement') &&
|
||||
m.body.body[0].type === 'ExpressionStatement' &&
|
||||
m.body.body[0].expression.type === 'Literal' &&
|
||||
m.body.body[0].expression.value === 'use strict'
|
||||
? m.body.body[1] : null;
|
||||
if (statement &&
|
||||
statement.type === 'ExpressionStatement' &&
|
||||
statement.expression.type === 'AssignmentExpression' &&
|
||||
statement.expression.operator === '=' &&
|
||||
statement.expression.left.type === 'MemberExpression' &&
|
||||
statement.expression.left.object.type === 'Identifier' &&
|
||||
'params' in m &&
|
||||
m.params.length > 0 &&
|
||||
'name' in m.params[0] &&
|
||||
statement.expression.left.object.name === m.params[0].name &&
|
||||
statement.expression.left.property.type === 'Identifier' &&
|
||||
statement.expression.left.property.name === 'exports' &&
|
||||
statement.expression.right.type === 'CallExpression' &&
|
||||
statement.expression.right.callee.type === 'Identifier' &&
|
||||
statement.expression.right.callee.name === 'require' &&
|
||||
statement.expression.right.arguments.length === 1 &&
|
||||
statement.expression.right.arguments[0].type === 'Literal') {
|
||||
externalMap.set(k, statement.expression.right.arguments[0].value);
|
||||
}
|
||||
}
|
||||
for (const [, m] of modules) {
|
||||
if ('params' in m && m.params.length === 3 && m.params[2].type === 'Identifier') {
|
||||
const assignedVars = new Map();
|
||||
(0, estree_walker_1.walk)(m.body, {
|
||||
enter(_node, _maybeParent) {
|
||||
const node = _node;
|
||||
const maybeParent = _maybeParent;
|
||||
if (node.type === 'CallExpression' &&
|
||||
node.callee.type === 'Identifier' &&
|
||||
'name' in m.params[2] &&
|
||||
node.callee.name === m.params[2].name &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Literal') {
|
||||
const externalId = externalMap.get(String(node.arguments[0].value));
|
||||
if (externalId) {
|
||||
const replacement = {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'Identifier',
|
||||
name: 'require'
|
||||
},
|
||||
arguments: [{
|
||||
type: 'Literal',
|
||||
value: externalId
|
||||
}]
|
||||
};
|
||||
const parent = maybeParent;
|
||||
if ('right' in parent && parent.right === node) {
|
||||
parent.right = replacement;
|
||||
}
|
||||
else if ('left' in parent && parent.left === node) {
|
||||
parent.left = replacement;
|
||||
}
|
||||
else if ('object' in parent && parent.object === node) {
|
||||
parent.object = replacement;
|
||||
}
|
||||
else if ('callee' in parent && parent.callee === node) {
|
||||
parent.callee = replacement;
|
||||
}
|
||||
else if ('arguments' in parent && parent.arguments.some(arg => arg === node)) {
|
||||
parent.arguments = parent.arguments.map(arg => arg === node ? replacement : arg);
|
||||
}
|
||||
else if ('init' in parent && parent.init === node) {
|
||||
if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier')
|
||||
assignedVars.set(parent.id.name, externalId);
|
||||
parent.init = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node.type === 'CallExpression' &&
|
||||
node.callee.type === 'MemberExpression' &&
|
||||
node.callee.object.type === 'Identifier' &&
|
||||
'name' in m.params[2] &&
|
||||
node.callee.object.name === m.params[2].name &&
|
||||
node.callee.property.type === 'Identifier' &&
|
||||
node.callee.property.name === 'n' &&
|
||||
node.arguments.length === 1 &&
|
||||
node.arguments[0].type === 'Identifier') {
|
||||
if (maybeParent && 'init' in maybeParent && maybeParent.init === node) {
|
||||
const req = node.arguments[0];
|
||||
const callExpression = {
|
||||
type: 'CallExpression',
|
||||
optional: false,
|
||||
callee: {
|
||||
type: 'MemberExpression',
|
||||
computed: false,
|
||||
optional: false,
|
||||
object: {
|
||||
type: 'Identifier',
|
||||
name: 'Object'
|
||||
},
|
||||
property: {
|
||||
type: 'Identifier',
|
||||
name: 'assign'
|
||||
}
|
||||
},
|
||||
arguments: [
|
||||
{
|
||||
type: 'ArrowFunctionExpression',
|
||||
expression: true,
|
||||
params: [],
|
||||
body: req
|
||||
},
|
||||
{
|
||||
type: 'ObjectExpression',
|
||||
properties: [{
|
||||
type: 'Property',
|
||||
kind: 'init',
|
||||
method: false,
|
||||
computed: false,
|
||||
shorthand: false,
|
||||
key: {
|
||||
type: 'Identifier',
|
||||
name: 'a'
|
||||
},
|
||||
value: req
|
||||
}]
|
||||
}
|
||||
]
|
||||
};
|
||||
maybeParent.init = callExpression;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.handleWrappers = handleWrappers;
|
||||
1
node_modules/@vercel/nft/out/utils/wrappers.js.map
generated
vendored
Normal file
1
node_modules/@vercel/nft/out/utils/wrappers.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
141
node_modules/@vercel/nft/package.json
generated
vendored
Normal file
141
node_modules/@vercel/nft/package.json
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
{
|
||||
"name": "@vercel/nft",
|
||||
"version": "0.22.6",
|
||||
"repository": "vercel/nft",
|
||||
"license": "MIT",
|
||||
"main": "./out/index.js",
|
||||
"types": "./out/index.d.ts",
|
||||
"bin": {
|
||||
"nft": "./out/cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"prepublishOnly": "tsc && rm out/utils/*.d.ts && rm out/tsconfig.tsbuildinfo",
|
||||
"test": "jest --verbose",
|
||||
"test-verbose": "tsc --sourceMap && jest --verbose --coverage --globals \"{\\\"coverage\\\":true}\"",
|
||||
"codecov": "codecov"
|
||||
},
|
||||
"files": [
|
||||
"out"
|
||||
],
|
||||
"dependencies": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.5",
|
||||
"@rollup/pluginutils": "^4.0.0",
|
||||
"acorn": "^8.6.0",
|
||||
"async-sema": "^3.1.1",
|
||||
"bindings": "^1.4.0",
|
||||
"estree-walker": "2.0.2",
|
||||
"glob": "^7.1.3",
|
||||
"graceful-fs": "^4.2.9",
|
||||
"micromatch": "^4.0.2",
|
||||
"node-gyp-build": "^4.2.2",
|
||||
"resolve-from": "^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure/cosmos": "^2.1.7",
|
||||
"@bugsnag/js": "^6.3.2",
|
||||
"@ffmpeg-installer/ffmpeg": "^1.0.19",
|
||||
"@google-cloud/bigquery": "^4.1.4",
|
||||
"@google-cloud/firestore": "^4.11.0",
|
||||
"@sentry/node": "^5.5.0",
|
||||
"@tensorflow/tfjs-node": "^3.12.0",
|
||||
"@tpluscode/sparql-builder": "^0.3.12",
|
||||
"@types/bindings": "^1.3.0",
|
||||
"@types/estree": "^0.0.47",
|
||||
"@types/glob": "^7.1.2",
|
||||
"@types/graceful-fs": "^4.1.5",
|
||||
"@types/micromatch": "^4.0.1",
|
||||
"@types/node": "^14.14.37",
|
||||
"analytics-node": "^3.4.0-beta.1",
|
||||
"apollo-server-express": "^2.14.2",
|
||||
"argon2": "^0.27.2",
|
||||
"auth0": "^2.27.1",
|
||||
"axios": "^0.21.2",
|
||||
"azure-storage": "^2.10.3",
|
||||
"bcrypt": "^5.0.1",
|
||||
"browserify-middleware": "^8.1.1",
|
||||
"bull": "^3.10.0",
|
||||
"bullmq": "^1.74.2",
|
||||
"camaro": "^6.1.0",
|
||||
"canvas": "^2.10.2",
|
||||
"chromeless": "^1.5.2",
|
||||
"codecov": "^3.8.1",
|
||||
"consolidate": "^0.15.1",
|
||||
"copy": "^0.3.2",
|
||||
"cowsay": "^1.4.0",
|
||||
"es-get-iterator": "^1.1.0",
|
||||
"esbuild": "^0.14.12",
|
||||
"esm": "^3.2.25",
|
||||
"express": "^4.17.3",
|
||||
"fast-glob": "^3.1.1",
|
||||
"fetch-h2": "^2.2.0",
|
||||
"firebase": "^7",
|
||||
"firebase-admin": "^9.7.0",
|
||||
"fluent-ffmpeg": "^2.1.2",
|
||||
"geo-tz": "^7.0.1",
|
||||
"graphql": "^14.4.2",
|
||||
"highlights": "^3.1.6",
|
||||
"hot-shots": "^6.3.0",
|
||||
"ioredis": "^4.11.1",
|
||||
"isomorphic-unfetch": "^3.0.0",
|
||||
"jest": "^27.4.5",
|
||||
"jimp": "^0.6.4",
|
||||
"jugglingdb": "^2.0.1",
|
||||
"koa": "^2.7.0",
|
||||
"leveldown": "^5.6.0",
|
||||
"lighthouse": "^5.1.0",
|
||||
"loopback": "^3.26.0",
|
||||
"mailgun": "^0.5.0",
|
||||
"mariadb": "^2.0.5",
|
||||
"memcached": "^2.2.2",
|
||||
"microtime": "^3.0.0",
|
||||
"mongoose": "^5.7.5",
|
||||
"mysql": "^2.17.1",
|
||||
"npm": "^6.14.6",
|
||||
"oracledb": "^4.2.0",
|
||||
"paraphrase": "1.8.0",
|
||||
"passport": "^0.6.0",
|
||||
"passport-google-oauth": "^2.0.0",
|
||||
"passport-trakt": "^1.0.4",
|
||||
"path-platform": "^0.11.15",
|
||||
"pdf2json": "^2.0.0",
|
||||
"pdfkit": "^0.10.0",
|
||||
"pg": "^7.11.0",
|
||||
"phantomjs-prebuilt": "^2.1.16",
|
||||
"pixelmatch": "^5.2.1",
|
||||
"playwright-core": "^1.17.1",
|
||||
"polyfill-library": "3.93.0",
|
||||
"prismjs": "^1.27.0",
|
||||
"pug": "^3.0.1",
|
||||
"react": "^16.14.0",
|
||||
"react-dom": "^16.14.0",
|
||||
"redis": "^3.1.1",
|
||||
"remark-parse": "^10.0.0",
|
||||
"remark-prism": "^1.3.6",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^6.5.2",
|
||||
"saslprep": "^1.0.3",
|
||||
"semver": "^7.1.1",
|
||||
"sequelize": "^5.9.3",
|
||||
"sharp": "^0.30.5",
|
||||
"socket.io": "^2.4.0",
|
||||
"socket.io-client": "^2.2.0",
|
||||
"stripe": "^7.4.0",
|
||||
"swig": "^1.4.2",
|
||||
"tiny-json-http": "^7.1.2",
|
||||
"twilio": "^3.33.0",
|
||||
"typescript": "^4.8.4",
|
||||
"uglify-js": "^3.6.0",
|
||||
"unified": "^10.1.0",
|
||||
"vm2": "^3.9.11",
|
||||
"vue": "^2.6.10",
|
||||
"vue-server-renderer": "^2.6.10",
|
||||
"when": "^3.7.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
208
node_modules/@vercel/nft/readme.md
generated
vendored
Normal file
208
node_modules/@vercel/nft/readme.md
generated
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
# Node File Trace
|
||||
|
||||
[](https://github.com/vercel/nft/actions/workflows/ci.yml)
|
||||
[](https://codecov.io/gh/vercel/nft)
|
||||
|
||||
Used to determine exactly which files (including `node_modules`) are necessary for the application runtime.
|
||||
|
||||
This is similar to [@vercel/ncc](https://npmjs.com/package/@vercel/ncc) except there is no bundling performed and therefore no reliance on webpack. This achieves the same tree-shaking benefits without moving any assets or binaries.
|
||||
|
||||
## Usage
|
||||
|
||||
### Installation
|
||||
```bash
|
||||
npm i @vercel/nft
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
Provide the list of source files as input:
|
||||
|
||||
```js
|
||||
const { nodeFileTrace } = require('@vercel/nft');
|
||||
const files = ['./src/main.js', './src/second.js'];
|
||||
const { fileList } = await nodeFileTrace(files);
|
||||
```
|
||||
|
||||
The list of files will include all `node_modules` modules and assets that may be needed by the application code.
|
||||
|
||||
### Options
|
||||
|
||||
#### Base
|
||||
|
||||
The base path for the file list - all files will be provided as relative to this base.
|
||||
|
||||
By default the `process.cwd()` is used:
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
base: process.cwd()
|
||||
}
|
||||
```
|
||||
|
||||
Any files/folders above the `base` are ignored in the listing and analysis.
|
||||
|
||||
#### Process Cwd
|
||||
|
||||
When applying analysis certain functions rely on the `process.cwd()` value, such as `path.resolve('./relative')` or even a direct `process.cwd()`
|
||||
invocation.
|
||||
|
||||
Setting the `processCwd` option allows this analysis to be guided to the right path to ensure that assets are correctly detected.
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
processCwd: path.resolve(__dirname)
|
||||
}
|
||||
```
|
||||
|
||||
By default `processCwd` is the same as `base`.
|
||||
|
||||
#### Exports & Imports
|
||||
|
||||
By default tracing of the [Node.js "exports" and "imports" fields](https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_package_entry_points) is supported, with the `"node"`, `"require"`, `"import"` and `"default"` conditions traced as defined.
|
||||
|
||||
Alternatively the explicit list of conditions can be provided:
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
conditions: ['node', 'production']
|
||||
});
|
||||
```
|
||||
|
||||
Only the `"node"` export should be explicitly included (if needed) when specifying the exact export condition list. The `"require"`, `"import"` and `"default"` conditions will always be traced as defined, no matter what custom conditions are set.
|
||||
|
||||
#### Exports Only
|
||||
|
||||
When tracing exports the `"main"` / index field will still be traced for Node.js versions without `"exports"` support.
|
||||
|
||||
This can be disabled with the `exportsOnly` option:
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
exportsOnly: true
|
||||
});
|
||||
```
|
||||
|
||||
Any package with `"exports"` will then only have its exports traced, and the main will not be included at all. This can reduce the output size when targeting [Node.js 12.17.0](https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#12.17.0) or newer.
|
||||
|
||||
#### Paths
|
||||
|
||||
> Status: Experimental. May change at any time.
|
||||
|
||||
Custom resolution path definitions to use.
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
paths: {
|
||||
'utils/': '/path/to/utils/'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Trailing slashes map directories, exact paths map exact only.
|
||||
|
||||
#### Hooks
|
||||
|
||||
The following FS functions can be hooked by passing them as options:
|
||||
|
||||
* `readFile(path): Promise<string>`
|
||||
* `stat(path): Promise<FS.Stats>`
|
||||
* `readlink(path): Promise<string>`
|
||||
* `resolve(id: string, parent: string): Promise<string | string[]>`
|
||||
|
||||
#### TypeScript
|
||||
|
||||
The internal resolution supports resolving `.ts` files in traces by default.
|
||||
|
||||
By its nature of integrating into existing build systems, the TypeScript
|
||||
compiler is not included in this project - rather the TypeScript transform
|
||||
layer requires separate integration into the `readFile` hook.
|
||||
|
||||
#### File IO Concurrency
|
||||
|
||||
In some large projects, the file tracing logic may process many files at the same time. In this case, if you do not limit the number of concurrent files IO, OOM problems are likely to occur.
|
||||
|
||||
We use a default of 1024 concurrency to balance performance and memory usage for fs operations. You can increase this value to a higher number for faster speed, but be aware of the memory issues if the concurrency is too high.
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
fileIOConcurrency: 2048,
|
||||
});
|
||||
```
|
||||
|
||||
#### Analysis
|
||||
|
||||
Analysis options allow customizing how much analysis should be performed to exactly work out the dependency list.
|
||||
|
||||
By default as much analysis as possible is done to ensure no possibly needed files are left out of the trace.
|
||||
|
||||
To disable all analysis, set `analysis: false`. Alternatively, individual analysis options can be customized via:
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
// default
|
||||
analysis: {
|
||||
// whether to glob any analysis like __dirname + '/dir/' or require('x/' + y)
|
||||
// that might output any file in a directory
|
||||
emitGlobs: true,
|
||||
// whether __filename and __dirname style
|
||||
// expressions should be analyzed as file references
|
||||
computeFileReferences: true,
|
||||
// evaluate known bindings to assist with glob and file reference analysis
|
||||
evaluatePureExpressions: true,
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
#### Ignore
|
||||
|
||||
Custom ignores can be provided to skip file inclusion (and consequently analysis of the file for references in turn as well).
|
||||
|
||||
```js
|
||||
const { fileList } = await nodeFileTrace(files, {
|
||||
ignore: ['./node_modules/pkg/file.js']
|
||||
});
|
||||
```
|
||||
|
||||
Ignore will also accept a function or globs.
|
||||
|
||||
Note that the path provided to ignore is relative to `base`.
|
||||
|
||||
#### Cache
|
||||
|
||||
To persist the file cache between builds, pass an empty `cache` object:
|
||||
|
||||
```js
|
||||
const cache = Object.create(null);
|
||||
const { fileList } = await nodeFileTrace(['index.ts'], { cache });
|
||||
// later:
|
||||
{
|
||||
const { fileList } = await nodeFileTrace(['index.ts'], { cache });
|
||||
}
|
||||
```
|
||||
|
||||
Note that cache invalidations are not supported so the assumption is that the file system is not changed between runs.
|
||||
|
||||
#### Reasons
|
||||
|
||||
To get the underlying reasons for individual files being included, a `reasons` object is also provided by the output:
|
||||
|
||||
```js
|
||||
const { fileList, reasons } = await nodeFileTrace(files);
|
||||
```
|
||||
|
||||
The `reasons` output will then be an object of the following form:
|
||||
|
||||
```js
|
||||
{
|
||||
[file: string]: {
|
||||
type: 'dependency' | 'asset' | 'sharedlib',
|
||||
ignored: true | false,
|
||||
parents: string[]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`reasons` also includes files that were ignored as `ignored: true`, with their `ignoreReason`.
|
||||
|
||||
Every file is included because it is referenced by another file. The `parents` list will contain the list of all files that caused this file to be included.
|
||||
Reference in New Issue
Block a user